core

Changeset 24917

Show
Ignore:
Timestamp:
11/29/08 10:59:35 (6 weeks ago)
Author:
bp
Message:

removed add functions from BlockUtil?, Theme.class, modified config.php, gettext Smarty functions/modifier

Location:
development/main
Files:
1 added
1 removed
11 modified

Legend:

Unmodified
Added
Removed
  • development/main/config/config.php

    r24881 r24917  
    4141$PNConfig['System']['development'] = 1;          // should be set to 0/false when cutting a release for production use 
    4242$PNConfig['System']['default_timezone'] = 'GMT'; // TZ timezone 
     43$PNConfig['System']['dom'] = 'zikula';                  // gettext system domain 
    4344 
    4445// ---------------------------------------------------------------------- 
  • development/main/includes/BlockUtil.class.php

    r24916 r24917  
    7474            $blockinfo = self::getInfo($blockplacement['bid']); 
    7575            // block filtering 
    76 //bp 2008-02-12 - if session variable 'area' is set retrieve it     
    77             $area = SessionUtil::getVar('area',null); 
    7876 
    7977            if (!empty($blockinfo['filter']['modules']) || 
  • development/main/includes/DBConnectionStack.class.php

    r24916 r24917  
    123123        // bplagge - 2008/11/18 
    124124        if (!defined('_PNINSTALLVER') && ($dbdriver == 'mysql' || $dbdriver == 'mysqli')) { 
    125                 if (isset($dbcharset)) { 
    126                         $cs = str_replace('-','', strtolower($dbcharset)); 
    127                         $conn->Execute("set names $cs"); 
     125                        if (isset($dbcharset)) { 
     126                                $dbcharset = str_replace('-','', strtolower($dbcharset)); 
     127                                $res = $conn->Execute("SHOW VARIABLES LIKE 'character_set_database'"); 
     128                $curdbcharset = $res->fields[1]; 
     129                                if ($dbcharset != $curdbcharset) { 
     130                                        return pn_exit("Inconsistent DB character set in config ($dbcharset) and in current DB ($curdbcharset)"); 
     131                                } else { 
     132                                        // ensure that the server charset is also set! (see Mysql manual for details) 
     133                                        $conn->Execute("set names $dbcharset"); 
     134                                } 
     135                        } 
    128136                } 
    129         } 
    130137 
    131138        $GLOBALS['PNRuntime']['DB'][$count]             = $GLOBALS['PNConfig']['DBInfo'][$name]; 
  • development/main/includes/Theme.class.php

    r24916 r24917  
    5959        protected $isloggedin; 
    6060 
    61         //bp 2008-02-11 
    62         // area, logical subset of the website (similar to category 
    63         protected $area; 
    64  
    6561        /** 
    6662         * Initialize our class 
     
    149145            //bp 2008-11-17 - bindtextdomain 
    150146            //the name of the theme's textdomain must correspond to the name defined in pnversion.php! 
    151             //e.g. $themeversion['name'] = sql_ledger; 
     147            //e.g. $themeversion['name'] = theme99; 
    152148            $syscharset = Zikula::getConfigVar('syscharset'); 
    153149 
     
    167163               echo "syscharset: $syscharset, locale: $loc, themelocpath: $themelocpath, themedom: $this->name<br/> 
    168164                        bindtextdomain: $rt, bind_textdomain_codeset: $rc<br/>"; 
    169                 echo dgettext($this->name, 'Home'); 
     165                        echo dgettext($this->name, 'Home'); 
    170166                 
    171                 echo "<br/>set textdomain<br/>"; 
    172                 $rd=textdomain($this->name); 
    173                 echo _('Home');                  
     167                        echo "<br/>set textdomain<br/>"; 
     168                        $rd=textdomain($this->name); 
     169                        echo _('Home');                  
    174170             */ 
    175171            //end bp         
     
    310306            $masterpath = "themes/$os_theme/templates"; 
    311307 
    312             //bp 2008-02-11 area template path -> so we can specify area-specific templates 
    313             $areapath = "themes/$os_theme/templates/category"; 
    314             //bp end 
    315  
    316308            // 2. The module template path 
    317309            $modulepath = "themes/$os_theme/templates/modules"; 
     
    321313            $ostemplate = DataUtil::formatForOS($template); 
    322314 
    323             //bp 2008-02-11 - add $areapath and subdir for module to the search path 
    324315            $search_path = array($masterpath, 
    325                                  $areapath, 
    326                                  $areapath.'/'.$modulepath, 
    327316                                 $modulepath, 
    328317                                 $blockpath); 
     
    474463            } 
    475464 
    476 //bp 2008-02-11 - extract and save area id 
    477             foreach ($queryparts as $querypart) { 
    478                     if (stristr($querypart, 'area=')) { 
    479                             $n = strpos($querypart, '='); 
    480                             $this->area = substr($querypart, $n+1); 
    481                             $this->assign('area', $this->area); 
    482                             SessionUtil::setVar('area', $this->area); 
    483                     } 
    484             } 
    485             $this->area = SessionUtil::getVar('area',null); 
    486 //bp 
    487  
    488465 
    489466            // identify and load the correct module configuration 
     
    496473                $this->cachepage = false; 
    497474                $file = $pageconfigurations['*admin']['file']; 
    498 //bp 2008-02-11 
    499             } else if (isset($this->area) && isset($pageconfigurations[$this->area])) { 
    500                     $file = $pageconfigurations[$this->area]['file']; 
    501 //bp 
    502475            } else { 
    503476                $customargs = $this->module.'/'.$this->type.'/'.$this->func.$customargs; 
  • development/main/locale/gettext_notes.txt

    r24779 r24917  
    11B.Plagge, First Choice Internet, Tokyo 
    22bplagge@choicenet.ne.jp 
    3 2007-12-31, 2008-02-29 
    4 Version: 0.2 
     32007-12-31, 2008-02-29, 2008-11-29 
     4Version: 0.3 
    55 
    66This are a few notes how to use gettext functions in PostNuke programs. 
     
    7474     <!--[gt text="Edit %s" tag="Theme" html="1"]--> 
    7575or  
    76      <!--[gt text="User %s has email address %s" tag=array($user,$email) html="1"]--> 
     76     <!--[gt text="User %s has email address %s" tag="$user|True,$email" html="1"]--> 
    7777 
    7878The 'tag' and 'html' parameters are optional. 
    7979 
     80The 'tag' parameter has the following format: 
     81 * Format of the 'tag' parameter:  
     82 *               value string separated by commas; will converted to array('a','b', 'c') 
     83 *               if a value itself has the form 'a|True' it will be converted to array('a', 'True') 
    8084 
    81 What else? 
    82  
    83 PHP also supports the dgettext, dngettext, dcgettext, dcngettext functions which are only relevant if the domain is being 
    84 changed. I put corresponding plugin functions into the pnRender/plugin directory.  
    85 This may be useful if we want to provide theme-based domain override. However, afaik there is no 'fallback domain' in case the selected domain  
    86 (e.g. = theme) does not provide a translation. 
    8785 
    8886 
    8987Conversion 
    90 ---------- 
    91 To build one common language constants file I used the pnlwb (PN language workbench). The resulting file you find 'allcore.txt' 
    92 in directory locale/eng. 
    93 Note: I had to replace single quotes with dobule quotes to inclose the strings because some text strings contained '%s' and that 
    94 would cause syntax errors. 
     88------------ 
     89Please use the pnlwb (PN language workbench) to build a suitable file contain all text defines and specify it in 
     90the program gettexttizer.php. 
     91 
     92Previously the main gettext Smarty plugin was name 'pngt'; now it is called 'gt'. So, if you find pngt Smarty 
     93calls in any template please replace them! 
    9594 
    9695I used our gettexttizer.php program to replace constant strings with gettext clear text messages. This program also replaces pnml strings 
    97 in templates with pngt string. The program worked fine but in some cases it failed to correctly replace message strings. These were: 
     96in templates with gt string. The program worked fine but in some cases it failed to correctly replace message strings. These were: 
    9897  1) we really MEAN a constant e.g. _PNINSTALLER 
    9998  2) pnML function in programs (function seems to be quite new, program needs to be enhanced) 
  • development/main/system/pnRender/plugins/function.dcgt.php

    r24783 r24917  
    55 * @copyright (c) 2004, Zikula Development Team 
    66 * @link http://www.zikula.org 
    7  * @version $Id: $ 
     7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 
    88 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 
     9 * @author Bernd Plagge  
    910 * @package Zikula_Template_Plugins 
    1011 * @subpackage Functions 
    1112 */ 
     13 
    1214  
    1315/** 
     
    1719 *  
    1820 * Available parameters: 
    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 
     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 
    2325 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out 
    2426 *  
    2527 * Example 
    26  * <!--[dcgt domain="OtherModule" text="String" cat="4" html="1"]--> 
     28 * <!--[dcgt domain="OtherModule" name="At the tone, the time will be 12:00pm" cat="2" html="0"]--> 
    2729 *  
    2830 * The normal textdomain and the now to be used textdomain must have been set beforehand! 
     
    3537 *  
    3638 * @author       Bernd Plagge 
    37  * @author       Frank Schummertz 
    3839 * @since        2007-04-20 
    3940 * @param        array       $params      All attributes passed to this function from the template 
     
    4950    /* Gettext initialisation finished */ 
    5051 
    51         if (!isset($params['domain'])) { 
     52        extract($params);  
     53        unset($params); 
     54 
     55        if (!isset($domain)) { 
    5256                $smarty->trigger_error('dcgt: attribute domain required'); 
    5357                return false; 
    5458        }     
    55         if (!isset($params['text'])) { 
    56                 $smarty->trigger_error('dcgt: attribute text required'); 
     59        if (!isset($name)) { 
     60                $smarty->trigger_error('dcgt: attribute name required'); 
    5761                return false; 
    5862        }     
    59         if (!isset($params['cat'])) { 
     63        if (!isset($name)) { 
    6064                $smarty->trigger_error('dcgt: attribute cat required'); 
    6165                return false; 
    6266        }     
    6367         
    64         if (isset($params['html']) && ($params['html'] > 0)) { 
    65         $result = DataUtil::formatForDisplayHTML(dgettext($params['domain'], $params['text'], $params['cat']));         
     68        if (isset($html) && ($html > 0)) { 
     69        $result = DataUtil::formatForDisplayHTML(dcgettext($domain, $name, $cat));         
    6670        } else { 
    67             $result = DataUtil::formatForDisplay(dgettext($params['domain'], $params['text'], $params['cat'])); 
     71            $result = DataUtil::formatForDisplay(dcgettext($domain, $name, $cat)); 
    6872        } 
    6973 
    70     if (isset($params['assign'])) { 
    71         $smarty->assign($params['assign'], $result); 
     74    if (isset($assign)) { 
     75        $smarty->assign($assign, $result); 
    7276    } else { 
    7377        return $result;         
    7478    }       
    7579} 
     80?> 
  • development/main/system/pnRender/plugins/function.dcngt.php

    r24783 r24917  
    55 * @copyright (c) 2004, Zikula Development Team 
    66 * @link http://www.zikula.org 
    7  * @version $Id: $ 
     7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 
    88 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 
     9 * @author Bernd Plagge  
    910 * @package Zikula_Template_Plugins 
    1011 * @subpackage Functions 
    1112 */ 
     13 
    1214  
    1315/** 
    14  * Smarty function to use the PHP dcngettext() function    
     16 * Smarty function to use the PHP dcngettext() function  
    1517 *  
    1618 * This function takes a identifier and returns the corresponding language constant. 
    1719 *  
    1820 * Available parameters: 
    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 
     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 
    2628 *  
    2729 * Example 
    28  * <!--[dcngt domain="OtherModule" name="String" cat="4" html="1"]--> 
     30 * <!--[dcngt domain="OtherModule" name="%d person attended" plural="%d people attended" cat="0" html="0"]--> 
    2931 *  
    3032 * The normal textdomain and the now to be used textdomain must have been set beforehand! 
     
    3739 *  
    3840 * @author       Bernd Plagge 
    39  * @author       Frank Schummertz 
    4041 * @since        2007-04-20 
    4142 * @param        array       $params      All attributes passed to this function from the template 
     
    5152    /* Gettext initialisation finished */ 
    5253 
    53         if (!isset($params['domain'])) { 
     54        extract($params);  
     55        unset($params); 
     56 
     57        if (!isset($domain)) { 
    5458                $smarty->trigger_error('dcngt: attribute domain required'); 
    5559                return false; 
    5660        }     
    57         if (!isset($params['text'])) { 
    58                 $smarty->trigger_error('dcngt: attribute text required'); 
     61        if (!isset($name)) { 
     62                $smarty->trigger_error('dcngt: attribute name required'); 
    5963                return false; 
    60         }     
    61         if (!isset($params['cat'])) { 
     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)) { 
    6274                $smarty->trigger_error('dcngt: attribute cat required'); 
    6375                return false; 
    6476        }     
    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']));         
     77 
     78 
     79        if (isset($html) && ($html > 0)) { 
     80        $result = DataUtil::formatForDisplayHTML(dcngettext($domain, $name, $plural, $count, $cat));         
    7681        } else { 
    77             $result = DataUtil::formatForDisplay(dgettext($params['domain'], $params['text'], $params['plural'], $params['count'], $params['cat'])); 
    78         } 
     82            $result = DataUtil::formatForDisplay(dcngettext($domain, $name, $plural, $count, $cat)); 
     83        }        
    7984 
    80     if (isset($params['assign'])) { 
    81         $smarty->assign($params['assign'], $result); 
     85    if (isset($assign)) { 
     86        $smarty->assign($assign, $result); 
    8287    } else { 
    8388        return $result;         
    8489    }       
    8590} 
     91?> 
  • development/main/system/pnRender/plugins/function.dgt.php

    r24783 r24917  
    55 * @copyright (c) 2004, Zikula Development Team 
    66 * @link http://www.zikula.org 
    7  * @version $Id: $ 
     7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 
    88 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 
    99 * @package Zikula_Template_Plugins 
    10  * @subpackage Functions 
     10 * @author Bernd Plagge  
     11 * @package Zikula_Template_Plugins 
     12 * @subpackage Functions  
    1113 */ 
    12   
     14 
    1315/** 
    1416 * Smarty function to use the PHP dgettext() function    
     
    1719 *  
    1820 * Available parameters: 
    19  *   - domain:    textdomain to be used 
    20  *   - text:     string to translate 
    21  *   - html:     Treat the text as HTML 
     21 *       - domain:              textdomain to be used 
     22 *   - name:     Name of the language constant to return 
     23 *   - html:     Treat the language define as HTML 
    2224 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out 
    2325 *  
    2426 * Example 
    25  * <!--[dgt domain="OtherModule" name="String" html="1"]--> 
     27 * <!--[dgt domain="OtherModule" name="Example Text" html="1"]--> 
    2628 *  
    2729 * The normal textdomain and the now to be used textdomain must have been set beforehand! 
     
    3032 *  
    3133 * @author       Bernd Plagge 
    32  * @author       Frank Schummertz 
    3334 * @since        2007-04-20 
    3435 * @param        array       $params      All attributes passed to this function from the template 
     
    4445    /* Gettext initialisation finished */ 
    4546 
    46         if (!isset($params['domain'])) { 
     47        extract($params);  
     48        unset($params); 
     49 
     50        if (!isset($domain)) { 
    4751                $smarty->trigger_error('dgt: attribute domain required'); 
    4852                return false; 
    4953        }     
    50         if (!isset($params['text'])) { 
    51                 $smarty->trigger_error('dgt: attribute text required'); 
     54        if (!isset($name)) { 
     55                $smarty->trigger_error('dgt: attribute name required'); 
    5256                return false; 
    5357        }     
    5458         
    5559        if (isset($html) && ($html > 0)) { 
    56         $result = DataUtil::formatForDisplayHTML(dgettext($params['domain'], $params['text']));         
     60        $result = DataUtil::formatForDisplayHTML(dgettext($domain, $name));         
    5761        } else { 
    58             $result = DataUtil::formatForDisplay(dgettext($params['domain'], $params['text'])); 
     62            $result = DataUtil::formatForDisplay(dgettext($domain, $name)); 
    5963        } 
    6064 
    61     if (isset($params['assign'])) { 
    62         $smarty->assign($params['assign'], $result); 
     65    if (isset($assign)) { 
     66        $smarty->assign($assign, $result); 
    6367    } else { 
    6468        return $result;         
    6569    }       
    6670} 
     71?> 
  • development/main/system/pnRender/plugins/function.dngt.php

    r24783 r24917  
    55 * @copyright (c) 2004, Zikula Development Team 
    66 * @link http://www.zikula.org 
    7  * @version $Id: $ 
     7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 
    88 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 
     9 * @author Bernd Plagge  
    910 * @package Zikula_Template_Plugins 
    1011 * @subpackage Functions 
    1112 */ 
    1213 
     14  
    1315/** 
    1416 * Smarty function to use the PHP dngettext() function    
     
    1719 *  
    1820 * Available parameters: 
    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 
     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 
    2528 *  
    2629 * Example 
     
    3235 *  
    3336 * @author       Bernd Plagge 
    34  * @author       Frank Schummertz 
    3537 * @since        2007-04-20 
    3638 * @param        array       $params      All attributes passed to this function from the template 
     
    4648    /* Gettext initialisation finished */ 
    4749 
    48         if (!isset($params['domain'])) { 
     50        extract($params);  
     51        unset($params); 
     52 
     53        if (!isset($domain)) { 
    4954                $smarty->trigger_error('dngt: attribute domain required'); 
    5055                return false; 
    5156        }     
    52         if (!isset($params['text'])) { 
    53                 $smarty->trigger_error('dngt: attribute text required'); 
     57        if (!isset($name)) { 
     58                $smarty->trigger_error('dngt: attribute name required'); 
    5459                return false; 
    5560        }     
    56         if (!isset($params['plural'])) { 
     61        if (!isset($plural)) { 
    5762                $smarty->trigger_error('dngt: attribute plural required'); 
    5863                return false; 
    5964        }     
    60         if (!isset($params['count'])) { 
     65        if (!isset($count)) { 
    6166                $smarty->trigger_error('dngt: attribute count required'); 
    6267                return false; 
    63         }            
     68        }     
     69 
    6470         
    65         if (isset($params['html']) && ($params['html'] > 0)) { 
    66         $result = DataUtil::formatForDisplayHTML(dngettext($params['domain'], $params['text'], $params['plural'], $params['count']));         
     71        if (isset($html) && ($html > 0)) { 
     72        $result = DataUtil::formatForDisplayHTML(dngettext($domain, $name, $plural, $count));         
    6773        } else { 
    68             $result = DataUtil::formatForDisplay(dngettext($params['domain'], $params['text'], $params['plural'], $params['count'])); 
     74            $result = DataUtil::formatForDisplay(dngettext($domain, $name, $plural, $count)); 
    6975        } 
    7076 
    71     if (isset($params['assign'])) { 
    72         $smarty->assign($params['assign'], $result); 
     77    if (isset($assign)) { 
     78        $smarty->assign($assign, $result); 
    7379    } else { 
    7480        return $result;         
    7581    }       
    7682} 
     83?> 
  • development/main/system/pnRender/plugins/function.gt.php

    r24779 r24917  
    55 * @copyright (c) 2004, Zikula Development Team 
    66 * @link http://www.zikula.org 
    7  * @version $Id: $ 
     7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 
    88 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 
     9 * @author Bernd Plagge  
    910 * @package Zikula_Template_Plugins 
    1011 * @subpackage Functions 
    1112 */