当前位置: 首页>>代码示例>>PHP>>正文


PHP searchHelper::checkNoHTML方法代码示例

本文整理汇总了PHP中searchHelper::checkNoHTML方法的典型用法代码示例。如果您正苦于以下问题:PHP searchHelper::checkNoHTML方法的具体用法?PHP searchHelper::checkNoHTML怎么用?PHP searchHelper::checkNoHTML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在searchHelper的用法示例。


在下文中一共展示了searchHelper::checkNoHTML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onContentSearch

 /**
  * Tags Search method
  *
  * The sql must return the following fields that are
  * used in a common display routine: href, title, section, created, text,
  * browsernav
  * @param string Target search string
  * @param string mathcing option, exact|any|all
  * @param string ordering option, newest|oldest|popular|alpha|category
  * @param mixed An array if restricted to areas, null if search all
  */
 function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $searchText = $text;
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys(plgSearchTagsAreas()))) {
             return array();
         }
     }
     // load plugin params info
     $plugin = JPluginHelper::getPlugin('search', 'cedtags');
     $pluginParams = new JParameter($plugin->params);
     $limit = $pluginParams->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $rows = $this->searchForText($text, $limit);
     $count = count($rows);
     for ($i = 0; $i < $count; $i++) {
         $link = 'index.php?option=com_cedtag&task=tag&tag=' . CedTagsHelper::urlTagname($rows[$i]->name);
         $rows[$i]->href = JRoute::_($link);
         $rows[$i]->section = JText::_('TAG');
     }
     $return = array();
     foreach ($rows as $key => $tag) {
         if (searchHelper::checkNoHTML($tag, $searchText, array('name', 'title', 'text'))) {
             $return[] = $tag;
         }
     }
     return $return;
 }
开发者ID:lautarodragan,项目名称:ideary,代码行数:42,代码来源:cedtagsearch.php

示例2: plgSearchEvents

function plgSearchEvents($text, $phrase = '', $ordering = '', $areas = null)
{
    require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_search' . DS . 'helpers' . DS . 'search.php';
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchEventsAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'events');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $events = KService::get('com://admin/calendar.model.events')->sort('tbl.start_date')->direction('ASC')->limit($limit)->search($text)->getList();
    $return = array();
    foreach ($events as $event) {
        if (searchHelper::checkNoHTML($event, $text, array('title', 'description'))) {
            $event->text = $event->description;
            $event->origin = 'events';
            $event->href = 'index.php?option=com_calendar&view=event&id=' . $event->id . '&slug=' . $event->slug;
            $event->section = JText::_('Events');
            $return[] = $event->getData();
        }
    }
    return $return;
}
开发者ID:JSWebdesign,项目名称:intranet-platform,代码行数:29,代码来源:events.php

示例3: plgSearchArticles

function plgSearchArticles($text, $phrase = '', $ordering = '', $areas = null)
{
    require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_search' . DS . 'helpers' . DS . 'search.php';
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchArticlesAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'articles');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $articles = KService::get('com://admin/news.model.articles')->sort('tbl.created_on')->direction('DESC')->limit($limit)->search($text)->getList();
    $return = array();
    foreach ($articles as $article) {
        if (searchHelper::checkNoHTML($article, $text, array('title', 'text'))) {
            $article->origin = 'articles';
            $article->href = 'index.php?option=com_news&view=article&id=' . $article->id . '&slug=' . $article->slug;
            $article->section = $article->category_title;
            $return[] = $article->getData();
        }
    }
    return $return;
}
开发者ID:JSWebdesign,项目名称:intranet-platform,代码行数:28,代码来源:articles.php

示例4: onSearch

 /**
  * Categories Search method
  *
  * The sql must return the following fields that are
  * used in a common display routine: href, title, section, created, text,
  * browsernav
  * @param string Target search string
  * @param string mathcing option, exact|any|all
  * @param string ordering option, newest|oldest|popular|alpha|category
  * @param mixed An array if restricted to areas, null if search all
  */
 function onSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $db =& JFactory::getDbo();
     $user =& JFactory::getUser();
     $groups = implode(',', $user->authorisedLevels());
     $searchText = $text;
     require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys(plgSearchCategoryAreas()))) {
             return array();
         }
     }
     // load plugin params info
     $plugin =& JPluginHelper::getPlugin('search', 'categories');
     $pluginParams = new JParameter($plugin->params);
     $limit = $pluginParams->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     switch ($ordering) {
         case 'alpha':
             $order = 'a.title ASC';
             break;
         case 'category':
         case 'popular':
         case 'newest':
         case 'oldest':
         default:
             $order = 'a.title DESC';
     }
     $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
     $query = 'SELECT a.title, a.description AS text, "" AS created, "2" AS browsernav, a.id AS catid,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug' . ' FROM #__categories AS a' . ' WHERE (a.title LIKE ' . $text . ' OR a.description LIKE ' . $text . ')' . ' AND a.published = 1' . ' AND a.access IN (' . $groups . ')' . ' GROUP BY a.id' . ' ORDER BY ' . $order;
     $db->setQuery($query, 0, $limit);
     $rows = $db->loadObjectList();
     $count = count($rows);
     for ($i = 0; $i < $count; $i++) {
         $rows[$i]->href = ContentHelperRoute::getCategoryRoute($rows[$i]->slug);
         $rows[$i]->section = JText::_('Category');
     }
     $return = array();
     foreach ($rows as $key => $category) {
         if (searchHelper::checkNoHTML($category, $searchText, array('name', 'title', 'text'))) {
             $return[] = $category;
         }
     }
     return $return;
 }
开发者ID:joebushi,项目名称:joomla,代码行数:59,代码来源:categories.php

示例5: plgSearchSections

/**
* Sections Search method
*
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
 * @param mixed An array if restricted to areas, null if search all
*/
function plgSearchSections($text, $phrase = '', $ordering = '', $areas = null)
{
    $db =& JFactory::getDBO();
    $user =& JFactory::getUser();
    $searchText = $text;
    require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchSectionAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'sections');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    switch ($ordering) {
        case 'alpha':
            $order = 'a.name ASC';
            break;
        case 'category':
        case 'popular':
        case 'newest':
        case 'oldest':
        default:
            $order = 'a.name DESC';
    }
    $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
    $query = 'SELECT a.title AS title, a.description AS text, a.name, ' . ' "" AS created,' . ' "2" AS browsernav,' . ' a.id AS secid' . ' FROM #__sections AS a' . ' WHERE ( a.name LIKE ' . $text . ' OR a.title LIKE ' . $text . ' OR a.description LIKE ' . $text . ' )' . ' AND a.published = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' GROUP BY a.id' . ' ORDER BY ' . $order;
    $db->setQuery($query, 0, $limit);
    $rows = $db->loadObjectList();
    $count = count($rows);
    for ($i = 0; $i < $count; $i++) {
        $rows[$i]->href = ContentHelperRoute::getSectionRoute($rows[$i]->secid);
        $rows[$i]->section = JText::_('Section');
    }
    $return = array();
    foreach ($rows as $key => $section) {
        if (searchHelper::checkNoHTML($section, $searchText, array('name', 'title', 'text'))) {
            $return[] = $section;
        }
    }
    return $return;
}
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:57,代码来源:sections.php

