PluginProbe
CSS & JavaScript Toolbox / 8.2
CSS & JavaScript Toolbox v8.2
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
← All changes | models/statistics-metabox.php +23 -51 128.2 View file →
@@ -6,83 +6,55 @@
6 6 /**
7 7 * No direct access.
8 8 */
9 9 defined('ABSPATH') or die("Access denied");
10 -
10 +
11 11 /**
12 -*
12 +*
13 13 * @author Ahmed Said
14 14 * @version 6
15 15 */
16 16 class CJTStatisticsMetaboxModel {
17 -
17 +
18 18 /**
19 - *
19 + *
20 20 */
21 21 const CJT_LASTEST_SCRIPT_OPTION_NAME = 'CJTStatisticsMetaboxModel.latestscripts';
22 -
22 +
23 23 /**
24 - *
24 + *
25 25 */
26 26 const LATEST_SCRIPT_EXPIRES = 86400;
27 -
27 +
28 28 /**
29 29 * put your comment there...
30 - *
30 + *
31 31 * @var mixed
32 32 */
33 33 protected $dbDriver;
34 -
34 +
35 35 /**
36 36 * put your comment there...
37 - *
37 + *
38 38 */
39 39 public function __construct() {
40 40 $this->dbDriver =& cssJSToolbox::getInstance()->getDBDriver();
41 41 }
42 -
42 +
43 43 /**
44 44 * put your comment there...
45 - *
45 + *
46 46 * @param mixed $state
47 47 * @param mixed $type
48 48 */
49 - public function getBlocksCount($state, $type)
50 - {
51 -
52 - $query = " SELECT count(*) blocksCount
53 - FROM #__cjtoolbox_blocks
54 - WHERE backupId IS NULL AND state = '{$state}' AND type='{$type}';";
55 -
56 - $result = $this->dbDriver->select($query, ARRAY_A);
57 -
58 - $count = $result[0]['blocksCount'];
59 -
60 - return $count;
49 + public function getBlocksCount($state, $type) {
50 + $result = $this->dbDriver->select("SELECT count(*) blocksCount FROM #__cjtoolbox_blocks WHERE state = '{$state}' AND type='{$type}';", ARRAY_A);
51 + return $result[0]['blocksCount'];
61 52 }
62 -
63 - /**
64 - * put your comment there...
65 - *
66 - */
67 - public function getCodeFilesCount()
68 - {
69 -
70 - $query = ' SELECT count(*) codeFilesCount
71 - FROM #__cjtoolbox_blocks b LEFT JOIN #__cjtoolbox_block_files f
72 - ON b.id = f.blockId
73 - WHERE b.BackupId IS NULL AND b.type != "revision";';
74 -
75 - $result = $this->dbDriver->select($query, ARRAY_A);
76 -
77 - $count = $result[0]['codeFilesCount'];
78 -
79 - return $count;
80 - }
81 -
53 +
82 54 /**
83 55 * put your comment there...
84 - *
56 + *
85 57 */
86 58 public function getFeed() {
87 59 // Initialize.
88 60 $widgetTransitFeed = get_option(self::CJT_LASTEST_SCRIPT_OPTION_NAME, array('time' => 0));
@@ -88,14 +60,14 @@
88 60 $widgetTransitFeed = get_option(self::CJT_LASTEST_SCRIPT_OPTION_NAME, array('time' => 0));
89 61 // Only if cache is expires read feed from server.
90 62 if ((time() - $widgetTransitFeed['time']) > self::LATEST_SCRIPT_EXPIRES) {
91 63 # INitiaize
92 - $fieldsNames = array('title', 'link', 'description', 'pubDate');
64 + $fieldsNames = array('title', 'link', 'description');
93 65 # Get Latest Scripts/Packages from feed.
94 66 $scriptsFeed = new CJT_Framework_Wordpress_Feed(cssJSToolbox::CJT_WEB_SITE_DOMAIN, 'category/scripts/feed/', $fieldsNames);
95 67 $widgetTransitFeed['scripts'] = $scriptsFeed->getLatestItems(7);
96 68 # Get latest extensions from feed
97 - $extensionsFeed = new CJT_Framework_Wordpress_Feed(cssJSToolbox::CJT_WEB_SITE_DOMAIN, 'category/extensions/feed/', $fieldsNames);
69 + $extensionsFeed = new CJT_Framework_Wordpress_Feed(cssJSToolbox::CJT_WEB_SITE_DOMAIN, 'category/extensions/feed/', $fieldsNames);
98 70 $widgetTransitFeed['extensions'] = $extensionsFeed->getLatestItems(7);
99 71 # Get latest news from news feed.
100 72 $newsFeed = new CJT_Framework_Wordpress_Feed(cssJSToolbox::CJT_WEB_SITE_DOMAIN, 'category/news/feed/', $fieldsNames);
101 73 $widgetTransitFeed['news'] = $newsFeed->getLatestItems(1);
@@ -102,9 +74,9 @@
102 74 # Cache only if there is no errors.
103 75 if (!$newsFeed->isError() && !$scriptsFeed->isError() && !$extensionsFeed->isError()) {
104 76 # Store cache time.
105 77 $widgetTransitFeed['time'] = time();
106 - update_option(self::CJT_LASTEST_SCRIPT_OPTION_NAME, $widgetTransitFeed);
78 + update_option(self::CJT_LASTEST_SCRIPT_OPTION_NAME, $widgetTransitFeed);
107 79 }
108 80 }
109 81 # For versions 8.0 it will produce PHP notice because extensions item is not being exists in the cache
110 82 # The error will be always visible until next caching cycle!
@@ -117,9 +89,9 @@
117 89 }
118 90
119 91 /**
120 92 * put your comment there...
121 - *
93 + *
122 94 */
123 95 public function getPackagesCount() {
124 96 $result = $this->dbDriver->select('SELECT count(*) packagesCount FROM #__cjtoolbox_packages;', ARRAY_A);
125 97 return $result[0]['packagesCount'];
@@ -126,12 +98,12 @@
126 98 }
127 99
128 100 /**
129 101 * put your comment there...
130 - *
102 + *
131 103 */
132 104 public function getTemplatesCount() {
133 105 $result = $this->dbDriver->select('SELECT count(*) templatesCount FROM #__cjtoolbox_templates WHERE (attributes & 1) = 0;', ARRAY_A);
134 - return $result[0]['templatesCount'];
106 + return $result[0]['templatesCount'];
135 107 }
136 108
137 109 } // End class.