4 Description: prints out a wiki-news style summary of blog entries for the current page.
6 The Calendar plugin should be included for page creation and archival browsing.
9 Developed by AndyFundinger
10 Extended by WojciechJanKalka <w@kalka.org>
14 page=MyBlogPage // Page ID
15 num=20 // List how many Items
16 len=512 // List length till more
17 sort=0 // Sort order 1 ->pagename or 0 ->entrydate
18 sort_reverse=0 // Reverse sort
19 calendar=0 // Normal blog or calendar blog (0/1)
20 hr=0 // Horizontal Rule each item (0/1)
21 more=0 // Show more link to blog page (0/1)
24 1.1.4 - cleaned up the code, added documentation (wjk)
25 1.1.3 - +added sort on and reverse sort (wjk)
26 +added calendar blog choice (wjk) *untested*
27 +added some other boolean switches (wjk)
28 1.1.2 - changed the plugin from calendarlist to blog (wjk)
29 +added ewiki_blog_list (wjk)
30 1.1.1 - started this plugin (wjk)
34 // display a list of blog itmes
35 function ewiki_blog_list($n_num,$n_len,$b_sort,$b_sortrev,$b_hr,$b_more,$c_regex){
36 global $ewiki_plugins, $ewiki_config;
38 #-- fetch all page entries from DB, for sorting on pagename or lastmodified
40 $result = ewiki_db::GETALL(array("pagename"));
42 $result = ewiki_db::GETALL(array("lastmodified"));
47 // get an array from the database
48 while ($row = $result->get(0, 0x0137, EWIKI_DB_F_TEXT)) {
50 if ($c_regex && !preg_match($c_regex, $row["id"])) {
55 $sorted[$row["id"]] = $row["pagename"];
57 $sorted[$row["id"]] = $row["lastmodified"];
61 #-- sort normal or reversed
65 // if we sort on lastmodified reverse sort
69 $displayed = 0;//$displayed will count pages successfully displayed
73 foreach ($sorted as $id=>$uu) {
75 $row = ewiki_db::GET($id);
78 if (EWIKI_PROTECTED_MODE && !ewiki_auth($id, $row, "view", $ring=false, $force=0)) {
79 if (EWIKI_PROTECTED_MODE_HIDING) {
82 $row["content"] = ewiki_t("FORBIDDEN");
86 $text = "\n".substr($row["content"], 0, $n_len);
87 $text = str_replace("[internal://", "[ internal://", $text);
89 #-- shore more link or not
91 $text .= " [...[read more | $id]]\n";
94 #-- title mangling (from ewiki.php)
96 if ($ewiki_config["split_title"] && $may_split) {
97 $title = ewiki_split_title($title, $ewiki_config["split_title"], 0&($title!=$ewiki_title)); //Why 0&?
100 $title = htmlentities($title);
102 if ($pf_a = @$ewiki_plugins["title_transform"]) {
103 foreach ($pf_a as $pf) { $pf($id, $title, $go_action); }
106 if($ewiki_config["wm_publishing_headers"]){
107 $text = preg_replace("/^!([^!])/m","!! \$1",$text);
111 $text = preg_replace("/^!!!/m","!!",$text);
113 "!!! [\"$title\"$id]";
115 $o .=" µµ". strftime(ewiki_t("LASTCHANGED"), $row["lastmodified"])."µµ\n";
118 // add a horizontal line if wanted
129 #-- render requested wiki page <-- goal !!!
130 $render_args = array(
132 "html" => (EWIKI_ALLOW_HTML||(@$data["flags"]&EWIKI_DB_F_HTML)),
134 $o = $ewiki_plugins["render"][0] ($o, $render_args);
139 $ewiki_plugins["mpi"]["blog"] = "ewiki_mpi_blog";
141 // the mpi funcion call
142 function ewiki_mpi_blog($action="html", $args, &$iii, &$s) {
144 global $ewiki_config;
146 // read parameters or use default values
147 ($id = $args["page"]) or ($id = $GLOBALS["ewiki_id"]);
148 ($n_num = $args["line"]) or ($n_num = 20);
149 ($n_len = $args["length"]) or ($n_len = 512);
150 ($b_hr = $args["hr"]) or ($b_hr = 0);
151 ($b_sort = $args["sort"]) or ($b_sort = 0);
152 ($b_calendar = $args["calendar"]) or ($b_calendar = 0);
153 ($b_more = $args["displaymore"]) or ($b_more = 0);
154 ($b_sortrev = $args["sort_reverse"]) or ($b_sortrev = 0);
156 // if we use the plugin for the calendar, quit on no calendar pages
157 if ( (!calendar_exists(false)) && ($b_calendar) ){
162 $o='<div class="text-blog">'
163 // .'DEBUG -> '.' Line = '.$hr.' Sort = '.$sort.' Reverse = '.$b_sortrev
164 .ewiki_blog_list($n_num,$n_len,$b_sort,$b_sortrev,$b_hr,$b_more,'/^'.$id.EWIKI_NAME_SEP.'\d{8}$/')