示例6: onSearch

 /**
  * Weblink Search method
  *
  * The sql must return the following fields that are used in a common display
  * routine: href, title, section, created, text, browsernav
  * @param string Target search string
  * @param string mathcing option, exact|any|all
  * @param string ordering option, newest|oldest|popular|alpha|category
  * @param mixed An array if the search it to be restricted to areas, null if search all
  */
 function onSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $db =& JFactory::getDbo();
     $user =& JFactory::getUser();
     $groups = implode(',', $user->authorisedLevels());
     $searchText = $text;
     require_once JPATH_SITE . '/components/com_weblinks/router.php';
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys(plgSearchWeblinksAreas()))) {
             return array();
         }
     }
     // load plugin params info
     $plugin =& JPluginHelper::getPlugin('search', 'weblinks');
     $pluginParams = new JParameter($plugin->params);
     $limit = $pluginParams->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $section = JText::_('WEB_LINKS');
     $wheres = array();
     switch ($phrase) {
         case 'exact':
             $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
             $wheres2 = array();
             $wheres2[] = 'a.url LIKE ' . $text;
             $wheres2[] = 'a.description LIKE ' . $text;
             $wheres2[] = 'a.title LIKE ' . $text;
             $where = '(' . implode(') OR (', $wheres2) . ')';
             break;
         case 'all':
         case 'any':
         default:
             $words = explode(' ', $text);
             $wheres = array();
             foreach ($words as $word) {
                 $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
                 $wheres2 = array();
                 $wheres2[] = 'a.url LIKE ' . $word;
                 $wheres2[] = 'a.description LIKE ' . $word;
                 $wheres2[] = 'a.title LIKE ' . $word;
                 $wheres[] = implode(' OR ', $wheres2);
             }
             $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
             break;
     }
     switch ($ordering) {
         case 'oldest':
             $order = 'a.date ASC';
             break;
         case 'popular':
             $order = 'a.hits DESC';
             break;
         case 'alpha':
             $order = 'a.title ASC';
             break;
         case 'category':
             $order = 'b.title ASC, a.title ASC';
             break;
         case 'newest':
         default:
             $order = 'a.date DESC';
     }
     $query = 'SELECT a.title AS title, a.description AS text, a.date AS created, a.url, ' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(\':\', b.id, b.alias) ELSE b.id END as catslug, ' . ' CONCAT_WS(" / ", ' . $db->Quote($section) . ', b.title) AS section,' . ' "1" AS browsernav' . ' FROM #__weblinks AS a' . ' INNER JOIN #__categories AS b ON b.id = a.catid' . ' WHERE (' . $where . ')' . ' AND a.state = 1' . ' AND b.published = 1' . ' AND b.access IN (' . $groups . ')' . ' ORDER BY ' . $order;
     $db->setQuery($query, 0, $limit);
     $rows = $db->loadObjectList();
     foreach ($rows as $key => $row) {
         $rows[$key]->href = WeblinksRoute::weblink($row->slug, $row->catslug);
     }
     $return = array();
     foreach ($rows as $key => $weblink) {
         if (searchHelper::checkNoHTML($weblink, $searchText, array('url', 'text', 'title'))) {
             $return[] = $weblink;
         }
     }
     return $return;
 }
开发者ID:joebushi,项目名称:joomla,代码行数:88,代码来源:weblinks.php

示例7: onContentSearch


//.........这里部分代码省略.........
         case 'oldest':
             $order = 'a.date_added ASC';
             break;
         case 'popular':
             $order = 'a.downloads DESC';
             break;
         case 'alpha':
             $order = 'a.file_title ASC';
             break;
         case 'category':
             $order = 'c.title ASC, a.title ASC';
             $morder = 'a.title ASC';
             break;
         case 'newest':
         default:
             $order = 'a.date_added DESC';
             break;
     }
     $uncategorised = JText::_('PLG_SEARCH_JDOWNLOADS_UNCATEGORISED');
     $rows = array();
     $query = $db->getQuery(true);
     // search downloads
     if ($limit > 0) {
         $query->clear();
         //sqlsrv changes
         $case_when = ' CASE WHEN ';
         $case_when .= $query->charLength('a.file_alias');
         $case_when .= ' THEN ';
         $a_id = $query->castAsChar('a.file_id');
         $case_when .= $query->concatenate(array($a_id, 'a.file_alias'), ':');
         $case_when .= ' ELSE ';
         $case_when .= $a_id . ' END as slug';
         $case_when1 = ' CASE WHEN ';
         $case_when1 .= $query->charLength('c.alias');
         $case_when1 .= ' THEN ';
         $c_id = $query->castAsChar('c.id');
         $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
         $case_when1 .= ' ELSE ';
         $case_when1 .= $c_id . ' END as catslug';
         $query->select('a.file_title AS title, a.metadesc, a.metakey, a.date_added AS created, a.language, a.author, a.url_download, a.extern_file, a.password, a.license_agree, a.other_file_id');
         $query->select($query->concatenate(array('a.description', 'a.description_long')) . ' AS text');
         $query->select('CASE c.title WHEN \'root\' THEN ' . $db->Quote($uncategorised) . ' ELSE c.title END AS section, ' . $case_when . ',' . $case_when1 . ', ' . '\'2\' AS browsernav');
         $query->from('#__jdownloads_files AS a');
         $query->innerJoin('#__jdownloads_categories AS c ON c.id = a.cat_id');
         $query->where('(' . $where . ')' . 'AND a.published = 1 AND c.published = 1 AND a.access IN (' . $groups . ') ' . 'AND c.access IN (' . $groups . ') ' . 'AND (a.publish_from = ' . $db->Quote($nullDate) . ' OR a.publish_from <= ' . $db->Quote($now) . ') ' . 'AND (a.publish_to = ' . $db->Quote($nullDate) . ' OR a.publish_to >= ' . $db->Quote($now) . ')');
         $query->group('a.file_id, a.file_title, a.metadesc, a.metakey, a.date_added, a.description, a.description_long, c.title, a.file_alias, c.alias, c.id, a.author');
         $query->order($order);
         // Filter by language
         if ($app->isSite() && $app->getLanguageFilter()) {
             $query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
             $query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
         }
         $db->setQuery($query, 0, $limit);
         $list = $db->loadObjectList();
         $limit -= count($list);
         if (isset($list)) {
             $jlistConfig = JDHelper::buildjlistConfig();
             $user_rules = JDHelper::getUserRules();
             foreach ($list as $key => $item) {
                 $direct_download = $jlistConfig['direct.download'];
                 if (!$item->url_download && !$item->extern_file && !$item->other_file_id || $item->password || $item->license_agree || $user_rules->view_captcha) {
                     // this download is a simple document without a file so we can not use 'direct' download option
                     // or we need the summary page for password, captcha or license agree
                     $direct_download = 0;
                 }
                 if ($jlistConfig['view.detailsite']) {
                     // we must link to the details page
                     $list[$key]->href = JDownloadsHelperRoute::getDownloadRoute($item->slug, $item->catslug, $item->language);
                 } else {
                     if ($direct_download) {
                         // we must start the download process directly
                         $list[$key]->href = JRoute::_('index.php?option=com_jdownloads&amp;task=download.send&amp;id=' . (int) $item->slug . '&amp;catid=' . (int) $item->catslug . '&amp;m=0');
                     } else {
                         if (!$item->url_download && !$item->extern_file && !$item->other_file_id) {
                             // Download is only a simple document without a file so we must link to the details page
                             $list[$key]->href = JDownloadsHelperRoute::getDownloadRoute($item->slug, $item->catslug, $item->language);
                         } else {
                             // we must link to the summary page
                             $list[$key]->href = JRoute::_('index.php?option=com_jdownloads&amp;view=summary&amp;id=' . $item->slug . '&amp;catid=' . (int) $item->catslug);
                         }
                     }
                 }
             }
         }
         $rows[] = $list;
     }
     $results = array();
     if (count($rows)) {
         foreach ($rows as $row) {
             $new_row = array();
             foreach ($row as $key => $download) {
                 if (searchHelper::checkNoHTML($download, $searchText, array('text', 'title', 'metadesc', 'metakey', 'author'))) {
                     $new_row[] = $download;
                 }
             }
             $results = array_merge($results, (array) $new_row);
         }
     }
     return $results;
 }
