/** * Builds a dropdown of available pages for a client. This is used by the administrator * to display the list of pages available for the clients menus, etc. * * @param string $selected * @param array $attributes * @param array $omit_pages */ function ft_get_client_menu_pages_dropdown($selected, $attributes, $omit_pages = array()) { global $LANG; // stores the non-option lines of the select box: <select>, </select> and the optgroups $select_lines = array(); $select_lines[] = array("type" => "select_open"); if (!in_array("", $omit_pages)) { $select_lines[] = array("type" => "option", "v" => $LANG["phrase_please_select"]); } if (!in_array("custom_url", $omit_pages)) { $select_lines[] = array("type" => "optgroup_open", "label" => $LANG["word_custom"]); $select_lines[] = array("type" => "option", "k" => "custom_url", "v" => $LANG["phrase_custom_url"]); $select_lines[] = array("type" => "optgroup_close"); } $select_lines[] = array("type" => "optgroup_open", "label" => $LANG["word_main"]); if (!in_array("client_forms", $omit_pages)) { $select_lines[] = array("type" => "option", "k" => "client_forms", "v" => $LANG["word_forms"]); } if (!in_array("client_form_submissions", $omit_pages)) { $select_lines[] = array("type" => "option", "k" => "client_form_submissions", "v" => $LANG["phrase_form_submissions"]); } if (!in_array("client_account", $omit_pages)) { $select_lines[] = array("type" => "option", "k" => "client_account", "v" => $LANG["word_account"]); } if (!in_array("client_account_login", $omit_pages)) { $select_lines[] = array("type" => "option", "k" => "client_account_login", "v" => $LANG["phrase_login_info"]); } if (!in_array("client_account_settings", $omit_pages)) { $select_lines[] = array("type" => "option", "k" => "client_account_settings", "v" => $LANG["phrase_account_settings"]); } if (!in_array("logout", $omit_pages)) { $select_lines[] = array("type" => "option", "k" => "logout", "v" => $LANG["word_logout"]); } $select_lines[] = array("type" => "optgroup_close"); // if the Pages module is enabled, display any custom pages that have been defined. Only show the optgroup // if there's at least ONE page defined if (ft_check_module_enabled("pages")) { ft_include_module("pages"); $pages_info = pg_get_pages("all"); $pages = $pages_info["results"]; if (count($pages) > 0) { $select_lines[] = array("type" => "optgroup_open", "label" => $LANG["phrase_pages_module"]); foreach ($pages as $page) { $page_id = $page["page_id"]; $page_name = $page["page_name"]; $select_lines[] = array("type" => "option", "k" => "page_{$page_id}", "v" => $page_name); } $select_lines[] = array("type" => "optgroup_close"); } } extract(ft_process_hook_calls("middle", compact("select_lines"), array("select_lines")), EXTR_OVERWRITE); $select_lines[] = array("type" => "select_close"); // now build the HTML $dd = ""; foreach ($select_lines as $line) { switch ($line["type"]) { case "select_open": $attribute_str = ""; while (list($key, $value) = each($attributes)) { $attribute_str .= " {$key}=\"{$value}\""; } $dd .= "<select {$attribute_str}>"; break; case "select_close": $dd .= "</select>"; break; case "optgroup_open": $dd .= "<optgroup label=\"{$line["label"]}\">"; break; case "optgroup_close": $dd .= "</optgroup>"; break; case "option": $key = $line["k"]; $value = $line["v"]; $dd .= "<option value=\"{$key}\"" . ($selected == $key ? " selected" : "") . ">{$value}</option>\n"; break; } } return $dd; }
<?php require_once "../../global/library.php"; ft_init_module_page(); $folder = dirname(__FILE__); require_once "{$folder}/library.php"; if (isset($_GET["delete"])) { list($g_success, $g_message) = pg_delete_page($_GET["delete"]); } $page = ft_load_module_field("pages", "page", "module_pages_page", 1); $num_pages_per_page = ft_get_module_settings("num_pages_per_page"); $pages_info = pg_get_pages($num_pages_per_page, $page); $results = $pages_info["results"]; $num_results = $pages_info["num_results"]; $text_intro_para_2 = ft_eval_smarty_string($L["text_intro_para_2"], array("url" => "../../admin/settings/index.php?page=menus")); // ------------------------------------------------------------------------------------------------ $page_vars = array(); $page_vars["pages"] = $results; $page_vars["head_title"] = $L["module_name"]; $page_vars["pagination"] = ft_get_page_nav($num_results, $num_pages_per_page, $page, ""); $page_vars["js_messages"] = array("word_edit", "phrase_please_confirm", "word_yes", "word_no"); $page_vars["module_js_messages"] = array("confirm_delete_page"); $page_vars["text_intro_para_2"] = $text_intro_para_2; $page_vars["head_string"] = <<<EOF <script type="text/javascript" src="scripts/pages.js"></script> EOF; ft_display_module_page("templates/index.tpl", $page_vars);