• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ConfigFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main_default

function main_default($eventData)
{
    global $gEnv, $gLocale, $gPage_content;
    $jp_cfg = new ConfigFile(CONFIG_PATH . 'jpcache.cfg', true);
    $xml_def = '<vertgroup><name>prefs</name><children>
  <form><name>prefs</name><args><method>post</method><action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'default', ''), array('action', 'setprefs', '')))) . '</action></args><children>
    <grid><name>prefs</name><children>
      <label row="0" col="0"><name>cachetime</name><args><label type="encoded">' . urlencode($gLocale->GetStr('cachetime.label')) . '</label></args></label>
      <string row="0" col="1"><name>cachetime</name><args><disp>action</disp><size>5</size><value>' . $jp_cfg->Value('CACHE_TIME') . '</value></args></string>
      <label row="1" col="0"><name>cacheon</name><args><label type="encoded">' . urlencode($gLocale->GetStr('cacheon.label')) . '</label></args></label>
      <checkbox row="1" col="1"><name>cacheon</name><args><disp>action</disp><checked>' . ($jp_cfg->Value('CACHE_ON') == '1' ? 'true' : 'false') . '</checked></args></checkbox>
      <label row="2" col="0"><name>usegzip</name><args><label type="encoded">' . urlencode($gLocale->GetStr('usegzip.label')) . '</label></args></label>
      <checkbox row="2" col="1"><name>usegzip</name><args><disp>action</disp><checked>' . ($jp_cfg->Value('USE_GZIP') == '1' ? 'true' : 'false') . '</checked></args></checkbox>
      <label row="3" col="0"><name>cachepost</name><args><label type="encoded">' . urlencode($gLocale->GetStr('cachepost.label')) . '</label></args></label>
      <checkbox row="3" col="1"><name>cachepost</name><args><disp>action</disp><checked>' . ($jp_cfg->Value('CACHE_POST') == '1' ? 'true' : 'false') . '</checked></args></checkbox>
    </children></grid>
  </children></form>
  <horizbar><name>hb</name></horizbar>
  <button><name>submit</name>
    <args>
      <label type="encoded">' . urlencode($gLocale->GetStr('setprefs.submit')) . '</label>
      <themeimage>button_ok</themeimage>
      <horiz>true</horiz>
      <frame>true</frame>
      <formsubmit>prefs</formsubmit>
      <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'default', ''), array('action', 'setprefs', '')))) . '</action>
    </args>
  </button>
</children></vertgroup>';
    $gPage_content = new HuiXml('page', array('definition' => $xml_def));
}
开发者ID:alexpagnoni,项目名称:jpcache,代码行数:31,代码来源:jpcache.php


示例2: fillDbLayers

 public function fillDbLayers()
 {
     global $dbtypes;
     $dbtypes = array();
     $dbcfgfile = new ConfigFile(CONFIG_PATH . 'dblayers.cfg', TRUE);
     $dbtypes = (array) $dbcfgfile->ValuesArray();
 }
开发者ID:alexpagnoni,项目名称:ampoliros,代码行数:7,代码来源:DBLayerFactory.php


示例3: getValidators

 /**
  * Returns validator list
  *
  * @param ConfigFile $cf Config file instance
  *
  * @return array
  */
 public static function getValidators(ConfigFile $cf)
 {
     static $validators = null;
     if ($validators === null) {
         $validators = $cf->getDbEntry('_validators', array());
         if (!defined('PMA_SETUP')) {
             // not in setup script: load additional validators for user
             // preferences we need original config values not overwritten
             // by user preferences, creating a new PMA_Config instance is a
             // better idea than hacking into its code
             $uvs = $cf->getDbEntry('_userValidators', array());
             foreach ($uvs as $field => $uv_list) {
                 $uv_list = (array) $uv_list;
                 foreach ($uv_list as &$uv) {
                     if (!is_array($uv)) {
                         continue;
                     }
                     for ($i = 1; $i < count($uv); $i++) {
                         if (substr($uv[$i], 0, 6) == 'value:') {
                             $uv[$i] = PMA_arrayRead(substr($uv[$i], 6), $GLOBALS['PMA_Config']->base_settings);
                         }
                     }
                 }
                 $validators[$field] = isset($validators[$field]) ? array_merge((array) $validators[$field], $uv_list) : $uv_list;
             }
         }
     }
     return $validators;
 }