开发者ID:madcsaba,项目名称:li-de,代码行数:101,代码来源:jdownloads.php

示例8: plgSearchContent


//.........这里部分代码省略.........
            $wheres2 = array();
            $wheres2[] = 'a.title LIKE ' . $text;
            $wheres2[] = 'a.introtext LIKE ' . $text;
            $wheres2[] = 'a.`fulltext` LIKE ' . $text;
            $wheres2[] = 'a.metakey LIKE ' . $text;
            $wheres2[] = 'a.metadesc LIKE ' . $text;
            $where = '(' . implode(') OR (', $wheres2) . ')';
            break;
        case 'all':
        case 'any':
        default:
            $words = explode(' ', $text);
            $wheres = array();
            foreach ($words as $word) {
                $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
                $wheres2 = array();
                $wheres2[] = 'a.title LIKE ' . $word;
                $wheres2[] = 'a.introtext LIKE ' . $word;
                $wheres2[] = 'a.`fulltext` LIKE ' . $word;
                $wheres2[] = 'a.metakey LIKE ' . $word;
                $wheres2[] = 'a.metadesc LIKE ' . $word;
                $wheres[] = implode(' OR ', $wheres2);
            }
            $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
            break;
    }
    $morder = '';
    switch ($ordering) {
        case 'oldest':
            $order = 'a.created ASC';
            break;
        case 'popular':
            $order = 'a.hits DESC';
            break;
        case 'alpha':
            $order = 'a.title ASC';
            break;
        case 'category':
            $order = 'b.title ASC, a.title ASC';
            $morder = 'a.title ASC';
            break;
        case 'newest':
        default:
            $order = 'a.created DESC';
            break;
    }
    $rows = array();
    // search articles
    if ($sContent && $limit > 0) {
        $query = 'SELECT a.title AS title, a.metadesc, a.metakey,' . ' a.created AS created,' . ' CONCAT(a.introtext, a.`fulltext`) AS text,' . ' CONCAT_WS( "/", u.title, b.title ) AS section,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(":", b.id, b.alias) ELSE b.id END as catslug,' . ' u.id AS sectionid,' . ' "2" AS browsernav' . ' FROM #__content AS a' . ' INNER JOIN #__categories AS b ON b.id=a.catid' . ' INNER JOIN #__sections AS u ON u.id = a.sectionid' . ' WHERE ( ' . $where . ' )' . ' AND a.state = 1' . ' AND u.published = 1' . ' AND b.published = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' AND b.access <= ' . (int) $user->get('aid') . ' AND u.access <= ' . (int) $user->get('aid') . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )' . ' GROUP BY a.id' . ' ORDER BY ' . $order;
        $db->setQuery($query, 0, $limit);
        $list = $db->loadObjectList();
        $limit -= count($list);
        if (isset($list)) {
            foreach ($list as $key => $item) {
                $list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid);
            }
        }
        $rows[] = $list;
    }
    // search uncategorised content
    if ($sUncategorised && $limit > 0) {
        $query = 'SELECT id, a.title AS title, a.created AS created, a.metadesc, a.metakey, ' . ' a.introtext AS text,' . ' "2" as browsernav, "' . $db->Quote(JText::_('Uncategorised Content')) . '" AS section' . ' FROM #__content AS a' . ' WHERE (' . $where . ')' . ' AND a.state = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' AND a.sectionid = 0' . ' AND a.catid = 0' . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )' . ' ORDER BY ' . ($morder ? $morder : $order);
        $db->setQuery($query, 0, $limit);
        $list2 = $db->loadObjectList();
        $limit -= count($list2);
        if (isset($list2)) {
            foreach ($list2 as $key => $item) {
                $list2[$key]->href = ContentHelperRoute::getArticleRoute($item->id);
            }
        }
        $rows[] = $list2;
    }
    // search archived content
    if ($sArchived && $limit > 0) {
        $searchArchived = JText::_('Archived');
        $query = 'SELECT a.title AS title, a.metadesc, a.metakey,' . ' a.created AS created,' . ' a.introtext AS text,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(":", b.id, b.alias) ELSE b.id END as catslug,' . ' u.id AS sectionid,' . ' "2" AS browsernav' . ' FROM #__content AS a' . ' INNER JOIN #__categories AS b ON b.id=a.catid AND b.access <= ' . $user->get('gid') . ' INNER JOIN #__sections AS u ON u.id = a.sectionid' . ' WHERE ( ' . $where . ' )' . ' AND a.state = -1' . ' AND u.published = 1' . ' AND b.published = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' AND b.access <= ' . (int) $user->get('aid') . ' AND u.access <= ' . (int) $user->get('aid') . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )' . ' ORDER BY ' . $order;
        $db->setQuery($query, 0, $limit);
        $list3 = $db->loadObjectList();
        if (isset($list3)) {
            foreach ($list3 as $key => $item) {
                $list3[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid);
            }
        }
        $rows[] = $list3;
    }
    $results = array();
    if (count($rows)) {
        foreach ($rows as $row) {
            $new_row = array();
            foreach ($row as $key => $article) {
                if (searchHelper::checkNoHTML($article, $searchText, array('text', 'title', 'metadesc', 'metakey'))) {
                    $new_row[] = $article;
                }
            }
            $results = array_merge($results, (array) $new_row);
        }
    }
    return $results;
}
开发者ID:esumerfd,项目名称:ssol_joomla,代码行数:101,代码来源:content.php

