本文整理汇总了PHP中FileManager::mkdir方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::mkdir方法的具体用法?PHP FileManager::mkdir怎么用?PHP FileManager::mkdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::mkdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateLocaleFile
/**
* Perform message string munging.
* @param $localeFile string
* @param $localeFilePath string
* @param $outFile string
*/
function generateLocaleFile($localeFile, $localeFilePath, $outFile)
{
$localeData = LocaleFile::load($localeFilePath);
if (!isset($localeData)) {
printf('Invalid locale \'%s\'', $this->inLocale);
exit(1);
}
$destDir = dirname($outFile);
if (!file_exists($destDir)) {
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
if (!$fileManager->mkdir($destDir)) {
printf('Failed to createDirectory \'%s\'', $destDir);
exit(1);
}
}
$fp = fopen($outFile, 'wb');
if (!$fp) {
printf('Failed to write to \'%s\'', $outFile);
exit(1);
}
$dtdLocation = substr($localeFilePath, 0, 3) == 'lib' ? '../../dtd/locale.dtd' : '../../lib/pkp/dtd/locale.dtd';
fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . "<!DOCTYPE locale SYSTEM \"{$dtdLocation}\">\n\n" . "<!--\n" . " * {$localeFile}\n" . " *\n" . " * Copyright (c) 2013-2016 Simon Fraser University Library\n" . " * Copyright (c) 2003-2016 John Willinsky\n" . " * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.\n" . " *\n" . sprintf(" * Localization strings for the %s (%s) locale.\n", $this->outLocale, DEFAULT_OUT_LOCALE_NAME) . " *\n" . " -->\n\n" . sprintf("<locale name=\"%s\" full_name=\"%s\">\n", $this->outLocale, DEFAULT_OUT_LOCALE_NAME));
foreach ($localeData as $key => $message) {
$outMessage = $this->fancifyString($message);
if (strstr($outMessage, '<') || strstr($outMessage, '>')) {
$outMessage = '<![CDATA[' . $outMessage . ']]>';
}
fwrite($fp, sprintf("\t<message key=\"%s\">%s</message>\n", $key, $outMessage));
}
fwrite($fp, "</locale>\n");
fclose($fp);
}
示例2: __construct
public function __construct()
{
// Get paths to system base directories
$this->baseDir = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))))))))));
// Load and execute initialization code
chdir($this->baseDir);
define('INDEX_FILE_LOCATION', $this->baseDir . '/index.php');
require $this->baseDir . '/lib/pkp/includes/bootstrap.inc.php';
$publicDir = Config::getVar('files', 'public_files_dir');
$this->baseUrl = Config::getVar('general', 'base_url');
// Load user variables
$sessionManager =& SessionManager::getManager();
$userSession =& $sessionManager->getUserSession();
$user =& $userSession->getUser();
if (isset($user)) {
// User is logged in
$siteDir = $this->baseDir . '/' . $publicDir . '/site/';
if (!file_exists($siteDir . '/images/')) {
import('classes.file.FileManager');
// Check that the public/site/ directory exists and is writeable
if (!file_exists($siteDir) || !is_writeable($siteDir)) {
die(__('installer.installFilesDirError'));
}
// Create the images directory
if (!FileManager::mkdir($siteDir . '/images/')) {
die(__('installer.installFilesDirError'));
}
}
//Check if user's image directory exists, else create it
if (Validation::isLoggedIn() && !file_exists($siteDir . '/images/' . $user->getUsername())) {
import('classes.file.FileManager');
// Check that the public/site/images/ directory exists and is writeable
if (!file_exists($siteDir . '/images/') || !is_writeable($siteDir . '/images/')) {
die(__('installer.installFilesDirError'));
}
// Create the directory to store the user's images
if (!FileManager::mkdir($siteDir . '/images/' . $user->getUsername())) {
die(__('installer.installFilesDirError'));
}
$this->imageDir = $publicDir . '/site/images/' . $user->getUsername();
} else {
if (Validation::isLoggedIn()) {
// User's image directory already exists
$this->imageDir = $publicDir . '/site/images/' . $user->getUsername();
}
}
} else {
// Not logged in; Do not allow images to be uploaded
$this->imageDir = null;
}
// Set the base directory back to its original location
chdir(dirname($_SERVER['SCRIPT_FILENAME']));
}
示例3: extractTarFile
/**
* Recursively unpack the given tar file
* and return its contents as an array.
* @param $tarFile string
* @return array
*/
protected function extractTarFile($tarFile)
{
$tarBinary = Config::getVar('cli', 'tar');
// Cygwin compat.
$cygwin = Config::getVar('cli', 'cygwin');
// Make sure we got the tar binary installed.
self::assertTrue(!empty($tarBinary) && is_executable($tarBinary) || is_executable($cygwin), 'tar must be installed');
// Create a temporary directory.
do {
$tempdir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . md5(time() . mt_rand());
} while (file_exists($tempdir));
$fileManager = new FileManager();
$fileManager->mkdir($tempdir);
// Extract the tar to the temporary directory.
if ($cygwin) {
$tarCommand = $cygwin . " --login -c '" . $tarBinary . ' -C ' . escapeshellarg(cygwinConversion($tempdir)) . ' -xzf ' . escapeshellarg(cygwinConversion($tarFile)) . "'";
} else {
$tarCommand = $tarBinary . ' -C ' . escapeshellarg($tempdir) . ' -xzf ' . escapeshellarg($tarFile);
}
exec($tarCommand);
// Read the results into an array.
$result = array();
foreach (glob($tempdir . DIRECTORY_SEPARATOR . '*.{tar.gz,xml}', GLOB_BRACE) as $extractedFile) {
if (substr($extractedFile, -4) == '.xml') {
// Read the XML file into the result array.
$result[basename($extractedFile)] = file_get_contents($extractedFile);
} else {
// Recursively extract tar files.
$result[basename($extractedFile)] = $this->extractTarFile($extractedFile);
}
unlink($extractedFile);
}
rmdir($tempdir);
ksort($result);
return $result;
}
示例4: mkdirtree
/**
* Create a new directory, including all intermediate directories if required (equivalent to "mkdir -p")
* @param $dirPath string the full path of the directory to be created
* @param $perms string the permissions level of the directory (optional)
* @return boolean returns true if successful
*/
function mkdirtree($dirPath, $perms = null)
{
if (!file_exists($dirPath)) {
if (FileManager::mkdirtree(dirname($dirPath), $perms)) {
return FileManager::mkdir($dirPath, $perms);
} else {
return false;
}
}
return true;
}
示例5: execute
/**
* Save conference settings.
* @param $request PKPRequest
*/
function execute($request)
{
$conferenceDao = DAORegistry::getDAO('ConferenceDAO');
if (isset($this->contextId)) {
$conference =& $conferenceDao->getById($this->contextId);
}
if (!isset($conference)) {
$conference = $conferenceDao->newDataObject();
}
$conference->setPath($this->getData('path'));
$conference->setEnabled($this->getData('enabled'));
if ($conference->getId() != null) {
$isNewConference = false;
$conferenceDao->updateObject($conference);
$section = null;
} else {
$isNewConference = true;
$site = $request->getSite();
// Give it a default primary locale
$conference->setPrimaryLocale($site->getPrimaryLocale());
$conferenceId = $conferenceDao->insertObject($conference);
$conferenceDao->resequence();
// Make the site administrator the conference manager of newly created conferences
$sessionManager =& SessionManager::getManager();
$userSession =& $sessionManager->getUserSession();
if ($userSession->getUserId() != null && $userSession->getUserId() != 0 && !empty($conferenceId)) {
$role = new Role();
$role->setConferenceId($conferenceId);
$role->setUserId($userSession->getUserId());
$role->setRoleId(ROLE_ID_MANAGER);
$roleDao = DAORegistry::getDAO('RoleDAO');
$roleDao->insertRole($role);
}
// Make the file directories for the conference
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
$fileManager->mkdir(Config::getVar('files', 'files_dir') . '/conferences/' . $conferenceId);
$fileManager->mkdir(Config::getVar('files', 'files_dir') . '/conferences/' . $conferenceId . '/schedConfs');
$fileManager->mkdir(Config::getVar('files', 'public_files_dir') . '/conferences/' . $conferenceId);
$fileManager->mkdir(Config::getVar('files', 'public_files_dir') . '/conferences/' . $conferenceId . '/schedConfs');
// Install default conference settings
$conferenceSettingsDao = DAORegistry::getDAO('ConferenceSettingsDAO');
$names = $this->getData('name');
AppLocale::requireComponents(LOCALE_COMPONENT_APP_DEFAULT, LOCALE_COMPONENT_APP_COMMON);
$dispatcher = $request->getDispatcher();
$conferenceSettingsDao->installSettings($conferenceId, 'registry/conferenceSettings.xml', array('privacyStatementUrl' => $dispatcher->url($request, ROUTE_PAGE, array($this->getData('path'), 'index'), 'about', 'submissions', null, null, 'privacyStatement'), 'loginUrl' => $dispatcher->url($request, ROUTE_PAGE, array('index', 'index'), 'login'), 'conferenceUrl' => $dispatcher->url($request, ROUTE_PAGE, array($this->getData('path'), 'index')), 'conferencePath' => $this->getData('path'), 'primaryLocale' => $site->getPrimaryLocale(), 'aboutUrl' => $dispatcher->url($request, ROUTE_PAGE, array($this->getData('path'), 'index'), 'about'), 'accountUrl' => $dispatcher->url($request, ROUTE_PAGE, array($this->getData('path'), 'index'), 'user', 'register'), 'conferenceName' => $names[$site->getPrimaryLocale()]));
// Install the default RT versions.
import('classes.rt.ocs.ConferenceRTAdmin');
$conferenceRtAdmin = new ConferenceRTAdmin($conferenceId);
$conferenceRtAdmin->restoreVersions(false);
}
$conference->updateSetting('name', $this->getData('name'), 'string', true);
$conference->updateSetting('description', $this->getData('description'), 'string', true);
// Make sure all plugins are loaded for settings preload
PluginRegistry::loadAllPlugins();
HookRegistry::call('ConferenceSiteSettingsForm::execute', array(&$this, &$conference));
}
示例6: createDirectories
/**
* Create required files directories
* FIXME No longer needed since FileManager will auto-create?
* @return boolean
*/
function createDirectories()
{
// Check if files directory exists and is writeable
if (!(file_exists($this->getParam('filesDir')) && is_writeable($this->getParam('filesDir')))) {
// Files upload directory unusable
$this->setError(INSTALLER_ERROR_GENERAL, 'installer.installFilesDirError');
return false;
} else {
// Create required subdirectories
$dirsToCreate = $this->getCreateDirectories();
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
foreach ($dirsToCreate as $dirName) {
$dirToCreate = $this->getParam('filesDir') . '/' . $dirName;
if (!file_exists($dirToCreate)) {
if (!$fileManager->mkdir($dirToCreate)) {
$this->setError(INSTALLER_ERROR_GENERAL, 'installer.installFilesDirError');
return false;
}
}
}
}
// Check if public files directory exists and is writeable
$publicFilesDir = Config::getVar('files', 'public_files_dir');
if (!(file_exists($publicFilesDir) && is_writeable($publicFilesDir))) {
// Public files upload directory unusable
$this->setError(INSTALLER_ERROR_GENERAL, 'installer.publicFilesDirError');
return false;
} else {
// Create required subdirectories
$dirsToCreate = $this->getCreateDirectories();
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
foreach ($dirsToCreate as $dirName) {
$dirToCreate = $publicFilesDir . '/' . $dirName;
if (!file_exists($dirToCreate)) {
if (!$fileManager->mkdir($dirToCreate)) {
$this->setError(INSTALLER_ERROR_GENERAL, 'installer.publicFilesDirError');
return false;
}
}
}
}
return true;
}
示例7: fileMakeDir
/**
* Create a new directory
* @param $args array
* @param $request PKPRequest
*/
function fileMakeDir($args, &$request)
{
$this->validate();
$this->_parseDirArg($args, $currentDir, $parentDir);
if ($dirName = $request->getUserVar('dirName')) {
$currentPath = $this->_getRealFilesDir($request, $currentDir);
$newDir = $currentPath . '/' . $this->_cleanFileName($dirName);
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
@$fileManager->mkdir($newDir);
}
$request->redirect(null, null, null, 'files', explode('/', $currentDir));
}
示例8: FileManager
/**
* Return the plug-ins export directory.
*
* This will create the directory if it doesn't exist yet.
*
* @return string|array The export directory name or an array with
* errors if something went wrong.
*/
function _getExportPath()
{
$exportPath = Config::getVar('files', 'files_dir') . DIRECTORY_SEPARATOR . $this->getPluginId();
if (!file_exists($exportPath)) {
$fileManager = new FileManager();
$fileManager->mkdir($exportPath);
}
if (!is_writable($exportPath)) {
$errors = array(array('plugins.importexport.common.export.error.outputFileNotWritable', $exportPath));
return $errors;
}
return realpath($exportPath) . DIRECTORY_SEPARATOR;
}
示例9: execute
/**
* Save press settings.
*/
function execute()
{
$pressDao =& DAORegistry::getDAO('PressDAO');
if (isset($this->pressId)) {
$press =& $pressDao->getPress($this->pressId);
}
if (!isset($press)) {
$press = new Press();
}
$press->setPath($this->getData('path'));
$press->setEnabled($this->getData('enabled'));
if ($press->getId() != null) {
$isNewPress = false;
$pressDao->updatePress($press);
$series = null;
} else {
$isNewPress = true;
$site =& Request::getSite();
// Give it a default primary locale
$press->setPrimaryLocale($site->getPrimaryLocale());
$pressId = $pressDao->insertPress($press);
$pressDao->resequencePresses();
// Make the file directories for the press
import('lib.pkp.classes.file.FileManager');
FileManager::mkdir(Config::getVar('files', 'files_dir') . '/presses/' . $pressId);
FileManager::mkdir(Config::getVar('files', 'files_dir') . '/presses/' . $pressId . '/monographs');
FileManager::mkdir(Config::getVar('files', 'public_files_dir') . '/presses/' . $pressId);
$installedLocales =& $site->getInstalledLocales();
// Install default genres
$genreDao =& DAORegistry::getDAO('GenreDAO');
$genreDao->installDefaults($pressId, $installedLocales);
/* @var $genreDao GenreDAO */
// Install default publication formats
$publicationFormatDao =& DAORegistry::getDAO('PublicationFormatDAO');
/* @var $publicationFormatDao PublicationFormatDAO */
$publicationFormatDao->installDefaults($pressId, $installedLocales);
// Install default user groups
$userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
$userGroupDao->installSettings($pressId, 'registry/userGroups.xml');
// Make the site administrator the press manager of newly created presses
$sessionManager =& SessionManager::getManager();
$userSession =& $sessionManager->getUserSession();
if ($userSession->getUserId() != null && $userSession->getUserId() != 0 && !empty($pressId)) {
// get the default site admin user group
$managerUserGroup =& $userGroupDao->getDefaultByRoleId($pressId, ROLE_ID_PRESS_MANAGER);
$userGroupDao->assignUserToGroup($userSession->getUserId(), $managerUserGroup->getId());
}
// Install default press settings
$pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO');
$titles = $this->getData('title');
Locale::requireComponents(array(LOCALE_COMPONENT_OMP_DEFAULT_SETTINGS));
$pressSettingsDao->installSettings($pressId, 'registry/pressSettings.xml', array('indexUrl' => Request::getIndexUrl(), 'pressPath' => $this->getData('path'), 'primaryLocale' => $site->getPrimaryLocale(), 'pressName' => $titles[$site->getPrimaryLocale()]));
}
$press->updateSetting('name', $this->getData('name'), 'string', true);
$press->updateSetting('description', $this->getData('description'), 'string', true);
// Make sure all plugins are loaded for settings preload
PluginRegistry::loadAllPlugins();
HookRegistry::call('PressSiteSettingsForm::execute', array(&$this, &$press, &$series, &$isNewPress));
}
示例10: test_rmdir_recursive
function test_rmdir_recursive()
{
$res = FileManager::mkdir('rmdir_recursive_test');
$this->assertTrue($res);
$this->assertTrue(is_dir('files/rmdir_recursive_test'));
$res = FileManager::touch('rmdir_recursive_test/test.txt');
$this->assertTrue($res);
$this->assertTrue(file_exists('files/rmdir_recursive_test/test.txt'));
$res = FileManager::rmdir('rmdir_recursive_test');
$this->assertFalse($res);
$this->assertEquals('Folder must be empty', FileManager::error());
$res = FileManager::rmdir('rmdir_recursive_test', true);
$this->assertTrue($res);
$this->assertFalse(is_dir('files/rmdir_recursive_test'));
}
示例11: die
die(Locale::translate('installer.installFilesDirError'));
}
// Create the images directory
if (!FileManager::mkdir($siteDir . '/images/')) {
die(Locale::translate('installer.installFilesDirError'));
}
}
//Check if user's image directory exists, else create it
if (Validation::isLoggedIn() && !file_exists($siteDir . '/images/' . $user->getUsername())) {
import('file.FileManager');
// Check that the public/site/images/ directory exists and is writeable
if (!file_exists($siteDir . '/images/') || !is_writeable($siteDir . '/images/')) {
die(Locale::translate('installer.installFilesDirError'));
}
// Create the directory to store the user's images
if (!FileManager::mkdir($siteDir . '/images/' . $user->getUsername())) {
die(Locale::translate('installer.installFilesDirError'));
}
array_push($cfg['ilibs'], array('value' => '/' . $init['publicDir'] . '/site/images/' . $user->getUsername() . '/', 'text' => 'Your images'));
} else {
if (Validation::isLoggedIn()) {
array_push($cfg['ilibs'], array('value' => '/' . $init['publicDir'] . '/site/images/' . $user->getUsername() . '/', 'text' => 'Your images'));
}
}
//-------------------------------------------------------------------------
// use dynamic image libraries - if $cfg['ilibs_inc'] is set, static image libraries above are ignored
// image directories to be scanned
// $cfg['ilibs_dir'] = array('/public/site/images/public'); // image library path with slashes; absolute to root directory - please make sure that the directories have write permissions
// $cfg['ilibs_dir_show'] = true; // show main library (true) or only sub-dirs (false)
// $cfg['ilibs_inc'] = realpath(dirname(__FILE__) . '/../scripts/init.php'); // file to include in ibrowser.php (useful for setting $cfg['ilibs] dynamically
//-------------------------------------------------------------------------
示例12: execute
/**
* Process apache log files, copying and filtering them
* to the usage stats stage directory. Can work with both
* a specific file or a directory.
*/
function execute()
{
$fileMgr = new FileManager();
$filesDir = Config::getVar('files', 'files_dir');
$filePath = current($this->argv);
$usageStatsDir = $this->_usageStatsDir;
$tmpDir = $this->_tmpDir;
if ($fileMgr->fileExists($tmpDir, 'dir')) {
$fileMgr->rmtree($tmpDir);
}
if (!$fileMgr->mkdir($tmpDir)) {
printf(__('admin.copyAccessLogFileTool.error.creatingFolder', array('tmpDir' => $tmpDir)) . "\n");
exit(1);
}
if ($fileMgr->fileExists($filePath, 'dir')) {
// Directory.
$filesToCopy = glob($filePath . DIRECTORY_SEPARATOR . '*');
foreach ($filesToCopy as $file) {
$this->_copyFile($file);
}
} else {
if ($fileMgr->fileExists($filePath)) {
// File.
$this->_copyFile($filePath);
} else {
// Can't access.
printf(__('admin.copyAccessLogFileTool.error.acessingFile', array('filePath' => $filePath)) . "\n");
}
}
$fileMgr->rmtree($tmpDir);
}
示例13: testMkDirWhenExists
public function testMkDirWhenExists()
{
$path = __DIR__;
$this->manager->mkdir($path);
}
示例14: FileManager
function _getTmpPath()
{
$tmpPath = Config::getVar('files', 'files_dir') . '/fullJournalImportExport';
if (!file_exists($tmpPath)) {
$fileManager = new FileManager();
$fileManager->mkdir($tmpPath);
}
if (!is_writable($tmpPath)) {
$errors = array(__('plugins.importexport.common.export.error.outputFileNotWritable', $tmpPath));
return $errors;
}
return realpath($tmpPath) . '/';
}
示例15: getExportPath
/**
* Return the plugin export directory.
*
* This will create the directory if it doesn't exist yet.
*
* @return string|array The export directory name or an array with
* errors if something went wrong.
*/
function getExportPath()
{
$exportPath = Config::getVar('files', 'files_dir') . '/' . $this->getPluginSettingsPrefix();
if (!file_exists($exportPath)) {
$fileManager = new FileManager();
$fileManager->mkdir($exportPath);
}
if (!is_writable($exportPath)) {
$errors = array(array('plugins.importexport.common.export.error.outputFileNotWritable', $exportPath));
return $errors;
}
return realpath($exportPath) . '/';
}