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


PHP sfContext::getInstance方法代码示例

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


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

示例1: addFallbackCriteria

 /**
  * Add fallback query criteria to $criteria
  *
  * @param Criteria $criteria
  * @param array $options
  * @return QubitQuery array of objects
  */
 public static function addFallbackCriteria($criteria, $fallbackClassName, $options = array())
 {
     if (isset($options['culture'])) {
         $culture = $options['culture'];
     } else {
         $culture = sfContext::getInstance()->user->getCulture();
     }
     // Expose class constants so we can call them using a dynamic class name
     $fallbackClass = new ReflectionClass($fallbackClassName);
     $fallbackClassI18n = new ReflectionClass("{$fallbackClassName}I18n");
     // Add fallback columns (calculated)
     $criteria = self::addFallbackColumns($criteria, $fallbackClassI18n->getName());
     // Get i18n "CULTURE" column name, with "<tablename>." stripped off the front
     $cultureColName = str_replace($fallbackClassI18n->getConstant('TABLE_NAME') . '.', '', $fallbackClassI18n->getConstant('CULTURE'));
     // Build join strings
     $currentJoinString = 'current.id AND current.' . $cultureColName . ' = \'' . $culture . '\'';
     $sourceJoinString = 'source.id AND source.' . $cultureColName . ' = ' . $fallbackClass->getConstant('SOURCE_CULTURE');
     $sourceJoinString .= ' AND source.' . $cultureColName . ' <> \'' . $culture . '\'';
     // Build fancy criteria to get fallback values
     $criteria->addAlias('current', $fallbackClassI18n->getConstant('TABLE_NAME'));
     $criteria->addAlias('source', $fallbackClassI18n->getConstant('TABLE_NAME'));
     $criteria->addJoin(array($fallbackClass->getConstant('ID'), 'current.' . $cultureColName), array('current.id', '\'' . $culture . '\''), Criteria::LEFT_JOIN);
     $criteria->addJoin(array($fallbackClass->getConstant('ID'), 'source.' . $cultureColName), array('source.id', $fallbackClass->getConstant('SOURCE_CULTURE') . ' AND source.' . $cultureColName . ' <> \'' . $culture . '\''), Criteria::LEFT_JOIN);
     return $criteria;
 }
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:32,代码来源:QubitCultureFallback.class.php

示例2: end

 public function end()
 {
     $this->addCombo();
     @($this->afExtjs->public['init'] .= "\n\t    Ext.QuickTips.init();\n\t    Ext.apply(Ext.QuickTips.getQuickTip(), {\n\t\t    trackMouse: true\n\t\t});\n\t\tExt.form.Field.prototype.msgTarget = 'side';\n\t\tExt.History.init();\n\t\t");
     @($this->afExtjs->public['init'] .= "\n\t\tsetTimeout(function(){\n\t\t\tExt.get('loading').remove();\n\t        Ext.get('loading-mask').fadeOut({remove:true});\n\t    }, 250);\n\t    afApp.urlPrefix = '" . sfContext::getInstance()->getRequest()->getRelativeUrlRoot() . "';\n\t    ");
     $this->afExtjs->init();
 }
开发者ID:cbsistem,项目名称:appflower_engine,代码行数:7,代码来源:afExtjsHomepageLayout.class.php

示例3: render

    /**
     * @param  string $name        The element name
     * @param  string $value       The value displayed in this widget
     * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
     * @param  array  $errors      An array of errors for the field
     *
     * @return string An HTML tag string
     *
     * @see sfWidgetForm
     */
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        $sfContext = sfContext::getInstance();
        $resp = $sfContext->getResponse();
        $resp->addJavascript('/majaxDoctrineMediaPlugin/js/grid.locale-en.js');
        $resp->addJavascript('/majaxDoctrineMediaPlugin/js/jquery.jqGrid.min.js');
        $resp->addStylesheet('/majaxDoctrineMediaPlugin/css/ui.jqgrid.css');
        $resp->addJavascript('/majaxDoctrineMediaPlugin/js/jquery.majax.media.js');
        $sfContext->getConfiguration()->loadHelpers(array('Url'));
        $id = $this->generateId($name);
        $fetch_url = url_for('majaxMediaAdminModule/list?sf_format=xml');
        $lookup_url = url_for('majaxMediaAdminModule/lookup');
        $out = $this->renderTag('input', array_merge(array('type' => 'text', 'name' => $name, 'value' => $value), $attributes));
        $out .= '<script type="text/javascript">
