Diglin_UIOptimization - Version 1.3.0

Version Notes

- Version 1.3.0: improve canonical url generation, improve some configuration parameters, remove the option JS Packer because incompatible with Magento
- Version 1.2.0: improve compatibility with compilation feature of Magento, add a js/css flush button directly in the configuration page
- Version 1.1.0: rewrite some classes of the minify libraries to respect PHP 5 and prevent some errors, change the module name, make it compatible with compilation feature of Magento, add canonical url feature for SEO
- Version 1.0.10: fix type for css files stored in /js/ folder
- Version 1.0.9: make correct package for Magento prior to 1.5
- Version 1.0.8: make it compatible with 1.5 and some improvements.
- Version 1.0.2: add cron task to allow to update compressed/minified js/css files periodically
- Version 1.0.1: fix a missing config element class, this class seems to exists only since 1.4.1 or more

Download this release

Release Info

Developer Magento Core Team
Extension Diglin_UIOptimization
Version 1.3.0
Comparing to
See all releases


Code changes from version 1.2.0 to 1.3.0

Files changed (34) hide show
  1. app/code/community/Diglin/UIOptimization/Block/Adminhtml/Config/Source/Heading.php +18 -0
  2. app/code/community/Diglin/UIOptimization/Block/Adminhtml/Config/Source/Hint.php +2 -10
  3. app/code/community/Diglin/UIOptimization/Block/Optimize/Head.php +264 -252
  4. app/code/community/Diglin/UIOptimization/Block/W3Ccssvalidator.php +48 -54
  5. app/code/community/Diglin/UIOptimization/Block/W3Chtmlvalidator.php +48 -54
  6. app/code/community/Diglin/UIOptimization/Helper/Data.php +108 -99
  7. app/code/community/Diglin/UIOptimization/Model/Config/Source/Caseproperties.php +5 -15
  8. app/code/community/Diglin/UIOptimization/Model/Config/Source/Charset.php +5 -14
  9. app/code/community/Diglin/UIOptimization/Model/Config/Source/Csslevel.php +5 -15
  10. app/code/community/Diglin/UIOptimization/Model/Config/Source/Csstypeminify.php +7 -16
  11. app/code/community/Diglin/UIOptimization/Model/Config/Source/Doctype.php +28 -38
  12. app/code/community/Diglin/UIOptimization/Model/Config/Source/Jstypeminify.php +7 -16
  13. app/code/community/Diglin/UIOptimization/Model/Config/Source/Language.php +9 -19
  14. app/code/community/Diglin/UIOptimization/Model/Config/Source/Mergeselectors.php +5 -15
  15. app/code/community/Diglin/UIOptimization/Model/Config/Source/Optishorthand.php +5 -15
  16. app/code/community/Diglin/UIOptimization/Model/Config/Source/Profile.php +13 -23
  17. app/code/community/Diglin/UIOptimization/Model/Config/Source/Template.php +7 -17
  18. app/code/community/Diglin/UIOptimization/Model/Config/Source/Usermedium.php +13 -23
  19. app/code/community/Diglin/UIOptimization/Model/Config/Source/Warning.php +6 -16
  20. app/code/community/Diglin/UIOptimization/Model/Observer.php +12 -28
  21. app/code/community/Diglin/UIOptimization/Model/Overwrite/Design/Package.php +10 -18
  22. app/code/community/Diglin/UIOptimization/etc/adminhtml.xml +22 -22
  23. app/code/community/Diglin/UIOptimization/etc/config.xml +94 -91
  24. app/code/community/Diglin/UIOptimization/etc/system.xml +536 -509
  25. app/design/frontend/default/default/layout/uioptimization.xml +3 -73
  26. app/design/frontend/default/default/template/uioptimization/canonicalurl.phtml +24 -0
  27. app/design/frontend/default/default/template/uioptimization/canonicalurl/head-blog.phtml +0 -27
  28. app/design/frontend/default/default/template/uioptimization/canonicalurl/head-home.phtml +0 -27
  29. app/design/frontend/default/default/template/uioptimization/canonicalurl/head-product.phtml +0 -27
  30. app/design/frontend/default/default/template/uioptimization/canonicalurl/head.phtml +0 -27
  31. app/design/frontend/default/default/template/uioptimization/w3ccssvalidator.phtml +2 -10
  32. app/design/frontend/default/default/template/uioptimization/w3chtmlvalidator.phtml +3 -12
  33. lib/Diglin/Csstidy/Core.php +0 -1
  34. package.xml +7 -6
