a0e107f17f
New plugins: * LRDD LRDD implements client-side RFC6415 and RFC7033 resource descriptor discovery procedures. I.e. LRDD, host-meta and WebFinger stuff. OStatus and OpenID now depend on the LRDD plugin (XML_XRD). * WebFinger This plugin implements the server-side of RFC6415 and RFC7033. Note: WebFinger technically doesn't handle XRD, but we serve both that and JRD (JSON Resource Descriptor), depending on Accept header and one ugly hack to check for old StatusNet installations. WebFinger depends on LRDD. We might make this even prettier by using Net_WebFinger, but it is not currently RFC7033 compliant (no /.well-known/webfinger resource GETs). Disabling the WebFinger plugin would effectively render your site non- federated (which might be desired on a private site). Disabling the LRDD plugin would make your site unable to do modern web URI lookups (making life just a little bit harder).
80 lines
1.8 KiB
PHP
80 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Part of XML_XRD
|
|
*
|
|
* PHP version 5
|
|
*
|
|
* @category XML
|
|
* @package XML_XRD
|
|
* @author Christian Weiske <cweiske@php.net>
|
|
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
|
* @link http://pear.php.net/package/XML_XRD
|
|
*/
|
|
|
|
require_once 'XML/XRD/Serializer/Exception.php';
|
|
|
|
/**
|
|
* Serialization dispatcher - loads the correct serializer for saving XRD data.
|
|
*
|
|
* @category XML
|
|
* @package XML_XRD
|
|
* @author Christian Weiske <cweiske@php.net>
|
|
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
|
* @version Release: @package_version@
|
|
* @link http://pear.php.net/package/XML_XRD
|
|
*/
|
|
class XML_XRD_Serializer
|
|
{
|
|
/**
|
|
* XRD data storage
|
|
*
|
|
* @var XML_XRD
|
|
*/
|
|
protected $xrd;
|
|
|
|
/**
|
|
* Init object with xrd object
|
|
*
|
|
* @param XML_XRD $xrd Data storage the data are fetched from
|
|
*/
|
|
public function __construct(XML_XRD $xrd)
|
|
{
|
|
$this->xrd = $xrd;
|
|
}
|
|
|
|
/**
|
|
* Convert the XRD data into a string of the given type
|
|
*
|
|
* @param string $type File type: xml or json
|
|
*
|
|
* @return string Serialized data
|
|
*/
|
|
public function to($type)
|
|
{
|
|
return (string)$this->getSerializer($type);
|
|
}
|
|
|
|
/**
|
|
* Creates a XRD loader object for the given type
|
|
*
|
|
* @param string $type File type: xml or json
|
|
*
|
|
* @return XML_XRD_Loader
|
|
*/
|
|
protected function getSerializer($type)
|
|
{
|
|
$class = 'XML_XRD_Serializer_' . strtoupper($type);
|
|
$file = str_replace('_', '/', $class) . '.php';
|
|
include_once $file;
|
|
if (class_exists($class)) {
|
|
return new $class($this->xrd);
|
|
}
|
|
|
|
throw new XML_XRD_Serializer_Exception(
|
|
'No serializer for type "' . $type . '"',
|
|
XML_XRD_Loader_Exception::NO_LOADER
|
|
);
|
|
}
|
|
}
|
|
?>
|