function createmwCalendar($input) { /** * check if date in $_GET-parameter * fallback on default this month */ if (isset($_GET['month']) && isset($_GET['year'])) { $month = intval($_GET['month']); $month = $month < 10 ? "0" . $month : $month; $year = $_GET['year']; } else { $month = date("m"); $year = date("Y"); } $mwCalendar = new mwCalendar(); $mwCalendar->dateNow($month, $year); preg_match('/category=([^|]*)/', $input, $matches); if (isset($matches[1])) { $mwCalendar->SetCatName($matches[1]); } if (strpos($input, 'ajaxprevnext=on') !== false) { $mwCalendar->AjaxPrevNext(true); } else { $mwCalendar->AjaxPrevNext(false); } if (strpos($input, 'upcoming=off') === false) { $mwCalendar->ShowUpcoming(true); } else { $mwCalendar->ShowUpcoming(false); } if (strpos($input, 'calendar=off') === false) { $mwCalendar->ShowCalendar(true); } else { $mwCalendar->ShowCalendar(false); } return $mwCalendar->showThisMonth(); }
function execute($par) { global $wgOut, $wgRequest, $wgParser, $wgTitle, $wgUser; $year = isset($_GET['year']) ? $_REQUEST['year'] : null; $month = isset($_GET['month']) ? $_REQUEST['month'] : null; $day = isset($_GET['day']) ? $_REQUEST['day'] : null; if ($year == "") { $year = date("Y"); } if ($month == "") { $month = date("m"); } if (isset($_GET['category'])) { $catname = $_GET['category']; } else { $catname = 'Events'; } if (isset($_GET['ajax'])) { require_once 'Calendar.php'; $mwCalendar = new mwCalendar(); $mwCalendar->dateNow($month, $year); $mwCalendar->SetCatName($catname); $mwCalendar->AjaxPrevNext(true); if (isset($_GET['upcoming']) && $_GET['upcoming'] == 'off') { $mwCalendar->ShowUpcoming(false); } else { $mwCalendar->ShowUpcoming(true); } $mwCalendar->ShowCalendar(true); echo $mwCalendar->showThisMonth(); exit; } # Don't show the navigation if we're including the page if (!$this->mIncluding) { $this->setHeaders(); $wgOut->addWikiText(wfMsg('events-header')); } if ($day == "") { $wgOut->AddWikiText('<calendar>upcoming=off|ajaxprevnext=off|category=' . $catname . '</calendar>'); $day = "__"; } //build the SQL query $dbr =& wfGetDB(DB_SLAVE); $sPageTable = $dbr->tableName('page'); $categorylinks = $dbr->tableName('categorylinks'); $sSqlSelect = "SELECT page_namespace, page_title, page_id, clike1.cl_to AS catlike1 "; $sSqlSelectFrom = "FROM {$sPageTable} INNER JOIN {$categorylinks} AS c1 ON page_id = c1.cl_from AND c1.cl_to='{$catname}' INNER JOIN {$categorylinks} " . "AS clike1 ON page_id = clike1.cl_from AND clike1.cl_to LIKE '{$year}/{$month}/{$day}'"; $sSqlWhere = ' WHERE page_is_redirect = 0 '; $sSqlOrderby = ' ORDER BY catlike1 ASC'; //DEBUG: output SQL query //$wgOut->addHTML('[' . $sSqlSelect . $sSqlSelectFrom . $sSqlWhere . $sSqlOrderby . ']'); $res = $dbr->query($sSqlSelect . $sSqlSelectFrom . $sSqlWhere . $sSqlOrderby); $sk =& $wgUser->getSkin(); while ($row = $dbr->fetchObject($res)) { $title = Title::makeTitle($row->page_namespace, $row->page_title); $wgOut->addHTML('<div class="eventsblock">'); $title_text = $title->getSubpageText(); $wgOut->addHTML('<b>' . $sk->makeKnownLinkObj($title, $title_text) . '</b><br>'); $wl_article = new Article($title); $wl = $wl_article->getContent(); $parserOptions = ParserOptions::newFromUser($wgUser); $parserOptions->setEditSection(false); $parserOptions->setTidy(true); $parserOutput = $wgParser->parse($wl, $title, $parserOptions); $previewHTML = $parserOutput->getText(); $wgOut->addHTML($previewHTML); $wgOut->addHTML('</div>'); } }