Permalink
Browse files

fields can be set to custom xml now

  • Loading branch information...
shama committed Oct 9, 2010
1 parent f39db22 commit d1fed995bca8ba17085728ffd0692ab90502ef4a
Showing with 28 additions and 34 deletions.
  1. +11 −10 README.md
  2. +14 −9 models/datasources/freshbooks_source.php
  3. +3 −15 models/project.php
View
@@ -148,21 +148,22 @@ FreshCake is offered under an [MIT license](http://www.opensource.org/licenses/m
## Roadmap and Known Issues
* MORE TESTING! MORE TESTS!
-* Fix issue with some text fields showing up as Array
-* Format lines/xml on invoice, estimate and recurring afterFind (so they dont break scaffold)
-* Implement estimate.sendByEmail
-* Implement invoice.sendByEmail, invoice.sendBySnailMail
-* Implement recurring.auto_bill
-* Implement staff.current
-* Implement OAuth support
-* Add support for staff (needs custom afterFind)
-* Test support for linking models together (hopefully already does automatically)
-* i18n
+* Fix issue with some text fields showing up as Array - v0.2
+* Format lines/xml on invoice, estimate and recurring afterFind (so they dont break scaffold) - v0.2
+* Implement estimate.sendByEmail - v0.2
+* Implement invoice.sendByEmail, invoice.sendBySnailMail - v0.2
+* Implement recurring.auto_bill - v0.2
+* Implement staff.current - v0.2
+* Add support for staff (needs custom afterFind) - v0.2
+* Test support for linking models together (hopefully already does automatically) - v0.2
+* Implement OAuth support - v0.3
+* i18n - v0.3
## Changelog
### 0.2
+* Fields can be set to custom XML now (needed for fixing tasks in project)
* Added test cases for callback.verify, callback.resendToken
* Added support for callback.verify, callback.resendToken
* Added methods to return last request and response xml
@@ -230,16 +230,21 @@ public function create(&$model, $fields=null, $values=null) {
$submethod = 'create';
}
$xml =& new Xml(array('Request' => array('method' => $method.'.'.$submethod)));
- if (!isset($data['xml'])) {
- foreach ($data as $key => $val) {
- if (is_array($val)) {
- $singular = Inflector::singularize($key);
- $data[$key] = array($singular => $val);
- }
+ $node =& new Xml(array($method => array()));
+ foreach ($data as $key => $val) {
+ if (is_array($val)) {
+ $singular = Inflector::singularize($key);
+ $val = array($key => array($singular => $val));
+ $node->first()->append($val, array('format' => 'tags'));
+ unset($data[$key]);
+ } elseif (substr($val, 0, 1) == '<') {
+ $my_node =& new Xml($val);
+ $node->first()->append($my_node->children);
+ unset($data[$key]);
+ } else {
+ $my = array($key => array(array($val)));
+ $node->first()->append($my);
}
- $node =& new Xml(array($method => $data), array('format' => 'tags'));
- } else {
- $node =& new Xml($data['xml']);
}
$xml->first()->append($node->children);
$this->__requestXml = $xml->toString(array('header' => true));
View
@@ -44,10 +44,6 @@ class Project extends FreshbooksAppModel {
'type' => 'text',
'null' => true,
),
- 'xml' => array(
- 'type' => 'text',
- 'null' => true,
- ),
);
public $validate = array(
'name' => 'notEmpty',
@@ -56,8 +52,8 @@ class Project extends FreshbooksAppModel {
/**
* beforeSave
- * Custom format because datasource
- * can't handle 'tasks'.
+ * Set tasks to xml as the datasource
+ * cant handle it automatically
*
* @return boolean
*/
@@ -68,15 +64,7 @@ public function beforeSave() {
array('tasks' => $this->data[$this->name]['tasks']),
array('format' => 'tags')
);
- unset($this->data[$this->name]['tasks']);
- $data =& new Xml($this->data, array('format' => 'tags'));
- $data->first()->append($tasks->children);
- $xml = $data->toString();
- $this->data = array(
- $this->name => array(
- 'xml' => $xml,
- ),
- );
+ $this->data[$this->name]['tasks'] = $tasks->toString();
}
return true;
}

0 comments on commit d1fed99

Please sign in to comment.