getURLForBlock() публичный статический Метод

Get the URL for a give module & action combination
public static getURLForBlock ( string $module, string $action = null, string $language = null, array $data = null ) : string
$module string The module wherefore the URL should be build.
$action string The specific action wherefore the URL should be build.
$language string The language wherein the URL should be retrieved, if not provided we will load the language that was provided in the URL.
$data array An array with keys and values that partially or fully match the data of the block. If it matches multiple versions of that block it will just return the first match.
Результат string
Пример #1
0
 /**
  * Add productdata into the comment
  *
  * @param  string $text The comment.
  * @param string $title The title for the product.
  * @param string $URL The URL for the product.
  * @param int $id The id of the comment.
  * @return string
  */
 public static function addProductData($text, $title, $URL, $id)
 {
     // reset URL
     $URL = BackendModel::getURLForBlock('Catalog', 'Detail') . '/' . $URL . '#comment-' . $id;
     // build HTML
     return '<p><em>' . sprintf(BL::msg('CommentOnWithURL'), $URL, $title) . '</em></p>' . "\n" . (string) $text;
 }
Пример #2
0
 /**
  * Parse the form
  */
 protected function parse()
 {
     parent::parse();
     // parse additional variables
     $this->tpl->assign('commentsRSSURL', SITE_URL . BackendModel::getURLForBlock($this->URL->getModule(), 'comments_rss'));
     $this->tpl->assign('isGod', $this->isGod);
 }
Пример #3
0
 public function execute()
 {
     parent::execute();
     try {
         $id = Uuid::fromString($this->getParameter('id', 'string'));
         $teamMember = $this->get('team_repository')->find($id);
     } catch (\Exception $e) {
         return $this->redirect(Model::createURLForAction('Index') . '&error=non-existing');
     }
     $form = new TeamType('edit', $teamMember);
     if ($form->handle()) {
         $teamMember = $form->getData();
         $this->get('team_repository')->save($teamMember);
         return $this->redirect(Model::createURLForAction('Index') . '&report=edited' . '&highlight=row-' . $teamMember->getId());
     }
     // assign the detail url to the template if available
     $url = Model::getURLForBlock($this->URL->getModule(), 'Detail');
     if (Model::getURL(404) != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
     $form->parse($this->tpl);
     $this->tpl->assign('teamMember', $teamMember->toArray());
     $this->parse();
     $this->display();
 }
Пример #4
0
 public function parse()
 {
     parent::parse();
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'Category');
     $url404 = BackendModel::getURL(404);
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
 }
Пример #5
0
 /**
  * Parse the page
  */
 protected function parse()
 {
     parent::parse();
     // assign the url for the detail page
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'Group');
     $url404 = BackendModel::getURL(404);
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
 }
Пример #6
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('editSubscription');
     // create elements
     $this->frm->addText('name', $this->record['name']);
     $this->frm->addText('email', $this->record['email']);
     // assign URL
     $this->tpl->assign('itemURL', BackendModel::getURLForBlock($this->getModule(), 'detail') . '/' . $this->record['agenda_url'] . '#subscription-' . $this->record['agenda_id']);
     $this->tpl->assign('itemTitle', $this->record['agenda_title']);
 }
Пример #7
0
 /**
  * Parse the page
  */
 protected function parse()
 {
     parent::parse();
     // get url
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'detail');
     $url404 = BackendModel::getURL(404);
     // parse additional variables
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
 }
Пример #8
0
 /**
  * Parse the form
  */
 protected function parse()
 {
     parent::parse();
     // assign the data
     $this->tpl->assign('item', $this->record);
     $this->tpl->assign('showFaqDeleteCategory', BackendFaqModel::deleteCategoryAllowed($this->id) && BackendAuthentication::isAllowedAction('DeleteCategory'));
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'Category');
     $url404 = BackendModel::getURL(404);
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
 }
 /**
  * Parse the page
  */
 protected function parse()
 {
     parent::parse();
     // Get url
     $url = Model::getURLForBlock($this->URL->getModule(), 'Detail');
     $url404 = Model::getURL(404);
     // Parse additional variables
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
     $this->tpl->assign('item', $this->record);
 }
