Diglin_UIOptimization - Version 1.1.0

Version Notes

- 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.1.0
Comparing to
See all releases


Version 1.1.0

Files changed (182) hide show
  1. app/code/community/Diglin/UIOptimization/Block/Adminhtml/Config/Source/Hint.php +44 -0
  2. app/code/community/Diglin/UIOptimization/Block/Optimize/Head.php +357 -0
  3. app/code/community/Diglin/UIOptimization/Block/W3Ccssvalidator.php +83 -0
  4. app/code/community/Diglin/UIOptimization/Block/W3Chtmlvalidator.php +83 -0
  5. app/code/community/Diglin/UIOptimization/Helper/Data.php +140 -0
  6. app/code/community/Diglin/UIOptimization/Model/Config/Source/Caseproperties.php +43 -0
  7. app/code/community/Diglin/UIOptimization/Model/Config/Source/Charset.php +81 -0
  8. app/code/community/Diglin/UIOptimization/Model/Config/Source/Csslevel.php +43 -0
  9. app/code/community/Diglin/UIOptimization/Model/Config/Source/Csstypeminify.php +42 -0
  10. app/code/community/Diglin/UIOptimization/Model/Config/Source/Doctype.php +66 -0
  11. app/code/community/Diglin/UIOptimization/Model/Config/Source/Jstypeminify.php +42 -0
  12. app/code/community/Diglin/UIOptimization/Model/Config/Source/Language.php +49 -0
  13. app/code/community/Diglin/UIOptimization/Model/Config/Source/Mergeselectors.php +43 -0
  14. app/code/community/Diglin/UIOptimization/Model/Config/Source/Optishorthand.php +43 -0
  15. app/code/community/Diglin/UIOptimization/Model/Config/Source/Profile.php +51 -0
  16. app/code/community/Diglin/UIOptimization/Model/Config/Source/Template.php +45 -0
  17. app/code/community/Diglin/UIOptimization/Model/Config/Source/Usermedium.php +51 -0
  18. app/code/community/Diglin/UIOptimization/Model/Config/Source/Warning.php +44 -0
  19. app/code/community/Diglin/UIOptimization/Model/Observer.php +73 -0
  20. app/code/community/Diglin/UIOptimization/Model/Overwrite/Design/Package.php +47 -0
  21. app/code/community/Diglin/UIOptimization/etc/adminhtml.xml +25 -0
  22. app/code/community/Diglin/UIOptimization/etc/config.xml +107 -0
  23. app/code/community/Diglin/UIOptimization/etc/system.xml +519 -0
  24. app/design/frontend/default/default/layout/uioptimization.xml +118 -0
  25. app/design/frontend/default/default/template/uioptimization/canonicalurl/head-blog.phtml +27 -0
  26. app/design/frontend/default/default/template/uioptimization/canonicalurl/head-home.phtml +27 -0
  27. app/design/frontend/default/default/template/uioptimization/canonicalurl/head-product.phtml +27 -0
  28. app/design/frontend/default/default/template/uioptimization/canonicalurl/head.phtml +27 -0
  29. app/design/frontend/default/default/template/uioptimization/w3ccssvalidator.phtml +112 -0
  30. app/design/frontend/default/default/template/uioptimization/w3chtmlvalidator.phtml +123 -0
  31. app/etc/modules/Diglin_UIOptimization.xml +9 -0
  32. lib/Diglin/Csstidy/Core.php +998 -0
  33. lib/Diglin/Csstidy/Optimise.php +808 -0
  34. lib/Diglin/Csstidy/Print.php +348 -0
  35. lib/Diglin/Csstidy/README +28 -0
  36. lib/Diglin/Csstidy/data.inc.php +473 -0
  37. lib/Diglin/FirePHP.php +1370 -0
  38. lib/Diglin/HTTP/ConditionalGet.php +348 -0
  39. lib/Diglin/HTTP/Encoder.php +326 -0
  40. lib/Diglin/HTTP/Request2.php +861 -0
  41. lib/Diglin/HTTP/Request2/Adapter.php +154 -0
  42. lib/Diglin/HTTP/Request2/Adapter/Curl.php +461 -0
  43. lib/Diglin/HTTP/Request2/Adapter/Mock.php +171 -0
  44. lib/Diglin/HTTP/Request2/Adapter/Socket.php +1046 -0
  45. lib/Diglin/HTTP/Request2/Exception.php +62 -0
  46. lib/Diglin/HTTP/Request2/MultipartBody.php +274 -0
  47. lib/Diglin/HTTP/Request2/Observer/Log.php +215 -0
  48. lib/Diglin/HTTP/Request2/Response.php +559 -0
  49. lib/Diglin/Io/File.php +71 -0
  50. lib/Diglin/JSMin.php +314 -0
  51. lib/Diglin/JSMinPlus.php +1872 -0
  52. lib/Diglin/JavaScriptPacker.php +537 -0
  53. lib/Diglin/Minify.php +532 -0
  54. lib/Diglin/Minify/Build.php +103 -0
  55. lib/Diglin/Minify/CSS.php +83 -0
  56. lib/Diglin/Minify/CSS/Compressor.php +250 -0
  57. lib/Diglin/Minify/CSS/UriRewriter.php +270 -0
  58. lib/Diglin/Minify/Cache/APC.php +130 -0
  59. lib/Diglin/Minify/Cache/File.php +125 -0
  60. lib/Diglin/Minify/Cache/Memcache.php +137 -0
  61. lib/Diglin/Minify/CommentPreserver.php +90 -0
  62. lib/Diglin/Minify/Controller/Base.php +202 -0
  63. lib/Diglin/Minify/Controller/Files.php +78 -0
  64. lib/Diglin/Minify/Controller/Groups.php +94 -0
  65. lib/Diglin/Minify/Controller/MinApp.php +132 -0
  66. lib/Diglin/Minify/Controller/Page.php +82 -0
  67. lib/Diglin/Minify/Controller/Version1.php +118 -0
  68. lib/Diglin/Minify/HTML.php +245 -0
  69. lib/Diglin/Minify/ImportProcessor.php +157 -0
  70. lib/Diglin/Minify/Lines.php +131 -0
  71. lib/Diglin/Minify/Logger.php +45 -0
  72. lib/Diglin/Minify/Packer.php +37 -0
  73. lib/Diglin/Minify/Source.php +187 -0
  74. lib/Diglin/Minify/YUICompressor.php +139 -0
  75. lib/Diglin/Net/URL2.php +894 -0
  76. lib/Diglin/ParseMaster.php +202 -0
  77. lib/Diglin/Services/W3C/CSSValidator.php +430 -0
  78. lib/Diglin/Services/W3C/CSSValidator/Error.php +78 -0
  79. lib/Diglin/Services/W3C/CSSValidator/Message.php +100 -0
  80. lib/Diglin/Services/W3C/CSSValidator/Response.php +144 -0
  81. lib/Diglin/Services/W3C/CSSValidator/Warning.php +58 -0
  82. lib/Diglin/Services/W3C/HTMLValidator.php +412 -0
  83. lib/Diglin/Services/W3C/HTMLValidator/Error.php +35 -0
  84. lib/Diglin/Services/W3C/HTMLValidator/Exception.php +31 -0
  85. lib/Diglin/Services/W3C/HTMLValidator/Message.php +97 -0
  86. lib/Diglin/Services/W3C/HTMLValidator/Response.php +92 -0
  87. lib/Diglin/Services/W3C/HTMLValidator/Warning.php +35 -0
  88. lib/Diglin/Solar/Dir.php +199 -0
  89. lib/Diglin/yuicompressor-2.4.6/LICENSE.TXT +54 -0
  90. lib/Diglin/yuicompressor-2.4.6/ant.properties +8 -0
  91. lib/Diglin/yuicompressor-2.4.6/build.xml +69 -0
  92. lib/Diglin/yuicompressor-2.4.6/build/yuicompressor-2.4.6.jar +0 -0
  93. lib/Diglin/yuicompressor-2.4.6/doc/CHANGELOG +257 -0
  94. lib/Diglin/yuicompressor-2.4.6/doc/README +145 -0
  95. lib/Diglin/yuicompressor-2.4.6/lib/jargs-1.0.jar +0 -0
  96. lib/Diglin/yuicompressor-2.4.6/lib/rhino-1.6R7.jar +0 -0
  97. lib/Diglin/yuicompressor-2.4.6/ports/js/cssmin.js +231 -0
  98. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/Bootstrap.java +23 -0
  99. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/CssCompressor.java +304 -0
  100. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/JarClassLoader.java +158 -0
  101. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/JavaScriptCompressor.java +1317 -0
  102. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/JavaScriptIdentifier.java +55 -0
  103. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/JavaScriptToken.java +28 -0
  104. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java +160 -0
  105. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/YUICompressor.java +255 -0
  106. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/Decompiler.java +908 -0
  107. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/Decompiler.java.orig +910 -0
  108. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/Parser.java +2160 -0
  109. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/Parser.java.orig +2159 -0
  110. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/Token.java +406 -0
  111. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/Token.java.orig +417 -0
  112. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/TokenStream.java +1365 -0
  113. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/TokenStream.java.orig +1398 -0
  114. lib/Diglin/yuicompressor-2.4.6/tests/README +6 -0
  115. lib/Diglin/yuicompressor-2.4.6/tests/_munge.js +8 -0
  116. lib/Diglin/yuicompressor-2.4.6/tests/_munge.js.min +1 -0
  117. lib/Diglin/yuicompressor-2.4.6/tests/_string_combo.js +5 -0
  118. lib/Diglin/yuicompressor-2.4.6/tests/_string_combo.js.min +1 -0
  119. lib/Diglin/yuicompressor-2.4.6/tests/_syntax_error.js +73 -0
  120. lib/Diglin/yuicompressor-2.4.6/tests/_syntax_error.js.min +1 -0
  121. lib/Diglin/yuicompressor-2.4.6/tests/background-position.css +2 -0
  122. lib/Diglin/yuicompressor-2.4.6/tests/background-position.css.min +1 -0
  123. lib/Diglin/yuicompressor-2.4.6/tests/border-none.css +5 -0
  124. lib/Diglin/yuicompressor-2.4.6/tests/border-none.css.min +1 -0
  125. lib/Diglin/yuicompressor-2.4.6/tests/box-model-hack.css +9 -0
  126. lib/Diglin/yuicompressor-2.4.6/tests/box-model-hack.css.min +1 -0
  127. lib/Diglin/yuicompressor-2.4.6/tests/bug2527974.css +10 -0
  128. lib/Diglin/yuicompressor-2.4.6/tests/bug2527974.css.min +1 -0
  129. lib/Diglin/yuicompressor-2.4.6/tests/bug2527991.css +19 -0
  130. lib/Diglin/yuicompressor-2.4.6/tests/bug2527991.css.min +1 -0
  131. lib/Diglin/yuicompressor-2.4.6/tests/bug2527998.css +4 -0
  132. lib/Diglin/yuicompressor-2.4.6/tests/bug2527998.css.min +1 -0
  133. lib/Diglin/yuicompressor-2.4.6/tests/bug2528034.css +5 -0
  134. lib/Diglin/yuicompressor-2.4.6/tests/bug2528034.css.min +1 -0
  135. lib/Diglin/yuicompressor-2.4.6/tests/charset-media.css +9 -0
  136. lib/Diglin/yuicompressor-2.4.6/tests/charset-media.css.min +1 -0
  137. lib/Diglin/yuicompressor-2.4.6/tests/color.css +7 -0
  138. lib/Diglin/yuicompressor-2.4.6/tests/color.css.min +1 -0
  139. lib/Diglin/yuicompressor-2.4.6/tests/comment.css +3 -0
  140. lib/Diglin/yuicompressor-2.4.6/tests/comment.css.min +1 -0
  141. lib/Diglin/yuicompressor-2.4.6/tests/concat-charset.css +15 -0
  142. lib/Diglin/yuicompressor-2.4.6/tests/concat-charset.css.min +1 -0
  143. lib/Diglin/yuicompressor-2.4.6/tests/decimals.css +3 -0
  144. lib/Diglin/yuicompressor-2.4.6/tests/decimals.css.min +1 -0
  145. lib/Diglin/yuicompressor-2.4.6/tests/dollar-header.css +7 -0
  146. lib/Diglin/yuicompressor-2.4.6/tests/dollar-header.css.min +3 -0
  147. lib/Diglin/yuicompressor-2.4.6/tests/float.js +2 -0
  148. lib/Diglin/yuicompressor-2.4.6/tests/float.js.min +1 -0
  149. lib/Diglin/yuicompressor-2.4.6/tests/font-face.css +6 -0
  150. lib/Diglin/yuicompressor-2.4.6/tests/font-face.css.min +1 -0
  151. lib/Diglin/yuicompressor-2.4.6/tests/ie5mac.css +5 -0
  152. lib/Diglin/yuicompressor-2.4.6/tests/ie5mac.css.min +1 -0
  153. lib/Diglin/yuicompressor-2.4.6/tests/media-empty-class.css +16 -0
  154. lib/Diglin/yuicompressor-2.4.6/tests/media-empty-class.css.min +1 -0
  155. lib/Diglin/yuicompressor-2.4.6/tests/media-multi.css +3 -0
  156. lib/Diglin/yuicompressor-2.4.6/tests/media-multi.css.min +1 -0
  157. lib/Diglin/yuicompressor-2.4.6/tests/media-test.css +3 -0
  158. lib/Diglin/yuicompressor-2.4.6/tests/media-test.css.min +1 -0
  159. lib/Diglin/yuicompressor-2.4.6/tests/opacity-filter.css +14 -0
  160. lib/Diglin/yuicompressor-2.4.6/tests/opacity-filter.css.min +1 -0
  161. lib/Diglin/yuicompressor-2.4.6/tests/preserve-new-line.css +6 -0
  162. lib/Diglin/yuicompressor-2.4.6/tests/preserve-new-line.css.min +3 -0
  163. lib/Diglin/yuicompressor-2.4.6/tests/preserve-strings.css +7 -0
  164. lib/Diglin/yuicompressor-2.4.6/tests/preserve-strings.css.min +1 -0
  165. lib/Diglin/yuicompressor-2.4.6/tests/pseudo-first.css +16 -0
  166. lib/Diglin/yuicompressor-2.4.6/tests/pseudo-first.css.min +1 -0
  167. lib/Diglin/yuicompressor-2.4.6/tests/pseudo.css +4 -0
  168. lib/Diglin/yuicompressor-2.4.6/tests/pseudo.css.min +1 -0
  169. lib/Diglin/yuicompressor-2.4.6/tests/special-comments.css +13 -0
  170. lib/Diglin/yuicompressor-2.4.6/tests/special-comments.css.min +9 -0
  171. lib/Diglin/yuicompressor-2.4.6/tests/star-underscore-hacks.css +5 -0
  172. lib/Diglin/yuicompressor-2.4.6/tests/star-underscore-hacks.css.min +1 -0
  173. lib/Diglin/yuicompressor-2.4.6/tests/string-in-comment.css +8 -0
  174. lib/Diglin/yuicompressor-2.4.6/tests/string-in-comment.css.min +1 -0
  175. lib/Diglin/yuicompressor-2.4.6/tests/suite.rhino +3 -0
  176. lib/Diglin/yuicompressor-2.4.6/tests/suite.sh +62 -0
  177. lib/Diglin/yuicompressor-2.4.6/tests/webkit-transform.css +2 -0
  178. lib/Diglin/yuicompressor-2.4.6/tests/webkit-transform.css.min +1 -0
  179. lib/Diglin/yuicompressor-2.4.6/tests/zeros.css +6 -0
  180. lib/Diglin/yuicompressor-2.4.6/tests/zeros.css.min +1 -0
  181. package.xml +59 -0
  182. skin/frontend/default/default/css/w3c-validator.css +36 -0
