/**
 * "View Children" tab setup
 */
$maxpageSize = $modx->config['number_of_results'];
define('MAX_DISPLAY_RECORDS_NUM', $maxpageSize);
if (!class_exists('makeTable')) {
    include_once $modx->config['site_manager_path'] . 'includes/extenders/maketable.class.php';
}
$childsTable = new makeTable();
// Get child document count
$rs = $modx->db->select('count(DISTINCT sc.id)', "{$tbl_site_content} AS sc\n\t\tLEFT JOIN {$tbl_document_groups} AS dg ON dg.document = sc.id", "sc.parent='{$content['id']}' AND ({$access})");
$numRecords = $modx->db->getValue($rs);
$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon';
$dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : 'DESC';
// Get child documents (with paging)
$rs = $modx->db->select('DISTINCT sc.*', "{$tbl_site_content} AS sc\n\t\tLEFT JOIN {$tbl_document_groups} AS dg ON dg.document = sc.id", "sc.parent='{$content['id']}' AND ({$access})", "{$sort} {$dir}", $childsTable->handlePaging());
$filter_sort = '';
$filter_dir = '';
if ($numRecords > 0) {
    $filter_sort = '<p><select size="1" name="sort" onchange="document.location=\'index.php?a=3&id=' . $id . '&dir=' . $dir . '&sort=\'+this.options[this.selectedIndex].value">' . '<option value="createdon"' . ($sort == 'createdon' ? ' selected' : '') . '>' . $_lang['createdon'] . '</option>' . '<option value="pub_date"' . ($sort == 'pub_date' ? ' selected' : '') . '>' . $_lang["page_data_publishdate"] . '</option>' . '<option value="pagetitle"' . ($sort == 'pagetitle' ? ' selected' : '') . '>' . $_lang['pagetitle'] . '</option>' . '<option value="menuindex"' . ($sort == 'menuindex' ? ' selected' : '') . '>' . $_lang['resource_opt_menu_index'] . '</option>' . '<option value="published"' . ($sort == 'published' ? ' selected' : '') . '>' . $_lang['resource_opt_is_published'] . '</option>' . '</select>';
    $filter_dir = '<select size="1" name="dir" onchange="document.location=\'index.php?a=3&id=' . $id . '&sort=' . $sort . '&dir=\'+this.options[this.selectedIndex].value">' . '<option value="DESC"' . ($dir == 'DESC' ? ' selected' : '') . '>' . $_lang['sort_desc'] . '</option>' . '<option value="ASC"' . ($dir == 'ASC' ? ' selected' : '') . '>' . $_lang['sort_asc'] . '</option>' . '</select></p>';
    $resource = $modx->db->makeArray($rs);
    // CSS style for table
    $tableClass = 'grid';
    $rowHeaderClass = 'gridHeader';
    $rowRegularClass = 'gridItem';
    $rowAlternateClass = 'gridAltItem';
    $childsTable->setTableClass($tableClass);
    $childsTable->setRowHeaderClass($rowHeaderClass);
    $childsTable->setRowRegularClass($rowRegularClass);
    $childsTable->setRowAlternateClass($rowAlternateClass);
}
/**
 * "View Children" tab setup
 */
$maxpageSize = $modx->config['number_of_results'];
define('MAX_DISPLAY_RECORDS_NUM', $maxpageSize);
if (!class_exists('makeTable')) {
    include_once $modx->config['base_path'] . 'manager/includes/extenders/maketable.class.php';
}
$childsTable = new makeTable();
// Get child document count
$sql = 'SELECT DISTINCT sc.id ' . 'FROM ' . $tbl_site_content . ' AS sc ' . 'LEFT JOIN ' . $tbl_document_groups . ' AS dg ON dg.document = sc.id ' . 'WHERE sc.parent=\'' . $content['id'] . '\' ' . 'AND (' . $access . ')';
$rs = $modx->db->query($sql);
$numRecords = $modx->db->getRecordCount($rs);
// Get child documents (with paging)
$sql = 'SELECT DISTINCT sc.* ' . 'FROM ' . $tbl_site_content . ' AS sc ' . 'LEFT JOIN ' . $tbl_document_groups . ' AS dg ON dg.document = sc.id ' . 'WHERE sc.parent=\'' . $content['id'] . '\' ' . 'AND (' . $access . ') ' . $childsTable->handlePaging();
// add limit clause
if ($numRecords > 0) {
    if (!($rs = $modx->db->query($sql))) {
        // sql error
        $e->setError(1);
        $e->dumpError();
        include $modx->config['base_path'] . 'manager/includes/footer.inc.php';
        exit;
    } else {
        $resource = array();
        while ($row = $modx->fetchRow($rs)) {
            $resource[] = $row;
        }
        // CSS style for table
        $tableClass = 'grid';