2 /***************************************************************
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Module: Indexing Engine Overview
30 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 * [CLASS/FUNCTION INDEX of SCRIPT]
37 * 83: class SC_mod_tools_isearch_index
39 * 110: function jumpToUrl(URL)
40 * 133: function menuConfig()
41 * 156: function main()
42 * 193: function printContent()
44 * SECTION: OTHER FUNCTIONS:
45 * 216: function getRecordsNumbers()
46 * 234: function tableHead($str)
47 * 243: function getPhashStat()
48 * 278: function getPhashT3pages()
49 * 347: function getPhashExternalDocs()
50 * 416: function formatFeGroup($fegroup_recs)
51 * 432: function formatCHash($arr)
52 * 447: function getNumberOfSections($phash)
53 * 459: function getNumberOfWords($phash)
54 * 471: function getGrlistRecord($phash)
55 * 487: function getNumberOfFulltext($phash)
56 * 498: function getPhashTypes()
57 * 528: function countUniqueTypes($item_type)
60 * (This index is automatically created/updated by the extension "extdeveval")
67 require ($BACK_PATH."init.php");
68 require ($BACK_PATH."template.php");
69 $BE_USER->modAccess($MCONF,1);
71 t3lib_extMgm
::isLoaded("indexed_search",1);
72 require_once(t3lib_extMgm
::extPath('indexed_search').'class.indexer.php');
77 * Backend module providing boring statistics of the index-tables.
79 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
81 * @subpackage tx_indexedsearch
83 class SC_mod_tools_isearch_index
{
85 var $MOD_MENU=array();
86 var $MOD_SETTINGS=array();
89 * document template object
95 var $include_once=array();
104 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
105 $this->MCONF
= $GLOBALS["MCONF"];
109 $this->doc
= t3lib_div
::makeInstance("noDoc");
110 $this->doc
->form
='<form action="" method="POST">';
111 $this->doc
->backPath
= $BACK_PATH;
113 $this->doc
->JScode
= '
114 <script language="javascript" type="text/javascript">
116 function jumpToUrl(URL) {
117 window.location.href = URL;
121 $this->doc
->tableLayout
= Array (
123 "0" => Array('<td valign="top" nowrap>','</td>'),
124 "defCol" => Array('<TD><img src="'.$this->doc
->backPath
.'clear.gif" width=10 height=1></td><td valign="top" nowrap>','</td>')
128 $indexer = t3lib_div
::makeInstance('tx_indexedsearch_indexer');
129 $indexer->initializeExternalParsers();
130 #debug(array_keys($indexer->external_parsers));
131 #debug($indexer->internal_log);
135 * [Describe function...]
139 function menuConfig() {
140 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
143 // If array, then it's a selector box menu
144 // If empty string it's just a variable, that'll be saved.
145 // Values NOT in this array will not be saved in the settings-array for the module.
146 $this->MOD_MENU
= array(
148 "stat" => "General statistics",
149 "typo3pages" => "List: TYPO3 Pages",
150 "externalDocs" => "List: External documents",
154 $this->MOD_SETTINGS
= t3lib_BEfunc
::getModuleData($this->MOD_MENU
, t3lib_div
::_GP("SET"), $this->MCONF
["name"], "ses");
158 * [Describe function...]
163 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
166 $this->content
.=$this->doc
->startPage("Indexing Engine Statistics");
168 $menu=t3lib_BEfunc
::getFuncMenu(0,"SET[function]",$this->MOD_SETTINGS
["function"],$this->MOD_MENU
["function"]);
170 $this->content
.=$this->doc
->header("Indexing Engine Statistics");
171 $this->content
.=$this->doc
->spacer(5);
172 $this->content
.=$this->doc
->section('',$menu);
174 switch($this->MOD_SETTINGS
["function"]) {
176 $this->content
.=$this->doc
->section('Records',$this->doc
->table($this->getRecordsNumbers()),0,1);
177 $this->content
.=$this->doc
->spacer(15);
178 // $this->content.=$this->doc->section('index_phash STATISTICS',$this->doc->table($this->getPhashStat()),1);
179 // $this->content.=$this->doc->spacer(15);
180 $this->content
.=$this->doc
->section('index_phash TYPES',$this->doc
->table($this->getPhashTypes()),1);
181 $this->content
.=$this->doc
->spacer(15);
184 $this->content
.=$this->doc
->section('External documents',$this->doc
->table($this->getPhashExternalDocs()),0,1);
185 $this->content
.=$this->doc
->spacer(15);
188 $this->content
.=$this->doc
->section('TYPO3 Pages',$this->doc
->table($this->getPhashT3pages()),0,1);
189 $this->content
.=$this->doc
->spacer(15);
195 * [Describe function...]
199 function printContent() {
200 $this->content
.=$this->doc
->endPage();
213 /***************************
217 ***************************/
222 function getRecordsNumbers() {
223 $tables=explode(",","index_phash,index_words,index_rel,index_grlist,index_section,index_fulltext");
226 while(list(,$t)=each($tables)) {
227 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $t, '');
228 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
229 $recList[] = array($this->tableHead($t), $row[0]);
235 * [Describe function...]
237 * @param [type] $str: ...
240 function tableHead($str) {
241 return "<strong>".$str.": </strong>";
245 * [Describe function...]
249 function getPhashStat() {
252 // TYPO3 pages, unique
254 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_page_id!=0', 'phash_grouping,pcount,phash');
255 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
258 $recList[] = array($this->tableHead("TYPO3 pages"), count($items));
261 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_page_id!=0');
262 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
263 $recList[] = array($this->tableHead("TYPO3 pages, raw"), $row[0]);
265 // External files, unique
267 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),phash', 'index_phash', 'data_filename!=\'\'', 'phash_grouping');
268 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
269 $recList[] = array($this->tableHead("External files"), $row[0]);
272 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'data_filename!=\'\'');
273 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
274 $recList[] = array($this->tableHead("External files, raw"), $row[0]);
280 * [Describe function...]
284 function getPhashT3pages() {
286 $this->tableHead("id/type"),
287 $this->tableHead("Title"),
288 $this->tableHead("Size"),
289 $this->tableHead("Words"),
290 $this->tableHead("mtime"),
291 $this->tableHead("Indexed"),
292 $this->tableHead("Updated"),
293 $this->tableHead("Parsetime"),
294 $this->tableHead("#sec/gr/full"),
295 $this->tableHead("#sub"),
296 $this->tableHead("Lang"),
297 $this->tableHead("cHash"),
298 $this->tableHead("phash")
301 // TYPO3 pages, unique
302 $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');
303 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
305 $cHash = count(unserialize($row["cHashParams"])) ?
$this->formatCHash(unserialize($row["cHashParams"])) : "";
306 $grListRec = $this->getGrlistRecord($row["phash"]);
308 $row["data_page_id"].($row["data_page_type"]?
"/".$row["data_page_type"]:""),
309 t3lib_div
::fixed_lgd($row["item_title"],30),
310 t3lib_div
::formatSize($row["item_size"]),
311 $this->getNumberOfWords($row["phash"]),
312 t3lib_BEfunc
::datetime($row["item_mtime"]),
313 t3lib_BEfunc
::datetime($row["crdate"]),
314 ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc
::datetime($row["tstamp"]) : ""),
316 $this->getNumberOfSections($row["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row["phash"]),
317 $row["pcount"]."/".$this->formatFeGroup($grListRec),
318 $row["sys_language_uid"],
323 if ($row["pcount"]>1) {
324 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping='.intval($row['phash_grouping']).' AND phash!='.intval($row['phash']));
325 while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) {
326 $grListRec = $this->getGrlistRecord($row2["phash"]);
330 t3lib_div
::formatSize($row2["item_size"]),
331 $this->getNumberOfWords($row2["phash"]),
332 t3lib_BEfunc
::datetime($row2["item_mtime"]),
333 t3lib_BEfunc
::datetime($row2["crdate"]),
334 ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc
::datetime($row2["tstamp"]) : ""),
336 $this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row2["phash"]),
337 "-/".$this->formatFeGroup($grListRec),
349 * [Describe function...]
353 function getPhashExternalDocs() {
355 $this->tableHead("Filename"),
356 $this->tableHead("Size"),
357 $this->tableHead("Words"),
358 $this->tableHead("mtime"),
359 $this->tableHead("Indexed"),
360 $this->tableHead("Updated"),
361 $this->tableHead("Parsetime"),
362 $this->tableHead("#sec/gr/full"),
363 $this->tableHead("#sub"),
364 $this->tableHead("cHash"),
365 $this->tableHead("phash"),
366 $this->tableHead("Path")
369 // TYPO3 pages, unique
370 $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');
371 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
373 $cHash = count(unserialize($row["cHashParams"])) ?
$this->formatCHash(unserialize($row["cHashParams"])) : "";
374 $grListRec = $this->getGrlistRecord($row["phash"]);
376 t3lib_div
::fixed_lgd($row["item_title"],30),
377 t3lib_div
::formatSize($row["item_size"]),
378 $this->getNumberOfWords($row["phash"]),
379 t3lib_BEfunc
::datetime($row["item_mtime"]),
380 t3lib_BEfunc
::datetime($row["crdate"]),
381 ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc
::datetime($row["tstamp"]) : ""),
383 $this->getNumberOfSections($row["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row["phash"]),
387 t3lib_div
::fixed_lgd($row["data_filename"],100)
390 if ($row["pcount"]>1) {
391 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_phash.*', 'index_phash', 'phash_grouping='.intval($row['phash_grouping']).' AND phash!='.intval($row['phash']));
392 while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) {
393 $cHash = count(unserialize($row2["cHashParams"])) ?
$this->formatCHash(unserialize($row2["cHashParams"])) : "";
394 $grListRec = $this->getGrlistRecord($row2["phash"]);
398 $this->getNumberOfWords($row2["phash"]),
400 t3lib_BEfunc
::datetime($row2["crdate"]),
401 ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc
::datetime($row2["tstamp"]) : ""),
403 $this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row2["phash"]),
417 * [Describe function...]
419 * @param [type] $fegroup_recs: ...
422 function formatFeGroup($fegroup_recs) {
423 reset($fegroup_recs);
425 while(list(,$row)=each($fegroup_recs)) {
426 $str[] = $row["gr_list"]=="0,-1" ?
"NL" : $row["gr_list"];
429 return implode("|",$str);
433 * [Describe function...]
435 * @param [type] $arr: ...
438 function formatCHash($arr) {
441 while(list($k,$v)=each($arr)) {
444 return implode("<BR>",$list);
448 * [Describe function...]
450 * @param [type] $phash: ...
453 function getNumberOfSections($phash) {
454 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_section', 'phash='.intval($phash));
455 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
460 * [Describe function...]
462 * @param [type] $phash: ...
465 function getNumberOfWords($phash) {
466 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_rel', 'phash='.intval($phash));
467 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
472 * [Describe function...]
474 * @param [type] $phash: ...
477 function getGrlistRecord($phash) {
478 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_grlist.*', 'index_grlist', 'phash='.intval($phash));
480 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
481 $row["pcount"] = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
488 * [Describe function...]
490 * @param [type] $phash: ...
493 function getNumberOfFulltext($phash) {
494 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_fulltext', 'phash='.intval($phash));
495 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
500 * [Describe function...]
504 function getPhashTypes() {
516 $revTypes=array_flip($Itypes);
517 $revTypes[0]="TYPO3 page";
519 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*),item_type', 'index_phash', '', 'item_type', 'item_type');
520 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
522 $recList[] = array($this->tableHead($revTypes[$iT]." ($iT)"), $this->countUniqueTypes($iT)."/".$row[0]);
529 * [Describe function...]
531 * @param [type] $item_type: ...
534 function countUniqueTypes($item_type) {
535 // TYPO3 pages, unique
536 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'index_phash', 'item_type='.intval($item_type), 'phash_grouping');
538 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
541 return count($items);
545 // Include extension?
546 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE
]["XCLASS"]["ext/indexed_search/mod/index.php"]) {
547 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]["XCLASS"]["ext/indexed_search/mod/index.php"]);
562 $SOBE = t3lib_div
::makeInstance("SC_mod_tools_isearch_index");
565 $SOBE->printContent();