98f0e13d7301d445d9a565523120c198b7d93cb6
[atutor.git] / mods / wiki / plugins / markup / update_format.php
1 <?php
2
3 /*
4   Converts/Fixes misused markup to correct format (meaning of ! for
5   titles, spaces required with lists markup), when activated on a
6   page (this gets an option on the edit/ page).
7   
8 * AndyFundinger(Andy@burgiss.com)
9 */
10
11  $ewiki_t["en"]["UPDHEADERFORMAT"] = "Swap Header Order";               
12  $ewiki_t["de"]["UPDHEADERFORMAT"] = "vertausche Titel-Ordnung";
13  
14  $ewiki_plugins["action"]["updformatheader"] = "ewiki_header_format_swap";
15  $ewiki_config["action_links"]["view"]["updformatheader"] = "UPDHEADERFORMAT";
16  $ewiki_plugins["edit_form_append"][] = "ewiki_edit_form_append_updFormat";
17
18  function ewiki_header_format_swap($id, &$data, $action){ 
19
20     ewiki_clean_format($data["content"]);
21     $data["content"]=preg_replace("/^!!! (.*)$/im",'!x $1',$data["content"]);
22     $data["content"]=preg_replace("/^! (.*)$/im",'!!! $1',$data["content"]);
23     $data["content"]=preg_replace("/^!x (.*)$/im",'! $1',$data["content"]);
24     
25     //echo $data["content"];
26     
27     return(ewiki_page_edit($id,$data,$action));
28  }
29  
30  function ewiki_clean_format(&$wikiText){ 
31     $wikiText=preg_replace("/^([;:#\*!-]+) *(.*)$/im",'$1 $2',$wikiText);
32  }
33
34 function ewiki_edit_form_append_updFormat($id, $data, $action) {
35     global $ewiki_ring;
36         
37     if (!ewiki_auth_perm_liveuser($id, $data, 'manage', $ewiki_ring, 0)) {    
38         return '';
39     }
40     
41     return(' &nbsp; <a href="'. ewiki_script('updformatheader', $id) . '">' . ewiki_t("UPDHEADERFORMAT") . '</a>');
42 }
43
44 ?>