public function getAll($lng = "nl", $paginator = true, $pindex = 1, $perpage = 25, $cache = false) { if ($cache == true) { $cacheId = 'SxModule_Pageform_getAll_' . sha1(var_export($paginator, true) . '_' . var_export($pindex, true) . '_' . var_export($perpage, true)); $cache = Zend_Registry::get('cache'); if (true == ($result = $cache->load($cacheId))) { return $result; } } $db = Zend_Registry::get('db'); $select = $db->select()->from(array('i' => $this->_tablename()), array('*'))->join(array('pft' => 'pageform_tsl'), 'pft.pageform_id = i.pf_id', array('*'))->where('pft.language = ?', $lng); if ($paginator === true) { $adapter = new Base_PaginatorAdapter($select); $adapter->setMapper($this->_mapper); $data = new Zend_Paginator($adapter); $data->setCurrentPageNumber((int) $pindex); $data->setItemCountPerPage((int) $perpage); } else { $results = $db->fetchAll($select); $data = $this->_mapper->mapAll($results); } $pageform_ids = array(); foreach ($data as $pageform) { $pageform_ids[] = $pageform->getId(); } if (count($pageform_ids) != 0) { $pagesProxy = new SxCms_Page_Pageform_Proxy(); $pages = $pagesProxy->getByPageformIds($pageform_ids, false); foreach ($data as $pageform) { foreach ($pages as $page) { if ($page->getPageformId() == $pageform->getId()) { $pageform->addPage($page->getPageid()); } } } } if ($cache == true) { $cacheTags = array('SxModule_Pageform', 'SxModule_Pageform_getAll'); $cache->save($data, $cacheId, $cacheTags); } return $data; }
public function getPageform() { $pageformproxy = new SxCms_Page_Pageform_Proxy(); $pageform = $pageformproxy->getById($this->getId(), false); return $pageform->getPageformid(); }
public function deleteAction() { if ($this->_getParam('id') != 1) { $system = new Zend_Session_Namespace('System'); SxCms_Acl::requireAcl('pageform', 'pageform.delete'); $this->_helper->viewRenderer->setNoRender(true); $this->_helper->layout->disableLayout(); $pageformProxy = new SxModule_Pageform_Proxy(); $config = Zend_Registry::get('config'); $i = 0; foreach ($config->system->language as $lng => $slng) { $i++; $pageform = $pageformProxy->getById((int) $this->_getParam('id'), $lng); foreach ($pageform->getTsl() as $tsl) { $tsl->delete(); } foreach ($pageform->getField() as $field) { $tsl = $field->getTsl(); $tsl->delete(); foreach ($field->getMeta() as $meta) { $meta->getTsl()->delete(); } } if ($i == count($config->system->language)) { foreach ($pageform->getField() as $field) { foreach ($field->getMeta() as $meta) { $meta->delete(); } $field->delete(); } } } $pagepageformproxy = new SxCms_Page_Pageform_Proxy(); $pagepageform = $pagepageformproxy->getByPageformId((int) $this->_getParam('id')); foreach ($pagepageform as $page) { $page->delete(); } $pageform->delete(); $cache = Zend_Registry::get('cache'); $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('SxModule_Pageform_Id' . $pageform->getId(), 'SxModule_Pageform_getAll', 'SxModule_Pageform_Field', 'SxModule_Pageform_Field_Tsl', 'SxModule_Pageform_Field_Meta', 'SxModule_Pageform_Field_Meta_Tsl', 'SxModule_Pageform_Status', 'SxModule_Pageform_Forward')); $flashMessenger = $this->_helper->getHelper('FlashMessenger'); $flashMessenger->addMessage($this->admin_tmx->_('itemdeleted')); $this->_helper->redirector->gotoSimple('index', 'pageform'); } }