public function __call($name, $args) { $attributes = array(); $addto = null; $id = null; $content = null; if (count($args) > 0) { foreach ($args as $arg) { if (!ctype_digit($arg) && !is_array($arg) && HTMLUTIL::startswith(trim($arg), "{")) { $attributes = json_decode($arg, true); } elseif (is_int($arg) && $arg > 0) { $id = $arg; } elseif (is_array($arg) && count($arg) == 1) { $addto = $arg[0]; } } } if ($id === $addto) { $id = null; } $element = array("id" => $id, "name" => $name, "attributes" => $attributes, "content" => $content, "addto" => $this->parent_id($addto)); $this->__id++; if ($this->__id == 0) { $element['id'] = 0; $element['addto'] = -1; } $this->__config[$this->__id] = $element; return $this; }
private function get_function($name, $property, $alias = "") { $dbalias = $this->__database_alias; $db = $this->__database; if (!is_object($property)) { $property = is_string($property) ? $this->get_variable($property) : $property; if ($name == "_limit") { if (is_array($property) && count($property) >= 2) { $this->{$alias}->limit($property[0] - 1, $property[1]); } else { $this->{$alias}->limit($property); } } elseif ($name == "_join") { if (is_array($property)) { if (is_array($property[0])) { foreach ($property as $properties) { $this->get_function($name, $properties, $alias); } } elseif (count($property) >= 3 && (is_string($property[0]) && is_string($property[1]) && is_string($property[2]))) { $new_operator = E::$dbalias($property[1]); $_links = [$property[0] => $property[1] . ":" . $property[2]]; $this->{$alias}->addLinks($_links); $this->{$alias}->joinAdd($new_operator); if (isset($property[3])) { $this->{$alias}->selectAs($new_operator, $property[3]); } } } if (is_string($property)) { $new_operator = E::$dbalias($property); $this->{$alias}->joinAdd($new_operator); } } elseif ($name == "_order" || $name == "_group") { $function = ltrim($name, "_") . "By"; $this->{$alias}->{$function}($property); } else { $database_functions = ["md5", "concat"]; $function = ltrim($name, "_"); if (in_array($function, $database_functions)) { $args = []; if (strtolower($function) == "concat") { if (is_array($property)) { foreach ($property as $arg) { $args[] = $this->set_item($alias, $arg); } } } if (strtolower($function) == "md5") { $args[] = $this->set_item($alias, $property); } $return = call_user_func_array($db . "::" . $function, $args); return $return; } } } else { foreach ($property as $tablename => $values) { foreach ($this->__rowarray__ as $aliasname => $value) { if ($this->{$aliasname}->tablename() == $db::tablename($tablename)) { $this->get_function($name, $values, $aliasname); } } if (UTIL::startswith($tablename, "_")) { if (is_object($values)) { $function = $this->get_function($tablename, $values, $aliasname); $function = $this->get_function($tablename, $function, $aliasname); } else { $function = $this->get_function($tablename, $values, $aliasname); } return $function; } } } }