added: mount option: html_template(file.html)

files: indexpatterns.h indexpatterns.cpp
removed: templates/index_root.html
        its content was moved to index.html


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@611 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-06-21 23:53:19 +00:00
parent 08f5865c72
commit 1e3f5e8695
22 changed files with 631 additions and 344 deletions

View File

@@ -8,16 +8,19 @@
*/
#include "templates.h"
#include "localefilter.h"
#include "../core/data.h"
#include "../core/request.h"
#include "../core/misc.h"
#include "../core/plugin.h"
#include "localefilter.h"
namespace TemplatesFunctions
{
IndexPatterns index_patterns;
TemplatesMisc::Patterns patterns;
Ezc::Functions functions;
PatternCacher pattern_cacher;
@@ -464,7 +467,7 @@ void Templates::CreateFunctions()
functions.Insert("winix_err_code", winix_err_code);
functions.Insert("winix_is_err_in_locales", winix_is_err_in_locales);
functions.Insert("winix_err_msg_from_locales",winix_err_msg_from_locales);
functions.Insert("winix_content_full", winix_content_full);
functions.Insert("winix_show_content_in_full_window", winix_show_content_in_full_window);
plugin.Call(WINIX_TEMPLATES_CREATEFUNCTIONS, &functions);
}
@@ -526,10 +529,54 @@ using namespace TemplatesFunctions;
ReadFile(pat_fun_subject, "fun_subject.html");
ReadFile(pat_fun_cp, "fun_cp.html");
ReadFile(pat_fun_tinymce, "fun_tinymce.html");
index_patterns.ReloadPatterns(locale, locale_filter, false);
}
// reading only new index templates (with parsing)
// those which are exists are not touched
// the rest are deleted
void Templates::ReadNewIndexTemplates()
{
Mounts::MountTab::const_iterator i;
using namespace TemplatesFunctions;
index_patterns.MarkAllToDelete();
const Mounts::MountTab * pmount_tab = data.mounts.GetMountTab();
for(i=pmount_tab->begin() ; i!=pmount_tab->end() ; ++i)
{
const std::string * file = i->second.HtmlTemplate();
if( file )
index_patterns.AddPatternIfNotExists(*file, locale, locale_filter, false); // file pattern will be unmarked
}
index_patterns.DeleteMarked();
}
// reading only index file names (without parsing the files)
void Templates::ReadIndexFileNames()
{
using namespace TemplatesFunctions;
Mounts::MountTab::const_iterator i;
const Mounts::MountTab * pmount_tab = data.mounts.GetMountTab();
for(i=pmount_tab->begin() ; i!=pmount_tab->end() ; ++i)
{
const std::string * file = i->second.HtmlTemplate();
if( file )
index_patterns.AddFileName(*file);
}
}
void Templates::ClearPatterns()
{
@@ -547,7 +594,16 @@ using namespace TemplatesFunctions;
if( static_cast<size_t>(locale.GetLang()) >= patterns.size() )
return;
Ezc::Generator generator(request.page, patterns[locale.GetLang()][pat_index], functions);
Ezc::Pattern * index = 0;
const std::string * index_file_local = data.mounts.pmount->HtmlTemplate();
if( index_file_local )
index = index_patterns.GetPattern(*index_file_local, locale.GetLang());
if( !index )
index = &patterns[locale.GetLang()][pat_index];
Ezc::Generator generator(request.page, *index, functions);
generator.Generate();
}