删除vendor
parent
f251d4d1da
commit
b0f4481eb1
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit4b3d592472598a8d8206a9f170e9bb91::getLoader();
|
@ -1,445 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see http://www.php-fig.org/psr/psr-0/
|
||||
* @see http://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
// PSR-4
|
||||
private $prefixLengthsPsr4 = array();
|
||||
private $prefixDirsPsr4 = array();
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
private $prefixesPsr0 = array();
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
private $useIncludePath = false;
|
||||
private $classMap = array();
|
||||
private $classMapAuthoritative = false;
|
||||
private $missingClasses = array();
|
||||
private $apcuPrefix;
|
||||
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classMap Class to filename map
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off searching the prefix and fallback directories for classes
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should class lookup fail if not found in the current class map?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClassMapAuthoritative()
|
||||
{
|
||||
return $this->classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApcuPrefix()
|
||||
{
|
||||
return $this->apcuPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return bool|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||
return false;
|
||||
}
|
||||
if (null !== $this->apcuPrefix) {
|
||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||
if ($hit) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if (false === $file && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if (null !== $this->apcuPrefix) {
|
||||
apcu_add($this->apcuPrefix.$class, $file);
|
||||
}
|
||||
|
||||
if (false === $file) {
|
||||
// Remember that this class does not exist.
|
||||
$this->missingClasses[$class] = true;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
$subPath = $class;
|
||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||
$subPath = substr($subPath, 0, $lastPos);
|
||||
$search = $subPath . '\\';
|
||||
if (isset($this->prefixDirsPsr4[$search])) {
|
||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||
if (file_exists($file = $dir . $pathEnd)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
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,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'CFPropertyList' => array($vendorDir . '/rodneyrehm/plist/classes'),
|
||||
);
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
|
||||
'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
|
||||
'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
|
||||
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
|
||||
);
|
@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit4b3d592472598a8d8206a9f170e9bb91
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4b3d592472598a8d8206a9f170e9bb91', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4b3d592472598a8d8206a9f170e9bb91', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require_once __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit4b3d592472598a8d8206a9f170e9bb91::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit4b3d592472598a8d8206a9f170e9bb91::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire4b3d592472598a8d8206a9f170e9bb91($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire4b3d592472598a8d8206a9f170e9bb91($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit4b3d592472598a8d8206a9f170e9bb91
|
||||
{
|
||||
public static $files = array (
|
||||
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
|
||||
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
|
||||
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
|
||||
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
|
||||
);
|
||||
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'P' =>
|
||||
array (
|
||||
'Psr\\Http\\Message\\' => 17,
|
||||
),
|
||||
'G' =>
|
||||
array (
|
||||
'GuzzleHttp\\Psr7\\' => 16,
|
||||
'GuzzleHttp\\Promise\\' => 19,
|
||||
'GuzzleHttp\\' => 11,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'Psr\\Http\\Message\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/http-message/src',
|
||||
),
|
||||
'GuzzleHttp\\Psr7\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
|
||||
),
|
||||
'GuzzleHttp\\Promise\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/guzzlehttp/promises/src',
|
||||
),
|
||||
'GuzzleHttp\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixesPsr0 = array (
|
||||
'C' =>
|
||||
array (
|
||||
'CFPropertyList' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/rodneyrehm/plist/classes',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4b3d592472598a8d8206a9f170e9bb91::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4b3d592472598a8d8206a9f170e9bb91::$prefixDirsPsr4;
|
||||
$loader->prefixesPsr0 = ComposerStaticInit4b3d592472598a8d8206a9f170e9bb91::$prefixesPsr0;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
@ -1,336 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "6.4.1",
|
||||
"version_normalized": "6.4.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/guzzle.git",
|
||||
"reference": "0895c932405407fd3a7368b6910c09a24d26db11"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/0895c932405407fd3a7368b6910c09a24d26db11",
|
||||
"reference": "0895c932405407fd3a7368b6910c09a24d26db11",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"guzzlehttp/promises": "^1.0",
|
||||
"guzzlehttp/psr7": "^1.6.1",
|
||||
"php": ">=5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-curl": "*",
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
|
||||
"psr/log": "^1.1"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/log": "Required for using the Log middleware"
|
||||
},
|
||||
"time": "2019-10-23T15:58:00+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "6.3-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
}
|
||||
],
|
||||
"description": "Guzzle is a PHP HTTP client library",
|
||||
"homepage": "http://guzzlephp.org/",
|
||||
"keywords": [
|
||||
"client",
|
||||
"curl",
|
||||
"framework",
|
||||
"http",
|
||||
"http client",
|
||||
"rest",
|
||||
"web service"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/promises",
|
||||
"version": "v1.3.1",
|
||||
"version_normalized": "1.3.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/promises.git",
|
||||
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
|
||||
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.0"
|
||||
},
|
||||
"time": "2016-12-20T10:07:11+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\Promise\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
}
|
||||
],
|
||||
"description": "Guzzle promises library",
|
||||
"keywords": [
|
||||
"promise"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
"version": "1.6.1",
|
||||
"version_normalized": "1.6.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/psr7.git",
|
||||
"reference": "239400de7a173fe9901b9ac7c06497751f00727a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a",
|
||||
"reference": "239400de7a173fe9901b9ac7c06497751f00727a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"psr/http-message": "~1.0",
|
||||
"ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/http-message-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-zlib": "*",
|
||||
"phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8"
|
||||
},
|
||||
"suggest": {
|
||||
"zendframework/zend-httphandlerrunner": "Emit PSR-7 responses"
|
||||
},
|
||||
"time": "2019-07-01T23:21:34+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.6-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\Psr7\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
},
|
||||
{
|
||||
"name": "Tobias Schultze",
|
||||
"homepage": "https://github.com/Tobion"
|
||||
}
|
||||
],
|
||||
"description": "PSR-7 message implementation that also provides common utility methods",
|
||||
"keywords": [
|
||||
"http",
|
||||
"message",
|
||||
"psr-7",
|
||||
"request",
|
||||
"response",
|
||||
"stream",
|
||||
"uri",
|
||||
"url"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "psr/http-message",
|
||||
"version": "1.0.1",
|
||||
"version_normalized": "1.0.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-message.git",
|
||||
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
|
||||
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"time": "2016-08-06T14:39:51+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Http\\Message\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for HTTP messages",
|
||||
"homepage": "https://github.com/php-fig/http-message",
|
||||
"keywords": [
|
||||
"http",
|
||||
"http-message",
|
||||
"psr",
|
||||
"psr-7",
|
||||
"request",
|
||||
"response"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ralouphie/getallheaders",
|
||||
"version": "3.0.3",
|
||||
"version_normalized": "3.0.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ralouphie/getallheaders.git",
|
||||
"reference": "120b605dfeb996808c31b6477290a714d356e822"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
|
||||
"reference": "120b605dfeb996808c31b6477290a714d356e822",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-coveralls/php-coveralls": "^2.1",
|
||||
"phpunit/phpunit": "^5 || ^6.5"
|
||||
},
|
||||
"time": "2019-03-08T08:55:37+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/getallheaders.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ralph Khattar",
|
||||
"email": "ralph.khattar@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "A polyfill for getallheaders."
|
||||
},
|
||||
{
|
||||
"name": "rodneyrehm/plist",
|
||||
"version": "v2.0.1",
|
||||
"version_normalized": "2.0.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rodneyrehm/CFPropertyList.git",
|
||||
"reference": "2ea0483806c989eb0518a767fa29a111bb29cb67"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rodneyrehm/CFPropertyList/zipball/2ea0483806c989eb0518a767fa29a111bb29cb67",
|
||||
"reference": "2ea0483806c989eb0518a767fa29a111bb29cb67",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"time": "2015-01-28T23:18:19+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"CFPropertyList": "classes/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Christian Kruse",
|
||||
"email": "cjk@wwwtech.de"
|
||||
},
|
||||
{
|
||||
"name": "Rodney Rehm",
|
||||
"email": "mail+github@rodneyrehm.de"
|
||||
}
|
||||
],
|
||||
"description": "Library for reading and writing Apple's CFPropertyList (plist) files in XML as well as binary format.",
|
||||
"homepage": "https://github.com/rodneyrehm/CFPropertyList",
|
||||
"keywords": [
|
||||
"plist"
|
||||
]
|
||||
}
|
||||
]
|
@ -1,7 +0,0 @@
|
||||
docs
|
||||
*tmp
|
||||
composer.lock
|
||||
vendor
|
||||
.foundation
|
||||
Makefile
|
||||
.DS_Store
|
@ -1,22 +0,0 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2009 Christian Kruse, Rodney Rehm
|
||||
|
||||
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,39 +0,0 @@
|
||||
# CFPropertyList
|
||||
|
||||
The PHP implementation of Apple's PropertyList can handle XML PropertyLists as well as binary PropertyLists. It offers functionality to easily convert data between worlds, e.g. recalculating timestamps from unix epoch to apple epoch and vice versa. A feature to automagically create (guess) the plist structure from a normal PHP data structure will help you dump your data to plist in no time.
|
||||
|
||||
Note: CFPropertylist was originally hosted on [Google Code](http://code.google.com/p/cfpropertylist/)
|
||||
|
||||
## Choose Your Favorite Operating System
|
||||
|
||||
CFPropertyList does not rely on any "Apple proprietary" components, like plutil. CFPropertyList runs on any Operating System with PHP and some standard extensions installed.
|
||||
|
||||
Although you might want to deliver data to your iPhone application, you might want to run those server side services on your standard Linux (or even Windows) environment, rather than buying an expensive Apple Server. With CFPropertyList you now have the power to provide data from your favorite Operating System.
|
||||
|
||||
## Requirements And Limitations
|
||||
|
||||
* requires PHP5.3 (as of CFPropertyList 2.0)
|
||||
* requires either [MBString](http://php.net/mbstring) or [Iconv](http://php.net/iconv)
|
||||
* requires either [BC](http://php.net/bc) or [GMP](http://php.net/gmp) or [phpseclib](http://phpseclib.sourceforge.net/) (see BigIntegerBug for an explanation) - as of CFPropertyList 1.0.1
|
||||
|
||||
## Authors
|
||||
|
||||
- Rodney Rehm <rodney.rehm@medialize.de>
|
||||
- Christian Kruse <cjk@wwwtech.de>
|
||||
- PSR-0 changes by Jarvis Badgley <https://github.com/ChiperSoft/CFPropertyList>
|
||||
|
||||
## License
|
||||
|
||||
CFPropertyList is published under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
|
||||
|
||||
## Installation
|
||||
|
||||
see [Composer / Packagist](http://packagist.org/packages/rodneyrehm/plist).
|
||||
|
||||
## Related
|
||||
|
||||
* [man(5) plist](http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/plist.5.html)
|
||||
* [CFBinaryPList.c](http://www.opensource.apple.com/source/CF/CF-476.15/CFBinaryPList.c)
|
||||
* [CFPropertyList in Ruby](http://rubyforge.org/projects/cfpropertylist/)
|
||||
* [CFPropertyList in Python](https://github.com/bencochran/CFPropertyList)
|
||||
* [plist on Wikipedia](http://en.wikipedia.org/wiki/Plist)
|
@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
/bin/sh /opt/local/share/phpDoc/phpdoc -ed /Users/rrehm/Projekte/plist/examples -d /Users/rrehm/Projekte/plist/classes -ti "CFPropertyList" -t /Users/rrehm/Projekte/plist/docs/ -ue on
|
||||
|
||||
cd /Users/rrehm/Projekte/plist/
|
||||
tar --exclude=".git|*.sh" -czf ../CFPropertyList.tgz .
|
File diff suppressed because it is too large
Load Diff
@ -1,608 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* CFPropertyList
|
||||
* {@link http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/plist.5.html Property Lists}
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @version $Id$
|
||||
* @example example-read-01.php Read an XML PropertyList
|
||||
* @example example-read-02.php Read a Binary PropertyList
|
||||
* @example example-read-03.php Read a PropertyList without knowing the type
|
||||
* @example example-create-01.php Using the CFPropertyList API
|
||||
* @example example-create-02.php Using {@link CFTypeDetector}
|
||||
* @example example-create-03.php Using {@link CFTypeDetector} with {@link CFDate} and {@link CFData}
|
||||
* @example example-modify-01.php Read, modify and save a PropertyList
|
||||
*/
|
||||
|
||||
namespace CFPropertyList;
|
||||
use \Iterator, \DOMDocument, \DOMException, DOMImplementation, DOMNode;
|
||||
|
||||
/**
|
||||
* Require IOException, PListException, CFType and CFBinaryPropertyList
|
||||
*/
|
||||
require_once(__DIR__.'/IOException.php');
|
||||
require_once(__DIR__.'/PListException.php');
|
||||
require_once(__DIR__.'/CFType.php');
|
||||
require_once(__DIR__.'/CFBinaryPropertyList.php');
|
||||
require_once(__DIR__.'/CFTypeDetector.php');
|
||||
|
||||
/**
|
||||
* Property List
|
||||
* Interface for handling reading, editing and saving Property Lists as defined by Apple.
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @example example-read-01.php Read an XML PropertyList
|
||||
* @example example-read-02.php Read a Binary PropertyList
|
||||
* @example example-read-03.php Read a PropertyList without knowing the type
|
||||
* @example example-create-01.php Using the CFPropertyList API
|
||||
* @example example-create-02.php Using {@link CFTypeDetector}
|
||||
* @example example-create-03.php Using {@link CFTypeDetector} with {@link CFDate} and {@link CFData}
|
||||
* @example example-create-04.php Using and extended {@link CFTypeDetector}
|
||||
*/
|
||||
class CFPropertyList extends CFBinaryPropertyList implements Iterator {
|
||||
/**
|
||||
* Format constant for binary format
|
||||
* @var integer
|
||||
*/
|
||||
const FORMAT_BINARY = 1;
|
||||
|
||||
/**
|
||||
* Format constant for xml format
|
||||
* @var integer
|
||||
*/
|
||||
const FORMAT_XML = 2;
|
||||
|
||||
/**
|
||||
* Format constant for automatic format recognizing
|
||||
* @var integer
|
||||
*/
|
||||
const FORMAT_AUTO = 0;
|
||||
|
||||
/**
|
||||
* Path of PropertyList
|
||||
* @var string
|
||||
*/
|
||||
protected $file = null;
|
||||
|
||||
/**
|
||||
* Detected format of PropertyList
|
||||
* @var integer
|
||||
*/
|
||||
protected $detectedFormat = null;
|
||||
|
||||
/**
|
||||
* Path of PropertyList
|
||||
* @var integer
|
||||
*/
|
||||
protected $format = null;
|
||||
|
||||
/**
|
||||
* CFType nodes
|
||||
* @var array
|
||||
*/
|
||||
protected $value = array();
|
||||
|
||||
/**
|
||||
* Position of iterator {@link http://php.net/manual/en/class.iterator.php}
|
||||
* @var integer
|
||||
*/
|
||||
protected $iteratorPosition = 0;
|
||||
|
||||
/**
|
||||
* List of Keys for numerical iterator access {@link http://php.net/manual/en/class.iterator.php}
|
||||
* @var array
|
||||
*/
|
||||
protected $iteratorKeys = null;
|
||||
|
||||
/**
|
||||
* List of NodeNames to ClassNames for resolving plist-files
|
||||
* @var array
|
||||
*/
|
||||
protected static $types = array(
|
||||
'string' => 'CFString',
|
||||
'real' => 'CFNumber',
|
||||
'integer' => 'CFNumber',
|
||||
'date' => 'CFDate',
|
||||
'true' => 'CFBoolean',
|
||||
'false' => 'CFBoolean',
|
||||
'data' => 'CFData',
|
||||
'array' => 'CFArray',
|
||||
'dict' => 'CFDictionary'
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Create new CFPropertyList.
|
||||
* If a path to a PropertyList is specified, it is loaded automatically.
|
||||
* @param string $file Path of PropertyList
|
||||
* @param integer $format he format of the property list, see {@link FORMAT_XML}, {@link FORMAT_BINARY} and {@link FORMAT_AUTO}, defaults to {@link FORMAT_AUTO}
|
||||
* @throws IOException if file could not be read by {@link load()}
|
||||
* @uses $file for storing the current file, if specified
|
||||
* @uses load() for loading the plist-file
|
||||
*/
|
||||
public function __construct($file=null,$format=self::FORMAT_AUTO) {
|
||||
$this->file = $file;
|
||||
$this->format = $format;
|
||||
$this->detectedFormat = $format;
|
||||
if($this->file) $this->load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an XML PropertyList.
|
||||
* @param string $file Path of PropertyList, defaults to {@link $file}
|
||||
* @return void
|
||||
* @throws IOException if file could not be read
|
||||
* @throws DOMException if XML-file could not be read properly
|
||||
* @uses load() to actually load the file
|
||||
*/
|
||||
public function loadXML($file=null) {
|
||||
$this->load($file,CFPropertyList::FORMAT_XML);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an XML PropertyList.
|
||||
* @param resource $stream A stream containing the xml document.
|
||||
* @return void
|
||||
* @throws IOException if stream could not be read
|
||||
* @throws DOMException if XML-stream could not be read properly
|
||||
*/
|
||||
public function loadXMLStream($stream) {
|
||||
if(($contents = stream_get_contents($stream)) === FALSE) throw IOException::notReadable('<stream>');
|
||||
$this->parse($contents,CFPropertyList::FORMAT_XML);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an binary PropertyList.
|
||||
* @param string $file Path of PropertyList, defaults to {@link $file}
|
||||
* @return void
|
||||
* @throws IOException if file could not be read
|
||||
* @throws PListException if binary plist-file could not be read properly
|
||||
* @uses load() to actually load the file
|
||||
*/
|
||||
public function loadBinary($file=null) {
|
||||
$this->load($file,CFPropertyList::FORMAT_BINARY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an binary PropertyList.
|
||||
* @param stream $stream Stream containing the PropertyList
|
||||
* @return void
|
||||
* @throws IOException if file could not be read
|
||||
* @throws PListException if binary plist-file could not be read properly
|
||||
* @uses parse() to actually load the file
|
||||
*/
|
||||
public function loadBinaryStream($stream) {
|
||||
if(($contents = stream_get_contents($stream)) === FALSE) throw IOException::notReadable('<stream>');
|
||||
$this->parse($contents,CFPropertyList::FORMAT_BINARY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a plist file.
|
||||
* Load and import a plist file.
|
||||
* @param string $file Path of PropertyList, defaults to {@link $file}
|
||||
* @param integer $format The format of the property list, see {@link FORMAT_XML}, {@link FORMAT_BINARY} and {@link FORMAT_AUTO}, defaults to {@link $format}
|
||||
* @return void
|
||||
* @throws PListException if file format version is not 00
|
||||
* @throws IOException if file could not be read
|
||||
* @throws DOMException if plist file could not be parsed properly
|
||||
* @uses $file if argument $file was not specified
|
||||
* @uses $value reset to empty array
|
||||
* @uses import() for importing the values
|
||||
*/
|
||||
public function load($file=null,$format=null) {
|
||||
$file = $file ? $file : $this->file;
|
||||
$format = $format !== null ? $format : $this->format;
|
||||
$this->value = array();
|
||||
|
||||
if(!is_readable($file)) throw IOException::notReadable($file);
|
||||
|
||||
switch($format) {
|
||||
case CFPropertyList::FORMAT_BINARY:
|
||||
$this->readBinary($file);
|
||||
break;
|
||||
case CFPropertyList::FORMAT_AUTO: // what we now do is ugly, but neccessary to recognize the file format
|
||||
$fd = fopen($file,"rb");
|
||||
if(($magic_number = fread($fd,8)) === false) throw IOException::notReadable($file);
|
||||
fclose($fd);
|
||||
|
||||
$filetype = substr($magic_number,0,6);
|
||||
$version = substr($magic_number,-2);
|
||||
|
||||
if($filetype == "bplist") {
|
||||
if($version != "00") throw new PListException("Wrong file format version! Expected 00, got $version!");
|
||||
$this->detectedFormat = CFPropertyList::FORMAT_BINARY;
|
||||
$this->readBinary($file);
|
||||
break;
|
||||
}
|
||||
$this->detectedFormat = CFPropertyList::FORMAT_XML;
|
||||
// else: xml format, break not neccessary
|
||||
case CFPropertyList::FORMAT_XML:
|
||||
$doc = new DOMDocument();
|
||||
if(!$doc->load($file)) throw new DOMException();
|
||||
$this->import($doc->documentElement, $this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a plist string.
|
||||
* Parse and import a plist string.
|
||||
* @param string $str String containing the PropertyList, defaults to {@link $content}
|
||||
* @param integer $format The format of the property list, see {@link FORMAT_XML}, {@link FORMAT_BINARY} and {@link FORMAT_AUTO}, defaults to {@link $format}
|
||||
* @return void
|
||||
* @throws PListException if file format version is not 00
|
||||
* @throws IOException if file could not be read
|
||||
* @throws DOMException if plist file could not be parsed properly
|
||||
* @uses $content if argument $str was not specified
|
||||
* @uses $value reset to empty array
|
||||
* @uses import() for importing the values
|
||||
*/
|
||||
public function parse($str=NULL,$format=NULL) {
|
||||
$format = $format !== null ? $format : $this->format;
|
||||
$str = $str !== null ? $str : $this->content;
|
||||
$this->value = array();
|
||||
|
||||
switch($format) {
|
||||
case CFPropertyList::FORMAT_BINARY:
|
||||
$this->parseBinary($str);
|
||||
break;
|
||||
case CFPropertyList::FORMAT_AUTO: // what we now do is ugly, but neccessary to recognize the file format
|
||||
if(($magic_number = substr($str,0,8)) === false) throw IOException::notReadable("<string>");
|
||||
|
||||
$filetype = substr($magic_number,0,6);
|
||||
$version = substr($magic_number,-2);
|
||||
|
||||
if($filetype == "bplist") {
|
||||
if($version != "00") throw new PListException("Wrong file format version! Expected 00, got $version!");
|
||||
$this->detectedFormat = CFPropertyList::FORMAT_BINARY;
|
||||
$this->parseBinary($str);
|
||||
break;
|
||||
}
|
||||
$this->detectedFormat = CFPropertyList::FORMAT_XML;
|
||||
// else: xml format, break not neccessary
|
||||
case CFPropertyList::FORMAT_XML:
|
||||
$doc = new DOMDocument();
|
||||
if(!$doc->loadXML($str)) throw new DOMException();
|
||||
$this->import($doc->documentElement, $this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a DOMNode into a CFType.
|
||||
* @param DOMNode $node Node to import children of
|
||||
* @param CFDictionary|CFArray|CFPropertyList $parent
|
||||
* @return void
|
||||
*/
|
||||
protected function import(DOMNode $node, $parent) {
|
||||
// abort if there are no children
|
||||
if(!$node->childNodes->length) return;
|
||||
|
||||
foreach($node->childNodes as $n) {
|
||||
// skip if we can't handle the element
|
||||
if(!isset(self::$types[$n->nodeName])) continue;
|
||||
|
||||
$class = 'CFPropertyList\\'.self::$types[$n->nodeName];
|
||||
$key = null;
|
||||
|
||||
// find previous <key> if possible
|
||||
$ps = $n->previousSibling;
|
||||
while($ps && $ps->nodeName == '#text' && $ps->previousSibling) $ps = $ps->previousSibling;
|
||||
|
||||
// read <key> if possible
|
||||
if($ps && $ps->nodeName == 'key') $key = $ps->firstChild->nodeValue;
|
||||
|
||||
switch($n->nodeName) {
|
||||
case 'date':
|
||||
$value = new $class(CFDate::dateValue($n->nodeValue));
|
||||
break;
|
||||
case 'data':
|
||||
$value = new $class($n->nodeValue,true);
|
||||
break;
|
||||
case 'string':
|
||||
$value = new $class($n->nodeValue);
|
||||
break;
|
||||
|
||||
case 'real':
|
||||
case 'integer':
|
||||
$value = new $class($n->nodeName == 'real' ? floatval($n->nodeValue) : intval($n->nodeValue));
|
||||
break;
|
||||
|
||||
case 'true':
|
||||
case 'false':
|
||||
$value = new $class($n->nodeName == 'true');
|
||||
break;
|
||||
|
||||
case 'array':
|
||||
case 'dict':
|
||||
$value = new $class();
|
||||
$this->import($n, $value);
|
||||
|
||||
if($value instanceof CFDictionary) {
|
||||
$hsh = $value->getValue();
|
||||
if(isset($hsh['CF$UID']) && count($hsh) == 1) {
|
||||
$value = new CFUid($hsh['CF$UID']->getValue());
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Dictionaries need a key
|
||||
if($parent instanceof CFDictionary) $parent->add($key, $value);
|
||||
// others don't
|
||||
else $parent->add($value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert CFPropertyList to XML and save to file.
|
||||
* @param string $file Path of PropertyList, defaults to {@link $file}
|
||||
* @return void
|
||||
* @throws IOException if file could not be read
|
||||
* @uses $file if $file was not specified
|
||||
*/
|
||||
public function saveXML($file) {
|
||||
$this->save($file,CFPropertyList::FORMAT_XML);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert CFPropertyList to binary format (bplist00) and save to file.
|
||||
* @param string $file Path of PropertyList, defaults to {@link $file}
|
||||
* @return void
|
||||
* @throws IOException if file could not be read
|
||||
* @uses $file if $file was not specified
|
||||
*/
|
||||
public function saveBinary($file) {
|
||||
$this->save($file,CFPropertyList::FORMAT_BINARY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert CFPropertyList to XML or binary and save to file.
|
||||
* @param string $file Path of PropertyList, defaults to {@link $file}
|
||||
* @param string $format Format of PropertyList, defaults to {@link $format}
|
||||
* @return void
|
||||
* @throws IOException if file could not be read
|
||||
* @throws PListException if evaluated $format is neither {@link FORMAT_XML} nor {@link FORMAL_BINARY}
|
||||
* @uses $file if $file was not specified
|
||||
* @uses $format if $format was not specified
|
||||
*/
|
||||
public function save($file=null,$format=null) {
|
||||
$file = $file ? $file : $this->file;
|
||||
$format = $format ? $format : $this->format;
|
||||
if($format == self::FORMAT_AUTO)$format = $this->detectedFormat;
|
||||
|
||||
if( !in_array( $format, array( self::FORMAT_BINARY, self::FORMAT_XML ) ) )
|
||||
throw new PListException( "format {$format} is not supported, use CFPropertyList::FORMAT_BINARY or CFPropertyList::FORMAT_XML" );
|
||||
|
||||
if(!file_exists($file)) {
|
||||
// dirname("file.xml") == "" and is treated as the current working directory
|
||||
if(!is_writable(dirname($file))) throw IOException::notWritable($file);
|
||||
}
|
||||
else if(!is_writable($file)) throw IOException::notWritable($file);
|
||||
|
||||
$content = $format == self::FORMAT_BINARY ? $this->toBinary() : $this->toXML();
|
||||
|
||||
$fh = fopen($file, 'wb');
|
||||
fwrite($fh,$content);
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert CFPropertyList to XML
|
||||
* @param bool $formatted Print plist formatted (i.e. with newlines and whitespace indention) if true; defaults to false
|
||||
* @return string The XML content
|
||||
*/
|
||||
public function toXML($formatted=false) {
|
||||
$domimpl = new DOMImplementation();
|
||||
// <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
$dtd = $domimpl->createDocumentType('plist', '-//Apple//DTD PLIST 1.0//EN', 'http://www.apple.com/DTDs/PropertyList-1.0.dtd');
|
||||
$doc = $domimpl->createDocument(null, "plist", $dtd);
|
||||
$doc->encoding = "UTF-8";
|
||||
|
||||
// format output
|
||||
if($formatted) {
|
||||
$doc->formatOutput = true;
|
||||
$doc->preserveWhiteSpace = true;
|
||||
}
|
||||
|
||||
// get documentElement and set attribs
|
||||
$plist = $doc->documentElement;
|
||||
$plist->setAttribute('version', '1.0');
|
||||
|
||||
// add PropertyList's children
|
||||
$plist->appendChild($this->getValue(true)->toXML($doc));
|
||||
|
||||
return $doc->saveXML();
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* M A N I P U L A T I O N
|
||||
************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Add CFType to collection.
|
||||
* @param CFType $value CFType to add to collection
|
||||
* @return void
|
||||
* @uses $value for adding $value
|
||||
*/
|
||||
public function add(CFType $value=null) {
|
||||
// anything but CFType is null, null is an empty string - sad but true
|
||||
if( !$value )
|
||||
$value = new CFString();
|
||||
|
||||
$this->value[] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get CFType from collection.
|
||||
* @param integer $key Key of CFType to retrieve from collection
|
||||
* @return CFType CFType found at $key, null else
|
||||
* @uses $value for retrieving CFType of $key
|
||||
*/
|
||||
public function get($key) {
|
||||
if(isset($this->value[$key])) return $this->value[$key];
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic getter (magic)
|
||||
*
|
||||
* @param integer $key Key of CFType to retrieve from collection
|
||||
* @return CFType CFType found at $key, null else
|
||||
* @author Sean Coates <sean@php.net>
|
||||
* @link http://php.net/oop5.overloading
|
||||
*/
|
||||
public function __get($key) {
|
||||
return $this->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove CFType from collection.
|
||||
* @param integer $key Key of CFType to removes from collection
|
||||
* @return CFType removed CFType, null else
|
||||
* @uses $value for removing CFType of $key
|
||||
*/
|
||||
public function del($key) {
|
||||
if(isset($this->value[$key])) {
|
||||
$t = $this->value[$key];
|
||||
unset($this->value[$key]);
|
||||
return $t;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty the collection
|
||||
* @return array the removed CFTypes
|
||||
* @uses $value for removing CFType of $key
|
||||
*/
|
||||
public function purge() {
|
||||
$t = $this->value;
|
||||
$this->value = array();
|
||||
return $t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get first (and only) child, or complete collection.
|
||||
* @param string $cftype if set to true returned value will be CFArray instead of an array in case of a collection
|
||||
* @return CFType|array CFType or list of CFTypes known to the PropertyList
|
||||
* @uses $value for retrieving CFTypes
|
||||
*/
|
||||
public function getValue($cftype=false) {
|
||||
if(count($this->value) === 1) {
|
||||
$t = array_values( $this->value );
|
||||
return $t[0];
|
||||
}
|
||||
if($cftype) {
|
||||
$t = new CFArray();
|
||||
foreach( $this->value as $value ) {
|
||||
if( $value instanceof CFType ) $t->add($value);
|
||||
}
|
||||
return $t;
|
||||
}
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create CFType-structure from guessing the data-types.
|
||||
* The functionality has been moved to the more flexible {@link CFTypeDetector} facility.
|
||||
* @param mixed $value Value to convert to CFType
|
||||
* @param array $options Configuration for casting values [autoDictionary, suppressExceptions, objectToArrayMethod, castNumericStrings]
|
||||
* @return CFType CFType based on guessed type
|
||||
* @uses CFTypeDetector for actual type detection
|
||||
* @deprecated
|
||||
*/
|
||||
public static function guess($value, $options=array()) {
|
||||
static $t = null;
|
||||
if( $t === null )
|
||||
$t = new CFTypeDetector( $options );
|
||||
|
||||
return $t->toCFType( $value );
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* S E R I A L I Z I N G
|
||||
************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Get PropertyList as array.
|
||||
* @return mixed primitive value of first (and only) CFType, or array of primitive values of collection
|
||||
* @uses $value for retrieving CFTypes
|
||||
*/
|
||||
public function toArray() {
|
||||
$a = array();
|
||||
foreach($this->value as $value) $a[] = $value->toArray();
|
||||
if(count($a) === 1) return $a[0];
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* I T E R A T O R I N T E R F A C E
|
||||
************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Rewind {@link $iteratorPosition} to first position (being 0)
|
||||
* @link http://php.net/manual/en/iterator.rewind.php
|
||||
* @return void
|
||||
* @uses $iteratorPosition set to 0
|
||||
* @uses $iteratorKeys store keys of {@link $value}
|
||||
*/
|
||||
public function rewind() {
|
||||
$this->iteratorPosition = 0;
|
||||
$this->iteratorKeys = array_keys($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Iterator's current {@link CFType} identified by {@link $iteratorPosition}
|
||||
* @link http://php.net/manual/en/iterator.current.php
|
||||
* @return CFType current Item
|
||||
* @uses $iteratorPosition identify current key
|
||||
* @uses $iteratorKeys identify current value
|
||||
*/
|
||||
public function current() {
|
||||
return $this->value[$this->iteratorKeys[$this->iteratorPosition]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Iterator's current key identified by {@link $iteratorPosition}
|
||||
* @link http://php.net/manual/en/iterator.key.php
|
||||
* @return string key of the current Item
|
||||
* @uses $iteratorPosition identify current key
|
||||
* @uses $iteratorKeys identify current value
|
||||
*/
|
||||
public function key() {
|
||||
return $this->iteratorKeys[$this->iteratorPosition];
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment {@link $iteratorPosition} to address next {@see CFType}
|
||||
* @link http://php.net/manual/en/iterator.next.php
|
||||
* @return void
|
||||
* @uses $iteratorPosition increment by 1
|
||||
*/
|
||||
public function next() {
|
||||
$this->iteratorPosition++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if {@link $iteratorPosition} addresses a valid element of {@link $value}
|
||||
* @link http://php.net/manual/en/iterator.valid.php
|
||||
* @return boolean true if current position is valid, false else
|
||||
* @uses $iteratorPosition test if within {@link $iteratorKeys}
|
||||
* @uses $iteratorPosition test if within {@link $value}
|
||||
*/
|
||||
public function valid() {
|
||||
return isset($this->iteratorKeys[$this->iteratorPosition]) && isset($this->value[$this->iteratorKeys[$this->iteratorPosition]]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# eof
|
@ -1,757 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Data-Types for CFPropertyList as defined by Apple.
|
||||
* {@link http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/plist.5.html Property Lists}
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @subpackage plist.types
|
||||
* @version $Id$
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
use \DOMDocument, \Iterator, \ArrayAccess;
|
||||
|
||||
/**
|
||||
* Base-Class of all CFTypes used by CFPropertyList
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @subpackage plist.types
|
||||
* @version $Id$
|
||||
* @example example-create-01.php Using the CFPropertyList API
|
||||
* @example example-create-02.php Using CFPropertyList::guess()
|
||||
* @example example-create-03.php Using CFPropertyList::guess() with {@link CFDate} and {@link CFData}
|
||||
*/
|
||||
abstract class CFType {
|
||||
/**
|
||||
* CFType nodes
|
||||
* @var array
|
||||
*/
|
||||
protected $value = null;
|
||||
|
||||
/**
|
||||
* Create new CFType.
|
||||
* @param mixed $value Value of CFType
|
||||
*/
|
||||
public function __construct($value=null) {
|
||||
$this->setValue($value);
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
* M A G I C P R O P E R T I E S
|
||||
************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Get the CFType's value
|
||||
* @return mixed CFType's value
|
||||
*/
|
||||
public function getValue() {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CFType's value
|
||||
* @return void
|
||||
*/
|
||||
public function setValue($value) {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
* S E R I A L I Z I N G
|
||||
************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Get XML-Node.
|
||||
* @param DOMDocument $doc DOMDocument to create DOMNode in
|
||||
* @param string $nodeName Name of element to create
|
||||
* @return DOMNode Node created based on CType
|
||||
* @uses $value as nodeValue
|
||||
*/
|
||||
public function toXML(DOMDocument $doc, $nodeName) {
|
||||
$node = $doc->createElement($nodeName);
|
||||
$text = $doc->createTextNode($this->value);
|
||||
$node->appendChild($text);
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert value to binary representation
|
||||
* @param CFBinaryPropertyList The binary property list object
|
||||
* @return The offset in the object table
|
||||
*/
|
||||
public abstract function toBinary(CFBinaryPropertyList &$bplist);
|
||||
|
||||
/**
|
||||
* Get CFType's value.
|
||||
* @return mixed primitive value
|
||||
* @uses $value for retrieving primitive of CFType
|
||||
*/
|
||||
public function toArray() {
|
||||
return $this->getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* String Type of CFPropertyList
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @subpackage plist.types
|
||||
*/
|
||||
class CFString extends CFType {
|
||||
/**
|
||||
* Get XML-Node.
|
||||
* @param DOMDocument $doc DOMDocument to create DOMNode in
|
||||
* @param string $nodeName For compatibility reasons; just ignore it
|
||||
* @return DOMNode <string>-Element
|
||||
*/
|
||||
public function toXML(DOMDocument $doc,$nodeName="") {
|
||||
return parent::toXML($doc, 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* convert value to binary representation
|
||||
* @param CFBinaryPropertyList The binary property list object
|
||||
* @return The offset in the object table
|
||||
*/
|
||||
public function toBinary(CFBinaryPropertyList &$bplist) {
|
||||
return $bplist->stringToBinary($this->value);
|
||||
}
|
||||
}
|
||||
|
||||
class CFUid extends CFType {
|
||||
public
|
||||
function toXML(DOMDocument $doc,$nodeName="") {
|
||||
$obj = new CFDictionary(array('CF$UID' => new CFNumber($this->value)));
|
||||
return $obj->toXml($doc);
|
||||
}
|
||||
|
||||
public
|
||||
function toBinary(CFBinaryPropertyList &$bplist) {
|
||||
return $bplist->uidToBinary($this->value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Number Type of CFPropertyList
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @subpackage plist.types
|
||||
*/
|
||||
class CFNumber extends CFType {
|
||||
/**
|
||||
* Get XML-Node.
|
||||
* Returns <real> if $value is a float, <integer> if $value is an integer.
|
||||
* @param DOMDocument $doc DOMDocument to create DOMNode in
|
||||
* @param string $nodeName For compatibility reasons; just ignore it
|
||||
* @return DOMNode <real> or <integer>-Element
|
||||
*/
|
||||
public function toXML(DOMDocument $doc,$nodeName="") {
|
||||
$ret = 'real';
|
||||
if(intval($this->value) == $this->value && !is_float($this->value) && strpos($this->value,'.') === false) {
|
||||
$this->value = intval($this->value);
|
||||
$ret = 'integer';
|
||||
}
|
||||
return parent::toXML($doc, $ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert value to binary representation
|
||||
* @param CFBinaryPropertyList The binary property list object
|
||||
* @return The offset in the object table
|
||||
*/
|
||||
public function toBinary(CFBinaryPropertyList &$bplist) {
|
||||
return $bplist->numToBinary($this->value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Date Type of CFPropertyList
|
||||
* Note: CFDate uses Unix timestamp (epoch) to store dates internally
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @subpackage plist.types
|
||||
*/
|
||||
class CFDate extends CFType {
|
||||
const TIMESTAMP_APPLE = 0;
|
||||
const TIMESTAMP_UNIX = 1;
|
||||
const DATE_DIFF_APPLE_UNIX = 978307200;
|
||||
|
||||
/**
|
||||
* Create new Date CFType.
|
||||
* @param integer $value timestamp to set
|
||||
* @param integer $format format the timestamp is specified in, use {@link TIMESTAMP_APPLE} or {@link TIMESTAMP_UNIX}, defaults to {@link TIMESTAMP_APPLE}
|
||||
* @uses setValue() to convert the timestamp
|
||||
*/
|
||||
function __construct($value,$format=CFDate::TIMESTAMP_UNIX) {
|
||||
$this->setValue($value,$format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Date CFType's value.
|
||||
* @param integer $value timestamp to set
|
||||
* @param integer $format format the timestamp is specified in, use {@link TIMESTAMP_APPLE} or {@link TIMESTAMP_UNIX}, defaults to {@link TIMESTAMP_UNIX}
|
||||
* @return void
|
||||
* @uses TIMESTAMP_APPLE to determine timestamp type
|
||||
* @uses TIMESTAMP_UNIX to determine timestamp type
|
||||
* @uses DATE_DIFF_APPLE_UNIX to convert Apple-timestamp to Unix-timestamp
|
||||
*/
|
||||
function setValue($value,$format=CFDate::TIMESTAMP_UNIX) {
|
||||
if($format == CFDate::TIMESTAMP_UNIX) $this->value = $value;
|
||||
else $this->value = $value + CFDate::DATE_DIFF_APPLE_UNIX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Date CFType's value.
|
||||
* @param integer $format format the timestamp is specified in, use {@link TIMESTAMP_APPLE} or {@link TIMESTAMP_UNIX}, defaults to {@link TIMESTAMP_UNIX}
|
||||
* @return integer Unix timestamp
|
||||
* @uses TIMESTAMP_APPLE to determine timestamp type
|
||||
* @uses TIMESTAMP_UNIX to determine timestamp type
|
||||
* @uses DATE_DIFF_APPLE_UNIX to convert Unix-timestamp to Apple-timestamp
|
||||
*/
|
||||
function getValue($format=CFDate::TIMESTAMP_UNIX) {
|
||||
if($format == CFDate::TIMESTAMP_UNIX) return $this->value;
|
||||
else return $this->value - CFDate::DATE_DIFF_APPLE_UNIX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get XML-Node.
|
||||
* @param DOMDocument $doc DOMDocument to create DOMNode in
|
||||
* @param string $nodeName For compatibility reasons; just ignore it
|
||||
* @return DOMNode <date>-Element
|
||||
*/
|
||||
public function toXML(DOMDocument $doc,$nodeName="") {
|
||||
$text = $doc->createTextNode(gmdate("Y-m-d\TH:i:s\Z",$this->getValue()));
|
||||
$node = $doc->createElement("date");
|
||||
$node->appendChild($text);
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert value to binary representation
|
||||
* @param CFBinaryPropertyList The binary property list object
|
||||
* @return The offset in the object table
|
||||
*/
|
||||
public function toBinary(CFBinaryPropertyList &$bplist) {
|
||||
return $bplist->dateToBinary($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a UNIX timestamp from a PList date string
|
||||
* @param string $val The date string (e.g. "2009-05-13T20:23:43Z")
|
||||
* @return integer The UNIX timestamp
|
||||
* @throws PListException when encountering an unknown date string format
|
||||
*/
|
||||
public static function dateValue($val) {
|
||||
//2009-05-13T20:23:43Z
|
||||
if(!preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z/',$val,$matches)) throw new PListException("Unknown date format: $val");
|
||||
return gmmktime($matches[4],$matches[5],$matches[6],$matches[2],$matches[3],$matches[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Boolean Type of CFPropertyList
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @subpackage plist.types
|
||||
*/
|
||||
class CFBoolean extends CFType {
|
||||
/**
|
||||
* Get XML-Node.
|
||||
* Returns <true> if $value is a true, <false> if $value is false.
|
||||
* @param DOMDocument $doc DOMDocument to create DOMNode in
|
||||
* @param string $nodeName For compatibility reasons; just ignore it
|
||||
* @return DOMNode <true> or <false>-Element
|
||||
*/
|
||||
public function toXML(DOMDocument $doc,$nodeName="") {
|
||||
return $doc->createElement($this->value ? 'true' : 'false');
|
||||
}
|
||||
|
||||
/**
|
||||
* convert value to binary representation
|
||||
* @param CFBinaryPropertyList The binary property list object
|
||||
* @return The offset in the object table
|
||||
*/
|
||||
public function toBinary(CFBinaryPropertyList &$bplist) {
|
||||
return $bplist->boolToBinary($this->value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Data Type of CFPropertyList
|
||||
* Note: Binary data is base64-encoded.
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @subpackage plist.types
|
||||
*/
|
||||
class CFData extends CFType {
|
||||
/**
|
||||
* Create new Data CFType
|
||||
* @param string $value data to be contained by new object
|
||||
* @param boolean $already_coded if true $value will not be base64-encoded, defaults to false
|
||||
*/
|
||||
public function __construct($value=null,$already_coded=false) {
|
||||
if($already_coded) $this->value = $value;
|
||||
else $this->setValue($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CFType's value and base64-encode it.
|
||||
* <b>Note:</b> looks like base64_encode has troubles with UTF-8 encoded strings
|
||||
* @return void
|
||||
*/
|
||||
public function setValue($value) {
|
||||
//if(function_exists('mb_check_encoding') && mb_check_encoding($value, 'UTF-8')) $value = utf8_decode($value);
|
||||
$this->value = base64_encode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base64 encoded data
|
||||
* @return string The base64 encoded data value
|
||||
*/
|
||||
public function getCodedValue() {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base64-decoded CFType's value.
|
||||
* @return mixed CFType's value
|
||||
*/
|
||||
public function getValue() {
|
||||
return base64_decode($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get XML-Node.
|
||||
* @param DOMDocument $doc DOMDocument to create DOMNode in
|
||||
* @param string $nodeName For compatibility reasons; just ignore it
|
||||
* @return DOMNode <data>-Element
|
||||
*/
|
||||
public function toXML(DOMDocument $doc,$nodeName="") {
|
||||
return parent::toXML($doc, 'data');
|
||||
}
|
||||
|
||||
/**
|
||||
* convert value to binary representation
|
||||
* @param CFBinaryPropertyList The binary property list object
|
||||
* @return The offset in the object table
|
||||
*/
|
||||
public function toBinary(CFBinaryPropertyList &$bplist) {
|
||||
return $bplist->dataToBinary($this->getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Array Type of CFPropertyList
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @subpackage plist.types
|
||||
*/
|
||||
class CFArray extends CFType implements Iterator, ArrayAccess {
|
||||
/**
|
||||
* Position of iterator {@link http://php.net/manual/en/class.iterator.php}
|
||||
* @var integer
|
||||
*/
|
||||
protected $iteratorPosition = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Create new CFType.
|
||||
* @param array $value Value of CFType
|
||||
*/
|
||||
public function __construct($value=array()) {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CFType's value
|
||||
* <b>Note:</b> this dummy does nothing
|
||||
* @return void
|
||||
*/
|
||||
public function setValue($value) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add CFType to collection.
|
||||
* @param CFType $value CFType to add to collection, defaults to null which results in an empty {@link CFString}
|
||||
* @return void
|
||||
* @uses $value for adding $value
|
||||
*/
|
||||
public function add(CFType $value=null) {
|
||||
// anything but CFType is null, null is an empty string - sad but true
|
||||
if( !$value )
|
||||
$value = new CFString();
|
||||
|
||||
$this->value[] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get CFType from collection.
|
||||
* @param integer $key Key of CFType to retrieve from collection
|
||||
* @return CFType CFType found at $key, null else
|
||||
* @uses $value for retrieving CFType of $key
|
||||
*/
|
||||
public function get($key) {
|
||||
if(isset($this->value[$key])) return $this->value[$key];
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove CFType from collection.
|
||||
* @param integer $key Key of CFType to removes from collection
|
||||
* @return CFType removed CFType, null else
|
||||
* @uses $value for removing CFType of $key
|
||||
*/
|
||||
public function del($key) {
|
||||
if(isset($this->value[$key])) unset($this->value[$key]);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* S E R I A L I Z I N G
|
||||
************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Get XML-Node.
|
||||
* @param DOMDocument $doc DOMDocument to create DOMNode in
|
||||
* @param string $nodeName For compatibility reasons; just ignore it
|
||||
* @return DOMNode <array>-Element
|
||||
*/
|
||||
public function toXML(DOMDocument $doc,$nodeName="") {
|
||||
$node = $doc->createElement('array');
|
||||
|
||||
foreach($this->value as $value) $node->appendChild($value->toXML($doc));
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert value to binary representation
|
||||
* @param CFBinaryPropertyList The binary property list object
|
||||
* @return The offset in the object table
|
||||
*/
|
||||
public function toBinary(CFBinaryPropertyList &$bplist) {
|
||||
return $bplist->arrayToBinary($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get CFType's value.
|
||||
* @return array primitive value
|
||||
* @uses $value for retrieving primitive of CFType
|
||||
*/
|
||||
public function toArray() {
|
||||
$a = array();
|
||||
foreach($this->value as $value) $a[] = $value->toArray();
|
||||
return $a;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* I T E R A T O R I N T E R F A C E
|
||||
************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Rewind {@link $iteratorPosition} to first position (being 0)
|
||||
* @link http://php.net/manual/en/iterator.rewind.php
|
||||
* @return void
|
||||
* @uses $iteratorPosition set to 0
|
||||
*/
|
||||
public function rewind() {
|
||||
$this->iteratorPosition = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Iterator's current {@link CFType} identified by {@link $iteratorPosition}
|
||||
* @link http://php.net/manual/en/iterator.current.php
|
||||
* @return CFType current Item
|
||||
* @uses $iteratorPosition identify current key
|
||||
*/
|
||||
public function current() {
|
||||
return $this->value[$this->iteratorPosition];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Iterator's current key identified by {@link $iteratorPosition}
|
||||
* @link http://php.net/manual/en/iterator.key.php
|
||||
* @return string key of the current Item
|
||||
* @uses $iteratorPosition identify current key
|
||||
*/
|
||||
public function key() {
|
||||
return $this->iteratorPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment {@link $iteratorPosition} to address next {@see CFType}
|
||||
* @link http://php.net/manual/en/iterator.next.php
|
||||
* @return void
|
||||
* @uses $iteratorPosition increment by 1
|
||||
*/
|
||||
public function next() {
|
||||
$this->iteratorPosition++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if {@link $iteratorPosition} addresses a valid element of {@link $value}
|
||||
* @link http://php.net/manual/en/iterator.valid.php
|
||||
* @return boolean true if current position is valid, false else
|
||||
* @uses $iteratorPosition test if within {@link $iteratorKeys}
|
||||
* @uses $iteratorPosition test if within {@link $value}
|
||||
*/
|
||||
public function valid() {
|
||||
return isset($this->value[$this->iteratorPosition]);
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
* ArrayAccess I N T E R F A C E
|
||||
************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Determine if the array's key exists
|
||||
* @param string $key the key to check
|
||||
* @return bool true if the offset exists, false if not
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
|
||||
* @uses $value to check if $key exists
|
||||
* @author Sean Coates <sean@php.net>
|
||||
*/
|
||||
public function offsetExists($key) {
|
||||
return isset($this->value[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a specific key from the CFArray
|
||||
* @param string $key the key to check
|
||||
* @return mixed the value associated with the key; null if the key is not found
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetget.php
|
||||
* @uses get() to get the key's value
|
||||
* @author Sean Coates <sean@php.net>
|
||||
*/
|
||||
public function offsetGet($key) {
|
||||
return $this->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value in the array
|
||||
* @param string $key the key to set
|
||||
* @param string $value the value to set
|
||||
* @return void
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetset.php
|
||||
* @uses setValue() to set the key's new value
|
||||
* @author Sean Coates <sean@php.net>
|
||||
*/
|
||||
public function offsetSet($key, $value) {
|
||||
return $this->setValue($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets a value in the array
|
||||
* <b>Note:</b> this dummy does nothing
|
||||
* @param string $key the key to set
|
||||
* @return void
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
|
||||
* @author Sean Coates <sean@php.net>
|
||||
*/
|
||||
public function offsetUnset($key) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Array Type of CFPropertyList
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @subpackage plist.types
|
||||
*/
|
||||
class CFDictionary extends CFType implements Iterator {
|
||||
/**
|
||||
* Position of iterator {@link http://php.net/manual/en/class.iterator.php}
|
||||
* @var integer
|
||||
*/
|
||||
protected $iteratorPosition = 0;
|
||||
|
||||
/**
|
||||
* List of Keys for numerical iterator access {@link http://php.net/manual/en/class.iterator.php}
|
||||
* @var array
|
||||
*/
|
||||
protected $iteratorKeys = null;
|
||||
|
||||
|
||||
/**
|
||||
* Create new CFType.
|
||||
* @param array $value Value of CFType
|
||||
*/
|
||||
public function __construct($value=array()) {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CFType's value
|
||||
* <b>Note:</b> this dummy does nothing
|
||||
* @return void
|
||||
*/
|
||||
public function setValue($value) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add CFType to collection.
|
||||
* @param string $key Key to add to collection
|
||||
* @param CFType $value CFType to add to collection, defaults to null which results in an empty {@link CFString}
|
||||
* @return void
|
||||
* @uses $value for adding $key $value pair
|
||||
*/
|
||||
public function add($key, CFType $value=null) {
|
||||
// anything but CFType is null, null is an empty string - sad but true
|
||||
if( !$value )
|
||||
$value = new CFString();
|
||||
|
||||
$this->value[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get CFType from collection.
|
||||
* @param string $key Key of CFType to retrieve from collection
|
||||
* @return CFType CFType found at $key, null else
|
||||
* @uses $value for retrieving CFType of $key
|
||||
*/
|
||||
public function get($key) {
|
||||
if(isset($this->value[$key])) return $this->value[$key];
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic getter (magic)
|
||||
* @param integer $key Key of CFType to retrieve from collection
|
||||
* @return CFType CFType found at $key, null else
|
||||
* @link http://php.net/oop5.overloading
|
||||
* @uses get() to retrieve the key's value
|
||||
* @author Sean Coates <sean@php.net>
|
||||
*/
|
||||
public function __get($key) {
|
||||
return $this->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove CFType from collection.
|
||||
* @param string $key Key of CFType to removes from collection
|
||||
* @return CFType removed CFType, null else
|
||||
* @uses $value for removing CFType of $key
|
||||
*/
|
||||
public function del($key) {
|
||||
if(isset($this->value[$key])) unset($this->value[$key]);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* S E R I A L I Z I N G
|
||||
************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Get XML-Node.
|
||||
* @param DOMDocument $doc DOMDocument to create DOMNode in
|
||||
* @param string $nodeName For compatibility reasons; just ignore it
|
||||
* @return DOMNode <dict>-Element
|
||||
*/
|
||||
public function toXML(DOMDocument $doc,$nodeName="") {
|
||||
$node = $doc->createElement('dict');
|
||||
|
||||
foreach($this->value as $key => $value) {
|
||||
$node->appendChild($doc->createElement('key', $key));
|
||||
$node->appendChild($value->toXML($doc));
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert value to binary representation
|
||||
* @param CFBinaryPropertyList The binary property list object
|
||||
* @return The offset in the object table
|
||||
*/
|
||||
public function toBinary(CFBinaryPropertyList &$bplist) {
|
||||
return $bplist->dictToBinary($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get CFType's value.
|
||||
* @return array primitive value
|
||||
* @uses $value for retrieving primitive of CFType
|
||||
*/
|
||||
public function toArray() {
|
||||
$a = array();
|
||||
|
||||
foreach($this->value as $key => $value) $a[$key] = $value->toArray();
|
||||
return $a;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* I T E R A T O R I N T E R F A C E
|
||||
************************************************************************************************/
|
||||
|
||||
/**
|
||||
* Rewind {@link $iteratorPosition} to first position (being 0)
|
||||
* @link http://php.net/manual/en/iterator.rewind.php
|
||||
* @return void
|
||||
* @uses $iteratorPosition set to 0
|
||||
* @uses $iteratorKeys store keys of {@link $value}
|
||||
*/
|
||||
public function rewind() {
|
||||
$this->iteratorPosition = 0;
|
||||
$this->iteratorKeys = array_keys($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Iterator's current {@link CFType} identified by {@link $iteratorPosition}
|
||||
* @link http://php.net/manual/en/iterator.current.php
|
||||
* @return CFType current Item
|
||||
* @uses $iteratorPosition identify current key
|
||||
* @uses $iteratorKeys identify current value
|
||||
*/
|
||||
public function current() {
|
||||
return $this->value[$this->iteratorKeys[$this->iteratorPosition]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Iterator's current key identified by {@link $iteratorPosition}
|
||||
* @link http://php.net/manual/en/iterator.key.php
|
||||
* @return string key of the current Item
|
||||
* @uses $iteratorPosition identify current key
|
||||
* @uses $iteratorKeys identify current value
|
||||
*/
|
||||
public function key() {
|
||||
return $this->iteratorKeys[$this->iteratorPosition];
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment {@link $iteratorPosition} to address next {@see CFType}
|
||||
* @link http://php.net/manual/en/iterator.next.php
|
||||
* @return void
|
||||
* @uses $iteratorPosition increment by 1
|
||||
*/
|
||||
public function next() {
|
||||
$this->iteratorPosition++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if {@link $iteratorPosition} addresses a valid element of {@link $value}
|
||||
* @link http://php.net/manual/en/iterator.valid.php
|
||||
* @return boolean true if current position is valid, false else
|
||||
* @uses $iteratorPosition test if within {@link $iteratorKeys}
|
||||
* @uses $iteratorPosition test if within {@link $value}
|
||||
*/
|
||||
public function valid() {
|
||||
return isset($this->iteratorKeys[$this->iteratorPosition]) && isset($this->value[$this->iteratorKeys[$this->iteratorPosition]]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# eof
|
@ -1,185 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CFTypeDetector
|
||||
* Interface for converting native PHP data structures to CFPropertyList objects.
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @subpackage plist.types
|
||||
* @example example-create-02.php Using {@link CFTypeDetector}
|
||||
* @example example-create-03.php Using {@link CFTypeDetector} with {@link CFDate} and {@link CFData}
|
||||
* @example example-create-04.php Using and extended {@link CFTypeDetector}
|
||||
*/
|
||||
|
||||
namespace CFPropertyList;
|
||||
use \DateTime, \Iterator;
|
||||
|
||||
class CFTypeDetector {
|
||||
|
||||
/**
|
||||
* flag stating if all arrays should automatically be converted to {@link CFDictionary}
|
||||
* @var boolean
|
||||
*/
|
||||
protected $autoDictionary = false;
|
||||
|
||||
/**
|
||||
* flag stating if exceptions should be suppressed or thrown
|
||||
* @var boolean
|
||||
*/
|
||||
protected $suppressExceptions = false;
|
||||
|
||||
/**
|
||||
* name of a method that will be used for array to object conversations
|
||||
* @var callable
|
||||
*/
|
||||
protected $objectToArrayMethod = null;
|
||||
|
||||
/**
|
||||
* flag stating if "123.23" should be converted to float (true) or preserved as string (false)
|
||||
* @var boolean
|
||||
*/
|
||||
protected $castNumericStrings = true;
|
||||
|
||||
|
||||
/**
|
||||
* Create new CFTypeDetector
|
||||
* @param array $options Configuration for casting values [autoDictionary, suppressExceptions, objectToArrayMethod, castNumericStrings]
|
||||
*/
|
||||
public function __construct(array $options=array()) {
|
||||
//$autoDicitionary=false,$suppressExceptions=false,$objectToArrayMethod=null
|
||||
foreach ($options as $key => $value) {
|
||||
if (property_exists($this, $key)) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an array is associative or numerical.
|
||||
* Numerical Arrays have incrementing index-numbers that don't contain gaps.
|
||||
* @param array $value Array to check indexes of
|
||||
* @return boolean true if array is associative, false if array has numeric indexes
|
||||
*/
|
||||
protected function isAssociativeArray($value) {
|
||||
$numericKeys = true;
|
||||
$i = 0;
|
||||
foreach($value as $key => $v) {
|
||||
if($i !== $key) {
|
||||
$numericKeys = false;
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return !$numericKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default value
|
||||
* @return CFType the default value to return if no suitable type could be determined
|
||||
*/
|
||||
protected function defaultValue() {
|
||||
return new CFString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create CFType-structure by guessing the data-types.
|
||||
* {@link CFArray}, {@link CFDictionary}, {@link CFBoolean}, {@link CFNumber} and {@link CFString} can be created, {@link CFDate} and {@link CFData} cannot.
|
||||
* <br /><b>Note:</b>Distinguishing between {@link CFArray} and {@link CFDictionary} is done by examining the keys.
|
||||
* Keys must be strictly incrementing integers to evaluate to a {@link CFArray}.
|
||||
* Since PHP does not offer a function to test for associative arrays,
|
||||
* this test causes the input array to be walked twice and thus work rather slow on large collections.
|
||||
* If you work with large arrays and can live with all arrays evaluating to {@link CFDictionary},
|
||||
* feel free to set the appropriate flag.
|
||||
* <br /><b>Note:</b> If $value is an instance of CFType it is simply returned.
|
||||
* <br /><b>Note:</b> If $value is neither a CFType, array, numeric, boolean nor string, it is omitted.
|
||||
* @param mixed $value Value to convert to CFType
|
||||
* @param boolean $autoDictionary if true {@link CFArray}-detection is bypassed and arrays will be returned as {@link CFDictionary}.
|
||||
* @return CFType CFType based on guessed type
|
||||
* @uses isAssociativeArray() to check if an array only has numeric indexes
|
||||
*/
|
||||
public function toCFType($value) {
|
||||
switch(true) {
|
||||
case $value instanceof CFType:
|
||||
return $value;
|
||||
break;
|
||||
|
||||
case is_object($value):
|
||||
// DateTime should be CFDate
|
||||
if(class_exists( 'DateTime' ) && $value instanceof DateTime){
|
||||
return new CFDate($value->getTimestamp());
|
||||
}
|
||||
|
||||
// convert possible objects to arrays, arrays will be arrays
|
||||
if($this->objectToArrayMethod && is_callable(array($value, $this->objectToArrayMethod))){
|
||||
$value = call_user_func( array( $value, $this->objectToArrayMethod ) );
|
||||
}
|
||||
|
||||
if(!is_array($value)){
|
||||
if($this->suppressExceptions)
|
||||
return $this->defaultValue();
|
||||
|
||||
throw new PListException('Could not determine CFType for object of type '. get_class($value));
|
||||
}
|
||||
/* break; omitted */
|
||||
|
||||
case $value instanceof Iterator:
|
||||
case is_array($value):
|
||||
// test if $value is simple or associative array
|
||||
if(!$this->autoDictionary) {
|
||||
if(!$this->isAssociativeArray($value)) {
|
||||
$t = new CFArray();
|
||||
foreach($value as $v) $t->add($this->toCFType($v));
|
||||
return $t;
|
||||
}
|
||||
}
|
||||
|
||||
$t = new CFDictionary();
|
||||
foreach($value as $k => $v) $t->add($k, $this->toCFType($v));
|
||||
|
||||
return $t;
|
||||
break;
|
||||
|
||||
case is_bool($value):
|
||||
return new CFBoolean($value);
|
||||
break;
|
||||
|
||||
case is_null($value):
|
||||
return new CFString();
|
||||
break;
|
||||
|
||||
case is_resource($value):
|
||||
if ($this->suppressExceptions) {
|
||||
return $this->defaultValue();
|
||||
}
|
||||
|
||||
throw new PListException('Could not determine CFType for resource of type '. get_resource_type($value));
|
||||
break;
|
||||
|
||||
case is_numeric($value):
|
||||
if (!$this->castNumericStrings && is_string($value)) {
|
||||
return new CFString($value);
|
||||
}
|
||||
|
||||
return new CFNumber($value);
|
||||
break;
|
||||
|
||||
case is_string($value):
|
||||
if(strpos($value, "\x00") !== false) {
|
||||
return new CFData($value);
|
||||
}
|
||||
return new CFString($value);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($this->suppressExceptions) {
|
||||
return $this->defaultValue();
|
||||
}
|
||||
|
||||
throw new PListException('Could not determine CFType for '. gettype($value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* CFPropertyList
|
||||
* {@link http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/plist.5.html Property Lists}
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @version $Id$
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
|
||||
/**
|
||||
* Basic Input / Output Exception
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
*/
|
||||
class IOException extends \Exception {
|
||||
/**
|
||||
* Flag telling the File could not be found
|
||||
*/
|
||||
const NOT_FOUND = 1;
|
||||
|
||||
/**
|
||||
* Flag telling the File is not readable
|
||||
*/
|
||||
const NOT_READABLE = 2;
|
||||
|
||||
/**
|
||||
* Flag telling the File is not writable
|
||||
*/
|
||||
const NOT_WRITABLE = 3;
|
||||
|
||||
/**
|
||||
* Flag telling there was a read error
|
||||
*/
|
||||
const READ_ERROR = 4;
|
||||
|
||||
/**
|
||||
* Flag telling there was a read error
|
||||
*/
|
||||
const WRITE_ERROR = 5;
|
||||
|
||||
/**
|
||||
* Create new IOException
|
||||
* @param string $path Source of the problem
|
||||
* @param integer $type Type of the problem
|
||||
*/
|
||||
public function __construct($path, $type=null) {
|
||||
parent::__construct( $path, $type );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new FileNotFound-Exception
|
||||
* @param string $path Source of the problem
|
||||
* @return IOException new FileNotFound-Exception
|
||||
*/
|
||||
public static function notFound($path) {
|
||||
return new IOException( $path, self::NOT_FOUND );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new FileNotReadable-Exception
|
||||
* @param string $path Source of the problem
|
||||
* @return IOException new FileNotReadable-Exception
|
||||
*/
|
||||
public static function notReadable($path) {
|
||||
return new IOException( $path, self::NOT_READABLE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new FileNotWritable-Exception
|
||||
* @param string $path Source of the problem
|
||||
* @return IOException new FileNotWritable-Exception
|
||||
*/
|
||||
public static function notWritable($path) {
|
||||
return new IOException( $path, self::NOT_WRITABLE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new ReadError-Exception
|
||||
* @param string $path Source of the problem
|
||||
* @return IOException new ReadError-Exception
|
||||
*/
|
||||
public static function readError($path) {
|
||||
return new IOException( $path, self::READ_ERROR );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new WriteError-Exception
|
||||
* @param string $path Source of the problem
|
||||
* @return IOException new WriteError-Exception
|
||||
*/
|
||||
public static function writeError($path) {
|
||||
return new IOException( $path, self::WRITE_ERROR );
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* CFPropertyList
|
||||
* {@link http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/plist.5.html Property Lists}
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
* @version $Id$
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
|
||||
/**
|
||||
* Exception for errors with the PList format
|
||||
* @author Rodney Rehm <rodney.rehm@medialize.de>
|
||||
* @author Christian Kruse <cjk@wwwtech.de>
|
||||
* @package plist
|
||||
*/
|
||||
class PListException extends \Exception {
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,30 +0,0 @@
|
||||
{
|
||||
"name": "rodneyrehm/plist",
|
||||
"description": "Library for reading and writing Apple's CFPropertyList (plist) files in XML as well as binary format.",
|
||||
"keywords": ["plist"],
|
||||
"type": "library",
|
||||
"homepage": "https://github.com/rodneyrehm/CFPropertyList",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Christian Kruse",
|
||||
"email": "cjk@wwwtech.de"
|
||||
},
|
||||
{
|
||||
"name": "Rodney Rehm",
|
||||
"email": "mail+github@rodneyrehm.de"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/rodneyrehm/CFPropertyList/issues",
|
||||
"source": "https://github.com/rodneyrehm/CFPropertyList"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"CFPropertyList":"classes\/"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Examples for how to use CFPropertyList
|
||||
* Create the PropertyList sample.xml.plist by using the CFPropertyList API.
|
||||
* @package plist
|
||||
* @subpackage plist.examples
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
|
||||
// just in case...
|
||||
error_reporting( E_ALL );
|
||||
ini_set( 'display_errors', 'on' );
|
||||
|
||||
/**
|
||||
* Require CFPropertyList
|
||||
*/
|
||||
require_once(__DIR__.'/../classes/CFPropertyList/CFPropertyList.php');
|
||||
|
||||
|
||||
/*
|
||||
* create a new CFPropertyList instance without loading any content
|
||||
*/
|
||||
$plist = new CFPropertyList();
|
||||
|
||||
/*
|
||||
* Manuall Create the sample.xml.plist
|
||||
*/
|
||||
// the Root element of the PList is a Dictionary
|
||||
$plist->add( $dict = new CFDictionary() );
|
||||
|
||||
// <key>Year Of Birth</key><integer>1965</integer>
|
||||
$dict->add( 'Year Of Birth', new CFNumber( 1965 ) );
|
||||
|
||||
// <key>Date Of Graduation</key><date>2004-06-22T19:23:43Z</date>
|
||||
$dict->add( 'Date Of Graduation', new CFDate( gmmktime( 19, 23, 43, 06, 22, 2004 ) ) );
|
||||
|
||||
// <key>Pets Names</key><array/>
|
||||
$dict->add( 'Pets Names', new CFArray() );
|
||||
|
||||
// <key>Picture</key><data>PEKBpYGlmYFCPA==</data>
|
||||
// to keep it simple we insert an already base64-encoded string
|
||||
$dict->add( 'Picture', new CFData( 'PEKBpYGlmYFCPA==', true ) );
|
||||
|
||||
// <key>City Of Birth</key><string>Springfield</string>
|
||||
$dict->add( 'City Of Birth', new CFString( 'Springfield' ) );
|
||||
|
||||
// <key>Name</key><string>John Doe</string>
|
||||
$dict->add( 'Name', new CFString( 'John Doe' ) );
|
||||
|
||||
// <key>Kids Names</key><array><string>John</string><string>Kyra</string></array>
|
||||
$dict->add( 'Kids Names', $array = new CFArray() );
|
||||
$array->add( new CFString( 'John' ) );
|
||||
$array->add( new CFString( 'Kyra' ) );
|
||||
|
||||
|
||||
/*
|
||||
* Save PList as XML
|
||||
*/
|
||||
$plist->saveXML( __DIR__.'/example-create-01.xml.plist' );
|
||||
|
||||
|
||||
/*
|
||||
* Save PList as Binary
|
||||
*/
|
||||
$plist->saveBinary( __DIR__.'/example-create-01.binary.plist' );
|
||||
|
||||
?>
|
@ -1,61 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Examples for how to use CFPropertyList
|
||||
* Create the PropertyList sample.xml.plist by using {@link CFTypeDetector}.
|
||||
* @package plist
|
||||
* @subpackage plist.examples
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
use \DateTime, \DateTimeZone;
|
||||
|
||||
// just in case...
|
||||
error_reporting( E_ALL );
|
||||
ini_set( 'display_errors', 'on' );
|
||||
|
||||
/**
|
||||
* Require CFPropertyList
|
||||
*/
|
||||
require_once(__DIR__.'/../classes/CFPropertyList/CFPropertyList.php');
|
||||
|
||||
|
||||
/*
|
||||
* create a new CFPropertyList instance without loading any content
|
||||
*/
|
||||
$plist = new CFPropertyList();
|
||||
|
||||
/*
|
||||
* import the array structure to create the sample.xml.plist
|
||||
* We make use of CFTypeDetector, which truly is not almighty!
|
||||
*/
|
||||
|
||||
$structure = array(
|
||||
'Year Of Birth' => 1965,
|
||||
// Note: dates cannot be guessed, so this will become a CFNumber and be treated as an integer
|
||||
// See example-04.php for a possible workaround
|
||||
'Date Of Graduation' => gmmktime( 19, 23, 43, 06, 22, 2004 ),
|
||||
'Date Of Birth' => new DateTime( '1984-09-07 08:15:23', new DateTimeZone( 'Europe/Berlin' ) ),
|
||||
'Pets Names' => array(),
|
||||
// Note: data cannot be guessed, so this will become a CFString
|
||||
// See example-03.php for a possible workaround
|
||||
'Picture' => 'PEKBpYGlmYFCPA==',
|
||||
'City Of Birth' => 'Springfield',
|
||||
'Name' => 'John Doe',
|
||||
'Kids Names' => array( 'John', 'Kyra' ),
|
||||
);
|
||||
|
||||
$td = new CFTypeDetector();
|
||||
$guessedStructure = $td->toCFType( $structure );
|
||||
$plist->add( $guessedStructure );
|
||||
|
||||
|
||||
/*
|
||||
* Save PList as XML
|
||||
*/
|
||||
$plist->saveXML( __DIR__.'/example-create-02.xml.plist' );
|
||||
|
||||
/*
|
||||
* Save PList as Binary
|
||||
*/
|
||||
$plist->saveBinary( __DIR__.'/example-create-02.binary.plist' );
|
||||
|
||||
?>
|
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Examples for how to use CFPropertyList
|
||||
* Create the PropertyList sample.xml.plist by using {@link CFTypeDetector}.
|
||||
* This example shows how to get around the limitation of guess() regarding {@link CFDate} and {@link CFData}.
|
||||
* @package plist
|
||||
* @subpackage plist.examples
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
|
||||
// just in case...
|
||||
error_reporting( E_ALL );
|
||||
ini_set( 'display_errors', 'on' );
|
||||
|
||||
/**
|
||||
* Require CFPropertyList
|
||||
*/
|
||||
require_once(__DIR__.'/../classes/CFPropertyList/CFPropertyList.php');
|
||||
|
||||
|
||||
/*
|
||||
* create a new CFPropertyList instance without loading any content
|
||||
*/
|
||||
$plist = new CFPropertyList();
|
||||
|
||||
/*
|
||||
* import the array structure to create the sample.xml.plist
|
||||
* We make use of CFTypeDetector, which truly is not almighty!
|
||||
*/
|
||||
|
||||
$structure = array(
|
||||
'Year Of Birth' => 1965,
|
||||
// Note: dates cannot be guessed, it thus has to be specified explicitly
|
||||
'Date Of Graduation' => new CFDate( gmmktime( 19, 23, 43, 06, 22, 2004 ) ),
|
||||
'Pets Names' => array(),
|
||||
// Note: data cannot be guessed, it thus has to be specified explicitly
|
||||
'Picture' => new CFData( 'PEKBpYGlmYFCPA==', true ),
|
||||
'City Of Birth' => 'Springfield',
|
||||
'Name' => 'John Doe',
|
||||
'Kids Names' => array( 'John', 'Kyra' ),
|
||||
);
|
||||
|
||||
$td = new CFTypeDetector();
|
||||
$guessedStructure = $td->toCFType( $structure );
|
||||
$plist->add( $guessedStructure );
|
||||
|
||||
|
||||
/*
|
||||
* Save PList as XML
|
||||
*/
|
||||
$plist->saveXML( __DIR__.'/example-create-03.xml.plist' );
|
||||
|
||||
/*
|
||||
* Save PList as Binary
|
||||
*/
|
||||
$plist->saveBinary( __DIR__.'/example-create-03.binary.plist' );
|
||||
|
||||
?>
|
@ -1,92 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Examples for how to use CFPropertyList
|
||||
* Create the PropertyList sample.xml.plist by using {@link CFTypeDetector}.
|
||||
* @package plist
|
||||
* @subpackage plist.examples
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
|
||||
// just in case...
|
||||
error_reporting( E_ALL );
|
||||
ini_set( 'display_errors', 'on' );
|
||||
|
||||
/**
|
||||
* Require CFPropertyList
|
||||
*/
|
||||
require_once(__DIR__.'/../classes/CFPropertyList/CFPropertyList.php');
|
||||
|
||||
class DemoDetector extends CFTypeDetector {
|
||||
|
||||
public function toCFType($value) {
|
||||
if( $value instanceof PListException ) {
|
||||
return new CFString( $value->getMessage() );
|
||||
}
|
||||
|
||||
return parent::toCFType($value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* import the array structure to create the sample.xml.plist
|
||||
* We make use of CFTypeDetector, which truly is not almighty!
|
||||
*/
|
||||
|
||||
$stack = new \SplStack();
|
||||
$stack[] = 1;
|
||||
$stack[] = 2;
|
||||
$stack[] = 3;
|
||||
|
||||
$structure = array(
|
||||
'NullValueTest' => null,
|
||||
'IteratorTest' => $stack,
|
||||
'ObjectTest' => new PListException('Just a test...'),
|
||||
);
|
||||
|
||||
/*
|
||||
* Try default detection
|
||||
*/
|
||||
try {
|
||||
$plist = new CFPropertyList();
|
||||
$td = new CFTypeDetector();
|
||||
$guessedStructure = $td->toCFType( $structure );
|
||||
$plist->add( $guessedStructure );
|
||||
$plist->saveXML( __DIR__.'/example-create-04.xml.plist' );
|
||||
$plist->saveBinary( __DIR__.'/example-create-04.binary.plist' );
|
||||
}
|
||||
catch( PListException $e ) {
|
||||
echo 'Normal detection: ', $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Try detection by omitting exceptions
|
||||
*/
|
||||
try {
|
||||
$plist = new CFPropertyList();
|
||||
$td = new CFTypeDetector( array('suppressExceptions' => true) );
|
||||
$guessedStructure = $td->toCFType( $structure );
|
||||
$plist->add( $guessedStructure );
|
||||
$plist->saveXML( __DIR__.'/example-create-04.xml.plist' );
|
||||
$plist->saveBinary( __DIR__.'/example-create-04.binary.plist' );
|
||||
}
|
||||
catch( PListException $e ) {
|
||||
echo 'Silent detection: ', $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Try detection with an extended version of CFTypeDetector
|
||||
*/
|
||||
try {
|
||||
$plist = new CFPropertyList();
|
||||
$td = new DemoDetector();
|
||||
$guessedStructure = $td->toCFType( $structure );
|
||||
$plist->add( $guessedStructure );
|
||||
$plist->saveXML( __DIR__.'/example-create-04.xml.plist' );
|
||||
$plist->saveBinary( __DIR__.'/example-create-04.binary.plist' );
|
||||
}
|
||||
catch( PListException $e ) {
|
||||
echo 'User defined detection: ', $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Examples for how to use CFPropertyList
|
||||
* Modify a PropertyList
|
||||
* @package plist
|
||||
* @subpackage plist.examples
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
|
||||
// just in case...
|
||||
error_reporting( E_ALL );
|
||||
ini_set( 'display_errors', 'on' );
|
||||
|
||||
/**
|
||||
* Require CFPropertyList
|
||||
*/
|
||||
require_once(__DIR__.'/../classes/CFPropertyList/CFPropertyList.php');
|
||||
|
||||
|
||||
// load an existing list
|
||||
$plist = new CFPropertyList( __DIR__.'/sample.xml.plist' );
|
||||
|
||||
|
||||
foreach( $plist->getValue(true) as $key => $value )
|
||||
{
|
||||
if( $key == "City Of Birth" )
|
||||
{
|
||||
$value->setValue( 'Mars' );
|
||||
}
|
||||
|
||||
if( $value instanceof \Iterator )
|
||||
{
|
||||
// The value is a CFDictionary or CFArray, you may continue down the tree
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// save data
|
||||
$plist->save( __DIR__.'/modified.plist', CFPropertyList::FORMAT_XML );
|
||||
|
||||
?>
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Examples for how to use CFPropertyList
|
||||
* Read an XML PropertyList
|
||||
* @package plist
|
||||
* @subpackage plist.examples
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
|
||||
// just in case...
|
||||
error_reporting( E_ALL );
|
||||
ini_set( 'display_errors', 'on' );
|
||||
|
||||
/**
|
||||
* Require CFPropertyList
|
||||
*/
|
||||
require_once(__DIR__.'/../classes/CFPropertyList/CFPropertyList.php');
|
||||
|
||||
|
||||
/*
|
||||
* create a new CFPropertyList instance which loads the sample.plist on construct.
|
||||
* since we know it's an XML file, we can skip format-determination
|
||||
*/
|
||||
$plist = new CFPropertyList( __DIR__.'/sample.xml.plist', CFPropertyList::FORMAT_XML );
|
||||
|
||||
/*
|
||||
* retrieve the array structure of sample.plist and dump to stdout
|
||||
*/
|
||||
|
||||
echo '<pre>';
|
||||
var_dump( $plist->toArray() );
|
||||
echo '</pre>';
|
||||
|
||||
?>
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Examples for how to use CFPropertyList
|
||||
* Read a Binary PropertyList
|
||||
* @package plist
|
||||
* @subpackage plist.examples
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
|
||||
// just in case...
|
||||
error_reporting( E_ALL );
|
||||
ini_set( 'display_errors', 'on' );
|
||||
|
||||
/**
|
||||
* Require CFPropertyList
|
||||
*/
|
||||
require_once(__DIR__.'/../classes/CFPropertyList/CFPropertyList.php');
|
||||
|
||||
|
||||
/*
|
||||
* create a new CFPropertyList instance which loads the sample.plist on construct.
|
||||
* since we know it's a binary file, we can skip format-determination
|
||||
*/
|
||||
$plist = new CFPropertyList( __DIR__.'/sample.binary.plist', CFPropertyList::FORMAT_BINARY );
|
||||
|
||||
/*
|
||||
* retrieve the array structure of sample.plist and dump to stdout
|
||||
*/
|
||||
|
||||
echo '<pre>';
|
||||
var_dump( $plist->toArray() );
|
||||
echo '</pre>';
|
||||
|
||||
$plist->saveBinary( __DIR__.'/sample.binary.plist' );
|
||||
|
||||
?>
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Examples for how to use CFPropertyList
|
||||
* Read a PropertyList without knowing the type
|
||||
* @package plist
|
||||
* @subpackage plist.examples
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
|
||||
// just in case...
|
||||
error_reporting( E_ALL );
|
||||
ini_set( 'display_errors', 'on' );
|
||||
|
||||
/**
|
||||
* Require CFPropertyList
|
||||
*/
|
||||
require_once(__DIR__.'/../classes/CFPropertyList/CFPropertyList.php');
|
||||
|
||||
|
||||
/*
|
||||
* create a new CFPropertyList instance which loads the sample.plist on construct.
|
||||
* since we know the format, use the automatic format-detection
|
||||
*/
|
||||
$plist = new CFPropertyList( __DIR__.'/sample.binary.plist' );
|
||||
|
||||
/*
|
||||
* retrieve the array structure of sample.plist and dump to stdout
|
||||
*/
|
||||
|
||||
echo '<pre>';
|
||||
var_dump( $plist->toArray() );
|
||||
echo '</pre>';
|
||||
|
||||
$plist->saveBinary( __DIR__.'/sample.binary.plist' );
|
||||
|
||||
?>
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Examples for how to use CFPropertyList with strings
|
||||
* Read a binary from a string PropertyList
|
||||
* @package plist
|
||||
* @subpackage plist.examples
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
|
||||
// just in case...
|
||||
error_reporting( E_ALL );
|
||||
ini_set( 'display_errors', 'on' );
|
||||
|
||||
/**
|
||||
* Require CFPropertyList
|
||||
*/
|
||||
require_once(__DIR__.'/../classes/CFPropertyList/CFPropertyList.php');
|
||||
|
||||
|
||||
/*
|
||||
* create a new CFPropertyList instance which loads the sample.plist on construct.
|
||||
* since we know it's an binary file, we can skip format-determination
|
||||
*/
|
||||
$content = file_get_contents(__DIR__.'/sample.binary.plist');
|
||||
$plist = new CFPropertyList();
|
||||
$plist->parseBinary($content);
|
||||
|
||||
/*
|
||||
* retrieve the array structure of sample.plist and dump to stdout
|
||||
*/
|
||||
|
||||
echo '<pre>';
|
||||
var_dump( $plist->toArray() );
|
||||
echo '</pre>';
|
||||
|
||||
?>
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Examples for how to use CFPropertyList with strings
|
||||
* Read a binary from a string PropertyList
|
||||
* @package plist
|
||||
* @subpackage plist.examples
|
||||
*/
|
||||
namespace CFPropertyList;
|
||||
|
||||
// just in case...
|
||||
error_reporting( E_ALL );
|
||||
ini_set( 'display_errors', 'on' );
|
||||
|
||||
/**
|
||||
* Require CFPropertyList
|
||||
*/
|
||||
require_once(__DIR__.'/../classes/CFPropertyList/CFPropertyList.php');
|
||||
|
||||
|
||||
/*
|
||||
* create a new CFPropertyList instance which loads the sample.plist on construct.
|
||||
* We don't know that it is a binary plist, so we simply call ->parse()
|
||||
*/
|
||||
$content = file_get_contents(__DIR__.'/sample.binary.plist');
|
||||
$plist = new CFPropertyList();
|
||||
$plist->parse($content);
|
||||
|
||||
/*
|
||||
* retrieve the array structure of sample.plist and dump to stdout
|
||||
*/
|
||||
|
||||
echo '<pre>';
|
||||
var_dump( $plist->toArray() );
|
||||
echo '</pre>';
|
||||
|
||||
?>
|
Binary file not shown.
@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Year Of Birth</key>
|
||||
<integer>1965</integer>
|
||||
|
||||
<key>Date Of Graduation</key>
|
||||
<date>2004-06-22T19:23:43Z</date>
|
||||
|
||||
<key>Pets Names</key>
|
||||
<array/>
|
||||
|
||||
<key>Picture</key>
|
||||
<data>PEKBpYGlmYFCPA==</data>
|
||||
|
||||
<key>City Of Birth</key>
|
||||
<string>Springfield</string>
|
||||
|
||||
<key>Name</key>
|
||||
<string>John Doe</string>
|
||||
|
||||
<key>Kids Names</key>
|
||||
<array>
|
||||
<string>John</string>
|
||||
<string>Kyra</string>
|
||||
</array>
|
||||
|
||||
</dict>
|
||||
</plist>
|
@ -1,122 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace CFPropertyList;
|
||||
|
||||
error_reporting(E_ALL|E_STRICT);
|
||||
ini_set('display_errors','on');
|
||||
|
||||
if(!defined('LIBDIR')) {
|
||||
define('LIBDIR',__DIR__.'/../classes/CFPropertyList');
|
||||
}
|
||||
|
||||
if(!defined('TEST_BINARY_DATA_FILE')) {
|
||||
define('TEST_BINARY_DATA_FILE',__DIR__.'/binary-data.plist');
|
||||
define('TEST_UID_BPLIST', __DIR__ . '/uid-list.plist');
|
||||
}
|
||||
|
||||
require_once(LIBDIR.'/CFPropertyList.php');
|
||||
|
||||
class BinaryParseTest extends \PHPUnit_Framework_TestCase {
|
||||
public function testParseBinary() {
|
||||
$plist = new CFPropertyList(TEST_BINARY_DATA_FILE);
|
||||
|
||||
$vals = $plist->toArray();
|
||||
$this->assertEquals(count($vals),4);
|
||||
|
||||
$this->assertEquals($vals['names']['given-name'],'John');
|
||||
$this->assertEquals($vals['names']['surname'],'Dow');
|
||||
|
||||
$this->assertEquals($vals['pets'][0],'Jonny');
|
||||
$this->assertEquals($vals['pets'][1],'Bello');
|
||||
|
||||
$this->assertEquals($vals['age'],28);
|
||||
$this->assertEquals($vals['birth-date'],412035803);
|
||||
}
|
||||
|
||||
public function testParseBinaryString() {
|
||||
$content = file_get_contents(TEST_BINARY_DATA_FILE);
|
||||
|
||||
$plist = new CFPropertyList();
|
||||
$plist->parse($content);
|
||||
|
||||
$vals = $plist->toArray();
|
||||
$this->assertEquals(count($vals),4);
|
||||
|
||||
$this->assertEquals($vals['names']['given-name'],'John');
|
||||
$this->assertEquals($vals['names']['surname'],'Dow');
|
||||
|
||||
$this->assertEquals($vals['pets'][0],'Jonny');
|
||||
$this->assertEquals($vals['pets'][1],'Bello');
|
||||
|
||||
$this->assertEquals($vals['age'],28);
|
||||
$this->assertEquals($vals['birth-date'],412035803);
|
||||
}
|
||||
|
||||
public function testParseStream() {
|
||||
$plist = new CFPropertyList();
|
||||
if(($fd = fopen(TEST_BINARY_DATA_FILE,"rb")) == NULL) {
|
||||
throw new IOException("Error opening test data file for reading!");
|
||||
}
|
||||
|
||||
$plist->readBinaryStream($fd);
|
||||
|
||||
$vals = $plist->toArray();
|
||||
$this->assertEquals(count($vals),4);
|
||||
|
||||
$this->assertEquals($vals['names']['given-name'],'John');
|
||||
$this->assertEquals($vals['names']['surname'],'Dow');
|
||||
|
||||
$this->assertEquals($vals['pets'][0],'Jonny');
|
||||
$this->assertEquals($vals['pets'][1],'Bello');
|
||||
|
||||
$this->assertEquals($vals['age'],28);
|
||||
$this->assertEquals($vals['birth-date'],412035803);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException CFPropertyList\PListException
|
||||
*/
|
||||
public function testEmptyString() {
|
||||
$plist = new CFPropertyList();
|
||||
$plist->parseBinary('');
|
||||
}
|
||||
|
||||
public function testInvalidString() {
|
||||
$catched = false;
|
||||
|
||||
try {
|
||||
$plist = new CFPropertyList();
|
||||
$plist->parseBinary('lalala');
|
||||
}
|
||||
catch(PListException $e) {
|
||||
$catched = true;
|
||||
}
|
||||
|
||||
if($catched == false) {
|
||||
$this->fail('No exception thrown for invalid string!');
|
||||
}
|
||||
|
||||
$catched = false;
|
||||
try {
|
||||
$plist = new CFPropertyList();
|
||||
$plist->parseBinary('bplist00dfwefwefwef');
|
||||
}
|
||||
catch(PListException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail('No exception thrown for invalid string!');
|
||||
}
|
||||
|
||||
public function testUidPlist() {
|
||||
$plist = new CFPropertyList(TEST_UID_BPLIST);
|
||||
$val = $plist->toArray();
|
||||
$this->assertEquals(array('test' => 1), $val);
|
||||
|
||||
$v = $plist->getValue()->getValue();
|
||||
$this->assertTrue($v['test'] instanceof CFUid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# eof
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace CFPropertyList;
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
ini_set('display_errors', 'on');
|
||||
|
||||
if (!defined('LIBDIR')) {
|
||||
define('LIBDIR', __DIR__ . '/../classes/CFPropertyList');
|
||||
}
|
||||
|
||||
require_once(LIBDIR . '/CFPropertyList.php');
|
||||
|
||||
class EmptyElementsTest extends \PHPUnit_Framework_TestCase {
|
||||
public function testWriteFile() {
|
||||
$expected = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0"><dict><key>string</key><string/><key>number</key><integer>0</integer><key>double</key><real>0</real></dict></plist>
|
||||
';
|
||||
|
||||
$plist = new CFPropertyList();
|
||||
$dict = new CFDictionary();
|
||||
|
||||
$dict->add('string', new CFString(''));
|
||||
$dict->add('number', new CFNumber(0));
|
||||
$dict->add('double', new CFNumber(0.0));
|
||||
|
||||
$plist->add($dict);
|
||||
$this->assertEquals($expected, $plist->toXML());
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace CFPropertyList;
|
||||
|
||||
error_reporting(E_ALL|E_STRICT);
|
||||
ini_set('display_errors','on');
|
||||
|
||||
if(!defined('LIBDIR')) {
|
||||
define('LIBDIR',__DIR__.'/../classes/CFPropertyList');
|
||||
}
|
||||
|
||||
if(!defined('TEST_XML_DATA_FILE')) {
|
||||
define('TEST_XML_DATA_FILE',__DIR__.'/xml-data.plist');
|
||||
define('TEST_UID_XML_PLIST', __DIR__ . '/uid-list.xml');
|
||||
}
|
||||
|
||||
require_once(LIBDIR.'/CFPropertyList.php');
|
||||
|
||||
class ParseXMLTest extends \PHPUnit_Framework_TestCase {
|
||||
public function testParse() {
|
||||
$plist = new CFPropertyList(TEST_XML_DATA_FILE);
|
||||
|
||||
$vals = $plist->toArray();
|
||||
$this->assertEquals(count($vals),4);
|
||||
|
||||
$this->assertEquals($vals['names']['given-name'],'John');
|
||||
$this->assertEquals($vals['names']['surname'],'Dow');
|
||||
|
||||
$this->assertEquals($vals['pets'][0],'Jonny');
|
||||
$this->assertEquals($vals['pets'][1],'Bello');
|
||||
|
||||
$this->assertEquals($vals['age'],28);
|
||||
$this->assertEquals($vals['birth-date'],412035803);
|
||||
}
|
||||
|
||||
public function testParseString() {
|
||||
$content = file_get_contents(TEST_XML_DATA_FILE);
|
||||
|
||||
$plist = new CFPropertyList();
|
||||
$plist->parse($content);
|
||||
|
||||
$vals = $plist->toArray();
|
||||
$this->assertEquals(count($vals),4);
|
||||
|
||||
$this->assertEquals($vals['names']['given-name'],'John');
|
||||
$this->assertEquals($vals['names']['surname'],'Dow');
|
||||
|
||||
$this->assertEquals($vals['pets'][0],'Jonny');
|
||||
$this->assertEquals($vals['pets'][1],'Bello');
|
||||
|
||||
$this->assertEquals($vals['age'],28);
|
||||
$this->assertEquals($vals['birth-date'],412035803);
|
||||
}
|
||||
|
||||
public function testParseStream() {
|
||||
$plist = new CFPropertyList();
|
||||
if(($fd = fopen(TEST_XML_DATA_FILE,"r")) == NULL) {
|
||||
throw new IOException("Error opening test data file for reading!");
|
||||
}
|
||||
|
||||
$plist->loadXMLStream($fd);
|
||||
|
||||
$vals = $plist->toArray();
|
||||
$this->assertEquals(count($vals),4);
|
||||
|
||||
$this->assertEquals($vals['names']['given-name'],'John');
|
||||
$this->assertEquals($vals['names']['surname'],'Dow');
|
||||
|
||||
$this->assertEquals($vals['pets'][0],'Jonny');
|
||||
$this->assertEquals($vals['pets'][1],'Bello');
|
||||
|
||||
$this->assertEquals($vals['age'],28);
|
||||
$this->assertEquals($vals['birth-date'],412035803);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException CFPropertyList\IOException
|
||||
*/
|
||||
public function testEmptyString() {
|
||||
$plist = new CFPropertyList();
|
||||
$plist->parse('');
|
||||
}
|
||||
|
||||
public function testInvalidString() {
|
||||
$catched = false;
|
||||
|
||||
try {
|
||||
$plist = new CFPropertyList();
|
||||
$plist->parse('lalala');
|
||||
}
|
||||
catch(\DOMException $e) {
|
||||
$catched = true;
|
||||
}
|
||||
catch(\PHPUnit_Framework_Error $e) {
|
||||
$catched = true;
|
||||
}
|
||||
|
||||
if($catched == false) {
|
||||
$this->fail('No exception thrown for invalid string!');
|
||||
}
|
||||
|
||||
$catched = false;
|
||||
try {
|
||||
$plist = new CFPropertyList();
|
||||
$plist->parse('<plist>');
|
||||
}
|
||||
catch(PListException $e) {
|
||||
return;
|
||||
}
|
||||
catch(\PHPUnit_Framework_Error $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail('No exception thrown for invalid string!');
|
||||
}
|
||||
|
||||
public function testUidPlist() {
|
||||
$plist = new CFPropertyList(TEST_UID_XML_PLIST);
|
||||
$val = $plist->toArray();
|
||||
$this->assertEquals(array('test' => 1), $val);
|
||||
$v = $plist->getValue()->getValue();
|
||||
$this->assertTrue($v['test'] instanceof CFUid);
|
||||
}
|
||||
}
|
||||
|
||||
# eof
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace CFPropertyList;
|
||||
|
||||
error_reporting(E_ALL|E_STRICT);
|
||||
ini_set('display_errors','on');
|
||||
|
||||
if(!defined('LIBDIR')) {
|
||||
define('LIBDIR',__DIR__.'/../classes/CFPropertyList');
|
||||
}
|
||||
|
||||
if(!defined('WRITE_BINARY_DATA_FILE')) {
|
||||
define('WRITE_BINARY_DATA_FILE',__DIR__.'/binary.plist');
|
||||
define('TEST_UID_BPLIST', __DIR__ . '/uid-list.plist');
|
||||
}
|
||||
|
||||
require_once(LIBDIR.'/CFPropertyList.php');
|
||||
|
||||
class WriteBinaryTest extends \PHPUnit_Framework_TestCase {
|
||||
public function testWriteFile() {
|
||||
$plist = new CFPropertyList();
|
||||
$dict = new CFDictionary();
|
||||
|
||||
$names = new CFDictionary();
|
||||
$names->add('given-name',new CFString('John'));
|
||||
$names->add('surname',new CFString('Dow'));
|
||||
|
||||
$dict->add('names',$names);
|
||||
|
||||
$pets = new CFArray();
|
||||
$pets->add(new CFString('Jonny'));
|
||||
$pets->add(new CFString('Bello'));
|
||||
$dict->add('pets',$pets);
|
||||
|
||||
$dict->add('age',new CFNumber(28));
|
||||
$dict->add('birth-date',new CFDate(412035803));
|
||||
|
||||
$plist->add($dict);
|
||||
$plist->saveBinary(WRITE_BINARY_DATA_FILE);
|
||||
|
||||
$this->assertTrue(is_file(WRITE_BINARY_DATA_FILE));
|
||||
$this->assertTrue(filesize(WRITE_BINARY_DATA_FILE) > 32);
|
||||
|
||||
$plist->load(WRITE_BINARY_DATA_FILE);
|
||||
|
||||
unlink(WRITE_BINARY_DATA_FILE);
|
||||
}
|
||||
|
||||
public function testWriteString() {
|
||||
$plist = new CFPropertyList();
|
||||
$dict = new CFDictionary();
|
||||
|
||||
$names = new CFDictionary();
|
||||
$names->add('given-name',new CFString('John'));
|
||||
$names->add('surname',new CFString('Dow'));
|
||||
|
||||
$dict->add('names',$names);
|
||||
|
||||
$pets = new CFArray();
|
||||
$pets->add(new CFString('Jonny'));
|
||||
$pets->add(new CFString('Bello'));
|
||||
$dict->add('pets',$pets);
|
||||
|
||||
$dict->add('age',new CFNumber(28));
|
||||
$dict->add('birth-date',new CFDate(412035803));
|
||||
|
||||
$plist->add($dict);
|
||||
$content = $plist->toBinary();
|
||||
|
||||
$this->assertTrue(strlen($content) > 32);
|
||||
|
||||
$plist->parse($content);
|
||||
}
|
||||
|
||||
public function testWriteUid() {
|
||||
$plist = new CFPropertyList();
|
||||
$dict = new CFDictionary();
|
||||
$dict->add('test', new CFUid(1));
|
||||
$plist->add($dict);
|
||||
|
||||
$plist1 = new CFPropertyList(TEST_UID_BPLIST);
|
||||
$this->assertEquals($plist1->toBinary(), $plist->toBinary());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# eof
|
@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace CFPropertyList;
|
||||
|
||||
error_reporting(E_ALL|E_STRICT);
|
||||
ini_set('display_errors','on');
|
||||
|
||||
if(!defined('LIBDIR')) {
|
||||
define('LIBDIR',__DIR__.'/../classes/CFPropertyList');
|
||||
}
|
||||
|
||||
if(!defined('WRITE_XML_DATA_FILE')) {
|
||||
define('WRITE_XML_DATA_FILE',__DIR__.'/binary.plist');
|
||||
define('TEST_UID_XML_PLIST', __DIR__ . '/uid-list.xml');
|
||||
}
|
||||
|
||||
require_once(LIBDIR.'/CFPropertyList.php');
|
||||
|
||||
class WriteXMLTest extends \PHPUnit_Framework_TestCase {
|
||||
public function testWriteFile() {
|
||||
$plist = new CFPropertyList();
|
||||
$dict = new CFDictionary();
|
||||
|
||||
$names = new CFDictionary();
|
||||
$names->add('given-name',new CFString('John'));
|
||||
$names->add('surname',new CFString('Dow'));
|
||||
|
||||
$dict->add('names',$names);
|
||||
|
||||
$pets = new CFArray();
|
||||
$pets->add(new CFString('Jonny'));
|
||||
$pets->add(new CFString('Bello'));
|
||||
$dict->add('pets',$pets);
|
||||
|
||||
$dict->add('age',new CFNumber(28));
|
||||
$dict->add('birth-date',new CFDate(412035803));
|
||||
|
||||
$plist->add($dict);
|
||||
$plist->saveXML(WRITE_XML_DATA_FILE);
|
||||
|
||||
$this->assertTrue(is_file(WRITE_XML_DATA_FILE));
|
||||
|
||||
$plist->load(WRITE_XML_DATA_FILE);
|
||||
|
||||
unlink(WRITE_XML_DATA_FILE);
|
||||
}
|
||||
|
||||
public function testWriteString() {
|
||||
$plist = new CFPropertyList();
|
||||
$dict = new CFDictionary();
|
||||
|
||||
$names = new CFDictionary();
|
||||
$names->add('given-name',new CFString('John'));
|
||||
$names->add('surname',new CFString('Dow'));
|
||||
|
||||
$dict->add('names',$names);
|
||||
|
||||
$pets = new CFArray();
|
||||
$pets->add(new CFString('Jonny'));
|
||||
$pets->add(new CFString('Bello'));
|
||||
$dict->add('pets',$pets);
|
||||
|
||||
$dict->add('age',new CFNumber(28));
|
||||
$dict->add('birth-date',new CFDate(412035803));
|
||||
|
||||
$plist->add($dict);
|
||||
$content = $plist->toXML();
|
||||
|
||||
$plist->parse($content);
|
||||
}
|
||||
|
||||
public
|
||||
function testWriteUid() {
|
||||
$plist = new CFPropertyList();
|
||||
$dict = new CFDictionary();
|
||||
$dict->add('test', new CFUid(1));
|
||||
$plist->add($dict);
|
||||
|
||||
$plist1 = new CFPropertyList(TEST_UID_XML_PLIST);
|
||||
$this->assertEquals($plist1->toXml(), $plist->toXml());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# eof
|
Binary file not shown.
Binary file not shown.
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>test</key>
|
||||
<dict>
|
||||
<key>CF$UID</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>age</key>
|
||||
<string>28</string>
|
||||
<key>birth-date</key>
|
||||
<date>1983-01-21T22:23:23Z</date>
|
||||
<key>names</key>
|
||||
<dict>
|
||||
<key>given-name</key>
|
||||
<string>John</string>
|
||||
<key>surname</key>
|
||||
<string>Dow</string>
|
||||
</dict>
|
||||
<key>pets</key>
|
||||
<array>
|
||||
<string>Jonny</string>
|
||||
<string>Bello</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
Loading…
Reference in New Issue