Ejemplo n.º 1
0
		public function partialReindex() {
			$this->setDataType("settings");
			$this->setActionType("view");

			$lastId = (int) getRequest("lastId");
			$search = searchModel::getInstance();
			
			$total = (int) $search->getAllIndexablePages();
			$limit = regedit::getInstance()->getVal("//modules/search/one_iteration_index");
			if ($limit==0) {
				$limit = 5;
			}
			$result = $search->index_all($limit, $lastId);
			
			$data = Array(
				'index-status' => Array(
					'attribute:current' => $result['current'],
					'attribute:total' => $total,
					'attribute:lastId' => $result['lastId']
				)
			);

			$this->setData($data);
			return $this->doData();
		}
 class searchModelTest extends umiTestCase {private static $testFixtures = array();public static function searchModel() {return searchModel::getInstance();}public static function setUpBeforeClass() {self::searchModel()->truncate_index();$vacd150a6885f609532931d89844070b1 = self::createPageFixture(__CLASS__, 'content', '');$vacd150a6885f609532931d89844070b1->setName(__CLASS__ . ': Страница не в индексе');$vacd150a6885f609532931d89844070b1->setValue('is_unindexed', 1);$vacd150a6885f609532931d89844070b1->setValue('content', 'НеВИндексе');$vacd150a6885f609532931d89844070b1->commit();$v87da0c1d74d7335f83acb6f445b85a44 = self::createPageFixture(__CLASS__, 'content', '');$v87da0c1d74d7335f83acb6f445b85a44->setName(__CLASS__ . ': Страница с ожидаемым весом слов 2');$v87da0c1d74d7335f83acb6f445b85a44->setValue('content', 'Тестовое словосочетание, Тестовое словосочетание, на из под');$v87da0c1d74d7335f83acb6f445b85a44->commit();$vdc45392e1ce06fd88b3ddfd6097b165c = self::createPageFixture(__CLASS__, 'content', '');$vdc45392e1ce06fd88b3ddfd6097b165c->setValue('content', 'Тестовые словосочетания');$vdc45392e1ce06fd88b3ddfd6097b165c->setName(__CLASS__ . ': Страница с ожидаемым весом слов 1');$vdc45392e1ce06fd88b3ddfd6097b165c->commit();$ve70f6935e016a9688ee4aac0770d2c2d = self::createPageFixture(__CLASS__, 'content', '');$ve70f6935e016a9688ee4aac0770d2c2d->setValue('content', 'Тестовое словосочетание');$ve70f6935e016a9688ee4aac0770d2c2d->setValue('h1', 'Тестовое словосочетание');$ve70f6935e016a9688ee4aac0770d2c2d->setValue('title', 'Тестовое словосочетание');$ve70f6935e016a9688ee4aac0770d2c2d->setValue('meta_keywords', 'Тестовое словосочетание');$ve70f6935e016a9688ee4aac0770d2c2d->setValue('meta_descriptions', 'Тестовое словосочетание');$ve70f6935e016a9688ee4aac0770d2c2d->setValue('tags', 'Тестовое словосочетание');$ve70f6935e016a9688ee4aac0770d2c2d->setName(__CLASS__ . ': Страница с ожидаемым весом слов 20');$ve70f6935e016a9688ee4aac0770d2c2d->commit();self::$testFixtures = array($vacd150a6885f609532931d89844070b1, $v87da0c1d74d7335f83acb6f445b85a44, $vdc45392e1ce06fd88b3ddfd6097b165c, $ve70f6935e016a9688ee4aac0770d2c2d);}public static function tearDownAfterClass() {parent::tearDownAfterClass();}public function testValidInstance() {$this->assertInstanceOf('iSearchModel', self::searchModel());}public function testIndexWords() {$v6b0e852a75c7df2e71d825ff0b3e1f6c = array(    "под",    "словосочетание",    "словосочетания",    "тестовое",    "тестовые"   );sort($v6b0e852a75c7df2e71d825ff0b3e1f6c);$result = $this->queryResult('SELECT word FROM cms3_search_index_words');$v4dbdfdb5f7e507c8955733a7117cb0b3 = array();foreach ($result as $vf1965a857bc285d26fe22023aa5ab50d) {$v4dbdfdb5f7e507c8955733a7117cb0b3[] = $vf1965a857bc285d26fe22023aa5ab50d['word'];}$this->assertEquals($v6b0e852a75c7df2e71d825ff0b3e1f6c, $v4dbdfdb5f7e507c8955733a7117cb0b3, 'Проблема с индексацией');}public function testIndexPages() {$v2095ef595ca7725d6314002120972a48 = self::$testFixtures[1]->getId();$v04dbac8856e5a4f10e1486d1b3e601da = self::$testFixtures[2]->getId();$v600268ac8c643efd853a7fc65cdb99e3 = self::$testFixtures[3]->getId();$v6b0e852a75c7df2e71d825ff0b3e1f6c = <<<EOF
Ejemplo n.º 3
0
 public function suggestions($template = 'default', $string = false, $limit = 10)
 {
     if ($string == false) {
         $string = getRequest('suggest-string');
     }
     list($template_block, $template_line, $template_block_empty) = self::loadTemplates("tpls/search/" . $template, "suggestion_block", "suggestion_block_line", "suggestion_block_empty");
     $search = searchModel::getInstance();
     $words = $search->suggestions($string, $limit);
     $total = sizeof($words);
     if ($total == 0) {
         return self::parseTemplate($template_block_empty, array());
     }
     $items_arr = array();
     foreach ($words as $word) {
         $item_arr = array('attribute:count' => $word['cnt'], 'node:word' => $word['word']);
         $items_arr[] = self::parseTemplate($template_line, $item_arr);
     }
     $block_arr = array('words' => array('nodes:word' => $items_arr), 'total' => $total);
     return self::parseTemplate($template_block, $block_arr);
 }
 protected function save()
 {
     $v7ffc4d510260a8544e5550e62ec56bc1 = (int) $this->rel;
     $v94757cae63fd3e398c0811a976dd6bbe = (int) $this->type_id;
     $v78e6dd7a49f5b0cb2106a3a434dd5c86 = (int) $this->lang_id;
     $v662cbf1253ac7d8750ed9190c52163e5 = (int) $this->domain_id;
     $vd02e12eb6d6c3f6ebd763197df01e211 = (int) $this->tpl_id;
     $vaf31437ce61345f416579830a98c91e5 = (int) $this->object_id;
     $v8bef1cc20ada3bef55fdf132cb2a1cb9 = (int) $this->ord;
     $vd84ff935144e00c3e1d395c2379aca47 = self::filterInputString($this->alt_name);
     $v4264c638e0098acb172519b0436db099 = (int) $this->is_active;
     $ve1c6c9ef2fcbe75f26f815c4ef2e60b4 = (int) $this->is_visible;
     $vf49e2553045b3240a95c36854d36dddc = (int) $this->is_deleted;
     $ve0df5a999da22bc6fa9e26b115eb4ae4 = (int) $this->update_time;
     $vf62baf4c4ead98d50d516eca0ac5a746 = (int) $this->is_default;
     if ($vf62baf4c4ead98d50d516eca0ac5a746) {
         $vac5c74b64b4b8352ef2f181affb5ac2a = "UPDATE cms3_hierarchy SET is_default = '0' WHERE is_default = '1' AND lang_id = '{$v78e6dd7a49f5b0cb2106a3a434dd5c86}' AND domain_id = '{$v662cbf1253ac7d8750ed9190c52163e5}'";
         l_mysql_query($vac5c74b64b4b8352ef2f181affb5ac2a);
     }
     $vac5c74b64b4b8352ef2f181affb5ac2a = "UPDATE cms3_hierarchy SET rel = '{$v7ffc4d510260a8544e5550e62ec56bc1}', type_id = '{$v94757cae63fd3e398c0811a976dd6bbe}', lang_id = '{$v78e6dd7a49f5b0cb2106a3a434dd5c86}', domain_id = '{$v662cbf1253ac7d8750ed9190c52163e5}', tpl_id = '{$vd02e12eb6d6c3f6ebd763197df01e211}', obj_id = '{$vaf31437ce61345f416579830a98c91e5}', ord = '{$v8bef1cc20ada3bef55fdf132cb2a1cb9}', alt_name = '{$vd84ff935144e00c3e1d395c2379aca47}', is_active = '{$v4264c638e0098acb172519b0436db099}', is_visible = '{$ve1c6c9ef2fcbe75f26f815c4ef2e60b4}', is_deleted = '{$vf49e2553045b3240a95c36854d36dddc}', updatetime = '{$ve0df5a999da22bc6fa9e26b115eb4ae4}', is_default = '{$vf62baf4c4ead98d50d516eca0ac5a746}' WHERE id = '{$this->id}'";
     l_mysql_query($vac5c74b64b4b8352ef2f181affb5ac2a);
     if ($this->is_updated) {
         $v06a943c59f33a34bb5924aaf72cd2995 = searchModel::getInstance();
         if (PAGES_AUTO_INDEX) {
             if ($this->getIsActive() && $this->getIsDeleted() == false) {
                 $v06a943c59f33a34bb5924aaf72cd2995->index_item($this->id);
             } else {
                 $v06a943c59f33a34bb5924aaf72cd2995->unindex_items($this->id);
             }
         }
     }
     if (!umiHierarchy::$ignoreSiteMap) {
         $this->updateSiteMap(true);
     }
     try {
         $this->updateYML();
     } catch (Exception $ve1671797c52e15f763380b45e841ec32) {
     }
     return true;
 }