Пример #1
0
 public function core_block_abstract_to_html_after(Varien_Event_Observer $observer)
 {
     $block = $observer->getBlock();
     if ($block instanceof Mage_Catalog_Block_Product_List) {
         /* will insert layered navigation block on top of the products list.. */
         $_block_code = $block->getNameInLayout();
         if (!in_array($_block_code, array("product_list", "search_result_list"))) {
             return;
         }
         $transport = $observer->getTransport();
         $html = $transport->getHtml();
         $html = '<div id="ajaxlist-reload-product_list">' . Mage::registry("top_layered_navigation_html") . $html . "</div>";
         $transport->setHtml($html);
     } elseif ($block instanceof Mage_Catalog_Block_Product_Compare_Abstract) {
         $_block_code = $block->getNameInLayout();
         if (!Mage::registry("ajaxcompare_check_code")) {
             $_check_code = explode(",", Mage::getStoreConfig("ajaxlist/ajaxcompare/reload_block"));
             Mage::register("ajaxcompare_check_code", $_check_code);
         }
         $_check_code = Mage::registry("ajaxcompare_check_code");
         if (count($_check_code) && in_array($_block_code, $_check_code)) {
             $transport = $observer->getTransport();
             $html = $transport->getHtml();
             $_code = str_replace(".", '-', $_block_code);
             $transport->setHtml('<div id="ajaxcompare-reload-block-' . $_code . '">' . $html . "</div>");
         }
     }
     return;
 }
 /**
  * Appends the "sortable" js code to the bottom of ajax-Request for the category-products loaded after
  * changing sort order.
  *
  * @param Varien_Event_Observer $observer
  */
 public function addSortableScriptOnGrid(Varien_Event_Observer $observer)
 {
     $_block = $observer->getBlock();
     $_type = $_block->getType();
     if (Mage::helper('ffuenf_categoryproductsortbackend')->isExtensionActive() && $_type == 'adminhtml/catalog_category_tab_product') {
         $content = $observer->getTransport()->getHtml();
         $dom = new DOMDocument('1.0', 'utf-8');
         $doc = new DOMDocument('1.0', 'utf-8');
         $dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'));
         foreach ($dom->getElementsByTagName('select') as $element) {
             if ($element->getAttribute('name') == 'limit') {
                 $option = $dom->createElement('option');
                 $option->appendChild($dom->createTextNode('All'));
                 $option->setAttribute('value', 0);
                 $option = $element->appendChild($option);
             }
         }
         $additionalHtml = $this->appendScript($content);
         $additionalDoc = new DOMDocument();
         $additionalDoc->loadHTML($additionalHtml);
         $additionalDocScript = $additionalDoc->getElementsByTagName('script')->item(0);
         $body = $dom->getElementsByTagName('body')->item(0);
         foreach ($body->childNodes as $child) {
             $doc->appendChild($doc->importNode($child, true));
         }
         $doc->appendChild($doc->importNode($additionalDocScript, true));
         $content = $doc->saveHTML();
         $observer->getTransport()->setHtml($content);
     }
 }
Пример #3
0
 public function onCoreBlockToHtmlAfter(Varien_Event_Observer $observer)
 {
     $helper = $this->helper();
     if ($helper->isCacheable() && !$this->_cached) {
         /* @var $block Mage_Core_Block_Abstract */
         $block = $observer->getEvent()->getBlock();
         $blockName = $block->getNameInLayout();
         if ($blockName == 'global_messages') {
             $block->setTemplate('bubble/fpc/messages.phtml');
             $observer->getTransport()->setHtml($block->renderView());
         } elseif ($helper->isBlockDynamic($blockName)) {
             // Save block html in cache
             $html = $observer->getTransport()->getHtml();
             $html = $helper->cleanHtml($html);
             $dynamicBlock = $helper->getBlockInstance($blockName);
             $helper->saveBlock($dynamicBlock->getName(), $html);
             if ($helper->isActionCacheable()) {
                 $placeholder = $dynamicBlock->getPlaceholder();
                 $hash = md5($placeholder);
                 $this->_placeholders[$hash] = $placeholder;
                 $html = sprintf($this->_placeholderFormat, $hash, $html, $hash);
                 $observer->getTransport()->setHtml($html);
             }
         }
     }
 }
Пример #4
0
 public function coreBlockAbstractToHtmlAfter(Varien_Event_Observer $observer)
 {
     if (!Mage::helper('aw_giftcard')->isModuleOutputEnabled()) {
         return $this;
     }
     if ($observer->getBlock() instanceof Mage_Checkout_Block_Cart_Coupon) {
         $block = Mage::app()->getLayout()->createBlock('aw_giftcard/frontend_checkout_cart_giftcard');
         $observer->getTransport()->setHtml($observer->getTransport()->getHtml() . $block->toHtml());
     }
     return $this;
 }
Пример #5
0
 public function insertBlock(Varien_Event_Observer $observer)
 {
     if (Mage::app()->getFrontController()->getAction()->getFullActionName() === 'adminhtml_dashboard_index') {
         if ($observer->getBlock()->getUseAsDashboardHook()) {
             $html = $observer->getTransport()->getHtml();
             $zendeskDash = $observer->getBlock()->getLayout()->createBlock('zendesk/adminhtml_dashboard')->setName('zendesk_dashboard');
             $zendeskGrid = $zendeskDash->getLayout()->createBlock('zendesk/adminhtml_dashboard_grids')->setName('zendesk_dashboard_grids');
             $zendeskDash->setChild('zendesk_dashboard_grids', $zendeskGrid);
             $html .= $zendeskDash->toHtml();
             $observer->getTransport()->setHtml($html);
         }
     }
 }
