Пример #1
0
 protected function _prepareLayout()
 {
     if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
         $breadcrumbs->addCrumb('home', array('label' => AO::helper('catalogsearch')->__('Home'), 'title' => AO::helper('catalogsearch')->__('Go to Home Page'), 'link' => AO::getBaseUrl()))->addCrumb('search', array('label' => AO::helper('catalogsearch')->__('Catalog Advanced Search'), 'link' => $this->getUrl('*/*/')))->addCrumb('search_result', array('label' => AO::helper('catalogsearch')->__('Results')));
     }
     return parent::_prepareLayout();
 }
Пример #2
0
 public function getUrl($params = array())
 {
     static $reservedKeys = array('module' => 1, 'controller' => 1, 'action' => 1, 'array' => 1);
     if (is_string($params)) {
         $paramsArr = explode('/', $params);
         $params = array('controller' => $paramsArr[0], 'action' => $paramsArr[1]);
     }
     $url = AO::getBaseUrl($params);
     if (!empty($params['frontName'])) {
         $url .= $params['frontName'] . '/';
     } else {
         $url .= $this->_config->getName() . '/';
     }
     if (!empty($params)) {
         $paramsStr = '';
         foreach ($params as $key => $value) {
             if (!isset($reservedKeys[$key]) && '_' !== $key[0] && !empty($value)) {
                 $paramsStr .= $key . '/' . $value . '/';
             }
         }
         if (empty($params['controller']) && !empty($paramsStr)) {
             $params['controller'] = 'index';
         }
         $url .= empty($params['controller']) ? '' : $params['controller'] . '/';
         if (empty($params['action']) && !empty($paramsStr)) {
             $params['action'] = 'index';
         }
         $url .= empty($params['action']) ? '' : $params['action'] . '/';
         $url .= $paramsStr;
         $url .= empty($params['array']) ? '' : '?' . http_build_query($params['array']);
     }
     return $url;
 }
 protected function _getUrl()
 {
     $url = false;
     if ($this->getValue()) {
         $url = AO::getBaseUrl('media') . 'catalog/product/' . $this->getValue();
     }
     return $url;
 }
 public function getUrl($object)
 {
     $url = false;
     if ($image = $object->getData($this->getAttribute()->getAttributeCode())) {
         $url = AO::getBaseUrl('media') . 'catalog/product/' . $image;
     }
     return $url;
 }
Пример #5
0
 /**
  * Checking installation status
  *
  * @return unknown
  */
 protected function _checkIfInstalled()
 {
     if ($this->_getInstaller()->isApplicationInstalled()) {
         $this->getResponse()->setRedirect(AO::getBaseUrl())->sendResponse();
         exit;
     }
     return true;
 }
Пример #6
0
 function setSrc($src, $type = null)
 {
     $type = (string) $type;
     if (empty($type)) {
         $type = 'js';
     }
     $url = AO::getBaseUrl($type) . $src;
     return $this->setTagParam('src', $url);
 }
 /**
  * Prepare link to display in grid
  *
  * @param Varien_Object $row
  * @return string
  */
 public function render(Varien_Object $row)
 {
     $fileName = preg_replace('/^\\//', '', $row->getSitemapPath() . $row->getSitemapFilename());
     $url = $this->htmlEscape(AO::getBaseUrl('web') . $fileName);
     if (file_exists(BP . DS . $fileName)) {
         return sprintf('<a href="%1$s">%1$s</a>', $url);
     }
     return $url;
 }
Пример #8
0
 function setHref($href, $type = null)
 {
     $type = (string) $type;
     if (empty($type)) {
         $type = 'skin';
     }
     $url = AO::getBaseUrl($type) . $href;
     return $this->setTagParam('href', $url);
 }
Пример #9
0
 public function getGlobalConfig()
 {
     $dom = new DOMDocument();
     $dom->load(AO::getModuleDir('etc', 'Mage_Reports') . DS . 'flexConfig.xml');
     $baseUrl = $dom->createElement('baseUrl');
     $baseUrl->nodeValue = AO::getBaseUrl();
     $dom->documentElement->appendChild($baseUrl);
     return $dom->saveXML();
 }
