forked from GNUsocial/gnu-social
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).
120 lines
2.6 KiB
PHP
120 lines
2.6 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/PropertyAccess.php';
|
|
|
|
/**
|
|
* Link element in a XRD file. Attribute access via object properties.
|
|
*
|
|
* Retrieving the title of a link is possible with the getTitle() convenience
|
|
* method.
|
|
*
|
|
* @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_Element_Link extends XML_XRD_PropertyAccess
|
|
{
|
|
/**
|
|
* Link relation
|
|
*
|
|
* @var string
|
|
*/
|
|
public $rel;
|
|
|
|
/**
|
|
* Link type (MIME type)
|
|
*
|
|
* @var string
|
|
*/
|
|
public $type;
|
|
|
|
/**
|
|
* Link URL
|
|
*
|
|
* @var string
|
|
*/
|
|
public $href;
|
|
|
|
/**
|
|
* Link URL template
|
|
*
|
|
* @var string
|
|
*/
|
|
public $template;
|
|
|
|
/**
|
|
* Array of key-value pairs: Key is the language, value the title
|
|
*
|
|
* @var array
|
|
*/
|
|
public $titles = array();
|
|
|
|
|
|
|
|
/**
|
|
* Create a new instance and load data from the XML element
|
|
*
|
|
* @param string $relOrXml string with the relation name/URL
|
|
* @param string $href HREF value
|
|
* @param string $type Type value
|
|
* @param boolean $isTemplate When set to true, the $href is
|
|
* used as template
|
|
*/
|
|
public function __construct(
|
|
$rel = null, $href = null, $type = null, $isTemplate = false
|
|
) {
|
|
$this->rel = $rel;
|
|
if ($isTemplate) {
|
|
$this->template = $href;
|
|
} else {
|
|
$this->href = $href;
|
|
}
|
|
$this->type = $type;
|
|
}
|
|
|
|
/**
|
|
* Returns the title of the link in the given language.
|
|
* If the language is not available, the first title without the language
|
|
* is returned. If no such one exists, the first title is returned.
|
|
*
|
|
* @param string $lang 2-letter language name
|
|
*
|
|
* @return string|null Link title
|
|
*/
|
|
public function getTitle($lang = null)
|
|
{
|
|
if (count($this->titles) == 0) {
|
|
return null;
|
|
}
|
|
|
|
if ($lang == null) {
|
|
return reset($this->titles);
|
|
}
|
|
|
|
if (isset($this->titles[$lang])) {
|
|
return $this->titles[$lang];
|
|
}
|
|
if (isset($this->titles[''])) {
|
|
return $this->titles[''];
|
|
}
|
|
|
|
//return first
|
|
return reset($this->titles);
|
|
}
|
|
}
|
|
|
|
?>
|