Fixed Bug #8529: dam_ttcontent does not respect workspaces
authorIngo Renner <ingo.renner@typo3.org>
Tue, 30 Sep 2008 11:59:32 +0000 (11:59 +0000)
committerIngo Renner <ingo.renner@typo3.org>
Tue, 30 Sep 2008 11:59:32 +0000 (11:59 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/dam/dam_ttcontent/trunk@12467 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
class.tx_damttcontent_workspacediffview.php [new file with mode: 0644]
class.ux_tx_cms_layout.php
class.ux_tx_version_cm1.php [new file with mode: 0644]
class.ux_wslib_gui.php [new file with mode: 0644]
ext_conf_template.txt
ext_localconf.php
pi_cssstyledcontent/class.tx_damttcontent_pi1.php

index 811da5e..728b656 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-09-30  Ingo Renner  <ingo@typo3.org>
+
+       * Fixed Bug #8529: dam_ttcontent does not respect workspaces
+
 2007-10-17  Michael Stucki  <michael@typo3.org>
 
        * Takeover by the DAM development team
diff --git a/class.tx_damttcontent_workspacediffview.php b/class.tx_damttcontent_workspacediffview.php
new file mode 100644 (file)
index 0000000..e9d9a2e
--- /dev/null
@@ -0,0 +1,150 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2008 Ingo Renner (ingo@typo3.org)
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+
+require_once(PATH_txdam.'lib/class.tx_dam_image.php');
+require_once(PATH_txdam.'lib/class.tx_dam_tcefunc.php');
+require_once(PATH_txdam.'lib/class.tx_dam_guifunc.php');
+
+
+/**
+ * class to render a more human friendly view of DAM enabled content element
+ * records in the workspace list views
+ *
+ * @author     Ingo Renner <ingo@typo3.org>
+ * @version    $Id$
+ * @package    TYPO3
+ * @subpackage DAM
+ */
+class tx_damttcontent_workspaceDiffView {
+
+       protected $fileFieldConfiguration;
+
+       /**
+        * constructor
+        *
+        */
+       public function __construct() {
+               $this->fileFieldConfiguration = $GLOBALS['TCA']['tt_content']['columns']['tx_damttcontent_files']['config'];
+       }
+
+
+       public function postProcessDiffView($table, $fieldName, $recordOld, $recordNew, $currentDiff, $parentObject) {
+               $diffView = $currentDiff;
+
+               if($table == 'tt_content'
+               && $fieldName == 'tx_damttcontent_files'
+               && $this->needsPostProcessing($recordOld, $recordNew)) {
+
+                       $filesOld = tx_dam_db::getReferencedFiles(
+                               'tt_content',
+                               $recordOld['uid'],
+                               $this->fileFieldConfiguration['MM_match_fields'],
+                               $this->fileFieldConfiguration['MM'],
+                               'tx_dam.*'
+                       );
+
+                       $filesNew = tx_dam_db::getReferencedFiles(
+                               'tt_content',
+                               $recordNew['uid'],
+                               $this->fileFieldConfiguration['MM_match_fields'],
+                               $this->fileFieldConfiguration['MM'],
+                               'tx_dam.*'
+                       );
+
+                               // building a string represemtation of the fields that can then
+                               // be sent to t3lib_diff, also collect the files to replace later
+                       $fieldContentOld = array();
+                       $placeholders    = array();
+                       foreach ($filesOld['rows'] as $damFile) {
+                               $fieldContentOld[] = 'tx_dam:' . $damFile['uid'];
+                               $placeholders['tx_dam:' . $damFile['uid']] = $damFile;
+                       }
+                       $fieldContentOld = implode(' ', $fieldContentOld);
+
+                       $fieldContentNew = array();
+                       foreach ($filesNew['rows'] as $damFile) {
+                               $fieldContentNew[] = 'tx_dam:' . $damFile['uid'];
+                               $placeholders['tx_dam:' . $damFile['uid']] = $damFile;
+                       }
+                       $fieldContentNew = implode(' ', $fieldContentNew);
+
+                               // create the diff
+                       $diff      = t3lib_div::makeInstance('t3lib_diff');
+                       $fieldDiff = $diff->makeDiffDisplay(
+                               $fieldContentOld,
+                               $fieldContentNew,
+                               'div'
+                       );
+
+                               // replace placeholders with thumbnail and title
+                       foreach ($placeholders as $placeholder => $damFile) {
+                               $thumbnail = tx_dam_guiFunc::thumbnail($damFile);
+
+                               $replacement = $thumbnail . ' ' . $damFile['title'];
+
+                               $fieldDiff = str_replace($placeholder, $replacement, $fieldDiff);
+                       }
+
+                       $diffView = $fieldDiff;
+               }
+
+               return $diffView;
+       }
+
+       /**
+        * checks whether the current record diff need post processing - that is
+        * when containing different values for the DAM image fields
+        *
+        * @param       array           the old record
+        * @param       array           the new record
+        * @return      boolean         true if post processing is neede, false otherwise
+        */
+       protected function needsPostProcessing($recordOld, $recordNew) {
+               $needsProcessing = false;
+
+               $mediaContentElements = array(
+                       'textpic',
+                       'image'
+               );
+
+               if ((in_array($recordOld['CType'], $mediaContentElements)
+                       || in_array($recordNew['CType'], $mediaContentElements))
+               && ($recordOld['tx_damttcontent_files'] != $recordNew['tx_damttcontent_files'])) {
+                       $needsProcessing = true;
+               }
+
+               return $needsProcessing;
+       }
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dam_ttcontent/class.tx_damttcontent_workspacediffview.php']) {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dam_ttcontent/class.tx_damttcontent_workspacediffview.php']);
+}
+
+?>\ No newline at end of file
index 16b7721..f7deec3 100755 (executable)
@@ -117,6 +117,19 @@ class ux_tx_cms_layout extends tx_cms_layout {
                                                require_once(PATH_txdam.'lib/class.tx_dam_tcefunc.php');
                                                require_once(PATH_txdam.'lib/class.tx_dam_guifunc.php');
                                                $config = $TCA['tt_content']['columns']['tx_damttcontent_files']['config'];
+
+                                               if ($GLOBALS['BE_USER']->workspace !== 0) {
+                                                       $workspaceRecord = t3lib_BEfunc::getWorkspaceVersionOfRecord(
+                                                               $GLOBALS['BE_USER']->workspace,
+                                                               'tt_content',
+                                                               $row['uid']
+                                                       );
+
+                                                       if ($workspaceRecord) {
+                                                               $row = $workspaceRecord;
+                                                       }
+                                               }
+
                                                $filesArray = tx_dam_db::getReferencedFiles('tt_content', $row['uid'], $config['MM_match_fields'], $config['MM'], 'tx_dam.*');
 
                                                foreach($filesArray['rows'] as $rowDAM) {
diff --git a/class.ux_tx_version_cm1.php b/class.ux_tx_version_cm1.php
new file mode 100644 (file)
index 0000000..57b9fe7
--- /dev/null
@@ -0,0 +1,175 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2008 Ingo Renner (ingo@typo3.org)
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+
+
+class ux_tx_version_cm1 extends tx_version_cm1 {
+
+       /**
+        * Create visual difference view of two records. Using t3lib_diff library
+        *
+        * @param       string          Table name
+        * @param       array           New version record (green)
+        * @param       array           Old version record (red)
+        * @return      array           Array with two keys (0/1) with HTML content / percentage integer (if -1, then it means N/A) indicating amount of change
+        */
+       function createDiffView($table, $diff_1_record, $diff_2_record) {
+               global $TCA;
+
+                       // Initialize:
+               $pctChange = 'N/A';
+
+                       // Check that records are arrays:
+               if (is_array($diff_1_record) && is_array($diff_2_record))       {
+
+                               // Load full table description and initialize diff-object:
+                       t3lib_div::loadTCA($table);
+                       $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
+
+                               // Add header row:
+                       $tRows = array();
+                       $tRows[] = '
+                               <tr class="bgColor5 tableheader">
+                                       <td>Fieldname:</td>
+                                       <td width="98%" nowrap="nowrap">Colored diff-view:</td>
+                               </tr>
+                       ';
+
+                               // Initialize variables to pick up string lengths in:
+                       $allStrLen = 0;
+                       $diffStrLen = 0;
+
+                               // Traversing the first record and process all fields which are editable:
+                       foreach($diff_1_record as $fN => $fV)   {
+                               if ($TCA[$table]['columns'][$fN] && $TCA[$table]['columns'][$fN]['config']['type']!='passthrough' && !t3lib_div::inList('t3ver_label',$fN))     {
+
+                                               // Check if it is files:
+                                       $isFiles = FALSE;
+                                       if (strcmp(trim($diff_1_record[$fN]),trim($diff_2_record[$fN])) &&
+                                                       $TCA[$table]['columns'][$fN]['config']['type']=='group' &&
+                                                       $TCA[$table]['columns'][$fN]['config']['internal_type']=='file')        {
+
+                                                       // Initialize:
+                                               $uploadFolder = $TCA[$table]['columns'][$fN]['config']['uploadfolder'];
+                                               $files1 = array_flip(t3lib_div::trimExplode(',', $diff_1_record[$fN],1));
+                                               $files2 = array_flip(t3lib_div::trimExplode(',', $diff_2_record[$fN],1));
+
+                                                       // Traverse filenames and read their md5 sum:
+                                               foreach($files1 as $filename => $tmp)   {
+                                                       $files1[$filename] = @is_file(PATH_site.$uploadFolder.'/'.$filename) ? md5(t3lib_div::getUrl(PATH_site.$uploadFolder.'/'.$filename)) : $filename;
+                                               }
+                                               foreach($files2 as $filename => $tmp)   {
+                                                       $files2[$filename] = @is_file(PATH_site.$uploadFolder.'/'.$filename) ? md5(t3lib_div::getUrl(PATH_site.$uploadFolder.'/'.$filename)) : $filename;
+                                               }
+
+                                                       // Implode MD5 sums and set flag:
+                                               $diff_1_record[$fN] = implode(' ',$files1);
+                                               $diff_2_record[$fN] = implode(' ',$files2);
+                                               $isFiles = TRUE;
+                                       }
+
+                                               // If there is a change of value:
+                                       if (strcmp(trim($diff_1_record[$fN]),trim($diff_2_record[$fN])))        {
+
+
+                                                       // Get the best visual presentation of the value and present that:
+                                               $val1 = t3lib_BEfunc::getProcessedValue($table,$fN,$diff_2_record[$fN],0,1);
+                                               $val2 = t3lib_BEfunc::getProcessedValue($table,$fN,$diff_1_record[$fN],0,1);
+
+                                                       // Make diff result and record string lenghts:
+                                               $diffres = $t3lib_diff_Obj->makeDiffDisplay($val1,$val2,$isFiles?'div':'span');
+                                               $diffStrLen+= $t3lib_diff_Obj->differenceLgd;
+                                               $allStrLen+= strlen($val1.$val2);
+
+                                                       // If the compared values were files, substituted MD5 hashes:
+                                               if ($isFiles)   {
+                                                       $allFiles = array_merge($files1,$files2);
+                                                       foreach($allFiles as $filename => $token)       {
+                                                               if (strlen($token)==32 && strstr($diffres,$token))      {
+                                                                       $filename =
+                                                                               t3lib_BEfunc::thumbCode(array($fN=>$filename),$table,$fN,$this->doc->backPath).
+                                                                               $filename;
+                                                                       $diffres = str_replace($token,$filename,$diffres);
+                                                               }
+                                                       }
+                                               }
+
+############# new hook for post processing of DAM images
+                                               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/mod/user/ws/class.wslib_gui.php']['postProcessDiffView'])) {
+                                                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/mod/user/ws/class.wslib_gui.php']['postProcessDiffView'] as $classRef) {
+                                                               $hookObject = &t3lib_div::getUserObj($classRef);
+
+                                                               if (method_exists($hookObject, 'postProcessDiffView')) {
+                                                                       $diffres = $hookObject->postProcessDiffView(
+                                                                               $table,
+                                                                               $fN,
+                                                                               $diff_2_record, // old!
+                                                                               $diff_1_record, // new!
+                                                                               $diffres,
+                                                                               $this
+                                                                       );
+                                                               }
+                                                       }
+                                               }
+#############
+
+                                                       // Add table row with result:
+                                               $tRows[] = '
+                                                       <tr class="bgColor4">
+                                                               <td>'.htmlspecialchars($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($table,$fN))).'</td>
+                                                               <td width="98%">'.$diffres.'</td>
+                                                       </tr>
+                                               ';
+                                       } else {
+                                                       // Add string lengths even if value matched - in this was the change percentage is not high if only a single field is changed:
+                                               $allStrLen+=strlen($diff_1_record[$fN].$diff_2_record[$fN]);
+                                       }
+                               }
+                       }
+
+                               // Calculate final change percentage:
+                       $pctChange = $allStrLen ? ceil($diffStrLen*100/$allStrLen) : -1;
+
+                               // Create visual representation of result:
+                       if (count($tRows)>1)    {
+                               $content.= '<table border="0" cellpadding="1" cellspacing="1" class="diffTable">'.implode('',$tRows).'</table>';
+                       } else {
+                               $content.= '<span class="nobr">'.$this->doc->icons(1).'Complete match on editable fields.</span>';
+                       }
+               } else $content.= $this->doc->icons(3).'ERROR: Records could strangely not be found!';
+
+                       // Return value:
+               return array($content,$pctChange);
+       }
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dam_ttcontent/class.ux_tx_version_cm1.php'])  {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dam_ttcontent/class.ux_tx_version_cm1.php']);
+}
+
+?>\ No newline at end of file
diff --git a/class.ux_wslib_gui.php b/class.ux_wslib_gui.php
new file mode 100644 (file)
index 0000000..fe2ae17
--- /dev/null
@@ -0,0 +1,188 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2008 Ingo Renner (ingo@typo3.org)
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * File providing an XCLASS for the workspace module to display thumbnails for reference fields
+ *
+ * $Id$
+ */
+
+
+
+
+/**
+ * Child class for the User -> Workspace module
+ *
+ * @author     Ingo Renner <ingo@typo3.org>
+ * @package TYPO3
+ * @subpackage dam_ttcontent
+ */
+class ux_wslib_gui extends wslib_gui {
+
+       /**
+        * Create visual difference view of two records. Using t3lib_diff library
+        *
+        * @param       string          Table name
+        * @param       array           New version record (green)
+        * @param       array           Old version record (red)
+        * @return      array           Array with two keys (0/1) with HTML content / percentage integer (if -1, then it means N/A) indicating amount of change
+        */
+       function createDiffView($table, $diff_1_record, $diff_2_record) {
+               global $TCA, $LANG;
+
+                       // Initialize:
+               $pctChange = 'N/A';
+
+                       // Check that records are arrays:
+               if (is_array($diff_1_record) && is_array($diff_2_record)) {
+
+                               // Load full table description and initialize diff-object:
+                       t3lib_div::loadTCA($table);
+                       $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
+
+                               // Add header row:
+                       $tRows = array();
+                       $tRows[] = '
+                               <tr class="bgColor5 tableheader">
+                                       <td>' . $LANG->getLL('diffview_label_field_name') . '</td>
+                                       <td width="98%" nowrap="nowrap">' . $LANG->getLL('diffview_label_colored_diff_view') . '</td>
+                               </tr>
+                       ';
+
+                               // Initialize variables to pick up string lengths in:
+                       $allStrLen  = 0;
+                       $diffStrLen = 0;
+
+                               // Traversing the first record and process all fields which are editable:
+                       foreach($diff_1_record as $fN => $fV)   {
+                               if ($TCA[$table]['columns'][$fN] && $TCA[$table]['columns'][$fN]['config']['type'] != 'passthrough' && !t3lib_div::inList('t3ver_label', $fN))  {
+
+                                               // Check if it is files:
+                                       $isFiles = FALSE;
+                                       if (strcmp(trim($diff_1_record[$fN]), trim($diff_2_record[$fN])) &&
+                                               $TCA[$table]['columns'][$fN]['config']['type'] == 'group' &&
+                                               $TCA[$table]['columns'][$fN]['config']['internal_type'] == 'file') {
+
+                                                       // Initialize:
+                                               $uploadFolder = $TCA[$table]['columns'][$fN]['config']['uploadfolder'];
+                                               $files1 = array_flip(t3lib_div::trimExplode(',', $diff_1_record[$fN],1));
+                                               $files2 = array_flip(t3lib_div::trimExplode(',', $diff_2_record[$fN],1));
+
+                                                       // Traverse filenames and read their md5 sum:
+                                               foreach($files1 as $filename => $tmp)   {
+                                                       $files1[$filename] = @is_file(PATH_site.$uploadFolder.'/'.$filename) ? md5(t3lib_div::getUrl(PATH_site.$uploadFolder.'/'.$filename)) : $filename;
+                                               }
+                                               foreach($files2 as $filename => $tmp)   {
+                                                       $files2[$filename] = @is_file(PATH_site.$uploadFolder.'/'.$filename) ? md5(t3lib_div::getUrl(PATH_site.$uploadFolder.'/'.$filename)) : $filename;
+                                               }
+
+                                               // Implode MD5 sums and set flag:
+                                               $diff_1_record[$fN] = implode(' ', $files1);
+                                               $diff_2_record[$fN] = implode(' ', $files2);
+                                               $isFiles = TRUE;
+                                       }
+
+                                               // If there is a change of value:
+                                       if (strcmp(trim($diff_1_record[$fN]), trim($diff_2_record[$fN]))) {
+
+                                                       // Get the best visual presentation of the value and present that:
+                                               $val1 = t3lib_BEfunc::getProcessedValue($table, $fN, $diff_2_record[$fN], 0, 1);
+                                               $val2 = t3lib_BEfunc::getProcessedValue($table, $fN, $diff_1_record[$fN], 0, 1);
+
+                                                       // Make diff result and record string lenghts:
+                                               $diffres = $t3lib_diff_Obj->makeDiffDisplay($val1, $val2, $isFiles ? 'div' : 'span');
+                                               $diffStrLen .= $t3lib_diff_Obj->differenceLgd;
+                                               $allStrLen  .= strlen($val1 . $val2);
+
+                                                       // If the compared values were files, substituted MD5 hashes:
+                                               if ($isFiles)   {
+                                                       $allFiles = array_merge($files1,$files2);
+                                                       foreach($allFiles as $filename => $token)       {
+                                                               if (strlen($token)==32 && strstr($diffres,$token))      {
+                                                                       $filename =
+                                                                       t3lib_BEfunc::thumbCode(array($fN=>$filename),$table,$fN,$this->doc->backPath).
+                                                                       $filename;
+                                                                       $diffres = str_replace($token,$filename,$diffres);
+                                                               }
+                                                       }
+                                               }
+
+############# new hook for post processing of DAM images
+                                               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/mod/user/ws/class.wslib_gui.php']['postProcessDiffView'])) {
+                                                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/mod/user/ws/class.wslib_gui.php']['postProcessDiffView'] as $classRef) {
+                                                               $hookObject = &t3lib_div::getUserObj($classRef);
+
+                                                               if (method_exists($hookObject, 'postProcessDiffView')) {
+                                                                       $diffres = $hookObject->postProcessDiffView(
+                                                                               $table,
+                                                                               $fN,
+                                                                               $diff_2_record, // old!
+                                                                               $diff_1_record, // new!
+                                                                               $diffres,
+                                                                               $this
+                                                                       );
+                                                               }
+                                                       }
+                                               }
+#############
+
+                                                       // Add table row with result:
+                                               $tRows[] = '
+                                                       <tr class="bgColor4">
+                                                               <td>'.htmlspecialchars($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($table,$fN))).'</td>
+                                                               <td width="98%">'.$diffres.'</td>
+                                                       </tr>
+                                               ';
+                                       } else {
+                                                       // Add string lengths even if value matched - in this was the change percentage is not high if only a single field is changed:
+                                               $allStrLen+=strlen($diff_1_record[$fN].$diff_2_record[$fN]);
+                                       }
+                               }
+                       }
+
+                               // Calculate final change percentage:
+                       $pctChange = $allStrLen ? ceil($diffStrLen*100/$allStrLen) : -1;
+
+                               // Create visual representation of result:
+                       if (count($tRows)>1)    {
+                               $content.= '<table border="0" cellpadding="1" cellspacing="1" class="diffTable">'.implode('',$tRows).'</table>';
+                       } else {
+                               $content.= '<span class="nobr">'.$this->doc->icons(1).$LANG->getLL('diffview_complete_match').'</span>';
+                       }
+               } else $content.= $this->doc->icons(3).$LANG->getLL('diffview_cannot_find_records');
+
+                       // Return value:
+               return array($content, $pctChange);
+       }
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dam_ttcontent/class.ux_wslib_gui.php'])       {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dam_ttcontent/class.ux_wslib_gui.php']);
+}
+
+?>\ No newline at end of file
index fa5371a..b7a02d6 100644 (file)
@@ -10,3 +10,5 @@ ctype_textpic_add_orig_field = 1
 add_css_styled_hook = 1
   # cat=basic/enable; type=boolean; label=Page module modifications: Enable modifications to the page module (XCLASS) to enable the display of thumbnails for reference fields.
 add_page_mod_xclass = 1
