Misc improvements

This commit is contained in:
Deon George 2014-07-18 12:37:45 +10:00
parent a889d25eda
commit 7961e60901
2 changed files with 12 additions and 4 deletions

View File

@ -77,8 +77,9 @@ abstract class lnApp_ORM extends Kohana_ORM {
$result['this'] = $this->object(); $result['this'] = $this->object();
foreach ($this->_sub_items as $o) if (isset($this->_sub_items))
$result['sub'][] = $o->dump(); foreach ($this->_sub_items as $o)
$result['sub'][] = $o->dump();
return $result; return $result;
} }
@ -137,14 +138,17 @@ abstract class lnApp_ORM extends Kohana_ORM {
* Return an array of data that can be used in a SELECT statement. * Return an array of data that can be used in a SELECT statement.
* The ID and VALUE is defined in the model for the select. * The ID and VALUE is defined in the model for the select.
*/ */
public function list_select($blank=FALSE) { public function list_select($blank=FALSE,$object=NULL) {
$result = array(); $result = array();
if (is_null($object))
$object = $this->find_all();
if ($blank) if ($blank)
$result[NULL] = ''; $result[NULL] = '';
if ($this->_form AND array_intersect(array('id','value'),$this->_form)) if ($this->_form AND array_intersect(array('id','value'),$this->_form))
foreach ($this->find_all() as $o) foreach ($object as $o)
$result[$o->{$this->_form['id']}] = $o->resolve($this->_form['value']); $result[$o->{$this->_form['id']}] = $o->resolve($this->_form['value']);
return $result; return $result;

View File

@ -104,6 +104,10 @@ abstract class lnApp_Table {
if (isset($this->postproc[$key]) and $x) { if (isset($this->postproc[$key]) and $x) {
foreach ($this->postproc[$key] as $act => $data) { foreach ($this->postproc[$key] as $act => $data) {
switch ($act) { switch ($act) {
case 'yesno':
$x = StaticList_YesNo::get($x,TRUE);
break;
case 'trim': case 'trim':
if (strlen($x) > $data) { if (strlen($x) > $data) {
$x = sprintf('<abbr title="%s">%s</abbr>',$x,substr($x,0,$data-3).str_repeat('.',3)); $x = sprintf('<abbr title="%s">%s</abbr>',$x,substr($x,0,$data-3).str_repeat('.',3));