Template based XML generation is replaced with native XML
This commit is contained in:
parent
2123b4d071
commit
ff89c1a8bf
9 changed files with 222 additions and 174 deletions
|
@ -20,20 +20,77 @@
|
|||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
function oexchange_init(App $a) {
|
||||
|
||||
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'xrd')) {
|
||||
$tpl = Renderer::getMarkupTemplate('oexchange_xrd.tpl');
|
||||
|
||||
$o = Renderer::replaceMacros($tpl, ['$base' => DI::baseUrl()]);
|
||||
System::httpExit($o, Response::TYPE_XML, 'application/xrd+xml');
|
||||
function oexchange_init(App $a)
|
||||
{
|
||||
if ((DI::args()->getArgc() <= 1) || (DI::args()->getArgv()[1] != 'xrd')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$baseURL = DI::baseUrl()->get();
|
||||
|
||||
$xml = null;
|
||||
|
||||
XML::fromArray([
|
||||
'XRD' => [
|
||||
'@attributes' => [
|
||||
'xmlns' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0',
|
||||
],
|
||||
'Subject' => $baseURL,
|
||||
'1:Property' => [
|
||||
'@attributes' => [
|
||||
'type' => 'http://www.oexchange.org/spec/0.8/prop/vendor',
|
||||
],
|
||||
'Friendica'
|
||||
],
|
||||
'2:Property' => [
|
||||
'@attributes' => [
|
||||
'type' => 'http://www.oexchange.org/spec/0.8/prop/title',
|
||||
],
|
||||
'Friendica Social Network'
|
||||
],
|
||||
'3:Property' => [
|
||||
'@attributes' => [
|
||||
'type' => 'http://www.oexchange.org/spec/0.8/prop/name',
|
||||
],
|
||||
'Friendica'
|
||||
],
|
||||
'4:Property' => [
|
||||
'@attributes' => [
|
||||
'type' => 'http://www.oexchange.org/spec/0.8/prop/prompt',
|
||||
],
|
||||
'Send to Friendica'
|
||||
],
|
||||
'1:link' => [
|
||||
'@attributes' => [
|
||||
'rel' => 'icon',
|
||||
'type' => 'image/png',
|
||||
'href' => $baseURL . '/images/friendica-16.png'
|
||||
]
|
||||
],
|
||||
'2:link' => [
|
||||
'@attributes' => [
|
||||
'rel' => 'icon32',
|
||||
'type' => 'image/png',
|
||||
'href' => $baseURL . '/images/friendica-32.png'
|
||||
]
|
||||
],
|
||||
'3:link' => [
|
||||
'@attributes' => [
|
||||
'rel' => 'http://www.oexchange.org/spec/0.8/rel/offer',
|
||||
'type' => 'text/html',
|
||||
'href' => $baseURL . '/oexchange'
|
||||
]
|
||||
],
|
||||
],
|
||||
], $xml);
|
||||
|
||||
System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml');
|
||||
}
|
||||
|
||||
function oexchange_content(App $a) {
|
||||
|
|
|
@ -24,13 +24,10 @@ use Friendica\App;
|
|||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
function poco_init(App $a) {
|
||||
if (intval(DI::config()->get('system', 'block_public')) || (DI::config()->get('system', 'block_local_dir'))) {
|
||||
|
@ -229,12 +226,9 @@ function poco_init(App $a) {
|
|||
|
||||
Logger::info("End of poco");
|
||||
|
||||
if ($format === 'xml') {
|
||||
System::httpExit(Renderer::replaceMacros(Renderer::getMarkupTemplate('poco_xml.tpl'), XML::arrayEscape(['$response' => $ret])), Response::TYPE_XML);
|
||||
}
|
||||
if ($format === 'json') {
|
||||
System::jsonExit($ret);
|
||||
} else {
|
||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||
throw new \Friendica\Network\HTTPException\UnsupportedMediaTypeException();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue