eZ Publish  [4.0]
ezcollaborationviewhandler.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZCollaborationViewHandler class
00004 //
00005 // Created on: <23-Jan-2003 11:59:34 amos>
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 ezcollaborationviewhandler.php
00032 */
00033 
00034 /*!
00035   \class eZCollaborationViewHandler ezcollaborationviewhandler.php
00036   \brief The class eZCollaborationViewHandler does
00037 
00038 */
00039 
00040 class eZCollaborationViewHandler
00041 {
00042     const TYPE_STANDARD = 1;
00043     const TYPE_GROUP = 2;
00044 
00045     /*!
00046      Initializes the view mode.
00047     */
00048     function eZCollaborationViewHandler( $viewMode, $viewType )
00049     {
00050         $this->ViewMode = $viewMode;
00051         $this->ViewType = $viewType;
00052         $this->TemplateName = $viewMode;
00053         $ini = $this->ini();
00054         if ( $viewType == self::TYPE_STANDARD )
00055         {
00056             $this->TemplatePrefix = "design:collaboration/view/";
00057             $viewGroup = $viewMode . "View";
00058         }
00059         else if ( $viewType == self::TYPE_GROUP )
00060         {
00061             $this->TemplatePrefix = "design:collaboration/group/view/";
00062             $viewGroup = $viewMode . "GroupView";
00063         }
00064         if ( $ini->hasGroup( $viewGroup ) )
00065         {
00066             if ( $ini->hasVariable( $viewGroup, 'TemplateName' ) )
00067                 $this->TemplateName = $ini->variable( $viewGroup, 'TemplateName' );
00068         }
00069     }
00070 
00071     /*!
00072      \return the template which is used for viewing the collaborations.
00073     */
00074     function template()
00075     {
00076         return $this->TemplatePrefix . $this->TemplateName . ".tpl";
00077     }
00078 
00079     /*!
00080      \static
00081      \return the ini object for collaboration.ini
00082     */
00083     static function ini()
00084     {
00085         return eZINI::instance( 'collaboration.ini' );
00086     }
00087 
00088     /*!
00089      \static
00090      \return true if the viewmode \a $viewMode exists with the current configuration
00091     */
00092     static function exists( $viewMode )
00093     {
00094         $list = eZCollaborationViewHandler::fetchList();
00095         return in_array( $viewMode, $list );
00096     }
00097 
00098     /*!
00099      \static
00100      \return true if the viewmode \a $viewMode exists for groups with the current configuration
00101     */
00102     static function groupExists( $viewMode )
00103     {
00104         $list = eZCollaborationViewHandler::fetchGroupList();
00105         return in_array( $viewMode, $list );
00106     }
00107 
00108     /*!
00109      \static
00110      \return a list of active viewmodes.
00111     */
00112     static function fetchList()
00113     {
00114         return eZCollaborationViewHandler::ini()->variable( 'ViewSettings', 'ViewList' );
00115     }
00116 
00117     /*!
00118      \static
00119      \return a list of active viewmodes for groups.
00120     */
00121     static function fetchGroupList()
00122     {
00123         return eZCollaborationViewHandler::ini()->variable( 'ViewSettings', 'GroupViewList' );
00124     }
00125 
00126     /*!
00127      \static
00128      \return the single instance of the viewmode \a $viewMode.
00129     */
00130     static function instance( $viewMode, $type = self::TYPE_STANDARD )
00131     {
00132         if ( $type == self::TYPE_STANDARD )
00133             $instance =& $GLOBALS["eZCollaborationView"][$viewMode];
00134         else if ( $type == self::TYPE_GROUP )
00135             $instance =& $GLOBALS["eZCollaborationGroupView"][$viewMode];
00136         else
00137         {
00138             return null;
00139         }
00140         if ( !isset( $instance ) )
00141         {
00142             $instance = new eZCollaborationViewHandler( $viewMode, $type );
00143         }
00144         return $instance;
00145     }
00146 
00147     /// \privatesection
00148     /// The viewmode
00149     public $ViewMode;
00150     public $ViewType;
00151     public $TemplateName;
00152     public $TemplatePrefix;
00153 }
00154 
00155 ?>