public function userAction()
 {
     $otwitter = Mage::getModel('sociallogin/twlogin');
     $requestToken = Mage::getSingleton('core/session')->getRequestToken();
     $oauth_data = array('oauth_token' => $this->getRequest()->getParam('oauth_token'), 'oauth_verifier' => $this->getRequest()->getParam('oauth_verifier'));
     $token = $otwitter->getAccessToken($oauth_data, unserialize($requestToken));
     $params = array('consumerKey' => Mage::helper('sociallogin')->getTwConsumerKey(), 'consumerSecret' => Mage::helper('sociallogin')->getTwConsumerSecret(), 'accessToken' => $token);
     $twitter = new Zend_Service_Twitter($params);
     $response = $twitter->userShow($token->user_id);
     $twitterId = (string) $response->id;
     // get twitter account ID
     $customerId = $this->getCustomerId($twitterId);
     if ($customerId) {
         //login
         $customer = Mage::getModel('customer/customer')->load($customerId);
         Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer);
         die("<script type=\"text/javascript\">try{window.opener.location.reload(true);}catch(e){window.opener.location.href=\"" . Mage::getBaseUrl() . "\"} window.close();</script>");
     } else {
         // redirect to login page
         Mage::getSingleton('core/session')->setTwitterId($twitterId);
         $connectingNotice = Mage::helper('sociallogin')->getTwConnectingNotice();
         $storeName = Mage::app()->getStore()->getName();
         Mage::getSingleton('core/session')->addNotice(str_replace('{{store}}', $storeName, $connectingNotice));
         $nextUrl = Mage::helper('sociallogin')->getLoginUrl();
         $backUrl = Mage::getSingleton('core/session')->getBackUrl();
         Mage::getSingleton('customer/session')->setBeforeAuthUrl($backUrl);
         // after login redirect to current url
         die("<script>window.close();window.opener.location = '{$nextUrl}';</script>");
     }
 }
 /**
  * getMergedCssUrl
  *
  * Merge specified css files and return URL to the merged file on success
  *
  * @param array $files
  * @return string
  */
 public function getMergedCssUrl($files)
 {
     //return parent::getMergedCssUrl($files);
     // secure or unsecure
     $isSecure = Mage::app()->getRequest()->isSecure();
     $mergerDir = $isSecure ? 'css_secure' : 'css';
     $targetDir = $this->_initMergerDir($mergerDir);
     if (!$targetDir) {
         return '';
     }
     // base hostname & port
     $baseMediaUrl = Mage::getBaseUrl('media', $isSecure);
     $hostname = parse_url($baseMediaUrl, PHP_URL_HOST);
     $port = parse_url($baseMediaUrl, PHP_URL_PORT);
     if (false === $port) {
         $port = $isSecure ? 443 : 80;
     }
     //we sum the size so we can determ if something changed
     $fileSizeTotal = $this->getSumFileSize($files);
     $targetFilename = md5(implode(',', $files) . "|{$hostname}|{$port}" . $fileSizeTotal) . '-' . $this->getSuffix('css') . '.css';
     $url = $baseMediaUrl . $mergerDir . '/' . $targetFilename;
     if (file_exists($targetDir . DS . $targetFilename)) {
         return $url;
     } else {
         if ($this->_mergeFiles($files, $targetDir . DS . $targetFilename, false, array($this, 'beforeMergeCss'), 'css')) {
             //check if we want to minify
             if (Mage::getStoreConfigFlag('dev/css/minify')) {
                 $this->minifyCSS($targetDir . DS . $targetFilename);
             }
             return $url;
         }
     }
     return '';
 }
Beispiel #3
0
 /**
  * Extracting available images
  *
  * @param string $thumbSize dimensions of thumbnail image (either number of width pixels or {width]x{height}
  * @param string $imageSize dimensions of detail image (either number of width pixels or {width]x{height}
  * @return unknown
  */
 public function getImages($thumbSize = null, $imageSize = null)
 {
     if (!($faq = $this->getFaq())) {
         return false;
     }
     // read images from dataset
     $images = $faq->getImage();
     $result = array();
     // if we have found images - process them
     if (is_array($images) && !empty($images)) {
         // get media model
         $mediaConfig = Mage::getSingleton('faq/faq_media_config');
         $mediaModel = Mage::getSingleton('media/image')->setConfig($mediaConfig);
         // iterate through images
         foreach ($images as $image) {
             // only go on if the image can be found
             if (file_exists(Mage::getBaseDir('media') . DS . 'faq' . DS . $image)) {
                 // gather needed information
                 $newImage = array('original' => $image, 'galleryUrl' => $this->getGalleryUrl($image));
                 if ($thumbSize) {
                     $newImage['src'] = $mediaModel->getSpecialLink($image, $thumbSize);
                 }
                 if ($imageSize) {
                     $newImage['href'] = $mediaModel->getSpecialLink($image, $imageSize);
                     $newImage['width'] = intval($imageSize);
                 } else {
                     $newImage['href'] = Mage::getBaseUrl('media') . '/faq/' . $image;
                     $newImage['width'] = $mediaModel->setFileName($image)->getDimensions()->getWidth();
                 }
                 $result[] = $newImage;
             }
         }
     }
     return $result;
 }
