コード例 #1
0
/**
 *	Function to get all sub pages id's from a given page id.
 *
 *	@param	int		Any valid page_id as 'root'.
 *	@param	array	A given linear array to store the results. Pass-by-reference!
 *
 *	@return	nothing	Keep in mind, that param "subs" is pass-by-reference!
 *
 *	@example	$all_subpages_ids = array();
 *				get_subs( 5, $all_subpages_ids);
 *
 *				Will result in a linear list like e.g. "[5,6,8,9,11,7]" as the subids
 *				are sorted by position (in the page-tree);
 *
 */
function get_subs($parent, &$subs)
{
    // Global reference to the database-instance.
    global $database;
    // Get id's
    $all = array();
    $database->execute_query('SELECT `page_id` FROM `' . TABLE_PREFIX . 'pages` WHERE `parent` = ' . $parent . " ORDER BY `position`", true, $all);
    foreach ($all as &$fetch) {
        $subs[] = $fetch['page_id'];
        // Get subs of this sub - recursive call!
        get_subs($fetch['page_id'], $subs);
    }
}
コード例 #2
0
 *
 */
require '../../config.php';
require_once WB_PATH . '/framework/class.admin.php';
$admin = new admin('Pages', 'pages');
// Include the WB functions file
require_once WB_PATH . '/framework/functions.php';
// Get page list from database
// $database = new database();
$query = "SELECT * FROM " . TABLE_PREFIX . "pages WHERE visibility = 'deleted' ORDER BY level DESC";
$get_pages = $database->query($query);
// Insert values into main page list
if ($get_pages->numRows() > 0) {
    while ($page = $get_pages->fetchRow()) {
        // Delete page subs
        $sub_pages = get_subs($page['page_id'], array());
        foreach ($sub_pages as $sub_page_id) {
            delete_page($sub_page_id);
        }
        // Delete page
        delete_page($page['page_id']);
    }
}
// Check if there is a db error, otherwise say successful
if ($database->is_error()) {
    $admin->print_error($database->get_error());
} else {
    $admin->print_success($TEXT['TRASH_EMPTIED']);
}
// Print admin
$admin->print_footer();
コード例 #3
0
                }
            }
        }
    }
    // Update the page visibility to 'deleted'
    $sql = 'UPDATE `' . TABLE_PREFIX . 'pages` SET ' . '`visibility` = \'deleted\' ' . 'WHERE `page_id` = ' . $page_id . ' ' . '';
    $database->query($sql);
    if ($database->is_error()) {
        $admin->print_error($database->get_error());
    }
    //
    // Run trash subs for this page
    trash_subs($page_id);
} else {
    // Really dump the page
    // Delete page subs
    $sub_pages = get_subs($page_id, array());
    foreach ($sub_pages as $sub_page_id) {
        delete_page($sub_page_id);
    }
    // Delete page
    delete_page($page_id);
}
// Check if there is a db error, otherwise say successful
if ($database->is_error()) {
    $admin->print_error($database->get_error());
} else {
    $admin->print_success($MESSAGE['PAGES_DELETED']);
}
// Print admin footer
$admin->print_footer();
コード例 #4
0
function get_subs($parent, array $subs)
{
    // Connect to the database
    global $database;
    // Get id's
    $sql = 'SELECT `page_id` FROM `' . TABLE_PREFIX . 'pages` WHERE `parent` = ' . intval($parent);
    if ($query = $database->query($sql)) {
        while ($fetch = $query->fetchRow(MYSQLI_ASSOC)) {
            $subs[] = intval($fetch['page_id']);
            // Get subs of this sub recursive
            $subs = get_subs($fetch['page_id'], $subs);
        }
    }
    // Return subs array
    return $subs;
}
コード例 #5
0
ファイル: delete.php プロジェクト: pixelhulk/LEPTON
                // Run this function again for all sub-pages
                trash_subs($page['page_id']);
            }
        }
    }
    // Update the page visibility to 'deleted'
    $database->query("UPDATE " . TABLE_PREFIX . "pages SET visibility = 'deleted' WHERE page_id = '{$page_id}' LIMIT 1");
    if ($database->is_error()) {
        trigger_error(sprintf('[%s - %s] %s', __FILE__, __LINE__, $database->get_error()), E_USER_ERROR);
    }
    // Run trash subs for this page
    trash_subs($page_id);
} else {
    // Really dump the page
    // Delete page subs
    $sub_pages = array();
    get_subs($page_id, $sub_pages);
    foreach ($sub_pages as $sub_page_id) {
        delete_page($sub_page_id);
    }
    // Delete page
    delete_page($page_id);
}
// Check if there is a db error, otherwise say successful
if ($database->is_error()) {
    $admin->print_error($database->get_error());
} else {
    $admin->print_success($MESSAGE['PAGES_DELETED']);
}
// Print admin footer
$admin->print_footer();