开发者ID:yszar,项目名称:linuxwp,代码行数:36,代码来源:Validator.class.php


示例4: PMA_userprefsPageInit

/**
 * Common initialization for user preferences modification pages
 *
 * @param ConfigFile $cf Config file instance
 *
 * @return void
 */
function PMA_userprefsPageInit(ConfigFile $cf)
{
    $forms_all_keys = PMA_readUserprefsFieldNames($GLOBALS['forms']);
    $cf->resetConfigData();
    // start with a clean instance
    $cf->setAllowedKeys($forms_all_keys);
    $cf->setCfgUpdateReadMapping(array('Server/hide_db' => 'Servers/1/hide_db', 'Server/only_db' => 'Servers/1/only_db'));
    $cf->updateWithGlobalConfig($GLOBALS['cfg']);
}
开发者ID:pmagent2013,项目名称:LonelyDadMeetup,代码行数:16,代码来源:user_preferences.lib.php


示例5: factory

 public static function factory($file, $type='file', $options=0) {
   $config = new ConfigFile();
   
   if (!$result = $config->loadFileType($file, $type, $options)) {
      die("FATAL ERROR: cannot load $type configuration file: " . self::getfileByType($file, $type));
   }
   
   return $config;
 }
开发者ID:JimiSlew,项目名称:kurogo-old,代码行数:9,代码来源:ConfigFile.php


示例6: getConfigVars

 protected function getConfigVars()
 {
     require_once 'ConfigFile.class.php';
     // Load the config
     $configFilePath = $this->argv[1];
     global $configFile;
     $configFile = new ConfigFile($configFilePath);
     $configFile->load();
     $vars = $configFile->getVars();
     return $vars;
 }
开发者ID:jibinam,项目名称:budabot2,代码行数:11,代码来源:BotRunner.php


示例7: factory

 public static function factory($file, $type='file', $options=0) {
   $config = new ConfigFile();
   
   if (!$result = $config->loadFileType($file, $type, $options)) {
       if ($options & ConfigFile::OPTION_DIE_ON_FAILURE) {
         die("FATAL ERROR: cannot load $type configuration file: $file");
       }
   }
   
   return $config;
 }
开发者ID:rezalutions,项目名称:Kurogo-Mobile-Web,代码行数:11,代码来源:ConfigFile.php


示例8: connect

 /**
  * Connects to the DB using the _POST array
  * Also writes a config file upon a successful connect
  */
 function connect()
 {
     $this->connector = new Connector($_POST[FORM_SERVER], $_POST[FORM_USER], $_POST[FORM_PASSWORD], $_POST[FORM_DATABASE]);
     $this->connector->connectDatabase();
     if ($this->connector->success()) {
         $cfg = new ConfigFile(CONFIG_FILE_NAME);
         $cfg->generate();
         return true;
     }
     echo "Couldn't connect to DB";
     return false;
 }
开发者ID:GianlucaScarciolla,项目名称:Duolex,代码行数:16,代码来源:installer.php


示例9: factory

 public static function factory($file, $type='file', $options=0) {
   $config = new ConfigFile();
   if (!($options & self::OPTION_DO_NOT_CREATE)) {
       $options = $options | self::OPTION_CREATE_WITH_DEFAULT;
   }
   
   if (!$result = $config->loadFileType($file, $type, $options)) {
       if ($options & self::OPTION_DO_NOT_CREATE) {
           return false;
       }
      throw new Exception("FATAL ERROR: cannot load $type configuration file: " . self::getfileByType($file, $type));
   }
   
   return $config;
 }
开发者ID:neoroman,项目名称:Kurogo-Mobile-Web,代码行数:15,代码来源:ConfigFile.php


示例10: factory

 public static function factory($file, $type = 'file', $options = 0)
 {
     Kurogo::log(LOG_DEBUG, "Loading config file {$file} of type {$type} with options {$options}", 'config');
     $config = new ConfigFile();
     if (!($options & self::OPTION_DO_NOT_CREATE)) {
         $options = $options | self::OPTION_CREATE_WITH_DEFAULT;
     }
     if (!($result = $config->loadFileType($file, $type, $options))) {
         if ($options & self::OPTION_DO_NOT_CREATE) {
             return false;
         }
         throw new KurogoConfigurationException("FATAL ERROR: cannot load {$type} configuration file: " . self::getfileByType($file, $type));
     }
     return $config;
 }