Пример #10
0
 /**
  * Parse the page
  */
 protected function parse()
 {
     parent::parse();
     $this->tpl->assign('item', $this->record);
     $this->tpl->assign('iframe', BackendModel::createURLForAction('preview') . "&id=" . $this->id);
     // get url
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'detail');
     $url404 = BackendModel::getURL(404);
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
 }
Пример #11
0
 /**
  * Parse the form
  */
 protected function parse()
 {
     parent::parse();
     // get url
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'detail');
     $url404 = BackendModel::getURL(404);
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
     // assign the active record and additional variables
     $this->tpl->assign('item', $this->record);
     $this->tpl->assign('feedback', $this->feedback);
 }
Пример #12
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('editComment');
     // create elements
     $this->frm->addText('author', $this->record['author']);
     $this->frm->addText('email', $this->record['email']);
     $this->frm->addText('website', $this->record['website'], null);
     $this->frm->addTextarea('text', $this->record['text']);
     // assign URL
     $this->tpl->assign('itemURL', BackendModel::getURLForBlock($this->getModule(), 'detail') . '/' . $this->record['post_url'] . '#comment-' . $this->record['post_id']);
     $this->tpl->assign('itemTitle', $this->record['post_title']);
 }
Пример #13
0
 public function execute()
 {
     parent::execute();
     $form = new TeamType('add');
     if ($form->handle()) {
         $teamMember = $form->getData();
         $this->get('team_repository')->add($teamMember);
         return $this->redirect(Model::createURLForAction('Index') . '&report=added' . '&highlight=row-' . $teamMember->getId());
     }
     // assign the detail url to the template if available
     $url = Model::getURLForBlock($this->URL->getModule(), 'Detail');
     if (Model::getURL(404) != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
     $form->parse($this->tpl);
     $this->parse();
     $this->display();
 }
Пример #14
0
 /**
  * Updates a list with campaignmonitor and in the database. Returns the affected rows
  *
  * @param array $item The new data.
  * @return int
  */
 public static function updateGroup($item)
 {
     // build unsubscribe link for this list
     $unsubscribeLink = SITE_URL . BackendModel::getURLForBlock('Mailmotor', 'unsubscribe', BL::getWorkingLanguage());
     // update the group with CM
     self::getCM()->updateList($item['name'], $unsubscribeLink . '/?group=' . $item['id'] . '&email=[email]', null, null, self::getCampaignMonitorID('list', $item['id']));
     // check if we have a default group set
     if ($item['is_default'] === 'Y' && $item['language'] != '0') {
         // set all defaults to N
         BackendModel::getContainer()->get('database')->update('mailmotor_groups', array('is_default' => 'N', 'language' => null), 'language = ?', array($item['language']));
     }
     // update the group in our database
     return (int) BackendMailmotorModel::updateGroup($item);
 }
Пример #15
0
 /**
  * Parse the form
  *
  * @return void
  */
 protected function parse()
 {
     //--Add javascript file
     $this->header->addJS('Jquery.uploadify.min.js', null, false);
     $this->header->addJS('Edit.js', null, false);
     $this->header->addCSS('Uploadify.css');
     // call parent
     parent::parse();
     // assign the category
     $this->tpl->assign('album', $this->record);
     $this->tpl->assign('images', $this->images);
     if ($this->frmAddImage) {
         $this->frmAddImage->parse($this->tpl);
     }
     if ($this->frmDeleteImage) {
         $this->frmDeleteImage->parse($this->tpl);
     }
     //--Add data to Javascript
     $this->header->addJsData("Galleria", "id", $this->id);
     // can the category be deleted?
     if (BackendGalleriaModel::deleteAlbumAllowed($this->id)) {
         $this->tpl->assign('showDelete', true);
     }
     // get url
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'group');
     $url404 = BackendModel::getURL(404);
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
 }
Пример #16
0
 /**
  * Get a preview URL to the specific mailing
  *
  * @param int    $id          The id of the mailing.
  * @param string $contentType The content-type, possible values are: html, plain.
  * @param bool   $forCM       Is the URL intended for Campaign Monitor.
  * @return string
  */
 public static function getMailingPreviewURL($id, $contentType = 'html', $forCM = false)
 {
     $contentType = \SpoonFilter::getValue($contentType, array('html', 'plain'), 'html');
     $forCM = \SpoonFilter::getValue($forCM, array(false, true), false, 'int');
     // return the URL
     return SITE_URL . BackendModel::getURLForBlock('Mailmotor', 'Detail') . '/' . $id . '?type=' . $contentType . '&cm=' . $forCM;
 }
Пример #17
0
 /**
  * Get the latest comments for a given type
  *
  * @param string $status The status for the comments to retrieve.
  * @param int    $limit  The maximum number of items to retrieve.
  *
  * @return array
  */
 public static function getLatestComments($status, $limit = 10)
 {
     // get the comments (order by id, this is faster then on date, the higher the id, the more recent
     $comments = (array) BackendModel::getContainer()->get('database')->getRecords('SELECT i.id, i.author, i.text, UNIX_TIMESTAMP(i.created_on) AS created_in,
          p.title, p.language, m.url
          FROM blog_comments AS i
          INNER JOIN blog_posts AS p ON i.post_id = p.id AND i.language = p.language
          INNER JOIN meta AS m ON p.meta_id = m.id
          WHERE i.status = ? AND p.status = ? AND i.language = ?
          ORDER BY i.created_on DESC
          LIMIT ?', array((string) $status, 'active', BL::getWorkingLanguage(), (int) $limit));
     // overwrite url
     $baseUrl = BackendModel::getURLForBlock('Blog', 'detail');
     foreach ($comments as &$row) {
         $row['full_url'] = $baseUrl . '/' . $row['url'];
     }
     return $comments;
 }
Пример #18
0
 /**
  * Parse the page
  */
 protected function parse()
 {
     parent::parse();
     $this->header->addJS('edit.js');
     $this->tpl->assign('item', $this->record);
     // get url
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'Group');
     $url404 = BackendModel::getURL(404);
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
 }
 /**
  * Parse the form
  *
  * @return void
  */
 protected function parse()
 {
     // call parent
     parent::parse();
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'Detail');
     $url404 = BackendModel::getURL(404);
     // parse additional variables
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
     // assign categories
     $this->tpl->assign('categories', $this->categories);
 }
Пример #20
0
 /**
  * Parse the page
  */
 protected function parse()
 {
     parent::parse();
     // get url
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'detail');
     $url404 = BackendModel::getURL(404);
     // parse additional variables
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
     $this->tpl->assign('product', $this->record);
     $this->tpl->assign('fieldLanguages', $this->fieldLanguages);
     //--Add media
     $this->tpl->assign('mediaItems', $this->media->getMediaItems());
 }
Пример #21
0
 /**
  * Parse the page
  */
 protected function parse()
 {
     parent::parse();
     // add css
     $this->header->addCSS('/src/Backend/Modules/' . $this->getModule() . '/Layout/Css/agenda.css', null, true);
     // get url
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'detail');
     $url404 = BackendModel::getURL(404);
     // parse additional variables
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
     $this->record['url'] = $this->meta->getURL();
     $this->tpl->assign('item', $this->record);
     $this->tpl->assign('mediaItems', $this->media->getMediaItems());
 }
