core

Changeset 24923

Show
Ignore:
Timestamp:
11/30/08 09:22:58 (6 weeks ago)
Author:
Landseer
Message:

fixed gettext plugins, partial rollback of changeset:24917

Location:
development/main/system/pnRender/plugins
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • development/main/system/pnRender/plugins/function.dcgt.php

    r24917 r24923  
    55 * @copyright (c) 2004, Zikula Development Team 
    66 * @link http://www.zikula.org 
    7  * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 
     7 * @version $Id: $ 
    88 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 
    9  * @author Bernd Plagge  
    109 * @package Zikula_Template_Plugins 
    1110 * @subpackage Functions 
    1211 */ 
    13  
    1412  
    1513/** 
     
    1917 *  
    2018 * Available parameters: 
    21  *        - domain:     textdomain to be used 
    22  *   - name:     Name of the language constant to return 
    23  *   - cat:               Locale category (e.g. '4' -> LC_MONETARY    
    24  *   - html:     Treat the language define as HTML 
     19 *       - domain:       textdomain to be used 
     20 *   - text:     string to translate 
     21 *   - cat:              Locale category (e.g. '4' -> LC_MONETARY    
     22 *   - html:     Treat the text as HTML 
    2523 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out 
    2624 *  
    2725 * Example 
    28  * <!--[dcgt domain="OtherModule" name="At the tone, the time will be 12:00pm" cat="2" html="0"]--> 
     26 * <!--[dcgt domain="OtherModule" text="String" cat="4" html="1"]--> 
    2927 *  
    3028 * The normal textdomain and the now to be used textdomain must have been set beforehand! 
     
    3735 *  
    3836 * @author       Bernd Plagge 
     37 * @author       Frank Schummertz (coding guideline changes) 
    3938 * @since        2007-04-20 
    4039 * @param        array       $params      All attributes passed to this function from the template 
     
    5049    /* Gettext initialisation finished */ 
    5150 
    52         extract($params);  
    53         unset($params); 
    54  
    55         if (!isset($domain)) { 
     51        if (!isset($params['domain'])) { 
    5652                $smarty->trigger_error('dcgt: attribute domain required'); 
    5753                return false; 
    5854        }     
    59         if (!isset($name)) { 
    60                 $smarty->trigger_error('dcgt: attribute name required'); 
     55        if (!isset($params['text'])) { 
     56                $smarty->trigger_error('dcgt: attribute text required'); 
    6157                return false; 
    6258        }     
    63         if (!isset($name)) { 
     59        if (!isset($params['cat'])) { 
    6460                $smarty->trigger_error('dcgt: attribute cat required'); 
    6561                return false; 
    6662        }     
    6763         
    68         if (isset($html) && ($html > 0)) { 
    69         $result = DataUtil::formatForDisplayHTML(dcgettext($domain, $name, $cat));         
     64        if (isset($params['html']) && ($params['html'] > 0)) { 
     65        $result = DataUtil::formatForDisplayHTML(dgettext($params['domain'], $params['text'], $params['cat']));         
    7066        } else { 
    71             $result = DataUtil::formatForDisplay(dcgettext($domain, $name, $cat)); 
     67            $result = DataUtil::formatForDisplay(dgettext($params['domain'], $params['text'], $params['cat'])); 
    7268        } 
    7369 
    74     if (isset($assign)) { 
    75         $smarty->assign($assign, $result); 
     70    if (isset($params['assign'])) { 
     71        $smarty->assign($params['assign'], $result); 
    7672    } else { 
    7773        return $result;         
    7874    }       
    7975} 
    80 ?> 
  • development/main/system/pnRender/plugins/function.dcngt.php

    r24917 r24923  
    55 * @copyright (c) 2004, Zikula Development Team 
    66 * @link http://www.zikula.org 
    7  * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 
     7 * @version $Id: $ 
    88 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 
    9  * @author Bernd Plagge  
    109 * @package Zikula_Template_Plugins 
    1110 * @subpackage Functions 
    1211 */ 
    13  
    1412  
    1513/** 
    16  * Smarty function to use the PHP dcngettext() function  
     14 * Smarty function to use the PHP dcngettext() function    
    1715 *  
    1816 * This function takes a identifier and returns the corresponding language constant. 
    1917 *  
    2018 * Available parameters: 
    21  *        - domain:     textdomain to be used 
    22  *   - name:     Name of the language constant to return 
    23  *        - plural:     Plural form 
    24  *        - count:        The actual number (e.g. '5' apples -> count='5')   
    25  *   - cat:             Locale category (e.g. '4' -> LC_MONETARY    
    26  *   - html:     Treat the language define as HTML 
    27  *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out 
     19 *       - domain:        textdomain to be used 
     20 *   - text:      string to translate 
     21 *       - plural:        Plural form 
     22 *       - count:         The actual number (e.g. '5' apples -> count='5')       
     23 *   - cat:               Locale category (e.g. '4' -> LC_MONETARY   
     24 *   - html:      Treat the text as HTML 
     25 *   - assign:    If set, the results are assigned to the corresponding variable instead of printed out 
    2826 *  
    2927 * Example 
    30  * <!--[dcngt domain="OtherModule" name="%d person attended" plural="%d people attended" cat="0" html="0"]--> 
     28 * <!--[dcngt domain="OtherModule" name="String" cat="4" html="1"]--> 
    3129 *  
    3230 * The normal textdomain and the now to be used textdomain must have been set beforehand! 
     
    3937 *  
    4038 * @author       Bernd Plagge 
     39 * @author       Frank Schummertz (coding guideline changes) 
    4140 * @since        2007-04-20 
    4241 * @param        array       $params      All attributes passed to this function from the template 
     
    5251    /* Gettext initialisation finished */ 
    5352 
    54         extract($params);  
    55         unset($params); 
    56  
    57         if (!isset($domain)) { 
     53        if (!isset($params['domain'])) { 
    5854                $smarty->trigger_error('dcngt: attribute domain required'); 
    5955                return false; 
    6056        }     
    61         if (!isset($name)) { 
    62                 $smarty->trigger_error('dcngt: attribute name required'); 
     57        if (!isset($params['text'])) { 
     58                $smarty->trigger_error('dcngt: attribute text required'); 
    6359                return false; 
    64         }  
    65         if (!isset($plural)) { 
    66                 $smarty->trigger_error('dcngt: attribute plural required'); 
    67                 return false; 
    68         }  
    69         if (!isset($count)) { 
    70                 $smarty->trigger_error('dcngt: attribute count required'); 
    71                 return false; 
    72         }                   
    73         if (!isset($cat)) { 
     60        }     
     61        if (!isset($params['cat'])) { 
    7462                $smarty->trigger_error('dcngt: attribute cat required'); 
    7563                return false; 
    7664        }     
     65        if (!isset($params['plural'])) { 
     66                $smarty->trigger_error('dcngt: attribute plural required'); 
     67                return false; 
     68        }     
     69        if (!isset($params['count'])) { 
     70                $smarty->trigger_error('dcngt: attribute count required'); 
     71                return false; 
     72        }            
     73         
     74        if (isset($params['html']) && ($params['html'] > 0)) { 
     75        $result = DataUtil::formatForDisplayHTML(dgettext($params['domain'], $params['text'], $params['plural'], $params['count'], $params['cat']));         
     76        } else { 
     77            $result = DataUtil::formatForDisplay(dgettext($params['domain'], $params['text'], $params['plural'], $params['count'], $params['cat'])); 
     78        } 
    7779 
    78  
    79         if (isset($html) && ($html > 0)) { 
    80         $result = DataUtil::formatForDisplayHTML(dcngettext($domain, $name, $plural, $count, $cat));         
    81         } else { 
    82             $result = DataUtil::formatForDisplay(dcngettext($domain, $name, $plural, $count, $cat)); 
    83         }        
    84  
    85     if (isset($assign)) { 
    86         $smarty->assign($assign, $result); 
     80    if (isset($params['assign'])) { 
     81        $smarty->assign($params['assign'], $result); 
    8782    } else { 
    8883        return $result;         
    8984    }       
    9085} 
    91 ?> 
  • development/main/system/pnRender/plugins/function.dgt.php

    r24917 r24923  
    55 * @copyright (c) 2004, Zikula Development Team 
    66 * @link http://www.zikula.org 
    7  * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 
     7 * @version $Id: $ 
    88 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 
    99 * @package Zikula_Template_Plugins 
    10  * @author Bernd Plagge  
    11  * @package Zikula_Template_Plugins 
    12  * @subpackage Functions  
     10 * @subpackage Functions 
    1311 */ 
    14  
     12  
    1513/** 
    1614 * Smarty function to use the PHP dgettext() function    
     
    1917 *  
    2018 * Available parameters: 
    21  *       - domain:              textdomain to be used 
    22  *   - name:     Name of the language constant to return 
    23  *   - html:     Treat the language define as HTML 
     19 *   - domain:    textdomain to be used 
     20 *   - text:     string to translate 
     21 *   - html:     Treat the text as HTML 
    2422 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out 
    2523 *  
    2624 * Example 
    27  * <!--[dgt domain="OtherModule" name="Example Text" html="1"]--> 
     25 * <!--[dgt domain="OtherModule" name="String" html="1"]--> 
    2826 *  
    2927 * The normal textdomain and the now to be used textdomain must have been set beforehand! 
     
    3230 *  
    3331 * @author       Bernd Plagge 
     32 * @author       Frank Schummertz (coding guideline changes) 
    3433 * @since        2007-04-20 
    3534 * @param        array       $params      All attributes passed to this function from the template 
     
    4544    /* Gettext initialisation finished */ 
    4645 
    47         extract($params);  
    48         unset($params); 
    49  
    50         if (!isset($domain)) { 
     46        if (!isset($params['domain'])) { 
    5147                $smarty->trigger_error('dgt: attribute domain required'); 
    5248                return false; 
    5349        }     
    54         if (!isset($name)) { 
    55                 $smarty->trigger_error('dgt: attribute name required'); 
     50        if (!isset($params['text'])) { 
     51                $smarty->trigger_error('dgt: attribute text required'); 
    5652                return false; 
    5753        }     
    5854         
    5955        if (isset($html) && ($html > 0)) { 
    60         $result = DataUtil::formatForDisplayHTML(dgettext($domain, $name));         
     56        $result = DataUtil::formatForDisplayHTML(dgettext($params['domain'], $params['text']));         
    6157        } else { 
    62             $result = DataUtil::formatForDisplay(dgettext($domain, $name)); 
     58            $result = DataUtil::formatForDisplay(dgettext($params['domain'], $params['text'])); 
    6359        } 
    6460 
    65     if (isset($assign)) { 
    66         $smarty->assign($assign, $result); 
     61    if (isset($params['assign'])) { 
     62        $smarty->assign($params['assign'], $result); 
    6763    } else { 
    6864        return $result;         
    6965    }       
    7066} 
    71 ?> 
  • development/main/system/pnRender/plugins/function.dngt.php

    r24917 r24923  
    55 * @copyright (c) 2004, Zikula Development Team 
    66 * @link http://www.zikula.org 
    7  * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 
     7 * @version $Id: $ 
    88 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 
    9  * @author Bernd Plagge  
    109 * @package Zikula_Template_Plugins 
    1110 * @subpackage Functions 
    1211 */ 
    1312 
    14   
    1513/** 
    1614 * Smarty function to use the PHP dngettext() function    
     
    1917 *  
    2018 * Available parameters: 
    21  *        - domain:       textdomain to be used 
    22  *   - name:     Name of the language constant to return 
    23  *        - plural:       Plural form 
    24  *        - count:        The actual number (e.g. '5' apples -> count='5') 
    25          
    26  *   - html:     Treat the language define as HTML 
    27  *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out 
     19 *   - domain:    textdomain to be used 
     20 *   - text:      string to translate 
     21 *   - plural:    Plural form 
     22 *   - count:     The actual number (e.g. '5' apples -> count='5') 
     23 *   - html:      Treat the text as HTML 
     24 *   - assign:    If set, the results are assigned to the corresponding variable instead of printed out 
    2825 *  
    2926 * Example 
     
    3532 *  
    3633 * @author       Bernd Plagge 
     34 * @author       Frank Schummertz (coding guideline changes) 
    3735 * @since        2007-04-20 
    3836 * @param        array       $params      All attributes passed to this function from the template 
     
    4846    /* Gettext initialisation finished */ 
    4947 
    50         extract($params);  
    51         unset($params); 
    52  
    53         if (!isset($domain)) { 
     48        if (!isset($params['domain'])) { 
    5449                $smarty->trigger_error('dngt: attribute domain required'); 
    5550                return false; 
    5651        }     
    57         if (!isset($name)) { 
    58                 $smarty->trigger_error('dngt: attribute name required'); 
     52        if (!isset($params['text'])) { 
     53                $smarty->trigger_error('dngt: attribute text required'); 
    5954                return false; 
    6055        }     
    61         if (!isset($plural)) { 
     56        if (!isset($params['plural'])) { 
    6257                $smarty->trigger_error('dngt: attribute plural required'); 
    6358                return false; 
    6459        }     
    65         if (!isset($count)) { 
     60        if (!isset($params['count'])) { 
    6661                $smarty->trigger_error('dngt: attribute count required'); 
    6762                return false; 
    68         }     
    69  
     63        }            
    7064         
    71         if (isset($html) && ($html > 0)) { 
    72         $result = DataUtil::formatForDisplayHTML(dngettext($domain, $name, $plural, $count));         
     65        if (isset($params['html']) && ($params['html'] > 0)) { 
     66        $result = DataUtil::formatForDisplayHTML(dngettext($params['domain'], $params['text'], $params['plural'], $params['count']));         
    7367        } else { 
    74             $result = DataUtil::formatForDisplay(dngettext($domain, $name, $plural, $count)); 
     68            $result = DataUtil::formatForDisplay(dngettext($params['domain'], $params['text'], $params['plural'], $params['count'])); 
    7569        } 
    7670 
    77     if (isset($assign)) { 
    78         $smarty->assign($assign, $result); 
     71    if (isset($params['assign'])) { 
     72        $smarty->assign($params['assign'], $result); 
    7973    } else { 
    8074        return $result;         
    8175    }       
    8276} 
    83 ?> 
  • development/main/system/pnRender/plugins/function.gt.php

    r24918 r24923  
    55 * @copyright (c) 2004, Zikula Development Team 
    66 * @link http://www.zikula.org 
    7  * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 
     7 * @version $Id: $ 
    88 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 
    9  * @author Bernd Plagge  
    109 * @package Zikula_Template_Plugins 
    1110 * @subpackage Functions 
    1211 */ 
    13  
    1412  
    1513/** 
     
    1917 *  
    2018 * Available parameters: 
    21  *   - name:     Name of the language constant to return 
     19 *   - text:     the text to translate 
    2220 *   - html:     Treat the language define as HTML 
    2321 *   - tag       single variable string or array 
     
    2624 *  
    2725 * Example 
    28  * <!--[gt name="Example %s Text" tag="Message" html="1"]--> 
    29  * Format of the 'tag' parameter:  
    30  *               value string separated by commas; will converted to array('a','b', 'c') 
    31  *               if a value itself has the form 'a|True' it will be converted to array('a', 'True') 
     26 * <!--[gt text="Example Text" html="1"]--> 
     27 *  
    3228 *  
    3329 * @author       Bernd Plagge 
     30 * @author       Frank Schummertz (coding guideline changes) 
    3431 * @since        08/08/2005 
    3532 * @param        array       $params      All attributes passed to this function from the template 
     
    3936function smarty_function_gt ($params, &$smarty)  
    4037{ 
    41         extract($params);  
    42         unset($params); 
    43  
    44         if (!isset($name)) { 
    45                 $smarty->trigger_error('gt: attribute name required'); 
     38        if (!isset($params['text'])) { 
     39                $smarty->trigger_error('gt: attribute text required'); 
    4640                return false; 
    4741        }  
    4842 
    49         if (isset($tag)) { 
    50                 $tag = _expand_tag($tag); 
     43        if (isset($params['tag'])) { 
    5144                // we call LanguageUtil::formatGettextMsg 
    52                 if (is_string($tag)) { 
    53                         $name = __fGT(_($name), array( $tag ) ); 
     45                if (is_string($params['tag'])) { 
     46                        $text = __fGT(_($params['text']), array( $params['tag'] ) ); 
    5447                } else { 
    55                         $name = __fGT( _($name), $tag ); 
     48                        $text = __fGT( _($params['text']), $params['tag'] ); 
    5649                } 
    5750        } else { 
    58         $name = _($name); 
     51        $text = _($params['text']); 
    5952        } 
    6053 
    61         if (isset($html) && ($html == true)) { 
    62         $result = DataUtil::formatForDisplayHTML($name);         
     54        if (isset($params['html']) && ($params['html'] == true)) { 
     55        $result = DataUtil::formatForDisplayHTML($text);         
    6356        } else { 
    64             $result = DataUtil::formatForDisplay($name); 
     57            $result = DataUtil::formatForDisplay($text); 
    6558        } 
    6659 
    67     if (isset($assign)) { 
    68         $smarty->assign($assign, $result); 
     60    if (isset($params['assign'])) { 
     61        $smarty->assign($params['assign'], $result); 
    6962    } else { 
    7063        return $result;         
    7164    }       
    7265} 
    73  
    74 /* 
    75  * 
    76  * Convert a tag string to an array 
    77  * 
    78  * The tag string is formated as follow: 
    79  * tag1|option1,tag2|option2,tag3,tag4|option4,tag5 
    80  * 
    81  * where optionN is an option for tagN and is optional 
    82  *  
    83  * @author       Vincent Touchard 
    84  * @since        19/11/2008 
    85  * @param        string      $param      the tags in a string. Each tag separated 
    86  *                                       by a comma, using a | between the tag and its option 
    87  * @return       array                   the tags in an array. 
    88  */ 
    89 function _expand_tag ($param) 
    90 { 
    91         // split all the tags 
    92         $tags = explode(',', $param); 
    93         foreach ($tags as $tag) { 
    94                 // split tag and option 
    95                 // If no option, returns the tag, else returns an array with the tag and the option 
    96                 $a = explode('|', $tag); 
    97                 if (count($a) > 1) { 
    98                         // transform the option into a boolean 
    99                         $a[1] = ($a[1] == '1' || strtolower($a[1]) == 'true'); 
    100                         $tags2[] = $a; 
    101                 } else { 
    102                         $tags2[] = $tag; 
    103                 } 
    104         } 
    105  
    106         return $tags2; 
    107 } 
  • development/main/system/pnRender/plugins/function.ngt.php

    r24917 r24923  
    55 * @copyright (c) 2004, Zikula Development Team 
    66 * @link http://www.zikula.org 
    7  * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 
     7 * @version $Id: $ 
    88 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 
    99 * @package Zikula_Template_Plugins 
    10  * @author Bernd Plagge  
    11  * @package Zikula_Template_Plugins 
    12  * @subpackage Functions  
     10 * @subpackage Functions 
    1311 */ 
    14   
     12 
    1513/** 
     14 * Renderer plugin 
     15 *  
     16 * This file is a plugin for Renderer, the PostNuke implementation of Smarty 
     17 * 
    1618 * Smarty function to use the PHP ngettext() function    
    1719 *  
    18  * This function takes a identifier and returns the corresponding language constant. 
     20 * This function takes a identifier and returns the corresponding language text. 
    1921 *  
    2022 * Available parameters: 
    2123 *   - name:     Name of the language constant to return 
    22  *        - plural:     Plural form 
    23  *        - count:        The actual number (e.g. '5' apples -> count='5') 
    24  *   - tag:             Use this to pass additional parameters to the plugin     
     24 *        - plural:       Plural form 
     25 *        - count:        The actual number (e.g. '5' apples -> count='5')       
    2526 *   - html:     Treat the language define as HTML 
    2627 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out 
    2728 *  
    2829 * Example 
    29  * <!--[ngt name="%d %s string" plural="%d %s strings" count="5"  tag="text" html="1"]--> 
     30 * <!--[ngt name="String" plural="Strings" count="5" html="1"]--> 
    3031 *  
    31  * format of the 'tag' parameter:  
    32  *               value string separated by commas; will converted to array('a','b', 'c') 
    33  *               if a value itself has the form 'a|True' it will be converted to array('a', 'True') 
    34  * 
     32 *  
    3533 * @author       Bernd Plagge 
    36  * @since        2007-04-20, 2008-11-29 
     34 * @author       Frank Schummertz (coding guideline changes) 
     35 * @since        2007-04-20 
    3736 * @param        array       $params      All attributes passed to this function from the template 
    3837 * @param        object      &$smarty     Reference to the Smarty object 
     
    4140function smarty_function_ngt ($params, &$smarty)  
    4241{ 
    43     /* Gettext initialisation start */ 
     42    $name   = (!isset($params['name']))   ? '' : $params['name']; 
     43    $plural = (!isset($params['plural'])) ? '' : $params['plural']; 
     44    $count  = (!isset($params['count']))  ? '' : $params['count']; 
    4445 
    45     $debug=0; 
    46  
    47     /* Gettext initialisation finished */ 
    48  
    49         extract($params);  
    50         unset($params); 
    51  
    52         if (!isset($name)) { 
    53                 $smarty->trigger_error('ngt: attribute name required'); 
     46        if (empty($name)) { 
     47                $smarty->trigger_error('pnngt: attribute name required'); 
    5448                return false; 
    5549        }     
    56         if (!isset($plural)) { 
    57                 $smarty->trigger_error('ngt: attribute plural required'); 
     50        if (empty($plural)) { 
     51                $smarty->trigger_error('pnngt: attribute plural required'); 
    5852                return false; 
    5953        }     
    60         if (!isset($count)) { 
    61                 $smarty->trigger_error('ngt: attribute count required'); 
     54        if (empty($count)) { 
     55                $smarty->trigger_error('pnngt: attribute count required'); 
    6256                return false; 
    6357        }     
    6458 
    65         if (isset($tag)) { 
    66                 $tag=_expand_tag($tag); 
    67  
    68 // we call LanguageUtil::formatGettextMsg 
    69                 if (is_string($tag)) { 
    70                         $name = __fNGT($name, $plural, $count, array( $tag ) ); 
    71                 } else { 
    72                         $name = __fNGT($name, $plural, $count, $tag ); 
    73                 } 
     59         
     60        if (isset($params['html']) && ($params['html'] > 0)) { 
     61        $result = DataUtil::formatForDisplayHTML(ngettext($name, $plural, $count));         
    7462        } else { 
    75         $name = sprintf(ngettext($name, $plural, $count), $count);