Fixed bug #16426: Link field for images is too short to provide links for every image...
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 18 Jan 2011 19:06:48 +0000 (19:06 +0000)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 18 Jan 2011 19:06:48 +0000 (19:06 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@10117 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/class.browse_links.php
typo3/sysext/cms/ext_tables.sql
typo3/sysext/cms/locallang_ttc.xml
typo3/sysext/cms/tbl_tt_content.php
typo3/sysext/css_styled_content/static/setup.txt
typo3/sysext/install/ext_localconf.php
typo3/sysext/install/mod/class.tx_install.php
typo3/sysext/install/updates/class.tx_coreupdates_imagelink.php [new file with mode: 0644]

index 0b902f7..9ba1a2a 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-01-18  Christian Kuhn  <lolli@schwarzbu.ch>
+
+       * Fixed bug #16426: Link field for images is too short to provide links for every image (Thanks to Jo Hasenau)
+
 2011-01-18  Ingo Renner  <ingo@typo3.org>
 
        * Added feature #17101: [reports] Warning in reports module for enabled PHP safe_mode, credits Christian Kuhn
@@ -74,7 +78,7 @@
 
        * Fixed bug #17042: Double class attribute for select tag of tceforms "type=select" if using icons
        * Fixed bug #17036: Misleading deprecation comment getReferenceHTML()
-       * Fixed bug #17034: Live search also returns records which not available to the user (Thanks to Peter Beernink)
+       * Fixed bug #17034: Live search also returns records which are not available to the user (Thanks to Peter Beernink)
        * Follow-up to #17032: Remove early return
 
 2011-01-14  Ernesto Baschny  <ernst@cron-it.de>
index e296e04..b1168f2 100644 (file)
@@ -814,7 +814,13 @@ class browse_links {
 
                        // CurrentUrl - the current link url must be passed around if it exists
                if ($this->mode == 'wizard')    {
-                       $currentLinkParts = t3lib_div::unQuoteFilenames($this->P['currentValue'], TRUE);
+                       $currentValues = t3lib_div::trimExplode(chr(10), trim($this->P['currentValue']));
+                       if (count($currentValues) > 0) {
+                               $currentValue = array_pop($currentValues);
+                       } else {
+                               $currentValue = '';
+                       }
+                       $currentLinkParts = t3lib_div::unQuoteFilenames($currentValue, TRUE);
                        $initialCurUrlArray = array (
                                'href'   => $currentLinkParts[0],
                                'target' => $currentLinkParts[1],
@@ -1005,7 +1011,11 @@ class browse_links {
                                                        cur_params = cur_params.replace(/\bid\=.*?(\&|$)/, "");
                                                }
                                                input = input + " " + cur_target + " " + cur_class + " " + cur_title + " " + cur_params;
-                                               field.value = input;
+                                               if(field.value && field.className.search(/textarea/) != -1) {
+                                                       field.value += "\n" + input;
+                                               } else {
+                                                       field.value = input;
+                                               }
                                                '.$update.'
                                        }
                                }
index 09be90c..08994fe 100755 (executable)
@@ -393,7 +393,7 @@ CREATE TABLE tt_content (
   fe_group varchar(100) DEFAULT '0' NOT NULL,
   header_link varchar(255) DEFAULT '' NOT NULL,
   imagecaption_position varchar(6) DEFAULT '' NOT NULL,
-  image_link varchar(255) DEFAULT '' NOT NULL,
+  image_link text,
   image_zoom tinyint(3) unsigned DEFAULT '0' NOT NULL,
   image_noRows tinyint(3) unsigned DEFAULT '0' NOT NULL,
   image_effects tinyint(3) unsigned DEFAULT '0' NOT NULL,
index e3a3037..9285c49 100755 (executable)
                        <label index="image_noRows.I.0">Deactivate</label>
                        <label index="image_noRows_formlabel">Display as Rows</label>
                        <label index="image_link">Link:</label>
-                       <label index="image_link_formlabel">Links (separate with commas, one link per image)</label>
+                       <label index="image_link_formlabel">Links (one per line, one link per image)</label>
                        <label index="image_zoom">Click-enlarge:</label>
                        <label index="image_zoom_formlabel">Enlarge on Click</label>
                        <label index="image_effects">Effects:</label>
index 3ce6080..1692fd5 100755 (executable)
@@ -811,10 +811,9 @@ $TCA['tt_content'] = array(
                        'exclude' => 1,
                        'label' => 'LLL:EXT:cms/locallang_ttc.xml:image_link',
                        'config' => array(
-                               'type' => 'input',
-                               'size' => '50',
-                               'max' => '51200',
-                               'eval' => 'trim',
+                               'type' => 'text',
+                               'cols' => '30',
+                               'rows' => '3',
                                'wizards' => array(
                                        '_PADDING' => 2,
                                        'link' => array(
index 4dcb6bf..85c8131 100644 (file)
@@ -498,10 +498,12 @@ tt_content.image.20 {
 
                        enable.field = image_zoom
                        enable.ifEmpty.typolink.parameter.field = image_link
+                       enable.ifEmpty.typolink.parameter.listNum.splitChar = 10
                        enable.ifEmpty.typolink.parameter.listNum.stdWrap.data = register : IMAGE_NUM_CURRENT
                        enable.ifEmpty.typolink.returnLast = url
 
                        typolink.parameter.field = image_link
+                       typolink.parameter.listNum.splitChar = 10
                        typolink.parameter.listNum.stdWrap.data = register : IMAGE_NUM_CURRENT
                        typolink.target = {$styles.content.links.target}
                        typolink.extTarget = {$styles.content.links.extTarget}
index 2e6e4e4..ab1be07 100644 (file)
@@ -51,4 +51,6 @@ $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['flagsFromSprites'] = 't
        // Version 4.5: Adds excludeable FlexForm fields to Backend group access lists (ACL)
 $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['addFlexformsToAcl'] = 'tx_coreupdates_addflexformstoacl';
 
+       // Version 4.5: Split tt_content image_link to newline by comma
+$TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['imagelink'] = 'tx_coreupdates_imagelink';
 ?>
\ No newline at end of file
index ea3b97a..2ef95f5 100755 (executable)
@@ -159,6 +159,7 @@ require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_co
 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_migrateworkspaces.php');
 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_flagsfromsprite.php');
 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_addflexformstoacl.php');
+require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_imagelink.php');
 
 /**
  * Install Tool module
diff --git a/typo3/sysext/install/updates/class.tx_coreupdates_imagelink.php b/typo3/sysext/install/updates/class.tx_coreupdates_imagelink.php
new file mode 100644 (file)
index 0000000..6fcaa6b
--- /dev/null
@@ -0,0 +1,98 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011 Christian Kuhn <lolli@schwarzbu.ch>
+ *  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!
+ ***************************************************************/
+
+/**
+ * Contains the update class to split existing image_link field by comma and
+ * switch to newlines.
+ *
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ */
+class tx_coreupdates_imagelink extends Tx_Install_Updates_Base {
+
+       protected $title = 'Update Existing image links';
+
+
+       /**
+        * Checks if an update is needed
+        *
+        * @param       string          &$description: The description for the update
+        * @return      boolean         True if an update is needed, false otherwise
+        */
+       public function checkForUpdate(&$description) {
+               $description = 'Since TYPO3 4.5 links to images of "Image" and "Text with image" content elements are separated by newline and not by comma anymore. This update converts existing comma separated links to the new form.';
+
+               $result = FALSE;
+               if ($this->versionNumber >= 4005000) {
+                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                               'uid',
+                               'tt_content',
+                               'image_link!="" AND image_link LIKE "%,%" AND image_link NOT LIKE "%\\n%"',
+                               '',
+                               '',
+                               '1'
+                       );
+                       if($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
+                               $result = TRUE;
+                       }
+                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
+               }
+
+               return $result;
+       }
+
+       /**
+        * Performs the database update.
+        *
+        * @param       array           &$dbQueries: queries done in this update
+        * @param       mixed           &$customMessages: custom messages
+        * @return      boolean         True on success, false on error
+        */
+       public function performUpdate(&$dbQueries, &$customMessages) {
+               $result = TRUE;
+               if($this->versionNumber >= 4005000) {
+                       $affectedRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                               'uid, image_link',
+                               'tt_content',
+                               'image_link!="" AND image_link LIKE "%,%" AND image_link NOT LIKE "%\\n%"'
+                       );
+
+                       foreach ($affectedRows as $row) {
+                               $newImageLink = t3lib_div::trimExplode(',', $row['image_link']);
+                               $newImageLink = implode(chr(10), $newImageLink);
+                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tt_content', 'uid=' . $row['uid'], array('image_link' => $newImageLink));
+                               $dbQueries[] = str_replace(chr(10), ' ', $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery);
+                               if ($GLOBALS['TYPO3_DB']->sql_error()) {
+                                       $customMessages = 'SQL-ERROR: ' . htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error());
+                                       $result = $result & FALSE;
+                               }
+                       }
+               }
+
+               return $result;
+       }
+}
+?>
\ No newline at end of file