Beispiel #4
0
 protected function _getOriginalImageUrl(Varien_Object $row)
 {
     if (strlen($image = $this->_getValue($row)) && $image != 'no_selection') {
         return Mage::getBaseUrl('media') . 'catalog/product/' . $image;
     }
     return null;
 }
Beispiel #5
0
 protected function setUp()
 {
     parent::setUp();
     $this->_screenshots = array();
     $browserName = Xtest::getArg('browser', 'firefox');
     $browserData = Mage::getConfig()->getNode('default/xtest/selenium/browserlist/' . strtolower($browserName));
     if ($browserData) {
         $browserData = $browserData->asArray();
         $capabilities = array();
         if ($browserData['is_browserstack']) {
             if ($browserstackConfig = Mage::getConfig()->getNode('default/xtest/selenium/browserstack')) {
                 $browserstackConfig = $browserstackConfig->asArray();
                 $this->setHost($browserstackConfig['host']);
                 $this->setPort((int) $browserstackConfig['port']);
                 if (file_exists($browserstackConfig['authfile'])) {
                     list($user, $key) = explode(':', file_get_contents($browserstackConfig['authfile']));
                     $capabilities['browserstack.user'] = trim($user);
                     $capabilities['browserstack.key'] = trim($key);
                 }
             }
         }
         $this->setBrowser($browserData['name']);
         if ($caps = $browserData['capabilities']) {
             $capabilities = array_merge($capabilities, $caps);
         }
         $this->setDesiredCapabilities($capabilities);
     } else {
         $this->setBrowser($browserName);
     }
     $this->setBrowserUrl(Mage::getBaseUrl());
     $this->setUpSessionStrategy(null);
     // Default Browser-Size
     $this->prepareSession()->currentWindow()->size(array('width' => 1280, 'height' => 1024));
     Xtest::initFrontend();
 }
Beispiel #6
0
 /**
  * Generates htaccess 301 redirects for the current magento site.  Output is written
  * to stdout.
  * 
  * Usage: wiz 301-htgen <csv_file>
  * 
  * CSV File will be a two-column CSV file in the following format:
  * /old/path/to/product1.html,SKU1
  * /old/path/to/product2.html,SKU2
  *
  * @param URL to SKU CSV File.
  * @return void
  * @author Nicholas Vahalik <*****@*****.**>
  */
 function htgenAction($options)
 {
     $filename = realpath($options[0]);
     if (!file_exists($filename)) {
         throw new Exception('Need a file to generate 301 mappings.');
     } else {
         file_put_contents('php://stderr', 'Reading current mappings from ' . $filename . PHP_EOL);
     }
     Wiz::getMagento('store');
     $file_contents = file_get_contents($filename);
     $lines = explode(PHP_EOL, $file_contents);
     $redirectFormat = 'redirect 301 %s %s' . PHP_EOL;
     $output = $errors = '';
     $model = Mage::getModel('catalog/product');
     $baseUrl = Mage::getBaseUrl();
     $done = 0;
     foreach ($lines as $line) {
         $done++;
         list($url, $sku) = explode(', ', $line);
         $sku = strtoupper(trim($sku));
         $productId = $model->getIdBySku($sku);
         if ($productId === FALSE) {
             $errors .= 'Product not found for SKU# ' . $sku . PHP_EOL;
         }
         $product = Mage::getModel('catalog/product')->load($productId);
         $output .= sprintf($redirectFormat, $url, str_replace($baseUrl, '/', $product->getProductUrl()));
     }
     echo $output . PHP_EOL;
     file_put_contents('php://stderr', 'Mapped ' . $done . ' records.' . PHP_EOL);
     if ($errors != '') {
         $errors = '========================================' . PHP_EOL . '== Errors                             ==' . PHP_EOL . '========================================' . PHP_EOL . $errors . PHP_EOL;
         file_put_contents('php://stderr', $errors);
     }
 }
 public function toOptionArray()
 {
     $result = array();
     $result[] = array('value' => 'style_1', 'label' => '&nbsp;&nbsp;
     <img src="' . Mage::getBaseUrl('skin') . "frontend/smartwave/default/socialicons/images/social-icons-hover-sprite.png" . '" style="vertical-align:middle;background-color: #000;"/><br/><br/>');
     return $result;
 }
Beispiel #8
0
    protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
    {
        $html = $element->getElementHtml();
        $isLoadScript = Mage::registry('gmap_loaded');
        $elementId = $element->getHtmlId();
        $elementId = str_replace("_address_preview", "", $elementId);
        $latElementId = $elementId . '_location_lat';
        $lngElementId = $elementId . '_location_lng';
        $addressElementId = $element->getHtmlId();
        if (empty($isLoadScript)) {
            $html .= '<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script><script src="http://js.maxmind.com/app/geoip.js" type="text/javascript"></script><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=places"></script><script src="' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS) . 'ves/themesettings/locationpicker.jquery.js"></script>';
            Mage::register('gmap_loaded', true);
        }
        $html .= '<br/><div id="map-' . $element->getHtmlId() . '" style="width:600px;height:400px">';
        $html .= '</div>';
        $html .= '<script type="text/javascript">

        jQuery(window).load(function(){
            jQuery("#map-' . $element->getHtmlId() . '").locationpicker({
                location: {latitude: $("' . $latElementId . '").value, longitude: $("' . $lngElementId . '").value},
                radius: 100,
                enableAutocomplete: true,
                inputBinding: {
                    latitudeInput: jQuery("#' . $latElementId . '"),
                    longitudeInput: jQuery("#' . $lngElementId . '"),
                    locationNameInput: jQuery("#' . $addressElementId . '")
                }
            });
});
</script>';
        return $html;
    }