Пример #10
0
 public function switchAction()
 {
     if ($curency = (string) $this->getRequest()->getParam('currency')) {
         AO::app()->getStore()->setCurrentCurrencyCode($curency);
     }
     if (AO::getSingleton('checkout/session')->getQuote()) {
         AO::getSingleton('checkout/session')->getQuote()->collectTotals()->save();
     }
     $this->_redirectReferer(AO::getBaseUrl());
 }
Пример #11
0
 public function indexAction()
 {
     $url = AO::getBaseUrl('web') . 'downloader/?return=' . urlencode(AO::getUrl('adminhtml'));
     $this->getResponse()->setRedirect($url);
     return;
     $this->loadLayout();
     $this->_setActiveMenu('system/extensions/local');
     $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_local'));
     $this->renderLayout();
 }
Пример #12
0
 public function __construct()
 {
     parent::__construct();
     $this->_urls = array('base' => AO::getBaseUrl('web'), 'baseSecure' => AO::getBaseUrl('web', true), 'current' => $this->getRequest()->getRequestUri());
     $action = AO::app()->getFrontController()->getAction();
     if ($action) {
         $this->addBodyClass($action->getFullActionName('-'));
     }
     $this->_beforeCacheUrl();
 }
Пример #13
0
 /**
  * Prepare layout
  *
  * @return Mage_CatalogSearch_Block_Result
  */
 protected function _prepareLayout()
 {
     $title = $this->__("Search results for: '%s'", $this->helper('catalogSearch')->getEscapedQueryText());
     // add Home breadcrumb
     if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
         $breadcrumbs->addCrumb('home', array('label' => $this->__('Home'), 'title' => $this->__('Go to Home Page'), 'link' => AO::getBaseUrl()))->addCrumb('search', array('label' => $title, 'title' => $title));
     }
     $this->getLayout()->getBlock('head')->setTitle($title);
     return parent::_prepareLayout();
 }
Пример #14
0
 public function _prepareLayout()
 {
     if ($headBlock = $this->getLayout()->getBlock('head')) {
         $headBlock->setTitle(AO::helper('catalogsearch')->__('Catalog Advanced Search'));
     }
     // add Home breadcrumb
     if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
         $breadcrumbs->addCrumb('home', array('label' => AO::helper('catalogsearch')->__('Home'), 'title' => AO::helper('catalogsearch')->__('Go to Home Page'), 'link' => AO::getBaseUrl()))->addCrumb('search', array('label' => AO::helper('catalogsearch')->__('Catalog Advanced Search')));
     }
     return parent::_prepareLayout();
 }
 /**
  * Get image preview url
  *
  * @return string
  */
 protected function _getUrl()
 {
     $url = parent::_getUrl();
     $config = $this->getFieldConfig();
     /* @var $config Varien_Simplexml_Element */
     if (!empty($config->base_url)) {
         $el = $config->descend('base_url');
         $urlType = empty($el['type']) ? 'link' : (string) $el['type'];
         $url = AO::getBaseUrl($urlType) . (string) $config->base_url . '/' . $url;
     }
     return $url;
 }
Пример #16
0
 /**
  * Enter description here...
  *
  * @return string
  */
 public function getElementHtml()
 {
     $html = '';
     if ($this->getValue()) {
         $url = $this->_getUrl();
         if (!preg_match("/^http\\:\\/\\/|https\\:\\/\\//", $url)) {
             $url = AO::getBaseUrl('media') . $url;
         }
         $html = '<a href="' . $url . '" onclick="imagePreview(\'' . $this->getHtmlId() . '_image\'); return false;"><img src="' . $url . '" id="' . $this->getHtmlId() . '_image" title="' . $this->getValue() . '" alt="' . $this->getValue() . '" height="22" width="22" class="small-image-preview v-middle" /></a> ';
     }
     $this->setClass('input-file');
     $html .= parent::getElementHtml();
     $html .= $this->_getDeleteCheckbox();
     return $html;
 }
