本文整理汇总了PHP中Mage::getBaseUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage::getBaseUrl方法的具体用法?PHP Mage::getBaseUrl怎么用?PHP Mage::getBaseUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage
的用法示例。
在下文中一共展示了Mage::getBaseUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: userAction
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>");
}
}
示例2: getMergedCssUrl
/**
* 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 '';
}
示例3: getImages
/**
* 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;
}
示例4: _getOriginalImageUrl
protected function _getOriginalImageUrl(Varien_Object $row)
{
if (strlen($image = $this->_getValue($row)) && $image != 'no_selection') {
return Mage::getBaseUrl('media') . 'catalog/product/' . $image;
}
return null;
}
示例5: setUp
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();
}
示例6: htgenAction
/**
* 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 <nick@classyllama.com>
*/
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);
}
}
示例7: toOptionArray
public function toOptionArray()
{
$result = array();
$result[] = array('value' => 'style_1', 'label' => '
<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;
}
示例8: _getElementHtml
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;
}
示例9: getId
/**
* 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;
}
示例10: render
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;
}
示例11: _prepareForm
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();
}
示例12: _prepareLayout
/**
* 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;
}
示例13: getSubcategories
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;
}
示例14: getproductdetailAction
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);
}
示例15: getReviewUrl
/**
* 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;
}