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

@ -7,11 +7,11 @@
*/
if(!defined('DOCSVIEWER_PATH')) {
define('DOCSVIEWER_PATH', dirname(__FILE__));
define('DOCSVIEWER_PATH', dirname(__FILE__));
}
if(!defined('DOCSVIEWER_DIR')) {
$dir = explode(DIRECTORY_SEPARATOR, DOCSVIEWER_PATH);
$dir = explode(DIRECTORY_SEPARATOR, DOCSVIEWER_PATH);
define('DOCSVIEWER_DIR', array_pop($dir));
define('DOCSVIEWER_DIR', array_pop($dir));
}

View File

@ -10,10 +10,10 @@
* array(
* 'en/someniceurl/' => array(
* 'filepath' => '/path/to/docs/en/SomeniceFile.md',
* 'title' => 'Some nice URL',
* 'summary' => 'Summary Text',
* 'basename' => 'SomeniceFile.md',
* 'type' => 'DocumentationPage'
* 'title' => 'Some nice URL',
* 'summary' => 'Summary Text',
* 'basename' => 'SomeniceFile.md',
* 'type' => 'DocumentationPage'
* )
* )
* </code>
@ -21,10 +21,10 @@
* URL format is in the following structures:
*
* {lang}/{path}
* {lang}/{module}/{path}
* {lang}/{module}/{path}
* {lang}/{module}/{version}/{/path}
*
* @package framework
* @package framework
* @subpackage manifest
*/
class DocumentationManifest
@ -81,7 +81,7 @@ class DocumentationManifest
* or loaded from cache until needed.
*
* @param bool $includeTests Include tests in the manifest.
* @param bool $forceRegen Force the manifest to be regenerated.
* @param bool $forceRegen Force the manifest to be regenerated.
*/
public function __construct($forceRegen = false)
{
@ -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
);
@ -316,7 +320,7 @@ class DocumentationManifest
/**
* Get any redirect for the given url
*
* @param type $url
* @param type $url
* @return string
*/
public function getRedirect($url)
@ -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,21 +370,23 @@ class DocumentationManifest
$this->pages = array();
foreach ($grouped as $entity) {
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']);
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']);
if (strpos($b['filepath'], $a['filepath']) === 0) {
return -1;
if (strpos($b['filepath'], $a['filepath']) === 0) {
return -1;
}
if ($a['filepath'] == $b['filepath']) {
return 0;
}
return ($a['filepath'] < $b['filepath']) ? -1 : 1;
}
if ($a['filepath'] == $b['filepath']) {
return 0;
}
return ($a['filepath'] < $b['filepath']) ? -1 : 1;
});
);
$this->pages = array_merge($this->pages, $entity);
}
@ -399,23 +407,25 @@ class DocumentationManifest
/**
* Remove the link_base from the start of a link
*
* @param string $link
* @param string $link
* @return string
*/
protected function stripLinkBase($link)
{
return ltrim(str_replace(
Config::inst()->get('DocumentationViewer', 'link_base'),
'',
$link
), '/');
return ltrim(
str_replace(
Config::inst()->get('DocumentationViewer', 'link_base'),
'',
$link
), '/'
);
}
/**
*
* @param DocumentationPage $page
* @param string $basename
* @param string $path
* @param string $basename
* @param string $path
*/
protected function addPage($page, $basename, $path)
{
@ -474,7 +484,7 @@ class DocumentationManifest
*
* @param string $basename
* @param string $path
* @param int $depth
* @param int $depth
*/
public function handleFile($basename, $path, $depth)
{
@ -512,10 +522,14 @@ class DocumentationManifest
$parts = explode('/', trim($record->getRelativeLink(), '/'));
// Add the base link.
$output->push(new ArrayData(array(
'Link' => $base->Link(),
'Title' => $base->Title
)));
$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(
'Link' => $progress,
'Title' => DocumentationHelper::clean_page_name($part)
)));
$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(
'Link' => Controller::join_links($base, $url, '/'),
'Title' => $page['title'],
'LinkingMode' => $mode,
'Summary' => $page['summary'],
'Children' => $children
)));
$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(
'Title' => $check->getVersionTitle(),
'Version' => $check->getVersion(),
'Archived' => $check->getIsArchived(),
'Link' => $check->Link(),
'LinkingMode' => ($same) ? 'current' : 'link',
'IsStable' => $check->getIsStable()
)));
$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,9 +30,9 @@ class DocumentationParser
* Pathparts: folder/subfolder/page
*
* @param DocumentationPage $page
* @param String $baselink Link relative to webroot, up until the "root"
* of the module. Necessary to rewrite relative
* links
* @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
*
* @return String
*/
@ -238,16 +238,22 @@ class DocumentationParser
}
// Rewrite URL (relative or absolute)
$baselink = DocumentationHelper::relativePath(DocumentationHelper::normalizePath(
dirname($page->getPath())
));
$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(
$page->getEntity()->getPath(),
$url
)));
$relativeUrl = DocumentationHelper::normalizePath(
str_replace(
BASE_PATH, '', Controller::join_links(
$page->getEntity()->getPath(),
$url
)
)
);
} else {
$relativeUrl = rtrim($baselink, '/') . '/' . ltrim($url, '/');
}
@ -264,7 +270,7 @@ class DocumentationParser
);
// Replace any double slashes (apart from protocol)
// $absoluteUrl = preg_replace('/([^:])\/{2,}/', '$1/', $absoluteUrl);
// $absoluteUrl = preg_replace('/([^:])\/{2,}/', '$1/', $absoluteUrl);
// Replace in original content
$md = str_replace(
@ -299,8 +305,8 @@ class DocumentationParser
* The markdown parser gets confused by the extra pair of parentheses in links of the form [DataObject](api:DataObject::populateDefaults()) so
* all links are re-written as html markup instead of markdown [Title](url). This also prevents other markdown parsing problems.
*
* @param String $markdown
* @param DocumentationPage $doc_page
* @param String $markdown
* @param DocumentationPage $doc_page
* @return String
*/
public static function rewrite_api_links($markdown, $doc_page)
@ -324,19 +330,19 @@ class DocumentationParser
preg_match_all($regex, $markdown, $links);
if($links) {
foreach($links[0] as $i => $match) {
if($type === 'no_title'){
if($type === 'no_title') {
$title = $links[1][$i];
$link = $links[1][$i];
// change backticked links to avoid being parsed in the same way as non-backticked links
$markdown = str_replace('`'.$match.'`','XYZ'.$link.'XYZ',$markdown);
$markdown = str_replace('`'.$match.'`', 'XYZ'.$link.'XYZ', $markdown);
} else {
$title = $links[1][$i];
$link = $links[2][$i];
// change backticked links to avoid being parsed in the same way as non-backticked links
$markdown = str_replace('`'.$match.'`','XX'.$title.'YY'.$link.'ZZ',$markdown);
$markdown = str_replace('`'.$match.'`', 'XX'.$title.'YY'.$link.'ZZ', $markdown);
}
$html = sprintf($html_format, $link, $version, $module, $title);
$markdown = str_replace($match,$html,$markdown);
$markdown = str_replace($match, $html, $markdown);
}
}
}
@ -346,7 +352,7 @@ class DocumentationParser
if($links) {
foreach($links[0] as $i => $match) {
$link = $links[1][$i];
$markdown = str_replace($match,'`[api:'.$link.']`',$markdown);
$markdown = str_replace($match, '`[api:'.$link.']`', $markdown);
}
}
@ -356,7 +362,7 @@ class DocumentationParser
foreach($links[0] as $i => $match) {
$title = $links[1][$i];
$link = $links[2][$i];
$markdown = str_replace($match,'`['.$title.'](api:'.$link.')`',$markdown);
$markdown = str_replace($match, '`['.$title.'](api:'.$link.')`', $markdown);
}
}
@ -418,7 +424,7 @@ class DocumentationParser
/**
* Resolves all relative links within markdown.
*
* @param String $md Markdown content
* @param String $md Markdown content
* @param DocumentationPage $page
*
* @return String Markdown
@ -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

@ -21,7 +21,7 @@ class DocumentationPermalinks
*
* <code>
* DocumentationPermalinks::add(array(
* 'debugging' => 'current/en/sapphire/topics/debugging'
* 'debugging' => 'current/en/sapphire/topics/debugging'
* ));
* </code>
*

View File

@ -127,7 +127,7 @@ class DocumentationSearch
* Folder name for indexes (in the temp folder).
*
* @config
* @var string
* @var string
*/
private static $index_location;
@ -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);
}
@ -294,7 +301,7 @@ class DocumentationViewer extends Controller implements PermissionProvider
}
/**
* @param int $status
* @param int $status
* @param string $message
*
* @return SS_HTTPResponse
@ -304,9 +311,13 @@ class DocumentationViewer extends Controller implements PermissionProvider
$this->init();
$class = get_class($this);
$body = $this->customise(new ArrayData(array(
'Message' => $message
)))->renderWith(array("{$class}_error", $class));
$body = $this->customise(
new ArrayData(
array(
'Message' => $message
)
)
)->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(
'Title' => $entity->getTitle(),
'Link' => $link,
'LinkingMode' => $mode,
'DefaultEntity' => $entity->getIsDefaultEntity(),
'Children' => $children
)));
$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(
'Children' => $children
)))->renderWith('Includes/DocumentationPages');
return $this->customise(
new ArrayData(
array(
'Children' => $children
)
)
)->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(
'Link' => Controller::join_links($baseLink, $url),
'Title' => $page['title'],
'FirstLetter' => $first
)));
$output->push(
new ArrayData(
array(
'Link' => Controller::join_links($baseLink, $url),
'Title' => $page['title'],
'FirstLetter' => $first
)
)
);
}
}
@ -596,18 +619,18 @@ class DocumentationViewer extends Controller implements PermissionProvider
* to jump into editing the documentation.
*
* Some variables are replaced:
* - %version%
* - %entity%
* - %path%
* - %lang%
* - %version%
* - %entity%
* - %path%
* - %lang%
*
* For example to provide an edit link to the framework module in github:
*
* <code>
* DocumentationViewer::set_edit_link(
* 'framework',
* 'https://github.com/silverstripe/%entity%/edit/%version%/docs/%lang%/%path%',
* $opts
* 'framework',
* 'https://github.com/silverstripe/%entity%/edit/%version%/docs/%lang%/%path%',
* $opts
* ));
* </code>
*
@ -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,8 +752,9 @@ class DocumentationViewer extends Controller implements PermissionProvider
/**
* Gets whether there is a default entity or not
*
* @return boolean
* @see DocumentationManifest::getHasDefaultEntity()
* @see DocumentationManifest::getHasDefaultEntity()
*/
public function getHasDefaultEntity()
{

View File

@ -10,7 +10,7 @@
* <code>
* StaticExporter:
* extensions:
* - DocumentationStaticPublisherExtension
* - DocumentationStaticPublisherExtension
* </code>
*
* If you don't plan on using static publisher for anything else and you have

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(
'FutureRelease' => true,
'StableVersion' => DBField::create_field('HTMLText', $stable->getVersion())
)));
return $this->owner->customise(
new ArrayData(
array(
'FutureRelease' => true,
'StableVersion' => DBField::create_field('HTMLText', $stable->getVersion())
)
)
);
} else {
return $this->owner->customise(new ArrayData(array(
'OutdatedRelease' => true,
'StableVersion' => DBField::create_field('HTMLText', $stable->getVersion())
)));
return $this->owner->customise(
new ArrayData(
array(
'OutdatedRelease' => true,
'StableVersion' => DBField::create_field('HTMLText', $stable->getVersion())
)
)
);
}
return false;

View File

@ -11,8 +11,7 @@
* 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
* @package docsviewer
* @subpackage models
*/
@ -130,7 +129,7 @@ class DocumentationEntity extends ViewableData
*
* Includes the version information
*
* @param boolean $short If true, will attempt to return a short version of the url
* @param boolean $short If true, will attempt to return a short version of the url
* This might omit the version number if this is the default version.
* @return string
*/
@ -256,17 +255,19 @@ class DocumentationEntity extends ViewableData
*
* @return string
*/
public function getVersionTitle() {
public function getVersionTitle()
{
return $this->versionTitle;
}
/**
* Sets the title for this version
*
* @param string $title
* @param string $title
* @return $this
*/
public function setVersionTitle($title) {
public function setVersionTitle($title)
{
$this->versionTitle = $title;
return $this;
}
@ -274,10 +275,11 @@ class DocumentationEntity extends ViewableData
/**
* Set if this is archived
*
* @param bool $archived
* @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;
}
@ -354,7 +357,7 @@ class DocumentationEntity extends ViewableData
* version. Will return -1 for if the version is older, 0 if versions are
* the same and 1 if the version is greater than.
*
* @param DocumentationEntity $other
* @param DocumentationEntity $other
* @return int
*/
public function compare(DocumentationEntity $other)

View File

@ -5,7 +5,7 @@
*
* Maps to a folder on the file system.
*
* @package docsviewer
* @package docsviewer
* @subpackage model
*/
class DocumentationFolder extends DocumentationPage

View File

@ -7,7 +7,7 @@
* not always be the file name. If the file contains meta data with a nicer URL
* sthen it will use that.
*
* @package docsviewer
* @package docsviewer
* @subpackage model
*/
class DocumentationPage extends ViewableData
@ -38,8 +38,8 @@ class DocumentationPage extends ViewableData
/**
* @param DocumentationEntity $entity
* @param string $filename
* @param string $path
* @param string $filename
* @param string $path
*/
public function __construct(DocumentationEntity $entity, $filename, $path)
{
@ -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) {
if ($val) {
return $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) {
return DocumentationHelper::clean_page_url($a);
}, $url));
$url = implode(
'/', array_map(
function ($a) {
return DocumentationHelper::clean_page_url($a);
}, $url
)
);
$url = trim($url, '/') . '/';
@ -240,16 +248,18 @@ class DocumentationPage extends ViewableData
* Returns the URL that will be required for the user to hit to view the
* given document base name.
*
* @param boolean $short If true, will attempt to return a short version of the url
* @param boolean $short If true, will attempt to return a short version of the url
* This might omit the version number if this is the default version.
* @return string
*/
public function Link($short = false)
{
return ltrim(Controller::join_links(
$this->entity->Link($short),
$this->getRelativeLink()
), '/');
return ltrim(
Controller::join_links(
$this->entity->Link($short),
$this->getRelativeLink()
), '/'
);
}
/**
@ -257,7 +267,7 @@ class DocumentationPage extends ViewableData
* block on request
*
* @param DocumentationPage $md
* @param bool $remove
* @param bool $remove
*/
public function populateMetaDataFromText(&$md, $removeMetaData = false)
{

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";
@ -36,7 +40,7 @@ class CheckDocsSourcesTask extends BuildTask {
/**
* Validate all source files
*
* @param SS_HTTPRequest $request
* @param SS_HTTPRequest $request
* @throws Exception
*/
public function run($request)

View File

@ -5,7 +5,7 @@
*
* For the hourly cron rebuild use RebuildLuceneDocusIndex_Hourly
*
* @package docsviewer
* @package docsviewer
* @subpackage tasks
*/
@ -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(
'Version', $page->getEntity()->getVersion()
));
$doc->addField(
Zend_Search_Lucene_Field::Keyword(
'Version', $page->getEntity()->getVersion()
)
);
$doc->addField(Zend_Search_Lucene_Field::Keyword(
'Language', $page->getEntity()->getLanguage()
));
$doc->addField(
Zend_Search_Lucene_Field::Keyword(
'Language', $page->getEntity()->getLanguage()
)
);
$doc->addField(Zend_Search_Lucene_Field::Keyword(
'Entity', $page->getEntity()
));
$doc->addField(
Zend_Search_Lucene_Field::Keyword(
'Entity', $page->getEntity()
)
);
$doc->addField(Zend_Search_Lucene_Field::Keyword(
'Link', $page->Link()
));
$doc->addField(
Zend_Search_Lucene_Field::Keyword(
'Link', $page->Link()
)
);
// custom boosts
$titleField->boost = 3;

View File

@ -1,38 +1,38 @@
fieldset {
border: none;
margin: 0;
padding: 0 0 5px 0;
border: none;
margin: 0;
padding: 0 0 5px 0;
}
#DocumentationAdvancedSearchForm_AdvancedSearchForm_q {
width: 100%;
font-size: 15px;
padding: 10px 10px;
width: 100%;
font-size: 15px;
padding: 10px 10px;
}
#DocumentationAdvancedSearchForm_AdvancedSearchForm #q {
width: 55%;
padding-right: 2%;
float: left;
width: 55%;
padding-right: 2%;
float: left;
}
#DocumentationAdvancedSearchForm_AdvancedSearchForm #Entities {
width: 25%;
padding-right: 2%;
float: left;
width: 25%;
padding-right: 2%;
float: left;
}
#DocumentationAdvancedSearchForm_AdvancedSearchForm #Versions {
width: auto;
float: left;
margin-top: 12px;
width: auto;
float: left;
margin-top: 12px;
}
.optionset ul {
margin: 0;
margin: 0;
}
.optionset li {
list-style: none;
float: left;
padding-right: 12px;
list-style: none;
float: left;
padding-right: 12px;
}

View File

