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


PHP __d函数代码示例

本文整理汇总了PHP中__d函数的典型用法代码示例。如果您正苦于以下问题:PHP __d函数的具体用法?PHP __d怎么用?PHP __d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: __construct

 /**
  * Setup the config based on either the Configure::read() values
  * or the PaypalIpnConfig in config/paypal_ipn_config.php
  *
  * Will attempt to read configuration in the following order:
  *   Configure::read('PaypalIpn')
  *   App::import() of config/paypal_ipn_config.php
  *   App::import() of plugin's config/paypal_ipn_config.php
  */
 function __construct()
 {
     $this->config = Configure::read('PaypalIpn');
     if (empty($this->config)) {
         $importConfig = array('type' => 'File', 'name' => 'PaypalIpn.PaypalIpnConfig', 'file' => CONFIGS . 'paypal_ipn_config.php');
         if (!class_exists('PaypalIpnConfig')) {
             App::import($importConfig);
         }
         if (!class_exists('PaypalIpnConfig')) {
             // Import from paypal plugin configuration
             $importConfig['file'] = 'config' . DS . 'paypal_ipn_config.php';
             App::import($importConfig);
         }
         if (!class_exists('PaypalIpnConfig')) {
             trigger_error(__d('paypal_ipn', 'PaypalIpnConfig: The configuration could not be loaded.', true), E_USER_ERROR);
         }
         if (!PHP5) {
             $config =& new PaypalIpnConfig();
         } else {
             $config = new PaypalIpnConfig();
         }
         $vars = get_object_vars($config);
         foreach ($vars as $property => $configuration) {
             if (strpos($property, 'encryption_') === 0) {
                 $name = substr($property, 11);
                 $this->encryption[$name] = $configuration;
             } else {
                 $this->config[$property] = $configuration;
             }
         }
     }
     parent::__construct();
 }
开发者ID:ranium,项目名称:CakePHP-Paypal-IPN-Plugin,代码行数:42,代码来源:paypal.php

示例2: beforeValidate

 /**
  * Overide before validate of UploadBehavior plugin processing.
  *
  * @param Model $model Model instance
  * @param array $options Options passed from Model::save().
  * @return bool
  */
 public function beforeValidate(Model $model, $options = array())
 {
     // only run in step validate
     if (!isset($model->data[$model->alias]['upload_flag'])) {
         return parent::beforeValidate($model, $options);
     }
     foreach ($this->settings[$model->alias] as $field => $options) {
         if (!empty($model->data[$model->alias][$field]) && $this->_isUrl($model->data[$model->alias][$field])) {
             $uri = $model->data[$model->alias][$field];
             if (!$this->_grab($model, $field, $uri)) {
                 $model->invalidate($field, __d('upload', 'File was not downloaded.', true));
                 return false;
             }
         }
         // unset if uploaded
         if (empty($model->data[$model->alias][$field]['name']) && !empty($model->data[$model->alias][$field . '_uploaded'])) {
             // if field is empty, don't delete/nullify existing file
             unset($model->data[$model->alias][$field]);
             continue;
         }
         // set data to validate
         $this->runtime[$model->alias][$field] = $model->data[$model->alias][$field];
     }
     return true;
 }
开发者ID:sonnt1991,项目名称:Threestep,代码行数:32,代码来源:ThreestepUploadBehavior.php

示例3: beforeSave

 public function beforeSave($options = array())
 {
     //when password field
     if (isset($this->data[$this->alias]['password']) && isset($this->data[$this->alias]['password2'])) {
         if (empty($this->data[$this->alias]['password']) && empty($this->data[$this->alias]['password2'])) {
             unset($this->data[$this->alias]['password']);
             unset($this->data[$this->alias]['password2']);
         } elseif (!empty($this->data[$this->alias]['password'])) {
             if ($this->data[$this->alias]['password'] != $this->data[$this->alias]['password2']) {
                 $this->invalidate('password', __d('backend', "The passwords do not match"));
                 $this->invalidate('password2', __d('backend', "The passwords do not match"));
                 $this->data[$this->alias]['password2'] = null;
                 return false;
             }
         }
     } elseif (isset($this->data[$this->alias]['password'])) {
         $this->invalidate('password', __d('backend', 'Password verification not submitted'));
         $this->invalidate('password2', __d('backend', 'Password verification not submitted'));
         return false;
     }
     if (isset($this->data[$this->alias]['password']) && !empty($this->data[$this->alias]['password'])) {
         $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
     }
     return true;
 }
开发者ID:fm-labs,项目名称:cakephp-backend,代码行数:25,代码来源:BackendUser.php

