Example #1
0
/**
 * Inserts a linked list to the archives.
 *
 * @param array $params
 * @param object $smarty
 * @return string
 */
function smarty_archive_list($params, &$smarty)
{
    global $Archive_array, $PIVOTX;
    $params = cleanParams($params);
    $Current_weblog = getDefault($params['weblog'], $PIVOTX['weblogs']->getCurrent());
    $format = getDefault($params['format'], "<a href=\"%url%\">%st_day% %st_monname% - %en_day% %en_monname% %st_year% </a><br />");
    $unit = getDefault($params['unit'], "month");
    $separator = getDefault($params['separator'], "");
    // if not yet done, load / make the array of archive filenames (together
    // with at least one date)
    if (!isset($Archive_array)) {
        makeArchiveArray(false, $unit);
    }
    // If we use 'isactive', set up the $active_arc and $isactive vars.
    if (!empty($params['isactive'])) {
        $active_arc = $pagetype = $PIVOTX['parser']->modifier['archive'];
        $isactive = $params['isactive'];
    } else {
        $isactive = "";
    }
    $output = array();
    if (is_array($Archive_array[$Current_weblog])) {
        // maybe flip and reverse it.
        if ($params['order'] == 'descending' || $params['order'] == 'desc') {
            $mylist = $Archive_array[$Current_weblog];
        } else {
            $mylist = array_reverse($Archive_array[$Current_weblog]);
        }
        // Iterate over the list, formatting output as we go.
        $counter = 0;
        foreach ($mylist as $date) {
            $counter++;
            $filelink = makeArchiveLink($date, $unit, $params['weblog']);
            // Check if the current archive is the 'active' one.
            if (!empty($isactive) && makeArchiveName($date, '', $unit) == $active_arc) {
                $thisactive = $isactive;
            } else {
                $thisactive = "";
            }
            // fix the rest of the string..
            list($start_date, $stop_date) = getDateRange($date, $unit);
            $this_output = formatDateRange($start_date, $stop_date, $format);
            $this_output = str_replace("%counter%", $counter, $this_output);
            $this_output = str_replace("%url%", $filelink, $this_output);
            $this_output = str_replace("%active%", $thisactive, $this_output);
            $output[] = "\n" . $this_output;
        }
    }
    return implode($separator, $output);
}
Example #2
0
/**
 * Display 'buildindex' page.
 */
function pageBuildindex()
{
    global $PIVOTX;
    // check if the user has the required userlevel to view this page.
    $PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
    $PIVOTX['template']->assign('title', __('Rebuild the Index'));
    $PIVOTX['template']->assign('heading', __('Rebuild the index of your Database'));
    @set_time_limit(0);
    // Force the archive index and tag index file to be updated
    @unlink($PIVOTX['paths']['db_path'] . 'ser-archives.php');
    // Force the tag index to be updated
    @unlink($PIVOTX['paths']['db_path'] . 'ser_tags.php');
    $dir = dir($PIVOTX['paths']['db_path'] . 'tagdata/');
    while (false !== ($entry = $dir->read())) {
        if (getExtension($entry) == "cache") {
            unlink($PIVOTX['paths']['db_path'] . 'tagdata/' . $entry);
        }
    }
    $dir->close();
    // Make a new archive array.
    makeArchiveArray();
    $output = "<p>" . __('Now building Index. This may take a short while, so please do not interrupt.') . "<br />\n";
    $output .= "<div id='output'></div>";
    // Much of the hard work is done by the ajaxy function rebuildIndex() in ajaxhelper.php
    $output .= "<script type='text/javascript'>\n        jQuery(function(\$) {\n            ajaxRebuildCall('rebuildIndex',0,0);\n        });\n        </script>\n        ";
    $PIVOTX['template']->assign('html', $output);
    renderTemplate('generic.tpl');
}