Beispiel #1
0
Datei: data.php Projekt: jasny/Q
 /**
  * Output list of records.
  */
 public function overview()
 {
     $show = !empty($_GET['show']) ? $_GET['show'] : 'current';
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : $_ENV['cfg']['cms']['limit_overview'];
     $filters = !empty($_GET['filter']) ? $_GET['filter'] : array();
     $order = isset($_GET['order']) ? $_GET['order'] : null;
     $statement = $this->td->getStatement('overview.xml');
     $statement->addToPart(DB::COMMAND_PART, 'SQL_CALC_FOUND_ROWS');
     foreach ($filters as $key => $value) {
         if (empty($value)) {
             continue;
         }
         list($field, $operator) = explode(' ', $key . ' ');
         $statement->addCriteria(strpos('.', $field) === false ? DB::i()->makeIdentifier($this->table, $field) : DB::i()->quoteIdentifier($field), $value, $operator);
     }
     if (isset($limit)) {
         $statement->setLimit($limit, DB::arg('page', $page));
     }
     if (isset($order)) {
         list($field, $sort) = explode(" ", $order . ' ASC');
         $statement->addOrderBy((strpos('.', $field) === false ? DB::i()->makeIdentifier($this->table, $field) : DB::i()->quoteIdentifier($field)) . ' ' . $sort);
     }
     $xml = join("\n", (array) $statement->execute(DB::arg('state', $state))->getColumn());
     $rowcount = DB::i()->query("SELECT FOUND_ROWS()")->fetchValue();
     $xml = '<overview table="' . htmlspecialchars($this->table, ENT_COMPAT, 'UTF-8') . '" page="' . $page . '" count="' . $rowcount . '"' . (isset($limit) ? ' limit="' . $limit . '"' : '') . ' descfield="' . htmlspecialchars($this->td->getFieldProperty('#role:description', 'name'), ENT_COMPAT, 'UTF-8') . '">' . $xml . '</overview>';
     self::outputXML($xml);
 }