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


PHP IOHelper::getFileName方法代码示例

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


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

示例1: actionDownloadBackupFile

 /**
  * Returns a database backup zip file to the browser.
  *
  * @return null
  */
 public function actionDownloadBackupFile()
 {
     $fileName = craft()->request->getRequiredQuery('fileName');
     if (($filePath = IOHelper::fileExists(craft()->path->getTempPath() . $fileName . '.zip')) == true) {
         craft()->request->sendFile(IOHelper::getFileName($filePath), IOHelper::getFileContents($filePath), array('forceDownload' => true));
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:12,代码来源:ToolsController.php

示例2: actionDownloadFile

 /**
  * Downloads a file and cleans up old temporary assets
  */
 public function actionDownloadFile()
 {
     // Clean up temp assets files that are more than a day old
     $fileResults = array();
     $files = IOHelper::getFiles(craft()->path->getTempPath(), true);
     foreach ($files as $file) {
         $lastModifiedTime = IOHelper::getLastTimeModified($file, true);
         if (substr(IOHelper::getFileName($file, false, true), 0, 6) === "assets" && DateTimeHelper::currentTimeStamp() - $lastModifiedTime->getTimestamp() >= 86400) {
             IOHelper::deleteFile($file);
         }
     }
     // Sort out the file we want to download
     $id = craft()->request->getParam('id');
     $criteria = craft()->elements->getCriteria(ElementType::Asset);
     $criteria->id = $id;
     $asset = $criteria->first();
     if ($asset) {
         // Get a local copy of the file
         $sourceType = craft()->assetSources->getSourceTypeById($asset->sourceId);
         $localCopy = $sourceType->getLocalCopy($asset);
         // Send it to the browser
         craft()->request->sendFile($asset->filename, IOHelper::getFileContents($localCopy), array('forceDownload' => true));
         craft()->end();
     }
 }
开发者ID:supercool,项目名称:Tools,代码行数:28,代码来源:SupercoolToolsController.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: getTemplateByName

 /**
  * Get template file by its name
  * 		
  * @param  string $templateName Template file name
  * @return array               Returns template file information
  */
 public function getTemplateByName($templateName)
 {
     $template = [];
     $path = craft()->path->getPluginsPath() . 'formbuilder2/templates/email/templates/' . $templateName;
     $file = IOHelper::getFile($path);
     $template = ['fileName' => $file->getFileName(false), 'fileOriginalName' => $file->getFileName(), 'fileNameCleaned' => IOHelper::cleanFilename(IOHelper::getFileName($file->getRealPath(), false)), 'fileExtension' => $file->getExtension(), 'filePath' => $file->getRealPath(), 'fileContents' => $file->getContents()];
     return $template;
 }
开发者ID:roundhouse,项目名称:FormBuilder-2-Craft-CMS,代码行数:14,代码来源:FormBuilder2_TemplateService.php

示例5: actionDownload

 /**
  * Download zip.
  */
 public function actionDownload()
 {
     // Get wanted filename
     $filename = craft()->request->getRequiredParam('filename');
     // Get file id's
     $files = craft()->request->getRequiredParam('files');
     // Generate zipfile
     $zipfile = craft()->zipAssets->download($files, $filename);
     // Download it
     craft()->request->sendFile(IOHelper::getFileName($zipfile), IOHelper::getFileContents($zipfile), array('forceDownload' => true));
 }
开发者ID:brammittendorff,项目名称:zipassets,代码行数:14,代码来源:ZipAssetsController.php

示例6: getFileName

 /**
  * @param bool $includeExtension
  *
  * @return mixed
  */
 public function getFileName($includeExtension = true)
 {
     if ($includeExtension) {
         if (!$this->_fileName) {
             $this->_fileName = IOHelper::getFileName($this->getRealPath(), $includeExtension);
         }
         return $this->_fileName;
     } else {
         if (!$this->_baseName) {
             $this->_baseName = IOHelper::getFileName($this->getRealPath(), $includeExtension);
         }
         return $this->_baseName;
     }
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:19,代码来源:File.php

示例7: performAction

 /**
  * Performs the tool's action.
  *
  * @param array $params
  * @return array
  */
 public function performAction($params = array())
 {
     $file = craft()->db->backup();
     if (IOHelper::fileExists($file) && isset($params['downloadBackup']) && (bool) $params['downloadBackup']) {
         $destZip = craft()->path->getTempPath() . IOHelper::getFileName($file, false) . '.zip';
         if (IOHelper::fileExists($destZip)) {
             IOHelper::deleteFile($destZip, true);
         }
         IOHelper::createFile($destZip);
         if (Zip::add($destZip, $file, craft()->path->getDbBackupPath())) {
             return array('backupFile' => IOHelper::getFileName($destZip, false));
         }
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:20,代码来源:DbBackupTool.php

示例8: 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

示例9: getAlerts

 /**
  * @param string|null $path
  * @param bool        $fetch
  *
  * @return array
  */
 public static function getAlerts($path = null, $fetch = false)
 {
     $alerts = array();
     $user = craft()->userSession->getUser();
     if (!$user) {
         return $alerts;
     }
     if (craft()->updates->isUpdateInfoCached() || $fetch) {
         // Fetch the updates regardless of whether we're on the Updates page or not, because the other alerts are
         // relying on cached Elliott info
         $updateModel = craft()->updates->getUpdates();
         // Get the license key status
         $licenseKeyStatus = craft()->et->getLicenseKeyStatus();
         // Invalid license?
         if ($licenseKeyStatus == LicenseKeyStatus::Invalid) {
             $alerts[] = Craft::t('Your license key is invalid.');
         } else {
             if (craft()->hasWrongEdition()) {
                 $alerts[] = Craft::t('You’re running Craft {edition} with a Craft {licensedEdition} license.', array('edition' => craft()->getEditionName(), 'licensedEdition' => craft()->getLicensedEditionName())) . ' <a class="go edition-resolution">' . Craft::t('Resolve') . '</a>';
             }
         }
         if ($path != 'updates' && $user->can('performUpdates')) {
             if (!empty($updateModel->app->releases)) {
                 if (craft()->updates->criticalCraftUpdateAvailable($updateModel->app->releases)) {
                     $alerts[] = Craft::t('There’s a critical Craft update available.') . ' <a class="go nowrap" href="' . UrlHelper::getUrl('updates') . '">' . Craft::t('Go to Updates') . '</a>';
                 }
             }
         }
         // Domain mismatch?
         if ($licenseKeyStatus == LicenseKeyStatus::Mismatched) {
             $licensedDomain = craft()->et->getLicensedDomain();
             $licenseKeyPath = craft()->path->getLicenseKeyPath();
             $licenseKeyFile = IOHelper::getFolderName($licenseKeyPath, false) . '/' . IOHelper::getFileName($licenseKeyPath);
             $message = Craft::t('The license located at {file} belongs to {domain}.', array('file' => $licenseKeyFile, 'domain' => '<a href="http://' . $licensedDomain . '" target="_blank">' . $licensedDomain . '</a>'));
             // Can they actually do something about it?
             if ($user->admin) {
                 $action = '<a class="go domain-mismatch">' . Craft::t('Transfer it to this domain') . '</a>';
             } else {
                 $action = Craft::t('Please notify one of your site’s admins.');
             }
             $alerts[] = $message . ' ' . $action;
         }
     }
     $allPluginAlerts = craft()->plugins->call('getCpAlerts', array($path, $fetch), true);
     foreach ($allPluginAlerts as $pluginAlerts) {
         $alerts = array_merge($alerts, $pluginAlerts);
     }
     return $alerts;
 }
开发者ID:amite,项目名称:arc-va,代码行数:55,代码来源:CpHelper.php

示例10: 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

示例11: performAction

 /**
  * @inheritDoc ITool::performAction()
  *
  * @param array $params
  *
  * @return array
  */
 public function performAction($params = array())
 {
     // In addition to the default tables we want to ignore data in, we also don't care about data in the session
     // table in this tools' case.
     $file = craft()->db->backup(array('sessions'));
     if (IOHelper::fileExists($file) && isset($params['downloadBackup']) && (bool) $params['downloadBackup']) {
         $destZip = craft()->path->getTempPath() . IOHelper::getFileName($file, false) . '.zip';
         if (IOHelper::fileExists($destZip)) {
             IOHelper::deleteFile($destZip, true);
         }
         IOHelper::createFile($destZip);
         if (Zip::add($destZip, $file, craft()->path->getDbBackupPath())) {
             return array('backupFile' => IOHelper::getFileName($destZip, false));
         }
     }
 }
开发者ID:kant312,项目名称:sop,代码行数:23,代码来源:DbBackupTool.php

示例12: 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

示例13: 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

示例14: cleanAssetName

 /**
  * Clean an Asset's filename.
  *
  * @param $name
  * @param bool $isFilename if set to true (default), will separate extension
  *                         and clean the filename separately.
  *
  * @return mixed
  */
 public static function cleanAssetName($name, $isFilename = true)
 {
     if ($isFilename) {
         $baseName = IOHelper::getFileName($name, false);
         $extension = '.' . IOHelper::getExtension($name);
     } else {
         $baseName = $name;
         $extension = '';
     }
     $separator = craft()->config->get('filenameWordSeparator');
     if (!is_string($separator)) {
         $separator = null;
     }
     $baseName = IOHelper::cleanFilename($baseName, craft()->config->get('convertFilenamesToAscii'), $separator);
     if ($isFilename && empty($baseName)) {
         $baseName = '-';
     }
     return $baseName . $extension;
 }
开发者ID:nathanedwards,项目名称:cowfields.craft,代码行数:28,代码来源:AssetsHelper.php

示例15: 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


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