[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <23-Sen-2005 13:42:58 vd> 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 include_once ( "kernel/classes/ezcontentobject.php" ); 28 include_once ( "lib/ezutils/classes/ezhttptool.php" ); 29 include_once ( "kernel/common/template.php" ); 30 include_once ( 'kernel/classes/ezpreferences.php' ); 31 32 $http =& eZHTTPTool::instance(); 33 34 $Module =& $Params['Module']; 35 $NodeID =& $Params['NodeID']; 36 37 if ( $http->hasPostVariable( "BackButton" ) ) 38 { 39 $userRedirectURI = $http->sessionVariable( 'userRedirectURIReverseRelatedList' ); 40 $http->removeSessionVariable( 'userRedirectURIReverseRelatedList' ); 41 return $Module->redirectTo( $userRedirectURI ); 42 } 43 44 if ( !isset( $Offset ) ) 45 $Offset = false; 46 47 $children_list_limit = eZPreferences::value( "reverse_children_list_limit" ); 48 49 switch ( $children_list_limit ) 50 { 51 case 0: 52 $pageLimit = 10; 53 break; 54 case 1: 55 $pageLimit = 10; 56 break; 57 case 2: 58 $pageLimit = 25; 59 break; 60 case 3: 61 $pageLimit = 50; 62 break; 63 default: 64 $pageLimit = 10; 65 break; 66 } 67 68 if ( $Offset < $pageLimit ) 69 $Offset = 0; 70 71 $requestedURI = ''; 72 $userRedirectURI = ''; 73 $requestedURI =& $GLOBALS['eZRequestedURI']; 74 if ( get_class( $requestedURI ) == 'ezuri' ) 75 { 76 $userRedirectURI = $requestedURI->uriString( true ); 77 } 78 $http->setSessionVariable( 'userRedirectURIReverseObjects', $userRedirectURI ); 79 80 $db =& eZDB::instance(); 81 82 $deleteIDArray = array(); 83 84 $contentObjectTreeNode = eZContentObjectTreeNode::fetch( $NodeID ); 85 if ( !$contentObjectTreeNode ) 86 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 87 88 $path_strings = '( '; 89 $path_strings2 = '( '; 90 $except_path_strings = ''; 91 $i = 0; 92 93 // Create WHERE section 94 $path_strings .= "tree.path_string like '$contentObjectTreeNode->PathString%'"; 95 $path_strings2 .= "tree2.path_string like '$contentObjectTreeNode->PathString%'"; 96 97 $path_strings_where = $path_strings2." ) "; 98 $path_strings .= " )"; 99 100 // Select all elements having reverse relations. And ignore those items that don't relate to objects other than being removed. 101 $rows = $db->arrayQuery( "SELECT DISTINCT( tree.node_id ) 102 FROM ezcontentobject_tree tree, ezcontentobject obj, 103 ezcontentobject_link link LEFT JOIN ezcontentobject_tree tree2 104 ON link.from_contentobject_id = tree2.contentobject_id 105 WHERE $path_strings 106 and link.to_contentobject_id = tree.contentobject_id 107 and obj.id = link.from_contentobject_id 108 and obj.current_version = link.from_contentobject_version 109 and not ( $path_strings_where ) 110 111 ", array( 'limit' => $pageLimit, 112 'offset' => $Offset ) ); 113 // Total count of sub items 114 $countOfItems = $db->arrayQuery( "SELECT COUNT( DISTINCT( tree.node_id ) ) count 115 116 FROM ezcontentobject_tree tree, ezcontentobject obj, 117 ezcontentobject_link link LEFT JOIN ezcontentobject_tree tree2 118 ON link.from_contentobject_id = tree2.contentobject_id 119 WHERE $path_strings 120 and link.to_contentobject_id = tree.contentobject_id 121 and obj.id = link.from_contentobject_id 122 and obj.current_version = link.from_contentobject_version 123 and not ( $path_strings_where ) 124 " ); 125 $rowsCount = 0; 126 if ( isset( $countOfItems[0] ) ) 127 $rowsCount = $countOfItems[0]['count']; 128 129 $childrenList = array(); // Contains children of Nodes from $deleteIDArray 130 131 // Fetch number of reverse related objects for each of the items being removed. 132 $reverselistCountChildrenArray = array(); 133 foreach( $rows as $child ) 134 { 135 $contentObject =& eZContentObject::fetchByNodeID( $child['node_id'] ); 136 $contentObject_ID = $contentObject->attribute('id'); 137 $reverseObjectCount = $contentObject->reverseRelatedObjectCount( false, false, false, 1 ); 138 $reverselistCountChildrenArray[$contentObject_ID] = $reverseObjectCount; 139 $childrenList[] = eZContentObjectTreeNode::fetch( $child['node_id'] ); 140 } 141 142 $contentObjectName = $contentObjectTreeNode->attribute('name'); 143 $viewParameters = array( 'offset' => $Offset ); 144 145 $tpl =& templateInit(); 146 147 $tpl->setVariable( 'children_list', $childrenList ); 148 $tpl->setVariable( 'view_parameters', $viewParameters ); 149 $tpl->setVariable( 'children_count', $rowsCount ); 150 $tpl->setVariable( 'content_object_name', $contentObjectName ); 151 $tpl->setVariable( 'reverse_list_count_children_array', $reverselistCountChildrenArray ); 152 $tpl->setVariable( 'reverse_list_children_count', count( $reverselistCountChildrenArray ) ); 153 $tpl->setVariable( 'node_id', $NodeID ); 154 155 $Result = array(); 156 157 $contentObject =& $contentObjectTreeNode->attribute( 'object' ); 158 if ( $contentObject ) 159 { 160 $section = eZSection::fetch( $contentObject->attribute( 'section_id' ) ); 161 if ( $section ) 162 { 163 $navigationPartIdentifier = $section->attribute( 'navigation_part_identifier' ); 164 if ( $navigationPartIdentifier ) 165 { 166 $Result['navigation_part'] = $navigationPartIdentifier; 167 } 168 } 169 } 170 171 $Result['content'] =& $tpl->fetch( "design:content/reverserelatedlist.tpl" ); 172 $Result['path'] = array( array( 'url' => false, 173 'text' => ezi18n( 'kernel/content', "\"$contentObjectName\": Sub items that are used by other objects" ) ) ); 174 175 ?>
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 |