本文整理汇总了PHP中mage::registry方法的典型用法代码示例。如果您正苦于以下问题:PHP mage::registry方法的具体用法?PHP mage::registry怎么用?PHP mage::registry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mage
的用法示例。
在下文中一共展示了mage::registry方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareForm
protected function _prepareForm()
{
$model = mage::registry('pdfgenerator_template');
$form = new Varien_Data_Form();
$fieldset = $form->addFieldset('general_fieldset', array('legend' => Mage::helper('pdfgenerator')->__('Template Information'), 'class' => 'fieldset'));
$fieldset->addField('orig_template_variables', 'hidden', array('name' => 'orig_template_variables'));
$fieldset->addField('variables', 'hidden', array('name' => 'variables', 'value' => Zend_Json::encode($this->getVariables())));
$fieldset->addField('template_variables', 'hidden', array('name' => 'template_variables'));
/*
* We will use this when needed.
*/
$insertVariableButton = $this->getLayout()->createBlock('adminhtml/widget_button', '', array('type' => 'button', 'label' => Mage::helper('pdfgenerator')->__('Insert Variable...'), 'onclick' => 'MagentovariablePlugin.loadChooser(\'' . $this->getVariablesWysiwygActionUrl() . '\', \'pdft_filename\');'));
$fieldset->addField('insert_variable', 'note', array('text' => $insertVariableButton->toHtml()));
$fieldset->addField('pdft_filename', 'text', array('name' => 'pdft_filename', 'label' => Mage::helper('pdfgenerator')->__('File Name'), 'required' => true));
$fieldset->addField('pdftp_format', 'select', array('label' => Mage::helper('pdfgenerator')->__('Page format'), 'title' => Mage::helper('pdfgenerator')->__('Page format'), 'name' => 'pdftp_format', 'required' => true, 'options' => array('5' => Mage::helper('pdfgenerator')->__('Legal'), '4' => Mage::helper('pdfgenerator')->__('Letter'), '3' => Mage::helper('pdfgenerator')->__('A6'), '2' => Mage::helper('pdfgenerator')->__('A5'), '1' => Mage::helper('pdfgenerator')->__('A3'), '0' => Mage::helper('pdfgenerator')->__('A4'))));
$fieldset->addField('pdftc_customchek', 'select', array('label' => Mage::helper('pdfgenerator')->__('Custom format'), 'name' => 'pdftc_customchek', 'options' => array('1' => Mage::helper('pdfgenerator')->__('Yes'), '0' => Mage::helper('pdfgenerator')->__('No')), 'onclick' => "", 'onchange' => "", 'disabled' => false));
$fieldset->addField('pdft_customwidth', 'text', array('name' => 'pdft_customwidth', 'class' => 'validate-zero-or-greater', 'label' => Mage::helper('pdfgenerator')->__('Width (mm)'), 'required' => false));
$fieldset->addField('pdft_customheight', 'text', array('name' => 'pdft_customheight', 'class' => 'validate-zero-or-greater', 'label' => Mage::helper('pdfgenerator')->__('Height (mm)'), 'required' => false));
$fieldset->addField('pdft_orientation', 'select', array('label' => Mage::helper('pdfgenerator')->__('Page orientation'), 'title' => Mage::helper('pdfgenerator')->__('Page orientation'), 'name' => 'pdft_orientation', 'required' => true, 'options' => array('portrait' => Mage::helper('pdfgenerator')->__('Portrait'), 'landscape' => Mage::helper('pdfgenerator')->__('Landscape'))));
$fieldset->addField('pdftm_top', 'text', array('name' => 'pdftm_top', 'class' => 'validate-greater-than-zero', 'label' => Mage::helper('pdfgenerator')->__('Top (mm)'), 'required' => true));
$fieldset->addField('pdftm_bottom', 'text', array('name' => 'pdftm_bottom', 'class' => 'validate-greater-than-zero', 'label' => Mage::helper('pdfgenerator')->__('Bottom (mm)'), 'required' => true));
$fieldset->addField('pdftm_left', 'text', array('name' => 'pdftm_left', 'class' => 'validate-greater-than-zero', 'label' => Mage::helper('pdfgenerator')->__('Left (mm)'), 'required' => true));
$fieldset->addField('pdftm_right', 'text', array('name' => 'pdftm_right', 'class' => 'validate-greater-than-zero', 'label' => Mage::helper('pdfgenerator')->__('Right (mm)'), 'required' => true));
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
示例2: _prepareForm
/**
* Add fields to form and create template info form
*
* @return Mage_Adminhtml_Block_Widget_Form
*/
protected function _prepareForm()
{
$model = mage::registry('pdfgenerator_template');
$form = new Varien_Data_Form();
$fieldset = $form->addFieldset('general_fieldset', array('legend' => Mage::helper('pdfgenerator')->__('Template Information'), 'class' => 'fieldset'));
$fieldset->addField('pdftemplate_name', 'text', array('name' => 'pdftemplate_name', 'label' => Mage::helper('pdfgenerator')->__('Template Name'), 'required' => true));
$fieldset->addField('pdftemplate_desc', 'text', array('name' => 'pdftemplate_desc', 'label' => Mage::helper('pdfgenerator')->__('Template Description'), 'required' => false));
if ($model->getPdftemplateId()) {
$fieldset->addField('pdftemplate_id', 'hidden', array('name' => 'pdftemplate_id'));
}
if (!Mage::app()->isSingleStoreMode()) {
$field = $fieldset->addField('template_store_id', 'select', array('name' => 'template_store_id', 'label' => Mage::helper('cms')->__('Store View'), 'title' => Mage::helper('cms')->__('Store View'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
$field->setRenderer($renderer);
} else {
$fieldset->addField('template_store_id', 'hidden', array('name' => 'template_store_id', 'value' => Mage::app()->getStore(true)->getId()));
$model->setStoreId(Mage::app()->getStore(true)->getId());
}
$fieldset->addField('pdft_is_active', 'select', array('label' => Mage::helper('cms')->__('Status'), 'title' => Mage::helper('cms')->__('Status'), 'name' => 'pdft_is_active', 'required' => true, 'options' => array('1' => Mage::helper('cms')->__('Enabled'), '0' => Mage::helper('cms')->__('Disabled'))));
$fieldset->addField('pdft_default', 'select', array('label' => Mage::helper('pdfgenerator')->__('Default'), 'title' => Mage::helper('pdfgenerator')->__('Default'), 'name' => 'pdft_default', 'required' => false, 'options' => array('1' => Mage::helper('cms')->__('Yes'), '0' => Mage::helper('cms')->__('No')), 'class' => 'disabled', 'disabled' => true, 'readonly' => 'readonly', 'permission' => 'readonly'));
if ($this->getThePdfType()) {
$fieldset->addField('pdft_type', 'select', array('label' => Mage::helper('pdfgenerator')->__('Type'), 'title' => Mage::helper('pdfgenerator')->__('Type'), 'name' => 'pdft_type', 'options' => array('1' => $this->getThePdfType()), 'value' => 1, 'required' => true, 'readonly' => true));
}
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
示例3: getProduct
/**
* Retourne le produit courant
*/
public function getProduct()
{
//Charge le produit si il ne l'est pas
if ($this->_product == null) {
$this->_product = mage::registry('current_product');
}
return $this->_product;
}
示例4: getCurrentModel
protected function getCurrentModel()
{
$model = mage::registry('awb_template');
if ($model) {
return $model;
}
return false;
}
示例5: _prepareForm
protected function _prepareForm()
{
$model = mage::registry('pdfgenerator_template');
$form = new Varien_Data_Form();
$fieldset = $form->addFieldset('header_fieldset', array('legend' => Mage::helper('pdfgenerator')->__('Template Css'), 'class' => 'fieldset-wide'));
$fieldset->addField('pdft_css', 'editor', array('name' => 'pdft_css', 'label' => Mage::helper('pdfgenerator')->__('Template Css'), 'title' => Mage::helper('pdfgenerator')->__('Template Css'), 'style' => 'width:700px; height:300px;', 'wysiwyg' => false, 'required' => false));
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
示例6: _prepareForm
/**
* Add fields to form and create template info form
*
* @return Mage_Adminhtml_Block_Widget_Form
*/
protected function _prepareForm()
{
$model = mage::registry('pdfgenerator_template');
$form = new Varien_Data_Form();
$fieldset = $form->addFieldset('general_fieldset', array('legend' => Mage::helper('pdfgenerator')->__('Template Body'), 'class' => 'fieldset-wide'));
$editor = Mage::getSingleton('eadesign/wysiwyg_config')->getConfig(array('tab_id' => $this->getTabId()));
$fieldset->addField('pdftemplate_body', 'editor', array('name' => 'pdftemplate_body', 'label' => Mage::helper('pdfgenerator')->__('Template Body'), 'title' => Mage::helper('pdfgenerator')->__('Template Body'), 'style' => 'width:700px; height:500px;', 'config' => $editor, 'wysiwyg' => true, 'required' => true));
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
示例7: smartFilter
/**
* smartFilter
*
* @param bool $curCategory (default: false)
* @param mixed $categoryValues
* @return array
*/
public function smartFilter($curCategory = false, $categoryValues)
{
if ($categoryValues == '') {
return array();
}
$queryParams = Mage::app()->getRequest()->getParams();
if (isset($queryParams['cat']) && $queryParams['cat'] > 0) {
$curCategory = $queryParams['cat'];
}
if (!$curCategory) {
$curCategory = mage::registry('current_category');
} elseif (is_numeric($curCategory)) {
$curCategory = Mage::getModel('catalog/category')->load($curCategory);
}
if (is_object($curCategory)) {
if (strlen(trim($categoryValues)) >= 1 || $categoryValues) {
$allIds = array();
$attributeConditions = unserialize($categoryValues);
$condition = "";
foreach ($attributeConditions as $attribute) {
$productCollection = Mage::getResourceModel('catalog/product_collection');
$curType = "=";
$attributeFilterArray = array();
if ($attribute['attribute'] == "category_id") {
$productCollection->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'inner');
$categoryFilterCondition = array();
$missingCategories = array();
foreach (explode(",", $attribute['value']) as $categoryId) {
$categoryObject = Mage::getModel('catalog/category')->load($categoryId);
if (!$categoryObject || !$categoryObject->getId()) {
$missingCategories[] = $categoryId;
}
$categoryFilterCondition[] = array('finset' => $categoryId);
}
if (count($missingCategories) > 0) {
$pluralTitle = count($missingCategories) > 1 ? $this->__("categories") : $this->__("category");
$categoryIdsStr = implode(', ', $missingCategories);
$message = $this->__("The %s '%s' that you are trying to clone, does not exist.", $pluralTitle, $categoryIdsStr);
Mage::getSingleton('core/session')->addNotice($message);
}
if (sizeof($categoryFilterCondition) > 0) {
$productCollection->addAttributeToFilter('category_id', $categoryFilterCondition);
} else {
continue;
}
} elseif ($attribute['attribute'] == 'created_at' || $attribute['attribute'] == 'updated_at') {
$allowedOperatorsDate = array('>' => 'lt', '<' => 'gt', '>=' => 'lteq', '<=' => 'gteq');
$ranger = substr($attribute['value'], 0, 2);
$rangerToStrip = 2;
$rightRanger = substr($ranger, 1);
if (is_numeric($rightRanger)) {
$ranger = substr($attribute['value'], 0, 1);
$rangerToStrip = 1;
}
if (!is_numeric($ranger)) {
if (!array_key_exists($ranger, $allowedOperatorsDate)) {
$ranger = '<';
}
$curType = $allowedOperatorsDate[$ranger];
$attribute['value'] = substr($attribute['value'], $rangerToStrip);
}
$dateValue = date('Y-m-d', strtotime('-' . $attribute['value'] . ' days'));
if ($curType == "=") {
$dateStart = date('Y-m-d 00:00:00', strtotime($dateValue));
$dateEnd = date('Y-m-d 23:59:59', strtotime($dateValue));
$attributeFilterArray = array('from' => $dateStart, 'to' => $dateEnd);
} else {
$attributeFilterArray = array($curType => $dateValue);
}
$productCollection->addAttributeToFilter($attribute['attribute'], $attributeFilterArray);
} else {
$attributeModel = Mage::getModel('catalog/resource_eav_attribute')->load($attribute['attribute']);
$attributeCode = $attributeModel->getAttributeCode();
$allowedOperators = array('>' => 'gt', '<' => 'lt', '!' => 'neq', '>=' => 'gteq', '<=' => 'lteq', '=' => 'eq');
switch (strtolower($attribute['value'])) {
case 'yes':
case 'true':
$attribute['value'] = 1;
break;
case 'no':
case 'false':
$attribute['value'] = '0';
break;
}
if (strpos($attribute['value'], '*') !== false) {
$attribute['value'] = str_replace('*', '%', $attribute['value']);
$attributeFilterArray = array('like' => $attribute['value']);
}
if ($attributeModel->getFrontendInput() == "select") {
if (substr($attribute['value'], 0, 1) == '!') {
$curType = '!=';
$attribute['value'] = substr($attribute['value'], 1);
}
//.........这里部分代码省略.........