开发者ID:narenv,项目名称:Kurogo-Mobile-Web,代码行数:15,代码来源:ConfigFile.php


示例11: getInstance

 /**
  * Returns class instance
  *
  * @return ConfigFile
  */
 public static function getInstance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new ConfigFile();
     }
     return self::$_instance;
 }
开发者ID:shishenkov,项目名称:zpanel,代码行数:12,代码来源:ConfigFile.class.php


示例12: testGetConfigArray

 /**
  * Test for ConfigFile::getConfigArray
  *
  * @return void
  * @test
  */
 public function testGetConfigArray()
 {
     $this->object->setPersistKeys(array(self::SIMPLE_KEY_WITH_DEFAULT_VALUE));
     $this->object->set('Array/test', array('x', 'y'));
     $default_value = $this->object->getDefault(self::SIMPLE_KEY_WITH_DEFAULT_VALUE);
     $this->assertEquals(array(self::SIMPLE_KEY_WITH_DEFAULT_VALUE => $default_value, 'Array/test' => array('x', 'y')), $this->object->getConfigArray());
 }
开发者ID:yonh,项目名称:php-mvc,代码行数:13,代码来源:PMA_ConfigFile_test.php


示例13: testGetConfigFile

 /**
  * Test for ConfigGenerator::getConfigFile
  *
  * @return void
  * @group medium
  */
 public function testGetConfigFile()
 {
     $GLOBALS['cfg']['AvailableCharsets'] = array();
     unset($_SESSION['eol']);
     $GLOBALS['PMA_Config'] = new PMA_Config();
     $GLOBALS['server'] = 0;
     $cf = new ConfigFile();
     $_SESSION['ConfigFile0'] = array('a', 'b', 'c');
     $_SESSION['ConfigFile0']['Servers'] = array(array(1, 2, 3));
     $cf->setPersistKeys(array("1/", 2));
     $date = date(DATE_RFC1123);
     $result = ConfigGenerator::getConfigFile($cf);
     $this->assertContains("<?php\n" . "/*\n" . " * Generated configuration file\n" . " * Generated by: phpMyAdmin " . $GLOBALS['PMA_Config']->get('PMA_VERSION') . " setup script\n" . " * Date: " . $date . "\n" . " */\n\n", $result);
     $this->assertContains("/* Servers configuration */\n" . '$i = 0;' . "\n\n" . "/* Server: localhost [0] */\n" . '$i++;' . "\n" . '$cfg[\'Servers\'][$i][\'0\'] = 1;' . "\n" . '$cfg[\'Servers\'][$i][\'1\'] = 2;' . "\n" . '$cfg[\'Servers\'][$i][\'2\'] = 3;' . "\n\n" . "/* End of servers configuration */\n\n", $result);
     $this->assertContains('?>', $result);
 }
开发者ID:kfjihailong,项目名称:phpMyAdmin,代码行数:22,代码来源:PMA_ConfigGenerator_test.php


示例14: init

 /**
  * Initializes the application.
  *
  * Sets the application's root directory, loads the configuration file
  * and initializes the authorization.
  *
  * @param string $rootDir Root directory of this application
  */
 public static function init($rootDir)
 {
     self::$rootDir = $rootDir;
     if (ConfigFile::load()) {
         Security\Authorization::init();
     }
 }
开发者ID:tniessen,项目名称:tinyIt,代码行数:15,代码来源:Application.php


示例15: loadModel

 public function loadModel($id)
 {
     $model = ConfigFile::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('mc', 'The requested page does not exist.'));
     }
     return $model;
 }
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:8,代码来源:ConfigFileController.php


示例16: PMA_config_validate

/**
 * Runs validation $validator_id on values $values and returns error list.
 *
 * Return values:
 * o array, keys - field path or formset id, values - array of errors
 *   when $isPostSource is true values is an empty array to allow for error list
 *   cleanup in HTML documen
 * o false - when no validators match name(s) given by $validator_id
 *
 * @param string|array $validator_id ID of validator(s) to run
 * @param array        $values       Values to validate
 * @param bool         $isPostSource tells whether $values are directly from
 *                                   POST request
 *
 * @return bool|array
 */