示例9: onContentSearch

 function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $searchText = $text;
     require_once JPATH_SITE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'helpers' . DS . 'route.php';
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return array();
         }
     }
     // load plugin params info
     $plugin = JPluginHelper::getPlugin('search', 'djcatalog2');
     $pluginParams = $this->params;
     $limit = $pluginParams->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $query = $db->getQuery(true);
     $query->select('image.fullpath AS image, i.id AS id, i.alias as alias, i.name AS title, i.intro_desc AS intro, i.created as created, c.id AS catid, c.name AS category, c.alias as catalias, i.description as text, i.metakey as metakey, i.metadesc as metadesc, p.name as producer_name, "2" as browsernav');
     $query->from('#__djc2_items AS i');
     $where = '';
     $textSearch = array();
     switch ($phrase) {
         case 'exact':
             $textSearch[] = 'LOWER(i.name) LIKE ' . $db->quote('%' . $db->escape($text, true) . '%', false);
             $textSearch[] = 'LOWER(i.description) LIKE ' . $db->quote('%' . $db->escape($text, true) . '%', false);
             $textSearch[] = 'LOWER(i.intro_desc) LIKE ' . $db->quote('%' . $db->escape($text, true) . '%', false);
             $textSearch[] = 'LOWER(i.metadesc) LIKE ' . $db->quote('%' . $db->escape($text, true) . '%', false);
             $textSearch[] = 'LOWER(i.metakey) LIKE ' . $db->quote('%' . $db->escape($text, true) . '%', false);
             $textSearch[] = 'LOWER(c.name) LIKE ' . $db->quote('%' . $db->escape($text, true) . '%', false);
             $textSearch[] = 'LOWER(p.name) LIKE ' . $db->quote('%' . $db->escape($text, true) . '%', false);
             $optionsSearch = ' select i.id ' . ' from #__djc2_items as i ' . ' inner join #__djc2_items_extra_fields_values_int as efv on efv.item_id = i.id' . ' inner join #__djc2_items_extra_fields as ef on ef.id = efv.field_id and ef.searchable = 1 ' . ' inner join #__djc2_items_extra_fields_options as efo on efo.id = efv.value and lower(efo.value) like ' . $db->quote('%' . $db->escape($text, true) . '%', false) . ' union ' . 'select i.id ' . ' from #__djc2_items as i ' . ' inner join #__djc2_items_extra_fields_values_text as efv on efv.item_id = i.id' . ' inner join #__djc2_items_extra_fields as ef on ef.id = efv.field_id and ef.searchable = 1 and lower(efv.value) like ' . $db->quote('%' . $db->escape($text, true) . '%', false);
             $query->join('LEFT', '(' . $optionsSearch . ') AS customattribute_search ON customattribute_search.id = i.id');
             $textSearch[] = 'i.id = customattribute_search.id';
             $where = ' ( ' . implode(' OR ', $textSearch) . ' ) ';
             break;
         case 'all':
         case 'any':
         default:
             $words = explode(' ', $text);
             $textSearches = array();
             foreach ($words as $k => $word) {
                 $textSearch = array();
                 $textSearch[] = 'LOWER(i.name) LIKE ' . $db->quote('%' . $db->escape($word, true) . '%', false);
                 $textSearch[] = 'LOWER(i.description) LIKE ' . $db->quote('%' . $db->escape($word, true) . '%', false);
                 $textSearch[] = 'LOWER(i.intro_desc) LIKE ' . $db->quote('%' . $db->escape($word, true) . '%', false);
                 $textSearch[] = 'LOWER(i.metadesc) LIKE ' . $db->quote('%' . $db->escape($word, true) . '%', false);
                 $textSearch[] = 'LOWER(i.metakey) LIKE ' . $db->quote('%' . $db->escape($word, true) . '%', false);
                 $textSearch[] = 'LOWER(c.name) LIKE ' . $db->quote('%' . $db->escape($word, true) . '%', false);
                 $textSearch[] = 'LOWER(p.name) LIKE ' . $db->quote('%' . $db->escape($word, true) . '%', false);
                 $optionsSearch = ' select i.id ' . ' from #__djc2_items as i ' . ' inner join #__djc2_items_extra_fields_values_int as efv on efv.item_id = i.id' . ' inner join #__djc2_items_extra_fields as ef on ef.id = efv.field_id and ef.searchable = 1 ' . ' inner join #__djc2_items_extra_fields_options as efo on efo.id = efv.value and lower(efo.value) like ' . $db->quote('%' . $db->escape($word, true) . '%', false) . ' union ' . 'select i.id ' . ' from #__djc2_items as i ' . ' inner join #__djc2_items_extra_fields_values_text as efv on efv.item_id = i.id' . ' inner join #__djc2_items_extra_fields as ef on ef.id = efv.field_id and ef.searchable = 1 and lower(efv.value) like ' . $db->quote('%' . $db->escape($word, true) . '%', false);
                 $query->join('LEFT', '(' . $optionsSearch . ') AS customattribute_search_' . $k . ' ON customattribute_search_' . $k . '.id = i.id');
                 $textSearch[] = 'i.id = customattribute_search_' . $k . '.id';
                 $textSearches[] = implode(' OR ', $textSearch);
             }
             $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $textSearches) . ')';
             break;
     }
     $query->join('left', '#__djc2_categories AS c ON c.id = i.cat_id');
     $query->join('left', '#__djc2_producers AS p ON p.id = i.producer_id');
     $query->join('left', '#__djc2_images AS image ON image.item_id = i.id');
     $lang = JFactory::getLanguage();
     $query->where($where . " AND i.published=1 AND c.published=1 AND image.ordering = 1 AND i.language = '{$lang->getTag()}'");
     $query->group('i.id');
     switch ($ordering) {
         case 'alpha':
             $order = 'i.name ASC';
             break;
         case 'category':
         case 'popular':
         case 'newest':
         case 'oldest':
         default:
             $order = 'i.name DESC';
     }
     $query->order($order);
     $db->setQuery($query, 0, $limit);
     //echo str_replace('#_','jos',$query);
     $rows = $db->loadObjectList();
     $count = count($rows);
     for ($i = 0; $i < $count; $i++) {
         $rows[$i]->href = JRoute::_(DJCatalogHelperRoute::getItemRoute($rows[$i]->id . ':' . $rows[$i]->alias, $rows[$i]->catid . ':' . $rows[$i]->catalias));
         $rows[$i]->section = JText::_('PLG_SEARCH_DJCATALOG2_DJCATALOGITEMS') . ': ' . $rows[$i]->category;
         // because extra attributes are also taken into accout, we have to trick checkNoHTML function
         $rows[$i]->__term = $searchText;
     }
     $return = array();
     foreach ($rows as $key => $section) {
         if (searchHelper::checkNoHTML($section, $searchText, array('title', 'text', 'intro', 'metadesc', 'metakey', 'producer_name', '__term'))) {
             $return[] = $section;
         }
     }
     return $return;
 }
