コード例 #1
0
 public function testIndexEvent()
 {
     if (class_module_system_module::getModuleByName("tags") == null || class_module_system_module::getModuleByName("system") == null) {
         return;
     }
     $strSearchKey1 = generateSystemid();
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName($strSearchKey1);
     $objAspect->updateObjectToDb();
     $objSearchCommons = new class_module_search_commons();
     $objSearchParams = new class_module_search_search();
     $objSearchParams->setStrQuery($strSearchKey1);
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 1);
     $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objAspect->getStrSystemid());
     $strSearchKey2 = generateSystemid();
     $objTag = new class_module_tags_tag();
     $objTag->setStrName($strSearchKey2);
     $objTag->updateObjectToDb();
     $objSearchParams = new class_module_search_search();
     $objSearchParams->setStrQuery($strSearchKey2);
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 1);
     $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objTag->getStrSystemid());
     $objTag->assignToSystemrecord($objAspect->getStrSystemid());
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 2);
     $objSearchParams->setStrInternalFilterModules(_system_modul_id_);
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 1);
     $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objAspect->getStrSystemid());
     $objTag->removeFromSystemrecord($objAspect->getStrSystemid());
     //the aspect itself should not be found any more
     $objSearchParams = new class_module_search_search();
     $objSearchParams->setStrQuery($strSearchKey2);
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 1);
     $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objTag->getStrSystemid());
     $objAspect->deleteObjectFromDatabase();
     $objTag->deleteObjectFromDatabase();
 }
コード例 #2
0
 /**
  * Renders the search form with results
  *
  * @permissions view
  * @return string
  * @autoTestable
  */
 protected function actionSearch()
 {
     $strReturn = "";
     $objSearch = new class_module_search_search($this->getParam("systemid"));
     $objForm = $this->getSearchAdminForm($objSearch);
     $objForm->updateSourceObject();
     if ($this->getParam("filtermodules") != "") {
         $objSearch->setStrInternalFilterModules($this->getParam("filtermodules"));
     }
     if ($this->getParam("search_filter_all") != "") {
         $objSearch->setStrInternalFilterModules("-1");
     }
     // Search Form
     $objForm = $this->getSearchAdminForm($objSearch);
     $strReturn .= $objForm->renderForm(class_link::getLinkAdminHref($this->getArrModule("modul"), "search"), class_admin_formgenerator::BIT_BUTTON_SUBMIT);
     // Execute Search
     $objSearchCommons = new class_module_search_commons();
     $arrResult = $objSearchCommons->doAdminSearch($objSearch);
     $objArraySectionIterator = new class_array_section_iterator($objSearchCommons->getIndexedSearchCount($objSearch));
     $objArraySectionIterator->setPageNumber((int) ($this->getParam("pv") != "" ? $this->getParam("pv") : 1));
     $objArraySectionIterator->setArraySection($objSearchCommons->doIndexedSearch($objSearch, $objArraySectionIterator->calculateStartPos(), $objArraySectionIterator->calculateEndPos()));
     //convert entries to real objects
     $arrObjects = array();
     /** @var $objSearchResult class_search_result */
     foreach ($arrResult as $objSearchResult) {
         $arrObjects[] = $objSearchResult->getObjObject();
     }
     $objArraySectionIterator->setArrElements($arrObjects);
     $objArraySectionIterator->setArraySection($objArraySectionIterator->getElementsOnPage(1));
     $strQueryAppend = "&filtermodules=" . $objSearch->getStrInternalFilterModules();
     if ($objSearch->getObjChangeStartdate() != null) {
         $strQueryAppend .= "&search_changestartdate=" . $objSearch->getObjChangeStartdate()->getLongTimestamp();
     }
     if ($objSearch->getObjChangeEnddate() != null) {
         $strQueryAppend .= "&search_changeenddate=" . $objSearch->getObjChangeEnddate()->getLongTimestamp();
     }
     $strReturn .= $this->renderList($objArraySectionIterator, false, "searchResultList", false, "&search_query=" . $objSearch->getStrQuery() . $strQueryAppend);
     return $strReturn;
 }