Пример #6
0
 /**
  * Adds DDQ HTML to inventory tab (where editing products). Could potentially also
  * be used for other things in the future.
  *
  * @param Varien_Event_Observer $observer
  */
 public function afterAbstractHtml(Varien_Event_Observer $observer)
 {
     try {
         /* @var $block Mage_Core_Block_Abstract */
         $block = $observer->getEvent()->getBlock();
         $blockClass = get_class($block);
         if ($this->_getControllerName() == 'catalog_product' && ($this->_getActionName() == 'edit' || $this->_getActionName() == 'new')) {
             if ($blockClass == 'Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Inventory' || $blockClass == 'Aitoc_Aitpermissions_Block_Rewrite_AdminhtmlCatalogProductEditTabInventory') {
                 // adds our customised block to the inventory tab
                 $observer->getTransport()->setHtml($observer->getTransport()->getHtml() . Mage::getBlockSingleton('ddq/adminhtml_catalog_product_form')->toHtml());
             }
         }
     } catch (Exception $e) {
         Mage::helper('ddq')->log($e->getMessage());
     }
 }
Пример #7
0
 /**
  * @param Varien_Event_Observer $observer
  *
  * @return $this
  */
 public function handleInlineJs(Varien_Event_Observer $observer)
 {
     Varien_Profiler::start('MeanbeeFooterJs');
     /** @var Meanbee_Footerjs_Helper_Data $helper */
     $helper = Mage::helper('meanbee_footerjs');
     if (!$helper->isEnabled()) {
         return $this;
     }
     /** @var Mage_Core_Block_Abstract $block */
     $block = $observer->getBlock();
     if (!is_null($block->getParentBlock())) {
         // Only look for JS at the root block
         return $this;
     }
     /** @var Varien_Object $transport */
     $transport = $observer->getTransport();
     $patterns = array('js' => self::REGEX_JS, 'document_end' => self::REGEX_DOCUMENT_END);
     foreach ($patterns as $pattern) {
         $matches = array();
         $html = $transport->getHtml();
         $success = preg_match_all($pattern, $html, $matches);
         if ($success) {
             $text = implode('', $matches[0]);
             $html = preg_replace($pattern, '', $html);
             $transport->setHtml($html . $text);
         }
     }
     Varien_Profiler::stop('MeanbeeFooterJs');
     return $this;
 }
Пример #8
0
 /**
  * Retrieve the blog route
  * If Root enabled, set the blog route as an empty string
  *
  * @param Varien_Event_Observer $observer
  * @return $this
  */
 public function blogRouteGetObserver(Varien_Event_Observer $observer)
 {
     if ($this->isEnabled()) {
         $observer->getTransport()->setBlogRoute('');
     }
     return $this;
 }
Пример #9
0
 public function interceptOutput(Varien_Event_Observer $observer)
 {
     $transport = $observer->getTransport();
     $html = $transport->getHtml();
     if (strpos($html, '<div class="middle"') !== false && isset($_GET['cleantalk_message'])) {
         $html = str_replace('<div class="middle"', '<div class="notification-global  notification-global-error"><b>CleanTalk error: ' . $_GET['cleantalk_message'] . '</b></div><div class="middle"', $html);
         $transport->setHtml($html);
     }
     $show_notice = intval(Mage::getStoreConfig('general/cleantalk/show_notice'));
     if (strpos($html, '<div class="middle"') !== false && $show_notice == 1) {
         $message = "Like Anti-spam by CleanTalk? Help others learn about CleanTalk! <a  target='_blank' href='http://www.magentocommerce.com/magento-connect/antispam-by-cleantalk.html'>Leave a review at the Magento Connect</a> <a href='?close_notice=1' style='float:right;'>Close</a>";
         $html = str_replace('<div class="middle"', '<div class="notification-global  notification-global-notice">' . $message . '</div><div class="middle"', $html);
         $transport->setHtml($html);
     }
     if (strpos($html, '%LINK_TEXT%') !== false) {
         $api_key = Mage::getStoreConfig('general/cleantalk/api_key');
         if (trim($api_key) == '') {
             Mage::app()->cleanCache();
             $admin_email = Mage::getStoreConfig('trans_email/ident_general/email');
             $button = "<input type='button' style='margin-top:5px;-webkit-border-bottom-left-radius: 5px;-webkit-border-bottom-right-radius: 5px;-webkit-border-radius: 5px;-webkit-border-top-left-radius: 5px;-webkit-border-top-right-radius: 5px;background: #3399FF;border-radius: 5px;box-sizing: border-box;color: #FFFFFF;font: normal normal 400 14px/16.2px \"Open Sans\";padding:3px;border:0px none;cursor:pointer;' value='Get access key automatically' onclick='location.href=\"?get_auto_key=1\"'><br /><a target='_blank' href='https://cleantalk.org/register?platform=magento&email=" . $admin_email . "&website=" . $_SERVER['HTTP_HOST'] . "'>Click here to get access key manually</a><br />Admin e-mail (" . $admin_email . ") will be used for registration<br /><a target='__blank' href='http://cleantalk.org/publicoffer' style='color:#e5e5e5'>License agreement</a>";
             $html = str_replace('%LINK_TEXT%', $button, $html);
         } else {
             $html = str_replace('%LINK_TEXT%', "<a target='__blank' href='http://cleantalk.org/my' >Click here to get anti-spam statistics</a>", $html);
         }
         $transport->setHtml($html);
     }
 }
