Example #1
0
    reset($Weblogs);
    $Current_weblog = key($Weblogs);
}
// Display the search results.
LoadWeblogLanguage($Weblogs[$Current_weblog]['language']);
$db = new db();
$result = "\n<div class='pivot-search-result'>\n";
$result .= search_result();
$result .= "<!-- Search took " . timetaken() . " seconds -->\n";
$result .= "</div>\n";
unset($db->entry);
// Set the template for the tags page
if (!isset($Pivot_Vars['t']) || empty($Pivot_Vars['t'])) {
    if (isset($Weblogs[$Current_weblog]['extra_template']) && $Weblogs[$Current_weblog]['extra_template'] != "") {
        $template = $Weblogs[$Current_weblog]['extra_template'];
    } else {
        $template = $Weblogs[$Current_weblog]['archive_template'];
    }
} else {
    $template = $Pivot_Vars['t'];
}
$template_html = load_template($template);
$template_html = replace_subweblogs_templates($template_html, $result);
if (!$template_html) {
    piv_error("Template error", "Could not load template file, <i>" . htmlspecialchars($template) . "</i>, because it doesn't exist.");
} else {
    $output = $template_html;
    $output = parse_step4($output);
}
echo $output;
flush();
Example #2
0
            piv_error("Weblog doesn't exist", "Selected weblog \"" . htmlspecialchars($Pivot_Vars['w']) . "\" doesn't exist.");
        } else {
            $Current_weblog = $override_weblog;
        }
    }
} else {
    reset($Weblogs);
    $Current_weblog = key($Weblogs);
}
LoadWeblogLanguage($Weblogs[$Current_weblog]['language']);
// Set the template for the tags page
list($Pivot_Vars['t']) = explode("/", $Pivot_Vars['t']);
if (!isset($Pivot_Vars['t']) || empty($Pivot_Vars['t'])) {
    if (isset($Weblogs[$Current_weblog]['extra_template']) && $Weblogs[$Current_weblog]['extra_template'] != "") {
        $template = $Weblogs[$Current_weblog]['extra_template'];
    } else {
        $template = $Weblogs[$Current_weblog]['archive_template'];
    }
} else {
    $template = $Pivot_Vars['t'];
}
$template_html = load_template($template);
$template_html = replace_subweblogs_templates($template_html, "[[tagpage]]\n");
if (!$template_html) {
    piv_error("Template error", "Could not load template file, <i>" . htmlspecialchars($template) . "</i>, because it doesn't exist.");
} else {
    $output = $template_html;
    $output = parse_step4($output);
}
echo $output;
flush();
function make_default()
{
    global $Weblogs, $Current_weblog, $db, $entry;
    $db = new db();
    $arc_list = "";
    if (file_exists($pivot_dir . "db/ser-archive_overview_cat.php") && file_exists($pivot_dir . "db/ser-archive_overview_cat.php")) {
        $arc_array_cat = load_serialize($pivot_dir . "db/ser-archive_overview_cat.php", TRUE);
        $arc_array_mon = load_serialize($pivot_dir . "db/ser-archive_overview_mon.php", TRUE);
        // if over three three days old.
        if (mktime() - filemtime($pivot_dir . "db/ser-archive_overview_cat.php") > 259200) {
            unlink($pivot_dir . "db/ser-archive_overview_cat.php");
            unlink($pivot_dir . "db/ser-archive_overview_mon.php");
        }
    } else {
        $list_entries = $db->getlist_range("1970-01-01-00-00", "2020-12-31-23-59", "", "", FALSE);
        // iterate through all of the entries, building the arrays for both the
        // per-month and per-category lists..
        foreach ($list_entries as $list_entry) {
            $date = format_date($list_entry['date'], $Weblogs[$Current_weblog]['fulldate_format']);
            $link = make_filelink($list_entry['code']);
            list($ye, $mo) = explode("-", $list_entry['date']);
            if (isset($list_entry['category'])) {
                foreach ($list_entry['category'] as $cat) {
                    $arc_array_cat[$cat][$ye] = 1;
                }
            }
            $arc_array_mon[$ye][$mo] = 1;
        }
        save_serialize($pivot_dir . "db/ser-archive_overview_cat.php", $arc_array_cat, FALSE);
        save_serialize($pivot_dir . "db/ser-archive_overview_mon.php", $arc_array_mon, FALSE);
    }
    $current_cats = find_cats_in_weblog($Current_weblog);
    // build the per-month list
    foreach ($arc_array_mon as $ye => $months) {
        $arc_list .= "<p><b>{$ye}:</b><br />\n";
        ksort($months);
        $temp_arr = array();
        foreach ($months as $mo => $dummy) {
            $temp_arr[] = sprintf("<a href=\"%s/%s/\">%s</a>\n", $ye, $mo, lang('months', -1 + $mo));
        }
        $arc_list .= implode(", ", $temp_arr) . "<br /></p>\n";
    }
    // build the per-category list
    ksort($arc_array_cat);
    if (count($arc_array_cat) > 1) {
        foreach ($arc_array_cat as $cat => $year) {
            if (in_array($cat, $current_cats)) {
                $arc_list .= "<p><b>{$cat}:</b>\n";
                ksort($year);
                $temp_arr = array();
                foreach ($year as $ye => $dummy) {
                    $temp_arr[] = sprintf("<a href=\"%s/%s/\">%s</a>\n", $cat, $ye, $ye);
                }
                $arc_list .= implode(", ", $temp_arr) . "</p>\n";
            }
        }
    }
    // the search template for the current weblog
    if (isset($Weblogs[$Current_weblog]['extra_template']) && $Weblogs[$Current_weblog]['extra_template'] != "") {
        $template_html = load_template($Weblogs[$Current_weblog]['extra_template']);
    } else {
        $template_html = load_template($Weblogs[$Current_weblog]['archive_template']);
    }
    $template_html = replace_subweblogs_templates($template_html, $arc_list);
    $filename = $Weblogs[$Current_weblog]['archive_path'] . make_archive_name();
    if (!$template_html) {
        ErrorOut("Could not load template file: <i>{$template}</i> [does not exist]");
    } else {
        $output = $template_html;
        $output = parse_step4($output);
    }
    echo $output;
    flush();
}
Example #4
0
/**
 * piv_error prints an error message, does a debug backtrace print out
 * and exits.
 *
 * On the admin pages it will just display the text on the current page and
 * add the page footer (if endpage is equal to 1). On weblog pages it will use
 * the extra page template for the current weblog.
 *
 * @param string $name
 * @param string $message
 * @param boolean $endpage
 */
