/* * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2008-2010, Tomasz Sowa * All rights reserved. * */ #include #include #include "templates.h" #include "core/misc.h" namespace TemplatesFunctions { void template_index(Info & i) { i.out << config->templates_index; } static std::vector temp_tab; static size_t temp_req_id = 0; static size_t temp_def; static size_t temp_index; void template_set_def() { temp_def = (size_t)-1; // none const std::wstring * html_file; if( request->is_item ) html_file = &request->item.html_template; else html_file = &request->dir_tab.back()->html_template; if( html_file->empty() ) { // the first default item should be selected (that first in html source with value="") return; } for(size_t i=0 ; itemplates_index); Mount::ParamRow & par = system->mounts.pmount->param[system->mounts.MountParHtmlTemplate()]; if( par.defined ) { size_t len = par.arg.size(); for(size_t i=0 ; iid != temp_req_id ) { temp_req_id = request->id; template_init(); } temp_index = i.iter; i.res = temp_index < temp_tab.size(); } void template_tab_index(Info & i) { i.out << temp_index; } void template_tab_isdefault(Info & i) { if( temp_index < temp_tab.size() ) i.res = (temp_index == temp_def); } void template_tab_file_name(Info & i) { if( temp_index < temp_tab.size() ) i.out << temp_tab[temp_index]; } } // namespace