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


PHP IOHelper::getFolderContents方法代码示例

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


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

示例1: getSettingsHtml

 public function getSettingsHtml()
 {
     $pluginSettings = craft()->plugins->getPlugin('placid')->getSettings();
     // Get placid requests and send them to the widget settings
     $requests = craft()->placid_requests->findAllRequests();
     $requestsArray = array('' => 'No request selected');
     foreach ($requests as $request) {
         $requestsArray[$request->handle] = $request->name;
     }
     $templatesPath = craft()->path->getSiteTemplatesPath() . $pluginSettings->widgetTemplatesPath;
     $templates = IOHelper::getFolderContents($templatesPath, TRUE);
     $templatesArray = array('' => Craft::t('No template selected'));
     if (!$templates) {
         $templatesArray = array('' => 'Cannot find templates');
         Craft::log('Cannot find templates in path "' . $templatesPath . '"', LogLevel::Error);
     } else {
         // Turn array into ArrayObject
         $templates = new \ArrayObject($templates);
         // Iterate over template list
         // * Remove full path
         // * Remove folders from list
         for ($list = $templates->getIterator(); $list->valid(); $list->next()) {
             $filename = $list->current();
             $filename = str_replace($templatesPath, '', $filename);
             $filenameIncludingSubfolder = $filename;
             $isTemplate = preg_match("/(.html|.twig)\$/u", $filename);
             if ($isTemplate) {
                 $templatesArray[$filenameIncludingSubfolder] = $filename;
             }
         }
     }
     return craft()->templates->render('placid/_widgets/request/settings', array('requests' => $requestsArray, 'templates' => $templatesArray, 'settings' => $this->getSettings()));
 }
开发者ID:andyra,项目名称:tes,代码行数:33,代码来源:Placid_RequestWidget.php

示例2: getInputHtml

 public function getInputHtml($name, $value)
 {
     // Get site templates path
     $templatesPath = $siteTemplatesPath = craft()->path->getSiteTemplatesPath();
     // Check if the templates path is overriden by configuration
     // TODO: Normalize path
     $limitToSubfolder = craft()->config->get('templateselectSubfolder');
     if ($limitToSubfolder) {
         $templatesPath = $templatesPath . rtrim($limitToSubfolder, '/') . '/';
     }
     // Check if folder exists, or give error
     if (!IOHelper::folderExists($templatesPath)) {
         throw new \InvalidArgumentException('(Template Select) Folder doesn\'t exist: ' . $templatesPath);
     }
     // Get folder contents
     $templates = IOHelper::getFolderContents($templatesPath, TRUE);
     // Add placeholder for when there is no template selected
     $filteredTemplates = array('' => Craft::t('No template selected'));
     // Turn array into ArrayObject
     $templates = new \ArrayObject($templates);
     // Iterate over template list
     // * Remove full path
     // * Remove folders from list
     for ($list = $templates->getIterator(); $list->valid(); $list->next()) {
         $filename = $list->current();
         $filename = str_replace($templatesPath, '', $filename);
         $filenameIncludingSubfolder = $limitToSubfolder ? $limitToSubfolder . $filename : $filename;
         $isTemplate = preg_match("/(.html|.twig)\$/u", $filename);
         if ($isTemplate) {
             $filteredTemplates[$filenameIncludingSubfolder] = $filename;
         }
     }
     // Render field
     return craft()->templates->render('_includes/forms/select', array('name' => $name, 'value' => $value, 'options' => $filteredTemplates));
 }
开发者ID:alexrubin,项目名称:Craft-TemplateSelect,代码行数:35,代码来源:TemplateSelect_SelectFieldType.php

