Use INI instead of YML

This commit is contained in:
Ivan Lanin 2014-05-16 14:44:56 +07:00
parent f380c29eef
commit 048436cd04
10 changed files with 33 additions and 1224 deletions

2
.gitignore vendored
View File

@ -6,7 +6,7 @@ Thumbs.db
Desktop.ini
composer.phar
phpunit.xml
phpword.yml
phpword.ini
/.buildpath
/.idea
/.project

View File

@ -1,5 +1,5 @@
filter:
excluded_paths: [ 'vendor/*', 'tests/*', 'samples/*', 'src/PhpWord/Shared/PCLZip/*', 'src/PhpWord/Shared/Spyc/*' ]
excluded_paths: [ 'vendor/*', 'tests/*', 'samples/*', 'src/PhpWord/Shared/PCLZip/*' ]
before_commands:
- "composer install --prefer-source --dev"

View File

@ -44,11 +44,11 @@ before_script:
script:
## PHP_CodeSniffer
- ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip --ignore=src/PhpWord/Shared/Spyc
- ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
## PHP Copy/Paste Detector
- php phpcpd.phar src/ tests/ --verbose
## PHP Mess Detector
- phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php,Spyc.php
- phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
## PHPLOC
#- php phploc.phar src/
## PHPUnit

14
phpword.ini.dist Normal file
View File

@ -0,0 +1,14 @@
; Default config file for PHPWord
; Copy this file into phpword.ini and use Settings::loadConfig to load
[General]
compatibility = true
zipClass = ZipArchive
pdfRendererName = DomPDF
pdfRendererPath =
[Font]
defaultFontName = Arial
defaultFontSize = 10

View File

@ -1,9 +0,0 @@
# Default config file for PHPWord
# Copy and this file into phpword.yml and use Settings::loadConfig to load
compatibility: true
zipClass: ZipArchive
pdfRendererName: DomPDF
pdfRendererPath:
defaultFontName: "Arial"
defaultFontSize: 10

View File

@ -132,16 +132,14 @@ class Settings
* This sets the setIndent and setIndentString for better compatibility
*
* @param bool $compatibility
* @return bool
* @return true
*/
public static function setCompatibility($compatibility)
{
if (is_bool($compatibility)) {
self::$xmlWriterCompatibility = $compatibility;
return true;
}
$compatibility = (bool)$compatibility;
self::$xmlWriterCompatibility = $compatibility;
return false;
return true;
}
/**
@ -328,7 +326,11 @@ class Settings
// Get config file
$configFile = null;
$configPath = __DIR__ . '/../../';
$files = array($filename, "{$configPath}phpword.yml", "{$configPath}phpword.yml.dist");
if ($filename !== null) {
$files = array($filename);
} else {
$files = array("{$configPath}phpword.ini", "{$configPath}phpword.ini.dist");
}
foreach ($files as $file) {
if (file_exists($file)) {
$configFile = realpath($file);
@ -336,12 +338,13 @@ class Settings
}
}
// Use Spyc to load config file
// Parse config file
$config = array();
$spycLibrary = realpath(__DIR__ . '/Shared/Spyc/Spyc.php');
if (file_exists($spycLibrary) && $configFile !== null) {
require_once $spycLibrary;
$config = spyc_load_file($configFile);
if ($configFile !== null) {
$config = parse_ini_file($configFile);
if ($config === false) {
return $config;
}
}
// Set config value

View File

@ -1,21 +0,0 @@
The MIT License
Copyright (c) 2011 Vladimir Andersen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,30 +0,0 @@
**Spyc** is a YAML loader/dumper written in pure PHP. Given a YAML document, Spyc will return an array that
you can use however you see fit. Given an array, Spyc will return a string which contains a YAML document
built from your data.
**YAML** is an amazingly human friendly and strikingly versatile data serialization language which can be used
for log files, config files, custom protocols, the works. For more information, see http://www.yaml.org.
Spyc supports YAML 1.0 specification.
## Using Spyc
Using Spyc is trivial:
```
<?php
require_once "spyc.php";
$Data = Spyc::YAMLLoad('spyc.yaml');
```
or (if you prefer functional syntax)
```
<?php
require_once "spyc.php";
$Data = spyc_load_file('spyc.yaml');
```
## Donations, anyone?
If you find Spyc useful, I'm accepting Bitcoin donations (who doesn't these days?) at 193bEkLP7zMrNLZm9UdUet4puGD5mQiLai

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,6 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(Settings::hasCompatibility());
$this->assertTrue(Settings::setCompatibility(false));
$this->assertFalse(Settings::hasCompatibility());
$this->assertFalse(Settings::setCompatibility('Non boolean'));
}
/**