Updated to TER v 1.0.0
authorjocrau <jocrau@735d13b6-9817-0410-8766-e36946ffe9aa>
Fri, 20 Mar 2009 11:04:12 +0000 (11:04 +0000)
committerBastian Bringenberg <spam@bastian-bringenberg.de>
Thu, 4 Dec 2014 23:56:06 +0000 (00:56 +0100)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/contagged/trunk@18111 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
class.tx_contagged.php
doc/cooluri_example.xml [new file with mode: 0755]
ext_emconf.php
locallang_db.xml
model/class.tx_contagged_model_mapper.php
pi1/class.tx_contagged_pi1.php
static/setup.txt

index e82ec8d..c1e1f57 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+v1.0.0 2009-03-20 Jochen Rau <j.rau@web.de>
+
+       * CHG Status is now STABLE (thanks for the feed-back)
+       * ADD Default configuration of typolinks (e.g. "plugin.tx_contagged.typolink.target = _top" or "plugin.tx_contagged.types.definition.typolink.target = _top"); types configuration will overwrite global configuration
+       * ADD Added a CoolUrl example configuration to "doc" folder -- thanks to Carine who provided the code
+       * FIX $dataSourceConfigArray['mapping.']['uid.']['field'] was never used as an unique identifier -- thanks to Carine
+       * FIX Labels could not be overwritten by _LOCAL_LANG ($this->conf was set after $this->pi_loadLL() was invoked)
+       * FIX Unititialized $wrappedSubpartArray in contagged_pi1
+       
+v0.2.1 2009-03-10 Jochen Rau <j.rau@web.de>
+
+       * FIX Labels could not be overwritten by _LOCAL_LANG ($this->conf was set after $this->pi_loadLL() was invoked)
+       * FIX Uninitialized variables (arrays) if $tableArray is NULL
+       * FIX Handling of UTF-8 (if you have UTF-8 enabled, please add "u" to "contagged.modifier = Uisu" in your TS constants)
+       
 v0.2.1 2009-03-10 Jochen Rau <j.rau@web.de>
 
        * FIX Uninitialized variables (arrays) if result from fetchRelatedTerms() and fetchIndex() is NULL (drops a warning)