示例4: createDatabaseFile

 public function createDatabaseFile($data)
 {
     App::uses('File', 'Utility');
     App::uses('ConnectionManager', 'Model');
     $config = $this->defaultConfig;
     foreach ($data['Install'] as $key => $value) {
         if (isset($data['Install'][$key])) {
             $config[$key] = $value;
         }
     }
     $result = copy(APP . 'Config' . DS . 'database.php.install', APP . 'Config' . DS . 'database.php');
     if (!$result) {
         return __d('croogo', 'Could not copy database.php file.');
     }
     $file = new File(APP . 'Config' . DS . 'database.php', true);
     $content = $file->read();
     foreach ($config as $configKey => $configValue) {
         $content = str_replace('{default_' . $configKey . '}', $configValue, $content);
     }
     if (!$file->write($content)) {
         return __d('croogo', 'Could not write database.php file.');
     }
     try {
         ConnectionManager::create('default', $config);
         $db = ConnectionManager::getDataSource('default');
     } catch (MissingConnectionException $e) {
         return __d('croogo', 'Could not connect to database: ') . $e->getMessage();
     }
     if (!$db->isConnected()) {
         return __d('croogo', 'Could not connect to database.');
     }
     return true;
 }
开发者ID:ahmadhasankhan,项目名称:croogo,代码行数:33,代码来源:InstallManager.php

示例5: testValidationThatHasBeenModifiedBefore

 /**
  * ConfirmableBehaviorTest::testBasicValidation()
  *
  * @return void
  */
 public function testValidationThatHasBeenModifiedBefore()
 {
     $this->Articles = TableRegistry::get('SluggedArticles');
     /*
     $this->Articles->validator()->add('confirm', 'notBlank', [
     		'rule' => function ($value, $context) {
     			return !empty($value);
     		},
     		'message' => __('Please select checkbox to continue.'),
     		'requirePresence' => true,
     		'allowEmpty' => false,
     		'last' => true,
     	]);
     $this->Articles->validator()->remove('confirm');
     */
     $this->Articles->addBehavior('Tools.Confirmable');
     $animal = $this->Articles->newEntity();
     $data = ['name' => 'FooBar', 'confirm' => '0'];
     $animal = $this->Articles->patchEntity($animal, $data);
     $this->assertNotEmpty($animal->errors());
     $this->assertSame(['confirm' => ['notBlank' => __d('tools', 'Please confirm the checkbox')]], $animal->errors());
     $data = ['name' => 'FooBar', 'confirm' => '1'];
     $animal = $this->Articles->patchEntity($animal, $data);
     $this->assertEmpty($animal->errors());
 }
开发者ID:ayman-alkom,项目名称:cakephp-tools,代码行数:30,代码来源:ConfirmableBehaviorTest.php

示例6: init

 /**
  * Initializes git, makes tmp folders writeable, and adds the core submodules (or specified group)
  *
  * @return void
  */
 public function init($working)
 {
     $this->out(__d('baking_plate', "\n<info>Making temp folders writeable...</info>"));
     $tmp = array('tmp' . DS . 'cache', 'tmp' . DS . 'cache' . DS . 'models', 'tmp' . DS . 'cache' . DS . 'persistent', 'tmp' . DS . 'cache' . DS . 'views', 'tmp' . DS . 'logs', 'tmp' . DS . 'sessions', 'tmp' . DS . 'tests', 'webroot' . DS . 'ccss', 'webroot' . DS . 'cjs', 'webroot' . DS . 'uploads');
     foreach ($tmp as $dir) {
         if (!is_dir($working . DS . $dir)) {
             $this->out(__d('baking_plate', "\n<info>Creating Directory %s with permissions 0777</info>", $dir));
             mkdir($working . DS . $dir, 0777);
         } else {
             $this->out(__d('baking_plate', "\n<info>Setting Permissions of %s to 0777</info>", $dir));
             chmod($working . DS . $dir, 0777);
         }
     }
     $this->nl();
     chdir($working);
     $this->out();
     $this->out(passthru('git init'));
     $this->all();
     $this->args = null;
     if (!file_exists($working . 'Config' . DS . 'database.php')) {
         $this->DbConfig->path = $working . 'Config' . DS;
         $this->out();
         $this->out(__d('baking_plate', '<warning>Your database configuration was not found. Take a moment to create one.</warning>'));
         $this->DbConfig->execute();
     }
 }
开发者ID:novrian,项目名称:BakingPlate,代码行数:31,代码来源:PlateShell.php

示例7: __get

 /**
  * Getter
  *
  * @param string $name
  * @throws RuntimeException
  * @return void
  */
 public function __get($name)
 {
     if ($name === 'createVersions') {
         throw new \RuntimeException(__d('file_storage', 'createVersions was removed, see the change log'));
     }
     parent::__get($name);
 }