@ -1,11 +1,11 @@
html {
background: #fff;
font: 15px/1.5 "proxima-nova", "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #586667;
padding-bottom: 40px;
-webkit-font-smoothing: antialiased;
box-sizing: border-box;
overflow-y: scroll;
background: #fff;
font: 15px/1.5 "proxima-nova", "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #586667;
padding-bottom: 40px;
-webkit-font-smoothing: antialiased;
box-sizing: border-box;
overflow-y: scroll;
}
*, *:before, *:after {
@ -14,406 +14,406 @@ html {
/*! container */
.wrapper {
margin-right: auto;
margin-left: auto;
padding-left: 15px;
padding-right: 15px;
margin-right: auto;
margin-left: auto;
padding-left: 15px;
padding-right: 15px;
}
.introduction {}
.introduction h1 {
margin-bottom: 20px;
}
.introduction h1 {
margin-bottom: 20px;
}
.introduction p {
font-size: 20px;
margin-bottom: 10px;
max-width: 80%;
}
.introduction p {
font-size: 20px;
margin-bottom: 10px;
max-width: 80%;
}
.no-box {
padding: 15px;
padding: 15px;
}
/*! main content column */
#content {
float: right;
width: 72%;
float: right;
width: 72%;
}
#content .box {
padding: 30px 5px;
}
#content .box {
padding: 30px 5px;
}
/*! sidebar */
#sidebar {
float: left;
padding-top:20px;
float: left;
padding-top:20px;
}
#sidebar .nav,
#sidebar .minor-nav {
margin: 0;
padding: 0;
list-style: none;
}
#sidebar .nav,
#sidebar .minor-nav {
margin: 0;
padding: 0;
list-style: none;
}
#sidebar .nav {
font-size: 16px;
}
#sidebar .nav {
font-size: 16px;
}
#sidebar .nav .top {
width: 100%;
display: block;
line-height: 15px;
color: #808c8d;
padding: 15px 15px 14px;
text-transform: uppercase;
}
#sidebar .nav .top {
width: 100%;
display: block;
line-height: 15px;
color: #808c8d;
padding: 15px 15px 14px;
text-transform: uppercase;
}
#sidebar .nav .current .top {
color: #1389CE;
font-weight: 700;
}
#sidebar .nav .current .top {
color: #1389CE;
font-weight: 700;
}
#sidebar .nav a {
display:block;
padding-top:7px;
padding-bottom:7px;
padding-right:12px;
}
#sidebar .nav a {
display:block;
padding-top:7px;
padding-bottom:7px;
padding-right:12px;
}
/* Sidebar hover states */
#sidebar .nav a:hover,
#sidebar .nav a.top:hover,
#sidebar .nav .section ul li .section:hover,
#sidebar .nav a.current:hover,
/* Sidebar focus states */
#sidebar .nav a:focus,
#sidebar .nav a.top:focus,
#sidebar .nav .section ul li .section:focus,
#sidebar .nav a.current:focus {
background-color: #1389ce;
color: #fff;
text-decoration: none;
-webkit-transition: all 500ms ease;
-moz-transition: all 500ms ease;
transition: all 500ms ease;
}
/* Sidebar hover states */
#sidebar .nav a:hover,
#sidebar .nav a.top:hover,
#sidebar .nav .section ul li .section:hover,
#sidebar .nav a.current:hover,
/* Sidebar focus states */
#sidebar .nav a:focus,
#sidebar .nav a.top:focus,
#sidebar .nav .section ul li .section:focus,
#sidebar .nav a.current:focus {
background-color: #1389ce;
color: #fff;
text-decoration: none;
-webkit-transition: all 500ms ease;
-moz-transition: all 500ms ease;
transition: all 500ms ease;
}
#sidebar .nav .section .top {
border: none;
color: #1389CE;
}
#sidebar .nav .section .top {
border: none;
color: #1389CE;
}
#sidebar li {
margin: 0;
list-style:none;
}
#sidebar li {
margin: 0;
list-style:none;
}
#sidebar li a.current {
color:#fff;
}
#sidebar li a.current {
color:#fff;
}
#sidebar .nav > li {}
#sidebar .nav > li {}
#sidebar .nav .section ul,
#sidebar .nav .current ul {
border-bottom: 1px solid #eee;
margin: 0;
padding:0;
}
#sidebar .nav .section ul,
#sidebar .nav .current ul {
border-bottom: 1px solid #eee;
margin: 0;
padding:0;
}
#sidebar .nav .section ul li a,
#sidebar .nav .current ul li a {
padding-left:30px;
}
#sidebar .nav .section ul li a,
#sidebar .nav .current ul li a {
padding-left:30px;
}
#sidebar .nav .section ul li a.section {
color: #1389CE;
}
#sidebar .nav .section ul li a.section {
color: #1389CE;
}
#sidebar .nav .section ul li ul li a,
#sidebar .nav .current ul li ul li a {
padding-left:48px;
font-size:14px;
}
#sidebar .nav .section ul li ul li a,
#sidebar .nav .current ul li ul li a {
padding-left:48px;
font-size:14px;
}
#sidebar .nav a.current {
color: #1389CE;
font-weight: 700;
}
#sidebar .nav a.current {
color: #1389CE;
font-weight: 700;
}
#sidebar .minor-nav a {
color: #181C17;
opacity: 0.4;
filter: alpha(opacity=40);
}
#sidebar .minor-nav a {
color: #181C17;
opacity: 0.4;
filter: alpha(opacity=40);
}
#sidebar .search {}
#sidebar .search {}
#sidebar .search fieldset {
border-bottom: 1px solid #eee;
padding: 15px 10px 14px;
}
#sidebar .search fieldset {
border-bottom: 1px solid #eee;
padding: 15px 10px 14px;
}
#sidebar .search label,
#sidebar .search .Actions {
display: none;
}
#sidebar .search label,
#sidebar .search .Actions {
display: none;
}
#sidebar .search input {
width: 100%;
outline: none;
border-radius: 2px;
border: 1px solid #ddd;
padding: 9px;
}
#sidebar .search input {
width: 100%;
outline: none;
border-radius: 2px;
border: 1px solid #ddd;
padding: 9px;
}
#sidebar .search input:focus {
border-color: #1389ce;
}
#sidebar .search input:focus {
border-color: #1389ce;
}
#layout {
padding-bottom: 20px;
position:relative;
padding-bottom: 20px;
position:relative;
}
#masthead {
padding: 50px 0;
background:#f6f7f8;
position:relative;
padding: 50px 0;
background:#f6f7f8;
position:relative;
}
#masthead.has_versions {
padding-bottom: 0;
}
#masthead.has_versions {
padding-bottom: 0;
}
#masthead .wrapper {
overflow: hidden;
}
#masthead .wrapper {
overflow: hidden;
}
.versions {
float: right;
float: right;
}
.versions p {
margin: 0 0 5px;
font-size: 12px;
}
.versions p {
margin: 0 0 5px;
font-size: 12px;
}
.versions ul {
margin: 0;
padding: 0;
}
.versions ul {
margin: 0;
padding: 0;
}
.versions li {
list-style: none;
display: block;
float: left;
margin: 0 0 0 5px;
}
.versions li {
list-style: none;
display: block;
float: left;
margin: 0 0 0 5px;
}
.versions li a {
padding: 10px 15px;
display: block;
}
.versions li a {
padding: 10px 15px;
display: block;
}
.versions .current {
background: #fff;
}
.versions .current {
background: #fff;
}
/*! language */
#language {}
#language label {
float: left;
width: 830px;
line-height: 19px;
text-align: right;
font-size: 11px;
color: #999;
}
#language label {
float: left;
width: 830px;
line-height: 19px;
text-align: right;
font-size: 11px;
color: #999;
}
#language select {
float: right;
width: 120px;
}
#language select {
float: right;
width: 120px;
}
#language input.action {
float: right;
margin-top: 4px;
}
#language input.action {
float: right;
margin-top: 4px;
}
/* Header */
#header {
padding: 0 0 14px 0;
overflow: hidden;
padding: 0 0 14px 0;
overflow: hidden;
}
#header h1 {
margin: 0;
line-height: 38px;
float: left;
}
#header h1 {
margin: 0;
line-height: 38px;
float: left;
}
#header h1 a {
text-decoration: none;
font-size: 22px;
color: #0973A6;
letter-spacing: -1px;
}
#header h1 a {
text-decoration: none;
font-size: 22px;
color: #0973A6;
letter-spacing: -1px;
}
#header .logo {
background: #fff url(../../docsviewer/images/logo.jpg) no-repeat bottom left;
height: 36px; width: 140px;
display: inline-block;
}
#header .logo {
background: #fff url(../../docsviewer/images/logo.jpg) no-repeat bottom left;
height: 36px; width: 140px;
display: inline-block;
}
/* Search Results */
#search-results {}
#search-results li {
list-style: none;
border-bottom: 1px solid #ddd;
padding: 0 0 19px 0;
margin: 0 0 20px 0;
background: none;
}
#search-results li {
list-style: none;
border-bottom: 1px solid #ddd;
padding: 0 0 19px 0;
margin: 0 0 20px 0;
background: none;
}
/* Comments */
#comments {
clear: both;
padding-top: 18px;
clear: both;
padding-top: 18px;
}
#comments .notice {
font-size: 14px;
}
#comments .notice {
font-size: 14px;
}
/* Footer */
#footer {
margin: 20px auto;
padding: 0 30px;
margin: 20px auto;
padding: 0 30px;
}
#footer p {
color: #798D85;
}
#footer p {
color: #798D85;
}
#footer p a {
color: #798D85;
}
#footer p a {
color: #798D85;
}
/*! Pagination */
#page-numbers span,
#page-numbers a {
padding: 3px 5px;
padding: 3px 5px;
}
#page-numbers span {}
#page-numbers a:hover {
color: #FFFFFF;
background-color: #005F99;
}
#page-numbers a:hover {
color: #FFFFFF;
background-color: #005F99;
}
.pagination {
margin: 27px 0;
margin: 27px 0;
}
.pagination li {
display: inline;
background: none;
padding: 0 4px 0 0;
}
.pagination li {
display: inline;
background: none;
padding: 0 4px 0 0;
}
.pagination li strong, .pagination li a {
padding: 1px 4px;
}
.pagination li strong, .pagination li a {
padding: 1px 4px;
}
.pagination li.active strong {
background-color: #c3dbd4;
}
.pagination li.active strong {
background-color: #c3dbd4;
}
.pagination li a:hover {
background-color: #0973A6;
color: #fff;
text-decoration: none;
}
.pagination li a:hover {
background-color: #0973A6;
color: #fff;
text-decoration: none;
}
/* Table of contents */
#table-of-contents {
margin: 0 0 10px 0;
padding: 6px 6px 6px 10px;
background: #f6fbfe;
border: 1px solid #DDE8ED;
border-radius: 4px;
cursor: pointer;
margin-bottom: 21px;
margin: 0 0 10px 0;
padding: 6px 6px 6px 10px;
background: #f6fbfe;
border: 1px solid #DDE8ED;
border-radius: 4px;
cursor: pointer;
margin-bottom: 21px;
}
#table-of-contents h4 {
font-size: 14px;
margin: 0;
padding: 0;
}
#table-of-contents h4 {
font-size: 14px;
margin: 0;
padding: 0;
}
#table-of-contents h4 span.updown {
color: #a2c1d0;
margin-left: 6px;
font-size: 10px;
}
#table-of-contents h4 span.updown {
color: #a2c1d0;
margin-left: 6px;
font-size: 10px;
}
#table-of-contents h4:hover {
opacity: 0.8;
filter: alpha(opacity=80);
}
#table-of-contents h4:hover {
opacity: 0.8;
filter: alpha(opacity=80);
}
#table-of-contents ul {
margin: 0;
padding: 0;
}
#table-of-contents ul {
margin: 0;
padding: 0;
}
#table-of-contents li {
line-height: 14px;
padding: 0;
list-style: none;
margin: 0;
line-height: 20px;
}
#table-of-contents li {
line-height: 14px;
padding: 0;
list-style: none;
margin: 0;
line-height: 20px;
}
#table-of-contents li.H2 { padding-left:20px; }
#table-of-contents li.H3 { padding-left:40px; }
#table-of-contents li.H4 { padding-left:60px; }
#table-of-contents li.H5 { padding-left:80px; }
#table-of-contents li.H6 { padding-left:100px; }
#table-of-contents li.H2 { padding-left:20px; }
#table-of-contents li.H3 { padding-left:40px; }
#table-of-contents li.H4 { padding-left:60px; }
#table-of-contents li.H5 { padding-left:80px; }
#table-of-contents li.H6 { padding-left:100px; }
#table-of-contents li li {
padding-left: 20px;
}
#table-of-contents li li {
padding-left: 20px;
}
#table-of-contents a,
#table-of-contents a:visited {
color: #1389ce;
text-decoration: none;
}
#table-of-contents a,
#table-of-contents a:visited {
color: #1389ce;
text-decoration: none;
}
#table-of-contents a:hover,
#table-of-contents a:focus {
text-decoration: underline;
color: #1389ce;
}
#table-of-contents a:hover,
#table-of-contents a:focus {
text-decoration: underline;
color: #1389ce;
}
/*! Messages */
/**
* Example:
* <div class="info">
* <h5>This is a info message</h5>
* <p>Body text</p>
* <a href="#" class="close" title="Close notification">close</a>
* <h5>This is a info message</h5>
* <p>Body text</p>
* <a href="#" class="close" title="Close notification">close</a>
* </div>
*/
#content .warningBox h5,
@ -421,22 +421,22 @@ html {
#content .notice h5,
#content .warning h5,
#content .info h5 {
margin-bottom: 0px;
margin-bottom: 0px;
}
.hint a.close,
.notice a.close,
.warning a.close,
.info a.close {
background:url(../../docsviewer/images/ico_close_off.png) no-repeat scroll left top transparent;
display:block;
font-size:0;
height:11px;
position:absolute;
right:3px;
text-indent:-9999px;
top:3px;
width:11px;
background:url(../../docsviewer/images/ico_close_off.png) no-repeat scroll left top transparent;
display:block;
font-size:0;
height:11px;
position:absolute;
right:3px;
text-indent:-9999px;
top:3px;
width:11px;
}
.hint,
@ -447,17 +447,17 @@ html {
.info,
.pageSkip,
.warningBox {
border-radius:4px;
padding: 10px 20px;
clear: both;
position: relative;
margin: 40px 0;
border-radius:4px;
padding: 10px 20px;
clear: both;
position: relative;
margin: 40px 0;
}
.typography .note h3,
.typography .hint h3 {
line-height: 27px;
}
.typography .note h3,
.typography .hint h3 {
line-height: 27px;
}
.hint p,
.note p,
@ -466,357 +466,357 @@ html {
.warning p,
.info p,
.warningBox p {
margin-bottom: 0;
font-weight:400;
margin-bottom: 0;
font-weight:400;
}
.pageSkip {
background-color: #f9fafa;
border: 1px solid #a5b5b0;
text-align: center;
background-color: #f9fafa;
border: 1px solid #a5b5b0;
text-align: center;
}
.notice,
.note,
.warningBox {
background: #FFFFAD;
background: #FFFFAD;
}
.warning,
.alert {
background: #FF8480;
color:#fff;
background: #FF8480;
color:#fff;
}
.warning a,
.alert a {
color:#fff;
text-decoration:underline;
color:#fff;
text-decoration:underline;
}
.warning code,
.alert code {
color:#666;
color:#666;
}
.hint {
background: #f4f4f4;
background: #f4f4f4;
}
.info {
background: #CAF7FF;
background: #CAF7FF;
}
.warning p {
margin-bottom: 0;
margin-bottom: 0;
}
.warningBoxTop {
padding: 10px 10px 10px 70px;
background: url(../../docsviewer/images/warning.png) no-repeat 18px 14px;
padding: 10px 10px 10px 70px;
background: url(../../docsviewer/images/warning.png) no-repeat 18px 14px;
}
.warningBoxTop h1 {
margin-bottom: 0;
margin-bottom: 0;
}
.warningBoxTop ul {
margin: 9px 0 18px;
margin: 9px 0 18px;
}
.warningBoxTop li {
margin-bottom: 0;
margin-bottom: 0;
}
.warningBox {
margin-top: 0;
margin-top: 0;
}
.warningBoxBottom {
background-color: #0973A6;
padding: 12px 0 16px;
background-color: #0973A6;
padding: 12px 0 16px;
}
.warningBoxBottom a { color: #fff; }
.warningBoxBottom a:hover { color: #f3fbfe; }
.warningBoxBottom ul { margin: 0 0 0 40px; }
.warningBoxBottom li { background: none; margin-bottom: 0; }
.warningBoxBottom a { color: #fff; }
.warningBoxBottom a:hover { color: #f3fbfe; }
.warningBoxBottom ul { margin: 0 0 0 40px; }
.warningBoxBottom li { background: none; margin-bottom: 0; }
.doc-breadcrumbs {}
.doc-breadcrumbs p {
margin: 0 0 5px 0;
color: #999;
font-size: 38px;
}
.doc-breadcrumbs p {
margin: 0 0 5px 0;
color: #999;
font-size: 38px;
}
.doc-breadcrumbs p a {
color: rgb(3, 91, 136);
text-decoration:none;
font-weight:200;
}
.doc-breadcrumbs p a {
color: rgb(3, 91, 136);
text-decoration:none;
font-weight:200;
}
.doc-breadcrumbs p a.current {
color:#696868;
}
.doc-breadcrumbs p a.current {
color:#696868;
}
.menu-open {
display:none;
display:none;
}
.well {
min-height: 20px;
padding: 19px;
margin-bottom: 40px;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
border-radius: 4px;
box-shadow: inset 0 1px 1px rgba(0,0,0,.05);
min-height: 20px;
padding: 19px;
margin-bottom: 40px;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
border-radius: 4px;
box-shadow: inset 0 1px 1px rgba(0,0,0,.05);
}
.well h4 {
margin-top: 0;
}
.well h4 {
margin-top: 0;
}
.result {}
.result h2 {
margin-bottom: 0;
}
.result h2 {
margin-bottom: 0;
}
.documentation_children {
overflow: hidden;
padding-bottom: 20px;
overflow: hidden;
padding-bottom: 20px;
}
.documentation_children ul {
margin: 0;
}
.documentation_children ul {
margin: 0;
}
.documentation_children h3 {
font-size: 18px;
border-top: 1px solid #ddd;
padding-top: 19px;
margin-top: 0;
margin-bottom: 0 0 1px 0;
}
.documentation_children h3 {
font-size: 18px;
border-top: 1px solid #ddd;
padding-top: 19px;
margin-top: 0;
margin-bottom: 0 0 1px 0;
}
.documentation_children li {
float: left;
width: 33%;
margin: 0 0 40px;
padding: 0 3% 0 0;
list-style: none;
}
.documentation_children li {
float: left;
width: 33%;
margin: 0 0 40px;
padding: 0 3% 0 0;
list-style: none;
}
.documentation_children li:nth-child(3n+1) {
clear: both;
}
.documentation_children li:nth-child(3n+1) {
clear: both;
}
.documentation_children p {
font-size: 15px;
opacity: 0.9;
filter: alpha(opacity=90);
}
.documentation_children p {
font-size: 15px;
opacity: 0.9;
filter: alpha(opacity=90);
}
.btn {
background: #eee;
padding: 10px;
border-radius: 4px;
font-weight: 400;
background: #eee;
padding: 10px;
border-radius: 4px;
font-weight: 400;
}
.btn:hover {
text-decoration:none;
background:#E7E6E6;
text-decoration:none;
background:#E7E6E6;
}
.next-prev {
border-top: 1px solid #eee;
margin-top: 20px;
padding-top: 19px;
border-top: 1px solid #eee;
margin-top: 20px;
padding-top: 19px;
}
.next-prev a {
color: #798D85;
}
.next-prev a {
color: #798D85;
}
.next-prev p {
margin: 0;
}
.next-prev p {
margin: 0;
}
.next-prev .prev-link {
float: left;
}
.next-prev .prev-link {
float: left;
}
.next-prev .next-link {
float: right;
}
.next-prev .next-link {
float: right;
}
@media (max-width: 767px) {
a.breadcrumb, .introduction p {
font-size:14px;
}
a.breadcrumb, .introduction p {
font-size:14px;
}
.documentation_children li {
float: none;
width: auto;
}
.documentation_children li {
float: none;
width: auto;
}
.next-prev .prev-link,
.next-prev .next-link {
float:none;
margin:20px 0;
}
.next-prev .prev-link,
.next-prev .next-link {
float:none;
margin:20px 0;
}
}
@media (min-width: 768px) {
.wrapper {
width: 750px;
}
.wrapper {
width: 750px;
}
.documentation_children li {
width: 50%;
}
.documentation_children li {
width: 50%;
}
}
@media (min-width: 992px) {
.wrapper {
width: 970px;
}
.wrapper {
width: 970px;
}
#sidebar {
width: 25%;
}
/* Removes close button on desktop view */
#sidebar .menu-close {
display: none;
}
#sidebar {
width: 25%;
}
/* Removes close button on desktop view */
#sidebar .menu-close {
display: none;
}
.documentation_children li {
width:33%;
}
.documentation_children li {
width:33%;
}
}
@media (min-width: 1200px) {
.wrapper {
width: 1170px;
}
.wrapper {
width: 1170px;
}
}
/* Sidebar mobile styles (default:hidden) */
@media (max-width: 991px) {
#sidebar {
position: fixed;
background: transparent;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
z-index: -1; /* [-1] Sidebar: hidden, [0] Page, [1] Sidebar: Show */
box-shadow: none;
overflow-x: hidden;
overflow-y: auto;
-webkit-transition: all 300ms ease;
-moz-transition: all 300ms ease;
transition: all 300ms ease;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-moz-box-shadow: none!important;
-webkit-box-shadow: none!important;
box-shadow: none!important;
}
#sidebar {
position: fixed;
background: transparent;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
z-index: -1; /* [-1] Sidebar: hidden, [0] Page, [1] Sidebar: Show */
box-shadow: none;
overflow-x: hidden;
overflow-y: auto;
-webkit-transition: all 300ms ease;
-moz-transition: all 300ms ease;
transition: all 300ms ease;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-moz-box-shadow: none!important;
-webkit-box-shadow: none!important;
box-shadow: none!important;
}
/* Opened sidebar styles */
#sidebar.open {
z-index: 1;
background: #fff;
opacity: 1;
}
/* Fade out sidebar state styles before class is removed */
#sidebar.hide {
z-index: 1;
background: transparent;
color: white;
}
/* Opened sidebar styles */
#sidebar.open {
z-index: 1;
background: #fff;
opacity: 1;
}
/* Fade out sidebar state styles before class is removed */
#sidebar.hide {
z-index: 1;
background: transparent;
color: white;
}
#content {
float:none;
width:auto;
}
#content {
float:none;
width:auto;
}
#masthead {
padding:20px 0;
}
#masthead {
padding:20px 0;
}
.doc-breadcrumbs p {
font-size:18px;
}
.doc-breadcrumbs p {
font-size:18px;
}
.introduction p {
font-size:14px;
}
.introduction p {
font-size:14px;
}
/* Menu button styles */
.wrapper .menu-open {
display: block;
position: relative;
width: 70px;
height: 40px;
margin-left: auto;
margin-bottom: 20px;
padding: 7px 10px;
font-weight: 700;
text-decoration: none;
text-transform: uppercase;
color: #1389ce;
background-color: transparent;
border: 2px solid #1389ce;
border-radius: 5px;
/* Menu button styles */
.wrapper .menu-open {
display: block;
position: relative;
width: 70px;
height: 40px;
margin-left: auto;
margin-bottom: 20px;
padding: 7px 10px;
font-weight: 700;
text-decoration: none;
text-transform: uppercase;
color: #1389ce;
background-color: transparent;
border: 2px solid #1389ce;
border-radius: 5px;
cursor: pointer;
-webkit-user-select: none; /* Chrome/Safari */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE10+ */
}
cursor: pointer;
-webkit-user-select: none; /* Chrome/Safari */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE10+ */
}
.wrapper .menu-open:hover {
background-color: #1389ce;
color: #fff;
transition: 300ms 0.1s ease;
}
.wrapper .menu-open:hover {
background-color: #1389ce;
color: #fff;
transition: 300ms 0.1s ease;
}
/* Close button styles */
.menu-close {
display: block;
position: relative;
margin-left: auto;
margin-right: 10px;
padding: 0px 12px;
font-size: 33px;
font-weight: 700;
line-height: 33px;
text-decoration: none;
color: #1389ce;
width: 40px;
height: 40px;
cursor: pointer;
-webkit-user-select: none; /* Chrome/Safari */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE10+ */
}
.menu-close:hover {
text-decoration: none;
}
/* Close button styles */
.menu-close {
display: block;
position: relative;
margin-left: auto;
margin-right: 10px;
padding: 0px 12px;
font-size: 33px;
font-weight: 700;
line-height: 33px;
text-decoration: none;
color: #1389ce;
width: 40px;
height: 40px;
cursor: pointer;
-webkit-user-select: none; /* Chrome/Safari */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE10+ */
}
.menu-close:hover {
text-decoration: none;
}
}
/* Hamburger positioning */
@media (max-width:992px) {
#content {
float: right;
width: 100%;
}
#content {
float: right;
width: 100%;
}
}
#content pre {
@ -828,9 +828,9 @@ html {
}
#content pre code {
color:#fff;
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
font-weight:bold;
color:#fff;
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
font-weight:bold;
}
pre .nocode {
@ -900,11 +900,11 @@ li.L1, li.L3, li.L5, li.L7, li.L9 {}
@media print {
#content pre.prettyprint {
background-color: none;
display: block;
background-color: #333;
border-radius:4px;
padding:13px 16px;
margin-bottom:30px;
display: block;
background-color: #333;
border-radius:4px;
padding:13px 16px;
margin-bottom:30px;
}
pre .str,code .str {

View File

@ -219,45 +219,45 @@
.syntaxhighlighter .line.highlighted .number
{
background-color: #ddd !important;
color: black !important;
background-color: #ddd !important;
color: black !important;
}
/* Highlighed line */
.syntaxhighlighter .line.highlighted.alt1 .content,
.syntaxhighlighter .line.highlighted.alt2 .content
{
background-color: #ddd !important;
background-color: #ddd !important;
}
/* Gutter line numbers */
.syntaxhighlighter .line .number
{
color: #aaa !important;
color: #aaa !important;
}
/* Add border to the lines */
.syntaxhighlighter .line .content
{
border-left: 2px solid #ccc !important;
color: #000 !important;
border-left: 2px solid #ccc !important;
color: #000 !important;
}
.syntaxhighlighter.printing .line .content
{
border: 0 !important;
border: 0 !important;
}
/* First line */
.syntaxhighlighter .line.alt1 .content
{
background-color: #fafafa !important;
background-color: #fafafa !important;
}
/* Second line */
.syntaxhighlighter .line.alt2 .content
{
background-color: #fafafa !important;
background-color: #fafafa !important;
}
.syntaxhighlighter .line .content .block
@ -267,53 +267,53 @@
.syntaxhighlighter .ruler
{
color: silver !important;
background-color: #F8F8F8 !important;
border-left: 3px solid #6CE26C !important;
color: silver !important;
background-color: #F8F8F8 !important;
border-left: 3px solid #6CE26C !important;
}
.syntaxhighlighter.nogutter .ruler
{
border: 0 !important;
border: 0 !important;
}
.syntaxhighlighter .toolbar
{
background-color: #ddd !important;
background-color: #ddd !important;
}
.syntaxhighlighter .toolbar a
{
color: #a0a0a0 !important;
color: #a0a0a0 !important;
}
.syntaxhighlighter .toolbar a:hover
{
color: red !important;
color: red !important;
}
.syntaxhighlighter .comments,
.syntaxhighlighter .comments a
{
color: #999988 !important;
font-style: italic !important;
color: #999988 !important;
font-style: italic !important;
line-height: 13px !important;
}
.syntaxhighlighter .string,
.syntaxhighlighter .string a
{
color: #D81745 !important;
color: #D81745 !important;
}
.syntaxhighlighter .keyword
{
font-weight: bold !important;
font-weight: bold !important;
}
.syntaxhighlighter .preprocessor
{
color: gray !important;
color: gray !important;
}
.syntaxhighlighter .regex
@ -338,46 +338,46 @@
.syntaxhighlighter .variable
{
color: #177F80 !important;
color: #177F80 !important;
}
.syntaxhighlighter .value
{
color: red !important;
color: red !important;
}
.syntaxhighlighter .functions
{
color: #990000 !important;
font-weight:bold !important;
color: #990000 !important;
font-weight:bold !important;
}
.syntaxhighlighter .constants
{
color: #177F80 !important;
color: #177F80 !important;
}
.syntaxhighlighter .script
{
background-color: yellow !important;
background-color: yellow !important;
}
.syntaxhighlighter .color1,
.syntaxhighlighter .color1 a
{
color: #177F80 !important;
color: #177F80 !important;
}
.syntaxhighlighter .color2,
.syntaxhighlighter .color2 a
{
color: #960B73 !important;
color: #960B73 !important;
}
.syntaxhighlighter .color3,
.syntaxhighlighter .color3 a
{
color: red !important;
color: red !important;
}
/** end ugliness */

View File

@ -1,36 +1,36 @@
@media screen and (max-width: 540px) {
#content-column {
width: 100%;
padding: 0;
}
#content-column {
width: 100%;
padding: 0;
}
#container {
padding: 15px;
}
#container {
padding: 15px;
}
#sidebar-column {
width: 100%;
}
#sidebar-column {
width: 100%;
}
#sidebar-column .sidebar-box {
padding: 10px;
}
#sidebar-column .sidebar-box {
padding: 10px;
}
#footer {
padding: 20px;
}
#footer {
padding: 20px;
}
.pinned { position: absolute; left: 0; top: 0; background: #fff; width: 35%; overflow: hidden; overflow-x: scroll; border-right: 1px solid #ccc; border-left: 1px solid #ccc; }
.pinned table { border-right: none; border-left: none; width: 100%; }
.pinned table th, .pinned table td { white-space: nowrap; }
.pinned td:last-child { border-bottom: 0; }
div.table-wrapper { position: relative; margin-bottom: 20px; overflow: hidden; border-right: 1px solid #ccc; }
div.table-wrapper div.scrollable table { margin-left: 35%; }
div.table-wrapper div.scrollable { overflow: scroll; overflow-y: hidden; }
table td, table th { position: relative; white-space: nowrap; overflow: hidden; }
table th:first-child, table td:first-child, table td:first-child, .pinned table td { display: none; }
.pinned table td:first-child,
.pinned table th:first-child { display: block; }
.pinned { position: absolute; left: 0; top: 0; background: #fff; width: 35%; overflow: hidden; overflow-x: scroll; border-right: 1px solid #ccc; border-left: 1px solid #ccc; }
.pinned table { border-right: none; border-left: none; width: 100%; }
.pinned table th, .pinned table td { white-space: nowrap; }
.pinned td:last-child { border-bottom: 0; }
div.table-wrapper { position: relative; margin-bottom: 20px; overflow: hidden; border-right: 1px solid #ccc; }
div.table-wrapper div.scrollable table { margin-left: 35%; }
div.table-wrapper div.scrollable { overflow: scroll; overflow-y: hidden; }
table td, table th { position: relative; white-space: nowrap; overflow: hidden; }
table th:first-child, table td:first-child, table td:first-child, .pinned table td { display: none; }
.pinned table td:first-child,
.pinned table th:first-child { display: block; }
}

View File

@ -1,49 +1,49 @@
/*! text selection */
::-moz-selection {
text-shadow:none;
color: #ffffff;
background: #1389CE;
text-shadow:none;
color: #ffffff;
background: #1389CE;
}
::selection {
text-shadow: none;
color: #ffffff;
background: #1389CE;
text-shadow: none;
color: #ffffff;
background: #1389CE;
}
/*! links */
a {
color: #808c8d;
text-decoration: none;
color: #808c8d;
text-decoration: none;
}
a:hover,
a:focus {
text-decoration: underline;
}
a:hover,
a:focus {
text-decoration: underline;
}
a[href$=".pdf"],
a[href$=".PDF"],
a.pdf {
padding: 2px;
padding-left: 20px;
background: url(../../docsviewer/images/icons/page_white_acrobat.png) no-repeat left center;
padding: 2px;
padding-left: 20px;
background: url(../../docsviewer/images/icons/page_white_acrobat.png) no-repeat left center;
}
a[href$=".doc"],
a[href$=".DOC"],
a.doc {
padding: 2px;
padding-left: 20px;
background: url(../../docsviewer/images/icons/page_word.png) no-repeat left center;
padding: 2px;
padding-left: 20px;
background: url(../../docsviewer/images/icons/page_word.png) no-repeat left center;
}
a[href$=".xls"],
a[href$=".XLS"],
a.xls {
padding: 2px;
padding-left: 20px;
background: url(../../docsviewer/images/icons/page_excel.png) no-repeat left center;
padding: 2px;
padding-left: 20px;
background: url(../../docsviewer/images/icons/page_excel.png) no-repeat left center;
}
a[href$=".gz"],
@ -53,136 +53,136 @@ a[href$=".GZIP"],
a[href$=".zip"],
a[href$=".ZIP"],
a.archive {
padding: 2px;
padding-left: 20px;
background: url(../../docsviewer/images/icons/page_white_zip.png) no-repeat left center;
padding: 2px;
padding-left: 20px;
background: url(../../docsviewer/images/icons/page_white_zip.png) no-repeat left center;
}
a[href$=".exe"],
a[href$=".EXE"],
a.application {
padding: 2px;
padding-left: 20px;
background: url(../../docsviewer/images/icons/application.png) no-repeat left center;
padding: 2px;
padding-left: 20px;
background: url(../../docsviewer/images/icons/application.png) no-repeat left center;
}
/*! pargraphs */
p {
font-size: 15px;
line-height: 1.5;
margin: 0 0 25px;
font-size: 15px;
line-height: 1.5;
margin: 0 0 25px;
}
.text-wrap {
word-break: break-all;
word-break: break-all;
}
/*! lists */
ul {
margin: 10px 0 20px 20px;
padding: 0;
margin: 10px 0 20px 20px;
padding: 0;
}
li, dd, li p {
font-size: 15px;
margin: 0 0 10px 0;
line-height: 1.5;
font-size: 15px;
margin: 0 0 10px 0;
line-height: 1.5;
}
li {
list-style-position: inside;
list-style-position: inside;
}
li ul,
li ol {
margin: 0 0 5px 20px;
margin: 0 0 5px 20px;
}
dl {
margin: 7px 0 21px 0;
margin: 7px 0 21px 0;
}
dt {
font-weight: bold;
font-weight: bold;
}
dd {
margin: 5px 0 10px 20px;
margin: 5px 0 10px 20px;
}
.semantic {
list-style: none;
margin: 0;
padding: 0;
list-style: none;
margin: 0;
padding: 0;
}
ul.third {
overflow: hidden;
overflow: hidden;
}
ul.third li {
float: left;
width: 33.3%;
padding-right: 30px;
padding-bottom: 20px;
}
ul.third li {
float: left;
width: 33.3%;
padding-right: 30px;
padding-bottom: 20px;
}
ul.third li:nth-child(3n+1) {
clear: both;
}
ul.third li:nth-child(3n+1) {
clear: both;
}
/*! headers */
h1 {
font-size: 35px;
line-height: 40px;
margin-bottom: 10px;
margin-top: 0;
letter-spacing: -1px;
color:rgb(3, 91, 136);
font-size: 35px;
line-height: 40px;
margin-bottom: 10px;
margin-top: 0;
letter-spacing: -1px;
color:rgb(3, 91, 136);
}
#table-of-contents + p {
font-size: 18px;
line-height: 20px;
}
#table-of-contents + p {
font-size: 18px;
line-height: 20px;
}
h1 + p {
margin-top: 30px;
}
h1 + p {
margin-top: 30px;
}
h2 {
font-size: 28px;
line-height: 30px;
margin: 40px 0 20px;
border-top: 1px solid #eee;
padding-top: 29px;
letter-spacing: -1px;
color: rgb(3, 91, 136);
font-size: 28px;
line-height: 30px;
margin: 40px 0 20px;
border-top: 1px solid #eee;
padding-top: 29px;
letter-spacing: -1px;
color: rgb(3, 91, 136);
}
h3 {
font-size: 20px;
line-height: 20px;
margin: 30px 0 10px;
color: #181c1d;
font-size: 20px;
line-height: 20px;
margin: 30px 0 10px;
color: #181c1d;
}
h4 {
font-size: 16px;
margin-bottom: 14px;
line-height: 21px;
font-size: 16px;
margin-bottom: 14px;
line-height: 21px;
}
h5 {
font-size: 14px;
line-height: 14px;
margin-bottom: 7px;
font-size: 14px;
line-height: 14px;
margin-bottom: 7px;
}
h6 {
font-size: 12px;
line-height: 15px;
margin-bottom: 10px;
font-size: 12px;
line-height: 15px;
margin-bottom: 10px;
}
h1 .heading-anchor-link,
@ -191,167 +191,167 @@ h3 .heading-anchor-link,
h4 .heading-anchor-link,
h5 .heading-anchor-link,
h6 .heading-anchor-link {
display: none;
color: #fff;
text-decoration: none;
display: none;
color: #fff;
text-decoration: none;
}
h1.hover .heading-anchor-link,
h2.hover .heading-anchor-link,
h3.hover .heading-anchor-link,
h4.hover .heading-anchor-link,
h5.hover .heading-anchor-link,
h6.hover .heading-anchor-link,
.heading-anchor-link:hover {
display: inline;
color: #aaa;
}
h1.hover .heading-anchor-link,
h2.hover .heading-anchor-link,
h3.hover .heading-anchor-link,
h4.hover .heading-anchor-link,
h5.hover .heading-anchor-link,
h6.hover .heading-anchor-link,
.heading-anchor-link:hover {
display: inline;
color: #aaa;
}
/*! images */
img {
max-width: 100%;
border: 1px solid #ccc;
padding: 6px;
margin: 10px 0;
border-radius: 3px;
max-width: 100%;
border: 1px solid #ccc;
padding: 6px;
margin: 10px 0;
border-radius: 3px;
}
/*! code */
pre {
margin: 20px 0 30px;
font: 13px/20px Monaco, 'Bitstream Vera Sans Mono', 'Courier New', monospace;
background-color: #f6f7f8;
border: 1px solid #e9eaed;
padding: 14px;
border-radius: 3px;
overflow-x: scroll;
color: #4E5661;
margin: 20px 0 30px;
font: 13px/20px Monaco, 'Bitstream Vera Sans Mono', 'Courier New', monospace;
background-color: #f6f7f8;
border: 1px solid #e9eaed;
padding: 14px;
border-radius: 3px;
overflow-x: scroll;
color: #4E5661;
}
pre code {
background: none;
font-weight: normal;
padding: 0;
}
pre code {
background: none;
font-weight: normal;
padding: 0;
}
code {
font: 13px/15px Monaco, 'Bitstream Vera Sans Mono', Courier, monospace;
background: #ecf0f1;
padding: 2px;
font: 13px/15px Monaco, 'Bitstream Vera Sans Mono', Courier, monospace;
background: #ecf0f1;
padding: 2px;
}
code a {
color: #4E5661;
}
code a {
color: #4E5661;
}
/*! quotes */
blockquote {
margin: 28px 0;
padding: 14px 14px 0 38px;
background: #f8f9fa url(../../docsviewer/images/quote.gif) no-repeat 9px 18px;
overflow: hidden;
margin: 28px 0;
padding: 14px 14px 0 38px;
background: #f8f9fa url(../../docsviewer/images/quote.gif) no-repeat 9px 18px;
overflow: hidden;
}
blockquote h1,
blockquote h2,
blockquote h3,
blockquote h4,
blockquote h5,
blockquote h6 {
font-style: italic;
color: #627871;
}
blockquote h1,
blockquote h2,
blockquote h3,
blockquote h4,
blockquote h5,
blockquote h6 {
font-style: italic;
color: #627871;
}
blockquote h4 {
font-size: 18px;
}
blockquote h4 {
font-size: 18px;
}
blockquote p {
font-style: italic;
font-size: 14px;
color: #667D76;
}
blockquote p {
font-style: italic;
font-size: 14px;
color: #667D76;
}
/*! tables */
table {
border-collapse: collapse;
width: 100%;
background-color: #fafafa;
margin-bottom: 28px;
border: 1px solid #c3cdca;
border-collapse: collapse;
width: 100%;
background-color: #fafafa;
margin-bottom: 28px;
border: 1px solid #c3cdca;
}
table tr:nth-child(even) {
background: #eef4f6;
}
table tr:nth-child(even) {
background: #eef4f6;
}
table caption {
text-align: left;
font-weight: bold;
font-size: 18px;
line-height: 21px;
}
table caption {
text-align: left;
font-weight: bold;
font-size: 18px;
line-height: 21px;
}
table thead {
background: #fafafa;
}
table thead {
background: #fafafa;
}
table thead th {
padding: 7px 10px 6px;
font-size: 15px;
text-align: left;
border-right: 1px solid #c3cdca;
}
table thead th {
padding: 7px 10px 6px;
font-size: 15px;
text-align: left;
border-right: 1px solid #c3cdca;
}
table tbody tr {
border-top: 1px solid #c3cdca;
}
table tbody tr {
border-top: 1px solid #c3cdca;
}
table td {
font-size: 15px;
line-height: 21px;
padding: 7px;
border-right: 1px solid #c3cdca;
}
table td {
font-size: 15px;
line-height: 21px;
padding: 7px;
border-right: 1px solid #c3cdca;
}
/*! Edit Link */
#edit-link {
margin: 30px 0;
margin: 30px 0;
}
#edit-link p {
margin: 0;
overflow: hidden;
}
#edit-link p {
margin: 0;
overflow: hidden;
}
#edit-link a {
display: block;
background: #fafafa;
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#fafafa), color-stop(100%,#e6e6e6));
background: -webkit-linear-gradient(top, #fafafa 1%,#e6e6e6 100%);
background: -webkit-linear-gradient(top, #fafafa 1%, #e6e6e6 100%);
background: linear-gradient(to bottom, #fafafa 1%,#e6e6e6 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fafafa', endColorstr='#e6e6e6',GradientType=0 );
border: 1px solid #d4d4d4;
border-bottom-color: #bcbcbc;
text-shadow: 0 1px 0 #fff;
color: #333;
font-weight: bold;
margin-bottom: 5px;
text-decoration: none;
padding: 5px 10px;
border-radius: 3px;
float: left;
}
#edit-link a {
display: block;
background: #fafafa;
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#fafafa), color-stop(100%,#e6e6e6));
background: -webkit-linear-gradient(top, #fafafa 1%,#e6e6e6 100%);
background: -webkit-linear-gradient(top, #fafafa 1%, #e6e6e6 100%);
background: linear-gradient(to bottom, #fafafa 1%,#e6e6e6 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fafafa', endColorstr='#e6e6e6',GradientType=0 );
border: 1px solid #d4d4d4;
border-bottom-color: #bcbcbc;
text-shadow: 0 1px 0 #fff;
color: #333;
font-weight: bold;
margin-bottom: 5px;
text-decoration: none;
padding: 5px 10px;
border-radius: 3px;
float: left;
}
#edit-link a:hover,
#edit-link a:focus {
color: #fff;
text-shadow: 0 -1px 1px #3072B3;
border-color: #518CC6;
background: #599BDC;
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#3072B3), color-stop(100%,#3072B3));
background: -webkit-linear-gradient(top, #599BDC 1%,#3072B3 100%);
background: -webkit-linear-gradient(top, #599BDC 1%, #3072B3 100%);
background: linear-gradient(to bottom, #599BDC 1%,#3072B3 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#599BDC', endColorstr='#3072B3',GradientType=0 );
}
#edit-link a:hover,
#edit-link a:focus {
color: #fff;
text-shadow: 0 -1px 1px #3072B3;
border-color: #518CC6;
background: #599BDC;
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#3072B3), color-stop(100%,#3072B3));
background: -webkit-linear-gradient(top, #599BDC 1%,#3072B3 100%);
background: -webkit-linear-gradient(top, #599BDC 1%, #3072B3 100%);
background: linear-gradient(to bottom, #599BDC 1%,#3072B3 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#599BDC', endColorstr='#3072B3',GradientType=0 );
}

View File

@ -1,24 +1,24 @@
.clear {
clear: both;
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
clear: both;
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
}
.clearfix:after {
clear: both;
content:' ';
display: block;
font-size: 0;
line-height: 0;
visibility: hidden;
width: 0;
height: 0
clear: both;
content:' ';
display: block;
font-size: 0;
line-height: 0;
visibility: hidden;
width: 0;
height: 0
}
* html .clearfix,
*:first-child+html .clearfix{
zoom: 1;
zoom: 1;
}

View File

@ -1,192 +1,233 @@
;(function($) {
$(document).ready(function() {
$(document).ready(
function() {
// Open sidebar on mobile
$('.menu-open').click(function(){
$('#sidebar').removeClass('hide').addClass('open');
return false;
});
// Close sidebar on mobile
$('.menu-close').click(function(){
$('#sidebar').removeClass('open').addClass('hide');
// Open sidebar on mobile
$('.menu-open').click(
function(){
$('#sidebar').removeClass('hide').addClass('open');
return false;
}
);
// Close sidebar on mobile
$('.menu-close').click(
function(){
$('#sidebar').removeClass('open').addClass('hide');
setTimeout(function() {
$('#sidebar').removeClass('hide');
}, 500);
return false;
});
// Close sidebar by hitting of ESC
$(document).keyup(function(e) {
if (e.keyCode == 27) {
$('#sidebar').removeClass('open');
}
});
setTimeout(
function() {
$('#sidebar').removeClass('hide');
}, 500
);
return false;
}
);
// Close sidebar by hitting of ESC
$(document).keyup(
function(e) {
if (e.keyCode == 27) {
$('#sidebar').removeClass('open');
}
}
);
var switched = false;
var switched = false;
var updateTables = function() {
if (($(window).width() < 540) && !switched ){
switched = true;
var updateTables = function() {
if (($(window).width() < 540) && !switched ) {
switched = true;
$("table").each(function(i, element) {
splitTable($(element));
});
$("table").each(
function(i, element) {
splitTable($(element));
}
);
return true;
}
else if (switched && ($(window).width() > 540)) {
switched = false;
return true;
}
else if (switched && ($(window).width() > 540)) {
switched = false;
$("table").each(function(i, element) {
unsplitTable($(element));
});
}
};
$("table").each(
function(i, element) {
unsplitTable($(element));
}
);
}
};
$(window).load(updateTables);
$(window).on("redraw",function() {
switched = false;
updateTables();
}); // An event to listen for
$(window).load(updateTables);
$(window).on(
"redraw",function() {
switched = false;
updateTables();
}
); // An event to listen for
$(window).on("resize", updateTables);
$(window).on("resize", updateTables);
function splitTable(original) {
original.wrap("<div class='table-wrapper' />");
function splitTable(original) {
original.wrap("<div class='table-wrapper' />");
var copy = original.clone();
copy.find("td:not(:first-child), th:not(:first-child)").css("display", "none");
copy.removeClass("responsive");
var copy = original.clone();
copy.find("td:not(:first-child), th:not(:first-child)").css("display", "none");
copy.removeClass("responsive");
original.closest(".table-wrapper").append(copy);
copy.wrap("<div class='pinned' />");
original.wrap("<div class='scrollable' />");
original.closest(".table-wrapper").append(copy);
copy.wrap("<div class='pinned' />");
original.wrap("<div class='scrollable' />");
setCellHeights(original, copy);
}
setCellHeights(original, copy);
}
function unsplitTable(original) {
original.closest(".table-wrapper").find(".pinned").remove();
original.unwrap();
original.unwrap();
}
function unsplitTable(original) {
original.closest(".table-wrapper").find(".pinned").remove();
original.unwrap();
original.unwrap();
}
function setCellHeights(original, copy) {
var tr = original.find('tr'),
tr_copy = copy.find('tr'),
heights = [];
function setCellHeights(original, copy) {
var tr = original.find('tr'),
tr_copy = copy.find('tr'),
heights = [];
tr.each(function (index) {
var self = $(this),
tx = self.find('th, td');
tr.each(
function (index) {
var self = $(this),
tx = self.find('th, td');
tx.each(function () {
var height = $(this).outerHeight(true);
heights[index] = heights[index] || 0;
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) {
$(this).height(heights[index]);
});
}
tr_copy.each(
function (index) {
$(this).height(heights[index]);
}
);
}
/** -----------------------------------------------
* TABLE OF CONTENTS
*
* Transform a #table-of-contents div to a nested list
*/
if($("#table-contents-holder").length > 0) {
var toc = '<div id="table-of-contents" class="open">' +
'<h4>Table of contents<span class="updown">&#9660;</span></h4><ul style="display: none;">';
/**
* -----------------------------------------------
* TABLE OF CONTENTS
*
* Transform a #table-of-contents div to a nested list
*/
if($("#table-contents-holder").length > 0) {
var toc = '<div id="table-of-contents" class="open">' +
'<h4>Table of contents<span class="updown">&#9660;</span></h4><ul style="display: none;">';
// Remove existing anchor redirection in the url
var pageURL = window.location.href.replace(/#[a-zA-Z0-9\-\_]*/g, '');
// Remove existing anchor redirection in the url
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) {
var current = $(this);
var tagName = current.prop("tagName");
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>';
});
var itemCount = 0;
$('#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();
}
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 no items in the table of contents, don't show anything
if(itemCount == 0) { return false;
}
toc += '</ul></div>';
toc += '</ul></div>';
$('#table-contents-holder').prepend(toc);
$('#table-contents-holder').prepend(toc);
// Toggle the TOC
$('#table-of-contents').attr('href', 'javascript:void()').toggle(
function() {
$("#table-of-contents ul").animate({'height':'show'}, 200, function(){$('#table-of-contents h4 span').html('&#9650;');})
},
function() {
$("#table-of-contents ul").animate({'height':'hide'}, 200, function(){$('#table-of-contents h4 span').html('&#9660;');})
}
);
// Toggle the TOC
$('#table-of-contents').attr('href', 'javascript:void()').toggle(
function() {
$("#table-of-contents ul").animate({'height':'show'}, 200, function(){$('#table-of-contents h4 span').html('&#9650;');})
},
function() {
$("#table-of-contents ul").animate({'height':'hide'}, 200, function(){$('#table-of-contents h4 span').html('&#9660;');})
}
);
// Make sure clicking a link won't toggle the TOC
$("#table-of-contents li a").click(function (e) { e.stopPropagation(); });
// Make sure clicking a link won't toggle the TOC
$("#table-of-contents li a").click(function (e) { e.stopPropagation(); });
}
}
/** ---------------------------------------------
* HEADING ANCHOR LINKS
*
* Automatically adds anchor links to headings that have IDs
*/
var url = window.location.href.replace(/#[a-zA-Z0-9\-\_]*/g, '');
/**
* ---------------------------------------------
* 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() {
var link = '<a class="heading-anchor-link" title="Link to this section" href="'+ url + '#' + $(this).attr('id') + '">&para;</a>';
$(this).append(' ' + link);
});
$("#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() {
$(this).addClass('hover');
});
$("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() {
$(this).removeClass('hover');
});
$("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();
/**
* ---------------------------------------------
* LANGAUGE SELECTER
*
* Hide the change button and do it onclick
*/
$("#Form_LanguageForm .Actions").hide();
$("#Form_LanguageForm select").change(function() {
$("#Form_LanguageForm").submit();
});
$("#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) {
var code = $(elem).find('code[class^=language]');
/**
* ---------------------------------------------
* 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) {
var code = $(elem).find('code[class^=language]');
if(code.length > 0) {
var brush = code.attr('class').replace('language-', '');
$(elem).attr('class', 'prettyprint lang-' + brush);
// $(elem).html(code.html());
}
});
if(code.length > 0) {
var brush = code.attr('class').replace('language-', '');
$(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),
@ -17,9 +18,10 @@ class DocumentationEntityTest extends SapphireTest
* @dataProvider dataCompare
* @param string $left
* @param string $right
* @param int $result
* @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(
'00_file-path.md'
));
$this->assertEquals(
"File path", DocumentationHelper::clean_page_name(
'00_file-path.md'
)
);
}
public function testCleanUrl()
{
$this->assertEquals("some_path", DocumentationHelper::clean_page_url(
'Some Path'
));
$this->assertEquals(
"some_path", DocumentationHelper::clean_page_url(
'Some Path'
)
);
$this->assertEquals("somefilepath", DocumentationHelper::clean_page_url(
'00_SomeFilePath.md'
));
$this->assertEquals(
"somefilepath", DocumentationHelper::clean_page_url(
'00_SomeFilePath.md'
)
);
}
public function testTrimSortNumber()
{
$this->assertEquals('file', DocumentationHelper::trim_sort_number(
'0_file'
));
$this->assertEquals(
'file', DocumentationHelper::trim_sort_number(
'0_file'
)
);
$this->assertEquals('2.1', DocumentationHelper::trim_sort_number(
'2.1'
));
$this->assertEquals(
'2.1', DocumentationHelper::trim_sort_number(
'2.1'
)
);
$this->assertEquals('dev/tasks/2.1', DocumentationHelper::trim_sort_number(
'dev/tasks/2.1'
));
$this->assertEquals(
'dev/tasks/2.1', DocumentationHelper::trim_sort_number(
'dev/tasks/2.1'
)
);
}
public function testTrimExtension()
{
$this->assertEquals('file', DocumentationHelper::trim_extension_off(
'file.md'
));
$this->assertEquals(
'file', DocumentationHelper::trim_extension_off(
'file.md'
)
);
$this->assertEquals('dev/path/file', DocumentationHelper::trim_extension_off(
'dev/path/file.md'
));
$this->assertEquals(
'dev/path/file', DocumentationHelper::trim_extension_off(
'dev/path/file.md'
)
);
}
public function testGetExtension()
{
$this->assertEquals('md', DocumentationHelper::get_extension(
'file.md'
));
$this->assertEquals(
'md', DocumentationHelper::get_extension(
'file.md'
)
);
$this->assertEquals('md', DocumentationHelper::get_extension(
'dev/tasks/file.md'
));
$this->assertEquals(
'md', DocumentationHelper::get_extension(
'dev/tasks/file.md'
)
);
$this->assertEquals('txt', DocumentationHelper::get_extension(
'dev/tasks/file.txt'
));
$this->assertEquals(
'txt', DocumentationHelper::get_extension(
'dev/tasks/file.txt'
)
);
$this->assertNull(DocumentationHelper::get_extension(
'doc_test/2.3'
));
$this->assertNull(
DocumentationHelper::get_extension(
'doc_test/2.3'
)
);
$this->assertNull(DocumentationHelper::get_extension(
'dev/docs/en/doc_test/2.3/subfolder'
));
$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(
DOCSVIEWER_PATH . '/tests/docs/en/subfolder/subsubfolder/subsubpage.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
)->Link);
$this->assertStringEndsWith(
'2.3/test/', $this->manifest->getNextPage(
DOCSVIEWER_PATH . '/tests/docs/en/subfolder/subsubfolder/subsubpage.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
)->Link
);
// after sorting, 2 is shown.
$this->assertContains('/intermediate/', $this->manifest->getNextPage(
DOCSVIEWER_PATH . '/tests/docs/en/sort/01-basic.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
)->Link);
$this->assertContains(
'/intermediate/', $this->manifest->getNextPage(
DOCSVIEWER_PATH . '/tests/docs/en/sort/01-basic.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
)->Link
);
// next gets the following URL
$this->assertContains('/test/', $this->manifest->getNextPage(
DOCSVIEWER_PATH . '/tests/docs-v2.4/en/index.md',
DOCSVIEWER_PATH . '/tests/docs-v2.4/en/'
)->Link);
$this->assertContains(
'/test/', $this->manifest->getNextPage(
DOCSVIEWER_PATH . '/tests/docs-v2.4/en/index.md',
DOCSVIEWER_PATH . '/tests/docs-v2.4/en/'
)->Link
);
// last folder in a entity does not leak
$this->assertNull($this->manifest->getNextPage(
DOCSVIEWER_PATH . '/tests/docs/en/test.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
));
$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(
DOCSVIEWER_PATH . '/tests/docs/en/test.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
)->Link);
$this->assertContains(
'subfolder/subsubfolder/subsubpage', $this->manifest->getPreviousPage(
DOCSVIEWER_PATH . '/tests/docs/en/test.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
)->Link
);
// does not leak between entities
$this->assertNull($this->manifest->getPreviousPage(
DOCSVIEWER_PATH . '/tests/docs/en/index.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
));
$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(
DOCSVIEWER_PATH . ' /tests/docs/en/index.md',
DOCSVIEWER_PATH . '/tests/docs/en/'
));
$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(
DOCSVIEWER_PATH . "/tests/docs/en/"
));
$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(
DOCSVIEWER_PATH . '/tests/docs-v3.0/en/',
DOCSVIEWER_PATH . '/tests/docs-v3.0/en/ChangeLog.md'
));
$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(
Director::absoluteBaseURL(), DOCSVIEWER_DIR, '/tests/docs/en/_images/image.png'
)),
sprintf(
'[parent image link](%s)', Controller::join_links(
Director::absoluteBaseURL(), DOCSVIEWER_DIR, '/tests/docs/en/_images/image.png'
)
),
$result
);
@ -341,17 +343,17 @@ HTML;
array('`[Title](api:DataObject)`','`[Title](api:DataObject)`'),
array('`[Title](api:DataObject::$defaults)`','`[Title](api:DataObject::$defaults)`'),
array('`[Title](api:DataObject::populateDefaults())`','`[Title](api:DataObject::populateDefaults())`'),
array('[api:DataObject]', sprintf($html_format,'DataObject','DataObject')),
array('[api:DataObject::$defaults]',sprintf($html_format,'DataObject::$defaults','DataObject::$defaults')),
array('[api:DataObject::populateDefaults()]',sprintf($html_format,'DataObject::populateDefaults()','DataObject::populateDefaults()')),
array('[Title](api:DataObject)',sprintf($html_format,'DataObject','Title')),
array('[Title](api:DataObject::$defaults)',sprintf($html_format,'DataObject::$defaults','Title')),
array('[Title](api:DataObject::populateDefaults())',sprintf($html_format,'DataObject::populateDefaults()','Title'))
array('[api:DataObject]', sprintf($html_format, 'DataObject', 'DataObject')),
array('[api:DataObject::$defaults]',sprintf($html_format, 'DataObject::$defaults', 'DataObject::$defaults')),
array('[api:DataObject::populateDefaults()]',sprintf($html_format, 'DataObject::populateDefaults()', 'DataObject::populateDefaults()')),
array('[Title](api:DataObject)',sprintf($html_format, 'DataObject', 'Title')),
array('[Title](api:DataObject::$defaults)',sprintf($html_format, 'DataObject::$defaults', 'Title')),
array('[Title](api:DataObject::populateDefaults())',sprintf($html_format, 'DataObject::populateDefaults()', 'Title'))
);
foreach($test_cases as $test_case) {
$expected_html = $test_case[1];
$this->assertContains($expected_html,$parsed_page);
$this->assertContains($expected_html, $parsed_page);
}
}

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

@ -47,12 +47,12 @@ class DocumentationSearchTest extends FunctionalTest
{
$c = new DocumentationOpenSearchController();
$response = $c->handleRequest(new SS_HTTPRequest('GET', ''), DataModel::inst());
// $this->assertEquals(404, $response->getStatusCode());
// $this->assertEquals(404, $response->getStatusCode());
Config::inst()->update('DocumentationSearch', 'enabled', false);
$response = $c->handleRequest(new SS_HTTPRequest('GET', 'description/'), DataModel::inst());
// $this->assertEquals(404, $response->getStatusCode());
// $this->assertEquals(404, $response->getStatusCode());
// test we get a response to the description. The meta data test will
// check that the individual fields are valid but we should check urls
@ -61,9 +61,9 @@ class DocumentationSearchTest extends FunctionalTest
Config::inst()->update('DocumentationSearch', 'enabled', true);
$response = $c->handleRequest(new SS_HTTPRequest('GET', 'description'), DataModel::inst());
// $this->assertEquals(200, $response->getStatusCode());
// $this->assertEquals(200, $response->getStatusCode());
$desc = new SimpleXMLElement($response->getBody());
// $this->assertEquals(2, count($desc->Url));
// $this->assertEquals(2, count($desc->Url));
}
}

View File

@ -4,7 +4,7 @@
* Some of these tests are simply checking that pages load. They should not assume
* somethings working.
*
* @package docsviewer
* @package docsviewer
* @subpackage tests
*/

View File

@ -68,21 +68,21 @@ class DocumentationViewerVersionWarningTest extends SapphireTest
// the current version is set to 2.4, no notice should be shown on that page
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'en/testdocs/'), DataModel::inst());
// $this->assertFalse($v->VersionWarning());
// $this->assertFalse($v->VersionWarning());
// 2.3 is an older release, hitting that should return us an outdated flag
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'en/testdocs/2.3/'), DataModel::inst());
$warn = $v->VersionWarning();
// $this->assertTrue($warn->OutdatedRelease);
// $this->assertNull($warn->FutureRelease);
// $this->assertTrue($warn->OutdatedRelease);
// $this->assertNull($warn->FutureRelease);
// 3.0 is a future release
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'en/testdocs/3.0/'), DataModel::inst());
$warn = $v->VersionWarning();
// $this->assertNull($warn->OutdatedRelease);
// $this->assertTrue($warn->FutureRelease);
// $this->assertNull($warn->OutdatedRelease);
// $this->assertTrue($warn->FutureRelease);
}
}

View File

@ -12,11 +12,11 @@
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Search
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
* @category Zend
* @package Zend_Search
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
@ -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

@ -12,77 +12,121 @@
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Lucene.php 21640 2010-03-24 18:28:32Z alexander $
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Lucene.php 21640 2010-03-24 18:28:32Z alexander $
*/
/** 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';
@ -200,13 +244,15 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
/**
* Create index
*
* @param mixed $directory
* @param mixed $directory
* @return 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));
}
@ -214,21 +260,27 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
/**
* Open index
*
* @param mixed $directory
* @param mixed $directory
* @return 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;
/**
@ -238,7 +290,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
* 0 means pre-2.1 index format
* -1 means there are no segments files.
*
* @param Zend_Search_Lucene_Storage_Directory $directory
* @param Zend_Search_Lucene_Storage_Directory $directory
* @return integer
* @throws Zend_Search_Lucene_Exception
*/
@ -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
@ -319,7 +371,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
/**
* Get segments file name
*
* @param integer $generation
* @param integer $generation
* @return string
*/
public static function getSegmentFileName($generation)
@ -345,15 +397,16 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
* Set index format version.
* Index is converted to this format at the nearest upfdate time
*
* @param int $formatVersion
* @param int $formatVersion
* @throws Zend_Search_Lucene_Exception
*/
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,
$segName,
$segSize);
new Zend_Search_Lucene_Index_SegmentInfo(
$this->_directory,
$segName,
$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,
$segName,
$segSize,
$delGen,
$docStoreOptions,
$hasSingleNormFile,
$isCompound);
new Zend_Search_Lucene_Index_SegmentInfo(
$this->_directory,
$segName,
$segSize,
$delGen,
$docStoreOptions,
$hasSingleNormFile,
$isCompound
);
}
}
@ -502,18 +559,18 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
* IndexReader constructor needs Directory as a parameter. It should be
* a string with a path to the index folder or a Directory object.
*
* @param Zend_Search_Lucene_Storage_Directory_Filesystem|string $directory
* @param Zend_Search_Lucene_Storage_Directory_Filesystem|string $directory
* @throws Zend_Search_Lucene_Exception
*/
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,
$this->_segmentInfos,
$this->_formatVersion);
include_once 'Zend/Search/Lucene/Index/Writer.php';
$this->_writer = new Zend_Search_Lucene_Index_Writer(
$this->_directory,
$this->_segmentInfos,
$this->_formatVersion
);
}
return $this->_writer;
@ -701,14 +760,14 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
/**
* Checks, that document is deleted
*
* @param integer $id
* @param integer $id
* @return boolean
* @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range
*/
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.');
}
@ -911,20 +970,20 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
* of Zend_Search_Lucene_Search_QueryHit objects.
* Input is a string or Zend_Search_Lucene_Search_Query.
*
* @param Zend_Search_Lucene_Search_QueryParser|string $query
* @param Zend_Search_Lucene_Search_QueryParser|string $query
* @return array Zend_Search_Lucene_Search_QueryHit
* @throws Zend_Search_Lucene_Exception
*/
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,12 +999,14 @@ 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);
if( $docScore != 0 ) {
if($docScore != 0 ) {
$hit = new Zend_Search_Lucene_Search_QueryHit($this);
$hit->id = $id;
$hit->score = $docScore;
@ -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,
$ids, SORT_ASC, SORT_NUMERIC,
$hits);
array_multisort(
$scores, SORT_DESC, SORT_NUMERIC,
$ids, SORT_ASC, SORT_NUMERIC,
$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];
@ -1075,7 +1138,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
/**
* Returns a list of all unique field names that exist in this index.
*
* @param boolean $indexed
* @param boolean $indexed
* @return array
*/
public function getFieldNames($indexed = false)
@ -1092,7 +1155,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
* Returns a Zend_Search_Lucene_Document object for the document
* number $id in this index.
*
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @return Zend_Search_Lucene_Document
* @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range
*/
@ -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,
$fdtFile->readString(),
'UTF-8',
true,
$fieldInfo->isIndexed,
$bits & 1 );
$field = new Zend_Search_Lucene_Field(
$fieldInfo->name,
$fdtFile->readString(),
'UTF-8',
true,
$fieldInfo->isIndexed,
$bits & 1
);
} else { // Binary data
$field = new Zend_Search_Lucene_Field($fieldInfo->name,
$fdtFile->readBinary(),
'',
true,
$fieldInfo->isIndexed,
$bits & 1,
true );
$field = new Zend_Search_Lucene_Field(
$fieldInfo->name,
$fdtFile->readBinary(),
'',
true,
$fieldInfo->isIndexed,
$bits & 1,
true
);
}
$doc->addField($field);
@ -1161,7 +1228,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
*
* Is used for query optimization.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_Term $term
* @return boolean
*/
public function hasTerm(Zend_Search_Lucene_Index_Term $term)
@ -1178,8 +1245,8 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
/**
* Returns IDs of all documents containing term.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return array
*/
public function termDocs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
@ -1212,8 +1279,8 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
* It performs the same operation as termDocs, but return result as
* Zend_Search_Lucene_Index_DocsFilter object
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return Zend_Search_Lucene_Index_DocsFilter
*/
public function termDocsFilter(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
@ -1245,8 +1312,8 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
* Returns an array of all term freqs.
* Result array structure: array(docId => freq, ...)
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return integer
*/
public function termFreqs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
@ -1266,8 +1333,8 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
* Returns an array of all term positions in the documents.
* Result array structure: array(docId => array(pos1, pos2, ...), ...)
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return array
*/
public function termPositions(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
@ -1287,7 +1354,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
/**
* Returns the number of documents in this index containing the $term.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_Term $term
* @return integer
*/
public function docFreq(Zend_Search_Lucene_Index_Term $term)
@ -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();
}
@ -1321,8 +1390,8 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
/**
* Returns a normalization factor for "field, document" pair.
*
* @param integer $id
* @param string $fieldName
* @param integer $id
* @param string $fieldName
* @return float
*/
public function norm($id, $fieldName)
@ -1368,7 +1437,7 @@ class Zend_Search_Lucene implements Zend_Search_Lucene_Interface
* Deletes a document from the index.
* $id is an internal document id
*
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @throws Zend_Search_Lucene_Exception
*/
public function delete($id)
@ -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';
}
@ -96,7 +116,7 @@ abstract class Zend_Search_Lucene_Analysis_Analyzer
*
* Tokens are returned in UTF-8 (internal Zend_Search_Lucene encoding)
*
* @param string $data
* @param string $data
* @return array
*/
public function tokenize($data, $encoding = '')
@ -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';
@ -72,7 +82,7 @@ abstract class Zend_Search_Lucene_Analysis_Analyzer_Common extends Zend_Search_L
/**
* Apply filters to the token. Can return null when the token was removed.
*
* @param Zend_Search_Lucene_Analysis_Token $token
* @param Zend_Search_Lucene_Analysis_Token $token
* @return Zend_Search_Lucene_Analysis_Token
*/
public function normalize(Zend_Search_Lucene_Analysis_Token $token)

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,
$this->_bytePosition,
$binStartPos - $this->_bytePosition),
'UTF-8');
iconv_strlen(
substr(
$this->_input,
$this->_bytePosition,
$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,
$this->_bytePosition,
$binStartPos - $this->_bytePosition),
'UTF-8');
iconv_strlen(
substr(
$this->_input,
$this->_bytePosition,
$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';
@ -39,7 +41,7 @@ abstract class Zend_Search_Lucene_Analysis_TokenFilter
/**
* Normalize Token or remove it (if null is returned)
*
* @param Zend_Search_Lucene_Analysis_Token $srcToken
* @param Zend_Search_Lucene_Analysis_Token $srcToken
* @return Zend_Search_Lucene_Analysis_Token
*/
abstract public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken);

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Analysis_TokenFilter */
/**
* Zend_Search_Lucene_Analysis_TokenFilter
*/
require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php';
@ -40,15 +42,16 @@ class Zend_Search_Lucene_Analysis_TokenFilter_LowerCase extends Zend_Search_Luce
/**
* Normalize Token or remove it (if null is returned)
*
* @param Zend_Search_Lucene_Analysis_Token $srcToken
* @param Zend_Search_Lucene_Analysis_Token $srcToken
* @return Zend_Search_Lucene_Analysis_Token
*/
public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
{
$newToken = new Zend_Search_Lucene_Analysis_Token(
strtolower( $srcToken->getTermText() ),
$srcToken->getStartOffset(),
$srcToken->getEndOffset());
strtolower($srcToken->getTermText()),
$srcToken->getStartOffset(),
$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.');
}
}
@ -52,15 +54,16 @@ class Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 extends Zend_Search_
/**
* Normalize Token or remove it (if null is returned)
*
* @param Zend_Search_Lucene_Analysis_Token $srcToken
* @param Zend_Search_Lucene_Analysis_Token $srcToken
* @return Zend_Search_Lucene_Analysis_Token
*/
public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
{
$newToken = new Zend_Search_Lucene_Analysis_Token(
mb_strtolower($srcToken->getTermText(), 'UTF-8'),
$srcToken->getStartOffset(),
$srcToken->getEndOffset());
mb_strtolower($srcToken->getTermText(), 'UTF-8'),
$srcToken->getStartOffset(),
$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;
@ -46,19 +49,21 @@ class Zend_Search_Lucene_Analysis_TokenFilter_ShortWords extends Zend_Search_Luc
/**
* Constructs new instance of this filter.
*
* @param integer $short minimum allowed length of term which passes this filter (default 2)
* @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;
}
/**
* Normalize Token or remove it (if null is returned)
*
* @param Zend_Search_Lucene_Analysis_Token $srcToken
* @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,17 +52,19 @@ 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);
}
/**
* Normalize Token or remove it (if null is returned)
*
* @param Zend_Search_Lucene_Analysis_Token $srcToken
* @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 {
@ -73,27 +78,28 @@ class Zend_Search_Lucene_Analysis_TokenFilter_StopWords extends Zend_Search_Luce
*
* You can call this method one or more times. New stopwords are always added to current set.
*
* @param string $filepath full path for text file with stopwords
* @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)) {
while (!feof($fd)) {
$buffer = trim(fgets($fd));
if (strlen($buffer) > 0 && $buffer[0] != '#') {
$this->_stopSet[$buffer] = 1;
}
}
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';
@ -69,7 +71,7 @@ class Zend_Search_Lucene_Document
/**
* Add a field object to this document.
*
* @param Zend_Search_Lucene_Field $field
* @param Zend_Search_Lucene_Field $field
* @return Zend_Search_Lucene_Document
*/
public function addField(Zend_Search_Lucene_Field $field)
@ -94,13 +96,13 @@ class Zend_Search_Lucene_Document
/**
* Returns Zend_Search_Lucene_Field object for a named field in this document.
*
* @param string $fieldName
* @param string $fieldName
* @return Zend_Search_Lucene_Field
*/
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];
@ -110,7 +112,7 @@ class Zend_Search_Lucene_Document
/**
* Returns the string value of a named field in this document.
*
* @see __get()
* @see __get()
* @return string
*/
public function getFieldValue($fieldName)
@ -121,7 +123,7 @@ class Zend_Search_Lucene_Document
/**
* Returns the string value of a named field in UTF-8 encoding.
*
* @see __get()
* @see __get()
* @return string
*/
public function getFieldUtf8Value($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
*
@ -43,13 +46,14 @@ class Zend_Search_Lucene_Document_Docx extends Zend_Search_Lucene_Document_OpenX
/**
* Object constructor
*
* @param string $fileName
* @param boolean $storeContent
* @param string $fileName
* @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'])
. '/'
. basename($rel['Target']))
));
$contents = simplexml_load_string(
$package->getFromName(
$this->absoluteZipPath(
dirname($rel['Target'])
. '/'
. basename($rel['Target'])
)
)
);
$contents->registerXPathNamespace('w', Zend_Search_Lucene_Document_Docx::SCHEMA_WORDPROCESSINGML);
$paragraphs = $contents->xpath('//w:body/w:p');
@ -89,12 +97,12 @@ class Zend_Search_Lucene_Document_Docx extends Zend_Search_Lucene_Document_OpenX
}
foreach ($runs as $run) {
if ($run->getName() == 'br') {
// Break element
$documentBody[] = ' ';
} else {
$documentBody[] = (string)$run;
}
if ($run->getName() == 'br') {
// Break element
$documentBody[] = ' ';
} else {
$documentBody[] = (string)$run;
}
}
// Add space after each paragraph. So they are not bound together.
@ -135,14 +143,15 @@ class Zend_Search_Lucene_Document_Docx extends Zend_Search_Lucene_Document_OpenX
/**
* Load Docx document from a file
*
* @param string $fileName
* @param boolean $storeContent
* @param string $fileName
* @param boolean $storeContent
* @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

@ -12,11 +12,11 @@
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
@ -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
@ -81,10 +82,10 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
/**
* Object constructor
*
* @param string $data HTML string (may be HTML fragment, )
* @param string $data HTML string (may be HTML fragment, )
* @param boolean $isFile
* @param boolean $storeContent
* @param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag.
* @param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag.
*/
private function __construct($data, $isFile, $storeContent, $defaultEncoding = '')
{
@ -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'),
$metaNode->getAttribute('content'),
'UTF-8'));
$this->addField(
Zend_Search_Lucene_Field::Text(
$metaNode->getAttribute('name'),
$metaNode->getAttribute('content'),
'UTF-8'
)
);
}
$docBody = '';
@ -160,17 +172,17 @@ 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;
}
}
@ -211,7 +223,7 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
* We should exclude scripts, which may be not included into comment tags, CDATA sections,
*
* @param DOMNode $node
* @param string &$text
* @param string &$text
*/
private function _retrieveNodeText(DOMNode $node, &$text)
{
@ -250,9 +262,9 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
/**
* Load HTML document from a string
*
* @param string $data
* @param boolean $storeContent
* @param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag.
* @param string $data
* @param boolean $storeContent
* @param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag.
* @return Zend_Search_Lucene_Document_Html
*/
public static function loadHTML($data, $storeContent = false, $defaultEncoding = '')
@ -263,9 +275,9 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
/**
* Load HTML document from a file
*
* @param string $file
* @param boolean $storeContent
* @param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag.
* @param string $file
* @param boolean $storeContent
* @param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag.
* @return Zend_Search_Lucene_Document_Html
*/
public static function loadHTMLFile($file, $storeContent = false, $defaultEncoding = '')
@ -277,16 +289,18 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
/**
* Highlight text in text node
*
* @param DOMText $node
* @param array $wordsToHighlight
* @param callback $callback Callback method, used to transform (highlighting) text.
* @param array $params Array of additionall callback parameters (first non-optional parameter is a text to transform)
* @param DOMText $node
* @param array $wordsToHighlight
* @param callback $callback Callback method, used to transform (highlighting) text.
* @param array $params Array of additionall callback parameters (first non-optional parameter is a text to transform)
* @throws Zend_Search_Lucene_Exception
*/
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);
@ -345,10 +363,10 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
/**
* highlight words in content of the specified node
*
* @param DOMNode $contextNode
* @param array $wordsToHighlight
* @param callback $callback Callback method, used to transform (highlighting) text.
* @param array $params Array of additionall callback parameters (first non-optional parameter is a text to transform)
* @param DOMNode $contextNode
* @param array $wordsToHighlight
* @param callback $callback Callback method, used to transform (highlighting) text.
* @param array $params Array of additionall callback parameters (first non-optional parameter is a text to transform)
*/
protected function _highlightNodeRecursive(DOMNode $contextNode, $wordsToHighlight, $callback, $params)
{
@ -378,8 +396,8 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
/**
* Standard callback method used to highlight words.
*
* @param string $stringToHighlight
* @return string
* @param string $stringToHighlight
* @return string
* @internal
*/
public function applyColour($stringToHighlight, $colour)
@ -390,8 +408,8 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
/**
* Highlight text with specified color
*
* @param string|array $words
* @param string $colour
* @param string|array $words
* @param string $colour
* @return string
*/
public function highlight($words, $colour = '#66ffff')
@ -404,17 +422,19 @@ class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document
/**
* Highlight text using specified View helper or callback function.
*
* @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 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 (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';
@ -74,7 +76,7 @@ abstract class Zend_Search_Lucene_Document_OpenXml extends Zend_Search_Lucene_Do
/**
* Extract metadata from document
*
* @param ZipArchive $package ZipArchive OpenXML package
* @param ZipArchive $package ZipArchive OpenXML package
* @return array Key-value pairs containing document meta data
*/
protected function extractMetaData(ZipArchive $package)
@ -109,15 +111,17 @@ abstract class Zend_Search_Lucene_Document_OpenXml extends Zend_Search_Lucene_Do
/**
* Determine absolute zip path
*
* @param string $path
* @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';
/**
@ -66,14 +68,14 @@ class Zend_Search_Lucene_Document_Pptx extends Zend_Search_Lucene_Document_OpenX
/**
* Object constructor
*
* @param string $fileName
* @param boolean $storeContent
* @param string $fileName
* @param boolean $storeContent
* @throws Zend_Search_Lucene_Exception
*/
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,28 +92,28 @@ 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);
foreach ($relations->Relationship as $rel) {
if ($rel["Type"] == Zend_Search_Lucene_Document_OpenXml::SCHEMA_OFFICEDOCUMENT) {
// Found office document! Search for slides...
$slideRelations = simplexml_load_string($package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/_rels/" . basename($rel["Target"]) . ".rels")) );
$slideRelations = simplexml_load_string($package->getFromName($this->absoluteZipPath(dirname($rel["Target"]) . "/_rels/" . basename($rel["Target"]) . ".rels")));
foreach ($slideRelations->Relationship as $slideRel) {
if ($slideRel["Type"] == Zend_Search_Lucene_Document_Pptx::SCHEMA_SLIDERELATION) {
// Found slide!
$slides[ str_replace( 'rId', '', (string)$slideRel["Id"] ) ] = simplexml_load_string(
$package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/" . dirname($slideRel["Target"]) . "/" . basename($slideRel["Target"])) )
$slides[ str_replace('rId', '', (string)$slideRel["Id"]) ] = simplexml_load_string(
$package->getFromName($this->absoluteZipPath(dirname($rel["Target"]) . "/" . dirname($slideRel["Target"]) . "/" . basename($slideRel["Target"])))
);
// Search for slide notes
$slideNotesRelations = simplexml_load_string($package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/" . dirname($slideRel["Target"]) . "/_rels/" . basename($slideRel["Target"]) . ".rels")) );
$slideNotesRelations = simplexml_load_string($package->getFromName($this->absoluteZipPath(dirname($rel["Target"]) . "/" . dirname($slideRel["Target"]) . "/_rels/" . basename($slideRel["Target"]) . ".rels")));
foreach ($slideNotesRelations->Relationship as $slideNoteRel) {
if ($slideNoteRel["Type"] == Zend_Search_Lucene_Document_Pptx::SCHEMA_SLIDENOTESRELATION) {
// Found slide notes!
$slideNotes[ str_replace( 'rId', '', (string)$slideRel["Id"] ) ] = simplexml_load_string(
$package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/" . dirname($slideRel["Target"]) . "/" . dirname($slideNoteRel["Target"]) . "/" . basename($slideNoteRel["Target"])) )
$slideNotes[ str_replace('rId', '', (string)$slideRel["Id"]) ] = simplexml_load_string(
$package->getFromName($this->absoluteZipPath(dirname($rel["Target"]) . "/" . dirname($slideRel["Target"]) . "/" . dirname($slideNoteRel["Target"]) . "/" . basename($slideNoteRel["Target"])))
);
break;
@ -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'));
}
}
@ -189,8 +190,8 @@ class Zend_Search_Lucene_Document_Pptx extends Zend_Search_Lucene_Document_OpenX
/**
* Load Pptx document from a file
*
* @param string $fileName
* @param boolean $storeContent
* @param string $fileName
* @param boolean $storeContent
* @return Zend_Search_Lucene_Document_Pptx
*/
public static function loadPptxFile($fileName, $storeContent = false)

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,14 +75,14 @@ class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenX
/**
* Object constructor
*
* @param string $fileName
* @param boolean $storeContent
* @param string $fileName
* @param boolean $storeContent
* @throws Zend_Search_Lucene_Exception
*/
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,20 +99,20 @@ 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);
foreach ($relations->Relationship as $rel) {
if ($rel["Type"] == Zend_Search_Lucene_Document_OpenXml::SCHEMA_OFFICEDOCUMENT) {
// Found office document! Read relations for workbook...
$workbookRelations = simplexml_load_string($package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/_rels/" . basename($rel["Target"]) . ".rels")) );
$workbookRelations = simplexml_load_string($package->getFromName($this->absoluteZipPath(dirname($rel["Target"]) . "/_rels/" . basename($rel["Target"]) . ".rels")));
$workbookRelations->registerXPathNamespace("rel", Zend_Search_Lucene_Document_OpenXml::SCHEMA_RELATIONSHIP);
// Read shared strings
$sharedStringsPath = $workbookRelations->xpath("rel:Relationship[@Type='" . Zend_Search_Lucene_Document_Xlsx::SCHEMA_SHAREDSTRINGS . "']");
$sharedStringsPath = (string)$sharedStringsPath[0]['Target'];
$xmlStrings = simplexml_load_string($package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/" . $sharedStringsPath)) );
$xmlStrings = simplexml_load_string($package->getFromName($this->absoluteZipPath(dirname($rel["Target"]) . "/" . $sharedStringsPath)));
if (isset($xmlStrings) && isset($xmlStrings->si)) {
foreach ($xmlStrings->si as $val) {
if (isset($val->t)) {
@ -124,8 +126,8 @@ class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenX
// Loop relations for workbook and extract worksheets...
foreach ($workbookRelations->Relationship as $workbookRelation) {
if ($workbookRelation["Type"] == Zend_Search_Lucene_Document_Xlsx::SCHEMA_WORKSHEETRELATION) {
$worksheets[ str_replace( 'rId', '', (string)$workbookRelation["Id"]) ] = simplexml_load_string(
$package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/" . dirname($workbookRelation["Target"]) . "/" . basename($workbookRelation["Target"])) )
$worksheets[ str_replace('rId', '', (string)$workbookRelation["Id"]) ] = simplexml_load_string(
$package->getFromName($this->absoluteZipPath(dirname($rel["Target"]) . "/" . dirname($workbookRelation["Target"]) . "/" . basename($workbookRelation["Target"])))
);
}
}
@ -144,55 +146,56 @@ class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenX
// Determine data type
$dataType = (string)$c["t"];
switch ($dataType) {
case "s":
// Value is a shared string
if ((string)$c->v != '') {
$value = $sharedStrings[intval($c->v)];
} else {
$value = '';
}
case "s":
// Value is a shared string
if ((string)$c->v != '') {
$value = $sharedStrings[intval($c->v)];
} else {
$value = '';
}
break;
break;
case "b":
// Value is boolean
case "b":
// Value is boolean
$value = (string)$c->v;
if ($value == '0') {
$value = false;
} else if ($value == '1') {
$value = true;
} else {
$value = (bool)$c->v;
}
break;
case "inlineStr":
// Value is rich text inline
$value = $this->_parseRichText($c->is);
break;
case "e":
// Value is an error message
if ((string)$c->v != '') {
$value = (string)$c->v;
if ($value == '0') {
$value = false;
} else if ($value == '1') {
$value = true;
} else {
$value = (bool)$c->v;
}
break;
case "inlineStr":
// Value is rich text inline
$value = $this->_parseRichText($c->is);
break;
case "e":
// Value is an error message
if ((string)$c->v != '') {
$value = (string)$c->v;
} else {
$value = '';
}
break;
default:
// Value is a string
$value = (string)$c->v;
// 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;
} else {
$value = '';
}
break;
default:
// Value is a string
$value = (string)$c->v;
// 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;
}
}
}
$documentBody[] = $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'));
}
}
@ -232,10 +234,11 @@ class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenX
/**
* Parse rich text XML
*
* @param SimpleXMLElement $is
* @param SimpleXMLElement $is
* @return string
*/
private function _parseRichText($is = null) {
private function _parseRichText($is = null)
{
$value = array();
if (isset($is->t)) {
@ -252,8 +255,8 @@ class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenX
/**
* Load Xlsx document from a file
*
* @param string $fileName
* @param boolean $storeContent
* @param string $fileName
* @param boolean $storeContent
* @return Zend_Search_Lucene_Document_Xlsx
*/
public static function loadXlsxFile($fileName, $storeContent = false)

View File

@ -12,11 +12,11 @@
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
@ -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

@ -12,14 +12,16 @@
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: FSM.php 20096 2010-01-06 02:05:09Z bkarwin $
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @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';
/**
@ -31,10 +33,10 @@ require_once 'Zend/Search/Lucene/FSMAction.php';
* process() methods invokes a specified actions which may construct FSM output.
* Actions may be also used to signal, that we have reached Accept State
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Search_Lucene_FSM
{
@ -171,13 +173,13 @@ abstract class Zend_Search_Lucene_FSM
* Set FSM state.
* No any action is invoked
*
* @param integer|string $state
* @param integer|string $state
* @throws Zend_Search_Exception
*/
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.');
}
@ -239,24 +241,24 @@ abstract class Zend_Search_Lucene_FSM
/**
* Add symbol to the input alphabet
*
* @param integer|string $sourceState
* @param integer|string $input
* @param integer|string $targetState
* @param Zend_Search_Lucene_FSMAction|null $inputAction
* @param integer|string $sourceState
* @param integer|string $input
* @param integer|string $targetState
* @param Zend_Search_Lucene_FSMAction|null $inputAction
* @throws Zend_Search_Exception
*/
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.');
}
@ -282,13 +284,13 @@ abstract class Zend_Search_Lucene_FSM
* Several entry actions are allowed.
* Action execution order is defined by addEntryAction() calls
*
* @param integer|string $state
* @param integer|string $state
* @param Zend_Search_Lucene_FSMAction $action
*/
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. ').');
}
@ -304,13 +306,13 @@ abstract class Zend_Search_Lucene_FSM
* Several exit actions are allowed.
* Action execution order is defined by addEntryAction() calls
*
* @param integer|string $state
* @param integer|string $state
* @param Zend_Search_Lucene_FSMAction $action
*/
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. ').');
}
@ -326,18 +328,18 @@ abstract class Zend_Search_Lucene_FSM
* Several input actions are allowed.
* Action execution order is defined by addInputAction() calls
*
* @param integer|string $state
* @param integer|string $input
* @param integer|string $state
* @param integer|string $input
* @param Zend_Search_Lucene_FSMAction $action
*/
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. ').');
}
@ -356,18 +358,18 @@ abstract class Zend_Search_Lucene_FSM
* Several transition actions are allowed.
* Action execution order is defined by addTransitionAction() calls
*
* @param integer|string $sourceState
* @param integer|string $targetState
* @param integer|string $sourceState
* @param integer|string $targetState
* @param Zend_Search_Lucene_FSMAction $action
*/
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. ').');
}
@ -385,17 +387,17 @@ abstract class Zend_Search_Lucene_FSM
/**
* Process an input
*
* @param mixed $input
* @param mixed $input
* @throws Zend_Search_Exception
*/
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

@ -12,22 +12,21 @@
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: FSMAction.php 20096 2010-01-06 02:05:09Z bkarwin $
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: FSMAction.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* Abstract Finite State Machine
*
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @category Zend
* @package Zend_Search_Lucene
* @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_FSMAction
{

View File

@ -103,9 +103,9 @@ class Zend_Search_Lucene_Field
/**
* Object constructor
*
* @param string $name
* @param string $value
* @param string $encoding
* @param string $name
* @param string $value
* @param string $encoding
* @param boolean $isStored
* @param boolean $isIndexed
* @param boolean $isTokenized
@ -137,9 +137,9 @@ class Zend_Search_Lucene_Field
* Constructs a String-valued Field that is not tokenized, but is indexed
* and stored. Useful for non-text fields, e.g. date or url.
*
* @param string $name
* @param string $value
* @param string $encoding
* @param string $name
* @param string $value
* @param string $encoding
* @return Zend_Search_Lucene_Field
*/
public static function keyword($name, $value, $encoding = '')
@ -152,9 +152,9 @@ class Zend_Search_Lucene_Field
* Constructs a String-valued Field that is not tokenized nor indexed,
* but is stored in the index, for return with hits.
*
* @param string $name
* @param string $value
* @param string $encoding
* @param string $name
* @param string $value
* @param string $encoding
* @return Zend_Search_Lucene_Field
*/
public static function unIndexed($name, $value, $encoding = '')
@ -167,9 +167,9 @@ class Zend_Search_Lucene_Field
* Constructs a Binary String valued Field that is not tokenized nor indexed,
* but is stored in the index, for return with hits.
*
* @param string $name
* @param string $value
* @param string $encoding
* @param string $name
* @param string $value
* @param string $encoding
* @return Zend_Search_Lucene_Field
*/
public static function binary($name, $value)
@ -182,9 +182,9 @@ class Zend_Search_Lucene_Field
* and is stored in the index, for return with hits. Useful for short text
* fields, like "title" or "subject". Term vector will not be stored for this field.
*
* @param string $name
* @param string $value
* @param string $encoding
* @param string $name
* @param string $value
* @param string $encoding
* @return Zend_Search_Lucene_Field
*/
public static function text($name, $value, $encoding = '')
@ -197,9 +197,9 @@ class Zend_Search_Lucene_Field
* Constructs a String-valued Field that is tokenized and indexed,
* but that is not stored in the index.
*
* @param string $name
* @param string $value
* @param string $encoding
* @param string $name
* @param string $value
* @param string $encoding
* @return Zend_Search_Lucene_Field
*/
public static function unStored($name, $value, $encoding = '')
@ -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
@ -44,7 +43,7 @@ class Zend_Search_Lucene_Index_DictionaryLoader
*
* See Zend_Search_Lucene_Index_SegmintInfo class for details
*
* @param string $data
* @param string $data
* @return array
* @throws Zend_Search_Lucene_Exception
*/
@ -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,14 +74,15 @@ 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');
}
}
$indexTermCount = ord($data[$pos+4]) << 24 |
ord($data[$pos+5]) << 16 |
@ -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,11 +150,12 @@ 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);
$termSuffix = substr($termSuffix, 0, $count1+1)
. substr($termSuffix, $count1+2);
}
$count1 += $addBytes;
}
@ -218,7 +220,7 @@ class Zend_Search_Lucene_Index_DictionaryLoader
}
$proxPointer += $vint;
if( $docFreq >= $skipInterval ) {
if($docFreq >= $skipInterval ) {
// $skipDelta = $tiiFile->readVInt();
$nbyte = ord($data[$pos++]);
$vint = $nbyte & 0x7F;
@ -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';
@ -78,12 +80,14 @@ class Zend_Search_Lucene_Index_SegmentMerger
* and $name as a name of new segment
*
* @param Zend_Search_Lucene_Storage_Directory $directory
* @param string $name
* @param string $name
*/
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,
$fdtFile->readString(),
'UTF-8',
true,
$fieldInfo->isIndexed,
$bits & 1 );
new Zend_Search_Lucene_Field(
$fieldInfo->name,
$fdtFile->readString(),
'UTF-8',
true,
$fieldInfo->isIndexed,
$bits & 1
);
} else { // Binary data
$storedFields[] =
new Zend_Search_Lucene_Field($fieldInfo->name,
$fdtFile->readBinary(),
'',
true,
$fieldInfo->isIndexed,
$bits & 1,
true);
new Zend_Search_Lucene_Field(
$fieldInfo->name,
$fdtFile->readBinary(),
'',
true,
$fieldInfo->isIndexed,
$bits & 1,
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';
/**
@ -145,7 +151,7 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
* Object constructor.
*
* @param Zend_Search_Lucene_Storage_Directory $directory
* @param string $name
* @param string $name
*/
public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $name)
{
@ -159,7 +165,7 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
*
* Returns actual field number
*
* @param Zend_Search_Lucene_Field $field
* @param Zend_Search_Lucene_Field $field
* @return integer
*/
public function addField(Zend_Search_Lucene_Field $field)
@ -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,
$field->isIndexed,
$fieldNumber,
$field->storeTermVector);
new Zend_Search_Lucene_Index_FieldInfo(
$field->name,
$field->isIndexed,
$fieldNumber,
$field->storeTermVector
);
return $fieldNumber;
} else {
@ -186,7 +194,7 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
*
* Returns actual field number
*
* @param Zend_Search_Lucene_Index_FieldInfo $fieldInfo
* @param Zend_Search_Lucene_Index_FieldInfo $fieldInfo
* @return integer
*/
public function addFieldInfo(Zend_Search_Lucene_Index_FieldInfo $fieldInfo)
@ -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,
$fieldInfo->isIndexed,
$fieldNumber,
$fieldInfo->storeTermVector);
new Zend_Search_Lucene_Index_FieldInfo(
$fieldInfo->name,
$fieldInfo->isIndexed,
$fieldNumber,
$fieldInfo->storeTermVector
);
return $fieldNumber;
} else {
@ -288,11 +298,12 @@ 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 */ |
);
// not supported yet 0x04 /* term positions are stored with the term vectors */ |
// not supported yet 0x08 /* term offsets are stored with the term vectors */ |
);
if ($field->isIndexed) {
// pre-2.1 index mode (not used now)
@ -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
@ -434,7 +447,7 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
* Term positions is an array( docId => array(pos1, pos2, pos3, ...), ... )
*
* @param Zend_Search_Lucene_Index_Term $termEntry
* @param array $termDocs
* @param array $termDocs
*/
public function addTerm($termEntry, $termDocs)
{
@ -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);
@ -505,16 +522,17 @@ abstract class Zend_Search_Lucene_Index_SegmentWriter
* Dump Term Dictionary segment file entry.
* Used to write entry to .tis or .tii files
*
* @param Zend_Search_Lucene_Storage_File $dicFile
* @param Zend_Search_Lucene_Index_Term $prevTerm
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Storage_File $dicFile
* @param Zend_Search_Lucene_Index_Term $prevTerm
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_TermInfo $prevTermInfo
* @param Zend_Search_Lucene_Index_TermInfo $termInfo
*/
protected function _dumpTermDictEntry(Zend_Search_Lucene_Storage_File $dicFile,
&$prevTerm, Zend_Search_Lucene_Index_Term $term,
&$prevTermInfo, Zend_Search_Lucene_Index_TermInfo $termInfo)
{
&$prevTerm, Zend_Search_Lucene_Index_Term $term,
&$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';
/**
@ -52,7 +54,7 @@ class Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter extends Zend_Search_
* Object constructor.
*
* @param Zend_Search_Lucene_Storage_Directory $directory
* @param string $name
* @param string $name
*/
public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $name)
{
@ -66,13 +68,15 @@ class Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter extends Zend_Search_
/**
* Adds a document to this segment.
*
* @param Zend_Search_Lucene_Document $document
* @param Zend_Search_Lucene_Document $document
* @throws Zend_Search_Lucene_Exception
*/
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,14 +182,16 @@ 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])){
if (isset($docNorms[$fieldName])) {
$this->_norms[$fieldName] .= $docNorms[$fieldName];
} else {
$this->_norms[$fieldName] .= chr($similarity->encodeNorm( $similarity->lengthNorm($fieldName, 0) ));
$this->_norms[$fieldName] .= chr($similarity->encodeNorm($similarity->lengthNorm($fieldName, 0)));
}
}
@ -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,
$this->_name,
$this->_docCount,
-1,
null,
true,
true);
return new Zend_Search_Lucene_Index_SegmentInfo(
$this->_directory,
$this->_name,
$this->_docCount,
-1,
null,
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';
/**
@ -36,7 +38,7 @@ class Zend_Search_Lucene_Index_SegmentWriter_StreamWriter extends Zend_Search_Lu
* Object constructor.
*
* @param Zend_Search_Lucene_Storage_Directory $directory
* @param string $name
* @param string $name
*/
public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $name)
{
@ -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,
$this->_name,
$this->_docCount,
-1,
null,
true,
true);
return new Zend_Search_Lucene_Index_SegmentInfo(
$this->_directory,
$this->_name,
$this->_docCount,
-1,
null,
true,
true
);
}
}