app/code/community/Diglin/UIOptimization/Block/Adminhtml/Config/Source/Hint.php ADDED
@@ -0,0 +1,44 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
27
+ extends Mage_Adminhtml_Block_Abstract
28
+ implements Varien_Data_Form_Element_Renderer_Interface
29
+ {
30
+
31
+ /**
32
+ * Render fieldset html
33
+ *
34
+ * @param Varien_Data_Form_Element_Abstract $element
35
+ * @return string
36
+ */
37
+ public function render(Varien_Data_Form_Element_Abstract $element)
38
+ {
39
+ $version = Mage::getConfig()->getModuleConfig('Diglin_UIOptimization')->version;
40
+ return '<p><form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input name="cmd" type="hidden" value="_s-xclick" /> <input name="hosted_button_id" type="hidden" value="9SFPE62WPWG2U" /> <input alt="PayPal - The safer, easier way to pay online!" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" type="image" /> <img src="https://www.paypal.com/fr_FR/i/scr/pixel.gif" border="0" alt="" width="1" height="1" /> </form>Please, Invite me for a drink for the hard work done. Thank you in advance for your donation</p>
41
+ <p><strong>Diglin_UIOptimization Version: '.$version.'</strong></p>';
42
+
43
+ }
44
+ }
app/code/community/Diglin/UIOptimization/Block/Optimize/Head.php ADDED
@@ -0,0 +1,357 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
32
+ * filenames, rather than render urls.
33
+ * The merger callback is responsible for checking whether files exist, merging them and giving result URL
34
+ *
35
+ * @param string $format - HTML element format for sprintf('<element src="%s"%s />', $src, $params)
36
+ * @param array $staticItems - array of relative names of static items to be grabbed from js/ folder
37
+ * @param array $skinItems - array of relative names of skin items to be found in skins according to design config
38
+ * @param callback $mergeCallback
39
+ * @return string
40
+ */
41
+ protected function &_prepareStaticAndSkinElements($format, array $staticItems, array $skinItems, $mergeCallback = null)
42
+ {
43
+ $designPackage = Mage::getDesign();
44
+ $baseJsUrl = Mage::getBaseUrl('js');
45
+ $items = array();
46
+ if ($mergeCallback && !is_callable($mergeCallback)) {
47
+ $mergeCallback = null;
48
+ }
49
+
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
+
77
+ $html = '';
78
+ foreach ($items as $params => $rows) {
79
+ // attempt to merge
80
+ $mergedUrl = false;
81
+ if ($mergeCallback) {
82
+ $mergedUrl = call_user_func($mergeCallback, $rows);
83
+ }
84
+ // render elements
85
+ $params = trim($params);
86
+ $params = $params ? ' ' . $params : '';
87
+ if ($mergedUrl) {
88
+ $html .= sprintf($format, $mergedUrl, $params);
89
+ } else {
90
+ foreach ($rows as $src) {
91
+ $html .= sprintf($format, $src, $params);
92
+ }
93
+ }
94
+ }
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
+ }
app/code/community/Diglin/UIOptimization/Block/W3Ccssvalidator.php ADDED
@@ -0,0 +1,83 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ }
app/code/community/Diglin/UIOptimization/Block/W3Chtmlvalidator.php ADDED
@@ -0,0 +1,83 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ }
app/code/community/Diglin/UIOptimization/Helper/Data.php ADDED
@@ -0,0 +1,140 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
118
+ *
119
+ * @param string $dirRelativeName
120
+ * @param bool $cleanup
121
+ * @return bool|string
122
+ */
123
+ public function initMergerDir($dirRelativeName, $cleanup = false)
124
+ {
125
+ $mediaDir = Mage::getBaseDir('media');
126
+ try {
127
+ $dir = Mage::getBaseDir('media') . DS . $dirRelativeName;
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;
135
+ } catch (Exception $e) {
136
+ Mage::logException($e);
137
+ }
138
+ return false;
139
+ }
140
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Caseproperties.php ADDED
@@ -0,0 +1,43 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
32
+ * @return array
33
+ */
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
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Charset.php ADDED
@@ -0,0 +1,81 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
31
+ * @return array
32
+ */
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)"),
40
+ array('value' => "iso-8859-2", 'label' => "iso-8859-2 (Central Europe)"),
41
+ array('value' => "iso-8859-3", 'label' => "iso-8859-3 (Southern Europe)"),
42
+ array('value' => "iso-8859-4", 'label' => "iso-8859-4 (North European)"),
43
+ array('value' => "iso-8859-5", 'label' => "iso-8859-5 (Cyrillic)"),
44
+ array('value' => "iso-8859-6-i", 'label' => "iso-8859-6-i (Arabic)"),
45
+ array('value' => "iso-8859-7", 'label' => "iso-8859-7 (Greek)"),
46
+ array('value' => "iso-8859-8", 'label' => "iso-8859-8 (Hebrew, visual)"),
47
+ array('value' => "iso-8859-8-i", 'label' => "iso-8859-8-i (Hebrew, logical)"),
48
+ array('value' => "iso-8859-9", 'label' => "iso-8859-9 (Turkish)"),
49
+ array('value' => "iso-8859-10", 'label' => "iso-8859-10 (Latin 6)"),
50
+ array('value' => "iso-8859-11", 'label' => "iso-8859-11 (Latin/Thai)"),
51
+ array('value' => "iso-8859-13", 'label' => "iso-8859-13 (Latin 7, Baltic Rim)"),
52
+ array('value' => "iso-8859-14", 'label' => "iso-8859-14 (Latin 8, Celtic)"),
53
+ array('value' => "iso-8859-15", 'label' => "iso-8859-15 (Latin 9)"),
54
+ array('value' => "iso-8859-16", 'label' => "iso-8859-16 (Latin 10)"),
55
+ array('value' => "us-ascii", 'label' => "us-ascii (basic English)"),
56
+ array('value' => "euc-jp", 'label' => "euc-jp (Japanese, Unix)"),
57
+ array('value' => "shift_jis", 'label' => "shift_jis (Japanese, Win/Mac)"),
58
+ array('value' => "iso-2022-jp", 'label' => "iso-2022-jp (Japanese, email)"),
59
+ array('value' => "euc-kr", 'label' => "euc-kr (Korean)"),
60
+ array('value' => "ksc_5601", 'label' => "ksc_5601 (Korean)"),
61
+ array('value' => "gb2312", 'label' => "gb2312 (Chinese, simplified)"),
62
+ array('value' => "gb18030", 'label' => "gb18030 (Chinese, simplified)"),
63
+ array('value' => "big5", 'label' => "big5 (Chinese, traditional)"),
64
+ array('value' => "big5-HKSCS", 'label' => "Big5-HKSCS (Chinese, Hong Kong)"),
65
+ array('value' => "tis-620", 'label' => "tis-620 (Thai)"),
66
+ array('value' => "koi8-r", 'label' => "koi8-r (Russian)"),
67
+ array('value' => "koi8-u", 'label' => "koi8-u (Ukrainian)"),
68
+ array('value' => "iso-ir-111", 'label' => "iso-ir-111 (Cyrillic KOI-8)"),
69
+ array('value' => "macintosh", 'label' => "macintosh (MacRoman)"),
70
+ array('value' => "windows-1250", 'label' => "windows-1250 (Central Europe)"),
71
+ array('value' => "windows-1251", 'label' => "windows-1251 (Cyrillic)"),
72
+ array('value' => "windows-1252", 'label' => "windows-1252 (Western Europe)"),
73
+ array('value' => "windows-1253", 'label' => "windows-1253 (Greek)"),
74
+ array('value' => "windows-1254", 'label' => "windows-1254 (Turkish)"),
75
+ array('value' => "windows-1255", 'label' => "windows-1255 (Hebrew)"),
76
+ array('value' => "windows-1256", 'label' => "windows-1256 (Arabic)"),
77
+ array('value' => "windows-1257", 'label' => "windows-1257 (Baltic Rim)"),
78
+ );
79
+ }
80
+
81
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Csslevel.php ADDED
@@ -0,0 +1,43 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
32
+ * @return array
33
+ */
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
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Csstypeminify.php ADDED
@@ -0,0 +1,42 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
31
+ * @return array
32
+ */
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
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Doctype.php ADDED
@@ -0,0 +1,66 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
32
+ * @return array
33
+ */
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
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Jstypeminify.php ADDED
@@ -0,0 +1,42 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
31
+ * @return array
32
+ */
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
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Language.php ADDED
@@ -0,0 +1,49 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
32
+ * @return array
33
+ */
34
+ public function toOptionArray()
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
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Mergeselectors.php ADDED
@@ -0,0 +1,43 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
32
+ * @return array
33
+ */
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
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Optishorthand.php ADDED
@@ -0,0 +1,43 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
32
+ * @return array
33
+ */
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
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Profile.php ADDED
@@ -0,0 +1,51 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
32
+ * @return array
33
+ */
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
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Template.php ADDED
@@ -0,0 +1,45 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
32
+ * @return array
33
+ */
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
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Usermedium.php ADDED
@@ -0,0 +1,51 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
32
+ * @return array
33
+ */
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
+ }
app/code/community/Diglin/UIOptimization/Model/Config/Source/Warning.php ADDED
@@ -0,0 +1,44 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ *
32
+ * @return array
33
+ */
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
+ }
app/code/community/Diglin/UIOptimization/Model/Observer.php ADDED
@@ -0,0 +1,73 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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();
41
+ Mage::dispatchEvent('clean_media_cache_after');
42
+ } catch (Exception $e) {
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
+ }
app/code/community/Diglin/UIOptimization/Model/Overwrite/Design/Package.php ADDED
@@ -0,0 +1,47 @@
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
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
+ }
app/code/community/Diglin/UIOptimization/etc/adminhtml.xml ADDED
@@ -0,0 +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>
app/code/community/Diglin/UIOptimization/etc/config.xml ADDED
@@ -0,0 +1,107 @@
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 -->
101
+ <!-- schedule><cron_expr>0 2 * * 0</cron_expr></schedule-->
102
+ <schedule><config_path>uioptimization/general/cron_schedule</config_path></schedule>
103
+ <run><model>uioptimization/observer::regenerateMediaFiles</model></run>
104
+ </uioptimization_media_regeneration_all>
105
+ </jobs>
106
+ </crontab>
107
+ </config>
app/code/community/Diglin/UIOptimization/etc/system.xml ADDED
@@ -0,0 +1,519 @@