app/code/community/Diglin/UIOptimization/Block/Adminhtml/Config/Source/Heading.php ADDED
@@ -0,0 +1,18 @@
1
+ <?php
2
+ class Diglin_UIOptimization_Block_Adminhtml_Config_Source_Heading
3
+ extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
4
+ {
5
+ /**
6
+ * Render element html
7
+ *
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ * @return string
10
+ */
11
+ public function render(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
+ $useContainerId = $element->getData('use_container_id');
14
+ return sprintf('<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5"><h4>%s</h4></td></tr>',
15
+ $element->getHtmlId(), $element->getLabel()
16
+ );
17
+ }
18
+ }
app/code/community/Diglin/UIOptimization/Block/Adminhtml/Config/Source/Hint.php CHANGED
@@ -8,19 +8,11 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
class Diglin_UIOptimization_Block_Adminhtml_Config_Source_Hint
@@ -48,4 +40,4 @@ class Diglin_UIOptimization_Block_Adminhtml_Config_Source_Hint
48
<p><strong>Diglin_UIOptimization Version: '.$version.'</strong></p><p>' . $block->toHtml() .' ('. $this->__('You will be redirected to the Cache Management page with a successful message') .')</p>';
49
50
}
51
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
class Diglin_UIOptimization_Block_Adminhtml_Config_Source_Hint
40
<p><strong>Diglin_UIOptimization Version: '.$version.'</strong></p><p>' . $block->toHtml() .' ('. $this->__('You will be redirected to the Cache Management page with a successful message') .')</p>';
41
42
}
43
+ }
app/code/community/Diglin/UIOptimization/Block/Optimize/Head.php CHANGED
@@ -8,24 +8,16 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
- class Diglin_UIOptimization_Block_Optimize_Head extends Mage_Page_Block_Html_Head {
27
-
28
- /**
29
* Merge static and skin files of the same format into a set of HEAD directives or even into a directive
30
*
31
* Will attempt to merge into 1 directive, if merging callback is provided. In this case it will generate
@@ -50,27 +42,27 @@ class Diglin_UIOptimization_Block_Optimize_Head extends Mage_Page_Block_Html_Hea
50
// get static files from the js folder, no need in lookups
51
foreach ($staticItems as $params => $rows) {
52
foreach ($rows as $name) {
53
- if(strpos($name, '.css') !== false && Mage::getStoreConfigFlag('uioptimization/csscompression/enabled')){
54
- $items[$params][] = $this->_prepareCssCompression($name, $mergeCallback, true);
55
- }else if(strpos($name, '.js') !== false && Mage::getStoreConfigFlag('uioptimization/jscompression/enabled')){
56
- $items[$params][] = $this->_prepareJsCompression($name, $mergeCallback, true);
57
- }else{
58
- $items[$params][] = $mergeCallback ? Mage::getBaseDir() . DS . 'js' . DS . $name : $baseJsUrl . $name;
59
- }
60
}
61
}
62
63
// lookup each file basing on current theme configuration
64
foreach ($skinItems as $params => $rows) {
65
foreach ($rows as $name) {
66
- if(strpos($name, '.css') !== false && Mage::getStoreConfigFlag('uioptimization/csscompression/enabled')){
67
- $items[$params][] = $this->_prepareCssCompression($name, $mergeCallback);
68
- }else if(strpos($name, '.js') !== false && Mage::getStoreConfigFlag('uioptimization/jscompression/enabled')){
69
- $items[$params][] = $this->_prepareJsCompression($name, $mergeCallback);
70
- }else{
71
- $items[$params][] = $mergeCallback ? $designPackage->getFilename($name, array('_type' => 'skin'))
72
- : $designPackage->getSkinUrl($name, array());
73
- }
74
}
75
}
76
@@ -95,263 +87,283 @@ class Diglin_UIOptimization_Block_Optimize_Head extends Mage_Page_Block_Html_Hea
95
return $html;
96
}
97
98
- /**
99
- * Compress CSS files and write them to media/css folders
100
- *
101
- * @param string $name
102
- * @param string|array $mergeCallback
103
- * @param bool $static
104
- * @return string
105
- */
106
- protected function _prepareCssCompression($name, $mergeCallback = null, $static = false){
107
-
108
- $designPackage = Mage::getDesign ();
109
- $config = Mage::getStoreConfig('uioptimization/csscompression');
110
- $uiHelper = Mage::helper('uioptimization');
111
- $options = array();
112
-
113
- if($config['type'] == 'yuicompressor'){//YUI Compressor
114
- $minifier = 'Diglin_Minify_YUICompressor';
115
- $method = 'minifyCss';
116
- // init Minify class with YUI Compressor
117
- Diglin_Minify_YUICompressor::$jarFile = Mage::getBaseDir('lib') . DS . 'Diglin' . DS . 'yuicompressor-2.4.6' . DS . 'build' . DS . 'yuicompressor-2.4.6.jar' ;
118
- Diglin_Minify_YUICompressor::$tempDir = Mage::getBaseDir('tmp');
119
- if(strlen($config['java_path']) > 0){
120
- Diglin_Minify_YUICompressor::$javaExecutable = $config['java_path'];
121
- }
122
- }elseif($config['type'] == 'googleminify'){// Google Minify
123
- $minifier = 'Diglin_Minify_CSS';
124
- $method = 'minify';
125
- $options = array('minifierOptions' => array(Diglin_Minify::TYPE_CSS => array('preserveComments' => $config['preserve_comments'])));
126
- }else{// CSS Tidy
127
- $css = new Diglin_Csstidy_Core();
128
-
129
- switch($config['template']){
130
- case 'custom':
131
- $css->load_template ( $config['custom_template'] );
132
- break;
133
- case 'low_compression':
134
- case 'default':
135
- case 'high_compression':
136
- case 'highest_compression':
137
- default:
138
- $css->load_template ( $config['template'] );
139
- break;
140
- }
141
-
142
- $css->set_cfg ( 'remove_last_;', $config['remove_last_semicolon'] );
143
- $css->set_cfg ( 'remove_bslash', $config['remove_bslash'] );
144
- $css->set_cfg ( 'compress_colors', $config['compress_colors'] );
145
- $css->set_cfg ( 'compress_font-weight', $config['compress_font'] );
146
- $css->set_cfg ( 'lowercase_s', $config['lowercase_s'] );
147
- $css->set_cfg ( 'optimise_shorthands', $config['optimise_shorthands'] ); //0 = none, 1=safe optimize, 2=all optimize
148
- $css->set_cfg ( 'case_properties', $config['case_properties'] );
149
- $css->set_cfg ( 'sort_properties', $config['sort_properties'] );
150
- $css->set_cfg ( 'sort_selectors', $config['sort_selectors'] );
151
- $css->set_cfg ( 'merge_selectors', $config['merge_selectors'] );
152
- $css->set_cfg ( 'discard_invalid_properties', $config['discard_invalid_properties'] );
153
- $css->set_cfg ( 'css_level', $config['css_level'] ); //css2.0, css2.1, css1.0
154
- $css->set_cfg ( 'preserve_css', $config['preserve_css'] );
155
- $css->set_cfg ( 'timestamp', $config['timestamp'] );
156
- }
157
-
158
- $info = $uiHelper->getCompressedInfo($name, 'css', $static);
159
- if(!isset($info['result']) || $info['result'] != false){
160
- $info['result'] = true;
161
- }
162
-
163
- if (! file_exists ( $info['targetPathFile'] ) && $info['result'] ||
164
- !Mage::getStoreConfigFlag('uioptimization/general/cronupdate') && $info['result'] && filemtime($info['orgskin_path']) > filemtime($info['targetPathFile']) ) {
165
- $ioFile = new Diglin_Io_File();
166
- if($config['type'] == 'csstidy'){// CSS Tidy
167
- $css_code = $ioFile->read ( $info['orgskin_path'] );
168
- $css->parse ( $css_code );
169
- $cssText = $css->print->plain ();
170
- }else if($config['type'] == 'googleminify' || $config['type'] == 'yuicompressor'){ // Google Minify or YUI Compressor
171
- $options += array(
172
- 'quiet' => true,// quiet will allow to get the content as array mixed null, or, if the 'quiet' option is set to true, an array with keys "success" (bool), "statusCode" (int), "content" (string), and "headers" (array).
173
- 'files' => array($info['orgskin_path']),
174
- 'encodeMethod' => '',
175
- 'minifiers' => array(Diglin_Minify::TYPE_CSS => array($minifier, $method))
176
- );
177
- $results = Diglin_Minify::serve('Files', $options);
178
- $cssText = $results['content'];
179
- }
180
-
181
- //clean or fix @import and url(...); by comparing the path with the original CSS file (not the compressed one otherwise the path is wrong)
182
- $cssText = $designPackage->beforeMergeCss($info['orgskin_path'], $cssText);
183
-
184
- $info['result'] = $ioFile->write ( $info['targetPathFile'], $cssText, 0644 );
185
- };
186
- return $uiHelper->getResultPath($info, $mergeCallback);
187
- }
188
189
- /**
190
- * Compress JS files and write them to media/js folders
191
- *
192
- * @param string $name
193
- * @param string|array $mergeCallback
194
- * @param bool $static
195
- * @return string
196
- */
197
- protected function _prepareJsCompression($name, $mergeCallback = null, $static = false){
198
-
199
- $config = Mage::getStoreConfig('uioptimization/jscompression');
200
- $uiHelper = Mage::helper('uioptimization');
201
- $options = array();
202
-
203
- $info = $uiHelper->getCompressedInfo($name, 'js', $static);
204
- if(!isset($info['result']) || $info['result'] != false){
205
- $info['result'] = true;
206
- }
207
-
208
- if (! file_exists ( $info['targetPathFile'] ) && $info['result'] || !Mage::getStoreConfigFlag('uioptimization/general/cronupdate') && $info['result'] && filemtime($info['orgskin_path']) > filemtime($info['targetPathFile'])) {
209
- switch($config['type']){
210
- case 'packer':
211
- $minifier = 'Diglin_Minify_Packer';
212
- $method = 'minify';
213
- break;
214
- case 'yuicompressor':
215
- $minifier = 'Diglin_Minify_YUICompressor';
216
- $method = 'minifyJs';
217
- Diglin_Minify_YUICompressor::$jarFile = Mage::getBaseDir('lib') . DS . 'Diglin' . DS .'yuicompressor-2.4.6' . DS . 'build' . DS . 'yuicompressor-2.4.6.jar' ;
218
- Diglin_Minify_YUICompressor::$tempDir = Mage::getBaseDir('tmp');
219
- if(strlen($config['java_path']) > 0){
220
- Diglin_Minify_YUICompressor::$javaExecutable = $config['java_path'];
221
- }
222
- $options = array('minifierOptions' =>
223
- array(Diglin_Minify::TYPE_JS =>
224
- array(
225
- 'disable-optimizations'=>$config['disable_alloptimisation'],
226
- 'preserve-semi' => $config['preserve_semic'],
227
- 'nomunge' => $config['minify_only']
228
- )
229
- ));
230
- break;
231
- case 'jsmin':
232
- default:
233
- $minifier = 'Diglin_JSMin';
234
- $method = 'minify';
235
- break;
236
- }
237
-
238
- $options += array(
239
- 'quiet' => true,// quiet will allow to get the content as array mixed null, or, if the 'quiet' option is set to true, an array with keys "success" (bool), "statusCode" (int), "content" (string), and "headers" (array).
240
- 'minifiers' => array(Diglin_Minify::TYPE_JS => array($minifier, $method)),
241
- 'files' => array($info['orgskin_path']),
242
- 'encodeMethod' => '',
243
-
244
- );
245
- $results = Diglin_Minify::serve('Files', $options);
246
-
247
- if($results['success']){
248
- $io = new Diglin_Io_File;
249
- $info['result'] = $io->write ( $info['targetPathFile'], $results['content'], 0644 );
250
- }else{
251
- $info['result'] = false;
252
- }
253
- }
254
- return $uiHelper->getResultPath($info, $mergeCallback);
255
- }
256
-
257
- /**
258
- * Canonical URL
259
- */
260
- public function getHeadUrl ()
261
{
262
if (empty($this->_data['urlKey'])) {
263
$url = Mage::helper('core/url')->getCurrentUrl();
264
$parsedUrl = parse_url($url);
265
- $scheme = $parsedUrl['scheme'];
266
- $host = $parsedUrl['host'];
267
$port = isset($parsedUrl['port']) ? $parsedUrl['port'] : null;
268
- $path = $parsedUrl['path'];
269
- $headUrl = $scheme . '://' . $host . ($port && '80' != $port ? ':' . $port : '') . $path;
270
- if (Mage::getStoreConfig('uioptimization/seo/trailingslash')) {
271
- if (! preg_match('/\\.(rss|html|htm|xml|php?)#x2F;', strtolower($headUrl)) && substr($headUrl, - 1) != '/') {
272
- $headUrl .= '/';
273
- }
274
- }
275
- //return $headUrl;
276
- $this->_data['urlKey'] = $headUrl;
277
}
278
return $this->_data['urlKey'];
279
- }
280
281
- /**
282
- * Canonical URL
283
- */
284
- public function getHeadHomeUrl ()
285
{
286
if (empty($this->_data['urlKey'])) {
287
$url = Mage::helper('core/url')->getCurrentUrl();
288
$request = Mage::app()->getRequest();
289
$currentUri = $request->getRequestUri();
290
// Purpose: provide a canonical url for shop having store code in header for the homepage
291
if($request->getBaseUrl() && strpos($currentUri, $request->getBaseUrl()) !== false ){
292
- $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . substr($currentUri,strlen( $request->getBaseUrl()) +1);
293
-
294
- $currentUriClean = trim($currentUri, '/');
295
$parts = explode('/', $currentUriClean);
296
-
297
// Add code store to url if not provided by the client
298
- if(count($parts) <= 1 && Mage::getStoreConfigFlag('web/url/use_store') && Mage::getStoreConfigFlag('web/seo/use_rewrites')){
299
- $url .= Mage::app()->getStore()->getCode() . '/';
300
- }
301
- }
302
303
$parsedUrl = parse_url($url);
304
- $scheme = $parsedUrl['scheme'];
305
- $host = $parsedUrl['host'];
306
$port = isset($parsedUrl['port']) ? $parsedUrl['port'] : null;
307
- $path = $parsedUrl['path'];
308
- $headUrl = $scheme . '://' . $host . ($port && '80' != $port ? ':' . $port : '') . $path;
309
- if (Mage::getStoreConfig('uioptimization/seo/trailingslash')) {
310
- if (! preg_match('/\\.(rss|html|htm|xml|php?)#x2F;', strtolower($headUrl)) && substr($headUrl, - 1) != '/') {
311
- $headUrl .= '/';
312
- }
313
- }
314
- //return $headUrl;
315
- $this->_data['urlKey'] = $headUrl;
316
}
317
return $this->_data['urlKey'];
318
}
319
320
- /**
321
- * Canonical Product URL
322
- */
323
- public function getHeadProductUrl ()
324
{
325
if (empty($this->_data['urlKey'])) {
326
$product_id = $this->getRequest()->getParam('id');
327
- $_item = Mage::getModel('catalog/product')->load($product_id);
328
- $this->_data['urlKey'] = Mage::getBaseUrl() . $_item->getUrlKey() . Mage::helper('catalog/product')->getProductUrlSuffix();
329
- if (Mage::getStoreConfig('uioptimization/seo/trailingslash')) {
330
- if (! preg_match('/\\.(rss|html|htm|xml|php?)#x2F;', strtolower($this->_data['urlKey'])) && substr($this->_data['urlKey'], - 1) != '/') {
331
- $this->_data['urlKey'] .= '/';
332
- }
333
- }
334
}
335
return $this->_data['urlKey'];
336
}
337
-
338
- /**
339
- * Canonical Blog URL
340
- */
341
- public function getHeadBlogUrl ()
342
{
343
- $url = (! empty($_SERVER['HTTPS'])) ? "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] : "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
344
- $parsedUrl = parse_url($url);
345
- $scheme = $parsedUrl['scheme'];
346
- $host = $parsedUrl['host'];
347
- $port = isset($parsedUrl['port']) ? $parsedUrl['port'] : null;
348
- $path = $parsedUrl['path'];
349
- $headUrl = $scheme . '://' . $host . ($port && '80' != $port ? ':' . $port : '') . $path;
350
- if (Mage::getStoreConfig('uioptimization/seo/trailingslash')) {
351
- if (! preg_match('/\\.(rss|html|htm|xml|php?)#x2F;', strtolower($headUrl)) && substr($headUrl, - 1) != '/') {
352
- $headUrl .= '/';
353
- }
354
}
355
- return $headUrl;
356
}
357
}
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
+ class Diglin_UIOptimization_Block_Optimize_Head extends Mage_Page_Block_Html_Head
19
+ {
20
+ /**
21
* Merge static and skin files of the same format into a set of HEAD directives or even into a directive
22
*
23
* Will attempt to merge into 1 directive, if merging callback is provided. In this case it will generate
42
// get static files from the js folder, no need in lookups
43
foreach ($staticItems as $params => $rows) {
44
foreach ($rows as $name) {
45
+ if(strpos($name, '.css') !== false && Mage::getStoreConfigFlag('uioptimization/csscompression/enabled')){
46
+ $items[$params][] = $this->_prepareCssCompression($name, $mergeCallback, true);
47
+ }else if(strpos($name, '.js') !== false && Mage::getStoreConfigFlag('uioptimization/jscompression/enabled')){
48
+ $items[$params][] = $this->_prepareJsCompression($name, $mergeCallback, true);
49
+ }else{
50
+ $items[$params][] = $mergeCallback ? Mage::getBaseDir() . DS . 'js' . DS . $name : $baseJsUrl . $name;
51
+ }
52
}
53
}
54
55
// lookup each file basing on current theme configuration
56
foreach ($skinItems as $params => $rows) {
57
foreach ($rows as $name) {
58
+ if(strpos($name, '.css') !== false && Mage::getStoreConfigFlag('uioptimization/csscompression/enabled')){
59
+ $items[$params][] = $this->_prepareCssCompression($name, $mergeCallback);
60
+ }else if(strpos($name, '.js') !== false && Mage::getStoreConfigFlag('uioptimization/jscompression/enabled')){
61
+ $items[$params][] = $this->_prepareJsCompression($name, $mergeCallback);
62
+ }else{
63
+ $items[$params][] = $mergeCallback ? $designPackage->getFilename($name, array('_type' => 'skin'))
64
+ : $designPackage->getSkinUrl($name, array());
65
+ }
66
}
67
}
68
87
return $html;
88
}
89
90
+ /**
91
+ * Compress CSS files and write them to media/css folders
92
+ *
93
+ * @param string $name
94
+ * @param string|array $mergeCallback
95
+ * @param bool $static
96
+ * @return string
97
+ */
98
+ protected function _prepareCssCompression($name, $mergeCallback = null, $static = false)
99
+ {
100
+ $designPackage = Mage::getDesign ();
101
+ $config = Mage::getStoreConfig('uioptimization/csscompression');
102
+ $uiHelper = Mage::helper('uioptimization');
103
+ $options = array();
104
+
105
+ if($config['type'] == 'yuicompressor'){//YUI Compressor
106
+ $minifier = 'Diglin_Minify_YUICompressor';
107
+ $method = 'minifyCss';
108
+ // init Minify class with YUI Compressor
109
+ Diglin_Minify_YUICompressor::$jarFile = Mage::getBaseDir('lib') . DS . 'Diglin' . DS . 'yuicompressor-2.4.6' . DS . 'build' . DS . 'yuicompressor-2.4.6.jar' ;
110
+ Diglin_Minify_YUICompressor::$tempDir = Mage::getBaseDir('tmp');
111
+ if(strlen($config['java_path']) > 0){
112
+ Diglin_Minify_YUICompressor::$javaExecutable = $config['java_path'];
113
+ }
114
+ }elseif($config['type'] == 'googleminify'){// Google Minify
115
+ $minifier = 'Diglin_Minify_CSS';
116
+ $method = 'minify';
117
+ $options = array('minifierOptions' => array(Diglin_Minify::TYPE_CSS => array('preserveComments' => $config['preserve_comments'])));
118
+ }else{// CSS Tidy
119
+ $css = new Diglin_Csstidy_Core();
120
+
121
+ switch($config['template']){
122
+ case 'custom':
123
+ $css->load_template ( $config['custom_template'] );
124
+ break;
125
+ case 'low_compression':
126
+ case 'default':
127
+ case 'high_compression':
128
+ case 'highest_compression':
129
+ default:
130
+ $css->load_template ( $config['template'] );
131
+ break;
132
+ }
133
+
134
+ $css->set_cfg ( 'remove_last_;', $config['remove_last_semicolon'] );
135
+ $css->set_cfg ( 'remove_bslash', $config['remove_bslash'] );
136
+ $css->set_cfg ( 'compress_colors', $config['compress_colors'] );
137
+ $css->set_cfg ( 'compress_font-weight', $config['compress_font'] );
138
+ $css->set_cfg ( 'lowercase_s', $config['lowercase_s'] );
139
+ $css->set_cfg ( 'optimise_shorthands', $config['optimise_shorthands'] ); //0 = none, 1=safe optimize, 2=all optimize
140
+ $css->set_cfg ( 'case_properties', $config['case_properties'] );
141
+ $css->set_cfg ( 'sort_properties', $config['sort_properties'] );
142
+ $css->set_cfg ( 'sort_selectors', $config['sort_selectors'] );
143
+ $css->set_cfg ( 'merge_selectors', $config['merge_selectors'] );
144
+ $css->set_cfg ( 'discard_invalid_properties', $config['discard_invalid_properties'] );
145
+ $css->set_cfg ( 'css_level', $config['css_level'] ); //css2.0, css2.1, css1.0
146
+ $css->set_cfg ( 'preserve_css', $config['preserve_css'] );
147
+ $css->set_cfg ( 'timestamp', $config['timestamp'] );
148
+ }
149
+
150
+ $info = $uiHelper->getCompressedInfo($name, 'css', $static);
151
+ if(!isset($info['result']) || $info['result'] != false){
152
+ $info['result'] = true;
153
+ }
154
+
155
+ if (! file_exists ( $info['targetPathFile'] ) && $info['result'] ||
156
+ !Mage::getStoreConfigFlag('uioptimization/general/cronupdate') && $info['result'] && filemtime($info['orgskin_path']) > filemtime($info['targetPathFile']) ) {
157
+ $ioFile = new Diglin_Io_File();
158
+ if($config['type'] == 'csstidy'){// CSS Tidy
159
+ $css_code = $ioFile->read ( $info['orgskin_path'] );
160
+ $css->parse ( $css_code );
161
+ $cssText = $css->print->plain ();
162
+ }else if($config['type'] == 'googleminify' || $config['type'] == 'yuicompressor'){ // Google Minify or YUI Compressor
163
+ $options += array(
164
+ 'quiet' => true,// quiet will allow to get the content as array mixed null, or, if the 'quiet' option is set to true, an array with keys "success" (bool), "statusCode" (int), "content" (string), and "headers" (array).
165
+ 'files' => array($info['orgskin_path']),
166
+ 'encodeMethod' => '',
167
+ 'minifiers' => array(Diglin_Minify::TYPE_CSS => array($minifier, $method))
168
+ );
169
+ $results = Diglin_Minify::serve('Files', $options);
170
+ $cssText = $results['content'];
171
+ }
172
+
173
+ //clean or fix @import and url(...); by comparing the path with the original CSS file (not the compressed one otherwise the path is wrong)
174
+ $cssText = $designPackage->beforeMergeCss($info['orgskin_path'], $cssText);
175
+
176
+ $info['result'] = $ioFile->write ( $info['targetPathFile'], $cssText, 0644 );
177
+ };
178
+ return $uiHelper->getResultPath($info, $mergeCallback);
179
+ }
180
+
181
+ /**
182
+ * Compress JS files and write them to media/js folders
183
+ *
184
+ * @param string $name
185
+ * @param string|array $mergeCallback
186
+ * @param bool $static
187
+ * @return string
188
+ */
189
+ protected function _prepareJsCompression($name, $mergeCallback = null, $static = false)
190
+ {
191
+ $config = Mage::getStoreConfig('uioptimization/jscompression');
192
+ $uiHelper = Mage::helper('uioptimization');
193
+ $options = array();
194
+
195
+ $info = $uiHelper->getCompressedInfo($name, 'js', $static);
196
+ if(!isset($info['result']) || $info['result'] != false){
197
+ $info['result'] = true;
198
+ }
199
+
200
+ if (! file_exists ( $info['targetPathFile'] ) && $info['result'] || !Mage::getStoreConfigFlag('uioptimization/general/cronupdate') && $info['result'] && filemtime($info['orgskin_path']) > filemtime($info['targetPathFile'])) {
201
+ switch($config['type']){
202
+ case 'packer':
203
+ $minifier = 'Diglin_Minify_Packer';
204
+ $method = 'minify';
205
+ break;
206
+ case 'yuicompressor':
207
+ $minifier = 'Diglin_Minify_YUICompressor';
208
+ $method = 'minifyJs';
209
+ Diglin_Minify_YUICompressor::$jarFile = Mage::getBaseDir('lib') . DS . 'Diglin' . DS .'yuicompressor-2.4.6' . DS . 'build' . DS . 'yuicompressor-2.4.6.jar' ;
210
+ Diglin_Minify_YUICompressor::$tempDir = Mage::getBaseDir('tmp');
211
+ if(strlen($config['java_path']) > 0){
212
+ Diglin_Minify_YUICompressor::$javaExecutable = $config['java_path'];
213
+ }
214
+ $options = array('minifierOptions' =>
215
+ array(Diglin_Minify::TYPE_JS =>
216
+ array(
217
+ 'disable-optimizations'=>$config['disable_alloptimisation'],
218
+ 'preserve-semi' => $config['preserve_semic'],
219
+ 'nomunge' => $config['minify_only']
220
+ )
221
+ ));
222
+ break;
223
+ case 'jsmin':
224
+ default:
225
+ $minifier = 'Diglin_JSMin';
226
+ $method = 'minify';
227
+ break;
228
+ }
229
+
230
+ $options += array(
231
+ 'quiet' => true,// quiet will allow to get the content as array mixed null, or, if the 'quiet' option is set to true, an array with keys "success" (bool), "statusCode" (int), "content" (string), and "headers" (array).
232
+ 'minifiers' => array(Diglin_Minify::TYPE_JS => array($minifier, $method)),
233
+ 'files' => array($info['orgskin_path']),
234
+ 'encodeMethod' => '',
235
+
236
+ );
237
+ $results = Diglin_Minify::serve('Files', $options);
238
+
239
+ if($results['success']){
240
+ $io = new Diglin_Io_File ();
241
+ $info['result'] = $io->write ( $info['targetPathFile'], $results['content'], 0644 );
242
+ }else{
243
+ $info['result'] = false;
244
+ }
245
+ }
246
+ return $uiHelper->getResultPath($info, $mergeCallback);
247
+ }
248
249
+ /**
250
+ * Canonical URL
251
+ * @return $this Rissip_UIOptimization_Block_Optimize_Head
252
+ */
253
+ public function getCanonicalUrl ()
254
+ {
255
+ Mage::dispatchEvent('uioptimization_canonicalurl_before', array('head' => $this, 'transport' => ''));
256
+
257
+ if(is_string($this->transport) && strlen($this->transport) > 0){
258
+ return $this->transport;
259
+ }
260
+
261
+ $handles = Mage::app()->getLayout()->getUpdate()->getHandles();
262
+
263
+ $searchHandles = array('catalogsearch_result_index', 'catalogsearch_advanced_index', 'catalogsearch_advanced_result');
264
+ $productHandles = array('catalog_product_view');
265
+ $homeHandles = array('cms_index_index');
266
+ $blogHandles = array('blog_post_view', 'blog_cat_view');
267
+
268
+ foreach ($handles as $handle){
269
+ // Catalog Search
270
+ if (in_array($handle, $searchHandles) && Mage::getStoreConfigFlag('uioptimization/seo/search')) {
271
+ return $this->_setCanonicalSearchUrl();
272
+ }elseif (!Mage::getStoreConfigFlag('uioptimization/seo/search')) {
273
+ return;
274
+ }
275
+
276
+ // Catalog Product
277
+ if (in_array($handle, $productHandles) && Mage::getStoreConfigFlag('uioptimization/seo/products')) {
278
+ return $this->_setCanonicalProductUrl();
279
+ }elseif (!Mage::getStoreConfigFlag('uioptimization/seo/products')) {
280
+ return;
281
+ }
282
+
283
+ // Homepage CMS
284
+ if (in_array($handle, $homeHandles) && Mage::getStoreConfigFlag('uioptimization/seo/cmshome')) {
285
+ return $this->_setCanonicalHomeUrl();
286
+ }elseif (!Mage::getStoreConfigFlag('uioptimization/seo/cmshome')) {
287
+ return;
288
+ }
289
+ }
290
+ return $this->_setCanonicalUrl();
291
+ }
292
+
293
+ private function _setCanonicalUrl()
294
{
295
if (empty($this->_data['urlKey'])) {
296
$url = Mage::helper('core/url')->getCurrentUrl();
297
$parsedUrl = parse_url($url);
298
$port = isset($parsedUrl['port']) ? $parsedUrl['port'] : null;
299
+ $headUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . ($port && '80' != $port ? ':' . $port : '') . $parsedUrl['path'];
300
+ $this->_data['urlKey'] = Mage::helper('uioptimization')->getTrailingSlash($headUrl);
301
}
302
return $this->_data['urlKey'];
303
+ }
304
305
+ /**
306
+ * Canonical URL for homepage
307
+ */
308
+ private function _setCanonicalHomeUrl ()
309
{
310
if (empty($this->_data['urlKey'])) {
311
$url = Mage::helper('core/url')->getCurrentUrl();
312
$request = Mage::app()->getRequest();
313
$currentUri = $request->getRequestUri();
314
+
315
// Purpose: provide a canonical url for shop having store code in header for the homepage
316
if($request->getBaseUrl() && strpos($currentUri, $request->getBaseUrl()) !== false ){
317
+ $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . substr($currentUri,strlen( $request->getBaseUrl()) +1);
318
+
319
+ $currentUriClean = trim($currentUri, '/');
320
$parts = explode('/', $currentUriClean);
321
+
322
// Add code store to url if not provided by the client
323
+ if(count($parts) <= 1 && Mage::getStoreConfigFlag('web/url/use_store') && Mage::getStoreConfigFlag('web/seo/use_rewrites')){
324
+ $url .= Mage::app()->getStore()->getCode() . '/';
325
+ }
326
+ }
327
328
$parsedUrl = parse_url($url);
329
$port = isset($parsedUrl['port']) ? $parsedUrl['port'] : null;
330
+ $headUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . ($port && '80' != $port ? ':' . $port : '') . $parsedUrl['path'];
331
+ $this->_data['urlKey'] = Mage::helper('uioptimization')->getTrailingSlash($headUrl);
332
}
333
return $this->_data['urlKey'];
334
}
335
336
+ /**
337
+ * Canonical Product URL
338
+ */
339
+ private function _setCanonicalProductUrl ()
340
{
341
if (empty($this->_data['urlKey'])) {
342
$product_id = $this->getRequest()->getParam('id');
343
+ $_item = Mage::getModel('catalog/product')
344
+ ->setStoreId(Mage::app()->getStore()->getId())
345
+ ->load($product_id);
346
+ $headUrl = Mage::getBaseUrl() . $_item->getUrlPath() /*. Mage::helper('catalog/product')->getProductUrlSuffix()*/;
347
+ $this->_data['urlKey'] = Mage::helper('uioptimization')->getTrailingSlash($headUrl);
348
}
349
return $this->_data['urlKey'];
350
}
351
+
352
+ private function _setCanonicalSearchUrl()
353
{
354
+ if (empty($this->_data['urlKey'])) {
355
+
356
+ $headUrl = $this->_setCanonicalUrl();
357
+ $request = Mage::app()->getRequest();
358
+ $searchParam = $request->getParam('q');
359
+ $searchNameParam = $request->getParam('name');
360
+ $searchDescParam = $request->getParam('description');
361
+ $params = array();
362
+ if($searchParam) $params[] = 'q='.$searchParam;
363
+ if($searchNameParam) $params[] = 'name='.$searchNameParam;
364
+ if($searchDescParam) $params[] = 'description='.$searchDescParam;
365
+ $this->_data['urlKey'] = $headUrl . ((count($params))? '?' .implode('&', $params): '');
366
}
367
+ return $this->_data['urlKey'];
368
}
369
}
app/code/community/Diglin/UIOptimization/Block/W3Ccssvalidator.php CHANGED
@@ -8,76 +8,70 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
- class Diglin_UIOptimization_Block_W3Ccssvalidator extends Mage_Core_Block_Template{
27
-
28
- protected $_validator;
29
-
30
- public $results;
31
-
32
- protected function _beforeToHtml(){
33
-
34
if ( !Mage::getStoreConfig('uioptimization/w3ccssvalidator/enabled')
35
|| !Mage::helper('core')->isDevAllowed()
36
|| strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) {
37
return '';
38
}
39
40
- /**
41
- * To force to include the PEAR libs installed in Magento (downloader/pearlib) - Without that
42
- * we cannot have the Services_W3C_HTMLValidator dependencies
43
- * The var $pear is not used here for the moment. But the call to Varien_Pear is necessary
44
- */
45
- //$pear = Varien_Pear::getInstance (); // not compatible with Magento > 1.5
46
- $config = Mage::getStoreConfig ( 'uioptimization' );
47
-
48
- $this->_validator = new Diglin_Services_W3C_CSSValidator ();
49
-
50
- if(!empty($config['w3ccssvalidator']['validator_uri'])){
51
- $this->_validator->validator_uri = $config['w3ccssvalidator']['validator_uri'];
52
- };
53
-
54
- if(!empty($config['w3ccssvalidator']['charset'])){
55
- $this->_validator->charset = $config['w3ccssvalidator']['charset'];
56
- };
57
-
58
- if(!empty($config['w3ccssvalidator']['fbd'])){
59
- $this->_validator->fbc = (int)$config['w3ccssvalidator']['fbc'];
60
- };
61
-
62
- if(!empty($config['w3ccssvalidator']['doctype'])){
63
- $this->_validator->doctype = $config['w3ccssvalidator']['doctype'];
64
- };
65
-
66
- if(!empty($config['w3ccssvalidator']['fbc'])){
67
- $this->_validator->fbd = (int)$config['w3ccssvalidator']['fbc'];
68
- };
69
-
70
- //$this->results = $this->_validator->validate('http://www.google.com/');
71
- $this->results = $this->_validator->validateUri(Mage::helper('core/url')->getCurrentUrl());
72
-
73
- return parent::_beforeToHtml();
74
}
75
76
/**
77
*
78
* @return Services_W3C_HTMLValidator_Response $this->results
79
*/
80
- public function getValidatorResults(){
81
- return $this->results;
82
}
83
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
+ class Diglin_UIOptimization_Block_W3Ccssvalidator extends Mage_Core_Block_Template
19
+ {
20
+
21
+ protected $_validator;
22
+
23
+ public $results;
24
+
25
+ protected function _beforeToHtml()
26
+ {
27
if ( !Mage::getStoreConfig('uioptimization/w3ccssvalidator/enabled')
28
|| !Mage::helper('core')->isDevAllowed()
29
|| strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) {
30
return '';
31
}
32
33
+ /**
34
+ * To force to include the PEAR libs installed in Magento (downloader/pearlib) - Without that
35
+ * we cannot have the Services_W3C_HTMLValidator dependencies
36
+ * The var $pear is not used here for the moment. But the call to Varien_Pear is necessary
37
+ */
38
+ //$pear = Varien_Pear::getInstance (); // not compatible with Magento > 1.5
39
+ $config = Mage::getStoreConfig ( 'uioptimization' );
40
+
41
+ $this->_validator = new Diglin_Services_W3C_CSSValidator ();
42
+
43
+ if(!empty($config['w3ccssvalidator']['validator_uri'])){
44
+ $this->_validator->validator_uri = $config['w3ccssvalidator']['validator_uri'];
45
+ };
46
+
47
+ if(!empty($config['w3ccssvalidator']['charset'])){
48
+ $this->_validator->charset = $config['w3ccssvalidator']['charset'];
49
+ };
50
+
51
+ if(!empty($config['w3ccssvalidator']['fbd'])){
52
+ $this->_validator->fbc = (int)$config['w3ccssvalidator']['fbc'];
53
+ };
54
+
55
+ if(!empty($config['w3ccssvalidator']['doctype'])){
56
+ $this->_validator->doctype = $config['w3ccssvalidator']['doctype'];
57
+ };
58
+
59
+ if(!empty($config['w3ccssvalidator']['fbc'])){
60
+ $this->_validator->fbd = (int)$config['w3ccssvalidator']['fbc'];
61
+ };
62
+
63
+ //$this->results = $this->_validator->validate('http://www.google.com/');
64
+ $this->results = $this->_validator->validateUri(Mage::helper('core/url')->getCurrentUrl());
65
+
66
+ return parent::_beforeToHtml();
67
}
68
69
/**
70
*
71
* @return Services_W3C_HTMLValidator_Response $this->results
72
*/
73
+ public function getValidatorResults()
74
+ {
75
+ return $this->results;
76
}
77
+ }
app/code/community/Diglin/UIOptimization/Block/W3Chtmlvalidator.php CHANGED
@@ -8,76 +8,70 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
- class Diglin_UIOptimization_Block_W3Chtmlvalidator extends Mage_Core_Block_Template{
27
-
28
- protected $_validator;
29
-
30
- public $results;
31
-
32
- protected function _beforeToHtml(){
33
-
34
if ( !Mage::getStoreConfig('uioptimization/w3chtmlvalidator/enabled')
35
|| !Mage::helper('core')->isDevAllowed()
36
|| strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) {
37
return '';
38
}
39
40
- /**
41
- * To force to include the PEAR libs installed in Magento (downloader/pearlib) - Without that
42
- * we cannot have the Services_W3C_HTMLValidator dependencies
43
- * The var $pear is not used here for the moment. But the call to Varien_Pear is necessary
44
- */
45
- //$pear = Varien_Pear::getInstance (); // not compatible with Magento > 1.5
46
- $config = Mage::getStoreConfig ( 'uioptimization' );
47
-
48
- $this->_validator = new Diglin_Services_W3C_HTMLValidator ();
49
-
50
- if(!empty($config['w3chtmlvalidator']['validator_uri'])){
51
- $this->_validator->validator_uri = $config['w3chtmlvalidator']['validator_uri'];
52
- };
53
-
54
- if(!empty($config['w3chtmlvalidator']['charset'])){
55
- $this->_validator->charset = $config['w3chtmlvalidator']['charset'];
56
- };
57
-
58
- if(!empty($config['w3chtmlvalidator']['fbd'])){
59
- $this->_validator->fbc = (int)$config['w3chtmlvalidator']['fbc'];
60
- };
61
-
62
- if(!empty($config['w3chtmlvalidator']['doctype'])){
63
- $this->_validator->doctype = $config['w3chtmlvalidator']['doctype'];
64
- };
65
-
66
- if(!empty($config['w3chtmlvalidator']['fbc'])){
67
- $this->_validator->fbd = (int)$config['w3chtmlvalidator']['fbc'];
68
- };
69
-
70
- //$this->results = $this->_validator->validate('http://www.google.com/');
71
- $this->results = $this->_validator->validate(Mage::helper('core/url')->getCurrentUrl());
72
-
73
- return parent::_beforeToHtml();
74
}
75
76
/**
77
*
78
* @return Services_W3C_HTMLValidator_Response $this->results
79
*/
80
- public function getValidatorResults(){
81
- return $this->results;
82
}
83
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
+ class Diglin_UIOptimization_Block_W3Chtmlvalidator extends Mage_Core_Block_Template
19
+ {
20
+ protected $_validator;
21
+
22
+ public $results;
23
+
24
+ protected function _beforeToHtml()
25
+ {
26
+
27
if ( !Mage::getStoreConfig('uioptimization/w3chtmlvalidator/enabled')
28
|| !Mage::helper('core')->isDevAllowed()
29
|| strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) {
30
return '';
31
}
32
33
+ /**
34
+ * To force to include the PEAR libs installed in Magento (downloader/pearlib) - Without that
35
+ * we cannot have the Services_W3C_HTMLValidator dependencies
36
+ * The var $pear is not used here for the moment. But the call to Varien_Pear is necessary
37
+ */
38
+ //$pear = Varien_Pear::getInstance (); // not compatible with Magento > 1.5
39
+ $config = Mage::getStoreConfig ( 'uioptimization' );
40
+
41
+ $this->_validator = new Diglin_Services_W3C_HTMLValidator ();
42
+
43
+ if(!empty($config['w3chtmlvalidator']['validator_uri'])){
44
+ $this->_validator->validator_uri = $config['w3chtmlvalidator']['validator_uri'];
45
+ };
46
+
47
+ if(!empty($config['w3chtmlvalidator']['charset'])){
48
+ $this->_validator->charset = $config['w3chtmlvalidator']['charset'];
49
+ };
50
+
51
+ if(!empty($config['w3chtmlvalidator']['fbd'])){
52
+ $this->_validator->fbc = (int)$config['w3chtmlvalidator']['fbc'];
53
+ };
54
+
55
+ if(!empty($config['w3chtmlvalidator']['doctype'])){
56
+ $this->_validator->doctype = $config['w3chtmlvalidator']['doctype'];
57
+ };
58
+
59
+ if(!empty($config['w3chtmlvalidator']['fbc'])){
60
+ $this->_validator->fbd = (int)$config['w3chtmlvalidator']['fbc'];
61
+ };
62
+
63
+ //$this->results = $this->_validator->validate('http://www.google.com/');
64
+ $this->results = $this->_validator->validate(Mage::helper('core/url')->getCurrentUrl());
65
+
66
+ return parent::_beforeToHtml();
67
}
68
69
/**
70
*
71
* @return Services_W3C_HTMLValidator_Response $this->results
72
*/
73
+ public function getValidatorResults()
74
+ {
75
+ return $this->results;
76
}
77
+ }
app/code/community/Diglin/UIOptimization/Helper/Data.php CHANGED
@@ -8,110 +8,104 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
- /**
27
- * Only for String Translation
28
- */
29
- class Diglin_UIOptimization_Helper_Data extends Mage_Core_Helper_Abstract {
30
- /**
31
- * Retreive some basic information depending on the type of file: original path, destination path, type, name, static
32
- *
33
- * @param string $name
34
- * @param string $type
35
- * @param bool $static
36
- * @return array $info
37
- */
38
- public function getCompressedInfo($name, $type = 'css', $static = false){
39
-
40
- $info = array();
41
- $designPackage = Mage::getDesign();
42
-
43
- $orgname = $name;
44
- if(!$static){
45
- $info['orgskin_path'] = $designPackage->getFilename ( $orgname, array ('_type' => 'skin' ) );
46
- }else{
47
- $info['orgskin_path'] = Mage::getBaseDir() . DS . 'js'. DS . $name;
48
- }
49
-
50
- $orgpath = explode ( DS, $info['orgskin_path'] );
51
- if (count ( $orgpath ) > 1 && !$static) {
52
- // Get the theme of the original file
53
- $info['theme_name'] = $orgpath [count ( $orgpath ) - (count ( explode ( '/', $orgname ) ) + 1)];
54
- }
55
- $suffixFilename = (Mage::app()->getStore()->isCurrentlySecure())?'-ssl':'';
56
- $name = substr ( $name, 0, strpos($name, '.' . $type) );
57
- $name = $name . $suffixFilename .'_cp.'.$type;
58
-
59
- $file_path = explode('/', $name);
60
- if(count($file_path) > 1){
61
- $name = array_pop($file_path);
62
- $info['file_path'] = implode(DS, $file_path);
63
- }else{
64
- $info['file_path'] = '';
65
- }
66
67
- $info['original_name'] = $orgname;
68
- $info['new_name'] = $name;
69
- $info['type'] = $type;
70
- $info['static'] = $static;
71
-
72
- $targetDir = $this->initMergerDir ( $type );
73
- if (! $targetDir) {
74
- $info['success'] = false;
75
- return $info;
76
- }
77
-
78
- if(!$static){
79
- $info['targetPath'] = $targetDir . DS . 'skin' . DS . $info['theme_name'] . DS . $info['file_path'];
80
- }else{
81
- $info['targetPath'] = $targetDir . DS . $info['file_path'];
82
- }
83
- $info['targetPathFile'] = $info['targetPath'] . DS . $name;
84
-
85
- if(!file_exists($info['targetPath'])){
86
- $ioFile = new Diglin_Io_File();
87
- $ioFile->mkdir($info['targetPath'], 0755, true);
88
- }
89
-
90
- return $info;
91
- }
92
-
93
- /**
94
- * Provide the path URL of the filesystem for js or css files compressed or not
95
- *
96
- * @param array $info
97
- * @param string|array $mergeCallback
98
- * @return string
99
- */
100
- public function getResultPath($info, $mergeCallback ){
101
- $designPackage = Mage::getDesign();
102
-
103
- // Skin items
104
- if(!$info['result'] && !$info['static']){ // Default Folder
105
- return ($mergeCallback ? $designPackage->getFilename($info['original_name'], array('_type' => 'skin')) : $designPackage->getSkinUrl($info['original_name'], array()));
106
- }else if(!$info['static']){
107
- return ($mergeCallback ? $info['targetPathFile'] : Mage::getBaseUrl ( 'media' ) . $info['type'] . DS . 'skin' . DS . $info['theme_name'] . DS . $info['file_path'] . DS . $info['new_name']);
108
- // Static Items
109
- }else if(!$info['result'] && $info['static']){ // Default folder
110
- return $mergeCallback ? Mage::getBaseDir() . DS . 'js' . DS . $info['original_name'] : Mage::getBaseUrl('js') . $info['original_name'];
111
- }else{
112
- return $mergeCallback ? $info['targetPathFile'] : Mage::getBaseUrl ( 'media' ) . $info['type'] . DS . $info['file_path'] . DS . $info['new_name'];
113
- }
114
- }
115
/**
116
* Make sure merger dir exists and writeable
117
* Also can clean it up
@@ -120,7 +114,7 @@ class Diglin_UIOptimization_Helper_Data extends Mage_Core_Helper_Abstract {
120
* @param bool $cleanup
121
* @return bool|string
122
*/
123
- public function initMergerDir($dirRelativeName, $cleanup = false)
124
{
125
$mediaDir = Mage::getBaseDir('media');
126
try {
@@ -128,7 +122,7 @@ class Diglin_UIOptimization_Helper_Data extends Mage_Core_Helper_Abstract {
128
if ($cleanup) {
129
Diglin_Io_File::rmdirRecursive($dir);
130
}
131
- if (!is_dir($dir)) {
132
mkdir($dir);
133
}
134
return is_writeable($dir) ? $dir : false;
@@ -137,4 +131,19 @@ class Diglin_UIOptimization_Helper_Data extends Mage_Core_Helper_Abstract {
137
}
138
return false;
139
}
140
}
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
+ class Diglin_UIOptimization_Helper_Data extends Mage_Core_Helper_Abstract
19
+ {
20
+ /**
21
+ * Retreive some basic information depending on the type of file: original path, destination path, type, name, static
22
+ *
23
+ * @param string $name
24
+ * @param string $type
25
+ * @param bool $static
26
+ * @return array $info
27
+ */
28
+ public function getCompressedInfo($name, $type = 'css', $static = false)
29
+ {
30
+ $info = array();
31
+ $designPackage = Mage::getDesign();
32
+
33
+ $orgname = $name;
34
+ if(!$static){
35
+ $info['orgskin_path'] = $designPackage->getFilename ( $orgname, array ('_type' => 'skin' ) );
36
+ }else{
37
+ $info['orgskin_path'] = Mage::getBaseDir() . DS . 'js'. DS . $name;
38
+ }
39
+
40
+ $orgpath = explode ( DS, $info['orgskin_path'] );
41
+ if (count ( $orgpath ) > 1 && !$static) {
42
+ // Get the theme of the original file
43
+ $info['theme_name'] = $orgpath [count ( $orgpath ) - (count ( explode ( '/', $orgname ) ) + 1)];
44
+ }
45
+ $suffixFilename = (Mage::app()->getStore()->isCurrentlySecure())?'-ssl':'';
46
+ $name = substr ( $name, 0, strpos($name, '.' . $type) );
47
+ $name = $name . $suffixFilename .'_cp.'.$type;
48
+
49
+ $file_path = explode('/', $name);
50
+ if(count($file_path) > 1){
51
+ $name = array_pop($file_path);
52
+ $info['file_path'] = implode(DS, $file_path);
53
+ }else{
54
+ $info['file_path'] = '';
55
+ }
56
57
+ $info['original_name'] = $orgname;
58
+ $info['new_name'] = $name;
59
+ $info['type'] = $type;
60
+ $info['static'] = $static;
61
+
62
+ $targetDir = $this->initMergerDir ( $type );
63
+ if (! $targetDir) {
64
+ $info['success'] = false;
65
+ return $info;
66
+ }
67
+
68
+ if(!$static){
69
+ $info['targetPath'] = $targetDir . DS . 'skin' . DS . $info['theme_name'] . DS . $info['file_path'];
70
+ }else{
71
+ $info['targetPath'] = $targetDir . DS . $info['file_path'];
72
+ }
73
+ $info['targetPathFile'] = $info['targetPath'] . DS . $name;
74
+
75
+ if(!file_exists($info['targetPath'])){
76
+ $ioFile = new Diglin_Io_File();
77
+ $ioFile->mkdir($info['targetPath'], 0755, true);
78
+ }
79
+
80
+ return $info;
81
+ }
82
+ /**
83
+ * Provide the path URL of the filesystem for js or css files compressed or not
84
+ *
85
+ * @param array $info
86
+ * @param string|array $mergeCallback
87
+ * @return string
88
+ */
89
+ public function getResultPath ($info, $mergeCallback)
90
+ {
91
+ $designPackage = Mage::getDesign();
92
+ // Skin items
93
+ if (! $info['result'] && ! $info['static']) { // Default Folder
94
+ return ($mergeCallback ? $designPackage->getFilename($info['original_name'], array('_type' => 'skin')) : $designPackage->getSkinUrl($info['original_name'], array()));
95
+ } else {
96
+ if (! $info['static']) {
97
+ return ($mergeCallback ? $info['targetPathFile'] : Mage::getBaseUrl('media') . $info['type'] . DS . 'skin' . DS . $info['theme_name'] . DS . $info['file_path'] . DS . $info['new_name']);
98
+ // Static Items
99
+ } else {
100
+ if (! $info['result'] && $info['static']) { // Default folder
101
+ return $mergeCallback ? Mage::getBaseDir() . DS . 'js' . DS . $info['original_name'] : Mage::getBaseUrl('js') . $info['original_name'];
102
+ } else {
103
+ return $mergeCallback ? $info['targetPathFile'] : Mage::getBaseUrl('media') . $info['type'] . DS . $info['file_path'] . DS . $info['new_name'];
104
+ }
105
+ }
106
+ }
107
+ }
108
+
109
/**
110
* Make sure merger dir exists and writeable
111
* Also can clean it up
114
* @param bool $cleanup
115
* @return bool|string
116
*/
117
+ public function initMergerDir ($dirRelativeName, $cleanup = false)
118
{
119
$mediaDir = Mage::getBaseDir('media');
120
try {
122
if ($cleanup) {
123
Diglin_Io_File::rmdirRecursive($dir);
124
}
125
+ if (! is_dir($dir)) {
126
mkdir($dir);
127
}
128
return is_writeable($dir) ? $dir : false;
131
}
132
return false;
133
}
134
+
135
+ /**
136
+ * Add trailing slash if necessary
137
+ *
138
+ * @param string $url
139
+ */
140
+ public function getTrailingSlash ($url)
141
+ {
142
+ if (Mage::getStoreConfig('web/seo/trailingslash')) {
143
+ if (! preg_match('/\\.(rss|html|htm|xml|php?)#x2F;', strtolower($url)) && substr($url, - 1) != '/') {
144
+ $url .= '/';
145
+ }
146
+ }
147
+ return $url;
148
+ }
149
}
app/code/community/Diglin/UIOptimization/Model/Config/Source/Caseproperties.php CHANGED
@@ -8,24 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
class Diglin_UIOptimization_Model_Config_Source_Caseproperties
27
{
28
-
29
/**
30
* Options getter
31
*
@@ -34,10 +25,9 @@ class Diglin_UIOptimization_Model_Config_Source_Caseproperties
34
public function toOptionArray()
35
{
36
return array(
37
- array('value' => '0', 'label' => 'None'),
38
- array('value' => '1', 'label' => 'Lowercase'),
39
- array('value' => '2', 'label' => 'Uppercase'),
40
);
41
}
42
-
43
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
class Diglin_UIOptimization_Model_Config_Source_Caseproperties
19
{
20
/**
21
* Options getter
22
*
25
public function toOptionArray()
26
{
27
return array(
28
+ array('value' => '0', 'label' => 'None'),
29
+ array('value' => '1', 'label' => 'Lowercase'),
30
+ array('value' => '2', 'label' => 'Uppercase'),
31
);
32
}
33
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Charset.php CHANGED
@@ -8,23 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
- class Diglin_UIOptimization_Model_Config_Source_Charset {
27
-
28
/**
29
* Options getter
30
*
@@ -33,7 +25,7 @@ class Diglin_UIOptimization_Model_Config_Source_Charset {
33
public function toOptionArray()
34
{
35
return array(
36
- array('value' => "", 'label' => "(detect automatically)"),
37
array('value' => "utf-8", 'label' => "utf-8 (Unicode, worldwide)"),
38
array('value' => "utf-16", 'label' => "utf-16 (Unicode, worldwide)"),
39
array('value' => "iso-8859-1", 'label' => "iso-8859-1 (Western Europe)"),
@@ -77,5 +69,4 @@ class Diglin_UIOptimization_Model_Config_Source_Charset {
77
array('value' => "windows-1257", 'label' => "windows-1257 (Baltic Rim)"),
78
);
79
}
80
-
81
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
+ class Diglin_UIOptimization_Model_Config_Source_Charset
19
+ {
20
/**
21
* Options getter
22
*
25
public function toOptionArray()
26
{
27
return array(
28
+ array('value' => "", 'label' => "(detect automatically)"),
29
array('value' => "utf-8", 'label' => "utf-8 (Unicode, worldwide)"),
30
array('value' => "utf-16", 'label' => "utf-16 (Unicode, worldwide)"),
31
array('value' => "iso-8859-1", 'label' => "iso-8859-1 (Western Europe)"),
69
array('value' => "windows-1257", 'label' => "windows-1257 (Baltic Rim)"),
70
);
71
}
72
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Csslevel.php CHANGED
@@ -8,24 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
class Diglin_UIOptimization_Model_Config_Source_Csslevel
27
{
28
-
29
/**
30
* Options getter
31
*
@@ -34,10 +25,9 @@ class Diglin_UIOptimization_Model_Config_Source_Csslevel
34
public function toOptionArray()
35
{
36
return array(
37
- array('value' => 'CSS1.0', 'label' => 'CSS level 1'),
38
- array('value' => 'CSS2.0', 'label' => 'CSS level 2'),
39
- array('value' => 'CSS2.1', 'label' => 'CSS level 2.1'),
40
);
41
}
42
-
43
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
class Diglin_UIOptimization_Model_Config_Source_Csslevel
19
{
20
/**
21
* Options getter
22
*
25
public function toOptionArray()
26
{
27
return array(
28
+ array('value' => 'CSS1.0', 'label' => 'CSS level 1'),
29
+ array('value' => 'CSS2.0', 'label' => 'CSS level 2'),
30
+ array('value' => 'CSS2.1', 'label' => 'CSS level 2.1'),
31
);
32
}
33
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Csstypeminify.php CHANGED
@@ -8,23 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
- class Diglin_UIOptimization_Model_Config_Source_Csstypeminify{
27
-
28
/**
29
* Options getter
30
*
@@ -33,10 +25,9 @@ class Diglin_UIOptimization_Model_Config_Source_Csstypeminify{
33
public function toOptionArray()
34
{
35
return array(
36
- array('value' => 'csstidy', 'label' => 'CSS Tidy (Recommended)'),
37
- array('value' => 'yuicompressor', 'label' => 'YUICompressor'),
38
- array('value' => 'googleminify', 'label' => 'Google Minify'),
39
);
40
}
41
-
42
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
+ class Diglin_UIOptimization_Model_Config_Source_Csstypeminify
19
+ {
20
/**
21
* Options getter
22
*
25
public function toOptionArray()
26
{
27
return array(
28
+ array('value' => 'csstidy', 'label' => 'CSS Tidy (Recommended)'),
29
+ array('value' => 'yuicompressor', 'label' => 'YUICompressor (if Java installed)'),
30
+ array('value' => 'googleminify', 'label' => 'Google Minify'),
31
);
32
}
33
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Doctype.php CHANGED
@@ -8,24 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
class Diglin_UIOptimization_Model_Config_Source_Doctype
27
{
28
-
29
/**
30
* Options getter
31
*
@@ -34,33 +25,32 @@ class Diglin_UIOptimization_Model_Config_Source_Doctype
34
public function toOptionArray()
35
{
36
return array(
37
- array('value' => "Inline", 'label' => "(detect automatically)"),
38
- array('value' => "HTML5", 'label' => "HTML5 (experimental)"),
39
- array('value' => "XHTML 1.0 Strict", 'label' => "XHTML 1.0 Strict"),
40
- array('value' => "XHTML 1.0 Transitional", 'label' => "XHTML 1.0 Transitional"),
41
- array('value' => "XHTML 1.0 Frameset", 'label' => "XHTML 1.0 Frameset"),
42
- array('value' => "HTML 4.01 Strict", 'label' => "HTML 4.01 Strict"),
43
- array('value' => "HTML 4.01 Transitional", 'label' => "HTML 4.01 Transitional"),
44
- array('value' => "HTML 4.01 Frameset", 'label' => "HTML 4.01 Frameset"),
45
- array('value' => "HTML 3.2", 'label' => "HTML 3.2"),
46
- array('value' => "HTML 2.0", 'label' => "HTML 2.0"),
47
- array('value' => "ISO/IEC 15445:2000 (&quot;ISO HTML&quot;)", 'label' => "ISO/IEC 15445:2000 (\"ISO HTML\")"),
48
- array('value' => "XHTML 1.1", 'label' => "XHTML 1.1"),
49
- array('value' => "XHTML + RDFa", 'label' => "XHTML + RDFa"),
50
- array('value' => "XHTML Basic 1.0", 'label' => "XHTML Basic 1.0"),
51
- array('value' => "XHTML Basic 1.1", 'label' => "XHTML Basic 1.1"),
52
- array('value' => "XHTML Mobile Profile 1.2", 'label' => "XHTML Mobile Profile 1.2"),
53
- array('value' => "XHTML-Print 1.0", 'label' => "XHTML-Print 1.0"),
54
- array('value' => "XHTML 1.1 plus MathML 2.0", 'label' => "XHTML 1.1 plus MathML 2.0"),
55
- array('value' => "XHTML 1.1 plus MathML 2.0 plus SVG 1.1", 'label' => "XHTML 1.1 plus MathML 2.0 plus SVG 1.1"),
56
- array('value' => "MathML 2.0", 'label' => "MathML 2.0"),
57
- array('value' => "SVG 1.0", 'label' => "SVG 1.0"),
58
- array('value' => "SVG 1.1", 'label' => "SVG 1.1"),
59
- array('value' => "SVG 1.1 Tiny", 'label' => "SVG 1.1 Tiny"),
60
- array('value' => "SVG 1.1 Basic", 'label' => "SVG 1.1 Basic"),
61
- array('value' => "SMIL 1.0", 'label' => "SMIL 1.0"),
62
- array('value' => "SMIL 2.0", 'label' => "SMIL 2.0"),
63
);
64
}
65
-
66
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
class Diglin_UIOptimization_Model_Config_Source_Doctype
19
{
20
/**
21
* Options getter
22
*
25
public function toOptionArray()
26
{
27
return array(
28
+ array('value' => "Inline", 'label' => "(detect automatically)"),
29
+ array('value' => "HTML5", 'label' => "HTML5 (experimental)"),
30
+ array('value' => "XHTML 1.0 Strict", 'label' => "XHTML 1.0 Strict"),
31
+ array('value' => "XHTML 1.0 Transitional", 'label' => "XHTML 1.0 Transitional"),
32
+ array('value' => "XHTML 1.0 Frameset", 'label' => "XHTML 1.0 Frameset"),
33
+ array('value' => "HTML 4.01 Strict", 'label' => "HTML 4.01 Strict"),
34
+ array('value' => "HTML 4.01 Transitional", 'label' => "HTML 4.01 Transitional"),
35
+ array('value' => "HTML 4.01 Frameset", 'label' => "HTML 4.01 Frameset"),
36
+ array('value' => "HTML 3.2", 'label' => "HTML 3.2"),
37
+ array('value' => "HTML 2.0", 'label' => "HTML 2.0"),
38
+ array('value' => "ISO/IEC 15445:2000 (&quot;ISO HTML&quot;)", 'label' => "ISO/IEC 15445:2000 (\"ISO HTML\")"),
39
+ array('value' => "XHTML 1.1", 'label' => "XHTML 1.1"),
40
+ array('value' => "XHTML + RDFa", 'label' => "XHTML + RDFa"),
41
+ array('value' => "XHTML Basic 1.0", 'label' => "XHTML Basic 1.0"),
42
+ array('value' => "XHTML Basic 1.1", 'label' => "XHTML Basic 1.1"),
43
+ array('value' => "XHTML Mobile Profile 1.2", 'label' => "XHTML Mobile Profile 1.2"),
44
+ array('value' => "XHTML-Print 1.0", 'label' => "XHTML-Print 1.0"),
45
+ array('value' => "XHTML 1.1 plus MathML 2.0", 'label' => "XHTML 1.1 plus MathML 2.0"),
46
+ array('value' => "XHTML 1.1 plus MathML 2.0 plus SVG 1.1", 'label' => "XHTML 1.1 plus MathML 2.0 plus SVG 1.1"),
47
+ array('value' => "MathML 2.0", 'label' => "MathML 2.0"),
48
+ array('value' => "SVG 1.0", 'label' => "SVG 1.0"),
49
+ array('value' => "SVG 1.1", 'label' => "SVG 1.1"),
50
+ array('value' => "SVG 1.1 Tiny", 'label' => "SVG 1.1 Tiny"),
51
+ array('value' => "SVG 1.1 Basic", 'label' => "SVG 1.1 Basic"),
52
+ array('value' => "SMIL 1.0", 'label' => "SMIL 1.0"),
53
+ array('value' => "SMIL 2.0", 'label' => "SMIL 2.0"),
54
);
55
}
56
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Jstypeminify.php CHANGED
@@ -8,23 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
- class Diglin_UIOptimization_Model_Config_Source_Jstypeminify{
27
-
28
/**
29
* Options getter
30
*
@@ -33,10 +25,9 @@ class Diglin_UIOptimization_Model_Config_Source_Jstypeminify{
33
public function toOptionArray()
34
{
35
return array(
36
- array('value' => 'jsmin', 'label' => 'JSMin (Good ratio)'),
37
- array('value' => 'yuicompressor', 'label' => 'YUICompressor (recommended if java available)'),
38
- array('value' => 'packer', 'label' => 'Packer from Dean Edwards (best compression / less Magento compatible)'),
39
);
40
}
41
-
42
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
+ class Diglin_UIOptimization_Model_Config_Source_Jstypeminify
19
+ {
20
/**
21
* Options getter
22
*
25
public function toOptionArray()
26
{
27
return array(
28
+ array('value' => 'jsmin', 'label' => 'JSMin (Good ratio)'),
29
+ array('value' => 'yuicompressor', 'label' => 'YUICompressor (recommended if java available)'),
30
+ //array('value' => 'packer', 'label' => 'Packer from Dean Edwards (best compression / less Magento compatible)'),
31
);
32
}
33
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Language.php CHANGED
@@ -8,24 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
class Diglin_UIOptimization_Model_Config_Source_Language
27
{
28
-
29
/**
30
* Options getter
31
*
@@ -35,15 +26,14 @@ class Diglin_UIOptimization_Model_Config_Source_Language
35
{
36
return array(
37
array('value' => 'en','label'=>Mage::helper('uioptimization')->__("English")),
38
- array('value' => 'de','label'=>Mage::helper('uioptimization')->__("German")),
39
- array('value' => 'es','label'=>Mage::helper('uioptimization')->__("Spanish; Castilian")),
40
- array('value' => 'fr','label'=>Mage::helper('uioptimization')->__("French")),
41
- array('value' => 'it','label'=>Mage::helper('uioptimization')->__("Italian")),
42
- array('value' => 'ja','label'=>Mage::helper('uioptimization')->__("Japanese")),
43
- array('value' => 'ko','label'=>Mage::helper('uioptimization')->__("Korean")),
44
- array('value' => 'nl','label'=>Mage::helper('uioptimization')->__("Dutch; Flemish")),
45
- array('value' => 'zh-cn','label'=>Mage::helper('uioptimization')->__("Chinese (China)")),
46
);
47
}
48
-
49
}
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
class Diglin_UIOptimization_Model_Config_Source_Language
19
{
20
/**
21
* Options getter
22
*
26
{
27
return array(
28
array('value' => 'en','label'=>Mage::helper('uioptimization')->__("English")),
29
+ array('value' => 'de','label'=>Mage::helper('uioptimization')->__("German")),
30
+ array('value' => 'es','label'=>Mage::helper('uioptimization')->__("Spanish; Castilian")),
31
+ array('value' => 'fr','label'=>Mage::helper('uioptimization')->__("French")),
32
+ array('value' => 'it','label'=>Mage::helper('uioptimization')->__("Italian")),
33
+ array('value' => 'ja','label'=>Mage::helper('uioptimization')->__("Japanese")),
34
+ array('value' => 'ko','label'=>Mage::helper('uioptimization')->__("Korean")),
35
+ array('value' => 'nl','label'=>Mage::helper('uioptimization')->__("Dutch; Flemish")),
36
+ array('value' => 'zh-cn','label'=>Mage::helper('uioptimization')->__("Chinese (China)")),
37
);
38
}
39
}
app/code/community/Diglin/UIOptimization/Model/Config/Source/Mergeselectors.php CHANGED
@@ -8,24 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
class Diglin_UIOptimization_Model_Config_Source_Mergeselectors
27
{
28
-
29
/**
30
* Options getter
31
*
@@ -34,10 +25,9 @@ class Diglin_UIOptimization_Model_Config_Source_Mergeselectors
34
public function toOptionArray()
35
{
36
return array(
37
- array('value' => '0', 'label' => 'Do not change anything'),
38
- array('value' => '1', 'label' => 'Only seperate selectors (split at ,)'),
39
- array('value' => '2', 'label' => 'Merge selectors with the same properties (fast)'),
40
);
41
}
42
-
43
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
class Diglin_UIOptimization_Model_Config_Source_Mergeselectors
19
{
20
/**
21
* Options getter
22
*
25
public function toOptionArray()
26
{
27
return array(
28
+ array('value' => '0', 'label' => 'Do not change anything'),
29
+ array('value' => '1', 'label' => 'Only seperate selectors (split at ,)'),
30
+ array('value' => '2', 'label' => 'Merge selectors with the same properties (fast)'),
31
);
32
}
33
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Optishorthand.php CHANGED
@@ -8,24 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
class Diglin_UIOptimization_Model_Config_Source_Optishorthand
27
{
28
-
29
/**
30
* Options getter
31
*
@@ -34,10 +25,9 @@ class Diglin_UIOptimization_Model_Config_Source_Optishorthand
34
public function toOptionArray()
35
{
36
return array(
37
- array('value' => '0', 'label' => 'None'),
38
- array('value' => '1', 'label' => 'Safe Optimize'),
39
- array('value' => '2', 'label' => 'All optimize'),
40
);
41
}
42
-
43
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
class Diglin_UIOptimization_Model_Config_Source_Optishorthand
19
{
20
/**
21
* Options getter
22
*
25
public function toOptionArray()
26
{
27
return array(
28
+ array('value' => '0', 'label' => 'None'),
29
+ array('value' => '1', 'label' => 'Safe Optimize'),
30
+ array('value' => '2', 'label' => 'All optimize'),
31
);
32
}
33
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Profile.php CHANGED
@@ -8,24 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
class Diglin_UIOptimization_Model_Config_Source_Profile
27
{
28
-
29
/**
30
* Options getter
31
*
@@ -34,18 +25,17 @@ class Diglin_UIOptimization_Model_Config_Source_Profile
34
public function toOptionArray()
35
{
36
return array(
37
- array('value' => 'none', 'label' => 'none profile'),
38
- array('value' => 'css1', 'label' => 'CSS level 1'),
39
- array('value' => 'css2', 'label' => 'CSS level 2'),
40
- array('value' => 'css21', 'label' => 'CSS level 2.1'),
41
- array('value' => 'css3', 'label' => 'CSS level 3'),
42
- array('value' => 'svg', 'label' => 'SVG'),
43
- array('value' => 'svgbasic', 'label' => 'SVG Basic'),
44
- array('value' => 'svgtiny', 'label' => 'SVG Tiny'),
45
- array('value' => 'mobile', 'label' => 'Mobile'),
46
- array('value' => 'atsc-tv', 'label' => 'ATSC TV'),
47
- array('value' => 'tv', 'label' => 'TV'),
48
);
49
}
50
-
51
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
class Diglin_UIOptimization_Model_Config_Source_Profile
19
{
20
/**
21
* Options getter
22
*
25
public function toOptionArray()
26
{
27
return array(
28
+ array('value' => 'none', 'label' => 'none profile'),
29
+ array('value' => 'css1', 'label' => 'CSS level 1'),
30
+ array('value' => 'css2', 'label' => 'CSS level 2'),
31
+ array('value' => 'css21', 'label' => 'CSS level 2.1'),
32
+ array('value' => 'css3', 'label' => 'CSS level 3'),
33
+ array('value' => 'svg', 'label' => 'SVG'),
34
+ array('value' => 'svgbasic', 'label' => 'SVG Basic'),
35
+ array('value' => 'svgtiny', 'label' => 'SVG Tiny'),
36
+ array('value' => 'mobile', 'label' => 'Mobile'),
37
+ array('value' => 'atsc-tv', 'label' => 'ATSC TV'),
38
+ array('value' => 'tv', 'label' => 'TV'),
39
);
40
}
41
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Template.php CHANGED
@@ -8,24 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
class Diglin_UIOptimization_Model_Config_Source_Template
27
{
28
-
29
/**
30
* Options getter
31
*
@@ -34,12 +25,11 @@ class Diglin_UIOptimization_Model_Config_Source_Template
34
public function toOptionArray()
35
{
36
return array(
37
- array('value' => 'default', 'label' => 'Standard (balance between readability and size)'),
38
- array('value' => 'high_compression', 'label' => 'High (moderate readability, smaller size)'),
39
- array('value' => 'highest_compression', 'label' => 'Highest (no readability, smallest size)'),
40
- array('value' => 'low_compression', 'label' => 'Low (higher readability)'),
41
- array('value' => 'custom', 'label' => 'Custom (feel the textarea below)'),
42
);
43
}
44
-
45
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
class Diglin_UIOptimization_Model_Config_Source_Template
19
{
20
/**
21
* Options getter
22
*
25
public function toOptionArray()
26
{
27
return array(
28
+ array('value' => 'default', 'label' => 'Standard (balance between readability and size)'),
29
+ array('value' => 'high_compression', 'label' => 'High (moderate readability, smaller size)'),
30
+ array('value' => 'highest_compression', 'label' => 'Highest (no readability, smallest size)'),
31
+ array('value' => 'low_compression', 'label' => 'Low (higher readability)'),
32
+ array('value' => 'custom', 'label' => 'Custom (feel the textarea below)'),
33
);
34
}
35
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Usermedium.php CHANGED
@@ -8,24 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
class Diglin_UIOptimization_Model_Config_Source_Usermedium
27
{
28
-
29
/**
30
* Options getter
31
*
@@ -34,18 +25,17 @@ class Diglin_UIOptimization_Model_Config_Source_Usermedium
34
public function toOptionArray()
35
{
36
return array(
37
- array('value' => 'all', 'label' => 'all'),
38
- array('value' => 'aural', 'label' => 'aural'),
39
- array('value' => 'braille', 'label' => 'braille'),
40
- array('value' => 'embossed', 'label' => 'embossed'),
41
- array('value' => 'handheld', 'label' => 'handheld'),
42
- array('value' => 'print', 'label' => 'print'),
43
- array('value' => 'projection', 'label' => 'projection'),
44
- array('value' => 'screen', 'label' => 'screen'),
45
- array('value' => 'tty', 'label' => 'tty'),
46
- array('value' => 'tv', 'label' => 'tv'),
47
- array('value' => 'presentation', 'label' => 'presentation'),
48
);
49
}
50
-
51
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
class Diglin_UIOptimization_Model_Config_Source_Usermedium
19
{
20
/**
21
* Options getter
22
*
25
public function toOptionArray()
26
{
27
return array(
28
+ array('value' => 'all', 'label' => 'all'),
29
+ array('value' => 'aural', 'label' => 'aural'),
30
+ array('value' => 'braille', 'label' => 'braille'),
31
+ array('value' => 'embossed', 'label' => 'embossed'),
32
+ array('value' => 'handheld', 'label' => 'handheld'),
33
+ array('value' => 'print', 'label' => 'print'),
34
+ array('value' => 'projection', 'label' => 'projection'),
35
+ array('value' => 'screen', 'label' => 'screen'),
36
+ array('value' => 'tty', 'label' => 'tty'),
37
+ array('value' => 'tv', 'label' => 'tv'),
38
+ array('value' => 'presentation', 'label' => 'presentation'),
39
);
40
}
41
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Warning.php CHANGED
@@ -8,24 +8,15 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
class Diglin_UIOptimization_Model_Config_Source_Warning
27
{
28
-
29
/**
30
* Options getter
31
*
@@ -34,11 +25,10 @@ class Diglin_UIOptimization_Model_Config_Source_Warning
34
public function toOptionArray()
35
{
36
return array(
37
- array('value' => 'no', 'label' => 'None messages'),
38
- array('value' => '0', 'label' => 'Most important warning messages'),
39
- array('value' => '1', 'label' => 'Normal report'),
40
- array('value' => '2', 'label' => 'All warning messages'),
41
);
42
}
43
-
44
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
class Diglin_UIOptimization_Model_Config_Source_Warning
19
{
20
/**
21
* Options getter
22
*
25
public function toOptionArray()
26
{
27
return array(
28
+ array('value' => 'no', 'label' => 'None messages'),
29
+ array('value' => '0', 'label' => 'Most important warning messages'),
30
+ array('value' => '1', 'label' => 'Normal report'),
31
+ array('value' => '2', 'label' => 'All warning messages'),
32
);
33
}
34
+ }
app/code/community/Diglin/UIOptimization/Model/Observer.php CHANGED
@@ -8,33 +8,25 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
- class Diglin_UIOptimization_Model_Observer {
27
-
28
/**
29
* Delete content of media/js and media/css folders to refresh with updated compressed/minified js/css content
30
* If disabled, the updates are done each time an original file is updated. Can be resource overload on live website.
31
*
32
* @param Mage_Core_Model_Observer $observer
33
*/
34
- public function regenerateMediaFiles($observer){
35
-
36
- if( Mage::getStoreConfigFlag('uioptimization/general/cronupdate') && (Mage::getStoreConfigFlag('uioptimization/csscompression/enabled') || Mage::getStoreConfigFlag('uioptimization/jscompression/enabled'))){
37
-
38
// Clean up media/css and media/js folders and recreate the folders if necessary
39
try {
40
Mage::getModel('core/design_package')->cleanMergedJsCss();
@@ -43,31 +35,23 @@ class Diglin_UIOptimization_Model_Observer {
43
Mage::logException($e);
44
return;
45
}
46
-
47
$stores = Mage::app()->getStores();
48
-
49
- foreach($stores as $id => $v){
50
$url = Zend_Uri_Http::fromString(Mage::app()->getStore($id)->getBaseUrl());
51
-
52
// Recreate the js and css compressed file by using the normal process
53
- try{
54
$curl = new Zend_Http_Client_Adapter_Curl();
55
-
56
$curl->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
57
$curl->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
58
-
59
$curl->connect($url->getHost(), $url->getPort(), Mage_Core_Model_Store::isCurrentlySecure());
60
$curl->write(Zend_Http_Client::GET, $url);
61
-
62
$curl->close();
63
-
64
Mage::log('[Diglin_UIOptimization_Model_Observer] Update media js/css content for the different stores', ZEND_LOG::DEBUG);
65
-
66
- }catch(Exception $e){
67
Mage::logException($e);
68
return;
69
}
70
}
71
- }
72
}
73
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
+ class Diglin_UIOptimization_Model_Observer
19
+ {
20
/**
21
* Delete content of media/js and media/css folders to refresh with updated compressed/minified js/css content
22
* If disabled, the updates are done each time an original file is updated. Can be resource overload on live website.
23
*
24
* @param Mage_Core_Model_Observer $observer
25
*/
26
+ public function regenerateMediaFiles ($observer)
27
+ {
28
+ if (Mage::getStoreConfigFlag('uioptimization/general/cronupdate') &&
29
+ (Mage::getStoreConfigFlag('uioptimization/csscompression/enabled') || Mage::getStoreConfigFlag('uioptimization/jscompression/enabled'))) {
30
// Clean up media/css and media/js folders and recreate the folders if necessary
31
try {
32
Mage::getModel('core/design_package')->cleanMergedJsCss();
35
Mage::logException($e);
36
return;
37
}
38
$stores = Mage::app()->getStores();
39
+ foreach ($stores as $id => $v) {
40
$url = Zend_Uri_Http::fromString(Mage::app()->getStore($id)->getBaseUrl());
41
// Recreate the js and css compressed file by using the normal process
42
+ try {
43
$curl = new Zend_Http_Client_Adapter_Curl();
44
$curl->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
45
$curl->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
46
$curl->connect($url->getHost(), $url->getPort(), Mage_Core_Model_Store::isCurrentlySecure());
47
$curl->write(Zend_Http_Client::GET, $url);
48
$curl->close();
49
Mage::log('[Diglin_UIOptimization_Model_Observer] Update media js/css content for the different stores', ZEND_LOG::DEBUG);
50
+ } catch (Exception $e) {
51
Mage::logException($e);
52
return;
53
}
54
}
55
+ }
56
}
57
+ }
app/code/community/Diglin/UIOptimization/Model/Overwrite/Design/Package.php CHANGED
@@ -8,40 +8,32 @@
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
*
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
*
21
* @category Diglin
22
* @package Diglin_UIOptimization
23
- * @copyright Copyright (c) 2011 Diglin (http://www.diglin.com)
24
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
*/
26
- class Diglin_UIOptimization_Model_Overwrite_Design_Package extends Mage_Core_Model_Design_Package{
27
-
28
/**
29
* Merge specified css files and return URL to the merged file on success
30
*
31
* @param $files
32
* @return string
33
*/
34
- public function getMergedCssUrl($files)
35
- {
36
- $suffixFilename = (Mage::app()->getStore()->isCurrentlySecure())?'-ssl':'';
37
- $targetFilename = md5(implode(',', $files)) . $suffixFilename .'.css';
38
$targetDir = $this->_initMergerDir('css');
39
- if (!$targetDir) {
40
return '';
41
}
42
if (Mage::helper('core')->mergeFiles($files, $targetDir . DS . $targetFilename, false, array($this, 'beforeMergeCss'), 'css')) {
43
return Mage::getBaseUrl('media') . 'css/' . $targetFilename;
44
}
45
return '';
46
- }
47
- }
8
* that is bundled with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://opensource.org/licenses/osl-3.0.php
11
*
12
*
13
* @category Diglin
14
* @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
*/
18
+ class Diglin_UIOptimization_Model_Overwrite_Design_Package extends Mage_Core_Model_Design_Package
19
+ {
20
/**
21
* Merge specified css files and return URL to the merged file on success
22
*
23
* @param $files
24
* @return string
25
*/
26
+ public function getMergedCssUrl ($files)
27
+ {
28
+ $suffixFilename = (Mage::app()->getStore()->isCurrentlySecure()) ? '-ssl' : '';
29
+ $targetFilename = md5(implode(',', $files)) . $suffixFilename . '.css';
30
$targetDir = $this->_initMergerDir('css');
31
+ if (! $targetDir) {
32
return '';
33
}
34
if (Mage::helper('core')->mergeFiles($files, $targetDir . DS . $targetFilename, false, array($this, 'beforeMergeCss'), 'css')) {
35
return Mage::getBaseUrl('media') . 'css/' . $targetFilename;
36
}
37
return '';
38
+ }
39
+ }
app/code/community/Diglin/UIOptimization/etc/adminhtml.xml CHANGED
@@ -1,25 +1,25 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<config>
3
- <acl>
4
- <resources>
5
- <all>
6
- <title>Allow Everything</title>
7
- </all>
8
- <admin>
9
- <children>
10
- <system>
11
- <children>
12
- <config>
13
- <children>
14
- <uioptimization translate="title">
15
- <title>UI Optimization Section</title>
16
- </uioptimization>
17
- </children>
18
- </config>
19
- </children>
20
- </system>
21
- </children>
22
- </admin>
23
- </resources>
24
- </acl>
25
</config>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <uioptimization translate="title">
15
+ <title>UI Optimization Section</title>
16
+ </uioptimization>
17
+ </children>
18
+ </config>
19
+ </children>
20
+ </system>
21
+ </children>
22
+ </admin>
23
+ </resources>
24
+ </acl>
25
</config>
app/code/community/Diglin/UIOptimization/etc/config.xml CHANGED
@@ -1,100 +1,103 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<config>
3
- <modules>
4
- <Diglin_UIOptimization>
5
- <version>1.0.0</version>
6
- </Diglin_UIOptimization>
7
- </modules>
8
9
- <default>
10
- <uioptimization>
11
- <general>
12
- <cron_schedule>0 2 * * 0</cron_schedule>
13
- </general>
14
- <w3chtmlvalidator>
15
- <enabled>0</enabled>
16
- <charset></charset>
17
- <fbc>1</fbc>
18
- <doctype></doctype>
19
- <fbd>1</fbd>
20
- <validator_uri>http://validator.w3.org/check</validator_uri>
21
- </w3chtmlvalidator>
22
- <w3ccssvalidator>
23
- <enabled>0</enabled>
24
- <lang>en</lang>
25
- <profile>css21</profile>
26
- <warning>1</warning>
27
- <usermedium>all</usermedium>
28
- </w3ccssvalidator>
29
- <csscompression>
30
- <enabled>0</enabled>
31
- <type>csstidy</type>
32
- <template>highest_compression</template>
33
- <remove_last_semicolon>1</remove_last_semicolon>
34
- <remove_bslash>1</remove_bslash>
35
- <compress_colors>1</compress_colors>
36
- <compress_font_weight>1</compress_font_weight>
37
- <lowercase_s>0</lowercase_s>
38
- <optimise_shorthands>1</optimise_shorthands>
39
- <case_properties>1</case_properties>
40
- <sort_properties>0</sort_properties>
41
- <sort_selectors>0</sort_selectors>
42
- <merge_selectors>2</merge_selectors>
43
- <discard_invalid_properties>0</discard_invalid_properties>
44
- <css_level>CSS2.1</css_level>
45
- <preserve_css>0</preserve_css>
46
- <timestamp>1</timestamp>
47
- </csscompression>
48
- <jscompression>
49
- <enabled>0</enabled>
50
- <type>jsmin</type>
51
- <preserve_semic>1</preserve_semic>
52
- </jscompression>
53
- <seo>
54
<enabled>0</enabled>
55
- <trailingslash>1</trailingslash>
56
</seo>
57
- </uioptimization>
58
- </default>
59
-
60
- <global>
61
- <blocks>
62
- <uioptimization>
63
- <class>Diglin_UIOptimization_Block</class>
64
- </uioptimization>
65
- <page>
66
- <rewrite>
67
- <html_head>Diglin_UIOptimization_Block_Optimize_Head</html_head>
68
- </rewrite>
69
- </page>
70
- </blocks>
71
- <models>
72
- <uioptimization>
73
- <class>Diglin_UIOptimization_Model</class>
74
- </uioptimization>
75
- <core>
76
- <rewrite>
77
- <design_package>Diglin_UIOptimization_Model_Overwrite_Design_Package</design_package>
78
- </rewrite>
79
- </core>
80
- </models>
81
- <helpers>
82
- <uioptimization>
83
- <class>Diglin_UIOptimization_Helper</class>
84
- </uioptimization>
85
- </helpers>
86
- </global>
87
88
- <frontend>
89
- <layout>
90
- <updates>
91
- <uioptimization module="Diglin_UIOptimization">
92
- <file>uioptimization.xml</file>
93
- </uioptimization>
94
- </updates>
95
- </layout>
96
- </frontend>
97
-
98
<crontab>
99
<jobs>
100
<uioptimization_media_regeneration_all><!-- Every Sunday at 2:00 AM -->
1
<?xml version="1.0" encoding="UTF-8"?>
2
<config>
3
+ <modules>
4
+ <Diglin_UIOptimization>
5
+ <version>1.3.0</version>
6
+ </Diglin_UIOptimization>
7
+ </modules>
8
9
+ <default>
10
+ <uioptimization>
11
+ <general>
12
+ <cron_schedule>0 2 * * 0</cron_schedule>
13
+ </general>
14
+ <w3chtmlvalidator>
15
<enabled>0</enabled>
16
+ <charset></charset>
17
+ <fbc>1</fbc>
18
+ <doctype></doctype>
19
+ <fbd>1</fbd>
20
+ <validator_uri>http://validator.w3.org/check</validator_uri>
21
+ </w3chtmlvalidator>
22
+ <w3ccssvalidator>
23
+ <enabled>0</enabled>
24
+ <lang>en</lang>
25
+ <profile>css21</profile>
26
+ <warning>1</warning>
27
+ <usermedium>all</usermedium>
28
+ </w3ccssvalidator>
29
+ <csscompression>
30
+ <enabled>0</enabled>
31
+ <type>csstidy</type>
32
+ <template>highest_compression</template>
33
+ <remove_last_semicolon>1</remove_last_semicolon>
34
+ <remove_bslash>1</remove_bslash>
35
+ <compress_colors>1</compress_colors>
36
+ <compress_font_weight>1</compress_font_weight>
37
+ <lowercase_s>0</lowercase_s>
38
+ <optimise_shorthands>1</optimise_shorthands>
39
+ <case_properties>1</case_properties>
40
+ <sort_properties>0</sort_properties>
41
+ <sort_selectors>0</sort_selectors>
42
+ <merge_selectors>2</merge_selectors>
43
+ <discard_invalid_properties>0</discard_invalid_properties>
44
+ <css_level>CSS2.1</css_level>
45
+ <preserve_css>0</preserve_css>
46
+ <timestamp>1</timestamp>
47
+ </csscompression>
48
+ <jscompression>
49
+ <enabled>0</enabled>
50
+ <type>jsmin</type>
51
+ <preserve_semic>1</preserve_semic>
52
+ </jscompression>
53
+ <seo>
54
+ <enabled>0</enabled>
55
+ <trailingslash>1</trailingslash>
56
+ <products>1</products>
57
+ <search>1</search>
58
+ <cmshome>1</cmshome>
59
</seo>
60
+ </uioptimization>
61
+ </default>
62
+
63
+ <global>
64
+ <blocks>
65
+ <uioptimization>
66
+ <class>Diglin_UIOptimization_Block</class>
67
+ </uioptimization>
68
+ <page>
69
+ <rewrite>
70
+ <html_head>Diglin_UIOptimization_Block_Optimize_Head</html_head>
71
+ </rewrite>
72
+ </page>
73
+ </blocks>
74
+ <models>
75
+ <uioptimization>
76
+ <class>Diglin_UIOptimization_Model</class>
77
+ </uioptimization>
78
+ <core>
79
+ <rewrite>
80
+ <design_package>Diglin_UIOptimization_Model_Overwrite_Design_Package</design_package>
81
+ </rewrite>
82
+ </core>
83
+ </models>
84
+ <helpers>
85
+ <uioptimization>
86
+ <class>Diglin_UIOptimization_Helper</class>
87
+ </uioptimization>
88
+ </helpers>
89
+ </global>
90
91
+ <frontend>
92
+ <layout>
93
+ <updates>
94
+ <uioptimization module="Diglin_UIOptimization">
95
+ <file>uioptimization.xml</file>
96
+ </uioptimization>
97
+ </updates>
98
+ </layout>
99
+ </frontend>
100
+
101
<crontab>
102
<jobs>
103
<uioptimization_media_regeneration_all><!-- Every Sunday at 2:00 AM -->
app/code/community/Diglin/UIOptimization/etc/system.xml CHANGED
@@ -1,22 +1,22 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<config>
3
- <tabs>
4
- <diglin>
5
- <label>Diglin</label>
6
- <sort_order>400</sort_order>
7
- </diglin>
8
- </tabs>
9
-
10
- <sections>
11
- <uioptimization>
12
- <label>UI Optimization</label>
13
- <tab>diglin</tab>
14
- <frontend_type>text</frontend_type>
15
-