function make_archive_list($ye, $mo, $da, $title) { global $Weblogs, $Current_weblog, $db, $entry, $maxlength, $filtercat; $db = new db(); $current_cats = find_cats_in_weblog($Current_weblog); if ($da > 0 && $da < 32 && $mo > 0 && $mo < 13) { // get a list of the entries for the current day list($start_date, $stop_date) = getdaterange(sprintf("%02d-%02d-%02d-00-00", $ye, $mo, $da), 'day'); } else { if ($mo > 0 && $mo < 13) { // get a list of the entries for the current month list($start_date, $stop_date) = getdaterange(sprintf("%02d-%02d-01-00-00", $ye, $mo), 'month'); } else { // get a list of the entries for the current year list($start_date, $stop_date) = getdaterange(sprintf("%02d-%02d-01-00-00", $ye, $mo), 'year'); } } $list_entries = $db->getlist_range($start_date, $stop_date, "", "", FALSE); if ($title != "") { // Normalizing requested title and title of possible entries (once). $title = str_replace("http://", "", $title); $title = str_replace("http", "", $title); $title = safe_string(strtolower($title), TRUE); foreach ($list_entries as $key => $value) { $entrytitle = $list_entries[$key]['title']; $entrytitle = str_replace("http://", "", $entrytitle); $entrytitle = str_replace("http", "", $entrytitle); $entrytitle = safe_string(strtolower($entrytitle), TRUE); $list_entries[$key]['title'] = $entrytitle; } // we try to see if we can match a given name to a title.. foreach ($list_entries as $entry) { if ($title == $entry['title']) { $_POST['id'] = $entry['code']; include 'entry.php'; die; } } // next, we see if the start is the same.. foreach ($list_entries as $entry) { if (substr($title, 0, 19) == substr($entry['title'], 0, 19)) { $_POST['id'] = $entry['code']; include 'entry.php'; die; } } // next, we see if the start is the same.. foreach ($list_entries as $entry) { if (substr($title, 0, 7) == substr($entry['title'], 0, 7)) { $_POST['id'] = $entry['code']; include 'entry.php'; die; } } } // We continue with the selected entries, and display the bunch $arc_list = ""; foreach ($list_entries as $list_entry) { // added by sam $valid_entry_cats = array_intersect($list_entry['category'], $current_cats); if ($valid_entry_cats && (!isset($filtercat) || @in_array($filtercat, $list_entry['category']))) { // if we don't filter, or we filter on the entry's category.. if ($list_entry['status'] == 'publish') { //if the entry is published $diffdate = format_date($list_entry['date'], $Weblogs[$Current_weblog]['diffdate_format']); $date = format_date($list_entry['date'], $Weblogs[$Current_weblog]['entrydate_format']); $link = make_filelink($list_entry['code'], "", ""); if ($diffdate != $lastdiffdate) { $arc_list .= "<br />" . $diffdate . "<br />\n"; $lastdiffdate = $diffdate; } $arc_list .= sprintf("%s <a href='%s' title=\"(%s, %s comments)\">%s</a><br />\n", $date, $link, implode(", ", $valid_entry_cats), $list_entry['commcount'], trimtext($list_entry['title'], $maxlength)); } } } // 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(); }
/** * Process CMS tags into HTML for archives. */ function cms_tag_archive($tag_attr, $tag_default) { global $db, $Cfg, $Paths, $current_date, $Weblogs, $Current_weblog, $diffdate_lastformat, $even_odd; $order = get_attr_value('order', $tag_attr); if ($order == "firsttolast") { $order = "asc"; } else { $order = "desc"; } $countshow = 0; $output = ""; // to force the 'diffdate' to start anew on each (sub)weblog.. $diffdate_lastformat = ""; $subweblog = get_attr_value('subweblog', $tag_attr); $template = $Paths['templates_path'] . $Weblogs[$Current_weblog]['sub_weblog'][$subweblog]['template']; if (file_exists($template) && $Weblogs[$Current_weblog]['sub_weblog'][$subweblog]['template'] != "") { $tag_default_orig = implode("", file($template)); } else { debug("cant open file: " . $template); debug(" - for weblog " . $Current_weblog . ", subweblog " . $subweblog . " - {$tag_attr}, {$tag_default} - "); $tag_default_orig = ""; //debug_printbacktrace(); } // safety check to prevent recursive weblogs.. if (preg_match("/\\[\\[weblog:(.*)(:[0-9]*)?\\]\\]/mUi", $tag_default_orig)) { $tag_default_orig = "<p>(You can't recursively use [weblogs]!)</p>"; } $show = $Weblogs[$Current_weblog]['sub_weblog'][$subweblog]['num_entries']; $cats = $Weblogs[$Current_weblog]['sub_weblog'][$subweblog]['categories']; list($start_date, $stop_date) = getdaterange($db->entry['date'], $Weblogs[$Current_weblog]['archive_unit']); debug("Archive: start {$start_date}, stop {$stop_date}, entry " . $db->entry['code']); $db->disallow_write(); if ($order == 'asc') { $list_entries = $db->getlist_range($start_date, $stop_date, "", $cats, TRUE, "publish"); } else { $list_entries = $db->getlist_range($start_date, $stop_date, "", $cats, FALSE, "publish"); } foreach ($list_entries as $list_entry) { $entry = $db->read_entry($list_entry['code']); if (!isset($entry['status']) || $entry['status'] == 'publish') { // for 'even' and 'odd' messages.. if ($even_odd == 1) { $even_odd = 0; } else { $even_odd = 1; } // include an anchor, if it's not set manually with the [[id_anchor]] tag if (strpos($tag_default_orig, "[[id_anchor]]") == 0) { $entry_html = '<span id="e' . $db->entry['code'] . '"></span>'; } else { $entry_html = ""; } $entry_html .= parse_step4($tag_default_orig); $output .= $entry_html; } } return $output; }
function snippet_archive_list() { global $Weblogs, $Current_weblog, $Archive_array, $Archive_array_html, $Paths; if ($Weblogs[$Current_weblog]['archive_unit'] == "none") { // if no archives are needed, just return. return ""; } // if not yet done, load / make the array of archive filenames (together // with at least one date) if (!isset($Archive_array)) { make_archive_array(); } // if not yet done, compile the html for this archive list if (!isset($Archive_array_html[$Current_weblog])) { $output = ""; // maybe flip and reverse it. // 2004/11/23 =*=*= JM - changes to avoid array errors if (is_array($Archive_array[$Current_weblog])) { if ($Weblogs[$Current_weblog]['archive_order'] == 'descending') { $mylist = $Archive_array[$Current_weblog]; } else { $mylist = array_reverse($Archive_array[$Current_weblog]); } foreach ($mylist as $file => $date) { // make Mark proud, and make a nice absolute url for the archive.. $filelink = $Paths['pivot_url'] . $Weblogs[$Current_weblog]['archive_path'] . $file; $filelink = fixPath($filelink); // fix the rest of the string.. list($start_date, $stop_date) = getdaterange($date, $Weblogs[$Current_weblog]['archive_unit']); $this_output = format_date_range($start_date, $stop_date, $Weblogs[$Current_weblog]['archive_linkfile']); $this_output = str_replace("%url%", $filelink, $this_output); $output .= "\n" . $this_output; } } // store it for quick access later on.. $Archive_array_html[$Current_weblog] = $output; } else { // goodie, it's alread been done, so we just retrieve it. $output = $Archive_array_html[$Current_weblog]; } return stripslashes($output); }