| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // 4 // <creation-tag> 5 // 6 // SOFTWARE NAME: eZ publish 7 // SOFTWARE RELEASE: 3.9.0 8 // BUILD VERSION: 17785 9 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 10 // SOFTWARE LICENSE: GNU General Public License v2.0 11 // NOTICE: > 12 // This program is free software; you can redistribute it and/or 13 // modify it under the terms of version 2.0 of the GNU General 14 // Public License as published by the Free Software Foundation. 15 // 16 // This program is distributed in the hope that it will be useful, 17 // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 // GNU General Public License for more details. 20 // 21 // You should have received a copy of version 2.0 of the GNU General 22 // Public License along with this program; if not, write to the Free 23 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 24 // MA 02110-1301, USA. 25 // 26 // 27 28 include_once ( 'lib/ezutils/classes/ezhttptool.php' ); 29 include_once ( 'kernel/classes/ezcontentobject.php' ); 30 include_once ( 'kernel/common/template.php' ); 31 include_once ( 'lib/ezdiff/classes/ezdiff.php' ); 32 include_once ( 'lib/ezutils/classes/ezdebug.php' ); 33 34 $Module =& $Params['Module']; 35 $objectID = $Params['ObjectID']; 36 37 $Offset = $Params['Offset']; 38 39 $viewParameters = array( 'offset' => $Offset ); 40 41 $contentObject = eZContentObject::fetch( $objectID ); 42 43 if ( !$contentObject ) 44 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 45 46 $classID = $contentObject->attribute( 'contentclass_id' ); 47 $class = eZContentClass::fetch( $classID ); 48 49 if ( !$contentObject->attribute( 'can_read' ) ) 50 return $Module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel' ); 51 52 if ( !$contentObject->attribute( 'can_diff' ) ) 53 return $Module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel' ); 54 55 $http =& eZHTTPTool::instance(); 56 $tpl =& templateInit(); 57 58 $res =& eZTemplateDesignResource::instance(); 59 $res->setKeys( array( array( 'object', $contentObject->attribute( 'id' ) ), 60 array( 'class', $class->attribute( 'id' ) ), 61 array( 'class_identifier', $class->attribute( 'identifier' ) ) ) ); 62 63 $tpl->setVariable( 'object', $contentObject ); 64 $tpl->setVariable( 'view_parameters', $viewParameters ); 65 $tpl->setVariable( 'module', $Module ); 66 67 //Set default values 68 $previousVersion = 1; 69 $newestVersion = 1; 70 71 //By default, set preselect the previous and most recent version for diffing 72 if ( count( $contentObject->versions() ) > 1 ) 73 { 74 $versionArray = $contentObject->versions( false ); 75 $selectableVersions = array(); 76 foreach( $versionArray as $versionItem ) 77 { 78 //Only return version numbers of archived or published items 79 if ( in_array( $versionItem['status'], array( 0, 1, 3 ) ) ) 80 { 81 $selectableVersions[] = $versionItem['version']; 82 } 83 } 84 $newestVersion = array_pop( $selectableVersions ); 85 $previousVersion = array_pop( $selectableVersions ); 86 } 87 88 $tpl->setVariable( 'selectOldVersion', $previousVersion ); 89 $tpl->setVariable( 'selectNewVersion', $newestVersion ); 90 91 $diff = array(); 92 93 if ( $http->hasPostVariable( 'FromVersion' ) && $http->hasPostVariable( 'ToVersion' ) ) 94 { 95 $lang = false; 96 if ( $http->hasPostVariable( 'Language' ) ) 97 { 98 $lang = $http->postVariable( 'Language' ); 99 } 100 $oldVersion = $http->postVariable( 'FromVersion' ); 101 $newVersion = $http->postVariable( 'ToVersion' ); 102 103 if ( is_numeric( $oldVersion ) && is_numeric( $newVersion ) ) 104 { 105 $oldObject = $contentObject->version( $oldVersion ); 106 $newObject = $contentObject->version( $newVersion ); 107 108 if ( $lang ) 109 { 110 $initLang = $contentObject->initialLanguageCode(); 111 $oldAttributes = $contentObject->fetchDataMap( $oldVersion, $lang ); 112 if ( !$oldAttributes ) 113 { 114 $oldAttributes = $contentObject->fetchDataMap( $oldVersion, $initLang ); 115 } 116 $newAttributes = $contentObject->fetchDataMap( $newVersion, $lang ); 117 if ( !$newAttributes ) 118 { 119 $newAttributes = $contentObject->fetchDataMap( $newVersion, $initLang ); 120 } 121 122 } 123 else 124 { 125 $oldAttributes = $oldObject->dataMap(); 126 $newAttributes = $newObject->dataMap(); 127 } 128 129 $extraOptions = false; 130 if ( $http->hasPostVariable( 'ExtraOptions' ) ) 131 { 132 $extraOptions = $http->postVariable( 'ExtraOptions' ); 133 } 134 135 foreach ( $oldAttributes as $attribute ) 136 { 137 $newAttr = $newAttributes[$attribute->attribute( 'contentclass_attribute_identifier' )]; 138 $contentClassAttr = $newAttr->attribute( 'contentclass_attribute' ); 139 $diff[$contentClassAttr->attribute( 'id' )] = $contentClassAttr->diff( $attribute, $newAttr, $extraOptions ); 140 } 141 142 $tpl->setVariable( 'object', $contentObject ); 143 $tpl->setVariable( 'oldVersion', $oldVersion ); 144 $tpl->setVariable( 'oldVersionObject', $contentObject->version( $oldVersion ) ); 145 146 $tpl->setVariable( 'newVersion', $newVersion ); 147 $tpl->setVariable( 'newVersionObject', $contentObject->version( $newVersion ) ); 148 $tpl->setVariable( 'diff', $diff ); 149 } 150 } 151 152 eZDebug::writeNotice( 'The diff view has been deprecated, please use the /content/history/ view instead' ); 153 154 $Result = array(); 155 156 $section = eZSection::fetch( $contentObject->attribute( 'section_id' ) ); 157 if ( $section ) 158 { 159 $navigationPartIdentifier = $section->attribute( 'navigation_part_identifier' ); 160 if ( $navigationPartIdentifier ) 161 { 162 $Result['navigation_part'] = $navigationPartIdentifier; 163 } 164 } 165 166 $Result['content'] =& $tpl->fetch( "design:content/diff.tpl" ); 167 $Result['path'] = array( array( 'url' => false, 168 'text' => ezi18n( 'kernel/content', 'Differences' ) ) ); 169 170 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |