*/ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); require_once(DOKU_PLUGIN."noticeboard/classes/Notice.php"); require_once(DOKU_PLUGIN."noticeboard/classes/NoticeList.php"); require_once(DOKU_PLUGIN."noticeboard/classes/ArrayList.php"); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_noticeboard extends DokuWiki_Syntax_Plugin { private $noticeList; /** * return some info */ function getInfo() { return array( 'author' => 'Gina Häußge, Michael Klier, Esther Brunner', 'email' => 'dokuwiki@chimeric.de', 'date' => @file_get_contents(DOKU_PLUGIN.'discussion/VERSION'), 'name' => 'Discussion Plugin (comments component)', 'desc' => 'Enables discussion features', 'url' => 'http://wiki.splitbrain.org/plugin:discussion', ); } function getType() { return 'substition'; } function getPType() { return 'block'; } function getSort() { return 230; } /** * Connect pattern to lexer */ function connectTo($mode) { if ($mode == 'base') { $this->Lexer->addSpecialPattern('~~NOTICEBOARD~~', $mode, 'plugin_noticeboard'); } } /** * Handle the match */ function handle($match, $state, $pos, &$handler) { } function render($mode, &$renderer, $status) { Global $ID; Global $INFO; $renderer->info['cache'] = false; $renderer->doc .= "
"; $renderer->doc .= "
"; $renderer->doc .= $this->_showModeListButton(); $renderer->doc .= $this->_showModeCalendarButton(); $renderer->doc .= $this->_showRSSButton(); $renderer->doc .= $this->_showIcalButton(); if($INFO['perm'] >= 2){ $renderer->doc .= ' 'edit','noticeboard_newnotice'=> 'true')) . '" class="button2" title="">'.$this->getLang('addEvent').''; } $renderer->doc .= "
"; $renderer->doc .= $this->_showFilter(); if($_SESSION['noticeboard_mode']== 'list'){ //mode list $renderer->doc .= $this->_showList(); }else{ $renderer->doc .= $this->_showCalendar(); } $renderer->doc .= "
"; return true; // do nothing -> everything is handled in action component } private function _showModeListButton(){ Global $ID; $script = script(); $out; $out .= "
"; return $out; } private function _showModeCalendarButton(){ Global $ID; $script = script(); $out; $out .= "
"; return $out; } private function _showRSSButton(){ Global $ID; $script = script(); $out; $out .= "
"; return $out; } private function _showIcalButton(){ Global $ID; $script = script(); $out; $out .= "
"; return $out; } private function _showFilter(){ Global $ID; Global $INFO; $script = script(); $out; $category = $_SESSION['noticeboard_list_category']; $timeFilter = $_SESSION['noticeboard_show_time']; $sortFilter = $_SESSION['noticeboard_sort']; $sortOrder = $_SESSION['noticeboard_sort_order']; $out .="

".$this->getLang('category').":"; $out .= " 7 || !$category){ $category -=8; $out .="checked"; } $out .= "/> "; $out .= " 3){ $category -=4; $out .="checked"; } $out .= "/> "; $out .= " 1){ $category -=2; $out .="checked"; } $out .= "/> "; $out .= " getLang('time').":"; $out .= " getLang('past')." getLang('all')." getLang('filter')."' />

".$this->getLang('sort').": "; $out .= " "; $out .= " "; $out .="

