10 defined(
'JPATH_PLATFORM') or die;
30 private $_shortName =
"";
40 private $_images = array();
48 private $_urls = array();
57 public function __construct($options = array())
59 parent::__construct($options);
62 $this->_type =
'opensearch';
65 $this->_mime =
'application/opensearchdescription+xml';
69 $update->type =
'application/opensearchdescription+xml';
70 $update->rel =
'self';
72 $this->addUrl($update);
77 $dirs = array(JPATH_THEMES .
'/' . $app->getTemplate(), JPATH_BASE);
79 foreach ($dirs as $dir)
81 if (file_exists($dir .
'/favicon.ico'))
84 $path = str_replace(JPATH_BASE .
'/',
'', $dir);
85 $path = str_replace(
'\\',
'/', $path);
88 $favicon->data =
JUri::base() . $path .
'/favicon.ico';
89 $favicon->height =
'16';
90 $favicon->width =
'16';
91 $favicon->type =
'image/vnd.microsoft.icon';
93 $this->addImage($favicon);
110 public function render($cache =
false, $params = array())
112 $xml =
new DOMDocument(
'1.0',
'utf-8');
113 if (defined(
'JDEBUG') && JDEBUG)
115 $xml->formatOutput =
true;
119 $osns =
'http://a9.com/-/spec/opensearch/1.1/';
122 $elOs = $xml->createElementNS($osns,
'OpenSearchDescription');
124 $elShortName = $xml->createElementNS($osns,
'ShortName');
125 $elShortName->appendChild($xml->createTextNode(htmlspecialchars($this->_shortName)));
126 $elOs->appendChild($elShortName);
128 $elDescription = $xml->createElementNS($osns,
'Description');
129 $elDescription->appendChild($xml->createTextNode(htmlspecialchars($this->description)));
130 $elOs->appendChild($elDescription);
133 $elInputEncoding = $xml->createElementNS($osns,
'InputEncoding');
134 $elInputEncoding->appendChild($xml->createTextNode(
'UTF-8'));
135 $elOs->appendChild($elInputEncoding);
137 foreach ($this->_images as $image)
139 $elImage = $xml->createElementNS($osns,
'Image');
140 $elImage->setAttribute(
'type', $image->type);
141 $elImage->setAttribute(
'width', $image->width);
142 $elImage->setAttribute(
'height', $image->height);
143 $elImage->appendChild($xml->createTextNode(htmlspecialchars($image->data)));
144 $elOs->appendChild($elImage);
147 foreach ($this->_urls as $url)
149 $elUrl = $xml->createElementNS($osns,
'Url');
150 $elUrl->setAttribute(
'type', $url->type);
153 if ($url->rel !=
'results')
155 $elUrl->setAttribute(
'rel', $url->rel);
157 $elUrl->setAttribute(
'template', $url->template);
158 $elOs->appendChild($elUrl);
161 $xml->appendChild($elOs);
163 return $xml->saveXML();
175 public function setShortName($name)
177 $this->_shortName = $name;
193 $this->_urls[] = $url;
209 $this->_images[] = $image;