开发者ID:CodeBlastr,项目名称:FileStorage-CakePHP-Plugin,代码行数:14,代码来源:AudioStorage.php

示例8: main

 /**
  * Adds or drops the specified column.
  *
  * @return bool
  */
 public function main()
 {
     $options = (array) $this->params;
     $options['bundle'] = empty($options['bundle']) ? null : $options['bundle'];
     if (empty($options['use'])) {
         $this->err(__d('eav', 'You must indicate a table alias name using the "--use" option. Example: "Articles.Users"'));
         return false;
     }
     try {
         $table = TableRegistry::get($options['use']);
     } catch (\Exception $ex) {
         $table = false;
     }
     if (!$table) {
         $this->err(__d('eav', 'The specified table does not exists.'));
         return false;
     } elseif (!$table->behaviors()->has('Eav')) {
         $this->err(__d('eav', 'The specified table is not using EAV behavior.'));
         return false;
     }
     $columns = $table->listColumns($options['bundle']);
     ksort($columns, SORT_LOCALE_STRING);
     $rows = [[__d('eav', 'Column Name'), __d('eav', 'Data Type'), __d('eav', 'Bundle'), __d('eav', 'Searchable')]];
     foreach ($columns as $name => $info) {
         $rows[] = [$name, $info['type'], !empty($info['bundle']) ? $info['bundle'] : '---', !empty($info['searchable']) ? 'no' : 'yes'];
     }
     $this->out();
     $this->out(__d('eav', 'EAV information for table "{0}":', $options['use']));
     $this->out();
     $this->helper('table')->output($rows);
     return true;
 }
开发者ID:quickapps-plugins,项目名称:eav,代码行数:37,代码来源:InfoTask.php

示例9: implementedEvents

 /**
  * Return an array of events to listen to.
  *
  * @return array
  */
 public function implementedEvents()
 {
     $before = function ($name) {
         return function () use($name) {
             DebugTimer::start($name, __d('debug_kit', $name));
         };
     };
     $after = function ($name) {
         return function () use($name) {
             DebugTimer::stop($name);
         };
     };
     $both = function ($name) use($before, $after) {
         return [['priority' => 0, 'callable' => $before('Event: ' . $name)], ['priority' => 999, 'callable' => $after('Event: ' . $name)]];
     };
     return ['Controller.initialize' => [['priority' => 0, 'callable' => function () {
         DebugMemory::record(__d('debug_kit', 'Controller initialization'));
     }], ['priority' => 0, 'callable' => $before('Event: Controller.initialize')], ['priority' => 999, 'callable' => $after('Event: Controller.initialize')]], 'Controller.startup' => [['priority' => 0, 'callable' => $before('Event: Controller.startup')], ['priority' => 999, 'callable' => $after('Event: Controller.startup')], ['priority' => 999, 'callable' => function () {
         DebugMemory::record(__d('debug_kit', 'Controller action start'));
         DebugTimer::start(__d('debug_kit', 'Controller action'));
     }]], 'Controller.beforeRender' => [['priority' => 0, 'callable' => function () {
         DebugTimer::stop(__d('debug_kit', 'Controller action'));
     }], ['priority' => 0, 'callable' => $before('Event: Controller.beforeRender')], ['priority' => 999, 'callable' => $after('Event: Controller.beforeRender')], ['priority' => 999, 'callable' => function () {
         DebugMemory::record(__d('debug_kit', 'View Render start'));
         DebugTimer::start(__d('debug_kit', 'View Render start'));
     }]], 'View.beforeRender' => $both('View.beforeRender'), 'View.afterRender' => $both('View.afterRender'), 'View.beforeLayout' => $both('View.beforeLayout'), 'View.afterLayout' => $both('View.afterLayout'), 'View.beforeRenderFile' => [['priority' => 0, 'callable' => function ($event, $filename) {
         DebugTimer::start(__d('debug_kit', 'Render {0}', $filename));
     }]], 'View.afterRenderFile' => [['priority' => 0, 'callable' => function ($event, $filename) {
         DebugTimer::stop(__d('debug_kit', 'Render {0}', $filename));
     }]], 'Controller.shutdown' => [['priority' => 0, 'callable' => $before('Event: Controller.shutdown')], ['priority' => 0, 'callable' => function () {
         DebugTimer::stop(__d('debug_kit', 'View Render start'));
         DebugMemory::record(__d('debug_kit', 'Controller shutdown'));
     }], ['priority' => 999, 'callable' => $after('Event: Controller.shutdown')]]];
 }
开发者ID:fabioalvaro,项目名称:cakexuxu,代码行数:39,代码来源:TimerPanel.php

