mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Fixing XML support in Model and Set classes
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6427 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
71bd08b950
commit
acfc38e57d
4 changed files with 56 additions and 42 deletions
|
@ -792,7 +792,7 @@ class Set extends Object {
|
||||||
$out = array();
|
$out = array();
|
||||||
if (is_a($object, 'xmlnode') || is_a($object, 'XMLNode')) {
|
if (is_a($object, 'xmlnode') || is_a($object, 'XMLNode')) {
|
||||||
if (isset($object->name) && isset($object->children)) {
|
if (isset($object->name) && isset($object->children)) {
|
||||||
if ($object->name === 'root' && !empty($object->children)) {
|
if ($object->name === '#document' && !empty($object->children)) {
|
||||||
$out = Set::reverse($object->children[0]);
|
$out = Set::reverse($object->children[0]);
|
||||||
} else {
|
} else {
|
||||||
$children = array();
|
$children = array();
|
||||||
|
|
|
@ -1185,7 +1185,8 @@ class XMLManager {
|
||||||
'fb' => 'http://rssnamespace.org/feedburner/ext/1.0', // FeedBurner extensions
|
'fb' => 'http://rssnamespace.org/feedburner/ext/1.0', // FeedBurner extensions
|
||||||
'lj' => 'http://www.livejournal.org/rss/lj/1.0/', // Live Journal
|
'lj' => 'http://www.livejournal.org/rss/lj/1.0/', // Live Journal
|
||||||
'itunes' => 'http://www.itunes.com/dtds/podcast-1.0.dtd', // iTunes
|
'itunes' => 'http://www.itunes.com/dtds/podcast-1.0.dtd', // iTunes
|
||||||
'xhtml' => 'http://www.w3.org/1999/xhtml' // XHTML
|
'xhtml' => 'http://www.w3.org/1999/xhtml', // XHTML,
|
||||||
|
'atom' => 'http://www.w3.org/2005/Atom' // Atom
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* Returns a reference to the global XML object that manages app-wide XML settings
|
* Returns a reference to the global XML object that manages app-wide XML settings
|
||||||
|
|
|
@ -1990,10 +1990,10 @@ class ModelTest extends CakeTestCase {
|
||||||
|
|
||||||
function testSaveFromXml() {
|
function testSaveFromXml() {
|
||||||
$this->loadFixtures('Article');
|
$this->loadFixtures('Article');
|
||||||
if (!class_exists('Xml')) {
|
App::import('Core', 'Xml');
|
||||||
uses('xml');
|
|
||||||
}
|
|
||||||
$Article = new Article();
|
$Article = new Article();
|
||||||
|
$Article->save(new Xml('<article title="test xml" user_id="5" />'));
|
||||||
$this->assertTrue($Article->save(new Xml('<article title="test xml" user_id="5" />')));
|
$this->assertTrue($Article->save(new Xml('<article title="test xml" user_id="5" />')));
|
||||||
|
|
||||||
$results = $Article->find(array('Article.title' => 'test xml'));
|
$results = $Article->find(array('Article.title' => 'test xml'));
|
||||||
|
|
|
@ -429,6 +429,18 @@ class SetTest extends UnitTestCase {
|
||||||
$result = Set::reverse($map);
|
$result = Set::reverse($map);
|
||||||
$this->assertIdentical($result, $expected);
|
$this->assertIdentical($result, $expected);
|
||||||
|
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
'Post' => array('id'=> 1, 'title' => 'First Post'),
|
||||||
|
'Comment' => array(
|
||||||
|
array('id'=> 1, 'title' => 'First Comment'),
|
||||||
|
array('id'=> 2, 'title' => 'Second Comment')
|
||||||
|
),
|
||||||
|
'Tag' => array(
|
||||||
|
array('id'=> 1, 'title' => 'First Tag'),
|
||||||
|
array('id'=> 2, 'title' => 'Second Tag')
|
||||||
|
),
|
||||||
|
);
|
||||||
$map = Set::map($expected);
|
$map = Set::map($expected);
|
||||||
$this->assertIdentical($map->title, $expected['Post']['title']);
|
$this->assertIdentical($map->title, $expected['Post']['title']);
|
||||||
foreach ($map->Comment as $comment) {
|
foreach ($map->Comment as $comment) {
|
||||||
|
@ -942,9 +954,8 @@ class SetTest extends UnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testXmlSetReverse() {
|
function testXmlSetReverse() {
|
||||||
if (!class_exists('Xml')) {
|
App::import('Core', 'Xml');
|
||||||
uses('Xml');
|
|
||||||
}
|
|
||||||
$string = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
$string = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<rss version="2.0">
|
<rss version="2.0">
|
||||||
<channel>
|
<channel>
|
||||||
|
@ -972,21 +983,24 @@ class SetTest extends UnitTestCase {
|
||||||
</rss>';
|
</rss>';
|
||||||
$xml = new Xml($string);
|
$xml = new Xml($string);
|
||||||
$result = Set::reverse($xml);
|
$result = Set::reverse($xml);
|
||||||
$expected = array('Rss' => array('version' => '2.0',
|
$expected = array('Rss' => array(
|
||||||
|
'version' => '2.0',
|
||||||
'Channel' => array(
|
'Channel' => array(
|
||||||
array('title' => 'Cake PHP Google Group',
|
array('title' => 'Cake PHP Google Group',
|
||||||
'link' => 'http://groups.google.com/group/cake-php',
|
'link' => 'http://groups.google.com/group/cake-php',
|
||||||
'description' => 'Search this group before posting anything. There are over 20,000 posts and it's very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.',
|
'description' => 'Search this group before posting anything. There are over 20,000 posts and it's very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.',
|
||||||
'language' => 'en',
|
'language' => 'en',
|
||||||
'Item' => array(
|
'Item' => array(
|
||||||
array('title' => 'constructng result array when using findall',
|
array(
|
||||||
|
'title' => 'constructng result array when using findall',
|
||||||
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
|
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
|
||||||
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br><p>Array( <br> [0] => Array(",
|
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br><p>Array( <br> [0] => Array(",
|
||||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
|
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
|
||||||
'author' => 'bmil...@gmail.com(bpscrugs)',
|
'author' => 'bmil...@gmail.com(bpscrugs)',
|
||||||
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
|
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
|
||||||
),
|
),
|
||||||
array('title' => 'Re: share views between actions?',
|
array(
|
||||||
|
'title' => 'Re: share views between actions?',
|
||||||
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
|
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
|
||||||
'description' => 'Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other',
|
'description' => 'Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other',
|
||||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
|
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
|
||||||
|
@ -996,8 +1010,7 @@ class SetTest extends UnitTestCase {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
));
|
||||||
);
|
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$string ='<data><post title="Title of this post" description="cool" /></data>';
|
$string ='<data><post title="Title of this post" description="cool" /></data>';
|
||||||
|
|
Loading…
Add table
Reference in a new issue