?
Path : /home/admin/domains/happytokorea.com/public_html_bk/test3/plugins/content/sekh/ |
Current File : /home/admin/domains/happytokorea.com/public_html_bk/test3/plugins/content/sekh/ajax.php |
<?php define('_JEXEC', 1); // no direct access defined('_JEXEC') or die('Restricted access'); define( 'DS', DIRECTORY_SEPARATOR ); define('JPATH_BASE', dirname(__FILE__).DS.'..'.DS.'..'.DS.'..' ); define('JPATH_SITE', dirname(__FILE__).DS.'..'.DS.'..'.DS.'..' ); require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' ); jimport('joomla.database.database'); $seachKeys= JRequest::getVar('key'); $seachKeys=str_replace(',',' ',$seachKeys); $mainframe = &JFactory::getApplication('site'); $searResults=search($seachKeys); $seachEngineBox="<h2>You are searching ".$seachKeys." <a href=\"#\" onclick=\" $('search_engine_box').style.display='none';return false;\">[ X ]</a></h2>\n" ."<div>\n" ."Searching keywords are hilighted<br/>\n" ."You may interest in the following:<ul>\n"; foreach($searResults as $key=>$item){ $seachEngineBox.="<li><a href='".$item->href."' title='".$item->title."' target='_blank'>".$item->title."</a></li>\n"; } //$searchMore=JRoute::_("index.php?searchword=".$seachKeys."&ordering=newest&searchphrase=any&limit=20&option=com_search"); $searchMore="index.php?searchword=".$seachKeys."&ordering=newest&searchphrase=any&limit=20&option=com_search"; $seachEngineBox.="</ul>\n" ."<a href='".$searchMore."' target='_blank'>Site Search ".$seachKeys."</a>\n" ."</div>\n" ."</div>\n" ."<script type=\"text/javascript\">\n"; $seachEngineBox.="document.body.appendChild($('search_engine_box').remove());\n" ."$('search_engine_box').style.display='block';\n" ."</script>\n"; echo($seachEngineBox); function search($text){ $db =& JFactory::getDBO(); $limit=5; $text = trim( $text ); $keys=explode(" ", $text); $wheres2 = array(); $count=0; foreach($keys as $k){ $count++; $k= $db->Quote( '%'.$db->getEscaped( $k, true ).'%', false ); $wheres2[] = 'a.title LIKE '.$k; if($count>2){ break; } } $where = '(' . implode( ') OR (', $wheres2 ) . ')'; $query = 'SELECT a.title AS title,' . ' 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' . ' 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'; $db->setQuery( $query, 0, $limit ); $list = $db->loadObjectList(); //echo($query); require_once(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php'); if(isset($list)) { foreach($list as $key => $item){ ///$list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid); $list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid); } } return $list; }