| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZContentObjectTrashNode class 4 // 5 // Created on: <20-Sep-2006 00:00:00 rl> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezcontentobjecttrashnode.php 30 */ 31 32 /*! 33 \class eZContentObjectTrashNode ezcontentobjecttrashnode.php 34 \brief The class eZContentObjectTrashNode 35 */ 36 37 include_once ( "kernel/classes/ezcontentobjecttreenode.php" ); 38 39 //class eZContentObjectTrashNode extends eZPersistentObject 40 class eZContentObjectTrashNode extends eZContentObjectTreeNode 41 { 42 /*! 43 Constructor 44 */ 45 function eZContentObjectTrashNode( $row = array() ) 46 { 47 $this->eZPersistentObject( $row ); 48 } 49 50 function definition() 51 { 52 return array( 'fields' => array( 'node_id' => array( 'name' => 'NodeID', 53 'datatype' => 'integer', 54 'default' => 0, 55 'required' => true ), 56 'parent_node_id' => array( 'name' => 'ParentNodeID', 57 'datatype' => 'integer', 58 'default' => 0, 59 'required' => true ), 60 'main_node_id' => array( 'name' => 'MainNodeID', 61 'datatype' => 'integer', 62 'default' => 0, 63 'required' => true ), 64 'contentobject_id' => array( 'name' => 'ContentObjectID', 65 'datatype' => 'integer', 66 'default' => 0, 67 'required' => true, 68 'foreign_class' => 'eZContentObject', 69 'foreign_attribute' => 'id', 70 'multiplicity' => '1..*' ), 71 'contentobject_version' => array( 'name' => 'ContentObjectVersion', 72 'datatype' => 'integer', 73 'default' => 0, 74 'required' => true ), 75 'depth' => array( 'name' => 'Depth', 76 'datatype' => 'integer', 77 'default' => 0, 78 'required' => true ), 79 'sort_field' => array( 'name' => 'SortField', 80 'datatype' => 'integer', 81 'default' => 1, 82 'required' => true ), 83 'sort_order' => array( 'name' => 'SortOrder', 84 'datatype' => 'integer', 85 'default' => 1, 86 'required' => true ), 87 'priority' => array( 'name' => 'Priority', 88 'datatype' => 'integer', 89 'default' => 0, 90 'required' => true ), 91 'modified_subnode' => array( 'name' => 'ModifiedSubNode', 92 'datatype' => 'integer', 93 'default' => 0, 94 'required' => true ), 95 'path_string' => array( 'name' => 'PathString', 96 'datatype' => 'string', 97 'default' => '', 98 'required' => true ), 99 'path_identification_string' => array( 'name' => 'PathIdentificationString', 100 'datatype' => 'text', 101 'default' => '', 102 'required' => true ), 103 'remote_id' => array( 'name' => 'RemoteID', 104 'datatype' => 'string', 105 'default' => '', 106 'required' => true ), 107 'is_hidden' => array( 'name' => 'IsHidden', 108 'datatype' => 'integer', 109 'default' => 0, 110 'required' => true ), 111 'is_invisible' => array( 'name' => 'IsInvisible', 112 'datatype' => 'integer', 113 'default' => 0, 114 'required' => true ) 115 ), 116 117 'keys' => array( 'node_id' ), 118 'function_attributes' => array( // functional attributes derived from ezcontentobjecttreenode 119 'name' => 'getName', 120 'data_map' => 'dataMap', 121 'object' => 'object', 122 'contentobject_version_object' => 'contentObjectVersionObject', 123 'sort_array' => 'sortArray', 124 'can_read' => 'canRead', 125 'can_create' => 'canCreate', 126 'can_edit' => 'canEdit', 127 'can_remove' => 'canRemove', 128 'creator' => 'creator', 129 'path_array' => 'pathArray', 130 'parent' => 'fetchParent', 131 'class_identifier' => 'classIdentifier', 132 'class_name' => 'className', 133 // new functional attributes 134 'original_parent' => 'originalParent', 135 'original_parent_path_id_string' => 'originalParentPathIdentificationString' 136 ), 137 'class_name' => 'eZContentObjectTrashNode', 138 'name' => 'ezcontentobject_trash' ); 139 } 140 141 142 function createFromNode( $node ) 143 { 144 $row = array( 'node_id' => $node->attribute( 'node_id' ), 145 'parent_node_id' => $node->attribute( 'parent_node_id' ), 146 'main_node_id' => $node->attribute( 'main_node_id' ), 147 'contentobject_id' => $node->attribute( 'contentobject_id' ), 148 'contentobject_version' => $node->attribute( 'contentobject_version' ), 149 'contentobject_is_published' => $node->attribute( 'contentobject_is_published' ), 150 'depth' => $node->attribute( 'depth' ), 151 'sort_field' => $node->attribute( 'sort_field' ), 152 'sort_order' => $node->attribute( 'sort_order' ), 153 'priority' => $node->attribute( 'priority' ), 154 'modified_subnode' => $node->attribute( 'modified_subnode' ), 155 'path_string' => $node->attribute( 'path_string' ), 156 'path_identification_string' => $node->attribute( 'path_identification_string' ), 157 'remote_id' => $node->attribute( 'remote_id' ), 158 'is_hidden' => $node->attribute( 'is_hidden' ), 159 'is_invisible' => $node->attribute( 'is_invisible' ) ); 160 161 $trashNode = new eZContentObjectTrashNode( $row ); 162 return $trashNode; 163 } 164 165 function storeToTrash() 166 { 167 $this->store(); 168 } 169 170 function purgeForObject( $contentObjectID ) 171 { 172 if ( !is_numeric( $contentObjectID ) ) 173 return false; 174 $db =& eZDB::instance(); 175 $db->begin(); 176 $db->query( "DELETE FROM ezcontentobject_trash WHERE contentobject_id='$contentObjectID'" ); 177 $db->commit(); 178 } 179 180 function fetchListForObject( $objectID, $asObject = true, $offset = false, $limit = false ) 181 { 182 return false; 183 } 184 185 /* 186 Analog of eZContentObjectTreeNode::subTree(Count)() method, see it for extending this method 187 */ 188 function &trashList( $params = false, $asCount = false ) 189 { 190 if ( $params === false ) 191 { 192 $params = array( 'Offset' => false, 193 'Limit' => false, 194 'SortBy' => false, 195 'AttributeFilter' => false, 196 ); 197 } 198 199 $offset = ( isset( $params['Offset'] ) && is_numeric( $params['Offset'] ) ) ? $params['Offset'] : false; 200 $limit = ( isset( $params['Limit'] ) && is_numeric( $params['Limit'] ) ) ? $params['Limit'] : false; 201 $asObject = ( isset( $params['AsObject'] ) ) ? $params['AsObject'] : true; 202 $objectNameFilter = ( isset( $params['ObjectNameFilter'] ) ) ? $params['ObjectNameFilter'] : false; 203 204 if ( $asCount ) 205 { 206 $sqlSorting = ''; 207 } 208 else 209 { 210 // default sorting by the object name, but it probably should be optional in future 211 $params[ 'SortBy' ] = array( array( 'name' ) ); 212 $sortingInfo = eZContentObjectTreeNode::createSortingSQLStrings( $params['SortBy'], 'ezcot' ); 213 if ( $sortingInfo['sortingFields'] ) 214 $sqlSorting = " ORDER BY $sortingInfo[sortingFields]"; 215 else 216 $sqlSorting = ''; 217 } 218 $useVersionName = true; 219 $versionNameTables = eZContentObjectTreeNode::createVersionNameTablesSQLString ( $useVersionName ); 220 $versionNameTargets = eZContentObjectTreeNode::createVersionNameTargetsSQLString( $useVersionName ); 221 $versionNameJoins = eZContentObjectTreeNode::createVersionNameJoinsSQLString ( $useVersionName, false, false, false, 'ezcot' ); 222 223 $languageFilter = ' AND ' . eZContentLanguage::languagesSQLFilter( 'ezcontentobject' ); 224 225 $objectNameFilterSQL = eZContentObjectTreeNode::createObjectNameFilterConditionSQLString( $objectNameFilter ); 226 227 $limitation = ( isset( $params['Limitation'] ) && is_array( $params['Limitation'] ) ) ? $params['Limitation']: false; 228 $limitationList = eZContentObjectTreeNode::getLimitationList( $limitation ); 229 $sqlPermissionChecking = eZContentObjectTreeNode::createPermissionCheckingSQL( $limitationList, 'ezcontentobject_trash', 'ezcot' ); 230 231 if ( $asCount ) 232 { 233 $query = "SELECT count(*) as count \n"; 234 } 235 else 236 { 237 $query = "SELECT 238 ezcontentobject.*, 239 ezcot.*, 240 ezcontentclass.serialized_name_list as class_serialized_name_list, 241 ezcontentclass.identifier as class_identifier 242 $versionNameTargets \n"; 243 } 244 $query .= "FROM 245 ezcontentobject_trash AS ezcot, 246 ezcontentobject, 247 ezcontentclass 248 $versionNameTables 249 $sqlPermissionChecking[from] 250 WHERE 251 ezcontentclass.version=0 AND 252 ezcot.contentobject_id = ezcontentobject.id AND 253 ezcontentclass.id = ezcontentobject.contentclass_id AND 254 $versionNameJoins 255 $sqlPermissionChecking[where] 256 $objectNameFilterSQL 257 $languageFilter 258 $sqlSorting 259 "; 260 261 $db =& eZDB::instance(); 262 if ( !$offset && !$limit ) 263 $trashRowsArray = $db->arrayQuery( $query ); 264 else 265 $trashRowsArray = $db->arrayQuery( $query, array( 'offset' => $offset, 266 'limit' => $limit ) ); 267 if ( $asCount ) 268 { 269 return $trashRowsArray[0]['count']; 270 } 271 else if ( $asObject ) 272 { 273 $retTrashNodes = array(); 274 foreach ( array_keys( $trashRowsArray ) as $key ) 275 { 276 $trashRow =& $trashRowsArray[ $key ]; 277 $retTrashNodes[] = new eZContentObjectTrashNode( $trashRow ); 278 } 279 return $retTrashNodes; 280 } 281 else 282 { 283 return $trashRowsArray; 284 } 285 } 286 287 function trashListCount( $params = false ) 288 { 289 return eZContentObjectTrashNode::trashList( $params, true ); 290 } 291 292 function &originalParent() 293 { 294 $parent = $this->fetch( $this->attribute( 'parent_node_id' ) ); 295 $thisPathArray = $this->attribute( 'path_array' ); 296 297 if ( is_object( $parent ) and count( $thisPathArray ) > 0 ) 298 { 299 $realParentPathArray = $parent->attribute( 'path_array' ); 300 $realParentPath = implode( '/', $realParentPathArray ); 301 302 $thisParentPathArray = array_pop( $thisPathArray ); 303 $thisParentPath = implode( '/', $realParentPathArray ); 304 305 if ( $thisParentPath == $realParentPath ) 306 { 307 // original parent exists at the same placement 308 return $parent; 309 } 310 } 311 // original parent was moved or does not exist anymore 312 $ret = null; 313 return $ret; 314 } 315 316 function &originalParentPathIdentificationString() 317 { 318 $originalParent =& $this->originalParent(); 319 if ( $originalParent ) 320 { 321 return $originalParent->attribute( 'path_identification_string' ); 322 } 323 // original parent was moved or does not exist, return original parent path 324 $path = $this->attribute( 'path_identification_string' ); 325 $path = substr( $path, 0, strrpos( $path, '/') ); 326 return $path; 327 } 328 } 329 330 ?>
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 |