View File

@ -75,8 +75,8 @@ class Zend_Search_Lucene_Index_Term
/**
* Get term prefix
*
* @param string $str
* @param integer $length
* @param string $str
* @param integer $length
* @return string
*/
public static function getPrefix($str, $length)
@ -110,7 +110,7 @@ class Zend_Search_Lucene_Index_Term
/**
* Get UTF-8 string length
*
* @param string $str
* @param string $str
* @return string
*/
public static function getLength($str)

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';
/**
@ -37,8 +39,8 @@ class Zend_Search_Lucene_Index_TermsPriorityQueue extends Zend_Search_Lucene_Pri
*
* Returns true, if $termsStream1 is "less" than $termsStream2; else otherwise
*
* @param mixed $termsStream1
* @param mixed $termsStream2
* @param mixed $termsStream1
* @param mixed $termsStream2
* @return boolean
*/
protected function _less($termsStream1, $termsStream2)

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_LockManager */
/**
* Zend_Search_Lucene_LockManager
*/
require_once 'Zend/Search/Lucene/LockManager.php';
@ -161,20 +163,21 @@ class Zend_Search_Lucene_Index_Writer
* Create empty index
*
* @param Zend_Search_Lucene_Storage_Directory $directory
* @param integer $generation
* @param integer $nameCount
* @param integer $generation
* @param integer $nameCount
*/
public static function createIndex(Zend_Search_Lucene_Storage_Directory $directory, $generation, $nameCount)
{
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);
}
}
}
$segmentsFile = $directory->createFile('segments');
@ -216,9 +219,9 @@ class Zend_Search_Lucene_Index_Writer
* Open the index for writing
*
* @param Zend_Search_Lucene_Storage_Directory $directory
* @param array $segmentInfos
* @param integer $targetFormatVersion
* @param Zend_Search_Lucene_Storage_File $cleanUpLock
* @param array $segmentInfos
* @param integer $targetFormatVersion
* @param Zend_Search_Lucene_Storage_File $cleanUpLock
*/
public function __construct(Zend_Search_Lucene_Storage_Directory $directory, &$segmentInfos, $targetFormatVersion)
{
@ -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,
$segName,
$segSize,
$delGen,
$docStoreOptions,
$hasSingleNormFile,
$isCompound);
new Zend_Search_Lucene_Index_SegmentInfo(
$this->_directory,
$segName,
$segSize,
$delGen,
$docStoreOptions,
$hasSingleNormFile,
$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,
$filesNumbers, SORT_ASC, SORT_NUMERIC,
$filesToDelete, SORT_ASC, SORT_STRING);
array_multisort(
$filesTypes, SORT_ASC, SORT_NUMERIC,
$filesNumbers, SORT_ASC, SORT_NUMERIC,
$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);
}
@ -768,7 +790,7 @@ class Zend_Search_Lucene_Index_Writer
/**
* Merges the provided indexes into this index.
*
* @param array $readers
* @param array $readers
* @return void
*/
public function addIndexes($readers)

