本文整理汇总了PHP中Includes\Utils\FileManager::isDir方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::isDir方法的具体用法?PHP FileManager::isDir怎么用?PHP FileManager::isDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Includes\Utils\FileManager
的用法示例。
在下文中一共展示了FileManager::isDir方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDirectoryIterator
/**
* Return iterator to walk through directories
*
* @return \AppendIterator
*/
public function getDirectoryIterator()
{
$result = new \AppendIterator();
foreach ($this->getDirs() as $dir) {
if (\Includes\Utils\FileManager::isDir($dir)) {
$result->append($this->getDirectorySPLIterator($dir));
}
}
return $result;
}
示例2: getWrongPermissions
/**
* Return wrong permissions
*
* @return array
*/
protected function getWrongPermissions()
{
if (!isset($this->wrongPermissions)) {
$this->wrongPermissions = array('666' => array(), '777' => array());
foreach ($this->getUpgradeEntries() as $entry) {
foreach ($entry->getWrongPermissions() as $path) {
if (\Includes\Utils\FileManager::isDir($path)) {
$this->wrongPermissions['777'][] = $path;
} else {
$this->wrongPermissions['666'][] = $path;
}
}
}
foreach ($this->wrongPermissions as $k => $v) {
if ($v) {
$this->wrongPermissions[$k] = 'chmod ' . $k . ' ' . implode(' ', array_unique($v)) . ';';
} else {
unset($this->wrongPermissions[$k]);
}
}
}
return $this->wrongPermissions;
}
示例3: prepareImageData
/**
* Additional preparations for images.
* Upload them into specific directory
*
* @param string $optionValue Option value
* @param string $imageType Image type
*
* @return string
*/
protected function prepareImageData($optionValue, $imageType)
{
$dir = static::getLogoFaviconDir();
if ($_FILES && $_FILES[$imageType] && $_FILES[$imageType]['name']) {
$path = null;
$realName = preg_replace('/([^a-zA-Z0-9_\\-\\.]+)/', '_', $_FILES[$imageType]['name']);
if ($this->isImage($_FILES[$imageType]['tmp_name'], $realName)) {
if (!\Includes\Utils\FileManager::isDir($dir)) {
\Includes\Utils\FileManager::mkdirRecursive($dir);
}
if (\Includes\Utils\FileManager::isDir($dir)) {
// Remove file with same name as uploaded file in the destination directory
\Includes\Utils\FileManager::deleteFile($dir . LC_DS . ('favicon' === $imageType ? static::FAVICON : $realName));
// Move uploaded file to destination directory
$path = \Includes\Utils\FileManager::moveUploadedFile($imageType, $dir, 'favicon' === $imageType ? static::FAVICON : $realName);
if ($path) {
if ($optionValue && 'favicon' !== $imageType && basename($optionValue) != $realName) {
// Remove old image file
\Includes\Utils\FileManager::deleteFile($dir . basename($optionValue));
}
$optionValue = static::getLogoFaviconSubDir() . basename($path);
}
}
if (!isset($path)) {
$this->logoFaviconValidation = false;
\XLite\Core\TopMessage::addError('The "{{file}}" file was not uploaded', array('file' => $realName));
}
} else {
$this->logoFaviconValidation = false;
\XLite\Core\TopMessage::addError('The "{{file}}" file is not allowed image and was not uploaded. Allowed images are: {{extensions}}', array('file' => $realName, 'extensions' => implode(', ', $this->getImageExtensions())));
}
} elseif (\XLite\Core\Request::getInstance()->useDefaultImage[$imageType]) {
if ($optionValue) {
\Includes\Utils\FileManager::deleteFile($dir . basename($optionValue));
}
$optionValue = '';
}
return $optionValue;
}
示例4: writeDataToFile
/**
* Write data from request into a file
*
* @param \PEAR2\HTTP\Request\Response $response Response to get data
*
* @return string
*/
protected function writeDataToFile(\PEAR2\HTTP\Request\Response $response)
{
if (!\Includes\Utils\FileManager::isDir(LC_DIR_TMP)) {
\Includes\Utils\FileManager::mkdir(LC_DIR_TMP);
}
if (!\Includes\Utils\FileManager::isDirWriteable(LC_DIR_TMP)) {
\Includes\ErrorHandler::fireError('Directory "' . LC_DIR_TMP . '" is not writeable');
}
$path = \Includes\Utils\FileManager::getUniquePath(LC_DIR_TMP, uniqid() . '.' . \Includes\Utils\PHARManager::getExtension() ?: 'tar');
return isset($response->body) && \Includes\Utils\FileManager::write($path, $response->body) ? $path : null;
}
示例5: getUpgradeHelpersDir
/**
* Wrapper for the abstract method
*
* @param mixed $getFullPath Flag OPTIONAL
*
* @return string
*/
protected function getUpgradeHelpersDir($getFullPath = true)
{
$path = \Includes\Utils\FileManager::getCanonicalDir($this->getRepositoryPath());
if (!empty($path)) {
$dir = $this->getUpgradeHelperPath() . 'upgrade' . LC_DS;
}
return \Includes\Utils\FileManager::isDir($path . $dir) ? ($getFullPath ? $path : '') . $dir : null;
}
示例6: setMetadataDriver
/**
* Set metadata driver for Doctrine config
* FIXME: to revise
*
* @param \Doctrine\ORM\Configuration $config Config object
*
* @return void
*/
protected static function setMetadataDriver(\Doctrine\ORM\Configuration $config)
{
$chain = new \Doctrine\ORM\Mapping\Driver\DriverChain();
$chain->addDriver($config->newDefaultAnnotationDriver(static::getClassesDir() . 'XLite' . LC_DS . 'Model'), 'XLite\\Model');
$iterator = new \RecursiveDirectoryIterator(static::getClassesDir() . 'XLite' . LC_DS . 'Module', \FilesystemIterator::SKIP_DOTS);
foreach ($iterator as $dir) {
if (\Includes\Utils\FileManager::isDir($dir->getPathName())) {
$iterator2 = new \RecursiveDirectoryIterator($dir->getPathName(), \FilesystemIterator::SKIP_DOTS);
foreach ($iterator2 as $dir2) {
if (\Includes\Utils\FileManager::isDir($dir2->getPathName()) && \Includes\Utils\FileManager::isDir($dir2->getPathName() . LC_DS . 'Model')) {
$chain->addDriver($config->newDefaultAnnotationDriver($dir2->getPathName() . LC_DS . 'Model'), 'XLite\\Module\\' . $dir->getBaseName() . '\\' . $dir2->getBaseName() . '\\Model');
}
}
}
}
$config->setMetadataDriverImpl($chain);
}
示例7: connect
/**
* Connect and set-up Doctrine
*
* @return void
*/
public function connect()
{
$this->configuration = new \Doctrine\ORM\Configuration();
// Setup cache
$this->setDoctrineCache();
// Set metadata driver
$chain = new \Doctrine\ORM\Mapping\Driver\DriverChain();
$chain->addDriver($this->createAnnotationDriver(LC_DIR_CACHE_MODEL), 'XLite\\Model');
$iterator = new \RecursiveDirectoryIterator(LC_DIR_CACHE_CLASSES . 'XLite' . LC_DS . 'Module', \FilesystemIterator::SKIP_DOTS);
foreach ($iterator as $dir) {
if (\Includes\Utils\FileManager::isDir($dir->getPathName())) {
$iterator2 = new \RecursiveDirectoryIterator($dir->getPathName(), \FilesystemIterator::SKIP_DOTS);
foreach ($iterator2 as $dir2) {
if (\Includes\Utils\FileManager::isDir($dir2->getPathName()) && \Includes\Utils\FileManager::isDir($dir2->getPathName() . LC_DS . 'Model')) {
$chain->addDriver($this->createAnnotationDriver($dir2->getPathName() . LC_DS . 'Model'), 'XLite\\Module\\' . $dir->getBaseName() . '\\' . $dir2->getBaseName() . '\\Model');
}
}
}
}
$this->configuration->setMetadataDriverImpl($chain);
// Set proxy settings
$this->configuration->setProxyDir(rtrim(LC_DIR_CACHE_PROXY, LC_DS));
$this->configuration->setProxyNamespace(LC_MODEL_PROXY_NS);
$this->configuration->setAutoGenerateProxyClasses(false);
// Register custom functions
$this->configuration->addCustomStringFunction('if', '\\XLite\\Core\\Doctrine\\IfFunction');
$this->tablePrefix = \XLite::getInstance()->getOptions(array('database_details', 'table_prefix'));
// Initialize DB connection and entity manager
$this->startEntityManager();
}
示例8: download
/**
* Download pack
*
* @param \XLite\Core\Pack\APack $pack Files to pack
* @param boolean $compress Flag OPTIONAL
*
* @return void
*/
protected static function download(\XLite\Core\Pack\APack $pack, $compress = true)
{
if (!\Includes\Utils\FileManager::isDir(LC_DIR_TMP)) {
\Includes\Utils\FileManager::mkdir(LC_DIR_TMP);
}
if (!\Includes\Utils\FileManager::isDirWriteable(LC_DIR_TMP)) {
\Includes\ErrorHandler::fireError('Directory "' . LC_DIR_TMP . '" is not writeable');
}
$path = LC_DIR_TMP . $pack->getName() . '.tar';
$phar = static::pack($path, $pack->getDirectoryIterator(), $pack->getMetadata(), $compress);
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename="' . basename($path) . '"');
header('Content-Length: ' . filesize($path));
echo \Includes\Utils\FileManager::read($path);
\Includes\Utils\FileManager::deleteFile($path);
exit(0);
}
示例9: getWrongPermissions
/**
* Return wrong permissions
*
* @return array
*/
protected function getWrongPermissions()
{
if (!isset($this->wrongPermissions)) {
$wrongEntries = array('files' => array(), 'dirs' => array());
$common = $this->getCommonFolders();
foreach ($this->getUpgradeEntries() as $entry) {
foreach ($entry->getWrongPermissions() as $path) {
foreach ($common as $folder => $processed) {
if (false !== strpos($path, $folder)) {
if (\Includes\Utils\FileManager::isDir($path) && !$processed['dirs']) {
$this->wrongPermissions[] = 'find ' . $folder . ' -type d -execdir chmod 777 "{}" \\;;';
$common[$folder]['dirs'] = true;
} elseif (\Includes\Utils\FileManager::isFile($path) && !$processed['files']) {
$this->wrongPermissions[] = 'find ' . $folder . ' -type f -execdir chmod 666 "{}" \\;;';
$common[$folder]['files'] = true;
}
continue 2;
}
}
if (\Includes\Utils\FileManager::isDir($path)) {
$wrongEntries['dirs'][] = $path;
} else {
$wrongEntries['files'][] = $path;
}
}
}
foreach ($wrongEntries as $type => $paths) {
if ($paths) {
$permission = $type == 'dirs' ? '777' : '666';
$this->wrongPermissions[] = 'chmod ' . $permission . ' ' . implode(' ', array_unique($paths)) . ';';
}
}
}
return $this->wrongPermissions;
}
示例10: connect
/**
* Connect and set-up Doctrine
*
* @return void
*/
public function connect()
{
$this->configuration = new \Doctrine\ORM\Configuration();
// Setup cache
$this->setDoctrineCache();
// Set metadata driver
$chain = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
$chain->addDriver($this->createAnnotationDriver(\Includes\Decorator\ADecorator::getCacheModelsDir()), 'XLite\\Model');
$iterator = new \RecursiveDirectoryIterator(\Includes\Decorator\ADecorator::getCacheClassesDir() . 'XLite' . LC_DS . 'Module', \FilesystemIterator::SKIP_DOTS);
foreach ($iterator as $dir) {
if (\Includes\Utils\FileManager::isDir($dir->getPathName())) {
$iterator2 = new \RecursiveDirectoryIterator($dir->getPathName(), \FilesystemIterator::SKIP_DOTS);
foreach ($iterator2 as $dir2) {
if (\Includes\Utils\FileManager::isDir($dir2->getPathName()) && \Includes\Utils\FileManager::isDir($dir2->getPathName() . LC_DS . 'Model')) {
$chain->addDriver($this->createAnnotationDriver($dir2->getPathName() . LC_DS . 'Model'), 'XLite\\Module\\' . $dir->getBaseName() . '\\' . $dir2->getBaseName() . '\\Model');
}
}
}
}
$this->configuration->setMetadataDriverImpl($chain);
// Set proxy settings
$this->configuration->setProxyDir(rtrim(\Includes\Decorator\ADecorator::getCacheModelProxiesDir(), LC_DS));
$this->configuration->setProxyNamespace(LC_MODEL_PROXY_NS);
$this->configuration->setAutoGenerateProxyClasses(false);
// Register custom functions
$this->configuration->addCustomStringFunction('if', '\\XLite\\Core\\Doctrine\\IfFunction');
$this->configuration->addCustomStringFunction('IFNULL', '\\XLite\\Core\\Doctrine\\IfnullFunction');
$this->configuration->addCustomStringFunction('relevance', '\\XLite\\Core\\Doctrine\\RelevanceFunction');
$this->configuration->addCustomNumericFunction('intval', '\\XLite\\Core\\Doctrine\\IntvalFunction');
$this->configuration->addCustomStringFunction('findInSet', '\\XLite\\Core\\Doctrine\\FindInSetFunction');
$this->configuration->addCustomStringFunction('castChar', '\\XLite\\Core\\Doctrine\\CastCharFunction');
$this->configuration->addCustomStringFunction('collate', '\\XLite\\Core\\Doctrine\\CollateFunction');
$this->tablePrefix = trim(\XLite::getInstance()->getOptions(array('database_details', 'table_prefix')));
// Initialize DB connection and entity manager
$this->startEntityManager();
}