Changeset 18

Show
Ignore:
Timestamp:
09/04/07 20:27:23 (16 months ago)
Author:
llaumgui
Message:

Optimisations et correction.
L'opérateur fetch_topic disparait !

Location:
ez_publish/ezipb/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • ez_publish/ezipb/trunk/autoloads/ezipb_operators.php

    r17 r18  
    2424 * ###################### END LICENSE BLOCK #################### 
    2525 * 
    26  * Opérateur de templates pour eZ publish. 
     26 * Opérateurs de templates pour eZ publish. 
    2727 *  
    2828 * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com> 
     
    3333  
    3434/** 
    35  * Class contenant les opérateur d'ezipb 
     35 * Class contenant les opérateurs de l'extension ezipb 
    3636 * 
    3737 */ 
     
    4141        private $ezipb; 
    4242        private $ipsclass; 
    43          
    44         /*! 
     43 
     44         
     45         
     46        /** 
    4547         * Constructor 
    4648         */ 
     
    4850                 
    4951                /* Instanciation d'ezipb */ 
    50                 if ( !isset( $this->ezipb) ) { 
    51                         require_once( eZExtension::baseDirectory() . '/ezipb/classes/ezipb.php' ); 
    52                         $this->ezipb = new ezipb; 
    53                         $this->ipsclass =& $this->ezipb->ipsclass; 
    54                 } 
     52                require_once( eZExtension::baseDirectory() . '/ezipb/classes/ezipb.php' ); 
     53                $this->ezipb = ezipb::instance(); 
     54                $this->ipsclass =& $this->ezipb->ipsclass; 
    5555                 
    5656                /* Opérateurs */ 
     
    6060                                                                        'ezipb_member', 
    6161                                                                        'ezipb_md5_check', 
    62                                                                         'ezipb_vars', 
    63                                                                         'ezipb_fetch_topic' ); 
    64         } 
    65                  
     62                                                                        'ezipb_vars' ); 
     63        } 
     64 
     65         
    6666 
    6767        /* 
    68          * Fonctions génériques d'opérateurs (héritage ?) 
     68         * Fonctions génériques d'opérateurs 
     69         * (pourquoi pas d'héritage ou implémentation ?) 
    6970         */ 
    7071        function &operatorList() { 
    7172                return $this->Operators; 
    7273        } 
     74         
    7375        function namedParameterPerOperator() { 
    7476                return true; 
    7577        } 
    7678 
    77  
    78  
    7979        function namedParameterList() { 
    8080                 
    81                  return array(  'ezipb_isloggin'                => array( ), 
    82                                                 'ezipb_ismodo'                  => array(       'member_id' => array( 'type' => 'string', 'required' => false, 'default' => '' ) ), 
    83                                                 'ezipb_isadmin'                 => array(       'member_id' => array( 'type' => 'string', 'required' => false, 'default' => '' ) ), 
     81                 return array(  'ezipb_isloggin'                => array(), 
     82                                                'ezipb_issupermodo'             => array(), 
     83                                                'ezipb_isadmin'                 => array(), 
    8484                                                'ezipb_member'                  => array(       'index' => array( 'type' => 'string', 'required' => false, 'default' => '' ) ), 
    8585                                                'ezipb_md5_check'               => array(), 
    8686                                                'ezipb_vars'                    => array(       'index' => array( 'type' => 'string', 'required' => false, 'default' => '' ) ), 
    87                                                 'ezipb_fetch_topic'             => array(       'options' => array( 'type' => 'array', 'required' => false, 'default' => array() ) ) 
    8887                                        ); 
    8988        } 
    90  
    91  
    9289 
    9390        function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, 
     
    9794             
    9895                case 'ezipb_isloggin': 
    99                         $operatorValue = $this->ezipb_isloggin(); 
    100                         break; 
    101                 case 'ezipb_ismodo': 
    102                         $operatorValue = $this->ezipb_isadmin(  $namedParameters['member_id'] ); 
     96                        $operatorValue = $this->isLoggin(); 
     97                        break; 
     98                case 'ezipb_issupermodo': 
     99                        $operatorValue = $this->isSuperModo(); 
    103100                        break; 
    104101                case 'ezipb_isadmin': 
    105                         $operatorValue = $this->ezipb_isadmin(  $namedParameters['member_id'] ); 
     102                        $operatorValue = $this->isAdmin(); 
    106103                        break; 
    107104                case 'ezipb_member': 
    108                         $operatorValue = $this->ezipb_member(  $namedParameters['index'] ); 
     105                        $operatorValue = $this->getMember(  $namedParameters['index'] ); 
    109106                        break; 
    110107                case 'ezipb_md5_check': 
     
    112109                        break; 
    113110                case 'ezipb_vars': 
    114                         $operatorValue = $this->ezipb_vars(  $namedParameters['index'] ); 
    115                         break; 
    116                 case 'ezipb_fetch_topic': 
     111                        $operatorValue = $this->getVars(  $namedParameters['index'] ); 
     112                        break; 
     113                /*case 'ezipb_fetch_topic': 
    117114                        $operatorValue = $this->ezipb_fetch_topic(  $namedParameters['options'] ); 
    118                         break; 
     115                        break;*/ 
    119116                } 
    120117        } 
    121118 
     119         
    122120 
    123121        /** 
     
    126124         * @return boolean 
    127125         */ 
    128         function ezipb_isloggin() { 
     126        private function isLoggin() { 
    129127                 
    130128                if ( $this->ipsclass->member['id'] > 0 ) 
     
    136134         
    137135        /** 
     136         * Le membre est il super modérateur ? 
     137         * 
     138         * @return Booléen 
     139         */ 
     140        private function isSuperModo() { 
     141                 
     142                if ($this->ipsclass->member['g_is_supmod']) 
     143                        return true; 
     144                else 
     145                        return false; 
     146        } 
     147 
     148 
     149         
     150        /** 
    138151         * Le membre est il administrateur ? 
    139152         * 
    140          * @param int $memberid id du membre à checker 
    141153         * @return Booléen 
    142154         */ 
    143         function ezipb_isadmin( $memberid = '' ) { 
    144                  
    145                 if (!$memberid) { 
    146                         // Current Member 
    147                         if ($this->ipsclass->member['g_access_cp']) { 
    148                                 return TRUE; 
    149                         } else { 
    150                                 return FALSE; 
    151                         } 
    152                 } 
    153                 else { 
    154                         /* @TODO */ 
    155                 } 
    156         } 
    157          
    158          
    159         /** 
    160          * Récupération des information sur le membre. 
     155        private function isAdmin() { 
     156                 
     157                if ($this->ipsclass->member['g_access_cp']) 
     158                        return true; 
     159                else 
     160                        return false; 
     161        } 
     162         
     163         
     164         
     165        /** 
     166         * Récupération des informations sur le membre. 
    161167         * 
    162168         * @param String $index Index du tableau à récupérer 
    163169         * @return mixed 
    164170         */ 
    165         function ezipb_member ( $index ) { 
     171        private function getMember ( $index ) { 
    166172                 
    167173                //print_r( $this->ipsclass->member ); 
     
    182188         * @return mixed 
    183189         */ 
    184         function ezipb_vars ( $index ) { 
     190        private function getVars ( $index ) { 
    185191                 
    186192                if ( empty( $index ) ) 
     
    209215         * @return array Infos sur les postes 
    210216         */ 
    211         function ezipb_fetch_topic ( $options ) { 
    212  
    213                 /* Valeurs par défauts */ 
     217        /*function ezipb_fetch_topic ( $options ) { 
     218 
     219                / * Valeurs par défauts * / 
    214220                if ( !array_key_exists( 'sort_by', $options ) || !is_array( $options['sort_by']) ) 
    215221                        $options['sort_by']             = array( 'last_post', false ); 
     
    219225                        $options['limit']               =  0;                                                                                                                                                                                            
    220226                 
    221                 /* true() or false() - ascending or descending */ 
     227                /* true() or false() - ascending or descending * / 
    222228                if ( $options['sort_by'][1] ) 
    223229                         $options['sort_by'][1] = 'ASC'; 
     
    251257                } 
    252258                return $ezipb_fetch_topic; 
    253         } 
     259        }*/ 
    254260 
    255261} // EOC 
  • ez_publish/ezipb/trunk/autoloads/eztemplateautoload.php

    r17 r18  
    66                                                                                'class' => 'ezipbOperators', 
    77                                                                                'operator_names' => array(      'ezipb_isloggin', 
    8                                                                                                                                         'ezipb_ismodo', 
     8                                                                                                                                        'ezipb_issupermodo', 
    99                                                                                                                                        'ezipb_isadmin', 
    1010                                                                                                                                        'ezipb_member', 
    1111                                                                                                                                        'ezipb_md5_check', 
    12                                                                                                                                         'ezipb_vars', 
    13                                                                                                                                         'ezipb_fetch_topic' ) 
     12                                                                                                                                        'ezipb_vars' ) 
    1413                                                                        ); 
    1514?> 
  • ez_publish/ezipb/trunk/classes/ezipb.php

    r9 r18  
    3939         
    4040         
    41         /*! 
    42          * Constructor 
     41        /** 
     42         * Constructeur 
    4343         */ 
    4444        function __construct() { 
     
    8383                //echo "<pre>" . print_r( $this->ipsclass->DB->obj['cached_queries'] ) . "</pre>"; 
    8484        } 
    85 } 
     85         
     86         
     87        /** 
     88         * Permet d'instancier l'objet ezipb. 
     89         * 
     90         * @return object ezipb 
     91         */ 
     92        static function instance() { 
     93 
     94                $impl =& $GLOBALS["ezipbGlobalInstance"]; 
     95         
     96        $class = strtolower( get_class( $impl ) );   
     97        if ( $class != "ezipb" ) 
     98            $impl = new ezipb(); 
     99             
     100        return $impl; 
     101         } 
     102                 
     103}       // EOC 
    86104 
    87105?>