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  ***************************************************************/
00046 require_once(PATH_t3lib."class.t3lib_extobjbase.php");
00047 require_once(PATH_t3lib."class.t3lib_tsfebeuserauth.php");
00048 
00049 
00050 class tx_indexedsearch_modfunc2 extends t3lib_extobjbase {
00051 
00057         function main() {
00058 
00059                         // Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
00060                 global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00061 
00062                 $theOutput.=$this->pObj->doc->spacer(5);
00063                 $theOutput.=$this->pObj->doc->section($LANG->getLL('title'),$this->showStats(),0,1);
00064 
00065                 $menu=array();
00066                 $menu[]=t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[tx_indexedsearch_modfunc2_check]",$this->pObj->MOD_SETTINGS["tx_indexedsearch_modfunc2_check"]).$LANG->getLL("checklabel");
00067                 $theOutput.=$this->pObj->doc->spacer(5);
00068 
00069                 return $theOutput;
00070         }
00071 
00072 
00079         function showStats() {
00080                 global $LANG,$HTTP_GET_VARS,$TYPO3_CONF_VARS;
00081 
00082                 $conf['words']=50;                              //max words in result list
00083                 $conf['bid']=$HTTP_GET_VARS['id'];  //pageid for several statistics
00084 
00085                 $addwhere1='';                                                                          //for all
00086                 $addwhere2=" AND tstamp > ".(time()-30*24*60*60);       //for last 30 days
00087                 $addwhere3=" AND tstamp > ".(time()-24*60*60);          //for last 24 hours
00088 
00089                 $content.= $LANG->getLL('title2').'
00090                         <table cellpading="5" cellspacing="5" valign=top><tr><td valign=top>'
00091                         .$this->listSeveralStats($LANG->getLL("all"),$addwhere1,$conf).'</td><td valign=top>'
00092                         .$this->listSeveralStats($LANG->getLL("last30days"),$addwhere2,$conf).'</td><td valign=top>'
00093                         .$this->listSeveralStats($LANG->getLL("last24hours"),$addwhere3,$conf).'</td></tr></table>'
00094                         .$this->note;
00095 
00096                 return $content;
00097         }
00098 
00107         function listSeveralStats($title,$addwhere,$conf) {
00108                 global $LANG;
00109 
00110                 $queryParts['SELECT']= "* , count( * ) AS c";
00111                 $queryParts['FROM']="index_stat_word";
00112                 $queryParts['WHERE']=sprintf("pageid= %s ".$addwhere, $conf['bid']);
00113                 $queryParts['GROUPBY']="word";
00114                 $queryParts['ORDERBY']="c DESC,word";
00115                 $queryParts['LIMIT']=$conf['words'];
00116 
00117                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00118                                 $queryParts['SELECT'],
00119                                 $queryParts['FROM'],
00120                                 $queryParts['WHERE'],
00121                                 $queryParts['GROUPBY'],
00122                                 $queryParts['ORDERBY'],
00123                                 $queryParts['LIMIT']
00124                         );
00125 
00126                 if ( $res ) {
00127                         $count = $GLOBALS['TYPO3_DB']->sql_num_rows( $res );
00128                 }else{
00129                         $count = 0;
00130                 }
00131 
00132                 // exist several statistics for this page?
00133                 if( $count > 0 ){
00134                         $this->note =   $LANG->getLL("justthispage");
00135                 }else{
00136                         // Limit access to pages of the current site
00137                         $secureaddwhere = " AND pageid IN (".($this->extGetTreeList($conf['bid'],100,0,'1')).$conf['bid'].") ";
00138                         $this->note = $LANG->getLL("allpages");
00139 
00140                         $queryParts['WHERE']= '1 '.$addwhere.$secureaddwhere;
00141                 }
00142 
00143                 //make real query
00144                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00145                                 $queryParts['SELECT'],
00146                                 $queryParts['FROM'],
00147                                 $queryParts['WHERE'],
00148                                 $queryParts['GROUPBY'],
00149                                 $queryParts['ORDERBY'],
00150                                 $queryParts['LIMIT']
00151                 );
00152 
00153                 $table1='';
00154                 $i=0;
00155                 if( $res ){
00156                         while( $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc( $res ) ) {
00157                                 $i++;
00158                                 $table1.='<tr class="bgColor4"><td>'.$i.'.</td><td>'.$row['word'].'</td><td>&nbsp;&nbsp;'.$row['c'].'</td></tr>';
00159                         }
00160                 }
00161 
00162                 if( $i==0 ){
00163                         $table1='<tr class="bgColor4"><td callspan="3">'.$LANG->getLL("noresults").'</td></tr>';
00164                 }
00165 
00166                 $table1='<table class="bgColor5" cellpadding="2" cellspacing="1"><tr class="tableheader"><td colspan="3">'.$title.'</td></tr>'.$table1.'</table>';
00167 
00168 
00169                 return $note.$table1;
00170         }
00171 
00186         function extGetTreeList($id,$depth,$begin = 0,$perms_clause){
00187                 return t3lib_tsfeBeUserAuth::extGetTreeList($id,$depth,$begin,$perms_clause);
00188         }
00189 
00190 
00191 }
00192 
00193 
00194 
00195 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/modfunc2/class.tx_indexedsearch_modfunc2.php"]) {
00196         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/modfunc2/class.tx_indexedsearch_modfunc2.php"]);
00197 }
00198 
00199 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6