diff --git a/src/Pluf/HTTP/Response/Json.php b/src/Pluf/HTTP/Response/Json.php new file mode 100644 index 0000000..e96f07e --- /dev/null +++ b/src/Pluf/HTTP/Response/Json.php @@ -0,0 +1,36 @@ +sort_order) != 2) { + $order = null; + } else { + $s = $this->sort_order[1]; + if (in_array($this->sort_order[0], $this->sort_reverse_order)) { + $s = ($s == 'ASC') ? 'DESC' : 'ASC'; + } + $order = $this->sort_order[0].' '.$s; + } + if (!is_null($this->model)) { + $items = $this->model->getList(array('view' => $this->model_view, + 'filter' => $this->filter(), + 'order' => $order, + )); + } else { + $items = $this->items; + } + $out = array(); + foreach ($items as $item) { + $idata = array(); + if (!empty($this->list_display)) { + $i = 0; + foreach ($this->list_display as $key=>$col) { + if (!is_array($col)) { + $idata[$key] = $item->$key; + } else { + $_col = $col[0]; + $idata[$col[0]] = $item->$_col; + } + } + } else { + $idata = $item->id; + } + $out[] = $idata; + } + return $out; + } + + /** * Generate the footer of the table. */ function footer()