[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Site 5 * @subpackage com_finder 6 * 7 * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Finder\Site\View\Search; 12 13 use Joomla\CMS\Component\ComponentHelper; 14 use Joomla\CMS\Document\Opensearch\OpensearchUrl; 15 use Joomla\CMS\Factory; 16 use Joomla\CMS\MVC\View\AbstractView; 17 use Joomla\CMS\Router\Route; 18 use Joomla\CMS\Uri\Uri; 19 20 // phpcs:disable PSR1.Files.SideEffects 21 \defined('_JEXEC') or die; 22 // phpcs:enable PSR1.Files.SideEffects 23 24 /** 25 * OpenSearch View class for Finder 26 * 27 * @since 2.5 28 */ 29 class OpensearchView extends AbstractView 30 { 31 /** 32 * Method to display the view. 33 * 34 * @param string $tpl A template file to load. [optional] 35 * 36 * @return void 37 * 38 * @since 2.5 39 */ 40 public function display($tpl = null) 41 { 42 $app = Factory::getApplication(); 43 44 $params = ComponentHelper::getParams('com_finder'); 45 $this->document->setShortName($params->get('opensearch_name', $app->get('sitename', ''))); 46 $this->document->setDescription($params->get('opensearch_description', $app->get('MetaDesc', ''))); 47 48 // Prevent any output when OpenSearch Support is disabled 49 if (!$params->get('opensearch', 1)) { 50 return; 51 } 52 53 // Add the URL for the search 54 $searchUri = 'index.php?option=com_finder&view=search&q={searchTerms}'; 55 $suggestionsUri = 'index.php?option=com_finder&task=suggestions.opensearchsuggest&format=json&q={searchTerms}'; 56 $baseUrl = Uri::getInstance()->toString(array('host', 'port', 'scheme')); 57 $active = $app->getMenu()->getActive(); 58 59 if ($active->component == 'com_finder') { 60 $searchUri .= '&Itemid=' . $active->id; 61 $suggestionsUri .= '&Itemid=' . $active->id; 62 } 63 64 // Add the HTML result view 65 $htmlSearch = new OpensearchUrl(); 66 $htmlSearch->template = $baseUrl . Route::_($searchUri, false); 67 $this->document->addUrl($htmlSearch); 68 69 // Add the RSS result view 70 $htmlSearch = new OpensearchUrl(); 71 $htmlSearch->template = $baseUrl . Route::_($searchUri . '&format=feed&type=rss', false); 72 $htmlSearch->type = 'application/rss+xml'; 73 $this->document->addUrl($htmlSearch); 74 75 // Add the Atom result view 76 $htmlSearch = new OpensearchUrl(); 77 $htmlSearch->template = $baseUrl . Route::_($searchUri . '&format=feed&type=atom', false); 78 $htmlSearch->type = 'application/atom+xml'; 79 $this->document->addUrl($htmlSearch); 80 81 // Add suggestions URL 82 if ($params->get('show_autosuggest', 1)) { 83 $htmlSearch = new OpensearchUrl(); 84 $htmlSearch->template = $baseUrl . Route::_($suggestionsUri, false); 85 $htmlSearch->type = 'application/x-suggestions+json'; 86 $this->document->addUrl($htmlSearch); 87 } 88 } 89 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |