Beispiel #1
0
 /**
  * Save a wiki page
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Check if they are logged in
     if (User::isGuest()) {
         $url = Request::getVar('REQUEST_URI', '', 'server');
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url)));
         return;
     }
     // Incoming revision
     $rev = Request::getVar('revision', array(), 'post', 'none', 2);
     //$rev['pageid'] = (isset($rev['pageid'])) ? intval($rev['pageid']) : 0;
     $this->revision = $this->page->revision('current');
     $this->revision->set('version', $this->revision->get('version') + 1);
     if (!$this->revision->bind($rev)) {
         $this->setError($this->revision->getError());
         $this->editTask();
         return;
     }
     $this->revision->set('id', 0);
     // Incoming page
     $page = Request::getVar('page', array(), 'post', 'none', 2);
     $this->page = new Article(intval($rev['pageid']));
     if (!$this->page->bind($page)) {
         $this->setError($this->page->getError());
         $this->editTask();
         return;
     }
     $this->page->set('pagename', trim(Request::getVar('pagename', '', 'post')));
     $this->page->set('scope', trim(Request::getVar('scope', '', 'post')));
     // Get parameters
     $params = new \Hubzero\Config\Registry($this->page->get('params', ''));
     $params->merge(Request::getVar('params', array(), 'post'));
     $this->page->set('params', $params->toString());
     // Get the previous version to compare against
     if (!$rev['pageid']) {
         // New page - save it to the database
         $this->page->set('created_by', User::get('id'));
         $old = new Revision(0);
     } else {
         // Get the revision before changes
         $old = $this->page->revision('current');
     }
     // Was the preview button pushed?
     $this->preview = trim(Request::getVar('preview', ''));
     if ($this->preview) {
         // Set the component task
         if (!$rev['pageid']) {
             Request::setVar('task', 'new');
             $this->_task = 'new';
         } else {
             Request::setVar('task', 'edit');
             $this->_task = 'edit';
         }
         // Push on through to the edit form
         $this->editTask();
         return;
     }
     // Check content
     // First, make sure the pagetext isn't empty
     if ($this->revision->get('pagetext') == '') {
         $this->setError(Lang::txt('COM_WIKI_ERROR_MISSING_PAGETEXT'));
         $this->editTask();
         return;
     }
     // Store new content
     if (!$this->page->store(true)) {
         $this->setError($this->page->getError());
         $this->editTask();
         return;
     }
     // Get allowed authors
     if (!$this->page->updateAuthors(Request::getVar('authors', '', 'post'))) {
         $this->setError($this->page->getError());
         $this->editTask();
         return;
     }
     // Get the upload path
     $wpa = new Tables\Attachment($this->database);
     $path = $wpa->filespace();
     // Rename the temporary upload directory if it exist
     $lid = Request::getInt('lid', 0, 'post');
     if ($lid != $this->page->get('id')) {
         if (is_dir($path . DS . $lid)) {
             if (!\Filesystem::move($path . DS . $lid, $path . DS . $this->page->get('id'))) {
                 $this->setError(\Filesystem::move($path . DS . $lid, $path . DS . $this->page->get('id')));
             }
             $wpa->setPageID($lid, $this->page->get('id'));
         }
     }
     $this->revision->set('pageid', $this->page->get('id'));
     $this->revision->set('pagename', $this->page->get('pagename'));
     $this->revision->set('scope', $this->page->get('scope'));
     $this->revision->set('group_cn', $this->page->get('group_cn'));
     $this->revision->set('version', $this->revision->get('version') + 1);
     if ($this->page->param('mode', 'wiki') == 'knol') {
         // Set revisions to NOT approved
         $this->revision->set('approved', 0);
         // If an author or the original page creator, set to approved
         if ($this->page->get('created_by') == User::get('id') || $this->page->isAuthor(User::get('id'))) {
             $this->revision->set('approved', 1);
         }
     } else {
         // Wiki mode, approve revision
         $this->revision->set('approved', 1);
     }
     // Compare against previous revision
     // We don't want to create a whole new revision if just the tags were changed
     if (rtrim($old->get('pagetext')) != rtrim($this->revision->get('pagetext'))) {
         // Transform the wikitext to HTML
         $this->revision->set('pagehtml', '');
         $this->revision->set('pagehtml', $this->revision->content('parsed'));
         // Parse attachments
         /*$a = new Tables\Attachment($this->database);
         			$a->pageid = $this->page->id;
         			$a->path = $path;
         
         			$this->revision->pagehtml = $a->parse($this->revision->pagehtml);*/
         if ($this->page->access('manage') || $this->page->access('edit')) {
             $this->revision->set('approved', 1);
         }
         // Store content
         if (!$this->revision->store(true)) {
             $this->setError(Lang::txt('COM_WIKI_ERROR_SAVING_REVISION'));
             $this->editTask();
             return;
         }
         $this->page->set('version_id', $this->revision->get('id'));
         $this->page->set('modified', $this->revision->get('created'));
     } else {
         $this->page->set('modified', Date::toSql());
     }
     if (!$this->page->store(true)) {
         // This really shouldn't happen.
         $this->setError(Lang::txt('COM_WIKI_ERROR_SAVING_PAGE'));
         $this->editTask();
         return;
     }
     // Process tags
     $this->page->tag(Request::getVar('tags', ''));
     // Redirect
     App::redirect(Route::url($this->page->link()));
 }
