/** * Generiert den TemplateCache im Filesystem * * @param $template_id Id des zu generierenden Templates * * @return TRUE bei Erfolg, sonst FALSE */ function rex_generateTemplate($template_id) { global $REX; $sql = rex_sql::factory(); $qry = 'SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'template WHERE id = ' . $template_id; $sql->setQuery($qry); if ($sql->getRows() == 1) { $templatesDir = rex_template::getTemplatesDir(); $templateFile = rex_template::getFilePath($template_id); $content = $sql->getValue('content'); foreach ($REX['VARIABLES'] as $var) { $content = $var->getTemplate($content); } if (rex_file::put($templateFile, $content) !== false) { return true; } else { trigger_error('Unable to generate template ' . $template_id . '!', E_USER_ERROR); if (!is_writable()) { trigger_error('directory "' . $templatesDir . '" is not writable!', E_USER_ERROR); } } } else { trigger_error('Template with id "' . $template_id . '" does not exist!', E_USER_ERROR); } return false; }
function rex_generateTemplate($template_id) { global $REX; $sql = new rex_sql(); $qry = 'SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'template WHERE id = ' . $template_id; $sql->setQuery($qry); if ($sql->getRows() == 1) { $templatesDir = rex_template::getTemplatesDir(); $templateFile = rex_template::getFilePath($template_id); if ($fp = @fopen($templateFile, 'w')) { $content = $sql->getValue('content'); foreach ($REX['VARIABLES'] as $var) { $content = $var->getTemplate($content); } fwrite($fp, $content); fclose($fp); @chmod($templateFile, $REX['FILEPERM']); return true; } else { trigger_error('unable to generate template ' . $template_id . '!', E_USER_ERROR); if (!is_writable()) { trigger_error('directory "' . $templatesDir . '" is not writable!', E_USER_ERROR); } } } return false; }