ADD The maximum number of recurrences of a term (for a cObj) can be set by maxRecurre...
authorjocrau <jocrau@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 23 Sep 2008 12:35:09 +0000 (12:35 +0000)
committerBastian Bringenberg <spam@bastian-bringenberg.de>
Thu, 4 Dec 2014 23:56:05 +0000 (00:56 +0100)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/contagged/trunk@12246 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
class.tx_contagged.php
ext_emconf.php
static/constants.txt
static/setup.txt

index d985658..baff0fb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+v0.1.3 2008-09-22 Jochen Rau <j.rau@web.de>
+
+       * ADD The maximum number of recurrences of a term (for a cObj) can be set by maxRecurrences in the TS Setup
+
 v0.1.2 2008-09-09 Jochen Rau <j.rau@web.de>
 
        * FIX In some cases no term was found; the use of the modifier "u" didn't work if the content is not UTF-8; now support for UTF-8 must be activated manually by changing the RegEx-modifier "Uis" to "Uuis"; fixes bug #1483
index f9fc3c3..1e17bdd 100644 (file)
@@ -136,7 +136,6 @@ class tx_contagged extends tslib_pibase {
                        $regEx = $termArray['term_main'].$this->conf['modifier'];
                } else {
                        $regEx = '/(?<=\W|^)' . preg_quote($regExTerm,'/') . '(?=\W|$)/' . $this->conf['modifier'];
-                       // $regEx = '/(?<=\W|^)' . preg_quote($regExTerm,'/') . '(?=\W|$)/Uis';
                }
                
                return $regEx;
