예제 #1
0
 /**
  * Инициализация конфига
  * @param string $name имя шаблона, если указано - возвращается список всех
  * переменных
  * @param string $var необходимая переменная
  * @return string|array родительский шаблон или список всех переменных
  */
 public function init_cfg($name = null, $var = 'style_parent')
 {
     $f = 'main.conf';
     $var = $var ? $var : null;
     if ($name) {
         $tpldir = ROOT . THEMES_PATH . '/' . $name;
         if (!class_exists('Config_File', false)) {
             include_once SMARTY_DIR . 'Config_File.class.php';
         }
         $cfg = new Config_File($tpldir);
         $cfg->load_file($f);
         $vars = $cfg->get($f, null, $var);
         unset($cfg);
         // Destruct f*cking class
         return $vars;
     }
     if (!$this->conf_inited) {
         $this->config_load($f);
         $this->conf_inited = true;
     }
     return $this->get_config_vars($var);
 }
예제 #2
0
 /**
  * Formats the output and saved it to disk.
  *
  * @param   $contents  $contents    config array to save
  * @return  bool       \File::update result
  */
 public function save($contents)
 {
     // store the current filename
     $file = $this->file;
     // save it
     $return = parent::save($contents);
     // existing file? saved? and do we need to flush the opcode cache?
     if ($file == $this->file and $return and static::$flush_needed) {
         if ($this->file[0] !== '/' and (!isset($this->file[1]) or $this->file[1] !== ':')) {
             // locate the file
             $file = \Finder::search('config', $this->file, $this->ext);
         }
         // make sure we have a fallback
         $file or $file = APPPATH . 'config' . DS . $this->file . $this->ext;
         // flush the opcode caches that are active
         static::$uses_opcache and opcache_invalidate($file, true);
         static::$uses_apc and apc_compile_file($file);
     }
     return $return;
 }
예제 #3
0
function getErrorMessage($key)
{
    global $smarty, $config;
    include_once $config['smartyBase'] . 'Config_File.class.php';
    $path = $config['skinBase'] . $config['skin'] . '/' . $config['language'];
    $file = 'edit_thesaurus.conf';
    $cf = new Config_File($path);
    $message = $cf->get($file, null, $key);
    if (!$message) {
        $message = "[[{$key}]]";
    }
    return $message;
}
예제 #4
0
<?php

require "../config.inc.php";
require $config['smartydir'] . '/Smarty.class.php';
require $config['smartydir'] . '/Config_File.class.php';
header("Content-Type: text/plain");
$lang = $_GET['lang'];
if (!$lang) {
    die("lang missing");
}
$config_dir = $config['basedir'] . "/code/configs";
$engFile = $config_dir . "/eng.conf";
$newFile = $config_dir . "/{$lang}.conf";
if (is_file($newFile)) {
    $langConf = new Config_File($config_dir);
    $langConf->load_file($newFile, false);
    rename($newFile, "{$newFile}.old") || die("could not make backup");
}
$eng = file($engFile);
$out = fopen($newFile, "wb");
if (!$out) {
    die("could not write into: {$newFile}");
}
$section = NULL;
foreach ($eng as $line) {
    if (preg_match('/"{3}/', $line)) {
        die('please do not use multiline (""")');
    } elseif (preg_match('/^([^=]+)=\\s*(.*)/', $line, $m)) {
        $key = trim($m[1]);
        $val = trim($m[2]);
        //print("$section: $key = $val\n");
예제 #5
0
파일: Dir.php 프로젝트: jasny/Q
 /**
  * Load all settings (eager load).
  * (fluent interface)
  * 
  * @return Config_Dir
  */
 protected function loadAll()
 {
     if (!isset($this->_path) || !$this->_path instanceof Fs_Dir) {
         throw new Exception("Unable to create Config object: Path not specified or not instance of Fs_Dir");
     }
     $options = array();
     if ($this->_transformer) {
         $options['transformer'] = $this->_transformer;
     }
     if ($this->_ext) {
         $options['ext'] = $this->_ext;
     }
     $options['loadall'] = true;
     foreach ($this->_path as $key => $file) {
         if ($file instanceof Fs_Dir) {
             if (!isset($this[$file->filename()])) {
                 parent::offsetSet($file->filename(), new Config_Dir($file, $options));
             }
         } elseif ($file instanceof Fs_File) {
             if (isset($this->_ext) && substr($file, -strlen($this->_ext)) != $this->_ext) {
                 continue;
             }
             if (!isset($this[$file->filename()])) {
                 parent::offsetSet($file->filename(), new Config_File($file, $options));
             }
         }
     }
     return $this;
 }