Beispiel #2
0
 /**
  * Save changes to an entry
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     // Incoming
     $fields = Request::getVar('page', array(), 'post');
     $fields = array_map('trim', $fields);
     $authors = $fields['authors'];
     $tags = $fields['tags'];
     unset($fields['authors']);
     unset($fields['tags']);
     // Initiate extended database class
     $page = Page::oneOrNew($fields['id'])->set($fields);
     // Get parameters
     $params = Request::getVar('params', array(), 'post');
     if (is_array($params)) {
         $pparams = new \Hubzero\Config\Registry($page->get('params'));
         $pparams->merge($params);
         $page->set('params', $pparams->toString());
     }
     // Store new content
     if (!$page->save()) {
         Notify::error($page->getError());
         return $this->editTask($page);
     }
     if (!Author::setForPage($authors, $page->get('id'))) {
         Notify::error($page->getError());
         return $this->editTask($page);
     }
     $page->tag($tags);
     Notify::success(Lang::txt('COM_WIKI_PAGE_SAVED'));
     if ($this->getTask() == 'apply') {
         Request::setVar('id', $page->get('id'));
         return $this->editTask($page);
     }
     // Redirect to main listing
     $this->cancelTask();
 }
Beispiel #3
0
 /**
  * Update a page
  *
  * @apiParameter {
  * 		"name":        "id",
  * 		"description": "Entry identifier",
  * 		"type":        "integer",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "title",
  * 		"description": "Entry title",
  * 		"type":        "string",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "pagename",
  * 		"description": "Page name",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "pagetext",
  * 		"description": "Page content",
  * 		"type":        "string",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "created",
  * 		"description": "Created timestamp (YYYY-MM-DD HH:mm:ss)",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     "now"
  * }
  * @apiParameter {
  * 		"name":        "created_by",
  * 		"description": "User ID of entry creator",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":     0
  * }
  * @apiParameter {
  * 		"name":        "state",
  * 		"description": "Published state (0 = unpublished, 1 = published)",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":     0
  * }
  * @apiParameter {
  * 		"name":        "access",
  * 		"description": "Access level (0 = public, 1 = registered users, 4 = private)",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":     0
  * }
  * @apiParameter {
  * 		"name":        "scope",
  * 		"description": "Page scope",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "group_cn",
  * 		"description": "Group name the wiki page belongs to",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     ""
  * }
  * @apiParameter {
  * 		"name":        "params",
  * 		"description": "Page options",
  * 		"type":        "array",
  * 		"required":    false,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "summary",
  * 		"description": "Summary of changes made",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     null
  * }
  * @return  void
  */
 public function updateTask()
 {
     $this->requiresAuthentication();
     $fields = array('title' => Request::getVar('title', null, '', 'none', 2), 'pagename' => Request::getVar('pagename', null), 'scope' => Request::getVar('scope', null), 'created' => Request::getVar('created', null), 'created_by' => Request::getInt('created_by', null), 'state' => Request::getInt('state', null), 'access' => Request::getInt('access', null), 'group_cn' => Request::getVar('group_cn', null));
     if (!$id) {
         throw new Exception(Lang::txt('COM_TAGS_ERROR_MISSING_DATA'), 422);
     }
     $page = new Page($id);
     if (!$page->exists()) {
         throw new Exception(Lang::txt('Specified page not found.'), 404);
     }
     $revision = $page->revision('current');
     if (!$revision->bind($rev)) {
         throw new Exception($revision->getError(), 500);
     }
     $params = new \Hubzero\Config\Registry($page->get('params', ''));
     $params->merge(Request::getVar('params', array(), 'post'));
     $page->set('params', $params->toString());
     foreach ($fields as $key => $value) {
         if (!is_null($value)) {
             $page->set($key, $value);
         }
     }
     $page->set('modified', Date::toSql());
     if (!$page->store(true)) {
         throw new Exception($page->getError(), 500);
     }
     if (!$page->updateAuthors(Request::getVar('authors', '', 'post'))) {
         throw new Exception($page->getError(), 500);
     }
     $revision->set('pagetext', Request::getVar('pagetext', '', '', 'none', 2));
     $revision->set('summary', Request::getVar('summary', null));
     if ($revision->get('pagetext') == '') {
         $revision->set('id', 0);
         $revision->set('pageid', $page->get('id'));
         $revision->set('pagename', $page->get('pagename'));
         $revision->set('scope', $page->get('scope'));
         $revision->set('group_cn', $page->get('group_cn'));
         $revision->set('version', $revision->get('version') + 1);
         if ($page->param('mode', 'wiki') == 'knol') {
             // Set revisions to NOT approved
             $revision->set('approved', 0);
             // If an author or the original page creator, set to approved
             if ($page->get('created_by') == User::get('id') || $page->isAuthor(User::get('id'))) {
                 $revision->set('approved', 1);
             }
         } else {
             // Wiki mode, approve revision
             $revision->set('approved', 1);
         }
         $revision->set('pagehtml', $revision->content('parsed'));
         if ($page->access('manage') || $page->access('edit')) {
             $revision->set('approved', 1);
         }
         // Store content
         if (!$revision->store(true)) {
             throw new Exception(Lang::txt('COM_WIKI_ERROR_SAVING_REVISION'), 500);
         }
         $page->set('version_id', $revision->get('id'));
         if (!$page->store(true)) {
             throw new Exception($page->getError(), 500);
         }
     }
     $page->tag(Request::getVar('tags', ''));
     $this->send($page->toObject());
 }