"; $out .="
"; return $out; } private function _showList(){ Global $ID; Global $INFO; $script = script(); $out; $category = $_SESSION['noticeboard_list_category']; $timeFilter = $_SESSION['noticeboard_show_time']; $sortFilter = $_SESSION['noticeboard_sort']; $sortOrder = $_SESSION['noticeboard_sort_order']; $noticeList = new helper_plugin_noticeboard_NoticeList($ID); //set list position $start = ($_SESSION['noticeboard_list_start'])?$_SESSION['noticeboard_list_start']:'0'; //set category filter if($_SESSION['noticeboard_list_category']){ $noticeList->setCategoryFilter($_SESSION['noticeboard_list_category']); }else{ $noticeList->setCategoryFilter(8); } //set time filter if($_SESSION['noticeboard_show_time']){ $noticeList->setTimeFilter($_SESSION['noticeboard_show_time']); }else{ $noticeList->setTimeFilter(1); } //set sort filter if($_SESSION['noticeboard_sort']){ $noticeList->setSortFilter($_SESSION['noticeboard_sort']); }else{ $noticeList->setSortFilter(1); } //set sort order if($_SESSION['noticeboard_sort_order']){ $noticeList->setSortOrder($_SESSION['noticeboard_sort_order']); }else{ $noticeList->setSortOrder(0); } //get notice list + print $noticeList; $arrayList = $noticeList->getNoticeList($start,$start + $this->getConf('listSize')); while(($arrayList && $arrayList->hasNext()) ){ $notice = $arrayList->next(); $out .= ""; if($notice->getEndTime()){ $out .= ""; } if($notice->getDeadline()){ $out .= ""; } if($notice->getPlace()){ $out .= ""; } $out .= "
"; $out .= ''.$notice->getName().''; if($INFO['perm'] >= 2){ $out .= "
"; // $out .= ''.$this->getLang('delete').''; $out .= ''.$this->getLang('edit').''; } $out .= "
"; $out .= $this->getLang($notice->getCategory()); $out .= "
"; $out .= "".$this->getLang('startTime').": "; if($notice->hasStartTime()){ $out .= date("d.m.Y H:i",$notice->getStartTime()); }else{ $out .= date("d.m.Y",$notice->getStartTime()); } $out .= "
".$this->getLang('endTime').":"; if($notice->hasEndTime()){ $out .= date("d.m.Y H:i",$notice->getEndTime()); }else{ $out .= date("d.m.Y",$notice->getEndTime()); } $out .= "
".$this->getLang('deadline').":"; $out .= date("d.m.Y",$notice->getDeadline()); $out .= "
".$this->getLang('place').":"; $out .= $notice->getPlace(); $out .= "
"; //$out .= "Jméno: ".$notice->getName(); } //show previous button if($noticeList->hasPrevious){ $out .= "
"; } //show next button if($noticeList->hasNext){ $out .= "
"; } return $out; } public function _showCalendar(){ global $ID; $script = script(); $calendar_ns = ($data[0]) ? $data[0] : $ID; $langDays = $this->getLang('days'); $langMonth = $this->getLang('month'); $curDate = getdate(time()); $showMonth = (is_numeric($_SESSION['noticeboard_month'])) ? $_SESSION['noticeboard_month'] : $curDate['mon']; $showYear = (is_numeric($_SESSION['noticeboard_year'])) ? $_SESSION['noticeboard_year'] : $curDate['year']; $gTimestamp = mktime(0,0,0,$showMonth,1,$showYear); $numDays = date('t',$gTimestamp); $viewDate = getdate($gTimestamp); $today = ($viewDate['mon'] == $curDate['mon'] && $viewDate['year'] == $curDate['year']) ? $curDate['mday'] : null; $monthStart = ($viewDate['wday'] == 0) ? 7 : $viewDate['wday']; $monthStart = ($monthStart -1) %7; $prevMonth = ($showMonth-1 > 0) ? ($showMonth-1) : 12; $nextMonth = ($showMonth+1 < 13) ? ($showMonth+1) : 1; $out; switch(true) { case($prevMonth == 12): $prevYear = ($showYear-1); $nextYear = $showYear; break; case($nextMonth == 1): $nextYear = ($showYear+1); $prevYear = $showYear; break; default: $prevYear = $showYear; $nextYear = $showYear; break; } $out .= "
".$langMonth[$viewDate['mon']]." ".$showYear."
"; // week days $out .= ""; foreach($langDays as $day) { $out .= ""; } $out .= "\n"; // create calendar-body for($i=1;$i<=$numDays;$i++) { $day = $i; // close row at end of week if($wd == 7) $out .= ""; // set weekday if(!isset($wd) or $wd == 7) { $wd = 0; } // start new row when new week starts if($wd == 0) $out .= ""; // create blank fields up to the first day of the month if(!$firstWeek) { while($wd < $monthStart) { $out .= ""; $wd++; } // ok - first week is printet $firstWeek = true; } $time = mktime(0,0,0,$viewDate['mon'],$day,$showYear); // check for today if($today == $day) { $out .= ""; } else { $out .= ""; } // fill remaining days with blanks if($i == $numDays && $wd < 7) { while($wd<6) { $out .= ''; $wd++; } $out .= ''; } //weekdays $wd++; } $out .="
".$day."
 ".$day.""; $out .= $this->_getDayEvent($time); $out .= "".$day.""; $out .= $this->_getDayEvent($time); $out .= " 
"; $out .= '
'; $out .= ' '; $out .= ' '; $out .= ' '; $out .= ' '; $out .= ''; $out .= ' ' . DOKU_LF; $out .= '
'; return $out; } private function _getDayEvent($time){ Global $ID; $noticeList = new helper_plugin_noticeboard_NoticeList($ID); //set category filter if($_SESSION['noticeboard_list_category']){ $noticeList->setCategoryFilter($_SESSION['noticeboard_list_category']); }else{ $noticeList->setCategoryFilter(8); } //set time filter if($_SESSION['noticeboard_show_time']){ $noticeList->setTimeFilter($_SESSION['noticeboard_show_time']); }else{ $noticeList->setTimeFilter(1); } //set sort filter if($_SESSION['noticeboard_sort']){ $noticeList->setSortFilter($_SESSION['noticeboard_sort']); }else{ $noticeList->setSortFilter(1); } //set sort order if($_SESSION['noticeboard_sort_order']){ $noticeList->setSortOrder($_SESSION['noticeboard_sort_order']); }else{ $noticeList->setSortOrder(0); } $out .=""; return $out; } } // vim:ts=4:sw=4:et:enc=utf-8: