root/ez_publish/ezipb/trunk/autoloads/ezipb_operators.php

Revision 80, 4.1 KB (checked in by llaumgui, 15 months ago)

Cosmétique

Line 
1<?php
2/*
3 * #################### BEGIN LICENSE BLOCK ####################
4 * This file is part of ezipb.
5 * Copyright (c) 2007 Guillaume Kulakowski and contributors. All
6 * rights reserved.
7 *
8 * ezipb is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * ezipb is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
16 * the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with ezipb; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330,
21 * Boston, MA  02111-1307  USA
22 * or visit http://www.gnu.org/licenses/gpl.html
23 * ###################### END LICENSE BLOCK ####################
24 *
25 * Opérateurs de templates pour eZ publish.
26 *
27 * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com>
28 * @version 1.0
29 */
30
31class ezipbOperators {
32   
33    private $Operators;
34    private $ezipb;
35    private $ipsclass;
36
37
38
39    /**
40     * Constructor
41     */
42    function __construct() {
43       
44        /* Instanciation d'ezipb */
45        require_once( eZExtension::baseDirectory() . '/ezipb/classes/ezipb.php' );
46        $this->ezipb = ezipb::instance();
47        $this->ipsclass =& $this->ezipb->ipsclass;
48       
49        /* Opérateurs */
50        $this->Operators = array(     'ezipb_isloggin',
51                                    'ezipb_issupermodo',
52                                    'ezipb_isadmin',
53                                    'ezipb_member',
54                                    'ezipb_md5_check',
55                                    'ezipb_vars' );
56    }
57
58   
59
60    /*
61     * Fonctions génériques d'opérateurs
62     * (pourquoi pas d'héritage ou implémentation ?)
63     */
64    function &operatorList() {
65        return $this->Operators;
66    }
67   
68    function namedParameterPerOperator() {
69        return true;
70    }
71
72    function namedParameterList() {
73       
74         return array(     'ezipb_isloggin'        => array(),
75                         'ezipb_issupermodo'        => array(),
76                         'ezipb_isadmin'            => array(),
77                         'ezipb_member'             => array(     'index' => array( 'type' => 'string', 'required' => false, 'default' => '' ) ),
78                         'ezipb_md5_check'        => array(),
79                         'ezipb_vars'            => array(     'index' => array( 'type' => 'string', 'required' => false, 'default' => '' ) ),
80                     );
81    }
82
83    function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace,
84                      &$currentNamespace, &$operatorValue, &$namedParameters ) {
85       
86        switch ( $operatorName ) {
87       
88            case 'ezipb_isloggin':
89                $operatorValue = $this->isLoggin();
90                break;
91            case 'ezipb_issupermodo':
92                $operatorValue = $this->isSuperModo();
93                break;
94            case 'ezipb_isadmin':
95                $operatorValue = $this->isAdmin();
96                break;
97            case 'ezipb_member':
98                $operatorValue = $this->getMember$namedParameters['index'] );
99                break;
100            case 'ezipb_md5_check':
101                $operatorValue = $this->ipsclass->md5_check;
102                break;
103            case 'ezipb_vars':
104                $operatorValue = $this->getVars$namedParameters['index'] );
105                break;
106        }
107    }
108
109   
110
111    /**
112     * Le visiteur est il logué.
113     *
114     * @return boolean
115     */
116    private function isLoggin() {
117       
118        return $this->ezipb->isLoggin();
119    }
120
121   
122   
123    /**
124     * Le membre est il super modérateur ?
125     *
126     * @return Booléen
127     */
128    private function isSuperModo() {
129       
130        return $this->ezipb->isSuperModo();
131    }
132
133
134   
135    /**
136     * Le membre est il administrateur ?
137     *
138     * @return Booléen
139     */
140    private function isAdmin() {
141       
142        return $this->ezipb->isAdmin();
143    }
144       
145   
146   
147   
148    /**
149     * Récupération les informations sur le membre.
150     *
151     * @param String $index Index du tableau à récupérer
152     * @return mixed
153     */
154    private function getMember ( $index ) {
155           
156        if ( empty( $index ) )
157            return $this->ipsclass->member;
158       
159        return $this->ipsclass->member[$index];
160    }
161   
162   
163   
164    /**
165     * Récupération les variables IPB du fichier conf_global.php
166     *
167     * @param string $index  Index du tableau à récupérer
168     * @return mixed
169     */
170    private function getVars ( $index ) {
171       
172        if ( empty( $index ) )
173            return $this->ipsclass->vars;
174       
175        return $this->ipsclass->vars[$index];
176    }
177
178} // EOC
179
180?>
Note: See TracBrowser for help on using the browser.