public function changelayoutvisibilityAction() { if ($datas = $this->getRequest()->getPost()) { try { if (empty($datas['layout_id'])) { throw new Exception($this->_('An error occurred while changing your layout.')); } $layout = new Application_Model_Layout_Homepage(); $layout->find($datas['layout_id']); if (!$layout->getId()) { throw new Exception($this->_('An error occurred while changing your layout.')); } $html = array(); if ($layout->getId() == $this->getApplication()->getLayoutId()) { $html["success"] = 1; $visibility = $layout->getVisibility(); if ($layout->getVisibility() == Application_Model_Layout_Homepage::VISIBILITY_ALWAYS) { $visibility = !empty($datas["layout_is_visible_in_all_the_pages"]) ? Application_Model_Layout_Homepage::VISIBILITY_ALWAYS : Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE; } $this->getApplication()->setLayoutId($datas['layout_id'])->setLayoutVisibility($visibility)->save(); $html['reload'] = 1; $html["display_layout_options"] = $layout->getVisibility() == Application_Model_Layout_Homepage::VISIBILITY_ALWAYS; $html["layout_id"] = $layout->getId(); $html["layout_visibility"] = $this->getApplication()->getLayoutVisibility(); } } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function changelayoutAction() { if ($datas = $this->getRequest()->getPost()) { try { $html = array(); if (empty($datas['layout_id'])) { throw new Exception($this->_('An error occurred while changing your layout.')); } $layout = new Application_Model_Layout_Homepage(); $layout->find($datas['layout_id']); if (!$layout->getId()) { throw new Exception($this->_('An error occurred while changing your layout.')); } $html = array('success' => 1); if ($layout->getId() != $this->getApplication()->getLayoutId()) { $this->getApplication()->setLayoutId($datas['layout_id'])->save(); $html['reload'] = 1; } } catch (Exception $e) { // $html = array('message' => 'Une erreur est survenue lors de la sauvegarde, merci de réessayer ultérieurement'); $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
<?php $layout = new Application_Model_Layout_Homepage(); $layouts = $layout->findAll(); foreach ($layouts as $key => $layout) { ++$key; $layout->setCode("layout_" . $key)->setName("Layout " . $key)->save(); } $layout = new Application_Model_Layout_Homepage(); $layout->setData(array('code' => 'layout_9', 'name' => 'Layout 9', 'preview' => '/customization/layout/homepage/layout_9.png', 'use_more_button' => 0, 'position' => 80))->save(); $this->query("\n ALTER TABLE `application_layout_homepage`\n ADD `visibility` VARCHAR(10) NOT NULL DEFAULT 'homepage' AFTER `layout_id`,\n ADD position VARCHAR(10) NOT NULL DEFAULT 'bottom' AFTER `number_of_displayed_icons`\n ;\n"); $this->query("\n ALTER TABLE `application`\n ADD `layout_visibility` VARCHAR(10) NOT NULL DEFAULT 'homepage' AFTER `layout_id`;\n"); $layout = new Application_Model_Layout_Homepage(); $layouts = $layout->findAll(); foreach ($layouts as $key => $layout) { switch ($layout->getId()) { case 1: $layout->setVisibility(Application_Model_Layout_Homepage::VISIBILITY_ALWAYS)->setPosition("bottom"); break; case 7: $layout->setPosition("left"); break; case 9: $layout->setVisibility(Application_Model_Layout_Homepage::VISIBILITY_TOGGLE)->setPosition("left"); break; default: $layout->setVisibility(Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE)->setPosition("bottom"); break; } $layout->save(); }