protected function _toHtml() { $html = parent::_toHtml(); if (Mage::registry('current_product') && Mage::getStoreConfig('mageworx_seo/seosuite/product_og_enabled')) { $product = Mage::registry('current_product'); $product = Mage::getModel('catalog/product')->load($product->getId()); $doubleQuoteTitle = '"'; $doubleQuoteDescr = '"'; $descr = strip_tags($product->getShortDescription() ? $product->getShortDescription() : $product->getDescription()); $title = strip_tags($product->getName()); if (strpos($title, $doubleQuoteTitle) !== false) { $doubleQuoteTitle = "'"; } elseif (strpos($descr, $doubleQuoteDescr) !== false) { $doubleQuoteDescr = "'"; } $ogs = "<meta property=\"og:title\" content={$doubleQuoteTitle}" . $title . "{$doubleQuoteTitle}/>\n<meta property=\"og:description\" content={$doubleQuoteDescr}" . $descr . "{$doubleQuoteDescr}/>\n<meta property=\"og:url\" content=\"" . $product->getProductUrl() . "\"/>\n"; $ogs .= "<meta property=\"og:type\" content=\"product\"/>\n"; $gallery = $product->getMediaGallery(); if (isset($gallery['images'])) { foreach ($gallery['images'] as $_image) { $ogs .= "<meta property=\"og:image\" content=\"" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $_image['file'] . "\"/>\n"; } } $pos = strpos($html, 'xmlns:fb="http://www.facebook.com/2008/fbml'); if ($pos === false) { $html = str_replace("<html", '<html xmlns:fb="http://www.facebook.com/2008/fbml"', $html); } $pos = strpos($html, ' prefix="og: http://ogp.me/ns#"'); if ($pos === false) { $html = str_replace("<html", '<html prefix="og: http://ogp.me/ns#"', $html); } $html = str_replace("<head>", "<head>\n" . $ogs, $html); } return $html; }
protected function _construct() { parent::_construct(); $templateFile = 'devel/help/' . $this->getRequest()->getParam('topic', 'index') . '.phtml'; $filePath = Mage::getDesign()->getTemplateFilename($templateFile); if (!file_exists($filePath)) { $templateFile = 'devel/help/notfound.phtml'; } $this->setTemplate($templateFile); }
/** * Render the page html * Renders all placeholders inside the page. * * @return string */ protected function _toHtml() { if (!Mage::getStoreConfig('design/aoe_templateimport/enabled')) { return parent::_toHtml(); } $fullActionName = $this->getFullActionName(); $storeId = Mage::app()->getStore()->getId(); $origin = Mage::getModel('aoe_templateimport/origin'); /* @var $origin Aoe_TemplateImport_Model_Origin */ $origin->loadByFullActionNameAndStore($fullActionName, $storeId); if (!$origin->getId()) { Mage::log('[Aoe_TemplateImport] No configuration found for: ' . $fullActionName . ' in store ' . $storeId, Zend_Log::ERR); if (Mage::getIsDeveloperMode()) { return '[no config found for "' . $fullActionName . ' in store ' . $storeId . '"]'; } else { return ''; } } $source = $origin->getSource(); if (empty($source)) { $origin->refresh(); $source = $origin->getSource(); if (empty($source)) { Mage::log('[Aoe_TemplateImport] Error retrieving source for: ' . $fullActionName . ' in store ' . $storeId, Zend_Log::ERR); if (Mage::getIsDeveloperMode()) { return '[no content found for "' . $fullActionName . ' in store ' . $storeId . '"]'; } else { return ''; } } } $sourceHelper = Mage::helper('aoe_templateimport/source'); /* @var $sourceHelper Aoe_TemplateImport_Helper_Source */ $source = $sourceHelper->injectChildBlocks($source, $this); return $source; }
protected function _afterToHtml($html) { if ($this->getCachePage()) { if (Mage::app()->useCache('lightspeed')) { if (!Mage::getSingleton('customer/session')->isLoggedIn()) { if ($this->_isRegistered()) { if (Mage::getSingleton('checkout/cart')->getItemsCount() < 1) { if (!$this->_comparing()) { if (Mage::app()->getRequest()->getActionName() != 'noRoute') { $key = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $key = 'SECURE_' . $key; } //remove ids that should not be cached //get params from config to exclude from url key $excludeParams = Mage::getConfig()->getNode('lightspeed/global/params'); $excludeArr = explode(",", $excludeParams); $excludes = array(); foreach ($excludeArr as $param) { $excludes[] = $param; } //see if we even need to remove some params if (count($excludes)) { //if we do, blow it up and remake it $keyPart = explode("?", $key); if (isset($keyPart[1])) { $keyParse = parse_url($key); $newParams = explode("&", $keyParse['query']); $newString = '?'; foreach ($newParams as $iteration => $newParam) { $paramArr = explode("=", $newParam); if (!in_array($paramArr[0], $excludes)) { $newString .= $paramArr[0] . "=" . $paramArr[1] . "&"; } $key = $keyPart[0] . $newString; $key = rtrim($key, "&"); $key = preg_replace('/(\\?|&|&&)debug_back=1/s', '', $key); } } } else { $key = preg_replace('/(\\?|&|&&)debug_back=1/s', '', $key); } if ($this->_useMultiCurrency()) { $key .= '_' . Mage::app()->getStore()->getCurrentCurrencyCode(); } // remove pesky session id from url Mage::app()->setUseSessionVar(false); $html = Mage::getSingleton('core/url')->sessionUrlVar($html); $data = array((string) $html, $this->getDisqualifiers(), $this->getDisqualifiedContentPath()); $this->_aggregateTags(); $this->report("saving page with key: {$key}", true); Mage::getSingleton('lightspeed/server')->save($key, $data, $this->getExpires(), $this->getAggregateTags()); } else { $this->report("404 page", true); } } else { $this->report("found items in the compare", true); } } else { $this->report("found items in the cart", true); } } else { $this->report("invalid registration", true); } } else { $this->report("customer is logged in", true); } } else { $this->report("please enable the 'whole pages' cache checkbox in the cache management panel", true); } } else { $this->report("this page is not set to be cached according to the layout", true); } // remove any NOCACHE tags $html = preg_replace('/\\<!\\-\\- +nocache.+?\\-\\-\\>/si', "", $html); $html = preg_replace('/\\<!\\-\\- endnocache \\-\\-\\>/si', "", $html); return parent::_afterToHtml($html); }