本文整理汇总了PHP中FileManager::mkdirtree方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::mkdirtree方法的具体用法?PHP FileManager::mkdirtree怎么用?PHP FileManager::mkdirtree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::mkdirtree方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkFolderStructure
/**
* A public helper function that can be used to ensure
* that the file structure has actually been installed.
*
* @param $install boolean Set this parameter to true to
* install the folder structure if it is missing.
*
* @return boolean True if the folder structure exists,
* otherwise false.
*/
public function checkFolderStructure($install = false)
{
// Make sure that the base path is inside the private files dir.
// The files dir has appropriate write permissions and is assumed
// to be protected against information leak and symlink attacks.
$filesDir = realpath(Config::getVar('files', 'files_dir'));
if (is_null($this->_basePath) || strpos($this->_basePath, $filesDir) !== 0) {
$this->_notify(__('admin.fileLoader.wrongBasePathLocation', array('path' => $this->_basePath)), FILE_LOADER_ERROR_MESSAGE_TYPE);
return false;
}
// Check folder presence and readability.
$pathsToCheck = array($this->_stagePath, $this->_archivePath, $this->_rejectPath, $this->_processingPath);
$fileManager = null;
foreach ($pathsToCheck as $path) {
if (!(is_dir($path) && is_readable($path))) {
if ($install) {
// Try installing the folder if it is missing.
if (is_null($fileManager)) {
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
}
$fileManager->mkdirtree($path);
}
// Try again.
if (!(is_dir($path) && is_readable($path))) {
// Give up...
$this->_notify(__('admin.fileLoader.pathNotAccessible', array('path' => $path)), FILE_LOADER_ERROR_MESSAGE_TYPE);
return false;
}
}
}
return true;
}
示例2: execute
/**
* Save scheduled conference settings.
*/
function execute()
{
$schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
$conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
$conference =& $conferenceDao->getConference($this->getData('conferenceId'));
if (isset($this->schedConfId)) {
$schedConf =& $schedConfDao->getSchedConf($this->schedConfId);
}
if (!isset($schedConf)) {
$schedConf = new SchedConf();
}
$schedConf->setConferenceId($this->getData('conferenceId'));
$schedConf->setPath($this->getData('schedConfPath'));
if ($schedConf->getId() != null) {
$schedConfDao->updateSchedConf($schedConf);
$track = null;
// avoid warning
} else {
$schedConfId = $schedConfDao->insertSchedConf($schedConf);
$schedConfDao->resequenceSchedConfs($this->getData('conferenceId'));
// Make the file directories for the scheduled conference
import('lib.pkp.classes.file.FileManager');
$conferenceId = $schedConf->getConferenceId();
$privateBasePath = Config::getVar('files', 'files_dir') . '/conferences/' . $conferenceId . '/schedConfs/' . $schedConfId;
$publicBasePath = Config::getVar('files', 'public_files_dir') . '/conferences/' . $conferenceId . '/schedConfs/' . $schedConfId;
FileManager::mkdirtree($privateBasePath);
FileManager::mkdirtree($privateBasePath . '/papers');
FileManager::mkdirtree($privateBasePath . '/tracks');
FileManager::mkdirtree($publicBasePath);
// Install default scheduled conference settings
$schedConfSettingsDao =& DAORegistry::getDAO('SchedConfSettingsDAO');
$title = $this->getData('title');
$title = $title[$this->getFormLocale()];
Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_OCS_DEFAULT));
$schedConfSettingsDao->installSettings($schedConfId, Config::getVar('general', 'registry_dir') . '/schedConfSettings.xml', array('authorGuidelinesUrl' => Request::url($conference->getPath(), $this->getData('schedConfPath'), 'about', 'submissions', null, null, 'authorGuidelines'), 'indexUrl' => Request::getIndexUrl(), 'conferencePath' => $conference->getPath(), 'conferenceName' => $conference->getConferenceTitle(), 'schedConfPath' => $this->getData('schedConfPath'), 'schedConfUrl' => Request::url($conference->getPath(), $this->getData('schedConfPath'), 'index'), 'schedConfName' => $title));
// Create a default "Papers" track
$trackDao =& DAORegistry::getDAO('TrackDAO');
$track = new Track();
$track->setSchedConfId($schedConfId);
$track->setMetaReviewed(true);
$track->setTitle(Locale::translate('track.default.title'), $conference->getPrimaryLocale());
$track->setAbbrev(Locale::translate('track.default.abbrev'), $conference->getPrimaryLocale());
$track->setPolicy(Locale::translate('track.default.policy'), $conference->getPrimaryLocale());
$track->setDirectorRestricted(false);
$trackDao->insertTrack($track);
}
$schedConf->updateSetting('title', $this->getData('title'), 'string', true);
$schedConf->updateSetting('acronym', $this->getData('acronym'), 'string', true);
HookRegistry::call('SchedConfSettingsForm::execute', array(&$this, &$conference, &$schedConf, &$track));
}
示例3: 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;
}
示例4: import
/**
* Internal function to return the cover for publishing a research
* @param $sectionEditorSubmission SectionEditorSubmission
* @return string path to cover created
*/
function &_generateCover($sectionEditorSubmission)
{
$journal =& Request::getJournal();
import('classes.lib.tcpdf.pdf');
import('classes.lib.tcpdf.tcpdf');
Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_OJS_EDITOR, LOCALE_COMPONENT_PKP_SUBMISSION, LOCALE_COMPONENT_PKP_USER));
$pdf = new PDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// No header and footer for this document
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor($journal->getJournalTitle());
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, 20, PDF_MARGIN_RIGHT);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// Right now this cover page is only in english, but the english translation keys are ready
$pdf->AddPage();
$pdf->SetFont('dejavusans', 'B', 14);
$pdf->MultiCell(0, 6, 'Final Technical Report', 0, 'C');
// Locale::translate('editor.finalReport')
$pdf->ln();
$pdf->ln();
$pdf->MultiCell(0, 6, 'for', 0, 'C');
// Locale::translate('editor.finalReport.for')
$pdf->ln();
$pdf->ln();
$pdf->MultiCell(0, 6, 'Research Project', 0, 'C');
// Locale::translate('editor.finalReport.researchProject')
$pdf->ln();
$pdf->ln();
$pdf->ln();
$pdf->ln();
$abstract = $sectionEditorSubmission->getAbstractByLocale('en_US');
// Right now, considering only the english language
$pdf->SetFont('dejavusans', 'B', 16);
$pdf->MultiCell(0, 6, $abstract->getScientificTitle(), 0, 'C');
$pdf->ln();
$authors = $sectionEditorSubmission->getAuthors();
$coInvestigatorsString = (string) '';
$pInvestigatorsString = (string) '';
foreach ($authors as $author) {
if (!$author->getPrimaryContact()) {
if ($coInvestigatorsString == '') {
$coInvestigatorsString = $author->getFullName() . ' (' . $author->getAffiliation() . ')';
} else {
$coInvestigatorsString = $coInvestigatorsString . ', ' . $author->getFullName() . ' (' . $author->getAffiliation() . ')';
}
} else {
$pInvestigatorsString = $author->getFullName() . ' (' . $author->getAffiliation() . ')';
}
}
$pdf->SetFont('dejavusans', '', 16);
$pdf->MultiCell(0, 6, 'Principal Investigator: ' . $pInvestigatorsString, 0, 'C');
// Locale::translate('user.role.primaryInvestigator')
if ($coInvestigatorsString != '') {
$pdf->MultiCell(0, 6, 'Co-Investigator(s): ' . $coInvestigatorsString, 0, 'C');
// Locale::translate('user.role.coinvestigator')
}
$pdf->ln();
$pdf->ln();
$pdf->ln();
$pdf->ln();
$pdf->SetFont('dejavusans', 'B', 16);
$pdf->MultiCell(0, 6, $sectionEditorSubmission->getProposalId(), 0, 'C');
$pdf->ln();
$pdf->ln();
$decision = $sectionEditorSubmission->getLastSectionDecision();
$pdf->MultiCell(0, 0, date("F Y", strtotime($decision->getDateDecided())), 0, 'L', 0, 1, '', 250, true);
$pdf->Image("public/site/images/mainlogo.png", 'C', 230, 40, '', '', false, 'C', false, 300, 'R', false, false, 0, false, false, false);
$pdf->AddPage();
$pdf->SetFont('dejavusans', 'B', 14);
$pdf->MultiCell(0, 6, 'Final Technical Report', 0, 'C');
// Locale::translate('editor.finalReport')
$pdf->ln();
$pdf->ln();
$pdf->SetFont('dejavusans', 'B', 12);
$pdf->MultiCell(0, 6, 'Disclaimer', 0, 'C');
// Locale::translate('editor.finalReport.disclaimer')
$pdf->ln();
$pdf->ln();
$pdf->SetFont('dejavusans', '', 11);
$pdf->writeHTMLCell(0, 6, '', '', $journal->getSetting('reportDisclaimer'), 0, 0, false, true, 'J');
$filePath = Config::getVar('files', 'files_dir') . '/articles/' . $sectionEditorSubmission->getArticleId() . '/public/';
if (!FileManager::fileExists($filePath, 'dir')) {
FileManager::mkdirtree($filePath);
}
$pdf->Output($filePath . 'tempCover.pdf', 'F');
return $filePath;
}
示例5: handleWrite
/**
* PRIVATE routine to write a minutes file and add it to the database.
* @param $fileName original filename of the file
* @param $contents string contents of the file to write
* @param $mimeType string the mime type of the file
* @param $type string identifying type
* @param $fileId int ID of an existing file to update
* @return int the file ID (false if upload failed)
*/
function handleWrite(&$pdf, $type, $fileId = null)
{
if (HookRegistry::call('MinutesFileManager::handleWrite', array(&$contents, &$fileId, &$result))) {
return $result;
}
$minutesFileDao =& DAORegistry::getDAO('MinutesFileDAO');
$typePath = $this->typeToPath($type);
$dir = $this->filesDir . $typePath . '/';
if (!$fileId) {
$minutesFile =& $minutesFileDao->getGeneratedMinutesFile($this->meeting->getId(), $typePath);
if (!$minutesFile) {
$minutesFile =& $this->generateDummyFile($this->meeting);
}
$dummyFile = true;
} else {
$dummyFile = false;
$minutesFile = new MinutesFile();
$minutesFile->setMeetingId($this->meetingId);
$minutesFile->setFileId($fileId);
}
$minutesFile->setFileType('application/pdf');
$minutesFile->setOriginalFileName(null);
$minutesFile->setType($typePath);
$minutesFile->setDateCreated(Core::getCurrentDate());
$newFileName = $this->generateFilename($minutesFile, $typePath, '.pdf');
if (!FileManager::fileExists($dir, 'dir')) {
FileManager::mkdirtree($dir);
}
if ($pdf->Output($dir . $newFileName, "F") != '') {
$minutesFileDao->deleteMinutesFileById($minutesFile->getFileId());
return false;
} else {
$minutesFile->setFileSize(filesize($dir . $newFileName));
}
if ($dummyFile) {
$minutesFileDao->updateMinutesFile($minutesFile);
} else {
$minutesFileDao->insertMinutesFile($minutesFile);
}
return $minutesFile->getFileId();
}
示例6: execute
/**
* Save schedConf settings.
* @param $request PKPRequest
*/
function execute($request)
{
$schedConfDao = DAORegistry::getDAO('SchedConfDAO');
$conference = $request->getConference();
if (isset($this->contextId)) {
$schedConf = $schedConfDao->getById($this->contextId);
}
if (!isset($schedConf)) {
$schedConf = $schedConfDao->newDataObject();
$schedConf->setConferenceId($conference->getId());
}
$schedConf->setPath($this->getData('path'));
$schedConf->setEnabled($this->getData('enabled'));
if ($schedConf->getId() != null) {
$isNewSchedConf = false;
$schedConfDao->updateObject($schedConf);
$section = null;
} else {
$isNewSchedConf = true;
$site = $request->getSite();
// Give it a default primary locale
$schedConfId = $schedConfDao->insertObject($schedConf);
$schedConfDao->resequence();
// Make the file directories for the scheduled conference
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
$conferenceId = $schedConf->getConferenceId();
$privateBasePath = Config::getVar('files', 'files_dir') . '/conferences/' . $conferenceId . '/schedConfs/' . $schedConfId;
$publicBasePath = Config::getVar('files', 'public_files_dir') . '/conferences/' . $conferenceId . '/schedConfs/' . $schedConfId;
$fileManager->mkdirtree($privateBasePath);
$fileManager->mkdirtree($privateBasePath . '/papers');
$fileManager->mkdirtree($privateBasePath . '/tracks');
$fileManager->mkdirtree($publicBasePath);
// Install default scheduled conference settings
$schedConfSettingsDao = DAORegistry::getDAO('SchedConfSettingsDAO');
$name = $this->getData('name');
$name = $name[$this->getFormLocale()];
AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON, LOCALE_COMPONENT_APP_DEFAULT);
$dispatcher = $request->getDispatcher();
$schedConfSettingsDao->installSettings($schedConfId, Config::getVar('general', 'registry_dir') . '/schedConfSettings.xml', array('authorGuidelinesUrl' => $dispatcher->url($request, ROUTE_PAGE, array($conference->getPath(), $this->getData('schedConfPath')), 'about', 'submissions', null, null, 'authorGuidelines'), 'indexUrl' => $request->getIndexUrl(), 'conferencePath' => $conference->getPath(), 'conferenceName' => $conference->getLocalizedName(), 'schedConfPath' => $this->getData('path'), 'schedConfUrl' => $dispatcher->url($request, ROUTE_PAGE, array($conference->getPath(), $this->getData('schedConfPath')), 'index'), 'schedConfName' => $name));
// Create a default "Papers" track
$trackDao = DAORegistry::getDAO('TrackDAO');
$track = new Track();
$track->setSchedConfId($schedConfId);
$track->setMetaReviewed(true);
$track->setTitle(__('track.default.title'), $conference->getPrimaryLocale());
$track->setAbbrev(__('track.default.abbrev'), $conference->getPrimaryLocale());
$track->setPolicy(__('track.default.policy'), $conference->getPrimaryLocale());
$track->setDirectorRestricted(false);
$trackDao->insertTrack($track);
}
$schedConf->updateSetting('name', $this->getData('name'), 'string', true);
$schedConf->updateSetting('acronym', $this->getData('acronym'), 'string', true);
// Make sure all plugins are loaded for settings preload
PluginRegistry::loadAllPlugins();
HookRegistry::call('SchedConfSettingsForm::execute', array(&$this, &$schedConf));
}