protected function setUp() { $objObject = $this->createObject("class_module_system_aspect", ""); self::$arrObjectIds[] = $objObject->getSystemid(); $objSearchIndexWriter = new class_module_search_indexwriter(); $objSearchIndexWriter->clearIndex(); $objSearchDocument_1 = new class_module_search_document(); $objSearchDocument_1->setStrSystemId($objObject->getSystemid()); $objSearchDocument_1->setDocumentId(generateSystemid()); $objSearchDocument_1->addContent("title", "hallo"); $objSearchDocument_1->addContent("text", "welt"); $objSearchDocument_1->addContent("subtitle", "blub"); $objSearchDocument_1->addContent("text2", "blub"); $objObject = $this->createObject("class_module_search_search", ""); self::$arrObjectIds[] = $objObject->getSystemid(); $objSearchDocument_2 = new class_module_search_document(); $objSearchDocument_2->setStrSystemId($objObject->getSystemid()); $objSearchDocument_2->setDocumentId(generateSystemid()); $objSearchDocument_2->addContent("title", "hallo"); $objSearchDocument_2->addContent("text", "welt"); $objObject = $this->createObject("class_module_system_aspect", ""); self::$arrObjectIds[] = $objObject->getSystemid(); $objSearchDocument_3 = new class_module_search_document(); $objSearchDocument_3->setStrSystemId($objObject->getSystemid()); $objSearchDocument_3->setDocumentId(generateSystemid()); $objSearchDocument_3->addContent("title", "lorem ipsum dolor ipsum"); $objSearchDocument_3->addContent("text", "dolor ipsum sit amet, consetetur."); $objSearchIndexWriter->updateSearchDocumentToDb($objSearchDocument_1); $objSearchIndexWriter->updateSearchDocumentToDb($objSearchDocument_2); $objSearchIndexWriter->updateSearchDocumentToDb($objSearchDocument_3); parent::setUp(); }
/** * @see interface_admin_systemtast::executeTask() * @return string */ public function executeTask() { if (!class_module_system_module::getModuleByName("search")->rightEdit()) { return $this->getLang("commons_error_permissions"); } $objWorker = new class_module_search_indexwriter(); if (!class_carrier::getInstance()->getObjSession()->sessionIsset($this->STR_SESSION_KEY)) { //fetch all records to be indexed $strQuery = "SELECT system_id FROM " . _dbprefix_ . "system WHERE system_deleted = 0"; $arrRows = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, array()); $arrIds = array(); foreach ($arrRows as $arrOneRow) { $arrIds[] = $arrOneRow["system_id"]; } $objWorker->clearIndex(); class_carrier::getInstance()->getObjSession()->setSession($this->STR_SESSION_KEY, $arrIds); $this->setParam("totalCount", count($arrIds)); } $arrIds = class_carrier::getInstance()->getObjSession()->getSession($this->STR_SESSION_KEY); if (count($arrIds) == 0) { class_carrier::getInstance()->getObjSession()->sessionUnset($this->STR_SESSION_KEY); return $this->objToolkit->getTextRow($this->getLang("worker_indexrebuild_end", array($objWorker->getNumberOfDocuments(), $objWorker->getNumberOfContentEntries()))); } $intMax = 0; foreach ($arrIds as $intKey => $strOneValue) { $objObject = class_objectfactory::getInstance()->getObject($strOneValue); if ($objObject != null) { $objWorker->indexObject($objObject); } unset($arrIds[$intKey]); if ($intMax++ > 500) { break; } } class_carrier::getInstance()->getObjSession()->setSession($this->STR_SESSION_KEY, $arrIds); //and create a small progress-info $intTotal = $this->getParam("totalCount"); $floatOnePercent = 100 / $intTotal; //and multiply it with the already processed records $intLookupsDone = ((int) $intTotal - count($arrIds)) * $floatOnePercent; $intLookupsDone = round($intLookupsDone, 2); if ($intLookupsDone < 0) { $intLookupsDone = 0; } $this->setStrProgressInformation($this->getLang("worker_indexrebuild", array($objWorker->getNumberOfDocuments(), $objWorker->getNumberOfContentEntries()))); $this->setStrReloadParam("&totalCount=" . $this->getParam("totalCount")); return $intLookupsDone; }