eZ Publish  [4.0]
eztopmenuoperator.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZTopMenuOperator class
00004 //
00005 // Created on: <09-Nov-2004 14:33:28 sp>
00006 //
00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00008 // SOFTWARE NAME: eZ Publish
00009 // SOFTWARE RELEASE: 4.0.x
00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00011 // SOFTWARE LICENSE: GNU General Public License v2.0
00012 // NOTICE: >
00013 //   This program is free software; you can redistribute it and/or
00014 //   modify it under the terms of version 2.0  of the GNU General
00015 //   Public License as published by the Free Software Foundation.
00016 //
00017 //   This program is distributed in the hope that it will be useful,
00018 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //   GNU General Public License for more details.
00021 //
00022 //   You should have received a copy of version 2.0 of the GNU General
00023 //   Public License along with this program; if not, write to the Free
00024 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 //   MA 02110-1301, USA.
00026 //
00027 //
00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00029 //
00030 
00031 /*! \file eztopmenuoperator.php
00032 */
00033 
00034 /*!
00035   \class eZTopMenuOperator eztopmenuoperator.php
00036   \brief The class eZTopMenuOperator does
00037 
00038 */
00039 require_once( 'kernel/common/i18n.php' );
00040 
00041 class eZTopMenuOperator
00042 {
00043     /*!
00044      Constructor
00045     */
00046     function eZTopMenuOperator( $name = 'topmenu' )
00047     {
00048         $this->Operators = array( $name );
00049         $this->DefaultNames = array(
00050             'content' => array( 'name' => ezi18n( 'design/admin/pagelayout',
00051                                                   'Content structure' ),
00052                                 'tooltip'=> ezi18n( 'design/admin/pagelayout',
00053                                                     'Manage the main content structure of the site.' ) ),
00054             'media' => array( 'name' => ezi18n( 'design/admin/pagelayout',
00055                                                 'Media library' ),
00056                               'tooltip'=> ezi18n( 'design/admin/pagelayout',
00057                                                   'Manage images, files, documents, etc.' ) ),
00058             'users' => array( 'name' => ezi18n( 'design/admin/pagelayout',
00059                                                 'User accounts' ),
00060                               'tooltip'=> ezi18n( 'design/admin/pagelayout',
00061                                                   'Manage users, user groups and permission settings.' ) ),
00062             'shop' => array( 'name' => ezi18n( 'design/admin/pagelayout',
00063                                                'Webshop' ),
00064                              'tooltip'=> ezi18n( 'design/admin/pagelayout',
00065                                                  'Manage customers, orders, discounts and VAT types; view sales statistics.' ) ),
00066             'design' => array( 'name' => ezi18n( 'design/admin/pagelayout',
00067                                                  'Design' ),
00068                                'tooltip'=> ezi18n( 'design/admin/pagelayout',
00069                                                    'Manage templates, menus, toolbars and other things related to appearence.' ) ),
00070             'setup' => array( 'name' => ezi18n( 'design/admin/pagelayout',
00071                                                 'Setup' ),
00072                               'tooltip'=> ezi18n( 'design/admin/pagelayout',
00073                                                   'Configure settings and manage advanced functionality.' ) ),
00074             'my_account' => array( 'name' => ezi18n( 'design/admin/pagelayout',
00075                                                      'My account' ),
00076                                    'tooltip'=> ezi18n( 'design/admin/pagelayout',
00077                                                        'Manage items and settings that belong to your account.' ) ) );
00078     }
00079 
00080     /*!
00081      Returns the operators in this class.
00082     */
00083     function operatorList()
00084     {
00085         return $this->Operators;
00086     }
00087 
00088     /*!
00089      See eZTemplateOperator::namedParameterList()
00090     */
00091     function namedParameterList()
00092     {
00093         return array( 'context' => array( 'type' => 'string',
00094                                           'required' => true,
00095                                           'default' => 'content' ) );
00096     }
00097     /*!
00098      \reimp
00099     */
00100     function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters )
00101     {
00102 
00103         $ini = eZINI::instance( 'menu.ini' );
00104 
00105         if ( !$ini->hasVariable( 'TopAdminMenu', 'Tabs' ) )
00106         {
00107             eZDebug::writeError( "Top Admin menu is not configured. Ini  setting [TopAdminMenu] Tabs[] is missing" );
00108             $operatorValue = array();
00109             return;
00110         }
00111 
00112         $context = $namedParameters['context'];
00113 
00114         $tabIDs = $ini->variable( 'TopAdminMenu', 'Tabs' );
00115 
00116         $menu = array();
00117 
00118         foreach ( $tabIDs as $tabID )
00119         {
00120             $shownList = $ini->variable( 'Topmenu_' . $tabID , "Shown" );
00121             if ( isset( $shownList[$context] ) && $shownList[$context] === 'false' )
00122             {
00123                 continue;
00124             }
00125 
00126             $menuItem = array();
00127             $urlList = $ini->variable( 'Topmenu_' . $tabID , "URL" );
00128             if ( isset( $urlList[$context] ) )
00129             {
00130                 $menuItem['url'] = $urlList[$context];
00131             }
00132             else
00133             {
00134                 $menuItem['url'] = $urlList['default'];
00135             }
00136 
00137             $enabledList = $ini->variable( 'Topmenu_' . $tabID , "Enabled" );
00138             if ( isset( $enabledList[$context] ) )
00139             {
00140                 if ( $enabledList[$context] == 'true' )
00141                     $menuItem['enabled'] = true;
00142                 else
00143                     $menuItem['enabled'] = false;
00144             }
00145             else
00146             {
00147                 if ( $enabledList['default'] == true )
00148                     $menuItem['enabled'] = true;
00149                 else
00150                     $menuItem['enabled'] = false;
00151             }
00152 
00153             if ( $ini->hasVariable( 'Topmenu_' . $tabID , 'Name' ) &&  $ini->variable( 'Topmenu_' . $tabID , "Name" ) != '' )
00154             {
00155                 $menuItem['name'] = $ini->variable( 'Topmenu_' . $tabID , "Name" );
00156             }
00157             else
00158             {
00159                 $menuItem['name'] = $this->DefaultNames[$tabID]['name'];
00160             }
00161             if ( $ini->hasVariable( 'Topmenu_' . $tabID , 'Tooltip' ) &&  $ini->variable( 'Topmenu_' . $tabID , "Tooltip" ) != '' )
00162             {
00163                 $menuItem['tooltip'] =  $ini->variable( 'Topmenu_' . $tabID , "Tooltip" );
00164             }
00165             else
00166             {
00167                 $menuItem['tooltip'] = isset( $this->DefaultNames[$tabID]['tooltip'] ) ? $this->DefaultNames[$tabID]['tooltip'] : '';
00168             }
00169             $menuItem['navigationpart_identifier'] =  $ini->variable( 'Topmenu_' . $tabID , "NavigationPartIdentifier" );
00170             $menuItem['position'] = 'middle';
00171             $menu[] = $menuItem;
00172 
00173         }
00174         $menu[0]['position'] = 'first';
00175         $menu[count($menu) - 1]['position'] = 'last';
00176 
00177         $operatorValue = $menu;
00178     }
00179 
00180     /// \privatesection
00181     public $Operators;
00182     public $DefaultNames;
00183 }
00184 
00185 
00186 ?>