[+FEATURE] Contagged is now self-aware. The long description of a term is now parsed...
authorjocrau <jocrau@735d13b6-9817-0410-8766-e36946ffe9aa>
Wed, 23 Sep 2009 09:01:40 +0000 (09:01 +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@24725 735d13b6-9817-0410-8766-e36946ffe9aa

class.tx_contagged.php
model/class.tx_contagged_model_mapper.php
model/class.tx_contagged_model_terms.php
pi1/class.tx_contagged_pi1.php

index d98b3c0..e16f6f1 100644 (file)
@@ -39,20 +39,31 @@ class tx_contagged extends tslib_pibase {
        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
+        * The main method. It instantly delegates the process to the parse function.
         *
         * @param       string          $content: The content
         * @param       array           $conf: The configuration array
         * @return      string          The parsed and tagged content that is displayed on the website
         */
-       function main($content,$conf) {
+       public function main($content, $conf = NULL) {
+               return $this->parse($content, $conf);
+       }
+       
+       /**
+        * This method is to parse, tag and link specific terms in the given content.
+        *
+        * @param       string          $content: The content
+        * @param       array           $conf: The configuration array
+        * @return      string          The parsed and tagged content that is displayed on the website
+        */
+       public function parse($content, $conf = NULL) {
                $this->conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][$this->prefixId.'.'];
-
-               $this->local_cObj = t3lib_div::makeInstance('tslib_cObj');
-               $this->local_cObj->setCurrentVal($GLOBALS['TSFE']->id);
+               if (!is_object($this->cObj)) {
+                       $this->cObj = t3lib_div::makeInstance('tslib_cObj');
+                       $this->cObj->setCurrentVal($GLOBALS['TSFE']->id);
+               }
 
                $this->typolinkConf = is_array($this->conf['typolink.']) ? $this->conf['typolink.'] : array();
                if (!empty($this->typolinkConf['additionalParams'])) {
@@ -403,7 +414,7 @@ class tx_contagged extends tslib_pibase {
                        }
                        $typolinkConf['additionalParams'] = t3lib_div::implodeArrayForUrl('tx_contagged', $additionalParams, '', 1);
                        $typolinkConf['parameter'] = $parameter;
-                       $matchedTerm = $this->local_cObj->typolink($matchedTerm, $typolinkConf);                
+                       $matchedTerm = $this->cObj->typolink($matchedTerm, $typolinkConf);              
                }
                
                return $matchedTerm;
@@ -524,8 +535,10 @@ class tx_contagged extends tslib_pibase {
                if ( $GLOBALS['TSFE']->page['tx_contagged_dont_parse'] == 1) {
                        $result = true;
                }
-               if ( $this->cObj->getFieldVal('tx_contagged_dont_parse') == 1) {
-                       $result = true;
+               if (!empty($this->cObj)) {
+                       if ($this->cObj->getFieldVal('tx_contagged_dont_parse') == 1) {
+                               $result = true;
+                       }
                }
 
                return $result;
index d888185..2ed714e 100644 (file)
  */
 class tx_contagged_model_mapper {
        var $conf; // the TypoScript configuration array
-       var $cObj;
        var $controller;
 
        function tx_contagged_model_mapper($controller) {
                $this->controller = $controller;
                $this->conf = $controller->conf;
-               $this->cObj = $controller->cObj;
+               if (!is_object($this->cObj)) {
+                       $this->cObj = t3lib_div::makeInstance('tslib_cObj');
+               }
+
        }
 
        /**
index e5517f5..2f83c36 100644 (file)
@@ -32,7 +32,6 @@ require_once (t3lib_extMgm::extPath('contagged') . 'model/class.tx_contagged_mod
  */
 class tx_contagged_model_terms {
        var $conf; // the TypoScript configuration array
-       var $cObj;
        var $controller;
        var $tablesArray = array(); // array of all tables in the database
        var $terms = array();
@@ -41,7 +40,9 @@ class tx_contagged_model_terms {
        function __construct($controller) {
                $this->controller = $controller;
                $this->conf = $controller->conf;
-               $this->cObj = $controller->cObj;
+               if (!is_object($this->cObj)) {
+                       $this->cObj = t3lib_div::makeInstance('tslib_cObj');
+               }
 
                $mapperClassName = t3lib_div::makeInstanceClassName('tx_contagged_model_mapper');
                $this->mapper = new $mapperClassName($this->controller);
@@ -154,7 +155,7 @@ class tx_contagged_model_terms {
                                $whereClause = '1=1';
                                $whereClause .= $storagePidsList ? ' AND pid IN (' . $storagePidsList . ')' : '';
                                $whereClause .= $dataSourceConfigArray['hasSysLanguageUid'] ? ' AND (sys_language_uid=' . intval($GLOBALS['TSFE']->sys_language_uid) . ' OR sys_language_uid=-1)' : '';
-                               $whereClause .= tslib_cObj::enableFields($sourceName);
+                               $whereClause .= $this->cObj->enableFields($sourceName);
 
                                // execute SQL-query
                                $result = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
index 32e3822..36f3ea9 100644 (file)
@@ -23,6 +23,7 @@
        ***************************************************************/
 
 require_once (PATH_tslib . 'class.tslib_pibase.php');
+require_once (t3lib_extMgm::extPath('contagged') . 'class.tx_contagged.php');
 require_once (t3lib_extMgm::extPath('contagged') . 'model/class.tx_contagged_model_terms.php');
 require_once (t3lib_extMgm::extPath('contagged') . 'model/class.tx_contagged_model_mapper.php');
 
@@ -53,6 +54,8 @@ class tx_contagged_pi1 extends tslib_pibase {
         * @return      string                  a single or list view of terms
         */
        function main($content, $conf) {
+               $this->conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][$this->prefixId.'.'];
+               $this->parser = t3lib_div::makeInstance('tx_contagged');
                $this->local_cObj = t3lib_div::makeInstance('tslib_cObj');
                $this->local_cObj->setCurrentVal($GLOBALS['TSFE']->id);
                if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_contagged.'])) {
@@ -96,7 +99,7 @@ class tx_contagged_pi1 extends tslib_pibase {
                // TODO hook "newRenderFunctionName"
 
                $content = $this->removeUnfilledMarker($content);
-               
+                               
                return $this->pi_wrapInBaseClass($content);
        }
 
@@ -252,7 +255,7 @@ class tx_contagged_pi1 extends tslib_pibase {
                $markerArray['###TERM_ALT###'] = $termArray['term_alt']?implode(', ',$termArray['term_alt']):$this->pi_getLL('na');
                $markerArray['###TERM_REPLACE###'] = $termArray['term_replace']?$termArray['term_replace']:$this->pi_getLL('na');
                $markerArray['###DESC_SHORT###'] = $termArray['desc_short']?$termArray['desc_short']:$this->pi_getLL('na');
-               $markerArray['###DESC_LONG###'] = $termArray['desc_long']?$termArray['desc_long']:$this->pi_getLL('na');
+               $markerArray['###DESC_LONG###'] = $termArray['desc_long']?$this->parser->parse($termArray['desc_long']):$this->pi_getLL('na');
                $markerArray['###IMAGES###'] = $this->renderImages($termArray);
                $markerArray['###RELATED###'] = $this->renderRelated($termArray);
                $markerArray['###TERM_LANG###'] = $this->pi_getLL('lang.'.$termArray['term_lang'])?$this->pi_getLL('lang.'.$termArray['term_lang']):$this->pi_getLL('na');
@@ -456,7 +459,7 @@ class tx_contagged_pi1 extends tslib_pibase {
        protected function removeUnfilledMarker($content) {
                return preg_replace('/###.*?###/', '', $content);
        }
-
+       
 }