Enabled Search, Improved Navbar, Fixed Application Authorisation and some other minor fixes
This commit is contained in:
@@ -33,6 +33,13 @@ abstract class ORM extends Kohana_ORM {
|
||||
$this->_formated = TRUE;
|
||||
}
|
||||
|
||||
public function clear() {
|
||||
$this->_formated = FALSE;
|
||||
$this->_object_formated = array();
|
||||
|
||||
return parent::clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a formated columns, as per the model definition
|
||||
*/
|
||||
@@ -111,6 +118,62 @@ abstract class ORM extends Kohana_ORM {
|
||||
return $this->_where_active()->find_all();
|
||||
}
|
||||
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
|
||||
$result = array();
|
||||
|
||||
$query = empty($options['object']) ? $this : $options['object'];
|
||||
|
||||
foreach ($limit as $w) {
|
||||
list($k,$s,$v) = $w;
|
||||
|
||||
$query->and_where($k,$s,$v);
|
||||
}
|
||||
|
||||
$c = 0;
|
||||
foreach ((empty($options['object']) ? $query->find_all() : $query->execute()) as $o) {
|
||||
// If we got here via a DB query, we need to reload our ORM object from the result.
|
||||
if (! is_object($o)) {
|
||||
if (empty($options['key']))
|
||||
throw new Kohana_Exception('Missing key for non object');
|
||||
|
||||
$o = $this->clear()->where($options['key'],'=',$o[$options['key']])->find();
|
||||
}
|
||||
|
||||
switch ($index) {
|
||||
case 'url':
|
||||
if (empty($options['urlprefix']))
|
||||
throw new Kohana_Exception('Missing URL Prefix');
|
||||
|
||||
$v = $options['urlprefix'].$o->resolve($value);
|
||||
|
||||
break;
|
||||
|
||||
default: $v = $o->resolve($value);
|
||||
}
|
||||
|
||||
$k = '';
|
||||
foreach ($label as $k => $details)
|
||||
foreach ($details as $lvalue)
|
||||
$k = preg_replace('/%s/',$o->resolve($lvalue),$k,1);
|
||||
|
||||
$result[$c++] = array(
|
||||
'value'=>$v,
|
||||
'label'=>$k,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used so that methods can be called via variables
|
||||
*/
|
||||
public function resolve($key) {
|
||||
eval("\$x = \$this->$key;");
|
||||
|
||||
return $x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function help to find records that are active
|
||||
*/
|
||||
|
Reference in New Issue
Block a user