index 09684b1..4d24547 100644 (file)
@@ -38,6 +38,8 @@ class tx_contagged extends tslib_pibase {
        var $scriptRelPath = 'class.tx_contagged.php'; // path to this script relative to the extension dir
        var $extKey = 'contagged'; // the extension key
        var $conf; // the TypoScript configuration array
+       var $typolinkConf;
+       var $local_cObj;
 
        /**
         * The main method to parse, tag and link terms
@@ -49,6 +51,15 @@ class tx_contagged extends tslib_pibase {
        function main($content,$conf) {
                $this->conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][$this->prefixId.'.'];
 
+               $this->local_cObj = t3lib_div::makeInstance('tslib_cObj');
+               $this->local_cObj->setCurrentVal($GLOBALS['TSFE']->id);
+
+               $this->typolinkConf = is_array($this->conf['typolink.']) ? $this->conf['typolink.'] : array();
+               if (!empty($this->typolinkConf['additionalParams'])) {
+                       $this->typolinkConf['additionalParams'] = $this->cObj->stdWrap($typolinkConf['additionalParams'], $typolinkConf['additionalParams.']);
+                       unset($this->typolinkConf['additionalParams.']);
+               }
+
                // exit if the content should be skipped
                if ($this->isContentToSkip()) return $content;          
 
@@ -371,21 +382,23 @@ class tx_contagged extends tslib_pibase {
 
                // link the matched term to the front-end list page
                if ($makeLink) {
-                   $cache = 0;
-                   $this->pi_USER_INT_obj = 1;
-                   $label = $matchedTerm;  // the link text
-                   $overrulePIvars = array(
-                               'backPid' => $GLOBALS['TSFE']->id,
-                               'key' => $termKey,
-                       );
-                   $clearAnyway=1;    // the current values of piVars will NOT be preserved
+                       unset($typolinkConf);
+                       $typolinkConf = $this->typolinkConf;
+                       if (!empty($typeConfigArray['typolink.'])) {
+                               $typolinkConf = t3lib_div::array_merge_recursive_overrule($typolinkConf, $typeConfigArray['typolink.']);
+                       }
                        if ($termArray['link']) {
-                               $altPageId = $termArray['link']; // ID of the target page
+                               $parameter = $termArray['link'];
                        } else {
-                               $altPageId = $termArray['listPages'][0];
+                               $parameter = $termArray['listPages'][0];
                        }
-                       $GLOBALS['TSFE']->register['contagged_list_page'] = $altPageId;
-                   $matchedTerm = $this->pi_linkTP_keepPIvars($matchedTerm, $overrulePIvars, $cache, $clearAnyway, $altPageId);
+                       $additionalParams = array(
+                               'backPid' => $GLOBALS['TSFE']->id,
+                               'key' => $termKey
+                       );
+                       $typolinkConf['additionalParams'] = t3lib_div::implodeArrayForUrl('tx_contagged', $additionalParams, '', 1);
+                       $typolinkConf['parameter'] = $parameter;
+                       $matchedTerm = $this->local_cObj->typolink($matchedTerm, $typolinkConf);                
                }
                
                return $matchedTerm;
diff --git a/doc/cooluri_example.xml b/doc/cooluri_example.xml
new file mode 100755 (executable)
index 0000000..0259b90
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<cooluri>
+  <urlsuffix>.html</urlsuffix>
+  <removetrailingslash>1</removetrailingslash>
+  <cooluris>1</cooluris>
+  
+  <cache>
+    <usecache>1</usecache>
+    <params2cool>
+      <checkforchangeevery>1</checkforchangeevery>
+    </params2cool>
+    <cool2params>
+      <translateifnotfound>0</translateifnotfound>
+      <oldlinksvalidfor>365</oldlinksvalidfor>
+    </cool2params>
+    <cacheparams>0</cacheparams>
+    
+    <pagenotfound>
+      <status>HTTP/1.0 404 Not Found</status>
+      <behavior type="redirect">/index.php?id=404</behavior>
+    </pagenotfound>
+  </cache>
+
+  <pagepath>
+    <title>tx_realurl_pathsegment,alias,nav_title,title,subtitle</title>
+    <saveto>id</saveto>
+    <default>0</default>    
+    <userfunc>tx_cooluri->getPageTitle</userfunc>
+    <t3conv>1</t3conv>
+  </pagepath>
+  <uriparts>
+    <part>
+      <parameter>tx_contagged[key]</parameter>
+      <lookindb>
+        <to>SELECT term_main FROM tx_contagged_terms WHERE uid=$1</to>
+        <translatetoif>
+          <match>^[0-9]+$</match>
+        </translatetoif>
+        <t3conv>1</t3conv>
+      </lookindb>
+    </part>
+    <part>
+      <parameter>tx_contagged[index]</parameter>
+      <lookindb>
+        <to>SELECT CONCAT('letter-','$1')</to>
+        <translatetoif>
+          <match>^[0-9]+$</match>
+        </translatetoif>
+        <t3conv>1</t3conv>
+      </lookindb>
+    </part>
+  </uriparts>
+    
+  <predefinedparts>
+    <part>
+      <parameter>cHash</parameter>
+    </part>
+  </predefinedparts>
+  
+  <valuemaps>
+    <valuemap>
+      <parameter>L</parameter>
+      <value key="">0</value>
+      <value key="en">1</value>
+    </valuemap>
+    <valuemap>
+      <parameter>type</parameter>
+      <value key="rss">5432</value>
+      <value key="sitemap">6006</value>
+    </valuemap>
+  </valuemaps>
+  
+  <paramorder>
+    <param>no_cache</param>
+    <param>L</param>
+    <param>type</param>
+  </paramorder>
+  
+</cooluri>
\ No newline at end of file
index 7327c7f..641879d 100644 (file)
@@ -3,7 +3,7 @@
 ########################################################################
 # Extension Manager/Repository config file for ext: "contagged"
 #
-# Auto generated 10-03-2009 09:47
+# Auto generated 20-03-2009 12:03
 #
 # Manual updates:
 # Only the data in the array - anything else is removed by next write.
@@ -15,13 +15,13 @@ $EM_CONF[$_EXTKEY] = array(
        'description' => 'This extension parses your content to tag, replace and link specific terms. It is useful to auto-generate a glossary - but not only. See \'ChangeLog\' and WiKi (\'http://wiki.typo3.org/index.php/Contagged\').',
        'category' => 'fe',
        'shy' => 0,
-       'version' => '0.2.1',
+       'version' => '1.0.0',
        'dependencies' => '',
        'conflicts' => '',
        'priority' => '',
        'loadOrder' => '',
        'module' => '',
-       'state' => 'beta',
+       'state' => 'stable',
        'uploadfolder' => 1,
        'createDirs' => 'uploads/tx_contagged/rte/',
        'modify_tables' => 'tt_content,pages',
@@ -40,7 +40,7 @@ $EM_CONF[$_EXTKEY] = array(
                'suggests' => array(
                ),
        ),
-       '_md5_values_when_last_written' => 'a:30:{s:9:"ChangeLog";s:4:"0483";s:10:"README.txt";s:4:"72b7";s:22:"class.tx_contagged.php";s:4:"bc40";s:21:"ext_conf_template.txt";s:4:"3d40";s:12:"ext_icon.gif";s:4:"50a3";s:17:"ext_localconf.php";s:4:"f640";s:14:"ext_tables.php";s:4:"7a50";s:14:"ext_tables.sql";s:4:"0afa";s:27:"icon_tx_contagged_terms.gif";s:4:"50a3";s:16:"locallang_db.xml";s:4:"1a5e";s:7:"tca.php";s:4:"7ed7";s:14:"doc/manual.sxw";s:4:"0774";s:23:"doc/realurl_example.php";s:4:"7ef3";s:55:"extensions/contagged/class.tx_rtehtmlarea_contagged.php";s:4:"6e77";s:34:"extensions/contagged/locallang.xml";s:4:"9489";s:38:"extensions/contagged/skin/htmlarea.css";s:4:"5e97";s:46:"extensions/contagged/skin/images/contagged.gif";s:4:"50a3";s:46:"extensions/contagged/skin/images/contagged.png";s:4:"63d3";s:39:"htmlarea/plugins/contagged/contagged.js";s:4:"41da";s:40:"htmlarea/plugins/contagged/locallang.xml";s:4:"e333";s:16:"js/selecttext.js";s:4:"1179";s:41:"model/class.tx_contagged_model_mapper.php";s:4:"ecf3";s:40:"model/class.tx_contagged_model_terms.php";s:4:"b375";s:30:"pi1/class.tx_contagged_pi1.php";s:4:"2945";s:18:"pi1/contagged.tmpl";s:4:"55bf";s:17:"pi1/locallang.xml";s:4:"3830";s:20:"static/constants.txt";s:4:"a199";s:16:"static/setup.txt";s:4:"aa88";s:20:"static/css/setup.txt";s:4:"bfc8";s:25:"static/examples/setup.txt";s:4:"7887";}',
+       '_md5_values_when_last_written' => 'a:31:{s:9:"ChangeLog";s:4:"783f";s:10:"README.txt";s:4:"72b7";s:22:"class.tx_contagged.php";s:4:"0326";s:21:"ext_conf_template.txt";s:4:"3d40";s:12:"ext_icon.gif";s:4:"50a3";s:17:"ext_localconf.php";s:4:"f640";s:14:"ext_tables.php";s:4:"7a50";s:14:"ext_tables.sql";s:4:"0afa";s:27:"icon_tx_contagged_terms.gif";s:4:"50a3";s:16:"locallang_db.xml";s:4:"0305";s:7:"tca.php";s:4:"7ed7";s:23:"doc/cooluri_example.xml";s:4:"3b41";s:14:"doc/manual.sxw";s:4:"0774";s:23:"doc/realurl_example.php";s:4:"7ef3";s:55:"extensions/contagged/class.tx_rtehtmlarea_contagged.php";s:4:"6e77";s:34:"extensions/contagged/locallang.xml";s:4:"9489";s:38:"extensions/contagged/skin/htmlarea.css";s:4:"5e97";s:46:"extensions/contagged/skin/images/contagged.gif";s:4:"50a3";s:46:"extensions/contagged/skin/images/contagged.png";s:4:"63d3";s:39:"htmlarea/plugins/contagged/contagged.js";s:4:"41da";s:40:"htmlarea/plugins/contagged/locallang.xml";s:4:"e333";s:16:"js/selecttext.js";s:4:"1179";s:41:"model/class.tx_contagged_model_mapper.php";s:4:"7092";s:40:"model/class.tx_contagged_model_terms.php";s:4:"b375";s:30:"pi1/class.tx_contagged_pi1.php";s:4:"4d12";s:18:"pi1/contagged.tmpl";s:4:"55bf";s:17:"pi1/locallang.xml";s:4:"3830";s:20:"static/constants.txt";s:4:"a199";s:16:"static/setup.txt";s:4:"3980";s:20:"static/css/setup.txt";s:4:"bfc8";s:25:"static/examples/setup.txt";s:4:"7887";}',
        'suggests' => array(
        ),
 );
index 903b261..63995e5 100644 (file)
                        <label index="tx_contagged_terms.exclude">Von Frontend-Listen ausschließen</label>
                        <label index="pages.tx_contagged_dont_parse">Text nicht parsen</label>
                </languageKey>
+               <languageKey index="fr" type="array">
+                       <label index="tx_contagged_terms">Termes</label>
+                       <label index="tx_contagged_terms.plugin">Liste (contagged)</label>
+                       <label index="tx_contagged_terms.term_main">Terme</label>
+                       <label index="tx_contagged_terms.term_alt">Termes alternatifs</label>
+                       <label index="tx_contagged_terms.term_type">Type de terme</label>
+                       <label index="tx_contagged_terms.term_lang.I.1">Anglais</label>
+                       <label index="tx_contagged_terms.term_lang.I.2">Français</label>
+                       <label index="tx_contagged_terms.term_lang.I.3">Allemand</label>
+                       <label index="tx_contagged_terms.term_lang.I.4">Italien</label>
+                       <label index="tx_contagged_terms.term_lang.I.5">Espagnol</label>
+                       <label index="tx_contagged_terms.term_lang.I.6">argot</label>
+                       <label index="tx_contagged_terms.term_lang">Langue du terme</label>
+                       <label index="tx_contagged_terms.term_replace">Remplacement</label>
+                       <label index="tx_contagged_terms.desc_short">Description courte (ex. Union Européenne)</label>
+                       <label index="tx_contagged_terms.desc_long">Description longue</label>
+                       <label index="tx_contagged_terms.imagecaption">Légende(s) de(s) image(s)</label>
+                       <label index="tx_contagged_terms.imagealt">Texte(s) alternatif(s) de(s) image(s)</label>
+                       <label index="tx_contagged_terms.imagetitle">Titre(s) de(s) image(s)</label>
+                       <label index="tx_contagged_terms.related">Voir aussi</label>
+                       <label index="tx_contagged_terms.link">Lien</label>
+                       <label index="tx_contagged_terms.exclude">Ne pas afficher dans le glossaire</label>
+                       <label index="pages.tx_contagged_dont_parse">Ne pas remplacer automatiquement les sigles et abbréviations (du glossaire)</label>
+               </languageKey>
        </data>
 </T3locallang>
index 7d9c00d..a8c0faa 100644 (file)
@@ -66,9 +66,6 @@ class tx_contagged_model_mapper {
 
                // iterate through all data from the datasource
                foreach ($result as $row) {
-                       if ($dataSourceConfigArray['mapping.']['uid.']['field']) {
-                               $termKey = $row[$dataSourceConfigArray['mapping.']['uid.']['field']];
-                       }
                        $termMain = $dataSourceConfigArray['mapping.']['term_main.']['field'] ? $dataSourceConfigArray['mapping.']['term_main.']['field'] : '';
                        $termReplace = $dataSourceConfigArray['mapping.']['term_replace.']['field'] ? $dataSourceConfigArray['mapping.']['term_replace.']['field'] : '';
                        $term = $row[$termReplace] ? $row[$termReplace] : $row[$termMain];
@@ -121,7 +118,12 @@ class tx_contagged_model_mapper {
                        }
                        
                        // TODO: hook "mappingPostProcessing"
-                       $dataArray[] = $mappedDataArray;
+                       
+                       if (!empty($dataSourceConfigArray['mapping.']['uid.']['field'])) {
+                               $dataArray[$row[$dataSourceConfigArray['mapping.']['uid.']['field']]] = $mappedDataArray;
+                       } else {
+                               $dataArray[] = $mappedDataArray;
+                       }                       
                }
 
                return $dataArray;
index c7480c9..2f0e21f 100644 (file)
@@ -44,7 +44,6 @@ class tx_contagged_pi1 extends tslib_pibase {
        var $typolinkConf;
        var $backPid; // pid of the last visited page (from piVars)
        var $indexChar; // char of the given index the user has clicked on (from piVars)
-       
 
        /**
         * main method of the contagged list plugin
@@ -56,13 +55,15 @@ class tx_contagged_pi1 extends tslib_pibase {
        function main($content, $conf) {
                $this->local_cObj = t3lib_div::makeInstance('tslib_cObj');
                $this->local_cObj->setCurrentVal($GLOBALS['TSFE']->id);
-               $this->pi_loadLL();
                $this->conf = t3lib_div::array_merge_recursive_overrule($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_contagged.'], $conf);
+               $this->pi_loadLL();
                $this->templateCode = $this->cObj->fileResource($this->conf['templateFile']?$this->conf['templateFile']:$this->templateFile);
-               $this->typolinkConf = $this->conf['typolink.'];
+               $this->typolinkConf = is_array($this->conf['typolink.']) ? $this->conf['typolink.'] : array();
                $this->typolinkConf['parameter.']['current'] = 1;
-               $this->typolinkConf['additionalParams'] = $this->cObj->stdWrap($typolinkConf['additionalParams'], $typolinkConf['additionalParams.']);
-               unset($this->typolinkConf['additionalParams.']);
+               if (!empty($this->typolinkConf['additionalParams'])) {
+                       $this->typolinkConf['additionalParams'] = $this->cObj->stdWrap($typolinkConf['additionalParams'], $typolinkConf['additionalParams.']);
+                       unset($this->typolinkConf['additionalParams.']);
+               }
                $this->backPid = $this->piVars['backPid'] ? intval($this->piVars['backPid']) : NULL;
                $this->pointer = $this->piVars['pointer'] ? intval($this->piVars['pointer']) : NULL;
                $this->indexChar = $this->piVars['index'] ? urldecode($this->piVars['index']) : NULL; // TODO The length should be configurable
@@ -79,15 +80,15 @@ class tx_contagged_pi1 extends tslib_pibase {
                $this->model = new tx_contagged_model_terms($this);
                $this->termsArray = $this->model->findAllTermsToListOnPage();
 
-               if ((strtolower($this->conf['layout']) == 'minilist') || (strtolower($this->cObj->data['select_key']) == 'minilist')) {
+               if ( !is_null($termKey) ) {
+                       $content .= $this->renderSingleItemByKey($termKey);
+               } elseif ((strtolower($this->conf['layout']) == 'minilist') || (strtolower($this->cObj->data['select_key']) == 'minilist')) {
                        $content .= $this->renderMiniList();
                } elseif ( is_null($termKey) && is_null($sword) ) {
                        $content .= $this->renderList();
                } elseif ( is_null($termKey) && !is_null($sword) ) {
                        $content .= $this->renderListBySword($sword);
-               } elseif ( !is_null($termKey) ) {
-                       $content .= $this->renderSingleItemByKey($termKey);
-               }
+               } 
 
                // TODO hook "newRenderFunctionName"
 
@@ -102,8 +103,10 @@ class tx_contagged_pi1 extends tslib_pibase {
         * @return      $string The list as HTML
         */
        function renderList() {
+               $markerArray = array();
+               $wrappedSubpartArray = array();
                $subparts = $this->getSubparts('LIST');
-               $this->renderLinks($markerArray,$wrappedSubpartArray);
+               $this->renderLinks($markerArray, $wrappedSubpartArray);
                $this->renderIndex($markerArray);
                $this->renderSearchBox($markerArray);
                $indexedTerms = array();
@@ -260,6 +263,9 @@ class tx_contagged_pi1 extends tslib_pibase {
                $markerArray['###DETAILS###'] = $this->pi_getLL('details');
                unset($typolinkConf);
                $typolinkConf = $this->typolinkConf;
+               if (!empty($typeConfigArray['typolink.'])) {
+                       $typolinkConf = t3lib_div::array_merge_recursive_overrule($typolinkConf, $typeConfigArray['typolink.']);
+               }
                $typolinkConf['additionalParams'] .= '&' . $this->prefixId . '[key]=' . $termKey;
                $typolinkConf['parameter'] = $termArray['listPages'][0];
                $this->typolinkConf['parameter.']['current'] = 0;
@@ -275,7 +281,11 @@ class tx_contagged_pi1 extends tslib_pibase {
                                $key = key($result);
                                if (array_key_exists($key, $this->termsArray)) {
                                        $relatedTerm = current($result);
+                                       unset($typolinkConf);
                                        $typolinkConf = $this->typolinkConf;
+                                       if (!empty($typeConfigArray['typolink.'])) {
+                                               $typolinkConf = t3lib_div::array_merge_recursive_overrule($typolinkConf, $typeConfigArray['typolink.']);
+                                       }
                                        $typolinkConf['additionalParams'] .= '&' . $this->prefixId . '[key]=' . $key;
                                        $typolinkConf['parameter.']['wrap'] = "|,".$GLOBALS['TSFE']->type;
                                        $relatedCode .= $this->local_cObj->stdWrap($this->local_cObj->typoLink($relatedTerm['term'], $typolinkConf), $this->conf['related.']['single.']['stdWrap.']);                                   
@@ -318,10 +328,6 @@ class tx_contagged_pi1 extends tslib_pibase {
                        $imagesAltText = t3lib_div::trimExplode(chr(10), $termArray['imagealt']);
                        $imagesTitleText = t3lib_div::trimExplode(chr(10), $termArray['imagetitle']);
                }
-               // debug($images, 'images');
-               // debug($imagesCaption, 'imagesCaption');
-               // debug($imagesAltText, 'imagesAltText');
-               // debug($imagesTitleText, 'imagesTitleText');
                
                if (!empty($images)) {
                        foreach ($images as $key => $image) {
@@ -384,10 +390,7 @@ class tx_contagged_pi1 extends tslib_pibase {
                foreach ($this->termsArray as $termKey => $termArray) {
                        if ( $termArray['exclude']!=1 && $this->conf['types.'][$termArray['term_type'].'.']['dontListTerms']!=1 && in_array($GLOBALS['TSFE']->id,$termArray['listPages']) ) {
                                $sortField = $this->model->getSortField($termArray);
-                               // debug($sortField);
                                foreach ($reverseIndexArray as $subChar => $indexChar) {
-                                       // debug(preg_quote($subChar),$termArray['term']);
-                                       // debug(preg_match('/^'.preg_quote($subChar).'/ui',$termArray['term']));
                                        if ( preg_match('/^'.preg_quote($subChar).'/' . $this->conf['modifier'],$termArray[$sortField])>0 ) {
                                                $typolinkConf['additionalParams'] = '&' . $this->prefixId . '[index]=' . $indexChar;
                                                $indexArray[$indexChar] = $this->local_cObj->typolink($indexChar, $typolinkConf);
index ff1f9e2..9765b32 100644 (file)
@@ -33,7 +33,7 @@ plugin.tx_contagged {
        fieldsToMap = {$contagged.fieldsToMap}
        secureFields = {$contagged.secureFields}
        addBackLinkDescription = {$contagged.addBackLinkDescription}
-       
+               
        images {
                stdWrap.wrap = <div class="tx-contagged-images">|</div>
                caption.stdWrap.wrap = <div class="tx-contagged-imagecaption"> | </div>