/**
  * Retrieve a collection of splash pages that belong to this group
  *
  * @param Fishpig_AttributeSplash_Model_Group $group
  * @return Fishpig_AttributeSplash_Model_Resource_Page_Collection
  */
 public function getSplashPages(Fishpig_AttributeSplash_Model_Group $group)
 {
     $pages = Mage::getResourceModel('attributeSplash/page_collection')->addIsEnabledFilter();
     if ($group->getStoreId() > 0) {
         $pages->addStoreFilter($group->getStoreId());
     } else {
         if (($storeId = Mage::app()->getStore()->getId()) > 0) {
             $pages->addStoreFilter($storeId);
         }
     }
     return $pages->addAttributeIdFilter($group->getAttributeId());
 }
 /**
  * Apply custom layout handles to the splash page
  *
  * @param Fishpig_AttribtueSplash_Model_Page $splashPage
  * @return Fishpig_AttribtueSplash_PageController
  */
 protected function _applyCustomViewLayout(Fishpig_AttributeSplash_Model_Group $splashGroup)
 {
     $update = $this->getLayout()->getUpdate();
     $update->addHandle('default');
     $this->addActionLayoutHandles();
     $update->addHandle('attributesplash_group_view_' . $splashGroup->getId());
     $update->addHandle('attributesplash_group_view_' . $splashGroup->getAttributeCode());
     $this->loadLayoutUpdates();
     $update->addUpdate($splashGroup->getLayoutUpdateXml());
     $this->generateLayoutXml()->generateLayoutBlocks();
     if ($splashGroup->getPageLayout()) {
         $this->getLayout()->helper('page/layout')->applyTemplate($splashGroup->getPageLayout());
     } else {
         if ($pageLayout = Mage::getStoreConfig('attributeSplash/group/template')) {
             $this->getLayout()->helper('page/layout')->applyTemplate($pageLayout);
         }
     }
     $this->_isLayoutLoaded = true;
     return $this;
 }
 /**
  * Determine whether the group can be deleted
  *
  * @param Fishpig_AttributeSplash_Model_Group $group
  * @return bool
  */
 public function canDelete(Fishpig_AttributeSplash_Model_Group $group)
 {
     if (!$group->isGlobal()) {
         return true;
     }
     $select = $this->_getReadAdapter()->select()->from(array('main_table' => $this->getTable('eav/attribute_option')), 'option_id')->join(array('_splash' => $this->getTable('attributeSplash/page')), '_splash.option_id = main_table.option_id')->where('main_table.attribute_id=?', $group->getAttributeModel()->getId())->limit(1);
     return $this->_getReadAdapter()->fetchOne($select) === false;
 }