示例#1
0
文件: include.php 项目: nxc/nxc_esi
    }
}
header('X-NXC-ESI-Keys:' . $keysHeader);
switch ($includeType) {
    case 'empty':
        eZExecution::cleanExit();
        break;
    case 'template':
    case 'template-in-pagelayout':
        if (!isset($keys['template']) || trim($keys['template']) == '') {
            eZDebug::writeError('Tried to include a template without specifying which.', 'nxc_esi/include/' . $includeType);
            return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
        }
        $template = $keys['template'];
        unset($keys['template']);
        if (!nxcESI::isTemplateAllowed($template)) {
            eZDebug::writeError('Tried to include a template that is not allowed.', 'nxc_esi/include/' . $includeType);
            return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
        }
        header('X-NXC-ESI-Template: ' . rawurlencode($template));
        $tpl = eZTemplate::factory();
        foreach ($keys as $key => $value) {
            $tpl->setVariable($key, $value);
        }
        $content = $tpl->fetch($template);
        if (is_string($content)) {
            if ($includeType == 'template-in-pagelayout') {
                return array('content' => $content);
            }
            echo $content;
        }
示例#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;
 }