Beispiel #4
0
 /**
  * Return Module Rendered & Ready For Display
  *
  * @return void
  */
 public function moduleAction()
 {
     // get module id
     $moduleId = Request::getInt('moduleid', 0);
     // get list of modules
     $modulesList = $this->_loadModules($this->params->get('position', 'memberDashboard'));
     // load user preferences
     $preferences = $this->_loadPreferences();
     // get module preferences for moduleid
     $preference = new stdClass();
     foreach ($preferences as $p) {
         if ($p->module == $moduleId) {
             $preference = $p;
             break;
         }
     }
     // get the module
     $module = null;
     if (in_array($moduleId, array_keys($modulesList))) {
         $module = $modulesList[$moduleId];
         $module->positioning = new stdClass();
         $module->positioning->col = 1;
         $module->positioning->row = 1;
         $module->positioning->size_x = 1;
         $module->positioning->size_y = 2;
         // merge user params with hub wide params
         if (isset($preference->parameters)) {
             $params = new \Hubzero\Config\Registry($module->params);
             $uparams = new \Hubzero\Config\Registry($preference->parameters);
             $params->merge($uparams);
             $module->params = $params->toString();
         }
     }
     // create view object
     $view = $this->view('module', 'display');
     // get application location
     $view->admin = App::isAdmin();
     $view->module = $module;
     $content = $view->loadTemplate();
     $stylesheets = array();
     $scripts = array();
     $document = Document::getHeadData();
     foreach ($document['styleSheets'] as $strSrc => $strAttr) {
         if (strstr($strSrc, $module->module)) {
             $stylesheets[] = $strSrc;
         }
     }
     foreach ($document['scripts'] as $strSrc => $strType) {
         if (strstr($strSrc, $module->module)) {
             $scripts[] = $strSrc;
         }
     }
     // return content
     echo json_encode(array('html' => $content, 'assets' => array('scripts' => $scripts, 'stylesheets' => $stylesheets)));
     exit;
 }
