Added modfunc2 which offers statistics of entered search words.
authorAndreas Otto <andreas.otto@dkd.de>
Thu, 7 Apr 2005 08:43:20 +0000 (08:43 +0000)
committerAndreas Otto <andreas.otto@dkd.de>
Thu, 7 Apr 2005 08:43:20 +0000 (08:43 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@608 709f56b5-9817-0410-a4d7-c38de5d9e867

typo3/sysext/indexed_search/ChangeLog
typo3/sysext/indexed_search/ext_tables.php
typo3/sysext/indexed_search/ext_tables.sql
typo3/sysext/indexed_search/locallang.xml
typo3/sysext/indexed_search/modfunc2/class.tx_indexedsearch_modfunc2.php [new file with mode: 0644]
typo3/sysext/indexed_search/modfunc2/locallang.xml [new file with mode: 0644]

index 636ee27..c6500a9 100755 (executable)
@@ -1,3 +1,7 @@
+2005-04-07  Andreas Otto  <andreas.otto@dkd.de>
+
+       * Added modfunc2 which offers statistics of entered search words.
+
 2004-01-29  Ingmar Schlecht  <ingmar@typo3.org>
 
        * Fixed spelling mistake "Interne pages" => "Internal pages"
@@ -11,4 +15,3 @@
 
        * Added possibility of having more than the three fixed rootline columns.
 
-
index 4599750..ea84c6a 100755 (executable)
@@ -13,6 +13,15 @@ if (TYPO3_MODE=='BE')    {
     );
 }
 
