| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // 4 // Created on: <08-Nov-2002 16:02:26 wy> 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 ( "kernel/classes/ezcontentobject.php" ); 29 include_once ( "kernel/classes/ezcontentobjecttreenode.php" ); 30 include_once ( "lib/ezutils/classes/ezhttptool.php" ); 31 include_once ( "kernel/common/template.php" ); 32 33 $Module =& $Params["Module"]; 34 35 $http =& eZHTTPTool::instance(); 36 37 $viewMode = $http->sessionVariable( "CurrentViewMode" ); 38 $deleteIDArray = $http->sessionVariable( "DeleteIDArray" ); 39 $contentObjectID = $http->sessionVariable( 'ContentObjectID' ); 40 $contentNodeID = $http->sessionVariable( 'ContentNodeID' ); 41 42 $requestedURI = ''; 43 $userRedirectURI = ''; 44 $requestedURI =& $GLOBALS['eZRequestedURI']; 45 if ( get_class( $requestedURI ) == 'ezuri' ) 46 { 47 $userRedirectURI = $requestedURI->uriString( true ); 48 } 49 $http->setSessionVariable( 'userRedirectURIReverseRelatedList', $userRedirectURI ); 50 51 if ( $http->hasSessionVariable( 'ContentLanguage' ) ) 52 { 53 $contentLanguage = $http->sessionVariable( 'ContentLanguage' ); 54 } 55 else 56 { 57 $contentLanguage = false; 58 } 59 if ( count( $deleteIDArray ) <= 0 ) 60 return $Module->redirectToView( 'view', array( $viewMode, $contentNodeID, $contentLanguage ) ); 61 62 // Cleanup and redirect back when cancel is clicked 63 if ( $http->hasPostVariable( "CancelButton" ) ) 64 { 65 $http->removeSessionVariable( "CurrentViewMode" ); 66 $http->removeSessionVariable( "DeleteIDArray" ); 67 $http->removeSessionVariable( 'ContentObjectID' ); 68 $http->removeSessionVariable( 'ContentNodeID' ); 69 $http->removeSessionVariable( 'userRedirectURIReverseRelatedList' ); 70 return $Module->redirectToView( 'view', array( $viewMode, $contentNodeID, $contentLanguage ) ); 71 } 72 73 $contentINI =& eZINI::instance( 'content.ini' ); 74 75 $RemoveAction = $contentINI->hasVariable( 'RemoveSettings', 'DefaultRemoveAction' ) ? 76 $contentINI->variable( 'RemoveSettings', 'DefaultRemoveAction' ) : 'trash'; 77 if ( $RemoveAction != 'trash' and $RemoveAction != 'delete' ) 78 $RemoveAction = 'trash'; 79 80 $moveToTrash = ( $RemoveAction == 'trash' ) ? true : false; 81 if ( $http->hasPostVariable( 'SupportsMoveToTrash' ) ) 82 { 83 if ( $http->hasPostVariable( 'MoveToTrash' ) ) 84 $moveToTrash = $http->postVariable( 'MoveToTrash' ) ? true : false; 85 else 86 $moveToTrash = false; 87 } 88 89 $hideRemoveConfirm = $contentINI->hasVariable( 'RemoveSettings', 'HideRemoveConfirmation' ) ? 90 (( $contentINI->variable( 'RemoveSettings', 'HideRemoveConfirmation' ) == 'true' ) ? true : false ) : false; 91 if ( $http->hasPostVariable( 'HideRemoveConfirmation' ) ) 92 $hideRemoveConfirm = $http->postVariable( 'HideRemoveConfirmation' ) ? true : false; 93 94 if ( $http->hasPostVariable( "ConfirmButton" ) or 95 $hideRemoveConfirm ) 96 { 97 eZContentObjectTreeNode::removeSubtrees( $deleteIDArray, $moveToTrash ); 98 return $Module->redirectToView( 'view', array( $viewMode, $contentNodeID, $contentLanguage ) ); 99 } 100 101 $showCheck = $contentINI->hasVariable( 'RemoveSettings', 'ShowRemoveToTrashCheck' ) ? 102 (( $contentINI->variable( 'RemoveSettings', 'ShowRemoveToTrashCheck' ) == 'false' ) ? false : true ) : true; 103 104 $info = eZContentObjectTreeNode::subtreeRemovalInformation( $deleteIDArray ); 105 $deleteResult = $info['delete_list']; 106 $moveToTrashAllowed = $info['move_to_trash']; 107 $totalChildCount = $info['total_child_count']; 108 $exceededLimit = false; 109 110 // Check if number of nodes being removed not more then MaxNodesRemoveSubtree setting. 111 $maxNodesRemoveSubtree = $contentINI->hasVariable( 'RemoveSettings', 'MaxNodesRemoveSubtree' ) ? 112 $contentINI->variable( 'RemoveSettings', 'MaxNodesRemoveSubtree' ) : 100; 113 114 $deleteItemsExist = true; // If false, we should disable 'OK' button if count of each deletion items more then MaxNodesRemoveSubtree setting. 115 116 foreach ( array_keys( $deleteResult ) as $removeItemKey ) 117 { 118 $removeItem =& $deleteResult[$removeItemKey]; 119 if ( $removeItem['child_count'] > $maxNodesRemoveSubtree ) 120 { 121 $removeItem['exceeded_limit_of_subitems'] = true; 122 $exceededLimit = true; 123 $nodeObj = $removeItem['node']; 124 if ( !$nodeObj ) 125 continue; 126 127 $nodeID = $nodeObj->attribute( 'node_id' ); 128 $deleteIDArrayNew = array(); 129 foreach ( $deleteIDArray as $deleteID ) 130 { 131 if ( $deleteID != $nodeID ) 132 $deleteIDArrayNew[] = $deleteID; 133 } 134 $deleteItemsExist = count( $deleteIDArrayNew ) != 0; 135 $http->setSessionVariable( "DeleteIDArray", $deleteIDArrayNew ); 136 } 137 } 138 139 // We check if we can remove the nodes without confirmation 140 // to do this the following must be true: 141 // - The total child count must be zero 142 // - There must be no object removal (i.e. it is the only node for the object) 143 if ( $totalChildCount == 0 ) 144 { 145 $canRemove = true; 146 foreach ( $deleteResult as $item ) 147 { 148 if ( $item['object_node_count'] <= 1 ) 149 { 150 $canRemove = false; 151 break; 152 } 153 } 154 if ( $canRemove ) 155 { 156 eZContentObjectTreeNode::removeSubtrees( $deleteIDArray, $moveToTrash ); 157 return $Module->redirectToView( 'view', array( $viewMode, $contentNodeID, $contentLanguage ) ); 158 } 159 } 160 161 $tpl =& templateInit(); 162 163 $tpl->setVariable( 'reverse_related' , $info['reverse_related_count'] ); 164 $tpl->setVariable( 'module' , $Module ); 165 $tpl->setVariable( 'moveToTrashAllowed' , $moveToTrashAllowed ); // Backwards compatability 166 $tpl->setVariable( 'ChildObjectsCount' , $totalChildCount ); // Backwards compatability 167 $tpl->setVariable( 'DeleteResult' , $deleteResult ); // Backwards compatability 168 $tpl->setVariable( 'move_to_trash_allowed' , ( $moveToTrashAllowed and $showCheck ) ); 169 $tpl->setVariable( 'remove_list' , $deleteResult ); 170 $tpl->setVariable( 'total_child_count' , $totalChildCount ); 171 $tpl->setVariable( 'remove_info' , $info ); 172 $tpl->setVariable( 'exceeded_limit' , $exceededLimit ); 173 $tpl->setVariable( 'delete_items_exist' , $deleteItemsExist ); 174 $tpl->setVariable( 'move_to_trash' , $moveToTrash ); 175 176 $Result = array(); 177 $Result['content'] =& $tpl->fetch( "design:node/removeobject.tpl" ); 178 $Result['path'] = array( array( 'url' => false, 179 'text' => ezi18n( 'kernel/content', 'Remove object' ) ) ); 180 ?>
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 |