<?php

/* ====================
[BEGIN_SED_EXTPLUGIN]
Code=hidefuturepages
Part=page
File=hidefuturepages.page.edit.update.done
Hooks=page.edit.update.done
Tags=
Order=10
[END_SED_EXTPLUGIN]
==================== */
defined('SED_CODE') or die('Wrong URL');
if ((int) $rpagebegin > (int) $sys['now_offset']) {
    $id = (int) $id;
    sed_sql_query("UPDATE {$db_pages} SET page_state='3' WHERE page_id='{$id}'");
    sed_log("Edited page #" . $id, 'adm');
    sed_redirect(sed_url('admin', 'm=page&s=queue', NULL, TRUE));
}
function hfp_create_pagination($total, $page, $state)
{
    global $cfg;
    $limit = HFP_TOOL_ITEMS_PER_PAGE;
    $offset_page = $page - 1;
    $total = $total != 0 ? ceil($total / $limit) : 0;
    if ($offset_page != 0) {
        $previous_page = $page - 1;
        $previous_url = sed_url('admin', array('m' => 'tools', 'p' => 'hidefuturepages', 'state' => $state, 'page' => $previous_page));
        $output = '<a style="text-decoration: underline;" href="' . $previous_url . '"><img class="hfp_icon_16" src="' . $cfg['plugins_dir'] . '/hidefuturepages/img/arrow-left.png" /></a> &nbsp; ';
    }
    for ($i = 0; $total > $i; $i++) {
        $pageout = $i + 1;
        if ($pageout != $page) {
            $pagelist_url = sed_url('admin', array('m' => 'tools', 'p' => 'hidefuturepages', 'state' => $state, 'page' => $pageout));
            $output .= '<a style="text-decoration: underline;" href="' . $pagelist_url . '">' . $pageout . '</a> ';
        } else {
            $output .= '<b>' . $pageout . '</b> ';
        }
        if ($pageout != $total) {
            $output .= '&nbsp;';
        }
    }
    if ((int) $page != (int) $total) {
        $next_page = $page + 1;
        $next_url = sed_url('admin', array('m' => 'tools', 'p' => 'hidefuturepages', 'state' => $state, 'page' => $next_page));
        $output .= ' &nbsp; <a style="text-decoration: underline;" href="' . $next_url . '"><img class="hfp_icon_16" src="' . $cfg['plugins_dir'] . '/hidefuturepages/img/arrow-right.png" /></a> ';
    }
    return $output;
}