PluginProbe
CSS & JavaScript Toolbox / 7.2
CSS & JavaScript Toolbox v7.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 +43 -70 107.2 View file →
@@ -6,120 +6,93 @@
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 - $widgetTransitFeed = get_option(self::CJT_LASTEST_SCRIPT_OPTION_NAME, array('time' => 0));
60 + $widgetTransitFeed = get_option(self::CJT_LASTEST_SCRIPT_OPTION_NAME, array(
61 + 'scripts' => array(array('title' => 'cjt-script.com', 'link' => 'http://' . cssJSToolbox::CJT_SCRTIPS_WEB_SITE_DOMAIN)),
62 + 'news' => array(array('title' => 'css-javascript-toolbox.com', 'link' => 'http://' . cssJSToolbox::CJT_WEB_SITE_DOMAIN)),
63 + 'time' => 0
64 + ));
89 65 // Only if cache is expires read feed from server.
90 66 if ((time() - $widgetTransitFeed['time']) > self::LATEST_SCRIPT_EXPIRES) {
91 - # INitiaize
92 - $fieldsNames = array('title', 'link', 'description', 'pubDate');
93 67 # Get Latest Scripts/Packages from feed.
94 - $scriptsFeed = new CJT_Framework_Wordpress_Feed(cssJSToolbox::CJT_WEB_SITE_DOMAIN, 'category/scripts/feed/', $fieldsNames);
95 - $widgetTransitFeed['scripts'] = $scriptsFeed->getLatestItems(7);
96 - # Get latest extensions from feed
97 - $extensionsFeed = new CJT_Framework_Wordpress_Feed(cssJSToolbox::CJT_WEB_SITE_DOMAIN, 'category/extensions/feed/', $fieldsNames);
98 - $widgetTransitFeed['extensions'] = $extensionsFeed->getLatestItems(7);
68 + $scriptsFeed = new CJT_Framework_Wordpress_Feed(
69 + cssJSToolbox::CJT_SCRTIPS_WEB_SITE_DOMAIN,
70 + 'forums/script-packages/user-scripts/feed/',
71 + array('title', 'link')
72 + );
73 + if (!$scriptsFeed->isError()) {
74 + $widgetTransitFeed['scripts'] = $scriptsFeed->getLatestItems(1);
75 + }
99 76 # Get latest news from news feed.
100 - $newsFeed = new CJT_Framework_Wordpress_Feed(cssJSToolbox::CJT_WEB_SITE_DOMAIN, 'category/news/feed/', $fieldsNames);
101 - $widgetTransitFeed['news'] = $newsFeed->getLatestItems(1);
102 - # Cache only if there is no errors.
103 - if (!$newsFeed->isError() && !$scriptsFeed->isError() && !$extensionsFeed->isError()) {
104 - # Store cache time.
105 - $widgetTransitFeed['time'] = time();
106 - update_option(self::CJT_LASTEST_SCRIPT_OPTION_NAME, $widgetTransitFeed);
77 + $newsFeed = new CJT_Framework_Wordpress_Feed(
78 + cssJSToolbox::CJT_WEB_SITE_DOMAIN,
79 + 'category/news/feed/',
80 + array('title', 'link', 'description')
81 + );
82 + if (!$newsFeed->isError()) {
83 + $widgetTransitFeed['news'] = $newsFeed->getLatestItems(1);
107 84 }
85 + # Store cache time.
86 + $widgetTransitFeed['time'] = time();
87 + update_option(self::CJT_LASTEST_SCRIPT_OPTION_NAME, $widgetTransitFeed);
108 88 }
109 - # For versions 8.0 it will produce PHP notice because extensions item is not being exists in the cache
110 - # The error will be always visible until next caching cycle!
111 - # temporary solution
112 - else if (!isset($widgetTransitFeed['extensions'])) {
113 - $widgetTransitFeed['extensions'] = array();
114 - }
115 - # Returns
116 89 return $widgetTransitFeed;
117 90 }
118 91
119 92 /**
120 93 * put your comment there...
121 - *
94 + *
122 95 */
123 96 public function getPackagesCount() {
124 97 $result = $this->dbDriver->select('SELECT count(*) packagesCount FROM #__cjtoolbox_packages;', ARRAY_A);
125 98 return $result[0]['packagesCount'];
@@ -126,12 +99,12 @@
126 99 }
127 100
128 101 /**
129 102 * put your comment there...
130 - *
103 + *
131 104 */
132 105 public function getTemplatesCount() {
133 106 $result = $this->dbDriver->select('SELECT count(*) templatesCount FROM #__cjtoolbox_templates WHERE (attributes & 1) = 0;', ARRAY_A);
134 - return $result[0]['templatesCount'];
107 + return $result[0]['templatesCount'];
135 108 }
136 109
137 110 } // End class.