Exemple #1
0
/**
 * The screen that's shown when you click 'rebuild frontpage'
 *
 */
function buildfrontpage()
{
    global $Weblogs;
    PageHeader(lang('adminbar', 'buildfrontpage'), 1);
    PageAnkeiler(lang('adminbar', 'buildfrontpage'));
    echo "<p>";
    buildfrontpage_function();
    // Ensure that frontpages for all weblogs are built.
    foreach ($Weblogs as $name => $weblog) {
        generate_frontpage($name);
    }
    print_timers();
    echo "</p><p><b>" . lang('general', 'done') . "</b></p>";
}
/**
 * Generates entries, frontpages and archives for a given entry ID.
 *
 * @uses generate_html generates entry (HTML)
 * @uses generate_archive generates archive page
 * @uses generate_frontpage generates front page
 */
function generate_pages($id, $singlepage = TRUE, $frontpage = TRUE, $archive = TRUE, $ping = FALSE, $rss = TRUE)
{
    global $db, $Weblogs, $Current_weblog, $Allow_RSS;
    //LoadTempLanguage();
    $Allow_RSS = $rss;
    // load an entry
    $entry = $db->read_entry($id, TRUE);
    $in_weblogs = find_weblogs_with_cat($entry['category']);
    foreach ($in_weblogs as $in_weblog) {
        $entry = $db->read_entry($id);
        $org_date = $entry['date'];
        $Current_weblog = $in_weblog;
        $template = $Weblogs[$in_weblog]['entry_template'];
        // we generate the single (static) entry only if it's published
        if ($Weblogs[$in_weblog]['live_entries'] != 1 && $entry['status'] == 'publish') {
            generate_html($template, $in_weblog);
        }
        // generate the archives (for this date) only if the entry is
        // published.
        if ($archive && $Weblogs[$Current_weblog]['archive_unit'] != 'none' && $entry['status'] == 'publish') {
            generate_archive($in_weblog, $org_date);
        }
        // generate the frontpage
        if ($frontpage) {
            $filename = generate_frontpage($in_weblog);
        }
        LoadUserLanguage();
    }
    // if we need to ping. do here:
    if ($ping) {
        open_ping_window($in_weblogs);
    }
}
Exemple #3
0
/**
 * Screen that's shown when rebuilding all pages.
 */
function regen()
{
    global $Cfg, $db, $Weblogs, $Pivot_Vars, $VerboseGenerate, $Allow_RSS, $totalfiles, $done_archives, $archive_array_next, $archive_array_prev, $Archive_array;
    PageHeader(lang('adminbar', 'regen_title'), 1);
    PageAnkeiler(lang('userbar', 'admin') . ' &raquo; ' . lang('adminbar', 'regen_title'));
    // initialise the threshold..
    if (isset($Cfg['rebuild_threshold']) && $Cfg['rebuild_threshold'] > 4) {
        $threshold = $Cfg['rebuild_threshold'];
    } else {
        $threshold = 28;
    }
    $db = new db();
    // also force the archive index file to be updated
    @unlink('db/ser-archives.php');
    // Make a new archive array.
    $Archive_array = make_archive_array();
    // ugly hack, to get a big slice of mem back..
    $entries_arr = $db->getcodes_range("0000-00-00-00-00", "2010-01-01-00-00", "", "", FALSE);
    $totalfiles = 0;
    $count = 0;
    if (isset($Pivot_Vars['count'])) {
        $count = $Pivot_Vars['count'];
        $totalfiles = $Pivot_Vars['totalfiles'];
        reset($entries_arr);
        do {
            next($entries_arr);
            $key = key($entries_arr);
            //echo "(k $key)";
        } while ($key < $Pivot_Vars['count']);
    }
    do {
        $key = key($entries_arr);
        $loopentry = current($entries_arr);
        // Generate only archive pages and static entry pages, not
        // frontpage or RSS.
        generate_pages($loopentry, TRUE, FALSE, TRUE, FALSE, FALSE);
        $count++;
        if ($count % 10 == 0) {
            printf("%1.2f sec: Processed %d entries.." . "<br />\n", timetaken('int'), $count);
            flush();
        }
        // server friendly generate all..
        if (timetaken("int") > $threshold) {
            $myurl = sprintf("index.php?session=%s&menu=admin&func=admin&do=regen&count=%s&totalfiles=%s", $Pivot_Vars['session'], $count, $totalfiles);
            printf('<script> self.location = "%s"; </script>', $myurl);
            die;
        }
    } while (next($entries_arr));
    printf("<br />A total of <b>%s</b> entries have been processed, and <b>%s</b> files have been created" . "<br />\n", $count, $totalfiles);
    // Generate frontpages and feeds.
    echo "<p>" . lang('adminbar', 'buildfrontpage_title') . "</p>";
    $VerboseGenerate = true;
    $Allow_RSS = true;
    foreach ($Weblogs as $name => $weblog) {
        generate_frontpage($name);
    }
    echo "<p>" . lang('general', 'done') . "</p>";
    PageFooter();
}