Beispiel #9
0
 /**
  * Id for the offer
  * @return mixed
  */
 public function getId()
 {
     // The offer id will consist of the base URL stripped of the schema and the store view id plus the product id.
     $formattedBase = preg_replace('/(.*)\\:\\/\\/(.*?)((\\/index\\.php\\/?$)|$|(\\/index.php\\/admin\\/?))/is', '$2', Mage::getBaseUrl());
     $id = $formattedBase . '*' . $this->_storeId . '*' . $this->_productId;
     return $id;
 }
Beispiel #10
0
 public function render(Varien_Object $row)
 {
     if ($getter = $this->getColumn()->getGetter()) {
         $val = $row->{$getter}();
     }
     $html = "";
     $typeId = $row->getData('type_id');
     if ($typeId == 'simple') {
         $val = $row->getData($this->getColumn()->getIndex());
         //$val = str_replace("no_selection", "", $val);
         $_swatchImage = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/enterprise/lecom/images/NA.jpg';
         $_mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product';
         /*
         $swatchImgWidth = Mage::getStoreConfig('colorswatch/general/swatch_image_width');
         if($swatchImgWidth == "" || strtolower($swatchImgWidth) == "null") {
         	$swatchImgWidth = 20;
         }
         
         $swatchImgHeight = Mage::getStoreConfig('colorswatch/general/swatch_image_height');
         
         if($swatchImgHeight == "" || strtolower($swatchImgHeight) == "null") {
         	$swatchImgHeight = 20;
         }
         */
         if (!empty($val) && $val != "no_selection" && file_exists(Mage::getBaseDir('media') . '/catalog/product/' . $val)) {
             $_swatchImage = $_mediaUrl . $val;
             //$_swatchImage = Mage::helper('catalog/image')->init($_productchild,'color_swatch_image')->resize($swatchImgWidth,$swatchImgHeight);
         }
         $html = '<img ';
         $html .= 'id="' . $this->getColumn()->getId() . '" ';
         $html .= 'src="' . $_swatchImage . '"';
         $html .= 'class="grid-image ' . $this->getColumn()->getInlineCss() . '" width="20" height="20" />';
     }
     return $html;
 }
