[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/kernel/content/ -> versionview.php (source)

   1  <?php
   2  //
   3  // Created on: <03-May-2002 15:17:01 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  
  28  include_once ( 'kernel/classes/ezcontentobject.php' );
  29  include_once ( 'kernel/classes/ezcontentclass.php' );
  30  include_once ( 'kernel/classes/ezcontentobjecttreenode.php' );
  31  
  32  include_once ( 'lib/ezutils/classes/ezhttptool.php' );
  33  
  34  include_once ( 'kernel/common/template.php' );
  35  
  36  $Offset = $Params['Offset'];
  37  $viewParameters = array( 'offset' => $Offset );
  38  
  39  $tpl =& templateInit();
  40  // Will be sent from the content/edit page and should be kept
  41  // incase the user decides to continue editing.
  42  $FromLanguage = $Params['FromLanguage'];
  43  
  44  $ini =& eZINI::instance();
  45  
  46  $contentObject =& eZContentObject::fetch( $ObjectID );
  47  if ( $contentObject === null )
  48      return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' );
  49  
  50  $versionObject =& $contentObject->version( $EditVersion );
  51  if ( !$versionObject )
  52      return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' );
  53  
  54  if ( !$versionObject->attribute( 'can_read' ) )
  55  {
  56      return $Module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel' );
  57  }
  58  
  59  if ( !$LanguageCode )
  60  {
  61      $LanguageCode = $versionObject->initialLanguageCode();
  62  }
  63  
  64  $user =& eZUser::currentUser();
  65  
  66  $isCreator = ( $versionObject->attribute( 'creator_id' ) == $user->id() );
  67  
  68  if ( $Module->isCurrentAction( 'Versions' ) )
  69  {
  70      return $Module->redirectToView( 'history', array( $ObjectID, $EditVersion, $LanguageCode, $FromLanguage ) );
  71  }
  72  
  73  $sectionID = false;
  74  $placementID = false;
  75  $assignment = false;
  76  
  77  $http =& eZHTTPTool::instance();
  78  
  79  if ( $http->hasPostVariable( 'ContentObjectLanguageCode' ) )
  80      $LanguageCode = $http->postVariable( 'ContentObjectLanguageCode' );
  81  if ( $http->hasPostVariable( 'ContentObjectPlacementID' ) )
  82      $placementID = $http->postVariable( 'ContentObjectPlacementID' );
  83  
  84  $nodeAssignments =& $versionObject->attribute( 'node_assignments' );
  85  $virtualNodeID = null;
  86  if ( is_array( $nodeAssignments ) and
  87       count( $nodeAssignments ) == 1 )
  88  {
  89      if ( $contentObject->attribute( 'main_node_id' ) != null )
  90          $virtualNodeID = $contentObject->attribute( 'main_node_id' );
  91      else
  92          $virtualNodeID = null;
  93  
  94      $placementID = $nodeAssignments[0]->attribute( 'id' );
  95  }
  96  else if ( !$placementID && count( $nodeAssignments ) )
  97  {
  98      foreach ( array_keys( $nodeAssignments ) as $key )
  99      {
 100          $nodeAssignment =& $nodeAssignments[$key];
 101          if ( $nodeAssignment->attribute( 'is_main' ) )
 102          {
 103              $placementID = $nodeAssignment->attribute( 'id' );
 104              $parentNodeID = $nodeAssignment->attribute( 'parent_node' );
 105              $ObjectID = (int) $ObjectID;
 106              $query="SELECT node_id
 107                      FROM ezcontentobject_tree
 108                      WHERE contentobject_id=$ObjectID
 109                      AND parent_node_id=$parentNodeID";
 110  
 111              $db =& eZDB::instance();
 112              $nodeListArray = $db->arrayQuery( $query );
 113              $virtualNodeID = $nodeListArray[0]['node_id'];
 114              break;
 115          }
 116      }
 117  }
 118  $parentNodeID = false;
 119  $mainAssignment = false;
 120  foreach ( array_keys( $nodeAssignments ) as $key )
 121  {
 122      if ( $nodeAssignments[$key]->attribute( 'is_main' ) == 1 )
 123      {
 124          $mainAssignment =& $nodeAssignments[$key];
 125          $parentNodeID = $mainAssignment->attribute( 'parent_node' );
 126          break;
 127      }
 128  }
 129  
 130  $contentINI =& eZINI::instance( 'content.ini' );
 131  
 132  if ( $Module->isCurrentAction( 'ChangeSettings' ) )
 133  {
 134      if ( $Module->hasActionParameter( 'Language' ) )
 135      {
 136          $LanguageCode = $Module->actionParameter( 'Language' );
 137      }
 138  
 139      if ( $Module->hasActionParameter( 'PlacementID' ) )
 140      {
 141          $placementID = $Module->actionParameter( 'PlacementID' );
 142      }
 143  }
 144  
 145  $assignment = null;
 146  if ( is_numeric( $placementID ) )
 147      $assignment = eZNodeAssignment::fetchByID( $placementID );
 148  if ( $assignment !== null )
 149  {
 150      $node =& $assignment->getParentNode();
 151      if ( $node !== null )
 152      {
 153          $nodeObject =& $node->attribute( "object" );
 154          $sectionID = $nodeObject->attribute( "section_id" );
 155      }
 156  }
 157  else
 158  {
 159      $assignment = false;
 160  }
 161  
 162  $versionAttributes = $versionObject->contentObjectAttributes( $LanguageCode );
 163  if ( $versionAttributes === null or
 164       count( $versionAttributes ) == 0 )
 165  {
 166      $LanguageCode = $versionObject->initialLanguageCode();
 167      $versionAttributes = $versionObject->contentObjectAttributes( $LanguageCode );
 168  }
 169  
 170  $ini =& eZINI::instance();
 171  
 172  $relatedObjectArray =& $contentObject->relatedContentObjectArray( $EditVersion );
 173  
 174  
 175  if ( $assignment )
 176  {
 177      $parentNodeObject =& $assignment->attribute( 'parent_node_obj' );
 178  }
 179  
 180  $navigationPartIdentifier = false;
 181  if ( $sectionID !== false )
 182  {
 183      $designKeys[] = array( 'section', $sectionID ); // Section ID
 184      include_once ( 'kernel/classes/ezsection.php' );
 185      eZSection::setGlobalID( $sectionID );
 186  
 187      $section = eZSection::fetch( $sectionID );
 188      if ( $section )
 189          $navigationPartIdentifier = $section->attribute( 'navigation_part_identifier' );
 190  }
 191  $designKeys[] = array( 'navigation_part_identifier', $navigationPartIdentifier );
 192  
 193  $contentObject->setAttribute( 'current_version', $EditVersion );
 194  
 195  $class = eZContentClass::fetch( $contentObject->attribute( 'contentclass_id' ) );
 196  $objectName = $class->contentObjectName( $contentObject );
 197  $contentObject->setCachedName( $objectName );
 198  $contentObject->ContentObjectAttributeArray;
 199  if ( $assignment )
 200      $assignment->setName( $objectName );
 201  
 202  
 203  $path = array();
 204  $pathString = '';
 205  $pathIdentificationString = '';
 206  $requestedURIString = '';
 207  $depth = 2;
 208  if ( isset( $parentNodeObject ) && is_object( $parentNodeObject ) )
 209  {
 210      $pathString = $parentNodeObject->attribute( 'path_string' ) . $virtualNodeID . '/';
 211      $pathIdentificationString = $parentNodeObject->attribute( 'path_identification_string' ); //TODO add current node ident string.
 212      $depth = $parentNodeObject->attribute( 'depth' ) + 1;
 213      $requestedURIString = $parentNodeObject->attribute( 'url_alias' );
 214  }
 215  
 216  if ( isset( $node ) && is_object( $node ) )
 217  {
 218      $requestedURIString = $node->attribute( 'url_alias' );
 219  }
 220  
 221  $node = new eZContentObjectTreeNode();
 222  $node->setAttribute( 'contentobject_version', $EditVersion );
 223  $node->setAttribute( 'path_identification_string', $pathIdentificationString );
 224  $node->setAttribute( 'contentobject_id', $ObjectID );
 225  $node->setAttribute( 'parent_node_id', $parentNodeID );
 226  $node->setAttribute( 'main_node_id', $virtualNodeID );
 227  $node->setAttribute( 'path_string', $pathString );
 228  $node->setAttribute( 'depth', $depth );
 229  $node->setAttribute( 'node_id', $virtualNodeID );
 230  $node->setName( $objectName );
 231  
 232  $node->setContentObject( $contentObject );
 233  
 234  if ( $Params['SiteAccess'] )
 235  {
 236      $siteAccess = $Params['SiteAccess'];
 237  }
 238  else
 239  {
 240      include_once ( 'kernel/content/versionviewframe.php' );
 241      return;
 242  }
 243  
 244  $contentINI =& eZINI::instance( 'content.ini' );
 245  if ( !$siteAccess )
 246  {
 247      if ( $contentINI->hasVariable( 'VersionView', 'DefaultPreviewDesign' ) )
 248      {
 249          $siteAccess = $contentINI->variable( 'VersionView', 'DefaultPreviewDesign' );
 250      }
 251      else
 252      {
 253          $siteAccess = eZTemplateDesignResource::designSetting( 'site' );
 254      }
 255  }
 256  
 257  $GLOBALS['eZCurrentAccess']['name'] = $siteAccess;
 258  changeAccess( array( 'name' => $siteAccess ) );
 259  
 260  if ( $GLOBALS['eZCurrentAccess']['type'] == EZ_ACCESS_TYPE_URI )
 261  {
 262      eZSys::clearAccessPath();
 263      eZSys::addAccessPath( $siteAccess );
 264  }
 265  
 266  // Load the siteaccess extensions
 267  eZExtension::activateExtensions( 'access' );
 268  
 269  // Change content object default language
 270  $GLOBALS['eZContentObjectDefaultLanguage'] = $LanguageCode;
 271  eZContentObject::clearCache();
 272  
 273  eZContentLanguage::expireCache();
 274  
 275  $Module->setTitle( 'View ' . $class->attribute( 'name' ) . ' - ' . $contentObject->attribute( 'name' ) );
 276  
 277  $res =& eZTemplateDesignResource::instance();
 278  $res->setDesignSetting( $ini->variable( 'DesignSettings', 'SiteDesign' ), 'site' );
 279  $res->setOverrideAccess( $siteAccess );
 280  
 281  $designKeys = array( array( 'object', $contentObject->attribute( 'id' ) ), // Object ID
 282                       array( 'node', $virtualNodeID ), // Node id
 283                       array( 'class', $class->attribute( 'id' ) ), // Class ID
 284                       array( 'class_identifier', $class->attribute( 'identifier' ) ), // Class identifier
 285                       array( 'viewmode', 'full' ) );  // View mode
 286  
 287  if ( $assignment )
 288  {
 289      $designKeys[] = array( 'parent_node', $assignment->attribute( 'parent_node' ) );
 290      if ( get_class( $parentNodeObject ) == 'ezcontentobjecttreenode' )
 291          $designKeys[] = array( 'depth', $parentNodeObject->attribute( 'depth' ) + 1 );
 292  }
 293  
 294  
 295  $res->setKeys( $designKeys );
 296  
 297  include_once ( 'kernel/classes/eznodeviewfunctions.php' );
 298  
 299  unset( $contentObject );
 300  $contentObject =& $node->attribute( 'object' ); // do not remove &
 301  
 302  $Result =& eZNodeviewfunctions::generateNodeView( $tpl, $node, $contentObject, $LanguageCode, 'full', 0,
 303                                                   false, false, false );
 304  
 305  $Result['requested_uri_string'] = $requestedURIString;
 306  $Result['ui_context'] = 'view';
 307  
 308  ?>


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