View File

@ -12,27 +12,37 @@
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Interface.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';
/** 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';
@ -51,7 +61,7 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
* 0 means pre-2.1 index format
* -1 means there are no segments files.
*
* @param Zend_Search_Lucene_Storage_Directory $directory
* @param Zend_Search_Lucene_Storage_Directory $directory
* @return integer
* @throws Zend_Search_Lucene_Exception
*/
@ -60,7 +70,7 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
/**
* Get segments file name
*
* @param integer $generation
* @param integer $generation
* @return string
*/
public static function getSegmentFileName($generation);
@ -76,7 +86,7 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
* Set index format version.
* Index is converted to this format at the nearest upfdate time
*
* @param int $formatVersion
* @param int $formatVersion
* @throws Zend_Search_Lucene_Exception
*/
public function setFormatVersion($formatVersion);
@ -114,7 +124,7 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
/**
* Checks, that document is deleted
*
* @param integer $id
* @param integer $id
* @return boolean
* @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range
*/
@ -253,7 +263,7 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
* of Zend_Search_Lucene_Search_QueryHit objects.
* Input is a string or Zend_Search_Lucene_Search_Query.
*
* @param mixed $query
* @param mixed $query
* @return array Zend_Search_Lucene_Search_QueryHit
* @throws Zend_Search_Lucene_Exception
*/
@ -262,7 +272,7 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
/**
* Returns a list of all unique field names that exist in this index.
*
* @param boolean $indexed
* @param boolean $indexed
* @return array
*/
public function getFieldNames($indexed = false);
@ -271,7 +281,7 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
* Returns a Zend_Search_Lucene_Document object for the document
* number $id in this index.
*
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @return Zend_Search_Lucene_Document
*/
public function getDocument($id);
@ -281,7 +291,7 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
*
* Is used for query optimization.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_Term $term
* @return boolean
*/
public function hasTerm(Zend_Search_Lucene_Index_Term $term);
@ -289,8 +299,8 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
/**
* Returns IDs of all the documents containing term.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return array
*/
public function termDocs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null);
@ -301,8 +311,8 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
* It performs the same operation as termDocs, but return result as
* Zend_Search_Lucene_Index_DocsFilter object
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return Zend_Search_Lucene_Index_DocsFilter
*/
public function termDocsFilter(Zend_Search_Lucene_Index_Term $term, $docsFilter = null);
@ -311,8 +321,8 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
* Returns an array of all term freqs.
* Return array structure: array( docId => freq, ...)
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return integer
*/
public function termFreqs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null);
@ -321,8 +331,8 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
* Returns an array of all term positions in the documents.
* Return array structure: array( docId => array( pos1, pos2, ...), ...)
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return array
*/
public function termPositions(Zend_Search_Lucene_Index_Term $term, $docsFilter = null);
@ -330,7 +340,7 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
/**
* Returns the number of documents in this index containing the $term.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_Term $term
* @return integer
*/
public function docFreq(Zend_Search_Lucene_Index_Term $term);
@ -345,8 +355,8 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
/**
* Returns a normalization factor for "field, document" pair.
*
* @param integer $id
* @param string $fieldName
* @param integer $id
* @param string $fieldName
* @return float
*/
public function norm($id, $fieldName);
@ -362,7 +372,7 @@ interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStr
* Deletes a document from the index.
* $id is an internal document id
*
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @throws Zend_Search_Lucene_Exception
*/
public function delete($id);

