3 * This plugin extracts items from every page in the wiki database.
4 * You can view items by specific users by entering their initials in the textbox
5 * The filter supports the use of 'and' and 'or' expressions but not both.
10 * Start a todo item with @@ followed by a todo item type, item types are:
13 ** @@cancelled JE: cancelled
14 ** @@dEaDlInE JE: dEaDlInE
16 * Case of the class names does not matter.
17 * DO NOT use a colon ":" after the class name, this may seem logical but it will cause problems for EWikiCSS
19 Written By: Jeffrey Engleman
22 $ewiki_t["en"]["EXTODOTITLE"] = "Site Wide Todo Lists";
23 $ewiki_t["en"]["EXTODOFOR"] = "Todo items for ";
24 $ewiki_t["en"]["EXTODOFORALL"] = "All todo items.";
25 $ewiki_t["en"]["EXALLCONTROLS"] = '<div id="ewiki_todofilter"><form name="input" action="liveweb.php?" method="get"><p>Enter initials:
26 <input type="hidden" value="$controlid" name="id"><input type="text" id="q" name="q" size="2" maxlength"16"> <input type="submit"
27 value="Extract Items"><br />(Hint: For multiple users connect initials using "and" or "or")</p></form></div>';
28 $ewiki_t["en"]["EXALLERROR"] = "<p><h4>Error</h4><ul><li>Unable to complete query. Please do not combine the 'and' and 'or' operators.</li></ul></p>";
30 define("EWIKI_PAGE_EXALL", "ExAllTodo");
32 $ewiki_plugins["page"][EWIKI_PAGE_EXALL]="ewiki_page_exall";
34 function ewiki_page_exall($id=0, $data=0, $action=0){
35 global $ewiki_plugins, $ewiki_config;
37 //$timestart=getmicrotime();
38 $action=str_replace("all", "", strtolower($id));
41 $initials=ewiki_get_uservar("Initials");
42 $exinitials=ewiki_get_uservar("ExtractorInitials");
44 if(isset($_GET['q']) && $_GET['q']!=""){
45 if($_GET['q']!='ALL'){
46 $str_usr=str_replace(array("or", " ", "and"), array("|", "", "|"), $_GET['q']);
47 //$str_usr=$_GET['q']; //initials were entered
48 if(!(stristr($_GET['q'], "or")&& stristr($_GET['q'], "and"))){
49 if(stristr($_GET['q'], "and")){
52 $extractFor=$_GET['q'];
57 }elseif(strlen($initials)){
60 }elseif(strlen($exinitials)){
64 $str_usr="."; //no initials were entered
65 $o = ewiki_make_title($id, ewiki_t(strtoupper($action)."TITLE"), 2);
68 if(isset($extractFor)){
69 $o = ewiki_make_title($id, ewiki_t(strtoupper($action)."FOR").$extractFor, 2);
70 if(($extractFor != $exinitials)&&($extractFor != $initials)&&(strlen($extractFor)==2)){
71 ewiki_set_uservar("ExtractorInitials",$extractFor);
74 $o = ewiki_make_title($id, ewiki_t(strtoupper($action)."TITLE"), 2);
77 $o .= ewiki_t("EXALLCONTROLS", array("controlid"=>$id)); //prints text, textbox, and button
80 if(strlen($initials)){
81 $o.= '<a href="' . ewiki_script("", $id,array('q'=>$initials)) . '">' . ewiki_t(strtoupper($action)."FOR").$initials . "</a> ";
83 if(strlen($exinitials)&&($exinitials!=$initials)){
84 $o.= '<a href="' . ewiki_script("", $id,array('q'=>$exinitials) ). '">' . ewiki_t(strtoupper($action)."FOR").$exinitials . "</a> ";
86 $o.='<a href="' . ewiki_script("", $id,array('q'=>'ALL')) . '">' . ewiki_t(strtoupper($action)."FORALL"). "</a> ".'</p>';
89 return($o.ewiki_t("EXALLERROR"));
91 //define types of todo/policy items
92 $ext_types = $ewiki_config["extracttypes"][$action];
94 //get data from database
95 $data = ewiki_db::GETALL(array("content", "pagename", "flags"));
97 while ($content = $data->get()) {
100 if (($content["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
101 //code hijacked from action_extracttodo and modified
102 preg_match_all("/^([;:#\*\- ]*)((@@(".implode("|",$ext_types).")) ((".$str_usr.")+.*)(:.*))$/im", $content["content"], $matches);
104 if(!empty($matches[0])){
105 $extractedContent=NULL;
106 for($index=0;$index<sizeof($matches[0]);$index++){
107 //extract each todo/policy item
108 if($operator=="and"){
110 $a_users=explode("|", $str_usr);
111 foreach($a_users as $str_user){
112 if(!stristr($matches[5][$index],$str_user)){
121 if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($content["id"], $str_null, $action)) {
122 continue; //skip rest of loop and start from beginning
124 $extractedContent.="*".$matches[2][$index]."@@\n";
126 if($extractedContent!=NULL){
127 $o.=$ewiki_plugins["render"][0]("!!!".ewiki_t(strtoupper($action)."FROM")."[".$content["id"]."]");
128 $o .= "<div class='ewiki_page_todolist'>".$ewiki_plugins["render"][0] ( $extractedContent , 1,
129 EWIKI_ALLOW_HTML || (@$content["flags"]&EWIKI_DB_F_HTML) )."</div>";
135 $o.=$ewiki_plugins["render"][0](ewiki_t(strtoupper($action)."POSTSCRIPT"));
136 /*$timeend=getmicrotime();
137 $o.="time: ".($timeend-$timestart);*/