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()); }
public function encode($data, $human_readable = false) { require_once 'CFPropertyList.php'; if (!PlistFormat::$binary_mode) { PlistFormat::$binary_mode = !$human_readable; } else { $human_readable = false; } $plist = new CFPropertyList(); $td = new CFTypeDetector(); $guessedStructure = $td->toCFType(object_to_array($data)); $plist->add($guessedStructure); return $human_readable ? $plist->toXML(true) : $plist->toBinary(); }
public function frontendOutputPostGenerate($context) { if (!array_key_exists('plist', $_GET)) { return; } require_once "lib/CFPropertyList/CFPropertyList.php"; $xmlIterator = new SimpleXMLIterator($context['output']); $xmlArray = $this->sxiToArray($xmlIterator); $plist = new CFPropertyList(); $td = new CFTypeDetector(); $guessedStructure = $td->toCFType($xmlArray); $plist->add($guessedStructure); if ($_GET['plist'] == "binary") { echo $plist->toBinary(); } else { echo $plist->toXML(); } die; }
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); }