<? php <br>$ main_ctx = CMSContentObj::getInstance () - > getData("main_ctx");<br>$title = CMSContentObj::getInstance()- > getTitle();<br>// <br>? > <br> < html > <br> < head > <br> < meta content ="text/html; charset=utf-8" http-equiv ="Content-Type" /> <br> < title ><? =$title;? > - mysite.ru </ title > <br> < link href ="/_css/main.css" rel ="stylesheet" type ="text/css" > <br> < script type ="text/javascript" src ="/_js/jquery.js" ></ script > <br> </ head > <br> < body > <br>…<br> <? =$main_ctx;? > <br>…<br> </ body > <br> </ html > <br> <br> * This source code was highlighted with Source Code Highlighter .
<? xml version ="1.0" encoding ="utf-8" ? > <br> < xsl:stylesheet version ="1.0" xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" xmlns:php ="http://php.net/xsl" > <br> < xsl:output encoding ="utf-8" indent ="yes" method ="html" /> <br> < xsl:template match ="/page" > <br> <!-- <br> Variables <br> --> <br> < xsl:variable name ="title" select ="php:function('CMSStaticContent::getTitle')" /> <br> < xsl:variable name ="main_ctx" select ="php:function('CMSStaticContent::getData','main_ctx')" /> <br> <!-- <br> / Variables <br> --> <br> < html > <br> < head > <br> < meta content ="text/html; charset=utf-8" http-equiv ="Content-Type" /> <br> < title >< xsl:value-of disable-output-escaping ="yes" select ="$title" /> - mysite.ru </ title > <br> < link href ="/_css/main.css" rel ="stylesheet" type ="text/css" /> <br> < script type ="text/javascript" src ="/_js/jquery.js" /> <br> </ head > <br> < body > <br> …<br> < xsl:value-of disable-output-escaping ="yes" select ="$main_ctx" /> <br> …<br> </ body > <br> </ html > <br> </ xsl:template > <br> </ xsl:stylesheet > <br> <br> * This source code was highlighted with Source Code Highlighter .
class CMSStaticContent {<br> public static function __callStatic($name, $arguments) {<br> $cms = CMSContentObj::getInstance();<br> if (method_exists($cms, $name)) {<br> return call_user_func_array(array($cms, $name), $arguments);<br> } else {<br> throw new Exception();<br> }<br> }<br>}<br> <br> * This source code was highlighted with Source Code Highlighter .
$doc = new DOMDocument();<br>$doc->loadXML( '<page/>' );<br>$xsl = new DOMDocument();<br>$xsl->load($xsl_template);<br>$proc = new XSLTProcessor();<br>$proc->registerPHPFunctions(array('CMSStaticContent::getData', 'CMSStaticContent::getTitle'));<br>$proc->importStyleSheet($xsl);<br>echo $proc->transformToXML($doc);<br> <br> * This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/87417/
All Articles