开发者ID:ForAEdesWeb,项目名称:AEW25,代码行数:96,代码来源:djcatalog2.php

示例10: onContentSearch


//.........这里部分代码省略.........
         case 'newest':
             $order = 'i.created DESC';
             break;
         default:
             $order = 'i.created DESC';
             break;
     }
     // ****************************************************************************************
     // Create JOIN clause and WHERE clause part for filtering by current (viewing) access level
     // ****************************************************************************************
     $joinaccess = '';
     $andaccess = '';
     $select_access = '';
     // Extra access columns for main category and content type (item access will be added as 'access')
     $select_access .= ',  c.access as category_access, ty.access as type_access';
     if (!$show_noauth) {
         // User not allowed to LIST unauthorized items
         if (FLEXI_J16GE) {
             $aid_arr = JAccess::getAuthorisedViewLevels($user->id);
             $aid_list = implode(",", $aid_arr);
             $andaccess .= ' AND ty.access IN (0,' . $aid_list . ')';
             $andaccess .= ' AND  c.access IN (0,' . $aid_list . ')';
             $andaccess .= ' AND  i.access IN (0,' . $aid_list . ')';
         } else {
             $aid = (int) $user->get('aid');
             if (FLEXI_ACCESS) {
                 $joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gt ON ty.id = gt.axo AND gt.aco = "read" AND gt.axosection = "type"';
                 $joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gc ON  c.id = gc.axo AND gc.aco = "read" AND gc.axosection = "category"';
                 $joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gi ON  i.id = gi.axo AND gi.aco = "read" AND gi.axosection = "item"';
                 $andaccess .= ' AND (gt.aro IN ( ' . $user->gmid . ' ) OR ty.access <= ' . $aid . ')';
                 $andaccess .= ' AND (gc.aro IN ( ' . $user->gmid . ' ) OR  c.access <= ' . $aid . ')';
                 $andaccess .= ' AND (gi.aro IN ( ' . $user->gmid . ' ) OR  i.access <= ' . $aid . ')';
             } else {
                 $andaccess .= ' AND ty.access <= ' . $aid;
                 $andaccess .= ' AND  c.access <= ' . $aid;
                 $andaccess .= ' AND  i.access <= ' . $aid;
             }
         }
         $select_access .= ', 1 AS has_access';
     } else {
         // Access Flags for: content type, main category, item
         if (FLEXI_J16GE) {
             $aid_arr = JAccess::getAuthorisedViewLevels($user->id);
             $aid_list = implode(",", $aid_arr);
             $select_access .= ', ' . ' CASE WHEN ' . '  ty.access IN (' . $aid_list . ') AND ' . '   c.access IN (' . $aid_list . ') AND ' . '   i.access IN (' . $aid_list . ') ' . ' THEN 1 ELSE 0 END AS has_access';
         } else {
             $aid = (int) $user->get('aid');
             if (FLEXI_ACCESS) {
                 $joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gt ON ty.id = gt.axo AND gt.aco = "read" AND gt.axosection = "type"';
                 $joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gc ON  c.id = gc.axo AND gc.aco = "read" AND gc.axosection = "category"';
                 $joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gi ON  i.id = gi.axo AND gi.aco = "read" AND gi.axosection = "item"';
                 $select_access .= ', ' . ' CASE WHEN ' . '  (gt.aro IN ( ' . $user->gmid . ' ) OR ty.access <= ' . (int) $aid . ') AND ' . '  (gc.aro IN ( ' . $user->gmid . ' ) OR  c.access <= ' . (int) $aid . ') AND ' . '  (gi.aro IN ( ' . $user->gmid . ' ) OR  i.access <= ' . (int) $aid . ') ' . ' THEN 1 ELSE 0 END AS has_access';
             } else {
                 $select_access .= ', ' . ' CASE WHEN ' . '  (ty.access <= ' . (int) $aid . ') AND ' . '  ( c.access <= ' . (int) $aid . ') AND ' . '  ( i.access <= ' . (int) $aid . ') ' . ' THEN 1 ELSE 0 END AS has_access';
             }
         }
     }
     // **********************************************************************************************************************************************************
     // Create WHERE clause part for filtering by current active language, and current selected contend types ( !! although this is possible via a filter too ...)
     // **********************************************************************************************************************************************************
     $andlang = '';
     if ($app->isSite() && (FLEXI_FISH || FLEXI_J16GE && $app->getLanguageFilter()) && $filter_lang) {
         $andlang .= ' AND ( i.language LIKE ' . $db->Quote($lang . '%') . ' OR i.language="*" ) ';
         $andlang .= ' AND ( c.language LIKE ' . $db->Quote($lang . '%') . ' OR c.language="*" ) ';
     }
     // search articles
     $results = array();
     if ($limit > 0) {
         $query = $db->getQuery(true);
         $query->clear();
         $query->select('' . ' i.id as id,' . ' i.title AS title,' . ' i.language AS language,' . ' i.metakey AS metakey,' . ' i.metadesc AS metadesc,' . ' i.modified AS created,' . ' t.name AS tagname,' . ' fir.value as field,' . ' i.access, ie.type_id,' . ' CONCAT(i.introtext, i.fulltext) AS text,' . ' CONCAT_WS( " / ", ' . $db->Quote(JText::_('FLEXICONTENT')) . ', c.title, i.title ) AS section,' . ' CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(\':\', i.id, i.alias) ELSE i.id END AS slug,' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END AS catslug,' . ' "2" AS browsernav' . $select_access);
         $query->from('#__content AS i ' . ' JOIN #__categories AS c ON i.catid = c.id' . ' JOIN #__flexicontent_items_ext AS ie ON i.id = ie.item_id' . ' JOIN #__flexicontent_types AS ty ON ie.type_id = ty.id' . ' LEFT JOIN #__flexicontent_fields_item_relations AS fir ON i.id = fir.item_id' . ' LEFT JOIN #__flexicontent_fields AS f ON fir.field_id = f.id' . ' LEFT JOIN #__flexicontent_tags_item_relations AS tir ON i.id = tir.itemid' . ' LEFT JOIN #__flexicontent_tags AS t ON tir.tid = t.id	' . $joinaccess);
         $query->where(' (' . $where . ') ' . ' AND ie.type_id IN(' . $types . ') ' . ' AND i.state IN (1, -5) AND c.published = 1 ' . ' AND (i.publish_up = ' . $db->Quote($nullDate) . ' OR i.publish_up <= ' . $db->Quote($nowDate) . ') ' . ' AND (i.publish_down = ' . $db->Quote($nullDate) . ' OR i.publish_down >= ' . $db->Quote($nowDate) . ') ' . $andaccess . $andlang);
         $query->group('i.id');
         $query->order($order);
         //echo "<pre style='white-space:normal!important;'>".$query."</pre>";
         $db->setQuery($query, 0, $limit);
         $list = $db->loadObjectList();
         if ($db->getErrorNum()) {
             echo $db->getErrorMsg();
         }
         if ($list) {
             $item_cats = FlexicontentFields::_getCategories($list);
             foreach ($list as $key => $item) {
                 // echo $item->title." ".$item->tagname."<br/>"; // Before checking for noHTML
                 if (FLEXI_J16GE || $item->sectionid == FLEXI_SECTION) {
                     $item->categories = isset($item_cats[$item->id]) ? $item_cats[$item->id] : array();
                     // in case of item categories missing
                     $item->href = JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $item->catslug, 0, $item));
                 } else {
                     $item->href = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid));
                 }
                 if (searchHelper::checkNoHTML($item, $searchText, array('title', 'metadesc', 'metakey', 'tagname', 'field', 'text'))) {
                     $results[$item->id] = $item;
                 }
             }
         }
     }
     return $results;
 }
