コード例 #1
0
ファイル: content.php プロジェクト: nemein/com_meego_ocs
 /**
  * Gather licenses
  * @param array HTTP GET arguments
  */
 public function get_licenses(array $args)
 {
     $q = new midgard_query_select(new midgard_query_storage('com_meego_license'));
     $q->execute();
     $licenses = $q->list_objects();
     $total = $q->get_results_count();
     $query = $this->request->get_query();
     if (array_key_exists('pagesize', $query) && strlen($query['pagesize'])) {
         $this->pagesize = $query['pagesize'];
     }
     if ($total > $this->pagesize) {
         $page = 0;
         if (array_key_exists('page', $query) && strlen($query['page'])) {
             $page = $query['page'];
         }
         $offset = $page * $this->pagesize;
         if ($offset > $total) {
             $offset = $total - $this->pagesize;
         }
         $licenses = array_slice($licenses, $offset, $this->pagesize);
     }
     $ocs = new com_meego_ocs_OCSWriter();
     $ocs->writeMeta($total, $this->pagesize, '', 'ok', '100');
     $ocs->writeLicenses($licenses);
     $ocs->endDocument();
     self::output_xml($ocs);
 }