(function($){
  $(function(){
    var opts = {
      lookup_url: \'' . $lookup_url . '\',
      fetch_url: \'' . $fetch_url . '\',
    };
    $(\'#' . $id . '\').majaxmediaselector(opts);
  });
})(jQuery);
</script>
';
        return $out;
    }
开发者ID:jmather,项目名称:majaxDoctrineMediaPlugin,代码行数:37,代码来源:majaxMediaWidgetFormMedia.class.php

示例4: sw_combine_debug

function sw_combine_debug()
{
    if (ProjectConfiguration::getActive()->isDebug()) {
        $response = sfContext::getInstance()->getResponse();
        echo "<!-- DEBUG MODE - \nCombined files : \n" . var_export($response->getCombinedAssets(), 1) . "\n -->\n";
    }
}
开发者ID:resid,项目名称:swCombinePlugin,代码行数:7,代码来源:swCombineHelper.php

示例5: getDayString

 public function getDayString()
 {
     $context = sfContext::getInstance();
     $i18n = new sfI18N();
     $i18n->initialize($context);
     $i18n->setCulture($context->getUser()->getCulture());
     switch ($this->getDay()) {
         case '1':
             return $i18n->globalMessageFormat->format('_DAY_MONDAY_');
             break;
         case '2':
             return $i18n->globalMessageFormat->format('_DAY_TUESDAY_');
             break;
         case '3':
             return $i18n->globalMessageFormat->format('_DAY_WEDNESDAY_');
             break;
         case '4':
             return $i18n->globalMessageFormat->format('_DAY_THURSDAY_');
             break;
         case '5':
             return $i18n->globalMessageFormat->format('_DAY_FRIDAY_');
             break;
         case '6':
             return $i18n->globalMessageFormat->format('_DAY_SATURDAY_');
             break;
         case '7':
             return $i18n->globalMessageFormat->format('_DAY_SUNDAY_');
             break;
         default:
             return '-';
             break;
     }
 }
开发者ID:taryono,项目名称:school,代码行数:33,代码来源:CourseSchedule.php

示例6: getDoctrineEvents

  /**
   * Returns an array of Doctrine query events.
   *
   * @return array
   */
  protected function getDoctrineEvents()
  {
    $databaseManager = sfContext::getInstance()->getDatabaseManager();

    $events = array();
    if ($databaseManager)
    {
      foreach ($databaseManager->getNames() as $name)
      {
        $database = $databaseManager->getDatabase($name);
        if ($database instanceof sfDoctrineDatabase && $profiler = $database->getProfiler())
        {
          foreach ($profiler->getQueryExecutionEvents() as $event)
          {
            $events[$event->getSequence()] = $event;
          }
        }
      }
    }

    // sequence events
    ksort($events);

    return $events;
  }
开发者ID:nationalfield,项目名称:symfony,代码行数:30,代码来源:sfWebDebugPanelDoctrine.class.php

示例7: configure

 public function configure()
 {
     $employee = $this->getOption('employee');
     $this->allowActivate = $this->getOption('allowActivate');
     $this->allowTerminate = $this->getOption('allowTerminate');
     $empTerminatedId = $employee->termination_id;
     $terminateReasons = $this->__getTerminationReasons();
     //creating widgets
     $widgets = array('date' => new ohrmWidgetDatePickerNew(array(), array('id' => 'terminate_date')), 'reason' => new sfWidgetFormSelect(array('choices' => $terminateReasons)), 'note' => new sfWidgetFormTextArea());
     if (!$this->allowTerminate && !$this->allowActivate) {
         foreach ($widgets as $widget) {
             $widget->setAttribute('disabled', 'disabled');
         }
     }
     $this->setWidgets($widgets);
     $inputDatePattern = sfContext::getInstance()->getUser()->getDateFormat();
     //Setting validators
     $this->setValidators(array('date' => new ohrmDateValidator(array('date_format' => $inputDatePattern, 'required' => true), array('invalid' => 'Date format should be ' . $inputDatePattern)), 'reason' => new sfValidatorChoice(array('required' => true, 'choices' => array_keys($terminateReasons))), 'note' => new sfValidatorString(array('required' => false, 'max_length' => 250, 'trim' => true))));
     $this->setDefault('date', set_datepicker_date_format(date('Y-m-d')));
     $this->setDefault('reason', 1);
     if (!empty($empTerminatedId)) {
         $employeeTerminationRecord = $employee->getEmployeeTerminationRecord();
         $this->setDefault('date', set_datepicker_date_format($employeeTerminationRecord->getDate()));
         $this->setDefault('reason', $employeeTerminationRecord->getReasonId());
         $this->setDefault('note', $employeeTerminationRecord->getNote());
     }
     $this->widgetSchema->setNameFormat('terminate[%s]');
 }
