/** * Function will return all pages below the specified parent_id, the current user has access to. * * @param int $identifier * @param int $indent * @return string */ function communities_pages_inlists($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; } } $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 { $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_url` != '' AND `page_active` = '1' ORDER BY `page_order` ASC"; } $results = $db->GetAll($query); if ($results) { $output .= "<ul style=\"margin: 0 0 9px 0;\" class=\"community-page-list\" " . (isset($ul_id) ? "id = \"" . $ul_id . "\"" : "") . ">"; foreach ($results as $result) { $output .= "<li id=\"content_" . $result["cpage_id"] . "\">\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\">" . (!in_array($result["cpage_id"], $locked_ids) ? "<input type=\"checkbox\" id=\"delete_" . $result["cpage_id"] . "\" name=\"delete[]\" 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>"; $output .= communities_pages_inlists($result["cpage_id"], $indent + 1, $options, $locked_ids); $output .= "</li>\n"; } $output .= "</ul>"; } else { $output .= "<ul class=\"community-page-list empty\"></ul>"; } return $output; }
</tr> </thead> </table> <div class="community-page-list home"> <a href="<?php echo COMMUNITY_URL . $COMMUNITY_URL . ":pages?" . replace_query(array("action" => "edit", "step" => 1, "page" => "home")); ?> " style="font-weight: bold"> <?php $home_title = $db->GetOne("SELECT `menu_title` FROM `community_pages` WHERE `community_id` =" . $db->qstr($COMMUNITY_ID) . " AND `page_url` = ''"); echo isset($home_title) && $home_title != "" ? $home_title : "Home"; ?> </a> </div> <?php echo communities_pages_inlists(0, 0, array('id' => 'pagelists'), isset($COMMUNITY_LOCKED_PAGE_IDS) && $COMMUNITY_LOCKED_PAGE_IDS ? $COMMUNITY_LOCKED_PAGE_IDS : array()); ?> <input type="submit" id="delete_pages_button" class="btn btn-danger" value="Delete Selected" /> <input type="button" id="reorder_pages_button" class="btn" onclick="toggleSorting();" value="Reorder Pages"> </form> <form action="<?php echo COMMUNITY_URL . $community_details["community_url"] . ":pages?" . replace_query(array("action" => "reorder", "step" => 1)); ?> " method="post"> <div id="reorder-info" style="display: none;"> <textarea id="pageorder" name="pageorder" style="display: none;"></textarea> <p class="content-small">Rearrange the pages in the table above by dragging them, and then press the <strong>Save Ordering</strong> button.</p> <input type="submit" id="save_pages_order_button" class="btn btn-primary" value="Save Ordering" style="display:none;"/> </div> </form>