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


PHP SafeGlob函数代码示例

本文整理汇总了PHP中SafeGlob函数的典型用法代码示例。如果您正苦于以下问题:PHP SafeGlob函数的具体用法?PHP SafeGlob怎么用?PHP SafeGlob使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: AvailableThemes

 /**
  * Looks through the themes directory for valid themes and returns them as
  * an associative array of "Theme Name" => "Theme Info Array". It also adds
  * a "Folder" definition to the Theme Info Array for each.
  */
 public function AvailableThemes()
 {
     if (!is_array($this->_AvailableThemes)) {
         $ThemeInfo = array();
         $ThemeFolders = Gdn_FileSystem::Folders(PATH_THEMES);
         $ThemeAboutFiles = Gdn_FileSystem::FindAll(PATH_THEMES, 'about.php', $ThemeFolders);
         // Include them all right here and fill the theme info array
         $ThemeCount = is_array($ThemeAboutFiles) ? count($ThemeAboutFiles) : 0;
         for ($i = 0; $i < $ThemeCount; ++$i) {
             include $ThemeAboutFiles[$i];
             // Define the folder name for the newly added item
             foreach ($ThemeInfo as $ThemeName => $Info) {
                 if (array_key_exists('Folder', $ThemeInfo[$ThemeName]) === FALSE) {
                     $Folder = substr($ThemeAboutFiles[$i], strlen(PATH_THEMES));
                     if (substr($Folder, 0, 1) == DS) {
                         $Folder = substr($Folder, 1);
                     }
                     $Folder = substr($Folder, 0, strpos($Folder, DS));
                     $ThemeInfo[$ThemeName]['Folder'] = $Folder;
                     // Add the screenshot.
                     $ScreenshotPath = SafeGlob(PATH_THEMES . "/{$Folder}/screenshot.*", array('gif', 'jpg', 'png'));
                     if (count($ScreenshotPath) > 0) {
                         $ScreenshotPath = $ScreenshotPath[0];
                         $ThemeInfo[$ThemeName]['ScreenshotUrl'] = Asset(str_replace(PATH_ROOT, '', $ScreenshotPath));
                     }
                 }
             }
         }
         $this->_AvailableThemes = $ThemeInfo;
     }
     return $this->_AvailableThemes;
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:37,代码来源:class.thememanager.php

示例2: SettingsController_ProxyConnect_Create

 public function SettingsController_ProxyConnect_Create($Sender)
 {
     $Sender->Permission('Garden.Settings.Manage');
     $Sender->Title('Proxy Connect SSO');
     $Sender->Form = new Gdn_Form();
     $this->Provider = $this->LoadProviderData($Sender);
     // Load internal Integration Manager list
     $this->IntegrationManagers = array();
     $InternalPath = $this->GetResource('internal');
     try {
         // 2.0.18+
         // New PluginManager Code
         $IntegrationManagers = Gdn::PluginManager()->AvailablePluginFolders($InternalPath);
         $IntegrationList = array();
         foreach ($IntegrationManagers as $Integration) {
             $this->IntegrationManagers[$Integration] = Gdn::PluginManager()->GetPluginInfo($Integration);
         }
     } catch (Exception $e) {
         // 2.0.17.x and below
         // Old PluginManager Code
         if ($FolderHandle = opendir($InternalPath)) {
             // Loop through subfolders (ie. the actual plugin folders)
             while ($FolderHandle !== FALSE && ($Item = readdir($FolderHandle)) !== FALSE) {
                 if (in_array($Item, array('.', '..'))) {
                     continue;
                 }
                 $PluginPaths = SafeGlob($InternalPath . DS . $Item . DS . '*plugin.php');
                 $PluginPaths[] = $InternalPath . DS . $Item . DS . 'default.php';
                 foreach ($PluginPaths as $i => $PluginFile) {
                     if (file_exists($PluginFile)) {
                         $PluginInfo = Gdn::PluginManager()->ScanPluginFile($PluginFile);
                         if (!is_null($PluginInfo)) {
                             Gdn_LibraryMap::SafeCache('plugin', $PluginInfo['ClassName'], $PluginInfo['PluginFilePath']);
                             $Index = strtolower($PluginInfo['Index']);
                             $this->IntegrationManagers[$Index] = $PluginInfo;
                         }
                     }
                 }
             }
             closedir($FolderHandle);
         }
     }
     $this->IntegrationManager = C('Plugin.ProxyConnect.IntegrationManager', NULL);
     if (is_null($this->IntegrationManager)) {
         $this->SetIntegrationManager('proxyconnectmanual');
     }
     $this->EnableSlicing($Sender);
     $this->Dispatch($Sender, $Sender->RequestArgs);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:49,代码来源:class.proxyconnect.plugin.php

示例3: PluginController_CssThemes_Create

 /**
  * @package $Sender Gdn_Controller
  */
 public function PluginController_CssThemes_Create($Sender)
 {
     $Sender->Form = Gdn::Factory('Form');
     $Model = new Gdn_Model('ThemeSetting');
     $Sender->Form->SetModel($Model);
     if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
         // Grab the colors.
         $Data = $Model->Get();
         //$Data = ConsolidateArrayValuesByKey($Data->ResultArray(), 'Name', 'Setting');
         $Sender->SetData('ThemeSettings', $Data->ResultArray());
         //$Sender->Form->SetData($Data);
     } else {
         $Data = $Sender->Form->FormDataSet();
         // Update the database.
         $SQL = Gdn::SQL();
         foreach ($Data as $Row) {
             $SQL->Put('ThemeSetting', array('Setting' => $Row['Setting']), array('Name' => $Row['Name']));
         }
         // Clear out the css cache.
         $Files = SafeGlob(PATH_CACHE . DS . 'css' . DS . '*.css');
         foreach ($Files as $File) {
             unlink($File);
         }
         $Sender->SetData('ThemeSettings', $Data);
         $Sender->StatusMessage = Gdn::Translate('Your changes have been saved.');
     }
     // Add the javascript & css.
     $Sender->Head->AddScript('/plugins/cssthemes/colorpicker.js');
     $Sender->Head->AddScript('/plugins/cssthemes/cssthemes.js');
     $Sender->Head->AddCss('/plugins/cssthemes/colorpicker.css');
     $Sender->Head->AddCss('/plugins/cssthemes/cssthemes.css');
     // Add the side module.
     $Sender->AddSideMenu('/plugin/cssthemes');
     $Sender->View = dirname(__FILE__) . DS . 'views' . DS . 'cssthemes.php';
     $Sender->Render();
 }
开发者ID:edelbalso,项目名称:Garden,代码行数:39,代码来源:class.cssthemes.plugin.php

示例4: TestLocale

 /**
  * Temporarily enable a locale pack without installing it
  *
  * @param string $LocaleKey The key of the folder.
  */
 public function TestLocale($LocaleKey)
 {
     $Available = $this->AvailableLocalePacks();
     if (!isset($Available[$LocaleKey])) {
         throw NotFoundException('Locale');
     }
     // Grab all of the definition files from the locale.
     $Paths = SafeGlob(PATH_ROOT . "/locales/{$LocaleKey}/*.php");
     // Unload the dynamic config
     Gdn::Locale()->Unload();
     // Load each locale file, checking for errors
     foreach ($Paths as $Path) {
         Gdn::Locale()->Load($Path, FALSE);
     }
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:20,代码来源:class.localemodel.php

示例5: CreateZip

 public function CreateZip()
 {
     if (!class_exists('ZipArchive')) {
         throw new Exception('Your server does not support zipping files.', 400);
     }
     $Info = $this->GetInfoArray();
     $this->EnsureDefinitionFile();
     // Get the basename of the locale.
     $Key = key($Info);
     $ZipPath = PATH_UPLOADS . "/{$Key}.zip";
     $TmpPath = PATH_UPLOADS . "/tmp_" . RandomString(10);
     $Zip = new ZipArchive();
     $Zip->open($TmpPath, ZIPARCHIVE::CREATE);
     // Add all of the files in the locale to the zip.
     $Files = SafeGlob(rtrim($this->LocalePath, '/') . '/*.*', array('php', 'txt'));
     foreach ($Files as $File) {
         $LocalPath = $Key . '/' . basename($File);
         $Zip->addFile($File, $LocalPath);
     }
     $Zip->close();
     rename($TmpPath, $ZipPath);
     return $ZipPath;
 }
开发者ID:nilsen,项目名称:addons,代码行数:23,代码来源:class.localedeveloper.plugin.php

示例6: Base_BeforeAddCss_Handler

 public function Base_BeforeAddCss_Handler($Sender)
 {
     $WebRoot = Gdn::Request()->WebRoot();
     // Find all css file paths
     $CssToCache = array();
     foreach ($Sender->CssFiles() as $CssInfo) {
         $CssFile = $CssInfo['FileName'];
         if (strpos($CssFile, '/') !== FALSE) {
             // A direct path to the file was given.
             $CssPaths = array(CombinePaths(array(PATH_ROOT, str_replace('/', DS, $CssFile))));
         } else {
             $CssGlob = preg_replace('/(.*)(\\.css)/', '\\1*\\2', $CssFile);
             $AppFolder = $CssInfo['AppFolder'];
             if ($AppFolder == '') {
                 $AppFolder = $Sender->ApplicationFolder;
             }
             // CSS comes from one of four places:
             $CssPaths = array();
             if ($Sender->Theme) {
                 // 1. Application-specific css. eg. root/themes/theme_name/app_name/design/
                 // $CssPaths[] = PATH_THEMES . DS . $Sender->Theme . DS . $AppFolder . DS . 'design' . DS . $CssGlob;
                 // 2. Theme-wide theme view. eg. root/themes/theme_name/design/
                 // a) Check to see if a customized version of the css is there.
                 if ($Sender->ThemeOptions) {
                     $Filenames = GetValueR('Styles.Value', $Sender->ThemeOptions);
                     if (is_string($Filenames) && $Filenames != '%s') {
                         $CssPaths[] = PATH_THEMES . DS . $Sender->Theme . DS . 'design' . DS . ChangeBasename($CssFile, $Filenames);
                     }
                 }
                 // b) Use the default filename.
                 $CssPaths[] = PATH_THEMES . DS . $Sender->Theme . DS . 'design' . DS . $CssFile;
             }
             // 3. Application default. eg. root/applications/app_name/design/
             $CssPaths[] = PATH_APPLICATIONS . DS . $AppFolder . DS . 'design' . DS . $CssFile;
             // 4. Garden default. eg. root/applications/dashboard/design/
             $CssPaths[] = PATH_APPLICATIONS . DS . 'dashboard' . DS . 'design' . DS . $CssFile;
         }
         // Find the first file that matches the path.
         $CssPath = FALSE;
         foreach ($CssPaths as $Glob) {
             $Paths = SafeGlob($Glob);
             if (is_array($Paths) && count($Paths) > 0) {
                 $CssPath = $Paths[0];
                 break;
             }
         }
         if ($CssPath !== FALSE) {
             $CssPath = substr($CssPath, strlen(PATH_ROOT) + 1);
             $CssPath = str_replace(DS, '/', $CssPath);
             $CssToCache[] = $CssPath;
         }
     }
     $CssToCache = array_unique($CssToCache);
     // And now search for/add all JS files
     $JsToCache = array();
     // Add the global js files
     $GlobalJS = array('jquery.js', 'jquery.livequery.js', 'jquery.form.js', 'jquery.popup.js', 'jquery.gardenhandleajaxform.js', 'global.js');
     foreach ($Sender->JsFiles() as $JsInfo) {
         $JsFile = $JsInfo['FileName'];
         // Ignore the JsFile if it is in the globaljs minify group (defined in plugins/Minifiy/min/groupsConfig.php).
         if (!in_array($JsFile, $GlobalJS)) {
             if (strpos($JsFile, '/') !== FALSE) {
                 // A direct path to the file was given.
                 $JsPaths = array(CombinePaths(array(PATH_ROOT, str_replace('/', DS, $JsFile)), DS));
             } else {
                 $AppFolder = $JsInfo['AppFolder'];
                 if ($AppFolder == '') {
                     $AppFolder = $Sender->ApplicationFolder;
                 }
                 // JS can come from a theme, an any of the application folder, or it can come from the global js folder:
                 $JsPaths = array();
                 if ($Sender->Theme) {
                     // 1. Application-specific js. eg. root/themes/theme_name/app_name/design/
                     $JsPaths[] = PATH_THEMES . DS . $Sender->Theme . DS . $AppFolder . DS . 'js' . DS . $JsFile;
                     // 2. Garden-wide theme view. eg. root/themes/theme_name/design/
                     $JsPaths[] = PATH_THEMES . DS . $Sender->Theme . DS . 'js' . DS . $JsFile;
                 }
                 // 3. This application folder
                 $JsPaths[] = PATH_APPLICATIONS . DS . $AppFolder . DS . 'js' . DS . $JsFile;
                 // 4. Global JS folder. eg. root/js/
                 $JsPaths[] = PATH_ROOT . DS . 'js' . DS . $JsFile;
                 // 5. Global JS library folder. eg. root/js/library/
                 $JsPaths[] = PATH_ROOT . DS . 'js' . DS . 'library' . DS . $JsFile;
             }
             // Find the first file that matches the path.
             $JsPath = FALSE;
             foreach ($JsPaths as $Glob) {
                 $Paths = SafeGlob($Glob);
                 if (is_array($Paths) && count($Paths) > 0) {
                     $JsPath = $Paths[0];
                     break;
                 }
             }
             if ($JsPath !== FALSE) {
                 $JsPath = str_replace(array(PATH_ROOT, DS), array('', '/'), $JsPath);
                 $JsPath = substr($JsPath, 0, 1) == '/' ? substr($JsPath, 1) : $JsPath;
                 $JsToCache[] = $JsPath;
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:kerphi,项目名称:Garden,代码行数:101,代码来源:class.minify.plugin.php

示例7: index

 /**
  * Main import page.
  *
  * @since 2.0.0
  * @access public
  */
 public function index()
 {
     $this->permission('Garden.Import');
     // This permission doesn't exist, so only users with Admin == '1' will succeed.
     $Timer = new Gdn_Timer();
     // Determine the current step.
     $this->Form = new Gdn_Form();
     $Imp = new ImportModel();
     $Imp->loadState();
     // Search for the list of acceptable imports.
     $ImportPaths = array();
     $ExistingPaths = SafeGlob(PATH_UPLOADS . '/export*', array('gz', 'txt'));
     $ExistingPaths2 = SafeGlob(PATH_UPLOADS . '/porter/export*', array('gz'));
     $ExistingPaths = array_merge($ExistingPaths, $ExistingPaths2);
     foreach ($ExistingPaths as $Path) {
         $ImportPaths[$Path] = basename($Path);
     }
     // Add the database as a path.
     $ImportPaths = array_merge(array('db:' => t('This Database')), $ImportPaths);
     if ($Imp->CurrentStep < 1) {
         // Check to see if there is a file.
         $ImportPath = c('Garden.Import.ImportPath');
         $Validation = new Gdn_Validation();
         if (strcasecmp(Gdn::request()->requestMethod(), 'post') == 0) {
             $Upload = new Gdn_Upload();
             $Validation = new Gdn_Validation();
             if (count($ImportPaths) > 0) {
                 $Validation->applyRule('PathSelect', 'Required', t('You must select a file to import.'));
             }
             if (count($ImportPaths) == 0 || $this->Form->getFormValue('PathSelect') == 'NEW') {
                 $TmpFile = $Upload->ValidateUpload('ImportFile', false);
             } else {
                 $TmpFile = '';
             }
             if ($TmpFile) {
                 $Filename = $_FILES['ImportFile']['name'];
                 $Extension = pathinfo($Filename, PATHINFO_EXTENSION);
                 $TargetFolder = PATH_ROOT . DS . 'uploads' . DS . 'import';
                 if (!file_exists($TargetFolder)) {
                     mkdir($TargetFolder, 0777, true);
                 }
                 $ImportPath = $Upload->GenerateTargetName(PATH_ROOT . DS . 'uploads' . DS . 'import', $Extension);
                 $Upload->SaveAs($TmpFile, $ImportPath);
                 $Imp->ImportPath = $ImportPath;
                 $this->Form->setFormValue('PathSelect', $ImportPath);
                 $UploadedFiles = val('UploadedFiles', $Imp->Data);
                 $UploadedFiles[$ImportPath] = basename($Filename);
                 $Imp->Data['UploadedFiles'] = $UploadedFiles;
             } elseif ($PathSelect = $this->Form->getFormValue('PathSelect')) {
                 if ($PathSelect == 'NEW') {
                     $Validation->addValidationResult('ImportFile', 'ValidateRequired');
                 } else {
                     $Imp->ImportPath = $PathSelect;
                 }
             } elseif (!$Imp->ImportPath && count($ImportPaths) == 0) {
                 // There was no file uploaded this request or before.
                 $Validation->addValidationResult('ImportFile', $Upload->Exception);
             }
             // Validate the overwrite.
             if (true || strcasecmp($this->Form->getFormValue('Overwrite'), 'Overwrite') == 0) {
                 if (!stringBeginsWith($this->Form->getFormValue('PathSelect'), 'Db:', true)) {
                     $Validation->applyRule('Email', 'Required');
                 }
             }
             if ($Validation->validate($this->Form->formValues())) {
                 $this->Form->setFormValue('Overwrite', 'overwrite');
                 $Imp->fromPost($this->Form->formValues());
                 $this->View = 'Info';
             } else {
                 $this->Form->setValidationResults($Validation->results());
             }
         } else {
             $this->Form->setFormValue('PathSelect', $Imp->ImportPath);
         }
         $Imp->saveState();
     } else {
         $this->setData('Steps', $Imp->steps());
         $this->View = 'Info';
     }
     if (!stringBeginsWith($Imp->ImportPath, 'db:') && !file_exists($Imp->ImportPath)) {
         $Imp->deleteState();
     }
     try {
         $UploadedFiles = val('UploadedFiles', $Imp->Data, array());
         $ImportPaths = array_merge($ImportPaths, $UploadedFiles);
         $this->setData('ImportPaths', $ImportPaths);
         $this->setData('Header', $Imp->getImportHeader());
         $this->setData('Stats', val('Stats', $Imp->Data, array()));
         $this->setData('GenerateSQL', val('GenerateSQL', $Imp->Data));
         $this->setData('ImportPath', $Imp->ImportPath);
         $this->setData('OriginalFilename', val('OriginalFilename', $Imp->Data));
         $this->setData('CurrentStep', $Imp->CurrentStep);
         $this->setData('LoadSpeedWarning', $Imp->loadTableType(false) == 'LoadTableWithInsert');
     } catch (Gdn_UserException $Ex) {
//.........这里部分代码省略.........
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:101,代码来源:class.importcontroller.php

示例8: Index

 public function Index()
 {
     $this->Permission('Garden.Import');
     // This permission doesn't exist, so only users with Admin == '1' will succeed.
     $Timer = new Gdn_Timer();
     // Determine the current step.
     $this->Form = new Gdn_Form();
     $Imp = new ImportModel();
     $Imp->LoadState();
     if ($Imp->CurrentStep < 1) {
         // Check to see if there is a file.
         $ImportPath = Gdn::Config('Garden.Import.ImportPath');
         $Validation = new Gdn_Validation();
         if (strcasecmp(Gdn::Request()->RequestMethod(), 'post') == 0) {
             $Upload = new Gdn_Upload();
             $Validation = new Gdn_Validation();
             $TmpFile = $Upload->ValidateUpload('ImportFile', FALSE);
             if ($TmpFile) {
                 $Filename = $_FILES['ImportFile']['name'];
                 $Extension = pathinfo($Filename, PATHINFO_EXTENSION);
                 $TargetFolder = PATH_ROOT . DS . 'uploads' . DS . 'import';
                 if (!file_exists($TargetFolder)) {
                     mkdir($TargetFolder, 0777, TRUE);
                 }
                 $ImportPath = $Upload->GenerateTargetName(PATH_ROOT . DS . 'uploads' . DS . 'import', $Extension);
                 $Upload->SaveAs($TmpFile, $ImportPath);
                 $Imp->ImportPath = $ImportPath;
                 $Imp->Data['OriginalFilename'] = basename($Filename);
             } elseif (!$Imp->ImportPath) {
                 // There was no file uploaded this request or before.
                 $Validation->AddValidationResult('ImportFile', $Upload->Exception);
             }
             // Validate the overwrite.
             if (strcasecmp($this->Form->GetFormValue('Overwrite'), 'Overwrite') == 0) {
                 $Validation->ApplyRule('Email', 'Required');
                 $Validation->ApplyRule('Password', 'Required');
             }
             if ($Validation->Validate($this->Form->FormValues())) {
                 $Imp->Overwrite($this->Form->GetFormValue('Overwrite', 'Overwrite'), $this->Form->GetFormValue('Email'), $this->Form->GetFormValue('Password'));
                 $this->View = 'Info';
             } else {
                 $this->Form->SetValidationResults($Validation->Results());
             }
         } else {
             // Search for an existing file that was uploaded by the web admin.
             $ImportPaths = SafeGlob(PATH_ROOT . DS . 'uploads' . DS . 'import' . DS . 'import.*');
             if ($ImportPaths) {
                 $ImportPath = $ImportPaths[0];
                 if (in_array(pathinfo($ImportPath, PATHINFO_EXTENSION), array('gz', 'txt'))) {
                     $Imp->ImportPath = $ImportPath;
                     $Imp->Data['OriginalFilename'] = basename($ImportPath);
                 }
             }
         }
         $Imp->SaveState();
     } else {
         $this->View = 'Info';
     }
     $this->SetData('Header', $Imp->GetImportHeader());
     $this->SetData('ImportPath', $Imp->ImportPath);
     $this->SetData('OriginalFilename', GetValue('OriginalFilename', $Imp->Data));
     $this->Render();
 }
开发者ID:sheldon,项目名称:Garden,代码行数:63,代码来源:class.importcontroller.php

示例9: foreach

 <?php 
  $Alt = FALSE;
  $Cols = 3;
  $Col = 0;
  foreach ($this->AvailableThemes as $ThemeName => $ThemeInfo) {
      $ScreenName = ArrayValue('Name', $ThemeInfo, $ThemeName);
      $ThemeFolder = ArrayValue('Folder', $ThemeInfo, '');
      $Active = $ThemeFolder == $this->EnabledThemeFolder;
      if (!$Active) {
          $Version = ArrayValue('Version', $ThemeInfo, '');
          $ThemeUrl = ArrayValue('Url', $ThemeInfo, '');
          $Author = ArrayValue('Author', $ThemeInfo, '');
          $AuthorUrl = ArrayValue('AuthorUrl', $ThemeInfo, '');
          $NewVersion = ArrayValue('NewVersion', $ThemeInfo, '');
          $Upgrade = $NewVersion != '' && version_compare($NewVersion, $Version, '>');
          $PreviewImage = SafeGlob(PATH_THEMES . DS . $ThemeFolder . DS . "screenshot.*", GLOB_BRACE);
          $PreviewImage = count($PreviewImage) > 0 ? basename($PreviewImage[0]) : FALSE;
          if ($PreviewImage && !in_array(strtolower(pathinfo($PreviewImage, PATHINFO_EXTENSION)), array('gif', 'jpg', 'png'))) {
              $PreviewImage = FALSE;
          }
          $Col++;
          if ($Col == 1) {
              $ColClass = 'FirstCol';
              echo '<tr>';
          } elseif ($Col == 2) {
              $ColClass = 'MiddleCol';
          } else {
              $ColClass = 'LastCol';
              $Col = 0;
          }
          $ColClass .= $Active ? ' Enabled' : '';
开发者ID:sheldon,项目名称:Garden,代码行数:31,代码来源:themes.php

示例10: GetLocaleSources

 public function GetLocaleSources($LocaleName, $ApplicationWhiteList, $PluginWhiteList, $ForceRemapping = FALSE)
 {
     $SafeLocaleName = preg_replace('/([^\\w\\d_-])/', '', $LocaleName);
     // Removes everything from the string except letters, numbers, dashes, and underscores
     $LocaleSources = array();
     if (!is_array($ApplicationWhiteList)) {
         $ApplicationWhiteList = array();
     }
     if (!is_array($PluginWhiteList)) {
         $PluginWhiteList = array();
     }
     Gdn_LibraryMap::PrepareCache('locale', NULL, 'tree');
     $LocaleSources = Gdn_LibraryMap::GetCache('locale', $SafeLocaleName);
     if ($ForceRemapping === TRUE || !Gdn_LibraryMap::CacheReady('locale') || $LocaleSources === NULL) {
         $LocaleSources = array();
         // Get application-based locale definition files
         $ApplicationLocaleSources = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, CombinePaths(array('locale', $LocaleName . '.php')), $ApplicationWhiteList);
         if ($ApplicationLocaleSources !== FALSE) {
             $LocaleSources = array_merge($LocaleSources, $ApplicationLocaleSources);
         }
         $ApplicationLocaleSources = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, CombinePaths(array('locale', $LocaleName, 'definitions.php')), $ApplicationWhiteList);
         if ($ApplicationLocaleSources !== FALSE) {
             $LocaleSources = array_merge($LocaleSources, $ApplicationLocaleSources);
         }
         // Get locale-based locale definition files.
         $EnabledLocales = C('EnabledLocales');
         if (is_array($EnabledLocales)) {
             foreach ($EnabledLocales as $Key => $Locale) {
                 if ($Locale != $LocaleName) {
                     continue;
                 }
                 // skip locales that aren't in effect.
                 // Grab all of the files in the locale's folder.
                 $Paths = SafeGlob(PATH_ROOT . "/locales/{$Key}/*.php");
                 if (is_array($Paths)) {
                     foreach ($Paths as $Path) {
                         $LocaleSources[] = $Path;
                     }
                 }
             }
         }
         // Get plugin-based locale definition files
         $PluginLocaleSources = Gdn_FileSystem::FindAll(PATH_PLUGINS, CombinePaths(array('locale', $LocaleName . '.php')), $PluginWhiteList);
         if ($PluginLocaleSources !== FALSE) {
             $LocaleSources = array_merge($LocaleSources, $PluginLocaleSources);
         }
         $PluginLocaleSources = Gdn_FileSystem::FindAll(PATH_PLUGINS, CombinePaths(array('locale', $LocaleName, 'definitions.php')), $PluginWhiteList);
         if ($PluginLocaleSources !== FALSE) {
             $LocaleSources = array_merge($LocaleSources, $PluginLocaleSources);
         }
         // Get theme-based locale definition files.
         $Theme = C('Garden.Theme');
         if ($Theme) {
             $ThemeLocalePath = PATH_THEMES . "/{$Theme}/locale/{$LocaleName}.php";
             if (file_exists($ThemeLocalePath)) {
                 $LocaleSources[] = $ThemeLocalePath;
             }
         }
         // Save the mappings
         $FileContents = array();
         $Count = count($LocaleSources);
         for ($i = 0; $i < $Count; ++$i) {
             $FileContents[$SafeLocaleName][] = Gdn_Format::ArrayValueForPhp($LocaleSources[$i]);
         }
         // Look for a global locale.
         $ConfigLocale = PATH_CONF . '/locale.php';
         if (file_exists($ConfigLocale)) {
             $FileContents[$SafeLocaleName][] = $ConfigLocale;
         }
         // Look for a config locale that is locale-specific.
         $ConfigLocale = PATH_CONF . "/locale-{$LocaleName}.php";
         if (file_exists($ConfigLocale)) {
             $FileContents[$SafeLocaleName][] = $ConfigLocale;
         }
         Gdn_LibraryMap::PrepareCache('locale', $FileContents);
     }
     return $LocaleSources;
 }
开发者ID:3marproof,项目名称:vanilla,代码行数:78,代码来源:class.locale.php

示例11: array

 $Col = 0;
 $Classes = array('FirstCol', 'MiddleCol', 'LastCol');
 foreach ($this->data('ThemeInfo.Options.Styles') as $Key => $Options) {
     $Basename = val('Basename', $Options, '%s');
     if ($Col == 0) {
         echo '<tr>';
     }
     $Active = '';
     if ($this->data('ThemeOptions.Styles.Key') == $Key || !$this->data('ThemeOptions.Styles.Key') && $Basename == '%s') {
         $Active = ' Active';
     }
     $KeyID = str_replace(' ', '_', $Key);
     echo "<td id=\"{$KeyID}_td\" class=\"{$Classes[$Col]}{$Active}\">";
     echo '<h4>', t($Key), '</h4>';
     // Look for a screenshot for for the style.
     $Screenshot = SafeGlob(PATH_THEMES . DS . $this->data('ThemeFolder') . DS . 'design' . DS . ChangeBasename('screenshot.*', $Basename), array('gif', 'jpg', 'png'));
     if (is_array($Screenshot) && count($Screenshot) > 0) {
         $Screenshot = basename($Screenshot[0]);
         echo img('/themes/' . $this->data('ThemeFolder') . '/design/' . $Screenshot, array('alt' => t($Key), 'width' => '160'));
     }
     $Disabled = $Active ? ' Disabled' : '';
     echo '<div class="Buttons">', anchor(t('Select'), '?style=' . urlencode($Key), 'SmallButton SelectThemeStyle' . $Disabled, array('Key' => $Key)), '</div>';
     if (isset($Options['Description'])) {
         echo '<div class="Info2">', $Options['Description'], '</div>';
     }
     echo '</td>';
     $Col = ($Col + 1) % 3;
     if ($Col == 0) {
         echo '</tr>';
     }
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:31,代码来源:themeoptions.php

示例12: Set

   /**
    * Defines and loads the locale.
    *
    * @param string $LocaleName The name of the locale to load. Locale definitions are kept in each
    * application's locale folder. For example:
    *  /dashboard/locale/$LocaleName.php
    *  /vanilla/locale/$LocaleName.php
    * @param array $ApplicationWhiteList An array of application folders that are safe to examine for locale
    *  definitions.
    * @param array $PluginWhiteList An array of plugin folders that are safe to examine for locale
    *  definitions.
    * @param bool $ForceRemapping For speed purposes, the application folders are crawled for locale
    *  sources. Once sources are found, they are saved in the
    *  cache/locale_mapppings.php file. If ForceRemapping is true, this file will
    *  be ignored and the folders will be recrawled and the mapping file will be
    *  re-generated. You can also simply delete the file and it will
    *  automatically force a remapping.
    */
   public function Set($LocaleName, $ApplicationWhiteList, $PluginWhiteList, $ForceRemapping = FALSE) {
      $SafeLocaleName = preg_replace('/([^\w\d_-])/', '', $LocaleName); // Removes everything from the string except letters, numbers, dashes, and underscores
      $LocaleSources = array();
      
      if(!is_array($ApplicationWhiteList)) $ApplicationWhiteList = array();
      if(!is_array($PluginWhiteList)) $PluginWhiteList = array();
      
      Gdn_LibraryMap::PrepareCache('locale', NULL, 'tree');
      $LocaleSources = Gdn_LibraryMap::GetCache('locale',$SafeLocaleName);
      if ($ForceRemapping === TRUE || !Gdn_LibraryMap::CacheReady('locale') || $LocaleSources === NULL) {
         $LocaleSources = array();
         // Get application-based locale definition files
         $ApplicationLocaleSources = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, CombinePaths(array('locale', $LocaleName.'.php')), $ApplicationWhiteList);
         if ($ApplicationLocaleSources !== FALSE)
            $LocaleSources = array_merge($LocaleSources, $ApplicationLocaleSources);

         $ApplicationLocaleSources = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, CombinePaths(array('locale', $LocaleName, 'definitions.php')), $ApplicationWhiteList);
         if ($ApplicationLocaleSources !== FALSE)
            $LocaleSources = array_merge($LocaleSources, $ApplicationLocaleSources);

         // Get plugin-based locale definition files
         $PluginLocaleSources = Gdn_FileSystem::FindAll(PATH_PLUGINS, CombinePaths(array('locale', $LocaleName.'.php')), $PluginWhiteList);
         if ($PluginLocaleSources !== FALSE)
            $LocaleSources = array_merge($LocaleSources, $PluginLocaleSources);
            
         $PluginLocaleSources = Gdn_FileSystem::FindAll(PATH_PLUGINS, CombinePaths(array('locale', $LocaleName, 'definitions.php')), $PluginWhiteList);
         if ($PluginLocaleSources !== FALSE)
            $LocaleSources = array_merge($LocaleSources, $PluginLocaleSources);

         // Get theme-based locale definition files.
         $Theme = C('Garden.Theme');
         if($Theme) {
            $ThemeLocalePath = PATH_THEMES."/$Theme/locale/$LocaleName.php";
            if(file_exists($ThemeLocalePath))
               $LocaleSources[] = $ThemeLocalePath;
         }

         // Get locale-based locale definition files.
         $EnabledLocales = C('EnabledLocales');
         if (is_array($EnabledLocales)) {
            foreach ($EnabledLocales as $Key => $Locale) {
               if ($Locale != $LocaleName)
                  continue; // skip locales that aren't in effect.

               // Grab all of the files in the locale's folder.
               $Paths = SafeGlob(PATH_ROOT."/locales/$Key/*.php");
               if (is_array($Paths)) {
                  foreach($Paths as $Path) {
                     $LocaleSources[] = $Path;
                  }
               }
            }
         }
            
         // Save the mappings
         $FileContents = array();
         $Count = count($LocaleSources);
         for($i = 0; $i < $Count; ++$i) {
            $FileContents[$SafeLocaleName][] = Gdn_Format::ArrayValueForPhp($LocaleSources[$i]);
         }

         // Look for a global locale.
         $ConfigLocale = PATH_LOCAL_CONF.'/locale.php';
         if (file_exists($ConfigLocale))
            $FileContents[$SafeLocaleName][] = $ConfigLocale;

         // Look for a config locale that is locale-specific.
         $ConfigLocale = PATH_LOCAL_CONF."/locale-$LocaleName.php";
         if (file_exists($ConfigLocale))
            $FileContents[$SafeLocaleName][] = $ConfigLocale;
         
         Gdn_LibraryMap::PrepareCache('locale', $FileContents);
      }

      // Set up defaults
      $Definition = array();
      $this->_Definition = array();

      // Now set the locale name and import all of the sources.
      $this->_Locale = $LocaleName;
      $LocaleSources = Gdn_LibraryMap::GetCache('locale', $SafeLocaleName);
      if (is_null($SafeLocaleName))
//.........这里部分代码省略.........
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:101,代码来源:class.locale.php

示例13: Base_BeforeAddCss_Handler

 public function Base_BeforeAddCss_Handler($Sender)
 {
     if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL) {
         return;
     }
     $CssFiles =& $Sender->EventArguments['CssFiles'];
     foreach ($CssFiles as $Index => $CssInfo) {
         $CssFile = $CssInfo['FileName'];
         if (substr($CssFile, -7) != '.dt.css') {
             continue;
         }
         $AppFolder = $CssInfo['AppFolder'];
         if ($AppFolder == '') {
             $AppFolder = $Sender->ApplicationFolder;
         }
         $CssPaths = array();
         if (strpos($CssFile, '/') !== False) {
             $CssPaths[] = CombinePaths(array(PATH_ROOT, $CssFile));
         } else {
             if ($Sender->Theme) {
                 $CssPaths[] = PATH_THEMES . DS . $Sender->Theme . DS . 'design' . DS . $CssFile;
             }
             $CssPaths[] = PATH_APPLICATIONS . DS . $AppFolder . DS . 'design' . DS . $CssFile;
             $CssPaths[] = PATH_APPLICATIONS . DS . 'dashboard' . DS . 'design' . DS . $CssFile;
         }
         $CssPath = False;
         foreach ($CssPaths as $Glob) {
             $Paths = SafeGlob($Glob);
             if (count($Paths) > 0) {
                 $CssPath = $Paths[0];
                 break;
             }
         }
         if ($CssPath == False) {
             continue;
         }
         // not found
         $Basename = pathinfo(pathinfo($CssPath, 8), 8);
         // without .dt.css
         $Hash = self::GetHash($CssPath . filemtime($CssPath));
         $CacheFileName = sprintf('__%s-c-%s.css', $Basename, $Hash);
         $CachedCssFile = dirname($CssPath) . DS . $CacheFileName;
         if (!file_exists($CachedCssFile)) {
             self::MakeCssFile($CssPath, $CachedCssFile, True);
         }
         // TODO: use AbsoluteSource() from 2.0.18
         // ... and replace preprocessored dt.css file by css
         $CssInfo['FileName'] = substr($CachedCssFile, strlen(PATH_ROOT));
         $CssFiles[$Index] = $CssInfo;
         // AppFolder nevermind (will be ignored)
     }
 }
开发者ID:unlight,项目名称:DtCss,代码行数:52,代码来源:class.dtcss.plugin.php

示例14: foreach

 <?php 
  $Alt = FALSE;
  $Cols = 3;
  $Col = 0;
  foreach ($this->AvailableThemes as $ThemeName => $ThemeInfo) {
      $ScreenName = ArrayValue('Name', $ThemeInfo, $ThemeName);
      $ThemeFolder = ArrayValue('Folder', $ThemeInfo, '');
      $Active = $ThemeFolder == $this->EnabledThemeFolder;
      if (!$Active) {
          $Version = ArrayValue('Version', $ThemeInfo, '');
          $ThemeUrl = ArrayValue('Url', $ThemeInfo, '');
          $Author = ArrayValue('Author', $ThemeInfo, '');
          $AuthorUrl = ArrayValue('AuthorUrl', $ThemeInfo, '');
          $NewVersion = ArrayValue('NewVersion', $ThemeInfo, '');
          $Upgrade = $NewVersion != '' && version_compare($NewVersion, $Version, '>');
          $PreviewImage = SafeGlob(PATH_THEMES . DS . $ThemeFolder . DS . "screenshot{.gif,.jpg,.png}", GLOB_BRACE);
          $PreviewImage = count($PreviewImage) > 0 ? basename($PreviewImage[0]) : FALSE;
          $Col++;
          if ($Col == 1) {
              $ColClass = 'FirstCol';
              echo '<tr>';
          } elseif ($Col == 2) {
              $ColClass = 'MiddleCol';
          } else {
              $ColClass = 'LastCol';
              $Col = 0;
          }
          $ColClass .= $Active ? ' Enabled' : '';
          $ColClass .= $PreviewImage ? ' HasPreview' : '';
          ?>
          <td class="<?php 
开发者ID:Aetasiric,项目名称:Garden,代码行数:31,代码来源:themes.php

示例15: RenderMaster

 /**
  * Undocumented method.
  *
  * @todo Method RenderMaster() needs a description.
  */
 public function RenderMaster()
 {
     // Build the master view if necessary
     if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
         // Define some default master views unless one was explicitly defined
         if ($this->MasterView == '') {
             // If this is a syndication request, use the appropriate master view
             if ($this->SyndicationMethod == SYNDICATION_ATOM) {
                 $this->MasterView = 'atom';
             } else {
                 if ($this->SyndicationMethod == SYNDICATION_RSS) {
                     $this->MasterView = 'rss';
                 } else {
                     $this->MasterView = 'default';
                 }
             }
             // Otherwise go with the default
         }
         // Only get css & ui components if this is NOT a syndication request
         if ($this->SyndicationMethod == SYNDICATION_NONE && is_object($this->Head)) {
             if (ArrayHasValue($this->_CssFiles, 'style.css')) {
                 $this->AddCssFile('custom.css');
             }
             if (ArrayHasValue($this->_CssFiles, 'admin.css')) {
                 $this->AddCssFile('customadmin.css');
             }
             $this->EventArguments['CssFiles'] =& $this->_CssFiles;
             $this->FireEvent('BeforeAddCss');
             // And now search for/add all css files
             foreach ($this->_CssFiles as $CssInfo) {
                 $CssFile = $CssInfo['FileName'];
                 if (strpos($CssFile, '/') !== FALSE) {
                     // A direct path to the file was given.
                     $CssPaths = array(CombinePaths(array(PATH_ROOT, str_replace('/', DS, $CssFile))));
                 } else {
                     $CssGlob = preg_replace('/(.*)(\\.css)/', '\\1*\\2', $CssFile);
                     $AppFolder = $CssInfo['AppFolder'];
                     if ($AppFolder == '') {
                         $AppFolder = $this->ApplicationFolder;
                     }
                     // CSS comes from one of four places:
                     $CssPaths = array();
                     if ($this->Theme) {
                         // 1. Application-specific css. eg. root/themes/theme_name/app_name/design/
                         // $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . $AppFolder . DS . 'design' . DS . $CssGlob;
                         // 2. Theme-wide theme view. eg. root/themes/theme_name/design/
                         $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . 'design' . DS . $CssFile;
                     }
                     // 3. Application default. eg. root/applications/app_name/design/
                     $CssPaths[] = PATH_APPLICATIONS . DS . $AppFolder . DS . 'design' . DS . $CssFile;
                     // 4. Garden default. eg. root/applications/dashboard/design/
                     $CssPaths[] = PATH_APPLICATIONS . DS . 'dashboard' . DS . 'design' . DS . $CssFile;
                 }
                 // Find the first file that matches the path.
                 $CssPath = FALSE;
                 foreach ($CssPaths as $Glob) {
                     $Paths = SafeGlob($Glob);
                     if (is_array($Paths) && count($Paths) > 0) {
                         $CssPath = $Paths[0];
                         break;
                     }
                 }
                 // Check to see if there is a CSS cacher.
                 $CssCacher = Gdn::Factory('CssCacher');
                 if (!is_null($CssCacher)) {
                     $CssPath = $CssCacher->Get($CssPath, $AppFolder);
                 }
                 if ($CssPath !== FALSE) {
                     $CssPath = substr($CssPath, strlen(PATH_ROOT));
                     $CssPath = str_replace(DS, '/', $CssPath);
                     $this->Head->AddCss($CssPath, 'screen');
                 }
             }
             // And now search for/add all JS files
             foreach ($this->_JsFiles as $JsInfo) {
                 $JsFile = $JsInfo['FileName'];
                 if (strpos($JsFile, '/') !== FALSE) {
                     // A direct path to the file was given.
                     $JsPaths = array(CombinePaths(array(PATH_ROOT, str_replace('/', DS, $JsFile)), DS));
                 } else {
                     $AppFolder = $JsInfo['AppFolder'];
                     if ($AppFolder == '') {
                         $AppFolder = $this->ApplicationFolder;
                     }
                     // JS can come from a theme, an any of the application folder, or it can come from the global js folder:
                     $JsPaths = array();
                     if ($this->Theme) {
                         // 1. Application-specific js. eg. root/themes/theme_name/app_name/design/
                         $JsPaths[] = PATH_THEMES . DS . $this->Theme . DS . $AppFolder . DS . 'js' . DS . $JsFile;
                         // 2. Garden-wide theme view. eg. root/themes/theme_name/design/
                         $JsPaths[] = PATH_THEMES . DS . $this->Theme . DS . 'js' . DS . $JsFile;
                     }
                     // 3. This application folder
                     $JsPaths[] = PATH_APPLICATIONS . DS . $AppFolder . DS . 'js' . DS . $JsFile;
                     // 4. Global JS folder. eg. root/js/
//.........这里部分代码省略.........
开发者ID:sipp11,项目名称:Garden,代码行数:101,代码来源:class.controller.php


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