本文整理汇总了PHP中Mage::getBlockSingleton方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage::getBlockSingleton方法的具体用法?PHP Mage::getBlockSingleton怎么用?PHP Mage::getBlockSingleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage
的用法示例。
在下文中一共展示了Mage::getBlockSingleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _addHomeLink
protected function _addHomeLink()
{
if (Mage::getStoreConfig('weltpixel_megamenu/general/display_home_link')) {
$homeNode = new Varien_Data_Tree_Node(array('name' => 'Home', 'id' => 'home-link', 'url' => Mage::getBaseUrl(), 'is_active' => Mage::getBlockSingleton('page/html_header')->getIsHomePage()), 'id', $this->_menu->getTree());
$this->_menu->addChild($homeNode);
}
}
示例2: _prepareForm
protected function _prepareForm()
{
$model = Mage::registry('current_promo_checkoutrule_rule');
//$form = new Varien_Data_Form(array('id' => 'edit_form1', 'action' => $this->getData('action'), 'method' => 'post'));
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('rule_');
$renderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset')->setTemplate('promo/fieldset.phtml')->setNewChildUrl($this->getUrl('*/promo_checkoutrule/newConditionHtml/form/rule_conditions_fieldset'));
$fieldset = $form->addFieldset('conditions_fieldset', array('legend' => Mage::helper('checkoutrule')->__('Apply the rule only if the following conditions are met (leave blank for all products)')))->setRenderer($renderer);
$fieldset->addField('conditions', 'text', array('name' => 'conditions', 'label' => Mage::helper('checkoutrule')->__('Conditions'), 'title' => Mage::helper('checkoutrule')->__('Conditions')))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/conditions'));
/*
$fieldset = $form->addFieldset('actions_fieldset', array(
'legend'=>Mage::helper('checkoutrule')->__('Apply the rule to cart items matching the following conditions')
))->setRenderer($renderer);
$fieldset->addField('actions', 'text', array(
'name' => 'actions',
'label' => Mage::helper('checkoutrule')->__('Apply To'),
'title' => Mage::helper('checkoutrule')->__('Apply To'),
'required' => true,
))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/actions'));
*/
$form->setValues($model->getData());
//$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例3: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$html = $this->_getHeaderHtml($element);
$renderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
$attributes = Mage::getConfig()->getNode(self::XML_PATH_IMAGE_TYPES)->asArray();
foreach ($attributes as $key => $attribute) {
/**
* Watermark size field
*/
$field = new Varien_Data_Form_Element_Text();
$field->setName("groups[watermark][fields][{$key}_size][value]")->setForm($this->getForm())->setLabel(Mage::helper('adminhtml')->__('Size for %s', $attribute['title']))->setRenderer($renderer);
$html .= $field->toHtml();
/**
* Watermark upload field
*/
$field = new Varien_Data_Form_Element_Imagefile();
$field->setName("groups[watermark][fields][{$key}_image][value]")->setForm($this->getForm())->setLabel(Mage::helper('adminhtml')->__('Watermark File for %s', $attribute['title']))->setRenderer($renderer);
$html .= $field->toHtml();
/**
* Watermark position field
*/
$field = new Varien_Data_Form_Element_Select();
$field->setName("groups[watermark][fields][{$key}_position][value]")->setForm($this->getForm())->setLabel(Mage::helper('adminhtml')->__('Position of Watermark for %s', $attribute['title']))->setRenderer($renderer)->setValues(Mage::getSingleton('adminhtml/system_config_source_catalog_product_watermark_position')->toOptionArray());
$html .= $field->toHtml();
}
$html .= $this->_getFooterHtml($element);
return $html;
}
示例4: _sendEmail
protected function _sendEmail()
{
$data = $this->getRequest()->getParams();
$senderInfo = $data['sender'];
$recipients = $data['recipients'];
$recipientEmail = $recipients['email'];
$recipientName = $recipients['name'];
$offer = Mage::getModel('customerreward/offer')->load($this->getRequest()->getParam('offer_id'));
$offer->setCurrentDate(Mage::helper('core')->formatDate(now(), 'long'));
$description = Mage::getBlockSingleton('customerreward/offer_view')->setOffer($offer)->getTitleDescriptionHtml();
$offer->setTitleHtml($description['title']);
$offer->setDescription($description['description']);
$offer->setImageUrl(Mage::getBaseUrl('media') . $offer->getImage());
if (Mage::helper('customerreward')->getReferConfig('coupon')) {
$offer->setCoupon($data['coupon']);
}
//send email
$translate = Mage::getSingleton('core/translate');
$translate->setTranslateInline(false);
$mailTemplate = Mage::getModel('core/email_template');
$message = nl2br(htmlspecialchars($senderInfo['message']));
$sender = array('name' => Mage::helper('customerreward')->htmlEscape($senderInfo['name']), 'email' => Mage::helper('customerreward')->htmlEscape($senderInfo['email']));
$mailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => Mage::app()->getStore()->getId()));
$template = Mage::helper('customerreward')->getEmailConfig('sendfriend');
foreach ($recipientEmail as $k => $email) {
$name = $recipientName[$k];
$mailTemplate->sendTransactional($template, 'sales', $email, $name, array('store' => Mage::app()->getStore(), 'name' => $name, 'email' => $email, 'message' => $message, 'sender_name' => $sender['name'], 'sender_email' => $sender['email'], 'title' => $data['title'], 'url' => $data['url'], 'offer' => $offer));
}
$translate->setTranslateInline(true);
return $this;
}
示例5: _getFieldRenderer
protected function _getFieldRenderer()
{
if (empty($this->_fieldRenderer)) {
$this->_fieldRenderer = Mage::getBlockSingleton('Mage_Adminhtml_Block_System_Config_Form_Field');
}
return $this->_fieldRenderer;
}
示例6: getStateInfo
public function getStateInfo()
{
$_hlp = $this->_helper;
//Check the Layered Nav position (Search or Catalog pages)
$ajaxUrl = '';
if ($_hlp->isSearch()) {
$ajaxUrl = Mage::getUrl('layerednav/front/search');
} elseif ($cat = $this->getLayer()->getCurrentCategory()) {
$ajaxUrl = Mage::getUrl('layerednav/front/category', array('id' => $cat->getId()));
}
$ajaxUrl = $_hlp->stripQuery($ajaxUrl);
$url = $_hlp->getContinueShoppingUrl();
//Set the AJAX Pagination
$pageKey = Mage::getBlockSingleton('page/html_pager')->getPageVarName();
//Get parameters of serach
$queryStr = $_hlp->getParams(true, $pageKey);
if ($queryStr) {
$queryStr = substr($queryStr, 1);
}
$this->setClearAllUrl($_hlp->getClearAllUrl($url));
if (false !== strpos($url, '?')) {
$url = substr($url, 0, strpos($url, '?'));
}
return array($url, $queryStr, $ajaxUrl);
}
示例7: initProductSearch
/**
* process controller_action_predispatch_webpos_index_productsearch event
*
* @return Magestore_Inventorywebpos_Model_Observer
*/
public function initProductSearch($observer)
{
$keyword = Mage::app()->getRequest()->getPost('keyword');
$barcode = Mage::getModel('inventorybarcode/barcode')->load($keyword, 'barcode');
$result = array();
$storeId = Mage::app()->getStore()->getStoreId();
$showOutofstock = Mage::getStoreConfig('webpos/general/show_product_outofstock', $storeId);
$productBlock = Mage::getBlockSingleton('catalog/product_list');
if ($barcode->getId()) {
$productId = $barcode->getProductEntityId();
$product = Mage::getModel('catalog/product')->load($productId);
$addToCart = $productBlock->getAddToCartUrl($product) . 'tempadd/1';
$result[] = $productId;
$html = '';
$html .= '<ul>';
$html .= '<li id="sku_only" url="' . $addToCart . '" onclick="setLocation(\'' . $addToCart . '\')">';
$html .= '<strong>' . Mage::getBlockSingleton('core/template')->htmlEscape($product->getName()) . '</strong>-' . Mage::helper('core')->currency($product->getFinalPrice());
$html .= '<br /><strong>SKU: </strong>' . $product->getSku();
if ($showOutofstock) {
$html .= '<br />';
if ($product->isAvailable()) {
$html .= '<p class="availability in-stock">' . Mage::helper('inventorywebpos')->__('Availability:') . '<span>' . Mage::helper('inventorywebpos')->__('In stock') . '</span></p><div style="clear:both"></div>';
} else {
$html .= '<p class="availability out-of-stock">' . Mage::helper('inventorywebpos')->__('Availability:') . '<span>' . Mage::helper('inventorywebpos')->__('Out of stock') . '</span></p><div style="clear:both"></div>';
}
}
$html .= '</li>';
$html .= '</ul>';
echo $html;
return;
} else {
$searchInstance = new Magestore_Inventorywebpos_Model_Search_Barcode();
$results = $searchInstance->setStart(1)->setLimit(10)->setQuery($keyword)->load()->getResults();
if (count($results)) {
$html = '';
$html .= '<ul>';
foreach ($results as $item) {
$productId = $item['product_id'];
$product = Mage::getModel('catalog/product')->load($productId);
$addToCart = $productBlock->getAddToCartUrl($product) . 'tempadd/1';
$result[] = $product->getId();
$html .= '<li onclick="setLocation(\'' . $addToCart . '\')">';
$html .= '<strong>' . Mage::getBlockSingleton('core/template')->htmlEscape($product->getName()) . '</strong>-' . Mage::helper('core')->currency($product->getFinalPrice());
$html .= '<br /><strong>SKU: </strong>' . $product->getSku();
if ($showOutofstock) {
$html .= '<br />';
if ($product->isAvailable()) {
$html .= '<p class="availability in-stock">' . Mage::helper('inventorywebpos')->__('Availability:') . '<span>' . Mage::helper('inventorywebpos')->__('In stock') . '</span></p><div style="clear:both"></div>';
} else {
$html .= '<p class="availability out-of-stock">' . Mage::helper('inventorywebpos')->__('Availability:') . '<span>' . Mage::helper('inventorywebpos')->__('Out of stock') . '</span></p><div style="clear:both"></div>';
}
}
$html .= '</li>';
}
$html .= '</ul>';
echo $html;
return;
}
}
}
示例8: getRemoveUrl
/**
* Returns URL which should be loaded if person chooses to remove this filter item from active filters
* @return string
* @see Mage_Catalog_Model_Layer_Filter_Item::getRemoveUrl()
* This method is overridden by copying (method body was pasted from parent class and modified as needed). All
* changes are marked with comments.
*/
public function getRemoveUrl()
{
// MANA BEGIN: add multivalue filter handling
if ($this->hasData('remove_url')) {
return $this->getData('remove_url');
}
$values = $this->getFilter()->getMSelectedValues();
// this could fail if called from some kind of standard filter
if (!$values) {
$values = array();
}
unset($values[array_search($this->getValue(), $values)]);
if (count($values) > 0) {
$query = array($this->getFilter()->getRequestVar() => implode('_', $values), Mage::getBlockSingleton('page/html_pager')->getPageVarName() => null);
} else {
$query = array($this->getFilter()->getRequestVar() => $this->getFilter()->getResetValue());
}
// MANA END
$params = array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure());
$params['_current'] = true;
$params['_use_rewrite'] = true;
$params['_m_escape'] = '';
$params['_query'] = $query;
return Mage::helper('mana_filters')->markLayeredNavigationUrl(Mage::getUrl('*/*/*', $params), '*/*/*', $params);
}
示例9: getUrl
public function getUrl()
{
$request = Mage::app()->getRequest();
if ($request->getModuleName() == 'catalogsearch') {
return parent::getUrl();
}
if ($this->getFilter() instanceof Mage_Catalog_Model_Layer_Filter_Category) {
$category = Mage::getModel('catalog/category')->load($this->getValue());
$query = array(Mage::getBlockSingleton('page/html_pager')->getPageVarName() => null);
$suffix = Mage::getStoreConfig('catalog/seo/category_url_suffix');
$catpart = str_replace($suffix, '', $category->getUrl());
if (preg_match('/\\/l\\/.+/', Mage::app()->getRequest()->getOriginalPathInfo(), $matches)) {
$layeredpart = str_replace($suffix, '', $matches[0]);
} else {
$layeredpart = '';
}
return $catpart . $layeredpart . $suffix;
} else {
$var = $this->getFilter()->getRequestVar();
$request = Mage::app()->getRequest();
$labelValue = strpos($request->getRequestUri(), 'catalogsearch') !== false ? $this->getValue() : $this->getLabel();
$attribute = $this->getFilter()->getData('attribute_model');
//->getAttributeCode()
if ($attribute) {
$value = $attribute->getAttributeCode() == 'price' || $attribute->getBackendType() == 'decimal' ? $this->getValue() : $labelValue;
} else {
$value = $labelValue;
}
$query = array($var => $value, Mage::getBlockSingleton('page/html_pager')->getPageVarName() => null);
return Mage::helper('seosuite')->getLayerFilterUrl(array('_current' => true, '_use_rewrite' => true, '_query' => $query));
}
}
示例10: apiIndex
/**
* api page Dashboard
*
* ?call=bestsellers
* & params = {
* "page":"1",
* "limit":"10",
* "store":"1",
* "order_status":"string|array()",
* "date_range":"1d|7d|15d|30d|3m|6m|1y|2y|lt"
* }
*/
public function apiIndex($params)
{
//if filter by order status
if (isset($params['order_status'])) {
if (!is_array($params['order_status'])) {
$params['order_status'] = array($params['order_status']);
}
$this->_helper->setOrderStatus($params['order_status']);
}
//if filter by date range
if (isset($params['date_range'])) {
$this->_helper->setBestsellersDateRangeCode($params['date_range']);
}
$block_bestsellers = Mage::getBlockSingleton('simisalestrackingapi/bestsellers');
$rows = array();
$number = 0;
//number of bestsellers filtered
if ($collection = $this->_helper->getBestsellersCollection()) {
$collection->getSelect()->limit($params['limit'], $params['page'] * $params['limit']);
$data = $collection->getData();
$number = $this->_helper->getNumBestsellers();
foreach ($data as $r) {
$rows[] = array('product_id' => (int) $r['product_id'], 'sku' => $r['sku'], 'name' => $r['product_name'], 'qty' => (int) $r['qty'], 'sales' => Mage::helper('core')->currency($r['sales'], true, false));
}
}
return array('title' => $block_bestsellers->getTitleTime(), 'updated_at' => $block_bestsellers->getUpdatedTime(), 'is_old' => $block_bestsellers->isOld(), 'num_bestsellers' => $number, 'data' => $rows);
}
开发者ID:bigtailbear14,项目名称:rosstheme,代码行数:39,代码来源:Magestore_Simisalestrackingapi_Model_Api_Bestsellers.php
示例11: _prepareForm
protected function _prepareForm()
{
if (Mage::getSingleton('adminhtml/session')->getFormData()) {
$data = Mage::getSingleton('adminhtml/session')->getFormData();
} elseif ($this->getPeriod()) {
$data = $this->getPeriod()->getData();
}
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))), 'method' => 'post', 'enctype' => 'multipart/form-data'));
$fieldset = $form->addFieldset('period_details', array('legend' => $this->__('Period Details')));
$fieldset->addField('id', 'hidden', array('required' => false, 'name' => 'id'));
$fieldset->addField('name', 'text', array('required' => true, 'name' => 'name', 'label' => 'Name'));
$fieldset->addField('sort_order', 'text', array('required' => false, 'name' => 'sort_order', 'label' => 'Sort Order'));
$select = new Varien_Data_Form_Element_Select(array('name' => 'period_type', 'style' => 'width:241px', 'options' => Mage::getModel('sarp/source_periods')->getGridOptions()));
$select->setId('period_type')->setRenderer(Mage::getBlockSingleton('sarp/adminhtml_widget_form_renderer_element'))->setForm($form)->setValue(@$data['period_type']);
$fieldset->addField('period_value', 'text', array('required' => true, 'name' => 'period_value', 'label' => 'Repeat each', 'style' => 'width:30px', 'after_element_html' => $select->toHtml()));
$selectE = new Varien_Data_Form_Element_Select(array('name' => 'expire_type', 'style' => 'width:241px', 'options' => Mage::getModel('sarp/source_periods')->getGridOptions()));
$selectE->setId('expire_type')->setRenderer(Mage::getBlockSingleton('sarp/adminhtml_widget_form_renderer_element'))->setForm($form)->setValue(@$data['expire_type']);
$fieldset->addField('expire_value', 'text', array('required' => false, 'name' => 'expire_value', 'label' => 'Expires After', 'style' => 'width:30px', 'after_element_html' => $selectE->toHtml()));
$fieldset->addField('excluded_weekdays', 'multiselect', array('required' => false, 'name' => 'excluded_weekdays', 'label' => 'Exclude Weekdays', 'values' => Mage::getModel('sarp/source_periods_weekdays')->getAllOptions()));
$fieldset->addField('payment_offset', 'text', array('required' => false, 'name' => 'payment_offset', 'label' => 'Require payment before, days'));
if (!isset($data['expire_value']) || $data['expire_value'] == 0) {
$data['expire_value'] = '';
}
if (!isset($data['excluded_weekdays']) || !strlen($data['excluded_weekdays'])) {
$data['excluded_weekdays'] = -1;
}
$form->setValues($data);
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例12: _getAdditionalHtml
protected function _getAdditionalHtml()
{
if (Mage::getVersion() >= '1.4.0.1') {
$block = Mage::getBlockSingleton('aitunits/adjnav_layer_js');
return $block->toHtml();
}
}
示例13: render
public function render(Varien_Data_Form_Element_Abstract $element)
{
$this->setElement($element);
$model = Mage::getModel('salesrule/rule');
if ($websiteCode = $this->getRequest()->getParam('website')) {
$data = Mage::app()->getWebsite($websiteCode)->getConfig($this->_pathConfiguration);
}
if ($storeCode = $this->getRequest()->getParam('store')) {
$data = Mage::app()->getStore($storeCode)->getConfig($this->_pathConfiguration);
}
if (empty($data)) {
$data = Mage::getStoreConfig($this->_pathConfiguration, 0);
}
if (!empty($data)) {
$model->loadPost(unserialize($data));
}
$html = $this->_getHeaderHtml($element);
foreach ($element->getSortedElements() as $field) {
if ($field->getId() == 'atos_securecode_conditions') {
$field->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/conditions'));
$html .= '<tr id="row_' . $field->getId() . '">' . ' <td class="label"><label for="' . $field->getId() . '">' . $field->getLabel() . '</label></td>' . ' <td class="value"><div id="' . $field->getId() . '">' . $field->toHtml() . '</div></td>' . ' <td class="scope-label">' . $field->getScopeLabel() . '</td>' . ' <td class=""></td>' . '</tr>';
} else {
$html .= $field->toHtml();
}
}
$html .= $this->_getFooterHtml($element);
return $html;
}
示例14: _prepareForm
protected function _prepareForm()
{
//Création du formulaire et assignation au block
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))), 'method' => 'post'));
//On cree un fieldset auquel on va rajouter tous les champs
$fieldset = $form->addFieldset('edit_rule_id', array('legend' => $this->__('Customer AutoGroups Rule')));
$fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'required' => true, 'validate' => 'required-entry'));
$fieldset->addField('description', 'textarea', array('name' => 'description', 'label' => $this->__('Description'), 'required' => false, 'validate' => 'required-entry'));
$renderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset')->setTemplate('promo/fieldset.phtml')->setNewChildUrl($this->getUrl('*/promo_quote/newConditionHtml/form/rule_conditions_fieldset'));
$fieldset2 = $form->addFieldset('conditions_fieldset', array('legend' => $this->__('Select Customer Properties')))->setRenderer($renderer);
if (Mage::registry('autogroup_rule')) {
$model = Mage::registry('autogroup_rule');
} else {
$model = Mage::getModel('hhennes_autogroups/rule');
}
$fieldset2->addField('conditions', 'text', array('name' => 'conditions', 'label' => $this->__('Conditions'), 'title' => $this->__('Conditions')))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/conditions'));
//Récupération des groupes clients @ToDO voir pour utiliser les fonctions magento
$groups = Mage::helper('hhennes_autogroups')->getGroupList();
//Groupe de destination
$fieldset->addField('group_id', 'select', array('name' => 'group_id', 'label' => $this->__('Group'), 'required' => true, 'validate' => 'required-entry', 'options' => $groups));
$fieldset->addField('active', 'select', array('name' => 'active', 'label' => $this->__('Active'), 'required' => true, 'validate' => 'required-entry', 'options' => array('1' => $this->__('Yes'), '0' => $this->__('No'))));
$priority = Mage::helper('hhennes_autogroups')->getPrioritiesList();
$fieldset->addField('priority', 'select', array('name' => 'priority', 'label' => $this->__('priority'), 'required' => true, 'validate' => 'required-entry', 'options' => $priority));
$fieldset->addField('stop_processing', 'select', array('name' => 'stop_processing', 'label' => $this->__('Stop Processing'), 'required' => true, 'validate' => 'required-entry', 'options' => array('1' => $this->__('Yes'), '0' => $this->__('No'))));
if (Mage::registry('autogroup_rule')) {
$form->setValues(Mage::registry('autogroup_rule')->getData());
}
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例15: _prepareForm
protected function _prepareForm()
{
$model = Mage::registry('current_promo_quote_rule');
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('rule_');
$renderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset')->setTemplate('promo/fieldset.phtml');
$renderer->setNewChildUrl($this->getUrl('*/manage_promo_quote/newConditionHtml/form/rule_conditions_fieldset'));
$fieldset = $form->addFieldset('conditions_fieldset', array('legend' => Mage::helper('salesrule')->__('Apply the rule only if the following conditions are met (leave blank for all products)')))->setRenderer($renderer);
$fieldset->addField('conditions', 'text', array('name' => 'conditions', 'label' => Mage::helper('salesrule')->__('Conditions'), 'title' => Mage::helper('salesrule')->__('Conditions')))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/conditions'));
/*
$fieldset = $form->addFieldset('actions_fieldset', array(
'legend'=>Mage::helper('salesrule')->__('Apply the rule to cart items matching the following conditions')
))->setRenderer($renderer);
$fieldset->addField('actions', 'text', array(
'name' => 'actions',
'label' => Mage::helper('salesrule')->__('Apply to'),
'title' => Mage::helper('salesrule')->__('Apply to'),
'required' => true,
))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/actions'));
*/
if ($this->_isRedemptionType()) {
$this->_getPointsActionFieldset($form);
}
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}