Changeset 24923
- Timestamp:
- 11/30/08 09:22:58 (6 weeks ago)
- Location:
- development/main/system/pnRender/plugins
- Files:
-
- 6 modified
-
function.dcgt.php (modified) (4 diffs)
-
function.dcngt.php (modified) (3 diffs)
-
function.dgt.php (modified) (4 diffs)
-
function.dngt.php (modified) (4 diffs)
-
function.gt.php (modified) (4 diffs)
-
function.ngt.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
development/main/system/pnRender/plugins/function.dcgt.php
r24917 r24923 5 5 * @copyright (c) 2004, Zikula Development Team 6 6 * @link http://www.zikula.org 7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest$7 * @version $Id: $ 8 8 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 9 * @author Bernd Plagge10 9 * @package Zikula_Template_Plugins 11 10 * @subpackage Functions 12 11 */ 13 14 12 15 13 /** … … 19 17 * 20 18 * Available parameters: 21 * - domain:textdomain to be used22 * - name: Name of the language constant to return23 * - cat: Locale category (e.g. '4' -> LC_MONETARY24 * - html: Treat the language defineas HTML19 * - 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 25 23 * - assign: If set, the results are assigned to the corresponding variable instead of printed out 26 24 * 27 25 * 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"]--> 29 27 * 30 28 * The normal textdomain and the now to be used textdomain must have been set beforehand! … … 37 35 * 38 36 * @author Bernd Plagge 37 * @author Frank Schummertz (coding guideline changes) 39 38 * @since 2007-04-20 40 39 * @param array $params All attributes passed to this function from the template … … 50 49 /* Gettext initialisation finished */ 51 50 52 extract($params); 53 unset($params); 54 55 if (!isset($domain)) { 51 if (!isset($params['domain'])) { 56 52 $smarty->trigger_error('dcgt: attribute domain required'); 57 53 return false; 58 54 } 59 if (!isset($ name)) {60 $smarty->trigger_error('dcgt: attribute namerequired');55 if (!isset($params['text'])) { 56 $smarty->trigger_error('dcgt: attribute text required'); 61 57 return false; 62 58 } 63 if (!isset($ name)) {59 if (!isset($params['cat'])) { 64 60 $smarty->trigger_error('dcgt: attribute cat required'); 65 61 return false; 66 62 } 67 63 68 if (isset($ html) && ($html> 0)) {69 $result = DataUtil::formatForDisplayHTML(d cgettext($domain, $name, $cat));64 if (isset($params['html']) && ($params['html'] > 0)) { 65 $result = DataUtil::formatForDisplayHTML(dgettext($params['domain'], $params['text'], $params['cat'])); 70 66 } else { 71 $result = DataUtil::formatForDisplay(d cgettext($domain, $name, $cat));67 $result = DataUtil::formatForDisplay(dgettext($params['domain'], $params['text'], $params['cat'])); 72 68 } 73 69 74 if (isset($ assign)) {75 $smarty->assign($ assign, $result);70 if (isset($params['assign'])) { 71 $smarty->assign($params['assign'], $result); 76 72 } else { 77 73 return $result; 78 74 } 79 75 } 80 ?> -
development/main/system/pnRender/plugins/function.dcngt.php
r24917 r24923 5 5 * @copyright (c) 2004, Zikula Development Team 6 6 * @link http://www.zikula.org 7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest$7 * @version $Id: $ 8 8 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 9 * @author Bernd Plagge10 9 * @package Zikula_Template_Plugins 11 10 * @subpackage Functions 12 11 */ 13 14 12 15 13 /** 16 * Smarty function to use the PHP dcngettext() function 14 * Smarty function to use the PHP dcngettext() function 17 15 * 18 16 * This function takes a identifier and returns the corresponding language constant. 19 17 * 20 18 * Available parameters: 21 * - domain:textdomain to be used22 * - name: Name of the language constant to return23 * - plural:Plural form24 * - count: The actual number (e.g. '5' apples -> count='5')25 * - cat: Locale category (e.g. '4' -> LC_MONETARY26 * - html: Treat the language defineas HTML27 * - assign: If set, the results are assigned to the corresponding variable instead of printed out19 * - 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 28 26 * 29 27 * 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"]--> 31 29 * 32 30 * The normal textdomain and the now to be used textdomain must have been set beforehand! … … 39 37 * 40 38 * @author Bernd Plagge 39 * @author Frank Schummertz (coding guideline changes) 41 40 * @since 2007-04-20 42 41 * @param array $params All attributes passed to this function from the template … … 52 51 /* Gettext initialisation finished */ 53 52 54 extract($params); 55 unset($params); 56 57 if (!isset($domain)) { 53 if (!isset($params['domain'])) { 58 54 $smarty->trigger_error('dcngt: attribute domain required'); 59 55 return false; 60 56 } 61 if (!isset($ name)) {62 $smarty->trigger_error('dcngt: attribute namerequired');57 if (!isset($params['text'])) { 58 $smarty->trigger_error('dcngt: attribute text required'); 63 59 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'])) { 74 62 $smarty->trigger_error('dcngt: attribute cat required'); 75 63 return false; 76 64 } 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 } 77 79 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); 87 82 } else { 88 83 return $result; 89 84 } 90 85 } 91 ?> -
development/main/system/pnRender/plugins/function.dgt.php
r24917 r24923 5 5 * @copyright (c) 2004, Zikula Development Team 6 6 * @link http://www.zikula.org 7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest$7 * @version $Id: $ 8 8 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 9 9 * @package Zikula_Template_Plugins 10 * @author Bernd Plagge 11 * @package Zikula_Template_Plugins 12 * @subpackage Functions 10 * @subpackage Functions 13 11 */ 14 12 15 13 /** 16 14 * Smarty function to use the PHP dgettext() function … … 19 17 * 20 18 * Available parameters: 21 * - domain:textdomain to be used22 * - name: Name of the language constant to return23 * - html: Treat the language defineas HTML19 * - domain: textdomain to be used 20 * - text: string to translate 21 * - html: Treat the text as HTML 24 22 * - assign: If set, the results are assigned to the corresponding variable instead of printed out 25 23 * 26 24 * Example 27 * <!--[dgt domain="OtherModule" name=" Example Text" html="1"]-->25 * <!--[dgt domain="OtherModule" name="String" html="1"]--> 28 26 * 29 27 * The normal textdomain and the now to be used textdomain must have been set beforehand! … … 32 30 * 33 31 * @author Bernd Plagge 32 * @author Frank Schummertz (coding guideline changes) 34 33 * @since 2007-04-20 35 34 * @param array $params All attributes passed to this function from the template … … 45 44 /* Gettext initialisation finished */ 46 45 47 extract($params); 48 unset($params); 49 50 if (!isset($domain)) { 46 if (!isset($params['domain'])) { 51 47 $smarty->trigger_error('dgt: attribute domain required'); 52 48 return false; 53 49 } 54 if (!isset($ name)) {55 $smarty->trigger_error('dgt: attribute namerequired');50 if (!isset($params['text'])) { 51 $smarty->trigger_error('dgt: attribute text required'); 56 52 return false; 57 53 } 58 54 59 55 if (isset($html) && ($html > 0)) { 60 $result = DataUtil::formatForDisplayHTML(dgettext($ domain, $name));56 $result = DataUtil::formatForDisplayHTML(dgettext($params['domain'], $params['text'])); 61 57 } else { 62 $result = DataUtil::formatForDisplay(dgettext($ domain, $name));58 $result = DataUtil::formatForDisplay(dgettext($params['domain'], $params['text'])); 63 59 } 64 60 65 if (isset($ assign)) {66 $smarty->assign($ assign, $result);61 if (isset($params['assign'])) { 62 $smarty->assign($params['assign'], $result); 67 63 } else { 68 64 return $result; 69 65 } 70 66 } 71 ?> -
development/main/system/pnRender/plugins/function.dngt.php
r24917 r24923 5 5 * @copyright (c) 2004, Zikula Development Team 6 6 * @link http://www.zikula.org 7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest$7 * @version $Id: $ 8 8 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 9 * @author Bernd Plagge10 9 * @package Zikula_Template_Plugins 11 10 * @subpackage Functions 12 11 */ 13 12 14 15 13 /** 16 14 * Smarty function to use the PHP dngettext() function … … 19 17 * 20 18 * 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 28 25 * 29 26 * Example … … 35 32 * 36 33 * @author Bernd Plagge 34 * @author Frank Schummertz (coding guideline changes) 37 35 * @since 2007-04-20 38 36 * @param array $params All attributes passed to this function from the template … … 48 46 /* Gettext initialisation finished */ 49 47 50 extract($params); 51 unset($params); 52 53 if (!isset($domain)) { 48 if (!isset($params['domain'])) { 54 49 $smarty->trigger_error('dngt: attribute domain required'); 55 50 return false; 56 51 } 57 if (!isset($ name)) {58 $smarty->trigger_error('dngt: attribute namerequired');52 if (!isset($params['text'])) { 53 $smarty->trigger_error('dngt: attribute text required'); 59 54 return false; 60 55 } 61 if (!isset($p lural)) {56 if (!isset($params['plural'])) { 62 57 $smarty->trigger_error('dngt: attribute plural required'); 63 58 return false; 64 59 } 65 if (!isset($ count)) {60 if (!isset($params['count'])) { 66 61 $smarty->trigger_error('dngt: attribute count required'); 67 62 return false; 68 } 69 63 } 70 64 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'])); 73 67 } else { 74 $result = DataUtil::formatForDisplay(dngettext($ domain, $name, $plural, $count));68 $result = DataUtil::formatForDisplay(dngettext($params['domain'], $params['text'], $params['plural'], $params['count'])); 75 69 } 76 70 77 if (isset($ assign)) {78 $smarty->assign($ assign, $result);71 if (isset($params['assign'])) { 72 $smarty->assign($params['assign'], $result); 79 73 } else { 80 74 return $result; 81 75 } 82 76 } 83 ?> -
development/main/system/pnRender/plugins/function.gt.php
r24918 r24923 5 5 * @copyright (c) 2004, Zikula Development Team 6 6 * @link http://www.zikula.org 7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest$7 * @version $Id: $ 8 8 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 9 * @author Bernd Plagge10 9 * @package Zikula_Template_Plugins 11 10 * @subpackage Functions 12 11 */ 13 14 12 15 13 /** … … 19 17 * 20 18 * Available parameters: 21 * - name: Name of the language constant to return19 * - text: the text to translate 22 20 * - html: Treat the language define as HTML 23 21 * - tag single variable string or array … … 26 24 * 27 25 * 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 * 32 28 * 33 29 * @author Bernd Plagge 30 * @author Frank Schummertz (coding guideline changes) 34 31 * @since 08/08/2005 35 32 * @param array $params All attributes passed to this function from the template … … 39 36 function smarty_function_gt ($params, &$smarty) 40 37 { 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'); 46 40 return false; 47 41 } 48 42 49 if (isset($tag)) { 50 $tag = _expand_tag($tag); 43 if (isset($params['tag'])) { 51 44 // 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'] ) ); 54 47 } else { 55 $ name = __fGT( _($name), $tag);48 $text = __fGT( _($params['text']), $params['tag'] ); 56 49 } 57 50 } else { 58 $ name = _($name);51 $text = _($params['text']); 59 52 } 60 53 61 if (isset($ html) && ($html== true)) {62 $result = DataUtil::formatForDisplayHTML($ name);54 if (isset($params['html']) && ($params['html'] == true)) { 55 $result = DataUtil::formatForDisplayHTML($text); 63 56 } else { 64 $result = DataUtil::formatForDisplay($ name);57 $result = DataUtil::formatForDisplay($text); 65 58 } 66 59 67 if (isset($ assign)) {68 $smarty->assign($ assign, $result);60 if (isset($params['assign'])) { 61 $smarty->assign($params['assign'], $result); 69 62 } else { 70 63 return $result; 71 64 } 72 65 } 73 74 /*75 *76 * Convert a tag string to an array77 *78 * The tag string is formated as follow:79 * tag1|option1,tag2|option2,tag3,tag4|option4,tag580 *81 * where optionN is an option for tagN and is optional82 *83 * @author Vincent Touchard84 * @since 19/11/200885 * @param string $param the tags in a string. Each tag separated86 * by a comma, using a | between the tag and its option87 * @return array the tags in an array.88 */89 function _expand_tag ($param)90 {91 // split all the tags92 $tags = explode(',', $param);93 foreach ($tags as $tag) {94 // split tag and option95 // If no option, returns the tag, else returns an array with the tag and the option96 $a = explode('|', $tag);97 if (count($a) > 1) {98 // transform the option into a boolean99 $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 5 5 * @copyright (c) 2004, Zikula Development Team 6 6 * @link http://www.zikula.org 7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest$7 * @version $Id: $ 8 8 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 9 9 * @package Zikula_Template_Plugins 10 * @author Bernd Plagge 11 * @package Zikula_Template_Plugins 12 * @subpackage Functions 10 * @subpackage Functions 13 11 */ 14 12 15 13 /** 14 * Renderer plugin 15 * 16 * This file is a plugin for Renderer, the PostNuke implementation of Smarty 17 * 16 18 * Smarty function to use the PHP ngettext() function 17 19 * 18 * This function takes a identifier and returns the corresponding language constant.20 * This function takes a identifier and returns the corresponding language text. 19 21 * 20 22 * Available parameters: 21 23 * - 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') 25 26 * - html: Treat the language define as HTML 26 27 * - assign: If set, the results are assigned to the corresponding variable instead of printed out 27 28 * 28 29 * 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"]--> 30 31 * 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 * 35 33 * @author Bernd Plagge 36 * @since 2007-04-20, 2008-11-29 34 * @author Frank Schummertz (coding guideline changes) 35 * @since 2007-04-20 37 36 * @param array $params All attributes passed to this function from the template 38 37 * @param object &$smarty Reference to the Smarty object … … 41 40 function smarty_function_ngt ($params, &$smarty) 42 41 { 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']; 44 45 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'); 54 48 return false; 55 49 } 56 if ( !isset($plural)) {57 $smarty->trigger_error(' ngt: attribute plural required');50 if (empty($plural)) { 51 $smarty->trigger_error('pnngt: attribute plural required'); 58 52 return false; 59 53 } 60 if ( !isset($count)) {61 $smarty->trigger_error(' ngt: attribute count required');54 if (empty($count)) { 55 $smarty->trigger_error('pnngt: attribute count required'); 62 56 return false; 63 57 } 64 58 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)); 74 62 } else { 75 $name = sprintf(ngettext($name, $plural, $count), $count);
