PSR2 Formatting

This commit is contained in:
Damian Mooyman 2016-12-02 15:31:18 +13:00
parent babf1580b9
commit ad40d8fd1e
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
111 changed files with 3633 additions and 2882 deletions

View File

@ -89,10 +89,12 @@ class DocumentationManifest
$this->forceRegen = $forceRegen;
$this->registeredEntities = new ArrayList();
$this->cache = SS_Cache::factory('DocumentationManifest', 'Core', array(
$this->cache = SS_Cache::factory(
'DocumentationManifest', 'Core', array(
'automatic_serialization' => true,
'lifetime' => null
));
)
);
$this->setupEntities();
}
@ -153,7 +155,9 @@ class DocumentationManifest
foreach ($langs as $k => $lang) {
if (isset($possible[$lang])) {
/** @var DocumentationEntity $entity */
/**
* @var DocumentationEntity $entity
*/
$entity = Injector::inst()->create(
'DocumentationEntity', $key
);
@ -337,10 +341,12 @@ class DocumentationManifest
public function regenerate($cache = true)
{
$finder = new DocumentationManifestFileFinder();
$finder->setOptions(array(
$finder->setOptions(
array(
'dir_callback' => array($this, 'handleFolder'),
'file_callback' => array($this, 'handleFile')
));
)
);
$this->redirects = array();
foreach ($this->getEntities() as $entity) {
@ -364,7 +370,8 @@ class DocumentationManifest
$this->pages = array();
foreach ($grouped as $entity) {
uasort($entity, function ($a, $b) {
uasort(
$entity, function ($a, $b) {
// ensure parent directories are first
$a['filepath'] = str_replace('index.md', '', $a['filepath']);
$b['filepath'] = str_replace('index.md', '', $b['filepath']);
@ -378,7 +385,8 @@ class DocumentationManifest
}
return ($a['filepath'] < $b['filepath']) ? -1 : 1;
});
}
);
$this->pages = array_merge($this->pages, $entity);
}
@ -404,11 +412,13 @@ class DocumentationManifest
*/
protected function stripLinkBase($link)
{
return ltrim(str_replace(
return ltrim(
str_replace(
Config::inst()->get('DocumentationViewer', 'link_base'),
'',
$link
), '/');
), '/'
);
}
/**
@ -512,10 +522,14 @@ class DocumentationManifest
$parts = explode('/', trim($record->getRelativeLink(), '/'));
// Add the base link.
$output->push(new ArrayData(array(
$output->push(
new ArrayData(
array(
'Link' => $base->Link(),
'Title' => $base->Title
)));
)
)
);
$progress = $base->Link();
@ -523,10 +537,14 @@ class DocumentationManifest
if ($part) {
$progress = Controller::join_links($progress, $part, '/');
$output->push(new ArrayData(array(
$output->push(
new ArrayData(
array(
'Link' => $progress,
'Title' => DocumentationHelper::clean_page_name($part)
)));
)
)
);
}
}
@ -551,20 +569,24 @@ class DocumentationManifest
foreach ($this->getPages() as $url => $page) {
if ($grabNext && strpos($page['filepath'], $entityBase) !== false) {
return new ArrayData(array(
return new ArrayData(
array(
'Link' => Controller::join_links(Config::inst()->get('DocumentationViewer', 'link_base'), $url),
'Title' => $page['title']
));
)
);
}
if ($filepath == $page['filepath']) {
$grabNext = true;
} elseif (!$fallback && strpos($page['filepath'], $filepath) !== false) {
$fallback = new ArrayData(array(
$fallback = new ArrayData(
array(
'Link' => Controller::join_links(Config::inst()->get('DocumentationViewer', 'link_base'), $url),
'Title' => $page['title'],
'Fallback' => true
));
)
);
}
}
@ -593,10 +615,12 @@ class DocumentationManifest
foreach ($this->getPages() as $url => $page) {
if ($filepath == $page['filepath']) {
if ($previousUrl) {
return new ArrayData(array(
return new ArrayData(
array(
'Link' => Controller::join_links(Config::inst()->get('DocumentationViewer', 'link_base'), $previousUrl),
'Title' => $previousPage['title']
));
)
);
}
}
@ -675,13 +699,17 @@ class DocumentationManifest
$children = $this->getChildrenFor($pagePath, $recordPath);
}
$output->push(new ArrayData(array(
$output->push(
new ArrayData(
array(
'Link' => Controller::join_links($base, $url, '/'),
'Title' => $page['title'],
'LinkingMode' => $mode,
'Summary' => $page['summary'],
'Children' => $children
)));
)
)
);
}
}
@ -740,20 +768,26 @@ class DocumentationManifest
$output = new ArrayList();
/** @var DocumentationEntity $check */
/**
* @var DocumentationEntity $check
*/
foreach ($this->getEntities() as $check) {
if ($check->getKey() == $entity->getKey()) {
if ($check->getLanguage() == $entity->getLanguage()) {
$same = ($check->getVersion() == $entity->getVersion());
$output->push(new ArrayData(array(
$output->push(
new ArrayData(
array(
'Title' => $check->getVersionTitle(),
'Version' => $check->getVersion(),
'Archived' => $check->getIsArchived(),
'Link' => $check->Link(),
'LinkingMode' => ($same) ? 'current' : 'link',
'IsStable' => $check->getIsStable()
)));
)
)
);
}
}
}
@ -783,6 +817,7 @@ class DocumentationManifest
/**
* Gets whether there is a default entity or not
*
* @return boolean
*/
public function getHasDefaultEntity()

View File

@ -30,7 +30,7 @@ class DocumentationParser
* Pathparts: folder/subfolder/page
*
* @param DocumentationPage $page
* @param String $baselink Link relative to webroot, up until the "root"
* @param String $baselink Link relative to webroot, up until the "root" of the module. Necessary to rewrite relative links
* of the module. Necessary to rewrite relative
* links
*
@ -238,16 +238,22 @@ class DocumentationParser
}
// Rewrite URL (relative or absolute)
$baselink = DocumentationHelper::relativePath(DocumentationHelper::normalizePath(
$baselink = DocumentationHelper::relativePath(
DocumentationHelper::normalizePath(
dirname($page->getPath())
));
)
);
// if the image starts with a slash, it's absolute
if (substr($url, 0, 1) == '/') {
$relativeUrl = DocumentationHelper::normalizePath(str_replace(BASE_PATH, '', Controller::join_links(
$relativeUrl = DocumentationHelper::normalizePath(
str_replace(
BASE_PATH, '', Controller::join_links(
$page->getEntity()->getPath(),
$url
)));
)
)
);
} else {
$relativeUrl = rtrim($baselink, '/') . '/' . ltrim($url, '/');
}
@ -524,11 +530,13 @@ class DocumentationParser
public static function retrieve_meta_data(DocumentationPage &$page)
{
if ($md = $page->getMarkdown()) {
$matches = preg_match_all('/
$matches = preg_match_all(
'/
(?<key>[A-Za-z0-9_-]+):
\s*
(?<value>.*)
/x', $md, $meta);
/x', $md, $meta
);
if ($matches) {
foreach ($meta['key'] as $index => $key) {

View File

@ -240,7 +240,8 @@ class DocumentationSearch
$content = $hit->content;
$obj = new ArrayData(array(
$obj = new ArrayData(
array(
'Title' => DBField::create_field('Varchar', $doc->getFieldValue('Title')),
'BreadcrumbTitle' => DBField::create_field('HTMLText', $doc->getFieldValue('BreadcrumbTitle')),
'Link' => DBField::create_field('Varchar', $doc->getFieldValue('Link')),
@ -251,7 +252,8 @@ class DocumentationSearch
'Score' => $hit->score,
'Number' => $k + 1,
'ID' => md5($doc->getFieldValue('Link'))
));
)
);
$results->push($obj);
}
@ -267,13 +269,15 @@ class DocumentationSearch
// Pagination links
if ($currentPage > 1) {
$data['PrevUrl'] = DBField::create_field('Text',
$data['PrevUrl'] = DBField::create_field(
'Text',
$this->buildQueryUrl(array('start' => ($currentPage - 2) * $pageLength))
);
}
if ($currentPage < $totalPages) {
$data['NextUrl'] = DBField::create_field('Text',
$data['NextUrl'] = DBField::create_field(
'Text',
$this->buildQueryUrl(array('start' => $currentPage * $pageLength))
);
}
@ -284,9 +288,11 @@ class DocumentationSearch
$obj = new DataObject();
$obj->IsEllipsis = false;
$obj->PageNumber = $i;
$obj->Link = $this->buildQueryUrl(array(
$obj->Link = $this->buildQueryUrl(
array(
'start' => ($i - 1) * $pageLength
));
)
);
$obj->Current = false;
if ($i == $currentPage) {

View File

@ -41,8 +41,10 @@ class DocumentationOpenSearchController extends Controller
return $this->customise(
new ArrayData($data)
)->renderWith(array(
)->renderWith(
array(
'OpenSearchDescription'
));
)
);
}
}

View File

@ -105,14 +105,16 @@ class DocumentationViewer extends Controller implements PermissionProvider
Requirements::javascript('https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js');
Requirements::javascript(DOCSVIEWER_DIR .'/javascript/DocumentationViewer.js');
Requirements::combine_files('docs.css', array(
Requirements::combine_files(
'docs.css', array(
DOCSVIEWER_DIR .'/css/normalize.css',
DOCSVIEWER_DIR .'/css/utilities.css',
DOCSVIEWER_DIR .'/css/typography.css',
DOCSVIEWER_DIR .'/css/forms.css',
DOCSVIEWER_DIR .'/css/layout.css',
DOCSVIEWER_DIR .'/css/small.css'
));
)
);
}
}
@ -122,7 +124,8 @@ class DocumentationViewer extends Controller implements PermissionProvider
* @return array
*/
public function providePermissions() {
public function providePermissions()
{
return array(
'CMS_VIEW_DEVDOCS' => array(
'name' => 'View Site Documentation',
@ -270,10 +273,12 @@ class DocumentationViewer extends Controller implements PermissionProvider
$this->init();
$type = get_class($this->record);
$body = $this->renderWith(array(
$body = $this->renderWith(
array(
"DocumentationViewer_{$type}",
"DocumentationViewer"
));
)
);
return new SS_HTTPResponse($body, 200);
} elseif ($redirect = $this->getManifest()->getRedirect($url)) {
@ -281,10 +286,12 @@ class DocumentationViewer extends Controller implements PermissionProvider
$to = Controller::join_links(Director::baseURL(), $base, $redirect);
return $response->redirect($to, 301);
} elseif (!$url || $url == $lang) {
$body = $this->renderWith(array(
$body = $this->renderWith(
array(
"DocumentationViewer_DocumentationFolder",
"DocumentationViewer"
));
)
);
return new SS_HTTPResponse($body, 200);
}
@ -304,9 +311,13 @@ class DocumentationViewer extends Controller implements PermissionProvider
$this->init();
$class = get_class($this);
$body = $this->customise(new ArrayData(array(
$body = $this->customise(
new ArrayData(
array(
'Message' => $message
)))->renderWith(array("{$class}_error", $class));
)
)
)->renderWith(array("{$class}_error", $class));
return new SS_HTTPResponse($body, $status);
}
@ -386,13 +397,17 @@ class DocumentationViewer extends Controller implements PermissionProvider
$link = $entity->Link();
$output->push(new ArrayData(array(
$output->push(
new ArrayData(
array(
'Title' => $entity->getTitle(),
'Link' => $link,
'LinkingMode' => $mode,
'DefaultEntity' => $entity->getIsDefaultEntity(),
'Children' => $children
)));
)
)
);
}
return $output;
@ -449,9 +464,13 @@ class DocumentationViewer extends Controller implements PermissionProvider
}
}
return $this->customise(new ArrayData(array(
return $this->customise(
new ArrayData(
array(
'Children' => $children
)))->renderWith('Includes/DocumentationPages');
)
)
)->renderWith('Includes/DocumentationPages');
}
/**
@ -565,11 +584,15 @@ class DocumentationViewer extends Controller implements PermissionProvider
$first = strtoupper(trim(substr($page['title'], 0, 1)));
if ($first) {
$output->push(new ArrayData(array(
$output->push(
new ArrayData(
array(
'Link' => Controller::join_links($baseLink, $url),
'Title' => $page['title'],
'FirstLetter' => $first
)));
)
)
);
}
}
@ -662,7 +685,6 @@ class DocumentationViewer extends Controller implements PermissionProvider
$version,
ltrim($page->getRelativePath(), '/')
),
$url['url']
);
}
@ -683,7 +705,8 @@ class DocumentationViewer extends Controller implements PermissionProvider
{
return ($this->record)
? $this->getManifest()->getNextPage(
$this->record->getPath(), $this->getEntity()->getPath())
$this->record->getPath(), $this->getEntity()->getPath()
)
: null;
}
@ -697,7 +720,8 @@ class DocumentationViewer extends Controller implements PermissionProvider
{
return ($this->record)
? $this->getManifest()->getPreviousPage(
$this->record->getPath(), $this->getEntity()->getPath())
$this->record->getPath(), $this->getEntity()->getPath()
)
: null;
}
@ -728,6 +752,7 @@ class DocumentationViewer extends Controller implements PermissionProvider
/**
* Gets whether there is a default entity or not
*
* @return boolean
* @see DocumentationManifest::getHasDefaultEntity()
*/

View File

@ -33,15 +33,23 @@ class DocumentationViewerVersionWarning extends Extension
$compare = $entity->compare($stable);
if ($entity->getVersion() == "master" || $compare > 0) {
return $this->owner->customise(new ArrayData(array(
return $this->owner->customise(
new ArrayData(
array(
'FutureRelease' => true,
'StableVersion' => DBField::create_field('HTMLText', $stable->getVersion())
)));
)
)
);
} else {
return $this->owner->customise(new ArrayData(array(
return $this->owner->customise(
new ArrayData(
array(
'OutdatedRelease' => true,
'StableVersion' => DBField::create_field('HTMLText', $stable->getVersion())
)));
)
)
);
}
return false;

View File

@ -11,7 +11,6 @@
* entity can have a language attached to it. So for an instance with en, de and
* fr documentation you may have three {@link DocumentationEntities} registered.
*
*
* @package docsviewer
* @subpackage models
*/
@ -256,7 +255,8 @@ class DocumentationEntity extends ViewableData
*
* @return string
*/
public function getVersionTitle() {
public function getVersionTitle()
{
return $this->versionTitle;
}
@ -266,7 +266,8 @@ class DocumentationEntity extends ViewableData
* @param string $title
* @return $this
*/
public function setVersionTitle($title) {
public function setVersionTitle($title)
{
$this->versionTitle = $title;
return $this;
}
@ -277,7 +278,8 @@ class DocumentationEntity extends ViewableData
* @param bool $archived
* @return $this
*/
public function setIsArchived($archived) {
public function setIsArchived($archived)
{
$this->archived = $archived;
return $this;
}
@ -285,7 +287,8 @@ class DocumentationEntity extends ViewableData
/**
* @return bool
*/
public function getIsArchived() {
public function getIsArchived()
{
return $this->archived;
}

View File

@ -71,15 +71,19 @@ class DocumentationPage extends ViewableData
// add the module to the breadcrumb trail.
$pathParts[] = $this->entity->getTitle();
$titleParts = array_map(array(
$titleParts = array_map(
array(
'DocumentationHelper', 'clean_page_name'
), $pathParts);
), $pathParts
);
$titleParts = array_filter($titleParts, function ($val) {
$titleParts = array_filter(
$titleParts, function ($val) {
if ($val) {
return $val;
}
});
}
);
if ($this->getTitle()) {
array_unshift($titleParts, $this->getTitle());
@ -208,9 +212,13 @@ class DocumentationPage extends ViewableData
{
$path = $this->getRelativePath();
$url = explode('/', $path);
$url = implode('/', array_map(function ($a) {
$url = implode(
'/', array_map(
function ($a) {
return DocumentationHelper::clean_page_url($a);
}, $url));
}, $url
)
);
$url = trim($url, '/') . '/';
@ -246,10 +254,12 @@ class DocumentationPage extends ViewableData
*/
public function Link($short = false)
{
return ltrim(Controller::join_links(
return ltrim(
Controller::join_links(
$this->entity->Link($short),
$this->getRelativeLink()
), '/');
), '/'
);
}
/**

View File

@ -3,19 +3,22 @@
/**
* Check status of sources dirs
*/
class CheckDocsSourcesTask extends BuildTask {
class CheckDocsSourcesTask extends BuildTask
{
protected $errors = 0;
protected $description = "Check validity of all docs source files registered";
public function start() {
public function start()
{
if(!Director::is_cli()) {
echo "<ul>";
}
}
public function end() {
public function end()
{
if(Director::is_cli()) {
echo "\nTotal errors: {$this->errors}\n";
} else {
@ -24,7 +27,8 @@ class CheckDocsSourcesTask extends BuildTask {
}
}
public function showError($error) {
public function showError($error)
{
$this->errors++;
if(Director::is_cli()) {
echo "\n$error";

View File

@ -23,7 +23,7 @@ class RebuildLuceneDocsIndex extends BuildTask
public function rebuildIndexes($quiet = false)
{
require_once 'Zend/Search/Lucene.php';
include_once 'Zend/Search/Lucene.php';
ini_set("memory_limit", -1);
ini_set('max_execution_time', 0);
@ -85,21 +85,29 @@ class RebuildLuceneDocsIndex extends BuildTask
$doc->addField($titleField = Zend_Search_Lucene_Field::Text('Title', $page->getTitle()));
$doc->addField($breadcrumbField = Zend_Search_Lucene_Field::Text('BreadcrumbTitle', $page->getBreadcrumbTitle()));
$doc->addField(Zend_Search_Lucene_Field::Keyword(
$doc->addField(
Zend_Search_Lucene_Field::Keyword(
'Version', $page->getEntity()->getVersion()
));
)
);
$doc->addField(Zend_Search_Lucene_Field::Keyword(
$doc->addField(
Zend_Search_Lucene_Field::Keyword(
'Language', $page->getEntity()->getLanguage()
));
)
);
$doc->addField(Zend_Search_Lucene_Field::Keyword(
$doc->addField(
Zend_Search_Lucene_Field::Keyword(
'Entity', $page->getEntity()
));
)
);
$doc->addField(Zend_Search_Lucene_Field::Keyword(
$doc->addField(
Zend_Search_Lucene_Field::Keyword(
'Link', $page->Link()
));
)
);
// custom boosts
$titleField->boost = 3;

View File

@ -1,26 +1,35 @@
;(function($) {
$(document).ready(function() {
$(document).ready(
function() {
// Open sidebar on mobile
$('.menu-open').click(function(){
$('.menu-open').click(
function(){
$('#sidebar').removeClass('hide').addClass('open');
return false;
});
}
);
// Close sidebar on mobile
$('.menu-close').click(function(){
$('.menu-close').click(
function(){
$('#sidebar').removeClass('open').addClass('hide');
setTimeout(function() {
setTimeout(
function() {
$('#sidebar').removeClass('hide');
}, 500);
}, 500
);
return false;
});
}
);
// Close sidebar by hitting of ESC
$(document).keyup(function(e) {
$(document).keyup(
function(e) {
if (e.keyCode == 27) {
$('#sidebar').removeClass('open');
}
});
}
);
var switched = false;
@ -28,26 +37,32 @@
if (($(window).width() < 540) && !switched ) {
switched = true;
$("table").each(function(i, element) {
$("table").each(
function(i, element) {
splitTable($(element));
});
}
);
return true;
}
else if (switched && ($(window).width() > 540)) {
switched = false;
$("table").each(function(i, element) {
$("table").each(
function(i, element) {
unsplitTable($(element));
});
}
);
}
};
$(window).load(updateTables);
$(window).on("redraw",function() {
$(window).on(
"redraw",function() {
switched = false;
updateTables();
}); // An event to listen for
}
); // An event to listen for
$(window).on("resize", updateTables);
@ -77,24 +92,32 @@
tr_copy = copy.find('tr'),
heights = [];
tr.each(function (index) {
tr.each(
function (index) {
var self = $(this),
tx = self.find('th, td');
tx.each(function () {
tx.each(
function () {
var height = $(this).outerHeight(true);
heights[index] = heights[index] || 0;
if (height > heights[index]) heights[index] = height;
});
});
if (height > heights[index]) { heights[index] = height;
}
}
);
}
);
tr_copy.each(function (index) {
tr_copy.each(
function (index) {
$(this).height(heights[index]);
});
}
);
}
/** -----------------------------------------------
/**
* -----------------------------------------------
* TABLE OF CONTENTS
*
* Transform a #table-of-contents div to a nested list
@ -107,16 +130,20 @@
var pageURL = window.location.href.replace(/#[a-zA-Z0-9\-\_]*/g, '');
var itemCount = 0;
$('#content h1[id], #content h2[id], #content h3[id], #content h4[id]').each(function(i) {
$('#content h1[id], #content h2[id], #content h3[id], #content h4[id]').each(
function(i) {
var current = $(this);
var tagName = current.prop("tagName");
if(typeof tagName == "String") tagName = tagName.toLowerCase();
if(typeof tagName == "String") { tagName = tagName.toLowerCase();
}
itemCount++;
toc += '<li class="' + tagName + '"><a id="link' + i + '" href="'+ pageURL +'#' + $(this).attr('id') + '" title="' + current.html() + '">' + current.html() + '</a></li>';
});
}
);
// if no items in the table of contents, don't show anything
if(itemCount == 0) return false;
if(itemCount == 0) { return false;
}
toc += '</ul></div>';
@ -137,47 +164,59 @@
}
/** ---------------------------------------------
/**
* ---------------------------------------------
* HEADING ANCHOR LINKS
*
* Automatically adds anchor links to headings that have IDs
*/
var url = window.location.href.replace(/#[a-zA-Z0-9\-\_]*/g, '');
$("#content h1[id], #content h2[id], #content h3[id], #content h4[id], #content h5[id], #content h6[id]").each(function() {
$("#content h1[id], #content h2[id], #content h3[id], #content h4[id], #content h5[id], #content h6[id]").each(
function() {
var link = '<a class="heading-anchor-link" title="Link to this section" href="'+ url + '#' + $(this).attr('id') + '">&para;</a>';
$(this).append(' ' + link);
});
}
);
$("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").mouseenter(function() {
$("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").mouseenter(
function() {
$(this).addClass('hover');
});
}
);
$("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").mouseleave(function() {
$("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").mouseleave(
function() {
$(this).removeClass('hover');
});
}
);
/** ---------------------------------------------
/**
* ---------------------------------------------
* LANGAUGE SELECTER
*
* Hide the change button and do it onclick
*/
$("#Form_LanguageForm .Actions").hide();
$("#Form_LanguageForm select").change(function() {
$("#Form_LanguageForm select").change(
function() {
$("#Form_LanguageForm").submit();
});
}
);
/** ---------------------------------------------
/**
* ---------------------------------------------
* SYNTAX HIGHLIGHTER
*
* As the Markdown parser now uses the GFM structure (```yml) this does
* not work with SyntaxHighlighter. The below translates the GFM output
* to one SyntaxHighter can use
*/
$("pre").each(function(i, elem) {
$("pre").each(
function(i, elem) {
var code = $(elem).find('code[class^=language]');
if(code.length > 0) {
@ -185,8 +224,10 @@
$(elem).attr('class', 'prettyprint lang-' + brush);
// $(elem).html(code.html());
}
});
}
);
});
}
);
})(jQuery);

View File

@ -2,7 +2,8 @@
class DocumentationEntityTest extends SapphireTest
{
public function dataCompare() {
public function dataCompare()
{
return array(
array('3', '3.0', 1),
array('3.1', '3.1', 0),
@ -19,7 +20,8 @@ class DocumentationEntityTest extends SapphireTest
* @param string $right
* @param int $result
*/
public function testCompare($left, $right, $result) {
public function testCompare($left, $right, $result)
{
$leftVersion = new DocumentationEntity('Framework');
$leftVersion->setVersion($left);

View File

@ -8,68 +8,94 @@ class DocumentationHelperTests extends SapphireTest
{
public function testCleanName()
{
$this->assertEquals("File path", DocumentationHelper::clean_page_name(
$this->assertEquals(
"File path", DocumentationHelper::clean_page_name(
'00_file-path.md'
));
)
);
}
public function testCleanUrl()
{
$this->assertEquals("some_path", DocumentationHelper::clean_page_url(
$this->assertEquals(
"some_path", DocumentationHelper::clean_page_url(
'Some Path'
));
)
);
$this->assertEquals("somefilepath", DocumentationHelper::clean_page_url(
$this->assertEquals(
"somefilepath", DocumentationHelper::clean_page_url(
'00_SomeFilePath.md'
));
)
);
}
public function testTrimSortNumber()
{
$this->assertEquals('file', DocumentationHelper::trim_sort_number(
$this->assertEquals(
'file', DocumentationHelper::trim_sort_number(
'0_file'
));
)
);
$this->assertEquals('2.1', DocumentationHelper::trim_sort_number(
$this->assertEquals(
'2.1', DocumentationHelper::trim_sort_number(
'2.1'
));
)
);
$this->assertEquals('dev/tasks/2.1', DocumentationHelper::trim_sort_number(
$this->assertEquals(
'dev/tasks/2.1', DocumentationHelper::trim_sort_number(
'dev/tasks/2.1'
));
)
);
}
public function testTrimExtension()
{
$this->assertEquals('file', DocumentationHelper::trim_extension_off(
$this->assertEquals(
'file', DocumentationHelper::trim_extension_off(
'file.md'
));
)
);
$this->assertEquals('dev/path/file', DocumentationHelper::trim_extension_off(
$this->assertEquals(
'dev/path/file', DocumentationHelper::trim_extension_off(
'dev/path/file.md'
));
)
);
}
public function testGetExtension()
{
$this->assertEquals('md', DocumentationHelper::get_extension(
$this->assertEquals(
'md', DocumentationHelper::get_extension(
'file.md'
));
)
);
$this->assertEquals('md', DocumentationHelper::get_extension(
$this->assertEquals(
'md', DocumentationHelper::get_extension(
'dev/tasks/file.md'
));
)
);
$this->assertEquals('txt', DocumentationHelper::get_extension(
$this->assertEquals(
'txt', DocumentationHelper::get_extension(
'dev/tasks/file.txt'
));
)
);
$this->assertNull(DocumentationHelper::get_extension(
$this->assertNull(
DocumentationHelper::get_extension(
'doc_test/2.3'
));
)
);
$this->assertNull(DocumentationHelper::get_extension(
$this->assertNull(
DocumentationHelper::get_extension(
'dev/docs/en/doc_test/2.3/subfolder'
));
)
);
}
}

View File

@ -107,51 +107,65 @@ class DocumentationManifestTests extends SapphireTest
{
// get next page at the end of one subfolder goes back up to the top
// most directory
$this->assertStringEndsWith('2.3/test/', $this->manifest->getNextPage(
$this->assertStringEndsWith(
'2.3/test/', $this->manifest->getNextPage(
DOCSVIEWER_PATH . '/tests/docs/en/subfolder/subsubfolder/subsubpage.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
)->Link);
)->Link
);
// after sorting, 2 is shown.
$this->assertContains('/intermediate/', $this->manifest->getNextPage(
$this->assertContains(
'/intermediate/', $this->manifest->getNextPage(
DOCSVIEWER_PATH . '/tests/docs/en/sort/01-basic.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
)->Link);
)->Link
);
// next gets the following URL
$this->assertContains('/test/', $this->manifest->getNextPage(
$this->assertContains(
'/test/', $this->manifest->getNextPage(
DOCSVIEWER_PATH . '/tests/docs-v2.4/en/index.md',
DOCSVIEWER_PATH . '/tests/docs-v2.4/en/'
)->Link);
)->Link
);
// last folder in a entity does not leak
$this->assertNull($this->manifest->getNextPage(
$this->assertNull(
$this->manifest->getNextPage(
DOCSVIEWER_PATH . '/tests/docs/en/test.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
));
)
);
}
public function testGetPreviousPage()
{
// goes right into subfolders
$this->assertContains('subfolder/subsubfolder/subsubpage', $this->manifest->getPreviousPage(
$this->assertContains(
'subfolder/subsubfolder/subsubpage', $this->manifest->getPreviousPage(
DOCSVIEWER_PATH . '/tests/docs/en/test.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
)->Link);
)->Link
);
// does not leak between entities
$this->assertNull($this->manifest->getPreviousPage(
$this->assertNull(
$this->manifest->getPreviousPage(
DOCSVIEWER_PATH . '/tests/docs/en/index.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
));
)
);
// does not leak between entities
$this->assertNull($this->manifest->getPreviousPage(
$this->assertNull(
$this->manifest->getPreviousPage(
DOCSVIEWER_PATH . ' /tests/docs/en/index.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
));
)
);
}
public function testGetPage()
@ -170,9 +184,11 @@ class DocumentationManifestTests extends SapphireTest
array('Title' => 'Test', 'LinkingMode' => 'link')
);
$this->assertDOSContains($expected, $this->manifest->getChildrenFor(
$this->assertDOSContains(
$expected, $this->manifest->getChildrenFor(
DOCSVIEWER_PATH . "/tests/docs/en/"
));
)
);
$expected = array(
array('Title' => 'ChangeLog', 'LinkingMode' => 'current'),
@ -180,10 +196,12 @@ class DocumentationManifestTests extends SapphireTest
array('Title' => 'Empty')
);
$this->assertDOSContains($expected, $this->manifest->getChildrenFor(
$this->assertDOSContains(
$expected, $this->manifest->getChildrenFor(
DOCSVIEWER_PATH . '/tests/docs-v3.0/en/',
DOCSVIEWER_PATH . '/tests/docs-v3.0/en/ChangeLog.md'
));
)
);
}
public function testGetAllVersions()

View File

@ -43,7 +43,8 @@ class DocumentationPageTest extends SapphireTest
);
// single layer
$this->assertEquals('dev/docs/en/doctest/2.4/test/', $page->Link(),
$this->assertEquals(
'dev/docs/en/doctest/2.4/test/', $page->Link(),
'The page link should have no extension and have a language'
);

View File

@ -212,7 +212,7 @@ HTML;
$this->subPage
);
# @todo this should redirect to /subpage/
// @todo this should redirect to /subpage/
$this->assertContains(
'[link: relative](dev/docs/en/documentationparsertest/2.4/subfolder/subpage.md/)',
$result
@ -223,7 +223,7 @@ HTML;
$result
);
# @todo this should redirect to /
// @todo this should redirect to /
$this->assertContains(
'[link: absolute index with name](dev/docs/en/documentationparsertest/2.4/index/)',
$result
@ -304,9 +304,11 @@ HTML;
);
$this->assertContains(
sprintf('[parent image link](%s)', Controller::join_links(
sprintf(
'[parent image link](%s)', Controller::join_links(
Director::absoluteBaseURL(), DOCSVIEWER_DIR, '/tests/docs/en/_images/image.png'
)),
)
),
$result
);

View File

@ -9,30 +9,35 @@ class DocumentationPermalinksTest extends FunctionalTest
public function testSavingAndAccessingMapping()
{
// basic test
DocumentationPermalinks::add(array(
DocumentationPermalinks::add(
array(
'foo' => 'en/framework/subfolder/foo',
'bar' => 'en/cms/bar'
));
)
);
$this->assertEquals('en/framework/subfolder/foo',
$this->assertEquals(
'en/framework/subfolder/foo',
DocumentationPermalinks::map('foo')
);
$this->assertEquals('en/cms/bar',
$this->assertEquals(
'en/cms/bar',
DocumentationPermalinks::map('bar')
);
}
/**
* Tests to make sure short codes get translated to full paths.
*
*/
public function testRedirectingMapping()
{
DocumentationPermalinks::add(array(
DocumentationPermalinks::add(
array(
'foo' => 'en/framework/subfolder/foo',
'bar' => 'en/cms/bar'
));
)
);
$this->autoFollowRedirection = false;

View File

@ -33,5 +33,7 @@ require_once 'Zend/Exception.php';
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Search_Exception extends Zend_Exception
{}
{
}

View File

@ -20,69 +20,113 @@
*/
/** User land classes and interfaces turned on by Zend/Search/Lucene.php file inclusion. */
/** @todo Section should be removed with ZF 2.0 release as obsolete */
/**
* User land classes and interfaces turned on by Zend/Search/Lucene.php file inclusion.
*/
/**
* @todo Section should be removed with ZF 2.0 release as obsolete
*/
/** Zend_Search_Lucene_Document_Html */
/**
* Zend_Search_Lucene_Document_Html
*/
require_once 'Zend/Search/Lucene/Document/Html.php';
/** Zend_Search_Lucene_Document_Docx */
/**
* Zend_Search_Lucene_Document_Docx
*/
require_once 'Zend/Search/Lucene/Document/Docx.php';
/** Zend_Search_Lucene_Document_Pptx */
/**
* Zend_Search_Lucene_Document_Pptx
*/
require_once 'Zend/Search/Lucene/Document/Pptx.php';
/** Zend_Search_Lucene_Document_Xlsx */
/**
* Zend_Search_Lucene_Document_Xlsx
*/
require_once 'Zend/Search/Lucene/Document/Xlsx.php';
/** Zend_Search_Lucene_Search_QueryParser */
/**
* Zend_Search_Lucene_Search_QueryParser
*/
require_once 'Zend/Search/Lucene/Search/QueryParser.php';
/** Zend_Search_Lucene_Search_QueryHit */
/**
* Zend_Search_Lucene_Search_QueryHit
*/
require_once 'Zend/Search/Lucene/Search/QueryHit.php';
/** Zend_Search_Lucene_Analysis_Analyzer */
/**
* Zend_Search_Lucene_Analysis_Analyzer
*/
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
/** Zend_Search_Lucene_Search_Query_Term */
/**
* Zend_Search_Lucene_Search_Query_Term
*/
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
/** Zend_Search_Lucene_Search_Query_Phrase */
/**
* Zend_Search_Lucene_Search_Query_Phrase
*/
require_once 'Zend/Search/Lucene/Search/Query/Phrase.php';
/** Zend_Search_Lucene_Search_Query_MultiTerm */
/**
* Zend_Search_Lucene_Search_Query_MultiTerm
*/
require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
/** Zend_Search_Lucene_Search_Query_Wildcard */
/**
* Zend_Search_Lucene_Search_Query_Wildcard
*/
require_once 'Zend/Search/Lucene/Search/Query/Wildcard.php';
/** Zend_Search_Lucene_Search_Query_Range */
/**
* Zend_Search_Lucene_Search_Query_Range
*/
require_once 'Zend/Search/Lucene/Search/Query/Range.php';
/** Zend_Search_Lucene_Search_Query_Fuzzy */
/**
* Zend_Search_Lucene_Search_Query_Fuzzy
*/
require_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php';
/** Zend_Search_Lucene_Search_Query_Boolean */
/**
* Zend_Search_Lucene_Search_Query_Boolean
*/
require_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
/** Zend_Search_Lucene_Search_Query_Empty */
/**
* Zend_Search_Lucene_Search_Query_Empty
*/
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
/** Zend_Search_Lucene_Search_Query_Insignificant */
/**
* Zend_Search_Lucene_Search_Query_Insignificant
*/
require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
/** Internally used classes */
/**
* Internally used classes
*/
/** Zend_Search_Lucene_Interface */
/**
* Zend_Search_Lucene_Interface
*/
require_once 'Zend/Search/Lucene/Interface.php';
/** Zend_Search_Lucene_Index_SegmentInfo */
/**
* Zend_Search_Lucene_Index_SegmentInfo
*/
require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
/** Zend_Search_Lucene_LockManager */
/**
* Zend_Search_Lucene_LockManager
*/
require_once 'Zend/Search/Lucene/LockManager.php';
@ -205,8 +249,10 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
*/
public static function create($directory)
{
/** Zend_Search_Lucene_Proxy */
require_once 'Zend/Search/Lucene/Proxy.php';
/**
* Zend_Search_Lucene_Proxy
*/
include_once 'Zend/Search/Lucene/Proxy.php';
return new Zend_Search_Lucene_Proxy(new Zend_Search_Lucene($directory, true));
}
@ -219,16 +265,22 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
*/
public static function open($directory)
{
/** Zend_Search_Lucene_Proxy */
require_once 'Zend/Search/Lucene/Proxy.php';
/**
* Zend_Search_Lucene_Proxy
*/
include_once 'Zend/Search/Lucene/Proxy.php';
return new Zend_Search_Lucene_Proxy(new Zend_Search_Lucene($directory, false));
}
/** Generation retrieving counter */
/**
* Generation retrieving counter
*/
const GENERATION_RETRIEVE_COUNT = 10;
/** Pause between generation retrieving attempts in milliseconds */
/**
* Pause between generation retrieving attempts in milliseconds
*/
const GENERATION_RETRIEVE_PAUSE = 50;
/**
@ -255,7 +307,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
* without performance problems
*/
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
try {
for ($count = 0; $count < self::GENERATION_RETRIEVE_COUNT; $count++) {
// Try to get generation file
@ -350,10 +402,11 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
*/
public function setFormatVersion($formatVersion)
{
if ($formatVersion != self::FORMAT_PRE_2_1 &&
$formatVersion != self::FORMAT_2_1 &&
$formatVersion != self::FORMAT_2_3) {
require_once 'Zend/Search/Lucene/Exception.php';
if ($formatVersion != self::FORMAT_PRE_2_1
&& $formatVersion != self::FORMAT_2_1
&& $formatVersion != self::FORMAT_2_3
) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Unsupported index format');
}
@ -372,7 +425,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
$format = $segmentsFile->readInt();
if ($format != (int)0xFFFFFFFF) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Wrong segments file format');
}
@ -393,9 +446,11 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
$this->_docCount += $segSize;
$this->_segmentInfos[$segName] =
new Zend_Search_Lucene_Index_SegmentInfo($this->_directory,
new Zend_Search_Lucene_Index_SegmentInfo(
$this->_directory,
$segName,
$segSize);
$segSize
);
}
// Use 2.1 as a target version. Index will be reorganized at update time.
@ -418,7 +473,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
} else if ($format == (int)0xFFFFFFFD) {
$this->_formatVersion = self::FORMAT_2_1;
} else {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Unsupported segments file format');
}
@ -466,7 +521,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
$normGens[] = $segmentsFile->readLong();
}
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Separate norm files are not supported. Optimize index to use it with Zend_Search_Lucene.');
}
@ -486,13 +541,15 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
$this->_docCount += $segSize;
$this->_segmentInfos[$segName] =
new Zend_Search_Lucene_Index_SegmentInfo($this->_directory,
new Zend_Search_Lucene_Index_SegmentInfo(
$this->_directory,
$segName,
$segSize,
$delGen,
$docStoreOptions,
$hasSingleNormFile,
$isCompound);
$isCompound
);
}
}
@ -508,12 +565,12 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
public function __construct($directory = null, $create = false)
{
if ($directory === null) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Exception('No index directory specified');
}
if (is_string($directory)) {
require_once 'Zend/Search/Lucene/Storage/Directory/Filesystem.php';
include_once 'Zend/Search/Lucene/Storage/Directory/Filesystem.php';
$this->_directory = new Zend_Search_Lucene_Storage_Directory_Filesystem($directory);
$this->_closeDirOnExit = true;
} else {
@ -529,7 +586,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
$this->_generation = self::getActualGeneration($this->_directory);
if ($create) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
try {
Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);
} catch (Zend_Search_Lucene_Exception $e) {
@ -555,14 +612,14 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
$this->_generation++;
}
require_once 'Zend/Search/Lucene/Index/Writer.php';
include_once 'Zend/Search/Lucene/Index/Writer.php';
Zend_Search_Lucene_Index_Writer::createIndex($this->_directory, $this->_generation, $nameCounter);
Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
}
if ($this->_generation == -1) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Index doesn\'t exists in the specified directory.');
} else if ($this->_generation == 0) {
$this->_readPre21SegmentsFile();
@ -639,10 +696,12 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
private function _getIndexWriter()
{
if ($this->_writer === null) {
require_once 'Zend/Search/Lucene/Index/Writer.php';
$this->_writer = new Zend_Search_Lucene_Index_Writer($this->_directory,
include_once 'Zend/Search/Lucene/Index/Writer.php';
$this->_writer = new Zend_Search_Lucene_Index_Writer(
$this->_directory,
$this->_segmentInfos,
$this->_formatVersion);
$this->_formatVersion
);
}
return $this->_writer;
@ -708,7 +767,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
public function isDeleted($id)
{
if ($id >= $this->_docCount) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document id is out of the range.');
}
@ -918,13 +977,13 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
public function find($query)
{
if (is_string($query)) {
require_once 'Zend/Search/Lucene/Search/QueryParser.php';
include_once 'Zend/Search/Lucene/Search/QueryParser.php';
$query = Zend_Search_Lucene_Search_QueryParser::parse($query);
}
if (!$query instanceof Zend_Search_Lucene_Search_Query) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Query must be a string or Zend_Search_Lucene_Search_Query object');
}
@ -940,8 +999,10 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
$topScore = 0;
/** Zend_Search_Lucene_Search_QueryHit */
require_once 'Zend/Search/Lucene/Search/QueryHit.php';
/**
* Zend_Search_Lucene_Search_QueryHit
*/
include_once 'Zend/Search/Lucene/Search/QueryHit.php';
foreach ($query->matchedDocs() as $id => $num) {
$docScore = $query->score($id, $this);
@ -977,9 +1038,11 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
if (func_num_args() == 1) {
// sort by scores
array_multisort($scores, SORT_DESC, SORT_NUMERIC,
array_multisort(
$scores, SORT_DESC, SORT_NUMERIC,
$ids, SORT_ASC, SORT_NUMERIC,
$hits);
$hits
);
} else {
// sort by given field names
@ -996,7 +1059,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
$sortFieldValues = array();
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
for ($count = 1; $count < count($argList); $count++) {
$fieldName = $argList[$count];
@ -1104,7 +1167,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
}
if ($id >= $this->_docCount) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document id is out of the range.');
}
@ -1133,20 +1196,24 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
$fieldInfo = $segmentInfo->getField($fieldNum);
if (!($bits & 2)) { // Text data
$field = new Zend_Search_Lucene_Field($fieldInfo->name,
$field = new Zend_Search_Lucene_Field(
$fieldInfo->name,
$fdtFile->readString(),
'UTF-8',
true,
$fieldInfo->isIndexed,
$bits & 1 );
$bits & 1
);
} else { // Binary data
$field = new Zend_Search_Lucene_Field($fieldInfo->name,
$field = new Zend_Search_Lucene_Field(
$fieldInfo->name,
$fdtFile->readBinary(),
'',
true,
$fieldInfo->isIndexed,
$bits & 1,
true );
true
);
}
$doc->addField($field);
@ -1311,8 +1378,10 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
*/
public function getSimilarity()
{
/** Zend_Search_Lucene_Search_Similarity */
require_once 'Zend/Search/Lucene/Search/Similarity.php';
/**
* Zend_Search_Lucene_Search_Similarity
*/
include_once 'Zend/Search/Lucene/Search/Similarity.php';
return Zend_Search_Lucene_Search_Similarity::getDefault();
}
@ -1379,7 +1448,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
}
if ($id >= $this->_docCount) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document id is out of the range.');
}
@ -1466,8 +1535,10 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
{
$result = array();
/** Zend_Search_Lucene_Index_TermsPriorityQueue */
require_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php';
/**
* Zend_Search_Lucene_Index_TermsPriorityQueue
*/
include_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php';
$segmentInfoQueue = new Zend_Search_Lucene_Index_TermsPriorityQueue();
@ -1481,9 +1552,9 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
}
while (($segmentInfo = $segmentInfoQueue->pop()) !== null) {
if ($segmentInfoQueue->top() === null ||
$segmentInfoQueue->top()->currentTerm()->key() !=
$segmentInfo->currentTerm()->key()) {
if ($segmentInfoQueue->top() === null
|| $segmentInfoQueue->top()->currentTerm()->key() != $segmentInfo->currentTerm()->key()
) {
// We got new term
$result[] = $segmentInfo->currentTerm();
}
@ -1511,8 +1582,10 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
public function resetTermsStream()
{
if ($this->_termsStream === null) {
/** Zend_Search_Lucene_TermStreamsPriorityQueue */
require_once 'Zend/Search/Lucene/TermStreamsPriorityQueue.php';
/**
* Zend_Search_Lucene_TermStreamsPriorityQueue
*/
include_once 'Zend/Search/Lucene/TermStreamsPriorityQueue.php';
$this->_termsStream = new Zend_Search_Lucene_TermStreamsPriorityQueue($this->_segmentInfos);
} else {
@ -1573,5 +1646,6 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
* @todo Implementation
*/
public function undeleteAll()
{}
{
}
}

View File

@ -21,32 +21,52 @@
*/
/** User land classes and interfaces turned on by Zend/Search/Analyzer.php file inclusion. */
/** @todo Section should be removed with ZF 2.0 release as obsolete */
/**
* User land classes and interfaces turned on by Zend/Search/Analyzer.php file inclusion.
*/
/**
* @todo Section should be removed with ZF 2.0 release as obsolete
*/
if (!defined('ZEND_SEARCH_LUCENE_COMMON_ANALYZER_PROCESSED')) {
/** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 */
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php';
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php';
/** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive */
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/CaseInsensitive.php';
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/CaseInsensitive.php';
/** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num */
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php';
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php';
/** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive */
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/CaseInsensitive.php';
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/CaseInsensitive.php';
/** Zend_Search_Lucene_Analysis_Analyzer_Common_Text */
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php';
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_Text
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php';
/** Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive */
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php';
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php';
/** Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum */
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php';
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php';
/** Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive */
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum/CaseInsensitive.php';
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum/CaseInsensitive.php';
}
@ -162,8 +182,10 @@ abstract class Zend_Search_Lucene_Analysis_Analyzer
*/
public static function getDefault()
{
/** Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive */
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php';
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php';
if (!self::$_defaultImpl instanceof Zend_Search_Lucene_Analysis_Analyzer) {
self::$_defaultImpl = new Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive();

View File

@ -21,18 +21,28 @@
*/
/** Define constant used to provide correct file processing order */
/** @todo Section should be removed with ZF 2.0 release as obsolete */
/**
* Define constant used to provide correct file processing order
*/
/**
* @todo Section should be removed with ZF 2.0 release as obsolete
*/
define('ZEND_SEARCH_LUCENE_COMMON_ANALYZER_PROCESSED', true);
/** Zend_Search_Lucene_Analysis_Analyzer */
/**
* Zend_Search_Lucene_Analysis_Analyzer
*/
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
/** Zend_Search_Lucene_Analysis_Token */
/**
* Zend_Search_Lucene_Analysis_Token
*/
require_once 'Zend/Search/Lucene/Analysis/Token.php';
/** Zend_Search_Lucene_Analysis_TokenFilter */
/**
* Zend_Search_Lucene_Analysis_TokenFilter
*/
require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php';

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Analysis_Analyzer_Common */
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common
*/
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common.php';

View File

@ -21,10 +21,14 @@
*/
/** Zend_Search_Lucene_Analysis_Analyzer_Common_Text */
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_Text
*/
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php';
/** Zend_Search_Lucene_Analysis_TokenFilter_LowerCase */
/**
* Zend_Search_Lucene_Analysis_TokenFilter_LowerCase
*/
require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php';

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Analysis_Analyzer_Common */
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common
*/
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common.php';

View File

@ -21,10 +21,14 @@
*/
/** Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum */
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum
*/
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php';
/** Zend_Search_Lucene_Analysis_TokenFilter_LowerCase */
/**
* Zend_Search_Lucene_Analysis_TokenFilter_LowerCase
*/
require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php';

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Analysis_Analyzer_Common */
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common
*/
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common.php';
@ -58,7 +60,7 @@ class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 extends Zend_Search_Lucen
{
if (@preg_match('/\pL/u', 'a') != 1) {
// PCRE unicode support is turned off
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Utf8 analyzer needs PCRE unicode support to be enabled.');
}
}
@ -72,8 +74,9 @@ class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 extends Zend_Search_Lucen
$this->_bytePosition = 0;
// convert input into UTF-8
if (strcasecmp($this->_encoding, 'utf8' ) != 0 &&
strcasecmp($this->_encoding, 'utf-8') != 0 ) {
if (strcasecmp($this->_encoding, 'utf8') != 0
&& strcasecmp($this->_encoding, 'utf-8') != 0
) {
$this->_input = iconv($this->_encoding, 'UTF-8', $this->_input);
$this->_encoding = 'UTF-8';
}
@ -107,10 +110,14 @@ class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 extends Zend_Search_Lucen
// character position of the matched word in the input stream
$startPos = $this->_position +
iconv_strlen(substr($this->_input,
iconv_strlen(
substr(
$this->_input,
$this->_bytePosition,
$binStartPos - $this->_bytePosition),
'UTF-8');
$binStartPos - $this->_bytePosition
),
'UTF-8'
);
// character postion of the end of matched word in the input stream
$endPos = $startPos + iconv_strlen($matchedWord, 'UTF-8');

View File

@ -21,10 +21,14 @@
*/
/** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 */
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8
*/
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php';
/** Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 */
/**
* Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8
*/
require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php';

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Analysis_Analyzer_Common */
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common
*/
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common.php';
@ -58,7 +60,7 @@ class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num extends Zend_Search_Lu
{
if (@preg_match('/\pL/u', 'a') != 1) {
// PCRE unicode support is turned off
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Utf8Num analyzer needs PCRE unicode support to be enabled.');
}
}
@ -72,8 +74,9 @@ class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num extends Zend_Search_Lu
$this->_bytePosition = 0;
// convert input into UTF-8
if (strcasecmp($this->_encoding, 'utf8' ) != 0 &&
strcasecmp($this->_encoding, 'utf-8') != 0 ) {
if (strcasecmp($this->_encoding, 'utf8') != 0
&& strcasecmp($this->_encoding, 'utf-8') != 0
) {
$this->_input = iconv($this->_encoding, 'UTF-8', $this->_input);
$this->_encoding = 'UTF-8';
}
@ -107,10 +110,14 @@ class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num extends Zend_Search_Lu
// character position of the matched word in the input stream
$startPos = $this->_position +
iconv_strlen(substr($this->_input,
iconv_strlen(
substr(
$this->_input,
$this->_bytePosition,
$binStartPos - $this->_bytePosition),
'UTF-8');
$binStartPos - $this->_bytePosition
),
'UTF-8'
);
// character postion of the end of matched word in the input stream
$endPos = $startPos + iconv_strlen($matchedWord, 'UTF-8');

View File

@ -21,10 +21,14 @@
*/
/** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num */
/**
* Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num
*/
require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php';
/** Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 */
/**
* Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8
*/
require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php';

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Analysis_Token */
/**
* Zend_Search_Lucene_Analysis_Token
*/
require_once 'Zend/Search/Lucene/Analysis/Token.php';

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Analysis_TokenFilter */
/**
* Zend_Search_Lucene_Analysis_TokenFilter
*/
require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php';
@ -48,7 +50,8 @@ class Zend_Search_Lucene_Analysis_TokenFilter_LowerCase extends Zend_Search_Luce
$newToken = new Zend_Search_Lucene_Analysis_Token(
strtolower($srcToken->getTermText()),
$srcToken->getStartOffset(),
$srcToken->getEndOffset());
$srcToken->getEndOffset()
);
$newToken->setPositionIncrement($srcToken->getPositionIncrement());

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Analysis_TokenFilter */
/**
* Zend_Search_Lucene_Analysis_TokenFilter
*/
require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php';
@ -44,7 +46,7 @@ class Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 extends Zend_Search_
{
if (!function_exists('mb_strtolower')) {
// mbstring extension is disabled
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Utf8 compatible lower case filter needs mbstring extension to be enabled.');
}
}
@ -60,7 +62,8 @@ class Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 extends Zend_Search_
$newToken = new Zend_Search_Lucene_Analysis_Token(
mb_strtolower($srcToken->getTermText(), 'UTF-8'),
$srcToken->getStartOffset(),
$srcToken->getEndOffset());
$srcToken->getEndOffset()
);
$newToken->setPositionIncrement($srcToken->getPositionIncrement());

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Analysis_TokenFilter */
/**
* Zend_Search_Lucene_Analysis_TokenFilter
*/
require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php';
@ -39,6 +41,7 @@ class Zend_Search_Lucene_Analysis_TokenFilter_ShortWords extends Zend_Search_Luc
{
/**
* Minimum allowed term length
*
* @var integer
*/
private $length;
@ -48,7 +51,8 @@ class Zend_Search_Lucene_Analysis_TokenFilter_ShortWords extends Zend_Search_Luc
*
* @param integer $short minimum allowed length of term which passes this filter (default 2)
*/
public function __construct($length = 2) {
public function __construct($length = 2)
{
$this->length = $length;
}
@ -58,7 +62,8 @@ class Zend_Search_Lucene_Analysis_TokenFilter_ShortWords extends Zend_Search_Luc
* @param Zend_Search_Lucene_Analysis_Token $srcToken
* @return Zend_Search_Lucene_Analysis_Token
*/
public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken) {
public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
{
if (strlen($srcToken->getTermText()) < $this->length) {
return null;
} else {

View File

@ -20,7 +20,9 @@
* @version $Id: StopWords.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Analysis_TokenFilter */
/**
* Zend_Search_Lucene_Analysis_TokenFilter
*/
require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php';
/**
@ -40,6 +42,7 @@ class Zend_Search_Lucene_Analysis_TokenFilter_StopWords extends Zend_Search_Luce
{
/**
* Stop Words
*
* @var array
*/
private $_stopSet;
@ -49,7 +52,8 @@ class Zend_Search_Lucene_Analysis_TokenFilter_StopWords extends Zend_Search_Luce
*
* @param array $stopwords array (set) of words that will be filtered out
*/
public function __construct($stopwords = array()) {
public function __construct($stopwords = array())
{
$this->_stopSet = array_flip($stopwords);
}
@ -59,7 +63,8 @@ class Zend_Search_Lucene_Analysis_TokenFilter_StopWords extends Zend_Search_Luce
* @param Zend_Search_Lucene_Analysis_Token $srcToken
* @return Zend_Search_Lucene_Analysis_Token
*/
public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken) {
public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
{
if (array_key_exists($srcToken->getTermText(), $this->_stopSet)) {
return null;
} else {
@ -76,14 +81,15 @@ class Zend_Search_Lucene_Analysis_TokenFilter_StopWords extends Zend_Search_Luce
* @param string $filepath full path for text file with stopwords
* @throws Zend_Search_Exception When the file doesn`t exists or is not readable.
*/
public function loadFromFile($filepath = null) {
public function loadFromFile($filepath = null)
{
if (! $filepath || ! file_exists($filepath)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('You have to provide valid file path');
}
$fd = fopen($filepath, "r");
if (! $fd) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Cannot open file ' . $filepath);
}
while (!feof($fd)) {
@ -93,7 +99,7 @@ class Zend_Search_Lucene_Analysis_TokenFilter_StopWords extends Zend_Search_Luce
}
}
if (!fclose($fd)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Cannot close file ' . $filepath);
}
}

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Field */
/**
* Zend_Search_Lucene_Field
*/
require_once 'Zend/Search/Lucene/Field.php';
@ -100,7 +102,7 @@ class Zend_Search_Lucene_Document
public function getField($fieldName)
{
if (!array_key_exists($fieldName, $this->_fields)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception("Field name \"$fieldName\" not found in document.");
}
return $this->_fields[$fieldName];

View File

@ -20,7 +20,9 @@
* @version $Id: Docx.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Document_OpenXml */
/**
* Zend_Search_Lucene_Document_OpenXml
*/
require_once 'Zend/Search/Lucene/Document/OpenXml.php';
/**
@ -32,7 +34,8 @@ require_once 'Zend/Search/Lucene/Document/OpenXml.php';
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Search_Lucene_Document_Docx extends Zend_Search_Lucene_Document_OpenXml {
class Zend_Search_Lucene_Document_Docx extends Zend_Search_Lucene_Document_OpenXml
{
/**
* Xml Schema - WordprocessingML
*
@ -47,9 +50,10 @@ class Zend_Search_Lucene_Document_Docx extends Zend_Search_Lucene_Document_OpenX
* @param boolean $storeContent
* @throws Zend_Search_Lucene_Exception
*/
private function __construct($fileName, $storeContent) {
private function __construct($fileName, $storeContent)
{
if (!class_exists('ZipArchive', false)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('MS Office documents processing functionality requires Zip extension to be loaded');
}
@ -64,18 +68,22 @@ class Zend_Search_Lucene_Document_Docx extends Zend_Search_Lucene_Document_OpenX
// Read relations and search for officeDocument
$relationsXml = $package->getFromName('_rels/.rels');
if ($relationsXml === false) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Invalid archive or corrupted .docx file.');
}
$relations = simplexml_load_string($relationsXml);
foreach($relations->Relationship as $rel) {
if ($rel ["Type"] == Zend_Search_Lucene_Document_OpenXml::SCHEMA_OFFICEDOCUMENT) {
// Found office document! Read in contents...
$contents = simplexml_load_string($package->getFromName(
$this->absoluteZipPath(dirname($rel['Target'])
$contents = simplexml_load_string(
$package->getFromName(
$this->absoluteZipPath(
dirname($rel['Target'])
. '/'
. basename($rel['Target']))
));
. basename($rel['Target'])
)
)
);
$contents->registerXPathNamespace('w', Zend_Search_Lucene_Document_Docx::SCHEMA_WORDPROCESSINGML);
$paragraphs = $contents->xpath('//w:body/w:p');
@ -140,9 +148,10 @@ class Zend_Search_Lucene_Document_Docx extends Zend_Search_Lucene_Document_OpenX
* @return Zend_Search_Lucene_Document_Docx
* @throws Zend_Search_Lucene_Document_Exception
*/
public static function loadDocxFile($fileName, $storeContent = false) {
public static function loadDocxFile($fileName, $storeContent = false)
{
if (!is_readable($fileName)) {
require_once 'Zend/Search/Lucene/Document/Exception.php';
include_once 'Zend/Search/Lucene/Document/Exception.php';
throw new Zend_Search_Lucene_Document_Exception('Provided file \'' . $fileName . '\' is not readable.');
}

View File

@ -33,5 +33,7 @@ require_once 'Zend/Search/Lucene/Exception.php';
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Search_Lucene_Document_Exception extends Zend_Search_Lucene_Exception
{}
{
}

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Document */
/**
* Zend_Search_Lucene_Document
*/
require_once 'Zend/Search/Lucene/Document.php';
@ -68,7 +70,6 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
private static $_excludeNoFollowLinks = false;
/**
*
* List of inline tags
*
* @var array
@ -101,15 +102,19 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
if ($this->_doc->encoding === null) {
// Document encoding is not recognized
/** @todo improve HTML vs HTML fragment recognition */
/**
* @todo improve HTML vs HTML fragment recognition
*/
if (preg_match('/<html>/i', $htmlData, $matches, PREG_OFFSET_CAPTURE)) {
// It's an HTML document
// Add additional HEAD section and recognize document
$htmlTagOffset = $matches[0][1] + strlen($matches[0][0]);
@$this->_doc->loadHTML(iconv($defaultEncoding, 'UTF-8//IGNORE', substr($htmlData, 0, $htmlTagOffset))
@$this->_doc->loadHTML(
iconv($defaultEncoding, 'UTF-8//IGNORE', substr($htmlData, 0, $htmlTagOffset))
. '<head><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"/></head>'
. iconv($defaultEncoding, 'UTF-8//IGNORE', substr($htmlData, $htmlTagOffset)));
. iconv($defaultEncoding, 'UTF-8//IGNORE', substr($htmlData, $htmlTagOffset))
);
// Remove additional HEAD section
$xpath = new DOMXPath($this->_doc);
@ -117,13 +122,16 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
$head->parentNode->removeChild($head);
} else {
// It's an HTML fragment
@$this->_doc->loadHTML('<html><head><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"/></head><body>'
@$this->_doc->loadHTML(
'<html><head><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"/></head><body>'
. iconv($defaultEncoding, 'UTF-8//IGNORE', $htmlData)
. '</body></html>');
. '</body></html>'
);
}
}
/** @todo Add correction of wrong HTML encoding recognition processing
/**
* @todo Add correction of wrong HTML encoding recognition processing
* The case is:
* Content-type HTTP-EQUIV meta tag is presented, but ISO-8859-5 encoding is actually used,
* even $this->_doc->encoding demonstrates another recognized encoding
@ -141,9 +149,13 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
$metaNodes = $xpath->query('/html/head/meta[@name]');
foreach ($metaNodes as $metaNode) {
$this->addField(Zend_Search_Lucene_Field::Text($metaNode->getAttribute('name'),
$this->addField(
Zend_Search_Lucene_Field::Text(
$metaNode->getAttribute('name'),
$metaNode->getAttribute('content'),
'UTF-8'));
'UTF-8'
)
);
}
$docBody = '';
@ -160,16 +172,16 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
$linkNodes = $this->_doc->getElementsByTagName('a');
foreach ($linkNodes as $linkNode) {
if (($href = $linkNode->getAttribute('href')) != '' &&
(!self::$_excludeNoFollowLinks || strtolower($linkNode->getAttribute('rel')) != 'nofollow' )
if (($href = $linkNode->getAttribute('href')) != ''
&& (!self::$_excludeNoFollowLinks || strtolower($linkNode->getAttribute('rel')) != 'nofollow' )
) {
$this->_links[] = $href;
}
}
$linkNodes = $this->_doc->getElementsByTagName('area');
foreach ($linkNodes as $linkNode) {
if (($href = $linkNode->getAttribute('href')) != '' &&
(!self::$_excludeNoFollowLinks || strtolower($linkNode->getAttribute('rel')) != 'nofollow' )
if (($href = $linkNode->getAttribute('href')) != ''
&& (!self::$_excludeNoFollowLinks || strtolower($linkNode->getAttribute('rel')) != 'nofollow' )
) {
$this->_links[] = $href;
}
@ -285,8 +297,10 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
*/
protected function _highlightTextNode(DOMText $node, $wordsToHighlight, $callback, $params)
{
/** Zend_Search_Lucene_Analysis_Analyzer */
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
/**
* Zend_Search_Lucene_Analysis_Analyzer
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$analyzer = Zend_Search_Lucene_Analysis_Analyzer::getDefault();
$analyzer->setInput($node->nodeValue, 'UTF-8');
@ -321,11 +335,13 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
// into valid XHTML (It's automatically done by loadHTML() method)
$highlightedWordNodeSetDomDocument = new DOMDocument('1.0', 'UTF-8');
$success = @$highlightedWordNodeSetDomDocument->
loadHTML('<html><head><meta http-equiv="Content-type" content="text/html; charset=UTF-8"/></head><body>'
loadHTML(
'<html><head><meta http-equiv="Content-type" content="text/html; charset=UTF-8"/></head><body>'
. $highlightedWordNodeSetHtml
. '</body></html>');
. '</body></html>'
);
if (!$success) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception("Error occured while loading highlighted text fragment: '$highlightedWordNodeSetHtml'.");
}
$highlightedWordNodeSetXpath = new DOMXPath($highlightedWordNodeSetDomDocument);
@ -333,8 +349,10 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
for ($count = 0; $count < $highlightedWordNodeSet->length; $count++) {
$nodeToImport = $highlightedWordNodeSet->item($count);
$node->parentNode->insertBefore($this->_doc->importNode($nodeToImport, true /* deep copy */),
$matchedWordNode);
$node->parentNode->insertBefore(
$this->_doc->importNode($nodeToImport, true /* deep copy */),
$matchedWordNode
);
}
$node->parentNode->removeChild($matchedWordNode);
@ -406,15 +424,17 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
*
* @param string|array $words Words to highlight. Words could be organized using the array or string.
* @param callback $callback Callback method, used to transform (highlighting) text.
* @param array $params Array of additionall callback parameters passed through into it
* @param array $params Array of additionall callback parameters passed through into it (first non-optional parameter is an HTML fragment for highlighting) (first non-optional parameter is an HTML fragment for highlighting)
* (first non-optional parameter is an HTML fragment for highlighting)
* @return string
* @throws Zend_Search_Lucene_Exception
*/
public function highlightExtended($words, $callback, $params = array())
{
/** Zend_Search_Lucene_Analysis_Analyzer */
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
/**
* Zend_Search_Lucene_Analysis_Analyzer
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
if (!is_array($words)) {
$words = array($words);
@ -437,7 +457,7 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
}
if (!is_callable($callback)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('$viewHelper parameter mast be a View Helper name, View Helper object or callback.');
}

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Document */
/**
* Zend_Search_Lucene_Document
*/
require_once 'Zend/Search/Lucene/Document.php';
@ -112,12 +114,14 @@ abstract class Zend_Search_Lucene_Document_OpenXml extends Zend_Search_Lucene_Do
* @param string $path
* @return string
*/
protected function absoluteZipPath($path) {
protected function absoluteZipPath($path)
{
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
$absolutes = array();
foreach ($parts as $part) {
if ('.' == $part) continue;
if ('.' == $part) { continue;
}
if ('..' == $part) {
array_pop($absolutes);
} else {

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Document_OpenXml */
/**
* Zend_Search_Lucene_Document_OpenXml
*/
require_once 'Zend/Search/Lucene/Document/OpenXml.php';
/**
@ -73,7 +75,7 @@ class Zend_Search_Lucene_Document_Pptx extends Zend_Search_Lucene_Document_OpenX
private function __construct($fileName, $storeContent)
{
if (!class_exists('ZipArchive', false)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('MS Office documents processing functionality requires Zip extension to be loaded');
}
@ -90,7 +92,7 @@ class Zend_Search_Lucene_Document_Pptx extends Zend_Search_Lucene_Document_OpenX
// Read relations and search for officeDocument
$relationsXml = $package->getFromName('_rels/.rels');
if ($relationsXml === false) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Invalid archive or corrupted .pptx file.');
}
$relations = simplexml_load_string($relationsXml);
@ -180,8 +182,7 @@ class Zend_Search_Lucene_Document_Pptx extends Zend_Search_Lucene_Document_OpenX
}
// Store title (if not present in meta data)
if (!isset($coreProperties['title']))
{
if (!isset($coreProperties['title'])) {
$this->addField(Zend_Search_Lucene_Field::Text('title', $fileName, 'UTF-8'));
}
}

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Document_OpenXml */
/**
* Zend_Search_Lucene_Document_OpenXml
*/
require_once 'Zend/Search/Lucene/Document/OpenXml.php';
/**
@ -80,7 +82,7 @@ class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenX
private function __construct($fileName, $storeContent)
{
if (!class_exists('ZipArchive', false)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('MS Office documents processing functionality requires Zip extension to be loaded');
}
@ -97,7 +99,7 @@ class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenX
// Read relations and search for officeDocument
$relationsXml = $package->getFromName('_rels/.rels');
if ($relationsXml === false) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Invalid archive or corrupted .xlsx file.');
}
$relations = simplexml_load_string($relationsXml);
@ -189,9 +191,10 @@ class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenX
// Check for numeric values
if (is_numeric($value) && $dataType != 's') {
if ($value == (int)$value) $value = (int)$value;
elseif ($value == (float)$value) $value = (float)$value;
elseif ($value == (double)$value) $value = (double)$value;
if ($value == (int)$value) { $value = (int)$value;
} elseif ($value == (float)$value) { $value = (float)$value;
} elseif ($value == (double)$value) { $value = (double)$value;
}
}
}
@ -223,8 +226,7 @@ class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenX
}
// Store title (if not present in meta data)
if (!isset($coreProperties['title']))
{
if (!isset($coreProperties['title'])) {
$this->addField(Zend_Search_Lucene_Field::Text('title', $fileName, 'UTF-8'));
}
}
@ -235,7 +237,8 @@ class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenX
* @param SimpleXMLElement $is
* @return string
*/
private function _parseRichText($is = null) {
private function _parseRichText($is = null)
{
$value = array();
if (isset($is->t)) {

View File

@ -33,5 +33,7 @@ require_once 'Zend/Search/Exception.php';
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Search_Lucene_Exception extends Zend_Search_Exception
{}
{
}

View File

@ -19,7 +19,9 @@
* @version $Id: FSM.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_FSMAction */
/**
* Zend_Search_Lucene_FSMAction
*/
require_once 'Zend/Search/Lucene/FSMAction.php';
/**
@ -177,7 +179,7 @@ abstract class Zend_Search_Lucene_FSM
public function setState($state)
{
if (!isset($this->_states[$state])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('State \'' . $state . '\' is not on of the possible FSM states.');
}
@ -248,15 +250,15 @@ abstract class Zend_Search_Lucene_FSM
public function addRule($sourceState, $input, $targetState, $inputAction = null)
{
if (!isset($this->_states[$sourceState])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined source state (' . $sourceState . ').');
}
if (!isset($this->_states[$targetState])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined target state (' . $targetState . ').');
}
if (!isset($this->_inputAphabet[$input])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined input symbol (' . $input . ').');
}
@ -264,7 +266,7 @@ abstract class Zend_Search_Lucene_FSM
$this->_rules[$sourceState] = array();
}
if (isset($this->_rules[$sourceState][$input])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Rule for {state,input} pair (' . $sourceState . ', '. $input . ') is already defined.');
}
@ -288,7 +290,7 @@ abstract class Zend_Search_Lucene_FSM
public function addEntryAction($state, Zend_Search_Lucene_FSMAction $action)
{
if (!isset($this->_states[$state])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined state (' . $state. ').');
}
@ -310,7 +312,7 @@ abstract class Zend_Search_Lucene_FSM
public function addExitAction($state, Zend_Search_Lucene_FSMAction $action)
{
if (!isset($this->_states[$state])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined state (' . $state. ').');
}
@ -333,11 +335,11 @@ abstract class Zend_Search_Lucene_FSM
public function addInputAction($state, $inputSymbol, Zend_Search_Lucene_FSMAction $action)
{
if (!isset($this->_states[$state])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined state (' . $state. ').');
}
if (!isset($this->_inputAphabet[$inputSymbol])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined input symbol (' . $inputSymbol. ').');
}
@ -363,11 +365,11 @@ abstract class Zend_Search_Lucene_FSM
public function addTransitionAction($sourceState, $targetState, Zend_Search_Lucene_FSMAction $action)
{
if (!isset($this->_states[$sourceState])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined source state (' . $sourceState. ').');
}
if (!isset($this->_states[$targetState])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined source state (' . $targetState. ').');
}
@ -391,11 +393,11 @@ abstract class Zend_Search_Lucene_FSM
public function process($input)
{
if (!isset($this->_rules[$this->_currentState])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('There is no any rule for current state (' . $this->_currentState . ').');
}
if (!isset($this->_rules[$this->_currentState][$input])) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('There is no any rule for {current state, input} pair (' . $this->_currentState . ', ' . $input . ').');
}
@ -407,8 +409,9 @@ abstract class Zend_Search_Lucene_FSM
$action->doAction();
}
}
if (isset($this->_inputActions[$sourceState]) &&
isset($this->_inputActions[$sourceState][$input])) {
if (isset($this->_inputActions[$sourceState])
&& isset($this->_inputActions[$sourceState][$input])
) {
foreach ($this->_inputActions[$sourceState][$input] as $action) {
$action->doAction();
}
@ -417,8 +420,9 @@ abstract class Zend_Search_Lucene_FSM
$this->_currentState = $targetState;
if (isset($this->_transitionActions[$sourceState]) &&
isset($this->_transitionActions[$sourceState][$targetState])) {
if (isset($this->_transitionActions[$sourceState])
&& isset($this->_transitionActions[$sourceState][$targetState])
) {
foreach ($this->_transitionActions[$sourceState][$targetState] as $action) {
$action->doAction();
}
@ -433,7 +437,7 @@ abstract class Zend_Search_Lucene_FSM
public function reset()
{
if (count($this->_states) == 0) {
require_once 'Zend/Search/Exception.php';
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('There is no any state defined for FSM.');
}

View File

@ -23,7 +23,6 @@
/**
* Abstract Finite State Machine
*
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)

View File

@ -214,8 +214,9 @@ class Zend_Search_Lucene_Field
*/
public function getUtf8Value()
{
if (strcasecmp($this->encoding, 'utf8' ) == 0 ||
strcasecmp($this->encoding, 'utf-8') == 0 ) {
if (strcasecmp($this->encoding, 'utf8') == 0
|| strcasecmp($this->encoding, 'utf-8') == 0
) {
return $this->value;
} else {

View File

@ -27,7 +27,6 @@
* Manual "method inlining" is performed to increase dictionary index loading operation
* which is major bottelneck for search performance.
*
*
* @category Zend
* @package Zend_Search_Lucene
* @subpackage Index
@ -57,9 +56,10 @@ class Zend_Search_Lucene_Index_DictionaryLoader
// $tiVersion = $tiiFile->readInt();
$tiVersion = ord($data[0]) << 24 | ord($data[1]) << 16 | ord($data[2]) << 8 | ord($data[3]);
$pos += 4;
if ($tiVersion != (int)0xFFFFFFFE /* pre-2.1 format */ &&
$tiVersion != (int)0xFFFFFFFD /* 2.1+ format */) {
require_once 'Zend/Search/Lucene/Exception.php';
if ($tiVersion != (int)0xFFFFFFFE /* pre-2.1 format */
&& $tiVersion != (int)0xFFFFFFFD /* 2.1+ format */
) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Wrong TermInfoIndexFile file format');
}
@ -74,12 +74,13 @@ class Zend_Search_Lucene_Index_DictionaryLoader
ord($data[$pos+6]) << 8 |
ord($data[$pos+7]);
} else {
if ((ord($data[$pos]) != 0) ||
(ord($data[$pos+1]) != 0) ||
(ord($data[$pos+2]) != 0) ||
(ord($data[$pos+3]) != 0) ||
((ord($data[$pos+4]) & 0x80) != 0)) {
require_once 'Zend/Search/Lucene/Exception.php';
if ((ord($data[$pos]) != 0)
|| (ord($data[$pos+1]) != 0)
|| (ord($data[$pos+2]) != 0)
|| (ord($data[$pos+3]) != 0)
|| ((ord($data[$pos+4]) & 0x80) != 0)
) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Largest supported segment size (for 32-bit mode) is 2Gb');
}
@ -97,7 +98,7 @@ class Zend_Search_Lucene_Index_DictionaryLoader
$skipInterval = ord($data[$pos]) << 24 | ord($data[$pos+1]) << 16 | ord($data[$pos+2]) << 8 | ord($data[$pos+3]);
$pos += 4;
if ($indexTermCount < 1) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Wrong number of terms in a term dictionary index');
}
@ -149,8 +150,9 @@ class Zend_Search_Lucene_Index_DictionaryLoader
// Check for null character. Java2 encodes null character
// in two bytes.
if (ord($termSuffix[$count1]) == 0xC0 &&
ord($termSuffix[$count1+1]) == 0x80 ) {
if (ord($termSuffix[$count1]) == 0xC0
&& ord($termSuffix[$count1+1]) == 0x80
) {
$termSuffix[$count1] = 0;
$termSuffix = substr($termSuffix, 0, $count1+1)
. substr($termSuffix, $count1+2);
@ -253,7 +255,7 @@ class Zend_Search_Lucene_Index_DictionaryLoader
// Check special index entry mark
if ($termDictionary[0][0] != (int)0xFFFFFFFF) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Wrong TermInfoIndexFile file format');
}

View File

@ -20,7 +20,9 @@
* @version $Id: SegmentMerger.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Index_SegmentInfo */
/**
* Zend_Search_Lucene_Index_SegmentInfo
*/
require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
@ -82,8 +84,10 @@ class Zend_Search_Lucene_Index_SegmentMerger
*/
public function __construct($directory, $name)
{
/** Zend_Search_Lucene_Index_SegmentWriter_StreamWriter */
require_once 'Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php';
/**
* Zend_Search_Lucene_Index_SegmentWriter_StreamWriter
*/
include_once 'Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php';
$this->_writer = new Zend_Search_Lucene_Index_SegmentWriter_StreamWriter($directory, $name);
}
@ -110,15 +114,17 @@ class Zend_Search_Lucene_Index_SegmentMerger
public function merge()
{
if ($this->_mergeDone) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Merge is already done.');
}
if (count($this->_segmentInfos) < 1) {
require_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Wrong number of segments to be merged ('
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception(
'Wrong number of segments to be merged ('
. count($this->_segmentInfos)
. ').');
. ').'
);
}
$this->_mergeFields();
@ -191,21 +197,25 @@ class Zend_Search_Lucene_Index_SegmentMerger
if (!($bits & 2)) { // Text data
$storedFields[] =
new Zend_Search_Lucene_Field($fieldInfo->name,
new Zend_Search_Lucene_Field(
$fieldInfo->name,
$fdtFile->readString(),
'UTF-8',
true,
$fieldInfo->isIndexed,
$bits & 1 );
$bits & 1
);
} else { // Binary data
$storedFields[] =
new Zend_Search_Lucene_Field($fieldInfo->name,
new Zend_Search_Lucene_Field(
$fieldInfo->name,
$fdtFile->readBinary(),
'',
true,
$fieldInfo->isIndexed,
$bits & 1,
true);
true
);
}
}
@ -223,8 +233,10 @@ class Zend_Search_Lucene_Index_SegmentMerger
*/
private function _mergeTerms()
{
/** Zend_Search_Lucene_Index_TermsPriorityQueue */
require_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php';
/**
* Zend_Search_Lucene_Index_TermsPriorityQueue
*/
include_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php';
$segmentInfoQueue = new Zend_Search_Lucene_Index_TermsPriorityQueue();
@ -245,9 +257,9 @@ class Zend_Search_Lucene_Index_SegmentMerger
// Merge positions array
$termDocs += $segmentInfo->currentTermPositions();
if ($segmentInfoQueue->top() === null ||
$segmentInfoQueue->top()->currentTerm()->key() !=
$segmentInfo->currentTerm()->key()) {
if ($segmentInfoQueue->top() === null
|| $segmentInfoQueue->top()->currentTerm()->key() != $segmentInfo->currentTerm()->key()
) {
// We got new term
ksort($termDocs, SORT_NUMERIC);

View File

@ -21,13 +21,19 @@
*/
/** Zend_Search_Lucene_Index_FieldInfo */
/**
* Zend_Search_Lucene_Index_FieldInfo
*/
require_once 'Zend/Search/Lucene/Index/FieldInfo.php';
/** Zend_Search_Lucene_Index_Term */
/**
* Zend_Search_Lucene_Index_Term
*/
require_once 'Zend/Search/Lucene/Index/Term.php';
/** Zend_Search_Lucene_Index_TermInfo */
/**
* Zend_Search_Lucene_Index_TermInfo
*/
require_once 'Zend/Search/Lucene/Index/TermInfo.php';
/**
@ -167,10 +173,12 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
if (!isset($this->_fields[$field->name])) {
$fieldNumber = count($this->_fields);
$this->_fields[$field->name] =
new Zend_Search_Lucene_Index_FieldInfo($field->name,
new Zend_Search_Lucene_Index_FieldInfo(
$field->name,
$field->isIndexed,
$fieldNumber,
$field->storeTermVector);
$field->storeTermVector
);
return $fieldNumber;
} else {
@ -194,10 +202,12 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
if (!isset($this->_fields[$fieldInfo->name])) {
$fieldNumber = count($this->_fields);
$this->_fields[$fieldInfo->name] =
new Zend_Search_Lucene_Index_FieldInfo($fieldInfo->name,
new Zend_Search_Lucene_Index_FieldInfo(
$fieldInfo->name,
$fieldInfo->isIndexed,
$fieldNumber,
$fieldInfo->storeTermVector);
$fieldInfo->storeTermVector
);
return $fieldNumber;
} else {
@ -288,7 +298,8 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
foreach ($this->_fields as $field) {
$fnmFile->writeString($field->name);
$fnmFile->writeByte(($field->isIndexed ? 0x01 : 0x00) |
$fnmFile->writeByte(
($field->isIndexed ? 0x01 : 0x00) |
($field->storeTermVector ? 0x02 : 0x00)
// not supported yet 0x04 /* term positions are stored with the term vectors */ |
// not supported yet 0x08 /* term offsets are stored with the term vectors */ |
@ -401,7 +412,9 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
$this->_tiiFile->writeInt(self::$skipInterval);
$this->_tiiFile->writeInt(self::$maxSkipLevels);
/** Dump dictionary header */
/**
* Dump dictionary header
*/
$this->_tiiFile->writeVInt(0); // preffix length
$this->_tiiFile->writeString(''); // suffix
$this->_tiiFile->writeInt((int)0xFFFFFFFF); // field number
@ -469,10 +482,14 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
$skipOffset = 0;
}
$term = new Zend_Search_Lucene_Index_Term($termEntry->text,
$this->_fields[$termEntry->field]->number);
$termInfo = new Zend_Search_Lucene_Index_TermInfo(count($termDocs),
$freqPointer, $proxPointer, $skipOffset);
$term = new Zend_Search_Lucene_Index_Term(
$termEntry->text,
$this->_fields[$termEntry->field]->number
);
$termInfo = new Zend_Search_Lucene_Index_TermInfo(
count($termDocs),
$freqPointer, $proxPointer, $skipOffset
);
$this->_dumpTermDictEntry($this->_tisFile, $this->_prevTerm, $term, $this->_prevTermInfo, $termInfo);
@ -513,8 +530,9 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
*/
protected function _dumpTermDictEntry(Zend_Search_Lucene_Storage_File $dicFile,
&$prevTerm, Zend_Search_Lucene_Index_Term $term,
&$prevTermInfo, Zend_Search_Lucene_Index_TermInfo $termInfo)
{
&$prevTermInfo, Zend_Search_Lucene_Index_TermInfo $termInfo
) {
if (isset($prevTerm) && $prevTerm->field == $term->field) {
$matchedBytes = 0;
$maxBytes = min(strlen($prevTerm->text), strlen($term->text));

View File

@ -20,7 +20,9 @@
* @version $Id: DocumentWriter.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Index_SegmentWriter */
/**
* Zend_Search_Lucene_Index_SegmentWriter
*/
require_once 'Zend/Search/Lucene/Index/SegmentWriter.php';
/**
@ -71,8 +73,10 @@ class Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter extends Zend_Search_
*/
public function addDocument(Zend_Search_Lucene_Document $document)
{
/** Zend_Search_Lucene_Search_Similarity */
require_once 'Zend/Search/Lucene/Search/Similarity.php';
/**
* Zend_Search_Lucene_Search_Similarity
*/
include_once 'Zend/Search/Lucene/Search/Similarity.php';
$storedFields = array();
$docNorms = array();
@ -85,14 +89,16 @@ class Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter extends Zend_Search_
/**
* @todo term vector storing support
*/
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Store term vector functionality is not supported yet.');
}
if ($field->isIndexed) {
if ($field->isTokenized) {
/** Zend_Search_Lucene_Analysis_Analyzer */
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
/**
* Zend_Search_Lucene_Analysis_Analyzer
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$analyzer = Zend_Search_Lucene_Analysis_Analyzer::getDefault();
$analyzer->setInput($field->value, $field->encoding);
@ -123,10 +129,16 @@ class Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter extends Zend_Search_
$field = clone($field);
$field->isIndexed = $field->isTokenized = false;
} else {
$docNorms[$field->name] = chr($similarity->encodeNorm( $similarity->lengthNorm($field->name,
$tokenCounter)*
$docNorms[$field->name] = chr(
$similarity->encodeNorm(
$similarity->lengthNorm(
$field->name,
$tokenCounter
)*
$document->boost*
$field->boost ));
$field->boost
)
);
}
} else if (($fieldUtf8Value = $field->getUtf8Value()) == '') {
// Field contains empty value. Treat it as non-indexed and non-tokenized
@ -147,9 +159,13 @@ class Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter extends Zend_Search_
}
$this->_termDocs[$termKey][$this->_docCount][] = 0; // position
$docNorms[$field->name] = chr($similarity->encodeNorm( $similarity->lengthNorm($field->name, 1)*
$docNorms[$field->name] = chr(
$similarity->encodeNorm(
$similarity->lengthNorm($field->name, 1)*
$document->boost*
$field->boost ));
$field->boost
)
);
}
}
@ -166,8 +182,10 @@ class Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter extends Zend_Search_
}
if (!isset($this->_norms[$fieldName])) {
$this->_norms[$fieldName] = str_repeat(chr($similarity->encodeNorm( $similarity->lengthNorm($fieldName, 0) )),
$this->_docCount);
$this->_norms[$fieldName] = str_repeat(
chr($similarity->encodeNorm($similarity->lengthNorm($fieldName, 0))),
$this->_docCount
);
}
if (isset($docNorms[$fieldName])) {
@ -214,16 +232,20 @@ class Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter extends Zend_Search_
$this->_generateCFS();
/** Zend_Search_Lucene_Index_SegmentInfo */
require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
/**
* Zend_Search_Lucene_Index_SegmentInfo
*/
include_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
return new Zend_Search_Lucene_Index_SegmentInfo($this->_directory,
return new Zend_Search_Lucene_Index_SegmentInfo(
$this->_directory,
$this->_name,
$this->_docCount,
-1,
null,
true,
true);
true
);
}
}

View File

@ -20,7 +20,9 @@
* @version $Id: StreamWriter.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Index_SegmentWriter */
/**
* Zend_Search_Lucene_Index_SegmentWriter
*/
require_once 'Zend/Search/Lucene/Index/SegmentWriter.php';
/**
@ -79,16 +81,20 @@ class Zend_Search_Lucene_Index_SegmentWriter_StreamWriter extends Zend_Search_Lu
$this->_dumpFNM();
$this->_generateCFS();
/** Zend_Search_Lucene_Index_SegmentInfo */
require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
/**
* Zend_Search_Lucene_Index_SegmentInfo
*/
include_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
return new Zend_Search_Lucene_Index_SegmentInfo($this->_directory,
return new Zend_Search_Lucene_Index_SegmentInfo(
$this->_directory,
$this->_name,
$this->_docCount,
-1,
null,
true,
true);
true
);
}
}

View File

@ -20,7 +20,9 @@
* @version $Id: TermsPriorityQueue.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_PriorityQueue */
/**
* Zend_Search_Lucene_PriorityQueue
*/
require_once 'Zend/Search/Lucene/PriorityQueue.php';
/**

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_LockManager */
/**
* Zend_Search_Lucene_LockManager
*/
require_once 'Zend/Search/Lucene/LockManager.php';
@ -169,10 +171,11 @@ class Zend_Search_Lucene_Index_Writer
if ($generation == 0) {
// Create index in pre-2.1 mode
foreach ($directory->fileList() as $file) {
if ($file == 'deletable' ||
$file == 'segments' ||
isset(self::$_indexExtensions[ substr($file, strlen($file)-4)]) ||
preg_match('/\.f\d+$/i', $file) /* matches <segment_name>.f<decimal_nmber> file names */) {
if ($file == 'deletable'
|| $file == 'segments'
|| isset(self::$_indexExtensions[ substr($file, strlen($file)-4)])
|| preg_match('/\.f\d+$/i', $file) /* matches <segment_name>.f<decimal_nmber> file names */
) {
$directory->deleteFile($file);
}
}
@ -234,8 +237,10 @@ class Zend_Search_Lucene_Index_Writer
*/
public function addDocument(Zend_Search_Lucene_Document $document)
{
/** Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter */
require_once 'Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php';
/**
* Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter
*/
include_once 'Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php';
if ($this->_currentSegment === null) {
$this->_currentSegment =
@ -373,10 +378,14 @@ class Zend_Search_Lucene_Index_Writer
{
$newName = $this->_newSegmentName();
/** Zend_Search_Lucene_Index_SegmentMerger */
require_once 'Zend/Search/Lucene/Index/SegmentMerger.php';
$merger = new Zend_Search_Lucene_Index_SegmentMerger($this->_directory,
$newName);
/**
* Zend_Search_Lucene_Index_SegmentMerger
*/
include_once 'Zend/Search/Lucene/Index/SegmentMerger.php';
$merger = new Zend_Search_Lucene_Index_SegmentMerger(
$this->_directory,
$newName
);
foreach ($segments as $segmentInfo) {
$merger->addSource($segmentInfo);
$this->_segmentsToDelete[$segmentInfo->getName()] = $segmentInfo->getName();
@ -517,16 +526,20 @@ class Zend_Search_Lucene_Index_Writer
$isCompound = true;
}
/** Zend_Search_Lucene_Index_SegmentInfo */
require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
/**
* Zend_Search_Lucene_Index_SegmentInfo
*/
include_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
$this->_segmentInfos[$segName] =
new Zend_Search_Lucene_Index_SegmentInfo($this->_directory,
new Zend_Search_Lucene_Index_SegmentInfo(
$this->_directory,
$segName,
$segSize,
$delGen,
$docStoreOptions,
$hasSingleNormFile,
$isCompound);
$isCompound
);
} else {
// Retrieve actual deletions file generation number
$delGen = $this->_segmentInfos[$segName]->getDelGen();
@ -593,7 +606,9 @@ class Zend_Search_Lucene_Index_Writer
$newSegmentFile->writeInt($segmentsCount); // Update segments count
$newSegmentFile->close();
} catch (Exception $e) {
/** Restore previous index generation */
/**
* Restore previous index generation
*/
$generation--;
$genFile->seek(4, SEEK_SET);
// Write generation number twice
@ -603,7 +618,7 @@ class Zend_Search_Lucene_Index_Writer
Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
// Throw the exception
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
}
@ -672,8 +687,9 @@ class Zend_Search_Lucene_Index_Writer
// one of per segment files ('<segment_name>.<ext>')
$segmentName = substr($file, 0, strlen($file) - 4);
// Check if it's not one of the segments in the current segments set
if (!isset($segments[$segmentName]) &&
($this->_currentSegment === null || $this->_currentSegment->getName() != $segmentName)) {
if (!isset($segments[$segmentName])
&& ($this->_currentSegment === null || $this->_currentSegment->getName() != $segmentName)
) {
$filesToDelete[] = $file;
$filesTypes[] = 3; // second group of files for deletions
$filesNumbers[] = (int)base_convert(substr($file, 1 /* skip '_' */, strlen($file)-5), 36, 10); // order by segment number
@ -702,14 +718,20 @@ class Zend_Search_Lucene_Index_Writer
}
// Reorder files for deleting
array_multisort($filesTypes, SORT_ASC, SORT_NUMERIC,
array_multisort(
$filesTypes, SORT_ASC, SORT_NUMERIC,
$filesNumbers, SORT_ASC, SORT_NUMERIC,
$filesToDelete, SORT_ASC, SORT_STRING);
$filesToDelete, SORT_ASC, SORT_STRING
);
foreach ($filesToDelete as $file) {
try {
/** Skip shared docstore segments deleting */
/** @todo Process '.cfx' files to check if them are already unused */
/**
* Skip shared docstore segments deleting
*/
/**
* @todo Process '.cfx' files to check if them are already unused
*/
if (substr($file, strlen($file)-4) != '.cfx') {
$this->_directory->deleteFile($file);
}

View File

@ -20,19 +20,29 @@
*/
/** Zend_Search_Lucene_Index_TermsStream_Interface */
/**
* Zend_Search_Lucene_Index_TermsStream_Interface
*/
require_once 'Zend/Search/Lucene/Index/TermsStream/Interface.php';
/** Classes used within Zend_Search_Lucene_Interface API */
/**
* Classes used within Zend_Search_Lucene_Interface API
*/
/** Zend_Search_Lucene_Document */
/**
* Zend_Search_Lucene_Document
*/
require_once 'Zend/Search/Lucene/Document.php';
/** Zend_Search_Lucene_Index_Term */
/**
* Zend_Search_Lucene_Index_Term
*/
require_once 'Zend/Search/Lucene/Index/Term.php';
/** Zend_Search_Lucene_Index_DocsFilter */
/**
* Zend_Search_Lucene_Index_DocsFilter
*/
require_once 'Zend/Search/Lucene/Index/DocsFilter.php';

View File

@ -19,10 +19,14 @@
* @version $Id: LockManager.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Storage_Directory */
/**
* Zend_Search_Lucene_Storage_Directory
*/
require_once 'Zend/Search/Lucene/Storage/Directory.php';
/** Zend_Search_Lucene_Storage_File */
/**
* Zend_Search_Lucene_Storage_File
*/
require_once 'Zend/Search/Lucene/Storage/File.php';
/**
@ -54,7 +58,7 @@ class Zend_Search_Lucene_LockManager
{
$lock = $lockDirectory->createFile(self::WRITE_LOCK_FILE);
if (!$lock->lock(LOCK_EX)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Can\'t obtain exclusive index lock');
}
return $lock;
@ -99,7 +103,7 @@ class Zend_Search_Lucene_LockManager
{
$lock = $lockDirectory->createFile(self::READ_LOCK_PROCESSING_LOCK_FILE);
if (!$lock->lock(LOCK_EX)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Can\'t obtain exclusive lock for the read lock processing file');
}
return $lock;
@ -133,7 +137,7 @@ class Zend_Search_Lucene_LockManager
{
$lock = $lockDirectory->createFile(self::READ_LOCK_FILE);
if (!$lock->lock(LOCK_SH)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Can\'t obtain shared reading index lock');
}
return $lock;

View File

@ -20,7 +20,9 @@
*/
/** Zend_Search_Lucene_Interface */
/**
* Zend_Search_Lucene_Interface
*/
require_once 'Zend/Search/Lucene/Interface.php';
/**
@ -53,7 +55,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
foreach ($this->_indices as $index) {
if (!$index instanceof Zend_Search_Lucene_Interface) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('sub-index objects have to implement Zend_Search_Lucene_Interface.');
}
}
@ -83,7 +85,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
*/
public static function getActualGeneration(Zend_Search_Lucene_Storage_Directory $directory)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception("Generation number can't be retrieved for multi-searcher");
}
@ -106,7 +108,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
*/
public function getFormatVersion()
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception("Format version can't be retrieved for multi-searcher");
}
@ -130,7 +132,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
*/
public function getDirectory()
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception("Index directory can't be retrieved for multi-searcher");
}
@ -197,7 +199,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
$id -= $indexCount;
}
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document id is out of the range.');
}
@ -229,7 +231,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
public static function getDefaultSearchField()
{
if (count($this->_indices) == 0) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices list is empty');
}
@ -237,7 +239,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
foreach ($this->_indices as $index) {
if ($index->getDefaultSearchField() !== $defaultSearchField) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices have different default search field.');
}
}
@ -270,7 +272,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
public static function getResultSetLimit()
{
if (count($this->_indices) == 0) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices list is empty');
}
@ -278,7 +280,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
foreach ($this->_indices as $index) {
if ($index->getResultSetLimit() !== $defaultResultSetLimit) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices have different default search field.');
}
}
@ -300,7 +302,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
public function getMaxBufferedDocs()
{
if (count($this->_indices) == 0) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices list is empty');
}
@ -308,7 +310,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
foreach ($this->_indices as $index) {
if ($index->getMaxBufferedDocs() !== $maxBufferedDocs) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices have different default search field.');
}
}
@ -349,7 +351,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
public function getMaxMergeDocs()
{
if (count($this->_indices) == 0) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices list is empty');
}
@ -357,7 +359,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
foreach ($this->_indices as $index) {
if ($index->getMaxMergeDocs() !== $maxMergeDocs) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices have different default search field.');
}
}
@ -405,7 +407,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
public function getMergeFactor()
{
if (count($this->_indices) == 0) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices list is empty');
}
@ -413,7 +415,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
foreach ($this->_indices as $index) {
if ($index->getMergeFactor() !== $mergeFactor) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices have different default search field.');
}
}
@ -476,7 +478,9 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
$hitsList[] = $hits;
}
/** @todo Implement advanced sorting */
/**
* @todo Implement advanced sorting
*/
return call_user_func_array('array_merge', $hitsList);
}
@ -523,7 +527,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
$id -= $indexCount;
}
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document id is out of the range.');
}
@ -557,7 +561,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
public function termDocs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
{
if ($docsFilter != null) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document filters could not used with multi-searcher');
}
@ -593,7 +597,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
*/
public function termDocsFilter(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document filters could not used with multi-searcher');
}
@ -609,7 +613,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
public function termFreqs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
{
if ($docsFilter != null) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document filters could not used with multi-searcher');
}
@ -647,7 +651,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
public function termPositions(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
{
if ($docsFilter != null) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document filters could not used with multi-searcher');
}
@ -699,7 +703,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
public function getSimilarity()
{
if (count($this->_indices) == 0) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices list is empty');
}
@ -707,7 +711,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
foreach ($this->_indices as $index) {
if ($index->getSimilarity() !== $similarity) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices have different similarity.');
}
}
@ -773,7 +777,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
$id -= $indexCount;
}
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document id is out of the range.');
}
@ -799,7 +803,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
public function setDocumentDistributorCallback($callback)
{
if ($callback !== null && !is_callable($callback)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('$callback parameter must be a valid callback.');
}
@ -885,8 +889,10 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
public function resetTermsStream()
{
if ($this->_termsStream === null) {
/** Zend_Search_Lucene_TermStreamsPriorityQueue */
require_once 'Zend/Search/Lucene/TermStreamsPriorityQueue.php';
/**
* Zend_Search_Lucene_TermStreamsPriorityQueue
*/
include_once 'Zend/Search/Lucene/TermStreamsPriorityQueue.php';
$this->_termsStream = new Zend_Search_Lucene_TermStreamsPriorityQueue($this->_indices);
} else {

View File

@ -133,8 +133,8 @@ abstract class Zend_Search_Lucene_PriorityQueue
$childId = ($nodeId << 1) + 1; // First child
// Choose smaller child
if (($childId+1) < $lastId &&
$this->_less($this->_heap[$childId+1], $this->_heap[$childId])
if (($childId+1) < $lastId
&& $this->_less($this->_heap[$childId+1], $this->_heap[$childId])
) {
$childId++;
}

View File

@ -19,7 +19,9 @@
* @version $Id: Proxy.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Interface */
/**
* Zend_Search_Lucene_Interface
*/
require_once 'Zend/Search/Lucene/Interface.php';

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_FSM */
/**
* Zend_Search_Lucene_FSM
*/
require_once 'Zend/Search/Lucene/FSM.php';
/**
@ -33,14 +35,18 @@ require_once 'Zend/Search/Lucene/FSM.php';
*/
class Zend_Search_Lucene_Search_BooleanExpressionRecognizer extends Zend_Search_Lucene_FSM
{
/** State Machine states */
/**
* State Machine states
*/
const ST_START = 0;
const ST_LITERAL = 1;
const ST_NOT_OPERATOR = 2;
const ST_AND_OPERATOR = 3;
const ST_OR_OPERATOR = 4;
/** Input symbols */
/**
* Input symbols
*/
const IN_LITERAL = 0;
const IN_NOT_OPERATOR = 1;
const IN_AND_OPERATOR = 2;
@ -100,7 +106,8 @@ class Zend_Search_Lucene_Search_BooleanExpressionRecognizer extends Zend_Search_
*/
public function __construct()
{
parent::__construct( array(self::ST_START,
parent::__construct(
array(self::ST_START,
self::ST_LITERAL,
self::ST_NOT_OPERATOR,
self::ST_AND_OPERATOR,
@ -108,12 +115,14 @@ class Zend_Search_Lucene_Search_BooleanExpressionRecognizer extends Zend_Search_
array(self::IN_LITERAL,
self::IN_NOT_OPERATOR,
self::IN_AND_OPERATOR,
self::IN_OR_OPERATOR));
self::IN_OR_OPERATOR)
);
$emptyOperatorAction = new Zend_Search_Lucene_FSMAction($this, 'emptyOperatorAction');
$emptyNotOperatorAction = new Zend_Search_Lucene_FSMAction($this, 'emptyNotOperatorAction');
$this->addRules(array( array(self::ST_START, self::IN_LITERAL, self::ST_LITERAL),
$this->addRules(
array( array(self::ST_START, self::IN_LITERAL, self::ST_LITERAL),
array(self::ST_START, self::IN_NOT_OPERATOR, self::ST_NOT_OPERATOR),
array(self::ST_LITERAL, self::IN_AND_OPERATOR, self::ST_AND_OPERATOR),
@ -128,7 +137,8 @@ class Zend_Search_Lucene_Search_BooleanExpressionRecognizer extends Zend_Search_
array(self::ST_OR_OPERATOR, self::IN_LITERAL, self::ST_LITERAL),
array(self::ST_OR_OPERATOR, self::IN_NOT_OPERATOR, self::ST_NOT_OPERATOR),
));
)
);
$notOperatorAction = new Zend_Search_Lucene_FSMAction($this, 'notOperatorAction');
$orOperatorAction = new Zend_Search_Lucene_FSMAction($this, 'orOperatorAction');
@ -194,7 +204,7 @@ class Zend_Search_Lucene_Search_BooleanExpressionRecognizer extends Zend_Search_
public function finishExpression()
{
if ($this->getState() != self::ST_LITERAL) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Literal expected.');
}
@ -214,8 +224,10 @@ class Zend_Search_Lucene_Search_BooleanExpressionRecognizer extends Zend_Search_
*/
public function emptyOperatorAction()
{
/** Zend_Search_Lucene_Search_QueryParser */
require_once 'Zend/Search/Lucene/Search/QueryParser.php';
/**
* Zend_Search_Lucene_Search_QueryParser
*/
include_once 'Zend/Search/Lucene/Search/QueryParser.php';
if (Zend_Search_Lucene_Search_QueryParser::getDefaultOperator() == Zend_Search_Lucene_Search_QueryParser::B_AND) {
// Do nothing
@ -232,8 +244,10 @@ class Zend_Search_Lucene_Search_BooleanExpressionRecognizer extends Zend_Search_
*/
public function emptyNotOperatorAction()
{
/** Zend_Search_Lucene_Search_QueryParser */
require_once 'Zend/Search/Lucene/Search/QueryParser.php';
/**
* Zend_Search_Lucene_Search_QueryParser
*/
include_once 'Zend/Search/Lucene/Search/QueryParser.php';
if (Zend_Search_Lucene_Search_QueryParser::getDefaultOperator() == Zend_Search_Lucene_Search_QueryParser::B_AND) {
// Do nothing

View File

@ -20,7 +20,9 @@
* @version $Id: Default.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** @see Zend_Search_Lucene_Search_Highlighter_Interface */
/**
* @see Zend_Search_Lucene_Search_Highlighter_Interface
*/
require_once 'Zend/Search/Lucene/Search/Highlighter/Interface.php';
/**
* @category Zend

View File

@ -186,12 +186,14 @@ abstract class Zend_Search_Lucene_Search_Query
public function highlightMatches($inputHTML, $defaultEncoding = '', $highlighter = null)
{
if ($highlighter === null) {
require_once 'Zend/Search/Lucene/Search/Highlighter/Default.php';
include_once 'Zend/Search/Lucene/Search/Highlighter/Default.php';
$highlighter = new Zend_Search_Lucene_Search_Highlighter_Default();
}
/** Zend_Search_Lucene_Document_Html */
require_once 'Zend/Search/Lucene/Document/Html.php';
/**
* Zend_Search_Lucene_Document_Html
*/
include_once 'Zend/Search/Lucene/Document/Html.php';
$doc = Zend_Search_Lucene_Document_Html::loadHTML($inputHTML, false, $defaultEncoding);
$highlighter->setDocument($doc);
@ -212,15 +214,17 @@ abstract class Zend_Search_Lucene_Search_Query
public function htmlFragmentHighlightMatches($inputHtmlFragment, $encoding = 'UTF-8', $highlighter = null)
{
if ($highlighter === null) {
require_once 'Zend/Search/Lucene/Search/Highlighter/Default.php';
include_once 'Zend/Search/Lucene/Search/Highlighter/Default.php';
$highlighter = new Zend_Search_Lucene_Search_Highlighter_Default();
}
$inputHTML = '<html><head><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"/></head><body>'
. iconv($encoding, 'UTF-8//IGNORE', $inputHtmlFragment) . '</body></html>';
/** Zend_Search_Lucene_Document_Html */
require_once 'Zend/Search/Lucene/Document/Html.php';
/**
* Zend_Search_Lucene_Document_Html
*/
include_once 'Zend/Search/Lucene/Document/Html.php';
$doc = Zend_Search_Lucene_Document_Html::loadHTML($inputHTML);
$highlighter->setDocument($doc);

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -114,7 +116,8 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
* @param boolean|null $sign
* @return void
*/
public function addSubquery(Zend_Search_Lucene_Search_Query $subquery, $sign=null) {
public function addSubquery(Zend_Search_Lucene_Search_Query $subquery, $sign=null)
{
if ($sign !== true || $this->_signs !== null) { // Skip, if all subqueries are required
if ($this->_signs === null) { // Check, If all previous subqueries are required
$this->_signs = array();
@ -140,8 +143,10 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
$query->setBoost($this->getBoost());
foreach ($this->_subqueries as $subqueryId => $subquery) {
$query->addSubquery($subquery->rewrite($index),
($this->_signs === null)? true : $this->_signs[$subqueryId]);
$query->addSubquery(
$subquery->rewrite($index),
($this->_signs === null)? true : $this->_signs[$subqueryId]
);
}
return $query;
@ -174,7 +179,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
}
if (count($subqueries) == 0) {
// Boolean query doesn't has non-insignificant subqueries
require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
include_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
return new Zend_Search_Lucene_Search_Query_Insignificant();
}
// Check if all non-insignificant subqueries are prohibited
@ -186,7 +191,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
}
}
if ($allProhibited) {
require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
include_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
return new Zend_Search_Lucene_Search_Query_Insignificant();
}
@ -196,7 +201,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
if ($subquery instanceof Zend_Search_Lucene_Search_Query_Empty) {
if ($signs[$id] === true) {
// Matching is required, but is actually empty
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
} else {
// Matching is optional or prohibited, but is empty
@ -209,7 +214,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
// Check, if reduced subqueries list is empty
if (count($subqueries) == 0) {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
}
@ -222,7 +227,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
}
}
if ($allProhibited) {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
}
@ -357,7 +362,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
// Check, if all subqueries have been decomposed and all terms has the same boost factor
if (count($subqueries) == 0 && count(array_unique($boostFactors)) == 1) {
require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
include_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
$optimizedQuery = new Zend_Search_Lucene_Search_Query_MultiTerm($terms, $tsigns);
$optimizedQuery->setBoost(reset($boostFactors)*$this->getBoost());
@ -381,7 +386,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
}
if (count($terms) == 1) {
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
$clause = new Zend_Search_Lucene_Search_Query_Term(reset($terms));
$clause->setBoost(reset($boostFactors));
@ -391,7 +396,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
// Clear terms list
$terms = array();
} else if (count($terms) > 1 && count(array_unique($boostFactors)) == 1) {
require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
include_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
$clause = new Zend_Search_Lucene_Search_Query_MultiTerm($terms, $tsigns);
$clause->setBoost(reset($boostFactors));
@ -405,7 +410,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
if (count($prohibitedTerms) == 1) {
// (boost factors are not significant for prohibited clauses)
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
$subqueries[] = new Zend_Search_Lucene_Search_Query_Term(reset($prohibitedTerms));
$signs[] = false;
@ -420,7 +425,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
}
// (boost factors are not significant for prohibited clauses)
require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
include_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
$subqueries[] = new Zend_Search_Lucene_Search_Query_MultiTerm($prohibitedTerms, $prohibitedSigns);
// Clause sign is 'prohibited'
$signs[] = false;
@ -429,7 +434,9 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
$prohibitedTerms = array();
}
/** @todo Group terms with the same boost factors together */
/**
* @todo Group terms with the same boost factors together
*/
// Check, that all terms are processed
// Replace candidate for optimized query
@ -471,7 +478,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
*/
public function createWeight(Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Search/Weight/Boolean.php';
include_once 'Zend/Search/Lucene/Search/Weight/Boolean.php';
$this->_weight = new Zend_Search_Lucene_Search_Weight_Boolean($this, $reader);
return $this->_weight;
}
@ -498,9 +505,11 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
$resVectorsIds[] = $subqueryId;
}
// sort resvectors in order of subquery cardinality increasing
array_multisort($resVectorsSizes, SORT_ASC, SORT_NUMERIC,
array_multisort(
$resVectorsSizes, SORT_ASC, SORT_NUMERIC,
$resVectorsIds, SORT_ASC, SORT_NUMERIC,
$resVectors);
$resVectors
);
foreach ($resVectors as $nextResVector) {
if($this->_resVector === null) {
@ -562,9 +571,11 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
}
// sort resvectors in order of subquery cardinality increasing
array_multisort($requiredVectorsSizes, SORT_ASC, SORT_NUMERIC,
array_multisort(
$requiredVectorsSizes, SORT_ASC, SORT_NUMERIC,
$requiredVectorsIds, SORT_ASC, SORT_NUMERIC,
$requiredVectors);
$requiredVectors
);
$required = null;
foreach ($requiredVectors as $nextResVector) {
@ -612,8 +623,10 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
public function _conjunctionScore($docId, Zend_Search_Lucene_Interface $reader)
{
if ($this->_coord === null) {
$this->_coord = $reader->getSimilarity()->coord(count($this->_subqueries),
count($this->_subqueries) );
$this->_coord = $reader->getSimilarity()->coord(
count($this->_subqueries),
count($this->_subqueries)
);
}
$score = 0;
@ -694,7 +707,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
if ($docsFilter === null) {
// Create local documents filter if it's not provided by upper query
require_once 'Zend/Search/Lucene/Index/DocsFilter.php';
include_once 'Zend/Search/Lucene/Index/DocsFilter.php';
$docsFilter = new Zend_Search_Lucene_Index_DocsFilter();
}

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -65,7 +67,7 @@ class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Qu
*/
public function createWeight(Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Search/Weight/Empty.php';
include_once 'Zend/Search/Lucene/Search/Weight/Empty.php';
return new Zend_Search_Lucene_Search_Weight_Empty();
}

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -34,7 +36,9 @@ require_once 'Zend/Search/Lucene/Search/Query.php';
*/
class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Query
{
/** Default minimum similarity */
/**
* Default minimum similarity
*/
const DEFAULT_MIN_SIMILARITY = 0.5;
/**
@ -122,15 +126,15 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
public function __construct(Zend_Search_Lucene_Index_Term $term, $minimumSimilarity = self::DEFAULT_MIN_SIMILARITY, $prefixLength = null)
{
if ($minimumSimilarity < 0) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('minimumSimilarity cannot be less than 0');
}
if ($minimumSimilarity >= 1) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('minimumSimilarity cannot be greater than or equal to 1');
}
if ($prefixLength < 0) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('prefixLength cannot be less than 0');
}
@ -193,7 +197,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
$fields = array($this->_term->field);
}
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$prefix = Zend_Search_Lucene_Index_Term::getPrefix($this->_term->text, $this->_prefixLength);
$prefixByteLength = strlen($prefix);
$prefixUtf8Length = Zend_Search_Lucene_Index_Term::getLength($prefix);
@ -206,12 +210,12 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
$scaleFactor = 1/(1 - $this->_minimumSimilarity);
require_once 'Zend/Search/Lucene.php';
include_once 'Zend/Search/Lucene.php';
$maxTerms = Zend_Search_Lucene::getTermsPerQueryLimit();
foreach ($fields as $field) {
$index->resetTermsStream();
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
if ($prefix != '') {
$index->skipTo(new Zend_Search_Lucene_Index_Term($prefix, $field));
@ -249,7 +253,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
$this->_scores[] = ($similarity - $this->_minimumSimilarity)*$scaleFactor;
if ($maxTerms != 0 && count($this->_matches) > $maxTerms) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.');
}
}
@ -285,7 +289,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
$this->_scores[] = ($similarity - $this->_minimumSimilarity)*$scaleFactor;
if ($maxTerms != 0 && count($this->_matches) > $maxTerms) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.');
}
}
@ -298,21 +302,23 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
}
if (count($this->_matches) == 0) {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
} else if (count($this->_matches) == 1) {
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
return new Zend_Search_Lucene_Search_Query_Term(reset($this->_matches));
} else {
require_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
include_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
$rewrittenQuery = new Zend_Search_Lucene_Search_Query_Boolean();
array_multisort($this->_scores, SORT_DESC, SORT_NUMERIC,
array_multisort(
$this->_scores, SORT_DESC, SORT_NUMERIC,
$this->_termKeys, SORT_ASC, SORT_STRING,
$this->_matches);
$this->_matches
);
$termCount = 0;
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
foreach ($this->_matches as $id => $matchedTerm) {
$subquery = new Zend_Search_Lucene_Search_Query_Term($matchedTerm);
$subquery->setBoost($this->_scores[$id]);
@ -337,7 +343,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
*/
public function optimize(Zend_Search_Lucene_Interface $index)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Fuzzy query should not be directly used for search. Use $query->rewrite($index)');
}
@ -350,7 +356,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
public function getQueryTerms()
{
if ($this->_matches === null) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Search or rewrite operations have to be performed before.');
}
@ -366,7 +372,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
*/
public function createWeight(Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Fuzzy query should not be directly used for search. Use $query->rewrite($index)');
}
@ -381,7 +387,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
*/
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Fuzzy query should not be directly used for search. Use $query->rewrite($index)');
}
@ -395,7 +401,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
*/
public function matchedDocs()
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Fuzzy query should not be directly used for search. Use $query->rewrite($index)');
}
@ -409,7 +415,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
*/
public function score($docId, Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Fuzzy query should not be directly used for search. Use $query->rewrite($index)');
}
@ -422,7 +428,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
{
$words = array();
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$prefix = Zend_Search_Lucene_Index_Term::getPrefix($this->_term->text, $this->_prefixLength);
$prefixByteLength = strlen($prefix);
$prefixUtf8Length = Zend_Search_Lucene_Index_Term::getLength($prefix);
@ -436,7 +442,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
$scaleFactor = 1/(1 - $this->_minimumSimilarity);
$docBody = $highlighter->getDocument()->getFieldUtf8Value('body');
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($docBody, 'UTF-8');
foreach ($tokens as $token) {
$termText = $token->getTermText();

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -66,7 +68,7 @@ class Zend_Search_Lucene_Search_Query_Insignificant extends Zend_Search_Lucene_S
*/
public function createWeight(Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Search/Weight/Empty.php';
include_once 'Zend/Search/Lucene/Search/Weight/Empty.php';
return new Zend_Search_Lucene_Search_Weight_Empty();
}

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -106,7 +108,7 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
public function __construct($terms = null, $signs = null)
{
if (is_array($terms)) {
require_once 'Zend/Search/Lucene.php';
include_once 'Zend/Search/Lucene.php';
if (count($terms) > Zend_Search_Lucene::getTermsPerQueryLimit()) {
throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.');
}
@ -139,7 +141,8 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
* @param boolean|null $sign
* @return void
*/
public function addTerm(Zend_Search_Lucene_Index_Term $term, $sign = null) {
public function addTerm(Zend_Search_Lucene_Index_Term $term, $sign = null)
{
if ($sign !== true || $this->_signs !== null) { // Skip, if all terms are required
if ($this->_signs === null) { // Check, If all previous terms are required
$this->_signs = array();
@ -163,7 +166,7 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
public function rewrite(Zend_Search_Lucene_Interface $index)
{
if (count($this->_terms) == 0) {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
}
@ -179,17 +182,21 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
if ($allQualified) {
return $this;
} else {
/** transform multiterm query to boolean and apply rewrite() method to subqueries. */
require_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
/**
* transform multiterm query to boolean and apply rewrite() method to subqueries.
*/
include_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
$query = new Zend_Search_Lucene_Search_Query_Boolean();
$query->setBoost($this->getBoost());
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
foreach ($this->_terms as $termId => $term) {
$subquery = new Zend_Search_Lucene_Search_Query_Term($term);
$query->addSubquery($subquery->rewrite($index),
($this->_signs === null)? true : $this->_signs[$termId]);
$query->addSubquery(
$subquery->rewrite($index),
($this->_signs === null)? true : $this->_signs[$termId]
);
}
return $query;
@ -211,7 +218,7 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
if (!$index->hasTerm($term)) {
if ($signs === null || $signs[$id] === true) {
// Term is required
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
} else {
// Term is optional or prohibited
@ -235,7 +242,7 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
}
}
if ($allProhibited) {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
}
@ -248,7 +255,7 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
// It's already checked, that it's not a prohibited term
// It's one term query with one required or optional element
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
$optimizedQuery = new Zend_Search_Lucene_Search_Query_Term(reset($terms));
$optimizedQuery->setBoost($this->getBoost());
@ -256,7 +263,7 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
}
if (count($terms) == 0) {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
}
@ -308,7 +315,7 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
*/
public function createWeight(Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Search/Weight/MultiTerm.php';
include_once 'Zend/Search/Lucene/Search/Weight/MultiTerm.php';
$this->_weight = new Zend_Search_Lucene_Search_Weight_MultiTerm($this, $reader);
return $this->_weight;
}
@ -335,11 +342,13 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
$docFreqs[] = $reader->docFreq($term);
$ids[] = $id; // Used to keep original order for terms with the same selectivity and omit terms comparison
}
array_multisort($docFreqs, SORT_ASC, SORT_NUMERIC,
array_multisort(
$docFreqs, SORT_ASC, SORT_NUMERIC,
$ids, SORT_ASC, SORT_NUMERIC,
$this->_terms);
$this->_terms
);
require_once 'Zend/Search/Lucene/Index/DocsFilter.php';
include_once 'Zend/Search/Lucene/Index/DocsFilter.php';
$docsFilter = new Zend_Search_Lucene_Index_DocsFilter();
foreach ($this->_terms as $termId => $term) {
$termDocs = $reader->termDocs($term, $docsFilter);
@ -394,9 +403,11 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
}
// sort resvectors in order of subquery cardinality increasing
array_multisort($requiredVectorsSizes, SORT_ASC, SORT_NUMERIC,
array_multisort(
$requiredVectorsSizes, SORT_ASC, SORT_NUMERIC,
$requiredVectorsIds, SORT_ASC, SORT_NUMERIC,
$requiredVectors);
$requiredVectors
);
$required = null;
foreach ($requiredVectors as $nextResVector) {
@ -466,8 +477,10 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
public function _conjunctionScore($docId, Zend_Search_Lucene_Interface $reader)
{
if ($this->_coord === null) {
$this->_coord = $reader->getSimilarity()->coord(count($this->_terms),
count($this->_terms) );
$this->_coord = $reader->getSimilarity()->coord(
count($this->_terms),
count($this->_terms)
);
}
$score = 0.0;
@ -514,8 +527,8 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
$matchedTerms = 0;
foreach ($this->_terms as $termId=>$term) {
// Check if term is
if ($this->_signs[$termId] !== false && // not prohibited
isset($this->_termsFreqs[$termId][$docId]) // matched
if ($this->_signs[$termId] !== false // not prohibited
&& isset($this->_termsFreqs[$termId][$docId]) // matched
) {
$matchedTerms++;

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -102,7 +104,7 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
if (is_array($terms)) {
$this->_terms = array();
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
foreach ($terms as $termId => $termText) {
$this->_terms[$termId] = ($field !== null)? new Zend_Search_Lucene_Index_Term($termText, $field):
new Zend_Search_Lucene_Index_Term($termText);
@ -110,13 +112,13 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
} else if ($terms === null) {
$this->_terms = array();
} else {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('terms argument must be array of strings or null');
}
if (is_array($offsets)) {
if (count($this->_terms) != count($offsets)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('terms and offsets arguments must have the same size.');
}
$this->_offsets = $offsets;
@ -127,7 +129,7 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
$this->_offsets[$termId] = $position;
}
} else {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('offsets argument must be array of strings or null');
}
}
@ -162,11 +164,14 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
* @param Zend_Search_Lucene_Index_Term $term
* @param integer $position
*/
public function addTerm(Zend_Search_Lucene_Index_Term $term, $position = null) {
public function addTerm(Zend_Search_Lucene_Index_Term $term, $position = null)
{
if ((count($this->_terms) != 0)&&(end($this->_terms)->field != $term->field)) {
require_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('All phrase terms must be in the same field: ' .
$term->field . ':' . $term->text);
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception(
'All phrase terms must be in the same field: ' .
$term->field . ':' . $term->text
);
}
$this->_terms[] = $term;
@ -189,12 +194,12 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
public function rewrite(Zend_Search_Lucene_Interface $index)
{
if (count($this->_terms) == 0) {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
} else if ($this->_terms[0]->field !== null) {
return $this;
} else {
require_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
include_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
$query = new Zend_Search_Lucene_Search_Query_Boolean();
$query->setBoost($this->getBoost());
@ -202,7 +207,7 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
$subquery = new Zend_Search_Lucene_Search_Query_Phrase();
$subquery->setSlop($this->getSlop());
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
foreach ($this->_terms as $termId => $term) {
$qualifiedTerm = new Zend_Search_Lucene_Index_Term($term->text, $fieldName);
@ -227,14 +232,14 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
// Check, that index contains all phrase terms
foreach ($this->_terms as $term) {
if (!$index->hasTerm($term)) {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
}
}
if (count($this->_terms) == 1) {
// It's one term query
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
$optimizedQuery = new Zend_Search_Lucene_Search_Query_Term(reset($this->_terms));
$optimizedQuery->setBoost($this->getBoost());
@ -242,7 +247,7 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
}
if (count($this->_terms) == 0) {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
}
@ -281,7 +286,7 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
*/
public function createWeight(Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Search/Weight/Phrase.php';
include_once 'Zend/Search/Lucene/Search/Weight/Phrase.php';
$this->_weight = new Zend_Search_Lucene_Search_Weight_Phrase($this, $reader);
return $this->_weight;
}
@ -302,9 +307,9 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
// Calculate $lowCardTermId
foreach ($this->_terms as $termId => $term) {
if ($lowCardTermId === null ||
count($this->_termsPositions[$termId][$docId]) <
count($this->_termsPositions[$lowCardTermId][$docId]) ) {
if ($lowCardTermId === null
|| count($this->_termsPositions[$termId][$docId]) <count($this->_termsPositions[$lowCardTermId][$docId])
) {
$lowCardTermId = $termId;
}
}
@ -361,9 +366,11 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
}
} else {
for ($count = 0; $count < $queueSize; $count++) {
if ($lastTerm !== null &&
abs( $termPosition - $phraseQueue[$count][$lastTerm] -
($this->_offsets[$termId] - $this->_offsets[$lastTerm])) > $this->_slop) {
if ($lastTerm !== null
&& abs(
$termPosition - $phraseQueue[$count][$lastTerm] -
($this->_offsets[$termId] - $this->_offsets[$lastTerm])
) > $this->_slop) {
continue;
}
@ -434,9 +441,11 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
$this->_termsPositions[$termId] = $reader->termPositions($term);
}
// sort resvectors in order of subquery cardinality increasing
array_multisort($resVectorsSizes, SORT_ASC, SORT_NUMERIC,
array_multisort(
$resVectorsSizes, SORT_ASC, SORT_NUMERIC,
$resVectorsIds, SORT_ASC, SORT_NUMERIC,
$resVectors);
$resVectors
);
foreach ($resVectors as $nextResVector) {
if($this->_resVector === null) {

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -58,7 +60,7 @@ abstract class Zend_Search_Lucene_Search_Query_Preprocessing extends Zend_Search
*/
public function optimize(Zend_Search_Lucene_Interface $index)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('This query is not intended to be executed.');
}
@ -70,7 +72,7 @@ abstract class Zend_Search_Lucene_Search_Query_Preprocessing extends Zend_Search
*/
public function createWeight(Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('This query is not intended to be executed.');
}
@ -83,7 +85,7 @@ abstract class Zend_Search_Lucene_Search_Query_Preprocessing extends Zend_Search
*/
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('This query is not intended to be executed.');
}
@ -96,7 +98,7 @@ abstract class Zend_Search_Lucene_Search_Query_Preprocessing extends Zend_Search
*/
public function matchedDocs()
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('This query is not intended to be executed.');
}
@ -109,7 +111,7 @@ abstract class Zend_Search_Lucene_Search_Query_Preprocessing extends Zend_Search
*/
public function score($docId, Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('This query is not intended to be executed.');
}
@ -120,7 +122,7 @@ abstract class Zend_Search_Lucene_Search_Query_Preprocessing extends Zend_Search
*/
public function getQueryTerms()
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Rewrite operation has to be done before retrieving query terms.');
}
}

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query_Processing */
/**
* Zend_Search_Lucene_Search_Query_Processing
*/
require_once 'Zend/Search/Lucene/Search/Query/Preprocessing.php';
@ -96,29 +98,32 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy extends Zend_Search_Lu
public function rewrite(Zend_Search_Lucene_Interface $index)
{
if ($this->_field === null) {
require_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
include_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
$query = new Zend_Search_Lucene_Search_Query_Boolean();
$hasInsignificantSubqueries = false;
require_once 'Zend/Search/Lucene.php';
include_once 'Zend/Search/Lucene.php';
if (Zend_Search_Lucene::getDefaultSearchField() === null) {
$searchFields = $index->getFieldNames(true);
} else {
$searchFields = array(Zend_Search_Lucene::getDefaultSearchField());
}
require_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Fuzzy.php';
include_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Fuzzy.php';
foreach ($searchFields as $fieldName) {
$subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy($this->_word,
$subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy(
$this->_word,
$this->_encoding,
$fieldName,
$this->_minimumSimilarity);
$this->_minimumSimilarity
);
$rewrittenSubquery = $subquery->rewrite($index);
if ( !($rewrittenSubquery instanceof Zend_Search_Lucene_Search_Query_Insignificant ||
$rewrittenSubquery instanceof Zend_Search_Lucene_Search_Query_Empty) ) {
if (!($rewrittenSubquery instanceof Zend_Search_Lucene_Search_Query_Insignificant
|| $rewrittenSubquery instanceof Zend_Search_Lucene_Search_Query_Empty)
) {
$query->addSubquery($rewrittenSubquery);
}
@ -132,10 +137,10 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy extends Zend_Search_Lu
if (count($subqueries) == 0) {
$this->_matches = array();
if ($hasInsignificantSubqueries) {
require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
include_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
return new Zend_Search_Lucene_Search_Query_Insignificant();
} else {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
}
}
@ -153,10 +158,10 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy extends Zend_Search_Lu
// -------------------------------------
// Recognize exact term matching (it corresponds to Keyword fields stored in the index)
// encoding is not used since we expect binary matching
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$term = new Zend_Search_Lucene_Index_Term($this->_word, $this->_field);
if ($index->hasTerm($term)) {
require_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php';
include_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php';
$query = new Zend_Search_Lucene_Search_Query_Fuzzy($term, $this->_minimumSimilarity);
$query->setBoost($this->getBoost());
@ -171,33 +176,35 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy extends Zend_Search_Lu
// -------------------------------------
// Recognize wildcard queries
/** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */
/**
* @todo check for PCRE unicode support may be performed through Zend_Environment in some future
*/
if (@preg_match('/\pL/u', 'a') == 1) {
$subPatterns = preg_split('/[*?]/u', iconv($this->_encoding, 'UTF-8', $this->_word));
} else {
$subPatterns = preg_split('/[*?]/', $this->_word);
}
if (count($subPatterns) > 1) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Fuzzy search doesn\'t support wildcards (except within Keyword fields).');
}
// -------------------------------------
// Recognize one-term multi-term and "insignificant" queries
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_word, $this->_encoding);
if (count($tokens) == 0) {
$this->_matches = array();
require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
include_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
return new Zend_Search_Lucene_Search_Query_Insignificant();
}
if (count($tokens) == 1) {
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$term = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field);
require_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php';
include_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php';
$query = new Zend_Search_Lucene_Search_Query_Fuzzy($term, $this->_minimumSimilarity);
$query->setBoost($this->getBoost());
@ -209,7 +216,7 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy extends Zend_Search_Lu
}
// Word is tokenized into several tokens
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Fuzzy search is supported only for non-multiple word terms');
}
@ -220,14 +227,20 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy extends Zend_Search_Lu
*/
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{
/** Skip fields detection. We don't need it, since we expect all fields presented in the HTML body and don't differentiate them */
/**
* Skip fields detection. We don't need it, since we expect all fields presented in the HTML body and don't differentiate them
*/
/** Skip exact term matching recognition, keyword fields highlighting is not supported */
/**
* Skip exact term matching recognition, keyword fields highlighting is not supported
*/
// -------------------------------------
// Recognize wildcard queries
/** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */
/**
* @todo check for PCRE unicode support may be performed through Zend_Environment in some future
*/
if (@preg_match('/\pL/u', 'a') == 1) {
$subPatterns = preg_split('/[*?]/u', iconv($this->_encoding, 'UTF-8', $this->_word));
} else {
@ -241,16 +254,16 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy extends Zend_Search_Lu
// -------------------------------------
// Recognize one-term multi-term and "insignificant" queries
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_word, $this->_encoding);
if (count($tokens) == 0) {
// Do nothing
return;
}
if (count($tokens) == 1) {
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$term = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field);
require_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php';
include_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php';
$query = new Zend_Search_Lucene_Search_Query_Fuzzy($term, $this->_minimumSimilarity);
$query->_highlightMatches($highlighter);

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query_Processing */
/**
* Zend_Search_Lucene_Search_Query_Processing
*/
require_once 'Zend/Search/Lucene/Search/Query/Preprocessing.php';
/**
@ -131,11 +133,11 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Phrase extends Zend_Search_L
// Split query into subqueries if field name is not specified
if ($this->_field === null) {
require_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
include_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
$query = new Zend_Search_Lucene_Search_Query_Boolean();
$query->setBoost($this->getBoost());
require_once 'Zend/Search/Lucene.php';
include_once 'Zend/Search/Lucene.php';
if (Zend_Search_Lucene::getDefaultSearchField() === null) {
$searchFields = $index->getFieldNames(true);
} else {
@ -143,9 +145,11 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Phrase extends Zend_Search_L
}
foreach ($searchFields as $fieldName) {
$subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Phrase($this->_phrase,
$subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Phrase(
$this->_phrase,
$this->_phraseEncoding,
$fieldName);
$fieldName
);
$subquery->setSlop($this->getSlop());
$query->addSubquery($subquery->rewrite($index));
@ -157,10 +161,10 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Phrase extends Zend_Search_L
// Recognize exact term matching (it corresponds to Keyword fields stored in the index)
// encoding is not used since we expect binary matching
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$term = new Zend_Search_Lucene_Index_Term($this->_phrase, $this->_field);
if ($index->hasTerm($term)) {
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
$query = new Zend_Search_Lucene_Search_Query_Term($term);
$query->setBoost($this->getBoost());
@ -170,19 +174,19 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Phrase extends Zend_Search_L
// tokenize phrase using current analyzer and process it as a phrase query
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_phrase, $this->_phraseEncoding);
if (count($tokens) == 0) {
$this->_matches = array();
require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
include_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
return new Zend_Search_Lucene_Search_Query_Insignificant();
}
if (count($tokens) == 1) {
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$term = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field);
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
$query = new Zend_Search_Lucene_Search_Query_Term($term);
$query->setBoost($this->getBoost());
@ -192,9 +196,9 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Phrase extends Zend_Search_L
//It's non-trivial phrase query
$position = -1;
require_once 'Zend/Search/Lucene/Search/Query/Phrase.php';
include_once 'Zend/Search/Lucene/Search/Query/Phrase.php';
$query = new Zend_Search_Lucene_Search_Query_Phrase();
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
foreach ($tokens as $token) {
$position += $token->getPositionIncrement();
$term = new Zend_Search_Lucene_Index_Term($token->getTermText(), $this->_field);
@ -212,15 +216,21 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Phrase extends Zend_Search_L
*/
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{
/** Skip fields detection. We don't need it, since we expect all fields presented in the HTML body and don't differentiate them */
/**
* Skip fields detection. We don't need it, since we expect all fields presented in the HTML body and don't differentiate them
*/
/** Skip exact term matching recognition, keyword fields highlighting is not supported */
/**
* Skip exact term matching recognition, keyword fields highlighting is not supported
*/
/** Skip wildcard queries recognition. Supported wildcards are removed by text analyzer */
/**
* Skip wildcard queries recognition. Supported wildcards are removed by text analyzer
*/
// tokenize phrase using current analyzer and process it as a phrase query
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_phrase, $this->_phraseEncoding);
if (count($tokens) == 0) {

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query_Processing */
/**
* Zend_Search_Lucene_Search_Query_Processing
*/
require_once 'Zend/Search/Lucene/Search/Query/Preprocessing.php';
@ -83,24 +85,26 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
public function rewrite(Zend_Search_Lucene_Interface $index)
{
if ($this->_field === null) {
require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
include_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
$query = new Zend_Search_Lucene_Search_Query_MultiTerm();
$query->setBoost($this->getBoost());
$hasInsignificantSubqueries = false;
require_once 'Zend/Search/Lucene.php';
include_once 'Zend/Search/Lucene.php';
if (Zend_Search_Lucene::getDefaultSearchField() === null) {
$searchFields = $index->getFieldNames(true);
} else {
$searchFields = array(Zend_Search_Lucene::getDefaultSearchField());
}
require_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Term.php';
foreach ($searchFields as $fieldName) {
$subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Term($this->_word,
$subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Term(
$this->_word,
$this->_encoding,
$fieldName);
$fieldName
);
$rewrittenSubquery = $subquery->rewrite($index);
foreach ($rewrittenSubquery->getQueryTerms() as $term) {
$query->addTerm($term);
@ -114,10 +118,10 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
if (count($query->getTerms()) == 0) {
$this->_matches = array();
if ($hasInsignificantSubqueries) {
require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
include_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
return new Zend_Search_Lucene_Search_Query_Insignificant();
} else {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
}
}
@ -129,10 +133,10 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
// -------------------------------------
// Recognize exact term matching (it corresponds to Keyword fields stored in the index)
// encoding is not used since we expect binary matching
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$term = new Zend_Search_Lucene_Index_Term($this->_word, $this->_field);
if ($index->hasTerm($term)) {
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
$query = new Zend_Search_Lucene_Search_Query_Term($term);
$query->setBoost($this->getBoost());
@ -144,7 +148,9 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
// -------------------------------------
// Recognize wildcard queries
/** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */
/**
* @todo check for PCRE unicode support may be performed through Zend_Environment in some future
*/
if (@preg_match('/\pL/u', 'a') == 1) {
$word = iconv($this->_encoding, 'UTF-8', $this->_word);
$wildcardsPattern = '/[*?]/u';
@ -162,7 +168,7 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
$pattern = '';
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
foreach ($subPatterns as $id => $subPattern) {
// Append corresponding wildcard character to the pattern before each sub-pattern (except first)
if ($id != 0) {
@ -172,7 +178,7 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
// Check if each subputtern is a single word in terms of current analyzer
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($subPattern[0], $subPatternsEncoding);
if (count($tokens) > 1) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Wildcard search is supported only for non-multiple word terms');
}
foreach ($tokens as $token) {
@ -180,9 +186,9 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
}
}
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$term = new Zend_Search_Lucene_Index_Term($pattern, $this->_field);
require_once 'Zend/Search/Lucene/Search/Query/Wildcard.php';
include_once 'Zend/Search/Lucene/Search/Query/Wildcard.php';
$query = new Zend_Search_Lucene_Search_Query_Wildcard($term);
$query->setBoost($this->getBoost());
@ -196,19 +202,19 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
// -------------------------------------
// Recognize one-term multi-term and "insignificant" queries
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_word, $this->_encoding);
if (count($tokens) == 0) {
$this->_matches = array();
require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
include_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
return new Zend_Search_Lucene_Search_Query_Insignificant();
}
if (count($tokens) == 1) {
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$term = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field);
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
$query = new Zend_Search_Lucene_Search_Query_Term($term);
$query->setBoost($this->getBoost());
@ -217,14 +223,14 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
}
//It's not insignificant or one term query
require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
include_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
$query = new Zend_Search_Lucene_Search_Query_MultiTerm();
/**
* @todo Process $token->getPositionIncrement() to support stemming, synonyms and other
* analizer design features
*/
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
foreach ($tokens as $token) {
$term = new Zend_Search_Lucene_Index_Term($token->getTermText(), $this->_field);
$query->addTerm($term, true); // all subterms are required
@ -243,13 +249,19 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
*/
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{
/** Skip fields detection. We don't need it, since we expect all fields presented in the HTML body and don't differentiate them */
/**
* Skip fields detection. We don't need it, since we expect all fields presented in the HTML body and don't differentiate them
*/
/** Skip exact term matching recognition, keyword fields highlighting is not supported */
/**
* Skip exact term matching recognition, keyword fields highlighting is not supported
*/
// -------------------------------------
// Recognize wildcard queries
/** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */
/**
* @todo check for PCRE unicode support may be performed through Zend_Environment in some future
*/
if (@preg_match('/\pL/u', 'a') == 1) {
$word = iconv($this->_encoding, 'UTF-8', $this->_word);
$wildcardsPattern = '/[*?]/u';
@ -265,7 +277,7 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
$pattern = '';
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
foreach ($subPatterns as $id => $subPattern) {
// Append corresponding wildcard character to the pattern before each sub-pattern (except first)
if ($id != 0) {
@ -283,9 +295,9 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
}
}
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$term = new Zend_Search_Lucene_Index_Term($pattern, $this->_field);
require_once 'Zend/Search/Lucene/Search/Query/Wildcard.php';
include_once 'Zend/Search/Lucene/Search/Query/Wildcard.php';
$query = new Zend_Search_Lucene_Search_Query_Wildcard($term);
$query->_highlightMatches($highlighter);
@ -295,7 +307,7 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
// -------------------------------------
// Recognize one-term multi-term and "insignificant" queries
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_word, $this->_encoding);
if (count($tokens) == 0) {

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -88,11 +90,11 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
public function __construct($lowerTerm, $upperTerm, $inclusive)
{
if ($lowerTerm === null && $upperTerm === null) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('At least one term must be non-null');
}
if ($lowerTerm !== null && $upperTerm !== null && $lowerTerm->field != $upperTerm->field) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Both terms must be for the same field');
}
@ -159,19 +161,20 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
$fields = array($this->_field);
}
require_once 'Zend/Search/Lucene.php';
include_once 'Zend/Search/Lucene.php';
$maxTerms = Zend_Search_Lucene::getTermsPerQueryLimit();
foreach ($fields as $field) {
$index->resetTermsStream();
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
if ($this->_lowerTerm !== null) {
$lowerTerm = new Zend_Search_Lucene_Index_Term($this->_lowerTerm->text, $field);
$index->skipTo($lowerTerm);
if (!$this->_inclusive &&
$index->currentTerm() == $lowerTerm) {
if (!$this->_inclusive
&& $index->currentTerm() == $lowerTerm
) {
// Skip lower term
$index->nextTerm();
}
@ -190,7 +193,7 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
$this->_matches[] = $index->currentTerm();
if ($maxTerms != 0 && count($this->_matches) > $maxTerms) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.');
}
@ -207,7 +210,7 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
$this->_matches[] = $index->currentTerm();
if ($maxTerms != 0 && count($this->_matches) > $maxTerms) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.');
}
@ -219,13 +222,13 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
}
if (count($this->_matches) == 0) {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
} else if (count($this->_matches) == 1) {
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
return new Zend_Search_Lucene_Search_Query_Term(reset($this->_matches));
} else {
require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
include_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
$rewrittenQuery = new Zend_Search_Lucene_Search_Query_MultiTerm();
foreach ($this->_matches as $matchedTerm) {
@ -244,7 +247,7 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
*/
public function optimize(Zend_Search_Lucene_Interface $index)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)');
}
@ -257,7 +260,7 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
public function getQueryTerms()
{
if ($this->_matches === null) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Search or rewrite operations have to be performed before.');
}
@ -273,7 +276,7 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
*/
public function createWeight(Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)');
}
@ -288,7 +291,7 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
*/
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)');
}
@ -302,7 +305,7 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
*/
public function matchedDocs()
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)');
}
@ -316,7 +319,7 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
*/
public function score($docId, Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)');
}
@ -330,7 +333,7 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
$words = array();
$docBody = $highlighter->getDocument()->getFieldUtf8Value('body');
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($docBody, 'UTF-8');
$lowerTermText = ($this->_lowerTerm !== null)? $this->_lowerTerm->text : null;
@ -339,16 +342,18 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
if ($this->_inclusive) {
foreach ($tokens as $token) {
$termText = $token->getTermText();
if (($lowerTermText == null || $lowerTermText <= $termText) &&
($upperTermText == null || $termText <= $upperTermText)) {
if (($lowerTermText == null || $lowerTermText <= $termText)
&& ($upperTermText == null || $termText <= $upperTermText)
) {
$words[] = $termText;
}
}
} else {
foreach ($tokens as $token) {
$termText = $token->getTermText();
if (($lowerTermText == null || $lowerTermText < $termText) &&
($upperTermText == null || $termText < $upperTermText)) {
if (($lowerTermText == null || $lowerTermText < $termText)
&& ($upperTermText == null || $termText < $upperTermText)
) {
$words[] = $termText;
}
}

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -79,11 +81,11 @@ class Zend_Search_Lucene_Search_Query_Term extends Zend_Search_Lucene_Search_Que
if ($this->_term->field != null) {
return $this;
} else {
require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
include_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
$query = new Zend_Search_Lucene_Search_Query_MultiTerm();
$query->setBoost($this->getBoost());
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
foreach ($index->getFieldNames(true) as $fieldName) {
$term = new Zend_Search_Lucene_Index_Term($this->_term->text, $fieldName);
@ -104,7 +106,7 @@ class Zend_Search_Lucene_Search_Query_Term extends Zend_Search_Lucene_Search_Que
{
// Check, that index contains specified term
if (!$index->hasTerm($this->_term)) {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
}
@ -120,7 +122,7 @@ class Zend_Search_Lucene_Search_Query_Term extends Zend_Search_Lucene_Search_Que
*/
public function createWeight(Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Search/Weight/Term.php';
include_once 'Zend/Search/Lucene/Search/Weight/Term.php';
$this->_weight = new Zend_Search_Lucene_Search_Weight_Term($this->_term, $this, $reader);
return $this->_weight;
}

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -141,11 +143,13 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
$matchExpression = '/^' . str_replace(array('\\?', '\\*'), array('.', '.*'), preg_quote($this->_pattern->text, '/')) . '$/';
if ($prefixLength < self::$_minPrefixLength) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('At least ' . self::$_minPrefixLength . ' non-wildcard characters are required at the beginning of pattern.');
}
/** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */
/**
* @todo check for PCRE unicode support may be performed through Zend_Environment in some future
*/
if (@preg_match('/\pL/u', 'a') == 1) {
// PCRE unicode support is turned on
// add Unicode modifier to the match expression
@ -156,7 +160,7 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
foreach ($fields as $field) {
$index->resetTermsStream();
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
if ($prefix != '') {
$index->skipTo(new Zend_Search_Lucene_Index_Term($prefix, $field));
@ -167,7 +171,7 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
$this->_matches[] = $index->currentTerm();
if ($maxTerms != 0 && count($this->_matches) > $maxTerms) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.');
}
}
@ -182,7 +186,7 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
$this->_matches[] = $index->currentTerm();
if ($maxTerms != 0 && count($this->_matches) > $maxTerms) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.');
}
}
@ -195,13 +199,13 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
}
if (count($this->_matches) == 0) {
require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
} else if (count($this->_matches) == 1) {
require_once 'Zend/Search/Lucene/Search/Query/Term.php';
include_once 'Zend/Search/Lucene/Search/Query/Term.php';
return new Zend_Search_Lucene_Search_Query_Term(reset($this->_matches));
} else {
require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
include_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
$rewrittenQuery = new Zend_Search_Lucene_Search_Query_MultiTerm();
foreach ($this->_matches as $matchedTerm) {
@ -220,7 +224,7 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
*/
public function optimize(Zend_Search_Lucene_Interface $index)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
}
@ -245,7 +249,7 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
public function getQueryTerms()
{
if ($this->_matches === null) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Search has to be performed first to get matched terms');
}
@ -261,7 +265,7 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
*/
public function createWeight(Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
}
@ -276,7 +280,7 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
*/
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
}
@ -290,7 +294,7 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
*/
public function matchedDocs()
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
}
@ -304,7 +308,7 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
*/
public function score($docId, Zend_Search_Lucene_Interface $reader)
{
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)');
}
@ -325,7 +329,7 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
}
$docBody = $highlighter->getDocument()->getFieldUtf8Value('body');
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($docBody, 'UTF-8');
foreach ($tokens as $token) {
if (preg_match($matchExpression, $token->getTermText()) === 1) {

View File

@ -20,7 +20,9 @@
* @version $Id: Phrase.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Search_QueryEntry */
/**
* Zend_Search_Lucene_Search_QueryEntry
*/
require_once 'Zend/Search/Lucene/Search/QueryEntry.php';
/**
@ -97,13 +99,17 @@ class Zend_Search_Lucene_Search_QueryEntry_Phrase extends Zend_Search_Lucene_Sea
*/
public function getQuery($encoding)
{
/** Zend_Search_Lucene_Search_Query_Preprocessing_Phrase */
require_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Phrase.php';
$query = new Zend_Search_Lucene_Search_Query_Preprocessing_Phrase($this->_phrase,
/**
* Zend_Search_Lucene_Search_Query_Preprocessing_Phrase
*/
include_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Phrase.php';
$query = new Zend_Search_Lucene_Search_Query_Preprocessing_Phrase(
$this->_phrase,
$encoding,
($this->_field !== null)?
iconv($encoding, 'UTF-8', $this->_field) :
null);
null
);
if ($this->_proximityQuery) {
$query->setSlop($this->_wordsDistance);

View File

@ -20,7 +20,9 @@
* @version $Id: Subquery.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Search_QueryEntry */
/**
* Zend_Search_Lucene_Search_QueryEntry
*/
require_once 'Zend/Search/Lucene/Search/QueryEntry.php';
/**
@ -57,7 +59,7 @@ class Zend_Search_Lucene_Search_QueryEntry_Subquery extends Zend_Search_Lucene_S
*/
public function processFuzzyProximityModifier($parameter = null)
{
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('\'~\' sign must follow term or phrase');
}

View File

@ -20,7 +20,9 @@
* @version $Id: Term.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Search_QueryEntry */
/**
* Zend_Search_Lucene_Search_QueryEntry
*/
require_once 'Zend/Search/Lucene/Search/QueryEntry.php';
/**
@ -86,8 +88,10 @@ class Zend_Search_Lucene_Search_QueryEntry_Term extends Zend_Search_Lucene_Searc
if ($parameter !== null) {
$this->_similarity = $parameter;
} else {
/** Zend_Search_Lucene_Search_Query_Fuzzy */
require_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php';
/**
* Zend_Search_Lucene_Search_Query_Fuzzy
*/
include_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php';
$this->_similarity = Zend_Search_Lucene_Search_Query_Fuzzy::DEFAULT_MIN_SIMILARITY;
}
}
@ -102,9 +106,12 @@ class Zend_Search_Lucene_Search_QueryEntry_Term extends Zend_Search_Lucene_Searc
public function getQuery($encoding)
{
if ($this->_fuzzyQuery) {
/** Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy */
require_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Fuzzy.php';
$query = new Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy($this->_term,
/**
* Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy
*/
include_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Fuzzy.php';
$query = new Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy(
$this->_term,
$encoding,
($this->_field !== null)?
iconv($encoding, 'UTF-8', $this->_field) :
@ -116,9 +123,12 @@ class Zend_Search_Lucene_Search_QueryEntry_Term extends Zend_Search_Lucene_Searc
}
/** Zend_Search_Lucene_Search_Query_Preprocessing_Term */
require_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Term.php';
$query = new Zend_Search_Lucene_Search_Query_Preprocessing_Term($this->_term,
/**
* Zend_Search_Lucene_Search_Query_Preprocessing_Term
*/
include_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Term.php';
$query = new Zend_Search_Lucene_Search_Query_Preprocessing_Term(
$this->_term,
$encoding,
($this->_field !== null)?
iconv($encoding, 'UTF-8', $this->_field) :

View File

@ -32,24 +32,28 @@ class Zend_Search_Lucene_Search_QueryHit
{
/**
* Object handle of the index
*
* @var Zend_Search_Lucene_Interface
*/
protected $_index = null;
/**
* Object handle of the document associated with this hit
*
* @var Zend_Search_Lucene_Document
*/
protected $_document = null;
/**
* Number of the document in the index
*
* @var integer
*/
public $id;
/**
* Score of the hit
*
* @var float
*/
public $score;
@ -64,7 +68,7 @@ class Zend_Search_Lucene_Search_QueryHit
public function __construct(Zend_Search_Lucene_Interface $index)
{
require_once 'Zend/Search/Lucene/Proxy.php';
include_once 'Zend/Search/Lucene/Proxy.php';
$this->_index = new Zend_Search_Lucene_Proxy($index);
}

View File

@ -20,10 +20,14 @@
* @version $Id: QueryLexer.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_FSM */
/**
* Zend_Search_Lucene_FSM
*/
require_once 'Zend/Search/Lucene/FSM.php';
/** Zend_Search_Lucene_Search_QueryParser */
/**
* Zend_Search_Lucene_Search_QueryParser
*/
require_once 'Zend/Search/Lucene/Search/QueryToken.php';
/**
@ -35,7 +39,9 @@ require_once 'Zend/Search/Lucene/Search/QueryToken.php';
*/
class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
{
/** State Machine states */
/**
* State Machine states
*/
const ST_WHITE_SPACE = 0;
const ST_SYNT_LEXEME = 1;
const ST_LEXEME = 2;
@ -47,7 +53,9 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
const ST_MANTISSA = 8;
const ST_ERROR = 9;
/** Input symbols */
/**
* Input symbols
*/
const IN_WHITE_SPACE = 0;
const IN_SYNT_CHAR = 1;
const IN_LEXEME_MODIFIER = 2;
@ -96,7 +104,8 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
public function __construct()
{
parent::__construct( array(self::ST_WHITE_SPACE,
parent::__construct(
array(self::ST_WHITE_SPACE,
self::ST_SYNT_LEXEME,
self::ST_LEXEME,
self::ST_QUOTED_LEXEME,
@ -114,7 +123,8 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
self::IN_QUOTE,
self::IN_DECIMAL_POINT,
self::IN_ASCII_DIGIT,
self::IN_CHAR));
self::IN_CHAR)
);
$lexemeModifierErrorAction = new Zend_Search_Lucene_FSMAction($this, 'lexModifierErrException');
@ -123,7 +133,8 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
$this->addRules(array( array(self::ST_WHITE_SPACE, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE),
$this->addRules(
array( array(self::ST_WHITE_SPACE, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE),
array(self::ST_WHITE_SPACE, self::IN_SYNT_CHAR, self::ST_SYNT_LEXEME),
array(self::ST_WHITE_SPACE, self::IN_MUTABLE_CHAR, self::ST_SYNT_LEXEME),
array(self::ST_WHITE_SPACE, self::IN_LEXEME_MODIFIER, self::ST_LEXEME_MODIFIER),
@ -132,8 +143,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
array(self::ST_WHITE_SPACE, self::IN_DECIMAL_POINT, self::ST_LEXEME),
array(self::ST_WHITE_SPACE, self::IN_ASCII_DIGIT, self::ST_LEXEME),
array(self::ST_WHITE_SPACE, self::IN_CHAR, self::ST_LEXEME)
));
$this->addRules(array( array(self::ST_SYNT_LEXEME, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE),
)
);
$this->addRules(
array( array(self::ST_SYNT_LEXEME, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE),
array(self::ST_SYNT_LEXEME, self::IN_SYNT_CHAR, self::ST_SYNT_LEXEME),
array(self::ST_SYNT_LEXEME, self::IN_MUTABLE_CHAR, self::ST_SYNT_LEXEME),
array(self::ST_SYNT_LEXEME, self::IN_LEXEME_MODIFIER, self::ST_LEXEME_MODIFIER),
@ -142,8 +155,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
array(self::ST_SYNT_LEXEME, self::IN_DECIMAL_POINT, self::ST_LEXEME),
array(self::ST_SYNT_LEXEME, self::IN_ASCII_DIGIT, self::ST_LEXEME),
array(self::ST_SYNT_LEXEME, self::IN_CHAR, self::ST_LEXEME)
));
$this->addRules(array( array(self::ST_LEXEME, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE),
)
);
$this->addRules(
array( array(self::ST_LEXEME, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE),
array(self::ST_LEXEME, self::IN_SYNT_CHAR, self::ST_SYNT_LEXEME),
array(self::ST_LEXEME, self::IN_MUTABLE_CHAR, self::ST_LEXEME),
array(self::ST_LEXEME, self::IN_LEXEME_MODIFIER, self::ST_LEXEME_MODIFIER),
@ -155,8 +170,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
array(self::ST_LEXEME, self::IN_DECIMAL_POINT, self::ST_LEXEME),
array(self::ST_LEXEME, self::IN_ASCII_DIGIT, self::ST_LEXEME),
array(self::ST_LEXEME, self::IN_CHAR, self::ST_LEXEME)
));
$this->addRules(array( array(self::ST_QUOTED_LEXEME, self::IN_WHITE_SPACE, self::ST_QUOTED_LEXEME),
)
);
$this->addRules(
array( array(self::ST_QUOTED_LEXEME, self::IN_WHITE_SPACE, self::ST_QUOTED_LEXEME),
array(self::ST_QUOTED_LEXEME, self::IN_SYNT_CHAR, self::ST_QUOTED_LEXEME),
array(self::ST_QUOTED_LEXEME, self::IN_MUTABLE_CHAR, self::ST_QUOTED_LEXEME),
array(self::ST_QUOTED_LEXEME, self::IN_LEXEME_MODIFIER, self::ST_QUOTED_LEXEME),
@ -165,8 +182,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
array(self::ST_QUOTED_LEXEME, self::IN_DECIMAL_POINT, self::ST_QUOTED_LEXEME),
array(self::ST_QUOTED_LEXEME, self::IN_ASCII_DIGIT, self::ST_QUOTED_LEXEME),
array(self::ST_QUOTED_LEXEME, self::IN_CHAR, self::ST_QUOTED_LEXEME)
));
$this->addRules(array( array(self::ST_ESCAPED_CHAR, self::IN_WHITE_SPACE, self::ST_LEXEME),
)
);
$this->addRules(
array( array(self::ST_ESCAPED_CHAR, self::IN_WHITE_SPACE, self::ST_LEXEME),
array(self::ST_ESCAPED_CHAR, self::IN_SYNT_CHAR, self::ST_LEXEME),
array(self::ST_ESCAPED_CHAR, self::IN_MUTABLE_CHAR, self::ST_LEXEME),
array(self::ST_ESCAPED_CHAR, self::IN_LEXEME_MODIFIER, self::ST_LEXEME),
@ -175,8 +194,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
array(self::ST_ESCAPED_CHAR, self::IN_DECIMAL_POINT, self::ST_LEXEME),
array(self::ST_ESCAPED_CHAR, self::IN_ASCII_DIGIT, self::ST_LEXEME),
array(self::ST_ESCAPED_CHAR, self::IN_CHAR, self::ST_LEXEME)
));
$this->addRules(array( array(self::ST_ESCAPED_QCHAR, self::IN_WHITE_SPACE, self::ST_QUOTED_LEXEME),
)
);
$this->addRules(
array( array(self::ST_ESCAPED_QCHAR, self::IN_WHITE_SPACE, self::ST_QUOTED_LEXEME),
array(self::ST_ESCAPED_QCHAR, self::IN_SYNT_CHAR, self::ST_QUOTED_LEXEME),
array(self::ST_ESCAPED_QCHAR, self::IN_MUTABLE_CHAR, self::ST_QUOTED_LEXEME),
array(self::ST_ESCAPED_QCHAR, self::IN_LEXEME_MODIFIER, self::ST_QUOTED_LEXEME),
@ -185,8 +206,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
array(self::ST_ESCAPED_QCHAR, self::IN_DECIMAL_POINT, self::ST_QUOTED_LEXEME),
array(self::ST_ESCAPED_QCHAR, self::IN_ASCII_DIGIT, self::ST_QUOTED_LEXEME),
array(self::ST_ESCAPED_QCHAR, self::IN_CHAR, self::ST_QUOTED_LEXEME)
));
$this->addRules(array( array(self::ST_LEXEME_MODIFIER, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE),
)
);
$this->addRules(
array( array(self::ST_LEXEME_MODIFIER, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE),
array(self::ST_LEXEME_MODIFIER, self::IN_SYNT_CHAR, self::ST_SYNT_LEXEME),
array(self::ST_LEXEME_MODIFIER, self::IN_MUTABLE_CHAR, self::ST_SYNT_LEXEME),
array(self::ST_LEXEME_MODIFIER, self::IN_LEXEME_MODIFIER, self::ST_LEXEME_MODIFIER),
@ -203,8 +226,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
// IN_CHAR not allowed
array(self::ST_LEXEME_MODIFIER, self::IN_CHAR, self::ST_ERROR, $lexemeModifierErrorAction),
));
$this->addRules(array( array(self::ST_NUMBER, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE),
)
);
$this->addRules(
array( array(self::ST_NUMBER, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE),
array(self::ST_NUMBER, self::IN_SYNT_CHAR, self::ST_SYNT_LEXEME),
array(self::ST_NUMBER, self::IN_MUTABLE_CHAR, self::ST_SYNT_LEXEME),
array(self::ST_NUMBER, self::IN_LEXEME_MODIFIER, self::ST_LEXEME_MODIFIER),
@ -220,8 +245,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
// IN_CHAR not allowed
array(self::ST_NUMBER, self::IN_CHAR, self::ST_ERROR, $wrongNumberErrorAction),
));
$this->addRules(array( array(self::ST_MANTISSA, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE),
)
);
$this->addRules(
array( array(self::ST_MANTISSA, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE),
array(self::ST_MANTISSA, self::IN_SYNT_CHAR, self::ST_SYNT_LEXEME),
array(self::ST_MANTISSA, self::IN_MUTABLE_CHAR, self::ST_SYNT_LEXEME),
array(self::ST_MANTISSA, self::IN_LEXEME_MODIFIER, self::ST_LEXEME_MODIFIER),
@ -239,10 +266,13 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
// IN_CHAR not allowed
array(self::ST_MANTISSA, self::IN_CHAR, self::ST_ERROR, $wrongNumberErrorAction),
));
)
);
/** Actions */
/**
* Actions
*/
$syntaxLexemeAction = new Zend_Search_Lucene_FSMAction($this, 'addQuerySyntaxLexeme');
$lexemeModifierAction = new Zend_Search_Lucene_FSMAction($this, 'addLexemeModifier');
$addLexemeAction = new Zend_Search_Lucene_FSMAction($this, 'addLexeme');
@ -251,13 +281,17 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
$addLexemeCharAction = new Zend_Search_Lucene_FSMAction($this, 'addLexemeChar');
/** Syntax lexeme */
/**
* Syntax lexeme
*/
$this->addEntryAction(self::ST_SYNT_LEXEME, $syntaxLexemeAction);
// Two lexemes in succession
$this->addTransitionAction(self::ST_SYNT_LEXEME, self::ST_SYNT_LEXEME, $syntaxLexemeAction);
/** Lexeme */
/**
* Lexeme
*/
$this->addEntryAction(self::ST_LEXEME, $addLexemeCharAction);
$this->addTransitionAction(self::ST_LEXEME, self::ST_LEXEME, $addLexemeCharAction);
// ST_ESCAPED_CHAR => ST_LEXEME transition is covered by ST_LEXEME entry action
@ -270,7 +304,9 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
$this->addTransitionAction(self::ST_LEXEME, self::ST_MANTISSA, $addLexemeAction);
/** Quoted lexeme */
/**
* Quoted lexeme
*/
// We don't need entry action (skeep quote)
$this->addTransitionAction(self::ST_QUOTED_LEXEME, self::ST_QUOTED_LEXEME, $addLexemeCharAction);
$this->addTransitionAction(self::ST_ESCAPED_QCHAR, self::ST_QUOTED_LEXEME, $addLexemeCharAction);
@ -278,11 +314,15 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
$this->addTransitionAction(self::ST_QUOTED_LEXEME, self::ST_WHITE_SPACE, $addQuotedLexemeAction);
/** Lexeme modifier */
/**
* Lexeme modifier
*/
$this->addEntryAction(self::ST_LEXEME_MODIFIER, $lexemeModifierAction);
/** Number */
/**
* Number
*/
$this->addEntryAction(self::ST_NUMBER, $addLexemeCharAction);
$this->addEntryAction(self::ST_MANTISSA, $addLexemeCharAction);
$this->addTransitionAction(self::ST_NUMBER, self::ST_NUMBER, $addLexemeCharAction);
@ -357,7 +397,7 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
$this->process(self::IN_WHITE_SPACE);
if ($this->getState() != self::ST_WHITE_SPACE) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Unexpected end of query');
}
@ -389,9 +429,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
$this->_queryStringPosition++;
// check,
if ($this->_queryStringPosition == count($this->_queryString) ||
$this->_queryString[$this->_queryStringPosition] != $lexeme) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
if ($this->_queryStringPosition == count($this->_queryString)
|| $this->_queryString[$this->_queryStringPosition] != $lexeme
) {
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Two chars lexeme expected. ' . $this->_positionMsg());
}
@ -402,13 +443,14 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
$token = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_SYNTAX_ELEMENT,
$lexeme,
$this->_queryStringPosition);
$this->_queryStringPosition
);
// Skip this lexeme if it's a field indicator ':' and treat previous as 'field' instead of 'word'
if ($token->type == Zend_Search_Lucene_Search_QueryToken::TT_FIELD_INDICATOR) {
$token = array_pop($this->_lexemes);
if ($token === null || $token->type != Zend_Search_Lucene_Search_QueryToken::TT_WORD) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Field mark \':\' must follow field name. ' . $this->_positionMsg());
}
@ -426,7 +468,8 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
$this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_SYNTAX_ELEMENT,
$this->_queryString[$this->_queryStringPosition],
$this->_queryStringPosition);
$this->_queryStringPosition
);
}
@ -438,7 +481,8 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
$this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_WORD,
$this->_currentLexeme,
$this->_queryStringPosition - 1);
$this->_queryStringPosition - 1
);
$this->_currentLexeme = '';
}
@ -451,7 +495,8 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
$this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_PHRASE,
$this->_currentLexeme,
$this->_queryStringPosition);
$this->_queryStringPosition
);
$this->_currentLexeme = '';
}
@ -464,7 +509,8 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
$this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_NUMBER,
$this->_currentLexeme,
$this->_queryStringPosition - 1);
$this->_queryStringPosition - 1
);
$this->_currentLexeme = '';
}
@ -493,17 +539,17 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
*********************************************************************/
public function lexModifierErrException()
{
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Lexeme modifier character can be followed only by number, white space or query syntax element. ' . $this->_positionMsg());
}
public function quoteWithinLexemeErrException()
{
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Quote within lexeme must be escaped by \'\\\' char. ' . $this->_positionMsg());
}
public function wrongNumberErrException()
{
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Wrong number syntax.' . $this->_positionMsg());
}
}

View File

@ -21,17 +21,25 @@
*/
/** Internally used classes */
/**
* Internally used classes
*/
/** Zend_Search_Lucene_Analysis_Analyzer */
/**
* Zend_Search_Lucene_Analysis_Analyzer
*/
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
/** Zend_Search_Lucene_Search_QueryToken */
/**
* Zend_Search_Lucene_Search_QueryToken
*/
require_once 'Zend/Search/Lucene/Search/QueryToken.php';
/** Zend_Search_Lucene_FSM */
/**
* Zend_Search_Lucene_FSM
*/
require_once 'Zend/Search/Lucene/FSM.php';
/**
@ -152,7 +160,9 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
private $_defaultOperator = self::B_OR;
/** Query parser State Machine states */
/**
* Query parser State Machine states
*/
const ST_COMMON_QUERY_ELEMENT = 0; // Terms, phrases, operators
const ST_CLOSEDINT_RQ_START = 1; // Range query start (closed interval) - '['
const ST_CLOSEDINT_RQ_FIRST_TERM = 2; // First term in '[term1 to term2]' construction
@ -170,7 +180,8 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
*/
public function __construct()
{
parent::__construct(array(self::ST_COMMON_QUERY_ELEMENT,
parent::__construct(
array(self::ST_COMMON_QUERY_ELEMENT,
self::ST_CLOSEDINT_RQ_START,
self::ST_CLOSEDINT_RQ_FIRST_TERM,
self::ST_CLOSEDINT_RQ_TO_TERM,
@ -182,7 +193,8 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
self::ST_OPENEDINT_RQ_LAST_TERM,
self::ST_OPENEDINT_RQ_END
),
Zend_Search_Lucene_Search_QueryToken::getTypes());
Zend_Search_Lucene_Search_QueryToken::getTypes()
);
$this->addRules(
array(array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_WORD, self::ST_COMMON_QUERY_ELEMENT),
@ -200,19 +212,22 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_OR_LEXEME, self::ST_COMMON_QUERY_ELEMENT),
array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_NOT_LEXEME, self::ST_COMMON_QUERY_ELEMENT),
array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_NUMBER, self::ST_COMMON_QUERY_ELEMENT)
));
)
);
$this->addRules(
array(array(self::ST_CLOSEDINT_RQ_START, Zend_Search_Lucene_Search_QueryToken::TT_WORD, self::ST_CLOSEDINT_RQ_FIRST_TERM),
array(self::ST_CLOSEDINT_RQ_FIRST_TERM, Zend_Search_Lucene_Search_QueryToken::TT_TO_LEXEME, self::ST_CLOSEDINT_RQ_TO_TERM),
array(self::ST_CLOSEDINT_RQ_TO_TERM, Zend_Search_Lucene_Search_QueryToken::TT_WORD, self::ST_CLOSEDINT_RQ_LAST_TERM),
array(self::ST_CLOSEDINT_RQ_LAST_TERM, Zend_Search_Lucene_Search_QueryToken::TT_RANGE_INCL_END, self::ST_COMMON_QUERY_ELEMENT)
));
)
);
$this->addRules(
array(array(self::ST_OPENEDINT_RQ_START, Zend_Search_Lucene_Search_QueryToken::TT_WORD, self::ST_OPENEDINT_RQ_FIRST_TERM),
array(self::ST_OPENEDINT_RQ_FIRST_TERM, Zend_Search_Lucene_Search_QueryToken::TT_TO_LEXEME, self::ST_OPENEDINT_RQ_TO_TERM),
array(self::ST_OPENEDINT_RQ_TO_TERM, Zend_Search_Lucene_Search_QueryToken::TT_WORD, self::ST_OPENEDINT_RQ_LAST_TERM),
array(self::ST_OPENEDINT_RQ_LAST_TERM, Zend_Search_Lucene_Search_QueryToken::TT_RANGE_EXCL_END, self::ST_COMMON_QUERY_ELEMENT)
));
)
);
@ -250,7 +265,7 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
$this->addEntryAction(self::ST_CLOSEDINT_RQ_LAST_TERM, $closedRQLastTermAction);
require_once 'Zend/Search/Lucene/Search/QueryLexer.php';
include_once 'Zend/Search/Lucene/Search/QueryLexer.php';
$this->_lexer = new Zend_Search_Lucene_Search_QueryLexer();
}
@ -323,6 +338,7 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
}
/**
* Check 'suppress query parser exceptions' mode.
*
* @return boolean
*/
public static function queryParsingExceptionsSuppressed()
@ -357,9 +373,9 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
// Reset FSM if previous parse operation didn't return it into a correct state
self::$_instance->reset();
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
try {
require_once 'Zend/Search/Lucene/Search/QueryParserContext.php';
include_once 'Zend/Search/Lucene/Search/QueryParserContext.php';
self::$_instance->_encoding = ($encoding !== null) ? $encoding : self::$_instance->_defaultEncoding;
self::$_instance->_lastToken = null;
@ -369,7 +385,7 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
// Empty query
if (count(self::$_instance->_tokens) == 0) {
require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
include_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
return new Zend_Search_Lucene_Search_Query_Insignificant();
}
@ -385,7 +401,7 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
throw new Zend_Search_Lucene_Search_QueryParserException('Syntax error at char position ' . $token->position . '.', 0, $e);
}
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -399,12 +415,12 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
if (self::$_instance->_suppressQueryParsingExceptions) {
$queryTokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($strQuery, self::$_instance->_encoding);
require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
include_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
$query = new Zend_Search_Lucene_Search_Query_MultiTerm();
$termsSign = (self::$_instance->_defaultOperator == self::B_AND) ? true /* required term */ :
null /* optional term */;
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
foreach ($queryTokens as $token) {
$query->addTerm(new Zend_Search_Lucene_Index_Term($token->getTermText()), $termsSign);
}
@ -412,7 +428,7 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
return $query;
} else {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -429,7 +445,7 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
*/
public function addTermEntry()
{
require_once 'Zend/Search/Lucene/Search/QueryEntry/Term.php';
include_once 'Zend/Search/Lucene/Search/QueryEntry/Term.php';
$entry = new Zend_Search_Lucene_Search_QueryEntry_Term($this->_currentToken->text, $this->_context->getField());
$this->_context->addEntry($entry);
}
@ -439,7 +455,7 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
*/
public function addPhraseEntry()
{
require_once 'Zend/Search/Lucene/Search/QueryEntry/Phrase.php';
include_once 'Zend/Search/Lucene/Search/QueryEntry/Phrase.php';
$entry = new Zend_Search_Lucene_Search_QueryEntry_Phrase($this->_currentToken->text, $this->_context->getField());
$this->_context->addEntry($entry);
}
@ -477,7 +493,7 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
public function processModifierParameter()
{
if ($this->_lastToken === null) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Lexeme modifier parameter must follow lexeme modifier. Char position 0.');
}
@ -492,7 +508,7 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
default:
// It's not a user input exception
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Lexeme modifier parameter must follow lexeme modifier. Char position 0.');
}
}
@ -503,7 +519,7 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
*/
public function subqueryStart()
{
require_once 'Zend/Search/Lucene/Search/QueryParserContext.php';
include_once 'Zend/Search/Lucene/Search/QueryParserContext.php';
$this->_contextStack[] = $this->_context;
$this->_context = new Zend_Search_Lucene_Search_QueryParserContext($this->_encoding, $this->_context->getField());
@ -515,14 +531,14 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
public function subqueryEnd()
{
if (count($this->_contextStack) == 0) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Syntax Error: mismatched parentheses, every opening must have closing. Char position ' . $this->_currentToken->position . '.');
}
$query = $this->_context->getQuery();
$this->_context = array_pop($this->_contextStack);
require_once 'Zend/Search/Lucene/Search/QueryEntry/Subquery.php';
include_once 'Zend/Search/Lucene/Search/QueryEntry/Subquery.php';
$this->_context->addEntry(new Zend_Search_Lucene_Search_QueryEntry_Subquery($query));
}
@ -551,10 +567,10 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
{
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_rqFirstTerm, $this->_encoding);
if (count($tokens) > 1) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Range query boundary terms must be non-multiple word terms');
} else if (count($tokens) == 1) {
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$from = new Zend_Search_Lucene_Index_Term(reset($tokens)->getTermText(), $this->_context->getField());
} else {
$from = null;
@ -562,23 +578,23 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_currentToken->text, $this->_encoding);
if (count($tokens) > 1) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Range query boundary terms must be non-multiple word terms');
} else if (count($tokens) == 1) {
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$to = new Zend_Search_Lucene_Index_Term(reset($tokens)->getTermText(), $this->_context->getField());
} else {
$to = null;
}
if ($from === null && $to === null) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('At least one range query boundary term must be non-empty term');
}
require_once 'Zend/Search/Lucene/Search/Query/Range.php';
include_once 'Zend/Search/Lucene/Search/Query/Range.php';
$rangeQuery = new Zend_Search_Lucene_Search_Query_Range($from, $to, false);
require_once 'Zend/Search/Lucene/Search/QueryEntry/Subquery.php';
include_once 'Zend/Search/Lucene/Search/QueryEntry/Subquery.php';
$entry = new Zend_Search_Lucene_Search_QueryEntry_Subquery($rangeQuery);
$this->_context->addEntry($entry);
}
@ -600,10 +616,10 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
{
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_rqFirstTerm, $this->_encoding);
if (count($tokens) > 1) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Range query boundary terms must be non-multiple word terms');
} else if (count($tokens) == 1) {
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$from = new Zend_Search_Lucene_Index_Term(reset($tokens)->getTermText(), $this->_context->getField());
} else {
$from = null;
@ -611,23 +627,23 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_currentToken->text, $this->_encoding);
if (count($tokens) > 1) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Range query boundary terms must be non-multiple word terms');
} else if (count($tokens) == 1) {
require_once 'Zend/Search/Lucene/Index/Term.php';
include_once 'Zend/Search/Lucene/Index/Term.php';
$to = new Zend_Search_Lucene_Index_Term(reset($tokens)->getTermText(), $this->_context->getField());
} else {
$to = null;
}
if ($from === null && $to === null) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('At least one range query boundary term must be non-empty term');
}
require_once 'Zend/Search/Lucene/Search/Query/Range.php';
include_once 'Zend/Search/Lucene/Search/Query/Range.php';
$rangeQuery = new Zend_Search_Lucene_Search_Query_Range($from, $to, true);
require_once 'Zend/Search/Lucene/Search/QueryEntry/Subquery.php';
include_once 'Zend/Search/Lucene/Search/QueryEntry/Subquery.php';
$entry = new Zend_Search_Lucene_Search_QueryEntry_Subquery($rangeQuery);
$this->_context->addEntry($entry);
}

View File

@ -20,7 +20,9 @@
* @version $Id: QueryParserContext.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Search_QueryToken */
/**
* Zend_Search_Lucene_Search_QueryToken
*/
require_once 'Zend/Search/Lucene/Search/QueryToken.php';
@ -141,7 +143,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
public function setNextEntrySign($sign)
{
if ($this->_mode === self::GM_BOOLEAN) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('It\'s not allowed to mix boolean and signs styles in the same subquery.');
}
@ -152,7 +154,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
} else if ($sign == Zend_Search_Lucene_Search_QueryToken::TT_PROHIBITED) {
$this->_nextEntrySign = false;
} else {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Unrecognized sign type.');
}
}
@ -185,7 +187,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
{
// Check, that modifier has came just after word or phrase
if ($this->_nextEntryField !== null || $this->_nextEntrySign !== null) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('\'~\' modifier must follow word or phrase.');
}
@ -193,7 +195,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
if (!$lastEntry instanceof Zend_Search_Lucene_Search_QueryEntry) {
// there are no entries or last entry is boolean operator
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('\'~\' modifier must follow word or phrase.');
}
@ -211,7 +213,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
{
// Check, that modifier has came just after word or phrase
if ($this->_nextEntryField !== null || $this->_nextEntrySign !== null) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('\'^\' modifier must follow word, phrase or subquery.');
}
@ -219,7 +221,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
if (!$lastEntry instanceof Zend_Search_Lucene_Search_QueryEntry) {
// there are no entries or last entry is boolean operator
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('\'^\' modifier must follow word, phrase or subquery.');
}
@ -236,7 +238,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
public function addLogicalOperator($operator)
{
if ($this->_mode === self::GM_SIGNS) {
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('It\'s not allowed to mix boolean and signs styles in the same subquery.');
}
@ -254,10 +256,10 @@ class Zend_Search_Lucene_Search_QueryParserContext
*/
public function _signStyleExpressionQuery()
{
require_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
include_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
$query = new Zend_Search_Lucene_Search_Query_Boolean();
require_once 'Zend/Search/Lucene/Search/QueryParser.php';
include_once 'Zend/Search/Lucene/Search/QueryParser.php';
if (Zend_Search_Lucene_Search_QueryParser::getDefaultOperator() == Zend_Search_Lucene_Search_QueryParser::B_AND) {
$defaultSign = true; // required
} else {
@ -293,10 +295,10 @@ class Zend_Search_Lucene_Search_QueryParserContext
* one or more query entries
*/
require_once 'Zend/Search/Lucene/Search/BooleanExpressionRecognizer.php';
include_once 'Zend/Search/Lucene/Search/BooleanExpressionRecognizer.php';
$expressionRecognizer = new Zend_Search_Lucene_Search_BooleanExpressionRecognizer();
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
try {
foreach ($this->_entries as $entry) {
if ($entry instanceof Zend_Search_Lucene_Search_QueryEntry) {
@ -326,7 +328,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
// throw new Zend_Search_Lucene_Search_QueryParserException('Boolean expression error. Error message: \'' .
// $e->getMessage() . '\'.' );
// It's query syntax error message and it should be user friendly. So FSM message is omitted
require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Boolean expression error.', 0, $e);
}
@ -353,7 +355,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
if (count($conjuction) == 1) {
$subqueries[] = $conjuction[0][0]->getQuery($this->_encoding);
} else {
require_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
include_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
$subquery = new Zend_Search_Lucene_Search_Query_Boolean();
foreach ($conjuction as $conjuctionEntry) {
@ -365,7 +367,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
}
if (count($subqueries) == 0) {
require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
include_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
return new Zend_Search_Lucene_Search_Query_Insignificant();
}
@ -374,7 +376,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
}
require_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
include_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
$query = new Zend_Search_Lucene_Search_Query_Boolean();
foreach ($subqueries as $subquery) {

View File

@ -37,5 +37,7 @@ require_once 'Zend/Search/Lucene/Exception.php';
* Special exception type, which may be used to intercept wrong user input
*/
class Zend_Search_Lucene_Search_QueryParserException extends Zend_Search_Lucene_Exception
{}
{
}

View File

@ -209,7 +209,7 @@ class Zend_Search_Lucene_Search_QueryToken
break;
default:
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Unrecognized query syntax lexeme: \'' . $tokenText . '\'');
}
break;
@ -218,7 +218,7 @@ class Zend_Search_Lucene_Search_QueryToken
$this->type = self::TT_NUMBER;
default:
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Unrecognized lexeme type: \'' . $tokenCategory . '\'');
}
}

View File

@ -322,7 +322,7 @@ abstract class Zend_Search_Lucene_Search_Similarity
public static function getDefault()
{
if (!self::$_defaultImpl instanceof Zend_Search_Lucene_Search_Similarity) {
require_once 'Zend/Search/Lucene/Search/Similarity/Default.php';
include_once 'Zend/Search/Lucene/Search/Similarity/Default.php';
self::$_defaultImpl = new Zend_Search_Lucene_Search_Similarity_Default();
}
@ -435,8 +435,9 @@ abstract class Zend_Search_Lucene_Search_Similarity
}
// round to closest value
if ($highIndex != 255 &&
$f - self::$_normTable[$highIndex] > self::$_normTable[$highIndex+1] - $f ) {
if ($highIndex != 255
&& $f - self::$_normTable[$highIndex] > self::$_normTable[$highIndex+1] - $f
) {
return $highIndex + 1;
} else {
return $highIndex;

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Similarity */
/**
* Zend_Search_Lucene_Search_Similarity
*/
require_once 'Zend/Search/Lucene/Search/Similarity.php';

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Weight */
/**
* Zend_Search_Lucene_Search_Weight
*/
require_once 'Zend/Search/Lucene/Search/Weight.php';
@ -66,8 +68,9 @@ class Zend_Search_Lucene_Search_Weight_Boolean extends Zend_Search_Lucene_Search
* @param Zend_Search_Lucene_Interface $reader
*/
public function __construct(Zend_Search_Lucene_Search_Query $query,
Zend_Search_Lucene_Interface $reader)
{
Zend_Search_Lucene_Interface $reader
) {
$this->_query = $query;
$this->_reader = $reader;
$this->_weights = array();

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Weight */
/**
* Zend_Search_Lucene_Search_Weight
*/
require_once 'Zend/Search/Lucene/Search/Weight.php';

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Weight */
/**
* Zend_Search_Lucene_Search_Weight
*/
require_once 'Zend/Search/Lucene/Search/Weight.php';
@ -66,8 +68,9 @@ class Zend_Search_Lucene_Search_Weight_MultiTerm extends Zend_Search_Lucene_Sear
* @param Zend_Search_Lucene_Interface $reader
*/
public function __construct(Zend_Search_Lucene_Search_Query $query,
Zend_Search_Lucene_Interface $reader)
{
Zend_Search_Lucene_Interface $reader
) {
$this->_query = $query;
$this->_reader = $reader;
$this->_weights = array();
@ -76,7 +79,7 @@ class Zend_Search_Lucene_Search_Weight_MultiTerm extends Zend_Search_Lucene_Sear
foreach ($query->getTerms() as $id => $term) {
if ($signs === null || $signs[$id] === null || $signs[$id]) {
require_once 'Zend/Search/Lucene/Search/Weight/Term.php';
include_once 'Zend/Search/Lucene/Search/Weight/Term.php';
$this->_weights[$id] = new Zend_Search_Lucene_Search_Weight_Term($term, $query, $reader);
$query->setWeight($id, $this->_weights[$id]);
}

View File

@ -64,8 +64,9 @@ class Zend_Search_Lucene_Search_Weight_Phrase extends Zend_Search_Lucene_Search_
* @param Zend_Search_Lucene_Interface $reader
*/
public function __construct(Zend_Search_Lucene_Search_Query_Phrase $query,
Zend_Search_Lucene_Interface $reader)
{
Zend_Search_Lucene_Interface $reader
) {
$this->_query = $query;
$this->_reader = $reader;
}

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Weight */
/**
* Zend_Search_Lucene_Search_Weight
*/
require_once 'Zend/Search/Lucene/Search/Weight.php';
@ -80,8 +82,9 @@ class Zend_Search_Lucene_Search_Weight_Term extends Zend_Search_Lucene_Search_We
*/
public function __construct(Zend_Search_Lucene_Index_Term $term,
Zend_Search_Lucene_Search_Query $query,
Zend_Search_Lucene_Interface $reader)
{
Zend_Search_Lucene_Interface $reader
) {
$this->_term = $term;
$this->_query = $query;
$this->_reader = $reader;

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Storage_Directory */
/**
* Zend_Search_Lucene_Storage_Directory
*/
require_once 'Zend/Search/Lucene/Storage/Directory.php';
@ -116,11 +118,11 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
{
if (!is_dir($path)) {
if (file_exists($path)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Path exists, but it\'s not a directory');
} else {
if (!self::mkdirs($path)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception("Can't create directory '$path'.");
}
}
@ -156,7 +158,8 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
$dirContent = opendir($this->_dirPath);
while (($file = readdir($dirContent)) !== false) {
if (($file == '..')||($file == '.')) continue;
if (($file == '..')||($file == '.')) { continue;
}
if(!is_dir($this->_dirPath . '/' . $file) ) {
$result[] = $file;
@ -180,7 +183,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
$this->_fileHandlers[$filename]->close();
}
unset($this->_fileHandlers[$filename]);
require_once 'Zend/Search/Lucene/Storage/File/Filesystem.php';
include_once 'Zend/Search/Lucene/Storage/File/Filesystem.php';
$this->_fileHandlers[$filename] = new Zend_Search_Lucene_Storage_File_Filesystem($this->_dirPath . '/' . $filename, 'w+b');
// Set file permissions, but don't care about any possible failures, since file may be already
@ -209,7 +212,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
$trackErrors = ini_get('track_errors'); ini_set('track_errors', '1');
if (!@unlink($this->_dirPath . '/' . $filename)) {
ini_set('track_errors', $trackErrors);
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Can\'t delete file: ' . $php_errormsg);
}
ini_set('track_errors', $trackErrors);
@ -296,7 +299,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
if (file_exists($this->_dirPath . '/' . $to)) {
if (!unlink($this->_dirPath . '/' . $to)) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Delete operation failed');
}
}
@ -307,7 +310,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
$success = @rename($this->_dirPath . '/' . $from, $this->_dirPath . '/' . $to);
if (!$success) {
ini_set('track_errors', $trackErrors);
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception($php_errormsg);
}
@ -345,7 +348,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
{
$fullFilename = $this->_dirPath . '/' . $filename;
require_once 'Zend/Search/Lucene/Storage/File/Filesystem.php';
include_once 'Zend/Search/Lucene/Storage/File/Filesystem.php';
if (!$shareHandler) {
return new Zend_Search_Lucene_Storage_File_Filesystem($fullFilename);
}

View File

@ -168,10 +168,12 @@ abstract class Zend_Search_Lucene_Storage_File
public function writeInt($value)
{
settype($value, 'integer');
$this->_fwrite( chr($value>>24 & 0xFF) .
$this->_fwrite(
chr($value>>24 & 0xFF) .
chr($value>>16 & 0xFF) .
chr($value>>8 & 0xFF) .
chr($value & 0xFF), 4 );
chr($value & 0xFF), 4
);
}
@ -218,14 +220,16 @@ abstract class Zend_Search_Lucene_Storage_File
*/
if (PHP_INT_SIZE > 4) {
settype($value, 'integer');
$this->_fwrite( chr($value>>56 & 0xFF) .
$this->_fwrite(
chr($value>>56 & 0xFF) .
chr($value>>48 & 0xFF) .
chr($value>>40 & 0xFF) .
chr($value>>32 & 0xFF) .
chr($value>>24 & 0xFF) .
chr($value>>16 & 0xFF) .
chr($value>>8 & 0xFF) .
chr($value & 0xFF), 8 );
chr($value & 0xFF), 8
);
} else {
$this->writeLong32Bit($value);
}
@ -249,7 +253,7 @@ abstract class Zend_Search_Lucene_Storage_File
if ($wordHigh == (int)0xFFFFFFFF && ($wordLow & (int)0x80000000)) {
return $wordLow;
} else {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Long integers lower than -2147483648 (0x80000000) are not supported on 32-bit platforms.');
}
@ -279,7 +283,7 @@ abstract class Zend_Search_Lucene_Storage_File
public function writeLong32Bit($value)
{
if ($value < (int)0x80000000) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Long integers lower than -2147483648 (0x80000000) are not supported on 32-bit platforms.');
}
@ -379,8 +383,9 @@ abstract class Zend_Search_Lucene_Storage_File
// Check for null character. Java2 encodes null character
// in two bytes.
if (ord($str_val[$count]) == 0xC0 &&
ord($str_val[$count+1]) == 0x80 ) {
if (ord($str_val[$count]) == 0xC0
&& ord($str_val[$count+1]) == 0x80
) {
$str_val[$count] = 0;
$str_val = substr($str_val, 0, $count+1)
. substr($str_val, $count+2);
@ -447,7 +452,7 @@ abstract class Zend_Search_Lucene_Storage_File
}
if ($chars < 0) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Invalid UTF-8 string');
}

View File

@ -20,7 +20,9 @@
* @version $Id: Filesystem.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Storage_File */
/**
* Zend_Search_Lucene_Storage_File
*/
require_once 'Zend/Search/Lucene/Storage/File.php';
/**
@ -52,7 +54,7 @@ class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Stor
if (strpos($mode, 'w') === false && !is_readable($filename)) {
// opening for reading non-readable file
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('File \'' . $filename . '\' is not readable.');
}
@ -63,7 +65,7 @@ class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Stor
if ($this->_fileHandle === false) {
ini_set('track_errors', $trackErrors);
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception($php_errormsg);
}

View File

@ -20,7 +20,9 @@
* @version $Id: Memory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Storage_File */
/**
* Zend_Search_Lucene_Storage_File
*/
require_once 'Zend/Search/Lucene/Storage/File.php';
/**
@ -361,7 +363,7 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
if ($wordHigh == (int)0xFFFFFFFF && ($wordLow & (int)0x80000000)) {
return $wordLow;
} else {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Long integers lower than -2147483648 (0x80000000) are not supported on 32-bit platforms.');
}
@ -391,7 +393,7 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
public function writeLong32Bit($value)
{
if ($value < (int)0x80000000) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Long integers lower than -2147483648 (0x80000000) are not supported on 32-bit platforms.');
}
@ -497,8 +499,9 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
// Check for null character. Java2 encodes null character
// in two bytes.
if (ord($str_val[$count]) == 0xC0 &&
ord($str_val[$count+1]) == 0x80 ) {
if (ord($str_val[$count]) == 0xC0
&& ord($str_val[$count+1]) == 0x80
) {
$str_val[$count] = 0;
$str_val = substr($str_val, 0, $count+1)
. substr($str_val, $count+2);
@ -568,7 +571,7 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
}
if ($chars < 0) {
require_once 'Zend/Search/Lucene/Exception.php';
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Invalid UTF-8 string');
}

View File

@ -20,7 +20,9 @@
* @version $Id: TermStreamsPriorityQueue.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Index_TermsStream_Interface */
/**
* Zend_Search_Lucene_Index_TermsStream_Interface
*/
require_once 'Zend/Search/Lucene/Index/TermsStream/Interface.php';
@ -72,8 +74,10 @@ class Zend_Search_Lucene_TermStreamsPriorityQueue implements Zend_Search_Lucene_
*/
public function resetTermsStream()
{
/** Zend_Search_Lucene_Index_TermsPriorityQueue */
require_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php';
/**
* Zend_Search_Lucene_Index_TermsPriorityQueue
*/
include_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php';
$this->_termsStreamQueue = new Zend_Search_Lucene_Index_TermsPriorityQueue();
@ -123,9 +127,9 @@ class Zend_Search_Lucene_TermStreamsPriorityQueue implements Zend_Search_Lucene_
public function nextTerm()
{
while (($termStream = $this->_termsStreamQueue->pop()) !== null) {
if ($this->_termsStreamQueue->top() === null ||
$this->_termsStreamQueue->top()->currentTerm()->key() !=
$termStream->currentTerm()->key()) {
if ($this->_termsStreamQueue->top() === null
|| $this->_termsStreamQueue->top()->currentTerm()->key() != $termStream->currentTerm()->key()
) {
// We got new term
$this->_lastTerm = $termStream->currentTerm();