/** * Responsible for managing the addition and modification of Connect blog entries. */ public function upsertBlogEntryAction() { $this->view->currentPage = 'connect'; $blogEntryID = $this->getRequest()->getParam('id'); $blogEntries = new Datasource_Cms_Connect_BlogEntries(); if ($this->getRequest()->isPost()) { //Validate and possibly save form if ($this->_saveBlogEntry()) { //Changes saved - redirect to the main BLOG page. $this->_helper->getHelper('FlashMessenger')->addMessage(array('saved' => true)); $this->_helper->getHelper('Redirector')->goToUrl('/cms-admin/connect/blog'); return; } else { //Display the error message. $this->view->errorMessage = 'Data missing or incorrect'; //Re-layout from the form $upsertType = $this->getRequest()->getParam('upsertType'); $title = $this->getRequest()->getParam('title'); $summary = $this->getRequest()->getParam('summary'); $article = $this->getRequest()->getParam('article'); $status = $this->getRequest()->getParam('status'); $imageName = $this->getRequest()->getParam('imageName'); if (!empty($imageName)) { $params = Zend_Registry::get('params'); $imageToDisplay = $params->cms->imageDisplayPath . $imageName; } else { $imageToDisplay = $this->getRequest()->getParam('articleIcon'); } $tagString = $this->getRequest()->getParam('tagString'); } } else { //Load form if (empty($blogEntryID)) { //Layout new $upsertType = 'Add'; $title = ''; $summary = ''; $article = ''; $status = 3; //Pool blog entry $imageToDisplay = ''; $imageName = ''; $tagString = ''; } else { //Layout from database $upsertType = 'Edit'; $blogEntry = $blogEntries->getByID($blogEntryID); $title = $blogEntry['title']; $summary = $blogEntry['summary']; $article = $blogEntry['article']; $status = $blogEntry['status']; if (!empty($blogEntry['imageName'])) { $params = Zend_Registry::get('params'); $imageToDisplay = $params->cms->imageDisplayPath . $blogEntry['imageName']; $imageName = $blogEntry['imageName']; } else { $imageToDisplay = ''; $imageName = ''; } $tagString = $blogEntry['tagString']; } } //Load the possible blog tags from the database in a comma-separated string. $this->view->blogTags = $blogEntries->getPossibleTags(); $this->view->upsertType = $upsertType; $this->view->id = $blogEntryID; $this->view->title = $title; $this->view->summary = $summary; $this->view->article = $article; $this->view->status = $status; $this->view->imageToDisplay = $imageToDisplay; $this->view->imageName = $imageName; $this->view->tagString = $tagString; }