function process($tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace)
 {
     $params = $functionParameters;
     if (!isset($params["uri"])) {
         $tpl->missingParameter($this->IncludeName, "uri");
         return false;
     }
     $uri = $tpl->elementValue($params["uri"], $rootNamespace, $currentNamespace, $functionPlacement);
     $name = "";
     if (isset($params["name"])) {
         $name = $tpl->elementValue($params["name"], $rootNamespace, $currentNamespace, $functionPlacement);
     }
     if ($currentNamespace != "") {
         if ($name != "") {
             $name = "{$currentNamespace}:{$name}";
         } else {
             $name = $currentNamespace;
         }
     }
     reset($params);
     $whatParamsShouldBeUnset = array();
     $whatParamsShouldBeReplaced = array();
     while (($key = key($params)) !== null) {
         $item =& $params[$key];
         switch ($key) {
             case "name":
             case "uri":
                 break;
             default:
                 if (!$tpl->hasVariable($key, $name)) {
                     $whatParamsShouldBeUnset[] = $key;
                     // Tpl vars should be removed after including
                 } else {
                     $whatParamsShouldBeReplaced[$key] = $tpl->variable($key, $name);
                     // Tpl vars should be replaced after including
                 }
                 $item_value = $tpl->elementValue($item, $rootNamespace, $currentNamespace, $functionPlacement);
                 $tpl->setVariable($key, $item_value, $name);
                 break;
         }
         next($params);
     }
     eZTemplateIncludeFunction::handleInclude($textElements, $uri, $tpl, $rootNamespace, $name);
     // unset var
     foreach ($whatParamsShouldBeUnset as $key) {
         $tpl->unsetVariable($key, $name);
     }
     // replace var
     foreach ($whatParamsShouldBeReplaced as $key => $item_value) {
         $tpl->setVariable($key, $item_value, $name);
     }
 }
Example #2
0
function contentPDFGenerate($cacheFile, $node, $object = false, $viewCacheEnabled = true, $languageCode = false, $viewParameters = array())
{
    if ($languageCode) {
        $node->setCurrentLanguage($languageCode);
    }
    if ($object == false) {
        $object = $node->attribute('object');
    }
    $res = eZTemplateDesignResource::instance();
    $res->setKeys(array(array('object', $node->attribute('contentobject_id')), array('remote_id', $object->attribute('remote_id')), array('node_remote_id', $node->attribute('remote_id')), array('section', $object->attribute('section_id')), array('node', $node->attribute('node_id')), array('parent_node', $node->attribute('parent_node_id')), array('class', $object->attribute('contentclass_id')), array('depth', $node->attribute('depth')), array('url_alias', $node->attribute('url_alias')), array('class_group', $object->attribute('match_ingroup_id_list')), array('class_identifier', $object->attribute('class_identifier'))));
    $tpl = eZTemplate::factory();
    $tpl->setVariable('view_parameters', $viewParameters);
    $tpl->setVariable('node', $node);
    $tpl->setVariable('generate_toc', 0);
    $tpl->setVariable('tree_traverse', 0);
    $tpl->setVariable('class_array', 0);
    $tpl->setVariable('show_frontpage', 0);
    if ($viewCacheEnabled) {
        $tpl->setVariable('generate_file', 1);
        $tpl->setVariable('filename', $cacheFile);
    } else {
        $tpl->setVariable('generate_file', 0);
        $tpl->setVariable('generate_stream', 1);
    }
    $textElements = array();
    $uri = 'design:node/view/pdf.tpl';
    $tpl->setVariable('pdf_root_template', 1);
    eZTemplateIncludeFunction::handleInclude($textElements, $uri, $tpl, '', '');
    $pdf_definition = implode('', $textElements);
    $pdf_definition = str_replace(array(' ', "\r\n", "\t", "\n"), '', $pdf_definition);
    $tpl->setVariable('pdf_definition', $pdf_definition);
    $uri = 'design:node/view/execute_pdf.tpl';
    $textElements = '';
    eZTemplateIncludeFunction::handleInclude($textElements, $uri, $tpl, '', '');
}
 function renderTag($element, $content, $vars)
 {
     $currentTag = $this->OutputTags[$element->nodeName];
     if ($currentTag && isset($currentTag['quickRender'])) {
         $renderedTag = '';
         $attrString = '';
         foreach ($vars as $name => $value) {
             if ($value != '') {
                 $attrString .= " {$name}=\"{$value}\"";
             }
         }
         if (isset($currentTag['quickRender'][0]) && $currentTag['quickRender'][0]) {
             $renderedTag = '<' . $currentTag['quickRender'][0] . "{$attrString}>" . $content . '</' . $currentTag['quickRender'][0] . '>';
         } else {
             $renderedTag = $content;
         }
         if (isset($currentTag['quickRender'][1]) && $currentTag['quickRender'][1]) {
             $renderedTag .= $currentTag['quickRender'][1];
         }
     } else {
         if (isset($currentTag['contentVarName'])) {
             $contentVarName = $currentTag['contentVarName'];
         } else {
             $contentVarName = 'content';
         }
         $this->Tpl->setVariable($contentVarName, $content, 'xmltagns');
         eZTemplateIncludeFunction::handleInclude($textElements, $this->TemplateUri, $this->Tpl, 'foo', 'xmltagns');
         $renderedTag = is_array($textElements) ? implode('', $textElements) : '';
     }
     return $renderedTag;
 }
