package.xml 0000644 0001750 0001750 00000005563 12025431726 012566 0 ustar steinm steinm
LetoDMS_Lucene
pear.php.net
Fulltext search for LetoDMS
LetoDMS is a web based document management system (DMS). This is
the fulltext search engine for it, based on Lucene.
Uwe Steinmann
steinm
uwe@steinmann.cx
yes
2012-09-16
1.0.2
1.0.0
stable
stable
GPL License
- set Zend analyser to utf8 case insensitive
- use stop words list propperly
4.3.0
1.5.4
0.0.1
0.0.1
alpha
alpha
2009-04-27
BSD License
2011-11-06
1.0.1
1.0.0
beta
beta
GPL License
- New Release
LetoDMS_Lucene-1.0.2/Lucene/Indexer.php 0000644 0001750 0001750 00000001631 12025431726 017161 0 ustar steinm steinm
* @copyright Copyright (C) 2010, Uwe Steinmann
* @version Release: 1.0.2
*/
/**
* Class for managing a lucene index.
*
* @category DMS
* @package LetoDMS_Lucene
* @version @version@
* @author Uwe Steinmann
* @copyright Copyright (C) 2011, Uwe Steinmann
* @version Release: 1.0.2
*/
class LetoDMS_Lucene_Indexer extends Zend_Search_Lucene {
/**
* @var string $indexname name of lucene index
* @access protected
*/
protected $indexname;
/**
* Create a new index
*
* @return object instance of LetoDMS_Lucene_Search
*/
function __construct() { /* {{{ */
$this->version = '1.0.2';
if($this->version[0] == '@')
$this->version = '3.0.0';
} /* }}} */
}
?>
LetoDMS_Lucene-1.0.2/Lucene/Search.php 0000644 0001750 0001750 00000003200 12025431726 016762 0 ustar steinm steinm
* @copyright Copyright (C) 2010, Uwe Steinmann
* @version Release: 1.0.2
*/
/**
* Class for searching in a lucene index.
*
* @category DMS
* @package LetoDMS_Lucene
* @version @version@
* @author Uwe Steinmann
* @copyright Copyright (C) 2011, Uwe Steinmann
* @version Release: 1.0.2
*/
class LetoDMS_Lucene_Search {
/**
* @var object $index lucene index
* @access protected
*/
protected $index;
/**
* Create a new instance of the search
*
* @param object $index lucene index
* @return object instance of LetoDMS_Lucene_Search
*/
function __construct($index) { /* {{{ */
$this->index = $index;
$this->version = '1.0.2';
if($this->version[0] == '@')
$this->version = '3.0.0';
} /* }}} */
/**
* Search in index
*
* @param object $index lucene index
* @return object instance of LetoDMS_Lucene_Search
*/
function search($term, $owner, $status='', $categories=array()) { /* {{{ */
$query = '';
if($term)
$query .= trim($term);
if($owner) {
if($query)
$query .= ' && ';
$query .= 'owner:'.$owner;
}
if($categories) {
if($query)
$query .= ' && ';
$query .= '(category:"';
$query .= implode('" || category:"', $categories);
$query .= '")';
}
$hits = $this->index->find($query);
$recs = array();
foreach($hits as $hit) {
$recs[] = array('id'=>$hit->id, 'document_id'=>$hit->document_id);
}
return $recs;
} /* }}} */
}
?>
LetoDMS_Lucene-1.0.2/Lucene/IndexedDocument.php 0000644 0001750 0001750 00000005426 12025431726 020650 0 ustar steinm steinm
* @copyright Copyright (C) 2010, Uwe Steinmann
* @version Release: 1.0.2
*/
/**
* Class for managing an indexed document.
*
* @category DMS
* @package LetoDMS_Lucene
* @version @version@
* @author Uwe Steinmann
* @copyright Copyright (C) 2011, Uwe Steinmann
* @version Release: 1.0.2
*/
class LetoDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
/**
* Constructor. Creates our indexable document and adds all
* necessary fields to it using the passed in document
*/
public function __construct($dms, $document, $convcmd=null) {
$_convcmd = array(
'application/pdf' => 'pdftotext -enc UTF-8 -nopgbrk %s - |sed -e \'s/ [a-zA-Z0-9.]\{1\} / /g\' -e \'s/[0-9.]//g\'',
'application/msword' => 'catdoc %s',
'application/vnd.ms-excel' => 'ssconvert -T Gnumeric_stf:stf_csv -S %s fd://1',
'audio/mp3' => "id3 -l -R %s | egrep '(Title|Artist|Album)' | sed 's/^[^:]*: //g'",
'audio/mpeg' => "id3 -l -R %s | egrep '(Title|Artist|Album)' | sed 's/^[^:]*: //g'",
'text/plain' => 'cat %s',
);
if($convcmd) {
$_convcmd = $convcmd;
}
$version = $document->getLatestContent();
$this->addField(Zend_Search_Lucene_Field::Keyword('document_id', $document->getID()));
if($version) {
$this->addField(Zend_Search_Lucene_Field::Keyword('mimetype', $version->getMimeType()));
$this->addField(Zend_Search_Lucene_Field::UnIndexed('created', $version->getDate()));
}
$this->addField(Zend_Search_Lucene_Field::Text('title', $document->getName()));
if($categories = $document->getCategories()) {
$names = array();
foreach($categories as $cat) {
$names[] = $cat->getName();
}
$this->addField(Zend_Search_Lucene_Field::Text('category', implode(' ', $names)));
}
$owner = $document->getOwner();
$this->addField(Zend_Search_Lucene_Field::Text('owner', $owner->getLogin()));
if($keywords = $document->getKeywords()) {
$this->addField(Zend_Search_Lucene_Field::Text('keywords', $keywords));
}
if($comment = $document->getComment()) {
$this->addField(Zend_Search_Lucene_Field::Text('comment', $comment));
}
if($version) {
$path = $dms->contentDir . $version->getPath();
$content = '';
$fp = null;
$mimetype = $version->getMimeType();
if(isset($_convcmd[$mimetype])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
$fp = popen($cmd, 'r');
if($fp) {
$content = '';
while(!feof($fp)) {
$content .= fread($fp, 2048);
}
pclose($fp);
}
if($content) {
$this->addField(Zend_Search_Lucene_Field::UnStored('content', $content, 'utf-8'));
}
}
}
}
}
?>
LetoDMS_Lucene-1.0.2/Lucene.php 0000644 0001750 0001750 00000002405 12025431726 015563 0 ustar steinm steinm