Beispiel #5
0
 /**
  * Update a page
  *
  * @apiMethod PUT
  * @apiUri    /wiki/{id}
  * @apiParameter {
  * 		"name":        "id",
  * 		"description": "Entry identifier",
  * 		"type":        "integer",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "title",
  * 		"description": "Entry title",
  * 		"type":        "string",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "pagename",
  * 		"description": "Page name",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "pagetext",
  * 		"description": "Page content",
  * 		"type":        "string",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "created",
  * 		"description": "Created timestamp (YYYY-MM-DD HH:mm:ss)",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     "now"
  * }
  * @apiParameter {
  * 		"name":        "created_by",
  * 		"description": "User ID of entry creator",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":     0
  * }
  * @apiParameter {
  * 		"name":        "state",
  * 		"description": "Published state (0 = unpublished, 1 = published)",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":     0
  * }
  * @apiParameter {
  * 		"name":        "access",
  * 		"description": "Access level (0 = public, 1 = registered users, 4 = private)",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":     0
  * }
  * @apiParameter {
  * 		"name":        "scope",
  * 		"description": "Page scope",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     "site"
  * }
  * @apiParameter {
  * 		"name":        "scope_id",
  * 		"description": "Page scope ID",
  * 		"type":        "integer",
  * 		"required":    false,
  * 		"default":     0
  * }
  * @apiParameter {
  * 		"name":        "params",
  * 		"description": "Page options",
  * 		"type":        "array",
  * 		"required":    false,
  * 		"default":     null
  * }
  * @apiParameter {
  * 		"name":        "summary",
  * 		"description": "Summary of changes made",
  * 		"type":        "string",
  * 		"required":    false,
  * 		"default":     null
  * }
  * @return  void
  */
 public function updateTask()
 {
     $this->requiresAuthentication();
     $fields = array('title' => Request::getVar('title', null, '', 'none', 2), 'pagename' => Request::getVar('pagename', null), 'scope' => Request::getVar('scope', 'site'), 'scope_id' => Request::getInt('scope_id', 0), 'created' => Request::getVar('created', null), 'created_by' => Request::getInt('created_by', null), 'state' => Request::getInt('state', 0), 'access' => Request::getInt('access', 0), 'params' => Request::getVar('params', array()));
     if (!$id) {
         throw new Exception(Lang::txt('COM_WIKI_ERROR_PAGE_NOT_SPECIFIED'), 422);
     }
     $page = Page::oneOrFail($id);
     if (!$page->get('id')) {
         throw new Exception(Lang::txt('COM_WIKI_ERROR_PAGE_NOT_FOUND'), 404);
     }
     if ($page->isLocked() && !$page->access('manage')) {
         throw new Exception(Lang::txt('COM_WIKI_ERROR_NOTAUTH'), 403);
     }
     $revision = $page->version;
     // Get parameters
     $params = new \Hubzero\Config\Registry($page->get('params', ''));
     $params->merge(Request::getVar('params', array(), 'post'));
     $page->set('params', $params->toString());
     // Set data
     foreach ($fields as $key => $value) {
         if (!is_null($value)) {
             $page->set($key, $value);
         }
     }
     $page->set('modified', Date::toSql());
     if (!$page->save()) {
         throw new Exception($page->getError(), 500);
     }
     // Set authors
     if (!Author::setForPage(Request::getVar('authors', '', 'post'), $page->get('id'))) {
         throw new Exception(Lang::txt('COM_WIKI_ERROR_SAVING_AUTHORS'), 500);
     }
     $old = $revision->get('pagetext');
     $revision->set('id', 0);
     $revision->set('page_id', $page->get('id'));
     $revision->set('pagetext', Request::getVar('pagetext', '', '', 'none', 2));
     $revision->set('summary', Request::getVar('summary', null));
     $revision->set('version', $revision->get('version') + 1);
     if ($page->param('mode', 'wiki') == 'knol') {
         // Set revisions to NOT approved
         $revision->set('approved', 0);
         // If an author or the original page creator, set to approved
         if ($page->get('created_by') == User::get('id') || $page->isAuthor(User::get('id'))) {
             $revision->set('approved', 1);
         }
     } else {
         // Wiki mode, approve revision
         $revision->set('approved', 1);
     }
     // Compare against previous revision
     // We don't want to create a whole new revision if just the tags were changed
     if (rtrim($old) != rtrim($revision->get('pagetext'))) {
         $revision->set('pagehtml', $revision->content());
         if ($page->access('manage') || $page->access('edit')) {
             $revision->set('approved', 1);
         }
         if (!$revision->save()) {
             throw new Exception(Lang::txt('COM_WIKI_ERROR_SAVING_REVISION'), 500);
         }
         $page->set('version_id', $revision->get('id'));
         $page->set('modified', $revision->get('created'));
     }
     // Store changes
     if (!$page->save()) {
         throw new Exception($page->getError(), 500);
     }
     // Process tags
     $page->tag(Request::getVar('tags', ''));
     $this->send($page->toObject());
 }
