Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

listobj changes

  • Loading branch information...
commit 217a9abd4e30dd3472f8c246db632c9c6453b87a 1 parent 1aaad67
@KellyLSB KellyLSB authored
Showing with 45 additions and 9 deletions.
  1. +14 −9 library/architect.php
  2. +31 −0 library/listobj.php
View
23 library/architect.php
@@ -112,7 +112,8 @@ public function __construct(Connection $dbh, $table, $config) {
/**
* Make sure all required fields are present
*/
- foreach($fields as $field=>$val) {
+ $new_fields = array();
+ foreach($fields as $field => $val) {
if($val == '_suppress') { unset($fields[$field]); continue; }
@@ -125,23 +126,27 @@ public function __construct(Connection $dbh, $table, $config) {
'Extra' => ''
);
}
- else {
- if(!isset($val['Null'])) $val['Null'] = 'NO';
- if(!isset($val['Key'])) $val['Key'] = '';
- if(!isset($val['Default'])) $val['Default'] = NULL;
- if(!isset($val['Extra'])) $val['Extra'] = '';
+
+ if($field[0] === '+') {
+ $val['Key'] = 'MUL';
+ $field = substr($field, 1);
}
+ if(!isset($val['Null'])) $val['Null'] = 'NO';
+ if(!isset($val['Key'])) $val['Key'] = '';
+ if(!isset($val['Default'])) $val['Default'] = NULL;
+ if(!isset($val['Extra'])) $val['Extra'] = '';
+
if($val['Null'] === true) $val['Null'] = 'YES';
if($val['Null'] === false) $val['Null'] = 'NO';
- $fields[$field] = $val;
+ $new_fields[$field] = $val;
}
/**
* Save fields to the object
*/
- $this->fields = $fields;
+ $this->fields = $new_fields;
/**
* Check to see if the table exists
@@ -278,7 +283,7 @@ protected function _update() {
$key = "ALTER TABLE `$this->table` ADD UNIQUE KEY `$field` (`$field`)";
break;
case 'MUL':
- $key = "ALTER TABLE `$this->table` ADD KEY `$field` ($field)";
+ $key = "ALTER TABLE `$this->table` ADD KEY `$field` (`$field`)";
break;
default:
/**
View
31 library/listobj.php
@@ -622,6 +622,11 @@ public function raw() {
}
public function _run_query($count = false, $extra = false, $raw = false) {
+ /**
+ * Run all extensions with this method
+ */
+ $this->_->all('_on_run_query');
+
if($count === 'debug') {
$count = false;
$debug = true;
@@ -1036,6 +1041,7 @@ class ListExtensionHandler {
private $list;
private $extensions = array();
+ private $lextensions = array();
public function __construct($list) {
$this->list = $list;
@@ -1052,6 +1058,26 @@ public function __get($extension) {
return $this->extensions[$extension];
}
+ public function all($method, $args = array()) {
+ $return = array();
+
+ if(empty($this->lextensions)) foreach(Bundle::$db_structure as $table) {
+ if(isset($table['extensions'])) foreach($table['extensions'] as $ext)
+ $this->lextensions[] = $ext;
+ }
+
+ foreach($this->lextensions as $ext) {
+ $ext = strtolower($ext);
+ if(!isset($this->extensions[$ext]))
+ $this->extensions[$ext] = new ListExtensionAccess($this->list, Bundle::extension($ext));
+
+ if($this->extensions[$ext]->method_exists($method))
+ $return[] = $this->extensions[$ext]->__call($method, $args);
+ }
+
+ return $return;
+ }
+
}
/**
@@ -1068,6 +1094,11 @@ public function __construct($list, $extension) {
$this->extension = $extension;
}
+ public function method_exists($method) {
+ $method = "list" . ucfirst($method);
+ return method_exists($this->extension, $method);
+ }
+
public function __call($method, $args) {
$method = "list" . ucfirst($method);
array_unshift($args, $this->list);
Please sign in to comment.
Something went wrong with that request. Please try again.