From 45522f2a0f45a26044403311f044e8d44796fc5f Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Fri, 9 Feb 2001 05:04:21 +0000 Subject: [PATCH] Set to use template as an object --- admin/applications.php | 39 +++++++++++++++++----------------- admin/editapplication.php | 44 +++++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/admin/applications.php b/admin/applications.php index db8411fe62..229596fe25 100644 --- a/admin/applications.php +++ b/admin/applications.php @@ -15,7 +15,8 @@ $phpgw_info["flags"] = array("currentapp" => "admin", "enable_nextmatchs_class" => True); include("../header.inc.php"); - $phpgw->template->set_file(array("list" => "applications.tpl", + $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin')); + $p->set_file(array("list" => "applications.tpl", "row" => "applications_row.tpl")); if ($order) { @@ -28,14 +29,14 @@ $sort = "desc"; } - $phpgw->template->set_var("lang_installed",lang("Installed applications")); - $phpgw->template->set_var("bg_color",$phpgw_info["theme"]["bg_color"]); - $phpgw->template->set_var("th_bg",$phpgw_info["theme"]["th_bg"]); + $p->set_var("lang_installed",lang("Installed applications")); + $p->set_var("bg_color",$phpgw_info["theme"]["bg_color"]); + $p->set_var("th_bg",$phpgw_info["theme"]["th_bg"]); - $phpgw->template->set_var("sort_title",$phpgw->nextmatchs->show_sort_order($sort,"app_title",$order,"applications.php",lang("title"))); - $phpgw->template->set_var("lang_edit",lang("Edit")); - $phpgw->template->set_var("lang_delete",lang("Delete")); - $phpgw->template->set_var("lang_enabled",lang("Enabled")); + $p->set_var("sort_title",$phpgw->nextmatchs->show_sort_order($sort,"app_title",$order,"applications.php",lang("title"))); + $p->set_var("lang_edit",lang("Edit")); + $p->set_var("lang_delete",lang("Delete")); + $p->set_var("lang_enabled",lang("Enabled")); $phpgw->db->query("select * from phpgw_applications $ordermethod",__LINE__,__FILE__); while ($phpgw->db->next_record()) { @@ -45,24 +46,24 @@ if (! $phpgw->db->f("app_title")) $name = $phpgw->db->f("app_name"); if (! $name) $name = " "; - $phpgw->template->set_var("tr_color",$tr_color); - $phpgw->template->set_var("name",$name); - $phpgw->template->set_var("edit",' ' . lang("Edit") . ' '); - $phpgw->template->set_var("delete",' ' . lang("Delete") . ' '); + $p->set_var("tr_color",$tr_color); + $p->set_var("name",$name); + $p->set_var("edit",' ' . lang("Edit") . ' '); + $p->set_var("delete",' ' . lang("Delete") . ' '); if ($phpgw->db->f("app_enabled") != 0) { $status = lang("Yes"); } else { $status = "" . lang("No") . ""; } - $phpgw->template->set_var("status",$status); + $p->set_var("status",$status); - $phpgw->template->parse("rows","row",True); + $p->parse("rows","row",True); } - $phpgw->template->set_var("new_action",$phpgw->link("newapplication.php")); - $phpgw->template->set_var("lang_add",lang("add")); + $p->set_var("new_action",$phpgw->link("newapplication.php")); + $p->set_var("lang_add",lang("add")); - $phpgw->template->pparse("out","list"); - $phpgw->common->phpgw_footer(); -?> \ No newline at end of file + $p->pparse("out","list"); + $p->common->phpgw_footer(); +?> diff --git a/admin/editapplication.php b/admin/editapplication.php index 94ad4a025c..7128c1a889 100644 --- a/admin/editapplication.php +++ b/admin/editapplication.php @@ -18,21 +18,25 @@ $phpgw_info["flags"]["currentapp"] = "admin"; $phpgw_info["flags"]["enable_nextmatchs_class"] = True; + include("../header.inc.php"); + $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin')); + function display_row($label, $value) { - global $phpgw; - $phpgw->template->set_var("tr_color",$phpgw->nextmatchs->alternate_row_color()); - $phpgw->template->set_var("label",$label); - $phpgw->template->set_var("value",$value); + global $phpgw,$p; + $p->set_var("tr_color",$phpgw->nextmatchs->alternate_row_color()); + $p->set_var("label",$label); + $p->set_var("value",$value); - $phpgw->template->parse("rows","row",True); + $p->parse("rows","row",True); } - $phpgw->template->set_file(array("form" => "application_form.tpl", - "row" => "application_form_row.tpl" - )); + $p->set_file(array( + "form" => "application_form.tpl", + "row" => "application_form_row.tpl" + )); if ($submit) { if (! $app_order) { @@ -53,10 +57,10 @@ $phpgw->db->next_record(); if ($phpgw->db->f(0) != 0) { - $error[$totalerrors++] = lang("That application name already exsists."); + $error[$totalerrors++] = lang("That application name already exists."); } } - + if (! $totalerrors) { $phpgw->db->query("update phpgw_applications set app_name='" . addslashes($n_app_name) . "'," . "app_title='" . addslashes($n_app_title) . "', app_enabled='" @@ -79,9 +83,9 @@ $phpgw->common->phpgw_header(); echo parse_navbar(); - $phpgw->template->set_var("error","

" . $phpgw->common->error_list($error) . "

"); + $p->set_var("error","

" . $phpgw->common->error_list($error) . "

"); } else { - $phpgw->template->set_var("error",""); + $p->set_var("error",""); $n_app_name = $phpgw->db->f("app_name"); $n_app_title = $phpgw->db->f("app_title"); @@ -91,16 +95,16 @@ $n_app_anonymous = $phpgw->acl->check('', PHPGW_ACL_READ, $n_app_name); } - $phpgw->template->set_var("lang_header",lang("Edit application")); - $phpgw->template->set_var("hidden_vars",''); - $phpgw->template->set_var("th_bg",$phpgw_info["theme"]["th_bg"]); - $phpgw->template->set_var("form_action",$phpgw->link("editapplication.php")); + $p->set_var("lang_header",lang("Edit application")); + $p->set_var("hidden_vars",''); + $p->set_var("th_bg",$phpgw_info["theme"]["th_bg"]); + $p->set_var("form_action",$phpgw->link("editapplication.php")); display_row(lang("application name"),''); display_row(lang("application title"),''); - $phpgw->template->set_var("lang_status",lang("Status")); - $phpgw->template->set_var("lang_submit_button",lang("edit")); + $p->set_var("lang_status",lang("Status")); + $p->set_var("lang_submit_button",lang("edit")); $selected[$n_app_status] = " selected"; $status_html = '' @@ -118,9 +122,9 @@ display_row(lang("Allow Anonymous access to this app"),$str); - $phpgw->template->set_var("select_status",$status_html); + $p->set_var("select_status",$status_html); - $phpgw->template->pparse("out","form"); + $p->pparse("out","form"); $phpgw->common->phpgw_footer(); ?>