public function pagnation_make($_total_records, $_length = null) { if (!$_length && !$this->pagnation_get('custom_length') && !$this->pagnation_get('length')) { \lib\error::internal("PAGENAMTION LENGTH NOTFOUND"); return; } else { $length = $this->pagnation_get('length') ? $this->pagnation_get('length') : intval($_length); } $total_pages = intval(ceil($_total_records / $length)); $current = $this->pagnation_get('current') ? $this->pagnation_get('current') : 1; $next = $current + 1; $prev = $current - 1; if ($current > $total_pages) { $this->pagnation_error(); } $this->pagnation_set('total_pages', $total_pages); $this->pagnation_set('current', $current); $this->pagnation_set('next', $next <= $total_pages ? $next : false); $this->pagnation_set('prev', $prev >= 1 ? $prev : false); $this->pagnation_set('count_link', 7); $path = \lib\router::get_url() ? '/' . \lib\router::get_url() : null; if ($path === null) { $path = preg_replace("/\\/page\\=\\d+/", "", $_SERVER['REQUEST_URI']); } $current_url = $this->url('base') . $path; $this->pagnation_set('current_url', $this->pagnation_get('custom_length') ? $current_url . "/length={$length}" : $current_url); $this->pagnation_set('length', $length); }
public function mvc_inject_finder($_name, $_args, $_call) { $return = false; $method_exists = array_key_exists($_call, $this->Methods); $call_method_exists = method_exists($this, $_call); if (!$method_exists && !$call_method_exists) { \lib\error::internal(get_called_class() . "()->{$_name}()"); } if ($method_exists && array_key_exists('before', $this->Methods[$_call])) { foreach ($this->Methods[$_call]['before'] as $key => $before_method) { $before_method(...$_args); } } if ($method_exists && array_key_exists('edit', $this->Methods[$_call])) { $edit_method = end($this->Methods[$_call]['edit']); $return = $edit_method(...$_args); } else { $return = call_user_func_array(array($this, $_call), $_args); } if ($method_exists && array_key_exists('after', $this->Methods[$_call])) { foreach ($this->Methods[$_call]['after'] as $key => $after_method) { $after_method(...$_args); } } return $return; }
public function __call($name, $args) { $black = array("_construct", "corridor", "config"); if (method_exists($this, '_call_corridor') && method_exists($this, '_call') && ($value = $this->_call_corridor($name, $args))) { return $this->_call($name, $args, $value); } elseif (isset($this->Methods[$name])) { return call_user_func_array($this->Methods[$name], $args); } elseif (method_exists($this->controller, $name) && !preg_grep("/^{$name}\$/", $black)) { return call_user_func_array(array($this->controller, $name), $args); } \lib\error::internal(get_called_class() . "->{$name}()"); }
public function caller(...$_args) { if (count($_args) < 3) { error::internal("caller arguments count"); return; } elseif (!$_args[0] && !$args[1] || !$_args[2]) { error::internal("caller arguments invalid"); return; } $caller = [$_args[0], $_args[1]]; $route = new route(false); if (!is_array($_args[2])) { $_args[2] = [$_args[2]]; } $return_route = call_user_func_array(array($route, 'check_route'), $_args[2]); if ($route->status) { array_push($caller, new api\args_callback(['method' => 'caller', 'match' => $route->match])); if (!isset($this->caller)) { $this->caller = array(); } array_push($this->caller, $caller); } }