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


PHP IOHelper::fileExists方法代码示例

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


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

示例1: findMissingTranslation

 /**
  * Looks for a missing translation string in Yii's core translations.
  *
  * @param \CMissingTranslationEvent $event
  *
  * @return null
  */
 public static function findMissingTranslation(\CMissingTranslationEvent $event)
 {
     // Look for translation file from most to least specific.  So nl_nl.php gets checked before nl.php, for example.
     $translationFiles = array();
     $parts = explode('_', $event->language);
     $totalParts = count($parts);
     for ($i = 1; $i <= $totalParts; $i++) {
         $translationFiles[] = implode('_', array_slice($parts, 0, $i));
     }
     $translationFiles = array_reverse($translationFiles);
     // First see if we have any cached info.
     foreach ($translationFiles as $translationFile) {
         // We've loaded the translation file already, just check for the translation.
         if (isset(static::$_translations[$translationFile])) {
             if (isset(static::$_translations[$translationFile][$event->message])) {
                 $event->message = static::$_translations[$translationFile][$event->message];
             }
             // No translation... just give up.
             return;
         }
     }
     // No luck in cache, check the file system.
     $frameworkMessagePath = IOHelper::normalizePathSeparators(Craft::getPathOfAlias('app.framework.messages'));
     foreach ($translationFiles as $translationFile) {
         $path = $frameworkMessagePath . $translationFile . '/yii.php';
         if (IOHelper::fileExists($path)) {
             // Load it up.
             static::$_translations[$translationFile] = (include $path);
             if (isset(static::$_translations[$translationFile][$event->message])) {
                 $event->message = static::$_translations[$translationFile][$event->message];
                 return;
             }
         }
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:42,代码来源:LocalizationHelper.php

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

示例3: getDisplayTemplateInfo

 /**
  * Get a display (front-end displayForm) template information.
  *
  * @param string $defaultTemplate  Which default template are we looking for?
  * @param string $overrideTemplate Which override template was given?
  *
  * @return array
  */
 public function getDisplayTemplateInfo($defaultTemplate, $overrideTemplate)
 {
     // Plugin's default template path
     $templatePath = craft()->path->getPluginsPath() . 'amforms/templates/_display/templates/';
     $settingsName = $defaultTemplate . 'Template';
     $templateSetting = craft()->amForms_settings->getSettingsByHandleAndType($settingsName, AmFormsModel::SettingsTemplatePaths);
     if (empty($overrideTemplate) && $templateSetting) {
         $overrideTemplate = $templateSetting->value;
     }
     // Is the override template set?
     if ($overrideTemplate) {
         // Is the value a folder, or folder with template?
         $templateFile = craft()->path->getSiteTemplatesPath() . $overrideTemplate;
         if (is_dir($templateFile)) {
             // Only a folder was given, so still the default template template
             $templatePath = $templateFile;
         } else {
             // Try to find the template for each available template extension
             foreach (craft()->config->get('defaultTemplateExtensions') as $extension) {
                 if (IOHelper::fileExists($templateFile . '.' . $extension)) {
                     $pathParts = explode('/', $overrideTemplate);
                     $defaultTemplate = $pathParts[count($pathParts) - 1];
                     $templatePath = craft()->path->getSiteTemplatesPath() . implode('/', array_slice($pathParts, 0, count($pathParts) - 1));
                 }
             }
         }
     }
     return array('path' => $templatePath, 'template' => $defaultTemplate);
 }
开发者ID:am-impact,项目名称:amforms,代码行数:37,代码来源:AmFormsService.php

示例4: actionCropLogo

 /**
  * Crop user photo.
  */
 public function actionCropLogo()
 {
     $this->requireAjaxRequest();
     $this->requireAdmin();
     try {
         $x1 = craft()->request->getRequiredPost('x1');
         $x2 = craft()->request->getRequiredPost('x2');
         $y1 = craft()->request->getRequiredPost('y1');
         $y2 = craft()->request->getRequiredPost('y2');
         $source = craft()->request->getRequiredPost('source');
         // Strip off any querystring info, if any.
         if (($qIndex = strpos($source, '?')) !== false) {
             $source = substr($source, 0, strpos($source, '?'));
         }
         $imagePath = craft()->path->getTempUploadsPath() . $source;
         if (IOHelper::fileExists($imagePath) && craft()->images->setMemoryForImage($imagePath)) {
             $targetPath = craft()->path->getStoragePath() . 'logo/';
             IOHelper::ensureFolderExists($targetPath);
             IOHelper::clearFolder($targetPath);
             craft()->images->loadImage($imagePath)->crop($x1, $x2, $y1, $y2)->scaleToFit(300, 300, false)->saveAs($targetPath . $source);
             IOHelper::deleteFile($imagePath);
             $html = craft()->templates->render('settings/general/_logo');
             $this->returnJson(array('html' => $html));
         }
         IOHelper::deleteFile($imagePath);
     } catch (Exception $exception) {
         $this->returnErrorJson($exception->getMessage());
     }
     $this->returnErrorJson(Craft::t('Something went wrong when processing the logo.'));
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:33,代码来源:RebrandController.php

示例5: exists

 /**
  * @param $id
  * @return bool
  */
 public static function exists($id)
 {
     $id = static::getCanonicalID($id);
     $dataPath = static::$dataPath === null ? craft()->path->getFrameworkPath() . 'i18n/data' : static::$dataPath;
     $dataFile = $dataPath . '/' . $id . '.php';
     return IOHelper::fileExists($dataFile);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:11,代码来源:LocaleData.php

示例6: includeCpResources

 /**
  * Includes the plugin's resources for the Control Panel.
  */
 protected function includeCpResources()
 {
     // Prepare config
     $config = [];
     $config['iconMapping'] = craft()->config->get('iconMapping', 'redactoriconbuttons');
     $iconAdminPath = craft()->path->getConfigPath() . 'redactoriconbuttons/icons.svg';
     $iconPublicPath = craft()->config->get('iconFile', 'redactoriconbuttons');
     if (IOHelper::fileExists($iconAdminPath)) {
         $config['iconFile'] = UrlHelper::getResourceUrl('config/redactoriconbuttons/icons.svg');
     } elseif ($iconPublicPath) {
         $config['iconFile'] = craft()->config->parseEnvironmentString($iconPublicPath);
     } else {
         $config['iconFile'] = UrlHelper::getResourceUrl('redactoriconbuttons/icons/redactor-i.svg');
     }
     // Include JS
     $config = JsonHelper::encode($config);
     $js = "var RedactorIconButtons = {}; RedactorIconButtons.config = {$config};";
     craft()->templates->includeJs($js);
     craft()->templates->includeJsResource('redactoriconbuttons/redactoriconbuttons.js');
     // Include CSS
     craft()->templates->includeCssResource('redactoriconbuttons/redactoriconbuttons.css');
     // Add external spritemap support for IE9+ and Edge 12
     $ieShim = craft()->config->get('ieShim', 'redactoriconbuttons');
     if (filter_var($ieShim, FILTER_VALIDATE_BOOLEAN)) {
         craft()->templates->includeJsResource('redactoriconbuttons/lib/svg4everybody.min.js');
         craft()->templates->includeJs('svg4everybody();');
     }
 }
开发者ID:carlcs,项目名称:craft-redactoriconbuttons,代码行数:31,代码来源:RedactorIconButtonsPlugin.php

示例7: _createImageTransform

 /**
  * Create an image transform.
  *
  * @param array $params
  *
  * @return string
  */
 private function _createImageTransform($params)
 {
     $storeFolder = $this->_getStoreFolder($params);
     // Return existing file if already generated
     if (IOHelper::fileExists($this->_path . $storeFolder . $this->_asset->filename)) {
         return $this->_url . $storeFolder . $this->_asset->filename;
     }
     // Does the asset even exist?
     if (!IOHelper::fileExists($this->_path . $this->_asset->filename)) {
         return false;
     }
     // Create new image
     $this->_instance = new \Imagine\Imagick\Imagine();
     $this->_image = $this->_instance->open($this->_path . $this->_asset->filename);
     if (strtolower($params['mode']) == 'crop') {
         $this->_scaleAndCrop($params['width'], $params['height'], true, $params['position']);
     } else {
         $this->_scaleToFit($params['width'], $params['height']);
     }
     // Effect on image?
     $this->_addImageEffects($params['filters']);
     // Store the image!
     $this->_image->save($this->_path . $storeFolder . $this->_asset->filename, array('jpeg_quality' => $params['quality'], 'flatten' => true));
     // Return stored file
     return $this->_url . $storeFolder . $this->_asset->filename;
 }
开发者ID:chrisg2g,项目名称:amtools,代码行数:33,代码来源:AmTools_ImageFilterService.php

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

示例9: form

 public function form($elementId, $criteria = array())
 {
     $settings = craft()->plugins->getPlugin('comments')->getSettings();
     $oldPath = craft()->path->getTemplatesPath();
     $element = craft()->elements->getElementById($elementId);
     $criteria = array_merge($criteria, array('elementId' => $element->id, 'level' => '1'));
     $comments = craft()->comments->getCriteria($criteria);
     // Is the user providing their own templates?
     if ($settings->templateFolderOverride) {
         // Check if this file even exists
         $commentTemplate = craft()->path->getSiteTemplatesPath() . $settings->templateFolderOverride . '/comments';
         foreach (craft()->config->get('defaultTemplateExtensions') as $extension) {
             if (IOHelper::fileExists($commentTemplate . "." . $extension)) {
                 $templateFile = $settings->templateFolderOverride . '/comments';
             }
         }
     }
     // If no user templates, use our default
     if (!isset($templateFile)) {
         $templateFile = '_forms/templates/comments';
         craft()->path->setTemplatesPath(craft()->path->getPluginsPath() . 'comments/templates');
     }
     $variables = array('element' => $element, 'comments' => $comments);
     $html = craft()->templates->render($templateFile, $variables);
     craft()->path->setTemplatesPath($oldPath);
     // Finally - none of this matters if the permission to comment on this element is denied
     if (!craft()->comments_settings->checkPermissions($element)) {
         return false;
     }
     return new \Twig_Markup($html, craft()->templates->getTwig()->getCharset());
 }
开发者ID:Uxiliary,项目名称:Comments,代码行数:31,代码来源:CommentsVariable.php

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

示例11: getDisplayTemplateInfo

 /**
  * Get a display (front-end displayForm) template information.
  *
  * @param string $defaultTemplate  Which default template are we looking for?
  * @param string $overrideTemplate Which override template was given?
  *
  * @return array
  */
 public function getDisplayTemplateInfo($defaultTemplate, $overrideTemplate)
 {
     // Plugin's default template path
     $templatePath = craft()->path->getPluginsPath() . 'amforms/templates/_display/templates/';
     $settingsName = $defaultTemplate == 'email' ? 'notificationTemplate' : $defaultTemplate . 'Template';
     $templateSetting = craft()->amForms_settings->getSettingsByHandleAndType($settingsName, AmFormsModel::SettingsTemplatePaths);
     if (empty($overrideTemplate) && $templateSetting) {
         $overrideTemplate = $templateSetting->value;
     }
     // Is the override template set?
     if ($overrideTemplate) {
         // Is the value a folder, or folder with template?
         $pathParts = explode(DIRECTORY_SEPARATOR, $overrideTemplate);
         $templateFile = craft()->path->getSiteTemplatesPath() . $overrideTemplate;
         if (count($pathParts) < 2) {
             // Seems we only have a folder that will use the default template name
             $templateFile .= DIRECTORY_SEPARATOR . $defaultTemplate;
         }
         // Try to find the template for each available template extension
         foreach (craft()->config->get('defaultTemplateExtensions') as $extension) {
             if (IOHelper::fileExists($templateFile . '.' . $extension)) {
                 if (count($pathParts) > 1) {
                     // We set a specific template
                     $defaultTemplate = $pathParts[count($pathParts) - 1];
                     $templatePath = craft()->path->getSiteTemplatesPath() . str_replace(DIRECTORY_SEPARATOR . $defaultTemplate, '', implode(DIRECTORY_SEPARATOR, $pathParts));
                 } else {
                     // Only a folder was given, so still the default template template
                     $templatePath = craft()->path->getSiteTemplatesPath() . $overrideTemplate;
                 }
             }
         }
     }
     return array('path' => $templatePath, 'template' => $defaultTemplate);
 }
开发者ID:webremote,项目名称:amforms,代码行数:42,代码来源:AmFormsService.php

示例12: nav

 /**
  * Get the sections of the CP.
  *
  * @return array
  */
 public function nav($iconSize = 32)
 {
     $nav['dashboard'] = array('label' => Craft::t('Dashboard'), 'icon' => 'gauge');
     if (craft()->sections->getTotalEditableSections()) {
         $nav['entries'] = array('label' => Craft::t('Entries'), 'icon' => 'section');
     }
     $globals = craft()->globals->getEditableSets();
     if ($globals) {
         $nav['globals'] = array('label' => Craft::t('Globals'), 'url' => 'globals/' . $globals[0]->handle, 'icon' => 'globe');
     }
     if (craft()->categories->getEditableGroupIds()) {
         $nav['categories'] = array('label' => Craft::t('Categories'), 'icon' => 'categories');
     }
     if (craft()->assetSources->getTotalViewableSources()) {
         $nav['assets'] = array('label' => Craft::t('Assets'), 'icon' => 'assets');
     }
     if (craft()->getEdition() == Craft::Pro && craft()->userSession->checkPermission('editUsers')) {
         $nav['users'] = array('label' => Craft::t('Users'), 'icon' => 'users');
     }
     // Add any Plugin nav items
     $plugins = craft()->plugins->getPlugins();
     foreach ($plugins as $plugin) {
         if ($plugin->hasCpSection()) {
             $pluginHandle = $plugin->getClassHandle();
             if (craft()->userSession->checkPermission('accessPlugin-' . $pluginHandle)) {
                 $lcHandle = StringHelper::toLowerCase($pluginHandle);
                 $iconPath = craft()->path->getPluginsPath() . $lcHandle . '/resources/icon-mask.svg';
                 if (IOHelper::fileExists($iconPath)) {
                     $iconSvg = IOHelper::getFileContents($iconPath);
                 } else {
                     $iconSvg = false;
                 }
                 $nav[$lcHandle] = array('label' => $plugin->getName(), 'iconSvg' => $iconSvg);
             }
         }
     }
     if (craft()->userSession->isAdmin()) {
         $nav['settings'] = array('label' => Craft::t('Settings'), 'icon' => 'settings');
     }
     // Allow plugins to modify the nav
     craft()->plugins->call('modifyCpNav', array(&$nav));
     // Figure out which item is selected, and normalize the items
     $firstSegment = craft()->request->getSegment(1);
     if ($firstSegment == 'myaccount') {
         $firstSegment = 'users';
     }
     foreach ($nav as $handle => &$item) {
         if (is_string($item)) {
             $item = array('label' => $item);
         }
         $item['sel'] = $handle == $firstSegment;
         if (isset($item['url'])) {
             $item['url'] = UrlHelper::getUrl($item['url']);
         } else {
             $item['url'] = UrlHelper::getUrl($handle);
         }
     }
     return $nav;
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:64,代码来源:CpVariable.php

示例13: getVersion

 /**
  * Get Version
  */
 public function getVersion()
 {
     $path = CRAFT_PLUGINS_PATH . 'analytics/Info.php';
     if (IOHelper::fileExists($path)) {
         require_once $path;
         return ANALYTICS_VERSION;
     }
     return '3.2.0';
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:12,代码来源:AnalyticsPlugin.php

示例14: testSet

 /**
  * Test set.
  *
  * @covers ::set
  */
 public final function testSet()
 {
     $file = __DIR__ . '/../translations/test.php';
     IOHelper::changePermissions($file, 0666);
     $service = new TranslateService();
     $service->set('test', array());
     $result = IOHelper::fileExists($file);
     $this->assertTrue((bool) $result);
 }
开发者ID:boboldehampsink,项目名称:translate,代码行数:14,代码来源:TranslateServiceTest.php

示例15: dimmetsFileExists

 public function dimmetsFileExists()
 {
     $path = craft()->analytics_metadata->getDimmetsFilePath();
     if (IOHelper::fileExists($path, false)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:9,代码来源:Analytics_MetadataService.php


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