function piv_error($name, $message, $endpage = 0)
{
    global $db, $Current_weblog, $Weblogs, $Pivot_Vars;
    if (!isset($db)) {
        $db = new db();
    }
    if (!isset($Current_weblog)) {
        reset($Weblogs);
        if (isset($Pivot_Vars['w'])) {
            $Current_weblog = weblog_from_para($Pivot_Vars['w']);
            if (!$Current_weblog) {
                $Current_weblog = key($Weblogs);
            }
        } else {
            $Current_weblog = key($Weblogs);
        }
    }
    debug_printbacktrace();
    $text = "<div class='pivot-error'>\n<h2>{$name}</h2>\n\n" . "<p>{$message}</p>\n</div>\n";
    if ($endpage == 1 || !defined('LIVEPAGE') && !defined('INWEBLOG')) {
        echo $text;
        PageFooter();
        exit;
    }
    // Use the extra template for the current weblog
    if (isset($Weblogs[$Current_weblog]['extra_template']) && $Weblogs[$Current_weblog]['extra_template'] != "") {
        $template_html = load_template($Weblogs[$Current_weblog]['extra_template']);
    } else {
        $template_html = load_template($Weblogs[$Current_weblog]['archive_template']);
    }
    // Match and replace the [[weblog]] tags for the error output
    $template_html = replace_subweblogs_templates($template_html, $text);
    if (!$template_html) {
        ErrorOut("Could not load template file: <i>{$template}</i> [does not exist]");
    } else {
        $output = $template_html;
        $output = parse_step4($output);
    }
    echo $output;
    flush();
    exit;
}