function communities_pages_inradio($identifier = 0, $indent = 0, $options = array(), $locked_ids = array()) { global $db, $COMMUNITY_ID, $COMMUNITY_URL; if ($indent > 99) { die("Preventing infinite loop"); } $selected = 0; $selectable_children = true; if (is_array($options)) { if (isset($options["selected"]) && ($tmp_input = clean_input($options["selected"], array("nows", "int")))) { $selected = $tmp_input; } if (isset($options["selectable_children"])) { $selectable_children = (bool) $options["selectable_children"]; } if (isset($options["id"])) { $ul_id = $options["id"]; $options["id"] = null; } if (isset($options["nav_type"])) { $nav_type = $options["nav_type"]; } if (isset($options["parent_swap"])) { $new_parent = $options["parent_swap"]["parent_id"]; $page_id = $options["parent_swap"]["page_id"]; } } $identifier = (int) $identifier; $output = ""; if ($identifier && $indent === 0) { $query = "SELECT `cpage_id`, `page_url`, `menu_title`, `parent_id`, `page_visible`, `page_type` FROM `community_pages` WHERE `community_id` = " . $COMMUNITY_ID . " AND `cpage_id` = " . $db->qstr((int) $identifier) . " AND `page_url` != '0' AND `page_active` = '1' ORDER BY `page_order` ASC"; } else { if (!isset($options["parent_swap"])) { $query = "SELECT `cpage_id`, `page_url`, `menu_title`, `parent_id`, `page_visible`, `page_type` FROM `community_pages` WHERE `community_id` = " . $COMMUNITY_ID . " AND `parent_id` = " . $db->qstr((int) $identifier) . " AND `page_active` = '1' ORDER BY `page_order` ASC"; } else { $query = "SELECT `cpage_id`, `page_url`, `menu_title`, `parent_id`, `page_visible`, `page_type`\n\t\t\t\t\t\tFROM `community_pages`\n\t\t\t\t\t\tWHERE `community_id` = " . $COMMUNITY_ID . "\n\t\t\t\t\t\tAND `parent_id` = " . $db->qstr((int) $identifier) . "\n\t\t\t\t\t\tAND `cpage_id` != " . $db->qstr($page_id) . "\n\t\t\t\t\t\tAND `page_active` = '1'\n\t\t\t\t\t\tORDER BY `page_order` ASC"; } } $results = $db->GetAll($query); if (isset($options["parent_swap"]) && $options["parent_swap"] && $identifier == $new_parent && $page_id) { $query = "SELECT `cpage_id`, `page_url`, `menu_title`, `parent_id`, `page_visible`, `page_type`\n\t\t\t\t\tFROM `community_pages`\n\t\t\t\t\tWHERE `community_id` = " . $COMMUNITY_ID . "\n\t\t\t\t\tAND `cpage_id` = " . $db->qstr((int) $page_id) . "\n\t\t\t\t\tAND `page_url` != '0'\n\t\t\t\t\tAND `page_active` = '1'\n\t\t\t\t\tORDER BY `page_order` ASC"; $additional_page = $db->GetRow($query); array_push($results, $additional_page); } if ($results) { $output .= "<ul class=\"community-page-list\" " . (isset($ul_id) ? "id = \"" . $ul_id . "\"" : "") . ">"; foreach ($results as $result) { $output .= "<li id=\"content_" . $ul_id . "_" . $result["cpage_id"] . "\"" . (!$identifier || $indent !== 0 ? " class=\"parent_" . $identifier . "\"" : "") . ">\n"; $output .= "<div class=\"community-page-container\">"; if ($indent > 0 && !$selectable_children) { $output .= "\t<span class=\"delete\"> </span>\n"; $output .= "\t<span class=\"" . ((int) $result["page_visible"] == 0 ? "hidden-page " : "") . "next off\">" . html_encode($result["menu_title"]) . "</span>\n"; } else { $output .= "\t<span class=\"delete\">" . (array_search($result["cpage_id"], $locked_ids) === false ? "<input type=\"radio\" id=\"nav_" . $nav_type . "_page_id" . $result["cpage_id"] . "\" name=\"nav_" . $nav_type . "_page_id\" value=\"" . $result["cpage_id"] . "\"" . ($selected == $result["cpage_id"] ? " checked=\"checked\"" : "") . " />" : "<div class=\"locked-spacer\"> </div>") . "</span>\n"; $output .= "\t<span class=\"" . ((int) $result["page_visible"] == 0 ? "hidden-page " : "") . "next\">\n\t\t\t\t\t\t\t\t<a href=\"" . COMMUNITY_URL . $COMMUNITY_URL . ":pages?" . replace_query(array("action" => "edit", "step" => 1, "page" => $result["cpage_id"])) . "\">" . html_encode($result["menu_title"]) . "</a></span>\n"; } $output .= "</div>"; $options["id"] = $ul_id; $output .= communities_pages_inradio($result["cpage_id"], $indent + 1, $options); $output .= "</li>\n"; } $output .= "</ul>"; } else { $output .= "<ul class=\"community-page-list empty\"></ul>"; } return $output; }
</table> </td> </tr> <?php } ?> </tbody> </table> <div id="modal_page_navigation" style="display: none; text-align: left;"> <?php echo communities_pages_inradio(0, 0, array('id' => 'next_page_list', "nav_type" => "next", "selected" => isset($nav_next_page_id) && $nav_next_page_id ? $nav_next_page_id : $default_next_page["cpage_id"])); ?> </div> <div id="modal_previous_page_navigation" style="display: none; text-align: left;"> <?php echo communities_pages_inradio(0, 0, array('id' => 'previous_page_list', "nav_type" => "previous", "selected" => isset($nav_previous_page_id) && $nav_previous_page_id ? $nav_previous_page_id : (isset($default_previous_page["cpage_id"]) && $default_previous_page["cpage_id"] ? $default_previous_page["cpage_id"] : ""))); ?> </div> </form> <?php break; } } else { $url = COMMUNITY_URL . $COMMUNITY_URL . ":pages"; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; $ERROR++; $ERRORSTR[] = "The page you have requested does not currently exist within this community.<br /><br />You will now be redirected to the page management index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; echo display_error(); } } else { application_log("error", "Someone attempted to access this page who was not a community administrator. (Edit Page)");
if (!isset($_POST["page_order"]) || !($page_order = (int) $_POST["page_order"])) { $query = "SELECT (MAX(`page_order`) + 1) FROM `community_pages`\n\t\t\t\t\tWHERE `community_id` = " . $db->qstr($COMMUNITY_ID) . "\n\t\t\t\t\tAND `parent_id` = " . $db->qstr($parent_id); $page_order = $db->GetOne($query); } switch ($nav_type) { case "prev_id": case "previous_id": $default_previous_page = get_prev_community_page($COMMUNITY_ID, $cpage_id, $parent_id, $page_order); echo $default_previous_page["cpage_id"]; exit; break; case "prev": case "previous": $default_previous_page = get_prev_community_page($COMMUNITY_ID, $cpage_id, $parent_id, $page_order); echo communities_pages_inradio(0, 0, array("selected" => $default_previous_page["cpage_id"], "id" => "previous_page_list", "nav_type" => "previous", "parent_swap" => array("parent_id" => $parent_id, "page_id" => $cpage_id))); exit; break; case "next_id": default: $default_next_page = get_next_community_page($COMMUNITY_ID, $cpage_id, $parent_id, $page_order); echo $default_next_page["cpage_id"]; exit; break; case "next": default: $default_next_page = get_next_community_page($COMMUNITY_ID, $cpage_id, $parent_id, $page_order); echo communities_pages_inradio(0, 0, array("selected" => $default_next_page["cpage_id"], "id" => "next_page_list", "nav_type" => "next", "parent_swap" => array("parent_id" => $parent_id, "page_id" => $cpage_id))); exit; break; } }