public function EasyRdf_Resource::htmlLink in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Resource.php \EasyRdf_Resource::htmlLink()
Generates an HTML anchor tag, linking to this resource.
If no text is given, then the URI also uses as the link text.
Parameters
string $text Text for the link.:
array $options Associative array of attributes for the anchor tag:
Return value
string The HTML link string
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Resource.php, line 184
Class
- EasyRdf_Resource
- Class that represents an RDF resource
Code
public function htmlLink($text = null, $options = array()) {
$options = array_merge(array(
'href' => $this->uri,
), $options);
if ($text === null) {
$text = $this->uri;
}
$html = "<a";
foreach ($options as $key => $value) {
if (!preg_match('/^[-\\w]+$/', $key)) {
throw new InvalidArgumentException("\$options should use valid attribute names as keys");
}
$html .= " " . htmlspecialchars($key) . "=\"" . htmlspecialchars($value) . "\"";
}
$html .= ">" . htmlspecialchars($text) . "</a>";
return $html;
}