function PMA_config_validate($validator_id, &$values, $isPostSource)
{
    // find validators
    $validator_id = (array) $validator_id;
    $validators = PMA_config_get_validators();
    $vids = array();
    $cf = ConfigFile::getInstance();
    foreach ($validator_id as &$vid) {
        $vid = $cf->getCanonicalPath($vid);
        if (isset($validators[$vid])) {
            $vids[] = $vid;
        }
    }
    if (empty($vids)) {
        return false;
    }
    // create argument list with canonical paths and remember path mapping
    $arguments = array();
    $key_map = array();
    foreach ($values as $k => $v) {
        $k2 = $isPostSource ? str_replace('-', '/', $k) : $k;
        $k2 = strpos($k2, '/') ? $cf->getCanonicalPath($k2) : $k2;
        $key_map[$k2] = $k;
        $arguments[$k2] = $v;
    }
    // validate
    $result = array();
    foreach ($vids as $vid) {
        // call appropriate validation functions
        foreach ((array) $validators[$vid] as $validator) {
            $vdef = (array) $validator;
            $vname = array_shift($vdef);
            $args = array_merge(array($vid, &$arguments), $vdef);
            $r = call_user_func_array($vname, $args);
            // merge results
            if (is_array($r)) {
                foreach ($r as $key => $error_list) {
                    // skip empty values if $isPostSource is false
                    if (!$isPostSource && empty($error_list)) {
                        continue;
                    }
                    if (!isset($result[$key])) {
                        $result[$key] = array();
                    }
                    $result[$key] = array_merge($result[$key], (array) $error_list);
                }
            }
        }
    }
    // restore original paths
    $new_result = array();
    foreach ($result as $k => $v) {
        $k2 = isset($key_map[$k]) ? $key_map[$k] : $k;
        $new_result[$k2] = $v;
    }
    return empty($new_result) ? true : $new_result;
}
开发者ID:rizwanaabbas,项目名称:phpmyadmin,代码行数:73,代码来源:validate.lib.php


示例17: get_config

/**
 * Returns config file contents depending on GET type value:
 * o session - uses ConfigFile::getConfigFile()
 * o post - uses POST textconfig value
 *
 * @return string
 */
function get_config()
{
    $type = PMA_ifSetOr($_GET['type'], 'session');
    if ($type == 'session') {
        $config = ConfigFile::getInstance()->getConfigFile();
    } else {
        $config = PMA_ifSetOr($_POST['textconfig'], '');
        // make sure our eol is \n
        $config = str_replace("\r\n", "\n", $config);
        if ($_SESSION['eol'] == 'win') {
            $config = str_replace("\n", "\r\n", $config);
        }
    }
    return $config;
}
开发者ID:alecbenson,项目名称:TurnoutWeb-Patches,代码行数:22,代码来源:config.php


示例18: test_apply

 function test_apply()
 {
     $htaccess = new ConfigFile('testhtaccess');
     $htaccess->param('RewriteBase', 'RewriteBase /xxx/yyy/');
     $resultat = $htaccess->apply($this->HtaccessDist);
     $this->assertEqual($resultat, $this->HtaccessWithBase);
     $resultat = $htaccess->apply($resultat);
     //apply twice
     $this->assertEqual($resultat, $this->HtaccessWithBase);
     $htaccess->param('RewriteRule ^x/$', 'RewriteRule ^x/$  /yyyyyyy [L]');
     $resultat = $htaccess->apply($this->HtaccessDist);
     $this->assertEqual($resultat, $this->HtaccessNewRule);
 }
开发者ID:slim,项目名称:phtpasswd,代码行数:13,代码来源:test_configfile.php


