本文整理汇总了PHP中Mage::app方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage::app方法的具体用法?PHP Mage::app怎么用?PHP Mage::app使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage
的用法示例。
在下文中一共展示了Mage::app方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getSearchParam
/**
* Retrieve filter array
*
* @param Enterprise_Search_Model_Resource_Collection $collection
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param string|array $value
* @return array
*/
protected function _getSearchParam($collection, $attribute, $value)
{
if (!is_string($value) && empty($value) || is_string($value) && strlen(trim($value)) == 0 || is_array($value) && isset($value['from']) && empty($value['from']) && isset($value['to']) && empty($value['to'])) {
return array();
}
if (!is_array($value)) {
$value = array($value);
}
$field = Mage::getResourceSingleton('enterprise_search/engine')->getSearchEngineFieldName($attribute, 'nav');
if ($attribute->getBackendType() == 'datetime') {
$format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
foreach ($value as &$val) {
if (!is_empty_date($val)) {
$date = new Zend_Date($val, $format);
$val = $date->toString(Zend_Date::ISO_8601) . 'Z';
}
}
unset($val);
}
if (empty($value)) {
return array();
} else {
return array($field => $value);
}
}
示例2: _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();
}
示例3: _construct
protected function _construct()
{
$this->_init('catalogindex/price');
$this->_getResource()->setStoreId(Mage::app()->getStore()->getId());
$this->_getResource()->setRate(Mage::app()->getStore()->getCurrentCurrencyRate());
$this->_getResource()->setCustomerGroupId(Mage::getSingleton('customer/session')->getCustomerGroupId());
}
示例4: prepareItemUrls
/**
* Prepare cart items URLs
*
* @deprecated after 1.7.0.2
*/
public function prepareItemUrls()
{
$products = array();
/* @var $item Mage_Sales_Model_Quote_Item */
foreach ($this->getItems() as $item) {
$product = $item->getProduct();
$option = $item->getOptionByCode('product_type');
if ($option) {
$product = $option->getProduct();
}
if ($item->getStoreId() != Mage::app()->getStore()->getId() && !$item->getRedirectUrl() && !$product->isVisibleInSiteVisibility()) {
$products[$product->getId()] = $item->getStoreId();
}
}
if ($products) {
$products = Mage::getResourceSingleton('catalog/url')->getRewriteByProductStore($products);
foreach ($this->getItems() as $item) {
$product = $item->getProduct();
$option = $item->getOptionByCode('product_type');
if ($option) {
$product = $option->getProduct();
}
if (isset($products[$product->getId()])) {
$object = new Varien_Object($products[$product->getId()]);
$item->getProduct()->setUrlDataObject($object);
}
}
}
}
示例5: _addSubscriberToAutomation
protected function _addSubscriberToAutomation($email, $subscriber, $websiteId)
{
$storeId = $subscriber->getStoreId();
$store = Mage::app()->getStore($storeId);
$programId = Mage::helper('ddg')->getAutomationIdByType('XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER', $websiteId);
//not mapped ignore
if (!$programId) {
return;
}
try {
//check the subscriber alredy exists
$enrolmentCollection = Mage::getModel('ddg_automation/automation')->getCollection()->addFieldToFilter('email', $email)->addFieldToFilter('automation_type', Dotdigitalgroup_Email_Model_Automation::AUTOMATION_TYPE_NEW_SUBSCRIBER)->addFieldToFilter('website_id', $websiteId);
$enrolmentCollection->getSelect()->limit(1);
$enrolment = $enrolmentCollection->getFirstItem();
//add new subscriber to automation
if (!$enrolment->getId()) {
//save subscriber to the queue
$automation = Mage::getModel('ddg_automation/automation');
$automation->setEmail($email)->setAutomationType(Dotdigitalgroup_Email_Model_Automation::AUTOMATION_TYPE_NEW_SUBSCRIBER)->setEnrolmentStatus(Dotdigitalgroup_Email_Model_Automation::AUTOMATION_STATUS_PENDING)->setTypeId($subscriber->getId())->setWebsiteId($websiteId)->setStoreName($store->getName())->setProgramId($programId);
$automation->save();
}
} catch (Exception $e) {
Mage::logException($e);
}
}
示例6: _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();
}
示例7: setUp
protected function setUp()
{
$this->_product = Mage::getModel('Mage_Catalog_Model_Product');
$this->_product->load(1);
$this->_block = Mage::app()->getLayout()->createBlock('Mage_Catalog_Block_Product_View_Type_Configurable');
$this->_block->setProduct($this->_product);
}
示例8: load
/**
* Load backup file info
*
* @param string fileName
* @param string filePath
* @return Mage_Backup_Model_Backup
*/
public function load($fileName, $filePath)
{
$backupData = Mage::helper('backup')->extractDataFromFilename($fileName);
$this->addData(array('id' => $filePath . DS . $fileName, 'time' => (int) $backupData->getTime(), 'path' => $filePath, 'extension' => Mage::helper('backup')->getExtensionByType($backupData->getType()), 'display_name' => Mage::helper('backup')->nameToDisplayName($backupData->getName()), 'name' => $backupData->getName(), 'date_object' => new Zend_Date((int) $backupData->getTime(), Mage::app()->getLocale()->getLocaleCode())));
$this->setType($backupData->getType());
return $this;
}
示例9: isSingleStoreMode
/**
* Check whether it is single store mode
*
* @return bool
*/
public function isSingleStoreMode()
{
if (!Mage::app()->isSingleStoreMode()) {
return false;
}
return true;
}
示例10: _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();
}
示例11: preDispatch
/**
* Controller pre-dispatch method
*
* @return Mage_XmlConnect_Controller_AdminAction
*/
public function preDispatch()
{
Mage::getSingleton('adminhtml/url')->turnOffSecretKey();
// override admin store design settings via stores section
Mage::getDesign()->setArea($this->_currentArea)->setPackageName((string) Mage::getConfig()->getNode('stores/admin/design/package/name'))->setTheme((string) Mage::getConfig()->getNode('stores/admin/design/theme/default'));
foreach (array('layout', 'template', 'skin', 'locale') as $type) {
$value = (string) Mage::getConfig()->getNode("stores/admin/design/theme/{$type}");
if ($value) {
Mage::getDesign()->setTheme($type, $value);
}
}
$this->getLayout()->setArea($this->_currentArea);
Mage::dispatchEvent('adminhtml_controller_action_predispatch_start', array());
Mage_Core_Controller_Varien_Action::preDispatch();
if ($this->getRequest()->isDispatched() && $this->getRequest()->getActionName() !== 'denied' && !$this->_isAllowed()) {
$this->_forward('denied');
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
return $this;
}
if (is_null(Mage::getSingleton('adminhtml/session')->getLocale())) {
Mage::getSingleton('adminhtml/session')->setLocale(Mage::app()->getLocale()->getLocaleCode());
}
$this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
if ($this->_isCheckCookieRequired()) {
$this->_checkCookie();
}
return $this;
}
示例12: _saveCustomerInfo
/**
* Saving information about customer
*
* @param Mage_Log_Model_Visitor $visitor
*
* @return Mage_Log_Model_Resource_Visitor
*/
protected function _saveCustomerInfo($visitor)
{
$adapter = $this->_getWriteAdapter();
if ($visitor->getDoCustomerLogout() && ($logId = $visitor->getCustomerLogId())) {
$resource = Mage::getSingleton('core/resource');
$connection = $resource->getConnection('core_read');
$select = new Zend_Db_Select($connection);
$select->from($resource->getTableName('log/customer'));
$select->reset(Zend_Db_Select::COLUMNS);
$select->columns('login_at');
$select->where('log_id = ?', $logId);
$loginAt = $connection->fetchOne($select);
if (!$loginAt) {
return parent::_saveCustomerInfo($visitor);
}
$data = new Varien_Object(array('login_at' => $loginAt, 'logout_at' => Mage::getSingleton('core/date')->gmtDate(), 'store_id' => (int) Mage::app()->getStore()->getId()));
$bind = $this->_prepareDataForTable($data, $this->getTable('log/customer'));
$condition = array('log_id = ?' => (int) $logId);
$adapter->update($this->getTable('log/customer'), $bind, $condition);
$visitor->setDoCustomerLogout(false);
$visitor->setCustomerId(null);
$visitor->setCustomerLogId(null);
} else {
return parent::_saveCustomerInfo($visitor);
}
return $this;
}
示例13: _toHtml
protected function _toHtml()
{
$rssObj = Mage::getModel('rss/rss');
$route = Mage::helper('blog')->getRoute();
$url = $this->getUrl($route);
$title = Mage::getStoreConfig('blog/blog/title');
$data = array('title' => $title, 'description' => $title, 'link' => $url, 'charset' => 'UTF-8');
if (Mage::getStoreConfig('blog/rss/image') != "") {
$data['image'] = $this->getSkinUrl(Mage::getStoreConfig('blog/rss/image'));
}
$rssObj->_addHeader($data);
$collection = Mage::getModel('blog/blog')->getCollection()->addStoreFilter(Mage::app()->getStore()->getId())->setOrder('created_time ', 'desc');
$identifier = $this->getRequest()->getParam('identifier');
$tag = $this->getRequest()->getParam('tag');
if ($tag) {
$collection->addTagFilter(urldecode($tag));
}
if ($cat_id = Mage::getSingleton('blog/cat')->load($identifier)->getcatId()) {
Mage::getSingleton('blog/status')->addCatFilterToCollection($collection, $cat_id);
}
Mage::getSingleton('blog/status')->addEnabledFilterToCollection($collection);
$collection->setPageSize((int) Mage::getStoreConfig('blog/rss/posts'));
$collection->setCurPage(1);
if ($collection->getSize() > 0) {
foreach ($collection as $post) {
$data = array('title' => $post->getTitle(), 'link' => $this->getUrl($route . "/" . $post->getIdentifier()), 'description' => $post->getPostContent(), 'lastUpdate' => strtotime($post->getCreatedTime()));
$rssObj->_addEntry($data);
}
}
return $rssObj->createRssXml();
}
示例14: _beforeSave
/**
* Prepare data before save
*
* @param Varien_Object $object
* @return Mage_Eav_Model_Entity_Attribute_Backend_Store
*/
protected function _beforeSave($object)
{
if (!$object->getData($this->getAttribute()->getAttributeCode())) {
$object->setData($this->getAttribute()->getAttributeCode(), Mage::app()->getStore()->getId());
}
return $this;
}
示例15: _getElementHtml
/**
* Ajax Create the addressbooks.
*
* @param Varien_Data_Form_Element_Abstract $element
*
* @return string
*/
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$url = Mage::helper('adminhtml')->getUrl('*/connector/createnewaddressbook');
$website = Mage::app()->getRequest()->getParam('website', 0);
$element->setData('after_element_html', "<script>\n function createAddressbook(form, element) {\n var name = \$('connector_sync_settings_dynamic_addressbook_addressbook_name').value;\n var visibility = \$('connector_sync_settings_dynamic_addressbook_visibility').value;\n var reloadurl = '{$url}';\n if(name && visibility){\n new Ajax.Request(reloadurl, {\n method: 'post',\n parameters: {'name' : name, 'visibility' : visibility, 'website': '{$website}'},\n onComplete: function(transport) {\n window.location.reload();\n }\n });\n }\n return false;\n }\n </script>");
return parent::_getElementHtml($element);
}