PluginProbe
CSS & JavaScript Toolbox / 9.4
CSS & JavaScript Toolbox v9.4
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / models / packages.php

packages.php in CSS & JavaScript Toolbox 9.4, at models/packages.php

68 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 // Disllow direct access.
7 defined('ABSPATH') or die('Access denied');
8
9 /**
10 *
11 */
12 class CJTPackagesModel {
13
14 /**
15 * put your comment there...
16 *
17 */
18 public function getItems() {
19 // Build query.
20 $select = 'SELECT p.id, p.name, p.description, p.author, p.webSite, p.license, p.readme';
21 $queryBase = $this->getItemsQuery();
22 // Paging.
23 $itemsPerPage = $this->getItemsPerPage();
24 // Get page no#.
25 $page = !isset($_REQUEST['paged']) ? 1 : $_REQUEST['paged'];
26 // Calculate start offset.
27 $start = ($page - 1) * $itemsPerPage;
28 $limit = " LIMIT {$start},{$itemsPerPage}";
29 // final query.
30 $query = "{$select}{$queryBase['from']}{$limit}";
31 // Execute our query using MYSQL queue driver.
32 $result = cssJSToolbox::getInstance()->getDBDriver()->select($query);
33 return $result;
34 }
35
36 /**
37 * put your comment there...
38 *
39 */
40 public function getItemsPerPage() {
41 return 20;
42 }
43
44 /**
45 * put your comment there...
46 *
47 */
48 public function getItemsQuery() {
49 // From clause.
50 $query['from'] = ' FROM #__cjtoolbox_packages p';
51 return $query;
52 }
53
54 /**
55 * put your comment there...
56 *
57 */
58 public function getItemsTotal() {
59 $queryBase = $this->getItemsQuery();
60 $select = 'SELECT count(*) Total';
61 $query = "{$select}{$queryBase['from']}";
62 // Get items total.
63 $dbDriver = new CJTMYSQLQueueDriver($GLOBALS['wpdb']);
64 $result = $dbDriver->select($query);
65 return reset($result)->Total;
66 }
67
68 } // End class.