Site/Module setup work and auto_format fixes
This commit is contained in:
@@ -106,9 +106,18 @@ abstract class ORMOSB extends ORM {
|
||||
|
||||
public function __get($column) {
|
||||
// If the column is a blob, we'll decode it automatically
|
||||
if (array_key_exists($column,$this->_object) AND $this->_table_columns[$column]['data_type'] == 'blob' AND (! isset($this->_table_columns[$column]['auto_convert']) OR ! $this->_table_columns[$column]['auto_convert'])) {
|
||||
if (array_key_exists($column,$this->_table_columns) AND $this->_table_columns[$column]['data_type'] == 'blob' AND (! isset($this->_table_columns[$column]['auto_convert']) OR ! $this->_table_columns[$column]['auto_convert'])) {
|
||||
|
||||
// In case our blob hasnt been saved as one.
|
||||
try {
|
||||
$this->_object[$column] = $this->blob($this->_object[$column]);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
// @todo Log this exception
|
||||
echo Kohana_Exception::text($e), "\n";
|
||||
echo debug_print_backtrace();
|
||||
}
|
||||
|
||||
$this->_object[$column] = $this->blob($this->_object[$column]);
|
||||
$this->_table_columns[$column]['auto_convert'] = TRUE;
|
||||
}
|
||||
|
||||
@@ -119,9 +128,14 @@ abstract class ORMOSB extends ORM {
|
||||
// Find any fields that have changed, and that are blobs, and encode them.
|
||||
if ($this->_changed)
|
||||
foreach ($this->_changed as $c)
|
||||
if ($this->_table_columns[$c]['data_type'] == 'blob')
|
||||
if ($this->_table_columns[$c]['data_type'] == 'blob') {
|
||||
$this->$c = $this->blob($this->$c,TRUE);
|
||||
|
||||
// We need to reset our auto_convert flag
|
||||
if (isset($this->_table_columns[$c]['auto_convert']))
|
||||
$this->_table_columns[$c]['auto_convert'] = FALSE;
|
||||
}
|
||||
|
||||
return parent::save($validation);
|
||||
}
|
||||
|
||||
@@ -135,5 +149,11 @@ abstract class ORMOSB extends ORM {
|
||||
private function blob($data,$set=FALSE) {
|
||||
return $set ? gzcompress(serialize($data)) : unserialize(gzuncompress($data));
|
||||
}
|
||||
|
||||
public function config($key) {
|
||||
$mc = Config::instance()->so->module_config($this->_object_name);
|
||||
|
||||
return empty($mc[$key]) ? '' : $mc[$key];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user