Пример #17
0
 protected function _toHtml()
 {
     $system = $this->getOrder()->getPayment()->getMethodInstance();
     $form = new Varien_Data_Form();
     $form->setAction(AO::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . $system->getPayboxFile())->setId('paybox_system_checkout')->setName('paybox_system_checkout')->setMethod('POST')->setUseContainer(true);
     foreach ($system->getFormFields() as $field => $value) {
         $form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
     }
     $html = '<html><body>';
     $html .= $this->__('You will be redirected to Paybox in a few seconds.');
     $html .= $form->toHtml();
     $html .= '<script type="text/javascript">document.getElementById("paybox_system_checkout").submit();</script>';
     $html .= '</body></html>';
     return $html;
 }
 public function getUrl($object, $size = null)
 {
     $url = false;
     $image = $object->getData($this->getAttribute()->getAttributeCode());
     if (!is_null($size) && file_exists(AO::getBaseDir('media') . DS . 'catalog' . DS . 'product' . DS . $size . DS . $image)) {
         # resized image is cached
         $url = AO::getBaseUrl('media') . 'catalog/product/' . $size . '/' . $image;
     } elseif (!is_null($size)) {
         # resized image is not cached
         $url = AO::getBaseUrl() . 'catalog/product/image/size/' . $size . '/' . $image;
     } elseif ($image) {
         # using original image
         $url = AO::getBaseUrl('media') . 'catalog/product/' . $image;
     }
     return $url;
 }
Пример #19
0
 /**
  * Preparing layout
  *
  * @return Mage_Catalog_Block_Breadcrumbs
  */
 protected function _prepareLayout()
 {
     if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
         $breadcrumbsBlock->addCrumb('home', array('label' => AO::helper('catalog')->__('Home'), 'title' => AO::helper('catalog')->__('Go to Home Page'), 'link' => AO::getBaseUrl()));
         $title = array();
         $path = AO::helper('catalog')->getBreadcrumbPath();
         foreach ($path as $name => $breadcrumb) {
             $breadcrumbsBlock->addCrumb($name, $breadcrumb);
             $title[] = $breadcrumb['label'];
         }
         if ($headBlock = $this->getLayout()->getBlock('head')) {
             $headBlock->setTitle(join($this->getTitleSeparator(), array_reverse($title)));
         }
     }
     return parent::_prepareLayout();
 }
Пример #20
0
 /**
  * Subscription confirm action
  */
 public function confirmAction()
 {
     $id = (int) $this->getRequest()->getParam('id');
     $code = (string) $this->getRequest()->getParam('code');
     if ($id && $code) {
         $subscriber = AO::getModel('newsletter/subscriber')->load($id);
         $session = AO::getSingleton('core/session');
         if ($subscriber->getId() && $subscriber->getCode()) {
             if ($subscriber->confirm($code)) {
                 $session->addSuccess($this->__('Your subscription was successfully confirmed'));
             } else {
                 $session->addError($this->__('Invalid subscription confirmation code'));
             }
         } else {
             $session->addError($this->__('Invalid subscription ID'));
         }
     }
     $this->_redirectUrl(AO::getBaseUrl());
 }
Пример #21
0
 protected function _prepareLayout()
 {
     $page = $this->getPage();
     // show breadcrumbs
     if (AO::getStoreConfig('web/default/show_cms_breadcrumbs') && ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) && $page->getIdentifier() !== AO::getStoreConfig('web/default/cms_home_page') && $page->getIdentifier() !== AO::getStoreConfig('web/default/cms_no_route')) {
         $breadcrumbs->addCrumb('home', array('label' => AO::helper('cms')->__('Home'), 'title' => AO::helper('cms')->__('Go to Home Page'), 'link' => AO::getBaseUrl()));
         $breadcrumbs->addCrumb('cms_page', array('label' => $page->getTitle(), 'title' => $page->getTitle()));
     }
     if ($root = $this->getLayout()->getBlock('root')) {
         $template = (string) AO::getConfig()->getNode('global/cms/layouts/' . $page->getRootTemplate() . '/template');
         $root->setTemplate($template);
         $root->addBodyClass('cms-' . $page->getIdentifier());
     }
     if ($head = $this->getLayout()->getBlock('head')) {
         $head->setTitle($page->getTitle());
         $head->setKeywords($page->getMetaKeywords());
         $head->setDescription($page->getMetaDescription());
     }
 }