Пример #10
0
 /**
  * Looks for the hook we set and adds our own custom block.
  *
  * @param Varien_Event_Observer $observer
  * @return Smartbear_Alertsite_Model_Observer
  */
 public function coreBlockAbstractToHtmlAfter(Varien_Event_Observer $observer)
 {
     if (!Mage::helper('alertsite')->getConfig('alertsite_config', 'enabled') || strlen(trim(Mage::helper('alertsite')->getConfig('alertsite_config', 'alertsite_user'))) < 1) {
         return $this;
     }
     if (Mage::app()->getFrontController()->getAction()->getFullActionName() === 'adminhtml_dashboard_index') {
         if ($observer->getBlock()->getAlertsiteDashboardHook()) {
             $html = $observer->getTransport()->getHtml();
             // grab the html that's already rendered
             /** @var $dashboardBox Smartbear_Alertsite_Block_Adminhtml_Dashboard */
             $dashboardBox = $observer->getBlock()->getLayout()->createBlock('alertsite/adminhtml_dashboard');
             $dashboardBox->insert($observer->getBlock()->getLayout()->createBlock('core/template', 'alertsite.subheader')->setTemplate('alertsite/subheader.phtml'));
             $html .= $dashboardBox->toHtml();
             $observer->getTransport()->setHtml($html);
         }
     }
     return $this;
 }
 /**
  * Sets the row url in the transport object for a cms_page model
  *
  * @param Varien_Event_Observer $observer Observer Instance
  */
 public function setRowUrl(Varien_Event_Observer $observer)
 {
     /* @var $history FireGento_AdminMonitoring_Model_History */
     $history = $observer->getHistory();
     $rowUrl = $this->_getRowUrl($history, $this->_getClassName(), $this->_getRoutePath(), $this->_getRouteParams($history->getOriginalModel()));
     if ($rowUrl) {
         $observer->getTransport()->setRowUrl($rowUrl);
     }
 }
Пример #12
0
 /**
  * @event controller_response_redirect
  * @param Varien_Event_Observer $event
  */
 public function handleRedirect(Varien_Event_Observer $event)
 {
     $core = $this->_getCore();
     if ($core->isHoAjax() && !$core->isProceed()) {
         $core->setProceed();
         $response = Mage::getModel('ho_bootstrapajaxcart/response');
         $response->handleRedirect($this->_prepareRedirectUrl($event->getTransport()->getUrl()));
         $response->sendResponse();
     }
 }
Пример #13
0
 public function onCoreBlockAbstractToHtmlAfter(Varien_Event_Observer $observer)
 {
     $block = $observer->getBlock();
     if ($block instanceof Mage_Catalog_Block_Product_Price) {
         $id = $block->getProduct()->getId();
         if (!Mage::registry('amlabel_product_id_' . $id)) {
             // add product ID info in output
             Mage::register('amlabel_product_id_' . $id, true);
             $html = $html = $observer->getTransport()->getHtml();
             $observer->getTransport()->setHtml('<div class="price" id="amlabel-product-price-' . $id . '" style="display:none"></div>' . $html);
             // add label for product
             $label = Mage::helper('amlabel')->getLabels($block->getProduct());
             if ($label) {
                 $this->addScript($id, addslashes($label));
             }
         }
     }
     return $this;
 }
 /**
  * Add Template Hints
  *
  * @param Varien_Event_Observer $observer
  *
  */
 public function addTemplateHints(Varien_Event_Observer $observer)
 {
     if (!$this->showHints()) {
         return;
     }
     if (substr(trim($observer->getTransport()->getHtml()), 0, 4) == 'http') {
         return;
     }
     $block = $observer->getBlock();
     /* @var $block Mage_Core_Block_Abstract */
     if (!$block || !$block instanceof Mage_Core_Block_Abstract) {
         return;
     }
     $transport = $observer->getTransport();
     $blockHtml = $transport->getHtml();
     $this->hintId++;
     $wrappedHtml = '<div id="thh-' . $this->hintId . '-start" class="thh-wrap thh-start"></div>';
     $wrappedHtml .= $blockHtml;
     $wrappedHtml .= '<div id="thh-' . $this->hintId . '-stop" class="thh-wrap thh-stop"></div>';
     $transport->setHtml($wrappedHtml);
 }
Пример #15
0
 public function addPagarmeJs(Varien_Event_Observer $observer)
 {
     $block = $observer->getEvent()->getBlock();
     $blockType = $block->getType();
     $targetBlocks = array('checkout/onepage_payment', 'aw_onestepcheckout/onestep_form_paymentmethod', 'onestepcheckout/onestep_form_paymentmethod');
     if (in_array($blockType, $targetBlocks) && Mage::getStoreConfig('payment/pagarme_cc/active')) {
         $transport = $observer->getTransport();
         $html = $transport->getHtml();
         $preHtml = $block->getLayout()->createBlock('core/template')->setTemplate('pagarme/checkout/payment/js.phtml')->toHtml();
         $transport->setHtml($preHtml . $html);
     }
 }
