Changeset 227

Show
Ignore:
Timestamp:
08/02/06 01:24:02 (2 years ago)
Author:
laurentj
Message:

commentaires sur les plugins de templates et les classes jacl

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix/acl/jAcl.class.php

    r207 r227  
    55* @version     $Id:$ 
    66* @author      Laurent Jouanneau 
    7 * @contributor 
    87* @copyright   2006 Laurent Jouanneau 
    98* @link        http://www.jelix.org 
     
    1211 
    1312/** 
    14  * Permet de conna�e les droits 
     13 * Main class to query the acl system, and to know value of a right 
     14 * 
     15 * you should call this class (all method are static) when you want to know if 
     16 * the current user have a right, or to know if he is a member of a group 
     17 * This class needs the acl module. 
     18 * @package jelix 
     19 * @subpackage acl 
     20 * @static 
    1521 */ 
    1622class jAcl { 
    1723 
    18    private function __construct (){ } 
     24    /** 
     25     * @internal The constructor is private, because all methods are static 
     26     */ 
     27    private function __construct (){ } 
    1928 
    20    public static function isMemberOfGroup ($groupid){ 
    21       $groups = self::getGroups(); 
    22       return in_array($groupid, $groups); 
    23    } 
     29    /** 
     30     * Says if the current user is a member of the given user group 
     31     * @param int $groupid The id of a group 
     32     * @return boolean true if it's ok 
     33     */ 
     34    public static function isMemberOfGroup ($groupid){ 
     35        $groups = self::getGroups(); 
     36        return in_array($groupid, $groups); 
     37    } 
    2438 
    25    public static function check($subject, $value, $resource=null){ 
    26       $val = self::getRight($subject, $resource); 
    27       return ($val & $value)?true:false; 
    28    } 
     39    /** 
     40     * call this method to know if the current user has the right with the given value 
     41     * @param string  $subject the key of the subject to check 
     42     * @param int $value the value to test against 
     43     * @param string $resource the id of a resource 
     44     * @return boolean true if yes 
     45     */ 
     46    public static function check($subject, $value, $resource=null){ 
     47        $val = self::getRight($subject, $resource); 
     48        return ($val & $value)?true:false; 
     49    } 
    2950 
    30    public static function getRight($subject, $resource=null){ 
    31       static $aclres = array(); 
    32       static $acl = array(); 
     51    /** 
     52     * return the value of the right on the given subject (and on the optional resource) 
     53     * @param string  $subject the key of the subject 
     54     * @param string $resource the id of a resource 
     55     * @return int the value of the right 
     56     */ 
     57    public static function getRight($subject, $resource=null){ 
     58        static $aclres = array(); 
     59        static $acl = array(); 
    3360 
    34       if($resource === null){ 
    35          if(isset($acl[$subject])){ 
    36             return $acl[$subject]; 
    37          
    38       }else{ 
    39          if(isset($aclres[$subject][$resource])){ 
    40             return $aclres[$subject][$resource]; 
    41          
    42      
    43       if(!jAuth::isConnected()) 
    44          return 0; 
     61        if($resource === null){ 
     62            if(isset($acl[$subject])){ 
     63                return $acl[$subject]; 
     64            
     65        }else{ 
     66            if(isset($aclres[$subject][$resource])){ 
     67                return $aclres[$subject][$resource]; 
     68            
     69       
     70        if(!jAuth::isConnected()) 
     71            return 0; 
    4572 
    46       $groups = self::getGroups(); 
     73        $groups = self::getGroups(); 
    4774 
    48       // recup� toutes les valeurs correspondant aux groupes auquel appartient le user, 
    49       //   avec le sujet et ressource indiqu�     // droit = OU entre ces valeurs 
     75        // recup� toutes les valeurs correspondant aux groupes auquel appartient le user, 
     76        //   avec le sujet et ressource indiqu�       // droit = OU entre ces valeurs 
    5077 
    51       $dao = jDao::get('acl~jaclrights'); 
    52       if($resource === null){ 
    53          $list=$dao->getAllGroupRights($subject, $groups); 
    54       }else{ 
    55          $list=$dao->getAllGroupRightsWithRes($subject, $groups, $resource); 
    56        
    57       $value=0; 
    58       foreach($list as $right){ 
    59           $value |= intval($right->value); 
    60      
     78        $dao = jDao::get('acl~jaclrights'); 
     79        if($resource === null){ 
     80            $list=$dao->getAllGroupRights($subject, $groups); 
     81        }else{ 
     82            $list=$dao->getAllGroupRightsWithRes($subject, $groups, $resource); 
     83       
     84        $value=0; 
     85        foreach($list as $right){ 
     86            $value |= intval($right->value); 
     87       
    6188 
    62       if($resource === null){ 
    63          $aclres[$subject][$resource] =$value; 
    64       }else{ 
    65          $acl[$subject] = $value; 
    66      
    67       return $value; 
    68    
     89        if($resource === null){ 
     90            $aclres[$subject][$resource] =$value; 
     91        }else{ 
     92            $acl[$subject] = $value; 
     93       
     94        return $value; 
     95   
    6996 
     97    /** 
     98     * retrieve the list of group the current user is member of 
     99     * @return array list of group id 
     100     */ 
     101    protected static function getGroups(){ 
     102        static $groups = null; 
    70103 
    71   protected static function getGroups(){ 
    72       static $groups = null
     104        if(!isset($_SESSION['JELIX_USER']->login)) 
     105            return array()
    73106 
    74       if(!isset($_SESSION['JELIX_USER']->login)) 
    75          return array(); 
    76  
    77       // chargement des groupes 
    78       if($groups === null){ 
    79          $dao = jDao::get('acl~jaclusergroup'); 
    80          $gp = $dao->getGroupsUser($_SESSION['JELIX_USER']->login); 
    81          $groups = array(); 
    82          foreach($gp as $g){ 
    83             $groups[]=intval($g->id_aclgrp); 
    84          } 
    85       } 
    86       return $groups; 
    87   } 
     107        // chargement des groupes 
     108        if($groups === null){ 
     109            $dao = jDao::get('acl~jaclusergroup'); 
     110            $gp = $dao->getGroupsUser($_SESSION['JELIX_USER']->login); 
     111            $groups = array(); 
     112            foreach($gp as $g){ 
     113                $groups[]=intval($g->id_aclgrp); 
     114            } 
     115        } 
     116        return $groups; 
     117    } 
    88118} 
    89119 
  • trunk/lib/jelix/acl/jAclManager.class.php

    r206 r227  
    55* @version     $Id:$ 
    66* @author      Laurent Jouanneau 
    7 * @contributor 
    87* @copyright   2006 Laurent Jouanneau 
    98* @link        http://www.jelix.org 
     
    1312 
    1413/** 
    15  * Classe pour modifier les droits 
     14 * This class is used to manage rights 
     15 * It needs the acl module. 
     16 * @package     jelix 
     17 * @subpackage  acl 
     18 * @static 
    1619 */ 
    1720class jAclManager { 
    1821 
     22    /** 
     23     * @internal The constructor is private, because all methods are static 
     24     */ 
    1925    private function __construct (){ } 
    2026 
    2127    /** 
    22      * @return boolean  vrai si tout est ok 
     28     * specify the value of a right on the given subject/group/resource 
     29     * @return boolean  true if the right is set 
    2330     */ 
    2431    public static function setRight($group, $subject, $value , $resource=''){ 
     
    6269    } 
    6370 
     71    /** 
     72     * remove the right on the given subject/resource, for all groups 
     73     * @param string  $subject the key of the subject 
     74     * @param string $resource the id of a resource 
     75     */ 
    6476    public static function removeResourceRight($subject, $resource){ 
    6577        $daoright = jDao::get('acl~jaclrights'); 
     
    6779    } 
    6880 
    69  
     81    /** 
     82     * create a new subject 
     83     * @param string  $subject the key of the subject 
     84     * @param int $id_aclvalgrp the id of the values group with which the right can be set 
     85     * @param string $label_key the key of a locale which represents the label of the subject 
     86     */ 
    7087    public static function addSubject($subject, $id_aclvalgrp, $label_key){ 
    7188         // ajoute un sujet dans la table jacl_subject 
     
    7996    } 
    8097 
     98    /** 
     99     * Delete the given subject 
     100     * @param string  $subject the key of the subject 
     101     */ 
    81102    public static function removeSubject($subject){ 
    82103      // supprime dans jacl_rights 
  • trunk/lib/jelix/acl/jAclUserGroup.class.php

    r195 r227  
    55* @version     $Id:$ 
    66* @author      Laurent Jouanneau 
    7 * @contributor 
    87* @copyright   2006 Laurent Jouanneau 
    98* @link        http://www.jelix.org 
     
    1211 
    1312/** 
    14  * classe pour g�r les groupes d'utilisateur et gerer les utilisateurs inscrits dans 
    15  * le syst� de droits 
     13 * Use this class to register or unregister users in the acl system, and to manage user groups 
     14 * It needs the acl module. 
     15 * @package     jelix 
     16 * @subpackage  acl 
     17 * @static 
    1618 */ 
    1719class jAclUserGroup { 
    1820 
     21    /** 
     22     * @internal The constructor is private, because all methods are static 
     23     */ 
    1924    private function __construct (){ } 
    2025 
     26    /** 
     27     * get the list of the users of a group 
     28     * @param int $groupid  id of the user group 
     29     * @return array a list of users object (dao records) 
     30     */ 
    2131    public static function getUsersList($groupid){ 
    2232      $dao = jDao::get('acl~jaclusergroup'); 
     
    2434    } 
    2535 
     36    /** 
     37     * register a user in the acl system 
     38     * 
     39     * For example, this method is called by the acl module when responding 
     40     * to the event generated by the auth module when a user is created. 
     41     * When a user is registered, a private group is created. 
     42     * @param string $login the user login 
     43     * @param boolean $defaultGroup if true, the user become the member of default groups 
     44     */ 
    2645    public static function createUser($login, $defaultGroup=true){ 
    2746      $daousergroup = jDao::get('acl~jaclusergroup'); 
     
    5069    } 
    5170 
    52  
     71    /** 
     72     * add a user into a group 
     73     * 
     74     * (a user can be a member of several groups) 
     75     * @param string $login the user login 
     76     * @param int $groupid the group id 
     77     */ 
    5378    public static function addUserToGroup($login, $groupid){ 
    5479      $daousergroup = jDao::get('acl~jaclusergroup'); 
     
    5984    } 
    6085 
     86    /** 
     87     * remove a user from a group 
     88     * @param string $login the user login 
     89     * @param int $groupid the group id 
     90     */ 
    6191    public static function removeUserFromGroup($login,$groupid){ 
    6292      $daousergroup = jDao::get('acl~jaclusergroup'); 
     
    6494    } 
    6595 
     96    /** 
     97     * unregister a user in the acl system 
     98     * @param string $login the user login 
     99     */ 
    66100    public static function removeUser($login){ 
    67101      $daogroup = jDao::get('acl~jaclgroup'); 
     
    82116    } 
    83117 
    84      // renvoi group id 
     118    /** 
     119     * create a new group 
     120     * @param string $name its name 
     121     * @return int the id of the new group 
     122     */ 
    85123    public static function createGroup($name){ 
    86124        $group = jDao::createRecord('acl~jaclgroup'); 
     
    92130    } 
    93131 
     132    /** 
     133     * set a group to be default (or not) 
     134     * 
     135     * there can have several default group. A default group is a group 
     136     * where a user is assigned to during its registration 
     137     * @param int $groupid the group id 
     138     * @param boolean $default true if the group is to be default, else false 
     139     */ 
    94140    public static function setDefaultGroup($groupid, $default=true){ 
    95141       $daogroup = jDao::get('acl~jaclgroup'); 
     
    100146    } 
    101147 
     148    /** 
     149     * change the name of a group 
     150     * @param int $groupid the group id 
     151     * @param string $name the new name 
     152     */ 
    102153    public static function updateGroup($groupid, $name){ 
    103154       $daogroup = jDao::get('acl~jaclgroup'); 
     
    105156    } 
    106157 
     158    /** 
     159     * delete a group from the acl system 
     160     * @param int $groupid the group id 
     161     */ 
    107162    public static function removeGroup($groupid){ 
    108163       $daogroup = jDao::get('acl~jaclgroup'); 
     
    117172    } 
    118173 
    119     // renvoi liste de groupe non personnel 
     174    /** 
     175     * return a list of group. 
     176     * 
     177     * if a login is given, it returns only the groups of the user. 
     178     * Else it returns all groups (except private groups) 
     179     * @param string $login an optional login 
     180     * @return array a list of groups object (dao records) 
     181     */ 
    120182    public static function getGroupList($login=''){ 
    121183        if ($login === '') { 
     
    127189        } 
    128190    } 
    129  
    130191} 
    131192 
  • trunk/lib/jelix/tpl/plugins/common/block.ifacl.php

    r215 r227  
    22/** 
    33* @package    jelix 
    4 * @subpackage template plugins 
     4* @subpackage jtpl_plugin 
    55* @version    $Id$ 
    66* @author     Jouanneau Laurent 
    7 * @contributor 
    87* @copyright   2006 Jouanneau laurent 
    98* @link        http://www.jelix.org 
     
    1211 
    1312/** 
    14  * @param $params array  1:sujet 2:valeur du droit 3: ressource �ntuelles 
     13 * a special if block to test easily a right value 
     14 * 
     15 * usage : {ifacl array('subject',54)} ..here generated content if the user has the right  {/ifacl} 
     16 * @package    jelix 
     17 * @subpackage jtpl_plugin 
     18 * @param jTplCompiler $compiler the template compiler 
     19 * @param boolean true if it is the begin of block, else false 
     20 * @param $params array  1=>subject 2=>right value 3=>optional resource 
     21 * @return string the php code corresponding to the begin or end of the block 
    1522 */ 
    1623function jtpl_block_ifacl($compiler, $begin, $params=array()) 
  • trunk/lib/jelix/tpl/plugins/common/block.ifnotacl.php

    r215 r227  
    22/** 
    33* @package    jelix 
    4 * @subpackage template plugins 
     4* @subpackage jtpl_plugin 
    55* @version    $Id$ 
    66* @author     Jouanneau Laurent 
    7 * @contributor 
    87* @copyright   2006 Jouanneau laurent 
    98* @link        http://www.jelix.org 
     
    1110*/ 
    1211 
    13  
    1412/** 
    15  * @param $params array  1:sujet 2:valeur du droit 3: ressource �ntuelles 
     13 * a special if block to test easily a right value 
     14 * 
     15 * usage : {ifnotacl array('subject',54)} ..here generated content if the user has NOT the right  {/ifnotacl} 
     16 * @package    jelix 
     17 * @subpackage jtpl_plugin 
     18 * @param jTplCompiler $compiler the template compiler 
     19 * @param boolean true if it is the begin of block, else false 
     20 * @param $params array  1=>subject 2=>right value 3=>optional resource 
     21 * @return string the php code corresponding to the begin or end of the block 
    1622 */ 
    1723function jtpl_block_ifnotacl($compiler, $begin, $params=array()) 
  • trunk/lib/jelix/tpl/plugins/common/block.ifuserconnected.php

    r215 r227  
    22/** 
    33* @package    jelix 
    4 * @subpackage template plugins 
     4* @subpackage jtpl_plugin 
    55* @version    $Id$ 
    66* @author     Jouanneau Laurent 
    7 * @contributor 
    87* @copyright   2006 Jouanneau laurent 
    98* @link        http://www.jelix.org 
     
    1110*/ 
    1211 
     12/** 
     13 * a special if block to test easily if the current user is connected 
     14 * 
     15 * usage : {ifuserconnected} ..here generated content if the user is connected  {/ifuserconnected} 
     16 * @package    jelix 
     17 * @subpackage jtpl_plugin 
     18 * @param jTplCompiler $compiler the template compiler 
     19 * @param boolean true if it is the begin of block, else false 
     20 * @param array $params no parameters. array should be empty 
     21 * @return string the php code corresponding to the begin or end of the block 
     22 */ 
    1323function jtpl_block_ifuserconnected($compiler, $begin, $params=array()) 
    1424{ 
  • trunk/lib/jelix/tpl/plugins/common/block.ifusernotconnected.php

    r215 r227  
    22/** 
    33* @package    jelix 
    4 * @subpackage template plugins 
     4* @subpackage jtpl_plugin 
    55* @version    $Id$ 
    66* @author     Jouanneau Laurent 
    7 * @contributor 
    87* @copyright   2006 Jouanneau laurent 
    98* @link        http://www.jelix.org 
     
    1110*/ 
    1211 
     12/** 
     13 * a special if block to test easily if the current user is not connected 
     14 * 
     15 * usage : {ifusernotconnected} ..here generated content if the user is NOTconnected  {/ifusernotconnected} 
     16 * @package    jelix 
     17 * @subpackage jtpl_plugin 
     18 * @param jTplCompiler $compiler the template compiler 
     19 * @param boolean true if it is the begin of block, else false 
     20 * @param array $params no parameters. array should be empty 
     21 * @return string the php code corresponding to the begin or end of the block 
     22 */ 
    1323function jtpl_block_ifusernotconnected($compiler, $begin, $params=array()) 
    1424{ 
  • trunk/lib/jelix/tpl/plugins/common/function.include.php

    r124 r227  
    11 <?php 
    22/** 
    3  * Smarty plugin 
    4  * @package Smarty 
    5  * @subpackage plugins 
     3 * Plugin from smarty project and adapted for jtpl 
     4 * @package    jelix 
     5 * @subpackage jtpl_plugin 
     6 * @version    $Id$ 
     7 * @author 
     8 * @copyright  2001-2003 ispi of Lincoln, Inc. 
     9 * @link http://smarty.php.net/ 
     10 * @link http://jelix.org/ 
     11 * @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
    612 */ 
    713 
    8  
    914/** 
    10  * Smarty include template plugin 
     15 * function plugin :  include a template into another template 
    1116 * 
    12  * Type:     function<br> 
    13  * Name:     include<br> 
    14  * Purpose:  include a template into another template 
    15  * @param template 
    16  * @param string 
     17 * usage : {include 'myModule~foo'} 
     18 * @param jTpl $t template engine 
     19 * @param string $string the template selector 
    1720 */ 
    1821function jtpl_function_include($t, $string) { 
  • trunk/lib/jelix/tpl/plugins/common/function.zone.php

    r182 r227  
    22/** 
    33* @package    jelix 
    4 * @subpackage template plugins 
     4* @subpackage jtpl_plugin 
    55* @version    $Id$ 
    66* @author     Jouanneau Laurent 
    7 * @contributor 
    87* @copyright   2006 Jouanneau laurent 
    98* @link        http://www.jelix.org 
     
    1110*/ 
    1211 
     12/** 
     13 * function plugin :  include the content of a zone 
     14 * 
     15 * example : {zone 'myModule~myzone'} or {zone 'myModule~myzone',array('foo'=>'bar)} 
     16 * @param jTpl $tpl template engine 
     17 * @param string $string the zone selector 
     18 * @param array $params parameters for the zone 
     19 */ 
    1320function jtpl_function_zone($tpl, $name, $params=array()) 
    1421{ 
  • trunk/lib/jelix/tpl/plugins/common/modifier.cat.php

    r14 r227  
    11<?php 
    22/** 
    3  * Smarty plugin 
    4  * @package Smarty 
    5  * @subpackage plugins 
     3 * Plugin from smarty project and adapted for jtpl 
     4 * @package    jelix 
     5 * @subpackage jtpl_plugin 
     6 * @version    $Id$ 
     7 * @author     Monte Ohrt <monte at ohrt dot com> 
     8 * @copyright 2001-2003 ispi of Lincoln, Inc. 
     9 * @link http://smarty.php.net/ 
     10 * @link http://jelix.org/ 
     11 * @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
    612 */ 
    713 
    8  
    914/** 
    10  * Smarty cat modifier plugin 
     15 * Modifier plugin : catenate a value to a variable 
    1116 * 
    12  * Type:     modifier<br> 
    13  * Name:     cat<br> 
    14  * Date:     Feb 24, 2003 
    15  * Purpose:  catenate a value to a variable 
    16  * Input:    string to catenate 
    17  * Example:  {$var|cat:"foo"} 
    18  * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat 
    19  *          (Smarty online manual) 
    20  * @author   Monte Ohrt <monte at ohrt dot com> 
    21  * @version 1.0 
    22  * @param string 
    23  * @param string 
     17 * Example:  {$var|cat:"foo"}  {$var|cat:$othervar} 
     18 * @param string $string the string to be modified 
     19 * @param string $cat the string to concat to $string 
    2420 * @return string 
    2521 */ 
  • trunk/lib/jelix/tpl/plugins/common/modifier.count_characters.php

    r14 r227  
    11<?php 
    22/** 
    3  * Smarty plugin 
    4  * @package Smarty 
    5  * @subpackage plugins 
     3 * Plugin from smarty project and adapted for jtpl 
     4 * @package    jelix 
     5 * @subpackage jtpl_plugin 
     6 * @version    $Id$ 
     7 * @author 
     8 * @copyright  2001-2003 ispi of Lincoln, Inc. 
     9 * @link http://smarty.php.net/ 
     10 * @link http://jelix.org/ 
     11 * @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
    612 */ 
    713 
    8  
    914/** 
    10  * Smarty count_characters modifier plugin 
    11  * 
    12  * Type:     modifier<br> 
    13  * Name:     count_characteres<br> 
    14  * Purpose:  count the number of characters in a text 
    15  * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php 
    16  *          count_characters (Smarty online manual) 
     15 * Modifier plugin : count the number of characters in a text 
    1716 * @param string 
    1817 * @param boolean include whitespace in the character count 
  • trunk/lib/jelix/tpl/plugins/common/modifier.count_paragraphs.php

    r14 r227  
    11<?php 
    22/** 
    3  * Smarty plugin 
    4  * @package Smarty 
    5  * @subpackage plugins 
     3 * Plugin from smarty project and adapted for jtpl 
     4 * @package    jelix 
     5 * @subpackage jtpl_plugin 
     6 * @version    $Id$ 
     7 * @author 
     8 * @copyright  2001-2003 ispi of Lincoln, Inc. 
     9 * @link http://smarty.php.net/ 
     10 * @link http://jelix.org/ 
     11 * @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
    612 */ 
    713 
    8  
    914/** 
    10  * Smarty count_paragraphs modifier plugin 
    11  * 
    12  * Type:     modifier<br> 
    13  * Name:     count_paragraphs<br> 
    14  * Purpose:  count the number of paragraphs in a text 
    15  * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php 
    16  *          count_paragraphs (Smarty online manual) 
     15 * modifier plugin :  count the number of paragraphs in a text 
    1716 * @param string 
    1817 * @return integer 
  • trunk/lib/jelix/tpl/plugins/common/modifier.count_sentences.php

    r14 r227  
    11<?php 
    22/** 
    3  * Smarty plugin 
    4  * @package Smarty 
    5  * @subpackage plugins 
     3 * Plugin from smarty project and adapted for jtpl 
     4 * @package    jelix 
     5 * @subpackage jtpl_plugin 
     6 * @version    $Id$ 
     7 * @author 
     8 * @copyright  2001-2003 ispi of Lincoln, Inc. 
     9 * @link http://smarty.php.net/ 
     10 * @link http://jelix.org/ 
     11 * @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
    612 */ 
    713 
    8  
    914/** 
    10  * Smarty count_sentences modifier plugin 
    11  * 
    12  * Type:     modifier<br> 
    13  * Name:     count_sentences 
    14  * Purpose:  count the number of sentences in a text 
    15  * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php 
    16  *          count_sentences (Smarty online manual) 
     15 * modifier plugin : count the number of sentences in a text 
    1716 * @param string 
    1817 * @return integer 
  • trunk/lib/jelix/tpl/plugins/common/modifier.count_words.php

    r14 r227  
    11<?php 
    22/** 
    3  * Smarty plugin 
    4  * @package Smarty 
    5  * @subpackage plugins 
     3 * Plugin from smarty project and adapted for jtpl 
     4 * @package    jelix 
     5 * @subpackage jtpl_plugin 
     6 * @version    $Id$ 
     7 * @author 
     8 * @copyright  2001-2003 ispi of Lincoln, Inc. 
     9 * @link http://smarty.php.net/ 
     10 * @link http://jelix.org/ 
     11 * @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
    612 */ 
    713 
    8  
    914/** 
    10  * Smarty count_words modifier plugin 
    11  * 
    12  * Type:     modifier<br> 
    13  * Name:     count_words<br> 
    14  * Purpose:  count the number of words in a text 
    15  * @link http://smarty.php.net/manual/en/language.modifier.count.words.php 
    16  *          count_words (Smarty online manual) 
     15 * modifier plugin :  count the number of words in a text 
    1716 * @param string 
    1817 * @return integer 
  • trunk/lib/jelix/tpl/plugins/common/modifier.date_format.php

    r184 r227  
    11<?php 
     2/** 
     3 * Plugin from smarty project and adapted for jtpl 
     4 * @package    jelix 
     5 * @subpackage jtpl_plugin 
     6 * @version    $Id$ 
     7 * @author        Smarty team 
     8 * @contributor   Yannick Le Gu�rt <yannick at over-blog dot com> 
     9 * @copyright  2001-2003 ispi of Lincoln, Inc., Yannick Le Gu�rt 
     10 * @link http://smarty.php.net/ 
     11 * @link http://jelix.org/ 
     12 * @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     13 */ 
    214 
    315/** 
    4  * jTpl date_format modifier plugin 
    5  * adapted from date_format plugin of Smarty 
    6  *  
    7  * Input: 
    8  *               - string: input date string 
    9  *               - format: strftime format for output 
    10  *               - default_date: default date if $string is empty 
    11  *  
    12  * @author        Smarty team 
    13  * @contributor   Yannick Le Gu�rt <yannick at over-blog dot com> 
    14  * @copyright     Smarty team, Yannick Le Gu�rt 
    15  * @link          http://smarty.php.net 
    16  * @param string 
    17  * @param string 
    18  * @param string 
     16 * modifier plugin : format a date 
     17 * 
     18 * @param string $string input date string 
     19 * @param string $format strftime format for output 
     20 * @param string $default_date default date if $string is empty 
    1921 * @return string|void 
    2022 */ 
  • trunk/lib/jelix/tpl/plugins/common/modifier.escxml.php

    r195 r227  
    22/** 
    33* @package    jelix 
    4 * @subpackage template plugins 
     4* @subpackage jtpl_plugin 
    55* @version    $Id$ 
    66* @author     Jouanneau Laurent 
    7 * @contributor 
    87* @copyright   2006 Jouanneau laurent 
    98* @link        http://www.jelix.org 
     
    1110*/ 
    1211 
    13  
     12/** 
     13 * Modifier plugin : escape all forbiden xml characters 
     14 * 
     15 * it escape <,>,",',& 
     16 * Example:  {$var|escxml} 
     17 * @param string $string the string to be escaped 
     18 * @return string 
     19 */ 
    1420function jtpl_modifier_escxml($string) 
    1521{ 
  • trunk/lib/jelix/tpl/plugins/common/modifier.indent.php

    r14 r227  
    11<?php 
    22/** 
    3  * Smarty plugin 
    4  * @package Smarty 
    5  * @subpackage plugins 
     3 * Plugin from smarty project and adapted for jtpl 
     4 * @package    jelix 
     5 * @subpackage jtpl_plugin 
     6 * @version    $Id$ 
     7 * @author 
     8 * @copyright  2001-2003 ispi of Lincoln, Inc. 
     9 * @link http://smarty.php.net/ 
     10 * @link http://jelix.org/ 
     11 * @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
    612 */ 
    713 
    8  
    914/** 
    10  * Smarty indent modifier plugin 
    11  * 
    12  * Type:     modifier<br> 
    13  * Name:     indent<br> 
    14  * Purpose:  indent lines of text 
    15  * @link http://smarty.php.net/manual/en/language.modifier.indent.php 
    16  *          indent (Smarty online manual) 
     15 * Modifier plugin:  indent lines of text 
    1716 * @param string 
    1817 * @param integer 
  • trunk/lib/jelix/tpl/plugins/common/modifier.jdatetime.php

    r184 r227  
    11<?php 
     2/** 
     3* @package    jelix 
     4* @subpackage jtpl_plugin 
     5* @version    $Id$ 
     6* @author     Jouanneau Laurent 
     7* @copyright   2006 Jouanneau laurent 
     8* @link        http://www.jelix.org 
     9* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     10*/ 
    211 
    312/** 
    4  * jTpl jdatetime modifier plugin 
    5  * 
    6  * Type:     modifier<br> 
    7  * Name:     jdatetime<br> 
    8  * Purpose:  change the format of a date 
     13 * modifier plugin : change the format of a date 
    914 * 
    1015 * @param string 
     
    1217 * @param string 
    1318 * @return string 
     19 * @see jDateTime 
    1420 */ 
    15 function jtpl_modifier_jdatetime($date, $format_in = 'db_datetime',  
     21function jtpl_modifier_jdatetime($date, $format_in = 'db_datetime', 
    1622                                 $format_out = 'lang_date') { 
    1723    $formats = array( 
  • trunk/lib/jelix/tpl/plugins/common/modifier.regex_replace.php

    r184 r227  
    11<?php 
    22/** 
    3  * Smarty plugin 
    4  * @package Smarty 
    5  * @subpackage plugins 
     3 * Plugin from smarty project and adapted for jtpl 
     4 * @package    jelix 
     5 * @subpackage jtpl_plugin 
     6 * @version    $Id$ 
     7 * @author 
     8 * @copyright  2001-2003 ispi of Lincoln, Inc. 
     9 * @link http://smarty.php.net/ 
     10 * @link http://jelix.org/ 
     11 * @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
    612 */ 
    713 
    8  
    914/** 
    10  * Smarty regex_replace modifier plugin 
    11  * 
    12  * Type:     modifier<br> 
    13  * Name:     regex_replace<br> 
    14  * Purpose:  regular epxression search/replace 
    15  * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php 
    16  *          regex_replace (Smarty online manual) 
     15 * modifier plugin : regular epxression search/replace 
    1716 * @param string 
    1817 * @param string|array 
     
    2221function jtpl_modifier_regex_replace($string, $search, $replace) 
    2322{ 
    24     if (preg_match('!\W(\w+)$!s', $search, $match) &&  
     23    if (preg_match('!\W(\w+)$!s', $search, $match) && 
    2524            (strpos($match[1], 'e') !== false)) { 
    2625        /* remove eval-modifier from $search */ 
    27         $search = substr($search, 0, -strlen($match[1])) .  
     26        $search = substr($search, 0, -strlen($match[1])) . 
    2827            str_replace('e', '', $match[1]); 
    2928    } 
  • trunk/lib/jelix/tpl/plugins/common/modifier.replace.php