</tr> <?php if (!$home_page && array_search($PAGE_ID, isset($COMMUNITY_LOCKED_PAGE_IDS) && $COMMUNITY_LOCKED_PAGE_IDS ? $COMMUNITY_LOCKED_PAGE_IDS : array()) === false) { ?> <tr> <td colspan="2"> </td> </tr> <tr> <td><label for="parent_id" class="form-required">Page Parent:</label></td> <td> <select id="parent_id" name="parent_id" onchange="parentChange(this.value)" style="width: 304px"> <?php echo "<option value=\"0\"" . (!$page_details["parent_id"] ? " selected=\"selected\"" : "") . ">-- No Parent Page --</option>\n"; $current_selected = array($page_details["parent_id"]); $exclude = array($PAGE_ID); echo communities_pages_inselect(0, $current_selected, 0, $exclude, $COMMUNITY_ID); ?> </select> </td> </tr> <?php } ?> <tr> <td colspan="2"> </td> </tr> <tr> <td><label for="menu_title" class="form-required">Menu Title:</label></td> <td><input type="text" id="menu_title" name="menu_title" value="<?php echo isset($PROCESSED["menu_title"]) ? html_encode($PROCESSED["menu_title"]) : (isset($page_details["menu_title"]) ? html_encode($page_details["menu_title"]) : ""); ?>
/** * Function will return all pages below the specified parent_id, as option elements of an input select. * This is a recursive function that has a fall-out of 99 runs. * * @param int $parent_id * @param array $current_selected * @param int $indent * @param array $exclude * @return string */ function communities_pages_inselect($parent_id = 0, &$current_selected, $indent = 0, &$exclude = array()) { global $db, $COMMUNITY_ID; if ($indent > 99) { die("Preventing infinite loop"); } if (!is_array($current_selected)) { $current_selected = array($current_selected); } $output = ""; $query = "SELECT `cpage_id`, `menu_title`, `parent_id` FROM `community_pages` WHERE `community_id` = " . $db->qstr($COMMUNITY_ID) . " AND `page_active` = '1' AND `parent_id` = " . $db->qstr($parent_id) . " AND `page_url` != '' ORDER BY `page_order` ASC"; $results = $db->GetAll($query); if ($results) { foreach ($results as $result) { if (!@in_array($result["cpage_id"], $exclude) && !@in_array($parent_id, $exclude)) { $output .= "<option value=\"" . (int) $result["cpage_id"] . "\"" . (@in_array($result["cpage_id"], $current_selected) ? " selected=\"selected\"" : "") . ">" . str_repeat(" ", $indent) . ($indent > 0 ? "→ " : "") . html_encode($result["menu_title"]) . "</option>\n"; } else { $exclude[] = (int) $result["cpage_id"]; } $output .= communities_pages_inselect($result["cpage_id"], $current_selected, $indent + 1, $exclude); } } return $output; }