Пример #16
0
 /**
  * This method is minifying HTML of every block.
  * Multiple calls per page but they are cached.
  * 
  * @param Varien_Event_Observer $observer
  */
 public function minifyBlockHtml(Varien_Event_Observer $observer)
 {
     if ($this->getBlockMinifyStatus()) {
         $block = $observer->getBlock();
         $transport = $observer->getTransport();
         $html = $transport->getHtml();
         if ($this->getMaxMinifyStatus()) {
             $transport->setHtml(Minify_HTMLMaxComp::minify($html, $this->minifyOptions));
         } else {
             $transport->setHtml(Minify_HTMLComp::minify($html, $this->minifyOptions));
         }
     }
 }
Пример #17
0
 public function coreBlockAbstractToHtmlAfter(Varien_Event_Observer $observer)
 {
     $store = Mage::app()->getStore();
     if (!$store->isAdmin() && Mage::getModel('cmsassistant/assistant')->isEnabled($store->getId())) {
         $transport = $observer->getTransport();
         if ($transport->getHtml()) {
             $html = $this->addAssistant($observer->getBlock(), $transport->getHtml());
             if ($html) {
                 $transport->setHtml($html);
             }
         }
     }
 }
Пример #18
0
 public function getPaymentInfo(Varien_Event_Observer $observer)
 {
     $transport = $observer->getTransport();
     $payment = $observer->getPayment();
     if ($payment->getAdditionalInformation('payment_currency')) {
         $transport['Payment Currency'] = $payment->getAdditionalInformation('payment_currency');
     }
     if ($payment->getAdditionalInformation('due_amount')) {
         $transport['Amount Due'] = $payment->getAdditionalInformation('due_amount');
     }
     if ($payment->getAdditionalInformation('exchange_rate')) {
         $transport['Exchange Rate'] = $payment->getAdditionalInformation('exchange_rate');
     }
     return;
 }
Пример #19
0
 public function setSocialPointsOnProductPages(Varien_Event_Observer $observer)
 {
     /* @var $block Mage_Core_Block_Abstract */
     $block = $observer->getBlock();
     $transport = $observer->getTransport();
     $fileName = $block->getTemplateFile();
     $thisClass = get_class($block);
     if ($block->getNameInLayout() == 'product.info.addtocart') {
         $html = $transport->getHtml();
         $magento_block = Mage::getSingleton('core/layout');
         $productsHtml = $magento_block->createBlock('j2trewardsocial/socialpoints');
         $productsHtml->setTemplate('j2trewardsocial/product_view.phtml');
         $extraHtml = $productsHtml->toHtml();
         $transport->setHtml($html . $extraHtml);
     }
 }
Пример #20
0
 /**
  * Event core_block_abstract_to_html_after
  *
  * @param Varien_Event_Observer $params
  * @return void
  * @author Fabrizio Branca <*****@*****.**>
  * @since 2011-01-24
  */
 public function core_block_abstract_to_html_after(Varien_Event_Observer $params)
 {
     if (!$this->showHints()) {
         return;
     }
     $block = $params->getBlock();
     /* @var $block Mage_Core_Block_Abstract */
     $transport = $params->getTransport();
     $info = array();
     $moduleName = $block->getModuleName();
     $info['MODULE'] = $moduleName;
     $info['PATH'] = $this->getBlockPath($block);
     if ($block instanceof Mage_Cms_Block_Block) {
         $info['CMS-BLOCK-ID'] = $block->getBlockId();
     }
     if ($block instanceof Mage_Cms_Block_Page) {
         $info['CMS-PAGE-ID'] = $block->getPage()->getIdentifier();
     }
     $templateFile = $block->getTemplateFile();
     if ($templateFile) {
         $info['TEMPLATE'] = $templateFile;
     }
     $color = Mage::getStoreConfig('dev/debug/border_color_notcached');
     // not cached
     $cacheInfo = $this->getCacheInfo($block);
     if ($cacheInfo) {
         $info['CACHE'] = $cacheInfo;
         $color = Mage::getStoreConfig('dev/debug/border_color_cached');
         // cached
     } elseif ($this->isWithinCachedBlock($block)) {
         $color = Mage::getStoreConfig('dev/debug/border_color_cached_inherit');
         // not cached, but within cached
     }
     $title = array();
     foreach ($info as $key => $value) {
         $title[] = "{$key}: {$value}";
     }
     $title = implode(' // ', $title);
     // wrap info around block output
     $html = $transport->getHtml();
     $html = '<div class="tpl-hint" title="' . $title . '" style="border: 1px dotted ' . $color . '; margin:2px; padding:2px; overflow: hidden;">' . $html . '</div>';
     $transport->setHtml($html);
 }
    public function setTemplatePathHints(Varien_Event_Observer $observer)
    {
        $helper = Mage::helper('easypathhints');
        $isActive = $helper->isActive();
        $tp = Mage::app()->getRequest()->getParam('tp');
        $accessCode = Mage::app()->getRequest()->getParam('code');
        $dbAccessCode = $helper->getConfig('code');
        $dbCookieStatus = $helper->getConfig('cookie');
        $cookieStatus = Mage::app()->getRequest()->getParam('cookie');
        $checkAccessCode = true;
        if (!empty($dbAccessCode)) {
            $checkAccessCode = $dbAccessCode == $accessCode ? true : false;
        }
        if ($dbCookieStatus && $cookieStatus) {
            Mage::getModel('core/cookie')->set('etph_cookie', 1);
        }
        if ($tp && $isActive && $checkAccessCode || $isActive && Mage::getModel('core/cookie')->get('etph_cookie')) {
            /* @var $block Mage_Core_Block_Abstract */
            $block = $observer->getBlock();
            $transport = $observer->getTransport();
            $fileName = $block->getTemplateFile();
            $thisClass = get_class($block);
            if ($fileName) {
                $preHtml = '<div style="position:relative; border:1px dotted red; margin:6px 2px; padding:18px 2px 2px 2px; zoom:1;">
	<div style="position:absolute; left:0; top:0; padding:2px 5px; background:red; color:white; font:normal 11px Arial;
	text-align:left !important; z-index:998;" onmouseover="this.style.zIndex=\'999\'"
	onmouseout="this.style.zIndex=\'998\'" title="' . $fileName . '">' . $fileName . '</div>';
                $preHtml .= '<div style="position:absolute; right:0; top:0; padding:2px 5px; background:red; color:blue; font:normal 11px Arial;
		text-align:left !important; z-index:998;" onmouseover="this.style.zIndex=\'999\'" onmouseout="this.style.zIndex=\'998\'"
		title="' . $thisClass . '">' . $thisClass . '</div>';
                $postHtml = '</div>';
            } else {
                $preHtml = null;
                $postHtml = null;
            }
            $html = $transport->getHtml();
            $html = $preHtml . $html . $postHtml;
            $transport->setHtml($html);
        }
    }