@@ -146,9 +145,10 @@ class tx_contagged extends tslib_pibase {
                $regEx = $this->getRegEx($term,$termKey,$typeConfigArray);
                preg_match_all($regEx,$content,$matchesArray,PREG_OFFSET_CAPTURE);
                $matchesArray = $matchesArray[0]; // only take the full pattern matches of the regEx
-               // var_dump($matchesArray);
-               for ($i=0; $i < count($matchesArray); $i++) {
-                       
+               
+               // determine the maximum of recurrencies of the same term to be tagged
+               $maxRecurrencies = $this->conf['maxRecurrencies'] ? min($this->conf['maxRecurrencies'], count($matchesArray)) : count($matchesArray);
+               for ($i=0; $i < $maxRecurrencies; $i++) {
                        $preContent = substr($content,0,$matchesArray[$i][1]);
                        $postContent = substr($content,strlen($matchesArray[$i][0])+$matchesArray[$i][1]);
 
@@ -169,6 +169,7 @@ class tx_contagged extends tslib_pibase {
                                $matchStart = $matchesArray[$i][1] - strlen($preMatch[0]);
                                $matchEnd = $matchStart + strlen($matchedTerm);
                                
+                               // check for nested matches
                                $isNested = FALSE;
                                $checkArray = $positionsArray;
                                foreach ($checkArray as $start => $value) {
@@ -197,7 +198,6 @@ class tx_contagged extends tslib_pibase {
                if($positionsArray){
                        foreach ($positionsArray as $matchStart => $matchArray) {
                                if ($matchStart>=0) { // ignore nested matches
-                                       // debug($matchArray,'match');
                                        $matchLength = strlen($matchArray['matchedTerm']);
                                        $termKey = $matchArray['termKey'];
                                        $replacement = $this->getReplacement($termKey,$matchArray['matchedTerm'],$matchArray['preMatch'],$matchArray['postMatch']);
@@ -225,7 +225,6 @@ class tx_contagged extends tslib_pibase {
        function getReplacement($termKey,$matchedTerm,$preMatch,$postMatch) {
                $termArray = $this->termsArray[$termKey];
                $typeConfigArray = $this->typesArray[$termArray['term_type'] . '.'];
-               // debug($termArray);
                // register the term array
                $this->registerFields($typeConfigArray,$termKey);
                
@@ -315,10 +314,8 @@ class tx_contagged extends tslib_pibase {
 
        function insertKeywords() {
                $GLOBALS['TSFE']->register['contagged_termsFound'] = array_unique((array)$GLOBALS['TSFE']->register['contagged_termsFound']);
-               // debug($GLOBALS['TSFE']->register['contagged_termsFound']);
                // make a list of unique terms found in the content
                $termsFoundList = implode(',',$GLOBALS['TSFE']->register['contagged_termsFound']);
-               // debug($termsFoundList);
                // build an array to be passed to the UPDATE query
                $updateArray = array($this->prefixId . '_keywords' => $termsFoundList);
                // $updateArray = array('keywords' => $termsFoundList);
index 243780b..ff1f1cf 100644 (file)
@@ -3,7 +3,7 @@
 ########################################################################
 # Extension Manager/Repository config file for ext: "contagged"
 #
-# Auto generated 09-09-2008 12:05
+# Auto generated 23-09-2008 10:42
 #
 # Manual updates:
 # Only the data in the array - anything else is removed by next write.
 
 $EM_CONF[$_EXTKEY] = array(
        'title' => 'Content parser and tagger',
-       '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\'). Needs at least PHP 4.4.0',
+       '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.1.2',
+       'version' => '0.1.3',
        'dependencies' => '',
        'conflicts' => '',
        'priority' => '',
@@ -40,7 +40,7 @@ $EM_CONF[$_EXTKEY] = array(
                'suggests' => array(
                ),
        ),
-       '_md5_values_when_last_written' => 'a:23:{s:9:"ChangeLog";s:4:"2429";s:10:"README.txt";s:4:"72b7";s:22:"class.tx_contagged.php";s:4:"3429";s:21:"ext_conf_template.txt";s:4:"0086";s:12:"ext_icon.gif";s:4:"50a3";s:17:"ext_localconf.php";s:4:"d45d";s:14:"ext_tables.php";s:4:"022c";s:14:"ext_tables.sql";s:4:"3600";s:27:"icon_tx_contagged_terms.gif";s:4:"50a3";s:16:"locallang_db.xml";s:4:"750b";s:7:"tca.php";s:4:"b9b2";s:14:"doc/manual.sxw";s:4:"0774";s:23:"doc/realurl_example.php";s:4:"7ef3";s:16:"js/selecttext.js";s:4:"1179";s:41:"model/class.tx_contagged_model_mapper.php";s:4:"8ead";s:40:"model/class.tx_contagged_model_terms.php";s:4:"a8ed";s:30:"pi1/class.tx_contagged_pi1.php";s:4:"6370";s:18:"pi1/contagged.tmpl";s:4:"4d1f";s:17:"pi1/locallang.xml";s:4:"1a34";s:20:"static/constants.txt";s:4:"d5ab";s:16:"static/setup.txt";s:4:"635b";s:20:"static/css/setup.txt";s:4:"fd93";s:25:"static/examples/setup.txt";s:4:"b39c";}',
+       '_md5_values_when_last_written' => 'a:23:{s:9:"ChangeLog";s:4:"a31d";s:10:"README.txt";s:4:"72b7";s:22:"class.tx_contagged.php";s:4:"8994";s:21:"ext_conf_template.txt";s:4:"0086";s:12:"ext_icon.gif";s:4:"50a3";s:17:"ext_localconf.php";s:4:"d45d";s:14:"ext_tables.php";s:4:"022c";s:14:"ext_tables.sql";s:4:"3600";s:27:"icon_tx_contagged_terms.gif";s:4:"50a3";s:16:"locallang_db.xml";s:4:"750b";s:7:"tca.php";s:4:"b9b2";s:14:"doc/manual.sxw";s:4:"0774";s:23:"doc/realurl_example.php";s:4:"7ef3";s:16:"js/selecttext.js";s:4:"1179";s:41:"model/class.tx_contagged_model_mapper.php";s:4:"8ead";s:40:"model/class.tx_contagged_model_terms.php";s:4:"a8ed";s:30:"pi1/class.tx_contagged_pi1.php";s:4:"6370";s:18:"pi1/contagged.tmpl";s:4:"4d1f";s:17:"pi1/locallang.xml";s:4:"1a34";s:20:"static/constants.txt";s:4:"973c";s:16:"static/setup.txt";s:4:"97ff";s:20:"static/css/setup.txt";s:4:"fd93";s:25:"static/examples/setup.txt";s:4:"b39c";}',
        'suggests' => array(
        ),
 );
index 7ea1f24..a97a1d5 100644 (file)
@@ -29,6 +29,9 @@ contagged {
        # cat=plugin.contagged//46; type=int; label=[Storage PIDs)]:A comma separated list of pages or sysFolders (PIDs) the data is stored. This could be overwritten by the type configuration or the data source configuration.
        storagePids = 
 
+       # cat=plugin.contagged//48; type=boolean; label=[Max. Recurrencies]: The maximum number of terms to be tagged in a cObject.
+       maxRecurrencies = 
+
        # cat=plugin.contagged//50; type=boolean; label=[Check for joined words]: Take pre- and/or post-matches of joined words (with dash) into account (see documentation for examples).
        checkPreAndPostMatches = 1
 
index fe42835..3bb0c0f 100644 (file)
@@ -21,6 +21,7 @@ plugin.tx_contagged {
        addLangAttribute = {$contagged.addLangAttribute}
        addCssClassAttribute = {$contagged.addCssClassAttribute}
        replaceTerm = {$contagged.replaceTerm}
+       maxRecurrences = {$contagged.maxRecurrences}
        updateKeywords = {$contagged.updateKeywords}
        labelWrap1 = {$contagged.labelWrap1}
        labelWrap2 = {$contagged.labelWrap2}