Example #4
0
function generatePDF($pdfExport, $toFile = false)
{
    if ($pdfExport == null) {
        return;
    }
    $node = $pdfExport->attribute('source_node');
    if ($node) {
        $object = $node->attribute('object');
        $tpl = eZTemplate::factory();
        $tpl->setVariable('node', $node);
        $tpl->setVariable('generate_toc', 1);
        $tpl->setVariable('tree_traverse', $pdfExport->attribute('export_structure') == 'tree' ? 1 : 0);
        $tpl->setVariable('class_array', explode(':', $pdfExport->attribute('export_classes')));
        $tpl->setVariable('show_frontpage', $pdfExport->attribute('show_frontpage'));
        if ($pdfExport->attribute('show_frontpage') == 1) {
            $tpl->setVariable('intro_text', $pdfExport->attribute('intro_text'));
            $tpl->setVariable('sub_intro_text', $pdfExport->attribute('sub_text'));
        }
        if ($toFile === false) {
            $tpl->setVariable('generate_stream', 1);
        } else {
            $tpl->setVariable('generate_file', 1);
            $tpl->setVariable('filename', $toFile);
        }
        $res = eZTemplateDesignResource::instance();
        $res->setKeys(array(array('object', $object->attribute('id')), array('node', $node->attribute('node_id')), array('parent_node', $node->attribute('parent_node_id')), array('class', $object->attribute('contentclass_id')), array('class_identifier', $object->attribute('class_identifier')), array('depth', $node->attribute('depth')), array('url_alias', $node->attribute('url_alias'))));
        $textElements = array();
        $uri = 'design:node/view/pdf.tpl';
        $tpl->setVariable('pdf_root_template', 1);
        eZTemplateIncludeFunction::handleInclude($textElements, $uri, $tpl, '', '');
        $pdf_definition = implode('', $textElements);
        $pdf_definition = str_replace(array(' ', "\r\n", "\t", "\n"), '', $pdf_definition);
        $tpl->setVariable('pdf_definition', $pdf_definition);
        $uri = 'design:node/view/execute_pdf.tpl';
        $textElements = '';
        eZTemplateIncludeFunction::handleInclude($textElements, $uri, $tpl, '', '');
    }
}
Example #5
0
 function appendElementText(&$textElements, $item, $nspace, $name)
 {
     if (!is_array($textElements)) {
         $textElements = array();
     }
     if (is_object($item) and method_exists($item, 'templateValue')) {
         $item = $item->templateValue();
         $textElements[] = "{$item}";
     } else {
         if (is_object($item)) {
             $hasTemplateData = false;
             if (method_exists($item, 'templateData')) {
                 $templateData = $item->templateData();
                 if (is_array($templateData) and isset($templateData['type'])) {
                     if ($templateData['type'] == 'template' and isset($templateData['uri']) and isset($templateData['template_variable_name'])) {
                         $templateURI =& $templateData['uri'];
                         $templateVariableName =& $templateData['template_variable_name'];
                         $templateText = '';
                         $this->setVariable($templateVariableName, $item, $name);
                         eZTemplateIncludeFunction::handleInclude($textElements, $templateURI, $this, $nspace, $name);
                         $hasTemplateData = true;
                     }
                 }
             }
             if (!$hasTemplateData) {
                 $textElements[] = method_exists($item, '__toString') ? (string) $item : 'Object(' . get_class($item) . ')';
             }
         } else {
             $textElements[] = "{$item}";
         }
     }
     return $textElements;
 }