9 * @author Christian Weiske <cweiske@php.net>
10 * @license http://www.gnu.org/copyleft/lesser.html LGPL
11 * @link http://pear.php.net/package/XML_XRD
14 require_once 'XML/XRD/PropertyAccess.php';
17 * Link element in a XRD file. Attribute access via object properties.
19 * Retrieving the title of a link is possible with the getTitle() convenience
24 * @author Christian Weiske <cweiske@php.net>
25 * @license http://www.gnu.org/copyleft/lesser.html LGPL
26 * @version Release: @package_version@
27 * @link http://pear.php.net/package/XML_XRD
29 class XML_XRD_Element_Link extends XML_XRD_PropertyAccess
39 * Link type (MIME type)
60 * Array of key-value pairs: Key is the language, value the title
64 public $titles = array();
69 * Create a new instance and load data from the XML element
71 * @param string $relOrXml string with the relation name/URL
72 * @param string $href HREF value
73 * @param string $type Type value
74 * @param boolean $isTemplate When set to true, the $href is
77 public function __construct(
78 $rel = null, $href = null, $type = null, $isTemplate = false
82 $this->template = $href;
90 * Returns the title of the link in the given language.
91 * If the language is not available, the first title without the language
92 * is returned. If no such one exists, the first title is returned.
94 * @param string $lang 2-letter language name
96 * @return string|null Link title
98 public function getTitle($lang = null)
100 if (count($this->titles) == 0) {
105 return reset($this->titles);
108 if (isset($this->titles[$lang])) {
109 return $this->titles[$lang];
111 if (isset($this->titles[''])) {
112 return $this->titles[''];
116 return reset($this->titles);