Documentation TYPO3 par Ameos

class.tx_indexedsearch_modfunc1.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *  
00005 *  (c) 2001-2004 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 * 
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 ***************************************************************/
00032 require_once(PATH_t3lib."class.t3lib_pagetree.php");
00033 require_once(PATH_t3lib."class.t3lib_extobjbase.php");
00034 require_once(t3lib_extMgm::extPath("indexed_search")."class.indexer.php");
00035 
00036 class tx_indexedsearch_modfunc1 extends t3lib_extobjbase {
00037         var $allPhashListed=array();
00038         
00039     function modMenu()    {
00040         global $LANG;
00041         
00042                 return array (
00043                         "depth" => array(
00044                                 0 => $LANG->sL("LLL:EXT:lang/locallang_core.php:labels.depth_0"),
00045                                 1 => $LANG->sL("LLL:EXT:lang/locallang_core.php:labels.depth_1"),
00046                                 2 => $LANG->sL("LLL:EXT:lang/locallang_core.php:labels.depth_2"),
00047                                 3 => $LANG->sL("LLL:EXT:lang/locallang_core.php:labels.depth_3"),
00048                         )
00049                 );
00050     }
00051 
00052     function main()    {
00053             // Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
00054         global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00055         
00056                 if ($this->pObj->id<=0) return;
00057 
00058                 if (t3lib_div::_GP("deletePhash"))      {
00059                         $indexer = t3lib_div::makeInstance("tx_indexedsearch_indexer");
00060                         $indexer->removeIndexedPhashRow(t3lib_div::_GP("deletePhash"));
00061                 }
00062 
00063 
00064 
00065                 $h_func = t3lib_BEfunc::getFuncMenu($this->pObj->id,"SET[depth]",$this->pObj->MOD_SETTINGS["depth"],$this->pObj->MOD_MENU["depth"],"index.php");
00066                 
00067 
00068         $theOutput.=$this->pObj->doc->spacer(5);
00069         $theOutput.=$this->pObj->doc->section($LANG->getLL("title"),$h_func,0,1);
00070 
00071 
00072 
00073                         // Drawing tree:
00074                 $tree = t3lib_div::makeInstance("t3lib_pageTree");
00075                 $perms_clause = $GLOBALS["BE_USER"]->getPagePermsClause(1);
00076                 $tree->init("AND ".$perms_clause);
00077                 
00078                 $HTML='<IMG src="'.$BACK_PATH.t3lib_iconWorks::getIcon("pages",$this->pObj->pageinfo).'" width="18" height="16" align="top">';
00079                 $tree->tree[]=Array("row"=>$this->pObj->pageinfo,"HTML"=>$HTML);
00080                 if ($this->pObj->MOD_SETTINGS["depth"]) {
00081                         $tree->getTree($this->pObj->id,$this->pObj->MOD_SETTINGS["depth"],"");
00082                 }
00083                 
00084                 // 
00085                 $code='';
00086                 
00087                 reset($tree->tree);
00088                 while(list(,$data)=each($tree->tree))   {
00089                         $bgCol="";
00090                         $tLen=20;
00091                         $code.='<tr>
00092                                 <td align="left" nowrap'.$bgCol.' valign=top>'.$data["HTML"].t3lib_div::fixed_lgd($data["row"]["title"],$tLen).'&nbsp;</td>
00093                                 ';
00094 
00095                         $code.='<td valign=top>'.$this->indexed_info($data["row"]).'</td>';
00096                         $code.='</tr>';
00097                 }
00098 
00099 
00100 
00101                 $code='<table border=0 cellspacing=0 cellpadding=1>
00102                         <tr>
00103                                 <td></td>
00104                                 <td valign=top><table border=0 cellpadding=0 cellspacing=1>'.$this->printPhashRowHeader().'</table></td>
00105                         </tr>'.$code.'</table>';
00106                 
00107         $theOutput.=$this->pObj->doc->section("",$code,0,1);
00108         
00109         return $theOutput;
00110     }
00111         
00112         
00113         function indexed_info($data)    {
00114                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00115                                         'ISEC.*, IP.*, count(*) as count_val',
00116                                         'index_phash AS IP, index_section AS ISEC',
00117                                         'IP.phash = ISEC.phash AND ISEC.page_id = '.intval($data['uid']),
00118                                         'IP.phash', 
00119                                         'IP.crdate'
00120                                 );
00121                 $lines = array();
00122                 $phashAcc = array();
00123                 $phashAcc[] = 0;
00124                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00125                         $extraGrListRows = $this->getGrListEntriesForPhash($row["phash"],$row["gr_list"]);
00126                         if (isset($lines[$row["phash_grouping"]]))      {
00127                                 $lines[$row["phash_grouping"]].= $this->printPhashRow($row,1,$extraGrListRows);
00128                         } else {
00129                                 $lines[$row["phash_grouping"]] = $this->printPhashRow($row,0,$extraGrListRows);
00130                         }
00131                         $phashAcc[] = $row["phash"];
00132                         $this->allPhashListed[] = $row["phash"];
00133                 }
00134                 $out = implode("",$lines);
00135                 $out = '<table border=0 cellpadding=0 cellspacing=1>'.$out.'</table>';
00136                 
00137 
00138                         // Checking for phash-rows which are NOT joined with the section table:         
00139                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('IP.*', 'index_phash AS IP', 'IP.data_page_id = '.intval($data['uid']).' AND IP.phash NOT IN ('.implode(',',$phashAcc).')');
00140                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00141                         $out.= '<span class="typo3-red">Warning:</span> phash-row "'.$row["phash"].'" didn\'t have a representation in the index_section table!'.'<br>';
00142                         $this->allPhashListed[] = $row["phash"];
00143                 }
00144                 
00145                 return $out;
00146         }
00147         function printPhashRow($row,$grouping=0,$extraGrListRows)       {
00148 #debug($row);
00149                 $lines=array();
00150                 if (!$grouping) {
00151                         $lines[]='<td valign=top>'.$this->makeItemTypeIcon($row["item_type"],$row["data_filename"]?$row["data_filename"]:$row["item_title"]).'</td>';
00152                 } else {
00153                         $lines[]='<td valign=top class="bgColor">&nbsp;</td>';
00154                 }
00155                 $lines[]='<td valign=top nowrap>'.t3lib_div::fixed_lgd($row["item_title"],20).$this->clearGif(120).'</td>';
00156                 $lines[]='<td valign=top nowrap>'.$this->printRemoveIndexed($row["phash"]).'</td>';
00157 
00158                 $lines[]='<td valign=top nowrap>'.$row["phash"].$this->clearGif(80).'</td>';
00159                 $lines[]='<td valign=top nowrap>'.$row["contentHash"].$this->clearGif(80).'</td>';
00160                 $lines[]='<td valign=top nowrap>'.$row["rl0"].'.'.$row["rl1"].'.'.$row["rl2"].$this->clearGif(50).'</td>';
00161                 $lines[]='<td valign=top nowrap>'.($row["item_type"]?"":$row["data_page_id"].'.'.$row["data_page_type"].'.'.$row["sys_language_uid"].($row["data_page_mp"]?'.'.$row["data_page_mp"]:"")).$this->clearGif(50).'</td>';
00162                 $lines[]='<td valign=top nowrap>'.t3lib_div::formatSize($row["item_size"]).$this->clearGif(40).'</td>';
00163                 $lines[]='<td valign=top nowrap>'.$row["gr_list"].$this->printExtraGrListRows($extraGrListRows).$this->clearGif(45).'</td>';
00164                 $arr = unserialize($row["cHashParams"]);
00165                 unset($arr["cHash"]);
00166                 unset($arr["encryptionKey"]);
00167                 if ($row["item_type"]==2)       {       // pdf...
00168                         $lines[]='<td valign=top nowrap>Page '.$arr["key"].'</td>';
00169                 } elseif ($row["item_type"]==0) {
00170                         $lines[]='<td valign=top nowrap'.(count($arr)?'':' class="bgColor"').'>'.htmlspecialchars(t3lib_div::implodeArrayForUrl("",$arr)).'</td>';
00171                 } else {
00172                         $lines[]='<td valign=top class="bgColor"></td>';
00173                 }
00174                 
00175                 $out = '<tr'.($row["count_val"]!=1?' bgcolor="red"':' class="bgColor4"').'>'.implode("",$lines).'</tr>';
00176                 return $out;
00177         }
00178         function printRemoveIndexed($phash,$alt="Clear phash-row")      {
00179                 return '<a href="'.t3lib_div::linkThisScript(array("deletePhash"=>$phash)).'"><img src="'.$GLOBALS["BACK_PATH"].'gfx/garbage.gif" width="11" hspace=1 vspace=2 height="12" border="0" alt="'.$alt.'"></a>';
00180         }
00181         function printPhashRowHeader()  {
00182                 $lines=array();
00183                 $lines[]='<td>&nbsp;'.$this->clearGif(18).'</td>';
00184                 $lines[]='<td nowrap><strong>Title</strong>'.$this->clearGif(120).'</td>';
00185 #               $lines[]='<td>&nbsp;'.$this->clearGif(13).'</td>';
00186                 $lines[]='<td bgcolor="red">'.$this->printRemoveIndexed(implode(",",$this->allPhashListed),"Clear ALL phash-rows below!").'</td>';
00187 
00188                 $lines[]='<td nowrap><strong>pHash</strong>'.$this->clearGif(80).'</td>';
00189                 $lines[]='<td nowrap><strong>cHash</strong>'.$this->clearGif(80).'</td>';
00190                 $lines[]='<td nowrap><strong>rl-012</strong>'.$this->clearGif(50).'</td>';
00191                 $lines[]='<td nowrap><strong>pid.t.l</strong>'.$this->clearGif(50).'</td>';
00192                 $lines[]='<td nowrap><strong>Size</strong>'.$this->clearGif(40).'</td>';
00193                 $lines[]='<td nowrap><strong>grlist</strong>'.$this->clearGif(45).'</td>';
00194                 $lines[]='<td nowrap><strong>cHashParams</strong>'.$this->clearGif(50).'</td>';
00195                 
00196                 $out = '<tr class="bgColor5">'.implode("",$lines).'</tr>';
00197                 return $out;
00198         }
00199         function printExtraGrListRows($extraGrListRows) {
00200                 if (count($extraGrListRows))    {
00201                         reset($extraGrListRows);
00202                         $lines=array();
00203                         while(list(,$r)=each($extraGrListRows)) {
00204                                 $lines[]=$r["gr_list"];
00205                         }
00206                         return "<BR>".$GLOBALS["TBE_TEMPLATE"]->dfw(implode("<BR>",$lines));
00207                 }
00208         }
00209         function clearGif($width)       {
00210                 return '<br><img src=clear.gif width='.$width.' height=1>';
00211         }
00212         function getGrListEntriesForPhash($phash,$gr_list)      {
00213                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'index_grlist', 'phash='.intval($phash));
00214                 $lines = array();
00215                 $isRemoved = 0;
00216                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00217                         if (!$isRemoved && !strcmp($row["gr_list"],$gr_list))   {
00218                                 $isRemoved = 1;
00219                         } else {
00220                                 $lines[] = $row;
00221                         }
00222                 }
00223                 return $lines;
00224         }
00225 
00226         function makeItemTypeIcon($it,$alt="")  {
00227                 switch($it)     {
00228                         case 1:
00229                                 $icon="html.gif";
00230                         break;
00231                         case 2:
00232                                 $icon="pdf.gif";
00233                         break;
00234                         case 3:
00235                                 $icon="doc.gif";
00236                         break;
00237                         case 4:
00238                                 $icon="txt.gif";
00239                         break;
00240                         default:
00241                                 $icon="pages.gif";
00242                         break;
00243                 }
00244                 $fullPath = t3lib_extMgm::extPath("indexed_search").'pi/res/'.$icon;
00245                 $info = @getimagesize($fullPath);
00246                 $iconPath = $GLOBALS["BACK_PATH"].t3lib_extMgm::extRelPath("indexed_search").'pi/res/'.$icon;
00247                 return is_array($info) ? '<img src="'.$iconPath.'" '.$info[3].' title="'.htmlspecialchars($alt).'">' : '';
00248         }
00249         
00250         
00251         
00252 }
00253 
00254 
00255 
00256 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/modfunc1/class.tx_indexedsearch_modfunc1.php"])    {
00257     include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/indexed_search/modfunc1/class.tx_indexedsearch_modfunc1.php"]);
00258 }
00259 
00260 ?>


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