/** * Execute the action * * @return void */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendBlogModel::exists($this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // set category id $this->categoryId = SpoonFilter::getGetValue('category', null, null, 'int'); if ($this->categoryId == 0) { $this->categoryId = null; } // get data $this->record = (array) BackendBlogModel::get($this->id); // delete item BackendBlogModel::delete($this->id); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id)); // delete search indexes if (is_callable(array('BackendSearchModel', 'removeIndex'))) { BackendSearchModel::removeIndex($this->getModule(), $this->id); } // build redirect URL $redirectUrl = BackendModel::createURLForAction('index') . '&report=deleted&var=' . urlencode($this->record['title']); // append to redirect URL if ($this->categoryId != null) { $redirectUrl .= '&category=' . $this->categoryId; } // item was deleted, so redirect $this->redirect($redirectUrl); } else { $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing'); } }
/** * Load the data * * @return void */ private function loadData() { // get latest published comments $this->comments = BackendBlogModel::getLatestComments('published', 5); // get count $this->numCommentStatus = BackendBlogModel::getCommentStatusCount(); }
/** * Execute the action * * @return void */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendBlogModel::existsCategory($this->id)) { // get data $this->record = (array) BackendBlogModel::getCategory($this->id); // allowed to delete the category? if (BackendBlogModel::deleteCategoryAllowed($this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // delete item BackendBlogModel::deleteCategory($this->id); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_delete_category', array('id' => $this->id)); // category was deleted, so redirect $this->redirect(BackendModel::createURLForAction('categories') . '&report=deleted-category&var=' . urlencode($this->record['title'])); } else { $this->redirect(BackendModel::createURLForAction('categories') . '&error=delete-category-not-allowed&var=' . urlencode($this->record['title'])); } } else { $this->redirect(BackendModel::createURLForAction('categories') . '&error=non-existing'); } }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $categoryTitle = trim(SpoonFilter::getPostValue('value', null, '', 'string')); // validate if ($categoryTitle === '') { $this->output(self::BAD_REQUEST, null, BL::err('TitleIsRequired')); } // get the data // build array $item['title'] = SpoonFilter::htmlspecialchars($categoryTitle); $item['language'] = BL::getWorkingLanguage(); $meta['keywords'] = $item['title']; $meta['keywords_overwrite'] = 'N'; $meta['description'] = $item['title']; $meta['description_overwrite'] = 'N'; $meta['title'] = $item['title']; $meta['title_overwrite'] = 'N'; $meta['url'] = BackendBlogModel::getURLForCategory(SpoonFilter::urlise($item['title'])); // update $item['id'] = BackendBlogModel::insertCategory($item, $meta); // output $this->output(self::OK, $item, vsprintf(BL::msg('AddedCategory'), array($item['title']))); }
/** * Validate the form * * @return void */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // set callback for generating an unique URL $this->meta->setURLCallback('BackendBlogModel', 'getURLForCategory'); // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); // validate meta $this->meta->validate(); // no errors? if ($this->frm->isCorrect()) { // build item $item['title'] = $this->frm->getField('title')->getValue(); $item['language'] = BL::getWorkingLanguage(); $item['meta_id'] = $this->meta->save(); // insert the item $item['id'] = BackendBlogModel::insertCategory($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add_category', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('categories') . '&report=added-category&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }
/** * Execute the action */ public function execute() { parent::execute(); BackendBlogModel::deleteSpamComments(); // item was deleted, so redirect $this->redirect(BackendModel::createURLForAction('comments') . '&report=deleted-spam#tabSpam'); }
/** * Execute the action * * @return void */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // delete item BackendBlogModel::deleteSpamComments($this->id); // item was deleted, so redirect $this->redirect(BackendModel::createURLForAction('comments') . '&report=deleted-spam#tabSpam'); }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); // validate meta $this->meta->validate(); if ($this->frm->isCorrect()) { // build item $item['id'] = $this->id; $item['title'] = $this->frm->getField('title')->getValue(); $item['meta_id'] = $this->meta->save(true); // upate the item BackendBlogModel::updateCategory($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit_category', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('categories') . '&report=edited-category&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }
/** * Validate the form */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // get the status $status = SpoonFilter::getPostValue('status', array('active', 'draft'), 'active'); // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); $this->frm->getField('text')->isFilled(BL::err('FieldIsRequired')); $this->frm->getField('publish_on_date')->isValid(BL::err('DateIsInvalid')); $this->frm->getField('publish_on_time')->isValid(BL::err('TimeIsInvalid')); $this->frm->getField('category_id')->isFilled(BL::err('FieldIsRequired')); if ($this->frm->getField('category_id')->getValue() == 'new_category') { $this->frm->getField('category_id')->addError(BL::err('FieldIsRequired')); } if ($this->imageIsAllowed) { // validate the image if ($this->frm->getField('image')->isFilled()) { // image extension and mime type $this->frm->getField('image')->isAllowedExtension(array('jpg', 'png', 'gif', 'jpeg'), BL::err('JPGGIFAndPNGOnly')); $this->frm->getField('image')->isAllowedMimeType(array('image/jpg', 'image/png', 'image/gif', 'image/jpeg'), BL::err('JPGGIFAndPNGOnly')); } } // validate meta $this->meta->validate(); if ($this->frm->isCorrect()) { // build item $item['id'] = (int) BackendBlogModel::getMaximumId() + 1; $item['meta_id'] = $this->meta->save(); $item['category_id'] = (int) $this->frm->getField('category_id')->getValue(); $item['user_id'] = $this->frm->getField('user_id')->getValue(); $item['language'] = BL::getWorkingLanguage(); $item['title'] = $this->frm->getField('title')->getValue(); $item['introduction'] = $this->frm->getField('introduction')->getValue(); $item['text'] = $this->frm->getField('text')->getValue(); $item['publish_on'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($this->frm->getField('publish_on_date'), $this->frm->getField('publish_on_time'))); $item['created_on'] = BackendModel::getUTCDate(); $item['edited_on'] = $item['created_on']; $item['hidden'] = $this->frm->getField('hidden')->getValue(); $item['allow_comments'] = $this->frm->getField('allow_comments')->getChecked() ? 'Y' : 'N'; $item['num_comments'] = 0; $item['status'] = $status; if ($this->imageIsAllowed) { // the image path $imagePath = FRONTEND_FILES_PATH . '/blog/images'; // validate the image if ($this->frm->getField('image')->isFilled()) { // build the image name $item['image'] = $this->meta->getURL() . '.' . $this->frm->getField('image')->getExtension(); // upload the image $this->frm->getField('image')->moveFile($imagePath . '/source/' . $item['image']); } } // insert the item $item['revision_id'] = BackendBlogModel::insert($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item)); // save the tags BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule()); // active if ($item['status'] == 'active') { // add search index BackendSearchModel::saveIndex($this->getModule(), $item['id'], array('title' => $item['title'], 'text' => $item['text'])); // ping if (BackendModel::getModuleSetting($this->getModule(), 'ping_services', false)) { BackendModel::ping(SITE_URL . BackendModel::getURLForBlock('blog', 'detail') . '/' . $this->meta->getURL()); } // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['revision_id']); } elseif ($item['status'] == 'draft') { // everything is saved, so redirect to the edit action $this->redirect(BackendModel::createURLForAction('edit') . '&report=saved-as-draft&var=' . urlencode($item['title']) . '&id=' . $item['id'] . '&draft=' . $item['revision_id'] . '&highlight=row-' . $item['revision_id']); } } } }
/** * Execute the action * * @return void */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // current status $from = SpoonFilter::getGetValue('from', array('published', 'moderation', 'spam'), 'published'); // action to execute $action = SpoonFilter::getGetValue('action', array('published', 'moderation', 'spam', 'delete'), 'spam'); // no id's provided if (!isset($_GET['id'])) { $this->redirect(BackendModel::createURLForAction('comments') . '&error=no-comments-selected'); } else { // redefine id's $ids = (array) $_GET['id']; // delete comment(s) if ($action == 'delete') { BackendBlogModel::deleteComments($ids); } elseif ($action == 'spam') { // is the spamfilter active? if (BackendModel::getModuleSetting($this->URL->getModule(), 'spamfilter', false)) { // get data $comments = BackendBlogModel::getComments($ids); // loop comments foreach ($comments as $row) { // unserialize data $row['data'] = unserialize($row['data']); // check if needed data is available if (!isset($row['data']['server']['REMOTE_ADDR'])) { continue; } if (!isset($row['data']['server']['HTTP_USER_AGENT'])) { continue; } // build vars $userIp = $row['data']['server']['REMOTE_ADDR']; $userAgent = $row['data']['server']['HTTP_USER_AGENT']; $content = $row['text']; $author = $row['author']; $email = $row['email']; $url = isset($row['website']) && $row['website'] != '' ? $row['website'] : null; $referrer = isset($row['data']['server']['HTTP_REFERER']) ? $row['data']['server']['HTTP_REFERER'] : null; $others = $row['data']['server']; // submit as spam BackendModel::submitSpam($userIp, $userAgent, $content, $author, $email, $url, null, 'comment', $referrer, $others); } } // set new status BackendBlogModel::updateCommentStatuses($ids, $action); } else { // published? if ($action == 'published') { // is the spamfilter active? if (BackendModel::getModuleSetting($this->URL->getModule(), 'spamfilter', false)) { // get data $comments = BackendBlogModel::getComments($ids); // loop comments foreach ($comments as $row) { // previous status is spam if ($row['status'] == 'spam') { // unserialize data $row['data'] = unserialize($row['data']); // check if needed data is available if (!isset($row['data']['server']['REMOTE_ADDR'])) { continue; } if (!isset($row['data']['server']['HTTP_USER_AGENT'])) { continue; } // build vars $userIp = $row['data']['server']['REMOTE_ADDR']; $userAgent = $row['data']['server']['HTTP_USER_AGENT']; $content = $row['text']; $author = $row['author']; $email = $row['email']; $url = isset($row['website']) && $row['website'] != '' ? $row['website'] : null; $referrer = isset($row['data']['server']['HTTP_REFERER']) ? $row['data']['server']['HTTP_REFERER'] : null; $others = $row['data']['server']; // submit as spam BackendModel::submitHam($userIp, $userAgent, $content, $author, $email, $url, null, 'comment', $referrer, $others); } } } } // set new status BackendBlogModel::updateCommentStatuses($ids, $action); } // define report $report = count($ids) > 1 ? 'comments-' : 'comment-'; // init var if ($action == 'published') { $report .= 'moved-published'; } if ($action == 'moderation') { $report .= 'moved-moderation'; } if ($action == 'spam') { $report .= 'moved-spam'; } if ($action == 'delete') { $report .= 'deleted'; } // redirect $this->redirect(BackendModel::createURLForAction('comments') . '&report=' . $report . '#tab' . ucfirst($from)); } }
/** * Update the status for multiple comments at once. * * @return void * @param array $id The id/ids of the comment(s) to update. * @param string $status The new status for the comment. Possible values are: published, moderation, spam. */ public static function commentsUpdateStatus($id, $status) { // authorize if (API::authorize()) { // redefine if (!is_array($id)) { $id = (array) explode(',', $ids); } $status = (string) $status; // update statuses BackendBlogModel::updateCommentStatuses($id, $status); } }
/** * Validate the form * * @return void */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // validate fields $this->frm->getField('author')->isFilled(BL::err('AuthorIsRequired')); $this->frm->getField('email')->isEmail(BL::err('EmailIsInvalid')); $this->frm->getField('text')->isFilled(BL::err('FieldIsRequired')); if ($this->frm->getField('website')->isFilled()) { $this->frm->getField('website')->isURL(BL::err('InvalidURL')); } // no errors? if ($this->frm->isCorrect()) { // build item $item['id'] = $this->id; $item['status'] = $this->record['status']; $item['author'] = $this->frm->getField('author')->getValue(); $item['email'] = $this->frm->getField('email')->getValue(); $item['website'] = $this->frm->getField('website')->isFilled() ? $this->frm->getField('website')->getValue() : null; $item['text'] = $this->frm->getField('text')->getValue(); // insert the item BackendBlogModel::updateComment($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit_comment', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('comments') . '&report=edited-comment&id=' . $item['id'] . '&highlight=row-' . $item['id'] . '#tab' . SpoonFilter::toCamelCase($item['status'])); } } }
/** * Validate the form */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // XML provided? if ($this->frm->getField('blogger')->isFilled()) { $this->frm->getField('blogger')->isAllowedExtension(array('xml'), BL::err('XMLFilesOnly')); } else { $this->frm->getField('blogger')->addError(BL::err('FieldIsRequired')); } // no errors? if ($this->frm->isCorrect()) { // move the file $this->frm->getField('blogger')->moveFile(FRONTEND_FILES_PATH . '/blogger.xml'); // process the XML $this->processXML(); // recalculate the comments BackendBlogModel::reCalculateCommentCount($this->newIds); // remove the file SpoonFile::delete(FRONTEND_FILES_PATH . '/blogger.xml'); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('index') . '&report=imported'); } } }
/** * Validate the form */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // get the status $status = SpoonFilter::getPostValue('status', array('active', 'draft'), 'active'); // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); $this->frm->getField('text')->isFilled(BL::err('FieldIsRequired')); $this->frm->getField('publish_on_date')->isValid(BL::err('DateIsInvalid')); $this->frm->getField('publish_on_time')->isValid(BL::err('TimeIsInvalid')); $this->frm->getField('category_id')->isFilled(BL::err('FieldIsRequired')); // validate meta $this->meta->validate(); // no errors? if ($this->frm->isCorrect()) { // build item $item['id'] = $this->id; $item['revision_id'] = $this->record['revision_id']; // this is used to let our model know the status (active, archive, draft) of the edited item $item['meta_id'] = $this->meta->save(); $item['category_id'] = (int) $this->frm->getField('category_id')->getValue(); $item['user_id'] = $this->frm->getField('user_id')->getValue(); $item['language'] = BL::getWorkingLanguage(); $item['title'] = $this->frm->getField('title')->getValue(); $item['introduction'] = $this->frm->getField('introduction')->getValue(); $item['text'] = $this->frm->getField('text')->getValue(); $item['publish_on'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($this->frm->getField('publish_on_date'), $this->frm->getField('publish_on_time'))); $item['edited_on'] = BackendModel::getUTCDate(); $item['hidden'] = $this->frm->getField('hidden')->getValue(); $item['allow_comments'] = $this->frm->getField('allow_comments')->getChecked() ? 'Y' : 'N'; $item['status'] = $status; if ($this->imageIsAllowed) { $item['image'] = $this->record['image']; // the image path $imagePath = FRONTEND_FILES_PATH . '/blog/images'; // if the image should be deleted if ($this->frm->getField('delete_image')->isChecked()) { // delete the image SpoonFile::delete($imagePath . '/source/' . $item['image']); // reset the name $item['image'] = null; } // new image given? if ($this->frm->getField('image')->isFilled()) { // delete the old image SpoonFile::delete($imagePath . '/source/' . $this->record['image']); // build the image name $item['image'] = $this->meta->getURL() . '.' . $this->frm->getField('image')->getExtension(); // upload the image $this->frm->getField('image')->moveFile($imagePath . '/source/' . $item['image']); } elseif ($item['image'] != null) { // get the old file extension $imageExtension = SpoonFile::getExtension($imagePath . '/source/' . $item['image']); // get the new image name $newName = $this->meta->getURL() . '.' . $imageExtension; // only change the name if there is a difference if ($newName != $item['image']) { // move the old file to the new name SpoonFile::move($imagePath . '/source/' . $item['image'], $imagePath . '/source/' . $newName); // assign the new name to the database $item['image'] = $newName; } } } else { $item['image'] = null; } // update the item $item['revision_id'] = BackendBlogModel::update($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit', array('item' => $item)); // recalculate comment count so the new revision has the correct count BackendBlogModel::reCalculateCommentCount(array($this->id)); // save the tags BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule()); // active if ($item['status'] == 'active') { // edit search index BackendSearchModel::saveIndex($this->getModule(), $item['id'], array('title' => $item['title'], 'text' => $item['text'])); // ping if (BackendModel::getModuleSetting($this->URL->getModule(), 'ping_services', false)) { BackendModel::ping(SITE_URL . BackendModel::getURLForBlock($this->URL->getModule(), 'detail') . '/' . $this->meta->getURL()); } // build URL $redirectUrl = BackendModel::createURLForAction('index') . '&report=edited&var=' . urlencode($item['title']) . '&id=' . $this->id . '&highlight=row-' . $item['revision_id']; } elseif ($item['status'] == 'draft') { // everything is saved, so redirect to the edit action $redirectUrl = BackendModel::createURLForAction('edit') . '&report=saved-as-draft&var=' . urlencode($item['title']) . '&id=' . $item['id'] . '&draft=' . $item['revision_id'] . '&highlight=row-' . $item['revision_id']; } // append to redirect URL if ($this->categoryId != null) { $redirectUrl .= '&category=' . $this->categoryId; } // everything is saved, so redirect to the overview $this->redirect($redirectUrl); } } }
/** * Validate the form * * @return void */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // XML provided? if ($this->frm->getField('blogger')->isFilled()) { $this->frm->getField('blogger')->isAllowedExtension(array('xml'), BL::err('XMLFilesOnly')); } else { $this->frm->getField('blogger')->addError(BL::err('FieldIsRequired')); } // no errors? if ($this->frm->isCorrect()) { // move the file $this->frm->getField('blogger')->moveFile(FRONTEND_FILES_PATH . '/blogger.xml'); // init object $reader = new XMLReader(); // open the file $reader->open(FRONTEND_FILES_PATH . '/blogger.xml'); // start reading $reader->read(); // loop through the document while (true) { // start tag for entry? if ($reader->name == 'entry') { // end tag? if ($reader->nodeType == XMLReader::END_ELEMENT) { $reader->next(); } // get the raw XML $xmlString = $reader->readOuterXml(); // is it really an entry? if (substr($xmlString, 0, 6) == '<entry') { // read the XML as an SimpleXML-object $xml = @simplexml_load_string($reader->readOuterXml()); // validate if ($xml !== false) { // loop the categories foreach ($xml->category as $category) { // post if ($category['term'] == 'http://schemas.google.com/blogger/2008/kind#post') { // process the post $this->processXMLAsPost($xml); // stop looping break; } // comment if ($category['term'] == 'http://schemas.google.com/blogger/2008/kind#comment') { // process the post $this->processXMLAsComment($xml); // stop looping break; } } } } } // end if (!$reader->read()) { break; } } // close $reader->close(); // recalculate the comments BackendBlogModel::reCalculateCommentCount($this->newIds); // remove the file SpoonFile::delete(FRONTEND_FILES_PATH . '/blogger.xml'); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('index') . '&report=imported'); } } }
/** * Parse all datagrids */ protected function parse() { parent::parse(); // parse the datagrid for the drafts $this->tpl->assign('dgDrafts', $this->dgDrafts->getNumResults() != 0 ? $this->dgDrafts->getContent() : false); // parse the datagrid for all blogposts $this->tpl->assign('dgPosts', $this->dgPosts->getNumResults() != 0 ? $this->dgPosts->getContent() : false); // parse the datagrid for the most recent blogposts $this->tpl->assign('dgRecent', is_object($this->dgRecent) && $this->dgRecent->getNumResults() != 0 ? $this->dgRecent->getContent() : false); // get categories $categories = BackendBlogModel::getCategories(true); // multiple categories? if (count($categories) > 1) { // create form $frm = new BackendForm('filter', null, 'get', false); // create element $frm->addDropdown('category', $categories, $this->categoryId); $frm->getField('category')->setDefaultElement(''); // parse the form $frm->parse($this->tpl); } // parse category if (!empty($this->category)) { $this->tpl->assign('filterCategory', $this->category); } }
/** * Validate the form * * @return void */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // set callback for generating an unique URL $this->meta->setUrlCallback('BackendBlogModel', 'getURL', array($this->record['id'])); // get the status $status = SpoonFilter::getPostValue('status', array('active', 'draft'), 'active'); // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); $this->frm->getField('text')->isFilled(BL::err('FieldIsRequired')); $this->frm->getField('publish_on_date')->isValid(BL::err('DateIsInvalid')); $this->frm->getField('publish_on_time')->isValid(BL::err('TimeIsInvalid')); $this->frm->getField('category_id')->isFilled(BL::err('FieldIsRequired')); // validate meta $this->meta->validate(); // no errors? if ($this->frm->isCorrect()) { // build item $item['id'] = $this->id; $item['revision_id'] = $this->record['revision_id']; // this is used to let our model know the status (active, archive, draft) of the edited item $item['meta_id'] = $this->meta->save(); $item['category_id'] = (int) $this->frm->getField('category_id')->getValue(); $item['user_id'] = $this->frm->getField('user_id')->getValue(); $item['language'] = BL::getWorkingLanguage(); $item['title'] = $this->frm->getField('title')->getValue(); $item['introduction'] = $this->frm->getField('introduction')->getValue(); $item['text'] = $this->frm->getField('text')->getValue(); $item['publish_on'] = BackendModel::getUTCDate(null, BackendModel::getUTCTimestamp($this->frm->getField('publish_on_date'), $this->frm->getField('publish_on_time'))); $item['edited_on'] = BackendModel::getUTCDate(); $item['hidden'] = $this->frm->getField('hidden')->getValue(); $item['allow_comments'] = $this->frm->getField('allow_comments')->getChecked() ? 'Y' : 'N'; $item['status'] = $status; // update the item $item['revision_id'] = BackendBlogModel::update($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit', array('item' => $item)); // recalculate comment count so the new revision has the correct count BackendBlogModel::reCalculateCommentCount(array($this->id)); // save the tags BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule()); // active if ($item['status'] == 'active') { // edit search index if (is_callable(array('BackendSearchModel', 'editIndex'))) { BackendSearchModel::editIndex($this->getModule(), $item['id'], array('title' => $item['title'], 'text' => $item['text'])); } // ping if (BackendModel::getModuleSetting($this->URL->getModule(), 'ping_services', false)) { BackendModel::ping(SITE_URL . BackendModel::getURLForBlock($this->URL->getModule(), 'detail') . '/' . $this->meta->getURL()); } // build URL $redirectUrl = BackendModel::createURLForAction('index') . '&report=edited&var=' . urlencode($item['title']) . '&id=' . $this->id . '&highlight=row-' . $item['revision_id']; } elseif ($item['status'] == 'draft') { // everything is saved, so redirect to the edit action $redirectUrl = BackendModel::createURLForAction('edit') . '&report=saved-as-draft&var=' . urlencode($item['title']) . '&id=' . $item['id'] . '&draft=' . $item['revision_id'] . '&highlight=row-' . $item['revision_id']; } // append to redirect URL if ($this->categoryId != null) { $redirectUrl .= '&category=' . $this->categoryId; } // everything is saved, so redirect to the overview $this->redirect($redirectUrl); } } }