当前位置: 首页>>代码示例>>PHP>>正文


PHP AO::getSingleton方法代码示例

本文整理汇总了PHP中AO::getSingleton方法的典型用法代码示例。如果您正苦于以下问题:PHP AO::getSingleton方法的具体用法?PHP AO::getSingleton怎么用?PHP AO::getSingleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AO的用法示例。


在下文中一共展示了AO::getSingleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     parent::__construct(AO::getSingleton('core/resource')->getConnection('directory_read'));
     $this->_countryTable = AO::getSingleton('core/resource')->getTableName('directory/country');
     $this->_select->from(array('country' => $this->_countryTable));
     $this->setItemObjectClass(AO::getConfig()->getModelClassName('directory/country'));
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:7,代码来源:Mysql4_Country_Collection.php

示例2: prepareProductCollection

 /**
  * Prepare product collection
  *
  * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
  * @return Mage_Catalog_Model_Layer
  */
 public function prepareProductCollection($collection)
 {
     $collection->addAttributeToSelect(AO::getSingleton('catalog/config')->getProductAttributes())->addSearchFilter(AO::helper('catalogSearch')->getEscapedQueryText())->setStore(AO::app()->getStore())->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addStoreFilter()->addUrlRewrite();
     AO::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
     AO::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
     return $this;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:13,代码来源:Layer.php

示例3: _toHtml

 protected function _toHtml()
 {
     if (!$this->_beforeToHtml() || !AO::getStoreConfig('dev/debug/profiler') || !AO::helper('core')->isDevAllowed()) {
         return '';
     }
     $timers = Varien_Profiler::getTimers();
     #$out = '<div style="position:fixed;bottom:5px;right:5px;opacity:.1;background:white" onmouseover="this.style.opacity=1" onmouseout="this.style.opacity=.1">';
     #$out = '<div style="opacity:.1" onmouseover="this.style.opacity=1" onmouseout="this.style.opacity=.1">';
     $out = "<a href=\"javascript:void(0)\" onclick=\"\$('profiler_section').style.display=\$('profiler_section').style.display==''?'none':''\">[profiler]</a>";
     $out .= '<div id="profiler_section" style="background:white; display:block">';
     $out .= '<pre>Memory usage: real: ' . memory_get_usage(true) . ', emalloc: ' . memory_get_usage() . '</pre>';
     $out .= '<table border="1" cellspacing="0" cellpadding="2" style="width:auto">';
     $out .= '<tr><th>Code Profiler</th><th>Time</th><th>Cnt</th><th>Emalloc</th><th>RealMem</th></tr>';
     foreach ($timers as $name => $timer) {
         $sum = Varien_Profiler::fetch($name, 'sum');
         $count = Varien_Profiler::fetch($name, 'count');
         $realmem = Varien_Profiler::fetch($name, 'realmem');
         $emalloc = Varien_Profiler::fetch($name, 'emalloc');
         if ($sum < 0.001 && $count < 10 && $emalloc < 10000) {
             continue;
         }
         $out .= '<tr>' . '<td align="left">' . $name . '</td>' . '<td>' . number_format($sum, 4) . '</td>' . '<td align="right">' . $count . '</td>' . '<td align="right">' . number_format($emalloc) . '</td>' . '<td align="right">' . number_format($realmem) . '</td>' . '</tr>';
     }
     $out .= '</table>';
     $out .= '<pre>';
     $out .= print_r(Varien_Profiler::getSqlProfiler(AO::getSingleton('core/resource')->getConnection('core_write')), 1);
     $out .= '</pre>';
     $out .= '</div>';
     return $out;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:30,代码来源:Profiler.php

示例4: _joinFields

 protected function _joinFields()
 {
     $tagTable = AO::getSingleton('core/resource')->getTableName('tag/tag');
     $tagRelationTable = AO::getSingleton('core/resource')->getTableName('tag/relation');
     $this->addAttributeToSelect('name');
     $this->getSelect()->join(array('relation' => $tagRelationTable), "relation.product_id = e.entity_id")->join(array('t' => $tagTable), "t.tag_id =relation.tag_id", array('tag_id', 'status', 'tag_name' => 'name'));
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:7,代码来源:Mysql4_Tag_Product_Collection.php

示例5: _prepareForm

 protected function _prepareForm()
 {
     $model = AO::registry('api_user');
     $form = new Varien_Data_Form();
     $form->setHtmlIdPrefix('user_');
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => AO::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' => AO::helper('adminhtml')->__('User Name'), 'id' => 'username', 'title' => AO::helper('adminhtml')->__('User Name'), 'required' => true));
     $fieldset->addField('firstname', 'text', array('name' => 'firstname', 'label' => AO::helper('adminhtml')->__('First Name'), 'id' => 'firstname', 'title' => AO::helper('adminhtml')->__('First Name'), 'required' => true));
     $fieldset->addField('lastname', 'text', array('name' => 'lastname', 'label' => AO::helper('adminhtml')->__('Last Name'), 'id' => 'lastname', 'title' => AO::helper('adminhtml')->__('Last Name'), 'required' => true));
     $fieldset->addField('email', 'text', array('name' => 'email', 'label' => AO::helper('adminhtml')->__('Email'), 'id' => 'customer_email', 'title' => AO::helper('adminhtml')->__('User Email'), 'class' => 'required-entry validate-email', 'required' => true));
     if ($model->getUserId()) {
         $fieldset->addField('password', 'password', array('name' => 'new_api_key', 'label' => AO::helper('adminhtml')->__('New Api Key'), 'id' => 'new_pass', 'title' => AO::helper('adminhtml')->__('New Api Key'), 'class' => 'input-text validate-password'));
         $fieldset->addField('confirmation', 'password', array('name' => 'api_key_confirmation', 'label' => AO::helper('adminhtml')->__('Api Key Confirmation'), 'id' => 'confirmation', 'class' => 'input-text validate-cpassword'));
     } else {
         $fieldset->addField('password', 'password', array('name' => 'api_key', 'label' => AO::helper('adminhtml')->__('Api Key'), 'id' => 'customer_pass', 'title' => AO::helper('adminhtml')->__('Api Key'), 'class' => 'input-text required-entry validate-password', 'required' => true));
         $fieldset->addField('confirmation', 'password', array('name' => 'api_key_confirmation', 'label' => AO::helper('adminhtml')->__('Api Key Confirmation'), 'id' => 'confirmation', 'title' => AO::helper('adminhtml')->__('Api Key Confirmation'), 'class' => 'input-text required-entry validate-cpassword', 'required' => true));
     }
     if (AO::getSingleton('admin/session')->getUser()->getId() != $model->getUserId()) {
         $fieldset->addField('is_active', 'select', array('name' => 'is_active', 'label' => AO::helper('adminhtml')->__('This account is'), 'id' => 'is_active', 'title' => AO::helper('adminhtml')->__('Account status'), 'class' => 'input-select', 'style' => 'width: 80px', 'options' => array('1' => AO::helper('adminhtml')->__('Active'), '0' => AO::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();
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:34,代码来源:Api_User_Edit_Tab_Main.php

示例6: _toHtml

 public function _toHtml()
 {
     if (AO::getStoreConfigFlag('payment/paypaluk_express/active') && AO::getSingleton('checkout/session')->getQuote()->validateMinimumAmount()) {
         return parent::_toHtml();
     }
     return '';
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:7,代码来源:Link_Shortcut.php

示例7: addWishlistCount

 public function addWishlistCount()
 {
     $wishlistItemTable = AO::getSingleton('core/resource')->getTableName('wishlist/item');
     $this->getSelect()->from(array('wi' => $wishlistItemTable), 'count(wishlist_item_id) as wishlists')->where('wi.product_id=e.entity_id')->group('wi.product_id');
     $this->getEntity()->setStore(0);
     return $this;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:7,代码来源:Mysql4_Wishlist_Product_Collection.php

示例8: scheduledGenerateSitemaps

 /**
  * Generate sitemaps
  *
  * @param Mage_Cron_Model_Schedule $schedule
  */
 public function scheduledGenerateSitemaps($schedule)
 {
     $errors = array();
     // check if scheduled generation enabled
     if (!AO::getStoreConfigFlag(self::XML_PATH_GENERATION_ENABLED)) {
         return;
     }
     $collection = AO::getModel('sitemap/sitemap')->getCollection();
     /* @var $collection Mage_Sitemap_Model_Mysql4_Sitemap_Collection */
     foreach ($collection as $sitemap) {
         /* @var $sitemap Mage_Sitemap_Model_Sitemap */
         try {
             $sitemap->generateXml();
         } catch (Exception $e) {
             $errors[] = $e->getMessage();
         }
     }
     if ($errors && AO::getStoreConfig(self::XML_PATH_ERROR_RECIPIENT)) {
         $translate = AO::getSingleton('core/translate');
         /* @var $translate Mage_Core_Model_Translate */
         $translate->setTranslateInline(false);
         $emailTemplate = AO::getModel('core/email_template');
         /* @var $emailTemplate Mage_Core_Model_Email_Template */
         $emailTemplate->setDesignConfig(array('area' => 'backend'))->sendTransactional(AO::getStoreConfig(self::XML_PATH_ERROR_TEMPLATE), AO::getStoreConfig(self::XML_PATH_ERROR_IDENTITY), AO::getStoreConfig(self::XML_PATH_ERROR_RECIPIENT), null, array('warnings' => join("\n", $errors)));
         $translate->setTranslateInline(true);
     }
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:32,代码来源:Observer.php

示例9: _getProductAttribute

 /**
  * Retrieve product attribute
  *
  * @return Mage_Eav_Model_Entity_Attribute_Abstract
  */
 protected function _getProductAttribute($attribute)
 {
     if (empty($this->_productAttributes[$attribute])) {
         $this->_productAttributes[$attribute] = AO::getSingleton('catalog/product')->getResource()->getAttribute($attribute);
     }
     return $this->_productAttributes[$attribute];
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:12,代码来源:Resource_Eav_Mysql4_Product_Status.php

示例10: renderPrepare

 /**
  * Prepare form for render
  */
 public function renderPrepare($template)
 {
     $form = new Varien_Data_Form();
     if ($this->getRequest()->isPost()) {
         $post = $this->getRequest()->getPost();
         if (isset($post['template_id'])) {
             unset($post['template_id']);
         }
         if (isset($post['template_type'])) {
             unset($post['template_type']);
         }
         $template->addData($post);
     }
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => AO::helper('newsletter')->__('Template Information'), 'class' => 'fieldset-wide'));
     $fieldset->addField('code', 'text', array('name' => 'code', 'label' => AO::helper('newsletter')->__('Template Name'), 'title' => AO::helper('newsletter')->__('Template Name'), 'class' => 'required-entry', 'required' => true, 'value' => $template->getTemplateCode()));
     $fieldset->addField('subject', 'text', array('name' => 'subject', 'label' => AO::helper('newsletter')->__('Template Subject'), 'title' => AO::helper('newsletter')->__('Template Subject'), 'class' => 'required-entry', 'required' => true, 'value' => $template->getTemplateSubject()));
     $fieldset->addField('sender_name', 'text', array('name' => 'sender_name', 'label' => AO::helper('newsletter')->__('Sender Name'), 'title' => AO::helper('newsletter')->__('Sender Name'), 'class' => 'required-entry', 'required' => true, 'value' => $template->getTemplateSenderName()));
     $fieldset->addField('sender_email', 'text', array('name' => 'sender_email', 'label' => AO::helper('newsletter')->__('Sender Email'), 'title' => AO::helper('newsletter')->__('Sender Email'), 'class' => 'required-entry validate-email', 'required' => true, 'value' => $template->getTemplateSenderEmail()));
     $txtType = constant(AO::getConfig()->getModelClassName('newsletter/template') . '::TYPE_TEXT');
     $fieldset->addField('text', 'editor', array('name' => 'text', 'wysiwyg' => $template->getTemplateType() != $txtType, 'label' => AO::helper('newsletter')->__('Template Content'), 'title' => AO::helper('newsletter')->__('Template Content'), 'theme' => 'advanced', 'class' => 'required-entry', 'required' => true, 'state' => 'html', 'value' => $template->getTemplateText(), 'style' => 'height:36em;'));
     if ($template->getId()) {
         // If edit add id
         $form->addField('id', 'hidden', array('name' => 'id', 'value' => $template->getId()));
     }
     if ($values = AO::getSingleton('adminhtml/session')->getData('newsletter_template_form_data', true)) {
         $form->setValues($values);
     }
     $this->setForm($form);
     return $this;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:33,代码来源:Newsletter_Template_Edit_Form.php

示例11: getFlag

 /**
  * Retrieve Catalog Product Flat Flag object
  *
  * @return Mage_Catalog_Model_Product_Flat_Flag
  */
 public function getFlag()
 {
     if (is_null($this->_flagObject)) {
         $this->_flagObject = AO::getSingleton('catalog/product_flat_flag')->loadSelf();
     }
     return $this->_flagObject;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:12,代码来源:Flat.php

示例12: getSubscriptionObject

 /**
  * Get Customer Subscription Object Information
  *
  * @return Mage_Newsletter_Model_Subscriber
  */
 public function getSubscriptionObject()
 {
     if (is_null($this->_subscription)) {
         $this->_subscription = AO::getModel('newsletter/subscriber')->loadByCustomer(AO::getSingleton('customer/session')->getCustomer());
     }
     return $this->_subscription;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:12,代码来源:Account_Dashboard_Info.php

示例13: _getInstaller

 /**
  * Get installer singleton
  *
  * @return Mage_Install_Model_Installer
  */
 protected function _getInstaller()
 {
     if (is_null($this->_installer)) {
         $this->_installer = AO::getSingleton('install/installer');
     }
     return $this->_installer;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:12,代码来源:Installer_Abstract.php

示例14: __construct

 public function __construct()
 {
     parent::__construct(AO::getSingleton('core/resource')->getConnection('review_read'));
     $this->_setIdFieldName('status_id');
     $this->_reviewStatusTable = AO::getSingleton('core/resource')->getTableName('review/review_status');
     $this->_select->from($this->_reviewStatusTable);
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:7,代码来源:Mysql4_Review_Status_Collection.php

示例15: loadFile

    public function loadFile()
    {
        if (!$_FILES) {
            ?>
<form method="POST" enctype="multipart/form-data">
File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/>
</form>
<?php 
            exit;
        }
        if (!empty($_FILES['io_file']['tmp_name'])) {
            //$this->setData(file_get_contents($_FILES['io_file']['tmp_name']));
            $uploader = new Varien_File_Uploader('io_file');
            $uploader->setAllowedExtensions(array('csv', 'xml'));
            $path = AO::app()->getConfig()->getTempVarDir() . '/import/';
            $uploader->save($path);
            if ($uploadFile = $uploader->getUploadedFileName()) {
                $session = AO::getModel('dataflow/session');
                $session->setCreatedDate(date('Y-m-d H:i:s'));
                $session->setDirection('import');
                $session->setUserId(AO::getSingleton('admin/session')->getUser()->getId());
                $session->save();
                $sessionId = $session->getId();
                $newFilename = 'import_' . $sessionId . '_' . $uploadFile;
                rename($path . $uploadFile, $path . $newFilename);
                $session->setFile($newFilename);
                $session->save();
                $this->setData(file_get_contents($path . $newFilename));
                AO::register('current_dataflow_session_id', $sessionId);
            }
        }
        return $this;
    }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:33,代码来源:Http.php


注:本文中的AO::getSingleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。