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/coupling.php +110 -0 6.07.2 View file →
@@ -32,8 +32,15 @@
32 32 * put your comment there...
33 33 *
34 34 * @var mixed
35 35 */
36 + protected $onquerylinkedtemplates = array('parameters' => array('query'));
37 +
38 + /**
39 + * put your comment there...
40 + *
41 + * @var mixed
42 + */
36 43 protected $onpinsblockfilters = array('parameters' => array(
37 44 'params' => array('linksExpressionFlag', 'pinPoint', 'customPins')
38 45 )
39 46 );
@@ -47,9 +54,63 @@
47 54
48 55 /**
49 56 * put your comment there...
50 57 *
58 + * @var mixed
51 59 */
60 + public static $templateTypes = array('scripts' => 'javascript', 'styles' => 'css');
61 +
62 + /**
63 + * put your comment there...
64 + *
65 + * @param mixed $id
66 + */
67 + public function getBlockCode($id) {
68 + // Initialize.
69 + $code = '';
70 + // Initialize.
71 + $tblCodeFiles = new CJTBlockFilesTable(cssJSToolbox::getInstance()->getDBDriver());
72 + // Query Block Code Files.
73 + $codeFiles = $tblCodeFiles->set('blockId', $id)
74 + ->fetchAll();
75 + // Merge all code files.
76 + foreach ($codeFiles as $codeFile) {
77 + // Wrap by Tag + Merge files.
78 + $code .= $codeFile['tag'] ? sprintf($codeFile['tag'], " {$codeFile['code']} ") : $codeFile['code'];
79 + }
80 + // Return final code text.
81 + return $code;
82 + }
83 +
84 + /**
85 + * put your comment there...
86 + *
87 + * @param mixed $blockId
88 + */
89 + public function getExecTemplatesCode($blockId) {
90 + // Initialize.
91 + $code = '';
92 + // Get all HTML and PHP templates linked to the block.
93 + $templates = $this->getLinkedTemplates($blockId, array('php', 'html'));
94 + if (!empty($templates)) {
95 + // Instantiate template model.
96 + $templateModel = CJTModel::getInstance('template');
97 + // Concat their codes.
98 + foreach ($templates as $template) {
99 + // Fetch template record with code loaded from file and decrypted if PHP!
100 + $templateModel->inputs['id'] = $template->id;
101 + $template = $templateModel->getItem();
102 + // Concat
103 + $code .= $template->code;
104 + }
105 + }
106 + return $code;
107 + }
108 +
109 + /**
110 + * put your comment there...
111 + *
112 + */
52 113 public function getOrder() {
53 114 return $this->ongetorder(get_option('meta-box-order_cjtoolbox'));
54 115 }
55 116
@@ -77,8 +138,57 @@
77 138 $view->filters($linksExpressionFlag, array(), 'active', array_keys($blocks));
78 139 // We'll process all blocks inside single loop.
79 140 $blocks = $blocks + $this->onexpressionsandlinkedblocks($view->exec());
80 141 return $blocks;
142 + }
143 +
144 + /**
145 + * put your comment there...
146 + *
147 + * @param mixed $blocks
148 + * @param mixed $types
149 + */
150 + public function getLinkedTemplates($blocks, $types = array('javascript', 'css')) {
151 + // Accept single id too!
152 + $blocks = (array) $blocks;
153 + // Import dependencies!
154 + cssJSToolbox::import('framework:db:mysql:xtable.inc.php', 'tables:template-revision.php');
155 + // Initialize vars.
156 + $templates = array();
157 + $query['select'] = 'SELECT t.id, t.type, t.queueName, r.version, r.file, bt.blockId';
158 + $query['from'] = 'FROM #__cjtoolbox_block_templates bt LEFT JOIN #__cjtoolbox_templates t
159 + ON bt.templateId = t.id
160 + LEFT JOIN #__cjtoolbox_template_revisions r
161 + ON bt.templateId = r.templateId';
162 + // Filter by blocks ids and getting the last revision of the template!
163 + $query['where']['blocks'] = implode(',', $blocks);
164 + $query['where']['attributes'] = CJTTemplateRevisionTable::FLAG_LAST_REVISION;
165 + // Filter by type.
166 + $query['where']['types'] = '"' . implode('","', $types) . '"';
167 + // Where clause.
168 + $query['where'] = "WHERE bt.blockId IN ({$query['where']['blocks']}) AND
169 + (r.attributes & {$query['where']['attributes']}) AND
170 + t.type IN ({$query['where']['types']})";
171 + // Filering!
172 + $query = $this->onquerylinkedtemplates($query);
173 + $query = "{$query['select']} {$query['from']} {$query['where']}";
174 + $templates = cssJSToolbox::getInstance()->getDBDriver()->select($query);
175 + return $templates;
176 + }
177 +
178 + /**
179 + * put your comment there...
180 + *
181 + * @param mixed $type
182 + */
183 + public function getQueueObject($type) {
184 + // Make sure Queue Object is ready/instantiated!
185 + $globalQueueObjectName = "wp_{$type}";
186 + if (!isset($GLOBALS[$globalQueueObjectName])) {
187 + $queueClass = 'WP_' . ucfirst($type);
188 + $GLOBALS[$globalQueueObjectName] = new $queueClass();
189 + }
190 + return $GLOBALS[$globalQueueObjectName];
81 191 }
82 192
83 193 } // End class.
84 194