public function store_action($version) { $body = Request::get('body'); if (Request::isXhr()) { $body = studip_utf8decode($body); } submitWikiPage($this->keyword, $version, $body, $GLOBALS['user']->id, $this->range_id); $latest_version = getLatestVersion($this->keyword, $this->range_id); if (Request::isXhr()) { $this->render_json(array('version' => $latest_version['version'], 'body' => $latest_version['body'], 'messages' => implode(PageLayout::getMessages()) ?: false, 'zusatz' => getZusatz($latest_version))); } else { // Yeah, wait for the whole trailification of the wiki... } }
/** * Wikiseite ändern/hinzufügen * * @put /course/:course_id/wiki/:keyword */ public function putCourseWikiKeyword($course_id, $keyword) { if (!isset($this->data['content'])) { $this->error(400, 'No content provided'); } $last_version = \WikiPage::findLatestPage($course_id, $keyword); if (!$last_version) { $last_version = new \WikiPage(array($course_id, $keyword, 0)); } if (!$last_version->isCreatableBy($user_id = $GLOBALS['user']->id)) { $this->error(401); } // TODO: rewrite this code and put #submitWikiPage into // class \WikiPage if (!isset($GLOBALS['SessSemName'])) { $GLOBALS['SessSemName'] = array(1 => $course_id); } submitWikiPage($keyword, $last_version->version, $this->data['content'], $user_id, $course_id); $new_version = \WikiPage::findLatestPage($course_id, $keyword); $url = sprintf('course/%s/wiki/%s/%d', htmlReady($course_id), htmlReady($keyword), $new_version->version); $this->redirect($url, 201, 'ok'); }
wikiEdit($keyword, NULL, $user->id, Request::quoted('lastpage')); } else { // Default action: Display WikiPage (+ logic for submission) // if (empty($keyword)) { $keyword = 'WikiWikiWeb'; // display Start page as default } releaseLocks($keyword); // kill old locks $special = ""; if (Request::submitted('submit')) { // // Page was edited and submitted // submitWikiPage($keyword, $version, Studip\Markup::purifyHtml(Request::get('body')), $user->id, $SessSemName[1]); $version = ""; // $version="" means: get latest } else { if ($cmd == "abortedit") { // Editieren abgebrochen // // Editing page was aborted // releasePageLocks($keyword, $user->id); // kill lock (set when starting to edit) if (Request::quoted('lastpage')) { // if editing new page was aborted, display last page again $keyword = Request::quoted('lastpage'); } } else {