Пример #22
0
 /**
  * Event core_block_abstract_to_html_after
  *
  * @param Varien_Event_Observer $params
  * @return void
  * @author Fabrizio Branca
  * @since 2011-01-24
  */
 public function core_block_abstract_to_html_after(Varien_Event_Observer $params)
 {
     if (!$this->showHints()) {
         return;
     }
     if (substr(trim($params->getTransport()->getHtml()), 0, 4) == 'http') {
         return;
     }
     $wrappedHtml = '';
     $block = $params->getBlock();
     /* @var $block Mage_Core_Block_Abstract */
     // will only be called once and allows renderes to initialize themselves (e.g. adding js/css)
     if ($this->init && $this->afterHead && !Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $block->getModuleName()) && $block->getNameInLayout()) {
         $wrappedHtml = '<!-- INIT AOE_TEMPLATEHINTS RENDERER START -->' . $this->getRenderer()->init($wrappedHtml) . '<!-- INIT AOE_TEMPLATEHINTS RENDERER STOP -->';
         $this->init = false;
     }
     if ($block->getNameInLayout() == 'head') {
         $this->afterHead = true;
     }
     $transport = $params->getTransport();
     $this->hintId++;
     $wrappedHtml .= $this->getRenderer()->render($block, $transport->getHtml(), $this->hintId);
     $transport->setHtml($wrappedHtml);
 }
Пример #23
0
 /**
  * @param Varien_Event_Observer $observer
  *
  * @return $this
  */
 public function handleBlockInlineJs(Varien_Event_Observer $observer)
 {
     Varien_Profiler::start('MeanbeeFooterJs');
     /** @var Meanbee_Footerjs_Helper_Data $helper */
     $helper = Mage::helper('meanbee_footerjs');
     if (!$helper->isEnabled()) {
         return $this;
     }
     /** @var Varien_Object $transport */
     $transport = $observer->getTransport();
     /** @var Mage_Core_Block_Abstract $block */
     $block = $observer->getBlock();
     if (Mage::app()->getRequest()->getModuleName() == 'pagecache') {
         $transport->setHtml($helper->removeJs($transport->getHtml()));
         return $this;
     }
     if (!is_null($block->getParentBlock())) {
         // Only look for JS at the root block
         return $this;
     }
     $transport->setHtml($helper->moveJsToEnd($transport->getHtml()));
     Varien_Profiler::stop('MeanbeeFooterJs');
     return $this;
 }
 /**
  * Adds pagination toolbar to attribute option tab
  *
  * @event core_block_abstract_to_html_after
  * @area adminhtml
  * @param Varien_Event_Observer $observer
  * @return $this
  */
 public function addPaginationToBlock(Varien_Event_Observer $observer)
 {
     if (!$this->_pager) {
         return $this;
     }
     $block = $observer->getBlock();
     if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options) {
         $html = $observer->getTransport()->getHtml();
         //TODO inject toolbar at top and bottom of #matage-options-panel > .box with DOM
         $paginationHtml = $this->_toolbar->getBlock()->toHtml();
         $html = $paginationHtml . '<br/>' . $html . $paginationHtml;
         $observer->getTransport()->setHtml($html);
     }
     return $this;
 }
