PluginProbe
CSS & JavaScript Toolbox / 8.3.2
CSS & JavaScript Toolbox v8.3.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/template.php +32 -33 trunk8.3.2 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 -*
3 +*
4 4 */
5 5
6 6 // Disllow direct access.
7 7 defined('ABSPATH') or die('Access denied');
@@ -6,15 +6,15 @@
6 6 // Disllow direct access.
7 7 defined('ABSPATH') or die('Access denied');
8 8
9 9 /**
10 -*
10 +*
11 11 */
12 12 class CJTTemplateModel extends CJTHookableClass {
13 -
13 +
14 14 /**
15 15 * put your comment there...
16 - *
16 + *
17 17 * @var mixed
18 18 */
19 19 public $inputs;
20 20
@@ -19,23 +19,23 @@
19 19 public $inputs;
20 20
21 21 /**
22 22 * put your comment there...
23 - *
23 + *
24 24 * @var mixed
25 25 */
26 26 protected $onloadcodefile = array('parameters' => array('code', 'item'));
27 -
27 +
28 28 /**
29 29 * put your comment there...
30 - *
30 + *
31 31 * @var mixed
32 32 */
33 33 protected $onqueryitem = array('parameters' => array('query'));
34 -
34 +
35 35 /**
36 36 * put your comment there...
37 - *
37 + *
38 38 * @param mixed $code
39 39 */
40 40 public function decryptCode($encodedCode) {
41 41 /// base 64 code!
@@ -43,12 +43,12 @@
43 43 // Decode!
44 44 $code = base64_decode($code64);
45 45 return $code;
46 46 }
47 -
47 +
48 48 /**
49 49 * put your comment there...
50 - *
50 + *
51 51 * @param mixed $code
52 52 */
53 53 public function encryptCode($code) {
54 54 // Base 64 Encode!
@@ -56,12 +56,12 @@
56 56 // Hide inside PHP tags!
57 57 $encodedCode = "<?php defined(\"ABS_PATH\") or die(\"Access Denied\"); '{$code64}'; ?>";
58 58 return $encodedCode;
59 59 }
60 -
60 +
61 61 /**
62 62 * put your comment there...
63 - *
63 + *
64 64 * @param mixed $name
65 65 */
66 66 public function exists($name) {
67 67 // Find by name.
@@ -70,25 +70,25 @@
70 70 // Template object if exists with E_ALL complain!
71 71 return (($existsItem = $this->getTemplateBy()) && property_exists($existsItem, 'id') && $existsItem->id) ?
72 72 $existsItem : FALSE;
73 73 }
74 -
74 +
75 75 /**
76 76 * put your comment there...
77 - *
77 + *
78 78 */
79 79 public function getItem() {
80 80 $tManager = CJTModel::create('templates-manager');
81 81 $query = $tManager->getItemsQuery();
82 - $query['select'] = 'SELECT t.id,
82 + $query['select'] = 'SELECT t.id,
83 83 t.queueName,
84 - t.name,
85 - t.type,
86 - t.description,
87 - t.creationDate,
84 + t.name,
85 + t.type,
86 + t.description,
87 + t.creationDate,
88 88 t.keywords,
89 89 r.dateCreated lastModified,
90 - t.state,
90 + t.state,
91 91 a.name author,
92 92 r.changeLog,
93 93 r.version,
94 94 r.file,
@@ -108,12 +108,12 @@
108 108 $item->code = $this->onloadcodefile($code, $item);
109 109 // Return PHP StdClass object.
110 110 return $item;
111 111 }
112 -
112 +
113 113 /**
114 114 * Query Block based on the passed paramaters.
115 - *
115 + *
116 116 */
117 117 public function getTemplateBy() {
118 118 // import dependencies.
119 119 cssJSToolbox::import('framework:db:mysql:xtable.inc.php');
@@ -124,9 +124,9 @@
124 124 }
125 125
126 126 /**
127 127 * put your comment there...
128 - *
128 + *
129 129 */
130 130 public function save() {
131 131 // import libraries.
132 132 cssJSToolbox::import('framework:db:mysql:xtable.inc.php');
@@ -137,19 +137,18 @@
137 137 $saveId = isset($this->inputs['item']['template']['id']) ? $this->inputs['item']['template']['id'] : null;
138 138 // Load template data is exists (load), change values (setData).
139 139 $template = CJTxTable::getInstance('template');
140 140 if ($saveId) {
141 - $template->set('id', $saveId)->load();
141 + $template->set('id', $saveId)->load();
142 142 }
143 143 $template->setData($this->inputs['item']['template'])
144 144 ->setQueueName();
145 145 $templateDirName = $template->get('queueName');
146 - $contentDir = end( explode( DIRECTORY_SEPARATOR, dirname( dirname( plugin_dir_path( CJTOOLBOX_PLUGIN_FILE ) ) ) ) );
147 - $templateDir = "$contentDir/{$fSConfig->contentDir}/{$fSConfig->templatesDir}/{$templateDirName}";
146 + $templateDir = "wp-content/{$fSConfig->contentDir}/{$fSConfig->templatesDir}/{$templateDirName}";
148 147 if (!$template->get('id')) { // Add new Template
149 - // Search for author for the current local Wordpress user.
148 + // Search for author for the current local Wordpress user.
150 149 // If not created in the Authors table create one! If created get the ID!
151 - $author = CJTxTable::getInstance('author', null, "SELECT * FROM #__cjtoolbox_authors
150 + $author = CJTxTable::getInstance('author', null, "SELECT * FROM #__cjtoolbox_authors
152 151 WHERE name = '{$currentUser->user_login}'
153 152 AND (attributes & 2);");
154 153 // Create Wordpress user in Authors table.
155 154 if (!$author->get('id')) {
@@ -179,11 +178,11 @@
179 178 $lastRevisionNo = ((int) ($dbDriver->getRow("SELECT max(revisionNo) revisionNo
180 179 FROM #__cjtoolbox_template_revisions
181 180 WHERE templateId = {$template->get('id')}")->revisionNo));
182 181 // Checki if there is a previous revision and if there is changes!!
183 - $lastRevision = CJTxTable::getInstance('template-revision', null,
184 - "SELECT *
185 - FROM #__cjtoolbox_template_revisions
182 + $lastRevision = CJTxTable::getInstance('template-revision', null,
183 + "SELECT *
184 + FROM #__cjtoolbox_template_revisions
186 185 WHERE templateId = {$template->get('id')} AND revisionNo = {$lastRevisionNo}"
187 186 );
188 187 // Only add Revision if it has any field changed!
189 188 $revisionData = $this->inputs['item']['revision'];
@@ -229,9 +228,9 @@
229 228 }
230 229 // Return revision object.
231 230 return $revision->getData();
232 231 }
233 -
232 +
234 233 } // End class.
235 234
236 235 // Hookable!
237 236 CJTTemplateModel::define('CJTTemplateModel', array('hookType' => CJTWordpressEvents::HOOK_FILTER));