mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46: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();
|
||||
if (is_a($object, 'xmlnode') || is_a($object, 'XMLNode')) {
|
||||
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]);
|
||||
} else {
|
||||
$children = array();
|
||||
|
|
|
@ -1177,15 +1177,16 @@ class XMLManager {
|
|||
* @var array
|
||||
*/
|
||||
var $__defaultNamespaceMap = array(
|
||||
'dc' => 'http://purl.org/dc/elements/1.1/', // Dublin Core
|
||||
'dct' => 'http://purl.org/dc/terms/', // Dublin Core Terms
|
||||
'g' => 'http://base.google.com/ns/1.0', // Google Base
|
||||
'rc' => 'http://purl.org/rss/1.0/modules/content/', // RSS 1.0 Content Module
|
||||
'wf' => 'http://wellformedweb.org/CommentAPI/', // Well-Formed Web Comment API
|
||||
'fb' => 'http://rssnamespace.org/feedburner/ext/1.0', // FeedBurner extensions
|
||||
'lj' => 'http://www.livejournal.org/rss/lj/1.0/', // Live Journal
|
||||
'itunes' => 'http://www.itunes.com/dtds/podcast-1.0.dtd', // iTunes
|
||||
'xhtml' => 'http://www.w3.org/1999/xhtml' // XHTML
|
||||
'dc' => 'http://purl.org/dc/elements/1.1/', // Dublin Core
|
||||
'dct' => 'http://purl.org/dc/terms/', // Dublin Core Terms
|
||||
'g' => 'http://base.google.com/ns/1.0', // Google Base
|
||||
'rc' => 'http://purl.org/rss/1.0/modules/content/', // RSS 1.0 Content Module
|
||||
'wf' => 'http://wellformedweb.org/CommentAPI/', // Well-Formed Web Comment API
|
||||
'fb' => 'http://rssnamespace.org/feedburner/ext/1.0', // FeedBurner extensions
|
||||
'lj' => 'http://www.livejournal.org/rss/lj/1.0/', // Live Journal
|
||||
'itunes' => 'http://www.itunes.com/dtds/podcast-1.0.dtd', // iTunes
|
||||
'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
|
||||
|
|
|
@ -1990,10 +1990,10 @@ class ModelTest extends CakeTestCase {
|
|||
|
||||
function testSaveFromXml() {
|
||||
$this->loadFixtures('Article');
|
||||
if (!class_exists('Xml')) {
|
||||
uses('xml');
|
||||
}
|
||||
App::import('Core', 'Xml');
|
||||
|
||||
$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" />')));
|
||||
|
||||
$results = $Article->find(array('Article.title' => 'test xml'));
|
||||
|
|
|
@ -429,6 +429,18 @@ class SetTest extends UnitTestCase {
|
|||
$result = Set::reverse($map);
|
||||
$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);
|
||||
$this->assertIdentical($map->title, $expected['Post']['title']);
|
||||
foreach ($map->Comment as $comment) {
|
||||
|
@ -942,9 +954,8 @@ class SetTest extends UnitTestCase {
|
|||
}
|
||||
|
||||
function testXmlSetReverse() {
|
||||
if (!class_exists('Xml')) {
|
||||
uses('Xml');
|
||||
}
|
||||
App::import('Core', 'Xml');
|
||||
|
||||
$string = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
|
@ -972,32 +983,34 @@ class SetTest extends UnitTestCase {
|
|||
</rss>';
|
||||
$xml = new Xml($string);
|
||||
$result = Set::reverse($xml);
|
||||
$expected = array('Rss' => array('version' => '2.0',
|
||||
'Channel' => array(
|
||||
array('title' => 'Cake PHP Google Group',
|
||||
'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.',
|
||||
'language' => 'en',
|
||||
'Item' => array(
|
||||
array('title' => 'constructng result array when using findall',
|
||||
'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(",
|
||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
|
||||
'author' => 'bmil...@gmail.com(bpscrugs)',
|
||||
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
|
||||
),
|
||||
array('title' => 'Re: share views between actions?',
|
||||
'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',
|
||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
|
||||
'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)',
|
||||
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$expected = array('Rss' => array(
|
||||
'version' => '2.0',
|
||||
'Channel' => array(
|
||||
array('title' => 'Cake PHP Google Group',
|
||||
'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.',
|
||||
'language' => 'en',
|
||||
'Item' => array(
|
||||
array(
|
||||
'title' => 'constructng result array when using findall',
|
||||
'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(",
|
||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
|
||||
'author' => 'bmil...@gmail.com(bpscrugs)',
|
||||
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
|
||||
),
|
||||
array(
|
||||
'title' => 'Re: share views between actions?',
|
||||
'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',
|
||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
|
||||
'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)',
|
||||
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$string ='<data><post title="Title of this post" description="cool" /></data>';
|
||||
|
|
Loading…
Add table
Reference in a new issue