protected function render_set($res) { $output = ""; $index = 0; $records = array(); while ($data = $this->sql->get_next($res)) { if (isset($data[$this->config->id['name']])) { $has_kids = false; } else { $data[$this->config->id['name']] = $data['value'] . $this->id_postfix; $data[$this->config->text[0]['name']] = $data['value']; $has_kids = true; } $data = new $this->names["item_class"]($data, $this->config, $index); $this->event->trigger("beforeRender", $data); if ($has_kids === false) { $data->set_kids(false); } if ($data->has_kids() === -1 && $this->dload) { $data->set_kids(true); } $output .= $data->to_xml_start(); if (($data->has_kids() === -1 || $data->has_kids() == true && !$this->dload) && $has_kids == true) { $sub_request = new DataRequestConfig($this->request); $sub_request->set_relation(str_replace($this->id_postfix, "", $data->get_id())); $output .= $this->render_set($this->sql->select($sub_request)); } $output .= $data->to_xml_end(); $index++; } return $output; }
public function update($data) { $action = new DataAction('updated', $data[$this->config->id["name"]], $data); $request = new DataRequestConfig(); $request->set_source($this->request->get_source()); $this->config->limit_fields($data); $this->sql->update($action, $request); $this->config->restore_fields($data); return $action->get_status(); }
public function get_variants($name, $source) { $count = new DataRequestConfig($source); $count->set_fieldset("DISTINCT " . $this->escape_name($name) . " as value"); $sort = new SortInterface($source); $count->set_sort(null); for ($i = 0; $i < count($sort->rules); $i++) { if ($sort->rules[$i]['name'] == $name) { $count->set_sort($sort->rules[$i]['name'], $sort->rules[$i]['direction']); } } $count->set_limit(0, 0); return $this->select($count); }
public function get_updates() { $sub_request = new DataRequestConfig($this->request); $version = $this->request->get_version(); $user = $this->request->get_user(); $sub_request->parse_sql($this->select_update($this->table, $this->request->get_source(), $this->config->id['db_name'], $version, $user)); $sub_request->set_relation(false); $output = $this->render_set($this->sql->select($sub_request), $this->item_class); if (!isset($output["userdata"])) { $output["userdata"] = array(); } $output["userdata"] = array_merge($output["userdata"], $this->get_version()); $this->output(json_encode($output)); }
protected function render_set($res) { $output = ""; $index = 0; while ($data = $this->sql->get_next($res)) { $data = new $this->names["item_class"]($data, $this->config, $index); $this->event->trigger("beforeRender", $data); //there is no info about child elements, //if we are using dyn. loading - assume that it has, //in normal mode juse exec sub-render routine if ($data->has_kids() === -1 && $this->dload) { $data->set_kids(true); } $output .= $data->to_xml_start(); if ($data->has_kids() === -1 || $data->has_kids() == true && !$this->dload) { $sub_request = new DataRequestConfig($this->request); $sub_request->set_relation($data->get_id()); $output .= $this->render_set($this->sql->select($sub_request)); } $output .= $data->to_xml_end(); $index++; } return $output; }
public function get_variants($name, $source) { $count = new DataRequestConfig($source); $count->set_fieldset("DISTINCT " . $name . " as value"); $count->set_sort(null); $count->set_limit(0, 0); return $this->select($count); }
public function render_set($res, $name, $dload, $sep, $config) { $output = array(); $index = 0; $conn = $this->conn; while ($data = $conn->sql->get_next($res)) { if (isset($data[$config->id['name']])) { $has_kids = false; } else { $data[$config->id['name']] = $data['value'] . $this->id_postfix; $data[$config->text[0]['name']] = $data['value']; $has_kids = true; } $data = new $name($data, $config, $index); $conn->event->trigger("beforeRender", $data); if ($has_kids === false) { $data->set_kids(false); } if ($data->has_kids() === -1 && $dload) { $data->set_kids(true); } $record = $data->to_xml_start(); if (($data->has_kids() === -1 || $data->has_kids() == true && !$dload) && $has_kids == true) { $sub_request = new DataRequestConfig($conn->get_request()); $sub_request->set_relation(str_replace($this->id_postfix, "", $data->get_id())); $temp = $this->render_set($conn->sql->select($sub_request), $name, $dload, $sep, $config); if (sizeof($temp)) { $record["data"] = $temp; } } $output[] = $record; $index++; } return $output; }
public function get_updates() { $sub_request = new DataRequestConfig($this->request); $version = $this->request->get_version(); $user = $this->request->get_user(); $sub_request->parse_sql($this->select_update($this->table, $this->request->get_source(), $this->config->id['db_name'], $version, $user)); $sub_request->set_relation(false); $output = $this->render_set($this->sql->select($sub_request), $this->item_class); ob_clean(); header("Content-type:text/xml"); echo $this->updates_start(); echo $this->get_version(); echo $output; echo $this->updates_end(); }