Esempio n. 1
0
 private function extractInclude($psContent)
 {
     preg_match_all('#{{include file="([a-zA-Z0-9_/\\.]*)"}}#', $psContent, $arrResult);
     if (!empty($arrResult[0])) {
         #echo '<pre>'.print_r($arrResult, true).'</pre>';
         foreach ($arrResult[1] as $key => $sFileInclude) {
             $oYATS = new YATSPHP();
             $sDocRoot = null;
             if (is_null($this->docroot)) {
                 $sDocRoot = dirname($this->template) . DIRECTORY_SEPARATOR;
             } else {
                 if (substr($sFileInclude, 0, 2) == './') {
                     $sDocRoot = dirname($this->template) . DIRECTORY_SEPARATOR;
                     $sFileInclude = substr($sFileInclude, 2);
                 } else {
                     $sDocRoot = $this->docroot;
                 }
             }
             $oYATS->define($sFileInclude, $sDocRoot, $this->searchpath);
             $oYATS->assign($this->vars);
             $sInclude = $oYATS->render();
             $psContent = str_replace($arrResult[0][$key], $sInclude, $psContent);
         }
     }
     return $psContent;
 }
Esempio n. 2
0
 /**
  * @param YATSPHP $template
  * @return array
  */
 function yats_getvars($template)
 {
     return $template->getVariables();
 }