示例10: beforeValidate

 /**
  * {@inheritdoc}
  */
 public function beforeValidate(Model $Model, $options = array())
 {
     $ModelValidator = $Model->validator();
     foreach ($Model->data[$Model->alias] as $field => $value) {
         if (!preg_match('/^([a-z0-9_]+)_confirm$/i', $field, $match)) {
             continue;
         }
         if (!array_key_exists($match[1], $Model->data[$Model->alias])) {
             continue;
         }
         if (!($Ruleset = $ModelValidator->getField($match[1]))) {
             $Ruleset = new CakeValidationSet($match[1], array());
         }
         $ruleset = array();
         foreach ($Ruleset->getRules() as $name => $Rule) {
             $ruleset[$name] = (array) $Rule;
             foreach (array_keys($ruleset[$name]) as $key) {
                 if (!preg_match('/^[a-z]/i', $key)) {
                     unset($ruleset[$name][$key]);
                 }
             }
         }
         $ModelValidator->add($field, new CakeValidationSet($field, array()));
         $ModelValidator->getField($field)->setRule('confirmed', array('rule' => 'isConfirmed', 'message' => __d('common', "No match.")));
     }
     return true;
 }
开发者ID:gourmet,项目名称:common,代码行数:30,代码来源:ConfirmableBehavior.php

示例11: validationDefault

 /**
  * Default validation rules.
  *
  * @param \Cake\Validation\Validator $validator Validator instance.
  * @return \Cake\Validation\Validator
  */
 public function validationDefault(Validator $validator)
 {
     $validator->add('id', 'valid', ['rule' => 'numeric'])->allowEmpty('id', 'create');
     $validator->add('email', 'valid', ['rule' => 'email'])->notEmpty('email');
     $validator->notEmpty('password');
     $validator->allowEmpty('new_password');
     $validator->allowEmpty('confirm_password');
     $validator->add('new_password', 'custom', ['rule' => function ($value, $context) {
         if (!array_key_exists('confirm_password', $context['data'])) {
             return false;
         }
         if ($value !== $context['data']['confirm_password']) {
             return false;
         }
         return true;
     }, 'message' => __d('CakeAdmin', 'Passwords are not equal.')]);
     $validator->add('confirm_password', 'custom', ['rule' => function ($value, $context) {
         if (!array_key_exists('new_password', $context['data'])) {
             return false;
         }
         if ($value !== $context['data']['new_password']) {
             return false;
         }
         return true;
     }, 'message' => __d('CakeAdmin', 'Passwords are not equal.')]);
     return $validator;
 }
开发者ID:cakemanager,项目名称:cakephp-cakeadmin,代码行数:33,代码来源:AdministratorsTable.php

示例12: __construct

 /**
  * @param \Cake\ORM\Table $table
  * @param array $config
  */
 public function __construct(Table $table, array $config = [])
 {
     parent::__construct($table, $config);
     if (!$this->_config['message']) {
         $this->_config['message'] = __d('tools', 'Please confirm the checkbox');
     }
 }
开发者ID:alescx,项目名称:cakephp-tools,代码行数:11,代码来源:ConfirmableBehavior.php

示例13: __construct

 /**
  * __construct callback
  *
  * @param \Cake\View\View $View : View
  * @param array $config : Config
  * @throws Cake\Error\NotFoundException
  */
 public function __construct(\Cake\View\View $View, array $config = [])
 {
     parent::__construct($View, $config);
     if (!$this->_isSupportedFramework($fw = $this->config('assets.framework'))) {
         throw new NotFoundException(sprintf(__d('bootstrap', 'Configured JavaScript framework "{0}" is not supported. Only "{1}" are valid options.', $fw, implode(', ', $this->_authorizedJsLibs))));
     }
 }
开发者ID:cake17,项目名称:cakephp-bootstrap,代码行数:14,代码来源:BsSliderHelper.php

示例14: checkAddField

 /**
  * Perform check before field create.
  *
  * @param string $table Table to look in
  * @param string $field Field to look for
  * @throws MigrationException
  * @return bool
  */
 public function checkAddField($table, $field)
 {
     if ($this->tableExists($table) && $this->fieldExists($table, $field)) {
         throw new MigrationException($this->_migration, sprintf(__d('migrations', 'Field "%s" already exists in "%s".'), $field, $table));
     }
     return true;
 }
开发者ID:ogontaro,项目名称:elites-output,代码行数:15,代码来源:PrecheckException.php

示例15: __call

 public function __call($methodName, $params)
 {
     if (!method_exists($this->_service, $methodName)) {
         throw new BadMethodCallException(sprintf(__d('ninja', 'The method %s is not defined in %s class.', true), $methodName, get_class($this->_service)));
     }
     return $this->_dispatchService(array($this->_service, $methodName), $params);
 }
开发者ID:hiromi2424,项目名称:ninja,代码行数:7,代码来源:transaction_service.php


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