开发者ID:THM068,项目名称:orangehrm,代码行数:28,代码来源:EmployeeTerminateForm.php

示例8: getGuard

 public static function getGuard()
 {
     if (sfContext::getInstance()->getUser()->isAuthenticated()) {
         return sfContext::getInstance()->getUser()->getGuardUser();
     }
     return null;
 }
开发者ID:lendji4000,项目名称:compose,代码行数:7,代码来源:MyFunction.class.php

示例9: get

 static function get($key, $default = null, $class = false)
 {
     $tagger = sfContext::getInstance()->getViewCacheManager()->getTagger();
     if ($tagger instanceof sfTagCache) {
         $cache_key = 'registry_' . $key;
         $value = $tagger->get($cache_key);
         if (is_array($value)) {
             if ($class) {
                 return $value;
             } else {
                 return reset($value);
             }
         }
     }
     $reg = Doctrine_Core::getTable('Registry')->createQuery('r')->where('r.regkey = ?', $key)->fetchOne();
     if (!$reg) {
         return $default;
     }
     if ($tagger instanceof sfTagCache) {
         $tagger->set($cache_key, array($reg['value'], $reg['regclass']), null, array($reg->getTagName() => $reg->getObjectVersion()));
     }
     if ($class) {
         return array($reg['value'], $reg['regclass']);
     } else {
         return $reg['value'];
     }
 }
开发者ID:uniteddiversity,项目名称:policat,代码行数:27,代码来源:UtilRegistry.class.php

示例10: postValidateForm

 public function postValidateForm($validator, $values)
 {
     if (isset($values['promo_code'])) {
         $promo_code = PromoCodeTable::getInstance()->findOneByCode($values['promo_code']);
         if (!$promo_code) {
             throw new sfValidatorError($validator, 'Promotion Code is invalid');
         } else {
             $values['account_type'] = $promo_code->account_type;
         }
     }
     /** @var sfGuardUser $user */
     $user = sfGuardUserTable::getInstance()->createQuery('u')->where('u.email_address = ?', $values['email_address'])->fetchOne();
     if ($user && $values['password']) {
         if ($user->getIsActive() && $user->checkPassword($values['password'])) {
             sfContext::getInstance()->getUser()->signIn($user);
             sfContext::getInstance()->getController()->redirect('/project');
         } else {
             throw new sfValidatorError($validator, 'The email and/or password is invalid');
         }
     }
     $email = $values['email_address'];
     $domain = strtolower(substr($email, strpos($email, '@') + 1));
     if (DomainTable::getInstance()->findOneBy('name', $domain)) {
         $error = new sfValidatorError($validator, 'That looks like a personal email address. Please use your company email.');
         throw new sfValidatorErrorSchema($validator, array('email_address' => $error));
     }
     return $values;
 }
开发者ID:sensorsix,项目名称:app,代码行数:28,代码来源:sfGuardPromoRegisterForm.class.php

