|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZContentObjectEditHandler class 00004 // 00005 // Created on: <20-Dec-2005 14:19:36 hovik> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ Publish 00009 // SOFTWARE RELEASE: 4.0.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00011 // SOFTWARE LICENSE: GNU General Public License v2.0 00012 // NOTICE: > 00013 // This program is free software; you can redistribute it and/or 00014 // modify it under the terms of version 2.0 of the GNU General 00015 // Public License as published by the Free Software Foundation. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of version 2.0 of the GNU General 00023 // Public License along with this program; if not, write to the Free 00024 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00025 // MA 02110-1301, USA. 00026 // 00027 // 00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00029 // 00030 00031 /*! \file ezcontentobjectedithandler.php 00032 */ 00033 00034 /*! 00035 \class eZContentObjectEditHandler ezcontentobjectedithandler.php 00036 \brief The class eZContentObjectEditHandler provides a framework for handling 00037 content/edit view specific things in extensions. 00038 00039 */ 00040 00041 class eZContentObjectEditHandler 00042 { 00043 /*! 00044 Constructor 00045 */ 00046 function eZContentObjectEditHandler() 00047 { 00048 } 00049 00050 /*! 00051 \abstract 00052 00053 Override this function in the extension to handle edit input parameters. 00054 */ 00055 function fetchInput( $http, &$module, &$class, $object, &$version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage ) 00056 { 00057 } 00058 00059 /*! 00060 \abstract 00061 00062 Return list of HTTP postparameters which should trigger store action. 00063 */ 00064 static function storeActionList() 00065 { 00066 return array(); 00067 } 00068 00069 /*! 00070 \abstract 00071 00072 Do content object publish operations. 00073 */ 00074 function publish( $contentObjectID, $contentObjectVersion ) 00075 { 00076 } 00077 00078 /*! 00079 \static 00080 Initialize all extension input handler. 00081 */ 00082 static function initialize() 00083 { 00084 $contentINI = eZINI::instance( 'content.ini' ); 00085 foreach( array_unique( $contentINI->variable( 'EditSettings', 'ExtensionDirectories' ) ) as $extensionDirectory ) 00086 { 00087 $fileName = eZExtension::baseDirectory() . '/' . $extensionDirectory . '/content/' . $extensionDirectory . 'handler.php'; 00088 if ( file_exists( $fileName ) ) 00089 { 00090 include_once( $fileName ); 00091 $className = $extensionDirectory . 'Handler'; 00092 $storeActionList = call_user_func_array( array( $className, 'storeActionList' ), array() ); 00093 foreach( $storeActionList as $storeAction ) 00094 { 00095 eZContentObjectEditHandler::addStoreAction( $storeAction ); 00096 } 00097 } 00098 else 00099 { 00100 eZDebug::writeError( 'Cound not find content object edit handler ( defined in content.ini ) : ' . $fileName ); 00101 } 00102 } 00103 } 00104 00105 /*! 00106 \static 00107 Calls all extension object edit input handler, and executes this the fetchInput function 00108 */ 00109 static function executeInputHandlers( &$module, &$class, $object, &$version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage ) 00110 { 00111 $http = eZHTTPTool::instance(); 00112 $contentINI = eZINI::instance( 'content.ini' ); 00113 foreach( array_unique( $contentINI->variable( 'EditSettings', 'ExtensionDirectories' ) ) as $extensionDirectory ) 00114 { 00115 $fileName = eZExtension::baseDirectory() . '/' . $extensionDirectory . '/content/' . $extensionDirectory . 'handler.php'; 00116 if ( file_exists( $fileName ) ) 00117 { 00118 include_once( $fileName ); 00119 $className = $extensionDirectory . 'Handler'; 00120 $inputHandler = new $className(); 00121 call_user_func_array( array( $inputHandler, 'fetchInput' ), 00122 array( $http, &$module, &$class, $object, &$version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage ) ); 00123 } 00124 } 00125 } 00126 00127 /*! 00128 \static 00129 Calls all publish functions. 00130 */ 00131 static function executePublish( $contentObjectID, $contentObjectVersion ) 00132 { 00133 $contentINI = eZINI::instance( 'content.ini' ); 00134 foreach( array_unique( $contentINI->variable( 'EditSettings', 'ExtensionDirectories' ) ) as $extensionDirectory ) 00135 { 00136 $fileName = eZExtension::baseDirectory() . '/' . $extensionDirectory . '/content/' . $extensionDirectory . 'handler.php'; 00137 if ( file_exists( $fileName ) ) 00138 { 00139 include_once( $fileName ); 00140 $className = $extensionDirectory . 'Handler'; 00141 $inputHandler = new $className(); 00142 call_user_func_array( array( $inputHandler, 'publish' ), 00143 array( $contentObjectID, $contentObjectVersion ) ); 00144 } 00145 } 00146 } 00147 00148 /*! 00149 \static 00150 Set custom HTTP post parameters which should trigger store acrtions. 00151 00152 \param HTTP post parameter name 00153 */ 00154 static function addStoreAction( $name ) 00155 { 00156 if ( !isset( $GLOBALS['eZContentObjectEditHandler_StoreAction'] ) ) 00157 { 00158 $GLOBALS['eZContentObjectEditHandler_StoreAction'] = array(); 00159 } 00160 $GLOBALS['eZContentObjectEditHandler_StoreAction'][] = $name; 00161 } 00162 00163 /*! 00164 \static 00165 Check if any HTTP input trigger store action 00166 */ 00167 static function isStoreAction() 00168 { 00169 if ( !isset( $GLOBALS['eZContentObjectEditHandler_StoreAction'] ) ) 00170 return 0; 00171 return count( array_intersect( array_keys( $_POST ), $GLOBALS['eZContentObjectEditHandler_StoreAction'] ) ) > 0; 00172 } 00173 } 00174 00175 ?>