本文整理汇总了PHP中Mage::getSingleton方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage::getSingleton方法的具体用法?PHP Mage::getSingleton怎么用?PHP Mage::getSingleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage
的用法示例。
在下文中一共展示了Mage::getSingleton方法的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: _beforeSave
/**
* Action before save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Api_Model_Resource_Acl_Role
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getId()) {
$this->setCreated(Mage::getSingleton('core/date')->gmtDate());
}
return $this;
}
示例3: getAllOptions
public function getAllOptions()
{
if (!$this->_options) {
$this->_options = Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm(true, true);
}
return $this->_options;
}
示例4: generatePackageXml
public function generatePackageXml()
{
Mage::getSingleton('adminhtml/session')->setLocalExtensionPackageFormData($this->getData());
Varien_Pear::$reloadOnRegistryUpdate = false;
$pkg = new Varien_Pear_Package();
#$pkg->getPear()->runHtmlConsole(array('command'=>'list-channels'));
$pfm = $pkg->getPfm();
$pfm->setOptions(array('packagedirectory' => '.', 'baseinstalldir' => '.', 'simpleoutput' => true));
$this->_setPackage($pfm);
$this->_setRelease($pfm);
$this->_setMaintainers($pfm);
$this->_setDependencies($pfm);
$this->_setContents($pfm);
#echo "<pre>".print_r($pfm,1)."</pre>";
if (!$pfm->validate(PEAR_VALIDATE_NORMAL)) {
//echo "<pre>".print_r($this->getData(),1)."</pre>";
//echo "TEST:";
//echo "<pre>".print_r($pfm->getValidationWarnings(), 1)."</pre>";
$message = $pfm->getValidationWarnings();
//$message = $message[0]['message'];
throw Mage::exception('Mage_Adminhtml', Mage::helper('adminhtml')->__($message[0]['message']));
return $this;
}
$this->setPackageXml($pfm->getDefaultGenerator()->toXml(PEAR_VALIDATE_NORMAL));
return $this;
}
示例5: getUsername
/**
* Retrieve username for form field
*
* @return string
*/
public function getUsername()
{
if (-1 === $this->_username) {
$this->_username = Mage::getSingleton('customer/session')->getUsername(true);
}
return $this->_username;
}
示例6: indexModeLive
public function indexModeLive()
{
$processCollection = Mage::getSingleton('index/indexer')->getProcessesCollection();
$processCollection->walk('setMode', array(Mage_Index_Model_Process::MODE_REAL_TIME));
$processCollection->walk('save');
return true;
}
示例7: _processGiftRules
/**
* Process the gift rules
*
* @param Mage_Sales_Model_Quote_Address $address
*/
protected function _processGiftRules($address)
{
$quote = $address->getQuote();
$store = Mage::app()->getStore($quote->getStoreId());
$validator = Mage::getSingleton('gift/rule_validator')->init($store->getWebsiteId(), $quote->getCustomerGroupId());
$validator->process($address);
}
示例8: getIframeSourceUrl
/**
* Return url for iframe source
*
* @return string
*/
public function getIframeSourceUrl()
{
if (!Mage_AdminNotification_Model_Survey::isSurveyUrlValid() || Mage::getSingleton('install/installer')->getHideIframe()) {
return null;
}
return Mage_AdminNotification_Model_Survey::getSurveyUrl();
}
示例9: _prepareForm
/**
* Preparation of current form
*
* @return Inic_Faq_Block_Admin_Edit_Tab_Main Self
*/
protected function _prepareForm()
{
$model = Mage::registry('faq');
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('faq_');
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('faq')->__('General information'), 'class' => 'fieldset-wide'));
if ($model->getFaqId()) {
$fieldset->addField('faq_id', 'hidden', array('name' => 'faq_id'));
}
$approveInfo = $fieldset->addField('question', 'text', array('name' => 'question', 'label' => Mage::helper('faq')->__('FAQ item question'), 'title' => Mage::helper('faq')->__('FAQ item question'), 'required' => true));
/**
* Check is single store mode
*/
if (!Mage::app()->isSingleStoreMode()) {
$store_id = $fieldset->addField('store_id', 'multiselect', array('name' => 'store_id[]', 'label' => Mage::helper('faq')->__('Store view'), 'title' => Mage::helper('faq')->__('Store view'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
} else {
$store_id = $fieldset->addField('store_id', 'hidden', array('name' => 'store_id[]', 'value' => Mage::app()->getStore(true)->getId()));
$model->setStoreId(Mage::app()->getStore(true)->getId());
}
$status = $fieldset->addField('is_active', 'select', array('label' => Mage::helper('faq')->__('Status'), 'title' => Mage::helper('faq')->__('Item status'), 'name' => 'is_active', 'required' => true, 'options' => array('1' => Mage::helper('faq')->__('Enabled'), '0' => Mage::helper('faq')->__('Disabled'))));
$fieldset->addField('is_most_frequent', 'select', array('label' => Mage::helper('faq')->__('Is Most Frequent'), 'title' => Mage::helper('faq')->__('Is Most Frequent'), 'name' => 'is_most_frequent', 'required' => true, 'options' => array('1' => Mage::helper('faq')->__('Yes'), '0' => Mage::helper('faq')->__('No'))));
$category_id = $fieldset->addField('category_id', 'multiselect', array('label' => Mage::helper('faq')->__('Category'), 'title' => Mage::helper('faq')->__('Category'), 'name' => 'category_id[]', 'required' => false, 'values' => Mage::getResourceSingleton('faq/category_collection')->toOptionArray()));
$fieldset->addField('answer', 'editor', array('name' => 'answer', 'label' => Mage::helper('faq')->__('Content'), 'title' => Mage::helper('faq')->__('Content'), 'style' => 'height:36em;', 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(), 'state' => 'html', 'required' => true));
$data = $model->getData();
if (!count($data)) {
$data['store_id'] = 0;
}
$form->setValues($data);
$this->setForm($form);
$cat_id = $model->getData('category_id');
$selected = $cat_id ? $cat_id : "";
$this->setChild('form_after', $this->getLayout()->createBlock('faq/adminhtml_widget_form_element_selectdependence')->addFieldMap($store_id->getHtmlId(), $category_id->getHtmlId(), $selected));
return parent::_prepareForm();
}
示例10: addMediaFile
/**
*
* Add media file ( js, css ) ...
* @param $type string media type (js, skin_css)
* @param $source string source path
* @param $before boolean true/false
* @param $params mix
* @param $if string
* @param $cond string
*/
function addMediaFile($type = "", $source = "", $before = false, $params = null, $if = "", $cond = "")
{
$_head = Mage::getSingleton('core/layout')->getBlock('head');
if (is_object($_head) && !empty($source)) {
$items = $_head->getData('items');
$tmpItems = array();
$search = $type . "/" . $source;
if (is_array($items)) {
$key_array = array_keys($items);
foreach ($key_array as &$_key) {
if ($search == $_key) {
$tmpItems[$_key] = $items[$_key];
unset($items[$_key]);
}
}
}
if ($type == 'skin_css' && empty($params)) {
$params = 'media="all"';
}
if (empty($tmpItems)) {
$tmpItems[$type . '/' . $source] = array('type' => $type, 'name' => $source, 'params' => $params, 'if' => $if, 'cond' => $cond);
}
if ($before) {
$items = array_merge($tmpItems, $items);
} else {
$items = array_merge($items, $tmpItems);
}
$_head->setData('items', $items);
}
return $this;
}
示例11: getFilteredEvents
private function getFilteredEvents()
{
if (empty($this->filteredEvents)) {
$this->filteredEvents = Mage::getSingleton('debug/observer')->getFilteredEvents();
}
return $this->filteredEvents;
}
示例12: prefarestoreForm
public function prefarestoreForm($block)
{
if (Mage::registry('store_type') == 'store') {
$form = $block["block"]->getForm();
$storeid = Mage::app()->getRequest()->getParam("store_id");
$collections = Mage::getModel('jmmegamenu/jmmegamenugroup')->getCollection()->addFieldToFilter("storeid", array("eq" => $storeid))->setOrder("id", "DESC");
$listgroup = array();
foreach ($collections as $collection) {
$listgroup[$collection->id] = $collection->title;
}
//add the menugoup field
if (!empty($listgroup)) {
$resource = Mage::getSingleton('core/resource');
$read = $resource->getConnection('core_read');
$menutable = $resource->getTableName('jmmegamenu_store_menugroup');
$query = 'SELECT menugroupid ' . ' FROM ' . $menutable . ' WHERE store_id = ' . (int) $storeid . ' ORDER BY id';
$rows = $read->fetchRow($query);
$fieldset = $form->addFieldset('jmmegamenu_fieldset', array('legend' => Mage::helper('core')->__('Jm megamenu Information')));
//print_r($listgroup);die();
$fieldset->addField('menugroup', 'select', array('name' => 'menugroup', 'label' => Mage::helper('jmmegamenu')->__('Menu Group'), 'no_span' => true, 'values' => $listgroup));
$menugroup = $form->getElement("menugroup");
$menugroup->setValue($rows['menugroupid']);
if ($rows['menugroupid']) {
//die($rows['menugroupid']);
$form->setValue("menugroup", $rows['menugroupid']);
}
$block["block"]->setForm($form);
// print_r($block);die();
}
}
}
示例13: getMagentoOrderStatusList
public function getMagentoOrderStatusList()
{
if (is_null($this->_possibleMagentoStatuses)) {
$this->_possibleMagentoStatuses = Mage::getSingleton('sales/order_config')->getStatuses();
}
return $this->_possibleMagentoStatuses;
}
示例14: indexAction
/**
* Index action
*
* Stores a captured email address in legacy mode
*
* @return void
*/
public function indexAction()
{
try {
$email = $this->getRequest()->getParam('email');
if (Zend_Validate::is($email, 'EmailAddress')) {
$emailcaptureId = $this->getRequest()->getParam('cid');
/* @var Listrak_Remarketing_Model_Session $session */
$session = Mage::getSingleton('listrak/session');
$session->init();
$emailcapture = Mage::getModel('listrak/emailcapture')->load($emailcaptureId);
if ($emailcapture->getId()) {
/* @var Listrak_Remarketing_Model_Mysql4_Session $resource */
$resource = $session->getResource();
$resource->insertEmail($session, $email, $emailcaptureId);
$result = array('status' => true);
} else {
$result = array('status' => false);
}
header('Content-type: application/json');
echo json_encode($result);
}
} catch (Exception $e) {
/* @var Listrak_Remarketing_Model_Log $logger */
$logger = Mage::getModel("listrak/log");
$logger->addException($e);
}
}
示例15: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$this->setForm($form);
$fieldset = $form->addFieldset('promotional_form', array('legend' => Mage::helper('promotional')->__('General')));
$fieldset->addField('name', 'text', array('label' => Mage::helper('promotional')->__('Name'), 'name' => 'name', 'class' => 'required-entry', 'required' => true));
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$fieldset->addField('date_from', 'date', array('label' => Mage::helper('promotional')->__('Date From'), 'name' => 'date_from', 'required' => false, 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'format' => $dateFormatIso));
$fieldset->addField('date_to', 'date', array('label' => Mage::helper('promotional')->__('Date To'), 'name' => 'date_to', 'required' => false, 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'format' => $dateFormatIso));
if (!Mage::app()->isSingleStoreMode()) {
$fieldset->addField('store_view', 'multiselect', array('label' => Mage::helper('promotional')->__('Store View'), 'name' => 'store_view', 'class' => 'required-entry', 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
}
$fieldset->addField('page_type', 'multiselect', array('label' => Mage::helper('promotional')->__('Page Type'), 'name' => 'page_type', 'class' => 'required-entry', 'required' => true, 'values' => Mage::getModel('promotional/source_page')->toOptionArray()));
$fieldset->addField('position', 'select', array('label' => Mage::helper('promotional')->__('Position'), 'name' => 'position', 'class' => 'required-entry', 'required' => true, 'values' => Mage::getModel('promotional/source_position')->toOptionArray()));
$fieldset->addField('status', 'select', array('label' => Mage::helper('promotional')->__('Status'), 'name' => 'status', 'class' => 'required-entry', 'required' => true, 'values' => Mage::getModel('promotional/source_status')->toOptionArray()));
$fieldset->addField('width', 'text', array('label' => Mage::helper('promotional')->__('Width, px'), 'name' => 'width', 'required' => false, 'note' => $this->__('Minimum width is 200px')));
$fieldset->addField('height', 'text', array('label' => Mage::helper('promotional')->__('Height, px'), 'name' => 'height', 'required' => false, 'note' => $this->__('Miimum height is 300px')));
if (Mage::getSingleton('adminhtml/session')->getPromotionalData()) {
$form->setValues(Mage::getSingleton('adminhtml/session')->getPromotionalData());
Mage::getSingleton('adminhtml/session')->setPromotionalData(null);
} elseif (Mage::registry('promotional_data')) {
$form->setValues(Mage::registry('promotional_data')->getData());
}
if (Mage::getSingleton('adminhtml/session')->getPromotionalData() == NULL && Mage::registry('promotional_data')->getData() == NULL) {
$form->setValues(array('position' => Mage::helper('promotional')->getDefaultPosition()));
}
return parent::_prepareForm();
}