Documentation TYPO3 par Ameos

index.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
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 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00065 unset($MCONF);
00066 require ("conf.php");
00067 require ($BACK_PATH."init.php");
00068 require ($BACK_PATH."template.php");
00069 $BE_USER->modAccess($MCONF,1);
00070 
00071 t3lib_extMgm::isLoaded("indexed_search",1);
00072 require_once(t3lib_extMgm::extPath('indexed_search').'class.indexer.php');
00073 
00074 
00075 
00083 class SC_mod_tools_isearch_index {
00084         var $MCONF=array();
00085         var $MOD_MENU=array();
00086         var $MOD_SETTINGS=array();
00087         var $doc;
00088 
00089         var $include_once=array();
00090         var $content;
00091 
00097         function init() {
00098                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00099                 $this->MCONF = $GLOBALS["MCONF"];
00100 
00101                 $this->menuConfig();
00102 
00103                 $this->doc = t3lib_div::makeInstance("noDoc");
00104                 $this->doc->form='<form action="" method="POST">';
00105                 $this->doc->backPath = $BACK_PATH;
00106                                 // JavaScript
00107                 $this->doc->JScode = '
00108                 <script language="javascript" type="text/javascript">
00109                         script_ended = 0;
00110                         function jumpToUrl(URL) {
00111                                 window.location.href = URL;
00112                         }
00113                 </script>
00114                 ';
00115                 $this->doc->tableLayout = Array (
00116                         "defRow" => Array (
00117                                 "0" => Array('<td valign="top" nowrap>','</td>'),
00118                                 "defCol" => Array('<TD><img src="'.$this->doc->backPath.'clear.gif" width=10 height=1></td><td valign="top" nowrap>','</td>')
00119                         )
00120                 );
00121 
00122                 $indexer = t3lib_div::makeInstance('tx_indexedsearch_indexer');
00123                 $indexer->initializeExternalParsers();
00124                 #debug(array_keys($indexer->external_parsers));
00125                 #debug($indexer->internal_log);
00126         }
00127 
00133         function menuConfig()   {
00134                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00135 
00136                 // MENU-ITEMS:
00137                         // If array, then it's a selector box menu
00138                         // If empty string it's just a variable, that'll be saved.
00139                         // Values NOT in this array will not be saved in the settings-array for the module.
00140                 $this->MOD_MENU = array(
00141                         "function" => array(
00142                                 "stat" => "General statistics",
00143                                 "typo3pages" => "List: TYPO3 Pages",
00144                                 "externalDocs" => "List: External documents",
00145                         )
00146                 );
00147                         // CLEANSE SETTINGS
00148                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP("SET"), $this->MCONF["name"], "ses");
00149         }
00150 
00156         function main() {
00157                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00158 
00159                 $this->content="";
00160                 $this->content.=$this->doc->startPage("Indexing Engine Statistics");
00161 
00162                 $menu=t3lib_BEfunc::getFuncMenu(0,"SET[function]",$this->MOD_SETTINGS["function"],$this->MOD_MENU["function"]);
00163 
00164                 $this->content.=$this->doc->header("Indexing Engine Statistics");
00165                 $this->content.=$this->doc->spacer(5);
00166                 $this->content.=$this->doc->section('',$menu);
00167 
00168                 switch($this->MOD_SETTINGS["function"]) {
00169                         case "stat":
00170                                 $this->content.=$this->doc->section('Records',$this->doc->table($this->getRecordsNumbers()),0,1);
00171                                 $this->content.=$this->doc->spacer(15);
00172                 //              $this->content.=$this->doc->section('index_phash STATISTICS',$this->doc->table($this->getPhashStat()),1);
00173                 //              $this->content.=$this->doc->spacer(15);
00174                                 $this->content.=$this->doc->section('index_phash TYPES',$this->doc->table($this->getPhashTypes()),1);
00175                                 $this->content.=$this->doc->spacer(15);
00176                         break;
00177                         case "externalDocs":
00178                                 $this->content.=$this->doc->section('External documents',$this->doc->table($this->getPhashExternalDocs()),0,1);
00179                                 $this->content.=$this->doc->spacer(15);
00180                         break;
00181                         case "typo3pages":
00182                                 $this->content.=$this->doc->section('TYPO3 Pages',$this->doc->table($this->getPhashT3pages()),0,1);
00183                                 $this->content.=$this->doc->spacer(15);
00184                         break;
00185                 }
00186         }
00187 
00193         function printContent() {
00194                 $this->content.=$this->doc->endPage();
00195                 echo $this->content;
00196         }
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206 
00207         /***************************
00208          *
00209          * OTHER FUNCTIONS:
00210          *
00211          ***************************/
00212 
00216         function getRecordsNumbers()    {
00217                 $tables=explode(",","index_phash,index_words,index_rel,index_grlist,index_section,index_fulltext");
00218                 $recList=array();
00219                 reset($tables);
00220                 while(list(,$t)=each($tables))  {
00221                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $t, '');
00222                         $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00223                         $recList[] = array($this->tableHead($t), $row[0]);
00224                 }
00225                 return $recList;
00226         }
00227 
00234         function tableHead($str)        {
00235                 return "<strong>".$str.":&nbsp;&nbsp;&nbsp;</strong>";
00236         }
00237 
00243         function getPhashStat() {
00244                 $recList = array();
00245 
00246                         // TYPO3 pages, unique
00247                 $items = array();
00248                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_page_id!=0', 'phash_grouping,pcount,phash');
00249                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00250                         $items[] = $row;
00251                 }
00252                 $recList[] = array($this->tableHead("TYPO3 pages"), count($items));
00253 
00254                         // TYPO3 pages:
00255                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_page_id!=0');
00256                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00257                 $recList[] = array($this->tableHead("TYPO3 pages, raw"), $row[0]);
00258 
00259                         // External files, unique
00260                 $items = array();
00261                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_filename!=\'\'', 'phash_grouping');
00262                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00263                 $recList[] = array($this->tableHead("External files"), $row[0]);
00264 
00265                         // External files
00266                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_filename!=\'\'');
00267                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00268                 $recList[] = array($this->tableHead("External files, raw"), $row[0]);
00269 
00270                 return $recList;
00271         }
00272 
00278         function getPhashT3pages()      {
00279                 $recList[]=array(
00280                         $this->tableHead("id/type"),
00281                         $this->tableHead("Title"),
00282                         $this->tableHead("Size"),
00283                         $this->tableHead("Words"),
00284                         $this->tableHead("mtime"),
00285                         $this->tableHead("Indexed"),
00286                         $this->tableHead("Updated"),
00287                         $this->tableHead("Parsetime"),
00288                         $this->tableHead("#sec/gr/full"),
00289                         $this->tableHead("#sub"),
00290                         $this->tableHead("Lang"),
00291                         $this->tableHead("cHash"),
00292                         $this->tableHead("phash")
00293                 );
00294 
00295                         // TYPO3 pages, unique
00296                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) AS pcount,index_phash.*', 'index_phash', 'data_page_id!=0', 'phash_grouping,phash,cHashParams,data_filename,data_page_id,data_page_reg1,data_page_type,data_page_mp,gr_list,item_type,item_title,item_description,item_mtime,tstamp,item_size,contentHash,crdate,parsetime,sys_language_uid,item_crdate,externalUrl,recordUid,freeIndexUid', 'data_page_id');
00297                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00298 
00299                         $cHash = count(unserialize($row["cHashParams"])) ? $this->formatCHash(unserialize($row["cHashParams"])) : "";
00300                         $grListRec = $this->getGrlistRecord($row["phash"]);
00301                         $recList[] = array(
00302                                 $row["data_page_id"].($row["data_page_type"]?"/".$row["data_page_type"]:""),
00303                                 t3lib_div::fixed_lgd($row["item_title"],30),
00304                                 t3lib_div::formatSize($row["item_size"]),
00305                                 $this->getNumberOfWords($row["phash"]),
00306                                 t3lib_BEfunc::datetime($row["item_mtime"]),
00307                                 t3lib_BEfunc::datetime($row["crdate"]),
00308                                 ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : ""),
00309                                 $row["parsetime"],
00310                                 $this->getNumberOfSections($row["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row["phash"]),
00311                                 $row["pcount"]."/".$this->formatFeGroup($grListRec),
00312                                 $row["sys_language_uid"],
00313                                 $cHash,
00314                                 $row["phash"]
00315                         );
00316 
00317                         if ($row["pcount"]>1)   {
00318                                 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping='.intval($row['phash_grouping']).' AND phash!='.intval($row['phash']));
00319                                 while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2))     {
00320                                         $grListRec = $this->getGrlistRecord($row2["phash"]);
00321                                         $recList[] = array(
00322                                                 "",
00323                                                 "",
00324                                                 t3lib_div::formatSize($row2["item_size"]),
00325                                                 $this->getNumberOfWords($row2["phash"]),
00326                                                 t3lib_BEfunc::datetime($row2["item_mtime"]),
00327                                                 t3lib_BEfunc::datetime($row2["crdate"]),
00328                                                 ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : ""),
00329                                                 $row2["parsetime"],
00330                                                 $this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row2["phash"]),
00331                                                 "-/".$this->formatFeGroup($grListRec),
00332                                                 "",
00333                                                 "",
00334                                                 $row2["phash"]
00335                                         );
00336                                 }
00337                         }
00338                 }
00339                 return $recList;
00340         }
00341 
00347         function getPhashExternalDocs() {
00348                 $recList[]=array(
00349                         $this->tableHead("Filename"),
00350                         $this->tableHead("Size"),
00351                         $this->tableHead("Words"),
00352                         $this->tableHead("mtime"),
00353                         $this->tableHead("Indexed"),
00354                         $this->tableHead("Updated"),
00355                         $this->tableHead("Parsetime"),
00356                         $this->tableHead("#sec/gr/full"),
00357                         $this->tableHead("#sub"),
00358                         $this->tableHead("cHash"),
00359                         $this->tableHead("phash"),
00360                         $this->tableHead("Path")
00361                 );
00362 
00363                         // TYPO3 pages, unique
00364                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*) AS pcount,index_phash.*', 'index_phash', 'item_type>0', 'phash_grouping,phash,cHashParams,data_filename,data_page_id,data_page_reg1,data_page_type,data_page_mp,gr_list,item_type,item_title,item_description,item_mtime,tstamp,item_size,contentHash,crdate,parsetime,sys_language_uid,item_crdate,externalUrl,recordUid,freeIndexUid', 'item_type');
00365                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00366 
00367                         $cHash = count(unserialize($row["cHashParams"])) ? $this->formatCHash(unserialize($row["cHashParams"])) : "";
00368                         $grListRec = $this->getGrlistRecord($row["phash"]);
00369                         $recList[]=array(
00370                                 t3lib_div::fixed_lgd($row["item_title"],30),
00371                                 t3lib_div::formatSize($row["item_size"]),
00372                                 $this->getNumberOfWords($row["phash"]),
00373                                 t3lib_BEfunc::datetime($row["item_mtime"]),
00374                                 t3lib_BEfunc::datetime($row["crdate"]),
00375                                 ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : ""),
00376                                 $row["parsetime"],
00377                                 $this->getNumberOfSections($row["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row["phash"]),
00378                                 $row["pcount"],
00379                                 $cHash,
00380                                 $row["phash"],
00381                                 t3lib_div::fixed_lgd($row["data_filename"],100)
00382                         );
00383 
00384                         if ($row["pcount"]>1)   {
00385                                 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping='.intval($row['phash_grouping']).' AND phash!='.intval($row['phash']));
00386                                 while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2))     {
00387                                         $cHash = count(unserialize($row2["cHashParams"])) ? $this->formatCHash(unserialize($row2["cHashParams"])) : "";
00388                                         $grListRec = $this->getGrlistRecord($row2["phash"]);
00389                                         $recList[]=array(
00390                                                 "",
00391                                                 "",
00392                                                 $this->getNumberOfWords($row2["phash"]),
00393                                                 "",
00394                                                 t3lib_BEfunc::datetime($row2["crdate"]),
00395                                                 ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : ""),
00396                                                 $row2["parsetime"],
00397                                                 $this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row2["phash"]),
00398                                                 "",
00399                                                 $cHash,
00400                                                 $row2["phash"],
00401                                                 ""
00402                                         );
00403                                 }
00404                         }
00405         //              debug($row);
00406                 }
00407                 return $recList;
00408         }
00409 
00416         function formatFeGroup($fegroup_recs)   {
00417                 reset($fegroup_recs);
00418                 $str = array();
00419                 while(list(,$row)=each($fegroup_recs))  {
00420                         $str[] = $row["gr_list"]=="0,-1" ? "NL" : $row["gr_list"];
00421                 }
00422                 arsort($str);
00423                 return implode("|",$str);
00424         }
00425 
00432         function formatCHash($arr)      {
00433                 reset($arr);
00434                 $list=array();
00435                 while(list($k,$v)=each($arr))   {
00436                         $list[]=$k."=".$v;
00437                 }
00438                 return implode("<BR>",$list);
00439         }
00440 
00447         function getNumberOfSections($phash)    {
00448                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_section', 'phash='.intval($phash));
00449                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00450                 return $row[0];
00451         }
00452 
00459         function getNumberOfWords($phash)       {
00460                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_rel', 'phash='.intval($phash));
00461                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00462                 return $row[0];
00463         }
00464 
00471         function getGrlistRecord($phash)        {
00472                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_grlist.*', 'index_grlist', 'phash='.intval($phash));
00473                 $allRows = array();
00474                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00475                         $row["pcount"] = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
00476                         $allRows[] = $row;
00477                 }
00478                 return $allRows;
00479         }
00480 
00487         function getNumberOfFulltext($phash)    {
00488                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_fulltext', 'phash='.intval($phash));
00489                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00490                 return $row[0];
00491         }
00492 
00498         function getPhashTypes()        {
00499                 $recList=array();
00500 
00501                 // Types:
00502                 $Itypes = array(
00503                         "html" => 1,
00504                         "htm" => 1,
00505                         "pdf" => 2,
00506                         "doc" => 3,
00507                         "txt" => 4
00508                 );
00509 
00510                 $revTypes=array_flip($Itypes);
00511                 $revTypes[0]="TYPO3 page";
00512 
00513                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),item_type', 'index_phash', '', 'item_type', 'item_type');
00514                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00515                         $iT = $row[1];
00516                         $recList[] = array($this->tableHead($revTypes[$iT]." ($iT)"), $this->countUniqueTypes($iT)."/".$row[0]);
00517                 }
00518 
00519                 return $recList;
00520         }
00521 
00528         function countUniqueTypes($item_type)   {
00529                         // TYPO3 pages, unique
00530                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'item_type='.intval($item_type), 'phash_grouping');
00531                 $items = array();
00532                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
00533                         $items[] = $row;
00534                 }
00535                 return count($items);
00536         }
00537 }
00538 
00539 // Include extension?
00540 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/mod/index.php"])        {
00541         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/mod/index.php"]);
00542 }
00543 
00544 
00545 
00546 
00547 
00548 
00549 
00550 
00551 
00552 
00553 
00554 
00555 // Make instance:
00556 $SOBE = t3lib_div::makeInstance("SC_mod_tools_isearch_index");
00557 $SOBE->init();
00558 $SOBE->main();
00559 $SOBE->printContent();
00560 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6