Пример #22
0
 /**
  * Check if installer is run in shell, and redirect if run on web
  *
  * @param string $url fallback url to redirect to
  * @return boolean
  */
 public function checkConsole($url = null)
 {
     if (defined('STDIN') && defined('STDOUT') && defined('STDERR')) {
         return true;
     }
     if (is_null($url)) {
         $url = preg_replace('/install\\.php/i', '', AO::getBaseUrl());
         $url = preg_replace('/\\/\\/$/', '/', $url);
     }
     header('Location: ' . $url);
     return false;
 }
Пример #23
0
 /**
  * Get standard path variables.
  *
  * To be used in blocks, templates, etc.
  *
  * @param array|string $args Module name if string
  * @return array
  */
 public function getPathVars($args = null)
 {
     $path = array();
     $path['baseUrl'] = AO::getBaseUrl();
     $path['baseSecureUrl'] = AO::getBaseUrl('link', true);
     return $path;
 }
Пример #24
0
 /**
  * Set form object
  *
  * @param Varien_Data_Form $form
  * @return Mage_Adminhtml_Block_Widget_Form
  */
 public function setForm(Varien_Data_Form $form)
 {
     $this->_form = $form;
     $this->_form->setParent($this);
     $this->_form->setBaseUrl(AO::getBaseUrl());
     return $this;
 }
Пример #25
0
 /**
  * Front end main entry point
  *
  * @param string $code
  * @param string $type
  * @param string|array $options
  */
 public static function run($code = '', $type = 'store', $options = array())
 {
     try {
         Varien_Profiler::start('mage');
         Varien_Profiler::start('mage::app');
         self::initApp($code, $type, $options);
         Varien_Profiler::stop('mage::app');
         Varien_Profiler::start('mage::dispatch');
         self::$_app->getFrontController()->dispatch();
         Varien_Profiler::stop('mage::dispatch');
         Varien_Profiler::stop('mage');
     } catch (Mage_Core_Model_Session_Exception $e) {
         header('Location: ' . AO::getBaseUrl());
         die;
     } catch (Mage_Core_Model_Store_Exception $e) {
         $baseUrl = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
         if (!headers_sent()) {
             header('Location: ' . $baseUrl . '/404/');
         } else {
             print '<script type="text/javascript">';
             print "window.location.href = '{$baseUrl}';";
             print '</script>';
         }
         die;
     } catch (Exception $e) {
         if (self::isInstalled() || self::$_isDownloader) {
             self::printException($e);
             exit;
         }
         try {
             self::dispatchEvent('mage_run_exception', array('exception' => $e));
             if (!headers_sent()) {
                 header('Location:' . self::getUrl('install'));
             } else {
                 self::printException($e);
             }
         } catch (Exception $ne) {
             self::printException($ne, $e->getMessage());
         }
     }
 }
