Пример #1
0
/**
 * 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_intable($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"];
        }
    }
    $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) {
        foreach ($results as $result) {
            if ($indent > 0 && !$selectable_children) {
                $output .= "<tr id=\"content_" . $result["cpage_id"] . "\">\n";
                $output .= "\t<td>&nbsp;</td>\n";
                $output .= "\t<td " . ((int) $result["page_visible"] == 0 ? " class=\"hidden-page\"" : "") . "style=\"padding-left: " . $indent * 25 . "px; vertical-align: middle\"><img src=\"" . ENTRADA_URL . "/images/record-next-off.gif\" width=\"11\" height=\"11\" border=\"0\" alt=\"\" title=\"\" style=\"vertical-align: middle; margin-right: 5px\" />" . html_encode($result["menu_title"]) . "</td>\n";
                $output .= "</tr>\n";
            } else {
                $output .= "<tr id=\"content_" . $result["cpage_id"] . "\">\n";
                $output .= "\t<td>" . (array_search($result["cpage_id"], $locked_ids) === false ? "<input type=\"checkbox\" id=\"delete_" . $result["cpage_id"] . "\" name=\"delete[]\" value=\"" . $result["cpage_id"] . "\" style=\"vertical-align: middle\"" . ($selected == $result["cpage_id"] ? " checked=\"checked\"" : "") . " />" : "&nbsp;") . "</td>\n";
                $output .= "\t<td " . ((int) $result["page_visible"] == 0 ? " class=\"hidden-page\"" : "") . "style=\"padding-left: " . $indent * 25 . "px; vertical-align: middle\"><img src=\"" . ENTRADA_URL . "/images/record-next-on.gif\" width=\"11\" height=\"11\" border=\"0\" alt=\"\" title=\"\" style=\"vertical-align: middle; margin-right: 5px\" /><a href=\"" . COMMUNITY_URL . $COMMUNITY_URL . ":pages?" . replace_query(array("action" => "edit", "step" => 1, "page" => $result["cpage_id"])) . "\"" . ($result["parent_id"] == 0 ? " style=\"font-weight: bold\"" : "") . ">" . html_encode($result["menu_title"]) . "</a></td>\n";
                $output .= "</tr>\n";
            }
            $output .= communities_pages_intable($result["cpage_id"], $indent + 1, $options);
        }
    }
    return $output;
}
Пример #2
0
					<col class="modified" />
					<col class="title" />
				</colgroup>
				<thead>
					<tr>
						<td class="modified">&nbsp;</td>
						<td class="title">Community Pages</td>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<td>&nbsp;</td>
						<td style="padding-top: 10px">
							<input type="submit" class="btn btn-danger" value="Delete Selected" />
						</td>
					</tr>
				</tfoot>
				<tbody>
				<?php 
                foreach ($pages as $page) {
                    echo communities_pages_intable($page["CPAGE_ID"], 0, array("selected" => $page["CPAGE_ID"], "selectable_children" => false));
                }
                ?>
				</tbody>
				</table>
				</form>
				<?php 
            }
            break;
    }
}