Exemplo n.º 1
0
 public function fseoLayeredNavigationMatchEntityObserver(Varien_Event_Observer $observer)
 {
     if (!Mage::helper('fseo/layer')->isEntityTypeEnabled('attributeSplash_page')) {
         return $this;
     }
     $doubleBarrel = Mage::getStoreConfigFlag('attributeSplash/page/include_group_url_key');
     $urlKey = $observer->getEvent()->getRequestUri();
     $urlSuffix = Fishpig_AttributeSplash_Model_Page::getUrlSuffix();
     if ($urlSuffix && $urlSuffix !== '/') {
         if (substr($urlKey, -strlen($urlSuffix)) !== $urlSuffix) {
             return false;
         }
         $urlKey = substr($urlKey, 0, -strlen($urlSuffix));
     }
     $expectedSlashCount = 1 + (int) $doubleBarrel;
     if (substr_count($urlKey, '/') < $expectedSlashCount) {
         return false;
     }
     if ($doubleBarrel) {
         $baseUrlKey = substr($urlKey, 0, strpos($urlKey, '/', strpos($urlKey, '/') + 1));
         list($groupUrlKey, $pageUrlKey) = explode('/', $baseUrlKey);
     } else {
         $baseUrlKey = substr($urlKey, 0, strpos($urlKey, '/'));
         $groupUrlKey = null;
         $pageUrlKey = null;
     }
     $splashIds = Mage::getResourceModel('attributeSplash/page')->getPageAndGroupIdByUrlKeys($pageUrlKey, $groupUrlKey);
     if (!$splashIds) {
         return false;
     }
     list($pageId, $groupId) = array_values($splashIds);
     $tokens = explode('/', trim(substr($urlKey, strlen($baseUrlKey)), '/'));
     $observer->getEvent()->getTransport()->setEntityData(new Varien_Object(array('entity_id' => $pageId, 'entity_type' => 'attributeSplash_page', 'entity_url_key' => $baseUrlKey, 'url_suffix' => $urlSuffix, 'tokens' => $tokens, 'module_name' => 'splash', 'controller_name' => 'page', 'action_name' => 'view', 'params' => array('id' => $pageId, 'group_id' => $groupId))));
     Mage::helper('attributeSplash')->clearLayerRewrites();
     return $this;
 }
 /**
  * Apply custom layout handles to the splash page
  *
  * @param Fishpig_AttribtueSplash_Model_Page $splashPage
  * @return Fishpig_AttribtueSplash_PageController
  */
 protected function _applyCustomViewLayout(Fishpig_AttributeSplash_Model_Page $splashPage)
 {
     $update = $this->getLayout()->getUpdate();
     $update->addHandle('default');
     $this->addActionLayoutHandles();
     $update->addHandle('attributesplash_page_view_' . $splashPage->getId());
     $update->addHandle('attributesplash_page_view_' . $splashPage->getAttributeModel()->getAttributeCode());
     $this->loadLayoutUpdates();
     $update->addUpdate($splashPage->getLayoutUpdateXml());
     $this->generateLayoutXml()->generateLayoutBlocks();
     if ($splashPage->getPageLayout()) {
         $this->getLayout()->helper('page/layout')->applyTemplate($splashPage->getPageLayout());
     } else {
         if ($pageLayout = Mage::getStoreConfig('attributeSplash/page/template')) {
             $this->getLayout()->helper('page/layout')->applyTemplate($pageLayout);
         }
     }
     $this->_isLayoutLoaded = true;
     return $this;
 }
 protected function _handleImageUpload(Fishpig_AttributeSplash_Model_Page $page, $field)
 {
     $data = $page->getData($field);
     if (isset($data['value'])) {
         $page->setData($field, $data['value']);
     }
     if (isset($data['delete']) && $data['delete'] == '1') {
         $page->setData($field, '');
     }
     if ($filename = Mage::helper('attributeSplash/image')->uploadImage($field)) {
         $page->setData($field, $filename);
     }
 }
 /**
  * Retrieve the group associated with the splash page
  * This will retrieve the most related group
  * If there isn't a group for the same store, the admin group will be returned
  *
  * @param Fishpig_AttributeSplash_Model_Page $page
  * @return Fishpig_AttributeSplash_Model_Group|false
  */
 public function getSplashGroup(Fishpig_AttributeSplash_Model_Page $page)
 {
     $groups = Mage::getResourceModel('attributeSplash/group_collection')->addAttributeIdFilter($page->getAttributeModel()->getAttributeId())->addStoreFilter($page->getStoreId())->setCurPage(1)->setPageSize(1)->load();
     return count($groups) > 0 ? $groups->getFirstItem() : false;
 }
Exemplo n.º 5
0
 /**
  * Initialize the image object
  * This sets up the image object for resizing and caching
  *
  * @param Fishpig_AttributeSplash_Model_Page $page
  * @param string $attribute
  * @return Fishpig_AttributeSplash_Helper_Image
  */
 public function init(Fishpig_AttributeSplash_Model_Page $page, $attribute = 'image')
 {
     $this->_imageObject = null;
     $this->_forceRecreate = false;
     $this->_filename = null;
     $this->_settings = array();
     if ($imagePath = $this->getImagePath($page->getData($attribute))) {
         $this->_imageObject = new Varien_Image($imagePath);
         $this->_filename = basename($imagePath);
         $this->constrainOnly(true);
         $this->keepTransparency(true);
         $this->keepAspectRatio(true);
     }
     return $this;
 }