Пример #26
0
 public function getCssJsHtml()
 {
     //        return '';
     $lines = array();
     $baseJs = AO::getBaseUrl('js');
     $html = '';
     $script = '<script type="text/javascript" src="%s" %s></script>';
     $stylesheet = '<link rel="stylesheet" type="text/css" href="%s" %s />';
     $alternate = '<link rel="alternate" type="%s" href="%s" %s />';
     foreach ($this->_data['items'] as $item) {
         if (!is_null($item['cond']) && !$this->getData($item['cond'])) {
             continue;
         }
         $if = !empty($item['if']) ? $item['if'] : '';
         switch ($item['type']) {
             case 'js':
                 #$lines[$if]['other'][] = sprintf($script, $baseJs.$item['name'], $item['params']);
                 $lines[$if]['script'][] = $item['name'];
                 break;
             case 'js_css':
                 //proxying css will require real-time prepending path to all image urls, should we do it?
                 $lines[$if]['other'][] = sprintf($stylesheet, $baseJs . $item['name'], $item['params']);
                 #$lines[$if]['stylesheet'][] = $item['name'];
                 break;
             case 'skin_js':
                 $lines[$if]['other'][] = sprintf($script, $this->getSkinUrl($item['name']), $item['params']);
                 break;
             case 'skin_css':
                 $lines[$if]['other'][] = sprintf($stylesheet, $this->getSkinUrl($item['name']), $item['params']);
                 break;
             case 'rss':
                 $lines[$if]['other'][] = sprintf($alternate, 'application/rss+xml', $item['name'], $item['params']);
                 break;
         }
     }
     foreach ($lines as $if => $items) {
         if (!empty($if)) {
             $html .= '<!--[if ' . $if . ']>' . "\n";
         }
         if (!empty($items['script'])) {
             $scriptItems = array();
             if (!AO::getStoreConfigFlag('dev/js/deprecation')) {
                 $scriptItems = $this->getChunkedItems($items['script'], 'index.php?c=auto&amp;f=');
             } else {
                 $scriptItems = $items['script'];
             }
             foreach ($scriptItems as $item) {
                 $html .= sprintf($script, $baseJs . $item, '') . "\n";
             }
             //                foreach (array_chunk($items['script'], 15) as $chunk) {
             //                    $html .= sprintf($script, $baseJs.'index.php/x.js?f='.join(',',$chunk), '')."\n";
             //                }
         }
         if (!empty($items['stylesheet'])) {
             foreach ($this->getChunkedItems($items['stylesheet'], $baseJs . 'index.php?c=auto&amp;f=') as $item) {
                 $html .= sprintf($stylesheet, $item, '') . "\n";
             }
             //                foreach (array_chunk($items['stylesheet'], 15) as $chunk) {
             //                    $html .= sprintf($stylesheet, $baseJs.'index.php/x.css?f='.join(',',$chunk), '')."\n";
             //                }
         }
         if (!empty($items['other'])) {
             $html .= join("\n", $items['other']) . "\n";
         }
         if (!empty($if)) {
             $html .= '<![endif]-->' . "\n";
         }
     }
     return $html;
 }
Пример #27
0
 public function getImageUrl()
 {
     $url = false;
     if ($image = $this->getImage()) {
         $url = AO::getBaseUrl('media') . 'catalog/category/' . $image;
     }
     return $url;
 }
Пример #28
0
 protected function _getCurrentSecureUrl($request)
 {
     return AO::getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
 }
Пример #29
0
 /**
  * Database installation
  *
  * @return Mage_Install_Model_Installer
  */
 public function installDb()
 {
     Mage_Core_Model_Resource_Setup::applyAllUpdates();
     $data = $this->getDataModel()->getConfigData();
     /**
      * Saving host information into DB
      */
     $setupModel = new Mage_Core_Model_Resource_Setup('core_setup');
     if (!empty($data['use_rewrites'])) {
         $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_USE_REWRITES, 1);
     }
     $unsecureBaseUrl = AO::getBaseUrl('web');
     if (!empty($data['unsecure_base_url'])) {
         $unsecureBaseUrl = $data['unsecure_base_url'];
         $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_URL, $unsecureBaseUrl);
     }
     if (!empty($data['use_secure'])) {
         $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_SECURE_IN_FRONTEND, 1);
         $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL, $data['secure_base_url']);
         if (!empty($data['use_secure_admin'])) {
             $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_SECURE_IN_ADMINHTML, 1);
         }
     } elseif (!empty($data['unsecure_base_url'])) {
         $setupModel->setConfigData(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL, $unsecureBaseUrl);
     }
     /**
      * Saving locale information into DB
      */
     $locale = AO::getSingleton('install/session')->getLocaleData();
     if (!empty($locale['locale'])) {
         $setupModel->setConfigData(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $locale['locale']);
     }
     if (!empty($locale['timezone'])) {
         $setupModel->setConfigData(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $locale['timezone']);
     }
     if (!empty($locale['currency'])) {
         $setupModel->setConfigData(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE, $locale['currency']);
         $setupModel->setConfigData(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_DEFAULT, $locale['currency']);
         $setupModel->setConfigData(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_ALLOW, $locale['currency']);
     }
     return $this;
 }
Пример #30
0
 /**
  * Get url of base javascript file
  *
  * To get url of skin javascript file use getSkinUrl()
  *
  * @param string $fileName
  * @return string
  */
 public function getJsUrl($fileName = '')
 {
     if (!$this->_jsUrl) {
         $this->_jsUrl = AO::getBaseUrl('js');
     }
     return $this->_jsUrl . $fileName;
 }