Пример #1
0
 /**
  * Global search event listener
  * Appends the News search results to the search object
  * 
  * @param array $eventArgs
  */
 private function SearchFindContent(array $eventArgs)
 {
     $search = current($eventArgs);
     $term_db = contrexx_raw2db($search->getTerm());
     $query = "SELECT id, text AS content, title, date, redirect,\n               MATCH (text,title,teaser_text) AGAINST ('%{$term_db}%') AS score\n          FROM " . DBPREFIX . "module_news AS tblN\n         INNER JOIN " . DBPREFIX . "module_news_locale AS tblL ON tblL.news_id = tblN.id\n         WHERE (   text LIKE ('%{$term_db}%')\n                OR title LIKE ('%{$term_db}%')\n                OR teaser_text LIKE ('%{$term_db}%'))\n           AND lang_id=" . FRONTEND_LANG_ID . "\n           AND status=1\n           AND is_active=1\n           AND (startdate<='" . date('Y-m-d') . "' OR startdate='0000-00-00')\n           AND (enddate>='" . date('Y-m-d') . "' OR enddate='0000-00-00')";
     $pageUrl = function ($pageUri, $searchData) {
         static $objNewsLib = null;
         if (!$objNewsLib) {
             $objNewsLib = new \Cx\Core_Modules\News\Controller\NewsLibrary();
         }
         if (empty($searchData['redirect'])) {
             $newsId = $searchData['id'];
             $newsCategories = $objNewsLib->getCategoriesByNewsId($newsId);
             $objUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('News', $objNewsLib->findCmdById('details', array_keys($newsCategories)), FRONTEND_LANG_ID, array('newsid' => $newsId));
             $pageUrlResult = $objUrl->toString();
         } else {
             $pageUrlResult = $searchData['redirect'];
         }
         return $pageUrlResult;
     };
     $result = new \Cx\Core_Modules\Listing\Model\Entity\DataSet($search->getResultArray($query, 'News', '', $pageUrl, $search->getTerm()));
     $search->appendResult($result);
 }
 /**
  * Global search event listener
  * Appends the News search results to the search object
  *
  * @param array $eventArgs
  */
 private function SearchFindContent(array $eventArgs)
 {
     $search = current($eventArgs);
     $term_db = contrexx_raw2db($search->getTerm());
     $newsLib = new \Cx\Core_Modules\News\Controller\NewsLibrary();
     $newsLib->getSettings();
     $query = '
         SELECT
             `id`,
             `text` AS "content",
             `title`,
             `date`,
             `redirect`,
             MATCH (
                 `text`,`title`,`teaser_text`
             ) AGAINST (
                 "%' . $term_db . '%"
             ) AS `score`
         FROM
             `' . DBPREFIX . 'module_news` AS `tblN`
         INNER JOIN
             `' . DBPREFIX . 'module_news_locale` AS `nl`
         ON
             `nl`.`news_id` = `tblN`.`id`
         WHERE
             (
                `text` LIKE ("%' . $term_db . '%")
                 OR `title` LIKE ("%' . $term_db . '%")
                 OR `teaser_text` LIKE ("%' . $term_db . '%")
             )' . $newsLib->getNewsFilterQuery('tblN', '', '');
     $pageUrl = function ($pageUri, $searchData) {
         static $objNewsLib = null;
         if (!$objNewsLib) {
             $objNewsLib = new \Cx\Core_Modules\News\Controller\NewsLibrary();
         }
         if (empty($searchData['redirect'])) {
             $newsId = $searchData['id'];
             $newsCategories = $objNewsLib->getCategoriesByNewsId($newsId);
             $objUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('News', $objNewsLib->findCmdById('details', array_keys($newsCategories)), FRONTEND_LANG_ID, array('newsid' => $newsId));
             $pageUrlResult = $objUrl->toString();
         } else {
             $pageUrlResult = $searchData['redirect'];
         }
         return $pageUrlResult;
     };
     $result = new \Cx\Core_Modules\Listing\Model\Entity\DataSet($search->getResultArray($query, 'News', '', $pageUrl, $search->getTerm()));
     $search->appendResult($result);
 }