本文整理汇总了PHP中Folder::slashTerm方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::slashTerm方法的具体用法?PHP Folder::slashTerm怎么用?PHP Folder::slashTerm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::slashTerm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clear
/**
* Empty the folder.
* Instead of deleting the folder itself as delete() does,
* this method only removes its content recursivly.
*
* Note: It skips hidden folders (starting with a . dot).
*
* @return bool Success or null on invalid folder
*/
public function clear($path = null)
{
if (!$path) {
$path = $this->pwd();
}
if (!$path) {
return null;
}
$path = Folder::slashTerm($path);
if (!is_dir($path)) {
return null;
}
$normalFiles = glob($path . '*');
$hiddenFiles = glob($path . '\\.?*');
$normalFiles = $normalFiles ? $normalFiles : array();
$hiddenFiles = $hiddenFiles ? $hiddenFiles : array();
$files = array_merge($normalFiles, $hiddenFiles);
foreach ($files as $file) {
if (preg_match('/(\\.|\\.\\.)$/', $file)) {
continue;
}
if (is_file($file)) {
if (@unlink($file)) {
$this->_messages[] = __('%s removed', $file);
} else {
$this->_errors[] = __('%s NOT removed', $file);
}
} elseif (is_dir($file) && $this->delete($file) === false) {
return false;
}
}
return true;
}
示例2: pwd
/**
* Returns the full path of the File.
*
* @return string Full path to file
* @access public
*/
function pwd()
{
if (is_null($this->path)) {
$this->path = $this->Folder->slashTerm($this->Folder->pwd()) . $this->name;
}
return $this->path;
}
示例3: execute
/**
* Checks that given project path does not already exist, and
* finds the app directory in it. Then it calls bake() with that information.
*
* @param string $project Project path
* @access public
*/
function execute($project = null)
{
if ($project === null) {
if (isset($this->args[0])) {
$project = $this->args[0];
$this->Dispatch->shiftArgs();
}
}
if ($project) {
$this->Dispatch->parseParams(array('-app', $project));
$project = $this->params['working'];
}
if (empty($this->params['skel'])) {
$this->params['skel'] = '';
if (is_dir(CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'console' . DS . 'libs' . DS . 'templates' . DS . 'skel') === true) {
$this->params['skel'] = CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'console' . DS . 'libs' . DS . 'templates' . DS . 'skel';
}
}
while (!$project) {
$project = $this->in("What is the full path for this app including the app directory name?\nExample: " . $this->params['working'] . DS . "myapp", null, $this->params['working'] . DS . 'myapp');
}
if ($project) {
$response = false;
while ($response == false && is_dir($project) === true && file_exists($project . 'config' . 'core.php')) {
$response = $this->in('A project already exists in this location: ' . $project . ' Overwrite?', array('y', 'n'), 'n');
if (strtolower($response) === 'n') {
$response = $project = false;
}
}
}
if ($this->bake($project)) {
$path = Folder::slashTerm($project);
if ($this->createHome($path)) {
$this->out(__('Welcome page created', true));
} else {
$this->out(__('The Welcome page was NOT created', true));
}
if ($this->securitySalt($path) === true) {
$this->out(__('Random hash key created for \'Security.salt\'', true));
} else {
$this->err(sprintf(__('Unable to generate random hash for \'Security.salt\', you should change it in %s', true), CONFIGS . 'core.php'));
}
$corePath = $this->corePath($path);
if ($corePath === true) {
$this->out(sprintf(__('CAKE_CORE_INCLUDE_PATH set to %s in webroot/index.php', true), CAKE_CORE_INCLUDE_PATH));
$this->out(sprintf(__('CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php', true), CAKE_CORE_INCLUDE_PATH));
$this->out(__('Remember to check these value after moving to production server', true));
} elseif ($corePath === false) {
$this->err(sprintf(__('Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', true), $path . 'webroot' . DS . 'index.php'));
}
$Folder = new Folder($path);
if (!$Folder->chmod($path . 'tmp', 0777)) {
$this->err(sprintf(__('Could not set permissions on %s', true), $path . DS . 'tmp'));
$this->out(sprintf(__('chmod -R 0777 %s', true), $path . DS . 'tmp'));
}
$this->params['working'] = $path;
$this->params['app'] = basename($path);
return true;
}
}
示例4: pwd
/**
* Returns the full path of the file.
*
* @return string Full path to the file
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::pwd
*/
public function pwd()
{
if ($this->path === null) {
$this->path = $this->Folder->slashTerm($this->Folder->pwd()) . $this->name;
}
return $this->path;
}
示例5: pwd
/**
* Returns the full path of the file.
*
* @return string Full path to the file
*/
public function pwd()
{
if ($this->path === null) {
$dir = $this->Folder->pwd();
if (is_dir($dir)) {
$this->path = $this->Folder->slashTerm($dir) . $this->name;
}
}
return $this->path;
}
示例6: beforeFilter
/**
* beforeFilter callback
*
* @return void
**/
public function beforeFilter()
{
parent::beforeFilter();
$this->ApiConfig = ClassRegistry::init('ApiGenerator.ApiConfig');
$this->ApiConfig->read();
$path = $this->ApiConfig->getPath();
if (empty($path)) {
$path = APP;
$this->ApiConfig->data['paths'][$path] = true;
}
$this->path = Folder::slashTerm(realpath($path));
}
示例7: create
/**
* Create new project
*/
public function create()
{
$project = '.';
$root = ROOT;
$app = APP_DIR;
$working = APP;
$core = "{$root}/{$app}/Vendor/cakephp/cakephp/lib";
$skel = "{$core}/Cake/Console/Templates/skel";
$this->out(__d('cake_console', '<info>Create project `%s` in `%s`</info>', $app, $working));
if (!empty($project) && !Folder::isAbsolute($project) && isset($_SERVER['PWD'])) {
$project = $_SERVER['PWD'] . DS . $project;
}
if ($this->_bake($project, $skel)) {
$path = Folder::slashTerm($project);
$this->_fixConfigureFiles($path);
$this->_fixCakeCoreIncludePath($path);
$this->_fixDebugKitPlugin($path);
$this->_fixAutoloader($path);
$this->_fixPermissionForDirs($path);
$this->_fixGitIgnore($path);
}
}
示例8: uploadFullPath
public function uploadFullPath()
{
return Folder::slashTerm($this->uploadPath() . $this->uploadDir());
}
示例9: make
/**
* Parses instruction sets and invokes `makeVersion()` for each version on a file.
* Also creates the destination directory if enabled by settings.
*
* If the `makeVersion()` method is implemented in the current model it'll be used
* for generating a specifc version of the file (i.e. `s`, `m` or `l`) otherwise
* the method within this behavior is going to be used.
*
* If you already have generated versions of files and change the filter
* configuration afterwards you may want to recreate those files with the new
* settings.
*
* You can achieve that by removing already generated files first (optional), than
* invoking the task from the shell:
* $ cake media make
*
* For more information on options and arguments for the task call:
* $ cake media help
*
* @param Model $Model
* @param string $file Path to a file relative to `baseDirectory` or an absolute path to a file
* @return boolean
*/
function make(&$Model, $file)
{
extract($this->settings[$Model->alias]);
list($file, $relativeFile) = $this->_file($Model, $file);
$relativeDirectory = DS . rtrim(dirname($relativeFile), '.');
$filter = Configure::read('Media.filter.' . Mime_Type::guessName($file));
$result = true;
foreach ($filter as $version => $instructions) {
$directory = Folder::slashTerm($filterDirectory . $version . $relativeDirectory);
$Folder = new Folder($directory, $createDirectory, $createDirectoryMode);
if (!$Folder->pwd()) {
$message = "GeneratorBehavior::make - Directory `{$directory}` ";
$message .= "could not be created or is not writable. ";
$message .= "Please check the permissions.";
trigger_error($message, E_USER_WARNING);
$result = false;
continue;
}
try {
$result = $Model->makeVersion($file, compact('version', 'directory', 'instructions'));
} catch (Exception $E) {
$message = "GeneratorBehavior::make - While making version `{$version}` ";
$message .= "of file `{$file}` an exception was thrown, the message provided ";
$message .= 'was `' . $E->getMessage() . '`. Skipping version.';
trigger_error($message, E_USER_WARNING);
$result = false;
}
if (!$result) {
$message = "GeneratorBehavior::make - The method responsible for making version ";
$message .= "`{$version}` of file `{$file}` returned `false`. Skipping version.";
trigger_error($message, E_USER_WARNING);
$result = false;
}
}
return $result;
}
示例10: _path
/**
* Returns a path based on settings configuration
*
* @param Model $model Model instance
* @param string $field Name of field being modified
* @param array $options Options to use when building a path
* @return string
**/
protected function _path(Model $model, $field, $options = array())
{
$defaults = array('isThumbnail' => true, 'path' => '{ROOT}webroot{DS}files{DS}{model}{DS}{field}{DS}', 'rootDir' => $this->defaults['rootDir']);
$options = array_merge($defaults, $options);
foreach ($options as $key => $value) {
if ($value === null) {
$options[$key] = $defaults[$key];
}
}
if (!$options['isThumbnail']) {
$options['path'] = str_replace(array('{size}', '{geometry}'), '', $options['path']);
}
$replacements = array('{ROOT}' => $options['rootDir'], '{primaryKey}' => $model->id, '{model}' => Inflector::underscore($model->alias), '{field}' => $field, '{time}' => time(), '{microtime}' => microtime(), '{DS}' => DIRECTORY_SEPARATOR, '//' => DIRECTORY_SEPARATOR, '/' => DIRECTORY_SEPARATOR, '\\' => DIRECTORY_SEPARATOR);
$newPath = Folder::slashTerm(str_replace(array_keys($replacements), array_values($replacements), $options['path']));
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
if (!preg_match('/^([a-zA-Z]:\\\\|\\\\)/', $newPath)) {
$newPath = $options['rootDir'] . $newPath;
}
} elseif ($newPath[0] !== DIRECTORY_SEPARATOR) {
$newPath = $options['rootDir'] . $newPath;
}
$pastPath = $newPath;
while (true) {
$pastPath = $newPath;
$newPath = str_replace(array('//', '\\', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR, $newPath);
if ($pastPath == $newPath) {
break;
}
}
return $newPath;
}
示例11: __realPath
/**
* __realPath
*
* @param string $path path
* @return string Real path
*/
private function __realPath($path)
{
$replacements = array('{ROOT}' => $this->rootDir, '{DS}' => DS);
$path = Folder::slashTerm(str_replace(array_keys($replacements), array_values($replacements), $path));
return $path;
}
示例12: execute
/**
* Checks that given project path does not already exist, and
* finds the app directory in it. Then it calls bake() with that information.
*
* @return mixed
*/
public function execute()
{
$project = null;
if (isset($this->args[0])) {
$project = $this->args[0];
} else {
$appContents = array_diff(scandir(APP), array('.', '..'));
if (empty($appContents)) {
$suggestedPath = rtrim(APP, DS);
} else {
$suggestedPath = APP . 'myapp';
}
}
while (!$project) {
$prompt = __d('cake_console', "What is the path to the project you want to bake?");
$project = $this->in($prompt, null, $suggestedPath);
}
if ($project && !Folder::isAbsolute($project) && isset($_SERVER['PWD'])) {
$project = $_SERVER['PWD'] . DS . $project;
}
$response = false;
while (!$response && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
$prompt = __d('cake_console', '<warning>A project already exists in this location:</warning> %s Overwrite?', $project);
$response = $this->in($prompt, array('y', 'n'), 'n');
if (strtolower($response) === 'n') {
$response = $project = false;
}
}
$success = true;
if ($this->bake($project)) {
$path = Folder::slashTerm($project);
if ($this->securitySalt($path) === true) {
$this->out(__d('cake_console', ' * Random hash key created for \'Security.salt\''));
} else {
$this->err(__d('cake_console', 'Unable to generate random hash for \'Security.salt\', you should change it in %s', APP . 'Config' . DS . 'core.php'));
$success = false;
}
if ($this->securityCipherSeed($path) === true) {
$this->out(__d('cake_console', ' * Random seed created for \'Security.cipherSeed\''));
} else {
$this->err(__d('cake_console', 'Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', APP . 'Config' . DS . 'core.php'));
$success = false;
}
if ($this->cachePrefix($path)) {
$this->out(__d('cake_console', ' * Cache prefix set'));
} else {
$this->err(__d('cake_console', 'The cache prefix was <error>NOT</error> set'));
$success = false;
}
if ($this->consolePath($path) === true) {
$this->out(__d('cake_console', ' * app/Console/cake.php path set.'));
} else {
$this->err(__d('cake_console', 'Unable to set console path for app/Console.'));
$success = false;
}
$hardCode = false;
if ($this->cakeOnIncludePath()) {
$this->out(__d('cake_console', '<info>CakePHP is on your `include_path`. CAKE_CORE_INCLUDE_PATH will be set, but commented out.</info>'));
} else {
$this->out(__d('cake_console', '<warning>CakePHP is not on your `include_path`, CAKE_CORE_INCLUDE_PATH will be hard coded.</warning>'));
$this->out(__d('cake_console', 'You can fix this by adding CakePHP to your `include_path`.'));
$hardCode = true;
}
$success = $this->corePath($path, $hardCode) === true;
if ($success) {
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in %s', CAKE_CORE_INCLUDE_PATH, 'webroot/index.php'));
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in %s', CAKE_CORE_INCLUDE_PATH, 'webroot/test.php'));
} else {
$this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' . DS . 'index.php'));
$success = false;
}
if ($success && $hardCode) {
$this->out(__d('cake_console', ' * <warning>Remember to check these values after moving to production server</warning>'));
}
$Folder = new Folder($path);
if (!$Folder->chmod($path . 'tmp', 0777)) {
$this->err(__d('cake_console', 'Could not set permissions on %s', $path . DS . 'tmp'));
$this->out('chmod -R 0777 ' . $path . DS . 'tmp');
$success = false;
}
if ($success) {
$this->out(__d('cake_console', '<success>Project baked successfully!</success>'));
} else {
$this->out(__d('cake_console', 'Project baked but with <warning>some issues.</warning>.'));
}
return $path;
}
}
示例13: env
// Define the default/fallback datastore folder as application_folder/data
Configure::load('defaults');
// If a datastore.php exists, overwrite the datastore folder location
if (file_exists(APP . 'Config' . DS . 'datastore.php')) {
$datastorePath = (include APP . 'Config' . DS . 'datastore.php');
}
// Alternatively read the '[APP_NAME]_DATASTORE' environment variable
if (empty($datastorePath)) {
$datastorePath = env(APP_NAME . '_DATASTORE');
}
// If the datastore path was set by datastore.php OR the environment variable
if (!empty($datastorePath)) {
Configure::write(APP_NAME . '.datastore', Folder::slashTerm($datastorePath));
}
// Build datastore paths
$datastorePath = Folder::slashTerm(Configure::read(APP_NAME . '.datastore'));
$datastoreConfig = $datastorePath . 'config' . DS;
$datastoreFiles = $datastorePath . 'files' . DS;
$datastoreLogs = $datastorePath . 'logs' . DS;
$datastoreTmp = $datastorePath . 'tmp' . DS;
$datastoreCache = $datastoreTmp . 'cache' . DS;
$datastoreSessions = $datastoreTmp . 'sessions' . DS;
// Reset Cache, logging and Session paths accordingly
Configure::write('Cache.default.path', $datastoreCache);
Configure::write('Cache.core.path', $datastoreCache . 'persistent' . DS);
Configure::write('Cache.model.path', $datastoreCache . 'models' . DS);
Configure::write('Session.ini', Hash::merge(Configure::read('Session.ini'), array('session.save_path' => $datastoreSessions)));
Configure::write(APP_NAME . '.logging.debug.path', $datastoreLogs);
Configure::write(APP_NAME . '.logging.error.path', $datastoreLogs);
// Ignore datastore when using the AppSetup shell
if (php_sapi_name() == "cli" && (in_array('orca_app_setup.app_setup', env('argv')) || in_array('orca_app_setup.AppSetup', env('argv')) || in_array('OrcaAppSetup.app_setup', env('argv')) || in_array('OrcaAppSetup.AppSetup', env('argv')))) {
示例14: getFullPath
/**
* Returns the full path of the File.
*
* @return string
*/
function getFullPath()
{
return $this->folder->slashTerm($this->folder->pwd()) . $this->getName();
}
示例15: testStatic
/**
* testStatic method
*
* @access public
* @return void
*/
function testStatic()
{
$result = Folder::slashTerm('/path/to/file');
$this->assertEqual($result, '/path/to/file/');
}