/**
  * Looks through the root Garden directory for valid applications and
  * returns them as an associative array of "Application Name" =>
  * "Application Info Array". It also adds a "Folder" definition to the
  * Application Info Array for each application.
  */
 public function AvailableApplications()
 {
     if (!is_array($this->_AvailableApplications)) {
         $ApplicationInfo = array();
         $AppFolders = Gdn_FileSystem::Folders(PATH_APPLICATIONS);
         // Get an array of all application folders
         $ApplicationAboutFiles = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, 'settings' . DS . 'about.php', $AppFolders);
         // Now look for about files within them.
         // Include them all right here and fill the application info array
         $ApplicationCount = count($ApplicationAboutFiles);
         for ($i = 0; $i < $ApplicationCount; ++$i) {
             include $ApplicationAboutFiles[$i];
             // Define the folder name for the newly added item
             foreach ($ApplicationInfo as $ApplicationName => $Info) {
                 if (array_key_exists('Folder', $ApplicationInfo[$ApplicationName]) === FALSE) {
                     $Folder = substr($ApplicationAboutFiles[$i], strlen(PATH_APPLICATIONS));
                     if (substr($Folder, 0, 1) == DS) {
                         $Folder = substr($Folder, 1);
                     }
                     $Folder = substr($Folder, 0, strpos($Folder, DS));
                     $ApplicationInfo[$ApplicationName]['Folder'] = $Folder;
                 }
             }
         }
         $this->_AvailableApplications = $ApplicationInfo;
     }
     return $this->_AvailableApplications;
 }
