4 Thread plugin for ewiki
6 Add this plugin after aview_posts to enable threads. Threads are sub pages
7 which are named as $id.EWIKI_THREAD_SEPARATOR.{thread name}. Threads may or
8 may not be edited but should definately have posts added to them. This
9 plugin is incomplete. It still lacks a title_transform for threads and
12 by AndyFundinger (http://erfurtwiki.sourceforge.net/?id=AndyFundinger)
15 $ewiki_plugins["view_append"][]="ewiki_view_append_threads";
16 $ewiki_plugins["action"]["addthread"] = "ewiki_add_thread";
18 $ewiki_t["en"]["THREADS"]= "Threads";
19 $ewiki_t["en"]["NEWTHREAD"]= "Create new thread";
20 define ('EWIKI_THREAD_SEPARATOR','_THREAD_');
22 function isThread($id){
23 return((strpos($id,EWIKI_THREAD_SEPARATOR)!==FALSE)&&!isPost($id));
26 function ewiki_view_append_threads($id, $data, $action) {
27 if(isThread($id)) return("");
29 $result = ewiki_db::SEARCH("id", $id.EWIKI_THREAD_SEPARATOR);
30 while ($row = $result->get()) {
31 if(!isPost($row["id"])){
32 $pages[$row["id"]] = "";
37 $o = "<div class='wiki_threads'><small>".ewiki_t('THREADS').":</small><br />";
38 $o .= ewiki_list_pages($pages)."</div>\n";
41 $o .="<form action='".ewiki_script('addthread', $id)."' method='POST'>".
42 ewiki_t("NEWTHREAD").": <input type='text' name='threadname'>".
43 "<input type='submit' value='Add Thread'>".
46 return("<div class='wiki aview threads'>".$o.'</div>');
50 //Adding a thread is just creating a specially named page.
51 //We create a blank page and then edit a post off of it
52 function ewiki_add_thread($id, $data, $action){
53 global $ewiki_plugins;
55 $id=$id.EWIKI_THREAD_SEPARATOR.$_REQUEST['threadname'];
62 "author" => ewiki_author(),
63 "lastmodified" => time(),
65 "meta" => array('isThread'=>'1'),
70 if (!ewiki_db::WRITE($save)) {
71 return(ewiki_t("ERRORSAVING"));
74 return(ewiki_add_post($id, array(), 'addpost'));