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


PHP BFCHelper::getResourcesSearch方法代码示例

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


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

示例1: onContentSearch

 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;
 }
开发者ID:Bookingfor,项目名称:joomla-extension-v-2,代码行数:88,代码来源:bookingforconnectorresource.php


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