public function getEntries() { $offset = $this->request->getInt('offset', 0); $weeks = $this->request->getInt('weeks', 2); $entries = GamingCalendar::loadEntries($offset, $weeks); $this->response->setVal('entries', $entries); $this->response->setCacheValidity(3600, 3600, array(WikiaResponse::CACHE_TARGET_BROWSER, WikiaResponse::CACHE_TARGET_VARNISH)); }
public function updateCalendarEntriesForDate() { global $wgUser; //@todo move this to init once it supports exceptions // Boilerplate special page permissions if ($this->wg->user->isBlocked()) { $this->setVal('error', wfMsg('blockedtext')); return false; // skip rendering } if (!$this->wg->user->isAllowed('specialgamingcalendar')) { $this->setVal('error', wfMsg('badaccess-group0')); return false; } if (wfReadOnly() && !wfAutomaticReadOnly()) { $this->setVal('error', wfMsg('readonlytext')); return false; } wfProfileIn(__METHOD__); $res = array(); $type = $this->getVal('type', null); $date = $this->getVal('date', null); $titles = $this->getVal('title', null); $subtitles = $this->getVal('subtitle', null); $descriptions = $this->getVal('description', null); $images = $this->getVal('image', null); $systemses = $this->getVal('systems', null); $rating = $this->getVal('rating', null); $moreInfoUrls = $this->getVal('moreinfourl', null); $preorderUrls = $this->getVal('preorderurl', null); // input validation if (empty($type)) { $res = array('success' => false, 'error' => F::app()->renderView('Error', 'Index', array(wfMsg('gamingcalendar-error-missing-type')))); $this->setVal('res', $res); return; } // create message content $content = ''; foreach ($titles as $i => $title) { if (empty($title)) { continue; } if (!empty($subtitles[$i])) { $title = trim($title) . '|' . trim($subtitles[$i]); } $content .= GamingCalendar::$ENTRY_TITLE_MARKER . ' ' . $title . "\n"; if (!empty($descriptions[$i])) { $content .= GamingCalendar::$ENTRY_ATTRIBUTE_MARKER . ' ' . GamingCalendar::$ENTRY_DESCRIPTION_MARKER . ' ' . $descriptions[$i] . "\n"; } if (!empty($images[$i])) { $content .= GamingCalendar::$ENTRY_ATTRIBUTE_MARKER . ' ' . GamingCalendar::$ENTRY_IMAGE_MARKER . ' ' . $images[$i] . "\n"; } if (!empty($systemses[$i])) { $systems = explode(',', $systemses[$i]); foreach ($systems as &$system) { $system = trim($system); } $content .= GamingCalendar::$ENTRY_ATTRIBUTE_MARKER . ' ' . GamingCalendar::$ENTRY_SYSTEMS_MARKER . ' ' . implode(',', $systems) . "\n"; } if (!empty($rating[$i])) { $content .= GamingCalendar::$ENTRY_ATTRIBUTE_MARKER . ' ' . GamingCalendar::$ENTRY_RATING_MARKER . ' ' . $rating[$i] . "\n"; } if (!empty($moreInfoUrls[$i])) { $content .= GamingCalendar::$ENTRY_ATTRIBUTE_MARKER . ' ' . GamingCalendar::$ENTRY_MOREINFO_MARKER . ' ' . $moreInfoUrls[$i] . "\n"; } if (!empty($preorderUrls[$i])) { $content .= GamingCalendar::$ENTRY_ATTRIBUTE_MARKER . ' ' . GamingCalendar::$ENTRY_PREORDER_MARKER . ' ' . $preorderUrls[$i] . "\n"; } } // save message $msgTitle = Title::newFromText(GamingCalendar::getEntryKey($type, $date), NS_MEDIAWIKI); $article = new Article($msgTitle); if ($msgTitle->getArticleID()) { $editMsg = 'Message edited'; $editMode = EDIT_UPDATE; } else { $editMsg = 'Message created'; $editMode = EDIT_NEW; } $status = $article->doEdit($content, $editMsg, $editMode, false, $wgUser); $title_object = $article->getTitle(); // @todo check status object $res = array('success' => true, 'url' => '/wiki/Special:GamingCalendar?type=' . $type . '&year=' . date('Y', $date) . '&month=' . date('n', $date)); $this->setVal('res', $res); wfProfileOut(__METHOD__); }