View File

@ -12,26 +12,30 @@
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: LockManager.php 20096 2010-01-06 02:05:09Z bkarwin $
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @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';
/**
* This is an utility class which provides index locks processing functionality
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @category Zend
* @package Zend_Search_Lucene
* @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_LockManager
{
@ -46,7 +50,7 @@ class Zend_Search_Lucene_LockManager
/**
* Obtain exclusive write lock on the index
*
* @param Zend_Search_Lucene_Storage_Directory $lockDirectory
* @param Zend_Search_Lucene_Storage_Directory $lockDirectory
* @return Zend_Search_Lucene_Storage_File
* @throws Zend_Search_Lucene_Exception
*/
@ -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;
@ -91,7 +95,7 @@ class Zend_Search_Lucene_LockManager
* of opportunity for another process to gain an exclusive lock when
* it shoudln't be allowed to).
*
* @param Zend_Search_Lucene_Storage_Directory $lockDirectory
* @param Zend_Search_Lucene_Storage_Directory $lockDirectory
* @return Zend_Search_Lucene_Storage_File
* @throws Zend_Search_Lucene_Exception
*/
@ -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;
@ -125,7 +129,7 @@ class Zend_Search_Lucene_LockManager
*
* It doesn't block other read or update processes, but prevent index from the premature cleaning-up
*
* @param Zend_Search_Lucene_Storage_Directory $defaultLockDirectory
* @param Zend_Search_Lucene_Storage_Directory $defaultLockDirectory
* @return Zend_Search_Lucene_Storage_File
* @throws Zend_Search_Lucene_Exception
*/
@ -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;
@ -153,7 +157,7 @@ class Zend_Search_Lucene_LockManager
/**
* Escalate Read lock to exclusive level
*
* @param Zend_Search_Lucene_Storage_Directory $lockDirectory
* @param Zend_Search_Lucene_Storage_Directory $lockDirectory
* @return boolean
*/
public static function escalateReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
@ -210,7 +214,7 @@ class Zend_Search_Lucene_LockManager
*
* Returns lock object on success and false otherwise (doesn't block execution)
*
* @param Zend_Search_Lucene_Storage_Directory $lockDirectory
* @param Zend_Search_Lucene_Storage_Directory $lockDirectory
* @return mixed
*/
public static function obtainOptimizationLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)

View File

@ -12,24 +12,26 @@
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: MultiSearcher.php 20096 2010-01-06 02:05:09Z bkarwin $
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: MultiSearcher.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Search_Lucene_Interface */
/**
* Zend_Search_Lucene_Interface
*/
require_once 'Zend/Search/Lucene/Interface.php';
/**
* Multisearcher allows to search through several independent indexes.
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @category Zend
* @package Zend_Search_Lucene
* @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_Interface_MultiSearcher implements Zend_Search_Lucene_Interface
{
@ -44,7 +46,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
/**
* Object constructor.
*
* @param array $indices Arrays of indices for search
* @param array $indices Arrays of indices for search
* @throws Zend_Search_Lucene_Exception
*/
public function __construct($indices = array())
@ -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.');
}
}
@ -77,20 +79,20 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
* 0 means pre-2.1 index format
* -1 means there are no segments files.
*
* @param Zend_Search_Lucene_Storage_Directory $directory
* @param Zend_Search_Lucene_Storage_Directory $directory
* @return integer
* @throws Zend_Search_Lucene_Exception
*/
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");
}
/**
* Get segments file name
*
* @param integer $generation
* @param integer $generation
* @return string
*/
public static function getSegmentFileName($generation)
@ -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");
}
@ -181,7 +183,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
/**
* Checks, that document is deleted
*
* @param integer $id
* @param integer $id
* @return boolean
* @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range
*/
@ -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.');
}
}
@ -450,7 +452,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
* of Zend_Search_Lucene_Search_QueryHit objects.
* Input is a string or Zend_Search_Lucene_Search_Query.
*
* @param mixed $query
* @param mixed $query
* @return array Zend_Search_Lucene_Search_QueryHit
* @throws Zend_Search_Lucene_Exception
*/
@ -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);
}
@ -484,7 +488,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
/**
* Returns a list of all unique field names that exist in this index.
*
* @param boolean $indexed
* @param boolean $indexed
* @return array
*/
public function getFieldNames($indexed = false)
@ -502,7 +506,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
* Returns a Zend_Search_Lucene_Document object for the document
* number $id in this index.
*
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @return Zend_Search_Lucene_Document
* @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range
*/
@ -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.');
}
@ -532,7 +536,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
*
* Is used for query optimization.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_Term $term
* @return boolean
*/
public function hasTerm(Zend_Search_Lucene_Index_Term $term)
@ -549,15 +553,15 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
/**
* Returns IDs of all the documents containing term.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return array
* @throws Zend_Search_Lucene_Exception
*/
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');
}
@ -586,14 +590,14 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
* It performs the same operation as termDocs, but return result as
* Zend_Search_Lucene_Index_DocsFilter object
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return Zend_Search_Lucene_Index_DocsFilter
* @throws Zend_Search_Lucene_Exception
*/
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');
}
@ -601,15 +605,15 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
* Returns an array of all term freqs.
* Return array structure: array( docId => freq, ...)
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return integer
* @throws Zend_Search_Lucene_Exception
*/
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');
}
@ -639,15 +643,15 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
* Returns an array of all term positions in the documents.
* Return array structure: array( docId => array( pos1, pos2, ...), ...)
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return array
* @throws Zend_Search_Lucene_Exception
*/
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');
}
@ -676,7 +680,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
/**
* Returns the number of documents in this index containing the $term.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_Term $term
* @return integer
*/
public function docFreq(Zend_Search_Lucene_Index_Term $term)
@ -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.');
}
}
@ -718,8 +722,8 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
/**
* Returns a normalization factor for "field, document" pair.
*
* @param integer $id
* @param string $fieldName
* @param integer $id
* @param string $fieldName
* @return float
*/
public function norm($id, $fieldName)
@ -757,7 +761,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
* Deletes a document from the index.
* $id is an internal document id
*
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @throws Zend_Search_Lucene_Exception
*/
public function delete($id)
@ -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.');
}
@ -793,13 +797,13 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
/**
* Set callback for choosing target index.
*
* @param callback $callback
* @param callback $callback
* @throws Zend_Search_Lucene_Exception
*/
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.');
}
@ -819,7 +823,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
/**
* Adds a document to this index.
*
* @param Zend_Search_Lucene_Document $document
* @param Zend_Search_Lucene_Document $document
* @throws Zend_Search_Lucene_Exception
*/
public function addDocument(Zend_Search_Lucene_Document $document)
@ -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

@ -12,11 +12,11 @@
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: PriorityQueue.php 20096 2010-01-06 02:05:09Z bkarwin $
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: PriorityQueue.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
@ -30,10 +30,10 @@
*
* It provides O(log(N)) time of put/pop operations, where N is a size of queue
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Search_Lucene_PriorityQueue
{
@ -133,9 +133,9 @@ 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++;
}
}
@ -162,8 +162,8 @@ abstract class Zend_Search_Lucene_PriorityQueue
*
* Returns true, if $el1 is less than $el2; else otherwise
*
* @param mixed $el1
* @param mixed $el2
* @param mixed $el1
* @param mixed $el2
* @return boolean
*/
abstract protected function _less($el1, $el2);

View File

