Returns the evaluated PHP

@param $strFilename
@param $mixArgumentArray
@param null $templateSettings
@return mixed|string
329606
protected function evaluatePHP($strFilename, $mixArgumentArray, &$templateSettings = null)
    {
        // Get all the arguments and set them locally
        if ($mixArgumentArray) {
            foreach ($mixArgumentArray as $strName => $mixValue) {
                $$strName = $mixValue;
            }
        }
        global $_TEMPLATE_SETTINGS;
        unset($_TEMPLATE_SETTINGS);
        $_TEMPLATE_SETTINGS = null;

        // Of course, we also need to locally allow "objCodeGen"
        $objCodeGen = $this;

        // Get Database Escape Identifiers
        $strEscapeIdentifierBegin = \QCubed\Database\Service::getDatabase($this->intDatabaseIndex)->EscapeIdentifierBegin;
        $strEscapeIdentifierEnd = \QCubed\Database\Service::getDatabase($this->intDatabaseIndex)->EscapeIdentifierEnd;

        // Store the Output Buffer locally
        $strAlreadyRendered = ob_get_contents();

        if (ob_get_level()) {
            ob_clean();
        }
        ob_start();
        include($strFilename);
        $strTemplate = ob_get_contents();
        ob_end_clean();

        $templateSettings = $_TEMPLATE_SETTINGS;
        unset($_TEMPLATE_SETTINGS);

        // Restore the output buffer and return evaluated template
        print($strAlreadyRendered);

        // Remove all \r from the template (for Win/*nix compatibility)
        $strTemplate = str_replace("\r", '', $strTemplate);
        return $strTemplate;
    }
624252
protected function resolveTemplateFile(array $templates = array())
    {
        $templatePath = $this->getTemplatePath();

        $templates = array_merge($templates, $this->getDefaultTemplates());

        if (empty($templates)) {
            throw new Exception("No templates available.");
        }

        foreach ($templates as $templateFile) {
            $filePath = "$templatePath/$templateFile";

            if (is_file($filePath)) {
                return $filePath;
            }
        }

        return null;
    }
1088799
public function getTemplate( $templateId ){
        $path = sprintf( self::PATH_TEMPLATE_LOOKUP, $templateId );

        return $this->httpGet( $path );

    }
987567
public function loadTemplate($strFilename) {
        if(file_exists($strFilename)) {
            $template = new PHPWord_Template($strFilename);
            return $template;
        } else {
            trigger_error('Template file '.$strFilename.' not found.', E_ERROR);
        }
    }
778724
public function getTemplateDefinition($webAssetTemplateName = false)
    {
        $ret = clone $this->templateDefinition;

        if (false !== $webAssetTemplateName) {
            $customPath = str_replace($ret->getName(), $webAssetTemplateName, $ret->getPath());
            $ret->setName($webAssetTemplateName);
            $ret->setPath($customPath);
        }

        return $ret;
    }
102494
private function resolveTemplateType($templateType)
    {
        if (is_string($templateType)
            && !$templateType = $this->templateTypeLoader->retrieve($templateTypeName = $templateType)) {
            throw new \InvalidArgumentException(sprintf('Given template type name is invalid, "%s" given.',
                $templateTypeName
            ));
        }
        if ($templateType instanceof TemplateTypeInterface) {
            return $templateType;
        }

        throw new \InvalidArgumentException(sprintf(
            '%s only supports template type names or template type objects, "%s" given.',
            __CLASS__,
            is_object($templateType) ? get_class($templateType) : $templateType
        ));
    }
1111639
public function getPageUsingTemplate($templatefile)
    {
        $pages = $this->getPagesUsingTemplate($templatefile);

        return count($pages) ? $pages[0] : null;
    }
416270
public function renderTemplate($filename, array $templateDir, array $params = [], array $vars = [])
    {
        $this->addDirPathIntoLoaderIfNotExists($templateDir);
        $render = '';
        try {
            $params['this'] = $this;
            $params = array_merge($params, $vars);

            try {
                $render = $this->twig->render($filename, $params);
            } catch (\Twig_Error_Runtime $e) {
                if($e->getPrevious() instanceof FrontControllerException) {
                    throw $e->getPrevious();
                }

                throw $e;
            }

        } catch (FrontControllerException $fe) {
            throw $fe;
        } catch (\Exception $e) {
            throw new RendererException(
                sprintf('%s in %s.', $e->getMessage(), $filename),
                RendererException::RENDERING_ERROR,
                $e
            );
        }

        return $render;
    }
609361
protected function getTemplate($templateName)
    {
        $template = new Template($this->getModulePath() . '/Template/' . $this->getThemeName() . '/' . $templateName);
        $template->setVars($this->dataCollection->toArray());

        return $template;
    }
1007221
protected function getTemplate($templateName)
    {
        $template = new Template($this->userTemplatePath . '/' . $templateName);
        $template->setVars($this->dataCollection->toArray());

        return $template;
    }
1257446
public function getTemplate() : ?string 
    {
        if ( ! $this->hasTemplate()) {
            $this->setTemplate($this->getDefaultTemplate());
        }
        return $this->template;
    }
308695
public function isValidTemplateFile($filename, array $templateDir)
    {
        if (0 === count($templateDir)) {
            return false;
        }

        $this->addDirPathIntoLoaderIfNotExists($templateDir);

        return $this->loader->exists($filename);
    }
972842
public function addTemplateFile($urlOfFile,$templateFileType)
    {
        $file = new File($this->getContext(),$this->getResourcePath());
        $qry = new InvokePostMethodQuery(
            $this->getResourcePath(),
            "addTemplateFile",
            array(
                "urlOfFile" => $urlOfFile,
                "templateFileType" => (int)$templateFileType
            )
        );
        $this->getContext()->addQuery($qry,$file);
        return $file;
    }
