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));
     }
 }
 public function findallAction()
 {
     $option_values = $this->getApplication()->getPages(10);
     $data = array('pages' => array());
     $color = $this->getApplication()->getBlock('tabbar')->getImageColor();
     $background_color = $this->getApplication()->getBlock('tabbar')->getBackgroundColor();
     foreach ($option_values as $option_value) {
         $data['pages'][] = array('value_id' => $option_value->getId(), 'id' => intval($option_value->getId()), 'code' => $option_value->getCode(), 'name' => $option_value->getTabbarName(), 'is_active' => $option_value->isActive(), 'url' => $option_value->getUrl(null, array('value_id' => $option_value->getId()), false), 'path' => $option_value->getPath(null, array('value_id' => $option_value->getId()), false), 'icon_url' => $this->_getColorizedImage($option_value->getIconId(), $color), 'icon_is_colorable' => $option_value->getImage()->getCanBeColorized(), 'is_locked' => $option_value->isLocked(), 'is_link' => !$option_value->getIsAjax(), 'position' => $option_value->getPosition());
     }
     $option = new Application_Model_Option();
     $option->findTabbarMore();
     $data['more_items'] = array('code' => $option->getCode(), 'name' => $option->getTabbarName(), 'is_active' => $option->isActive(), 'url' => "", 'icon_url' => $this->_getColorizedImage($option->getIconUrl(), $color), 'icon_is_colorable' => 1);
     $option = new Application_Model_Option();
     $option->findTabbarAccount();
     $data['customer_account'] = array('code' => $option->getCode(), 'name' => $option->getTabbarName(), 'is_active' => $option->isActive(), 'url' => $this->getUrl("customer/mobile_account_login"), 'path' => $this->getPath("customer/mobile_account_login"), 'login_url' => $this->getUrl("customer/mobile_account_login"), 'login_path' => $this->getPath("customer/mobile_account_login"), 'edit_url' => $this->getUrl("customer/mobile_account_edit"), 'edit_path' => $this->getPath("customer/mobile_account_edit"), 'icon_url' => $this->_getColorizedImage($option->getIconUrl(), $color), 'icon_is_colorable' => 1, 'is_visible' => $this->getApplication()->usesUserAccount());
     $layout = new Application_Model_Layout_Homepage();
     $layout->find($this->getApplication()->getLayoutId());
     $data['layout'] = array("layout_id" => "l{$this->getApplication()->getLayoutId()}", "visibility" => $this->getApplication()->getLayoutVisibility(), "use_horizontal_scroll" => (int) $layout->getUseHorizontalScroll(), "position" => $layout->getPosition());
     $data['limit_to'] = $this->getApplication()->getLayout()->getNumberOfDisplayedIcons();
     $data['layout_id'] = 'l' . $this->getApplication()->getLayoutId();
     $data['tabbar_is_transparent'] = $background_color == "transparent";
     $data['homepage_slider_is_visible'] = (bool) $this->getApplication()->getHomepageSliderIsVisible();
     $data['homepage_slider_duration'] = $this->getApplication()->getHomepageSliderDuration();
     $data['homepage_slider_loop_at_beginning'] = (bool) $this->getApplication()->getHomepageSliderLoopAtBeginning();
     $homepage_slider_images = array();
     $slider_images = $this->getApplication()->getSliderImages();
     foreach ($slider_images as $slider_image) {
         $homepage_slider_images[] = $slider_image->getLink();
     }
     $data['homepage_slider_images'] = $homepage_slider_images;
     $this->_sendHtml($data);
 }
<?php

$this->query("\n    ALTER TABLE `application_layout_homepage`\n        ADD `number_of_displayed_icons` tinyint(2) NULL DEFAULT NULL AFTER `use_more_button`\n    ;\n");
$layout = new Application_Model_Layout_Homepage();
$layout->find(1);
$layout->setNumberOfDisplayedIcons(5)->save();
$layout = new Application_Model_Layout_Homepage();
$layout->find(2);
$layout->setNumberOfDisplayedIcons(10)->save();