@ -12,14 +12,16 @@
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Proxy.php 20096 2010-01-06 02:05:09Z bkarwin $
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @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';
@ -28,10 +30,10 @@ require_once 'Zend/Search/Lucene/Interface.php';
*
* It tracks, when index object goes out of scope and forces ndex closing
*
* @category Zend
* @package Zend_Search_Lucene
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @category Zend
* @package Zend_Search_Lucene
* @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_Proxy implements Zend_Search_Lucene_Interface
{
@ -72,7 +74,7 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
* 0 means pre-2.1 index format
* -1 means there are no segments files.
*
* @param Zend_Search_Lucene_Storage_Directory $directory
* @param Zend_Search_Lucene_Storage_Directory $directory
* @return integer
* @throws Zend_Search_Lucene_Exception
*/
@ -84,7 +86,7 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
/**
* Get segments file name
*
* @param integer $generation
* @param integer $generation
* @return string
*/
public static function getSegmentFileName($generation)
@ -106,7 +108,7 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
* Set index format version.
* Index is converted to this format at the nearest upfdate time
*
* @param int $formatVersion
* @param int $formatVersion
* @throws Zend_Search_Lucene_Exception
*/
public function setFormatVersion($formatVersion)
@ -159,7 +161,7 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
/**
* Checks, that document is deleted
*
* @param integer $id
* @param integer $id
* @return boolean
* @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range
*/
@ -333,7 +335,7 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
* of Zend_Search_Lucene_Search_QueryHit objects.
* Input is a string or Zend_Search_Lucene_Search_Query.
*
* @param mixed $query
* @param mixed $query
* @return array Zend_Search_Lucene_Search_QueryHit
* @throws Zend_Search_Lucene_Exception
*/
@ -349,7 +351,7 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
/**
* Returns a list of all unique field names that exist in this index.
*
* @param boolean $indexed
* @param boolean $indexed
* @return array
*/
public function getFieldNames($indexed = false)
@ -361,7 +363,7 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
* Returns a Zend_Search_Lucene_Document object for the document
* number $id in this index.
*
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @return Zend_Search_Lucene_Document
*/
public function getDocument($id)
@ -374,7 +376,7 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
*
* Is used for query optimization.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_Term $term
* @return boolean
*/
public function hasTerm(Zend_Search_Lucene_Index_Term $term)
@ -385,8 +387,8 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
/**
* Returns IDs of all the documents containing term.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return array
*/
public function termDocs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
@ -400,8 +402,8 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
* It performs the same operation as termDocs, but return result as
* Zend_Search_Lucene_Index_DocsFilter object
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return Zend_Search_Lucene_Index_DocsFilter
*/
public function termDocsFilter(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
@ -413,8 +415,8 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
* Returns an array of all term freqs.
* Return array structure: array( docId => freq, ...)
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return integer
*/
public function termFreqs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
@ -426,8 +428,8 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
* Returns an array of all term positions in the documents.
* Return array structure: array( docId => array( pos1, pos2, ...), ...)
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @return array
*/
public function termPositions(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
@ -438,7 +440,7 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
/**
* Returns the number of documents in this index containing the $term.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param Zend_Search_Lucene_Index_Term $term
* @return integer
*/
public function docFreq(Zend_Search_Lucene_Index_Term $term)
@ -459,8 +461,8 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
/**
* Returns a normalization factor for "field, document" pair.
*
* @param integer $id
* @param string $fieldName
* @param integer $id
* @param string $fieldName
* @return float
*/
public function norm($id, $fieldName)
@ -482,7 +484,7 @@ class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface
* Deletes a document from the index.
* $id is an internal document id
*
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @throws Zend_Search_Lucene_Exception
*/
public function delete($id)

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,20 +106,23 @@ 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,
self::ST_OR_OPERATOR),
array(self::IN_LITERAL,
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
@ -81,7 +83,7 @@ class Zend_Search_Lucene_Search_Highlighter_Default implements Zend_Search_Lucen
/**
* Highlight specified words
*
* @param string|array $words Words to highlight. They could be organized using the array or string.
* @param string|array $words Words to highlight. They could be organized using the array or string.
*/
public function highlight($words)
{

View File

@ -47,7 +47,7 @@ interface Zend_Search_Lucene_Search_Highlighter_Interface
/**
* Highlight specified words (method is invoked once per subquery)
*
* @param string|array $words Words to highlight. They could be organized using the array or string.
* @param string|array $words Words to highlight. They could be organized using the array or string.
*/
public function highlight($words);
}

View File

@ -76,8 +76,8 @@ abstract class Zend_Search_Lucene_Search_Query
/**
* Score specified document
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
abstract public function score($docId, Zend_Search_Lucene_Interface $reader);
@ -97,7 +97,7 @@ abstract class Zend_Search_Lucene_Search_Query
*
* Query specific implementation
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
*/
abstract public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null);
@ -105,7 +105,7 @@ abstract class Zend_Search_Lucene_Search_Query
/**
* Constructs an appropriate Weight implementation for this query.
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @return Zend_Search_Lucene_Search_Weight
*/
abstract public function createWeight(Zend_Search_Lucene_Interface $reader);
@ -131,7 +131,7 @@ abstract class Zend_Search_Lucene_Search_Query
/**
* Re-write query into primitive queries in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
abstract public function rewrite(Zend_Search_Lucene_Interface $index);
@ -139,7 +139,7 @@ abstract class Zend_Search_Lucene_Search_Query
/**
* Optimize query in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
abstract public function optimize(Zend_Search_Lucene_Interface $index);
@ -171,27 +171,29 @@ abstract class Zend_Search_Lucene_Search_Query
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
abstract protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter);
/**
* Highlight matches in $inputHTML
*
* @param string $inputHTML
* @param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag.
* @param Zend_Search_Lucene_Search_Highlighter_Interface|null $highlighter
* @param string $inputHTML
* @param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag.
* @param Zend_Search_Lucene_Search_Highlighter_Interface|null $highlighter
* @return string
*/
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);
@ -204,23 +206,25 @@ abstract class Zend_Search_Lucene_Search_Query
/**
* Highlight matches in $inputHtmlFragment and return it (without HTML header and body tag)
*
* @param string $inputHtmlFragment
* @param string $encoding Input HTML string encoding
* @param Zend_Search_Lucene_Search_Highlighter_Interface|null $highlighter
* @param string $inputHtmlFragment
* @param string $encoding Input HTML string encoding
* @param Zend_Search_Lucene_Search_Highlighter_Interface|null $highlighter
* @return string
*/
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';
@ -79,8 +81,8 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
* if $signs array is omitted then all subqueries are required
* it differs from addSubquery() behavior, but should never be used
*
* @param array $subqueries Array of Zend_Search_Search_Query objects
* @param array $signs Array of signs. Sign is boolean|null.
* @param array $subqueries Array of Zend_Search_Search_Query objects
* @param array $signs Array of signs. Sign is boolean|null.
* @return void
*/
public function __construct($subqueries = null, $signs = null)
@ -111,10 +113,11 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
* NULL - subquery is neither prohibited, nor required
*
* @param Zend_Search_Lucene_Search_Query $subquery
* @param boolean|null $sign
* @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();
@ -131,7 +134,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
/**
* Re-write queries into primitive queries
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
public function rewrite(Zend_Search_Lucene_Interface $index)
@ -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;
@ -150,7 +155,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
/**
* Optimize query in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
public function optimize(Zend_Search_Lucene_Interface $index)
@ -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();
}
@ -262,7 +267,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
// remove subquery from a subqueries list
unset($subqueries[$id]);
unset($signs[$id]);
} else if ($subquery instanceof Zend_Search_Lucene_Search_Query_MultiTerm) {
} else if ($subquery instanceof Zend_Search_Lucene_Search_Query_MultiTerm) {
$subTerms = $subquery->getTerms();
$subSigns = $subquery->getSigns();
@ -330,14 +335,14 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
// Continue if non-optional terms are presented in this multi-term subquery
if (!$onlyOptional) {
continue;
continue;
}
foreach ($subTerms as $termId => $term) {
$terms[] = $term;
$tsigns[] = ($signs[$id] === null)? null /* optional */ :
false /* prohibited */;
$boostFactors[] = $subquery->getBoost();
$terms[] = $term;
$tsigns[] = ($signs[$id] === null)? null /* optional */ :
false /* prohibited */;
$boostFactors[] = $subquery->getBoost();
}
// remove subquery from a subqueries list
@ -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
@ -466,12 +473,12 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
/**
* Constructs an appropriate Weight implementation for this query.
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @return Zend_Search_Lucene_Search_Weight
*/
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,
$resVectorsIds, SORT_ASC, SORT_NUMERIC,
$resVectors);
array_multisort(
$resVectorsSizes, SORT_ASC, SORT_NUMERIC,
$resVectorsIds, SORT_ASC, SORT_NUMERIC,
$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,
$requiredVectorsIds, SORT_ASC, SORT_NUMERIC,
$requiredVectors);
array_multisort(
$requiredVectorsSizes, SORT_ASC, SORT_NUMERIC,
$requiredVectorsIds, SORT_ASC, SORT_NUMERIC,
$requiredVectors
);
$required = null;
foreach ($requiredVectors as $nextResVector) {
@ -605,15 +616,17 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
/**
* Score calculator for conjunction queries (all subqueries are required)
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
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;
@ -635,8 +648,8 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
/**
* Score calculator for non conjunction queries (not all subqueries are required)
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
public function _nonConjunctionScore($docId, Zend_Search_Lucene_Interface $reader)
@ -684,7 +697,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
* Execute query in context of index reader
* It also initializes necessary internal structures
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
*/
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
@ -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();
}
@ -731,8 +744,8 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
/**
* Score specified document
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
public function score($docId, Zend_Search_Lucene_Interface $reader)
@ -769,7 +782,7 @@ class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -37,7 +39,7 @@ class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Qu
/**
* Re-write query into primitive queries in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
public function rewrite(Zend_Search_Lucene_Interface $index)
@ -48,7 +50,7 @@ class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Qu
/**
* Optimize query in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
public function optimize(Zend_Search_Lucene_Interface $index)
@ -60,12 +62,12 @@ class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Qu
/**
* Constructs an appropriate Weight implementation for this query.
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @return Zend_Search_Lucene_Search_Weight
*/
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();
}
@ -73,7 +75,7 @@ class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Qu
* Execute query in context of index reader
* It also initializes necessary internal structures
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
*/
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
@ -96,8 +98,8 @@ class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Qu
/**
* Score specified document
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
public function score($docId, Zend_Search_Lucene_Interface $reader)
@ -118,7 +120,7 @@ class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Qu
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{

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;
/**
@ -114,23 +118,23 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
/**
* Zend_Search_Lucene_Search_Query_Wildcard constructor.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param float $minimumSimilarity
* @param integer $prefixLength
* @param Zend_Search_Lucene_Index_Term $term
* @param float $minimumSimilarity
* @param integer $prefixLength
* @throws Zend_Search_Lucene_Exception
*/
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');
}
@ -162,9 +166,9 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
/**
* Calculate maximum distance for specified word length
*
* @param integer $prefixLength
* @param integer $termLength
* @param integer $length
* @param integer $prefixLength
* @param integer $termLength
* @param integer $length
* @return integer
*/
private function _calculateMaxDistance($prefixLength, $termLength, $length)
@ -176,7 +180,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
/**
* Re-write query into primitive queries in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
* @throws Zend_Search_Lucene_Exception
*/
@ -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));
@ -231,7 +235,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
$similarity = (($prefixUtf8Length == 0)? 0 : 1 - strlen($target)/$prefixUtf8Length);
} else if (strlen($target) == 0) {
$similarity = (($prefixUtf8Length == 0)? 0 : 1 - $termRestLength/$prefixUtf8Length);
} else if ($maxDistance < abs($termRestLength - strlen($target))){
} else if ($maxDistance < abs($termRestLength - strlen($target))) {
//just adding the characters of term to target or vice-versa results in too many edits
//for example "pre" length is 3 and "prefixes" length is 8. We can see that
//given this optimal circumstance, the edit distance cannot be less than 5.
@ -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.');
}
}
@ -267,7 +271,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
$this->_maxDistances[strlen($target)] :
$this->_calculateMaxDistance(0, $termRestLength, strlen($target));
if ($maxDistance < abs($termRestLength - strlen($target))){
if ($maxDistance < abs($termRestLength - strlen($target))) {
//just adding the characters of term to target or vice-versa results in too many edits
//for example "pre" length is 3 and "prefixes" length is 8. We can see that
//given this optimal circumstance, the edit distance cannot be less than 5.
@ -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,
$this->_termKeys, SORT_ASC, SORT_STRING,
$this->_matches);
array_multisort(
$this->_scores, SORT_DESC, SORT_NUMERIC,
$this->_termKeys, SORT_ASC, SORT_STRING,
$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]);
@ -332,12 +338,12 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
/**
* Optimize query in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
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.');
}
@ -360,13 +366,13 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
/**
* Constructs an appropriate Weight implementation for this query.
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @return Zend_Search_Lucene_Search_Weight
* @throws Zend_Search_Lucene_Exception
*/
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)');
}
@ -375,13 +381,13 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
* Execute query in context of index reader
* It also initializes necessary internal structures
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @throws Zend_Search_Lucene_Exception
*/
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,34 +401,34 @@ 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)');
}
/**
* Score specified document
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
* @throws Zend_Search_Lucene_Exception
*/
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)');
}
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{
$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();
@ -455,7 +461,7 @@ class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Qu
$similarity = (($prefixUtf8Length == 0)? 0 : 1 - strlen($target)/$prefixUtf8Length);
} else if (strlen($target) == 0) {
$similarity = (($prefixUtf8Length == 0)? 0 : 1 - $termRestLength/$prefixUtf8Length);
} else if ($maxDistance < abs($termRestLength - strlen($target))){
} else if ($maxDistance < abs($termRestLength - strlen($target))) {
//just adding the characters of term to target or vice-versa results in too many edits
//for example "pre" length is 3 and "prefixes" length is 8. We can see that
//given this optimal circumstance, the edit distance cannot be less than 5.

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -39,7 +41,7 @@ class Zend_Search_Lucene_Search_Query_Insignificant extends Zend_Search_Lucene_S
/**
* Re-write query into primitive queries in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
public function rewrite(Zend_Search_Lucene_Interface $index)
@ -50,7 +52,7 @@ class Zend_Search_Lucene_Search_Query_Insignificant extends Zend_Search_Lucene_S
/**
* Optimize query in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
public function optimize(Zend_Search_Lucene_Interface $index)
@ -61,12 +63,12 @@ class Zend_Search_Lucene_Search_Query_Insignificant extends Zend_Search_Lucene_S
/**
* Constructs an appropriate Weight implementation for this query.
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @return Zend_Search_Lucene_Search_Weight
*/
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();
}
@ -74,7 +76,7 @@ class Zend_Search_Lucene_Search_Query_Insignificant extends Zend_Search_Lucene_S
* Execute query in context of index reader
* It also initializes necessary internal structures
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
*/
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
@ -97,8 +99,8 @@ class Zend_Search_Lucene_Search_Query_Insignificant extends Zend_Search_Lucene_S
/**
* Score specified document
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
public function score($docId, Zend_Search_Lucene_Interface $reader)
@ -119,7 +121,7 @@ class Zend_Search_Lucene_Search_Query_Insignificant extends Zend_Search_Lucene_S
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -99,14 +101,14 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
* if $signs array is omitted then all terms are required
* it differs from addTerm() behavior, but should never be used
*
* @param array $terms Array of Zend_Search_Lucene_Index_Term objects
* @param array $signs Array of signs. Sign is boolean|null.
* @param array $terms Array of Zend_Search_Lucene_Index_Term objects
* @param array $signs Array of signs. Sign is boolean|null.
* @throws Zend_Search_Lucene_Exception
*/
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.');
}
@ -136,10 +138,11 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
* NULL - term is neither prohibited, nor required
*
* @param Zend_Search_Lucene_Index_Term $term
* @param boolean|null $sign
* @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();
@ -157,13 +160,13 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
/**
* Re-write query into primitive queries in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
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;
@ -199,7 +206,7 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
/**
* Optimize query in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
public function optimize(Zend_Search_Lucene_Interface $index)
@ -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();
}
@ -291,7 +298,7 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
/**
* Set weight for specified term
*
* @param integer $num
* @param integer $num
* @param Zend_Search_Lucene_Search_Weight_Term $weight
*/
public function setWeight($num, $weight)
@ -303,12 +310,12 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
/**
* Constructs an appropriate Weight implementation for this query.
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @return Zend_Search_Lucene_Search_Weight
*/
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,
$ids, SORT_ASC, SORT_NUMERIC,
$this->_terms);
array_multisort(
$docFreqs, SORT_ASC, SORT_NUMERIC,
$ids, SORT_ASC, SORT_NUMERIC,
$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,
$requiredVectorsIds, SORT_ASC, SORT_NUMERIC,
$requiredVectors);
array_multisort(
$requiredVectorsSizes, SORT_ASC, SORT_NUMERIC,
$requiredVectorsIds, SORT_ASC, SORT_NUMERIC,
$requiredVectors
);
$required = null;
foreach ($requiredVectors as $nextResVector) {
@ -459,15 +470,17 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
/**
* Score calculator for conjunction queries (all terms are required)
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
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;
@ -489,8 +502,8 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
/**
* Score calculator for non conjunction queries (not all terms are required)
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
public function _nonConjunctionScore($docId, $reader)
@ -514,9 +527,9 @@ 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++;
/**
@ -537,7 +550,7 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
* Execute query in context of index reader
* It also initializes necessary internal structures
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
*/
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
@ -567,8 +580,8 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
/**
* Score specified document
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
public function score($docId, Zend_Search_Lucene_Interface $reader)
@ -609,7 +622,7 @@ class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Searc
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -91,9 +93,9 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
/**
* Class constructor. Create a new prase query.
*
* @param string $field Field to search.
* @param array $terms Terms to search Array of strings.
* @param array $offsets Relative term positions. Array of integers.
* @param string $field Field to search.
* @param array $terms Terms to search Array of strings.
* @param array $offsets Relative term positions. Array of integers.
* @throws Zend_Search_Lucene_Exception
*/
public function __construct($terms = null, $offsets = null, $field = null)
@ -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');
}
}
@ -160,13 +162,16 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
* after the last term added.
*
* @param Zend_Search_Lucene_Index_Term $term
* @param integer $position
* @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;
@ -183,18 +188,18 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
/**
* Re-write query into primitive queries in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
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);
@ -219,7 +224,7 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
/**
* Optimize query in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
public function optimize(Zend_Search_Lucene_Interface $index)
@ -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();
}
@ -264,7 +269,7 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
/**
* Set weight for specified term
*
* @param integer $num
* @param integer $num
* @param Zend_Search_Lucene_Search_Weight_Term $weight
*/
public function setWeight($num, $weight)
@ -276,12 +281,12 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
/**
* Constructs an appropriate Weight implementation for this query.
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @return Zend_Search_Lucene_Search_Weight
*/
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;
}
@ -290,7 +295,7 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
/**
* Score calculator for exact phrase queries (terms sequence is fixed)
*
* @param integer $docId
* @param integer $docId
* @return float
*/
public function _exactPhraseFreq($docId)
@ -302,11 +307,11 @@ 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;
}
}
}
// Walk through positions of the term with lowest cardinality
@ -335,8 +340,8 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
/**
* Score calculator for sloppy phrase queries (terms sequence is fixed)
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
public function _sloppyPhraseFreq($docId, Zend_Search_Lucene_Interface $reader)
@ -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;
}
@ -412,7 +419,7 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
* Execute query in context of index reader
* It also initializes necessary internal structures
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
*/
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
@ -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,
$resVectorsIds, SORT_ASC, SORT_NUMERIC,
$resVectors);
array_multisort(
$resVectorsSizes, SORT_ASC, SORT_NUMERIC,
$resVectorsIds, SORT_ASC, SORT_NUMERIC,
$resVectors
);
foreach ($resVectors as $nextResVector) {
if($this->_resVector === null) {
@ -484,8 +493,8 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
/**
* Score specified document
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
public function score($docId, Zend_Search_Lucene_Interface $reader)
@ -525,7 +534,7 @@ class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Q
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -53,24 +55,24 @@ abstract class Zend_Search_Lucene_Search_Query_Preprocessing extends Zend_Search
/**
* Optimize query in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
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.');
}
/**
* Constructs an appropriate Weight implementation for this query.
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @return Zend_Search_Lucene_Search_Weight
*/
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.');
}
@ -78,12 +80,12 @@ abstract class Zend_Search_Lucene_Search_Query_Preprocessing extends Zend_Search
* Execute query in context of index reader
* It also initializes necessary internal structures
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
*/
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,20 +98,20 @@ 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.');
}
/**
* Score specified document
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
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';
@ -74,9 +76,9 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy extends Zend_Search_Lu
/**
* Class constructor. Create a new preprocessing object for prase query.
*
* @param string $word Non-tokenized word (query parser lexeme) to search.
* @param string $encoding Word encoding.
* @param string $fieldName Field name.
* @param string $word Non-tokenized word (query parser lexeme) to search.
* @param string $encoding Word encoding.
* @param string $fieldName Field name.
* @param float $minimumSimilarity minimum similarity
*/
public function __construct($word, $encoding, $fieldName, $minimumSimilarity)
@ -90,35 +92,38 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy extends Zend_Search_Lu
/**
* Re-write query into primitive queries in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
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,
$this->_encoding,
$fieldName,
$this->_minimumSimilarity);
$subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy(
$this->_word,
$this->_encoding,
$fieldName,
$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,25 +216,31 @@ 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');
}
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
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';
/**
@ -81,9 +83,9 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Phrase extends Zend_Search_L
/**
* Class constructor. Create a new preprocessing object for prase query.
*
* @param string $phrase Phrase to search.
* @param string $phraseEncoding Phrase encoding.
* @param string $fieldName Field name.
* @param string $phrase Phrase to search.
* @param string $phraseEncoding Phrase encoding.
* @param string $fieldName Field name.
*/
public function __construct($phrase, $phraseEncoding, $fieldName)
{
@ -116,26 +118,26 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Phrase extends Zend_Search_L
/**
* Re-write query into primitive queries in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
public function rewrite(Zend_Search_Lucene_Interface $index)
{
// Allow to use wildcards within phrases
// They are either removed by text analyzer or used as a part of keyword for keyword fields
//
// if (strpos($this->_phrase, '?') !== false || strpos($this->_phrase, '*') !== false) {
// require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
// throw new Zend_Search_Lucene_Search_QueryParserException('Wildcards are only allowed in a single terms.');
// }
// Allow to use wildcards within phrases
// They are either removed by text analyzer or used as a part of keyword for keyword fields
//
// if (strpos($this->_phrase, '?') !== false || strpos($this->_phrase, '*') !== false) {
// require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
// throw new Zend_Search_Lucene_Search_QueryParserException('Wildcards are only allowed in a single terms.');
// }
// 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,
$this->_phraseEncoding,
$fieldName);
$subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Phrase(
$this->_phrase,
$this->_phraseEncoding,
$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);
@ -208,19 +212,25 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Phrase extends Zend_Search_L
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
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';
@ -63,9 +65,9 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
/**
* Class constructor. Create a new preprocessing object for prase query.
*
* @param string $word Non-tokenized word (query parser lexeme) to search.
* @param string $encoding Word encoding.
* @param string $fieldName Field name.
* @param string $word Non-tokenized word (query parser lexeme) to search.
* @param string $encoding Word encoding.
* @param string $fieldName Field name.
*/
public function __construct($word, $encoding, $fieldName)
{
@ -77,30 +79,32 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
/**
* Re-write query into primitive queries in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
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,
$this->_encoding,
$fieldName);
$subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Term(
$this->_word,
$this->_encoding,
$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
@ -239,17 +245,23 @@ class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Luc
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
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';
@ -80,19 +82,19 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
/**
* Zend_Search_Lucene_Search_Query_Range constructor.
*
* @param Zend_Search_Lucene_Index_Term|null $lowerTerm
* @param Zend_Search_Lucene_Index_Term|null $upperTerm
* @param boolean $inclusive
* @param Zend_Search_Lucene_Index_Term|null $lowerTerm
* @param Zend_Search_Lucene_Index_Term|null $upperTerm
* @param boolean $inclusive
* @throws Zend_Search_Lucene_Exception
*/
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');
}
@ -145,7 +147,7 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
/**
* Re-write query into primitive queries in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
public function rewrite(Zend_Search_Lucene_Interface $index)
@ -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) {
@ -239,12 +242,12 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
/**
* Optimize query in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
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.');
}
@ -267,13 +270,13 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
/**
* Constructs an appropriate Weight implementation for this query.
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @return Zend_Search_Lucene_Search_Weight
* @throws Zend_Search_Lucene_Exception
*/
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)');
}
@ -282,13 +285,13 @@ class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Qu
* Execute query in context of index reader
* It also initializes necessary internal structures
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @throws Zend_Search_Lucene_Exception
*/
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,35 +305,35 @@ 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)');
}
/**
* Score specified document
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
* @throws Zend_Search_Lucene_Exception
*/
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)');
}
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{
$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';
@ -61,7 +63,7 @@ class Zend_Search_Lucene_Search_Query_Term extends Zend_Search_Lucene_Search_Que
* Zend_Search_Lucene_Search_Query_Term constructor
*
* @param Zend_Search_Lucene_Index_Term $term
* @param boolean $sign
* @param boolean $sign
*/
public function __construct(Zend_Search_Lucene_Index_Term $term)
{
@ -71,7 +73,7 @@ class Zend_Search_Lucene_Search_Query_Term extends Zend_Search_Lucene_Search_Que
/**
* Re-write query into primitive queries in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
public function rewrite(Zend_Search_Lucene_Interface $index)
@ -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);
@ -97,14 +99,14 @@ class Zend_Search_Lucene_Search_Query_Term extends Zend_Search_Lucene_Search_Que
/**
* Optimize query in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
public function optimize(Zend_Search_Lucene_Interface $index)
{
// 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();
}
@ -115,12 +117,12 @@ class Zend_Search_Lucene_Search_Query_Term extends Zend_Search_Lucene_Search_Que
/**
* Constructs an appropriate Weight implementation for this query.
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @return Zend_Search_Lucene_Search_Weight
*/
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;
}
@ -129,7 +131,7 @@ class Zend_Search_Lucene_Search_Query_Term extends Zend_Search_Lucene_Search_Que
* Execute query in context of index reader
* It also initializes necessary internal structures
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
*/
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
@ -156,8 +158,8 @@ class Zend_Search_Lucene_Search_Query_Term extends Zend_Search_Lucene_Search_Que
/**
* Score specified document
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
*/
public function score($docId, Zend_Search_Lucene_Interface $reader)
@ -195,7 +197,7 @@ class Zend_Search_Lucene_Search_Query_Term extends Zend_Search_Lucene_Search_Que
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Query */
/**
* Zend_Search_Lucene_Search_Query
*/
require_once 'Zend/Search/Lucene/Search/Query.php';
@ -97,7 +99,7 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
/**
* Get terms prefix
*
* @param string $word
* @param string $word
* @return string
*/
private static function _getPrefix($word)
@ -121,7 +123,7 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
/**
* Re-write query into primitive queries in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
* @throws Zend_Search_Lucene_Exception
*/
@ -138,14 +140,16 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
$prefix = self::_getPrefix($this->_pattern->text);
$prefixLength = strlen($prefix);
$matchExpression = '/^' . str_replace(array('\\?', '\\*'), array('.', '.*') , preg_quote($this->_pattern->text, '/')) . '$/';
$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) {
@ -215,12 +219,12 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
/**
* Optimize query in the context of specified index
*
* @param Zend_Search_Lucene_Interface $index
* @param Zend_Search_Lucene_Interface $index
* @return Zend_Search_Lucene_Search_Query
*/
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');
}
@ -255,13 +259,13 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
/**
* Constructs an appropriate Weight implementation for this query.
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Interface $reader
* @return Zend_Search_Lucene_Search_Weight
* @throws Zend_Search_Lucene_Exception
*/
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)');
}
@ -270,13 +274,13 @@ class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search
* Execute query in context of index reader
* It also initializes necessary internal structures
*
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @param Zend_Search_Lucene_Interface $reader
* @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
* @throws Zend_Search_Lucene_Exception
*/
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,34 +294,34 @@ 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)');
}
/**
* Score specified document
*
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @param integer $docId
* @param Zend_Search_Lucene_Interface $reader
* @return float
* @throws Zend_Search_Lucene_Exception
*/
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)');
}
/**
* Query specific matches highlighting
*
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
* @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting)
*/
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{
$words = array();
$matchExpression = '/^' . str_replace(array('\\?', '\\*'), array('.', '.*') , preg_quote($this->_pattern->text, '/')) . '$/';
$matchExpression = '/^' . str_replace(array('\\?', '\\*'), array('.', '.*'), preg_quote($this->_pattern->text, '/')) . '$/';
if (@preg_match('/\pL/u', 'a') == 1) {
// PCRE unicode support is turned on
// add Unicode modifier to the match expression
@ -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

@ -48,7 +48,7 @@ abstract class Zend_Search_Lucene_Search_QueryEntry
/**
* Transform entry to a subquery
*
* @param string $encoding
* @param string $encoding
* @return Zend_Search_Lucene_Search_Query
*/
abstract public function getQuery($encoding);

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';
/**
@ -91,19 +93,23 @@ class Zend_Search_Lucene_Search_QueryEntry_Phrase extends Zend_Search_Lucene_Sea
/**
* Transform entry to a subquery
*
* @param string $encoding
* @param string $encoding
* @return Zend_Search_Lucene_Search_Query
* @throws Zend_Search_Lucene_Search_QueryParserException
*/
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,
$encoding,
($this->_field !== null)?
/**
* 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';
/**
@ -52,12 +54,12 @@ class Zend_Search_Lucene_Search_QueryEntry_Subquery extends Zend_Search_Lucene_S
/**
* Process modifier ('~')
*
* @param mixed $parameter
* @param mixed $parameter
* @throws Zend_Search_Lucene_Search_QueryParserException
*/
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');
}
@ -65,7 +67,7 @@ class Zend_Search_Lucene_Search_QueryEntry_Subquery extends Zend_Search_Lucene_S
/**
* Transform entry to a subquery
*
* @param string $encoding
* @param string $encoding
* @return Zend_Search_Lucene_Search_Query
*/
public function getQuery($encoding)

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;
}
}
@ -95,35 +99,41 @@ class Zend_Search_Lucene_Search_QueryEntry_Term extends Zend_Search_Lucene_Searc
/**
* Transform entry to a subquery
*
* @param string $encoding
* @param string $encoding
* @return Zend_Search_Lucene_Search_Query
* @throws Zend_Search_Lucene_Search_QueryParserException
*/
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,
$encoding,
($this->_field !== null)?
/**
* 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) :
null,
$this->_similarity
);
$this->_similarity
);
$query->setBoost($this->_boost);
return $query;
}
/** 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,
$encoding,
($this->_field !== null)?
/**
* 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) :
null
);
);
$query->setBoost($this->_boost);
return $query;
}

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);
}
@ -73,7 +77,7 @@ class Zend_Search_Lucene_Search_QueryHit
* Convenience function for getting fields from the document
* associated with this hit.
*
* @param string $offset
* @param string $offset
* @return string
*/
public function __get($offset)

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,
@ -106,7 +115,7 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
self::ST_NUMBER,
self::ST_MANTISSA,
self::ST_ERROR),
array(self::IN_WHITE_SPACE,
array(self::IN_WHITE_SPACE,
self::IN_SYNT_CHAR,
self::IN_MUTABLE_CHAR,
self::IN_LEXEME_MODIFIER,
@ -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);
@ -303,7 +343,7 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
/**
* Translate input char to an input symbol of state machine
*
* @param string $char
* @param string $char
* @return integer
*/
private function _translateInput($char)
@ -313,9 +353,9 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
} else if (strpos(self::QUERY_MUTABLE_CHARS, $char) !== false) { return self::IN_MUTABLE_CHAR;
} else if (strpos(self::QUERY_LEXEMEMODIFIER_CHARS, $char) !== false) { return self::IN_LEXEME_MODIFIER;
} else if (strpos(self::QUERY_ASCIIDIGITS_CHARS, $char) !== false) { return self::IN_ASCII_DIGIT;
} else if ($char === '"' ) { return self::IN_QUOTE;
} else if ($char === '.' ) { return self::IN_DECIMAL_POINT;
} else if ($char === '\\') { return self::IN_ESCAPE_CHAR;
} else if ($char === '"' ) { return self::IN_QUOTE;
} else if ($char === '.' ) { return self::IN_DECIMAL_POINT;
} else if ($char === '\\') { return self::IN_ESCAPE_CHAR;
} else { return self::IN_CHAR;
}
}
@ -324,8 +364,8 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
/**
* This method is used to tokenize query string into lexemes
*
* @param string $inputString
* @param string $encoding
* @param string $inputString
* @param string $encoding
* @return array
* @throws Zend_Search_Lucene_Search_QueryParserException
*/
@ -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,26 +429,28 @@ 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());
}
}
// duplicate character
$lexeme .= $lexeme;
}
$token = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_SYNTAX_ELEMENT,
$lexeme,
$this->_queryStringPosition);
Zend_Search_Lucene_Search_QueryToken::TC_SYNTAX_ELEMENT,
$lexeme,
$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());
}
@ -424,9 +466,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
public function addLexemeModifier()
{
$this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_SYNTAX_ELEMENT,
$this->_queryString[$this->_queryStringPosition],
$this->_queryStringPosition);
Zend_Search_Lucene_Search_QueryToken::TC_SYNTAX_ELEMENT,
$this->_queryString[$this->_queryStringPosition],
$this->_queryStringPosition
);
}
@ -436,9 +479,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
public function addLexeme()
{
$this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_WORD,
$this->_currentLexeme,
$this->_queryStringPosition - 1);
Zend_Search_Lucene_Search_QueryToken::TC_WORD,
$this->_currentLexeme,
$this->_queryStringPosition - 1
);
$this->_currentLexeme = '';
}
@ -449,9 +493,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
public function addQuotedLexeme()
{
$this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_PHRASE,
$this->_currentLexeme,
$this->_queryStringPosition);
Zend_Search_Lucene_Search_QueryToken::TC_PHRASE,
$this->_currentLexeme,
$this->_queryStringPosition
);
$this->_currentLexeme = '';
}
@ -462,9 +507,10 @@ class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM
public function addNumberLexeme()
{
$this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_NUMBER,
$this->_currentLexeme,
$this->_queryStringPosition - 1);
Zend_Search_Lucene_Search_QueryToken::TC_NUMBER,
$this->_currentLexeme,
$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,10 +193,11 @@ 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),
array(array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_WORD, self::ST_COMMON_QUERY_ELEMENT),
array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_PHRASE, self::ST_COMMON_QUERY_ELEMENT),
array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_FIELD, self::ST_COMMON_QUERY_ELEMENT),
array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_REQUIRED, 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(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(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();
}
@ -284,7 +299,7 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
*/
public static function getDefaultEncoding()
{
return self::_getInstance()->_defaultEncoding;
return self::_getInstance()->_defaultEncoding;
}
/**
@ -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()
@ -334,7 +350,7 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
/**
* Escape keyword to force it to be parsed as one term
*
* @param string $keyword
* @param string $keyword
* @return string
*/
public static function escape($keyword)
@ -345,8 +361,8 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
/**
* Parses a query string
*
* @param string $strQuery
* @param string $encoding
* @param string $strQuery
* @param string $encoding
* @return Zend_Search_Lucene_Search_Query
* @throws Zend_Search_Lucene_Search_QueryParserException
*/
@ -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();
}
@ -382,16 +398,16 @@ class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM
self::$_instance->_lastToken = $token;
} catch (Exception $e) {
if (strpos($e->getMessage(), 'There is no any rule for') !== false) {
throw new Zend_Search_Lucene_Search_QueryParserException( 'Syntax error at char position ' . $token->position . '.', 0, $e);
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);
}
}
if (count(self::$_instance->_contextStack) != 0) {
throw new Zend_Search_Lucene_Search_QueryParserException('Syntax Error: mismatched parentheses, every opening must have closing.' );
throw new Zend_Search_Lucene_Search_QueryParserException('Syntax Error: mismatched parentheses, every opening must have closing.');
}
return self::$_instance->_context->getQuery();
@ -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,23 +493,23 @@ 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';
throw new Zend_Search_Lucene_Search_QueryParserException('Lexeme modifier parameter must follow lexeme modifier. Char position 0.' );
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.');
}
switch ($this->_lastToken->type) {
case Zend_Search_Lucene_Search_QueryToken::TT_FUZZY_PROX_MARK:
$this->_context->processFuzzyProximityModifier($this->_currentToken->text);
break;
case Zend_Search_Lucene_Search_QueryToken::TT_FUZZY_PROX_MARK:
$this->_context->processFuzzyProximityModifier($this->_currentToken->text);
break;
case Zend_Search_Lucene_Search_QueryToken::TT_BOOSTING_MARK:
$this->_context->boost($this->_currentToken->text);
break;
case Zend_Search_Lucene_Search_QueryToken::TT_BOOSTING_MARK:
$this->_context->boost($this->_currentToken->text);
break;
default:
// It's not a user input exception
require_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Lexeme modifier parameter must follow lexeme modifier. Char position 0.' );
default:
// It's not a user input exception
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';
throw new Zend_Search_Lucene_Search_QueryParserException('Syntax Error: mismatched parentheses, every opening must have closing. Char position ' . $this->_currentToken->position . '.' );
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';
@ -101,7 +103,7 @@ class Zend_Search_Lucene_Search_QueryParserContext
/**
* Context object constructor
*
* @param string $encoding
* @param string $encoding
* @param string|null $defaultField
*/
public function __construct($encoding, $defaultField = null)
@ -135,13 +137,13 @@ class Zend_Search_Lucene_Search_QueryParserContext
/**
* Set sign for next entry
*
* @param integer $sign
* @param integer $sign
* @throws Zend_Search_Lucene_Exception
*/
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,30 +295,30 @@ 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) {
$expressionRecognizer->processLiteral($entry);
} else {
switch ($entry) {
case Zend_Search_Lucene_Search_QueryToken::TT_AND_LEXEME:
$expressionRecognizer->processOperator(Zend_Search_Lucene_Search_BooleanExpressionRecognizer::IN_AND_OPERATOR);
break;
case Zend_Search_Lucene_Search_QueryToken::TT_AND_LEXEME:
$expressionRecognizer->processOperator(Zend_Search_Lucene_Search_BooleanExpressionRecognizer::IN_AND_OPERATOR);
break;
case Zend_Search_Lucene_Search_QueryToken::TT_OR_LEXEME:
$expressionRecognizer->processOperator(Zend_Search_Lucene_Search_BooleanExpressionRecognizer::IN_OR_OPERATOR);
break;
case Zend_Search_Lucene_Search_QueryToken::TT_OR_LEXEME:
$expressionRecognizer->processOperator(Zend_Search_Lucene_Search_BooleanExpressionRecognizer::IN_OR_OPERATOR);
break;
case Zend_Search_Lucene_Search_QueryToken::TT_NOT_LEXEME:
$expressionRecognizer->processOperator(Zend_Search_Lucene_Search_BooleanExpressionRecognizer::IN_NOT_OPERATOR);
break;
case Zend_Search_Lucene_Search_QueryToken::TT_NOT_LEXEME:
$expressionRecognizer->processOperator(Zend_Search_Lucene_Search_BooleanExpressionRecognizer::IN_NOT_OPERATOR);
break;
default:
throw new Zend_Search_Lucene('Boolean expression error. Unknown operator type.');
default:
throw new Zend_Search_Lucene('Boolean expression error. Unknown operator type.');
}
}
}
@ -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

@ -128,98 +128,98 @@ class Zend_Search_Lucene_Search_QueryToken
$this->position = $position + 1; // Start from 1
switch ($tokenCategory) {
case self::TC_WORD:
if ( strtolower($tokenText) == 'and') {
$this->type = self::TT_AND_LEXEME;
} else if (strtolower($tokenText) == 'or') {
$this->type = self::TT_OR_LEXEME;
} else if (strtolower($tokenText) == 'not') {
$this->type = self::TT_NOT_LEXEME;
} else if (strtolower($tokenText) == 'to') {
$this->type = self::TT_TO_LEXEME;
} else {
$this->type = self::TT_WORD;
}
case self::TC_WORD:
if (strtolower($tokenText) == 'and') {
$this->type = self::TT_AND_LEXEME;
} else if (strtolower($tokenText) == 'or') {
$this->type = self::TT_OR_LEXEME;
} else if (strtolower($tokenText) == 'not') {
$this->type = self::TT_NOT_LEXEME;
} else if (strtolower($tokenText) == 'to') {
$this->type = self::TT_TO_LEXEME;
} else {
$this->type = self::TT_WORD;
}
break;
case self::TC_PHRASE:
$this->type = self::TT_PHRASE;
break;
case self::TC_NUMBER:
$this->type = self::TT_NUMBER;
break;
case self::TC_SYNTAX_ELEMENT:
switch ($tokenText) {
case ':':
$this->type = self::TT_FIELD_INDICATOR;
break;
case self::TC_PHRASE:
$this->type = self::TT_PHRASE;
case '+':
$this->type = self::TT_REQUIRED;
break;
case self::TC_NUMBER:
$this->type = self::TT_NUMBER;
case '-':
$this->type = self::TT_PROHIBITED;
break;
case self::TC_SYNTAX_ELEMENT:
switch ($tokenText) {
case ':':
$this->type = self::TT_FIELD_INDICATOR;
break;
case '+':
$this->type = self::TT_REQUIRED;
break;
case '-':
$this->type = self::TT_PROHIBITED;
break;
case '~':
$this->type = self::TT_FUZZY_PROX_MARK;
break;
case '^':
$this->type = self::TT_BOOSTING_MARK;
break;
case '[':
$this->type = self::TT_RANGE_INCL_START;
break;
case ']':
$this->type = self::TT_RANGE_INCL_END;
break;
case '{':
$this->type = self::TT_RANGE_EXCL_START;
break;
case '}':
$this->type = self::TT_RANGE_EXCL_END;
break;
case '(':
$this->type = self::TT_SUBQUERY_START;
break;
case ')':
$this->type = self::TT_SUBQUERY_END;
break;
case '!':
$this->type = self::TT_NOT_LEXEME;
break;
case '&&':
$this->type = self::TT_AND_LEXEME;
break;
case '||':
$this->type = self::TT_OR_LEXEME;
break;
default:
require_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Unrecognized query syntax lexeme: \'' . $tokenText . '\'');
}
case '~':
$this->type = self::TT_FUZZY_PROX_MARK;
break;
case self::TC_NUMBER:
$this->type = self::TT_NUMBER;
case '^':
$this->type = self::TT_BOOSTING_MARK;
break;
case '[':
$this->type = self::TT_RANGE_INCL_START;
break;
case ']':
$this->type = self::TT_RANGE_INCL_END;
break;
case '{':
$this->type = self::TT_RANGE_EXCL_START;
break;
case '}':
$this->type = self::TT_RANGE_EXCL_END;
break;
case '(':
$this->type = self::TT_SUBQUERY_START;
break;
case ')':
$this->type = self::TT_SUBQUERY_END;
break;
case '!':
$this->type = self::TT_NOT_LEXEME;
break;
case '&&':
$this->type = self::TT_AND_LEXEME;
break;
case '||':
$this->type = self::TT_OR_LEXEME;
break;
default:
require_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Unrecognized lexeme type: \'' . $tokenCategory . '\'');
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Unrecognized query syntax lexeme: \'' . $tokenText . '\'');
}
break;
case self::TC_NUMBER:
$this->type = self::TT_NUMBER;
default:
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();
}
@ -350,8 +350,8 @@ abstract class Zend_Search_Lucene_Search_Similarity
* 'fieldName' of 'doc'.
* Returns a normalization factor for hits on this field of this document
*
* @param string $fieldName
* @param integer $numTokens
* @param string $fieldName
* @param integer $numTokens
* @return float
*/
abstract public function lengthNorm($fieldName, $numTokens);
@ -367,7 +367,7 @@ abstract class Zend_Search_Lucene_Search_Similarity
* sumOfSquaredWeights - the sum of the squares of query term weights
* Returns a normalization factor for query weights
*
* @param float $sumOfSquaredWeights
* @param float $sumOfSquaredWeights
* @return float
*/
abstract public function queryNorm($sumOfSquaredWeights);
@ -376,7 +376,7 @@ abstract class Zend_Search_Lucene_Search_Similarity
/**
* Decodes a normalization factor stored in an index.
*
* @param integer $byte
* @param integer $byte
* @return float
*/
public static function decodeNorm($byte)
@ -396,18 +396,18 @@ abstract class Zend_Search_Lucene_Search_Similarity
* small to represent are rounded up to the smallest positive representable
* value.
*
* @param float $f
* @param float $f
* @return integer
*/
static function encodeNorm($f)
{
return self::_floatToByte($f);
return self::_floatToByte($f);
}
/**
* Float to byte conversion
*
* @param integer $b
* @param integer $b
* @return float
*/
private static function _floatToByte($f)
@ -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;
@ -458,7 +459,7 @@ abstract class Zend_Search_Lucene_Search_Similarity
* freq - the frequency of a term within a document
* Returns a score factor based on a term's within-document frequency
*
* @param float $freq
* @param float $freq
* @return float
*/
abstract public function tf($freq);
@ -476,7 +477,7 @@ abstract class Zend_Search_Lucene_Search_Similarity
* distance - the edit distance of this sloppy phrase match
* Returns the frequency increment for this match
*
* @param integer $distance
* @param integer $distance
* @return float
*/
abstract public function sloppyFreq($distance);
@ -492,8 +493,8 @@ abstract class Zend_Search_Lucene_Search_Similarity
* reader - reader the document collection being searched
* Returns a score factor for the term
*
* @param mixed $input
* @param Zend_Search_Lucene_Interface $reader
* @param mixed $input
* @param Zend_Search_Lucene_Interface $reader
* @return a score factor for the term
*/
public function idf($input, Zend_Search_Lucene_Interface $reader)
@ -523,8 +524,8 @@ abstract class Zend_Search_Lucene_Search_Similarity
* numDocs - the total number of documents in the collection
* Returns a score factor based on the term's document frequency
*
* @param integer $docFreq
* @param integer $numDocs
* @param integer $docFreq
* @param integer $numDocs
* @return float
*/
abstract public function idfFreq($docFreq, $numDocs);
@ -542,8 +543,8 @@ abstract class Zend_Search_Lucene_Search_Similarity
* maxOverlap - the total number of terms in the query
* Returns a score factor based on term overlap with the query
*
* @param integer $overlap
* @param integer $maxOverlap
* @param integer $overlap
* @param integer $maxOverlap
* @return float
*/
abstract public function coord($overlap, $maxOverlap);

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Search_Similarity */
/**
* Zend_Search_Lucene_Search_Similarity
*/
require_once 'Zend/Search/Lucene/Search/Similarity.php';
@ -38,8 +40,8 @@ class Zend_Search_Lucene_Search_Similarity_Default extends Zend_Search_Lucene_Se
/**
* Implemented as '1/sqrt(numTerms)'.
*
* @param string $fieldName
* @param integer $numTerms
* @param string $fieldName
* @param integer $numTerms
* @return float
*/
public function lengthNorm($fieldName, $numTerms)
@ -54,7 +56,7 @@ class Zend_Search_Lucene_Search_Similarity_Default extends Zend_Search_Lucene_Se
/**
* Implemented as '1/sqrt(sumOfSquaredWeights)'.
*
* @param float $sumOfSquaredWeights
* @param float $sumOfSquaredWeights
* @return float
*/
public function queryNorm($sumOfSquaredWeights)
@ -65,7 +67,7 @@ class Zend_Search_Lucene_Search_Similarity_Default extends Zend_Search_Lucene_Se
/**
* Implemented as 'sqrt(freq)'.
*
* @param float $freq
* @param float $freq
* @return float
*/
public function tf($freq)
@ -76,7 +78,7 @@ class Zend_Search_Lucene_Search_Similarity_Default extends Zend_Search_Lucene_Se
/**
* Implemented as '1/(distance + 1)'.
*
* @param integer $distance
* @param integer $distance
* @return float
*/
public function sloppyFreq($distance)
@ -87,8 +89,8 @@ class Zend_Search_Lucene_Search_Similarity_Default extends Zend_Search_Lucene_Se
/**
* Implemented as 'log(numDocs/(docFreq+1)) + 1'.
*
* @param integer $docFreq
* @param integer $numDocs
* @param integer $docFreq
* @param integer $numDocs
* @return float
*/
public function idfFreq($docFreq, $numDocs)
@ -99,8 +101,8 @@ class Zend_Search_Lucene_Search_Similarity_Default extends Zend_Search_Lucene_Se
/**
* Implemented as 'overlap/maxOverlap'.
*
* @param integer $overlap
* @param integer $maxOverlap
* @param integer $overlap
* @param integer $maxOverlap
* @return float
*/
public function coord($overlap, $maxOverlap)

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';
@ -79,9 +81,10 @@ class Zend_Search_Lucene_Search_Weight_Term extends Zend_Search_Lucene_Search_We
* @param Zend_Search_Lucene_Interface $reader
*/
public function __construct(Zend_Search_Lucene_Index_Term $term,
Zend_Search_Lucene_Search_Query $query,
Zend_Search_Lucene_Interface $reader)
{
Zend_Search_Lucene_Search_Query $query,
Zend_Search_Lucene_Interface $reader
) {
$this->_term = $term;
$this->_query = $query;
$this->_reader = $reader;

View File

@ -48,7 +48,7 @@ abstract class Zend_Search_Lucene_Storage_Directory
/**
* Creates a new, empty file in the directory with the given $filename.
*
* @param string $filename
* @param string $filename
* @return Zend_Search_Lucene_Storage_File
*/
abstract public function createFile($filename);
@ -57,7 +57,7 @@ abstract class Zend_Search_Lucene_Storage_Directory
/**
* Removes an existing $filename in the directory.
*
* @param string $filename
* @param string $filename
* @return void
*/
abstract public function deleteFile($filename);
@ -67,7 +67,7 @@ abstract class Zend_Search_Lucene_Storage_Directory
*
* Method is used to prevent 'too many open files' error
*
* @param string $filename
* @param string $filename
* @return void
*/
abstract public function purgeFile($filename);
@ -75,7 +75,7 @@ abstract class Zend_Search_Lucene_Storage_Directory
/**
* Returns true if a file with the given $filename exists.
*
* @param string $filename
* @param string $filename
* @return boolean
*/
abstract public function fileExists($filename);
@ -84,7 +84,7 @@ abstract class Zend_Search_Lucene_Storage_Directory
/**
* Returns the length of a $filename in the directory.
*
* @param string $filename
* @param string $filename
* @return integer
*/
abstract public function fileLength($filename);
@ -93,7 +93,7 @@ abstract class Zend_Search_Lucene_Storage_Directory
/**
* Returns the UNIX timestamp $filename was last modified.
*
* @param string $filename
* @param string $filename
* @return integer
*/
abstract public function fileModified($filename);
@ -102,8 +102,8 @@ abstract class Zend_Search_Lucene_Storage_Directory
/**
* Renames an existing file in the directory.
*
* @param string $from
* @param string $to
* @param string $from
* @param string $to
* @return void
*/
abstract public function renameFile($from, $to);
@ -112,7 +112,7 @@ abstract class Zend_Search_Lucene_Storage_Directory
/**
* Sets the modified time of $filename to now.
*
* @param string $filename
* @param string $filename
* @return void
*/
abstract public function touchFile($filename);
@ -126,8 +126,8 @@ abstract class Zend_Search_Lucene_Storage_Directory
* Shared handler are good for short atomic requests.
* Non-shared handlers are useful for stream file reading (especial for compound files).
*
* @param string $filename
* @param boolean $shareHandler
* @param string $filename
* @param boolean $shareHandler
* @return Zend_Search_Lucene_Storage_File
*/
abstract public function getFileObject($filename, $shareHandler = true);

View File

@ -21,7 +21,9 @@
*/
/** Zend_Search_Lucene_Storage_Directory */
/**
* Zend_Search_Lucene_Storage_Directory
*/
require_once 'Zend/Search/Lucene/Storage/Directory.php';
@ -47,7 +49,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
* Cache for Zend_Search_Lucene_Storage_File_Filesystem objects
* Array: filename => Zend_Search_Lucene_Storage_File object
*
* @var array
* @var array
* @throws Zend_Search_Lucene_Exception
*/
protected $_fileHandlers;
@ -84,9 +86,9 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
/**
* Utility function to recursive directory creation
*
* @param string $dir
* @param integer $mode
* @param boolean $recursive
* @param string $dir
* @param integer $mode
* @param boolean $recursive
* @return boolean
*/
@ -109,18 +111,18 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
* Object constructor
* Checks if $path is a directory or tries to create it.
*
* @param string $path
* @param string $path
* @throws Zend_Search_Lucene_Exception
*/
public function __construct($path)
{
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'.");
}
}
@ -154,11 +156,12 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
{
$result = array();
$dirContent = opendir( $this->_dirPath );
$dirContent = opendir($this->_dirPath);
while (($file = readdir($dirContent)) !== false) {
if (($file == '..')||($file == '.')) continue;
if (($file == '..')||($file == '.')) { continue;
}
if( !is_dir($this->_dirPath . '/' . $file) ) {
if(!is_dir($this->_dirPath . '/' . $file) ) {
$result[] = $file;
}
}
@ -170,7 +173,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
/**
* Creates a new, empty file in the directory with the given $filename.
*
* @param string $filename
* @param string $filename
* @return Zend_Search_Lucene_Storage_File
* @throws Zend_Search_Lucene_Exception
*/
@ -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
@ -194,7 +197,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
/**
* Removes an existing $filename in the directory.
*
* @param string $filename
* @param string $filename
* @return void
* @throws Zend_Search_Lucene_Exception
*/
@ -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);
@ -220,7 +223,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
*
* Method is used to prevent 'too many open files' error
*
* @param string $filename
* @param string $filename
* @return void
*/
public function purgeFile($filename)
@ -235,7 +238,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
/**
* Returns true if a file with the given $filename exists.
*
* @param string $filename
* @param string $filename
* @return boolean
*/
public function fileExists($filename)
@ -248,12 +251,12 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
/**
* Returns the length of a $filename in the directory.
*
* @param string $filename
* @param string $filename
* @return integer
*/
public function fileLength($filename)
{
if (isset( $this->_fileHandlers[$filename] )) {
if (isset($this->_fileHandlers[$filename])) {
return $this->_fileHandlers[$filename]->size();
}
return filesize($this->_dirPath .'/'. $filename);
@ -263,7 +266,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
/**
* Returns the UNIX timestamp $filename was last modified.
*
* @param string $filename
* @param string $filename
* @return integer
*/
public function fileModified($filename)
@ -275,8 +278,8 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
/**
* Renames an existing file in the directory.
*
* @param string $from
* @param string $to
* @param string $from
* @param string $to
* @return void
* @throws Zend_Search_Lucene_Exception
*/
@ -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);
}
@ -320,7 +323,7 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
/**
* Sets the modified time of $filename to now.
*
* @param string $filename
* @param string $filename
* @return void
*/
public function touchFile($filename)
@ -337,20 +340,20 @@ class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene
* Shared handler are good for short atomic requests.
* Non-shared handlers are useful for stream file reading (especial for compound files).
*
* @param string $filename
* @param boolean $shareHandler
* @param string $filename
* @param boolean $shareHandler
* @return Zend_Search_Lucene_Storage_File
*/
public function getFileObject($filename, $shareHandler = true)
{
$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);
}
if (isset( $this->_fileHandlers[$filename] )) {
if (isset($this->_fileHandlers[$filename])) {
$this->_fileHandlers[$filename]->seek(0);
return $this->_fileHandlers[$filename];
}

View File

@ -33,7 +33,7 @@ abstract class Zend_Search_Lucene_Storage_File
* Reads $length number of bytes at the current position in the
* file and advances the file pointer.
*
* @param integer $length
* @param integer $length
* @return string
*/
abstract protected function _fread($length=1);
@ -51,8 +51,8 @@ abstract class Zend_Search_Lucene_Storage_File
* in offset.)
* Upon success, returns 0; otherwise, returns -1
*
* @param integer $offset
* @param integer $whence
* @param integer $offset
* @param integer $whence
* @return integer
*/
abstract public function seek($offset, $whence=SEEK_SET);
@ -77,7 +77,7 @@ abstract class Zend_Search_Lucene_Storage_File
* Writes $length number of bytes (all, if $length===null) to the end
* of the file.
*
* @param string $data
* @param string $data
* @param integer $length
*/
abstract protected function _fwrite($data, $length=null);
@ -87,7 +87,7 @@ abstract class Zend_Search_Lucene_Storage_File
*
* Lock type may be a LOCK_SH (shared lock) or a LOCK_EX (exclusive lock)
*
* @param integer $lockType
* @param integer $lockType
* @return boolean
*/
abstract public function lock($lockType, $nonBlockinLock = false);
@ -122,7 +122,7 @@ abstract class Zend_Search_Lucene_Storage_File
* Read num bytes from the current position in the file
* and advances the file pointer.
*
* @param integer $num
* @param integer $num
* @return string
*/
public function readBytes($num)
@ -134,7 +134,7 @@ abstract class Zend_Search_Lucene_Storage_File
* Writes num bytes of data (all, if $num===null) to the end
* of the string.
*
* @param string $data
* @param string $data
* @param integer $num
*/
public function writeBytes($data, $num=null)
@ -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
);
}
@ -207,7 +209,7 @@ abstract class Zend_Search_Lucene_Storage_File
/**
* Writes long integer to the end of file
*
* @param integer $value
* @param integer $value
* @throws Zend_Search_Lucene_Exception
*/
public function writeLong($value)
@ -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.');
}
@ -273,13 +277,13 @@ abstract class Zend_Search_Lucene_Storage_File
/**
* Writes long integer to the end of file (32-bit platforms implementation)
*
* @param integer|float $value
* @param integer|float $value
* @throws Zend_Search_Lucene_Exception
*/
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.');
}
@ -329,7 +333,7 @@ abstract class Zend_Search_Lucene_Storage_File
{
settype($value, 'integer');
while ($value > 0x7F) {
$this->_fwrite(chr( ($value & 0x7F)|0x80 ));
$this->_fwrite(chr(($value & 0x7F)|0x80));
$value >>= 7;
}
$this->_fwrite(chr($value));
@ -379,11 +383,12 @@ 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);
$str_val = substr($str_val, 0, $count+1)
. substr($str_val, $count+2);
}
$count += $addBytes;
}
@ -396,7 +401,7 @@ abstract class Zend_Search_Lucene_Storage_File
/**
* Writes a string to the end of file.
*
* @param string $str
* @param string $str
* @throws Zend_Search_Lucene_Exception
*/
public function writeString($str)
@ -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);
}
@ -84,8 +86,8 @@ class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Stor
*
* Upon success, returns 0; otherwise, returns -1
*
* @param integer $offset
* @param integer $whence
* @param integer $offset
* @param integer $whence
* @return integer
*/
public function seek($offset, $whence=SEEK_SET)
@ -137,7 +139,7 @@ class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Stor
$position = ftell($this->_fileHandle);
fseek($this->_fileHandle, 0, SEEK_END);
$size = ftell($this->_fileHandle);
fseek($this->_fileHandle,$position);
fseek($this->_fileHandle, $position);
return $size;
}
@ -145,7 +147,7 @@ class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Stor
/**
* Read a $length bytes from the file and advance the file pointer.
*
* @param integer $length
* @param integer $length
* @return string
*/
protected function _fread($length=1)
@ -171,7 +173,7 @@ class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Stor
* Writes $length number of bytes (all, if $length===null) to the end
* of the file.
*
* @param string $data
* @param string $data
* @param integer $length
*/
protected function _fwrite($data, $length=null)
@ -188,8 +190,8 @@ class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Stor
*
* Lock type may be a LOCK_SH (shared lock) or a LOCK_EX (exclusive lock)
*
* @param integer $lockType
* @param boolean $nonBlockingLock
* @param integer $lockType
* @param boolean $nonBlockingLock
* @return boolean
*/
public function lock($lockType, $nonBlockingLock = false)

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';
/**
@ -61,7 +63,7 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
* Reads $length number of bytes at the current position in the
* file and advances the file pointer.
*
* @param integer $length
* @param integer $length
* @return string
*/
protected function _fread($length = 1)
@ -84,28 +86,28 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
* in offset.)
* Upon success, returns 0; otherwise, returns -1
*
* @param integer $offset
* @param integer $whence
* @param integer $offset
* @param integer $whence
* @return integer
*/
public function seek($offset, $whence=SEEK_SET)
{
switch ($whence) {
case SEEK_SET:
$this->_position = $offset;
break;
case SEEK_SET:
$this->_position = $offset;
break;
case SEEK_CUR:
$this->_position += $offset;
break;
case SEEK_CUR:
$this->_position += $offset;
break;
case SEEK_END:
$this->_position = strlen($this->_data);
$this->_position += $offset;
break;
case SEEK_END:
$this->_position = strlen($this->_data);
$this->_position += $offset;
break;
default:
break;
default:
break;
}
}
@ -137,7 +139,7 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
* Writes $length number of bytes (all, if $length===null) to the end
* of the file.
*
* @param string $data
* @param string $data
* @param integer $length
*/
protected function _fwrite($data, $length=null)
@ -159,7 +161,7 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
*
* Lock type may be a LOCK_SH (shared lock) or a LOCK_EX (exclusive lock)
*
* @param integer $lockType
* @param integer $lockType
* @return boolean
*/
public function lock($lockType, $nonBlockinLock = false)
@ -210,7 +212,7 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
* Read num bytes from the current position in the file
* and advances the file pointer.
*
* @param integer $num
* @param integer $num
* @return string
*/
public function readBytes($num)
@ -225,7 +227,7 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
* Writes num bytes of data (all, if $num===null) to the end
* of the string.
*
* @param string $data
* @param string $data
* @param integer $num
*/
public function writeBytes($data, $num=null)
@ -314,7 +316,7 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
/**
* Writes long integer to the end of file
*
* @param integer $value
* @param integer $value
* @throws Zend_Search_Lucene_Exception
*/
public function writeLong($value)
@ -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.');
}
@ -385,13 +387,13 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
/**
* Writes long integer to the end of file (32-bit platforms implementation)
*
* @param integer|float $value
* @param integer|float $value
* @throws Zend_Search_Lucene_Exception
*/
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.');
}
@ -443,7 +445,7 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
settype($value, 'integer');
while ($value > 0x7F) {
$this->_data .= chr( ($value & 0x7F)|0x80 );
$this->_data .= chr(($value & 0x7F)|0x80);
$value >>= 7;
}
$this->_data .= chr($value);
@ -497,11 +499,12 @@ 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);
$str_val = substr($str_val, 0, $count+1)
. substr($str_val, $count+2);
}
$count += $addBytes;
}
@ -514,7 +517,7 @@ class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_
/**
* Writes a string to the end of file.
*
* @param string $str
* @param string $str
* @throws Zend_Search_Lucene_Exception
*/
public function writeString($str)
@ -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';
@ -58,7 +60,7 @@ class Zend_Search_Lucene_TermStreamsPriorityQueue implements Zend_Search_Lucene_
/**
* Object constructor
*
* @param array $termStreams array of term streams (Zend_Search_Lucene_Index_TermsStream_Interface objects)
* @param array $termStreams array of term streams (Zend_Search_Lucene_Index_TermsStream_Interface objects)
*/
public function __construct(array $termStreams)
{
@ -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();