示例11: executeAjaxSearch

 public function executeAjaxSearch(sfWebRequest $request)
 {
     if ($request->hasParameter('models')) {
         $query = Doctrine::getTable('rtIndex')->getStandardSearchComponentInQuery($request->getParameter('q', ''), $this->getUser()->getCulture(), Doctrine::getTable('rtIndex')->getModelTypeRestrictionQuery(explode(',', $request->getParameter('models'))));
     } else {
         $query = Doctrine::getTable('rtIndex')->getBasePublicSearchQuery($request->getParameter('q'), $this->getUser()->getCulture());
     }
     $this->logMessage('{testing}' . $request->getParameter('q', ''), 'notice');
     $query->limit(100);
     $rt_indexes = $query->execute();
     $routes = $this->getContext()->getRouting()->getRoutes();
     $items = array();
     foreach ($rt_indexes as $rt_index) {
         $route = Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show';
         $url = '';
         if (isset($routes[Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show'])) {
             $url = sfContext::getInstance()->getController()->genUrl(array('sf_route' => $route, 'sf_subject' => $rt_index->getObject()));
             $url = str_replace('/frontend_dev.php', '', $url);
         }
         $object = $rt_index->getObject();
         $item = array('title' => $object->getTitle(), 'link' => $url);
         $item['placeholder'] = $object instanceof rtSnippet ? '![' . $object->getTitle() . '](snippet:' . $object->getCollection() . ')' : '';
         $items[] = $item;
     }
     return $this->returnJSONResponse(array('status' => 'success', 'items' => $items), $request);
 }
开发者ID:pierswarmers,项目名称:rtCorePlugin,代码行数:26,代码来源:BasertSearchAdminActions.class.php

示例12: getContext

 public function getContext()
 {
     if (!class_exists('sfContext') || !\sfContext::getInstance()) {
         $this->initialiseSf1Context();
     }
     return \sfContext::getInstance();
 }
开发者ID:gzankevich,项目名称:IngewikkeldWrapperBundle,代码行数:7,代码来源:Sf1ContextProxy.php

示例13: __construct

 /**
  * Constructor
  */
 public function __construct(Invoice $invoice)
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url'));
     $defaults = array('WMI_MERCHANT_ID' => sfConfig::get('app_w1_merchant'), 'WMI_PAYMENT_AMOUNT' => sprintf('%01.2f', $invoice->getAmount()), 'WMI_CURRENCY_ID' => 980, 'WMI_PAYMENT_NO' => $invoice->getId(), 'WMI_DESCRIPTION' => $invoice->geDescription(), 'WMI_SUCCESS_URL' => url_for('payment_w1_success', array(), true), 'WMI_FAIL_URL' => url_for('payment_w1_fail', array(), true), 'WMI_PTENABLED' => 'CashTerminalUAH');
     $defaults['WMI_SIGNATURE'] = $this->createSign($defaults);
     parent::__construct($defaults);
 }
开发者ID:pycmam,项目名称:myPaymentPlugin,代码行数:10,代码来源:W1RequestForm.class.php

示例14: configure

 public function configure()
 {
     $this->setWidgets(array('file' => new sfWidgetFormInputFile(), 'imageName' => new sfWidgetFormInputText()));
     $this->widgetSchema->setLabels(array('file' => sfContext::getInstance()->getI18N()->__('画像ファイル'), 'imageName' => sfContext::getInstance()->getI18N()->__('画像ファイル名')));
     $this->setValidators(array('file' => new opValidatorImageFile(), 'imageName' => new sfValidatorRegex(array('pattern' => '/^[\\w\\-]+$/'))));
     $this->widgetSchema->setNameFormat('image[%s]');
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:7,代码来源:ImageForm.php

示例15: execute

 /**
  * Executes this configuration handler.
  *
  * @param array $configFiles An array of absolute filesystem path to a configuration file
  *
  * @return string Data to be written to a cache file
  *
  * @throws sfConfigurationException If a requested configuration file does not exist or is not readable
  * @throws sfParseException If a requested configuration file is improperly formatted
  * @throws sfInitializationException If a generator.yml key check fails
  */
 public function execute($configFiles)
 {
     // parse the yaml
     $config = self::getConfiguration($configFiles);
     if (!$config) {
         return '';
     }
     if (!isset($config['generator'])) {
         throw new sfParseException(sprintf('Configuration file "%s" must specify a generator section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0]));
     }
     $config = $config['generator'];
     if (!isset($config['class'])) {
         throw new sfParseException(sprintf('Configuration file "%s" must specify a generator class section under the generator section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0]));
     }
     foreach (array('fields', 'list', 'edit') as $section) {
         if (isset($config[$section])) {
             throw new sfParseException(sprintf('Configuration file "%s" can specify a "%s" section but only under the param section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0], $section));
         }
     }
     // generate class and add a reference to it
     $generatorManager = new sfGeneratorManager(sfContext::getInstance()->getConfiguration());
     // generator parameters
     $generatorParam = isset($config['param']) ? $config['param'] : array();
     // hack to find the module name (look for the last /modules/ in path)
     preg_match('#.*/modules/([^/]+)/#', $configFiles[0], $match);
     $generatorParam['moduleName'] = $match[1];
     // compile data
     $retval = "<?php\n" . "// auto-generated by sfGeneratorConfigHandler\n" . "// date: %s\n%s\n";
     $retval = sprintf($retval, date('Y/m/d H:i:s'), self::getContent($generatorManager, $config['class'], $generatorParam));
     return $retval;
 }
开发者ID:vcgato29,项目名称:poff,代码行数:42,代码来源:sfGeneratorConfigHandler.class.php


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