开发者ID:noxidsoft,项目名称:flexicontent-cck,代码行数:101,代码来源:flexisearch.php

示例11: onContentSearch

    /**
     * Search method
     *
     * The sql must return the following fields that are used in a common display
     * routine: href, title, section, created, text, browsernav
     *
     * @param string $keyword Target search string
     * @param string $type  matching option, exact|any|all
     * @param string $order ordering option, newest|oldest|popular|alpha|category
     * @param null   $areas An array if the search it to be restricted to areas, null if search all
     *
     * @return array results
     */
    public function onContentSearch($keyword, $type='', $order='', $areas=null)
    {
        if (is_array($areas))
        {
            if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
                return array();
            }
        }

        $keyword = trim($keyword);
        if (empty($keyword)) {
            return array();
        }

        $return = array();
        $pages  = KObjectManager::getInstance()->getObject('com://admin/docman.model.pages')->fetch();
        if (count($pages))
        {
            $limit = $this->params->def('search_limit', 50);

            $order_map = array(
                'default'  => array('tbl.title', 'ASC'),
                'oldest'   => array('tbl.created_on', 'ASC'),
                'newest'   => array('tbl.created_on', 'DESC'),
                'category' => array('category_title', 'ASC'),
                'popular'  => array('tbl.hits', 'DESC')
            );

            if (!array_key_exists($order, $order_map)) {
                $order = 'default';
            }
            list($sort, $direction) = $order_map[$order];

            $user = KObjectManager::getInstance()->getObject('user');

            $model = KObjectManager::getInstance()->getObject('com://admin/docman.model.documents');
            $model->enabled(1)
                ->status('published')
                ->current_user($user->getId())
                ->access($user->getRoles())
                ->page('all')
                ->search($keyword)
                ->search_by($type)
                ->limit($limit)
                ->sort($sort)
                ->direction($direction);

            $list = $model->fetch();

            if (!count($list)) {
                return array();
            }

            $return = array();
            foreach ($list as $item)
            {
                if (!$item->itemid || !searchHelper::checkNoHTML($item, $keyword, array('title', 'description'))) {
                    continue;
                }

                $entity = new stdClass();
                $entity->created = $item->created_on;

                $entity->href = JRoute::_(sprintf('index.php?option=com_docman&view=document&alias=%s&category_slug=%s&Itemid=%d',
                    $item->alias, $item->category->slug, $item->itemid));
                $entity->browsernav = '';
                $entity->title = $item->title;
                $entity->section = '';
                $entity->text = $item->description;

                $return[] = $entity;
            }
        }

        return $return;
    }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:89,代码来源:docman.php

示例12: onSearch


