public function test3D()
 {
     $settings = array('3D' => array('Decimal' => array(42, 0), 'Array' => array('Decimal' => array('a' => 42, 'b' => 0), 'Mixed' => array('b' => false, 2 => "Derick \"Tiger\" Rethans"))));
     $comments = array('3D' => array('Decimal' => array(" One with a comment", " Second one with a comment"), 'Array' => array('Mixed' => array(2 => " One with a comment"))));
     $test = new ezcConfiguration($settings, $comments);
     $backend = new ezcConfigurationIniWriter($this->tempDir . '/multi-dim2.ini', $test);
     $backend->save();
     $backend = new ezcConfigurationIniReader($this->tempDir . '/multi-dim2.ini');
     $return = $backend->load();
     $this->assertEquals($test, $return);
 }
 *
 * @package Configuration
 * @subpackage Examples
 */
require 'autoload.php';
// A small example which reads an INI file and reads out some settings
// It uses the array reader/writer to cache the INI file.
//
// If something goes wrong (file reading or setting access) it will catch
// the exception and show the problem.
try {
    $ini = new ezcConfigurationArrayReader(dirname(__FILE__) . '/settings.php');
    if (!$ini->configExists()) {
        print "Cache does not exist, generating\n";
        // Cache is not present so we read the original file
        $ini = new ezcConfigurationIniReader(dirname(__FILE__) . '/settings.ini');
        $conf = $ini->load();
        // Write back the cache
        $cache = new ezcConfigurationArrayWriter(dirname(__FILE__) . '/settings.php', $conf);
        $cache->save();
    } else {
        print "Reading from cache\n";
        $conf = $ini->load();
    }
    $title = $conf->getSetting('site', 'title');
    print "Title is {$title}\n";
} catch (Exception $e) {
    print "Caught exception while reading INI file\n";
    print $e->getMessage() . "(" . $e->getCode() . ")\n";
    print $e->getTraceAsString() . "\n";
}
Ejemplo n.º 3
0
 public function testQuoteInHashKey()
 {
     $path = 'Configuration/tests/files/bug15309.ini';
     $backend = new ezcConfigurationIniReader($path);
     $return = $backend->load();
     $this->assertEquals(array("CÔTE D'IVOIRE" => 'Wybrzeże Kości Słoniowej'), $return->getSetting('TestSettings', "Countries"));
 }
<?php

require_once 'tutorial_autoload.php';
$reader = new ezcConfigurationIniReader();
$reader->init(dirname(__FILE__), 'settings');
// validate the settings file, and loop over all the validation errors and
// warnings
$result = $reader->validate();
foreach ($result->getResultList() as $resultItem) {
    print $resultItem->file . ":" . $resultItem->line . ":" . $resultItem->column . ":";
    print " " . $resultItem->details . "\n";
}
// load the settings into an ezcConfiguration object
$cfg = $reader->load();
Ejemplo n.º 5
0
<?php
/**
 * WebChecker config php file
 * Created on January, the 12th 2010 at 21:26:14 by ronan
 *
 * @copyright Copyright (C) 2011 Ronan Guilloux. All rights reserved.
 * @license http://www.gnu.org/licenses/agpl.html GNU AFFERO GPL v3
 * @version //autogen//
 * @author Ronan Guilloux - coolforest.net
 * @package WebChecker
 * @filesource config.php
 */

// SPL autoloading for Zeta components
// see http://incubator.apache.org/zetacomponents/documentation/install.html
require_once 'src/zetacomponents/Base/base.php';
spl_autoload_register( array( 'ezcBase', 'autoload' ) );

// Zeta components autoloading for the all rest :
$options = new ezcBaseAutoloadOptions( array( 'debug' => false, 'preload' => true ) );
ezcBase::setOptions( $options );
ezcBase::addClassRepository( dirname( __FILE__ ) . '/src/checker', null, 'chk' );
// here you can add your own libs using addClassRepository()

// App. settings
$reader = new ezcConfigurationIniReader();
$reader->init( dirname( __FILE__ ), 'settings' ); 
$ini = $reader->load();

?>
 public function testBug7855()
 {
     $path = 'Configuration/tests/files/bug7855.ini';
     $backend = new ezcConfigurationIniReader($path);
     $return = $backend->load();
     $settings = array('TestSettings' => array('SettingA' => 1, 'SettingB' => 2));
     $comments = array('TestSettings' => array('SettingB' => " This setting has no new line behind it - make sure it stays like this in this\n test file"));
     $expected = new ezcConfiguration($settings, $comments);
     $this->assertEquals($expected, $return);
 }