/**
  * Returns an array of blog entries associated with the tag string passed in.
  * 
  * @param string $tagName
  * The name of the tag against which this method will try to find
  * associated blog entries.
  * 
  * @return mixed
  * Returns an array of blog entries associated with the tag name
  * passed in, or null if there are no associated blog entries.
  */
 public function getBlogEntriesByTagName($tagName)
 {
     $blogEntryTags = new Datasource_Cms_Connect_BlogEntryTags();
     $tagId = $blogEntryTags->getID($tagName);
     //Now get all the blog entries associated with that tag id.
     $blogEntryTagMap = new Datasource_Cms_Connect_BlogEntryTagMap();
     $blogEntryDetails = $blogEntryTagMap->getByTagId($tagId);
     $returnArray = array();
     if (!empty($blogEntryDetails)) {
         $blogEntries = new Datasource_Cms_Connect_BlogEntries();
         foreach ($blogEntryDetails as $currentBlogEntry) {
             $returnArray[] = $blogEntries->getByID($currentBlogEntry->blog_entry_id);
         }
     }
     //Provide a return value consistent with this function's contract.
     if (empty($returnArray)) {
         $returnVal = null;
     } else {
         $returnVal = $returnArray;
     }
     return $returnVal;
 }
 /**
  * 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;
 }