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:
117
templates/indexpatterns.cpp
Executable file
117
templates/indexpatterns.cpp
Executable file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "indexpatterns.h"
|
||||
#include "../core/log.h"
|
||||
#include "../core/data.h"
|
||||
|
||||
|
||||
|
||||
|
||||
Ezc::Pattern * IndexPatterns::GetPattern(const std::string & file, Locale::Lang lang)
|
||||
{
|
||||
Tab::iterator i = tab.find(file);
|
||||
|
||||
if( i == tab.end() )
|
||||
return 0;
|
||||
|
||||
size_t index = static_cast<size_t>(lang);
|
||||
|
||||
if( index >= i->second.patterns.size() )
|
||||
{
|
||||
log << log1 << "IndexPatterns: there is no a pattern: " << file << ", for lang: " << index << logend;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return &i->second.patterns[index];
|
||||
}
|
||||
|
||||
|
||||
|
||||
void IndexPatterns::AddPattern(const std::string & file, Locale & locale, LocaleFilter & locale_filter, bool delete_white)
|
||||
{
|
||||
std::pair<Tab::iterator, bool> ins = tab.insert( std::make_pair(file, Template()) );
|
||||
Tab::iterator i = ins.first;
|
||||
|
||||
i->second.to_delete = false;
|
||||
ReadPattern(i, locale, locale_filter, delete_white);
|
||||
}
|
||||
|
||||
|
||||
void IndexPatterns::AddPatternIfNotExists(const std::string & file, Locale & locale, LocaleFilter & locale_filter, bool delete_white)
|
||||
{
|
||||
Tab::iterator i = tab.find(file);
|
||||
|
||||
if( i != tab.end() )
|
||||
return;
|
||||
|
||||
AddPattern(file, locale, locale_filter, delete_white);
|
||||
}
|
||||
|
||||
|
||||
void IndexPatterns::AddFileName(const std::string & file)
|
||||
{
|
||||
tab.insert( std::make_pair(file, Template()) );
|
||||
}
|
||||
|
||||
|
||||
void IndexPatterns::ReadPattern(Tab::iterator & iter, Locale & locale, LocaleFilter & locale_filter, bool delete_white)
|
||||
{
|
||||
size_t i;
|
||||
size_t len = Locale::lang_unknown;
|
||||
Template & templ = iter->second;
|
||||
|
||||
templ.patterns.resize(len);
|
||||
|
||||
for(i=0 ; i<len ; ++i)
|
||||
{
|
||||
templ.patterns[i].delete_all_white = delete_white;
|
||||
templ.patterns[i].Directory(data.templates_dir, data.templates_dir_default);
|
||||
templ.patterns[i].ParseFile(iter->first);
|
||||
|
||||
locale_filter.Filter(templ.patterns[i], locale, static_cast<Locale::Lang>(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IndexPatterns::ReloadPatterns(Locale & locale, LocaleFilter & locale_filter, bool delete_white)
|
||||
{
|
||||
Tab::iterator i;
|
||||
|
||||
for(i=tab.begin() ; i!=tab.end() ; ++i)
|
||||
ReadPattern(i, locale, locale_filter, delete_white);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void IndexPatterns::MarkAllToDelete()
|
||||
{
|
||||
Tab::iterator i;
|
||||
|
||||
for(i=tab.begin() ; i!=tab.end() ; ++i)
|
||||
i->second.to_delete = true;
|
||||
}
|
||||
|
||||
|
||||
void IndexPatterns::DeleteMarked()
|
||||
{
|
||||
Tab::iterator i = tab.begin();
|
||||
Tab::iterator next;
|
||||
|
||||
while( i != tab.end() )
|
||||
{
|
||||
next = i;
|
||||
++next;
|
||||
|
||||
if( i->second.to_delete )
|
||||
tab.erase(i);
|
||||
|
||||
i = next;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user