<?php
/**
 * 
 * @file template_view.php
 * @copyright (c) 2005 - 2007 eifr.com
 * @license http://www.gnu.org/copyleft/gpl.html gnu/gpl
 * eifr is free software
 */

require_once('../../includes/inc_admin.php');

$sys_charset = SYS_CHARSET;
$sys_weburl = SYS_WEBURL;
$soft_name = SOFT_NAME;
$soft_version = SOFT_VERSION;
$soft_copyright = SOFT_COPYRIGHT;
$soft_weburl = SOFT_WEBURL;
$img_path = DIR_INSTALL . 'images/';
$css_path = DIR_INSTALL . 'style/';
$js_path = DIR_INSTALL . 'js/';

if (isset($selectValue)) $selectid = $selectValue;
$layout_code = '';
if (isset($layout_id)) {
    $selectid = dbGetFieldValue(TB_TEMPLATE_LAYOUT, 'template_id', "id='" . $layout_id . "'");
    $layout_code = dbGetFieldValue(TB_TEMPLATE_LAYOUT, 'layout_code', "id='" . $layout_id . "'");
} 

$tplfile = dbGetFieldValue(TB_TEMPLATE, 'template_filename', "id='" . $selectid . "'");
$pfile = dbGetFieldValue(TB_TEMPLATE, 'program_filename', "id='" . $selectid . "'");

$layout_id_list = "''";
$sql = "select * from " . TB_TEMPLATE_LAYOUT . " where template_id='$selectid' order by ordernum asc ";
$rs = $db -> Execute($sql);
while (!$rs -> EOF) {
    $layout_id_list .= ",'" . $rs -> fields['layout_code'] . "'";
    $rs -> MoveNext();
} 
$rs -> Close();

$layout_foot_js = "<script language='javascript' src='" . SYS_ADMIN_STYLE_PATH . "js/layout_foot.js'></script>\n";
$layout_foot_js .= "<script language='javascript'>\n";
$layout_foot_js .= "var layoutArr=[$layout_id_list];\n";
$layout_foot_js .= "showSelectLayoutId(layoutArr,'$layout_code');\n";
$layout_foot_js .= "</script>\n";

addCookie(COOKIE_PREVIEW_FOOTJS, $layout_foot_js);

header("Location:" . DIR_INSTALL . "$pfile?tpl_file=$tplfile");

?>