[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/visual/ -> templateview.php (source)

   1  <?php
   2  //
   3  // Created on: <08-May-2003 11:16:19 bf>
   4  //
   5  // SOFTWARE NAME: eZ publish
   6  // SOFTWARE RELEASE: 3.9.0
   7  // BUILD VERSION: 17785
   8  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   9  // SOFTWARE LICENSE: GNU General Public License v2.0
  10  // NOTICE: >
  11  //   This program is free software; you can redistribute it and/or
  12  //   modify it under the terms of version 2.0  of the GNU General
  13  //   Public License as published by the Free Software Foundation.
  14  //
  15  //   This program is distributed in the hope that it will be useful,
  16  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18  //   GNU General Public License for more details.
  19  //
  20  //   You should have received a copy of version 2.0 of the GNU General
  21  //   Public License along with this program; if not, write to the Free
  22  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  23  //   MA 02110-1301, USA.
  24  //
  25  //
  26  
  27  $http =& eZHTTPTool::instance();
  28  $module =& $Params["Module"];
  29  $parameters =& $Params["Parameters"];
  30  
  31  include_once ( "kernel/common/template.php" );
  32  include_once ( "kernel/common/eztemplatedesignresource.php" );
  33  include_once ( 'lib/ezutils/classes/ezhttptool.php' );
  34  
  35  $ini =& eZINI::instance();
  36  $tpl =& templateInit();
  37  
  38  $template = "";
  39  
  40  foreach ( $parameters as $param )
  41  {
  42      $template .= "/$param";
  43  }
  44  
  45  if ( $module->isCurrentAction( 'SelectCurrentSiteAccess' ) )
  46  {
  47      if ( $http->hasPostVariable( 'CurrentSiteAccess' ) )
  48      {
  49          $http->setSessionVariable( 'eZTemplateAdminCurrentSiteAccess', $http->postVariable( 'CurrentSiteAccess' ) );
  50      }
  51  }
  52  
  53  // Fetch siteaccess settings for the selected override
  54  // Default to first defined siteacces if none are selected
  55  if ( !$http->hasSessionVariable( 'eZTemplateAdminCurrentSiteAccess' ) )
  56  {
  57      $siteAccessList = $ini->variable( 'SiteAccessSettings', 'AvailableSiteAccessList' );
  58      $http->setSessionVariable( 'eZTemplateAdminCurrentSiteAccess', $siteAccessList[0] );
  59  }
  60  
  61  $siteAccess = $http->sessionVariable( 'eZTemplateAdminCurrentSiteAccess' );
  62  
  63  if ( $module->isCurrentAction( 'NewOverride' ) )
  64  {
  65      if ( $http->hasPostVariable( 'CurrentSiteAccess' ) )
  66      {
  67          $http->setSessionVariable( 'eZTemplateAdminCurrentSiteAccess', $http->postVariable( 'CurrentSiteAccess' ) );
  68      }
  69  
  70      $module->redirectTo( '/visual/templatecreate'. $template );
  71      return EZ_MODULE_HOOK_STATUS_CANCEL_RUN;
  72  }
  73  
  74  if ( $module->isCurrentAction( 'UpdateOverride' ) )
  75  {
  76      if ( $http->hasPostVariable( 'PriorityArray' ) )
  77      {
  78          $priorityArray = $http->postVariable( 'PriorityArray' );
  79  
  80          // Load override.ini for the current siteaccess
  81          $overrideINI = eZINI::instance( 'override.ini', 'settings', null, null, true );
  82          $overrideINI->prependOverrideDir( "siteaccess/$siteAccess", false, 'siteaccess' );
  83          $overrideINI->loadCache();
  84  
  85          asort( $priorityArray );
  86          $currentINIGroups =& $overrideINI->groups();
  87  
  88          $newGroupArray = array();
  89          foreach ( array_keys( $priorityArray ) as $key )
  90          {
  91              $newGroupArray[$key] = $currentINIGroups[$key];
  92              unset( $currentINIGroups[$key] );
  93          }
  94          $overrideINI->setGroups( array_merge( $currentINIGroups, $newGroupArray ) );
  95  
  96          $filePermission = $ini->variable( 'FileSettings', 'StorageFilePermissions' );
  97  
  98          $oldumask = umask( 0 );
  99          $overrideINI->save( "siteaccess/$siteAccess/override.ini.append" );
 100          chmod( "settings/siteaccess/$siteAccess/override.ini.append", octdec( $filePermission ) );
 101          umask( $oldumask );
 102      }
 103  }
 104  
 105  $overrideINISaveFailed = false;
 106  $notRemoved = array();
 107  
 108  if ( $module->isCurrentAction( 'RemoveOverride' ) )
 109  {
 110      if ( $http->hasPostVariable( 'RemoveOverrideArray' ) )
 111      {
 112          $removeOverrideArray = $http->postVariable( 'RemoveOverrideArray' );
 113          // TODO: read from correct site.ini
 114          $siteBase = $siteAccess;
 115  
 116          // Load override.ini for the current siteaccess
 117          $overrideINI = eZINI::instance( 'override.ini', 'settings', null, null, true );
 118          $overrideINI->prependOverrideDir( "siteaccess/$siteAccess", false, 'siteaccess' );
 119          $overrideINI->loadCache();
 120  
 121          $siteINI = eZINI::instance( 'site.ini', 'settings', null, null, true );
 122          $siteINI->prependOverrideDir( "siteaccess/$siteAccess", false, 'siteaccess' );
 123          $siteINI->loadCache();
 124          $siteBase = $siteINI->variable( 'DesignSettings', 'SiteDesign' );
 125  
 126          // Remove settings and file
 127          foreach ( $removeOverrideArray as $removeOverride )
 128          {
 129              $group = $overrideINI->group( $removeOverride );
 130  
 131              $fileName = "design/$siteBase/override/templates/" . $group['MatchFile'];
 132  
 133              if ( unlink( $fileName ) )
 134              {
 135                  $overrideINI->removeGroup( $removeOverride );
 136              }
 137              else
 138              {
 139                  $notRemoved[] = array( 'filename' => $fileName );
 140                  // eZDebug::writeError( "Could not remove override template, check permissions on $fileName", "Template override" );
 141              }
 142          }
 143          if ( $overrideINI->save( "siteaccess/$siteAccess/override.ini.append" ) == false )
 144          {
 145              $overrideINISaveFailed = true;
 146          }
 147  
 148          // Expire content view cache
 149          include_once ( 'kernel/classes/ezcontentcachemanager.php' );
 150          eZContentCacheManager::clearAllContentCache();
 151  
 152          // Clear override cache
 153          $cachedDir = eZSys::cacheDirectory();
 154          $cachedDir .= "/override/";
 155          eZDir::recursiveDelete( $cachedDir );
 156      }
 157  }
 158  
 159  $overrideArray = eZTemplateDesignResource::overrideArray( $siteAccess );
 160  
 161  $templateSettings = false;
 162  if ( isset( $overrideArray[$template] ) )
 163  {
 164      $templateSettings = $overrideArray[$template];
 165  }
 166  
 167  if ( !isset( $templateSettings['custom_match'] ) )
 168      $templateSettings['custom_match'] = 0;
 169  
 170  $tpl->setVariable( 'template_settings', $templateSettings );
 171  $tpl->setVariable( 'current_siteaccess', $siteAccess );
 172  $tpl->setVariable( 'not_removed', $notRemoved );
 173  $tpl->setVariable( 'ini_not_saved', $overrideINISaveFailed );
 174  
 175  $siteINI =& eZINI::instance( 'site.ini' );
 176  if ( $siteINI->variable( 'BackwardCompatibilitySettings', 'UsingDesignAdmin34' ) == 'enabled' )
 177  {
 178      $tpl->setVariable( 'custom_match', $templateSettings['custom_match'] );
 179  }
 180  
 181  $Result = array();
 182  $Result['content'] =& $tpl->fetch( "design:visual/templateview.tpl" );
 183  $Result['path'] = array( array( 'url' => "/visual/templatelist/",
 184                                  'text' => ezi18n( 'kernel/design', 'Template list' ) ),
 185                           array( 'url' => false,
 186                                  'text' => ezi18n( 'kernel/design', 'Template view' ) ) );
 187  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7