Beispiel #6
0
 /**
  * Save changes to an entry
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $page = Request::getVar('page', array(), 'post');
     $page = array_map('trim', $page);
     // Initiate extended database class
     $row = new Page(intval($page['id']));
     if (!$row->bind($page)) {
         $this->setMessage($row->getError(), 'error');
         $this->editTask($row);
         return;
     }
     // Get parameters
     $params = Request::getVar('params', array(), 'post');
     if (is_array($params)) {
         $pparams = new \Hubzero\Config\Registry($row->get('params'));
         $pparams->merge($params);
         $row->set('params', $pparams->toString());
     }
     // Store new content
     if (!$row->store(true)) {
         $this->setMessage($row->getError(), 'error');
         $this->editTask($row);
         return;
     }
     if (!$row->updateAuthors($page['authors'])) {
         $this->setMessage($row->getError(), 'error');
         $this->editTask($row);
         return;
     }
     $row->tag($page['tags']);
     if ($this->getTask() == 'apply') {
         Request::setVar('id', $row->get('id'));
         return $this->editTask($row);
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_WIKI_PAGE_SAVED'));
 }
Beispiel #7
0
 /**
  * Save a wiki page
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Check if they are logged in
     if (User::isGuest()) {
         $url = Request::getVar('REQUEST_URI', '', 'server');
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url), false));
     }
     // Incoming revision
     $revision = $this->page->version;
     $revision->set('version', $revision->get('version') + 1);
     $revision->set(Request::getVar('revision', array(), 'post', 'none', 2));
     $revision->set('id', 0);
     // Incoming page
     $page = Request::getVar('page', array(), 'post', 'none', 2);
     if (!isset($page['protected']) || !$page['protected']) {
         $page['protected'] = 0;
     }
     $this->page = Page::oneOrNew(intval($revision->get('page_id')));
     $this->page->set($page);
     $this->page->set('pagename', trim(Request::getVar('pagename', '', 'post')));
     // Get parameters
     $params = new \Hubzero\Config\Registry($this->page->get('params', ''));
     $params->merge(Request::getVar('params', array(), 'post'));
     $this->page->set('params', $params->toString());
     // Get the previous version to compare against
     if (!$revision->get('page_id')) {
         // New page - save it to the database
         $this->page->set('created_by', User::get('id'));
         $old = Version::blank();
     } else {
         // Get the revision before changes
         $old = $this->page->version;
     }
     // Was the preview button pushed?
     $this->preview = trim(Request::getVar('preview', ''));
     if ($this->preview) {
         // Set the component task
         if (!$page['id']) {
             Request::setVar('task', 'new');
             $this->_task = 'new';
         } else {
             Request::setVar('task', 'edit');
             $this->_task = 'edit';
         }
         // Push on through to the edit form
         return $this->editTask($revision);
     }
     // Check content
     // First, make sure the pagetext isn't empty
     if ($revision->get('pagetext') == '') {
         $this->setError(Lang::txt('COM_WIKI_ERROR_MISSING_PAGETEXT'));
         return $this->editTask($revision);
     }
     // Store new content
     if (!$this->page->save()) {
         $this->setError($this->page->getError());
         return $this->editTask($revision);
     }
     // Get allowed authors
     if (!Author::setForPage(Request::getVar('authors', '', 'post'), $this->page->get('id'))) {
         $this->setError(Lang::txt('COM_WIKI_ERROR_SAVING_AUTHORS'));
         return $this->editTask($revision);
     }
     // Get the upload path
     $path = Attachment::blank()->filespace();
     // Rename the temporary upload directory if it exist
     $lid = Request::getInt('lid', 0, 'post');
     if ($lid != $this->page->get('id')) {
         if (is_dir($path . DS . $lid)) {
             if (!\Filesystem::move($path . DS . $lid, $path . DS . $this->page->get('id'))) {
                 $this->setError(\Filesystem::move($path . DS . $lid, $path . DS . $this->page->get('id')));
             }
         }
         foreach (Attachment::all()->whereEquals('page_id', $lid)->rows() as $attachment) {
             $attachment->set('page_id', $this->page->get('id'));
             if (!$attachment->save()) {
                 $this->setError($attachment->getError());
             }
         }
     }
     $revision->set('page_id', $this->page->get('id'));
     $revision->set('version', $revision->get('version') + 1);
     if ($this->page->param('mode', 'wiki') == 'knol') {
         // Set revisions to NOT approved
         $revision->set('approved', 0);
         // If an author or the original page creator, set to approved
         if ($this->page->get('created_by') == User::get('id') || $this->page->isAuthor(User::get('id'))) {
             $revision->set('approved', 1);
         }
     } else {
         // Wiki mode, approve revision
         $revision->set('approved', 1);
     }
     // Compare against previous revision
     // We don't want to create a whole new revision if just the tags were changed
     if (rtrim($old->get('pagetext')) != rtrim($revision->get('pagetext'))) {
         // Transform the wikitext to HTML
         $revision->set('pagehtml', '');
         $revision->set('pagehtml', $revision->content($this->page));
         if ($this->page->access('manage') || $this->page->access('edit')) {
             $revision->set('approved', 1);
         }
         // Store content
         if (!$revision->save()) {
             $this->setError(Lang::txt('COM_WIKI_ERROR_SAVING_REVISION'));
             return $this->editTask($revision);
         }
         $this->page->set('version_id', $revision->get('id'));
         $this->page->set('modified', $revision->get('created'));
     } else {
         $this->page->set('modified', Date::toSql());
     }
     if (!$this->page->save()) {
         // This really shouldn't happen.
         $this->setError(Lang::txt('COM_WIKI_ERROR_SAVING_PAGE'));
         return $this->editTask($revision);
     }
     // Process tags
     $this->page->tag(Request::getVar('tags', ''));
     // Log activity
     $recipients = array(['wiki.site', 1], ['user', $this->page->get('created_by')], ['user', $revision->get('created_by')]);
     if ($this->page->get('scope') != 'site') {
         $recipients[] = [$this->page->get('scope'), $this->page->get('scope_id')];
         $recipients[0] = ['wiki.' . $this->page->get('scope'), $this->page->get('scope_id')];
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => $page['id'] ? 'updated' : 'created', 'scope' => 'wiki.page', 'scope_id' => $this->page->get('id'), 'description' => Lang::txt('COM_WIKI_ACTIVITY_PAGE_' . ($page['id'] ? 'UPDATED' : 'CREATED'), '<a href="' . Route::url($this->page->link()) . '">' . $this->page->title . '</a>'), 'details' => array('title' => $this->page->title, 'url' => Route::url($this->page->link()), 'name' => $this->page->get('pagename'), 'revision' => $revision->get('id'))], 'recipients' => $recipients]);
     // Redirect
     App::redirect(Route::url($this->page->link()));
 }