2 # makes a pages` calendar title more readable,
3 # replaces the standard _print_title with a _calendar_title
5 # Also replaces the titles in page lists by usurping a spot in the list_pages plugin
6 # and calling whatever was there before after it has transformed the list.
8 # Written by: Andy Fundinger
10 # the isCalendarId function from calendar.php is necessary starting with this
14 $ewiki_plugins["title_transform"][] = "ewiki_calendar_title_transform";
15 $ewiki_plugins["list_transform"][] = "ewiki_calendar_list_pages";
17 @define("EWIKI_NAME_SEP", "_");
18 @define("CALENDAR_NAME_SEP", EWIKI_NAME_SEP);
19 @define("CALENDAR_PAGE_TITLE_REGEX","/^(.*?)".preg_quote(CALENDAR_NAME_SEP) ."\d{8}$/");
20 @define("CALENDAR_PAGE_DATE_PARSE_REGEX", '#(.*)'. preg_quote(CALENDAR_NAME_SEP) .' ?(\d{4})(\d{2})(\d{2})#');
21 $ewiki_t["en"]['CALENDERENTRYFOR']='Calendar entry for ';
22 $ewiki_t["de"]['CALENDERENTRYFOR']='KalenderEintrag für ';
24 function ewiki_calendar_list_pages(&$lines) {
25 global $ewiki_plugins;
27 for($index=0;$index<count($lines);$index++){
29 $lines[$index]=preg_replace("#(.*>)(.*?".preg_quote(CALENDAR_NAME_SEP) ." ?\d{8})(.*)#e"," \"$1\".ewiki_calendar_page_title('$2').'$3'",$lines[$index]);
35 function ewiki_calendar_title_transform($id, &$title, &$go_action){
37 if (ewiki_isCalendarId($id)) {
38 $title=ewiki_calendar_page_title ($id);
42 #-- title string replacing
43 function ewiki_print_calendar_title(&$html, $id, $data, $action, $split=EWIKI_SPLIT_TITLE) {
46 if (ewiki_isCalendarId($id)) {
47 $html=str_replace(">$ewiki_title<", ">".ewiki_calendar_page_title($id,$split)."<", $html);
51 function ewiki_calendar_page_title ($id='', $split=EWIKI_SPLIT_TITLE) {
52 strlen($id) or ($id = $GLOBALS["ewiki_page"]);
55 if (!isset($month_names)) {
56 $month_names = explode(" ", ewiki_t("MONTHS"));
59 if(preg_match(CALENDAR_PAGE_DATE_PARSE_REGEX,$id,$dateParts) ){
61 /*Transform Parent title using plugins */
62 $parentId=$dateParts[1];
64 $parentTitle=$parentId;
65 if ($ewiki_config["split_title"] || $split) {
66 $parentTitle = ewiki_split_title($parentId);
70 if ($pf_a = $ewiki_plugins["title_transform"]) {
71 foreach ($pf_a as $pf) { $pf($parentId, $parentTitle, ''); }
74 $title=ewiki_t("CALENDERENTRYFOR").$parentTitle.": ". $month_names[$dateParts[3]-1]." ".$dateParts[4].", ".$dateParts[2];