コード例 #1
0
 protected function _construct()
 {
     parent::_construct();
     if ($this->getCmsmode()) {
         AW_Collpur_Helper_Deals::setActiveMenus($this->getCmsmode());
     }
     $this->setTemplate('aw_collpur/deals/list.phtml');
     $this->setAvailableDealsScope($this->getAvailableDeals());
 }
コード例 #2
0
ファイル: Router.php プロジェクト: bigtailbear14/rosstheme
 private function _combineRequest($request)
 {
     $identifier = $request->getPathInfo();
     /*
      *  Immidiate return if
      *  It's not a deal module      
      */
     if (!preg_match("#(^/)*deals/#is", $identifier)) {
         return false;
     }
     if (!AW_Collpur_Model_Source_Menus::getFirstAvailable() && $identifier == '/deals/') {
         /* No deals available and we redirect to the empty page and only if user clicks deals link i.e goes to the route page
          * otherwise redirect to 404             
          */
         $request->setModuleName('deals')->setControllerName('index')->setActionName('empty');
         return true;
     }
     /* As a default start page assumed to be featured deal, but if it's unavailable,
      * there is no choice but redirect to the first available list section
      */
     if ($identifier == '/deals/' || preg_match("#/deals/" . AW_Collpur_Helper_Deals::FEATURED . "#is", $identifier)) {
         if (AW_Collpur_Model_Source_Menus::isNotAllowed(AW_Collpur_Helper_Deals::FEATURED) || !Mage::getModel('collpur/deal')->getRandomFeaturedId()) {
             $startPage = AW_Collpur_Model_Source_Menus::getFirstAvailable();
             $request->setModuleName('deals')->setControllerName('index')->setActionName('list')->setParam('section', $startPage);
             return true;
         }
         $request->setModuleName('deals')->setControllerName('index')->setActionName('view')->setParam('id', Mage::getModel('collpur/deal')->getRandomFeaturedId())->setParam('mode', AW_Collpur_Helper_Deals::FEATURED);
         return true;
     }
     /* Handle list category  mode */
     $key = preg_replace("#(/|deals/|\\..+)#is", "", $identifier);
     /* Clearing $key */
     if (in_array($key, AW_Collpur_Helper_Deals::getSectionsKeys())) {
         $request->setModuleName('deals')->setControllerName('index')->setActionName('list')->setParam('section', $key);
         return true;
     }
     /* Default handle for deal view */
     if ($dealId = $this->_rewriteResource->loadByKey($key, Mage::app()->getStore()->getId())) {
         $deal = Mage::getModel('collpur/deal')->load($dealId);
         if ($deal->isAllowed() && !$deal->isArchived() && $deal->getId()) {
             $request->setModuleName('deals')->setControllerName('index')->setActionName('view')->setParam('id', $dealId);
             return true;
         }
     }
 }
コード例 #3
0
ファイル: Observer.php プロジェクト: bigtailbear14/rosstheme
 /**
  *  @test
  *  Simple coverage just to make sure function is present
  *
  */
 public function testProcessMenu()
 {
     $menus = new Varien_Object(array(1, 2, 3));
     $event = new Varien_Object();
     $event->setMenu($menus);
     AW_Collpur_Helper_Deals::$menus = array(1, 2, 3);
     Mage::getModel('collpur/observer')->processMenu($event);
 }
コード例 #4
0
ファイル: Deals.php プロジェクト: bigtailbear14/rosstheme
 /**
  * @test
  */
 public function testGetSectionsKeys()
 {
     if (!is_array(AW_Collpur_Helper_Deals::getSectionsKeys())) {
         $this->fail('getSectionsAssoc function is supposed to be an array of values');
     }
 }
コード例 #5
0
 public function _modifyCrumbs($layout, $bridge = false, $deal = false, $mode = 'product')
 {
     $sections = AW_Collpur_Helper_Deals::getSectionsAssoc();
     if ($mode == 'category') {
         $currentSection = Mage::app()->getRequest()->getParam('section');
         $layout->getBlock('breadcrumbs')->addCrumb('home', array('label' => 'Home', 'title' => 'Home', 'link' => Mage::getBaseUrl()));
         if (array_key_exists($currentSection, $sections)) {
             $layout->getBlock('breadcrumbs')->addCrumb('category', array('label' => $this->__($sections[$currentSection]), 'title' => $this->__($sections[$currentSection])));
             $layout->getBlock('head')->setTitle($this->__($sections[$currentSection]));
         }
         return;
     }
     $deal = $this->getDealInstance($deal->getId());
     if (!$deal->getId()) {
         return;
     }
     $disallowActive = false;
     if ($deal->isNotRunning()) {
         $categoryCrumb = AW_Collpur_Helper_Deals::NOT_RUNNING;
         $categoryLabel = $this->__($sections[AW_Collpur_Helper_Deals::NOT_RUNNING]);
     } else {
         if ($deal->isRunning()) {
             $categoryCrumb = AW_Collpur_Helper_Deals::RUNNING;
             $categoryLabel = $this->__($sections[AW_Collpur_Helper_Deals::RUNNING]);
             $data = AW_Collpur_Model_Source_Menus::getMenusArray(false);
             foreach ($data as $info) {
                 if ($info['key'] == AW_Collpur_Helper_Deals::RUNNING) {
                     if (!Mage::getStoreConfig("collpur/{$info['alias']}/enabled")) {
                         $disallowActive = true;
                         break;
                     }
                     $disallowActive = false;
                     break;
                 }
                 $disallowActive = false;
             }
         } else {
             if ($deal->isClosed()) {
                 $categoryCrumb = AW_Collpur_Helper_Deals::CLOSED;
                 $categoryLabel = $this->__($sections[AW_Collpur_Helper_Deals::CLOSED]);
             }
         }
     }
     $layout->getBlock('breadcrumbs')->addCrumb('home', array('label' => 'Home', 'title' => 'Home', 'link' => Mage::getBaseUrl()));
     if (!$disallowActive) {
         $layout->getBlock('breadcrumbs')->addCrumb('category', array('label' => $categoryLabel, 'title' => $categoryLabel, 'link' => $this->getDealTabUrl($categoryCrumb)));
     }
     $layout->getBlock('breadcrumbs')->addCrumb('product', array('label' => $this->processDealName($deal)));
 }