/**
 * Regénération de tous les documents
 * @package Backend
 * @subpackage Presentation
 * @author Laurent Jouanneau
 * @author Florian Hatat
 * @copyright Copyright © 2003 OpenWeb.eu.org
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
 */
define('OW_BACKEND_ACTION', 'ACT_DOCREGEN');
require_once "../../include/backend/init.inc.php";
require_once PATH_INC_BACKEND_SERVICE . 'DocumentManager.class.php';
require_once PATH_INC_BACKEND_SERVICE . 'ReferenceManager.class.php';
// instanciation des services
$am = new DocumentManager($db);
$nbrtotal = $am->nbrDocs();
if (isset($_GET['act']) && $_GET['act'] == 'do') {
    $page = isset($_GET['pg']) ? $_GET['pg'] : 0;
    if ($page == 0) {
        $ref = new ReferenceManager($db);
        $ref->dumpClassements();
    }
    $nextpage = $am->toutRegenerer($page);
    if ($nextpage > 0) {
        ?>
<form action="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
" method="get">
<fieldset>
<legend>Regénération</legend>
echo html_liste_actions();
$ref = new ReferenceManager($db);
$listeCrit = $ref->getCriterionList();
$listeCat = array();
foreach ($listeCrit as $crit => $name) {
    $listeCat[$name] = $ref->getEntriesList($crit);
    if (empty($listeCat[$name])) {
        /* on enlève lorsqu'aucun classement n'existe */
        unset($listeCat[$name]);
    }
}
$listeArticles = array();
if (isset($_GET['catid'])) {
    $catid = $_GET['catid'];
    $am = new DocumentManager($db);
    $am->nbParPage = $am->nbrDocs();
    if (isset($_POST['liste'])) {
        $am->setDocumentOrder($catid, array_flip($liste));
    }
    $listeArticles = $am->getListBy1Critere($catid);
} else {
    $catid = null;
    $listeArticles = array();
}
?>
<script type="text/javascript" src="deversoir.js"></script>

<form action="<?php 
echo $_SERVER['PHP_SELF'];
?>
" method="get" name="frm">