本文整理汇总了PHP中Mage::registry方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage::registry方法的具体用法?PHP Mage::registry怎么用?PHP Mage::registry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage
的用法示例。
在下文中一共展示了Mage::registry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
$form->setHtmlIdPrefix("template");
$form->setFieldNameSuffix("template");
/* @var $template Mzax_Emarketing_Model_Template */
$template = Mage::registry('current_template');
if ($template->getId()) {
$form->addField('template_id', 'hidden', array('name' => 'template_id', 'value' => $template->getId()));
}
$fieldset = $form->addFieldset('base_fieldset', array('legend' => $this->__('Template Option'), 'class' => 'fieldset-wide'))->addType('editor', Mage::getConfig()->getModelClassName('mzax_emarketing/form_element_templateEditor'))->addType('credits', Mage::getConfig()->getModelClassName('mzax_emarketing/form_element_credits'));
$fieldset->addField('credits', 'credits', array('name' => 'credits', 'required' => true));
$fieldset->addField('name', 'text', array('name' => 'name', 'required' => true, 'label' => $this->__('Template Name'), 'title' => $this->__('Template Name')));
$fieldset->addField('description', 'textarea', array('name' => 'description', 'required' => true, 'label' => $this->__('Description'), 'title' => $this->__('Description'), 'style' => 'height:4em;', 'note' => "For internal use only"));
$snippets = new Mzax_Emarketing_Model_Medium_Email_Snippets();
Mage::getSingleton('mzax_emarketing/medium_email')->prepareSnippets($snippets);
$editorConfig = new Varien_Object();
$editorConfig->setFilesBrowserWindowUrl($this->getUrl('adminhtml/cms_wysiwyg_images/index'));
$editorConfig->setWidgetWindowUrl($this->getUrl('adminhtml/widget/index'));
$editorConfig->setSnippets($snippets);
$editor = $fieldset->addField('body', 'editor', array('name' => 'body', 'required' => true, 'label' => $this->__('Template HTML'), 'title' => $this->__('Template HTML'), 'logo' => $this->getSkinUrl('images/logo.gif'), 'fullscreen_title' => $this->__('Template %s', $template->getName()), 'style' => 'height:50em;', 'value' => '', 'config' => $editorConfig));
// Setting custom renderer for content field to remove label column
$renderer = $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset_element')->setTemplate('cms/page/edit/form/renderer/content.phtml');
$editor->setRenderer($renderer);
$form->addValues($template->getData());
$this->setForm($form);
$form->setUseContainer(true);
return parent::_prepareForm();
}
示例2: getTag
public function getTag()
{
if (!$this->_tag) {
$this->_tag = Mage::registry('tagModel');
}
return $this->_tag;
}
示例3: __construct
public function __construct()
{
parent::__construct();
$this->setTemplate('sales/order/details.phtml');
$this->setOrder(Mage::getModel('sales/order')->load($this->getRequest()->getParam('order_id')));
Mage::registry('action')->getLayout()->getBlock('root')->setHeaderTitle(Mage::helper('sales')->__('Order Details'));
}
示例4: editAction
public function editAction()
{
$id = (int) $this->getRequest()->getParam('id');
$model = Mage::getModel('amgroupcat/rules')->load($id);
$postData = Mage::registry('amgroupcat_rules_saved_data');
if ($id == 0 && $postData) {
$model = Mage::getModel('amgroupcat/rules')->load($id);
} else {
if ($id && !$model->getId()) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('amgroupcat')->__('Record does not exist'));
$this->_redirect('*/*/');
return;
}
}
/*
* save form data for all children tabs forms
*/
Mage::register('amgroupcat_rules', $model);
/*
* add tabs on page
*/
$this->loadLayout();
$this->_setActiveMenu('catalog/amgroupcat/rules');
$this->_title($this->__($id ? 'Edit rule' : 'New rule'));
$this->_addContent($this->getLayout()->createBlock('amgroupcat/adminhtml_rules_edit'));
$this->_addLeft($this->getLayout()->createBlock('amgroupcat/adminhtml_rules_edit_tabs'));
/*
* add ExtJS library for "Category Access Restriction" tab with hierarchical visual output categories
*/
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true)->setCanLoadRulesJs(true);
$this->renderLayout();
}
示例5: getProduct
function getProduct()
{
if (!$this->_product) {
$this->_product = Mage::registry('product');
}
return $this->_product;
}
示例6: _toHtml
protected function _toHtml()
{
$rssObj = Mage::getModel('rss/rss');
$order = Mage::registry('current_order');
$title = Mage::helper('rss')->__('Order # %s Notification(s)', $order->getIncrementId());
$newurl = Mage::getUrl('sales/order/view', array('order_id' => $order->getId()));
$data = array('title' => $title, 'description' => $title, 'link' => $newurl, 'charset' => 'UTF-8');
$rssObj->_addHeader($data);
$resourceModel = Mage::getResourceModel('rss/order');
$results = $resourceModel->getAllCommentCollection($order->getId());
if ($results) {
foreach ($results as $result) {
$urlAppend = 'view';
$type = $result['entity_type_code'];
if ($type && $type != 'order') {
$urlAppend = $type;
}
$type = Mage::helper('rss')->__(ucwords($type));
$title = Mage::helper('rss')->__('Details for %s #%s', $type, $result['increment_id']);
$description = '<p>' . Mage::helper('rss')->__('Notified Date: %s<br/>', $this->formatDate($result['created_at'])) . Mage::helper('rss')->__('Comment: %s<br/>', $result['comment']) . '</p>';
$url = Mage::getUrl('sales/order/' . $urlAppend, array('order_id' => $order->getId()));
$data = array('title' => $title, 'link' => $url, 'description' => $description);
$rssObj->_addEntry($data);
}
}
$title = Mage::helper('rss')->__('Order #%s created at %s', $order->getIncrementId(), $this->formatDate($order->getCreatedAt()));
$url = Mage::getUrl('sales/order/view', array('order_id' => $order->getId()));
$description = '<p>' . Mage::helper('rss')->__('Current Status: %s<br/>', $order->getStatusLabel()) . Mage::helper('rss')->__('Total: %s<br/>', $order->formatPrice($order->getGrandTotal())) . '</p>';
$data = array('title' => $title, 'link' => $url, 'description' => $description);
$rssObj->_addEntry($data);
return $rssObj->createRssXml();
}
示例7: getAttributeObject
public function getAttributeObject()
{
if (null === $this->_attribute) {
return Mage::registry('entity_attribute');
}
return $this->_attribute;
}
示例8: initForm
public function initForm()
{
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('_info');
$model = Mage::registry('current_giftcardaccount');
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('enterprise_giftcardaccount')->__('Information')));
if ($model->getId()) {
$fieldset->addField('code', 'label', array('name' => 'code', 'label' => Mage::helper('enterprise_giftcardaccount')->__('Gift Card Code'), 'title' => Mage::helper('enterprise_giftcardaccount')->__('Gift Card Code')));
$fieldset->addField('state_text', 'label', array('name' => 'state_text', 'label' => Mage::helper('enterprise_giftcardaccount')->__('Status'), 'title' => Mage::helper('enterprise_giftcardaccount')->__('Status')));
}
$fieldset->addField('status', 'select', array('label' => Mage::helper('enterprise_giftcardaccount')->__('Active'), 'title' => Mage::helper('enterprise_giftcardaccount')->__('Active'), 'name' => 'status', 'required' => true, 'options' => array(Enterprise_GiftCardAccount_Model_Giftcardaccount::STATUS_ENABLED => Mage::helper('enterprise_giftcardaccount')->__('Yes'), Enterprise_GiftCardAccount_Model_Giftcardaccount::STATUS_DISABLED => Mage::helper('enterprise_giftcardaccount')->__('No'))));
if (!$model->getId()) {
$model->setData('status', Enterprise_GiftCardAccount_Model_Giftcardaccount::STATUS_ENABLED);
}
$fieldset->addField('is_redeemable', 'select', array('label' => Mage::helper('enterprise_giftcardaccount')->__('Redeemable'), 'title' => Mage::helper('enterprise_giftcardaccount')->__('Redeemable'), 'name' => 'is_redeemable', 'required' => true, 'options' => array(Enterprise_GiftCardAccount_Model_Giftcardaccount::REDEEMABLE => Mage::helper('enterprise_giftcardaccount')->__('Yes'), Enterprise_GiftCardAccount_Model_Giftcardaccount::NOT_REDEEMABLE => Mage::helper('enterprise_giftcardaccount')->__('No'))));
if (!$model->getId()) {
$model->setData('is_redeemable', Enterprise_GiftCardAccount_Model_Giftcardaccount::REDEEMABLE);
}
$fieldset->addField('website_id', 'select', array('name' => 'website_id', 'label' => Mage::helper('enterprise_giftcardaccount')->__('Website'), 'title' => Mage::helper('enterprise_giftcardaccount')->__('Website'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm(true)));
$fieldset->addType('price', 'Enterprise_GiftCardAccount_Block_Adminhtml_Giftcardaccount_Form_Price');
$fieldset->addField('balance', 'price', array('label' => Mage::helper('enterprise_giftcardaccount')->__('Balance'), 'title' => Mage::helper('enterprise_giftcardaccount')->__('Balance'), 'name' => 'balance', 'class' => 'validate-number', 'required' => true, 'note' => '<div id="balance_currency"></div>'));
$fieldset->addField('date_expires', 'date', array('name' => 'date_expires', 'label' => Mage::helper('enterprise_giftcardaccount')->__('Expiration Date'), 'title' => Mage::helper('enterprise_giftcardaccount')->__('Expiration Date'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)));
$form->setValues($model->getData());
$this->setForm($form);
return $this;
}
示例9: _prepareForm
protected function _prepareForm()
{
$model = Mage::registry('permissions_user');
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('user_');
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('adminhtml')->__('Account Information')));
if ($model->getUserId()) {
$fieldset->addField('user_id', 'hidden', array('name' => 'user_id'));
} else {
if (!$model->hasData('is_active')) {
$model->setIsActive(1);
}
}
$fieldset->addField('username', 'text', array('name' => 'username', 'label' => Mage::helper('adminhtml')->__('User Name'), 'id' => 'username', 'title' => Mage::helper('adminhtml')->__('User Name'), 'required' => true));
$fieldset->addField('firstname', 'text', array('name' => 'firstname', 'label' => Mage::helper('adminhtml')->__('First Name'), 'id' => 'firstname', 'title' => Mage::helper('adminhtml')->__('First Name'), 'required' => true));
$fieldset->addField('lastname', 'text', array('name' => 'lastname', 'label' => Mage::helper('adminhtml')->__('Last Name'), 'id' => 'lastname', 'title' => Mage::helper('adminhtml')->__('Last Name'), 'required' => true));
$fieldset->addField('email', 'text', array('name' => 'email', 'label' => Mage::helper('adminhtml')->__('Email'), 'id' => 'customer_email', 'title' => Mage::helper('adminhtml')->__('User Email'), 'class' => 'required-entry validate-email', 'required' => true));
$fieldset->addField('current_password', 'obscure', array('name' => 'current_password', 'label' => Mage::helper('adminhtml')->__('Current Admin Password'), 'id' => 'current_password', 'title' => Mage::helper('adminhtml')->__('Current Admin Password'), 'class' => 'input-text', 'required' => true));
if ($model->getUserId()) {
$fieldset->addField('password', 'password', array('name' => 'new_password', 'label' => Mage::helper('adminhtml')->__('New Password'), 'id' => 'new_pass', 'title' => Mage::helper('adminhtml')->__('New Password'), 'class' => 'input-text validate-admin-password'));
$fieldset->addField('confirmation', 'password', array('name' => 'password_confirmation', 'label' => Mage::helper('adminhtml')->__('Password Confirmation'), 'id' => 'confirmation', 'class' => 'input-text validate-cpassword'));
} else {
$fieldset->addField('password', 'password', array('name' => 'password', 'label' => Mage::helper('adminhtml')->__('Password'), 'id' => 'customer_pass', 'title' => Mage::helper('adminhtml')->__('Password'), 'class' => 'input-text required-entry validate-admin-password', 'required' => true));
$fieldset->addField('confirmation', 'password', array('name' => 'password_confirmation', 'label' => Mage::helper('adminhtml')->__('Password Confirmation'), 'id' => 'confirmation', 'title' => Mage::helper('adminhtml')->__('Password Confirmation'), 'class' => 'input-text required-entry validate-cpassword', 'required' => true));
}
if (Mage::getSingleton('admin/session')->getUser()->getId() != $model->getUserId()) {
$fieldset->addField('is_active', 'select', array('name' => 'is_active', 'label' => Mage::helper('adminhtml')->__('This account is'), 'id' => 'is_active', 'title' => Mage::helper('adminhtml')->__('Account Status'), 'class' => 'input-select', 'style' => 'width: 80px', 'options' => array('1' => Mage::helper('adminhtml')->__('Active'), '0' => Mage::helper('adminhtml')->__('Inactive'))));
}
$fieldset->addField('user_roles', 'hidden', array('name' => 'user_roles', 'id' => '_user_roles'));
$data = $model->getData();
unset($data['password']);
$form->setValues($data);
$this->setForm($form);
return parent::_prepareForm();
}
示例10: _prepareForm
/**
* Prepare form fields and structure
*
* @return Mage_Adminhtml_Block_Widget_Form
*/
protected function _prepareForm()
{
$model = Mage::registry('current_status');
$labels = $model ? $model->getStoreLabels() : array();
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('Mage_Sales_Helper_Data')->__('Order Status Information')));
$fieldset->addField('is_new', 'hidden', array('name' => 'is_new', 'value' => 1));
$fieldset->addField('status', 'text', array('name' => 'status', 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Status Code'), 'class' => 'required-entry validate-code', 'required' => true));
$fieldset->addField('label', 'text', array('name' => 'label', 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Status Label'), 'class' => 'required-entry', 'required' => true));
$fieldset = $form->addFieldset('store_labels_fieldset', array('legend' => Mage::helper('Mage_Sales_Helper_Data')->__('Store View Specific Labels'), 'table_class' => 'form-list stores-tree'));
foreach (Mage::app()->getWebsites() as $website) {
$fieldset->addField("w_{$website->getId()}_label", 'note', array('label' => $website->getName(), 'fieldset_html_class' => 'website'));
foreach ($website->getGroups() as $group) {
$stores = $group->getStores();
if (count($stores) == 0) {
continue;
}
$fieldset->addField("sg_{$group->getId()}_label", 'note', array('label' => $group->getName(), 'fieldset_html_class' => 'store-group'));
foreach ($stores as $store) {
$fieldset->addField("store_label_{$store->getId()}", 'text', array('name' => 'store_labels[' . $store->getId() . ']', 'required' => false, 'label' => $store->getName(), 'value' => isset($labels[$store->getId()]) ? $labels[$store->getId()] : '', 'fieldset_html_class' => 'store'));
}
}
}
if ($model) {
$form->addValues($model->getData());
}
$form->setAction($this->getUrl('*/sales_order_status/save'));
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例11: _initSelect
/**
* Instantiate select to get matched customers
*
* @return Enterprise_Reminder_Model_Resource_Customer_Collection
*/
protected function _initSelect()
{
$rule = Mage::registry('current_reminder_rule');
$select = $this->getSelect();
$customerTable = $this->getTable('customer/entity');
$couponTable = $this->getTable('enterprise_reminder/coupon');
$logTable = $this->getTable('enterprise_reminder/log');
$salesRuleCouponTable = $this->getTable('salesrule/coupon');
$select->from(array('c' => $couponTable), array('associated_at', 'emails_failed', 'is_active'));
$select->where('c.rule_id = ?', $rule->getId());
$select->joinInner(array('e' => $customerTable), 'e.entity_id = c.customer_id', array('entity_id', 'email'));
$subSelect = $this->getConnection()->select();
$subSelect->from(array('g' => $logTable), array('customer_id', 'rule_id', 'emails_sent' => new Zend_Db_Expr('COUNT(log_id)'), 'last_sent' => new Zend_Db_Expr('MAX(sent_at)')));
$subSelect->where('rule_id = ?', $rule->getId());
$subSelect->group(array('customer_id', 'rule_id'));
$select->joinLeft(array('l' => $subSelect), 'l.rule_id = c.rule_id AND l.customer_id = c.customer_id', array('l.emails_sent', 'l.last_sent'));
$select->joinLeft(array('sc' => $salesRuleCouponTable), 'sc.coupon_id = c.coupon_id', array('code', 'usage_limit', 'usage_per_customer'));
$this->_joinFields['associated_at'] = array('table' => 'c', 'field' => 'associated_at');
$this->_joinFields['emails_failed'] = array('table' => 'c', 'field' => 'emails_failed');
$this->_joinFields['is_active'] = array('table' => 'c', 'field' => 'is_active');
$this->_joinFields['code'] = array('table' => 'sc', 'field' => 'code');
$this->_joinFields['usage_limit'] = array('table' => 'sc', 'field' => 'usage_limit');
$this->_joinFields['usage_per_customer'] = array('table' => 'sc', 'field' => 'usage_per_customer');
$this->_joinFields['emails_sent'] = array('table' => 'l', 'field' => 'emails_sent');
$this->_joinFields['last_sent'] = array('table' => 'l', 'field' => 'last_sent');
return $this;
}
示例12: _initRule
protected function _initRule()
{
Mage::register('current_promo_quote_rule', Mage::getModel('rewards/salesrule_rule'));
if ($id = (int) $this->getRequest()->getParam('id')) {
Mage::registry('current_promo_quote_rule')->load($id);
}
}
示例13: getProduct
/**
* Retrieve Product object
*
* @return Mage_Catalog_Model_Product
*/
public function getProduct()
{
if (!$this->getData('product')) {
$this->setData('product', Mage::registry('product'));
}
return $this->getData('product');
}
示例14: getGoogleShoppingItemId
/**
* Returns Google shopping item ID or null if product was published in current store
*
* @return string|null
* @throws RuntimeException If Mage_GoogleShopping is not active
*/
public function getGoogleShoppingItemId()
{
if (false === $this->_gsItem) {
$this->_gsItem = ($product = Mage::registry('current_product')) ? $this->_getGoogleShoppingAdapter()->getItemId($product) : null;
}
return $this->_gsItem;
}
示例15: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form();
/**
* Initialize product object as form property
* for using it in elements generation
*/
$form->setDataObject(Mage::registry('product'));
$fieldset = $form->addFieldset('group_fields', array());
$attributes = $this->getGroupAttributes();
$this->_setFieldset($attributes, $fieldset, array('gallery'));
$values = Mage::registry('product')->getData();
/**
* Set attribute default values for new product
*/
if (!Mage::registry('product')->getId()) {
foreach ($attributes as $attribute) {
if (!isset($values[$attribute->getAttributeCode()])) {
$values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
}
}
}
Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form' => $form));
$form->addValues($values);
$form->setFieldNameSuffix('product');
$this->setForm($form);
}