本文整理匯總了PHP中Inflector::camelize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::camelize方法的具體用法?PHP Inflector::camelize怎麽用?PHP Inflector::camelize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::camelize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get
public function get(Model $model, $name)
{
$inflectedName = Inflector::camelize($name);
$className = 'Cloggy' . $inflectedName;
$class = ClassRegistry::init('Cloggy.' . $className);
return $class;
}
示例2: find
function find($type, $query = array())
{
if (is_array($type)) {
$query = $type;
} else {
$query['type'] = $type;
}
if (!is_array($query)) {
$query = array('Title' => $query);
}
$map = array('info' => 'ResponseGroup', 'type' => 'SearchIndex');
foreach ($map as $old => $new) {
$query[$new] = $query[$old];
unset($query[$old]);
}
foreach ($query as $key => $val) {
if (preg_match('/^[a-z]/', $key)) {
$query[Inflector::camelize($key)] = $val;
unset($query[$key]);
}
}
$query = am(array('Service' => 'AWSECommerceService', 'AWSAccessKeyId' => $this->config['key'], 'Operation' => 'ItemSearch', 'Version' => '2008-06-28'), $query);
$r = $this->Http->get('http://ecs.amazonaws.com/onca/xml', $query);
$r = Set::reverse(new Xml($r));
return $r;
}
示例3: auth
/**
* acl and auth
*
* @return void
*/
public function auth()
{
//Configure AuthComponent
$this->_controller->Auth->authenticate = array(AuthComponent::ALL => array('userModel' => 'User', 'fields' => array('username' => 'username', 'password' => 'password'), 'scope' => array('User.status' => 1)), 'Form');
$actionPath = 'controllers';
$this->_controller->Auth->authorize = array(AuthComponent::ALL => array('actionPath' => $actionPath), 'Actions');
$this->_controller->Auth->loginAction = array('plugin' => null, 'controller' => 'users', 'action' => 'login');
$this->_controller->Auth->logoutRedirect = array('plugin' => null, 'controller' => 'users', 'action' => 'login');
$this->_controller->Auth->loginRedirect = array('plugin' => null, 'controller' => 'users', 'action' => 'index');
if ($this->_controller->Auth->user() && $this->_controller->Auth->user('role_id') == 1) {
// Role: Admin
$this->_controller->Auth->allow();
} else {
if ($this->_controller->Auth->user()) {
$roleId = $this->_controller->Auth->user('role_id');
} else {
$roleId = 3;
// Role: Public
}
$allowedActions = ClassRegistry::init('Acl.AclPermission')->getAllowedActionsByRoleId($roleId);
$linkAction = Inflector::camelize($this->_controller->request->params['controller']) . '/' . $this->_controller->request->params['action'];
if (in_array($linkAction, $allowedActions)) {
$this->_controller->Auth->allowedActions = array($this->_controller->request->params['action']);
}
}
}
示例4: _setupField
/**
* Setup a particular upload field
*
* @param Model $model Model instance
* @param string $field Name of field being modified
* @param array $options array of configuration settings for a field
* @return void
*/
protected function _setupField(Model $model, $field, $options)
{
if (is_int($field)) {
$field = $options;
$options = array();
}
$this->defaults['rootDir'] = ROOT . DS . APP_DIR . DS;
if (!isset($this->settings[$model->alias][$field])) {
$options = array_merge($this->defaults, (array) $options);
$options['fields'] += $this->defaults['fields'];
$options['rootDir'] = $this->_getRootDir($options['rootDir']);
$options['thumbnailName'] = $this->_getThumbnailName($options['thumbnailName'], $options['thumbnailPrefixStyle']);
$options['thumbnailPath'] = Folder::slashTerm($this->_path($model, $field, array('isThumbnail' => true, 'path' => $options['thumbnailPath'] === null ? $options['path'] : $options['thumbnailPath'], 'rootDir' => $options['rootDir'])));
$options['path'] = Folder::slashTerm($this->_path($model, $field, array('isThumbnail' => false, 'path' => $options['path'], 'rootDir' => $options['rootDir'])));
if (!in_array($options['thumbnailMethod'], $this->_resizeMethods)) {
$options['thumbnailMethod'] = 'imagick';
}
if (!in_array($options['pathMethod'], $this->_pathMethods)) {
$options['pathMethod'] = 'primaryKey';
}
$options['pathMethod'] = '_getPath' . Inflector::camelize($options['pathMethod']);
$options['thumbnailMethod'] = '_resize' . Inflector::camelize($options['thumbnailMethod']);
$this->settings[$model->alias][$field] = $options;
}
}
示例5: load
function load($admin, $useDbAssociations = false)
{
// Load an instance of the admin model object
$plugin = Inflector::camelize($admin->plugin);
$modelObj = ClassRegistry::init(array('class' => "{$plugin}.{$admin->modelName}Admin", 'table' => $admin->useTable, 'ds' => $admin->useDbConfig));
$adminModelObj = ClassRegistry::init(array('class' => "{$plugin}.{$admin->modelName}Admin", 'table' => $admin->useTable, 'ds' => $admin->useDbConfig));
$modelClass = $admin->modelName . 'Admin';
$primaryKey = $adminModelObj->primaryKey;
$displayField = $adminModelObj->displayField;
$schema = $adminModelObj->schema(true);
$fields = array_keys($schema);
$controllerName = $this->_controllerName($admin->modelName);
$controllerRoute = $this->_pluralName($admin->modelName);
$pluginControllerName = $this->_controllerName($admin->modelName . 'Admin');
$singularVar = Inflector::variable($modelClass);
$singularName = $this->_singularName($modelClass);
$singularHumanName = $this->_singularHumanName($this->_controllerName($admin->modelName));
$pluralVar = Inflector::variable($pluginControllerName);
$pluralName = $this->_pluralName($modelClass);
$pluralHumanName = Inflector::humanize($this->_pluralName($controllerName));
if ($useDbAssociations) {
$associations = $this->loadAssociations($modelObj, $admin);
} else {
$associations = $this->__associations($adminModelObj);
}
return compact('admin', 'modelObj', 'adminModelObj', 'modelClass', 'primaryKey', 'displayField', 'schema', 'fields', 'controllerName', 'controllerRoute', 'pluginControllerName', 'singularVar', 'singularName', 'singularHumanName', 'pluralVar', 'pluralName', 'pluralHumanName', 'associations');
}
示例6: beforeRender
/**
* beforeRender is used for pre-render processing.
* Search the model schema for enum fields and transform
* them to use selects instead of text-input boxes
*
* During the model loop, we also check for form validation
* errors, and add them to an array, so that we can consolidate
* errors at the top of the page.
*
* This code is probably Mysql specific.
*/
function beforeRender()
{
$this->_persistValidation();
$validationErrors = array();
foreach ($this->modelNames as $model) {
// add validationerrors to view
if (is_array($this->{$model}->validationErrors)) {
$validationErrors = array_merge($validationErrors, array_values($this->{$model}->validationErrors));
}
// enum fixer
foreach ($this->{$model}->_schema as $var => $field) {
// === used here because 0 != FALSE
if (strpos($field['type'], 'enum') === FALSE) {
continue;
}
preg_match_all("/\\'([^\\']+)\\'/", $field['type'], $strEnum);
if (is_array($strEnum[1])) {
$varName = Inflector::camelize(Inflector::pluralize($var));
$varName[0] = strtolower($varName[0]);
// make nice cases in <selects>
$names = array();
foreach ($strEnum[1] as $name) {
$names[] = ucwords(strtolower($name));
}
$this->set($varName, array_combine($strEnum[1], $names));
}
}
}
$this->set('validationErrors', $validationErrors);
}
示例7: beforeFilter
function beforeFilter()
{
parent::beforeFilter();
$this->getConfig = Configure::read('webConfig');
$this->theme = $this->getConfig['template'];
$this->layout = $this->getConfig['template'];
//Collemos a configuración da tenda da bbdd
$this->set('config', $this->getConfig);
//Collemos os tamaños das imxes da bbdd para cada controlador
if (isset($this->getConfig['image_' . $this->params->controller])) {
$imageSize = explode('x', $this->getConfig['image_' . $this->params->controller]);
$this->set('imageSize', $imageSize);
}
//Collemos o nome da web (para os meta tags)
$this->set('webName', $this->getConfig['webName']);
$this->Auth->allow('index', 'view', 'contact', 'about');
$this->setDefaults();
//MODO MANTEMENTO
//----------------------------------------------------------------------
$this->manteinance();
//Default language for dashboard
$dashboardActions = array('add', 'edit', 'viewList');
$controller = Inflector::camelize(Inflector::singularize($this->params['controller']));
if (in_array($this->params['action'], $dashboardActions)) {
$this->{$controller}->locale = $this->getConfig['default_language'];
} else {
$this->{$controller}->locale = Configure::read('Config.language');
}
}
示例8: display
/**
* Method to output a tag-cloud formatted based on the weight of the tags
*
* @param array $tags
* @param array $options Display options. Valid keys are:
* - shuffle: true to shuffle the tag list, false to display them in the same order than passed [default: true]
* - extract: Set::extract() compatible format string. Path to extract weight values from the $tags array [default: {n}.GlobalTag.weight]
* - before: string to be displayed before each generated link. "%size%" will be replaced with tag size calculated from the weight [default: empty]
* - after: string to be displayed after each generated link. "%size%" will be replaced with tag size calculated from the weight [default: empty]
* - maxSize: size of the heaviest tag [default: 160]
* - minSize: size of the lightest tag [default: 80]
* - url: an array containing the default url
* - named: the named parameter used to send the tag [default: by]
* @return string
* @access public
*/
public function display($tags = null, $options = array())
{
if (empty($tags) || !is_array($tags)) {
return '';
}
$defaults = array('shuffle' => true, 'extract' => '{n}.GlobalTag.weight', 'between' => ' | ', 'maxSize' => 160, 'minSize' => 80, 'url' => array('action' => 'index'), 'named' => 'by');
$options = array_merge($defaults, $options);
$weights = Set::extract($tags, $options['extract']);
$maxWeight = max($weights);
$minWeight = min($weights);
// find the range of values
$spread = $maxWeight - $minWeight;
if (0 == $spread) {
$spread = 1;
}
if ($options['shuffle'] == true) {
shuffle($tags);
}
$cloud = array();
foreach ($tags as $tag) {
$options['url'][$options['named']] = $tag['GlobalTag']['keyname'];
$url = EventCore::trigger($this, Inflector::camelize($options['url']['plugin']) . '.slugUrl', array('type' => 'tag', 'data' => $options['url']));
$size = $options['minSize'] + ($tag['GlobalTag']['weight'] - $minWeight) * (($options['maxSize'] - $options['minSize']) / $spread);
$size = ceil($size);
$cloud[] = $this->Html->link($tag['GlobalTag']['name'], current($url['slugUrl']), array('class' => 'tag-' . $tag['GlobalTag']['id'])) . ' ';
}
return implode($options['between'], $cloud);
}
示例9: _getFullAssetPath
protected function _getFullAssetPath($path)
{
$filepath = preg_replace('/^' . preg_quote($this->Helper->request->webroot, '/') . '/', '', urldecode($path));
$webrootPath = WWW_ROOT . str_replace('/', DS, $filepath);
if (file_exists($webrootPath)) {
//@codingStandardsIgnoreStart
return $webrootPath;
//@codingStandardsIgnoreEnd
}
$segments = explode('/', ltrim($filepath, '/'));
if ($segments[0] === 'theme') {
$theme = $segments[1];
unset($segments[0], $segments[1]);
$themePath = App::themePath($theme) . 'webroot' . DS . implode(DS, $segments);
//@codingStandardsIgnoreStart
return $themePath;
//@codingStandardsIgnoreEnd
} else {
$plugin = Inflector::camelize($segments[0]);
if (CakePlugin::loaded($plugin)) {
unset($segments[0]);
$pluginPath = CakePlugin::path($plugin) . 'webroot' . DS . implode(DS, $segments);
//@codingStandardsIgnoreStart
return $pluginPath;
//@codingStandardsIgnoreEnd
}
}
return false;
}
示例10: parse
function parse($html = null, $blockName = 'document', $blockParams = null)
{
$blockParams = (array) $blockParams;
$blockParams += array('id' => null);
if ($blockParams['id']) {
$oldVars = $this->vars;
$this->vars = SlNode::get($blockParams['id'], array('auth' => true));
}
if ($blockName === 'NodeView') {
$skin = empty(SL::getInstance()->view->params['named']['skin']) ? Inflector::camelize($this->_getVar('CmsNode.skin')) : Inflector::camelize(SL::getInstance()->view->params['named']['skin']);
$skin = $skin && Pheme::init("NodeView{$skin}") ? "NodeView{$skin}" : "NodeViewDefault";
} else {
$skin = $blockName;
}
if ($skin != $blockName) {
PhemeParser::$parseCallStack[] = Pheme::get($skin);
$result = parent::parse($html, $skin);
array_pop(PhemeParser::$parseCallStack);
} else {
$result = parent::parse($html, $skin);
}
if (isset($oldVars)) {
$this->vars = $oldVars;
}
return $result;
}
示例11: initialize
/**
* initialize
*
* @param Controller $controller
* @return void
* @access public
*/
function initialize(&$controller)
{
/* 未インストール・インストール中の場合はすぐリターン */
if (!isInstalled()) {
return;
}
$plugins = Configure::read('Baser.enablePlugins');
/* プラグインフックコンポーネントが実際に存在するかチェックしてふるいにかける */
$pluginHooks = array();
if ($plugins) {
foreach ($plugins as $plugin) {
$pluginName = Inflector::camelize($plugin);
if (App::import('Component', $pluginName . '.' . $pluginName . 'Hook')) {
$pluginHooks[] = $pluginName;
}
}
}
/* プラグインフックを初期化 */
foreach ($pluginHooks as $pluginName) {
$className = $pluginName . 'HookComponent';
$this->pluginHooks[$pluginName] =& new $className();
// 各プラグインの関數をフックに登録する
if (isset($this->pluginHooks[$pluginName]->registerHooks)) {
foreach ($this->pluginHooks[$pluginName]->registerHooks as $hookName) {
$this->registerHook($hookName, $pluginName);
}
}
}
/* initialize のフックを実行 */
$this->executeHook('initialize', $controller);
}
示例12: changeStatus
public function changeStatus(Model $Model, $status, $id = null, $force = false)
{
if ($id === null) {
$id = $Model->getID();
}
if ($id === false) {
return false;
}
$force = true;
$Model->id = $id;
if (!$Model->exists()) {
throw new NotFoundException();
}
if ($force !== true) {
$modelData = $Model->read();
if ($modelData[$Model->alias]['status'] === $status) {
CakeLog::write(LOG_WARNING, __d('webshop', 'The status of %1$s with id %2$d is already set to %3$s. Not making a change', strtolower(Inflector::humanize(Inflector::underscore($Model->name))), $id, $status), array('webshop'));
return false;
}
} else {
CakeLog::write(LOG_WARNING, __d('webshop', 'Status change of %1$s with id %2$d is being forced to %3$s', strtolower(Inflector::humanize(Inflector::underscore($Model->name))), $id, $status), array('webshop'));
}
$Model->saveField('status', $status);
CakeLog::write(LOG_INFO, __d('webshop', 'Changed status of %1$s with id %2$d to %3$s', strtolower(Inflector::humanize(Inflector::underscore($Model->name))), $id, $status), array('webshop'));
$eventData = array();
$eventData[Inflector::underscore($Model->name)]['id'] = $id;
$eventData[Inflector::underscore($Model->name)]['status'] = $status;
$overallEvent = new CakeEvent($Model->name . '.statusChanged', $this, $eventData);
$specificEvent = new CakeEvent($Model->name . '.statusChangedTo' . Inflector::camelize($status), $this, $eventData);
CakeEventManager::instance()->dispatch($overallEvent);
CakeEventManager::instance()->dispatch($specificEvent);
return true;
}
示例13: input
/**
* This function inserts CK Editor for a form input
*
* @param string $input The name of the field, can be field_name or Model.field_name
* @param array $options Options include $options['label'] for a custom label - this can be expanded on if required
*/
public function input($input, $options = array())
{
echo $this->Html->script('//cdn.ckeditor.com/4.4.5.1/standard/ckeditor.js');
$input = explode('.', $input);
if (empty($input[1])) {
$field = $input[0];
$model = $this->Form->model();
} else {
$model = $input[0];
$field = $input[1];
}
if (!empty($options['label'])) {
echo '<label>' . $options['label'] . '</label>';
} else {
echo '<label>' . Inflector::humanize(Inflector::underscore($field)) . '</label>';
}
echo $this->Form->error($model . '.' . $field);
echo $this->Form->input($model . '.' . $field, array('type' => 'textarea', 'label' => false, 'error' => false, 'required' => false));
?>
<script type="text/javascript">
CKEDITOR.replace('<?php
echo Inflector::camelize($model . '_' . $field);
?>
', { customConfig: '<?php
echo $this->Html->url('/pages/ckeditor');
?>
' });
</script>
<p> </p>
<?php
}
示例14: main
/**
* Truncates all tables and loads fixtures into db
*
* @return void
* @access public
*/
function main()
{
if (!empty($this->args)) {
if ($this->args[0] == 'chmod') {
return $this->chmod();
}
$fixtures = $this->args;
foreach ($fixtures as $i => $fixture) {
$fixtures[$i] = APP . 'tests/fixtures/' . $fixture . '_fixture.php';
}
} else {
App::import('Folder');
$Folder = new Folder(APP . 'tests/fixtures');
$fixtures = $Folder->findRecursive('.+_fixture\\.php');
}
$db = ConnectionManager::getDataSource('default');
$records = 0;
foreach ($fixtures as $path) {
require_once $path;
$name = str_replace('_fixture.php', '', basename($path));
$class = Inflector::camelize($name) . 'Fixture';
$Fixture =& new $class($db);
$this->out('-> Truncating table "' . $Fixture->table . '"');
$db->truncate($Fixture->table);
$Fixture->insert($db);
$fixtureRecords = count($Fixture->records);
$records += $fixtureRecords;
$this->out('-> Inserting ' . $fixtureRecords . ' records for "' . $Fixture->table . '"');
}
$this->out(sprintf('-> Done inserting %d records for %d tables', $records, count($fixtures)));
}
示例15: _init
public function _init()
{
/*
* Auto bind the model
*
* If the controller -class has defined the variable "bindModelName", then we use the name in that variable,
* otherwise use the name of controller
*
* Example:
*
* class FoobarController extends Controller {
* var $bindModelName = "users";
* }
*
* This would cause the controller to automatically bind to model "users" instead of "foobar"
*
*/
$this->autoBindModel = Model::getModelIfExists(empty($this->bindModelName) ? $this->controllerName : $this->bindModelName);
/*
* Add the AUTOLOAD -models to this Controller. Autoload -models are models
* which are always available via $this->Modelname in all controllers
*/
if (property_exists('AppConfiguration', 'AUTOLOAD_MODELS')) {
foreach (AppConfiguration::$AUTOLOAD_MODELS as $model) {
$casedName = Inflector::camelize($model);
$this->{$casedName} = Model::getModel($model);
}
}
}