function onContentSearch($text, $phrase = '', $ordering = '', $areas = null) { //If the array is not correct, return it: if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $section = JText::_('PLG_SEARCH_BOOKINGFORCONNECTORRESOURCE'); //Then load the parameters of the plugin. $pluginParams = $this->params; //Now define the parameters like this: $limit = $pluginParams->def('search_limit', 20); $direction = $pluginParams->def('direction', "asc"); //Use the function trim to delete spaces in front of or at the back of the searching terms $text = trim($text); //Return Array when nothing was filled in. if ($text == '') { return array(); } $wheres = array(); switch ($phrase) { //search exact case 'exact': /*$text = $db->Quote( '%'.$db->getEscaped( $text, true ).'%', false ); $where = '(' . implode( ') OR (', $wheres2 ) . ')';*/ break; //search all or any //search all or any case 'all': case 'any': //set default //set default default: /* $words = explode( ' ', $text ); $wheres = array(); foreach ($words as $word) { $word = $db->Quote( '%'.$db->getEscaped( $word, true ).'%', false ); $wheres2 = array(); $wheres2[] = 'LOWER(a.name) LIKE '.$word; $wheres[] = implode( ' OR ', $wheres2 ); } $where = '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wheres ) . ')'; */ break; } //ordering of the results switch ($ordering) { //alphabetic, ascending case 'alpha': $order = 'Name'; break; //oldest first //oldest first case 'oldest': //popular first //popular first case 'popular': //newest first //newest first case 'newest': //default setting: alphabetic, ascending //default setting: alphabetic, ascending default: $order = 'Name'; } //replace nameofplugin $rows = array(); $resources = BFCHelper::getResourcesSearch($text, 0, $limit, $order, $direction); $document = JFactory::getDocument(); $language = $document->getLanguage(); /* we have to find the itemid for the target page */ $db = JFactory::getDBO(); $lang = JFactory::getLanguage()->getTag(); $uri = 'index.php?option=com_bookingforconnector&view=resource'; $db->setQuery('SELECT id FROM #__menu WHERE link LIKE ' . $db->Quote($uri . '%') . ' AND language=' . $db->Quote($lang) . ' LIMIT 1'); $itemId = $db->getErrorNum() ? 0 : intval($db->loadResult()); //The 'output' of the displayed link foreach ($resources as $resource) { //$rows[$key]->href = 'index.php?option=com_bookingforconnector&view=merchantdetails&merchantId=' . $merchant->MerchantId . ':' . BFCHelper::getSlug($merchant->Name); $resourceName = BFCHelper::getLanguage($resource->Name, $language); $rows[] = (object) array('href' => Jroute::_('index.php?Itemid=' . $itemId . '&option=com_bookingforconnector&view=resource&resourceId=' . $resource->ResourceId . ':' . BFCHelper::getSlug($resourceName)), 'title' => $resourceName, 'created' => null, 'section' => $section, 'text' => BFCHelper::getLanguage($resource->Description, $language, null, array('ln2br' => 'ln2br', 'striptags' => 'striptags')), 'browsernav' => '0'); } //Return the search results in an array return $rows; }