From: Philipp Holzer Date: Sat, 18 May 2019 15:43:58 +0000 (+0200) Subject: Move mod/opensearch to src/Module/OpenSearch X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9f13ae6e735625360b762a3f749276d041989573;p=friendica.git Move mod/opensearch to src/Module/OpenSearch --- diff --git a/mod/opensearch.php b/mod/opensearch.php deleted file mode 100644 index 0744157e53..0000000000 --- a/mod/opensearch.php +++ /dev/null @@ -1,19 +0,0 @@ - $a->getHostName(), - ]); - - echo $o; - - exit(); -} diff --git a/src/App/Router.php b/src/App/Router.php index cd59c3dd90..e37565b79c 100644 --- a/src/App/Router.php +++ b/src/App/Router.php @@ -172,6 +172,7 @@ class Router }); $this->routeCollector->addRoute(['GET'], '/outbox/{owner}', Module\Outbox::class); $this->routeCollector->addRoute(['GET'], '/owa', Module\Owa::class); + $this->routeCollector->addRoute(['GET'], '/opensearch', Module\OpenSearch::class); $this->routeCollector->addGroup('/photo', function (RouteCollector $collector) { $collector->addRoute(['GET'], '/{name}', Module\Photo::class); $collector->addRoute(['GET'], '/{type}/{name}', Module\Photo::class); diff --git a/src/Module/OpenSearch.php b/src/Module/OpenSearch.php new file mode 100644 index 0000000000..ff005bd56b --- /dev/null +++ b/src/Module/OpenSearch.php @@ -0,0 +1,72 @@ +getHostName(); + $baseUrl = self::getApp()->getBaseURL(); + + /** @var DOMDocument $xml */ + $xml = null; + + XML::fromArray([ + 'OpenSearchDescription' => [ + '@attributes' => [ + 'xmlns' => 'http://a9.com/-/spec/opensearch/1.1', + ], + 'ShortName' => "Friendica $hostname", + 'Description' => "Search in Friendica $hostname", + 'Contact' => 'https://github.com/friendica/friendica/issues', + ], + ], $xml); + + /** @var DOMElement $parent */ + $parent = $xml->getElementsByTagName('OpenSearchDescription')[0]; + + XML::addElement($xml, $parent, 'Image', + "$baseUrl/images/friendica-16.png", [ + 'height' => 16, + 'width' => 16, + 'type' => 'image/png', + ]); + + XML::addElement($xml, $parent, 'Image', + "$baseUrl/images/friendica-64.png", [ + 'height' => 64, + 'width' => 64, + 'type' => 'image/png', + ]); + + XML::addElement($xml, $parent, 'Url', '', [ + 'type' => 'text/html', + 'template' => "$baseUrl/search?search={searchTerms}", + ]); + + XML::addElement($xml, $parent, 'Url', '', [ + 'type' => 'application/opensearchdescription+xml', + 'rel' => 'self', + 'template' => "$baseUrl/opensearch", + ]); + + echo $xml->saveXML(); + + exit(); + } +} diff --git a/view/templates/opensearch.tpl b/view/templates/opensearch.tpl deleted file mode 100644 index 6efee25e7c..0000000000 --- a/view/templates/opensearch.tpl +++ /dev/null @@ -1,14 +0,0 @@ - - - - Friendica@{{$nodename}} - Search in Friendica@{{$nodename}} - http://bugs.friendica.com/ - {{$baseurl}}/images/friendica-16.png - {{$baseurl}}/images/friendica-64.png - - - \ No newline at end of file