[Customisation Database Commits] r1783 [16/63] - in /branches/stable: language/en/acp/ language/en/mods/ language/pt_br/ language/pt_br/acp/ language/pt_br/mods/ titania/ titania/authors/ titania/contributions/ titania/docs/ titania/download/ titania/download/modx/ titania/files/contrib_temp/ titania/files/modx_files/ titania/images/ titania/includes/ titania/includes/core/ titania/includes/hooks/ titania/includes/library/Zend/ titania/includes/library/Zend/Search/ titania/includes/library/Zend/Search/Lucene/ titania/includes/library/Zend/Search/Lucene/Analysis/ titania/includes/library/Zend/Search/Lucene/Analysis/Analyzer/ titania/includes/library/Zend/Search/Lucene/Analysis/Analyzer/Common/ titania/includes/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Text/ titania/includes/library/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum/ titania/includes/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/ titania/includes/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/ titania/includes/library/Zend/Search/Lucene/Analysis/TokenFilter/ titania/includes/library/Zend/Search/Lucene/Document/ titania/includes/library/Zend/Search/Lucene/Index/ titania/includes/library/Zend/Search/Lucene/Index/SegmentWriter/ titania/includes/library/Zend/Search/Lucene/Index/TermsStream/ titania/includes/library/Zend/Search/Lucene/Search/ titania/includes/library/Zend/Search/Lucene/Search/Highlighter/ titania/includes/library/Zend/Search/Lucene/Search/Query/ titania/includes/library/Zend/Search/Lucene/Search/Query/Preprocessing/ titania/includes/library/Zend/Search/Lucene/Search/QueryEntry/ titania/includes/library/Zend/Search/Lucene/Search/Similarity/ titania/includes/library/Zend/Search/Lucene/Search/Weight/ titania/includes/library/Zend/Search/Lucene/Storage/ titania/includes/library/Zend/Search/Lucene/Storage/Directory/ titania/includes/library/Zend/Search/Lucene/Storage/File/ titania/includes/library/automod/ titania/includes/library/ezcomponents/ titania/includes/library/ezcomponents/Base/ titania/includes/library/ezcomponents/Base/interfaces/ titania/includes/library/translations/ titania/includes/manage_tools/ titania/includes/objects/ titania/includes/overlords/ titania/includes/tools/ titania/includes/types/ titania/js/ titania/language/ titania/language/en/ titania/language/en/email/ titania/language/en/manage_tools/ titania/language/en/types/ titania/language/pt_br/ titania/language/pt_br/email/ titania/language/pt_br/manage_tools/ titania/language/pt_br/types/ titania/manage/ titania/store/ titania/store/phpbb_packages/ titania/store/phpbb_packages/extracted/ titania/store/search/ titania/styles/default/template/ titania/styles/default/template/authors/ titania/styles/default/template/common/ titania/styles/default/template/contributions/ titania/styles/default/template/manage/ titania/styles/default/template/posting/ titania/styles/default/template/posting/attachments/ titania/styles/default/template/posting/panels/ titania/styles/default/theme/ titania/styles/default/theme/en-gb/ titania/styles/prosilver/template/ titania/styles/prosilver/template/authors/ titania/styles/prosilver/template/common/ titania/styles/prosilver/theme/ titania/styles/prosilver/theme/en-gb/ umil/ umil/error_files/ umil/language/en/ umil/style/
Nathan Guse
exreaction at phpbb.com
Sat Nov 20 18:23:23 GMT 2010
Modified: branches/stable/titania/includes/library/Zend/Search/Lucene/Document/Xlsx.php
==============================================================================
*** branches/stable/titania/includes/library/Zend/Search/Lucene/Document/Xlsx.php (original)
--- branches/stable/titania/includes/library/Zend/Search/Lucene/Document/Xlsx.php Sat Nov 20 18:23:22 2010
***************
*** 1,263 ****
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Document
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
!
! /** Zend_Search_Lucene_Document_OpenXml */
! require_once 'Zend/Search/Lucene/Document/OpenXml.php';
!
! /**
! * Xlsx document.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Document
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! */
! class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenXml
! {
! /**
! * Xml Schema - SpreadsheetML
! *
! * @var string
! */
! const SCHEMA_SPREADSHEETML = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main';
!
! /**
! * Xml Schema - DrawingML
! *
! * @var string
! */
! const SCHEMA_DRAWINGML = 'http://schemas.openxmlformats.org/drawingml/2006/main';
!
! /**
! * Xml Schema - Shared Strings
! *
! * @var string
! */
! const SCHEMA_SHAREDSTRINGS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings';
!
! /**
! * Xml Schema - Worksheet relation
! *
! * @var string
! */
! const SCHEMA_WORKSHEETRELATION = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet';
!
! /**
! * Xml Schema - Slide notes relation
! *
! * @var string
! */
! const SCHEMA_SLIDENOTESRELATION = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide';
!
! /**
! * Object constructor
! *
! * @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';
! throw new Zend_Search_Lucene_Exception('MS Office documents processing functionality requires Zip extension to be loaded');
! }
!
! // Document data holders
! $sharedStrings = array();
! $worksheets = array();
! $documentBody = array();
! $coreProperties = array();
!
! // Open OpenXML package
! $package = new ZipArchive();
! $package->open($fileName);
!
! // Read relations and search for officeDocument
! $relationsXml = $package->getFromName('_rels/.rels');
! if ($relationsXml === false) {
! require_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->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)) );
! if (isset($xmlStrings) && isset($xmlStrings->si)) {
! foreach ($xmlStrings->si as $val) {
! if (isset($val->t)) {
! $sharedStrings[] = (string)$val->t;
! } elseif (isset($val->r)) {
! $sharedStrings[] = $this->_parseRichText($val);
! }
! }
! }
!
! // 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"])) )
! );
! }
! }
!
! break;
! }
! }
!
! // Sort worksheets
! ksort($worksheets);
!
! // Extract contents from worksheets
! foreach ($worksheets as $sheetKey => $worksheet) {
! foreach ($worksheet->sheetData->row as $row) {
! foreach ($row->c as $c) {
! // 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 = '';
! }
!
! break;
!
! 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;
! } 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;
! }
! }
! }
!
! // Read core properties
! $coreProperties = $this->extractMetaData($package);
!
! // Close file
! $package->close();
!
! // Store filename
! $this->addField(Zend_Search_Lucene_Field::Text('filename', $fileName, 'UTF-8'));
!
! // Store contents
! if ($storeContent) {
! $this->addField(Zend_Search_Lucene_Field::Text('body', implode(' ', $documentBody), 'UTF-8'));
! } else {
! $this->addField(Zend_Search_Lucene_Field::UnStored('body', implode(' ', $documentBody), 'UTF-8'));
! }
!
! // Store meta data properties
! foreach ($coreProperties as $key => $value)
! {
! $this->addField(Zend_Search_Lucene_Field::Text($key, $value, 'UTF-8'));
! }
!
! // Store title (if not present in meta data)
! if (!isset($coreProperties['title']))
! {
! $this->addField(Zend_Search_Lucene_Field::Text('title', $fileName, 'UTF-8'));
! }
! }
!
! /**
! * Parse rich text XML
! *
! * @param SimpleXMLElement $is
! * @return string
! */
! private function _parseRichText($is = null) {
! $value = array();
!
! if (isset($is->t)) {
! $value[] = (string)$is->t;
! } else {
! foreach ($is->r as $run) {
! $value[] = (string)$run->t;
! }
! }
!
! return implode('', $value);
! }
!
! /**
! * Load Xlsx document from a file
! *
! * @param string $fileName
! * @param boolean $storeContent
! * @return Zend_Search_Lucene_Document_Xlsx
! */
! public static function loadXlsxFile($fileName, $storeContent = false)
! {
! return new Zend_Search_Lucene_Document_Xlsx($fileName, $storeContent);
! }
! }
--- 1,263 ----
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Document
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
!
! /** Zend_Search_Lucene_Document_OpenXml */
! require_once 'Zend/Search/Lucene/Document/OpenXml.php';
!
! /**
! * Xlsx document.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Document
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! */
! class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenXml
! {
! /**
! * Xml Schema - SpreadsheetML
! *
! * @var string
! */
! const SCHEMA_SPREADSHEETML = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main';
!
! /**
! * Xml Schema - DrawingML
! *
! * @var string
! */
! const SCHEMA_DRAWINGML = 'http://schemas.openxmlformats.org/drawingml/2006/main';
!
! /**
! * Xml Schema - Shared Strings
! *
! * @var string
! */
! const SCHEMA_SHAREDSTRINGS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings';
!
! /**
! * Xml Schema - Worksheet relation
! *
! * @var string
! */
! const SCHEMA_WORKSHEETRELATION = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet';
!
! /**
! * Xml Schema - Slide notes relation
! *
! * @var string
! */
! const SCHEMA_SLIDENOTESRELATION = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide';
!
! /**
! * Object constructor
! *
! * @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';
! throw new Zend_Search_Lucene_Exception('MS Office documents processing functionality requires Zip extension to be loaded');
! }
!
! // Document data holders
! $sharedStrings = array();
! $worksheets = array();
! $documentBody = array();
! $coreProperties = array();
!
! // Open OpenXML package
! $package = new ZipArchive();
! $package->open($fileName);
!
! // Read relations and search for officeDocument
! $relationsXml = $package->getFromName('_rels/.rels');
! if ($relationsXml === false) {
! require_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->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)) );
! if (isset($xmlStrings) && isset($xmlStrings->si)) {
! foreach ($xmlStrings->si as $val) {
! if (isset($val->t)) {
! $sharedStrings[] = (string)$val->t;
! } elseif (isset($val->r)) {
! $sharedStrings[] = $this->_parseRichText($val);
! }
! }
! }
!
! // 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"])) )
! );
! }
! }
!
! break;
! }
! }
!
! // Sort worksheets
! ksort($worksheets);
!
! // Extract contents from worksheets
! foreach ($worksheets as $sheetKey => $worksheet) {
! foreach ($worksheet->sheetData->row as $row) {
! foreach ($row->c as $c) {
! // 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 = '';
! }
!
! break;
!
! 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;
! } 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;
! }
! }
! }
!
! // Read core properties
! $coreProperties = $this->extractMetaData($package);
!
! // Close file
! $package->close();
!
! // Store filename
! $this->addField(Zend_Search_Lucene_Field::Text('filename', $fileName, 'UTF-8'));
!
! // Store contents
! if ($storeContent) {
! $this->addField(Zend_Search_Lucene_Field::Text('body', implode(' ', $documentBody), 'UTF-8'));
! } else {
! $this->addField(Zend_Search_Lucene_Field::UnStored('body', implode(' ', $documentBody), 'UTF-8'));
! }
!
! // Store meta data properties
! foreach ($coreProperties as $key => $value)
! {
! $this->addField(Zend_Search_Lucene_Field::Text($key, $value, 'UTF-8'));
! }
!
! // Store title (if not present in meta data)
! if (!isset($coreProperties['title']))
! {
! $this->addField(Zend_Search_Lucene_Field::Text('title', $fileName, 'UTF-8'));
! }
! }
!
! /**
! * Parse rich text XML
! *
! * @param SimpleXMLElement $is
! * @return string
! */
! private function _parseRichText($is = null) {
! $value = array();
!
! if (isset($is->t)) {
! $value[] = (string)$is->t;
! } else {
! foreach ($is->r as $run) {
! $value[] = (string)$run->t;
! }
! }
!
! return implode('', $value);
! }
!
! /**
! * Load Xlsx document from a file
! *
! * @param string $fileName
! * @param boolean $storeContent
! * @return Zend_Search_Lucene_Document_Xlsx
! */
! public static function loadXlsxFile($fileName, $storeContent = false)
! {
! return new Zend_Search_Lucene_Document_Xlsx($fileName, $storeContent);
! }
! }
Modified: branches/stable/titania/includes/library/Zend/Search/Lucene/Exception.php
==============================================================================
*** branches/stable/titania/includes/library/Zend/Search/Lucene/Exception.php (original)
--- branches/stable/titania/includes/library/Zend/Search/Lucene/Exception.php Sat Nov 20 18:23:22 2010
***************
*** 1,37 ****
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
!
! /**
! * Framework base exception
! */
! require_once 'Zend/Search/Exception.php';
!
!
! /**
! * @category Zend
! * @package Zend_Search_Lucene
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! */
! class Zend_Search_Lucene_Exception extends Zend_Search_Exception
! {}
!
--- 1,37 ----
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
!
! /**
! * Framework base exception
! */
! require_once 'Zend/Search/Exception.php';
!
!
! /**
! * @category Zend
! * @package Zend_Search_Lucene
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! */
! class Zend_Search_Lucene_Exception extends Zend_Search_Exception
! {}
!
Modified: branches/stable/titania/includes/library/Zend/Search/Lucene/FSM.php
==============================================================================
*** branches/stable/titania/includes/library/Zend/Search/Lucene/FSM.php (original)
--- branches/stable/titania/includes/library/Zend/Search/Lucene/FSM.php Sat Nov 20 18:23:22 2010
***************
*** 1,443 ****
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
! /** Zend_Search_Lucene_FSMAction */
! require_once 'Zend/Search/Lucene/FSMAction.php';
!
! /**
! * Abstract Finite State Machine
! *
! * Take a look on Wikipedia state machine description: http://en.wikipedia.org/wiki/Finite_state_machine
! *
! * Any type of Transducers (Moore machine or Mealy machine) also may be implemented by using this abstract FSM.
! * 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-2009 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
! {
! /**
! * Machine States alphabet
! *
! * @var array
! */
! private $_states = array();
!
! /**
! * Current state
! *
! * @var integer|string
! */
! private $_currentState = null;
!
! /**
! * Input alphabet
! *
! * @var array
! */
! private $_inputAphabet = array();
!
! /**
! * State transition table
! *
! * [sourceState][input] => targetState
! *
! * @var array
! */
! private $_rules = array();
!
! /**
! * List of entry actions
! * Each action executes when entering the state
! *
! * [state] => action
! *
! * @var array
! */
! private $_entryActions = array();
!
! /**
! * List of exit actions
! * Each action executes when exiting the state
! *
! * [state] => action
! *
! * @var array
! */
! private $_exitActions = array();
!
! /**
! * List of input actions
! * Each action executes when entering the state
! *
! * [state][input] => action
! *
! * @var array
! */
! private $_inputActions = array();
!
! /**
! * List of input actions
! * Each action executes when entering the state
! *
! * [state1][state2] => action
! *
! * @var array
! */
! private $_transitionActions = array();
!
! /**
! * Finite State machine constructor
! *
! * $states is an array of integers or strings with a list of possible machine states
! * constructor treats fist list element as a sturt state (assignes it to $_current state).
! * It may be reassigned by setState() call.
! * States list may be empty and can be extended later by addState() or addStates() calls.
! *
! * $inputAphabet is the same as $states, but represents input alphabet
! * it also may be extended later by addInputSymbols() or addInputSymbol() calls.
! *
! * $rules parameter describes FSM transitions and has a structure:
! * array( array(sourseState, input, targetState[, inputAction]),
! * array(sourseState, input, targetState[, inputAction]),
! * array(sourseState, input, targetState[, inputAction]),
! * ...
! * )
! * Rules also can be added later by addRules() and addRule() calls.
! *
! * FSM actions are very flexible and may be defined by addEntryAction(), addExitAction(),
! * addInputAction() and addTransitionAction() calls.
! *
! * @param array $states
! * @param array $inputAphabet
! * @param array $rules
! */
! public function __construct($states = array(), $inputAphabet = array(), $rules = array())
! {
! $this->addStates($states);
! $this->addInputSymbols($inputAphabet);
! $this->addRules($rules);
! }
!
! /**
! * Add states to the state machine
! *
! * @param array $states
! */
! public function addStates($states)
! {
! foreach ($states as $state) {
! $this->addState($state);
! }
! }
!
! /**
! * Add state to the state machine
! *
! * @param integer|string $state
! */
! public function addState($state)
! {
! $this->_states[$state] = $state;
!
! if ($this->_currentState === null) {
! $this->_currentState = $state;
! }
! }
!
! /**
! * Set FSM state.
! * No any action is invoked
! *
! * @param integer|string $state
! * @throws Zend_Search_Exception
! */
! public function setState($state)
! {
! if (!isset($this->_states[$state])) {
! require_once 'Zend/Search/Exception.php';
! throw new Zend_Search_Exception('State \'' . $state . '\' is not on of the possible FSM states.');
! }
!
! $this->_currentState = $state;
! }
!
! /**
! * Get FSM state.
! *
! * @return integer|string $state|null
! */
! public function getState()
! {
! return $this->_currentState;
! }
!
! /**
! * Add symbols to the input alphabet
! *
! * @param array $inputAphabet
! */
! public function addInputSymbols($inputAphabet)
! {
! foreach ($inputAphabet as $inputSymbol) {
! $this->addInputSymbol($inputSymbol);
! }
! }
!
! /**
! * Add symbol to the input alphabet
! *
! * @param integer|string $inputSymbol
! */
! public function addInputSymbol($inputSymbol)
! {
! $this->_inputAphabet[$inputSymbol] = $inputSymbol;
! }
!
!
! /**
! * Add transition rules
! *
! * array structure:
! * array( array(sourseState, input, targetState[, inputAction]),
! * array(sourseState, input, targetState[, inputAction]),
! * array(sourseState, input, targetState[, inputAction]),
! * ...
! * )
! *
! * @param array $rules
! */
! public function addRules($rules)
! {
! foreach ($rules as $rule) {
! $this->addrule($rule[0], $rule[1], $rule[2], isset($rule[3])?$rule[3]:null);
! }
! }
!
! /**
! * 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
! * @throws Zend_Search_Exception
! */
! public function addRule($sourceState, $input, $targetState, $inputAction = null)
! {
! if (!isset($this->_states[$sourceState])) {
! require_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';
! throw new Zend_Search_Exception('Undefined target state (' . $targetState . ').');
! }
! if (!isset($this->_inputAphabet[$input])) {
! require_once 'Zend/Search/Exception.php';
! throw new Zend_Search_Exception('Undefined input symbol (' . $input . ').');
! }
!
! if (!isset($this->_rules[$sourceState])) {
! $this->_rules[$sourceState] = array();
! }
! if (isset($this->_rules[$sourceState][$input])) {
! require_once 'Zend/Search/Exception.php';
! throw new Zend_Search_Exception('Rule for {state,input} pair (' . $sourceState . ', '. $input . ') is already defined.');
! }
!
! $this->_rules[$sourceState][$input] = $targetState;
!
!
! if ($inputAction !== null) {
! $this->addInputAction($sourceState, $input, $inputAction);
! }
! }
!
!
! /**
! * Add state entry action.
! * Several entry actions are allowed.
! * Action execution order is defined by addEntryAction() calls
! *
! * @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';
! throw new Zend_Search_Exception('Undefined state (' . $state. ').');
! }
!
! if (!isset($this->_entryActions[$state])) {
! $this->_entryActions[$state] = array();
! }
!
! $this->_entryActions[$state][] = $action;
! }
!
! /**
! * Add state exit action.
! * Several exit actions are allowed.
! * Action execution order is defined by addEntryAction() calls
! *
! * @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';
! throw new Zend_Search_Exception('Undefined state (' . $state. ').');
! }
!
! if (!isset($this->_exitActions[$state])) {
! $this->_exitActions[$state] = array();
! }
!
! $this->_exitActions[$state][] = $action;
! }
!
! /**
! * Add input action (defined by {state, input} pair).
! * Several input actions are allowed.
! * Action execution order is defined by addInputAction() calls
! *
! * @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';
! throw new Zend_Search_Exception('Undefined state (' . $state. ').');
! }
! if (!isset($this->_inputAphabet[$inputSymbol])) {
! require_once 'Zend/Search/Exception.php';
! throw new Zend_Search_Exception('Undefined input symbol (' . $inputSymbol. ').');
! }
!
! if (!isset($this->_inputActions[$state])) {
! $this->_inputActions[$state] = array();
! }
! if (!isset($this->_inputActions[$state][$inputSymbol])) {
! $this->_inputActions[$state][$inputSymbol] = array();
! }
!
! $this->_inputActions[$state][$inputSymbol][] = $action;
! }
!
! /**
! * Add transition action (defined by {state, input} pair).
! * Several transition actions are allowed.
! * Action execution order is defined by addTransitionAction() calls
! *
! * @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';
! throw new Zend_Search_Exception('Undefined source state (' . $sourceState. ').');
! }
! if (!isset($this->_states[$targetState])) {
! require_once 'Zend/Search/Exception.php';
! throw new Zend_Search_Exception('Undefined source state (' . $targetState. ').');
! }
!
! if (!isset($this->_transitionActions[$sourceState])) {
! $this->_transitionActions[$sourceState] = array();
! }
! if (!isset($this->_transitionActions[$sourceState][$targetState])) {
! $this->_transitionActions[$sourceState][$targetState] = array();
! }
!
! $this->_transitionActions[$sourceState][$targetState][] = $action;
! }
!
!
! /**
! * Process an input
! *
! * @param mixed $input
! * @throws Zend_Search_Exception
! */
! public function process($input)
! {
! if (!isset($this->_rules[$this->_currentState])) {
! require_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';
! throw new Zend_Search_Exception('There is no any rule for {current state, input} pair (' . $this->_currentState . ', ' . $input . ').');
! }
!
! $sourceState = $this->_currentState;
! $targetState = $this->_rules[$this->_currentState][$input];
!
! if ($sourceState != $targetState && isset($this->_exitActions[$sourceState])) {
! foreach ($this->_exitActions[$sourceState] as $action) {
! $action->doAction();
! }
! }
! if (isset($this->_inputActions[$sourceState]) &&
! isset($this->_inputActions[$sourceState][$input])) {
! foreach ($this->_inputActions[$sourceState][$input] as $action) {
! $action->doAction();
! }
! }
!
!
! $this->_currentState = $targetState;
!
! if (isset($this->_transitionActions[$sourceState]) &&
! isset($this->_transitionActions[$sourceState][$targetState])) {
! foreach ($this->_transitionActions[$sourceState][$targetState] as $action) {
! $action->doAction();
! }
! }
! if ($sourceState != $targetState && isset($this->_entryActions[$targetState])) {
! foreach ($this->_entryActions[$targetState] as $action) {
! $action->doAction();
! }
! }
! }
!
! public function reset()
! {
! if (count($this->_states) == 0) {
! require_once 'Zend/Search/Exception.php';
! throw new Zend_Search_Exception('There is no any state defined for FSM.');
! }
!
! $this->_currentState = $this->_states[0];
! }
! }
!
--- 1,443 ----
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
! /** Zend_Search_Lucene_FSMAction */
! require_once 'Zend/Search/Lucene/FSMAction.php';
!
! /**
! * Abstract Finite State Machine
! *
! * Take a look on Wikipedia state machine description: http://en.wikipedia.org/wiki/Finite_state_machine
! *
! * Any type of Transducers (Moore machine or Mealy machine) also may be implemented by using this abstract FSM.
! * 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-2009 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
! {
! /**
! * Machine States alphabet
! *
! * @var array
! */
! private $_states = array();
!
! /**
! * Current state
! *
! * @var integer|string
! */
! private $_currentState = null;
!
! /**
! * Input alphabet
! *
! * @var array
! */
! private $_inputAphabet = array();
!
! /**
! * State transition table
! *
! * [sourceState][input] => targetState
! *
! * @var array
! */
! private $_rules = array();
!
! /**
! * List of entry actions
! * Each action executes when entering the state
! *
! * [state] => action
! *
! * @var array
! */
! private $_entryActions = array();
!
! /**
! * List of exit actions
! * Each action executes when exiting the state
! *
! * [state] => action
! *
! * @var array
! */
! private $_exitActions = array();
!
! /**
! * List of input actions
! * Each action executes when entering the state
! *
! * [state][input] => action
! *
! * @var array
! */
! private $_inputActions = array();
!
! /**
! * List of input actions
! * Each action executes when entering the state
! *
! * [state1][state2] => action
! *
! * @var array
! */
! private $_transitionActions = array();
!
! /**
! * Finite State machine constructor
! *
! * $states is an array of integers or strings with a list of possible machine states
! * constructor treats fist list element as a sturt state (assignes it to $_current state).
! * It may be reassigned by setState() call.
! * States list may be empty and can be extended later by addState() or addStates() calls.
! *
! * $inputAphabet is the same as $states, but represents input alphabet
! * it also may be extended later by addInputSymbols() or addInputSymbol() calls.
! *
! * $rules parameter describes FSM transitions and has a structure:
! * array( array(sourseState, input, targetState[, inputAction]),
! * array(sourseState, input, targetState[, inputAction]),
! * array(sourseState, input, targetState[, inputAction]),
! * ...
! * )
! * Rules also can be added later by addRules() and addRule() calls.
! *
! * FSM actions are very flexible and may be defined by addEntryAction(), addExitAction(),
! * addInputAction() and addTransitionAction() calls.
! *
! * @param array $states
! * @param array $inputAphabet
! * @param array $rules
! */
! public function __construct($states = array(), $inputAphabet = array(), $rules = array())
! {
! $this->addStates($states);
! $this->addInputSymbols($inputAphabet);
! $this->addRules($rules);
! }
!
! /**
! * Add states to the state machine
! *
! * @param array $states
! */
! public function addStates($states)
! {
! foreach ($states as $state) {
! $this->addState($state);
! }
! }
!
! /**
! * Add state to the state machine
! *
! * @param integer|string $state
! */
! public function addState($state)
! {
! $this->_states[$state] = $state;
!
! if ($this->_currentState === null) {
! $this->_currentState = $state;
! }
! }
!
! /**
! * Set FSM state.
! * No any action is invoked
! *
! * @param integer|string $state
! * @throws Zend_Search_Exception
! */
! public function setState($state)
! {
! if (!isset($this->_states[$state])) {
! require_once 'Zend/Search/Exception.php';
! throw new Zend_Search_Exception('State \'' . $state . '\' is not on of the possible FSM states.');
! }
!
! $this->_currentState = $state;
! }
!
! /**
! * Get FSM state.
! *
! * @return integer|string $state|null
! */
! public function getState()
! {
! return $this->_currentState;
! }
!
! /**
! * Add symbols to the input alphabet
! *
! * @param array $inputAphabet
! */
! public function addInputSymbols($inputAphabet)
! {
! foreach ($inputAphabet as $inputSymbol) {
! $this->addInputSymbol($inputSymbol);
! }
! }
!
! /**
! * Add symbol to the input alphabet
! *
! * @param integer|string $inputSymbol
! */
! public function addInputSymbol($inputSymbol)
! {
! $this->_inputAphabet[$inputSymbol] = $inputSymbol;
! }
!
!
! /**
! * Add transition rules
! *
! * array structure:
! * array( array(sourseState, input, targetState[, inputAction]),
! * array(sourseState, input, targetState[, inputAction]),
! * array(sourseState, input, targetState[, inputAction]),
! * ...
! * )
! *
! * @param array $rules
! */
! public function addRules($rules)
! {
! foreach ($rules as $rule) {
! $this->addrule($rule[0], $rule[1], $rule[2], isset($rule[3])?$rule[3]:null);
! }
! }
!
! /**
! * 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
! * @throws Zend_Search_Exception
! */
! public function addRule($sourceState, $input, $targetState, $inputAction = null)
! {
! if (!isset($this->_states[$sourceState])) {
! require_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';
! throw new Zend_Search_Exception('Undefined target state (' . $targetState . ').');
! }
! if (!isset($this->_inputAphabet[$input])) {
! require_once 'Zend/Search/Exception.php';
! throw new Zend_Search_Exception('Undefined input symbol (' . $input . ').');
! }
!
! if (!isset($this->_rules[$sourceState])) {
! $this->_rules[$sourceState] = array();
! }
! if (isset($this->_rules[$sourceState][$input])) {
! require_once 'Zend/Search/Exception.php';
! throw new Zend_Search_Exception('Rule for {state,input} pair (' . $sourceState . ', '. $input . ') is already defined.');
! }
!
! $this->_rules[$sourceState][$input] = $targetState;
!
!
! if ($inputAction !== null) {
! $this->addInputAction($sourceState, $input, $inputAction);
! }
! }
!
!
! /**
! * Add state entry action.
! * Several entry actions are allowed.
! * Action execution order is defined by addEntryAction() calls
! *
! * @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';
! throw new Zend_Search_Exception('Undefined state (' . $state. ').');
! }
!
! if (!isset($this->_entryActions[$state])) {
! $this->_entryActions[$state] = array();
! }
!
! $this->_entryActions[$state][] = $action;
! }
!
! /**
! * Add state exit action.
! * Several exit actions are allowed.
! * Action execution order is defined by addEntryAction() calls
! *
! * @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';
! throw new Zend_Search_Exception('Undefined state (' . $state. ').');
! }
!
! if (!isset($this->_exitActions[$state])) {
! $this->_exitActions[$state] = array();
! }
!
! $this->_exitActions[$state][] = $action;
! }
!
! /**
! * Add input action (defined by {state, input} pair).
! * Several input actions are allowed.
! * Action execution order is defined by addInputAction() calls
! *
! * @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';
! throw new Zend_Search_Exception('Undefined state (' . $state. ').');
! }
! if (!isset($this->_inputAphabet[$inputSymbol])) {
! require_once 'Zend/Search/Exception.php';
! throw new Zend_Search_Exception('Undefined input symbol (' . $inputSymbol. ').');
! }
!
! if (!isset($this->_inputActions[$state])) {
! $this->_inputActions[$state] = array();
! }
! if (!isset($this->_inputActions[$state][$inputSymbol])) {
! $this->_inputActions[$state][$inputSymbol] = array();
! }
!
! $this->_inputActions[$state][$inputSymbol][] = $action;
! }
!
! /**
! * Add transition action (defined by {state, input} pair).
! * Several transition actions are allowed.
! * Action execution order is defined by addTransitionAction() calls
! *
! * @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';
! throw new Zend_Search_Exception('Undefined source state (' . $sourceState. ').');
! }
! if (!isset($this->_states[$targetState])) {
! require_once 'Zend/Search/Exception.php';
! throw new Zend_Search_Exception('Undefined source state (' . $targetState. ').');
! }
!
! if (!isset($this->_transitionActions[$sourceState])) {
! $this->_transitionActions[$sourceState] = array();
! }
! if (!isset($this->_transitionActions[$sourceState][$targetState])) {
! $this->_transitionActions[$sourceState][$targetState] = array();
! }
!
! $this->_transitionActions[$sourceState][$targetState][] = $action;
! }
!
!
! /**
! * Process an input
! *
! * @param mixed $input
! * @throws Zend_Search_Exception
! */
! public function process($input)
! {
! if (!isset($this->_rules[$this->_currentState])) {
! require_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';
! throw new Zend_Search_Exception('There is no any rule for {current state, input} pair (' . $this->_currentState . ', ' . $input . ').');
! }
!
! $sourceState = $this->_currentState;
! $targetState = $this->_rules[$this->_currentState][$input];
!
! if ($sourceState != $targetState && isset($this->_exitActions[$sourceState])) {
! foreach ($this->_exitActions[$sourceState] as $action) {
! $action->doAction();
! }
! }
! if (isset($this->_inputActions[$sourceState]) &&
! isset($this->_inputActions[$sourceState][$input])) {
! foreach ($this->_inputActions[$sourceState][$input] as $action) {
! $action->doAction();
! }
! }
!
!
! $this->_currentState = $targetState;
!
! if (isset($this->_transitionActions[$sourceState]) &&
! isset($this->_transitionActions[$sourceState][$targetState])) {
! foreach ($this->_transitionActions[$sourceState][$targetState] as $action) {
! $action->doAction();
! }
! }
! if ($sourceState != $targetState && isset($this->_entryActions[$targetState])) {
! foreach ($this->_entryActions[$targetState] as $action) {
! $action->doAction();
! }
! }
! }
!
! public function reset()
! {
! if (count($this->_states) == 0) {
! require_once 'Zend/Search/Exception.php';
! throw new Zend_Search_Exception('There is no any state defined for FSM.');
! }
!
! $this->_currentState = $this->_states[0];
! }
! }
!
Modified: branches/stable/titania/includes/library/Zend/Search/Lucene/FSMAction.php
==============================================================================
*** branches/stable/titania/includes/library/Zend/Search/Lucene/FSMAction.php (original)
--- branches/stable/titania/includes/library/Zend/Search/Lucene/FSMAction.php Sat Nov 20 18:23:22 2010
***************
*** 1,66 ****
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
!
! /**
! * Abstract Finite State Machine
! *
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! */
! class Zend_Search_Lucene_FSMAction
! {
! /**
! * Object reference
! *
! * @var object
! */
! private $_object;
!
! /**
! * Method name
! *
! * @var string
! */
! private $_method;
!
! /**
! * Object constructor
! *
! * @param object $object
! * @param string $method
! */
! public function __construct($object, $method)
! {
! $this->_object = $object;
! $this->_method = $method;
! }
!
! public function doAction()
! {
! $methodName = $this->_method;
! $this->_object->$methodName();
! }
! }
!
--- 1,66 ----
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
!
! /**
! * Abstract Finite State Machine
! *
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! */
! class Zend_Search_Lucene_FSMAction
! {
! /**
! * Object reference
! *
! * @var object
! */
! private $_object;
!
! /**
! * Method name
! *
! * @var string
! */
! private $_method;
!
! /**
! * Object constructor
! *
! * @param object $object
! * @param string $method
! */
! public function __construct($object, $method)
! {
! $this->_object = $object;
! $this->_method = $method;
! }
!
! public function doAction()
! {
! $methodName = $this->_method;
! $this->_object->$methodName();
! }
! }
!
Modified: branches/stable/titania/includes/library/Zend/Search/Lucene/Field.php
==============================================================================
*** branches/stable/titania/includes/library/Zend/Search/Lucene/Field.php (original)
--- branches/stable/titania/includes/library/Zend/Search/Lucene/Field.php Sat Nov 20 18:23:22 2010
***************
*** 1,226 ****
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Document
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
!
! /**
! * A field is a section of a Document. Each field has two parts,
! * a name and a value. Values may be free text or they may be atomic
! * keywords, which are not further processed. Such keywords may
! * be used to represent dates, urls, etc. Fields are optionally
! * stored in the index, so that they may be returned with hits
! * on the document.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Document
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! */
! class Zend_Search_Lucene_Field
! {
! /**
! * Field name
! *
! * @var string
! */
! public $name;
!
! /**
! * Field value
! *
! * @var boolean
! */
! public $value;
!
! /**
! * Field is to be stored in the index for return with search hits.
! *
! * @var boolean
! */
! public $isStored = false;
!
! /**
! * Field is to be indexed, so that it may be searched on.
! *
! * @var boolean
! */
! public $isIndexed = true;
!
! /**
! * Field should be tokenized as text prior to indexing.
! *
! * @var boolean
! */
! public $isTokenized = true;
! /**
! * Field is stored as binary.
! *
! * @var boolean
! */
! public $isBinary = false;
!
! /**
! * Field are stored as a term vector
! *
! * @var boolean
! */
! public $storeTermVector = false;
!
! /**
! * Field boost factor
! * It's not stored directly in the index, but affects on normalization factor
! *
! * @var float
! */
! public $boost = 1.0;
!
! /**
! * Field value encoding.
! *
! * @var string
! */
! public $encoding;
!
! /**
! * Object constructor
! *
! * @param string $name
! * @param string $value
! * @param string $encoding
! * @param boolean $isStored
! * @param boolean $isIndexed
! * @param boolean $isTokenized
! * @param boolean $isBinary
! */
! public function __construct($name, $value, $encoding, $isStored, $isIndexed, $isTokenized, $isBinary = false)
! {
! $this->name = $name;
! $this->value = $value;
!
! if (!$isBinary) {
! $this->encoding = $encoding;
! $this->isTokenized = $isTokenized;
! } else {
! $this->encoding = '';
! $this->isTokenized = false;
! }
!
! $this->isStored = $isStored;
! $this->isIndexed = $isIndexed;
! $this->isBinary = $isBinary;
!
! $this->storeTermVector = false;
! $this->boost = 1.0;
! }
!
!
! /**
! * 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
! * @return Zend_Search_Lucene_Field
! */
! public static function keyword($name, $value, $encoding = '')
! {
! return new self($name, $value, $encoding, true, true, false);
! }
!
!
! /**
! * 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
! * @return Zend_Search_Lucene_Field
! */
! public static function unIndexed($name, $value, $encoding = '')
! {
! return new self($name, $value, $encoding, true, false, false);
! }
!
!
! /**
! * 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
! * @return Zend_Search_Lucene_Field
! */
! public static function binary($name, $value)
! {
! return new self($name, $value, '', true, false, false, true);
! }
!
! /**
! * Constructs a String-valued Field that is tokenized and indexed,
! * 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
! * @return Zend_Search_Lucene_Field
! */
! public static function text($name, $value, $encoding = '')
! {
! return new self($name, $value, $encoding, true, true, true);
! }
!
!
! /**
! * 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
! * @return Zend_Search_Lucene_Field
! */
! public static function unStored($name, $value, $encoding = '')
! {
! return new self($name, $value, $encoding, false, true, true);
! }
!
! /**
! * Get field value in UTF-8 encoding
! *
! * @return string
! */
! public function getUtf8Value()
! {
! if (strcasecmp($this->encoding, 'utf8' ) == 0 ||
! strcasecmp($this->encoding, 'utf-8') == 0 ) {
! return $this->value;
! } else {
!
! return (PHP_OS != 'AIX') ? iconv($this->encoding, 'UTF-8', $this->value) : iconv('ISO8859-1', 'UTF-8', $this->value);
! }
! }
! }
!
--- 1,226 ----
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Document
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
!
! /**
! * A field is a section of a Document. Each field has two parts,
! * a name and a value. Values may be free text or they may be atomic
! * keywords, which are not further processed. Such keywords may
! * be used to represent dates, urls, etc. Fields are optionally
! * stored in the index, so that they may be returned with hits
! * on the document.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Document
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! */
! class Zend_Search_Lucene_Field
! {
! /**
! * Field name
! *
! * @var string
! */
! public $name;
!
! /**
! * Field value
! *
! * @var boolean
! */
! public $value;
!
! /**
! * Field is to be stored in the index for return with search hits.
! *
! * @var boolean
! */
! public $isStored = false;
!
! /**
! * Field is to be indexed, so that it may be searched on.
! *
! * @var boolean
! */
! public $isIndexed = true;
!
! /**
! * Field should be tokenized as text prior to indexing.
! *
! * @var boolean
! */
! public $isTokenized = true;
! /**
! * Field is stored as binary.
! *
! * @var boolean
! */
! public $isBinary = false;
!
! /**
! * Field are stored as a term vector
! *
! * @var boolean
! */
! public $storeTermVector = false;
!
! /**
! * Field boost factor
! * It's not stored directly in the index, but affects on normalization factor
! *
! * @var float
! */
! public $boost = 1.0;
!
! /**
! * Field value encoding.
! *
! * @var string
! */
! public $encoding;
!
! /**
! * Object constructor
! *
! * @param string $name
! * @param string $value
! * @param string $encoding
! * @param boolean $isStored
! * @param boolean $isIndexed
! * @param boolean $isTokenized
! * @param boolean $isBinary
! */
! public function __construct($name, $value, $encoding, $isStored, $isIndexed, $isTokenized, $isBinary = false)
! {
! $this->name = $name;
! $this->value = $value;
!
! if (!$isBinary) {
! $this->encoding = $encoding;
! $this->isTokenized = $isTokenized;
! } else {
! $this->encoding = '';
! $this->isTokenized = false;
! }
!
! $this->isStored = $isStored;
! $this->isIndexed = $isIndexed;
! $this->isBinary = $isBinary;
!
! $this->storeTermVector = false;
! $this->boost = 1.0;
! }
!
!
! /**
! * 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
! * @return Zend_Search_Lucene_Field
! */
! public static function keyword($name, $value, $encoding = '')
! {
! return new self($name, $value, $encoding, true, true, false);
! }
!
!
! /**
! * 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
! * @return Zend_Search_Lucene_Field
! */
! public static function unIndexed($name, $value, $encoding = '')
! {
! return new self($name, $value, $encoding, true, false, false);
! }
!
!
! /**
! * 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
! * @return Zend_Search_Lucene_Field
! */
! public static function binary($name, $value)
! {
! return new self($name, $value, '', true, false, false, true);
! }
!
! /**
! * Constructs a String-valued Field that is tokenized and indexed,
! * 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
! * @return Zend_Search_Lucene_Field
! */
! public static function text($name, $value, $encoding = '')
! {
! return new self($name, $value, $encoding, true, true, true);
! }
!
!
! /**
! * 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
! * @return Zend_Search_Lucene_Field
! */
! public static function unStored($name, $value, $encoding = '')
! {
! return new self($name, $value, $encoding, false, true, true);
! }
!
! /**
! * Get field value in UTF-8 encoding
! *
! * @return string
! */
! public function getUtf8Value()
! {
! if (strcasecmp($this->encoding, 'utf8' ) == 0 ||
! strcasecmp($this->encoding, 'utf-8') == 0 ) {
! return $this->value;
! } else {
!
! return (PHP_OS != 'AIX') ? iconv($this->encoding, 'UTF-8', $this->value) : iconv('ISO8859-1', 'UTF-8', $this->value);
! }
! }
! }
!
Modified: branches/stable/titania/includes/library/Zend/Search/Lucene/Index/DictionaryLoader.php
==============================================================================
*** branches/stable/titania/includes/library/Zend/Search/Lucene/Index/DictionaryLoader.php (original)
--- branches/stable/titania/includes/library/Zend/Search/Lucene/Index/DictionaryLoader.php Sat Nov 20 18:23:22 2010
***************
*** 1,268 ****
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Index
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
! /**
! * Dictionary loader
! *
! * It's a dummy class which is created to encapsulate non-good structured code.
! * 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
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! */
! class Zend_Search_Lucene_Index_DictionaryLoader
! {
! /**
! * Dictionary index loader.
! *
! * It takes a string which is actually <segment_name>.tii index file data and
! * returns two arrays - term and tremInfo lists.
! *
! * See Zend_Search_Lucene_Index_SegmintInfo class for details
! *
! * @param string $data
! * @return array
! * @throws Zend_Search_Lucene_Exception
! */
! public static function load($data)
! {
! $termDictionary = array();
! $termInfos = array();
! $pos = 0;
!
! // $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';
! throw new Zend_Search_Lucene_Exception('Wrong TermInfoIndexFile file format');
! }
!
! // $indexTermCount = $tiiFile->readLong();
! if (PHP_INT_SIZE > 4) {
! $indexTermCount = ord($data[$pos]) << 56 |
! ord($data[$pos+1]) << 48 |
! ord($data[$pos+2]) << 40 |
! ord($data[$pos+3]) << 32 |
! ord($data[$pos+4]) << 24 |
! ord($data[$pos+5]) << 16 |
! 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';
! 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 |
! ord($data[$pos+6]) << 8 |
! ord($data[$pos+7]);
! }
! $pos += 8;
!
! // $tiiFile->readInt(); // IndexInterval
! $pos += 4;
!
! // $skipInterval = $tiiFile->readInt();
! $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';
! throw new Zend_Search_Lucene_Exception('Wrong number of terms in a term dictionary index');
! }
!
! if ($tiVersion == (int)0xFFFFFFFD /* 2.1+ format */) {
! /* Skip MaxSkipLevels value */
! $pos += 4;
! }
!
! $prevTerm = '';
! $freqPointer = 0;
! $proxPointer = 0;
! $indexPointer = 0;
! for ($count = 0; $count < $indexTermCount; $count++) {
! //$termPrefixLength = $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $termPrefixLength = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $termPrefixLength |= ($nbyte & 0x7F) << $shift;
! }
!
! // $termSuffix = $tiiFile->readString();
! $nbyte = ord($data[$pos++]);
! $len = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $len |= ($nbyte & 0x7F) << $shift;
! }
! if ($len == 0) {
! $termSuffix = '';
! } else {
! $termSuffix = substr($data, $pos, $len);
! $pos += $len;
! for ($count1 = 0; $count1 < $len; $count1++ ) {
! if (( ord($termSuffix[$count1]) & 0xC0 ) == 0xC0) {
! $addBytes = 1;
! if (ord($termSuffix[$count1]) & 0x20 ) {
! $addBytes++;
!
! // Never used for Java Lucene created index.
! // Java2 doesn't encode strings in four bytes
! if (ord($termSuffix[$count1]) & 0x10 ) {
! $addBytes++;
! }
! }
! $termSuffix .= substr($data, $pos, $addBytes);
! $pos += $addBytes;
! $len += $addBytes;
!
! // Check for null character. Java2 encodes null character
! // in two bytes.
! if (ord($termSuffix[$count1]) == 0xC0 &&
! ord($termSuffix[$count1+1]) == 0x80 ) {
! $termSuffix[$count1] = 0;
! $termSuffix = substr($termSuffix,0,$count1+1)
! . substr($termSuffix,$count1+2);
! }
! $count1 += $addBytes;
! }
! }
! }
!
! // $termValue = Zend_Search_Lucene_Index_Term::getPrefix($prevTerm, $termPrefixLength) . $termSuffix;
! $pb = 0; $pc = 0;
! while ($pb < strlen($prevTerm) && $pc < $termPrefixLength) {
! $charBytes = 1;
! if ((ord($prevTerm[$pb]) & 0xC0) == 0xC0) {
! $charBytes++;
! if (ord($prevTerm[$pb]) & 0x20 ) {
! $charBytes++;
! if (ord($prevTerm[$pb]) & 0x10 ) {
! $charBytes++;
! }
! }
! }
!
! if ($pb + $charBytes > strlen($data)) {
! // wrong character
! break;
! }
!
! $pc++;
! $pb += $charBytes;
! }
! $termValue = substr($prevTerm, 0, $pb) . $termSuffix;
!
! // $termFieldNum = $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $termFieldNum = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $termFieldNum |= ($nbyte & 0x7F) << $shift;
! }
!
! // $docFreq = $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $docFreq = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $docFreq |= ($nbyte & 0x7F) << $shift;
! }
!
! // $freqPointer += $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $vint = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $vint |= ($nbyte & 0x7F) << $shift;
! }
! $freqPointer += $vint;
!
! // $proxPointer += $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $vint = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $vint |= ($nbyte & 0x7F) << $shift;
! }
! $proxPointer += $vint;
!
! if( $docFreq >= $skipInterval ) {
! // $skipDelta = $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $vint = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $vint |= ($nbyte & 0x7F) << $shift;
! }
! $skipDelta = $vint;
! } else {
! $skipDelta = 0;
! }
!
! // $indexPointer += $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $vint = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $vint |= ($nbyte & 0x7F) << $shift;
! }
! $indexPointer += $vint;
!
!
! // $this->_termDictionary[] = new Zend_Search_Lucene_Index_Term($termValue, $termFieldNum);
! $termDictionary[] = array($termFieldNum, $termValue);
!
! $termInfos[] =
! // new Zend_Search_Lucene_Index_TermInfo($docFreq, $freqPointer, $proxPointer, $skipDelta, $indexPointer);
! array($docFreq, $freqPointer, $proxPointer, $skipDelta, $indexPointer);
!
! $prevTerm = $termValue;
! }
!
! // Check special index entry mark
! if ($termDictionary[0][0] != (int)0xFFFFFFFF) {
! require_once 'Zend/Search/Lucene/Exception.php';
! throw new Zend_Search_Lucene_Exception('Wrong TermInfoIndexFile file format');
! }
!
! if (PHP_INT_SIZE > 4) {
! // Treat 64-bit 0xFFFFFFFF as -1
! $termDictionary[0][0] = -1;
! }
!
! return array($termDictionary, $termInfos);
! }
! }
!
--- 1,268 ----
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Index
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
! /**
! * Dictionary loader
! *
! * It's a dummy class which is created to encapsulate non-good structured code.
! * 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
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! */
! class Zend_Search_Lucene_Index_DictionaryLoader
! {
! /**
! * Dictionary index loader.
! *
! * It takes a string which is actually <segment_name>.tii index file data and
! * returns two arrays - term and tremInfo lists.
! *
! * See Zend_Search_Lucene_Index_SegmintInfo class for details
! *
! * @param string $data
! * @return array
! * @throws Zend_Search_Lucene_Exception
! */
! public static function load($data)
! {
! $termDictionary = array();
! $termInfos = array();
! $pos = 0;
!
! // $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';
! throw new Zend_Search_Lucene_Exception('Wrong TermInfoIndexFile file format');
! }
!
! // $indexTermCount = $tiiFile->readLong();
! if (PHP_INT_SIZE > 4) {
! $indexTermCount = ord($data[$pos]) << 56 |
! ord($data[$pos+1]) << 48 |
! ord($data[$pos+2]) << 40 |
! ord($data[$pos+3]) << 32 |
! ord($data[$pos+4]) << 24 |
! ord($data[$pos+5]) << 16 |
! 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';
! 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 |
! ord($data[$pos+6]) << 8 |
! ord($data[$pos+7]);
! }
! $pos += 8;
!
! // $tiiFile->readInt(); // IndexInterval
! $pos += 4;
!
! // $skipInterval = $tiiFile->readInt();
! $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';
! throw new Zend_Search_Lucene_Exception('Wrong number of terms in a term dictionary index');
! }
!
! if ($tiVersion == (int)0xFFFFFFFD /* 2.1+ format */) {
! /* Skip MaxSkipLevels value */
! $pos += 4;
! }
!
! $prevTerm = '';
! $freqPointer = 0;
! $proxPointer = 0;
! $indexPointer = 0;
! for ($count = 0; $count < $indexTermCount; $count++) {
! //$termPrefixLength = $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $termPrefixLength = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $termPrefixLength |= ($nbyte & 0x7F) << $shift;
! }
!
! // $termSuffix = $tiiFile->readString();
! $nbyte = ord($data[$pos++]);
! $len = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $len |= ($nbyte & 0x7F) << $shift;
! }
! if ($len == 0) {
! $termSuffix = '';
! } else {
! $termSuffix = substr($data, $pos, $len);
! $pos += $len;
! for ($count1 = 0; $count1 < $len; $count1++ ) {
! if (( ord($termSuffix[$count1]) & 0xC0 ) == 0xC0) {
! $addBytes = 1;
! if (ord($termSuffix[$count1]) & 0x20 ) {
! $addBytes++;
!
! // Never used for Java Lucene created index.
! // Java2 doesn't encode strings in four bytes
! if (ord($termSuffix[$count1]) & 0x10 ) {
! $addBytes++;
! }
! }
! $termSuffix .= substr($data, $pos, $addBytes);
! $pos += $addBytes;
! $len += $addBytes;
!
! // Check for null character. Java2 encodes null character
! // in two bytes.
! if (ord($termSuffix[$count1]) == 0xC0 &&
! ord($termSuffix[$count1+1]) == 0x80 ) {
! $termSuffix[$count1] = 0;
! $termSuffix = substr($termSuffix,0,$count1+1)
! . substr($termSuffix,$count1+2);
! }
! $count1 += $addBytes;
! }
! }
! }
!
! // $termValue = Zend_Search_Lucene_Index_Term::getPrefix($prevTerm, $termPrefixLength) . $termSuffix;
! $pb = 0; $pc = 0;
! while ($pb < strlen($prevTerm) && $pc < $termPrefixLength) {
! $charBytes = 1;
! if ((ord($prevTerm[$pb]) & 0xC0) == 0xC0) {
! $charBytes++;
! if (ord($prevTerm[$pb]) & 0x20 ) {
! $charBytes++;
! if (ord($prevTerm[$pb]) & 0x10 ) {
! $charBytes++;
! }
! }
! }
!
! if ($pb + $charBytes > strlen($data)) {
! // wrong character
! break;
! }
!
! $pc++;
! $pb += $charBytes;
! }
! $termValue = substr($prevTerm, 0, $pb) . $termSuffix;
!
! // $termFieldNum = $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $termFieldNum = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $termFieldNum |= ($nbyte & 0x7F) << $shift;
! }
!
! // $docFreq = $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $docFreq = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $docFreq |= ($nbyte & 0x7F) << $shift;
! }
!
! // $freqPointer += $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $vint = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $vint |= ($nbyte & 0x7F) << $shift;
! }
! $freqPointer += $vint;
!
! // $proxPointer += $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $vint = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $vint |= ($nbyte & 0x7F) << $shift;
! }
! $proxPointer += $vint;
!
! if( $docFreq >= $skipInterval ) {
! // $skipDelta = $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $vint = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $vint |= ($nbyte & 0x7F) << $shift;
! }
! $skipDelta = $vint;
! } else {
! $skipDelta = 0;
! }
!
! // $indexPointer += $tiiFile->readVInt();
! $nbyte = ord($data[$pos++]);
! $vint = $nbyte & 0x7F;
! for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) {
! $nbyte = ord($data[$pos++]);
! $vint |= ($nbyte & 0x7F) << $shift;
! }
! $indexPointer += $vint;
!
!
! // $this->_termDictionary[] = new Zend_Search_Lucene_Index_Term($termValue, $termFieldNum);
! $termDictionary[] = array($termFieldNum, $termValue);
!
! $termInfos[] =
! // new Zend_Search_Lucene_Index_TermInfo($docFreq, $freqPointer, $proxPointer, $skipDelta, $indexPointer);
! array($docFreq, $freqPointer, $proxPointer, $skipDelta, $indexPointer);
!
! $prevTerm = $termValue;
! }
!
! // Check special index entry mark
! if ($termDictionary[0][0] != (int)0xFFFFFFFF) {
! require_once 'Zend/Search/Lucene/Exception.php';
! throw new Zend_Search_Lucene_Exception('Wrong TermInfoIndexFile file format');
! }
!
! if (PHP_INT_SIZE > 4) {
! // Treat 64-bit 0xFFFFFFFF as -1
! $termDictionary[0][0] = -1;
! }
!
! return array($termDictionary, $termInfos);
! }
! }
!
Modified: branches/stable/titania/includes/library/Zend/Search/Lucene/Index/DocsFilter.php
==============================================================================
*** branches/stable/titania/includes/library/Zend/Search/Lucene/Index/DocsFilter.php (original)
--- branches/stable/titania/includes/library/Zend/Search/Lucene/Index/DocsFilter.php Sat Nov 20 18:23:22 2010
***************
*** 1,59 ****
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Index
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
!
! /**
! * A Zend_Search_Lucene_Index_DocsFilter is used to filter documents while searching.
! *
! * It may or _may_not_ be used for actual filtering, so it's just a hint that upper query limits
! * search result by specified list.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Index
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! */
! class Zend_Search_Lucene_Index_DocsFilter
! {
! /**
! * Set of segment filters:
! * array( <segmentName> => array(<docId> => <undefined_value>,
! * <docId> => <undefined_value>,
! * <docId> => <undefined_value>,
! * ... ),
! * <segmentName> => array(<docId> => <undefined_value>,
! * <docId> => <undefined_value>,
! * <docId> => <undefined_value>,
! * ... ),
! * <segmentName> => array(<docId> => <undefined_value>,
! * <docId> => <undefined_value>,
! * <docId> => <undefined_value>,
! * ... ),
! * ...
! * )
! *
! * @var array
! */
! public $segmentFilters = array();
! }
!
--- 1,59 ----
! <?php
! /**
! * Zend Framework
! *
! * LICENSE
! *
! * This source file is subject to the new BSD license that is bundled
! * with this package in the file LICENSE.txt.
! * It is also available through the world-wide-web at this URL:
! * http://framework.zend.com/license/new-bsd
! * If you did not receive a copy of the license and are unable to
! * obtain it through the world-wide-web, please send an email
! * to license at zend.com so we can send you a copy immediately.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Index
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! * @version $Id$
! */
!
!
! /**
! * A Zend_Search_Lucene_Index_DocsFilter is used to filter documents while searching.
! *
! * It may or _may_not_ be used for actual filtering, so it's just a hint that upper query limits
! * search result by specified list.
! *
! * @category Zend
! * @package Zend_Search_Lucene
! * @subpackage Index
! * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
! * @license http://framework.zend.com/license/new-bsd New BSD License
! */
! class Zend_Search_Lucene_Index_DocsFilter
! {
! /**
! * Set of segment filters:
! * array( <segmentName> => array(<docId> => <undefined_value>,
! * <docId> => <undefined_value>,
! * <docId> => <undefined_value>,
! * ... ),
! * <segmentName> => array(<docId> => <undefined_value>,
! * <docId> => <undefined_value>,
! * <docId> => <undefined_value>,
! * ... ),
! * <segmentName> => array(<docId> => <undefined_value>,
! * <docId> => <undefined_value>,
! * <docId> => <undefined_value>,
! * ... ),
! * ...
! * )
! *
! * @var array
! */
! public $segmentFilters = array();
! }
!
More information about the customisationdb-commits
mailing list