- date: documentation ( source)
<?php
$xml = <<<XML
<footer xmlns:t="ddtemplate">
<p>
<t:span child="sign-in" class="sign-in" />
<t:span child="copyright" class="footer-copyright" />
</p>
</footer>
XML;
$doc = DOMDocument::loadXML($xml);
/* Template Values */
$tv = array();
$f = $doc->createDocumentFragment();
if ($u->isRegistered()) {
if (Config::get("ENABLE_USER_PROFILES")) {
$userName = '<a href="' . $this->url('/profile') . '">' . $u->getUserName() . '</a>';
} else {
$userName = $u->getUserName();
}
$f->appendXML(t('Currently logged in as <b>%s</b>.', $userName) . '<a href="' . $this->url('/login', 'logout') . '">' . t('Sign Out') . '</a>');
} else {
$f->appendXML('<a href="' . $this->url('/login') . '">' . t('Sign In to Edit this Site') . '</a>');
}
$tv['sign-in'] = $f;
$tv['copyright'] = $doc->createTextNode('©' . date('Y') . ' ' . SITE);
foreach($doc->getElementsByTagNameNS('ddtemplate','*') as $el) {
$el->appendChild($tv[$el->getAttribute('child')]);
}
echo $doc->saveHTML();