Beispiel #11
0
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     $this->setForm($form);
     $fieldset = $form->addFieldset('banners_form', array('legend' => Mage::helper('banners')->__('Item information')));
     $object = Mage::getModel('banners/banners')->load($this->getRequest()->getParam('id'));
     $imgPath = Mage::getBaseUrl('media') . "Banners/images/thumb/" . $object['bannerimage'];
     $fieldset->addField('title', 'text', array('label' => Mage::helper('banners')->__('Title'), 'class' => 'required-entry', 'required' => true, 'name' => 'title'));
     $fieldset->addField('bannerimage', 'file', array('label' => Mage::helper('banners')->__('Banner Image'), 'required' => false, 'name' => 'bannerimage'));
     if ($object->getId()) {
         $tempArray = array('name' => 'filethumbnail', 'style' => 'display:none;');
         $fieldset->addField($imgPath, 'thumbnail', $tempArray);
     }
     $fieldset->addField('link', 'text', array('label' => Mage::helper('banners')->__('Link'), 'required' => false, 'name' => 'link'));
     $fieldset->addField('target', 'select', array('label' => Mage::helper('banners')->__('Target'), 'name' => 'target', 'values' => array(array('value' => '_blank', 'label' => Mage::helper('banners')->__('Open in new window')), array('value' => '_self', 'label' => Mage::helper('banners')->__('Open in same window')))));
     $fieldset->addField('sort_order', 'text', array('label' => Mage::helper('banners')->__('Sort Order'), 'required' => false, 'name' => 'sort_order'));
     $fieldset->addField('textblend', 'select', array('label' => Mage::helper('banners')->__('Text Blend ?'), 'name' => 'textblend', 'values' => array(array('value' => 'yes', 'label' => Mage::helper('banners')->__('Yes')), array('value' => 'no', 'label' => Mage::helper('banners')->__('No')))));
     $fieldset->addField('store_id', 'multiselect', array('name' => 'stores[]', 'label' => Mage::helper('banners')->__('Store View'), 'title' => Mage::helper('banners')->__('Store View'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
     $fieldset->addField('status', 'select', array('label' => Mage::helper('banners')->__('Status'), 'name' => 'status', 'values' => array(array('value' => 1, 'label' => Mage::helper('banners')->__('Enabled')), array('value' => 2, 'label' => Mage::helper('banners')->__('Disabled')))));
     $fieldset->addField('content', 'editor', array('name' => 'content', 'label' => Mage::helper('banners')->__('Content'), 'title' => Mage::helper('banners')->__('Content'), 'style' => 'width:700px; height:500px;', 'wysiwyg' => false, 'required' => true));
     if (Mage::getSingleton('adminhtml/session')->getBannersData()) {
         $form->setValues(Mage::getSingleton('adminhtml/session')->getBannersData());
         Mage::getSingleton('adminhtml/session')->setBannersData(null);
     } elseif (Mage::registry('banners_data')) {
         $form->setValues(Mage::registry('banners_data')->getData());
     }
     return parent::_prepareForm();
 }
 /**
  * Prepare global layout
  *
  * @return Zeon_Faq_Block_List
  */
 protected function _prepareLayout()
 {
     $helper = Mage::helper('zeon_faq');
     if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
         $breadcrumbs->addCrumb('home', array('label' => $helper->__('Home'), 'title' => $helper->__('Go to Home Page'), 'link' => Mage::getBaseUrl()));
         if ($categoryId = $this->getRequest()->getParam('category_id', null)) {
             $breadcrumbs->addCrumb('faq_list', array('label' => $helper->__('FAQ'), 'title' => $helper->__('FAQ'), 'link' => Mage::getUrl('*')));
             $categoryTitle = Mage::getResourceModel('zeon_faq/category')->getFaqCategoryTitleById($categoryId);
             $breadcrumbs->addCrumb('faq_category', array('label' => $categoryTitle, 'title' => $categoryTitle));
         } elseif ($mfaq = $this->getRequest()->getParam('mfaq', null)) {
             $breadcrumbs->addCrumb('faq_list', array('label' => $helper->__('FAQ'), 'title' => $helper->__('FAQ'), 'link' => Mage::getUrl('*')));
             $breadcrumbs->addCrumb('faq_category', array('label' => $helper->__('MFAQ'), 'title' => $helper->__('MFAQ')));
         } elseif ($toSearch = $this->getRequest()->getParam('faqsearch')) {
             $breadcrumbs->addCrumb('faq_list', array('label' => $helper->__('FAQ'), 'title' => $helper->__('FAQ'), 'link' => Mage::getUrl('*')));
             $breadcrumbs->addCrumb('faq_search', array('label' => $toSearch, 'title' => $toSearch));
         } else {
             $breadcrumbs->addCrumb('faq_list', array('label' => $helper->__('FAQ'), 'title' => $helper->__('FAQ')));
         }
     }
     $head = $this->getLayout()->getBlock('head');
     if ($head) {
         $head->setTitle($helper->getDefaultTitle());
         $head->setKeywords($helper->getDefaultMetaKeywords());
         $head->setDescription($helper->getDefaultMetaDescription());
     }
     parent::_prepareLayout();
     $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
     $pager->setAvailableLimit(array(5 => 5, 10 => 10, 20 => 20, 'all' => 'all'));
     $pager->setCollection($this->getCollection());
     $this->setChild('pager', $pager);
     $this->getCollection()->load();
     return $this;
 }
 public function getSubcategories()
 {
     $orders = array('position', 'name');
     $order = $this->getOrder();
     if (!in_array($order, $orders)) {
         $order = current($orders);
     }
     $layer = Mage::getSingleton('catalog/layer');
     /* @var $category Mage_Catalog_Model_Category */
     $category = $layer->getCurrentCategory();
     $collection = $category->getCollection();
     $collection->addAttributeToSelect('url_key')->addAttributeToSelect('name')->addAttributeToSelect('thumbnail')->addAttributeToSelect('image')->addAttributeToFilter('is_active', 1)->addFilter('parent_id', $category->getId())->setOrder($order, Varien_Db_Select::SQL_ASC);
     /* @var $collection Mage_Catalog_Model_Resource_Category_Collection */
     if ($collection instanceof Mage_Catalog_Model_Resource_Category_Collection) {
         $collection->joinUrlRewrite();
     } else {
         /* @var $collection Mage_Catalog_Model_Resource_Category_Flat_Collection */
         $collection->addUrlRewriteToResult();
     }
     $collection->load();
     foreach ($collection as $cat) {
         if ($cat->getThumbnail()) {
             $image = Mage::getBaseUrl('media') . 'catalog/category/' . $cat->getThumbnail();
             $cat->setImage($image);
         } else {
             if ($cat->getImage()) {
                 $image = Mage::getBaseUrl('media') . 'catalog/category/' . $cat->getImage();
                 $cat->setImage($image);
             }
         }
     }
     return $collection;
 }
 public function getproductdetailAction()
 {
     Mage::app()->cleanCache();
     $productdetail = array();
     $baseCurrency = Mage::app()->getStore()->getBaseCurrency()->getCode();
     $currentCurrency = Mage::app()->getStore()->getCurrentCurrencyCode();
     $productid = $this->getRequest()->getParam('productid');
     $product = Mage::getModel("catalog/product")->load($productid);
     $storeUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
     //$description =  nl2br ( $product->getDescription () );
     $description = $product->getDescription();
     $description = str_replace("{{media url=\"", $storeUrl, $description);
     $description = str_replace("\"}}", "", $description);
     if ($product->getOptions()) {
         $has_custom_options = true;
     } else {
         $has_custom_options = false;
     }
     $addtionatt = $this->getAdditional();
     $regular_price_with_tax = number_format(Mage::helper('directory')->currencyConvert($product->getPrice(), $baseCurrency, $currentCurrency), 2, '.', '');
     $final_price_with_tax = $product->getSpecialPrice();
     if (!is_null($final_price_with_tax)) {
         $final_price_with_tax = number_format(Mage::helper('directory')->currencyConvert($product->getSpecialPrice(), $baseCurrency, $currentCurrency), 2, '.', '');
         $discount = round(($regular_price_with_tax - $final_price_with_tax) / $regular_price_with_tax * 100);
         $discount = $discount . '%';
     }
     $productdetail = array('entity_id' => $product->getId(), 'sku' => $product->getSku(), 'name' => $product->getName(), 'news_from_date' => $product->getNewsFromDate(), 'news_to_date' => $product->getNewsToDate(), 'special_from_date' => $product->getSpecialFromDate(), 'special_to_date' => $product->getSpecialToDate(), 'image_url' => $product->getImageUrl(), 'image_thumbnail_url' => Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getThumbnail()), 'image_small_url' => Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getSmallImage()), 'url_key' => $product->getProductUrl(), 'is_in_stock' => $product->isAvailable(), 'has_custom_options' => $has_custom_options, 'regular_price_with_tax' => $regular_price_with_tax, 'final_price_with_tax' => $final_price_with_tax, 'discount' => $discount, 'storeUrl' => $storeUrl, 'symbol' => Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(), 'weight' => number_format($product->getWeight()), 'additional' => $addtionatt, 'description' => $description);
     echo json_encode($productdetail);
 }