29219
public function replaceTemplateTypesWithArgTypes(array $template_types, Codebase $codebase = null)
    {
        $keys_to_unset = [];

        $new_types = [];

        $is_mixed = false;

        foreach ($this->types as $key => $atomic_type) {
            if ($atomic_type instanceof Type\Atomic\TTemplateParam) {
                $keys_to_unset[] = $key;

                $template_type = null;

                if (isset($template_types[$key][$atomic_type->defining_class ?: ''])) {
                    $template_type = $template_types[$key][$atomic_type->defining_class ?: ''][0];

                    if (!$atomic_type->as->isMixed() && $template_type->isMixed()) {
                        $template_type = clone $atomic_type->as;
                    } else {
                        $template_type = clone $template_type;
                    }
                } elseif ($codebase && $atomic_type->defining_class) {
                    foreach ($template_types as $template_type_map) {
                        foreach ($template_type_map as $template_class => $_) {
                            if (!$template_class) {
                                continue;
                            }

                            try {
                                $classlike_storage = $codebase->classlike_storage_provider->get($template_class);

                                if ($classlike_storage->template_type_extends) {
                                    $defining_class_lc = strtolower($atomic_type->defining_class);

                                    if (isset($classlike_storage->template_type_extends[$defining_class_lc])) {
                                        $param_map = $classlike_storage->template_type_extends[$defining_class_lc];

                                        if (isset($param_map[$key])
                                            && isset($template_types[(string) $param_map[$key]][$template_class])
                                        ) {
                                            $template_type = clone $template_types
                                                [(string) $param_map[$key]]
                                                [$template_class]
                                                [0];
                                        }
                                    }
                                }
                            } catch (\InvalidArgumentException $e) {
                            }
                        }
                    }
                }

                if ($template_type) {
                    foreach ($template_type->types as $template_type_part) {
                        if ($template_type_part instanceof Type\Atomic\TMixed) {
                            $is_mixed = true;
                        }

                        $new_types[$template_type_part->getKey()] = $template_type_part;
                    }
                } else {
                    $new_types[$key] = $atomic_type;
                }
            } elseif ($atomic_type instanceof Type\Atomic\TTemplateParamClass) {
                $template_type = isset($template_types[$atomic_type->param_name][$atomic_type->defining_class ?: ''])
                    ? clone $template_types[$atomic_type->param_name][$atomic_type->defining_class ?: ''][0]
                    : Type::getMixed();

                foreach ($template_type->types as $template_type_part) {
                    if ($template_type_part instanceof Type\Atomic\TMixed
                        || $template_type_part instanceof Type\Atomic\TObject
                    ) {
                        $unknown_class_string = new Type\Atomic\TClassString();

                        $new_types[$unknown_class_string->getKey()] = $unknown_class_string;
                        $keys_to_unset[] = $key;
                    } elseif ($template_type_part instanceof Type\Atomic\TNamedObject) {
                        $literal_class_string = new Type\Atomic\TClassString(
                            $template_type_part->value,
                            $template_type_part
                        );

                        $new_types[$literal_class_string->getKey()] = $literal_class_string;
                        $keys_to_unset[] = $key;
                    }
                }
            } else {
                $atomic_type->replaceTemplateTypesWithArgTypes($template_types);
            }
        }

        $this->id = null;

        if ($is_mixed) {
            $this->types = $new_types;

            return;
        }

        foreach ($keys_to_unset as $key) {
            unset($this->types[$key]);
        }

        $this->types = array_merge($this->types, $new_types);
    }
1308142
public function getTemplate(string $templateName): array
    {
        if (is_array($this->template))
            return $this->template;

        if (property_exists($this->getTemplateManager(), $templateName))
            return $this->getTemplateManager()->$templateName;

        $templateName = 'get' . ucfirst($templateName);
        if (! method_exists($this->getTemplateManager(), $templateName))
            trigger_error(sprintf('No template "%s" was found in %s Manager.', $templateName, get_class($this->getTemplateManager())), E_USER_ERROR);

        return $this->getTemplateManager()->$templateName();
    }
529566
public function renderString($templateString)
    {
        try {
            return $this->twigStringEnvironment->render($templateString, $this->getData());
        } catch (SecurityException $e) {
            throw new SecurityException($e->getMessage(), $e->getCode(), $e);
        } catch (\Twig_Error_Runtime $e) {
            throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
        } catch (\Twig_Error_Syntax $e) {
            throw new InvalidSyntaxException($e->getMessage(), $e->getCode(), $e);
        } catch (\Twig_Error_Loader $e) {

            if ($this->ignoreUndefinedTemplateErrors && Str::contains($e->getMessage(), 'is not defined'))
            {
                return;
            }

            throw new InvalidTemplateException($e->getMessage(), $e->getCode(), $e);
        }
    }
189589
protected function getTemplateName()
    {
        $templateName = '';
        $templateFile = '';

        if (isset($this->ffData['templateFile'])) {
            $templateFile = $this->ffData['templateFile'];
        } elseif (isset($this->conf['defaultTemplateFileName'])) {
            $templateFile = $this->conf['defaultTemplateFileName'];
        }

        if ($templateFile === $this->conf['defaultTemplateFileName'] ||
            $templateFile === 'default') {
            $templateName = 'default';
        }

        // cutting off the file extension
        if ($templateName !== 'default') {
            $templateName = substr($templateFile, 0, strrpos($templateFile, '.'));
        }

        return $templateName;
    }