/** * Process CMS tags into HTML for weblogs. */ function cms_tag_weblog($tag_attr, $tag_default) { global $db, $Cfg, $Paths, $current_date, $Weblogs, $Current_weblog, $Current_subweblog, $diffdate_lastformat, $even_odd, $Pivot_Vars; // some people use [[subweblog]] inside an entry page. to allow this // we need to 'store' the entry, make the subweblog, and 'restore' // the entry.. if (isset($db->entry)) { $temp_entry = $db->entry; } $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); $Current_subweblog = $subweblog; $template = $Paths['templates_path'] . $Weblogs[$Current_weblog]['sub_weblog'][$subweblog]['template']; if (file_exists($template)) { $tag_default_orig = implode("", file($template)); } else { piv_error("File does not exist!", "Could not load template file '" . $template . "'. Make sure it exists, and has the right permissions", 0); } // 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 = get_attr_value('showme', $tag_attr); if ($show == "") { $show = $Weblogs[$Current_weblog]['sub_weblog'][$subweblog]['num_entries']; } $cats = $Weblogs[$Current_weblog]['sub_weblog'][$subweblog]['categories']; $offset = $Weblogs[$Current_weblog]['sub_weblog'][$subweblog]['offset']; // If called from a 'dynamic archive page', the offset needs to be taken into account. if ($Pivot_Vars['o'] > 0) { $offset += $Pivot_Vars['o']; } $db->disallow_write(); // Select published entries according to order, default is descending if ($order == 'asc') { $list_entries = $db->getlist($show, $offset, "", $cats, TRUE, "", "publish"); } else { $list_entries = $db->getlist_end(-$show - $offset, "", $cats, TRUE, "publish"); } if (count($list_entries) > 0) { foreach ($list_entries as $list_entry) { // If descending order we need to handle the offset: // if offset > 0, we need to skip this entry if ($order == "desc" && $offset > 0) { $offset--; continue; } $entry = $db->read_entry($list_entry['code'], TRUE); 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 . "\n"; if ($Weblogs[$Current_weblog]['rss'] == 1) { add_rss($entry['code'], $entry['date'], $entry['title'], $entry['introduction'], $entry['body'], $entry['user'], $entry['category']); } } } } // perhaps restore the entry if (isset($temp_entry)) { $db->set_entry($temp_entry); } return $output; }
function html_head($title = 'No title', $css = array(), $js = array(), $rss = array()) { global $appname, $index_image; echo '<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>' . $appname . ' : ' . $title . '</title> <link type="image/jpg" rel="icon" href="' . theme_image($index_image) . '">' . "\n"; $css[] = 'debug.css'; add_css($css); $js[] = 'debug.js'; add_js($js); add_rss($rss); echo ' </head>' . "\n"; }