Exemple #2
0
 /**
  * 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;
                 }
             }
         }
         $this->_AvailableThemes = $ThemeInfo;
     }
     return $this->_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;
 }
Exemple #4
0
 /**
  * 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_FileCache::PrepareCache('locale');
     if ($ForceRemapping === TRUE || !Gdn_FileCache::CacheReady('locale')) {
         $LocaleSources = array();
         // Get application-based locale definition files
         $ApplicationLocaleSources = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, CombinePaths(array('locale', $LocaleName, 'definitions.php')), $ApplicationWhiteList);
         if ($ApplicationLocaleSources !== FALSE) {
             $LocaleSources = $ApplicationLocaleSources;
         }
         // Get plugin-based locale definition files
         $PluginLocaleSources = Gdn_FileSystem::FindAll(PATH_PLUGINS, CombinePaths(array('locale', $LocaleName, 'definitions.php')), $PluginWhiteList);
         if ($PluginLocaleSources !== FALSE) {
             $LocaleSources = array_merge($LocaleSources, $PluginLocaleSources);
         }
         // Save the mappings
         $FileContents = array();
         $Count = count($LocaleSources);
         for ($i = 0; $i < $Count; ++$i) {
             $FileContents[$SafeLocaleName][] = Gdn_Format::ArrayValueForPhp($LocaleSources[$i]);
         }
         // Add the config locale if it exists
         $ConfigLocale = PATH_CONF . DS . 'locale.php';
         if (file_exists($ConfigLocale)) {
             $FileContents[$SafeLocaleName][] = $ConfigLocale;
         }
         Gdn_FileCache::Import('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_FileCache::GetCache('locale', $SafeLocaleName);
     if (is_null($SafeLocaleName)) {
         $LocaleSources = array();
     }
     $ConfLocaleOverride = PATH_CONF . DS . 'locale.php';
     $Count = count($LocaleSources);
     for ($i = 0; $i < $Count; ++$i) {
         if ($ConfLocaleOverride != $LocaleSources[$i]) {
             // Don't double include the conf override file... and make sure it comes last
             @(include_once $LocaleSources[$i]);
         }
     }
     // Also load any custom defined definitions from the conf directory
     @(include_once $ConfLocaleOverride);
     // All of the included files should have contained
     // $Definition['Code'] = 'Definition'; assignments. The overwrote each
     // other in the order they were included. Now assign the $Definition array
     // to the local private _Definition property.
     $this->_Definition = $Definition;
 }
Exemple #5
0
 /**
  * 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:
  *  /garden/locale/$LocaleName.php
  *  /people/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)
 {
     $LocaleMappings = PATH_CACHE . DS . 'locale_mappings.php';
     $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();
     }
     if ($ForceRemapping === FALSE && file_exists($LocaleMappings)) {
         include $LocaleMappings;
     } else {
         $LocaleSources = array();
         // Get application-based locale definition files
         $ApplicationLocaleSources = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, CombinePaths(array('locale', $LocaleName, 'definitions.php')), $ApplicationWhiteList);
         if ($ApplicationLocaleSources !== FALSE) {
             $LocaleSources = $ApplicationLocaleSources;
         }
         // Get plugin-based locale definition files
         $PluginLocaleSources = Gdn_FileSystem::FindAll(PATH_PLUGINS, CombinePaths(array('locale', $LocaleName, 'definitions.php')), $PluginWhiteList);
         if ($PluginLocaleSources !== FALSE) {
             $LocaleSources = array_merge($LocaleSources, $PluginLocaleSources);
         }
         // Save the mappings
         $FileContents = array();
         $FileContents[] = "<?php if (!defined('APPLICATION')) exit();";
         $Count = count($LocaleSources);
         for ($i = 0; $i < $Count; ++$i) {
             $FileContents[] = "\$LocaleSources['" . $SafeLocaleName . "'][] = '" . Format::ArrayValueForPhp($LocaleSources[$i]) . "';";
         }
         Gdn_FileSystem::SaveFile($LocaleMappings, implode("\n", $FileContents));
     }
     // Set up defaults
     $Definition = array();
     $this->_Definition = array();
     // Now set the locale name and import all of the sources.
     $this->_Locale = $LocaleName;
     if (!array_key_exists($SafeLocaleName, $LocaleSources)) {
         $LocaleSources[$SafeLocaleName] = array();
     }
     $Count = count($LocaleSources[$SafeLocaleName]);
     for ($i = 0; $i < $Count; ++$i) {
         @(include $LocaleSources[$SafeLocaleName][$i]);
     }
     // Also load any custom defined definitions from the conf directory
     @(include PATH_CONF . DS . 'locale.php');
     // All of the included files should have contained
     // $Definition['Code'] = 'Definition'; assignments. The overwrote each
     // other in the order they were included. Now assign the $Definition array
     // to the local private _Definition property.
     $this->_Definition = $Definition;
 }
 private function PrepareCache($LocaleName = False)
 {
     if ($LocaleName === False) {
         $LocaleName = $this->_Locale->Current();
     }
     $EnabledApplications = Gdn::Config('EnabledApplications', array());
     $EnabledPlugins = Gdn::Config('EnabledPlugins', array());
     $LocaleSources = array();
     // Get application-based locale special definition files
     // 2.0.0+ (TODO: REMOVE)
     $ApplicationLocaleSources = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, CombinePaths(array('locale', $LocaleName, 'distinctions.php')), $EnabledApplications);
     if ($ApplicationLocaleSources !== False) {
         if (C('Debug')) {
             Deprecated("Move all application's locale distinctions.php files to [applicationname]/locale/[localename].custom.php, distinctions.php filenames");
         }
         $LocaleSources = array_merge($LocaleSources, $ApplicationLocaleSources);
     }
     // 2.0.11+ (TODO: REMOVE)
     $ApplicationLocaleSources = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, CombinePaths(array('locale', $LocaleName . '.distinct.php')), $EnabledApplications);
     if ($ApplicationLocaleSources !== False) {
         if (C('Debug')) {
             Deprecated("Rename all application's locale [localename].distinct.php files to [localename].custom.php, [localename].distinct.php filenames");
         }
         $LocaleSources = array_merge($LocaleSources, $ApplicationLocaleSources);
     }
     // 2.0.18+
     $ApplicationLocaleSources = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, CombinePaths(array('locale', $LocaleName . '.custom.php')), $EnabledApplications);
     if ($ApplicationLocaleSources !== False) {
         $LocaleSources = array_merge($LocaleSources, $ApplicationLocaleSources);
     }
     // Get plugin-based locale special definition files
     // 2.0.0+ (TODO: REMOVE)
     $PluginLocaleSources = Gdn_FileSystem::FindAll(PATH_PLUGINS, CombinePaths(array('locale', $LocaleName, 'distinctions.php')), $EnabledPlugins);
     if ($PluginLocaleSources !== False) {
         if (C('Debug')) {
             Deprecated("Move all plugin's locale distinctions.php files to [pluginname]/locale/[localename].custom.php, distinctions.php filenames");
         }
         $LocaleSources = array_merge($LocaleSources, $PluginLocaleSources);
     }
     // 2.0.11+ (TODO: REMOVE)
     $PluginLocaleSources = Gdn_FileSystem::FindAll(PATH_PLUGINS, CombinePaths(array('locale', $LocaleName . '.distinct.php')), $EnabledPlugins);
     if ($PluginLocaleSources !== False) {
         if (C('Debug')) {
             Deprecated("Rename all plugin's locale [localename].distinct.php files to [localename].custom.php, [localename].distinct.php filenames");
         }
         $LocaleSources = array_merge($LocaleSources, $PluginLocaleSources);
     }
     // 2.0.18+
     $PluginLocaleSources = Gdn_FileSystem::FindAll(PATH_PLUGINS, CombinePaths(array('locale', $LocaleName . '.custom.php')), $EnabledPlugins);
     if ($PluginLocaleSources !== False) {
         $LocaleSources = array_merge($LocaleSources, $PluginLocaleSources);
     }
     // Get theme-based locale special definition files.
     $Theme = Gdn::Config('Garden.Theme');
     if ($Theme) {
         // 2.0.11+, TODO: REMOVE
         $ThemeLocalePath = PATH_THEMES . "/{$Theme}/locale/{$LocaleName}.distinct.php";
         if (file_exists($ThemeLocalePath)) {
             $LocaleSources[] = $ThemeLocalePath;
             if (C('Debug')) {
                 Deprecated("Rename file to {$LocaleName}.custom.php, {$LocaleName}.distinct.php filename");
             }
         }
         // 2.0.18+
         $ThemeLocalePath = PATH_THEMES . "/{$Theme}/locale/{$LocaleName}.distinct.php";
         if (file_exists($ThemeLocalePath)) {
             $LocaleSources[] = $ThemeLocalePath;
         }
     }
     // Get locale-based locale special definition files.
     $EnabledLocales = Gdn::Config('EnabledLocales');
     if (is_array($EnabledLocales)) {
         foreach ($EnabledLocales as $Key => $Locale) {
             if ($Locale != $LocaleName) {
                 continue;
             }
             // Grab all of the files in the locale's folder (subdirectory custom)
             $Paths = glob(PATH_ROOT . "/locales/{$Key}/custom/*.php");
             if (is_array($Paths)) {
                 foreach ($Paths as $Path) {
                     $LocaleSources[] = $Path;
                 }
             }
         }
     }
     $PhpLocaleName = var_export($LocaleName, True);
     $PhpLocaleSources = var_export($LocaleSources, True);
     $PhpArrayCode = "\n\$_[{$PhpLocaleName}] = {$PhpLocaleSources};";
     $CacheFile = PATH_CACHE . '/customtranslation_map.ini';
     if (!file_exists($CacheFile)) {
         $PhpArrayCode = '<?php' . $PhpArrayCode;
     }
     file_put_contents($CacheFile, $PhpArrayCode, FILE_APPEND | LOCK_EX);
 }
Exemple #7
0
 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;
 }
   /**
    * 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))
         $LocaleSources = array();

      $ConfLocaleOverride = PATH_LOCAL_CONF . DS . 'locale.php';
      $Count = count($LocaleSources);
      for($i = 0; $i < $Count; ++$i) {
         if ($ConfLocaleOverride != $LocaleSources[$i] && file_exists($LocaleSources[$i])) // Don't double include the conf override file... and make sure it comes last
            include($LocaleSources[$i]);
      }

      // Also load any custom defined definitions from the conf directory
      if (file_exists($ConfLocaleOverride))
         include($ConfLocaleOverride);

      // All of the included files should have contained
      // $Definition['Code'] = 'Definition'; assignments. The overwrote each
      // other in the order they were included. Now assign the $Definition array
      // to the local private _Definition property.
      $this->_Definition = $Definition;
   }