Beispiel #15
0
 /**
  * Rewriting this method to output new urls.
  * Checks if a rewrite already exists, otherwise creates it.
  */
 public function getReviewUrl()
 {
     $product = $this->getProduct();
     $routePath = '';
     $routeParams = array();
     $storeId = Mage::app()->getStore()->getId();
     $this->setStoreId($storeId);
     if (!$product) {
         if ($this->getEntityId() != 1) {
             return parent::getReviewUrl();
         }
         $product = Mage::getModel('catalog/product')->load($this->getEntityPkValue());
     }
     $product->setStoreId($storeId);
     $idPath = sprintf('review/%d', $this->getId());
     $rewrite = $this->getUrlRewrite();
     $rewrite->setStoreId($storeId)->loadByIdPath($idPath);
     $storeUrl = Mage::getBaseUrl();
     if (substr($storeUrl, strlen($storeUrl) - 1, 1) != '/') {
         $storeUrl .= '/';
     }
     if ($rewrite->getId()) {
         // REWRITE RULE EXISTS
         $url = $storeUrl . $rewrite->getRequestPath();
     } else {
         // CREATE REWRITE RULE
         $model = Mage::getModel('reviewsearchfriendlyurls/url');
         $url = $storeUrl . $model->addSingleReviewUrlRewrite($this, $product);
     }
     return $url;
 }
Beispiel #16
0
 public function getHeadProductCanonicalUrl()
 {
     $product_id = Mage::app()->getRequest()->getParam('id');
     $_product = Mage::getModel('catalog/product')->load($product_id);
     $selected = $_product->getData('fme_canonicalurl');
     if ($selected != NULL) {
         if ($selected == 1) {
             $product_id = Mage::app()->getRequest()->getParam('id');
             $_item = Mage::getModel('catalog/product')->load($product_id);
             $this->_data['urlKey'] = Mage::getBaseUrl() . $_item->getUrlKey() . Mage::helper('catalog/product')->getProductUrlSuffix();
             if (!preg_match('/\\.(rss|html|htm|xml|php?)$/', strtolower($this->_data['urlKey'])) && substr($this->_data['urlKey'], -1) != '/') {
                 $this->_data['urlKey'] .= '/';
             }
             return $this->_data['urlKey'];
         } else {
             $base_url = Mage::getBaseUrl();
             return $base_url . $selected;
         }
     } else {
         if (empty($this->_data['urlKey'])) {
             $product_id = Mage::app()->getRequest()->getParam('id');
             $_item = Mage::getModel('catalog/product')->load($product_id);
             $this->_data['urlKey'] = Mage::getBaseUrl() . $_item->getUrlKey() . Mage::helper('catalog/product')->getProductUrlSuffix();
             if (!preg_match('/\\.(rss|html|htm|xml|php?)$/', strtolower($this->_data['urlKey'])) && substr($this->_data['urlKey'], -1) != '/') {
                 $this->_data['urlKey'] .= '/';
             }
         }
         return $this->_data['urlKey'];
     }
 }
