当前位置: 首页>>代码示例>>PHP>>正文


PHP FileManager::isExists方法代码示例

本文整理汇总了PHP中Includes\Utils\FileManager::isExists方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::isExists方法的具体用法?PHP FileManager::isExists怎么用?PHP FileManager::isExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Includes\Utils\FileManager的用法示例。


在下文中一共展示了FileManager::isExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPromotionMessage

 /**
  * Get promotion message
  *
  * @return string
  */
 protected function getPromotionMessage()
 {
     $addons = $this->getAddons();
     $modules = array();
     $params = array('clearCnd' => 1);
     foreach ($addons as $addon => $title) {
         if (!\Includes\Utils\Operator::checkIfClassExists('\\XLite\\Module\\' . $addon . '\\Main')) {
             $match = explode('\\', $addon);
             $mainClassFile = LC_DIR_MODULES . str_replace('\\', '/', $addon) . '/Main.php';
             if (\Includes\Utils\FileManager::isExists($mainClassFile)) {
                 // Module is installed but not enabled
                 $limit = \XLite\View\Pager\Admin\Module\Manage::getInstance()->getItemsPerPage();
                 $pageId = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->getInstalledPageId($match[0], $match[1], $limit);
                 $pageParam = 'page';
                 $target = 'addons_list_installed';
             } else {
                 // Module is not installed
                 list(, $limit) = $this->getWidget(array(), '\\XLite\\View\\Pager\\Admin\\Module\\Install')->getLimitCondition()->limit;
                 $pageId = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->getMarketplacePageId($match[0], $match[1], $limit);
                 $pageParam = 'pageId';
                 $target = 'addons_list_marketplace';
             }
             if (0 < $pageId) {
                 $params[$pageParam] = $pageId;
             }
             $url = $this->buildURL($target, '', $params) . '#' . $match[1];
             $modules[] = '<a href="' . $url . '">' . $title . '</a>';
         }
     }
     return 0 < count($modules) ? static::t('Install additional modules to add more product sources', array('list' => implode(', ', $modules))) : '';
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:36,代码来源:Admin.php

示例2: doActionDelete

 /**
  * doActionDelete
  *
  * @return void
  * @throws
  */
 protected function doActionDelete()
 {
     if (\Includes\Utils\FileManager::isExists($this->sqldumpFile) && !\Includes\Utils\FileManager::deleteFile($this->sqldumpFile)) {
         \XLite\Core\TopMessage::addError(static::t('Unable to delete file') . ' ' . $this->sqldumpFile);
     } else {
         \XLite\Core\TopMessage::addInfo('SQL file was deleted successfully');
     }
     $this->doRedirect();
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:15,代码来源:DbBackup.php

示例3: __construct

 /**
  * Constructor
  * Creates directory for locks if needed
  */
 public function __construct()
 {
     if (!\Includes\Utils\FileManager::isExists(rtrim(static::LOCK_DIR, LC_DS))) {
         \Includes\Utils\FileManager::mkdirRecursive(rtrim(static::LOCK_DIR, LC_DS));
     }
     if (!\Includes\Utils\FileManager::isReadable(static::LOCK_DIR) || !\Includes\Utils\FileManager::isWriteable(static::LOCK_DIR)) {
         \XLite\Logger::getInstance()->log('Cannot create lock for keys', LOG_DEBUG);
     }
     parent::__construct();
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:14,代码来源:FileLock.php

示例4: doActionImport

 /**
  * Action 'import'
  *
  * @return void
  */
 protected function doActionImport()
 {
     $fileName = \XLite\Core\Session::getInstance()->language_import_file;
     if (\Includes\Utils\FileManager::isExists($fileName)) {
         $result = \XLite\Core\Database::getRepo('XLite\\Model\\Language')->parseImportFile($fileName, true);
         \XLite\Core\Session::getInstance()->language_import_result = $result;
     } else {
         \XLite\Core\Session::getInstance()->language_import_file = null;
         \XLite\Core\TopMessage::addError('File not found');
     }
     $this->setReturnURL($this->buildURL('languages'));
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:17,代码来源:LanguageImport.php

示例5: processItem

 /**
  * Process item
  *
  * @param mixed $item Item
  *
  * @return boolean
  */
 protected function processItem($item)
 {
     $result = false;
     $path = tempnam(LC_DIR_TMP, 'migrate_file');
     file_put_contents($path, $item->getBody());
     if (\Includes\Utils\FileManager::isExists($path)) {
         $localPath = $item->isURL() ? null : $item->getStoragePath();
         $result = $item->loadFromLocalFile($path, $item->getFileName() ?: basename($item->getPath()));
         if ($result && $localPath && \Includes\Utils\FileManager::isExists($localPath)) {
             \Includes\Utils\FileManager::deleteFile($localPath);
         }
         \Includes\Utils\FileManager::deleteFile($path);
     }
     if (!$result) {
         if (!isset($this->record['s3_error_count'])) {
             $this->record['s3_error_count'] = 0;
         }
         $this->record['s3_error_count']++;
         \XLite\Logger::getInstance()->log('Couldn\'t move image ' . $item->getPath() . ' (local file system to Amazon S3)', LOG_ERR);
     }
     return true;
 }
开发者ID:kingsj,项目名称:core,代码行数:29,代码来源:MigrateToS3.php

示例6: updateCustomImages

 /**
  * Update custom images
  *
  * @return void
  */
 protected function updateCustomImages()
 {
     $dir = \XLite\Module\XC\ThemeTweaker\Main::getThemeDir() . 'images' . LC_DS;
     if ($_FILES && $_FILES['new_images'] && $_FILES['new_images']['name']) {
         if (!\Includes\Utils\FileManager::isExists($dir)) {
             \Includes\Utils\FileManager::mkdirRecursive($dir);
         }
         if (\Includes\Utils\FileManager::isDirWriteable($dir)) {
             foreach ($_FILES['new_images']['name'] as $i => $data) {
                 \Includes\Utils\FileManager::moveUploadedFileByMultiple('new_images', $i, $dir);
             }
         } else {
             \XLite\Core\TopMessage::addError('The directory {{dir}} does not exist or is not writable.', array('dir' => $dir));
         }
     }
     $delete = \XLite\Core\Request::getInstance()->delete;
     if ($delete && is_array($delete)) {
         foreach ($delete as $file => $del) {
             if ($del) {
                 \Includes\Utils\FileManager::deleteFile($dir . $file);
             }
         }
     }
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:29,代码来源:Images.php

示例7: getFilePointer

    /**
     * Get file pointer
     * This dedicates to greatest developer of all time, Maxim Shamaev. Because getFilename() is not enough for name combining.
     *
     * @return resource
     */
    protected function getFilePointer()
    {
        if (!isset($this->filePointer)) {
            $name = $this->getFilename();
            $dir = \Includes\Utils\FileManager::getRealPath(LC_DIR_VAR . $this->generator->getOptions()->dir);
            if (is_writable($dir)) {
                if (!\Includes\Utils\FileManager::isExists($dir . LC_DS . '.htaccess')) {
                    // Try to create .htaccess file to protect directory
                    $out = <<<OUT
Options -Indexes

Deny from all

OUT;
                    \Includes\Utils\FileManager::write($dir . LC_DS . '.htaccess', $out);
                }
                $this->filePath = $dir . LC_DS . $name;
                $this->filePointer = @fopen($dir . LC_DS . $name, 'ab');
            } else {
                $this->generator->addError(static::t('Directory does not have permissions to write'), static::t('Directory X does not have permissions to write. Please set necessary permissions to directory X.', array('path' => $dir)));
            }
        }
        return $this->filePointer;
    }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:30,代码来源:Categories.php

示例8: doActionImport

 /**
  * Import action
  *
  * @return void
  */
 protected function doActionImport()
 {
     foreach (\XLite\Logic\Import\Importer::getImportOptionsList() as $key) {
         \XLite\Core\Database::getRepo('XLite\\Model\\Config')->createOption(array('category' => 'Import', 'name' => $key, 'value' => isset(\XLite\Core\Request::getInstance()->options[$key]) ? \XLite\Core\Request::getInstance()->options[$key] : false));
     }
     \XLite\Core\Config::updateInstance();
     $dirTo = LC_DIR_VAR . \XLite\Logic\Import\Importer::getImportDir();
     if (!\Includes\Utils\FileManager::isExists($dirTo)) {
         \Includes\Utils\FileManager::mkdirRecursive($dirTo);
     }
     $filesToImport = array();
     if ($_FILES && isset($_FILES['files']) && $_FILES['files']['name'] && $_FILES['files']['name'][0] && \Includes\Utils\FileManager::isDirWriteable($dirTo)) {
         $list = glob($dirTo . LC_DS . '*');
         if ($list) {
             foreach ($list as $path) {
                 if (is_file($path)) {
                     \Includes\Utils\FileManager::deleteFile($path);
                 }
             }
         }
         $files = $_FILES['files'];
         foreach ($files['name'] as $key => $name) {
             $path = null;
             if ($name && UPLOAD_ERR_OK === $files['error'][$key]) {
                 $path = \Includes\Utils\FileManager::getUniquePath($dirTo, $name ?: $files['name'][$key]);
                 if (move_uploaded_file($files['tmp_name'][$key], $path)) {
                     if (\XLite\Core\Archive::getInstance()->isArchive($path) || 'csv' == substr(strrchr($path, '.'), 1)) {
                         $filesToImport[] = $path;
                     } else {
                         \XLite\Core\TopMessage::addError('The "{{file}}" is not CSV or archive', array('file' => $name));
                         \Includes\Utils\FileManager::deleteFile($path);
                     }
                 } else {
                     $path = null;
                 }
             }
             if (!$path) {
                 \XLite\Core\TopMessage::addError('The "{{file}}" file was not uploaded', array('file' => $name));
             }
         }
     }
     if ($filesToImport) {
         \XLite\Logic\Import\Importer::run(\XLite\Logic\Import\Importer::assembleImportOptions() + array('files' => $filesToImport));
     }
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:50,代码来源:ImportAbstract.php

示例9: deleteFileCallback

 /**
  * Callback for a common operation for upgrade
  *
  * @param string  $path       File short path
  * @param boolean $isTestMode If in test mode
  *
  * @return void
  */
 protected function deleteFileCallback($path, $isTestMode)
 {
     if ($isTestMode) {
         if (!\Includes\Utils\FileManager::isDirWriteable($this->manageFile($path, 'getDir'))) {
             $this->addFileErrorMessage('File\'s directory is not writable', $path, false);
             $this->wrongPermissions[] = $this->manageFile($path, 'getDir');
         }
     } elseif ($this->manageFile($path, 'deleteFile')) {
         $this->addFileInfoMessage('File is deleted', $path, true);
         // Remove the parent directory if upgrade process removes all files in it
         $dir = dirname($path);
         if (\Includes\Utils\FileManager::isEmptyDir($dir)) {
             \Includes\Utils\FileManager::unlinkRecursive($dir);
             if (!\Includes\Utils\FileManager::isExists($dir)) {
                 $this->addFileInfoMessage('Directory is deleted', $dir, true);
             } else {
                 $this->addFileInfoMessage('Unable to delete directory', $dir, true);
             }
         }
     } else {
         $this->addFileErrorMessage('Unable to delete file', $path, true);
     }
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:31,代码来源:AEntry.php

示例10: loadFromLocalFile

 /**
  * Load from local file
  *
  * @param string $path     Absolute path
  * @param string $basename File name OPTIONAL
  *
  * @return boolean
  */
 public function loadFromLocalFile($path, $basename = null)
 {
     $result = true;
     $basename = $basename ?: basename($path);
     if (\Includes\Utils\FileManager::isExists($path)) {
         foreach ($this->getAllowedFileSystemRoots() as $root) {
             if (\Includes\Utils\FileManager::getRelativePath($path, $root)) {
                 $local = true;
                 break;
             }
         }
         if (empty($local)) {
             $newPath = \Includes\Utils\FileManager::getUniquePath($this->getStoreFileSystemRoot(), $basename);
             if (\Includes\Utils\FileManager::copy($path, $newPath)) {
                 $path = $newPath;
                 $this->setStorageType(static::STORAGE_RELATIVE);
             } else {
                 \XLite\Logger::getInstance()->log('\'' . $path . '\' file could not be copied to a new location \'' . $newPath . '\'.', LOG_ERR);
                 $result = false;
             }
         } else {
             $this->setStorageType(static::STORAGE_ABSOLUTE);
         }
     } else {
         $result = false;
     }
     if ($result && $basename) {
         $this->setFileName($basename);
     }
     return $result && $this->savePath($path);
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:39,代码来源:Storage.php

示例11: isRebuildNeeded

 /**
  * Check if cache rebuild is needed
  *
  * @param string $step Current step name OPTIONAL
  *
  * @return boolean
  */
 public static function isRebuildNeeded($step = null)
 {
     if (!isset($step)) {
         $step = static::getCurrentStep();
     }
     return $step ? !\Includes\Utils\FileManager::isExists(static::getCacheStateIndicatorFileName($step)) : false;
 }
开发者ID:kingsj,项目名称:core,代码行数:14,代码来源:CacheManager.php

示例12: getCommonHelperAddLabelsFiles

 /**
  * Get yaml files name to run common helper 'add_labels'
  *
  * @return string
  */
 protected function getCommonHelperAddLabelsFiles()
 {
     list($author, $name) = explode('\\', $this->getActualName());
     $result = array();
     $dir = \Includes\Utils\ModulesManager::getAbsoluteDir($author, $name);
     $file = $dir . 'install.yaml';
     if (\Includes\Utils\FileManager::isExists($file)) {
         $result[] = $file;
     }
     foreach ((array) glob($dir . 'install_*.yaml') as $translationFile) {
         if (\Includes\Utils\FileManager::isExists($translationFile)) {
             $result[] = $translationFile;
         }
     }
     return $result;
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:21,代码来源:AModule.php

示例13: deleteAllFiles

 /**
  * Delete all files
  *
  * @return void
  */
 public function deleteAllFiles()
 {
     $dir = \Includes\Utils\FileManager::getRealPath(LC_DIR_VAR . $this->getOptions()->dir);
     if (!\Includes\Utils\FileManager::isExists($dir)) {
         \Includes\Utils\FileManager::mkdir($dir);
     }
     $list = glob($dir . LC_DS . '*');
     if ($list) {
         foreach ($list as $path) {
             if (is_file($path)) {
                 \Includes\Utils\FileManager::deleteFile($path);
             } else {
                 \Includes\Utils\FileManager::unlinkRecursive($path);
             }
         }
     }
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:22,代码来源:Importer.php

示例14: isFileExists

 /**
  * isFileExists
  *
  * @return boolean
  */
 public function isFileExists()
 {
     return \Includes\Utils\FileManager::isExists($this->sqldumpFile);
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:9,代码来源:BackupRestore.php

示例15: uninstallModule

 /**
  * Uninstall module
  *
  * @param \XLite\Model\Module $module    Module object
  * @param array               &$messages Messages list
  *
  * @return boolean
  */
 public function uninstallModule(\XLite\Model\Module $module, &$messages)
 {
     $result = false;
     // Get module pack
     $pack = new \XLite\Core\Pack\Module($module);
     $dirs = $pack->getDirs();
     $nonWritableDirs = array();
     // Check module directories permissions
     foreach ($dirs as $dir) {
         if (\Includes\Utils\FileManager::isExists($dir) && !\Includes\Utils\FileManager::isDirWriteable($dir)) {
             $nonWritableDirs[] = \Includes\Utils\FileManager::getRelativePath($dir, LC_DIR_ROOT);
         }
     }
     $params = array('name' => sprintf('%s v%s (%s)', $module->getModuleName(), $module->getVersion(), $module->getAuthorName()));
     if (empty($nonWritableDirs)) {
         $yamlData = array();
         $yamlFiles = \Includes\Utils\ModulesManager::getModuleYAMLFiles($module->getAuthor(), $module->getName());
         foreach ($yamlFiles as $yamlFile) {
             $yamlData[] = \Includes\Utils\FileManager::read($yamlFile);
         }
         if (!$module->checkModuleMainClass()) {
             $classFile = LC_DIR_CLASSES . \Includes\Utils\Converter::getClassFile($module->getMainClass());
             if (\Includes\Utils\FileManager::isFileReadable($classFile)) {
                 require_once $classFile;
             }
         }
         // Call uninstall event method
         $r = $module->callModuleMethod('callUninstallEvent', 111);
         if (111 == $r) {
             \XLite\Logger::getInstance()->log($module->getActualName() . ': Method callUninstallEvent() was not called');
         }
         // Remove from FS
         foreach ($dirs as $dir) {
             \Includes\Utils\FileManager::unlinkRecursive($dir);
         }
         \Includes\Utils\ModulesManager::disableModule($module->getActualName());
         \Includes\Utils\ModulesManager::removeModuleFromDisabledStructure($module->getActualName());
         // Remove module from DB
         try {
             // Refresh module entity as it was changed by disableModule() method above
             $module = $this->find($module->getModuleID());
             $this->delete($module);
         } catch (\Exception $e) {
             $messages[] = $e->getMessage();
         }
         if ($module->getModuleID()) {
             $messages[] = \XLite\Core\Translation::getInstance()->translate('A DB error occured while uninstalling the module X', $params);
         } else {
             if (!empty($yamlData)) {
                 foreach ($yamlData as $yaml) {
                     \XLite\Core\Database::getInstance()->unloadFixturesFromYaml($yaml);
                 }
             }
             $messages[] = \XLite\Core\Translation::getInstance()->translate('The module X has been uninstalled successfully', $params);
             $result = true;
         }
     } else {
         $messages[] = \XLite\Core\Translation::getInstance()->translate('Unable to delete module X files: some dirs have no writable permissions: Y', $params + array('dirs' => implode(', ', $nonWritableDirs)));
     }
     return $result;
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:69,代码来源:Module.php


注:本文中的Includes\Utils\FileManager::isExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。