[Typo3-dev] index search and 3.6

Olivier Simah noname_paris at yahoo.fr
Tue Mar 9 16:32:17 CET 2004


I had a lot of problem to make the Indexed Search work with PDF and WORD
documents under Windows 2000
The reason: LONG NAMES !!!

Here are the changes I have Made to make that work perfectly (cf. changes
http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=16&tx_extrepmgm_pi1[tocEl]=43&cHash=f356fa37fd)

All the change have to be made in the file "class.indexer.php"

first of all add the function
     function longToShort( $myFile )
     {
      //create FSO instance
      $exFSO = new COM("Scripting.FileSystemObject") or die ("Could not
create Scripting.FileSystemObject");

      //get file objects
      $exFile = $exFSO->GetFile( $myFile );
      return $exFile->ShortPath;
     }

Then change the function "readFileContent($ext,$absFile,$cPKey)"
By :

function readFileContent($ext,$absFile,$cPKey) {
/************************
************************/
 define("TYPO3_OS",
stristr(PHP_OS,"win")&&!stristr(PHP_OS,"darwin")?"WIN":""); // lg
 if( TYPO3_OS == "WIN" )
 {
  $absFile2 = $this->longToShort( $absFile ) ;
 }
 else
  $absFile2 = $absFile;
/************************
************************/
  switch ($ext) {
   case "pdf":
    if ($this->app["pdfinfo"]) {
#debug($this->app);
      // Getting pdf-info:
     $cmd = $this->app["pdfinfo"]." ".$absFile2;
     exec($cmd,$res);
     $pdfInfo=$this->splitPdfInfo($res);

     if (intval($pdfInfo["pages"])) {
      list($low,$high) = explode("-",$cPKey);

       // Get pdf content:
      $tempFileName = tempnam("","Typo3_indexer");  // Create temporary name
      @unlink ($tempFileName); // Delete if exists, just to be safe.
      $cmd = $this->app["pdftotext"]." -f ".$low." -l ".$high." -q
".$absFile." ".$tempFileName;
 //     debug($cmd,1);
      exec($cmd,$res);
      if (@is_file($tempFileName)) {
       $content = t3lib_div::getUrl($tempFileName);
       unlink($tempFileName);
      } else {
       $GLOBALS["TT"]->setTSlogMessage("PDFtoText Failed on this document:
".$absFile.". Maybe the PDF file is locked for printing or encrypted.",2);
      }
      $contentArr = $this->splitRegularContent($content);
     }
    }
   break;
   case "doc":
    if ($this->app["catdoc"]) {
     $cmd = $this->app["catdoc"]." ".$absFile2;
     exec($cmd,$res);
     $content = implode(chr(10),$res);
     $contentArr = $this->splitRegularContent($content);
    }
   break;
   case "txt":
    $content = t3lib_div::getUrl($absFile);
    $contentArr = $this->splitRegularContent($content);
   break;
   case "html":
   case "htm":
    $fileContent = t3lib_div::getUrl($absFile);
    $contentArr = $this->splitHTMLContent($fileContent);
   break;
   default:
    return false;
   break;
  }
   // If no title (and why should there be...) then the file-name is set as
title. This will raise the hits considerably if the search matches the
document name.
  if (!$contentArr["title"]) {
   $contentArr["title"]=str_replace("_"," ",basename($absFile)); //
Substituting "_" for " " because many filenames may have this instead of a
space char.
  }
  return $contentArr;
 }


"Chi Hoang" <hoang at planb-media.de> wrote in message
news:mailman.1.1078841006.13730.typo3-dev at lists.netfielders.de...
> dan frost wrote:
> > Ok - does it work with Pdfs and Words docs?
> > dan
>
> I dont know, Im not using pdfs and word. Sorry :)
>
>
> Greets,
>
> Chi
>
>






More information about the TYPO3-dev mailing list