Пример #25
0
 /** Add coupon block after order items block
  *  (for order view page)
  *
  * @param Varien_Event_Observer $observer
  */
 public function insertCouponBlock($observer)
 {
     /** @var Varien_Object $transport */
     $transport = $observer->getTransport();
     /** @var Mage_Core_Block_Abstract $block */
     $block = $observer->getBlock();
     if ($block->getType() == 'adminhtml/sales_order_view_items' && $block->getNameInLayout() == 'order_items') {
         /** @var string $oldHtml */
         $oldHtml = $transport->getHtml();
         /** @var string $couponsBlockHtml */
         $couponsBlockHtml = Mage::getSingleton('core/layout')->createBlock('mageworx_orderspro/adminhtml_sales_order_coupons', 'coupons')->toHtml();
         /** @var string $newHtml */
         $newHtml = $oldHtml . $couponsBlockHtml;
         // append coupon block html
         $transport->setHtml($newHtml);
     }
     return;
 }
 public function hideProductsPrice(Varien_Event_Observer $observer)
 {
     if (Mage::getStoreConfig('amgroupcat/general/disable')) {
         return false;
     }
     $replace = false;
     /* flag about was replaced content or not */
     /*
      * check restrictions on product list
      * remove "add to cart" buttons
      */
     if ($observer->getBlock() instanceof Mage_Catalog_Block_Product_List) {
         $output = $observer->getTransport()->getHtml();
         if ($category = Mage::registry('current_category')) {
             $categoryId = Mage::registry('current_category')->getId();
         } else {
             $categoryId = -1;
         }
         $activeRules = Mage::helper('amgroupcat')->getActiveRules(array('hide_price = 1'));
         if (empty($activeRules)) {
             return false;
         }
         /*
          * replace with text: "price-box" container
          * if any rule have revrite set
          */
         foreach ($activeRules as $rule) {
             if (in_array($categoryId, explode(',', trim($rule['categories'], ',')))) {
                 if ($rule['price_on_product_list']) {
                     $replace = Mage::helper('cms')->getPageTemplateProcessor()->filter(Mage::getModel('cms/block')->load($rule['price_on_product_list'])->getContent());
                     $output = $this->replaceAllMatches($output, '<div class="price-box', '</div>', $replace);
                 }
             }
         }
         /*
          * only if there were any rules for replace block
          */
         if ($replace) {
             $output = $this->replaceCommons($output);
             /* direct replace all `commons` entries on the page */
         }
         /*
          *
          */
         /*
          * save result
          */
         $observer->getTransport()->setHtml($output);
     } else {
         /*
          * check restrictions on product page
          */
         if ($observer->getBlock() instanceof Mage_Catalog_Block_Product_Price || $observer->getBlock() instanceof Mage_Catalog_Block_Product_View) {
             $replace = false;
             $output = $observer->getTransport()->getHtml();
             try {
                 $productId = $observer->getBlock()->getProduct()->getId();
                 $categories = $observer->getBlock()->getProduct()->getCategoryCollection();
             } catch (Exception $e) {
                 return false;
             }
             $activeRules = Mage::helper('amgroupcat')->getActiveRulesForProductPrice($productId);
             /*
              * apply rules for product
              */
             if (!empty($activeRules)) {
                 foreach ($activeRules as $rule) {
                     if ($observer->getBlock() instanceof Mage_Catalog_Block_Product_View && $rule['price_on_product_view']) {
                         $replace = Mage::helper('cms')->getPageTemplateProcessor()->filter(Mage::getModel('cms/block')->load($rule['price_on_product_view'])->getContent());
                         $output = $this->replaceAllMatches($output, '<div class="price-box', '</div>', $replace);
                     } elseif ($observer->getBlock() instanceof Mage_Catalog_Block_Product_Price && $rule['price_on_product_list']) {
                         $replace = Mage::helper('cms')->getPageTemplateProcessor()->filter(Mage::getModel('cms/block')->load($rule['price_on_product_list'])->getContent());
                         $output = $this->addCommonsReplaceID($output, $productId, $replace);
                     }
                 }
                 $replace = true;
             }
             /*
              * apply rules for category
              */
             $categoryId = array();
             foreach ($categories as $category) {
                 $categoryId[] = $category->getId();
             }
             $activeRules = Mage::helper('amgroupcat')->getActiveRules(array('hide_price = 1'));
             if (is_array($activeRules) && count($activeRules) > 0) {
                 foreach ($activeRules as $rule) {
                     $categories = explode(',', trim($rule['categories'], ','));
                     foreach ($categoryId as $catId) {
                         if (in_array($catId, $categories)) {
                             if ($observer->getBlock() instanceof Mage_Catalog_Block_Product_View && $rule['price_on_product_view']) {
                                 $replace = Mage::helper('cms')->getPageTemplateProcessor()->filter(Mage::getModel('cms/block')->load($rule['price_on_product_view'])->getContent());
                                 $output = $this->replaceAllMatches($output, '<div class="price-box', '</div>', $replace);
                             } else {
                                 if ($rule['price_on_product_list']) {
                                     $replace = Mage::helper('cms')->getPageTemplateProcessor()->filter(Mage::getModel('cms/block')->load($rule['price_on_product_list'])->getContent());
                                     $output = $this->replaceCommons($output);
                                     $output = $this->addCommonsReplace($output, $replace);
                                     $replace = '';
                                 }
                             }
                         }
                     }
                 }
             }
             /*
              * hide price boxes and add to cart buttons
              */
             if ($replace) {
                 $output = $this->replaceCommons($output);
                 $output = $this->addCommonsHideId($output, $productId);
             }
             /*
              * save result
              */
             $observer->getTransport()->setHtml('<div class="amgroupcat">' . $output . '</div>');
         } else {
             /*
              * check restrictions for Category Hideng from menu
              * fix specially for Infortis Themes
              */
             if ($observer->getBlock() instanceof Infortis_UltraMegamenu_Block_Navigation || $observer->getBlock() instanceof Mage_Page_Block_Html_Topmenu) {
                 $output = $observer->getTransport()->getHtml();
                 $categoryIds = array();
                 $activeRules = Mage::helper('amgroupcat')->getActiveRules(array('remove_category_links = 1'));
                 /* active rules which have "remove_category_links" flag */
                 if (!empty($activeRules)) {
                     foreach ($activeRules as $rule) {
                         $ids = explode(',', $rule['categories']);
                         $categoryIds = array_merge($ids, $categoryIds);
                     }
                     $categoryIds = array_unique($categoryIds);
                 }
                 $storeId = Mage::app()->getStore()->getStoreId();
                 foreach ($categoryIds as $id) {
                     $category = Mage::getModel('catalog/category')->setStoreId($storeId)->load($id);
                     $catName = $category->getName();
                     $catUrl = $category->getUrl();
                     $output = $this->replaceAllMatches($output, '<a href="' . $catUrl . '"', '</a>', $replace);
                 }
                 $observer->getTransport()->setHtml($output);
             }
         }
     }
     return $this;
 }
