Documentation TYPO3 par Ameos

class.tx_indexedsearch_modfunc2.php

00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 2004 Dimitri Ebert (dimitri.ebert@dkd.de)
00006  *  All rights reserved
00007  *
00008  *  This script is part of the TYPO3 project. The TYPO3 project is
00009  *  free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  The GNU General Public License can be found at
00015  *  http://www.gnu.org/copyleft/gpl.html.
00016  *
00017  *  This script is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *  GNU General Public License for more details.
00021  *
00022  *  This copyright notice MUST APPEAR in all copies of the script!
00023  ***************************************************************/
00047 require_once(PATH_t3lib.'class.t3lib_extobjbase.php');
00048 require_once(PATH_t3lib.'class.t3lib_tsfebeuserauth.php');
00049 
00050 
00051 
00052 
00060 class tx_indexedsearch_modfunc2 extends t3lib_extobjbase {
00061 
00067         function main() {
00068                         // Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
00069                 global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00070 
00071                 $theOutput.=$this->pObj->doc->spacer(5);
00072                 $theOutput.=$this->pObj->doc->section($LANG->getLL('title'),$this->showStats(),0,1);
00073 
00074                 $menu=array();
00075                 $menu[]=t3lib_BEfunc::getFuncCheck($this->pObj->id,'SET[tx_indexedsearch_modfunc2_check]',$this->pObj->MOD_SETTINGS['tx_indexedsearch_modfunc2_check']).$LANG->getLL('checklabel');
00076                 $theOutput.=$this->pObj->doc->spacer(5);
00077 
00078                 return $theOutput;
00079         }
00080 
00081 
00088         function showStats()    {
00089                 global $LANG,$HTTP_GET_VARS,$TYPO3_CONF_VARS;
00090 
00091                 $conf['words']=50;      // max words in result list
00092                 $conf['bid']=$HTTP_GET_VARS['id'];      // pageid for several statistics
00093 
00094                 $addwhere1='';  // all records
00095                 $addwhere2=' AND tstamp > '.(time()-30*24*60*60);       // last 30 days
00096                 $addwhere3=' AND tstamp > '.(time()-24*60*60);          // last 24 hours
00097 
00098                 $content.= $LANG->getLL('title2').'
00099                         <table cellpading="5" cellspacing="5" valign="top"><tr><td valign="top">'
00100                         .$this->listSeveralStats($LANG->getLL('all'),$addwhere1,$conf).'</td><td valign="top">'
00101                         .$this->listSeveralStats($LANG->getLL('last30days'),$addwhere2,$conf).'</td><td valign="top">'
00102                         .$this->listSeveralStats($LANG->getLL('last24hours'),$addwhere3,$conf).'</td></tr></table>'
00103                         .$this->note;
00104 
00105                         // Ask hook to include more on the page:
00106                 if ($hookObj = &$this->hookRequest('additionalSearchStat'))     {
00107                         $content.= $hookObj->additionalSearchStat();
00108                 }
00109 
00110                 return $content;
00111         }
00112 
00121         function listSeveralStats($title,$addwhere,$conf)       {
00122                 global $LANG;
00123 
00124                 $queryParts['SELECT']= '*, COUNT(*) AS c';
00125                 $queryParts['FROM']='index_stat_word';
00126                 $queryParts['WHERE']=sprintf('pageid= %s '.$addwhere, $conf['bid']);
00127                 $queryParts['GROUPBY']='word';
00128                 $queryParts['ORDERBY']='c DESC,word';
00129                 $queryParts['LIMIT']=$conf['words'];
00130 
00131                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00132                                 $queryParts['SELECT'],
00133                                 $queryParts['FROM'],
00134                                 $queryParts['WHERE'],
00135                                 $queryParts['GROUPBY'],
00136                                 $queryParts['ORDERBY'],
00137                                 $queryParts['LIMIT']
00138                         );
00139 
00140                 if ($res)       {
00141                         $count = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
00142                 } else {
00143                         $count = 0;
00144                 }
00145 
00146                         // exist several statistics for this page?
00147                 if ($count > 0) {
00148                         $this->note =   $LANG->getLL('justthispage');
00149                 } else {
00150                                 // Limit access to pages of the current site
00151                         $secureaddwhere = ' AND pageid IN ('.($this->extGetTreeList($conf['bid'],100,0,'1')).$conf['bid'].') ';
00152                         $this->note = $LANG->getLL('allpages');
00153 
00154                         $queryParts['WHERE']= '1 '.$addwhere.$secureaddwhere;
00155                 }
00156 
00157                         // make real query
00158                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00159                                 $queryParts['SELECT'],
00160                                 $queryParts['FROM'],
00161                                 $queryParts['WHERE'],
00162                                 $queryParts['GROUPBY'],
00163                                 $queryParts['ORDERBY'],
00164                                 $queryParts['LIMIT']
00165                 );
00166 
00167                 $table1='';
00168                 $i=0;
00169                 if ($res)       {
00170                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
00171                                 $i++;
00172                                 $table1.='<tr class="bgColor4"><td>'.$i.'.</td><td>'.$row['word'].'</td><td>&nbsp;&nbsp;'.$row['c'].'</td></tr>';
00173                         }
00174                 }
00175 
00176                 if ($i==0)      {
00177                         $table1='<tr class="bgColor4"><td callspan="3">'.$LANG->getLL("noresults").'</td></tr>';
00178                 }
00179 
00180                 $table1='<table class="bgColor5" cellpadding="2" cellspacing="1"><tr class="tableheader"><td colspan="3">'.$title.'</td></tr>'.$table1.'</table>';
00181 
00182                 return $note.$table1;
00183         }
00184 
00199         function extGetTreeList($id,$depth,$begin = 0,$perms_clause)    {
00200                 return t3lib_tsfeBeUserAuth::extGetTreeList($id,$depth,$begin,$perms_clause);
00201         }
00202 
00210         function &hookRequest($functionName)    {
00211                 global $TYPO3_CONF_VARS;
00212 
00213                         // Hook: menuConfig_preProcessModMenu
00214                 if ($TYPO3_CONF_VARS['EXTCONF']['indexed_search']['be_hooks'][$functionName])   {
00215                         $hookObj = &t3lib_div::getUserObj($TYPO3_CONF_VARS['EXTCONF']['indexed_search']['be_hooks'][$functionName]);
00216                         if (method_exists ($hookObj, $functionName))    {
00217                                 $hookObj->pObj = &$this;
00218                                 return $hookObj;
00219                         }
00220                 }
00221         }
00222 }
00223 
00224 
00225 
00226 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/indexed_search/modfunc2/class.tx_indexedsearch_modfunc2.php']) {
00227         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/indexed_search/modfunc2/class.tx_indexedsearch_modfunc2.php']);
00228 }
00229 
00230 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6