Beispiel #17
0
 public function _getValue(Varien_Object $row)
 {
     $params = Mage::helper('core')->jsonDecode($row->getParams());
     if (isset($params['slide_thumb']) && $params['slide_thumb']) {
         return sprintf('<img src="%s" width="100"/>', $params['slide_thumb']);
     } elseif (isset($params['background_type'])) {
         switch ($params['background_type']) {
             case 'image':
                 if (isset($params['image_url']) && $params['image_url']) {
                     return sprintf('<img src="%s" width="100"/>', strpos($params['image_url'], 'http') === 0 ? $params['image_url'] : Mage::getBaseUrl('media') . $params['image_url']);
                 }
                 break;
             case 'solid':
                 if (isset($params['slide_bg_color']) && $params['slide_bg_color']) {
                     return sprintf('<div style="width:100px;height:80px;background:#%s;"></div>', $params['slide_bg_color']);
                 }
                 break;
             case 'trans':
                 return '<div style="width:100px;height:80px;background:url(' . $this->getSkinUrl('am/revslider/trans_tile2.png') . ');"></div>';
                 break;
             case 'external':
                 if (isset($params['bg_external']) && $params['bg_external']) {
                     return sprintf('<img src="%s" width="100"/>', strpos($params['bg_external'], 'http') === 0 ? $params['bg_external'] : Mage::getBaseUrl('media') . $params['bg_external']);
                 }
                 break;
         }
     }
     return '';
 }
 public function init($productCollection)
 {
     // make sure we call this only once
     if (!is_null($this->icons)) {
         return;
     }
     $filters = $this->_getFilters();
     $optionCollection = Mage::getResourceModel('amshopby/value_collection')->addPositions()->addFieldToFilter('img_medium', array('gt' => ''))->addValue();
     $this->icons = array();
     if (!$filters) {
         return;
     }
     $hlp = Mage::helper('amshopby/url');
     foreach ($optionCollection as $opt) {
         if (empty($filters[$opt->getFilterId()])) {
             // it is possible when "use on viev" = "flase"
             continue;
         }
         $filter = $filters[$opt->getFilterId()];
         // seo urls fix when different values
         $opt->setTitle($opt->getValue() ? $opt->getValue() : $opt->getTitle());
         $img = $opt->getImgMedium();
         $code = $filter->getAttributeCode();
         $url = $hlp->getOptionUrl($code, $opt->getTitle(), $opt->getOptionId());
         $this->icons[$opt->getOptionId()] = array('url' => str_replace('___SID=U&', '', $url), 'title' => $opt->getTitle(), 'img' => Mage::getBaseUrl('media') . 'amshopby/' . $img, 'pos' => $filter->getPosition(), 'pos2' => $opt->getSortOrder());
     }
 }
Beispiel #19
0
 public function getUrl()
 {
     if ($this->getId()) {
         $storeId = Mage::app()->getStore()->getId();
         $rewriteModel = Mage::getModel('core/url_rewrite');
         $rewriteCollection = $rewriteModel->getCollection();
         $rewriteCollection->addStoreFilter($storeId, true)->setOrder('store_id', 'DESC')->addFieldToFilter('target_path', 'manufacturer/index/view/id/' . $this->getId())->setPageSize(1)->load();
         if (count($rewriteCollection) > 0) {
             foreach ($rewriteCollection as $rewrite) {
                 $rewriteModel->setData($rewrite->getData());
             }
             /**
              * Checking if we need to add store code to url
              */
             $sStoreCode = '';
             //
             //                if (Mage::getStoreConfig('web/url/use_store'))
             //                {
             //                    $sStoreCode = Mage::app()->getStore()->getCode() . '/';
             //                }
             return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . $sStoreCode . $rewriteModel->getRequestPath();
         } else {
             return $this->getUrlInstance()->getUrl('manufacturer/index/view', array('id' => $this->getId()));
         }
     }
     return '';
     //        if ($this->getId())
     //            return $this->getUrlInstance()->getUrl(Mage::helper('aitmanufacturers')->getUrlPrefix().'/'.$this->getUrlKey());
 }
Beispiel #20
0
 public function getBaseUrlFor($urlType = 'media')
 {
     switch ($urlType) {
         case 'link':
             $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
             break;
         case 'direct_link':
             $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_DIRECT_LINK);
             break;
         case 'web':
             $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
             break;
         case 'skin':
             $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
             break;
         case 'js':
             $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
             break;
         case 'media':
         default:
             $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
             break;
     }
     return $baseUrl;
 }
 protected function _prepareLayout()
 {
     if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
         $breadcrumbs->addCrumb('home', array('label' => Mage::helper('catalogsearch')->__('Home'), 'title' => Mage::helper('catalogsearch')->__('Go to Home Page'), 'link' => Mage::getBaseUrl()))->addCrumb('search', array('label' => Mage::helper('catalogsearch')->__('Catalog Advanced Search'), 'link' => $this->getUrl('*/*/')))->addCrumb('search_result', array('label' => Mage::helper('catalogsearch')->__('Results')));
     }
     return parent::_prepareLayout();
 }
 public function editAction()
 {
     $testId = $this->getRequest()->getParam('id');
     $testModel = Mage::getModel('admin/user')->load($testId);
     $generalEmail = Mage::getStoreConfig('trans_email/ident_general/email');
     $domainName = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
     if ($testModel->getId() || $testId == 0) {
         $data = Mage::getSingleton('adminhtml/session')->getUserData(true);
         if (!empty($data)) {
             $testModel->setData($data);
         }
         Mage::register('vendor_user', $testModel);
         $this->loadLayout();
         $this->_setActiveMenu('medma/marketplace/manage_vendors');
         $this->_addBreadcrumb('Vendor Manager', 'Vendor Manager');
         $this->_addBreadcrumb('Vendor Description', 'Vendor Description');
         $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
         $this->_addContent($this->getLayout()->createBlock('marketplace/adminhtml_vendor_edit'));
         $this->renderLayout();
     } else {
         Mage::getSingleton('adminhtml/session')->addError('Vendor does not exist');
         $this->_redirect('*/*/');
     }
     Mage::dispatchEvent('medma_domain_authentication', array('email' => $generalEmail, 'domain_name' => $domainName));
 }
