function open($path, $validate = false, $method = "post", $name = "form1", $send_files = false) { $form = "<form id=\"{$name}\" name=\"{$name}\" action=\"" . linkForm($path) . "\" method=\"{$method}\""; $form .= $validate ? " onSubmit=\"return \$validate(this" . (application_debug_enviroment ? ",true" : "") . ");\"" : ""; $form .= $send_files ? " enctype=\"multipart/form-data\"" : ""; $form .= ">"; return $form; }
function form($content, $attributes) { $to = TemplateLogic::content($attributes["to"], $this->data); $name = array_key_exists("name", $attributes) ? TemplateLogic::content($attributes["name"], $this->data) : $this->getUniqueFormID(); $options = array(); $options["method"] = array_key_exists("method", $attributes) ? $attributes["method"] : "post"; $options["action"] = linkForm($to); if (array_key_exists("validate", $attributes) && $attributes["validate"] != '') { $options["onsubmit"] = "return \$validate(this,'" . $attributes["validate"] . "');"; } //$validate(frm,debug) if (array_key_exists("files", $attributes) && strToLower($attributes["files"]) == "true") { $options["enctype"] = "multipart/form-data"; } $result = $this->process($content); $select = form_tag($name, $result, $options); return $select; }
function redirect($path, $time = 0) { $options = array(); $options["http-equiv"] = "refresh"; $options["content"] = $time . "; URL=" . linkForm($path); $meta = new HTMLTag("meta", $options); return $meta->build(); }
function path($data, $attributes) { $to = $attributes["to"]; return linkForm(TemplateLogic::content($to, $data)); }
function search($page = 1, $searchQuery = null, $sort = "id") { $m = $this->model; $temp = new $m(); $searchQueryParsed = Options::parse($searchQuery); $where = array(); $queryData = new stdClass(); foreach ($searchQueryParsed as $key => $value) { if (APP_USE_LANGUAGE) { if ($value != "" && $value != null) { if (isset($m->{$key})) { $where[] = $temp->__table__ . ".{$key} LIKE \"%{$value}%\""; } else { $where[] = $temp->__table__ . ".{$key}_{$this->application->language} LIKE \"%{$value}%\""; } } } else { if ($value != "" && $value != null) { $where[] = $temp->__table__ . ".{$key} LIKE \"%{$value}%\""; } } $queryData->{$key} = $value; } $query = array(); //if($this->order!=null) $query["order"] = $this->order; if ($sort != null) { $query["order"] = "{$temp->__table__}.{$sort}"; } $query["group"] = $temp->__table__ . ".id"; $query["limit"] = ($page - 1) * $this->perPage . "," . $this->perPage; $query["founds"] = true; if (count($where) > 0) { $query["where"] = implode(" AND ", $where); } /* if($condition!=null){ $query["where"] = $condition; } */ $this->data["objects"] = Collection::load($this->model, $query, $total); $order = new stdClass(); foreach ($this->orderFields as $key) { $order->{$key} = $key; $sym = $key . "symbol"; $order->{$sym} = "[asc]"; if ($key == $sort) { $order->{$key} .= " desc"; $order->{$sym} = "[desc]"; } } $this->data["order"] = $order; import("data.Pager"); $page = max($page, 1); unset($this->data["objects"]["founds"]); $pager = new Pager($total, $this->perPage); $pager->to = "{$this->controller}/search/{page}/{$searchQuery}"; $this->data["pager"] = $pager->build($page); $this->data["querydata"] = $queryData; $this->data["uri"] = linkForm("/{$this->controller}/search/{$page}/{$searchQuery}"); $this->setView("{$this->folder}/{$this->subView}", $this->data); }