本文整理汇总了PHP中File::isDir方法的典型用法代码示例。如果您正苦于以下问题:PHP File::isDir方法的具体用法?PHP File::isDir怎么用?PHP File::isDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::isDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyDir
/**
* Recursively copy a folder and its contents
* http://aidan.dotgeek.org/lib/?file=function.copyr.php
*
* @author Aidan Lister <aidan@php.net>
* @version 1.0.1
* @param string $source Source path
* @param string $dest Destination path
* @return bool Returns TRUE on success, FALSE on failure
*/
function copyDir($source, $dest)
{
clearstatcache();
// Simple copy for a file
if (is_file($source)) {
return File::copy($source, $dest);
}
// Make destination directory
if (!File::isDir($dest)) {
File::createDir($dest);
}
// Loop through the folder
$dir = dir($source);
while (false !== ($entry = $dir->read())) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Deep copy directories
if ($dest !== "{$source}/{$entry}") {
MyFile::copyDir("{$source}/{$entry}", "{$dest}/{$entry}");
}
}
// Clean up
$dir->close();
return true;
}
示例2: validate
/**
* Returns true if the template is a valid template set
*/
function validate()
{
// first of all, check that the folder exists
if (!File::isDir($this->_fullName)) {
return ERROR_TEMPLATE_NOT_INSIDE_FOLDER;
}
// now check that all the basic files are available
foreach ($this->_basicFiles as $basicFile) {
if (!File::isReadable($this->_fullName . $basicFile)) {
return ERROR_MISSING_BASE_FILES;
}
}
return true;
}
示例3: getTemplateSubFolders
function getTemplateSubFolders($folder)
{
$templateSubFolders = array();
$files = Glob::myGlob($folder, "*");
foreach ($files as $file) {
if (File::isDir($file)) {
$tmp['name'] = basename($file);
if ($tmp['name'] != "backups") {
array_push($templateSubFolders, $tmp);
}
}
}
return $templateSubFolders;
}
示例4: getTemplateFiles
function getTemplateFiles($folder)
{
$templateFiles = array();
$files = Glob::myGlob($folder, "*");
foreach ($files as $file) {
if (!File::isDir($file)) {
$tmp['name'] = basename($file);
$tmp['size'] = filesize($file);
$tmp['isEditable'] = $this->isValidExtension($tmp['name']);
$tmp['isImage'] = $this->isImage($tmp['name']);
$tmp['url'] = $file;
array_push($templateFiles, $tmp);
}
}
return $templateFiles;
}
示例5: perform
$this->message .= "articles_text table updated successfully!<br/>";
return true;
}
function perform()
{
$updaters = array("updateArticleCategories", "updateArticleComments", "updateBlogs", "updateAlbums", "updateResources", "updateArticleText");
// loop through each one of the methods to take care of updating one of the tables
foreach ($updaters as $method) {
$result = $this->{$method}();
if (!$result) {
$this->_view = new WizardView("update3");
$this->_view->setErrorMessage($this->message);
return false;
}
}
// everything went fine so we can show the final page!
$this->_view = new WizardView("update4");
$this->_view->setValue("message", $this->message);
return true;
}
}
// check if the "./tmp" folder is writable by us, otherwise
// throw an error before the user gets countless errors
// from Smarty
if (!File::isWritable(TEMP_FOLDER) || !File::isDir(TEMP_FOLDER)) {
print "<span style=\"color:red; font-size: 14px;\">Error</span><br/><br/>This wizard needs the " . TEMP_FOLDER . " folder to be writable by the web server user.<br/><br/>Please correct that and try again.";
die;
}
//// main part ////
$controller = new Controller($_actionMap, "nextStep");
$controller->process(HttpVars::getRequest());
示例6: view
function view()
{
$this->Form->setAttribute('action', extension_filemanager::baseURL() . 'properties/?file=' . $_GET['file']);
$file = new File(DOCROOT . $this->_FileManager->getStartLocation() . $_GET['file']);
$FileManager =& $this->_Parent->ExtensionManager->create('filemanager');
$formHasErrors = is_array($this->_errors) && !empty($this->_errors);
if ($formHasErrors) {
$this->pageAlert('An error occurred while processing this form. <a href="#error">See below for details.</a>', AdministrationPage::PAGE_ALERT_ERROR);
}
if (isset($_GET['result'])) {
switch ($_GET['result']) {
case 'saved':
$this->pageAlert(__('%s updated successfully', array($file->isDir() ? 'Folder' : 'File')), Alert::SUCCESS);
break;
}
}
$this->setPageType('form');
$path = extension_filemanager::baseURL() . 'browse/';
$breadcrumb = '';
$pathelements = explode('/', $_GET['file']);
foreach ($pathelements as $element) {
if ($element != '') {
$path .= $element . '/';
$breadcrumb .= ' / ' . ($element == end($pathelements) ? $element : Widget::Anchor($element, $path)->generate());
}
}
$this->appendSubheading(trim($FileManager->getStartLocationLink(), '/') . $breadcrumb);
$fields = array();
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', 'Essentials'));
$div = new XMLElement('div');
$div->setAttribute('class', 'group');
$label = Widget::Label('Name');
$label->appendChild(Widget::Input('fields[name]', General::sanitize($file->name())));
if (isset($this->_errors['name'])) {
$div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['name']));
} else {
$div->appendChild($label);
}
$label = Widget::Label('Permissions');
$label->appendChild(Widget::Input('fields[permissions]', General::sanitize($file->permissions())));
if (isset($this->_errors['permissions'])) {
$div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['permissions']));
} else {
$div->appendChild($label);
}
$fieldset->appendChild($div);
$this->Form->appendChild($fieldset);
if (!$file->isDir() && in_array(File::fileType($file->name()), array(File::CODE, File::DOC))) {
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', 'Editor'));
$label = Widget::Label('Contents');
$label->appendChild(Widget::Textarea('fields[contents]', '25', '50', General::sanitize($file->contents()), array('class' => 'code')));
if (isset($this->_errors['contents'])) {
$fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['contents']));
} else {
$fieldset->appendChild($label);
}
$this->Form->appendChild($fieldset);
}
if (!$file->isDir() && File::fileType($file->name()) == File::IMAGE) {
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', 'Preview'));
$img = new XMLElement('img');
$img->setAttribute('src', URL . $FileManager->getStartLocation() . $_GET['file']);
$img->setAttribute('alt', $file->name());
$fieldset->appendChild($img);
$this->Form->appendChild($fieldset);
}
$div = new XMLElement('div');
$div->setAttribute('class', 'actions');
if (is_writeable(DOCROOT . $this->_FileManager->getStartLocation() . $_GET['file'])) {
$div->appendChild(Widget::Input('action[save]', 'Save Changes', 'submit', array('accesskey' => 's')));
$button = new XMLElement('button', 'Delete');
$button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => 'Delete this ' . ($file->isDir() ? 'Folder' : 'File')));
$div->appendChild($button);
} else {
$notice = new XMLElement('p', 'The server does not have permission to edit this file.');
$notice->setAttribute('class', 'inactive');
$div->appendChild($notice);
}
$this->Form->appendChild($div);
}
示例7: _getTemplateFileInfo
/**
* @private
* Factored out from above...
*/
function _getTemplateFileInfo($templateName, $layout, $blogInfo)
{
// build the file name
if ($blogInfo == null) {
$templateFileName = $layout . '/' . $templateName . '.template';
$templateFolder = TemplateSetStorage::getBaseTemplateFolder();
} else {
//
// might be the case that the template is not local but global, so
// by default, global templates will always have preference over
// local templates. If the template is global, then
//
$baseTemplateFolder = TemplateSetStorage::getBaseTemplateFolder();
$globalTemplateFolder = $baseTemplateFolder . '/' . $layout;
$localTemplateFolder = $baseTemplateFolder . '/' . BLOG_BASE_TEMPLATE_FOLDER . $blogInfo->getId() . '/' . $layout;
//print("local = $localTemplateFolder - global = $globalTemplateFolder<br/>");
$templateFileName = $layout . '/' . $templateName . '.template';
if (!File::isDir($globalTemplateFolder)) {
//$templateFileName = $layout."/".$templateName.".template";
$templateFolder = $baseTemplateFolder . '/' . BLOG_BASE_TEMPLATE_FOLDER . $blogInfo->getId();
} else {
$templateFolder = $baseTemplateFolder . '/';
}
}
$result['templateFileName'] = $templateFileName;
$result['templateFolder'] = $templateFolder;
return $result;
}
示例8: File
<?php
apd_set_pprof_trace();
require_once '../../lib/base/boot.php';
$f = new File(__FILE__);
var_dump($f->isDir());
var_dump($f->isFile());
$f->copyTo('/tmp/test');
#$t = getrusage();
#$t = doubleval($t['ru_utime.tv_sec']*1000) + doubleval($t['ru_utime.tv_usec']/1000000);
#printf("User time: %f", $t);
示例9: download
//.........这里部分代码省略.........
<div class="feature">
<div class="contenttextbook nano">
<div class="nano-content">
<div class="contentareablock titlearea">
</div>
</div>
</div>
</div>';
foreach ($isi as $item) {
//$this->getContents($item['Halaman']['content'],'http://localhost/skope/app/webroot/','"')
$item['Halaman']['content'] = str_replace("http://" . $servername . "/skope/app/webroot/", "files/", $item['Halaman']['content']);
$item['Halaman']['content'] = str_replace("/skope/files/image_mikroskop/", "files/image_mikroskop/", $item['Halaman']['content']);
$item['Halaman']['content'] = str_replace("/skope/files/video_mikroskop/", "files/video_mikroskop/", $item['Halaman']['content']);
$isifeature .= '<div class="echo">
<div class="contenttextbook nano">
<div class="nano-content">
<div class="contentareablock">
<h2 style="font-size:37px;">' . $item['Halaman']['deskripsi_halaman'] . '</h2>
' . $item['Halaman']['content'] . '
</div>
</div>
</div>
</div>';
}
$isifeature .= '</div><nav class="navigasiwow">
<ul>
<li><a id="first" href="#" title="goto first page" >First page</a></li>
<li><a id="back" href="#" title="go back one page" >Back</a></li>
<li><a id="next" href="#" title="go foward one page">Next</a></li>
<li><a id="last" href="#" title="goto last page" >last page</a></li>
<li><a id="zoomin" href="#" title="zoom in" >Zoom In</a></li>
<li><a id="zoomout" href="#" title="zoom out" >Zoom Out</a></li>
<li><a id="slideshow" href="#" title="start slideshow" >Slide Show</a></li>
<li><a id="flipsound" href="#" title="flip sound on/off" >Flip sound</a></li>
</ul>
</nav>
</div> <!--! end of #container -->
<footer>
</footer>
</div>
<script type="text/javascript" src="wow_book.min.js"></script>
<script type="text/javascript" src="js/jquery.nanoscroller.min.js"></script>
<style>
.makecenter{
position: absolute;
display: inline-block;
right: 0;
width: 61px;
padding: 5px 10px;
}
.makecenter > a {
color: #000;
background-color: transparent;
border: 1px solid;
margin: 2px;
}
</style>
<script type="text/javascript" src="wow_conf.js"></script>
<script type="text/javascript" src="js/plugins.js"></script>
<script type="text/javascript" src="js/script.js"></script>
</body>
</html>';
//var_dump($isifeature);exit();
$path = WWW_ROOT . DS . 'wow_book/index.html';
$file = new File($path, true, 0777);
$file->open('w', true);
$file->write($isifeature);
$file->close();
// Get real path for our folder
$rootPath = realpath(WWW_ROOT . DS . 'wow_book');
// Initialize archive object
$zip = new ZipArchive();
$zip->open('file.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
// Create recursive directory iterator
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootPath), RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($files as $name => $file) {
// Skip directories (they would be added automatically)
if (!$file->isDir()) {
// Get real and relative path for current file
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);
// Add current file to archive
$zip->addFile($filePath, $relativePath);
}
}
// Zip archive will be created only after closing object
$zip->close();
$this->layout = 'default_blank';
}
示例10: checkMediumSizePreviewsStorageFolder
/**
* @public
*/
function checkMediumSizePreviewsStorageFolder($ownerId)
{
$previewsFolder = GalleryResourceStorage::getMediumSizePreviewsFolder($ownerId);
if ($previewsFolder[strlen($previewsFolder) - 1] == "/") {
$previewsFolder = substr($previewsFolder, 0, strlen($previewsFolder) - 1);
}
if (!File::isDir($previewsFolder)) {
// folder does not exist, so we should try to create it
if (!File::createDir($previewsFolder, 0755)) {
throw new Exception("Could not create user storage folder for medium size previews: " . $previewsFolder);
//die();
return false;
}
}
if (!File::isReadable($previewsFolder)) {
throw new Exception($previewsFolder . " user previews storage folder exists but it is not readable!");
//die();
return false;
}
return true;
}
示例11: getPluginListFromFolder
/**
* refreshes the list of folders from disk
*/
function getPluginListFromFolder()
{
$pluginList = array();
$pluginFiles = Glob::glob($this->_pluginDir, "*");
if (!is_array($pluginFiles)) {
return $pluginList;
}
foreach ($pluginFiles as $pluginFile) {
if (File::isDir($pluginFile)) {
// build up the name of the file
$pluginId = array_pop(explode("/", $pluginFile));
$pluginFileName = "plugin" . $pluginId . ".class.php";
$pluginFullPath = PLOG_CLASS_PATH . "{$pluginFile}/{$pluginFileName}";
// and try to include it
if (File::isReadable($pluginFile . "/" . $pluginFileName)) {
$pluginList[] = $pluginId;
}
}
}
return $pluginList;
}
示例12: getFolders
private function getFolders()
{
$folders = array();
// If we're running in advanced directory mode, get information about the folders
if ($_SESSION['directoryMode'] == 'ADVANCED') {
$path = File::getUserSandboxPath();
// If we're not at the user's top-level folder, show the parent folder
if ($_SESSION['cwd'] != $_SESSION['userPath']) {
$folders[] = '..';
}
foreach (scandir($path) as $file) {
if (File::isDir($file) && $file != '.' && $file != '..') {
$folders[] = $file;
}
}
}
return $folders;
}
示例13: createBlogTemplateFolder
/**
* Creates the blog-specific folder where templates are stored.
* If the folder is not there, it will be created. If it is already there,
* then nothing will happen.
*
* @param blogId The identifier of the blog.
*/
function createBlogTemplateFolder($blogId)
{
// make sure that the blog-specific folder exists
$templateFolder = $this->getBaseTemplateFolder();
$blogTemplateFolder = "{$templateFolder}/blog_" . $blogId;
if (!File::isDir($blogTemplateFolder)) {
File::createDir($blogTemplateFolder);
}
return $blogTemplateFolder;
}
示例14: download
//.........这里部分代码省略.........
<style>
.makecenter{
position: absolute;
display: inline-block;
right: 0;
width: 61px;
padding: 5px 10px;
}
.makecenter > a {
color: #000;
background-color: transparent;
border: 1px solid;
margin: 2px;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$(".nano").nanoScroller();
$("#features").wowBook({
height : 550
,width : 950
,centeredWhenClosed : true
,hardcovers : true
,turnPageDuration : 1000
,numberedPages : [1,-2]
,controls : {
zoomIn : "#zoomin",
zoomOut : "#zoomout",
next : "#next",
back : "#back",
first : "#first",
last : "#last",
slideShow : "#slideshow",
flipSound : "#flipsound"
}
}).css({"display":"none", "margin":"auto"}).fadeIn(1000);
$("#cover").click(function(){
$.wowBook("#features").advance();
});
});
</script>
<script type="text/javascript" src="js/plugins.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script type="text/javascript">
var heightWindow = $( window ).height();
jwplayer("example_video_1").setup({
file: "opening/opening_skope.flv",
image: "opening/cover_opening_skope.png",
width: "100%",
height:heightWindow,
aspectratio: "12:5",
autostart:true,
onComplete: function() {
alert("done");
$("#videocontent").fadeOut();
$("#penelitiancontent").fadeIn();
}
});
jwplayer("example_video_1").onComplete(function() {
$("#videocontent").fadeOut();
});
</script>
</body>
</html>';
//var_dump($isifeature);exit();
$path = WWW_ROOT . DS . 'wow_book/index.html';
$file = new File($path, true, 0777);
$file->open('w', true);
$file->write($isifeature);
$file->close();
// Get real path for our folder
$rootPath = realpath(WWW_ROOT . DS . 'wow_book');
// Initialize archive object
$zip = new ZipArchive();
$zip->open('file.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
// Create recursive directory iterator
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootPath), RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($files as $name => $file) {
// Skip directories (they would be added automatically)
if (!$file->isDir()) {
// Get real and relative path for current file
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);
// Add current file to archive
$zip->addFile($filePath, $relativePath);
}
}
// Zip archive will be created only after closing object
$zip->close();
//$pathbatch=WWW_ROOT.DS.'compiler.bat';
//system("cmd /c ".$pathbatch);
$this->layout = 'default_blank';
}
示例15: deleteDir
/**
* removes a directory, optinally in a recursive fashion
*
* @param dirName
* @param recursive Whether to recurse through all subdirectories that
* are within the given one and remove them.
* @param onlyFiles If the recursive mode is enabled, setting this to 'true' will
* force the method to only remove files but not folders. The directory will not be
* removed but all the files included it in (and all subdirectories) will be.
* @return True if successful or false otherwise
* @static
*/
function deleteDir($dirName, $recursive = false, $onlyFiles = false)
{
// if the directory can't be read, then quit with an error
if (!File::isReadable($dirName) || !File::exists($dirName)) {
return false;
}
// if it's not a file, let's get out of here and transfer flow
// to the right place...
if (!File::isDir($dirName)) {
return File::delete($dirName);
}
// Glob::myGlob is easier to use than Glob::glob, specially when
// we're relying on the native version... This improved version
// will automatically ignore things like "." and ".." for us,
// making it much easier!
$files = Glob::myGlob($dirName, "*");
foreach ($files as $file) {
if (File::isDir($file)) {
// perform a recursive call if we were allowed to do so
if ($recursive) {
File::deleteDir($file, $recursive, $onlyFiles);
}
}
// File::delete can remove empty folders as well as files
if (File::isReadable($file)) {
File::delete($file);
}
}
// finally, remove the top-level folder but only in case we
// are supposed to!
if (!$onlyFiles) {
File::delete($dirName);
}
return true;
}