+if (TYPO3_MODE=="BE")  {
+       t3lib_extMgm::insertModuleFunction(
+               "web_info",
+               "tx_indexedsearch_modfunc2",
+               t3lib_extMgm::extPath($_EXTKEY)."modfunc2/class.tx_indexedsearch_modfunc2.php",
+               "LLL:EXT:indexed_search/locallang.php:mod2_indexed_search"
+       );
+}
+
 t3lib_extMgm::allowTableOnStandardPages('index_config');
 
 $TCA['index_config'] = Array (
index 227d4b6..edc3a89 100755 (executable)
@@ -169,3 +169,16 @@ CREATE TABLE index_config (
     PRIMARY KEY (uid),
     KEY parent (pid)
 );
+
+#
+# Table structure for table 'index_stat_word'
+#
+CREATE TABLE index_stat_word (
+  uid int(11) DEFAULT '0' NOT NULL auto_increment,
+  word varchar(30) DEFAULT '' NOT NULL,
+  index_stat_search_id int(11) DEFAULT '0' NOT NULL,
+  tstamp int(11) DEFAULT '0' NOT NULL,
+  pageid int(11) DEFAULT '0' NOT NULL,
+  PRIMARY KEY (uid),
+  KEY tstamp (tstamp,word)
+);
index 2aeb3d7..7b1d6c5 100755 (executable)
@@ -14,6 +14,7 @@
        <data type="array">
                <languageKey index="default" type="array">
                        <label index="mod_indexed_search">Indexed search</label>
+                       <label index="mod2_indexed_search">Indexed Search Statistics</label>
                </languageKey>
                <languageKey index="dk">EXT:csh_dk/indexed_search/dk.locallang.xml</languageKey>
                <languageKey index="de">EXT:csh_de/indexed_search/de.locallang.xml</languageKey>
diff --git a/typo3/sysext/indexed_search/modfunc2/class.tx_indexedsearch_modfunc2.php b/typo3/sysext/indexed_search/modfunc2/class.tx_indexedsearch_modfunc2.php
new file mode 100644 (file)
index 0000000..60ffb53
--- /dev/null
@@ -0,0 +1,199 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2004 Dimitri Ebert (dimitri.ebert@dkd.de)
+ *  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.
+ *
+ *  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!
+ ***************************************************************/
+/**
+ * Module extension (addition to function menu) 'Indexed search statistics' for the 'indexed_search' extension.
+ *
+ * @author     Dimitri Ebert <dimitri.ebert@dkd.de>
+ */
+
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ *
+ *
+ *
+ *   50: class tx_indexedsearch_modfunc2 extends t3lib_extobjbase
+ *   57:     function main()
+ *   79:     function showStats()
+ *  107:     function listSeveralStats($title,$addwhere,$conf)
+ *  186:     function extGetTreeList($id,$depth,$begin = 0,$perms_clause)
+ *
+ * TOTAL FUNCTIONS: 4
+ * (This index is automatically created/updated by the extension "extdeveval")
+ *
+ */
+
+require_once(PATH_t3lib."class.t3lib_extobjbase.php");
+require_once(PATH_t3lib."class.t3lib_tsfebeuserauth.php");
+
+
+class tx_indexedsearch_modfunc2 extends t3lib_extobjbase {
+
+       /**
+        * Calls showStats to generate output.
+        *
+        * @return      string  html table with results from showStats()
+        */
+       function main() {
+
+                       // Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
+               global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
+
+               $theOutput.=$this->pObj->doc->spacer(5);
+               $theOutput.=$this->pObj->doc->section($LANG->getLL('title'),$this->showStats(),0,1);
+
+               $menu=array();
+               $menu[]=t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[tx_indexedsearch_modfunc2_check]",$this->pObj->MOD_SETTINGS["tx_indexedsearch_modfunc2_check"]).$LANG->getLL("checklabel");
+               $theOutput.=$this->pObj->doc->spacer(5);
+
+               return $theOutput;
+       }
+
+
+       /**
+        * Generates html table containing the statistics.
+        * Calls listSeveralStats 3 times, for all statistics, statistics of the last 30 days and statistics of the last 24 hours.
+        *
+        * @return      string  html table with results
+        */
+       function showStats() {
+               global $LANG,$HTTP_GET_VARS,$TYPO3_CONF_VARS;
+
+               $conf['words']=50;                              //max words in result list
+               $conf['bid']=$HTTP_GET_VARS['id'];  //pageid for several statistics
+
+               $addwhere1='';                                                                          //for all
+               $addwhere2=" AND tstamp > ".(time()-30*24*60*60);       //for last 30 days
+               $addwhere3=" AND tstamp > ".(time()-24*60*60);          //for last 24 hours
+
+               $content.= $LANG->getLL('title2').'
+                       <table cellpading="5" cellspacing="5" valign=top><tr><td valign=top>'
+                       .$this->listSeveralStats($LANG->getLL("all"),$addwhere1,$conf).'</td><td valign=top>'
+                       .$this->listSeveralStats($LANG->getLL("last30days"),$addwhere2,$conf).'</td><td valign=top>'
+                       .$this->listSeveralStats($LANG->getLL("last24hours"),$addwhere3,$conf).'</td></tr></table>'
+                       .$this->note;
+
+               return $content;
+       }
+
+       /**
+        * Generates html table with title and several statistics
+        *
+        * @param       string  title for statistic, like 'Last 30 days' or 'Last 24 hours'
+        * @param       string  add where for sql query
+        * @param       array   configuration: words = max words for results, bid = pageid
+        * @return      string  html table with results
+        */
+       function listSeveralStats($title,$addwhere,$conf) {
+               global $LANG;
+
+               $queryParts['SELECT']= "* , count( * ) AS c";
+               $queryParts['FROM']="index_stat_word";
+               $queryParts['WHERE']=sprintf("pageid= %s ".$addwhere, $conf['bid']);
+               $queryParts['GROUPBY']="word";
+               $queryParts['ORDERBY']="c DESC,word";
+               $queryParts['LIMIT']=$conf['words'];
+
+               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                               $queryParts['SELECT'],
+                               $queryParts['FROM'],
+                               $queryParts['WHERE'],
+                               $queryParts['GROUPBY'],
+                               $queryParts['ORDERBY'],
+                               $queryParts['LIMIT']
+                       );
+
+               if ( $res ) {
+                       $count = $GLOBALS['TYPO3_DB']->sql_num_rows( $res );
+               }else{
+                       $count = 0;
+               }
+
+               // exist several statistics for this page?
+               if( $count > 0 ){
+                       $this->note =   $LANG->getLL("justthispage");
+               }else{
+                       // Limit access to pages of the current site
+                       $secureaddwhere = " AND pageid IN (".($this->extGetTreeList($conf['bid'],100,0,'1')).$conf['bid'].") ";
+                       $this->note = $LANG->getLL("allpages");
+
+                       $queryParts['WHERE']= '1 '.$addwhere.$secureaddwhere;
+               }
+
+               //make real query
+               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                               $queryParts['SELECT'],
+                               $queryParts['FROM'],
+                               $queryParts['WHERE'],
+                               $queryParts['GROUPBY'],
+                               $queryParts['ORDERBY'],
+                               $queryParts['LIMIT']
+               );
+
+               $table1='';
+               $i=0;
+               if( $res ){
+                       while( $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc( $res ) ) {
+                               $i++;
+                               $table1.='<tr class="bgColor4"><td>'.$i.'.</td><td>'.$row['word'].'</td><td>&nbsp;&nbsp;'.$row['c'].'</td></tr>';
+                       }
+               }
+
+               if( $i==0 ){
+                       $table1='<tr class="bgColor4"><td callspan="3">'.$LANG->getLL("noresults").'</td></tr>';
+               }
+
+               $table1='<table class="bgColor5" cellpadding="2" cellspacing="1"><tr class="tableheader"><td colspan="3">'.$title.'</td></tr>'.$table1.'</table>';
+
+
+               return $note.$table1;
+       }
+
+       /**
+        * Calls t3lib_tsfeBeUserAuth::extGetTreeList.
+        * Although this duplicates the function t3lib_tsfeBeUserAuth::extGetTreeList
+        * this is necessary to create the object that is used recursively by the original function.
+        *
+        * Generates a list of Page-uid's from $id. List does not include $id itself
+        * The only pages excluded from the list are deleted pages.
+        *
+        * @param       integer Start page id
+        * @param       integer Depth to traverse down the page tree.
+        * @param       integer $begin is an optional integer that determines at which level in the tree to start collecting uid's. Zero means 'start right away', 1 = 'next level and out'
+        * @param       string  Perms clause
+        * @return      string  Returns the list with a comma in the end (if any pages selected!)
+       */
+       function extGetTreeList($id,$depth,$begin = 0,$perms_clause){
+               return t3lib_tsfeBeUserAuth::extGetTreeList($id,$depth,$begin,$perms_clause);
+       }
+
+
+}
+
+
+
+if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/modfunc2/class.tx_indexedsearch_modfunc2.php"])        {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/modfunc2/class.tx_indexedsearch_modfunc2.php"]);
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/indexed_search/modfunc2/locallang.xml b/typo3/sysext/indexed_search/modfunc2/locallang.xml
new file mode 100644 (file)
index 0000000..702bd37
--- /dev/null
@@ -0,0 +1,297 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+    <meta type="array">
+        <description></description>
+        <type>module</type>
+        <csh_table></csh_table>
+        <fileId>EXT:dkd_isearch_stats/modfunc1/locallang.xml</fileId>
+        <labelContext type="array">
+            <label index="title"></label>
+            <label index="title2"></label>
+            <label index="noresults"></label>
+            <label index="all"></label>
+            <label index="last30days"></label>
+            <label index="last24hours"></label>
+            <label index="justthispage"></label>
+            <label index="allpages"></label>
+        </labelContext>
+    </meta>
+    <data type="array">
+        <languageKey index="default" type="array">
+            <label index="title">Indexed search statistics</label>
+            <label index="title2">List of most searched words</label>
+            <label index="noresults">No results</label>
+            <label index="all">All</label>
+            <label index="last30days">Last 30 days</label>
+            <label index="last24hours">Last 24 hours</label>
+            <label index="justthispage">Statistics for this page only</label>
+            <label index="allpages">Statistics for all pages. Select a page with indexed search form to see several statistics</label>
+        </languageKey>
+        <languageKey index="dk" type="array">
+        </languageKey>
+        <languageKey index="de" type="array">
+            <label index="title">Indexed Search Statistik</label>
+            <label index="title2">Liste der meistgesuchten W&amp;ouml;rter</label>
+            <label index="noresults">Kein Ergebnis</label>
+            <label index="all">Alle</label>
+            <label index="last30days">Letzte 30 Tage</label>
+            <label index="last24hours">Letzte 24 Stunden</label>
+            <label index="justthispage">Statistik f&amp;uuml;r diese Seite</label>
+            <label index="allpages">Statistik f&amp;uuml;r alle Seiten. Einzelstatistiken sind auf der Seiten mit Suchformularen von Indexed Search verf&amp;uuml;gbar</label>
+        </languageKey>
+        <languageKey index="no" type="array">
+        </languageKey>
+        <languageKey index="it" type="array">
+        </languageKey>
+        <languageKey index="fr" type="array">
+        </languageKey>
+        <languageKey index="es" type="array">
+        </languageKey>
+        <languageKey index="nl" type="array">
+        </languageKey>
+        <languageKey index="cz" type="array">
+        </languageKey>
+        <languageKey index="pl" type="array">
+        </languageKey>
+        <languageKey index="si" type="array">
+        </languageKey>
+        <languageKey index="fi" type="array">
+        </languageKey>
+        <languageKey index="tr" type="array">
+        </languageKey>
+        <languageKey index="se" type="array">
+        </languageKey>
+        <languageKey index="pt" type="array">
+        </languageKey>
+        <languageKey index="ru" type="array">
+        </languageKey>
+        <languageKey index="ro" type="array">
+        </languageKey>
+        <languageKey index="ch" type="array">
+        </languageKey>
+        <languageKey index="sk" type="array">
+        </languageKey>
+        <languageKey index="lt" type="array">
+        </languageKey>
+        <languageKey index="is" type="array">
+        </languageKey>
+        <languageKey index="hr" type="array">
+        </languageKey>
+        <languageKey index="hu" type="array">
+        </languageKey>
+        <languageKey index="gl" type="array">
+        </languageKey>
+        <languageKey index="th" type="array">
+        </languageKey>
+        <languageKey index="gr" type="array">
+        </languageKey>
+        <languageKey index="hk" type="array">
+        </languageKey>
+        <languageKey index="eu" type="array">
+        </languageKey>
+        <languageKey index="bg" type="array">
+        </languageKey>
+        <languageKey index="br" type="array">
+        </languageKey>
+        <languageKey index="et" type="array">
+        </languageKey>
+        <languageKey index="ar" type="array">
+        </languageKey>
+        <languageKey index="he" type="array">
+        </languageKey>
+        <languageKey index="ua" type="array">
+        </languageKey>
+        <languageKey index="lv" type="array">
+        </languageKey>
+        <languageKey index="jp" type="array">
+        </languageKey>
+        <languageKey index="vn" type="array">
+        </languageKey>
+        <languageKey index="ca" type="array">
+        </languageKey>
+        <languageKey index="ba" type="array">
+        </languageKey>
+        <languageKey index="kr" type="array">
+        </languageKey>
+    </data>
+    <orig_hash type="array">
+        <languageKey index="default" type="array">
+            <label index="title" type="integer">252429738</label>
+            <label index="title2" type="integer">18274704</label>
+            <label index="noresults" type="integer">260674928</label>
+            <label index="all" type="integer">169351776</label>
+            <label index="last30days" type="integer">2709049</label>
+            <label index="last24hours" type="integer">76613117</label>
+            <label index="justthispage" type="integer">127420273</label>
+            <label index="allpages" type="integer">139406157</label>
+        </languageKey>
+        <languageKey index="dk" type="array">
+        </languageKey>
+        <languageKey index="de" type="array">
+            <label index="title" type="integer">252429738</label>
+            <label index="title2" type="integer">18274704</label>
+            <label index="noresults" type="integer">260674928</label>
+            <label index="all" type="integer">169351776</label>
+            <label index="last30days" type="integer">2709049</label>
+            <label index="last24hours" type="integer">76613117</label>
+            <label index="justthispage" type="integer">127420273</label>
+            <label index="allpages" type="integer">139406157</label>
+        </languageKey>
+        <languageKey index="no" type="array">
+        </languageKey>
+        <languageKey index="it" type="array">
+        </languageKey>
+        <languageKey index="fr" type="array">
+        </languageKey>
+        <languageKey index="es" type="array">
+        </languageKey>
+        <languageKey index="nl" type="array">
+        </languageKey>
+        <languageKey index="cz" type="array">
+        </languageKey>
+        <languageKey index="pl" type="array">
+        </languageKey>
+        <languageKey index="si" type="array">
+        </languageKey>
+        <languageKey index="fi" type="array">
+        </languageKey>
+        <languageKey index="tr" type="array">
+        </languageKey>
+        <languageKey index="se" type="array">
+        </languageKey>
+        <languageKey index="pt" type="array">
+        </languageKey>
+        <languageKey index="ru" type="array">
+        </languageKey>
+        <languageKey index="ro" type="array">
+        </languageKey>
+        <languageKey index="ch" type="array">
+        </languageKey>
+        <languageKey index="sk" type="array">
+        </languageKey>
+        <languageKey index="lt" type="array">
+        </languageKey>
+        <languageKey index="is" type="array">
+        </languageKey>
+        <languageKey index="hr" type="array">
+        </languageKey>
+        <languageKey index="hu" type="array">
+        </languageKey>
+        <languageKey index="gl" type="array">
+        </languageKey>
+        <languageKey index="th" type="array">
+        </languageKey>
+        <languageKey index="gr" type="array">
+        </languageKey>
+        <languageKey index="hk" type="array">
+        </languageKey>
+        <languageKey index="eu" type="array">
+        </languageKey>
+        <languageKey index="bg" type="array">
+        </languageKey>
+        <languageKey index="br" type="array">
+        </languageKey>
+        <languageKey index="et" type="array">
+        </languageKey>
+        <languageKey index="ar" type="array">
+        </languageKey>
+        <languageKey index="he" type="array">
+        </languageKey>
+        <languageKey index="ua" type="array">
+        </languageKey>
+        <languageKey index="lv" type="array">
+        </languageKey>
+        <languageKey index="jp" type="array">
+        </languageKey>
+        <languageKey index="vn" type="array">
+        </languageKey>
+        <languageKey index="ca" type="array">
+        </languageKey>
+        <languageKey index="ba" type="array">
+        </languageKey>
+        <languageKey index="kr" type="array">
+        </languageKey>
+    </orig_hash>
+    <orig_text type="array">
+        <languageKey index="default" type="array">
+        </languageKey>
+        <languageKey index="dk" type="array">
+        </languageKey>
+        <languageKey index="de" type="array">
+        </languageKey>
+        <languageKey index="no" type="array">
+        </languageKey>
+        <languageKey index="it" type="array">
+        </languageKey>
+        <languageKey index="fr" type="array">
+        </languageKey>
+        <languageKey index="es" type="array">
+        </languageKey>
+        <languageKey index="nl" type="array">
+        </languageKey>
+        <languageKey index="cz" type="array">
+        </languageKey>
+        <languageKey index="pl" type="array">
+        </languageKey>
+        <languageKey index="si" type="array">
+        </languageKey>
+        <languageKey index="fi" type="array">
+        </languageKey>
+        <languageKey index="tr" type="array">
+        </languageKey>
+        <languageKey index="se" type="array">
+        </languageKey>
+        <languageKey index="pt" type="array">
+        </languageKey>
+        <languageKey index="ru" type="array">
+        </languageKey>
+        <languageKey index="ro" type="array">
+        </languageKey>
+        <languageKey index="ch" type="array">
+        </languageKey>
+        <languageKey index="sk" type="array">
+        </languageKey>
+        <languageKey index="lt" type="array">
+        </languageKey>
+        <languageKey index="is" type="array">
+        </languageKey>
+        <languageKey index="hr" type="array">
+        </languageKey>
+        <languageKey index="hu" type="array">
+        </languageKey>
+        <languageKey index="gl" type="array">
+        </languageKey>
+        <languageKey index="th" type="array">
+        </languageKey>
+        <languageKey index="gr" type="array">
+        </languageKey>
+        <languageKey index="hk" type="array">
+        </languageKey>
+        <languageKey index="eu" type="array">
+        </languageKey>
+        <languageKey index="bg" type="array">
+        </languageKey>
+        <languageKey index="br" type="array">
+        </languageKey>
+        <languageKey index="et" type="array">
+        </languageKey>
+        <languageKey index="ar" type="array">
+        </languageKey>
+        <languageKey index="he" type="array">
+        </languageKey>
+        <languageKey index="ua" type="array">
+        </languageKey>
+        <languageKey index="lv" type="array">
+        </languageKey>
+        <languageKey index="jp" type="array">
+        </languageKey>
+        <languageKey index="vn" type="array">
+        </languageKey>
+        <languageKey index="ca" type="array">
+        </languageKey>
+        <languageKey index="ba" type="array">
+        </languageKey>
+        <languageKey index="kr" type="array">
+        </languageKey>
+    </orig_text>
+</T3locallang>
\ No newline at end of file