//.........这里部分代码省略.........
     $pluginParams = class_exists('JParameter') ? new JParameter($plugin->params) : new JRegistry($plugin->params);
     $limit = $pluginParams->def('search_limit', 50);
     $text = JString::trim($text);
     if ($text == '') {
         return array();
     }
     switch ($phrase) {
         case 'exact':
             $text = $db->quote('%' . $db->escape($text, true) . '%', false);
             $wheres2 = array();
             $wheres2[] = 'p.item_sku LIKE ' . $text;
             $where = '(' . implode(') OR (', $wheres2) . ')';
             break;
         case 'all':
         case 'any':
         default:
             $words = explode(' ', $text);
             $wheres = array();
             foreach ($words as $word) {
                 $word = $db->quote('%' . $db->escape($word, true) . '%', false);
                 $wheres2 = array();
                 $wheres2[] = 'p.item_sku LIKE ' . $word;
                 $wheres[] = implode(' OR ', $wheres2);
             }
             $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
             break;
     }
     switch ($ordering) {
         case 'oldest':
             $order = 'a.created ASC';
             break;
         case 'popular':
             $order = 'a.hits DESC';
             break;
         case 'alpha':
             $order = 'a.title ASC';
             break;
         case 'category':
             $order = 'c.title ASC, a.title ASC';
             break;
         case 'newest':
         default:
             $order = 'a.created DESC';
             break;
     }
     $rows = array();
     $query = $db->getQuery(true);
     // Search articles.
     if ($limit > 0) {
         $query->clear();
         // SQLSRV changes.
         $case_when = ' CASE WHEN ';
         $case_when .= $query->charLength('a.alias', '!=', '0');
         $case_when .= ' THEN ';
         $a_id = $query->castAsChar('a.id');
         $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
         $case_when .= ' ELSE ';
         $case_when .= $a_id . ' END as slug';
         $case_when1 = ' CASE WHEN ';
         $case_when1 .= $query->charLength('c.alias', '!=', '0');
         $case_when1 .= ' THEN ';
         $c_id = $query->castAsChar('c.id');
         $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
         $case_when1 .= ' ELSE ';
         $case_when1 .= $c_id . ' END as catslug';
         $query->select('p.*');
         $query->from('#__j2store_prices as p');
         $query->where('p.product_enabled = 1');
         $query->where($where);
         $query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created')->select($query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS text')->select('c.title AS section, ' . $case_when . ',' . $case_when1 . ', ' . '\'2\' AS browsernav')->leftJoin('#__content as a ON a.id=p.article_id')->join('INNER', '#__categories AS c ON c.id=a.catid')->where('a.state=1 AND c.published = 1 AND a.access IN (' . $groups . ') ' . 'AND c.access IN (' . $groups . ') ' . 'AND (a.publish_up = ' . $db->quote($nullDate) . ' OR a.publish_up <= ' . $db->quote($now) . ') ' . 'AND (a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ')')->group('a.id, a.title, a.metadesc, a.metakey, a.created, a.introtext, a.fulltext, c.title, a.alias, c.alias, c.id')->order($order);
         // Filter by language.
         if ($app->isSite() && JLanguageMultilang::isEnabled()) {
             $query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')')->where('c.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
         }
         $db->setQuery($query, 0, $limit);
         $list = $db->loadObjectList();
         $limit -= count($list);
         if (isset($list)) {
             foreach ($list as $key => $item) {
                 $list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug);
             }
         }
         $rows[] = $list;
     }
     $results = array();
     if (count($rows)) {
         foreach ($rows as $row) {
             $new_row = array();
             foreach ($row as $key => $item) {
                 $item->browsernav = '';
                 $item->tag = $searchText;
                 if (searchHelper::checkNoHTML($item, $searchText, array('text', 'title', 'metakey', 'metadesc', 'section', 'image_caption', 'image_credits', 'video_caption', 'video_credits', 'extra_fields_search', 'tag'))) {
                     $new_row[] = $item;
                 }
             }
             $results = array_merge($results, (array) $new_row);
         }
     }
     return $results;
 }
开发者ID:ForAEdesWeb,项目名称:AEW4,代码行数:101,代码来源:j2store.php

示例13: plgSearchAcymailingsearch