示例19: __construct

  function __construct() {
    // Load main configuration file
    $config = ConfigFile::factory('kurogo', 'project', ConfigFile::OPTION_IGNORE_MODE | ConfigFile::OPTION_IGNORE_LOCAL);
    $this->addConfig($config);

    define('CONFIG_MODE', $config->getVar('CONFIG_MODE'));
    define('CONFIG_IGNORE_LOCAL', $config->getVar('CONFIG_IGNORE_LOCAL'));

    //make sure active site is set    
    if (!$site = $this->getVar('ACTIVE_SITE')) {
        die("FATAL ERROR: ACTIVE_SITE not set");
    }
    
    //make sure site_dir is set and is a valid path
    if (!($siteDir = $this->getVar('SITE_DIR')) || !($siteDir = realpath_exists($siteDir))) {
        die("FATAL ERROR: Site Directory ". $this->getVar('SITE_DIR') . " not found for site " . $site);
    }
    
    // Set up defines relative to SITE_DIR
    define('SITE_DIR',             $siteDir);
    define('SITE_KEY',             md5($siteDir));
    define('SITE_LIB_DIR',         SITE_DIR.'/lib');
    define('SITE_APP_DIR',         SITE_DIR.'/app');
    define('SITE_MODULES_DIR',     SITE_DIR.'/app/modules');
    define('DATA_DIR',             SITE_DIR.'/data');
    define('CACHE_DIR',            SITE_DIR.'/cache');
    define('LOG_DIR',              SITE_DIR.'/logs');
    define('SITE_CONFIG_DIR',      SITE_DIR.'/config');

    //load in the site config file (required);
    $config = ConfigFile::factory('site', 'site');
    $this->addConfig($config);

    // Set up theme define
    if (!$theme = $this->getVar('ACTIVE_THEME')) {
        die("FATAL ERROR: ACTIVE_THEME not set");
    }
    
    define('THEME_DIR', SITE_DIR.'/themes/'.$theme);
  }
开发者ID:neoroman,项目名称:Kurogo-Mobile-Web,代码行数:40,代码来源:SiteConfig.php


示例20: initializeForPage


//.........这里部分代码省略.........
                    $item[] = array(
                        'label'=>'Title',
                        'type'=>'text',
                        'name'=>"pageData[$page][pageTitle]",
                        'typename'=>"pageData][$page][pageTitle",
                        'value'=>isset($_pageData['pageTitle']) ? $_pageData['pageTitle'] : ''
                    );
                    $item[] = array(
                        'label'=>'Breadcrumb Title',
                        'type'=>'text',
                        'name'=>"pageData[$page][breadcrumbTitle]",
                        'typename'=>"pageData][$page][breadcrumbTitle",
                        'value'=>isset($_pageData['breadcrumbTitle']) ? $_pageData['breadcrumbTitle'] : ''
                    );
                    $item[] = array(
                        'label'=>'Breadcrumb Long Title',
                        'type'=>'text',
                        'name'=>"pageData[$page][breadcrumbLongTitle]",
                        'typename'=>"pageData][$page][breadcrumbLongTitle",
                        'value'=>isset($_pageData['breadcrumbLongTitle']) ? $_pageData['breadcrumbLongTitle'] : ''
                    );
                    $pages[$page] = $item;
                }
                
                $_module = array(
                    'id'=>$moduleID
                );

                $this->assign('pages'        , $pages);
                $this->assign('module'       , $_module);

                break;
            case 'strings':
                $configFile = ConfigFile::factory('strings', 'site', ConfigFile::OPTION_CREATE_WITH_DEFAULT | ConfigFile::OPTION_IGNORE_LOCAL);

                if ($this->getArg('submit')) {
                    $strings = $this->prepareSubmitData('strings');
                    $configFile->addSectionVars($strings, false);
                    $configFile->saveFile();
                    $this->redirectTo('index', false, false);
                } 

                $strings = $configFile->getSectionVars(true);
                $formListItems = array();
                foreach ($strings as $key=>$value) {
                    if (is_scalar($value)) {
                        $formListItems[] = array(
                        'label'=>implode(" ", array_map("ucfirst", explode("_", strtolower($key)))),
                        'name'=>"strings[$key]",
                        'typename'=>"strings][$key",
                        'value'=>$value,
                        'type'=>'text'
                        );
                    } else {
                        $formListItems[] = array(
                        'label'=>implode(" ", array_map("ucfirst", explode("_", strtolower($key)))),
                        'name'=>"strings[$key]",
                        'typename'=>"strings][$key",
                        'value'=>implode("\n\n", $value),
                        'type'=>'paragraph'
                        );
                    }
                }

                $this->assign('localFile'    , $configFile->localFile());
                $this->assign('strings', $strings);
开发者ID:nicosiseng,项目名称:Kurogo-Mobile-Web,代码行数:67,代码来源:AdminWebModule.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ConfigHelper类代码示例发布时间:2022-05-20
下一篇:
PHP ConfigFactory类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap