Use INI instead of YML
This commit is contained in:
parent
f380c29eef
commit
048436cd04
|
|
@ -6,7 +6,7 @@ Thumbs.db
|
||||||
Desktop.ini
|
Desktop.ini
|
||||||
composer.phar
|
composer.phar
|
||||||
phpunit.xml
|
phpunit.xml
|
||||||
phpword.yml
|
phpword.ini
|
||||||
/.buildpath
|
/.buildpath
|
||||||
/.idea
|
/.idea
|
||||||
/.project
|
/.project
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
filter:
|
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:
|
before_commands:
|
||||||
- "composer install --prefer-source --dev"
|
- "composer install --prefer-source --dev"
|
||||||
|
|
|
||||||
|
|
@ -44,11 +44,11 @@ before_script:
|
||||||
|
|
||||||
script:
|
script:
|
||||||
## PHP_CodeSniffer
|
## 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 Copy/Paste Detector
|
||||||
- php phpcpd.phar src/ tests/ --verbose
|
- php phpcpd.phar src/ tests/ --verbose
|
||||||
## PHP Mess Detector
|
## 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
|
## PHPLOC
|
||||||
#- php phploc.phar src/
|
#- php phploc.phar src/
|
||||||
## PHPUnit
|
## PHPUnit
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -132,16 +132,14 @@ class Settings
|
||||||
* This sets the setIndent and setIndentString for better compatibility
|
* This sets the setIndent and setIndentString for better compatibility
|
||||||
*
|
*
|
||||||
* @param bool $compatibility
|
* @param bool $compatibility
|
||||||
* @return bool
|
* @return true
|
||||||
*/
|
*/
|
||||||
public static function setCompatibility($compatibility)
|
public static function setCompatibility($compatibility)
|
||||||
{
|
{
|
||||||
if (is_bool($compatibility)) {
|
$compatibility = (bool)$compatibility;
|
||||||
self::$xmlWriterCompatibility = $compatibility;
|
self::$xmlWriterCompatibility = $compatibility;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -328,7 +326,11 @@ class Settings
|
||||||
// Get config file
|
// Get config file
|
||||||
$configFile = null;
|
$configFile = null;
|
||||||
$configPath = __DIR__ . '/../../';
|
$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) {
|
foreach ($files as $file) {
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
$configFile = realpath($file);
|
$configFile = realpath($file);
|
||||||
|
|
@ -336,12 +338,13 @@ class Settings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use Spyc to load config file
|
// Parse config file
|
||||||
$config = array();
|
$config = array();
|
||||||
$spycLibrary = realpath(__DIR__ . '/Shared/Spyc/Spyc.php');
|
if ($configFile !== null) {
|
||||||
if (file_exists($spycLibrary) && $configFile !== null) {
|
$config = parse_ini_file($configFile);
|
||||||
require_once $spycLibrary;
|
if ($config === false) {
|
||||||
$config = spyc_load_file($configFile);
|
return $config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set config value
|
// Set config value
|
||||||
|
|
|
||||||
|
|
@ -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.
|
|
||||||
|
|
@ -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
|
|
@ -34,7 +34,6 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertTrue(Settings::hasCompatibility());
|
$this->assertTrue(Settings::hasCompatibility());
|
||||||
$this->assertTrue(Settings::setCompatibility(false));
|
$this->assertTrue(Settings::setCompatibility(false));
|
||||||
$this->assertFalse(Settings::hasCompatibility());
|
$this->assertFalse(Settings::hasCompatibility());
|
||||||
$this->assertFalse(Settings::setCompatibility('Non boolean'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue