public function validate(SxModule_News $object) { $this->validateTextRequired($object->getTitle(), 'title', 'content'); //$this->validateTextRequired($object->getSummary(), 'summary', 'content', $this->_namespace); $this->validateTextareaRequired($object->getContent(), 'content', 'content'); $msgr = Sanmax_MessageStack::getInstance($this->_namespace); if (!$msgr->getNamespaceMessages()) { return true; } return false; }
public function toArray(SxModule_News $item, $type = '*') { $identity = Zend_Auth::getInstance()->getIdentity(); $data = array('nid' => $item->getId(), 'author_id' => $identity->getId(), 'date_created' => $item->getDateCreated(), 'date_published' => $item->getDatePublished(), 'date_expired' => $item->getDateExpired(), 'date_message' => $item->getDateByMessage(), 'picture' => $item->getPicture()); $tsl = array('lng' => $item->getLng(), 'title' => $item->getTitle(), 'summary' => $item->getSummary(), 'content' => $item->getContent(), 'url' => $item->_createUrl(), 'seo_keywords' => $item->getSeoKeywords(), 'seo_title' => $item->getSeoTitle(), 'seo_description' => $item->getSeoDescription(), 'active' => (int) $item->getActive()); if ($type == 'item') { return $data; } elseif ($type == 'tsl') { return $tsl; } return array_merge($data, $tsl); }
public function addAction() { SxCms_Acl::requireAcl('news', 'news.add'); $item = new SxModule_News(); if ($this->getRequest()->isPost()) { $mapper = new SxModule_News_Mapper(); $fields = $mapper->fromInput($this->_getAllParams(), $this->_editablefields()); $data = $mapper->toObject($fields); if ($this->_getParam('date_by_message') != '') { $dateByMessage = $this->_getParam('date_by_message') . ' ' . $this->_getParam('message_h') . ':' . $this->_getParam('message_i') . ':00'; } else { $dateByMessage = '0000-00-00 00:00:00'; } $datePublished = $this->_getParam('date_published') . ' ' . $this->_getParam('publish_h') . ':' . $this->_getParam('publish_i') . ':00'; $dateExpired = null; if ($this->_getParam('date_expired')) { $dateExpired = $this->_getParam('date_expired') . ' ' . $this->_getParam('expire_h') . ':' . $this->_getParam('expire_i') . ':00'; } $data->setDatePublished($datePublished)->setDateExpired($dateExpired)->setDateByMessage($dateByMessage)->setId((int) $item->getId())->setActive($this->_getParam('active', 0) == 1 ? 1 : 0); $validator = new SxModule_News_Validator(); if ($validator->validate($data)) { $this->_imageResizeAndSave($data); $data->save(); $cache = Zend_Registry::get('cache'); $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('SxModule_News')); $flashMessenger = $this->_helper->getHelper('FlashMessenger'); $flashMessenger->addMessage($this->admin_tmx->_('newscreated')); $this->_helper->redirector->gotoSimple('index', 'news'); } $item = $data; } $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_News'); $this->view->item = $item; }