|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 00028 /** 00029 * @author Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces) 00030 * @package Workspaces 00031 * @subpackage ExtDirect 00032 */ 00033 class tx_Workspaces_ExtDirect_Server extends tx_Workspaces_ExtDirect_AbstractHandler { 00034 /** 00035 * Get List of workspace changes 00036 * 00037 * @param object $parameter 00038 * @return array $data 00039 */ 00040 public function getWorkspaceInfos($parameter) { 00041 // To avoid too much work we use -1 to indicate that every page is relevant 00042 $pageId = $parameter->id > 0 ? $parameter->id : -1; 00043 00044 $wslibObj = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces'); 00045 $versions = $wslibObj->selectVersionsInWorkspace($this->getCurrentWorkspace(), 0, -99, $pageId, $parameter->depth); 00046 00047 $workspacesService = t3lib_div::makeInstance('tx_Workspaces_Service_GridData'); 00048 $data = $workspacesService->generateGridListFromVersions($versions, $parameter, $this->getCurrentWorkspace()); 00049 return $data; 00050 } 00051 00052 /** 00053 * Get List of available workspace actions 00054 * 00055 * @param object $parameter 00056 * @return array $data 00057 */ 00058 public function getStageActions($parameter) { 00059 $currentWorkspace = $this->getCurrentWorkspace(); 00060 $stages = array(); 00061 if ($currentWorkspace != tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES) { 00062 $stagesService = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages'); 00063 $stages = $stagesService->getStagesForWSUser(); 00064 } 00065 00066 $data = array( 00067 'total' => count($stages), 00068 'data' => $stages 00069 ); 00070 return $data; 00071 } 00072 00073 /** 00074 * Fetch futher information to current selected worspace record. 00075 * 00076 * @param object $parameter 00077 * @return array $data 00078 */ 00079 public function getRowDetails($parameter) { 00080 global $TCA,$BE_USER; 00081 $diffReturnArray = array(); 00082 $liveReturnArray = array(); 00083 00084 $t3lib_diff = t3lib_div::makeInstance('t3lib_diff'); 00085 $stagesService = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages'); 00086 00087 $liveRecord = t3lib_BEfunc::getRecord($parameter->table, $parameter->t3ver_oid); 00088 $versionRecord = t3lib_BEfunc::getRecord($parameter->table, $parameter->uid); 00089 $icon_Live = t3lib_iconWorks::mapRecordTypeToSpriteIconClass($parameter->table, $liveRecord); 00090 $icon_Workspace = t3lib_iconWorks::mapRecordTypeToSpriteIconClass($parameter->table, $versionRecord); 00091 $stagePosition = $stagesService->getPositionOfCurrentStage($parameter->stage); 00092 00093 $fieldsOfRecords = array_keys($liveRecord); 00094 00095 // get field list from TCA configuration, if available 00096 if ($TCA[$parameter->table]) { 00097 if ($TCA[$parameter->table]['interface']['showRecordFieldList']) { 00098 $fieldsOfRecords = $TCA[$parameter->table]['interface']['showRecordFieldList']; 00099 $fieldsOfRecords = t3lib_div::trimExplode(',',$fieldsOfRecords,1); 00100 } 00101 } 00102 00103 foreach ($fieldsOfRecords as $fieldName) { 00104 // check for exclude fields 00105 if ($GLOBALS['BE_USER']->isAdmin() || ($TCA[$parameter->table]['columns'][$fieldName]['exclude'] == 0) || t3lib_div::inList($BE_USER->groupData['non_exclude_fields'],$parameter->table.':'.$fieldName)) { 00106 // call diff class only if there is a difference 00107 if (strcmp($liveRecord[$fieldName],$versionRecord[$fieldName]) !== 0) { 00108 // Select the human readable values before diff 00109 $liveRecord[$fieldName] = t3lib_BEfunc::getProcessedValue($parameter->table,$fieldName,$liveRecord[$fieldName],0,1); 00110 $versionRecord[$fieldName] = t3lib_BEfunc::getProcessedValue($parameter->table,$fieldName,$versionRecord[$fieldName],0,1); 00111 00112 $fieldTitle = $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($parameter->table, $fieldName)); 00113 00114 if ($TCA[$parameter->table]['columns'][$fieldName]['config']['type'] == 'group' && $TCA[$parameter->table]['columns'][$fieldName]['config']['internal_type'] == 'file') { 00115 $versionThumb = t3lib_BEfunc::thumbCode($versionRecord, $parameter->table, $fieldName, ''); 00116 $liveThumb = t3lib_BEfunc::thumbCode($liveRecord, $parameter->table, $fieldName, ''); 00117 00118 $diffReturnArray[] = array( 00119 'label' => $fieldTitle, 00120 'content' => $versionThumb 00121 ); 00122 $liveReturnArray[] = array( 00123 'label' => $fieldTitle, 00124 'content' => $liveThumb 00125 ); 00126 } else { 00127 $diffReturnArray[] = array( 00128 'label' => $fieldTitle, 00129 'content' => $t3lib_diff->makeDiffDisplay($liveRecord[$fieldName], $versionRecord[$fieldName]) // call diff class to get diff 00130 ); 00131 $liveReturnArray[] = array( 00132 'label' => $fieldTitle, 00133 'content' => $liveRecord[$fieldName] 00134 ); 00135 } 00136 } 00137 } 00138 } 00139 00140 $commentsForRecord = $this->getCommentsForRecord($parameter->uid, $parameter->table); 00141 00142 return array( 00143 'total' => 1, 00144 'data' => array( 00145 array( 00146 'diff' => $diffReturnArray, 00147 'live_record' => $liveReturnArray, 00148 'path_Live' => $parameter->path_Live, 00149 'label_Stage' => $parameter->label_Stage, 00150 'stage_position' => $stagePosition['position'], 00151 'stage_count' => $stagePosition['count'], 00152 'comments' => $commentsForRecord, 00153 'icon_Live' => $icon_Live, 00154 'icon_Workspace' => $icon_Workspace 00155 ) 00156 ) 00157 ); 00158 } 00159 00160 /** 00161 * Gets an array with all sys_log entries and their comments for the given record uid and table 00162 * 00163 * @param integer $uid uid of changed element to search for in log 00164 * @return string $table table name 00165 */ 00166 public function getCommentsForRecord($uid, $table) { 00167 $stagesService = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages'); 00168 $sysLogReturnArray = array(); 00169 00170 $sysLogRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 00171 'log_data,tstamp,userid', 00172 'sys_log', 00173 'action=6 and details_nr=30 00174 AND tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_log').' 00175 AND recuid='.intval($uid), 00176 '', 00177 'tstamp DESC' 00178 ); 00179 00180 foreach($sysLogRows as $sysLogRow) { 00181 $sysLogEntry = array(); 00182 $data = unserialize($sysLogRow['log_data']); 00183 $beUserRecord = t3lib_BEfunc::getRecord('be_users', $sysLogRow['userid']); 00184 00185 $sysLogEntry['stage_title'] = $stagesService->getStageTitle($data['stage']); 00186 $sysLogEntry['user_uid'] = $sysLogRow['userid']; 00187 $sysLogEntry['user_username'] = is_array($beUserRecord) ? $beUserRecord['username'] : ''; 00188 $sysLogEntry['tstamp'] = t3lib_BEfunc::datetime($sysLogRow['tstamp']); 00189 $sysLogEntry['user_comment'] = $data['comment']; 00190 00191 $sysLogReturnArray[] = $sysLogEntry; 00192 } 00193 00194 return $sysLogReturnArray; 00195 } 00196 } 00197 00198 00199 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/ExtDirect/Server.php'])) { 00200 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/ExtDirect/Server.php']); 00201 } 00202 ?>
1.8.0