| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: sections.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 6 * @license GNU/GPL, see LICENSE.php 7 * Joomla! is free software. This version may have been modified pursuant 8 * to the GNU General Public License, and as distributed it includes or 9 * is derivative of works licensed under the GNU General Public License or 10 * other free or open source software licenses. 11 * See COPYRIGHT.php for copyright notices and details. 12 */ 13 14 // no direct access 15 defined( '_JEXEC' ) or die( 'Restricted access' ); 16 17 $mainframe->registerEvent( 'onSearch', 'plgSearchSections' ); 18 $mainframe->registerEvent( 'onSearchAreas', 'plgSearchSectionAreas' ); 19 20 JPlugin::loadLanguage( 'plg_search_sections' ); 21 22 /** 23 * @return array An array of search areas 24 */ 25 function &plgSearchSectionAreas() { 26 static $areas = array( 27 'sections' => 'Sections' 28 ); 29 return $areas; 30 } 31 32 /** 33 * Sections Search method 34 * 35 * The sql must return the following fields that are used in a common display 36 * routine: href, title, section, created, text, browsernav 37 * @param string Target search string 38 * @param string mathcing option, exact|any|all 39 * @param string ordering option, newest|oldest|popular|alpha|category 40 * @param mixed An array if restricted to areas, null if search all 41 */ 42 function plgSearchSections( $text, $phrase='', $ordering='', $areas=null ) 43 { 44 $db =& JFactory::getDBO(); 45 $user =& JFactory::getUser(); 46 47 $searchText = $text; 48 49 require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php'); 50 51 if (is_array( $areas )) { 52 if (!array_intersect( $areas, array_keys( plgSearchSectionAreas() ) )) { 53 return array(); 54 } 55 } 56 57 // load plugin params info 58 $plugin =& JPluginHelper::getPlugin('search', 'sections'); 59 $pluginParams = new JParameter( $plugin->params ); 60 61 $limit = $pluginParams->def( 'search_limit', 50 ); 62 63 $text = trim( $text ); 64 if ($text == '') { 65 return array(); 66 } 67 68 switch ( $ordering ) { 69 case 'alpha': 70 $order = 'a.name ASC'; 71 break; 72 73 case 'category': 74 case 'popular': 75 case 'newest': 76 case 'oldest': 77 default: 78 $order = 'a.name DESC'; 79 } 80 81 $text = $db->Quote( '%'.$db->getEscaped( $text, true ).'%', false ); 82 $query = 'SELECT a.title AS title, a.description AS text, a.name, ' 83 . ' "" AS created,' 84 . ' "2" AS browsernav,' 85 . ' a.id AS secid' 86 . ' FROM #__sections AS a' 87 . ' WHERE ( a.name LIKE '.$text 88 . ' OR a.title LIKE '.$text 89 . ' OR a.description LIKE '.$text.' )' 90 . ' AND a.published = 1' 91 . ' AND a.access <= '.(int) $user->get( 'aid' ) 92 . ' GROUP BY a.id' 93 . ' ORDER BY '. $order 94 ; 95 $db->setQuery( $query, 0, $limit ); 96 $rows = $db->loadObjectList(); 97 98 $count = count( $rows ); 99 for ( $i = 0; $i < $count; $i++ ) 100 { 101 $rows[$i]->href = ContentHelperRoute::getSectionRoute($rows[$i]->secid); 102 $rows[$i]->section = JText::_( 'Section' ); 103 } 104 105 $return = array(); 106 foreach($rows AS $key => $section) { 107 if(searchHelper::checkNoHTML($section, $searchText, array('name', 'title', 'text'))) { 108 $return[] = $section; 109 } 110 } 111 return $return; 112 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |