/*** {$text.tpl_add_container_code_comment_var} ***/
$container_name = trim(" "); //{$text.tpl_add_container_code_comment_container_name}
$plici_page_id = trim(" "); //{$text.tpl_add_container_code_comment_container_plici_page_id}
$position = trim("LEFT"); //{$text.tpl_add_container_code_comment_container_position}
$tpl_name = trim(" "); //{$text.tpl_add_container_code_comment_container_design_name}
$tpl_uri = trim(" "); //{$text.tpl_add_container_code_comment_container_design_file}
$entry_uri = null; // {$text.tpl_add_container_code_comment_container_entry}
/*** {$text.tpl_add_container_code_comment_cons} ***/
$array_page_id = array("TOP", "BOTTOM", "LEFT", "RIGHT", "TRASH");
$position = in_array($position, $array_page_id)?$position:"LEFT";
/*** {$text.tpl_add_container_code_comment_log} ***/
$LOG_REQUEST = false;
$LOG_RESULT = false;
$filename = "log_script.log";
if ($LOG_REQUEST || $LOG_RESULT) {literal}{{/literal} $handle = fopen($filename, 'w'); fwrite($handle, "\n\n\n");}
if ("" != $container_name) && ("" != $tpl_name) && ("" != $tpl_uri) {literal}{{/literal}
$request= "SELECT page_rb FROM t_page WHERE page_id=".$position.";";
$result = mysql_query($request);
$row = mysql_fetch_row($result);
if ($LOG_REQUEST)
fwrite($handle, "\n".$request);
$father_node_info["page_rb"] = $row[0];
if ($LOG_RESULT)
fwrite($handle, "\n{$text.tpl_add_container_code_result}=".$father_node_info["page_rb"]);
$request="UPDATE t_page SET page_lb = page_lb + 2 WHERE page_lb >= ".$father_node_info["page_rb"].";";
mysql_query($request);
if ($LOG_REQUEST)
fwrite($handle, "\n".$request);
$request="UPDATE t_page SET page_rb = page_rb + 2 WHERE page_rb >= ".$father_node_info["page_rb"].";";
mysql_query($request);
if ($LOG_REQUEST)
fwrite($handle, "\n".$request);
if (0<strlen(trim($plici_page_id)))
{literal}{{/literal}
$request="INSERT INTO t_page(plici_page_id, page_lb, page_rb, page_level, page_title_l1, page_visibility, page_type) VALUES('".$plici_page_id."', ".$father_node_info["page_rb"].", ".$father_node_info["page_rb"]."+1, 3, '".$container_name."', 'VI', 'CO')";
} else {literal}{{/literal}
$request="INSERT INTO t_page(page_lb, page_rb, page_level, page_title_l1, page_visibility, page_type) VALUES(".$father_node_info["page_rb"].", ".$father_node_info["page_rb"]."+1, 3, '".$container_name."', 'VI', 'CO')";
}
mysql_query($request);
if ($LOG_REQUEST)
fwrite($handle, "\n".$request);
$container_id = mysql_insert_id();
if ($LOG_RESULT)
fwrite($handle, "\n{$text.tpl_add_container_code_result}=".$container_id);
$request="INSERT INTO t_design(des_type, des_page_id, des_title, des_entry, des_template, des_level) VALUES ('CONTAINER', ".$container_id.", '".$tpl_name."', ";
$request .= null==$entry_uri?"null":"'".$entry_uri."'";
$request .= ", '".$tpl_uri."', null);";
mysql_query($request);
if ($LOG_REQUEST)
fwrite($handle, "\n".$request);
$design_id = mysql_insert_id();
if ($LOG_RESULT)
fwrite($handle, "\n{$text.tpl_add_container_code_result}=".$design_id);
$request="UPDATE t_page SET page_detail_des_id = ".$design_id." WHERE page_id=".$container_id.";";
mysql_query($request);
if ($LOG_REQUEST)
fwrite($handle, "\n".$request);
}
if ($LOG_REQUEST || $LOG_RESULT)
fclose($handle);