public function headerQuotes($tags = '', $includeGlobal = true)
 {
     if (!$tags) {
         $tags = '';
     }
     $quotes = new Datasource_Cms_HeaderQuotes();
     $quotesArray = $quotes->getByTags($tags, $includeGlobal);
     return $this->view->partialLoop('templates/partials/header-quote.phtml', $quotesArray);
 }
 /**
  * Save a new testimonial, or changes to an existing testimonial. If it's a new entry the function will return the ID for the record
  *
  * @return int
  */
 protected function _saveQuote()
 {
     $requiredText = new Zend_Validate();
     $requiredText->addValidator(new Zend_Validate_NotEmpty());
     $tagFilter = new Zend_Filter();
     $tagFilter->addFilter(new Zend_Filter_StringTrim());
     $tagFilter->addFilter(new Zend_Filter_StringTrim(','));
     $filters = array('id' => 'Digits', 'title' => 'StringTrim', 'subtitle' => 'StringTrim', 'tags' => $tagFilter);
     $validators = array('id' => array('allowEmpty' => true), 'title' => $requiredText, 'subtitle' => array('allowEmpty' => true), 'tags' => $requiredText);
     $input = new Zend_Filter_Input($filters, $validators, $_POST);
     if ($input->isValid()) {
         $quote = new Datasource_Cms_HeaderQuotes();
         // Data is all valid, formatted and sanitized so we can save it in the database
         if (!$input->id) {
             // This is a new quote so we need to create a new ID
             $quoteID = $quote->addNew($input->getUnescaped('title'), $input->subtitle, $input->tags);
         } else {
             // This is an existing article so we can just update the data
             $quote->saveChanges($input->id, $input->getUnescaped('title'), $input->subtitle, $input->tags);
             $quoteID = $input->id;
         }
         // Changes saved - so send them back with a nice success message
         $this->_helper->getHelper('FlashMessenger')->addMessage(array('saved' => true));
         $this->_helper->getHelper('Redirector')->goToUrl('/cms-admin/header-quotes/edit?id=' . $quoteID);
     } else {
         // Invalid data in form
         /*
         print_r($_POST);
         print_r($input->getErrors());
         print_r($input->getInvalid());
         */
     }
 }
 /**
  * Edit an existing site page
  *
  * @return void
  */
 public function editAction()
 {
     $this->view->currentPage = 'pages';
     $siteID = $this->getRequest()->getParam('site');
     if ($siteID == '') {
         $siteID = 1;
     }
     if ($this->getRequest()->isPost()) {
         // Save changes
         $this->_savePage($siteID);
     } else {
         // Edit page
         $pageID = $this->getRequest()->getParam('id');
         $page = new Datasource_Cms_Pages();
         $pageEdit = $page->getByID($pageID);
         $passThrough = $this->_helper->getHelper('FlashMessenger')->getMessages();
         if (count($passThrough) > 0) {
             if (isset($passThrough[0]['saved'])) {
                 if ($passThrough[0]['saved'] == true) {
                     $this->view->saved = true;
                 }
             }
             if (isset($passThrough[0]['errorMessage'])) {
                 $this->view->errorMessage = $passThrough[0]['errorMessage'];
             }
         }
         $this->view->pageContent = $pageEdit['pageContent'];
         $this->view->pageTitle = $pageEdit['pageTitle'];
         $this->view->pageURL = $pageEdit['url'];
         $this->view->pageID = $pageID;
         $this->view->metaKeywords = $pageEdit['keywords'];
         $this->view->metaDescription = $pageEdit['description'];
         $this->view->urlEditable = $pageEdit['urlEditable'] == 1 ? true : false;
         $meta = $page->getMeta($pageID);
         $metaFieldData = $page->getMetaFields($pageID);
         foreach ($metaFieldData as &$metaRow) {
             if (isset($meta[$metaRow['metaName']])) {
                 $metaRow['value'] = $meta[$metaRow['metaName']];
             }
         }
         $metaFieldList = $this->view->partialLoop('partials/edit-page-metafield.phtml', $metaFieldData);
         $this->view->metaFields = $metaFieldList;
         // Load the possible testimonial tags from the database
         $testimonials = new Datasource_Cms_Testimonials();
         $this->view->testimonialTags = $testimonials->getPossibleTags();
         // Load the possible header quote tags from the database
         $quotes = new Datasource_Cms_HeaderQuotes();
         $this->view->quoteTags = $quotes->getPossibleTags();
         $templates = new Datasource_Cms_Page_Template();
         $templateArray = $templates->getAll($siteID);
         foreach ($templateArray as &$template) {
             $template['current'] = $template['id'] == $pageEdit['layoutID'] ? true : false;
         }
         $templateList = $this->view->partialLoop('partials/edit-page-templatefield.phtml', $templateArray);
         $this->view->templateFields = $templateList;
     }
 }