示例3: findInstallableRecords

 /**
  * Finds installable records from the models folder.
  *
  * @return array
  */
 public function findInstallableRecords()
 {
     $records = array();
     $recordsFolder = craft()->path->getAppPath() . 'records/';
     $recordFiles = IOHelper::getFolderContents($recordsFolder, false, ".*Record\\.php\$");
     foreach ($recordFiles as $file) {
         if (IOHelper::fileExists($file)) {
             $fileName = IOHelper::getFileName($file, false);
             $class = __NAMESPACE__ . '\\' . $fileName;
             // Ignore abstract classes and interfaces
             $ref = new \ReflectionClass($class);
             if ($ref->isAbstract() || $ref->isInterface()) {
                 Craft::log("Skipping record {$file} because it’s abstract or an interface.", LogLevel::Warning);
                 continue;
             }
             $obj = new $class('install');
             if (method_exists($obj, 'createTable')) {
                 $records[] = $obj;
             } else {
                 Craft::log("Skipping record {$file} because it doesn’t have a createTable() method.", LogLevel::Warning);
             }
         } else {
             Craft::log("Skipping record {$file} because it doesn’t exist.", LogLevel::Warning);
         }
     }
     return $records;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:32,代码来源:InstallService.php

示例4: _getLogoPath

 /**
  * Returns the path to the logo, or false if a logo hasn't been uploaded.
  *
  * @access private
  * @return string
  */
 private function _getLogoPath()
 {
     if (!isset($this->_logoPath)) {
         $files = IOHelper::getFolderContents(craft()->path->getStoragePath() . 'logo/', false);
         if (!empty($files)) {
             $this->_logoPath = $files[0];
         } else {
             $this->_logoPath = false;
         }
     }
     return $this->_logoPath;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:18,代码来源:RebrandVariable.php

示例5: getSettingsHtml

 /**
  * Returns the field's settings HTML.
  *
  * @return string|null
  */
 public function getSettingsHtml()
 {
     $configOptions = array('' => Craft::t('Default'));
     $configPath = craft()->path->getConfigPath() . 'redactor/';
     if (IOHelper::folderExists($configPath)) {
         $configFiles = IOHelper::getFolderContents($configPath, false, '\\.json$');
         if (is_array($configFiles)) {
             foreach ($configFiles as $file) {
                 $configOptions[IOHelper::getFileName($file)] = IOHelper::getFileName($file, false);
             }
         }
     }
     return craft()->templates->render('_components/fieldtypes/RichText/settings', array('settings' => $this->getSettings(), 'configOptions' => $configOptions));
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:19,代码来源:RichTextFieldType.php

示例6: getSettingsHtml

 /**
  * @inheritDoc ISavableComponentType::getSettingsHtml()
  *
  * @return string|null
  */
 public function getSettingsHtml()
 {
     $configOptions = array('' => Craft::t('Default'));
     $configPath = craft()->path->getConfigPath() . 'redactor/';
     if (IOHelper::folderExists($configPath)) {
         $configFiles = IOHelper::getFolderContents($configPath, false, '\\.json$');
         if (is_array($configFiles)) {
             foreach ($configFiles as $file) {
                 $configOptions[IOHelper::getFileName($file)] = IOHelper::getFileName($file, false);
             }
         }
     }
     $columns = array('text' => Craft::t('Text (stores about 64K)'), 'mediumtext' => Craft::t('MediumText (stores about 4GB)'));
     return craft()->templates->render('_components/fieldtypes/RichText/settings', array('settings' => $this->getSettings(), 'configOptions' => $configOptions, 'columns' => $columns, 'existing' => !empty($this->model->id)));
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:20,代码来源:RichTextFieldType.php

示例7: fetchLogFiles

 /**
  * @return array
  *
  * @throws Exception
  */
 public final function fetchLogFiles($logPath)
 {
     $logFileNames = [];
     $logFolderContents = IOHelper::getFolderContents($logPath);
     if ($logFolderContents === false) {
         throw new Exception('Could not get log folder contents');
     } else {
         foreach ($logFolderContents as $index => $filePath) {
             if ($this->shouldFileBeIncluded($filePath)) {
                 $logFileNames[] = IOHelper::getFileName($filePath);
             }
         }
     }
     return $logFileNames;
 }
开发者ID:nerds-and-company,项目名称:craft-customlogviewer-plugin,代码行数:20,代码来源:CustomlogviewerService.php

示例8: getAppLocales

 /**
  * Returns an array of locales that Craft is translated into. The list of locales is based on whatever files exist
  * in craft/app/translations/.
  *
  * @return array An array of {@link LocaleModel} objects.
  */
 public function getAppLocales()
 {
     if (!$this->_appLocales) {
         $this->_appLocales = array(new LocaleModel('en_us'));
         $path = craft()->path->getCpTranslationsPath();
         $folders = IOHelper::getFolderContents($path, false, ".*\\.php");
         if (is_array($folders) && count($folders) > 0) {
             foreach ($folders as $dir) {
                 $localeId = IOHelper::getFileName($dir, false);
                 if ($localeId != 'en_us') {
                     $this->_appLocales[] = new LocaleModel($localeId);
                 }
             }
         }
     }
     return $this->_appLocales;
 }
开发者ID:webremote,项目名称:craft_boilerplate,代码行数:23,代码来源:LocalizationService.php

示例9: getTemplateFiles

 public function getTemplateFiles()
 {
     $folderEmpty = true;
     if (IOHelper::isFolderEmpty(craft()->path->getPluginsPath() . 'formbuilder2/templates/email/layouts')) {
         throw new HttpException(404, Craft::t('Looks like you don\'t have any templates in your email/layouts folder.'));
     } else {
         $folderEmpty = false;
     }
     $fileList = IOHelper::getFolderContents(craft()->path->getPluginsPath() . 'formbuilder2/templates/email/layouts');
     $files = [];
     $filesModel = [];
     if (!$folderEmpty) {
         foreach ($fileList as $key => $file) {
             $files[$key] = ['fileName' => IOHelper::getFileName($file, false), 'fileOriginalName' => IOHelper::getFileName($file), 'fileNameCleaned' => IOHelper::cleanFilename(IOHelper::getFileName($file, false)), 'fileExtension' => IOHelper::getExtension($file), 'filePath' => $file, 'fileContents' => IOHelper::getFileContents($file)];
             $filesModel[] = FormBuilder2_FileModel::populateModel($files[$key]);
         }
     }
     return $filesModel;
 }
开发者ID:roundhouse,项目名称:FormBuilder-2-Craft-CMS,代码行数:19,代码来源:FormBuilder2_LayoutService.php

示例10: actionSetTemplate

 public function actionSetTemplate()
 {
     $this->requirePostRequest();
     $this->requireAjaxRequest();
     $templatePath = craft()->request->getRequiredPost('templatePath');
     $folderContents = IOHelper::getFolderContents(craft()->path->getPluginsPath() . 'formbuilder2/templates/layouts/templates/');
     $theFile = '';
     if ($folderContents && $templatePath) {
         foreach ($folderContents as $key => $file) {
             $fileName = IOHelper::getFileName($file, false);
             if ($fileName == $templatePath) {
                 $theFile = IOHelper::getFile($file);
             }
         }
     }
     if ($theFile == '') {
         $this->returnErrorJson('No template with that name.');
     } else {
         $template = ['fileName' => $theFile->getFileName(false), 'fileOriginalName' => $theFile->getFileName(), 'fileNameCleaned' => IOHelper::cleanFilename(IOHelper::getFileName($theFile->getRealPath(), false)), 'fileExtension' => $theFile->getExtension(), 'filePath' => $theFile->getRealPath(), 'fileContents' => $theFile->getContents()];
         $this->returnJson(['success' => true, 'message' => Craft::t('Template is set.'), 'layout' => $template]);
     }
 }
开发者ID:roundhouse,项目名称:FormBuilder-2-Craft-CMS,代码行数:22,代码来源:FormBuilder2_LayoutController.php

示例11: getSettingsHtml

 /**
  * @inheritDoc ISavableComponentType::getSettingsHtml()
  *
  * @return string|null
  */
 public function getSettingsHtml()
 {
     $configOptions = array('' => Craft::t('Default'));
     $configPath = craft()->path->getConfigPath() . 'redactor/';
     if (IOHelper::folderExists($configPath)) {
         $configFiles = IOHelper::getFolderContents($configPath, false, '\\.json$');
         if (is_array($configFiles)) {
             foreach ($configFiles as $file) {
                 $configOptions[IOHelper::getFileName($file)] = IOHelper::getFileName($file, false);
             }
         }
     }
     $columns = array('text' => Craft::t('Text (stores about 64K)'), 'mediumtext' => Craft::t('MediumText (stores about 4GB)'));
     $sourceOptions = array();
     foreach (craft()->assetSources->getPublicSources() as $source) {
         $sourceOptions[] = array('label' => $source->name, 'value' => $source->id);
     }
     $transformOptions = array();
     foreach (craft()->assetTransforms->getAllTransforms() as $transform) {
         $transformOptions[] = array('label' => $transform->name, 'value' => $transform->id);
     }
     return craft()->templates->render('redactori/settings', array('settings' => $this->getSettings(), 'configOptions' => $configOptions, 'assetSourceOptions' => $sourceOptions, 'transformOptions' => $transformOptions, 'columns' => $columns, 'existing' => !empty($this->model->id)));
 }
开发者ID:pixelandtonic,项目名称:RedactorI,代码行数:28,代码来源:RedactorIFieldType.php

示例12: unzip

 /**
  * @param $srcZip
  * @param $destFolder
  *
  * @return bool
  */
 public static function unzip($srcZip, $destFolder)
 {
     craft()->config->maxPowerCaptain();
     if (IOHelper::fileExists($srcZip)) {
         if (IOHelper::getExtension($srcZip) == 'zip') {
             if (!IOHelper::folderExists($destFolder)) {
                 if (!IOHelper::createFolder($destFolder)) {
                     Craft::log('Tried to create the unzip destination folder, but could not: ' . $destFolder, LogLevel::Error);
                     return false;
                 }
             } else {
                 // If the destination folder exists and it has contents, clear them.
                 if (($conents = IOHelper::getFolderContents($destFolder)) !== false) {
                     // Begin the great purge.
                     if (!IOHelper::clearFolder($destFolder)) {
                         Craft::log('Tried to clear the contents of the unzip destination folder, but could not: ' . $destFolder, LogLevel::Error);
                         return false;
                     }
                 }
             }
             $zip = static::_getZipInstance($srcZip);
             $result = $zip->unzip($srcZip, $destFolder);
             if ($result === true) {
                 return $result;
             } else {
                 Craft::log('There was an error unzipping the file: ' . $srcZip, LogLevel::Error);
                 return false;
             }
         } else {
             Craft::log($srcZip . ' is not a zip file and cannot be unzipped.', LogLevel::Error);
             return false;
         }
     } else {
         Craft::log('Unzipping is only available for files.', LogLevel::Error);
         return false;
     }
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:43,代码来源:Zip.php

示例13: _cleanTempFiles

 /**
  * Remove any temp files and/or folders that might have been created.
  *
  * @param string $unzipFolder
  *
  * @return null
  */
 private function _cleanTempFiles($unzipFolder)
 {
     $appPath = craft()->path->getAppPath();
     // Get rid of all the .bak files/folders.
     $filesToDelete = IOHelper::getFolderContents($appPath, true, ".*\\.bak\$");
     // Now delete any files/folders that were marked for deletion in the manifest file.
     $manifestData = UpdateHelper::getManifestData($unzipFolder);
     if ($manifestData) {
         foreach ($manifestData as $row) {
             if (UpdateHelper::isManifestVersionInfoLine($row)) {
                 continue;
             }
             $rowData = explode(';', $row);
             if ($rowData[1] == PatchManifestFileAction::Remove) {
                 if (UpdateHelper::isManifestLineAFolder($rowData[0])) {
                     $tempFilePath = UpdateHelper::cleanManifestFolderLine($rowData[0]);
                 } else {
                     $tempFilePath = $rowData[0];
                 }
                 $filesToDelete[] = $appPath . $tempFilePath;
             }
         }
         foreach ($filesToDelete as $fileToDelete) {
             if (IOHelper::fileExists($fileToDelete)) {
                 if (IOHelper::isWritable($fileToDelete)) {
                     Craft::log('Deleting file: ' . $fileToDelete, LogLevel::Info, true);
                     IOHelper::deleteFile($fileToDelete, true);
                 }
             } else {
                 if (IOHelper::folderExists($fileToDelete)) {
                     if (IOHelper::isWritable($fileToDelete)) {
                         Craft::log('Deleting .bak folder:' . $fileToDelete, LogLevel::Info, true);
                         IOHelper::clearFolder($fileToDelete, true);
                         IOHelper::deleteFolder($fileToDelete, true);
                     }
                 }
             }
         }
     }
     // Clear the temp folder.
     IOHelper::clearFolder(craft()->path->getTempPath(), true);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:49,代码来源:Updater.php

示例14: _getImagePath

 /**
  * Returns the path to a rebrand image by type or false if it hasn't ben uploaded.
  *
  * @param string $type logo or image.
  *
  * @return string
  */
 private function _getImagePath($type)
 {
     if (!isset($this->_paths[$type])) {
         $files = IOHelper::getFolderContents(craft()->path->getRebrandPath() . $type . '/', false);
         if (!empty($files)) {
             $this->_paths[$type] = $files[0];
         } else {
             $this->_paths[$type] = false;
         }
     }
     return $this->_paths[$type];
 }
开发者ID:paulcarvill,项目名称:Convergence-craft,代码行数:19,代码来源:RebrandVariable.php

示例15: get

 /**
  * Get translations by criteria.
  *
  * @param ElementCriteriaModel $criteria
  *
  * @return array
  */
 public function get(ElementCriteriaModel $criteria)
 {
     // Ensure source is an array
     if (!is_array($criteria->source)) {
         $criteria->source = array($criteria->source);
     }
     // Gather all translatable strings
     $occurences = array();
     // Loop through paths
     foreach ($criteria->source as $path) {
         // Check if this is a folder or a file
         $isFile = IOHelper::fileExists($path);
         // If its not a file
         if (!$isFile) {
             // Set filter - no vendor folders, only template files
             $filter = '^((?!vendor|node_modules).)*(\\.(php|html|twig|js|json|atom|rss)?)$';
             // Get files
             $files = IOHelper::getFolderContents($path, true, $filter);
             // Loop through files and find translate occurences
             foreach ($files as $file) {
                 // Parse file
                 $elements = $this->_parseFile($path, $file, $criteria);
                 // Collect in array
                 $occurences = array_merge($occurences, $elements);
             }
         } else {
             // Parse file
             $elements = $this->_parseFile($path, $path, $criteria);
             // Collect in array
             $occurences = array_merge($occurences, $elements);
         }
     }
     return $occurences;
 }
开发者ID:boboldehampsink,项目名称:translate,代码行数:41,代码来源:TranslateService.php


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