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


PHP Gdn_Format::ArrayValueForPhp方法代码示例

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


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

示例1: FormatArrayAssignment

 function FormatArrayAssignment(&$Array, $Prefix, $Value)
 {
     if (is_array($Value)) {
         // If $Value doesn't contain a key of "0" OR it does and it's value IS
         // an array, this should be treated as an associative array.
         $IsAssociativeArray = array_key_exists(0, $Value) === FALSE || is_array($Value[0]) === TRUE ? TRUE : FALSE;
         if ($IsAssociativeArray === TRUE) {
             foreach ($Value as $k => $v) {
                 FormatArrayAssignment($Array, $Prefix . "['{$k}']", $v);
             }
         } else {
             // If $Value is not an associative array, just write it like a simple array definition.
             $FormattedValue = array_map(array('Gdn_Format', 'ArrayValueForPhp'), $Value);
             $Array[] = $Prefix .= " = array('" . implode("', '", $FormattedValue) . "');";
         }
     } elseif (is_int($Value)) {
         $Array[] = $Prefix .= ' = ' . $Value . ';';
     } elseif (is_bool($Value)) {
         $Array[] = $Prefix .= ' = ' . ($Value ? 'TRUE' : 'FALSE') . ';';
     } elseif (in_array($Value, array('TRUE', 'FALSE'))) {
         $Array[] = $Prefix .= ' = ' . ($Value == 'TRUE' ? 'TRUE' : 'FALSE') . ';';
     } else {
         if (strpos($Value, "'") !== FALSE) {
             $Array[] = $Prefix .= ' = "' . Gdn_Format::ArrayValueForPhp(str_replace('"', '\\"', $Value)) . '";';
         } else {
             $Array[] = $Prefix .= " = '" . Gdn_Format::ArrayValueForPhp($Value) . "';";
         }
     }
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:29,代码来源:functions.general.php

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

示例3: 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_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;
 }
开发者ID:sheldon,项目名称:Garden,代码行数:80,代码来源:class.locale.php

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


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