예제 #1
0
 public static function init_directive($directive, $directive_code)
 {
     $directive_data = DirectiveParser::get_directive_data($directive_code);
     $directive_name = $directive_data['directive_name'];
     $directive_parameters = $directive_data['directive_parameters'];
     $directive_contents = self::is_nested_directive($directive_name) ? $directive_data['directive_contents'] : null;
     $directive->set_parameters($directive_parameters);
     $directive->set_contents($directive_contents);
 }
예제 #2
0
파일: template.php 프로젝트: doomy/central
 private function process_nested_directives($output)
 {
     $startpos = strpos($output, DirectiveParser::DIRECTIVE_START);
     while ($startpos > -1) {
         $endpos = strpos($output, DirectiveParser::DIRECTIVE_END, $startpos);
         $length = $endpos - $startpos + 3;
         $raw_directive = substr($output, $startpos, $length);
         $directive_name = DirectiveParser::get_directive_name($raw_directive);
         if (DirectiveFactory::is_nested_directive($directive_name)) {
             $end_tag = DirectiveParser::DIRECTIVE_START . '/' . $directive_name . DirectiveParser::DIRECTIVE_END;
             $endpos = strpos($output, $end_tag);
             $length = $endpos - $startpos + strlen($end_tag);
             $raw_directive = substr($output, $startpos, $length);
             $replace = $this->process_directive($raw_directive, $output);
             $endpos = $startpos + strlen($replace);
             $output = substr_replace($output, $replace, $startpos, $length);
         }
         $startpos = strpos($output, DirectiveParser::DIRECTIVE_START, $endpos);
         // next occurence
     }
     return $output;
 }