本文整理匯總了PHP中Inflector::toEnglish方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::toEnglish方法的具體用法?PHP Inflector::toEnglish怎麽用?PHP Inflector::toEnglish使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::toEnglish方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testToEnglish
function testToEnglish()
{
$this->assertEquals('To English', Inflector::toEnglish('toEnglish'));
$this->assertEquals('To English', Inflector::toEnglish('ToEnglish'));
$this->assertEquals('To English', Inflector::toEnglish('to_english'));
$this->assertEquals('To English', Inflector::toEnglish('_____to______english____'));
}
示例2: __construct
public function __construct($part, $name, $value = '', $label = false)
{
$part = 'controls/' . $part;
if ($label === false) {
$label = Inflector::toEnglish($name);
}
if ($value === true) {
$value = '__true__';
} else {
if ($value === false) {
$value = '__false__';
}
}
parent::__construct($part, $this, $name, $value, $label);
}
示例3: foreach
<?php
Layout::extend('layouts/master');
$title = 'Home';
?>
<ul>
<?php
// This is a really slow way to generate navigation.
// You probably should not use this in a real app. Thx -Kris
Library::import('recess.lang.Inflector');
$app = $controller->application();
$controllers = $app->listControllers();
foreach ($controllers as $controllerClass) {
$title = Inflector::toEnglish(str_replace('Controller', '', $controllerClass));
?>
<li><?php
echo Html::anchor(Url::action($controllerClass . '::index'), $title);
?>
</li>
<?php
}
?>
</ul>
示例4: generateScaffolding
/** !Route GET, $app/model/$model/scaffolding */
public function generateScaffolding($app, $model)
{
$app = new $app();
if (strpos($app->controllersPrefix, 'recess.apps.') !== false) {
$base = $_ENV['dir.recess'];
} else {
$base = $_ENV['dir.apps'];
}
Library::import('recess.lang.Inflector');
$controllersDir = $base . str_replace(Library::dotSeparator, Library::pathSeparator, $app->controllersPrefix);
$viewsDir = $app->viewsDir;
Library::import($app->modelsPrefix . $model);
$replacements = array('modelName' => $model, 'modelNameLower' => Inflector::toCamelCaps($model), 'fullyQualifiedModel' => $app->modelsPrefix . $model, 'primaryKey' => Model::primaryKeyName($model), 'viewsPrefix' => Inflector::toCamelCaps($model), 'routesPrefix' => Inflector::toCamelCaps($model));
$this->messages[] = $this->tryGeneratingFile('RESTful ' . $model . ' Controller', $this->application->codeTemplatesDir . 'scaffolding/controllers/ResourceController.template.php', $controllersDir . $model . 'Controller.class.php', $replacements);
$indexFieldTemplate = $this->getTemplate($this->application->codeTemplatesDir . 'scaffolding/views/resource/indexField.template.php');
$indexDateFieldTemplate = $this->getTemplate($this->application->codeTemplatesDir . 'scaffolding/views/resource/indexDateField.template.php');
$editFormInputTemplate = $this->getTemplate($this->application->codeTemplatesDir . 'scaffolding/views/resource/editFormInput.template.php');
$indexFields = '';
$formFields = '';
foreach (Model::getProperties($model) as $property) {
if ($property->isPrimaryKey) {
continue;
}
$values = array('fieldName' => $property->name, 'primaryKey' => Model::primaryKeyName($model), 'modelName' => $model, 'modelNameLower' => Inflector::toCamelCaps($model), 'fieldNameEnglish' => Inflector::toEnglish($property->name));
switch ($property->type) {
case RecessType::DATE:
case RecessType::DATETIME:
case RecessType::TIME:
case RecessType::TIMESTAMP:
$template = $indexDateFieldTemplate;
break;
default:
$template = $indexFieldTemplate;
break;
}
$formFields .= $this->fillTemplate($editFormInputTemplate, $values);
$indexFields .= $this->fillTemplate($template, $values);
}
$replacements['fields'] = $indexFields;
$replacements['editFields'] = $formFields;
$viewsDir = $app->viewsDir . $replacements['viewsPrefix'] . '/';
$this->messages[] = $this->tryCreatingDirectory($viewsDir, $model . ' views dir');
$this->messages[] = $this->tryGeneratingFile('resource layout', $this->application->codeTemplatesDir . 'scaffolding/views/resource/resource.layout.template.php', $viewsDir . '../layouts/' . $replacements['viewsPrefix'] . '.layout.php', $replacements);
$this->messages[] = $this->tryGeneratingFile('index view', $this->application->codeTemplatesDir . 'scaffolding/views/resource/index.template.php', $viewsDir . 'index.html.php', $replacements);
$this->messages[] = $this->tryGeneratingFile('editForm view', $this->application->codeTemplatesDir . 'scaffolding/views/resource/editForm.template.php', $viewsDir . 'editForm.html.php', $replacements, true);
$this->messages[] = $this->tryGeneratingFile('form part', $this->application->codeTemplatesDir . 'scaffolding/views/resource/form.part.template.php', $viewsDir . 'form.part.php', $replacements, true);
$this->messages[] = $this->tryGeneratingFile('static details', $this->application->codeTemplatesDir . 'scaffolding/views/resource/details.template.php', $viewsDir . 'details.html.php', $replacements);
$this->messages[] = $this->tryGeneratingFile('details part', $this->application->codeTemplatesDir . 'scaffolding/views/resource/details.part.template.php', $viewsDir . 'details.part.php', $replacements);
$this->appName = get_class($app);
$this->modelName = $model;
}