本文整理汇总了PHP中AkInflector::titleize方法的典型用法代码示例。如果您正苦于以下问题:PHP AkInflector::titleize方法的具体用法?PHP AkInflector::titleize怎么用?PHP AkInflector::titleize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AkInflector
的用法示例。
在下文中一共展示了AkInflector::titleize方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: guide
public function guide()
{
$this->tab = 'docs';
$this->docs_helper->docs_path = 'guides';
$this->title = AkInflector::titleize(@$this->params['id']) . ', Akelos guides';
$this->guide = $this->docs_helper->get_doc_contents(empty($this->params['id']) ? 'getting_started' : $this->params['id']);
}
示例2: trim
function &recognize($Map = null)
{
AK_ENVIRONMENT != 'setup' ? $this->_connectToDatabase() : null;
$this->_startSession();
$this->_enableInternationalizationSupport();
$this->_mapRoutes($Map);
$params = $this->getParams();
$module_path = $module_class_peffix = '';
if (!empty($params['module'])) {
$module_path = trim(str_replace(array('/', '\\'), DS, Ak::sanitize_include($params['module'], 'high')), DS) . DS;
$module_shared_model = AK_CONTROLLERS_DIR . DS . trim($module_path, DS) . '_controller.php';
$module_class_peffix = str_replace(' ', '_', AkInflector::titleize(str_replace(DS, ' ', trim($module_path, DS)))) . '_';
}
$controller_file_name = AkInflector::underscore($params['controller']) . '_controller.php';
$controller_class_name = $module_class_peffix . AkInflector::camelize($params['controller']) . 'Controller';
$controller_path = AK_CONTROLLERS_DIR . DS . $module_path . $controller_file_name;
include_once AK_APP_DIR . DS . 'application_controller.php';
if (!empty($module_path) && file_exists($module_shared_model)) {
include_once $module_shared_model;
}
if (!is_file($controller_path) || !(include_once $controller_path)) {
defined('AK_LOG_EVENTS') && AK_LOG_EVENTS && $this->Logger->error('Controller ' . $controller_path . ' not found.');
if (AK_ENVIRONMENT == 'development') {
trigger_error(Ak::t('Could not find the file /app/controllers/<i>%controller_file_name</i> for ' . 'the controller %controller_class_name', array('%controller_file_name' => $controller_file_name, '%controller_class_name' => $controller_class_name)), E_USER_ERROR);
} elseif (@(include AK_PUBLIC_DIR . DS . '404.php')) {
$response = new AkTestResponse();
$response->addHeader('Status', 404);
return false;
//exit;
} else {
//header("HTTP/1.1 404 Not Found");
$response = new AkResponse();
$response->addHeader('Status', 404);
return false;
//die('404 Not found');
}
}
if (!class_exists($controller_class_name)) {
defined('AK_LOG_EVENTS') && AK_LOG_EVENTS && $this->Logger->error('Controller ' . $controller_path . ' does not implement ' . $controller_class_name . ' class.');
if (AK_ENVIRONMENT == 'development') {
trigger_error(Ak::t('Controller <i>%controller_name</i> does not exist', array('%controller_name' => $controller_class_name)), E_USER_ERROR);
} elseif (@(include AK_PUBLIC_DIR . DS . '405.php')) {
exit;
} else {
$response = new AkResponse();
$response->addHeader('Status', 405);
return false;
//header("HTTP/1.1 405 Method Not Allowed");
//die('405 Method Not Allowed');
}
}
$Controller =& new $controller_class_name(array('controller' => true));
$Controller->_module_path = $module_path;
isset($_SESSION) ? $Controller->session =& $_SESSION : null;
return $Controller;
}
示例3: suite
public static function suite()
{
$class_name = substr(basename(__FILE__), 0, -4);
$test_folder = strtolower(substr($class_name, 0, -9));
$suite = new ExamplesTestSuite(AkInflector::titleize($class_name));
$path = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . $test_folder;
$directory = new PHPUnit_Runner_IncludePathTestCollector(array($path));
$suite->addTestFiles($directory->collectTests());
return $suite;
}
示例4: _getMenuOptionsForControllersInModule
public function _getMenuOptionsForControllersInModule($type = 'admin')
{
$controllers = AkFileSystem::dir(AK_CONTROLLERS_DIR . DS . $this->_controller->getModuleName(), array('dirs' => false));
sort($controllers);
$menu_options = array();
foreach ($controllers as $controller) {
$controller_name = substr($controller, 0, -15);
$menu_options[AkInflector::titleize($controller_name)] = array('id' => $controller_name, 'url' => array('controller' => $controller_name));
}
$options_file = $this->_getMenuOptionsFile($type);
if (!file_exists($options_file)) {
AkFileSystem::file_put_contents(AK_CONFIG_DIR . DS . $options_file, Ak::convert('array', 'yaml', array('default' => $menu_options)));
}
return $menu_options;
}
示例5: _setupCloner
function _setupCloner()
{
$this->clone_setup_done = true;
$this->class_to_clone = AkInflector::underscore($this->class_to_clone);
$this->class_name = AkInflector::underscore($this->class_name);
$this->clone_replacements = array(AkInflector::camelize($this->class_to_clone) . 'Controller' => AkInflector::camelize($this->class_name) . 'Controller', AkInflector::humanize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::humanize(AkInflector::pluralize($this->class_name)), AkInflector::titleize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::titleize(AkInflector::pluralize($this->class_name)), AkInflector::humanize($this->class_to_clone) => AkInflector::humanize($this->class_name), AkInflector::titleize($this->class_to_clone) => AkInflector::titleize($this->class_name), AkInflector::camelize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::camelize(AkInflector::pluralize($this->class_name)), AkInflector::pluralize($this->class_to_clone) => AkInflector::pluralize($this->class_name), AkInflector::camelize($this->class_to_clone) => AkInflector::camelize($this->class_name), $this->class_to_clone => $this->class_name);
//AK_VIEWS_DIR.DS.AkInflector::underscore($this->class_name).DS.$action.'.tpl'
$this->files_to_clone = array(AkInflector::toModelFilename($this->class_to_clone) => AkInflector::toModelFilename($this->class_name), AK_TEST_DIR . DS . 'unit' . DS . 'test_' . $this->class_to_clone . '.php' => AK_TEST_DIR . DS . 'unit' . DS . 'test_' . $this->class_name . '.php', AK_TEST_DIR . DS . 'fixtures' . DS . AkInflector::tableize($this->class_to_clone) . '.yml' => AK_TEST_DIR . DS . 'fixtures' . DS . AkInflector::tableize($this->class_name) . '.yml', AkInflector::toControllerFilename($this->class_to_clone) => AkInflector::toControllerFilename($this->class_name), AK_TEST_DIR . DS . 'functional' . DS . 'test_' . AkInflector::camelize($this->class_to_clone . '_controller') . '.php' => AK_TEST_DIR . DS . 'functional' . DS . 'test_' . AkInflector::camelize($this->class_name . '_controller') . '.php', AK_HELPERS_DIR . DS . AkInflector::underscore("{$this->class_to_clone}_helper") . '.php' => AK_HELPERS_DIR . DS . AkInflector::underscore("{$this->class_name}_helper") . '.php');
foreach ($this->_getControllerViews() as $view_file) {
$this->files_to_clone[AK_VIEWS_DIR . DS . $this->class_to_clone . DS . $view_file . '.tpl'] = AK_VIEWS_DIR . DS . $this->class_name . DS . $view_file . '.tpl';
}
$this->files_to_clone[AK_VIEWS_DIR . DS . 'layouts' . DS . $this->class_to_clone . '.tpl'] = AK_VIEWS_DIR . DS . 'layouts' . DS . $this->class_name . '.tpl';
foreach (Ak::dir(AK_APP_DIR . DS . 'locales' . DS . $this->class_to_clone, array('dirs' => false)) as $locale_file) {
$this->files_to_clone[AK_APP_DIR . DS . 'locales' . DS . $this->class_to_clone . DS . $locale_file] = AK_APP_DIR . DS . 'locales' . DS . $this->class_name . DS . $locale_file;
}
}
示例6: handleSubpackage
function handleSubpackage($subpackage_description)
{
$this->subpackage = AkInflector::titleize($subpackage_description);
//Ak::trace($this->subpackage);
}
示例7: image_tag
/**
* Returns an image tag converting the +options+ into html options on the tag, but with these special cases:
*
* * <tt>alt</tt> - If no alt text is given, the file name part of the +src+ is used (capitalized and without the extension)
* * <tt>size</tt> - Supplied as "XxY", so "30x45" becomes width="30" and height="45"
*
* The +src+ can be supplied as a...
* * full path, like "/my_images/image.gif"
* * file name, like "rss.gif", that gets expanded to "/images/rss.gif"
* * file name without extension, like "logo", that gets expanded to "/images/logo.png"
*/
public function image_tag($source, $options = array())
{
if (!empty($options['size'])) {
list($options['width'], $options['height']) = preg_split('/x|X| /', trim(str_replace(' ', '', $options['size'])));
unset($options['size']);
}
$options['src'] = $this->image_path($source);
$options['alt'] = !empty($options['alt']) ? $options['alt'] : AkInflector::titleize(substr(basename($options['src']), 0, strpos(basename($options['src']), '.')), 'first');
return AkTagHelper::tag('img', $options);
}
示例8: titleize
/**
* Converts an underscored or CamelCase word into a English
* sentence.
*
* The titleize function converts text like "WelcomePage",
* "welcome_page" or "welcome page" to this "Welcome
* Page".
* If second parameter is set to 'first' it will only
* capitalize the first character of the title.
*
* @access public
* @static
* @param string $word Word to format as tile
* @param string $uppercase If set to 'first' it will only uppercase the
* first character. Otherwise it will uppercase all
* the words in the title.
* @return string Text formatted as title
*/
function titleize($text, $uppercase = '')
{
return AkInflector::titleize($text, $uppercase);
}
示例9: array
=& new $this-><?php
echo $CamelCaseSingular;
?>
();
}
$this-><?php
echo $CamelCaseSingular;
?>
->setAttributes($this->params['<?php
echo $CamelCaseSingular;
?>
']);
if($this->Request->isPost() && $this-><?php
echo $CamelCaseSingular;
?>
->save()){
$this->flash_options = array('seconds_to_close' => 10);
$this->flash['notice'] = $this->t('<?php
echo AkInflector::titleize($singular_name);
?>
was successfully '.($is_add?'created':'updated').'.');
$this->redirectTo(array('action' => 'show', 'id' => $this-><?php
echo $CamelCaseSingular;
?>
->getId()));
}
}
}
}
?>
示例10: trim
/**
* Recognizes a Request and returns the responsible controller instance
*
* @return AkActionController
*/
function &recognize($Map = null)
{
$this->_connectToDatabase();
$this->_startSession();
$this->_enableInternationalizationSupport();
$this->_mapRoutes($Map);
$params = $this->getParams();
$module_path = $module_class_peffix = '';
if(!empty($params['module'])){
$module_path = trim(str_replace(array('/','\\'), DS, Ak::sanitize_include($params['module'], 'high')), DS).DS;
$module_shared_model = AK_CONTROLLERS_DIR.DS.trim($module_path,DS).'_controller.php';
$module_class_peffix = str_replace(' ','_',AkInflector::titleize(str_replace(DS,' ', trim($module_path, DS)))).'_';
}
$controller_file_name = AkInflector::underscore($params['controller']).'_controller.php';
$controller_class_name = $module_class_peffix.AkInflector::camelize($params['controller']).'Controller';
$controller_path = AK_CONTROLLERS_DIR.DS.$module_path.$controller_file_name;
include_once(AK_APP_DIR.DS.'application_controller.php');
if(!empty($module_path) && file_exists($module_shared_model)){
include_once($module_shared_model);
}
if(@!include_once($controller_path)){
trigger_error(Ak::t('Could not find the file /app/controllers/<i>%controller_file_name</i> for '.
'the controller %controller_class_name',
array('%controller_file_name'=> $controller_file_name,
'%controller_class_name' => $controller_class_name)), E_USER_ERROR);
}
if(!class_exists($controller_class_name)){
trigger_error(Ak::t('Controller <i>%controller_name</i> does not exist',
array('%controller_name' => $controller_class_name)), E_USER_ERROR);
}
$Controller =& new $controller_class_name(array('controller'=>true));
$Controller->_module_path = $module_path;
isset($_SESSION) ? $Controller->session =& $_SESSION : null;
return $Controller;
}
示例11: Test_of_titleize
function Test_of_titleize()
{
foreach ($this->MixtureToTitleCase as $source => $expected) {
$this->assertEqual($expected, AkInflector::titleize($source));
}
}
示例12: titleize
public function titleize()
{
return AkInflector::titleize($this->value);
}
示例13: runFromOptions
static function runFromOptions($options = array())
{
$default_options = array('base_path' => AK_TEST_DIR, 'TestSuite' => null, 'reporter' => AK_TEST_DEFAULT_REPORTER, 'files' => array());
$options = array_merge($default_options, $options);
$descriptions = array();
if (!empty($options['files'])) {
$full_paths = array();
foreach ($options['files'] as $file) {
list($suite, $case) = explode('/', $file . '/');
$case = str_replace('.php', '', $case);
$full_paths[] = $options['base_path'] . DS . $suite . DS . 'cases' . DS . $case . '.php';
$descriptions[AkInflector::titleize($suite)][] = AkInflector::titleize($case);
}
$options['files'] = $full_paths;
}
AkUnitTestSuite::createTestingDatabaseIfNotAvailable();
if (!empty($options['component'])) {
$components = Ak::toArray($options['component']);
$real_base_path = $options['base_path'];
$options['description'] = '';
$options['files'] = array();
foreach ($components as $component) {
$options['base_path'] = $real_base_path . DS . $component;
if (empty($options['suites'])) {
$options['suites'] = array_diff(glob($options['base_path'] . DS . '*'), array(''));
} else {
$options['suites'] = Ak::toArray($options['suites']);
}
$options['description'] .= AkInflector::titleize($component) . " unit tests: Suites(";
foreach ($options['suites'] as $k => $suite) {
$suite_name = $options['suites'][$k] = trim(str_replace($options['base_path'] . DS, '', $suite), DS);
if (is_dir($options['base_path'] . DS . $suite_name)) {
$options['description'] .= $suite_name . ',';
$options['files'] = array_merge($options['files'], array_diff(glob($options['base_path'] . DS . $suite_name . DS . 'cases' . DS . '*.php'), array('')));
} else {
unset($options['suites'][$k]);
}
}
$options['description'] = str_replace(' Suites():', '', trim($options['description'], ', ') . "):\n");
if (empty($options['title'])) {
$options['title'] = AkUnitTestSuite::getTestTitle($options);
}
}
} else {
$options['description'] = '';
foreach ($descriptions as $suite => $cases) {
$options['description'] .= "{$suite} (cases): " . $options['description'] . rtrim(join(', ', $cases), ', ') . "\n";
}
if (empty($options['description'])) {
$options['description'] = AkInflector::titleize($options['suite']) . ' (suite)';
$options['files'] = array_diff(glob($options['base_path'] . DS . $options['suite'] . DS . 'cases' . DS . '*.php'), array(''));
}
if (empty($options['title'])) {
$suite_name = empty($options['suite']) ? preg_replace('/.+\\/([^\\/]+)\\/cases.+/', '$1', @$options['files'][0]) : $options['suite'];
AkConfig::setOption('testing_url', AK_TESTING_URL);
AkConfig::setOption('memcached_enabled', AkMemcache::isServerUp());
AkUnitTestSuite::checkIfTestingWebserverIsAccesible($options);
$dabase_settings = AK_DATABASE_SETTINGS_NAMESPACE == 'database' ? Ak::getSetting('database', 'type') : AK_DATABASE_SETTINGS_NAMESPACE;
$options['title'] = "PHP " . phpversion() . ", Environment: " . AK_ENVIRONMENT . ", Database: " . $dabase_settings . (AkConfig::getOption('memcached_enabled', false) ? ', Memcached: enabled' : '') . (AkConfig::getOption('webserver_enabled', false) ? ', Testing URL: ' . AkConfig::getOption('testing_url') : ', Testing URL: DISABLED!!!') . "\n" . "Error reporting set to: " . AkConfig::getErrorReportingLevelDescription() . "\n" . trim($options['description']) . '';
}
}
$options['TestSuite'] = new AkUnitTestSuite($options['title']);
$options['TestSuite']->running_from_config = true;
if (empty($options['files'])) {
$component = AkInflector::underscore($options['component']);
if (AkInflector::underscore(AK_APP_NAME) == $component) {
$options['files'] = glob(AK_TEST_DIR . DS . 'unit' . DS . '*.php');
} else {
$options['files'] = glob(AK_TEST_DIR . DS . 'unit' . DS . $component . '*.php');
}
if (empty($options['files'])) {
trigger_error('Could not find test cases to run.', E_USER_ERROR);
}
}
foreach ($options['files'] as $file) {
$options['TestSuite']->addFile($file);
}
//($options['TestSuite']->run(new $options['reporter']()) ? 0 : 1); file_put_contents(AK_LOG_DIR.DS.'included_files.php', var_export(get_included_files(), true)); return;
exit($options['TestSuite']->run(new $options['reporter']()) ? AkUnitTestSuite::runOnFailure(@$options['on_failure']) : AkUnitTestSuite::runOnSuccess(@$options['on_success']));
}
示例14: array
$this->redirectToAction('listing');
}
}
function _find<?php echo $model_name?>OrRedirect()
{
if( empty($this->params['id']) ||
!($this-><?php echo $CamelCaseSingular?> =& $this-><?php echo $model_name?>->find(@$this->params['id']))){
$this->flash['error'] = $this->t('<?php echo AkInflector::titleize($singular_name)?> not found.');
$this->redirectToAction('listing');
}
}
function _addOrEdit<?php echo $model_name?>($add_or_edit)
{
$is_add = $add_or_edit != 'edit';
if(!empty($this->params['<?php echo $CamelCaseSingular?>'])){
if($is_add){
$this-><?php echo $CamelCaseSingular?> =& new $this-><?php echo $CamelCaseSingular?>();
}
$this-><?php echo $CamelCaseSingular?>->setAttributes($this->params['<?php echo $CamelCaseSingular?>']);
if($this->Request->isPost() && $this-><?php echo $CamelCaseSingular?>->save()){
$this->flash_options = array('seconds_to_close' => 10);
$this->flash['notice'] = $this->t('<?php echo AkInflector::titleize($singular_name)?> was successfully '.($is_add?'created':'updated').'.');
$this->redirectTo(array('action' => 'show', 'id' => $this-><?php echo $CamelCaseSingular?>->getId()));
}
}
}
}
?>