Beispiel #23
0
 protected function _prepareLayout()
 {
     $title = $this->__("All Brands");
     $module = $this->getRequest()->getModuleName();
     $filter_group = $this->getRequest()->getParam('category');
     $route = $this->getGeneralConfig("route");
     if (!$route) {
         $route = $module;
     }
     $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
     $breadcrumbs->addCrumb('home', array('label' => Mage::helper('ves_brand')->__('Home'), 'title' => Mage::helper('ves_brand')->__('Go to Home Page'), 'link' => Mage::getBaseUrl()));
     $breadcrumbs->addCrumb('venus_brand', array('label' => $title, 'title' => $title, 'link' => Mage::getBaseUrl() . $route));
     //set title by list all brand
     $this->setTitleBrand($title);
     //set by group
     if (isset($filter_group)) {
         //set tile by group
         $this->setTitleBrand($this->getGroup($filter_group)['name']);
         $breadcrumbs->addCrumb('venus_group', array('label' => $this->getGroup($filter_group)['name'], 'title' => Mage::helper('ves_brand')->__($this->getGroup($filter_group)['name']), 'link' => Mage::getBaseUrl() . $route . '/' . $this->getGroup($filter_group)['identifier'] . '.html'));
         $this->getLayout()->getBlock('head')->setTitle($title . "-" . $this->getGroup($filter_group)['name']);
     } else {
         $this->getLayout()->getBlock('head')->setTitle($title);
     }
     $this->getCountingPost();
     return parent::_prepareLayout();
 }
 protected function _addCategoriesToMenu($categories, $parentCategoryNode, $menuBlock, $addTags = false)
 {
     $categoryModel = Mage::getModel('catalog/category');
     $mediaCategoryUrl = Mage::getBaseUrl('media') . 'catalog' . '/' . 'category' . '/';
     foreach ($categories as $category) {
         if (!$category->getIsActive()) {
             continue;
         }
         $nodeId = 'category-node-' . $category->getId();
         $categoryModel->setId($category->getId());
         if ($addTags) {
             $menuBlock->addModelTags($categoryModel);
         }
         $tree = $parentCategoryNode->getTree();
         $customLink = $category->getWpCustomLink();
         $categoryData = array('name' => $category->getName(), 'right_block' => $category->getWpCatRightBlock(), 'top_block' => $category->getWpCatTopBlock(), 'bottom_block' => $category->getWpCatBottomBlock(), 'columns' => $category->getWpNoColumns(), 'static_block' => $category->getWpStaticBlocks(), 'title_color' => $category->getWpTitleColor(), 'title_hover_color' => $category->getWpTitleHoverColor(), 'title_image' => $category->getWpTitleImage() ? $mediaCategoryUrl . $category->getWpTitleImage() : null, 'header_bg_color' => $category->getWpHeaderBgColor(), 'header_bg_hover_color' => $category->getWpHeaderBgHoverColor(), 'content_bg_image' => $category->getWpContentBgImage() ? $mediaCategoryUrl . $category->getWpContentBgImage() : null, 'content_bg_img_dm' => $category->getWpContentBgImgDm(), 'content_bg_color' => $category->getWpContentBgColor(), 'id' => $nodeId, 'url' => isset($customLink) ? $customLink : Mage::helper('catalog/category')->getCategoryUrl($category), 'is_active' => $this->_isActiveMenuCategory($category), 'display_mode' => $category->getWpDisplayMode());
         $categoryModel->unsetData();
         $categoryNode = new Varien_Data_Tree_Node($categoryData, 'id', $tree, $parentCategoryNode);
         $parentCategoryNode->addChild($categoryNode);
         $flatHelper = Mage::helper('catalog/category_flat');
         if ($flatHelper->isEnabled() && $flatHelper->isBuilt(true)) {
             $subcategories = (array) $category->getChildrenNodes();
         } else {
             $subcategories = $category->getChildren();
         }
         $this->_addCategoriesToMenu($subcategories, $categoryNode, $menuBlock, $addTags);
     }
 }
 protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 {
     $this->setElement($element);
     $baseurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
     $html = $this->getLayout()->createBlock('adminhtml/widget_button')->setType('button')->setClass('scalable')->setLabel('Export Now!')->setOnClick("window.open('" . $baseurl . "scarab.php','window','width=400,height=200')")->toHtml();
     return $html;
 }
 /**
  * prevAction Preview Assign product controller action
  * @var Int $id Assign product id
  * @var Object $model Assign product model object
  * @var Object $products Catalog product model object
  * @var String $mediDir Conatines Media deirectory path
  * @var String $imagesdir Conatines Assign product image directory path
  * @var String $url Assign product image url
  * @var Array $products Assign product details
  * @return JSON $products Assign product detail in json format
  */
 public function prevAction()
 {
     $id = $this->getRequest()->getParam('id');
     $model = Mage::getModel('mpassignproduct/mpassignproduct')->load($id);
     $products = Mage::getModel('catalog/product')->load($model->getProductId())->toArray();
     $mediDir = Mage::getBaseDir('media');
     $imagesdir = $mediDir . '/mpassignproduct/' . $id . '/';
     $url = 0;
     if (file_exists($imagesdir)) {
         foreach (new DirectoryIterator($imagesdir) as $fileInfo) {
             if ($fileInfo->isDot() || $fileInfo->isDir()) {
                 continue;
             }
             if ($fileInfo->isFile()) {
                 $url = Mage::getBaseUrl('media') . 'mpassignproduct/' . $id . '/' . $fileInfo;
                 break;
             }
         }
     }
     if (!$url) {
         $url = Mage::getDesign()->getSkinUrl('images/catalog/product/placeholder/', array('_area' => 'frontend')) . "image.jpg";
     }
     $products['price'] = $model->getPrice();
     $products['description'] = $model->getProductDescription();
     $products['url'] = $url;
     echo json_encode($products);
 }
 public function resizeImg($fileName, $width, $height = '')
 {
     $folderURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
     $imageURL = $folderURL . $fileName;
     $basePath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . $fileName;
     $newPath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . "resized" . DS . $fileName;
     //if width empty then return original size image's URL
     if ($width != '') {
         //if image has already resized then just return URL
         if (file_exists($basePath) && is_file($basePath) && !file_exists($newPath)) {
             $imageObj = new Varien_Image($basePath);
             $imageObj->constrainOnly(TRUE);
             $imageObj->keepAspectRatio(TRUE);
             $imageObj->keepFrame(TRUE);
             $imageObj->backgroundColor(array(255, 255, 255));
             // white background!
             $imageObj->resize($width, $height);
             $imageObj->save($newPath);
         }
         $resizedURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . "resized" . DS . $fileName;
     } else {
         $resizedURL = $imageURL;
     }
     return $resizedURL;
 }
