Theme work with focusbusiness and baseadmin

Improvements to NAVBAR, updates to StaticList methods, other minor items
Enable product category rendering and other minor improvements
Added ADSL-large category price plan
This commit is contained in:
Deon George
2013-04-26 11:42:09 +10:00
parent eeb8d61237
commit 04ebda2aaa
114 changed files with 1732 additions and 6797 deletions

View File

@@ -21,6 +21,9 @@ abstract class ORM_OSB extends ORM {
// Our attribute values that need to be stored as serialized
protected $_serialize_column = array();
// Our attributes that should be converted to NULL when empty
protected $_nullifempty = array();
// Our attributes used in forms.
protected $_form = array();
@@ -36,6 +39,52 @@ abstract class ORM_OSB extends ORM {
);
}
/**
* Try and (un)serialize our data, and if it fails, just return it.
*/
private function _serialize($data,$set=FALSE) {
try {
return $set ? serialize($data) : unserialize($data);
// Maybe the data serialized?
} catch (Exception $e) {
return $data;
}
}
/**
* Retrieve and Store DB BLOB data.
*/
private function _blob($data,$set=FALSE) {
try {
return $set ? gzcompress($this->_serialize($data,$set)) : $this->_serialize(gzuncompress($data));
// Maybe the data isnt compressed?
} catch (Exception $e) {
return $this->_serialize($data,$set);
}
}
/**
* If a column is marked to be nullified if it is empty, this is where it is done.
*/
private function _nullifempty(array $array) {
foreach ($array as $k=>$v) {
if (is_array($v)) {
if (is_null($x=$this->_nullifempty($v)))
unset($array[$k]);
else
$array[$k] = $x;
} else
if (! $v)
unset($array[$k]);
}
return count($array) ? $array : NULL;
}
/**
* Auto process some data as it comes from the database
* @see parent::__get()
@@ -52,9 +101,10 @@ abstract class ORM_OSB extends ORM {
// In case our blob hasnt been saved as one.
try {
$this->_object[$column] = $this->blob($this->_object[$column]);
$this->_object[$column] = $this->_blob($this->_object[$column]);
}
catch(Exception $e) {
echo Debug::vars($e);die();
// @todo Log this exception
echo Kohana_Exception::text($e), "\n";
echo debug_print_backtrace();
@@ -116,23 +166,6 @@ abstract class ORM_OSB extends ORM {
}
}
final public static function xform($table,$blank=FALSE) {
return ORM::factory($table)->formselect($blank);
}
/**
* Retrieve and Store DB BLOB data.
*/
private function blob($data,$set=FALSE) {
try {
return $set ? gzcompress(serialize($data)) : unserialize(gzuncompress($data));
// Maybe the data isnt compressed?
} catch (Exception $e) {
return $set ? serialize($data) : unserialize($data);
}
}
public function config($key) {
$mc = Config::instance()->module_config($this->_object_name);
@@ -176,18 +209,6 @@ abstract class ORM_OSB extends ORM {
return TRUE;
}
public function xformselect($blank) {
$result = array();
if ($blank)
$result[] = '';
foreach ($this->find_all() as $o)
$result[$o->{$this->_form['id']}] = $o->{$this->_form['value']};
return $result;
}
public function keyget($column,$key=NULL) {
if (is_null($key) OR ! is_array($this->$column))
return $this->$column;
@@ -202,10 +223,19 @@ abstract class ORM_OSB extends ORM {
public function save(Validation $validation = NULL) {
// Find any fields that have changed, and process them.
if ($this->_changed)
foreach ($this->_changed as $c)
foreach ($this->_changed as $c) {
// Convert to NULL
if (in_array($c,$this->_nullifempty)) {
if (is_array($this->_object[$c]))
$this->_object[$c] = $this->_nullifempty($this->_object[$c]);
elseif (! $this->_object[$c])
$this->_object[$c] = NULL;
}
// Any fields that are blobs, and encode them.
if ($this->_table_columns[$c]['data_type'] == 'blob') {
$this->_object[$c] = $this->blob($this->_object[$c],TRUE);
if (! is_null($this->_object[$c]) AND $this->_table_columns[$c]['data_type'] == 'blob') {
$this->_object[$c] = $this->_blob($this->_object[$c],TRUE);
// We need to reset our auto_convert flag
if (isset($this->_table_columns[$c]['auto_convert']))
@@ -215,14 +245,51 @@ abstract class ORM_OSB extends ORM {
} elseif (is_array($this->_object[$c]) AND in_array($c,$this->_serialize_column)) {
$this->_object[$c] = serialize($this->_object[$c]);
}
}
return parent::save($validation);
}
public function status($render=FALSE) {
if (! isset($this->_table_columns['status']))
return NULL;
if (! $render)
return $this->display('status');
return View::factory(Config::theme().'/status')
->set('label',$this->status ? 'label-success' : '')
->set('status',$this->display('status'));
}
/**
* Function help to find records that are active
*/
public function list_active() {
return $this->_where_active()->find_all();
}
public function list_count($active=TRUE) {
$x=($active ? $this->_where_active() : $this);
return $x->find_all()->count();
}
/**
* 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.
*/
public function list_select($blank=FALSE) {
$result = array();
if ($blank)
$result[] = '';
if ($this->_form AND array_intersect(array('id','value'),$this->_form))
foreach ($this->find_all() as $o)
$result[$o->{$this->_form['id']}] = $o->{$this->_form['value']};
return $result;
}
}
?>