/** * @param Mage_Core_Block_Abstract $target * @param string[] $handlers * @param array $params * @return mixed */ public function raise($target, $handlers, $params = array()) { if (!empty($handlers)) { $event = new Varien_Object(array_merge($params, array('target' => $target, 'result' => false, 'stop_event_handling' => false))); foreach ($handlers as $handler) { $handler = explode('::', $handler); if ($object = $target->getLayout()->getBlock($handler[0])) { $method = $handler[1]; $event->setResult($object->{$method}($event)); if ($event->getStopEventHandling()) { break; } } } return $event->getResult(); } else { return false; } }
/** * This method will dispatch the events 'magehost_clean_backend_cache_before' * and 'magehost_clean_backend_cache_after'. * Event listeners can change the mode or tags. * * {@inheritdoc} */ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { $transportObject = new Varien_Object(); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setMode($mode); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setTags($tags); Mage::dispatchEvent('jv_clean_backend_cache', array('transport' => $transportObject)); // deprecated Mage::dispatchEvent('magehost_clean_backend_cache_before', array('transport' => $transportObject)); /** @noinspection PhpUndefinedMethodInspection */ $mode = $transportObject->getMode(); /** @noinspection PhpUndefinedMethodInspection */ $tags = $transportObject->getTags(); $result = parent::clean($mode, $tags); $transportObject->setResult($result); Mage::dispatchEvent('magehost_clean_backend_cache_after', array('transport' => $transportObject)); $result = $transportObject->getResult(); return $result; }
public function renderHtml($block, $part, $data = array()) { $result = new Varien_Object(); switch ($part) { case 'groups': $result->setResult($this->getNoGroups($block->getFilters())); break; case 'name_attributes': echo ' data-id="' . $this->getFilterLayoutName($block, $data['filter']->getFilterOptions()) . '"'; break; case 'group_attributes': echo ' data-id="' . $block->getShowInFilter() . '-' . $data['group']->getId() . '"'; break; case 'menu_visible': $result->setResult(false); break; case 'currently_shopping_by': $result->setResult(true); break; case 'name_action': case 'group_action': $result->setResult(array()); break; } Mage::dispatchEvent('m_advanced_filter_' . $part, array_merge($data, compact('block', 'result'))); return $result->getResult(); }
/** * This method will dispatch the events 'magehost_clean_backend_cache_before' * and 'magehost_clean_backend_cache_after'. * Event listeners can change the mode or tags. * This method will return false when clean failed. * * {@inheritdoc} */ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { $result = false; $transportObject = new Varien_Object(); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setMode($mode); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setTags($tags); Mage::dispatchEvent('jv_clean_backend_cache', array('transport' => $transportObject)); // deprecated Mage::dispatchEvent('magehost_clean_backend_cache_before', array('transport' => $transportObject)); /** @noinspection PhpUndefinedMethodInspection */ $mode = $transportObject->getMode(); /** @noinspection PhpUndefinedMethodInspection */ $tags = $transportObject->getTags(); if ($this->works) { try { $result = parent::clean($mode, $tags); } catch (CredisException $e) { $this->processRedisException($e, 'remove'); $result = false; } catch (RedisException $e) { $this->processRedisException($e, 'remove'); $result = false; } catch (Zend_Cache_Exception $e) { $this->processRedisException($e, 'remove'); $result = false; } } $transportObject->setResult($result); Mage::dispatchEvent('magehost_clean_backend_cache_after', array('transport' => $transportObject)); $result = $transportObject->getResult(); return $result; }
public function renderDates($options, $item = null, $product = null, $isCart = false) { $isSingle = true; $nonSequential = 0; if ($item && $item->getOrder() && !$isCart) { $isSingleBool = ITwebexperts_Payperrentals_Helper_Data::isSingleOrder($item->getOrder()); $isSingle = $isSingleBool['bool']; } else { if ($item && $item->getQuote() && !$isCart) { $isSingle = false; } } $productId = -1; $storeId = 1; $qty = 0; if (!is_null($item) && !is_null($item->getProductId())) { $productId = $item->getProductId(); $storeId = $item->getStoreId(); $qty = $item->getQty(); $product = $item->getProduct(); } else { if (!is_null($product) && is_object($product)) { $productId = $product->getId(); } elseif (isset($options['info_buyRequest']['product'])) { $productId = $options['info_buyRequest']['product']; } } $showTime = (bool) Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'payperrentals_use_times', $storeId); $customerGroup = ITwebexperts_Payperrentals_Helper_Data::getCustomerGroup(); $source = $this->_getOptionsArray($product, $options); $options = array(); $isBuyout = isset($source['buyout']) ? $source['buyout'] : 'false'; if ($isBuyout != "false") { $options[] = array('label' => $this->__('Product Type'), 'value' => 'Rental Buyout', 'type' => 'reservation'); } else { if (isset($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION]) && $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION] != '') { $startDate = ITwebexperts_Payperrentals_Helper_Date::formatDbDate($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION], !$showTime, false); $endDate = ITwebexperts_Payperrentals_Helper_Date::formatDbDate($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION], !$showTime, false); if (!isset($nonSequential) || $nonSequential == 0) { $endDate = ITwebexperts_Payperrentals_Helper_Date::formatDbDate($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION], !$showTime, false); if (isset($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::FIXED_DATE_ID])) { $fixedRentalDatesCollection = Mage::getModel('payperrentals/fixedrentaldates')->getCollection()->addFieldToFilter('id', $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::FIXED_DATE_ID])->getFirstItem(); $fixedNameId = $fixedRentalDatesCollection->getNameid(); $fixedStartDate = $fixedRentalDatesCollection->getStartDate(); $fixedEndDate = $fixedRentalDatesCollection->getEndDate(); $difference = strtotime($fixedEndDate) - strtotime($fixedStartDate); $startDate = date('Y-m-d', strtotime($startDate)) . ' ' . date('H:i:s', strtotime($fixedStartDate)); $endDate = date('Y-m-d H:i:s', strtotime($startDate) + $difference); $fixedRentalNamesCollection = Mage::getModel('payperrentals/fixedrentalnames')->getCollection()->addFieldToFilter('id', $fixedNameId)->getFirstItem(); $fixedName = $fixedRentalNamesCollection->getName(); $options[] = array('label' => $this->__('Start Date'), 'value' => ITwebexperts_Payperrentals_Helper_Date::formatDbDate($startDate, !$showTime, false), 'type' => 'reservation'); $options[] = array('label' => $this->__('End Date'), 'value' => ITwebexperts_Payperrentals_Helper_Date::formatDbDate($endDate, !$showTime, false), 'type' => 'reservation'); //$options[] = array('label' => $this->__('Fixed Date'), 'value' => $fixedName, 'type' => 'reservation'); } else { $options[] = array('label' => $this->__('Start Date'), 'value' => $startDate, 'type' => 'reservation'); $options[] = array('label' => $this->__('End Date'), 'value' => $endDate, 'type' => 'reservation'); } } else { $options[] = array('label' => $this->__('Dates:'), 'value' => ITwebexperts_Payperrentals_Helper_Date::localiseNonsequentialBuyRequest($startDate, $showTime), 'type' => 'reservation'); } if (!$isCart && $isSingle) { $options = array(); } $damageWaiver = ITwebexperts_Payperrentals_Helper_Price::getDamageWaiver($productId, 1); if ($damageWaiver) { $options[] = array('label' => $this->__('Damage Waiver'), 'value' => ITwebexperts_Payperrentals_Helper_Price::getDamageWaiverHtml($item, (bool) $item->getBuyRequest()->getDamageWaiver(), $qty), 'type' => 'reservation'); } } else { return array(); } } $resultObject = new Varien_Object(); $resultObject->setResult($options); Mage::dispatchEvent('render_cart', array('options' => $source, 'result' => $resultObject, 'product' => $product, 'item' => $item, 'is_cart' => $isCart)); return $resultObject->getResult(); }