Пример #22
0
 /**
  * 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['meta_id'] = $this->meta->save();
             // this is used to let our model know the status (active, archive, draft) of the edited item
             $item['revision_id'] = $this->record['revision_id'];
             $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';
                 // create folders if needed
                 $fs = new Filesystem();
                 $fs->mkdir(array($imagePath . '/source', $imagePath . '/128x128'));
                 // If the image should be deleted, only the database entry is refreshed.
                 // The revision should keep it's file.
                 if ($this->frm->getField('delete_image')->isChecked()) {
                     // reset the name
                     $item['image'] = null;
                 }
                 // new image given?
                 if ($this->frm->getField('image')->isFilled()) {
                     // build the image name
                     // we use the previous revision-id in the filename to make the filename unique between
                     // the different revisions, to prevent that a new file would
                     // overwrite images of previous revisions that have the same title, and thus, the same filename
                     $item['image'] = $this->meta->getURL() . '-' . BL::getWorkingLanguage() . '-' . $item['revision_id'] . '.' . $this->frm->getField('image')->getExtension();
                     // upload the image & generate thumbnails
                     $this->frm->getField('image')->generateThumbnails($imagePath, $item['image']);
                 } elseif ($item['image'] != null) {
                     // generate the new filename
                     $image = new File($imagePath . '/source/' . $item['image']);
                     $newName = $this->meta->getURL() . '-' . BL::getWorkingLanguage() . '-' . $item['revision_id'] . '.' . $image->getExtension();
                     // extract the filenames excluding …-[language]-[revision-id].jpg
                     // to properly compare them to eachother
                     $regex = '/(.*)-[a-z]{2}-[0-9]+\\.(.*)/';
                     // only copy if the new name differs from the old filename
                     if (preg_replace($regex, '$1', $newName) != preg_replace($regex, '$1', $item['image'])) {
                         // loop folders
                         foreach (BackendModel::getThumbnailFolders($imagePath, true) as $folder) {
                             $fs->copy($folder['path'] . '/' . $item['image'], $folder['path'] . '/' . $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 ($this->get('fork.settings')->get($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') {
                 // 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);
         }
     }
 }
Пример #23
0
 /**
  * Create the basic mail
  *
  * @param $mailing
  * @param $template
  */
 public static function createMail($mailing, $template)
 {
     //--Replace the mail from the template
     $text = str_replace("[[MAIL]]", $mailing["text"], $template["template"]);
     //--Replace unsubscribe
     $unsubscribe = "http://" . $_SERVER['HTTP_HOST'] . BackendModel::getURLForBlock('Mailengine', 'MailengineUnsubscribe');
     $text = str_replace("[[UNSUBSCRIBE]]", $unsubscribe, $text);
     //--Replace the SUBJECT tag in the mailing
     $text = str_replace("[[SUBJECT]]", $mailing['subject'], $text);
     //--Add html-tags
     $text = '<html><head><title>' . $mailing['subject'] . '</title><style>' . $template['css'] . '</style></head><body>' . $text . '</body></html>';
     //--Replace relative paths from the images.
     $text = str_replace('src="/src/Frontend/', 'src="http://' . $_SERVER['HTTP_HOST'] . '/src/Frontend/', $text);
     $text = str_replace("src='/src/Frontend/", "src='http://" . $_SERVER['HTTP_HOST'] . "/src/Frontend/", $text);
     $text = str_replace('href="/src/Frontend/', 'href="http://' . $_SERVER['HTTP_HOST'] . '/src/Frontend/', $text);
     $text = str_replace("href='/src/Frontend/", "href='http://" . $_SERVER['HTTP_HOST'] . "/src/Frontend/", $text);
     return $text;
 }
Пример #24
0
 /**
  * Get a single comment
  *
  * @param int $id The id of the comment.
  *
  * @return array
  */
 public static function commentsGetById($id)
 {
     // authorize
     if (BaseAPI::isAuthorized() && BaseAPI::isValidRequestMethod('GET')) {
         // get comment
         $comment = (array) BackendBlogModel::getComment($id);
         // init var
         $return = array('comments' => null);
         // any comment found?
         if (empty($comment)) {
             return $return;
         }
         // create array
         $item['comment'] = array();
         // article meta data
         $item['comment']['article']['@attributes']['id'] = $comment['post_id'];
         $item['comment']['article']['@attributes']['lang'] = $comment['language'];
         $item['comment']['article']['title'] = $comment['post_title'];
         $item['comment']['article']['url'] = SITE_URL . BackendModel::getURLForBlock('Blog', 'Detail', $comment['language']) . '/' . $comment['post_url'];
         // set attributes
         $item['comment']['@attributes']['id'] = $comment['id'];
         $item['comment']['@attributes']['created_on'] = date('c', $comment['created_on']);
         $item['comment']['@attributes']['status'] = $comment['status'];
         // set content
         $item['comment']['text'] = $comment['text'];
         $item['comment']['url'] = $item['comment']['article']['url'] . '#comment-' . $comment['id'];
         // author data
         $item['comment']['author']['@attributes']['email'] = $comment['email'];
         $item['comment']['author']['name'] = $comment['author'];
         $item['comment']['author']['website'] = $comment['website'];
         // add
         $return['comments'][] = $item;
         return $return;
     }
 }
