本文整理匯總了PHP中Inflector::Camelize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::Camelize方法的具體用法?PHP Inflector::Camelize怎麽用?PHP Inflector::Camelize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::Camelize方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: beforeRender
function beforeRender()
{
if (!isset($this->viewVars['data'])) {
$this->set('data', $this->data);
}
if (!$this->_isRequestAction()) {
if (!$this->menuItems) {
$this->menuItems['Home'] = array('url' => '/');
if ($this->plugin) {
$Human = Inflector::humanize($this->plugin);
$this->menuItems[$Human]['url'] = '/' . $this->PluginName;
$this->menuItems[$Human]['active'] = true;
$FileList = listClasses(APP . "plugins" . DS . $this->plugin . DS . "controllers");
foreach ($FileList as $file) {
$list = explode("_", $file);
unset($list[count($list) - 1]);
$controller = implode($list, "_");
if (up($controller) != up($this->plugin)) {
$array = array("url" => '/' . $this->PluginName . '/' . Inflector::camelize($controller));
if (Inflector::underscore($this->name) == $controller) {
$array['active'] = true;
}
$this->menuItems[Inflector::humanize($controller)] = $array;
}
}
} else {
$this->menuItems['Home']['active'] = true;
uses('Folder');
$Folder = new Folder(APP . DS . "plugins");
list($Plugins) = $Folder->ls();
foreach ($Plugins as $Plugin) {
$Camel = Inflector::Camelize($Plugin);
$Human = Inflector::humanize($Plugin);
$this->menuItems[$Human] = array('url' => '/' . $Camel);
}
}
}
$this->set('Menu', $this->menuItems);
$this->set('javascripts', $this->javascripts);
}
}
示例2: all
//.........這裏部分代碼省略.........
}
foreach ($paths as $i => $path) {
if (rtrim($path, DS) == rtrim(APP, DS)) {
$folder = new Folder(APP);
$tFiles = $folder->find(strtolower($type) . '.*php');
} elseif ($type === 'View') {
$tFiles = Mi::files($path, $excludeFolders, '.*ctp');
} else {
$tFiles = Mi::files($path, $excludeFolders, $pattern);
}
if ($allFiles) {
$tFiles = array_diff($tFiles, $allFiles);
}
foreach ($tFiles as $i => $file) {
if ($excludePattern && preg_match($excludePattern, $file)) {
unset($tFiles[$i]);
}
}
$allFiles = am($allFiles, $tFiles);
$files[$type] = am($files[$type], $tFiles);
}
$folder = new Folder(APP);
$tFiles = $folder->find($pattern);
$tFiles = array_diff($tFiles, $allFiles);
foreach ($tFiles as $i => $file) {
if ($excludePattern && preg_match($excludePattern, $file)) {
unset($tFiles[$i]);
}
}
$allFiles = am($allFiles, $tFiles);
if ((array) $extension != array('php')) {
foreach ($files[$type] as $file) {
$name = preg_replace('@.*vendors[\\\\/]@', '', $file);
if (isset($return[$name])) {
continue;
}
$return[$name] = $file;
}
return $return;
}
foreach ($files[$type] as $file) {
if (strpos($file, '.ctp')) {
$name = str_replace('.ctp', '', $file);
$name = preg_replace('@.*views[\\\\/]@', '', $name);
} else {
if ($type === 'Plugin') {
foreach ($types as $_type) {
if (strpos($file, strtolower($_type))) {
$suffix = $_type;
break;
}
}
if ($suffix === 'Model') {
$suffix = '';
}
} else {
$suffix = '';
}
$name = preg_replace('@.(' . implode('|', (array) $extension) . ')$@', '', basename($file));
$name = str_replace('_controller.', '.', $name);
$name = str_replace('_model.', '.', $name);
$name = str_replace('_helper.', '.', $name);
if ($type === 'Model') {
$type = '';
}
$name = Inflector::Camelize($name) . $type . $suffix;
}
if (isset($return[$name])) {
continue;
}
$return[$name] = $file;
}
}
if ($includeCore) {
$tFiles = Mi::files(CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS, $excludeFolders);
$tFiles = array_diff($tFiles, $allFiles);
foreach ($tFiles as $i => $file) {
if ($excludePattern && preg_match($excludePattern, $file)) {
unset($tFiles[$i]);
}
}
$allFiles = am($allFiles, $tFiles);
foreach ($tFiles as $file) {
$name = str_replace('.php', '', basename($file));
$name = str_replace('_controller', '', $name);
$name = str_replace('_model', '', $name);
$name = str_replace('_helper', '', $name);
if ($type === 'Model') {
$type = '';
}
$name = Inflector::Camelize($name);
if (isset($return[$name])) {
continue;
}
$return[$name] = $file;
}
}
ksort($return);
return array_flip($return);
}
示例3: getParent
/**
* get the parent for this object based on the nesting model types
* @return SCAR_Generic or false
**/
public function getParent()
{
if (!$this->hasParent()) {
return false;
}
// do sql
$this->doSQL();
// if we don't know who we are, throw an exception
// can't multiplex children
if (!$this->whoAmI()) {
throw new SCAR_Method_Call_Exception('getParent', $this);
}
if ($this->_data['acts_as_materialized_path']) {
$scar = call_user_func_array(array($this->getSCAR(), 'get'), array($this->getName()));
$call = 'by' . Inflector::Camelize($this->_data['acts_as_materialized_path']);
$path = substr($this->path, 0, strrpos($this->path, '/', -2) + 1);
var_dump($this->id . ' ' . $path);
$scar->{$call}($path);
// path minus last node
return $scar;
}
}
示例4: go
function go($Plugin, $confirmed = false, $stuffList = array(), $excludeList = array())
{
$this->plugin = $Plugin;
$this->PluginName = Inflector::Camelize($Plugin);
// Plugin App controller handled seperately
array_push($excludeList, 'plugins' . DS . $this->plugin . DS . $this->plugin . '_app_controller.php');
// Include the components used to download the plugin, in the hope that other's might do the same :)
array_push($stuffList, APP . 'controllers' . DS . 'components' . DS . 'download_plugin.php');
array_push($stuffList, APP . 'controllers' . DS . 'components' . DS . 'zip.php');
uses("Folder");
if ($confirmed == false) {
$this->controller->viewPath = '_generic';
$this->controller->layout = 'flash';
$this->controller->set('pause', 5);
$this->controller->set('url', '/' . $this->PluginName . '/' . $this->controller->name . '/' . $this->controller->action . '/confirmed');
$this->controller->set('message', 'Your download will begin in 5 seconds.');
$this->controller->set('pluginUnderscore', $Plugin);
$this->controller->set('pluginCamel', $this->PluginName);
$this->controller->set('plugin', Inflector::Humanize($Plugin));
$date = $this->getLastUpdated($Plugin, $stuffList);
$this->controller->set('last_updated', $date);
$this->controller->render('download');
die;
}
$Folder = new Folder(APP . "plugins" . DS . $this->plugin . DS);
$FileList = $Folder->findRecursive();
$pattern = "@//--Private[^\\@]*//--Private End@U";
// include adapated app controller
$pluginApp = file_get_contents(APP . 'plugins' . DS . $this->plugin . DS . $this->plugin . '_app_controller.php');
$pluginApp = r("<?php", "<?php\r\ninclude('noswad_controller.php');", $pluginApp);
$pluginApp = r("extends AppController", "extends NoswadController", $pluginApp);
$pluginApp = preg_replace($pattern, '', $pluginApp);
$this->Zip->addData($pluginApp, 'plugins' . DS . $this->plugin . DS . $this->plugin . '_app_controller.php');
// include every file from the stuff list, but put it in the plugin unless it's from the webroot
foreach ($stuffList as $file) {
if (strstr($file, APP_DIR)) {
$relativePath = substr($file, strlen(APP));
$relativePath = 'plugins' . DS . $this->plugin . DS . $relativePath;
} else {
$relativePath = "webroot" . DS . substr($file, strlen(WWW_ROOT));
}
if (!in_array($relativePath, $excludeList) && file_exists($file)) {
$addedFiles[] = $relativePath;
$FileContents = file_get_contents($file);
$FileContents = preg_replace($pattern, '', $FileContents);
$this->Zip->addData($FileContents, $relativePath);
/*
$this->Zip->addFile(
$file,
$relativePath
);
*/
}
}
// include every file from the plugin
foreach ($FileList as $file) {
$relativePath = substr($file, strlen(APP));
if (!in_array($relativePath, $excludeList) && file_exists($file)) {
$addedFiles[] = $relativePath;
$FileContents = file_get_contents($file);
$FileContents = preg_replace($pattern, '', $FileContents);
$this->Zip->addData($FileContents, $relativePath);
/*
$this->Zip->addFile(
$file,
$relativePath
);
*/
}
}
// include every file from the generic include folder
if ($this->genericPath) {
$Folder = new Folder($this->genericPath);
$FileList = $Folder->findRecursive();
foreach ($FileList as $file) {
$relativePath = substr($file, strlen($this->genericPath));
if ($relativePath != 'read_me.txt') {
$relativePath = 'plugins' . DS . $this->plugin . DS . $relativePath;
}
if (!in_array($relativePath, $addedFiles)) {
// Allow for overriding of included content
$this->Zip->addFile($file, $relativePath);
}
}
}
$this->Zip->forceDownload($this->PluginName . '.zip');
}