function plgSearchAcymailingsearch($text, $phrase = '', $ordering = '', $areas = null)
{
    if (!(include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_acymailing' . DS . 'helpers' . DS . 'helper.php')) {
        return array();
    }
    $db =& JFactory::getDBO();
    $user =& JFactory::getUser();
    $searchText = $text;
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchAcymailingsearchAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'content');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->get('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $wheres = array();
    switch ($phrase) {
        case 'exact':
            $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
            $wheres2 = array();
            $wheres2[] = 'a.subject LIKE ' . $text;
            $wheres2[] = 'a.body LIKE ' . $text;
            $wheres2[] = 'a.altbody LIKE ' . $text;
            $where = '(' . implode(') OR (', $wheres2) . ')';
            break;
        case 'all':
        case 'any':
        default:
            $words = explode(' ', $text);
            $wheres = array();
            foreach ($words as $word) {
                $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
                $wheres2 = array();
                $wheres2[] = 'a.subject LIKE ' . $word;
                $wheres2[] = 'a.body LIKE ' . $word;
                $wheres2[] = 'a.altbody LIKE ' . $word;
                $wheres[] = implode(' OR ', $wheres2);
            }
            $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
            break;
    }
    $morder = '';
    switch ($ordering) {
        case 'oldest':
            $order = 'a.created ASC';
            break;
        case 'category':
            $order = 'b.ordering ASC';
            break;
        case 'alpha':
            $order = 'a.subject ASC';
            break;
        default:
            $order = 'a.created DESC';
            break;
    }
    //First we need to
    // search articles
    $query = 'SELECT "2" AS browsernav, a.*, b.listid, b.name as section, b.alias as listalias FROM `#__acymailing_list` as b ';
    $query .= 'LEFT JOIN `#__acymailing_listmail` as c ON b.listid = c.listid ';
    $query .= 'LEFT JOIN `#__acymailing_mail` as a ON c.mailid = a.mailid ';
    $query .= ' WHERE ( ' . $where . ' ) AND b.published = 1 AND b.visible = 1 AND a.type="news" AND a.published = 1 AND a.visible = 1 GROUP BY a.mailid ORDER BY ' . $order;
    $db->setQuery($query, 0, $limit);
    $newsletters = $db->loadObjectList();
    if (empty($newsletters)) {
        return array();
    }
    $return = array();
    foreach ($newsletters as $key => $item) {
        $newsletters[$key]->href = acymailing::completeLink('archive&task=view&listid=' . $item->listid . '-' . $item->listalias . '&mailid=' . $item->mailid . '-' . $item->alias);
        $newsletters[$key]->title = $newsletters[$key]->subject;
        $newsletters[$key]->created = JHTML::date(strtotime($item->created));
        $newsletters[$key]->text = $item->html && !empty($item->body) ? $item->body : nl2br($item->altbody);
        if (searchHelper::checkNoHTML($newsletters[$key], $text, array('title', 'text'))) {
            $return[] = $newsletters[$key];
        }
    }
    return $return;
}
开发者ID:rlee1962,项目名称:diylegalcenter,代码行数:85,代码来源:acymailingsearch.php

示例14: onContentSearch

	/**
	 * Newsfeeds Search method
	 *
	 * The sql must return the following fields that are used in a common display
	 * routine: href, title, section, created, text, browsernav
	 * @param string Target search string
	 * @param string mathcing option, exact|any|all
	 * @param string ordering option, newest|oldest|popular|alpha|category
	 * @param mixed An array if the search it to be restricted to areas, null if search all
	 */
	function onContentSearch($text, $phrase='', $ordering='', $areas=null)
	{
		$db		= JFactory::getDbo();
		$app	= JFactory::getApplication();
		$user	= JFactory::getUser();

        $searchText = $text;

        $limit = $this->params->get( 'search_limit', 50 );

        $text = trim( $db->escape($text) );

        if ($text == '') {
            return array();
        }
        $section 	= JText::_( 'Auction Factory' );

        $wheres 	= array();
        switch ($phrase)
        {
            case 'exact':
                $text		= $db->Quote( '%'.$db->getEscaped( $text, true ).'%', false );
                $wheres2 	= array();
                $wheres2[] 	= 'a.shortdescription LIKE '.$text;
                $wheres2[] 	= 'a.title LIKE '.$text;
                $where 		= '(' . implode( ') OR (', $wheres2 ) . ')';
                break;

            case 'all':
            case 'any':
            default:
                $words 	= explode( ' ', $text );
                $wheres = array();
                foreach ($words as $word)
                {
                    $word		= $db->Quote( '%'.$db->getEscaped( $word, true ).'%', false );
                    $wheres2 	= array();
                    $wheres2[] 	= 'a.shortdescription LIKE '.$word;
                    $wheres2[] 	= 'a.title LIKE '.$word;
                    $wheres[] 	= implode( ' OR ', $wheres2 );
                }
                $where 	= '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wheres ) . ')';
                break;
        }

        switch ( $ordering ) {
            case 'alpha':
                $order = 'title ASC';
                break;

            case 'category':
                $order = 'catname ASC, title ASC';
                break;

            case 'oldest':
                $order = 'start_date ASC, title ASC';
                break;
            case 'newest':
                $order = 'start_date DESC, title ASC';
                break;
            case 'popular':
            default:
                $order = 'hits DESC';
        }
        require_once (JPATH_ROOT.DS.'components'.DS.'com_bids'.DS.'helpers'.DS.'tools.php');
        $tmp_id = BidsHelperTools::getMenuItemId(array("task"=>"listauctions"));

        $query = "SELECT a.title,"
        . "\n start_date AS created,"
        . "\n shortdescription AS text,"
        . "\n concat('Cat: ',b.title) AS section,"
        . "\n CONCAT( 'index.php?option=com_bids&task=viewbids&Itemid={$tmp_id}&id=', a.id, ':', a.title ) AS href,"
        . "\n '1' AS browsernav"
        . "\n FROM #__bid_auctions a "
        . "\n LEFT JOIN #__categories AS b ON b.id = a.cat"
        . "\n WHERE ( $where )"
        . "\n AND a.published = 1 and a.start_date<=UTC_TIMESTAMP()"
        . "\n ORDER BY $order"
        ;

        $db->setQuery( $query, 0, $limit );
        $rows = $db->loadObjectList();

        $return = array();
        foreach($rows AS $key => $weblink) {
            if(searchHelper::checkNoHTML($weblink, $searchText, array('url', 'text', 'title'))) {
                $return[] = $weblink;
            }
        }

//.........这里部分代码省略.........
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:101,代码来源:bids.php

示例15: onContentSearch


//.........这里部分代码省略.........
     $groups = implode(',', $user->getAuthorisedViewLevels());
     $searchText = $text;
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return array();
         }
     }
     $sContent = $this->params->get('search_content', 1);
     $sArchived = $this->params->get('search_archived', 1);
     $limit = $this->params->def('search_limit', 50);
     $state = array();
     if ($sContent) {
         $state[] = 1;
     }
     if ($sArchived) {
         $state[] = 2;
     }
     if (empty($state)) {
         return array();
     }
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     /* TODO: The $where variable does not seem to be used at all
     		switch ($phrase)
     		{
     			case 'exact':
     				$text = $db->quote('%' . $db->escape($text, true) . '%', false);
     				$wheres2 = array();
     				$wheres2[] = 'a.title LIKE ' . $text;
     				$wheres2[] = 'a.description LIKE ' . $text;
     				$where = '(' . implode(') OR (', $wheres2) . ')';
     				break;
     
     			case 'any':
     			case 'all';
     			default:
     				$words = explode(' ', $text);
     				$wheres = array();
     				foreach ($words as $word)
     				{
     					$word = $db->quote('%' . $db->escape($word, true) . '%', false);
     					$wheres2 = array();
     					$wheres2[] = 'a.title LIKE ' . $word;
     					$wheres2[] = 'a.description LIKE ' . $word;
     					$wheres[] = implode(' OR ', $wheres2);
     				}
     				$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
     				break;
     		}
     		*/
     switch ($ordering) {
         case 'alpha':
             $order = 'a.title ASC';
             break;
         case 'category':
         case 'popular':
         case 'newest':
         case 'oldest':
         default:
             $order = 'a.title DESC';
     }
     $text = $db->quote('%' . $db->escape($text, true) . '%', false);
     $query = $db->getQuery(true);
     // SQLSRV changes.
     $case_when = ' CASE WHEN ';
     $case_when .= $query->charLength('a.alias', '!=', '0');
     $case_when .= ' THEN ';
     $a_id = $query->castAsChar('a.id');
     $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
     $case_when .= ' ELSE ';
     $case_when .= $a_id . ' END as slug';
     $query->select('a.title, a.description AS text, \'\' AS created, \'2\' AS browsernav, a.id AS catid, ' . $case_when)->from('#__categories AS a')->where('(a.title LIKE ' . $text . ' OR a.description LIKE ' . $text . ') AND a.published IN (' . implode(',', $state) . ') AND a.extension = ' . $db->quote('com_content') . 'AND a.access IN (' . $groups . ')')->group('a.id, a.title, a.description, a.alias')->order($order);
     if ($app->isSite() && JLanguageMultilang::isEnabled()) {
         $query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
     }
     $db->setQuery($query, 0, $limit);
     try {
         $rows = $db->loadObjectList();
     } catch (RuntimeException $e) {
         $rows = array();
         JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
         JLog::add($e->getMessage(), JLog::ERROR, 'controller');
     }
     $return = array();
     if ($rows) {
         $count = count($rows);
         for ($i = 0; $i < $count; $i++) {
             $rows[$i]->href = ContentHelperRoute::getCategoryRoute($rows[$i]->slug);
             $rows[$i]->section = JText::_('JCATEGORY');
         }
         foreach ($rows as $category) {
             if (searchHelper::checkNoHTML($category, $searchText, array('name', 'title', 'text'))) {
                 $return[] = $category;
             }
         }
     }
     return $return;
 }
开发者ID:shamsbd71,项目名称:joomla-cms,代码行数:101,代码来源:categories.php


注:本文中的searchHelper::checkNoHTML方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。