Пример #27
0
 /**
  * Add custom data to the payment info block
  *
  * @param Varien_Event_Observer $observer
  * @return void
  */
 public function paymentInfoBlockPrepareSpecificInformation(Varien_Event_Observer $observer)
 {
     /** @var $payment Mage_Sales_Model_Quote_Payment */
     $payment = $observer->getPayment();
     /** @var $transport Varien_Object */
     $transport = $observer->getTransport();
     $paymentMethod = $payment->getMethod();
     // Display custom data for supported payment methods only
     /** @var $helper CLS_Paypal_Helper_Data */
     $helper = Mage::helper('cls_paypal');
     if ($helper->isSupportedPaymentMethod($paymentMethod)) {
         if ($payment->hasAdditionalInformation('cc_save_future')) {
             $transport->setData($helper->__('Save this card for future use'), $helper->__('Yes'));
         }
     }
 }
Пример #28
0
 /**
  * Event listener for cache backend cleans.
  * The event 'magehost_clean_backend_cache_after' is only triggered if cache backend used in local.xml:
  *    'MageHost_Cm_Cache_Backend_File'
  * or 'MageHost_Cm_Cache_Backend_Redis'
  *
  * @param Varien_Event_Observer $observer
  */
 public function magehostCleanBackendCacheAfter($observer)
 {
     // Check if we need to flush the 'mini' dir containing minified JavaScript and CSS
     if ($this->miniDir) {
         $prefix = Mage::app()->getCacheInstance()->getFrontend()->getOption('cache_id_prefix');
         if (empty($observer->getTransport()->getTags())) {
             // no tags = clear everything
             $this->cleanMiniDir();
         } else {
             $cleanOnTags = array(strtoupper(Mage_Core_Block_Abstract::CACHE_GROUP), strtoupper(Mage_Core_Model_Layout_Update::LAYOUT_GENERAL_CACHE_TAG));
             $prefixMatch = '/^' . preg_quote($prefix, '/') . '/i';
             foreach ($observer->getTransport()->getTags() as $tag) {
                 $tag = preg_replace($prefixMatch, '', $tag);
                 if (in_array($tag, $cleanOnTags)) {
                     $this->cleanMiniDir();
                     break;
                 }
             }
         }
     }
     // Pass flush to other nodes in cluster if enabled
     if (Mage::getStoreConfigFlag(self::CONFIG_SECTION . '/cluster/enable_pass_cache_clean') && !Mage::registry('MageHost_cacheClean_via_Api')) {
         $localHostname = Mage::helper('magehost_hosting')->getLocalHostname();
         /** @noinspection PhpUndefinedMethodInspection */
         $transport = $observer->getTransport();
         /** @noinspection PhpUndefinedMethodInspection */
         Mage::log(sprintf("Cache Clean Event. Mode '%s', tags '%s'.", $transport->getMode(), implode(',', $transport->getTags())));
         $nodes = Mage::getStoreConfig(self::CONFIG_SECTION . '/cluster/http_nodes');
         $url = '';
         // Protection against occasional crash while trying to get API url during n98-magerun usage
         if (Mage::app()->getFrontController()->getRouter('admin')) {
             $url = Mage::getUrl('api');
         }
         // Fix wrong URL generated via n98 or other CLI tools
         if (false === strpos($url, '/index.php/api')) {
             $url = preg_replace('#/[\\w\\-]+\\.(php|phar)/api#', '/api', $url);
         }
         $url = str_replace('n98-magerun/', '', $url);
         if (empty($url)) {
             $url = Mage::getStoreConfig('web/unsecure/base_url') . 'api/';
         }
         $urlData = parse_url($url);
         $nodeList = explode("\n", $nodes);
         $localIPs = Mage::helper('magehost_hosting')->getLocalIPs();
         foreach ($nodeList as $node) {
             $node = trim($node);
             if (empty($node)) {
                 continue;
             }
             $nodeSplit = explode(':', $node);
             $nodeHost = $nodeSplit[0];
             $nodePort = empty($nodeSplit[1]) ? 80 : intval($nodeSplit[1]);
             if (preg_match('/^\\d+\\.\\d+\\.\\d+\\.\\d+$/', $nodeHost)) {
                 $nodeIP = $nodeHost;
             } else {
                 $nodeIP = gethostbyname($nodeHost);
             }
             if ($nodeHost == $localHostname || in_array($nodeIP, $localIPs)) {
                 continue;
             }
             $headers = array();
             $hostHeader = Mage::getStoreConfig(self::CONFIG_SECTION . '/cluster/host_header');
             if (empty($hostHeader)) {
                 $hostHeader = $urlData['host'];
             }
             $nodeScheme = $urlData['scheme'];
             $headers[] = 'Host: ' . $hostHeader;
             if (443 == $nodePort && 'https' != $nodeScheme) {
                 $nodeScheme = 'https';
                 $headers[] = 'X-Forwarded-Proto: http';
             } elseif (80 == $nodePort && 'http' != $nodeScheme) {
                 $nodeScheme = 'http';
                 $headers[] = 'X-Forwarded-Proto: https';
                 $headers[] = 'Ssl-Offloaded: 1';
             }
             $nodeLocation = $nodeScheme . '://' . $node . $urlData['path'];
             $apiUser = Mage::getStoreConfig(self::CONFIG_SECTION . '/cluster/api_user');
             $apiKey = Mage::getStoreConfig(self::CONFIG_SECTION . '/cluster/api_key');
             $options = array('uri' => 'urn:Magento', 'location' => $nodeLocation, 'curl_headers' => $headers);
             Mage::log(sprintf("%s::%s: Passing flush to '%s' with Host header '%s'", __CLASS__, __FUNCTION__, $nodeLocation, $hostHeader));
             try {
                 $client = new MageHost_Hosting_Model_SoapClientCurl(null, $options);
                 /** @noinspection PhpUndefinedMethodInspection */
                 $sessionId = $client->login($apiUser, $apiKey);
                 /** @noinspection PhpUndefinedMethodInspection */
                 $client->call($sessionId, 'magehost_hosting.cacheClean', array($transport->getMode(), $transport->getTags(), $localHostname));
             } catch (Exception $e) {
                 Mage::log(sprintf("%s::%s: ERROR during SOAP request: %s", __CLASS__, __FUNCTION__, $e->getMessage()));
             }
         }
     }
 }
