Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.2

Bug #1448 [patch] Use getLink() instead of links()
Submitted: 2004-05-19 22:36 UTC
From: justinpatrin Assigned: mw21st
Status: Closed Package: DB_DataObject_FormBuilder
PHP Version: Irrelevant OS: N/A
Roadmaps: (Not assigned)    
Subscription  


 [2004-05-19 22:36 UTC] justinpatrin
Description: ------------ I've made a small change to getDataObjectSelectDisplayValue() that makes use of getLink() instead of links(). It's much better IMHO than parsing the links() entries. You might want to try to figure out some similar thing for getSelectOptions(). Here's a diff (to newest release, not CVS). @@ -733,10 +733,6 @@ */ function getDataObjectSelectDisplayValue(&$do, $displayfield = false, $level = 1) { global $_DB_DATAOBJECT_FORMBUILDER; - if(@$_DB_DATAOBJECT_FORMBUILDER['CONFIG']['follow_links'] > $level) { - $links = $do->links(); - //$do->getLinks(); - } if ($displayfield === false) { if (isset($_DB_DATAOBJECT_FORMBUILDER['INI'][$do->database()][$do->tableName().'__display_fields'])) { $displayfield = $_DB_DATAOBJECT_FORMBUILDER['INI'][$do->database()][$do->tableName().'__display_fields']; @@ -758,13 +754,7 @@ $ret .= ', '; } if (isset($do->$field)) { - //$objField = '_'.$field; - //if (isset($do->$objField)) { - if(@$links[$field]) { - list($table, $linkField) = explode(':', $links[$field]); - $subDo = DB_DataObject::factory($table); - $subDo->get($linkField, $do->$field); - //$ret .= '('.$this->getDataObjectSelectDisplayValue($do->$objField, false, $level + 1).')'; + if(@$_DB_DATAOBJECT_FORMBUILDER['CONFIG']['follow_links'] > $level && $subDo = $do->getLink($field)) { $ret .= '('.$this->getDataObjectSelectDisplayValue($subDo, false, $level + 1).')'; } else { $ret .= $do->$field;

Comments

 [2004-05-20 21:14 UTC] justinpatrin
Actually, it turns out that using getLink() on non-link fields creates an error. Here's a patch vs. my previous patch (sorry about that) to use links() again to check for the link field, then use getLink() to actually get the linked DO. @@ -733,6 +733,7 @@ */ function getDataObjectSelectDisplayValue(&$do, $displayfield = false, $level = 1) { global $_DB_DATAOBJECT_FORMBUILDER; + $links = $do->links(); if ($displayfield === false) { if (isset($_DB_DATAOBJECT_FORMBUILDER['INI'][$do->database()][$do->tableName().'__display_fields'])) { $displayfield = $_DB_DATAOBJECT_FORMBUILDER['INI'][$do->database()][$do->tableName().'__display_fields']; @@ -754,8 +755,8 @@ $ret .= ', '; } if (isset($do->$field)) { - if(@$_DB_DATAOBJECT_FORMBUILDER['CONFIG']['follow_links'] > $level && $subDo = $do->getLink($field)) { - $ret .= '('.$this->getDataObjectSelectDisplayValue($subDo, false, $level + 1).')'; + if(@$_DB_DATAOBJECT_FORMBUILDER['CONFIG']['follow_links'] > $level && isset($links[$field])) { + $ret .= '('.$this->getDataObjectSelectDisplayValue($do->getLink($field), false, $level + 1).')'; } else { $ret .= $do->$field; }
 [2004-05-20 22:02 UTC] justinpatrin
Sorry for all of the patch versions here. This should eb the last (and it's vs. the latest CVS too). If getLink() doesn't return a DO you can get PHP errors. So to fix this, you need another patch. Note: This also includes by patch from bug 1457. http://www.reversefold.com/DB_DataObject_FormBuilder_patch_1448_1457.txt
 [2004-05-31 14:31 UTC] mw21st
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.