+  # cat=basic/enable; type=boolean; label=Workspace module modifications: Enable modifications to the workspace module (XCLASS) to enable the display of thumbnails for reference fields.
+add_ws_mod_xclass = 1
index 485ad25..e901570 100644 (file)
@@ -5,7 +5,9 @@ $GLOBALS['T3_VAR']['ext'][$_EXTKEY]['setup'] = unserialize($_EXTCONF);
 
 if ($GLOBALS['T3_VAR']['ext'][$_EXTKEY]['setup']['ctype_image_add_ref']) {
 
-       t3lib_extMgm::addTypoScript($_EXTKEY,'setup','
+       t3lib_extMgm::addTypoScript(
+               $_EXTKEY,
+               'setup','
                includeLibs.tx_damttcontent = EXT:dam/lib/class.tx_dam_tsfe.php
 
                temp.tx_dam.fileList < tt_content.image.20.imgList
@@ -25,12 +27,16 @@ if ($GLOBALS['T3_VAR']['ext'][$_EXTKEY]['setup']['ctype_image_add_ref']) {
                tt_content.image.20.imgPath >
                tt_content.image.20.imgPath =
 
-       ',43);
+               ',
+               43
+       );
 }
 
 if ($GLOBALS['T3_VAR']['ext'][$_EXTKEY]['setup']['ctype_textpic_add_ref']) {
 
-       t3lib_extMgm::addTypoScript($_EXTKEY,'setup','
+       t3lib_extMgm::addTypoScript(
+               $_EXTKEY,
+               'setup','
                includeLibs.tx_damttcontent = EXT:dam/lib/class.tx_dam_tsfe.php
 
                temp.tx_dam.fileList < tt_content.textpic.20.imgList
@@ -50,17 +56,32 @@ if ($GLOBALS['T3_VAR']['ext'][$_EXTKEY]['setup']['ctype_textpic_add_ref']) {
                tt_content.textpic.20.imgPath >
                tt_content.textpic.20.imgPath =
 
-       ',43);
+               ',
+               43
+       );
 }
 
 
+$PATH_damttcontent = t3lib_extMgm::extPath('dam_ttcontent');
+
 if ($GLOBALS['T3_VAR']['ext'][$_EXTKEY]['setup']['add_css_styled_hook']) {
        $TYPO3_CONF_VARS['EXTCONF']['css_styled_content']['pi1_hooks']['render_textpic'] = 'EXT:dam_ttcontent/pi_cssstyledcontent/class.tx_damttcontent_pi1.php:&tx_damttcontent_pi1';
 }
 
 
 if ($GLOBALS['T3_VAR']['ext'][$_EXTKEY]['setup']['add_page_mod_xclass']) {
-       $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php'] = t3lib_extMgm::extPath('dam_ttcontent').'class.ux_tx_cms_layout.php';
+       $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php'] = $PATH_damttcontent.'class.ux_tx_cms_layout.php';
+}
+
+
+if ($GLOBALS['T3_VAR']['ext'][$_EXTKEY]['setup']['add_ws_mod_xclass']) {
+
+               // yes, there's double code in the core!
+       $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/user/ws/class.wslib_gui.php'] = $PATH_damttcontent . 'class.ux_wslib_gui.php';
+       $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/version/cm1/index.php']             = $PATH_damttcontent . 'class.ux_tx_version_cm1.php';
+
+               // TODO when hook is added to TYPO3 core, add a version check
+       $TYPO3_CONF_VARS['SC_OPTIONS']['typo3/mod/user/ws/class.wslib_gui.php']['postProcessDiffView'][] = 'EXT:dam_ttcontent/class.tx_damttcontent_workspacediffview.php:&tx_damttcontent_workspaceDiffView';
 }
 
 ?>
\ No newline at end of file
index eff538a..30d4a29 100755 (executable)
@@ -61,7 +61,7 @@ class tx_damttcontent_pi1 extends tx_cssstyledcontent_pi1 {
                        $this->pObj->cObj->data['txdam_'.$key] = $value;
                }
        }
-       
+
        function removeMetaFromData () {
                foreach ($this->pObj->cObj->data as $key => $value) {
                        if (substr($key, 0, 6)=='txdam_') {
@@ -69,8 +69,8 @@ class tx_damttcontent_pi1 extends tx_cssstyledcontent_pi1 {
                        }
                }
        }
-       
-       
+
+
 
 
        /**
@@ -84,7 +84,6 @@ class tx_damttcontent_pi1 extends tx_cssstyledcontent_pi1 {
         */
         function render_textpic($content, $conf)       {
                global $TYPO3_CONF_VARS;
-               
 
                        // Look for hook before running default code for function
                if (method_exists($this, 'hookRequest') && $hookObj = &$this->hookRequest('render_textpic'))    {
@@ -97,7 +96,7 @@ class tx_damttcontent_pi1 extends tx_cssstyledcontent_pi1 {
                if (!$renderMethod || $renderMethod == 'table') {
                        return $this->pObj->cObj->IMGTEXT($conf);
                }
-               
+
                        // Specific configuration for the chosen rendering method
                if (is_array($conf['rendering.'][$renderMethod . '.'])) {
                        $conf = $this->pObj->cObj->joinTSarrays($conf, $conf['rendering.'][$renderMethod . '.']);
@@ -128,11 +127,11 @@ class tx_damttcontent_pi1 extends tx_cssstyledcontent_pi1 {
 
                $imgPath = $this->pObj->cObj->stdWrap($conf['imgPath'], $conf['imgPath.']);
 
-               
+
                if ($this->pObj->cObj->data['imagecaption_position']=='hidden') {
                        $hideCaption = true;
                }
-               
+
                        // Global caption
                $caption = '';
                if (!$hideCaption && !$conf['captionEach'] && !$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.']))        {
@@ -249,7 +248,7 @@ class tx_damttcontent_pi1 extends tx_cssstyledcontent_pi1 {
                $imgsTag = array();
                $imgsExtraData = array();
                $origImages = array();
-                               
+
                for ($a=0; $a<$imgCount; $a++)  {
                        $imgKey = $a+$imgStart;
                        $totalImagePath = $imgPath.$imgs[$imgKey];
@@ -261,7 +260,7 @@ class tx_damttcontent_pi1 extends tx_cssstyledcontent_pi1 {
                        $this->pObj->cObj->data[$this->pObj->cObj->currentValKey] = $totalImagePath;
 
 
-                               // fetch DAM data and provide it as field data prefixed with txdam_     
+                               // fetch DAM data and provide it as field data prefixed with txdam_
                        $media = tx_dam::media_getForFile($totalImagePath, '*');
                        if ($media->isAvailable) {
                                $this->addMetaToData ($media->getMetaArray());
@@ -269,9 +268,9 @@ class tx_damttcontent_pi1 extends tx_cssstyledcontent_pi1 {
                        } else {
                                $this->removeMetaFromData ();
                                $imgsExtraData[$imgKey] = array();
-                       }                       
+                       }
                        unset($media);
-                       
+
                        $imgObjNum = intval($splitArr[$a]['imgObjNum']);
                        $imgConf = $conf[$imgObjNum.'.'];
 
@@ -414,9 +413,9 @@ class tx_damttcontent_pi1 extends tx_cssstyledcontent_pi1 {
                                if ($separateRows && $colPos == 0) {
                                        $thisRow = '';
                                }
-                               
-                               $this->addMetaToData ($imgsExtraData[$i]);      
-                               
+
+                               $this->addMetaToData($imgsExtraData[$i]);
+
 
                                        // Render one image
                                $imageSpace = $origImages[$i][0] + $border*($borderSpace+$borderThickness)*2;
@@ -534,7 +533,7 @@ class tx_damttcontent_pi1 extends tx_cssstyledcontent_pi1 {
                }
 
                $this->removeMetaFromData ();
-                               
+
                return $output;
        }