Пример #29
0
 public function addRewardFormAdmin(Varien_Event_Observer $observer)
 {
     $block = $observer->getBlock();
     if (($block->getNameInLayout() == 'coupons' || $block->getBlockAlias() == 'coupons') && (Mage::app()->getRequest()->getControllerName() == "sales_order_create" || Mage::app()->getRequest()->getControllerName() == "sales_order_edit")) {
         //<block type="rewardpoints/adminhtml_createorder_reward" template="rewardpoints/form.phtml" name="reward_coupons" />
         if (version_compare(Mage::getVersion(), '1.5.0', '>=')) {
             $transport = $observer->getTransport();
             $fileName = $block->getTemplateFile();
             $thisClass = get_class($block);
             $html = $transport->getHtml();
             $magento_block = Mage::getSingleton('core/layout');
             $productsHtml = $magento_block->createBlock('rewardpoints/adminhtml_createorder_reward');
             $productsHtml->setTemplate('rewardpoints/form.phtml');
             $productsHtml->setNameInLayout("reward_coupons");
             $extraHtml = $productsHtml->toHtml();
             $transport->setHtml($extraHtml . $html);
         } else {
             $magento_block = Mage::getSingleton('core/layout');
             $productsHtml = $magento_block->createBlock('rewardpoints/adminhtml_createorder_reward');
             $productsHtml->setTemplate('rewardpoints/form.phtml');
             $productsHtml->setNameInLayout("reward_coupons");
             $extraHtml = $productsHtml->toHtml();
             echo $extraHtml;
         }
     }
 }
 /**
  * Event listener used to add or remove cache tags
  * Listens to event "jv_cache_save_block"
  *
  * @param Varien_Event_Observer $observer
  */
 public function cacheSave($observer)
 {
     $prefix = Mage::app()->getCacheInstance()->getFrontend()->getOption('cache_id_prefix');
     $pregPrefix = preg_quote($prefix, '|');
     $id = $observer->getId();
     /** @noinspection PhpUndefinedMethodInspection */
     $transport = $observer->getTransport();
     /** @noinspection PhpUndefinedMethodInspection */
     $tags = $transport->getTags();
     /**
      * We need this extra cache tag to be able to flush per URL later on.
      * This is the only way because some cache keys or blocks can be session dependent.
      */
     $tags[] = $prefix . 'URL_' . md5($this->getFilterUrl());
     if (preg_match('|^' . $pregPrefix . 'JV_PRD_|i', $id)) {
         // Remove category tags if adding disabled
         $addCategoryTag = Mage::getStoreConfig(self::CONFIG_SECTION . '/' . self::BLOCK_GROUP_PRODUCT . '/add_category_tag');
         if (!is_null($addCategoryTag) && !intval($addCategoryTag)) {
             // Setting exists and is "Yes".
             foreach ($tags as $key => $value) {
                 if (preg_match('|^' . $pregPrefix . 'CATALOG_CATEGORY|i', $value)) {
                     unset($tags[$key]);
                 }
             }
         }
     }
     /** @noinspection PhpUndefinedMethodInspection */
     $transport->setTags($tags);
 }