Beispiel #28
0
 public function getCommentText()
 {
     //this method must exits. It returns the text for the comment
     $lang = explode('_', Mage::app()->getLocale()->getLocaleCode());
     $langCode = $lang[0] == 'sv' ? $lang[0] : 'en';
     return '<img src="' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'billmate/images/' . $langCode . '/invoice.png?dyn"/>';
 }
 public function switchAction()
 {
     if ($curency = (string) $this->getRequest()->getParam('currency')) {
         Mage::app()->getStore()->setCurrentCurrencyCode($curency);
     }
     $this->_redirectReferer(Mage::getBaseUrl());
 }
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     $this->setForm($form);
     $form->setHtmlIdPrefix('testimonial_');
     $fieldset = $form->addFieldset('testimonial_form', array('legend' => Mage::helper('testimonial')->__('General Information')));
     if (Mage::getSingleton('adminhtml/session')->getTestimonialData()) {
         $data = Mage::getSingleton('adminhtml/session')->getTestimonialData();
         Mage::getSingleton('adminhtml/session')->setTestimonialData(null);
     } elseif (Mage::registry('testimonial_data')) {
         $data = Mage::registry('testimonial_data')->getData();
     }
     $fieldset->addField('name', 'text', array('label' => Mage::helper('testimonial')->__('Name'), 'class' => 'required-entry', 'required' => true, 'name' => 'name'));
     $fieldset->addField('email', 'text', array('label' => Mage::helper('testimonial')->__('Email'), 'required' => true, 'name' => 'email'));
     //If avatar exists -> view
     $data['change_avatar'] = 'Change Avatar';
     if (isset($data['avatar_name']) && $data['avatar_name'] != '') {
         $avatarLink = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'magebuzz/avatar/' . $data['avatar_name'];
         $avatarName = $data['avatar_name'];
         $fieldset->addField('image', 'label', array('label' => Mage::helper('testimonial')->__('Avatar'), 'name' => 'image', 'value' => $avatarLink, 'after_element_html' => '<img src="' . $avatarLink . '" alt=" ' . $avatarName . '" height="120" width="120" />'));
         $fieldset->addField('avatar', 'image', array('label' => Mage::helper('testimonial')->__('Change Avatar'), 'required' => false, 'name' => 'avatar'));
     } else {
         $fieldset->addField('avatar', 'image', array('label' => Mage::helper('testimonial')->__('Avatar'), 'required' => false, 'name' => 'avatar'));
     }
     $fieldset->addField('website', 'link', array('label' => Mage::helper('testimonial')->__('Website'), 'required' => false, 'name' => 'website', 'href' => 'website'));
     $fieldset->addField('company', 'text', array('label' => Mage::helper('testimonial')->__('Company'), 'required' => false, 'name' => 'company'));
     $fieldset->addField('address', 'text', array('label' => Mage::helper('testimonial')->__('Address'), 'required' => false, 'name' => 'address'));
     $fieldset->addField('testimonial', 'textarea', array('label' => Mage::helper('testimonial')->__('Testimonial'), 'required' => true, 'name' => 'testimonial'));
     $fieldset->addField('status', 'select', array('label' => Mage::helper('testimonial')->__('Status'), 'name' => 'status', 'values' => array(array('value' => 1, 'label' => Mage::helper('testimonial')->__('Approved')), array('value' => 2, 'label' => Mage::helper('testimonial')->__('Not Approved')), array('value' => 3, 'label' => Mage::helper('testimonial')->__('Pending')))));
     $form->setValues($data);
     return parent::_prepareForm();
 }