Ejemplo n.º 1
0
 /** Handle the processing of the es-include template function.
  * @see process()
  */
 private function processESIncludeFunction($tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace)
 {
     if (!isset($functionParameters['template']) && !isset($functionParameters['method'])) {
         $tpl->warning($this->ESIncludeName, 'Missing parameter template or method', $functionPlacement);
         return false;
     }
     $keys = $this->extractKeys($tpl, $functionParameters, $rootNamespace, $currentNamespace, $functionPlacement);
     if (isset($keys['template']) && trim($keys['template']) != '') {
         $template = $keys['template'];
         unset($keys['template']);
         if (!nxcESI::isTemplateAllowed($template)) {
             $tpl->warning($this->ESIncludeName, 'Tried to include a template that is not allowed.', $functionPlacement);
             return false;
         }
         $content = nxcESI::getIncludeForTemplate($template, $keys);
         if (is_string($content) && $content != '') {
             $textElements[] = $content;
             return true;
         }
     } elseif (isset($keys['method']) && trim($keys['method']) != '') {
         $method = $keys['method'];
         unset($keys['method']);
         $info = $this->parseMethod($tpl, $method, $functionPlacement);
         if (!is_array($info)) {
             return false;
         }
         if (!nxcESI::isMethodAllowed($info['class'], $info['method'])) {
             $tpl->warning($this->ESIncludeName, 'Tried to include a method call that is not allowed.', $functionPlacement);
             return false;
         }
         $content = nxcESI::getIncludeForMethodCall($info, $keys);
         if (is_string($content) && $content != '') {
             $textElements[] = $content;
             return true;
         }
     } else {
         $tpl->warning($this->ESIncludeName, 'Empty parameter template or method', $functionPlacement);
     }
     return false;
 }