Example #1
0
     eZExecution::cleanExit();
     break;
 case 'method':
 case 'method-static':
     if (!isset($keys['class']) || trim($keys['class']) == '') {
         eZDebug::writeError('Tried to include a method call without specifying the class.', 'nxc_esi/include/' . $includeType);
         return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
     }
     if (!isset($keys['method']) || trim($keys['method']) == '') {
         eZDebug::writeError('Tried to include a method call without specifying the method.', 'nxc_esi/include/' . $includeType);
         return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
     }
     $class = $keys['class'];
     $method = $keys['method'];
     unset($keys['class'], $keys['method']);
     if (!nxcESI::isMethodAllowed($class, $method)) {
         eZDebug::writeError('Tried to include a method call that is not allowed.', 'nxc_esi/include/' . $includeType);
         return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
     }
     if (!class_exists($class)) {
         eZDebug::writeError('Tried to include a method call on a non-existing class.', 'nxc_esi/include/' . $includeType);
         return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
     }
     if ($includeType == 'method-static') {
         $call = array($class, $method);
     } else {
         $call = array(new $class(), $method);
     }
     if (!is_callable($call)) {
         eZDebug::writeError('Tried to include a method call on a non-callable method.', 'nxc_esi/include/' . $includeType);
         return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
Example #2
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;
 }