Exemple #1
0
 /**
  *   -------------------------------------------------------------------------------------------
  *   Принимает вызов, возвращает результаты поиск
  *   @return
  *   -------------------------------------------------------------------------------------------
  */
 public function search($keyword, $start, $limit, $callback)
 {
     try {
         $aResult = Sitemap_Sample::search($keyword, $start, $limit);
         $nTotal = Sitemap_Sample::getTotalCount();
         $this->aOutput['totalcount'] = $nTotal;
         $this->aOutput['item'] = array();
         foreach ($aResult as $row) {
             $this->aOutput['item'][] = array('id' => $row['id'], 'name' => $row['name'], 'full_url' => $row['full_url'], 'date_updated' => $row['unixtimestamp']);
         }
     } catch (Exception $e) {
         $this->aOutput['error'] = 'Ошибка поиска, слишком короткая фраза';
     }
     $this->outputJSONP($callback);
 }
Exemple #2
0
 protected function searchSitemap()
 {
     try {
         ACLUser::checkCurrentUserGrants([SitemapModel::PermissionName]);
         $items = \Sitemap_Sample::search($this->searchPhrase, 0, 10);
     } catch (\Exception $e) {
         $items = [];
     }
     foreach ($items as $row) {
         $isScript = !empty($row['script_admin_url']);
         $add = new SearchResultModel();
         $add->title = $row['name'];
         $add->icon = 'glyphicon glyphicon-user';
         //
         if (!$isScript) {
             $route = CMS::getInstance()->getDispatcher()->getNamed('dashboard.sitemap.manage');
             $add->link = $route->buildUrl() . '?id=' . $row['id'];
         } else {
             $add->link = sprintf('http://%s%s', CMS::getDashboardWWWRoot(), $row['script_admin_url']);
         }
         $this->results[] = $add;
     }
 }