Пример #25
0
 /**
  * Load the form for step 4
  */
 private function loadFormForStep4()
 {
     // check if we have to redirect back to step 3 (HTML content is not set)
     if (empty($this->record['content_html'])) {
         $this->redirect(BackendModel::createURLForAction('Edit') . '&id=' . $this->id . '&step=3&error=complete-step-3');
     }
     // get preview URL
     $previewURL = BackendMailmotorModel::getMailingPreviewURL($this->record['id'], 'html', true);
     // check if the mailmotor is linked
     if (BackendModel::getURLForBlock($this->getModule(), 'detail') == BackendModel::getURL(404)) {
         $previewURL = false;
     }
     // parse the preview URL
     $this->tpl->assign('previewURL', $previewURL);
     // create form
     $this->frm = new BackendForm('step4');
     // subject
     $this->frm->addText('email');
     $this->frm->addDate('send_on_date', $this->record['send_on']);
     $this->frm->addTime('send_on_time', \SpoonDate::getDate('H:i', $this->record['send_on']));
     // show the form
     $this->tpl->assign('step4', true);
 }
Пример #26
0
 /**
  * Parse the page
  */
 protected function parse()
 {
     parent::parse();
     $this->tpl->assign('item', $this->record);
     // get url
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'Detail');
     $url404 = BackendModel::getURL(404);
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
     $this->tpl->assign("fieldLanguages", $this->fieldLanguages);
 }
 /**
  * Parse the form
  *
  * @return  void
  */
 protected function parse()
 {
     // call parent
     parent::parse();
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'Detail');
     $url404 = BackendModel::getURL(404);
     // parse additional variables
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
     // assign
     $this->tpl->assign('item', $this->record);
     $this->tpl->assign('dataGrid', $this->dataGrid->getNumResults() != 0 ? $this->dataGrid->getContent() : false);
     $this->tpl->assign('categories', $this->categories);
     $this->tpl->assign('imageCount', BackendSlideshowModel::getImagesByGallery($this->id));
     // settings allowed?
     $this->tpl->assign('settingsPerSlideshow', $this->get('fork.settings')->get('Slideshow', 'settings_per_slide'));
 }
Пример #28
0
 /**
  * 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;
             // insert the item
             $item['revision_id'] = BackendBlogModel::insert($item);
             if ($this->imageIsAllowed) {
                 // the image path
                 $imagePath = FRONTEND_FILES_PATH . '/blog/images';
                 // create folders if needed
                 $fs = new Filesystem();
                 $fs->mkdir(array($imagePath . '/source', $imagePath . '/128x128'));
                 // image provided?
                 if ($this->frm->getField('image')->isFilled()) {
                     // build the image name
                     $item['image'] = $this->meta->getURL() . '-' . BL::getWorkingLanguage() . '-' . $item['revision_id'] . '.' . $this->frm->getField('image')->getExtension();
                     // upload the image & generate thumbnails
                     $this->frm->getField('image')->generateThumbnails($imagePath, $item['image']);
                     // add the image to the database without changing the revision id
                     BackendBlogModel::updateRevision($item['revision_id'], array('image' => $item['image']));
                 }
             }
             // 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 ($this->get('fork.settings')->get($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') {
                 // 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']);
             }
         }
     }
 }