Пример #1
0
function step3()
{
    $db = Convert::getSourceDB('mod_wiki_images');
    $batch = new Batches('convert_wiki_images');
    $total = $db->count();
    if ($total < 1) {
        $batch->clear();
        Convert::addConvert('wiki');
        return dgettext('wiki', 'No wiki images to convert.  Module conversion complete!');
    }
    $batch->setTotalItems($total);
    $batch->setBatchSet(5);
    if (isset($_REQUEST['reset_batch'])) {
        $batch->clear();
    }
    $content[] = dgettext('wiki', 'Converting wiki images...');
    if (!$batch->load()) {
        $content[] = dgettext('wiki', 'Batch previously run.');
    } else {
        $result = runBatch($db, $batch);
        if (is_array($result)) {
            $content[] = dgettext('wiki', 'Some errors occurred when trying to convert the following images:');
            $content[] = '<ul><li>' . implode('</li><li>', $result) . '</li></ul>';
            return implode('<br />', $content);
        }
    }
    $percent = $batch->percentDone();
    $content[] = Convert::getGraph($percent);
    $batch->completeBatch();
    if (!$batch->isFinished()) {
        Convert::forward($batch->getAddress());
    } else {
        $batch->clear();
        Convert::addConvert('wiki');
        $content[] = dgettext('wiki', 'Module conversion complete!');
        $content[] = '<a href="index.php">' . dgettext('wiki', 'Go back to main menu.') . '</a>';
    }
    return implode('<br />', $content);
}