Version Notes
* Complete rewrite from the ground up
* Code standards improvements
* Fixed few small issues with admin blocks
* Empty Index is renamed to Clear Index including all block and methods
+ Added separate cron jobs, one for scanning one for optimization
+ Added option to force file permissions after optimization
Download this release
Release Info
Developer | Apptrian |
Extension | Apptrian_Image_Optimizer |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.3.0 to 2.0.0
- app/code/community/Apptrian/ImageOptimizer/Block/About.php +0 -43
- app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/About.php +50 -0
- app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/Button/Clear.php +45 -0
- app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/Button/Empty.php +0 -35
- app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/Button/Optimize.php +46 -41
- app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/Button/Scan.php +46 -41
- app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/Info.php +101 -0
- app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/Stats.php +47 -40
- app/code/community/Apptrian/ImageOptimizer/Block/Info.php +0 -70
- app/code/community/Apptrian/ImageOptimizer/Helper/Data.php +536 -307
- app/code/community/Apptrian/ImageOptimizer/Helper/Utility.php +0 -149
- app/code/community/Apptrian/ImageOptimizer/Model/Config/Batchsize.php +51 -50
- app/code/community/Apptrian/ImageOptimizer/Model/Config/Cron.php +0 -68
- app/code/community/Apptrian/ImageOptimizer/Model/Config/Cron/Optimize.php +75 -0
- app/code/community/Apptrian/ImageOptimizer/Model/Config/Cron/Scan.php +75 -0
- app/code/community/Apptrian/ImageOptimizer/Model/Config/Exactpath.php +54 -46
- app/code/community/Apptrian/ImageOptimizer/Model/Config/Options.php +54 -46
- app/code/community/Apptrian/ImageOptimizer/Model/Config/Path.php +51 -46
- app/code/community/Apptrian/ImageOptimizer/Model/Config/Paths.php +51 -46
- app/code/community/Apptrian/ImageOptimizer/Model/Config/Permissions.php +51 -0
- app/code/community/Apptrian/ImageOptimizer/Model/Config/Utility.php +52 -46
- app/code/community/Apptrian/ImageOptimizer/Model/Cron.php +97 -105
- app/code/community/Apptrian/ImageOptimizer/Model/File.php +17 -17
- app/code/community/Apptrian/ImageOptimizer/Model/Resource/File.php +264 -256
- app/code/community/Apptrian/ImageOptimizer/Model/Resource/File/Collection.php +18 -17
- app/code/community/Apptrian/ImageOptimizer/controllers/Adminhtml/Apptrian/ImgoptController.php +125 -92
- app/code/community/Apptrian/ImageOptimizer/etc/config.xml +159 -155
- app/code/community/Apptrian/ImageOptimizer/etc/system.xml +421 -379
- app/code/community/Apptrian/ImageOptimizer/sql/apptrian_imageoptimizer_setup/install-1.0.0.php +31 -22
- app/design/adminhtml/default/default/layout/apptrian_imageoptimizer.xml +20 -20
- app/etc/modules/Apptrian_ImageOptimizer.xml +21 -21
- app/locale/en_US/Apptrian_ImageOptimizer.csv +18 -8
- package.xml +12 -10
- skin/adminhtml/default/default/css/apptrian_imageoptimizer.css +19 -19
app/code/community/Apptrian/ImageOptimizer/Block/About.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category Apptrian
|
4 |
-
* @package Apptrian_ImageOptimizer
|
5 |
-
* @author Apptrian
|
6 |
-
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Block_About
|
10 |
-
extends Mage_Adminhtml_Block_Abstract
|
11 |
-
implements Varien_Data_Form_Element_Renderer_Interface
|
12 |
-
{
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Render fieldset html
|
16 |
-
*
|
17 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
18 |
-
* @return string
|
19 |
-
*/
|
20 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
21 |
-
{
|
22 |
-
$version = Mage::helper('apptrian_imageoptimizer')->getExtensionVersion();
|
23 |
-
$logopath = 'http://www.apptrian.com/media/apptrian.gif';
|
24 |
-
$html = <<<HTML
|
25 |
-
<div style="background:url('$logopath') no-repeat scroll 15px 15px #e7efef; border:1px solid #ccc; min-height:100px; margin:5px 0; padding:15px 15px 15px 140px;">
|
26 |
-
<p>
|
27 |
-
<strong>Apptrian Image Optimizer Extension v$version</strong><br />
|
28 |
-
Optimize your images, reduce their file size without losing image quality and speed up your site.
|
29 |
-
</p>
|
30 |
-
<p>
|
31 |
-
Website: <a href="http://www.apptrian.com" target="_blank">www.apptrian.com</a><br />
|
32 |
-
Like, share and follow us on
|
33 |
-
<a href="https://www.facebook.com/apptrian" target="_blank">Facebook</a>,
|
34 |
-
<a href="https://plus.google.com/+ApptrianCom" target="_blank">Google+</a>,
|
35 |
-
<a href="http://www.pinterest.com/apptrian" target="_blank">Pinterest</a>, and
|
36 |
-
<a href="http://twitter.com/apptrian" target="_blank">Twitter</a>.<br />
|
37 |
-
If you have any questions send email at <a href="mailto:service@apptrian.com">service@apptrian.com</a>.
|
38 |
-
</p>
|
39 |
-
</div>
|
40 |
-
HTML;
|
41 |
-
return $html;
|
42 |
-
}
|
43 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/About.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Block_Adminhtml_About
|
10 |
+
extends Mage_Adminhtml_Block_Abstract
|
11 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Render fieldset html
|
16 |
+
*
|
17 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
21 |
+
{
|
22 |
+
$element = null;
|
23 |
+
$version = Mage::helper('apptrian_imageoptimizer')
|
24 |
+
->getExtensionVersion();
|
25 |
+
$logopath = 'http://www.apptrian.com/media/apptrian.gif';
|
26 |
+
$html = <<<HTML
|
27 |
+
<div style="background:url('$logopath') no-repeat scroll 15px 15px #e7efef;
|
28 |
+
border:1px solid #ccc; min-height:100px; margin:5px 0;
|
29 |
+
padding:15px 15px 15px 140px;">
|
30 |
+
<p>
|
31 |
+
<strong>Apptrian Image Optimizer Extension v$version</strong><br />
|
32 |
+
Optimize your images, reduce their file size without losing image quality and
|
33 |
+
speed up your site.
|
34 |
+
</p>
|
35 |
+
<p>
|
36 |
+
Website:
|
37 |
+
<a href="http://www.apptrian.com" target="_blank">www.apptrian.com</a><br />
|
38 |
+
Like, share and follow us on
|
39 |
+
<a href="https://www.facebook.com/apptrian" target="_blank">Facebook</a>,
|
40 |
+
<a href="https://plus.google.com/+ApptrianCom" target="_blank">Google+</a>,
|
41 |
+
<a href="http://www.pinterest.com/apptrian" target="_blank">Pinterest</a>, and
|
42 |
+
<a href="http://twitter.com/apptrian" target="_blank">Twitter</a>.<br />
|
43 |
+
If you have any questions send email at
|
44 |
+
<a href="mailto:service@apptrian.com">service@apptrian.com</a>.
|
45 |
+
</p>
|
46 |
+
</div>
|
47 |
+
HTML;
|
48 |
+
return $html;
|
49 |
+
}
|
50 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/Button/Clear.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Block_Adminhtml_Button_Clear
|
10 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Retrieve element HTML markup
|
14 |
+
*
|
15 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
protected function _getElementHtml(
|
19 |
+
Varien_Data_Form_Element_Abstract $element
|
20 |
+
)
|
21 |
+
{
|
22 |
+
$element = null;
|
23 |
+
|
24 |
+
$buttonLabel = Mage::helper('apptrian_imageoptimizer')
|
25 |
+
->__('Clear Index');
|
26 |
+
|
27 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
28 |
+
'adminhtml/apptrian_imgopt/clear'
|
29 |
+
);
|
30 |
+
|
31 |
+
$confirmText = Mage::helper('apptrian_imageoptimizer')
|
32 |
+
->__('Are you sure you want to do this?');
|
33 |
+
|
34 |
+
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
35 |
+
->setType('button')
|
36 |
+
//->setId('apptrian_imageoptimizer_general_clear')
|
37 |
+
->setClass('apptrian-imageoptimizer-admin-button-clear')
|
38 |
+
->setLabel($buttonLabel)
|
39 |
+
->setOnClick("confirmSetLocation('".$confirmText."', '".$url."')")
|
40 |
+
->toHtml();
|
41 |
+
|
42 |
+
return $html;
|
43 |
+
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/Button/Empty.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category Apptrian
|
4 |
-
* @package Apptrian_ImageOptimizer
|
5 |
-
* @author Apptrian
|
6 |
-
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Block_Adminhtml_Button_Empty extends Mage_Adminhtml_Block_System_Config_Form_Field
|
10 |
-
{
|
11 |
-
/**
|
12 |
-
* Import static blocks
|
13 |
-
*
|
14 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
15 |
-
* @return String
|
16 |
-
*/
|
17 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
18 |
-
{
|
19 |
-
|
20 |
-
$buttonLabel = Mage::helper('apptrian_imageoptimizer')->__('Empty Index');
|
21 |
-
|
22 |
-
$url = Mage::helper('adminhtml')->getUrl(
|
23 |
-
'adminhtml/apptrian_imgopt/empty');
|
24 |
-
|
25 |
-
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
26 |
-
->setType('button')
|
27 |
-
->setClass('apptrian-imageoptimizer-admin-button-empty')
|
28 |
-
->setLabel($buttonLabel)
|
29 |
-
->setOnClick("setLocation('$url')")
|
30 |
-
->toHtml();
|
31 |
-
|
32 |
-
return $html;
|
33 |
-
|
34 |
-
}
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/Button/Optimize.php
CHANGED
@@ -1,41 +1,46 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Block_Adminhtml_Button_Optimize
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Block_Adminhtml_Button_Optimize
|
10 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Retrieve element HTML markup
|
14 |
+
*
|
15 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
protected function _getElementHtml(
|
19 |
+
Varien_Data_Form_Element_Abstract $element
|
20 |
+
)
|
21 |
+
{
|
22 |
+
|
23 |
+
$elementOriginalData = $element->getOriginalData();
|
24 |
+
|
25 |
+
if (isset($elementOriginalData['label'])) {
|
26 |
+
$buttonLabel = $elementOriginalData['label'];
|
27 |
+
} else {
|
28 |
+
return '<div>Button label was not specified</div>';
|
29 |
+
}
|
30 |
+
|
31 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
32 |
+
'adminhtml/apptrian_imgopt/optimize'
|
33 |
+
);
|
34 |
+
|
35 |
+
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
36 |
+
->setType('button')
|
37 |
+
//->setId('apptrian_imageoptimizer_general_optimize')
|
38 |
+
->setClass('apptrian-imageoptimizer-admin-button-optimize')
|
39 |
+
->setLabel($buttonLabel)
|
40 |
+
->setOnClick("setLocation('$url')")
|
41 |
+
->toHtml();
|
42 |
+
|
43 |
+
return $html;
|
44 |
+
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/Button/Scan.php
CHANGED
@@ -1,41 +1,46 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Block_Adminhtml_Button_Scan
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Block_Adminhtml_Button_Scan
|
10 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Retrieve element HTML markup
|
14 |
+
*
|
15 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
protected function _getElementHtml(
|
19 |
+
Varien_Data_Form_Element_Abstract $element
|
20 |
+
)
|
21 |
+
{
|
22 |
+
|
23 |
+
$elementOriginalData = $element->getOriginalData();
|
24 |
+
|
25 |
+
if (isset($elementOriginalData['label'])) {
|
26 |
+
$buttonLabel = $elementOriginalData['label'];
|
27 |
+
} else {
|
28 |
+
return '<div>Button label was not specified</div>';
|
29 |
+
}
|
30 |
+
|
31 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
32 |
+
'adminhtml/apptrian_imgopt/scan'
|
33 |
+
);
|
34 |
+
|
35 |
+
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
36 |
+
->setType('button')
|
37 |
+
//->setId('apptrian_imageoptimizer_general_scan')
|
38 |
+
->setClass('apptrian-imageoptimizer-admin-button-scan')
|
39 |
+
->setLabel($buttonLabel)
|
40 |
+
->setOnClick("setLocation('$url')")
|
41 |
+
->toHtml();
|
42 |
+
|
43 |
+
return $html;
|
44 |
+
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/Info.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Block_Adminhtml_Info
|
10 |
+
extends Mage_Adminhtml_Block_Abstract
|
11 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Render fieldset html
|
16 |
+
*
|
17 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
21 |
+
{
|
22 |
+
$element = null;
|
23 |
+
$logopath = 'http://www.apptrian.com/media/apptrian.gif';
|
24 |
+
$html = <<<HTML
|
25 |
+
<div style="background:url('$logopath') no-repeat scroll 15px 15px #e7efef;
|
26 |
+
border:1px solid #ccc; min-height:100px; margin:5px 0;
|
27 |
+
padding:15px 15px 15px 140px;">
|
28 |
+
<p>
|
29 |
+
<strong>Magento Online Stores & Extensions</strong><br />
|
30 |
+
<a href="http://www.apptrian.com" target="_blank">Apptrian</a> offers a wide
|
31 |
+
choice of products and services for your online business.
|
32 |
+
</p>
|
33 |
+
<p>
|
34 |
+
Website: <a href="http://www.apptrian.com" target="_blank">www.apptrian.com</a>
|
35 |
+
<br />
|
36 |
+
Like, share and follow us on
|
37 |
+
<a href="https://www.facebook.com/apptrian" target="_blank">Facebook</a>,
|
38 |
+
<a href="https://plus.google.com/+ApptrianCom" target="_blank">Google+</a>,
|
39 |
+
<a href="http://www.pinterest.com/apptrian" target="_blank">Pinterest</a>, and
|
40 |
+
<a href="http://twitter.com/apptrian" target="_blank">Twitter</a>.<br />
|
41 |
+
If you have any questions send email at
|
42 |
+
<a href="mailto:service@apptrian.com">service@apptrian.com</a>.
|
43 |
+
</p>
|
44 |
+
</div>
|
45 |
+
<div>
|
46 |
+
<p><strong>Products and services you might be interested in:</strong></p>
|
47 |
+
<a href="http://www.apptrian.com/facebook-pixel-for-magento"
|
48 |
+
target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
49 |
+
<img src="http://www.apptrian.com/media/facebook-pixel.jpg"
|
50 |
+
alt="Facebook Pixel" style="border:1px solid #ccc;" />
|
51 |
+
</a>
|
52 |
+
<a href="http://www.apptrian.com/image-optimizer-for-magento"
|
53 |
+
target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
54 |
+
<img src="http://www.apptrian.com/media/image-optimizer.jpg"
|
55 |
+
alt="Image Optimizer" style="border:1px solid #ccc;" />
|
56 |
+
</a>
|
57 |
+
<a href="http://www.apptrian.com/minify-html-css-js-for-magento"
|
58 |
+
target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
59 |
+
<img src="http://www.apptrian.com/media/minify-html-css-js.jpg"
|
60 |
+
alt="Minify HTML CSS JS" style="border:1px solid #ccc;" />
|
61 |
+
</a>
|
62 |
+
<a href="http://www.apptrian.com/professional-magento-installation"
|
63 |
+
target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
64 |
+
<img src="http://www.apptrian.com/media/professional-magento-installation.jpg"
|
65 |
+
alt="Professional Magento Installation" style="border:1px solid #ccc;" />
|
66 |
+
</a>
|
67 |
+
<a href="http://www.apptrian.com/quick-search-for-magento"
|
68 |
+
target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
69 |
+
<img src="http://www.apptrian.com/media/quick-search.jpg"
|
70 |
+
alt="Quick Search" style="border:1px solid #ccc;" />
|
71 |
+
</a>
|
72 |
+
<a href="http://www.apptrian.com/responsive-product-slider-for-magento"
|
73 |
+
target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
74 |
+
<img src="http://www.apptrian.com/media/responsive-product-slider.jpg"
|
75 |
+
alt="Responsive Product Slider" style="border:1px solid #ccc;" />
|
76 |
+
</a>
|
77 |
+
<a href="http://www.apptrian.com/schema-org-microdata-for-magento"
|
78 |
+
target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
79 |
+
<img src="http://www.apptrian.com/media/schema-org-microdata-for-magento.jpg"
|
80 |
+
alt="Schema.org Microdata for Magento" style="border:1px solid #ccc;" />
|
81 |
+
</a>
|
82 |
+
<a href="http://www.apptrian.com/snippets-generator-for-magento"
|
83 |
+
target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
84 |
+
<img src="http://www.apptrian.com/media/snippets-generator.jpg"
|
85 |
+
alt="Snippets Generator" style="border:1px solid #ccc;" />
|
86 |
+
</a>
|
87 |
+
<a href="http://www.apptrian.com/social-integrator-for-magento"
|
88 |
+
target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
89 |
+
<img src="http://www.apptrian.com/media/social-integrator.jpg"
|
90 |
+
alt="Social Integrator" style="border:1px solid #ccc;" />
|
91 |
+
</a>
|
92 |
+
<a href="http://www.apptrian.com/subcategories-grid-list-for-magento"
|
93 |
+
target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
94 |
+
<img src="http://www.apptrian.com/media/subcategories-grid-list.jpg"
|
95 |
+
alt="Subcategories Grid/List" style="border:1px solid #ccc;" />
|
96 |
+
</a>
|
97 |
+
</div>
|
98 |
+
HTML;
|
99 |
+
return $html;
|
100 |
+
}
|
101 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Block/Adminhtml/Stats.php
CHANGED
@@ -1,40 +1,47 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Block_Adminhtml_Stats
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Block_Adminhtml_Stats
|
10 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Retrieve element HTML markup.
|
14 |
+
*
|
15 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
protected function _getElementHtml(
|
19 |
+
Varien_Data_Form_Element_Abstract $element
|
20 |
+
)
|
21 |
+
{
|
22 |
+
$element = null;
|
23 |
+
$r = Mage::getResourceModel('apptrian_imageoptimizer/file');
|
24 |
+
|
25 |
+
$indexed = $r->getFileCount();
|
26 |
+
$optimized = $r->getFileCount(1);
|
27 |
+
|
28 |
+
// Fix for division by zero possibility
|
29 |
+
if ($indexed == 0) {
|
30 |
+
$percent = 0;
|
31 |
+
} else {
|
32 |
+
$percent = round((100 * $optimized) / $indexed, 2);
|
33 |
+
}
|
34 |
+
|
35 |
+
$html = '<div class="apptrian-imageoptimizer-bar-wrapper">
|
36 |
+
<div class="apptrian-imageoptimizer-bar-outer">
|
37 |
+
<div class="apptrian-imageoptimizer-bar-inner" style="width:'
|
38 |
+
. $percent .'%;"></div>
|
39 |
+
<div class="apptrian-imageoptimizer-bar-text"><span>' . $percent . '% '
|
40 |
+
. Mage::helper('apptrian_imageoptimizer')
|
41 |
+
->__('(%s of %s files)', $optimized, $indexed) . '</span></div>
|
42 |
+
</div></div>';
|
43 |
+
|
44 |
+
return $html;
|
45 |
+
|
46 |
+
}
|
47 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Block/Info.php
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category Apptrian
|
4 |
-
* @package Apptrian_ImageOptimizer
|
5 |
-
* @author Apptrian
|
6 |
-
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Block_Info
|
10 |
-
extends Mage_Adminhtml_Block_Abstract
|
11 |
-
implements Varien_Data_Form_Element_Renderer_Interface
|
12 |
-
{
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Render fieldset html
|
16 |
-
*
|
17 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
18 |
-
* @return string
|
19 |
-
*/
|
20 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
21 |
-
{
|
22 |
-
|
23 |
-
$logopath = 'http://www.apptrian.com/media/apptrian.gif';
|
24 |
-
$html = <<<HTML
|
25 |
-
<div style="background:url('$logopath') no-repeat scroll 15px 15px #e7efef; border:1px solid #ccc; min-height:100px; margin:5px 0; padding:15px 15px 15px 140px;">
|
26 |
-
<p>
|
27 |
-
<strong>Magento Online Stores & Extensions</strong><br />
|
28 |
-
<a href="http://www.apptrian.com" target="_blank">Apptrian</a> offers a wide choice of products and services for your online business.
|
29 |
-
</p>
|
30 |
-
<p>
|
31 |
-
Website: <a href="http://www.apptrian.com" target="_blank">www.apptrian.com</a><br />
|
32 |
-
Like, share and follow us on
|
33 |
-
<a href="https://www.facebook.com/apptrian" target="_blank">Facebook</a>,
|
34 |
-
<a href="https://plus.google.com/+ApptrianCom" target="_blank">Google+</a>,
|
35 |
-
<a href="http://www.pinterest.com/apptrian" target="_blank">Pinterest</a>, and
|
36 |
-
<a href="http://twitter.com/apptrian" target="_blank">Twitter</a>.<br />
|
37 |
-
If you have any questions send email at <a href="mailto:service@apptrian.com">service@apptrian.com</a>.
|
38 |
-
</p>
|
39 |
-
</div>
|
40 |
-
<div>
|
41 |
-
<p><strong>Products and services you might be interested in:</strong></p>
|
42 |
-
<a href="http://www.apptrian.com/image-optimizer-for-magento" target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
43 |
-
<img src="http://www.apptrian.com/media/apptrian-promotional/image-optimizer-for-magento.jpg" alt="Image Optimizer for Magento" style="border:1px solid #ccc;" />
|
44 |
-
</a>
|
45 |
-
<a href="http://www.apptrian.com/minify-html-css-js-for-magento" target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
46 |
-
<img src="http://www.apptrian.com/media/apptrian-promotional/minify-html-css-js-for-magento.jpg" alt="Minify HTML CSS JS for Magento" style="border:1px solid #ccc;" />
|
47 |
-
</a>
|
48 |
-
<a href="http://www.apptrian.com/professional-magento-installation" target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
49 |
-
<img src="http://www.apptrian.com/media/apptrian-promotional/professional-magento-installation.jpg" alt="Professional Magento Installation" style="border:1px solid #ccc;" />
|
50 |
-
</a>
|
51 |
-
<a href="http://www.apptrian.com/quick-search-for-magento" target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
52 |
-
<img src="http://www.apptrian.com/media/apptrian-promotional/quick-search-for-magento.jpg" alt="Quick Search for Magento" style="border:1px solid #ccc;" />
|
53 |
-
</a>
|
54 |
-
<a href="http://www.apptrian.com/responsive-product-slider-for-magento" target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
55 |
-
<img src="http://www.apptrian.com/media/apptrian-promotional/responsive-product-slider-for-magento.jpg" alt="Responsive Product Slider for Magento" style="border:1px solid #ccc;" />
|
56 |
-
</a>
|
57 |
-
<a href="http://www.apptrian.com/schema-org-microdata-for-magento" target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
58 |
-
<img src="http://www.apptrian.com/media/apptrian-promotional/schema-org-microdata-for-magento.jpg" alt="Schema.org Microdata for Magento" style="border:1px solid #ccc;" />
|
59 |
-
</a>
|
60 |
-
<a href="http://www.apptrian.com/social-integrator-for-magento" target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
61 |
-
<img src="http://www.apptrian.com/media/apptrian-promotional/social-integrator-for-magento.jpg" alt="Social Integrator" style="border:1px solid #ccc;" />
|
62 |
-
</a>
|
63 |
-
<a href="http://www.apptrian.com/subcategories-grid-list-for-magento" target="_blank" style="margin: 0 15px 15px 0; display: inline-block;">
|
64 |
-
<img src="http://www.apptrian.com/media/apptrian-promotional/subcategories-grid-list-for-magento.jpg" alt="Subcategories Grid/List" style="border:1px solid #ccc;" />
|
65 |
-
</a>
|
66 |
-
</div>
|
67 |
-
HTML;
|
68 |
-
return $html;
|
69 |
-
}
|
70 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Apptrian/ImageOptimizer/Helper/Data.php
CHANGED
@@ -1,307 +1,536 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Helper_Data extends Mage_Core_Helper_Abstract
|
10 |
-
{
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Helper_Data extends Mage_Core_Helper_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Magento Root full path.
|
14 |
+
*
|
15 |
+
* @var null|string
|
16 |
+
*/
|
17 |
+
protected $_baseDir = null;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Logging flag.
|
21 |
+
*
|
22 |
+
* @var null|int
|
23 |
+
*/
|
24 |
+
protected $_logging = null;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Path to utilities.
|
28 |
+
*
|
29 |
+
* @var null|string
|
30 |
+
*/
|
31 |
+
protected $_utilPath = null;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* extension (for win binaries)
|
35 |
+
*
|
36 |
+
* @var null|string
|
37 |
+
*/
|
38 |
+
protected $_utilExt = null;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Returns extension version.
|
42 |
+
*
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
public function getExtensionVersion()
|
46 |
+
{
|
47 |
+
return (string) Mage::getConfig()->getNode()
|
48 |
+
->modules->Apptrian_ImageOptimizer->version;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Based on provided configuration path returns configuration value.
|
53 |
+
*
|
54 |
+
* @param string $configPath
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
public function getConfig($configPath)
|
58 |
+
{
|
59 |
+
return Mage::getConfig()->getNode($configPath, 'default');
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Returns Magento Root full path.
|
64 |
+
*
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getBaseDir()
|
68 |
+
{
|
69 |
+
|
70 |
+
if ($this->_baseDir === null) {
|
71 |
+
|
72 |
+
$this->_baseDir = Mage::getBaseDir();
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
return $this->_baseDir;
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Checks if exec() function is enabled in php and suhosin config.
|
82 |
+
*
|
83 |
+
* @return boolean
|
84 |
+
*/
|
85 |
+
public function isExecFunctionEnabled()
|
86 |
+
{
|
87 |
+
$r = false;
|
88 |
+
|
89 |
+
// PHP disabled functions
|
90 |
+
$phpDisabledFunctions = array_map(
|
91 |
+
'strtolower',
|
92 |
+
array_map('trim', explode(',', ini_get('disable_functions')))
|
93 |
+
);
|
94 |
+
|
95 |
+
// Suhosin disabled functions
|
96 |
+
$suhosinDisabledFunctions = array_map(
|
97 |
+
'strtolower',
|
98 |
+
array_map(
|
99 |
+
'trim', explode(',', ini_get('suhosin.executor.func.blacklist'))
|
100 |
+
)
|
101 |
+
);
|
102 |
+
|
103 |
+
$disabledFunctions = array_merge(
|
104 |
+
$phpDisabledFunctions, $suhosinDisabledFunctions
|
105 |
+
);
|
106 |
+
|
107 |
+
$disabled = false;
|
108 |
+
|
109 |
+
if (in_array('exec', $disabledFunctions)) {
|
110 |
+
$disabled = true;
|
111 |
+
}
|
112 |
+
|
113 |
+
if (function_exists('exec') === true && $disabled === false) {
|
114 |
+
$r = true;
|
115 |
+
}
|
116 |
+
|
117 |
+
return $r;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Optimized way of getting logging flag from config.
|
122 |
+
*
|
123 |
+
* @return int
|
124 |
+
*/
|
125 |
+
public function isLoggingEnabled()
|
126 |
+
{
|
127 |
+
if ($this->_logging === null) {
|
128 |
+
|
129 |
+
$this->_logging = (int) $this->getConfig(
|
130 |
+
'apptrian_imageoptimizer/utility/log_output'
|
131 |
+
);
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
return $this->_logging;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Based on config returns array of all paths that will be scaned for
|
140 |
+
* images.
|
141 |
+
*
|
142 |
+
* @return array
|
143 |
+
*/
|
144 |
+
public function getPaths()
|
145 |
+
{
|
146 |
+
|
147 |
+
$paths = array();
|
148 |
+
|
149 |
+
$pathsString = trim(
|
150 |
+
trim($this->getConfig('apptrian_imageoptimizer/general/paths'), ';')
|
151 |
+
);
|
152 |
+
|
153 |
+
$rawPaths = explode(';', $pathsString);
|
154 |
+
|
155 |
+
foreach ($rawPaths as $p) {
|
156 |
+
|
157 |
+
$trimmed = trim(trim($p), '/');
|
158 |
+
|
159 |
+
$dirs = explode('/', $trimmed);
|
160 |
+
|
161 |
+
$paths[] = implode(DS, $dirs);
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
return array_unique($paths);
|
166 |
+
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Optimizes single file.
|
171 |
+
*
|
172 |
+
* @param string $filePath
|
173 |
+
* @return boolean
|
174 |
+
*/
|
175 |
+
public function optimizeFile($filePath)
|
176 |
+
{
|
177 |
+
|
178 |
+
$info = pathinfo($filePath);
|
179 |
+
|
180 |
+
$output = array();
|
181 |
+
|
182 |
+
switch (strtolower($info['extension'])) {
|
183 |
+
case 'jpg':
|
184 |
+
case 'jpeg':
|
185 |
+
exec($this->getJpgUtil($filePath), $output, $returnVar);
|
186 |
+
$type = 'jpg';
|
187 |
+
break;
|
188 |
+
case 'png':
|
189 |
+
exec($this->getPngUtil($filePath), $output, $returnVar);
|
190 |
+
$type = 'png';
|
191 |
+
break;
|
192 |
+
case 'gif':
|
193 |
+
exec($this->getGifUtil($filePath), $output, $returnVar);
|
194 |
+
$type = 'gif';
|
195 |
+
break;
|
196 |
+
}
|
197 |
+
|
198 |
+
if ($returnVar == 126) {
|
199 |
+
|
200 |
+
$error = $this->getConfig(
|
201 |
+
'apptrian_imageoptimizer/utility/' . $type
|
202 |
+
) . ' is not executable.';
|
203 |
+
|
204 |
+
Mage::log($error, null, 'apptrian_imageoptimizer.log');
|
205 |
+
|
206 |
+
return false;
|
207 |
+
|
208 |
+
} else {
|
209 |
+
|
210 |
+
if ($this->isLoggingEnabled()) {
|
211 |
+
|
212 |
+
Mage::log($filePath, null, 'apptrian_imageoptimizer.log');
|
213 |
+
Mage::log($output, null, 'apptrian_imageoptimizer.log');
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
$permissions = (string) $this->getConfig(
|
218 |
+
'apptrian_imageoptimizer/utility/permissions'
|
219 |
+
);
|
220 |
+
|
221 |
+
if ($permissions) {
|
222 |
+
chmod($filePath, octdec($permissions));
|
223 |
+
}
|
224 |
+
|
225 |
+
return true;
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Optimization process.
|
233 |
+
*
|
234 |
+
* @return boolean
|
235 |
+
*/
|
236 |
+
public function optimize()
|
237 |
+
{
|
238 |
+
// Get Batch Size
|
239 |
+
$batchSize = $this->getConfig(
|
240 |
+
'apptrian_imageoptimizer/general/batch_size'
|
241 |
+
);
|
242 |
+
|
243 |
+
// Get Collection of files for optimization but limited by batch size
|
244 |
+
$collection = Mage::getModel('apptrian_imageoptimizer/file')
|
245 |
+
->getCollection()
|
246 |
+
->addFieldToSelect(array('id', 'file_path'))
|
247 |
+
->addFieldToFilter('optimized', array('eq' => 0))
|
248 |
+
->setPageSize($batchSize)
|
249 |
+
->load();
|
250 |
+
|
251 |
+
$toUpdate = array();
|
252 |
+
$toDelete = array();
|
253 |
+
$oldFileSize = 0;
|
254 |
+
|
255 |
+
foreach ($collection as $item) {
|
256 |
+
|
257 |
+
$id = $item->getId();
|
258 |
+
$fPath = $item->getFilePath();
|
259 |
+
|
260 |
+
$filePath = realpath($fPath);
|
261 |
+
|
262 |
+
// If image exists, optimize else remove it from database
|
263 |
+
if (file_exists($filePath)) {
|
264 |
+
|
265 |
+
$oldFileSize = filesize($filePath);
|
266 |
+
|
267 |
+
if ($this->optimizeFile($filePath)) {
|
268 |
+
|
269 |
+
$toUpdate[$id]['file_path'] = $fPath;
|
270 |
+
$toUpdate[$id]['old_file_size'] = $oldFileSize;
|
271 |
+
$toUpdate[$id]['optimized'] = 1;
|
272 |
+
|
273 |
+
}
|
274 |
+
|
275 |
+
} else {
|
276 |
+
|
277 |
+
$toDelete[] = $id;
|
278 |
+
|
279 |
+
}
|
280 |
+
|
281 |
+
}
|
282 |
+
|
283 |
+
// Itereate over $toUpdate array and set modified time and new_file_size
|
284 |
+
// (mtime etc) takes a split second to update
|
285 |
+
foreach ($toUpdate as $i => $f) {
|
286 |
+
|
287 |
+
$filePath = realpath($f['file_path']);
|
288 |
+
|
289 |
+
if (file_exists($filePath)) {
|
290 |
+
$toUpdate[$i]['new_file_size'] = filesize($filePath);
|
291 |
+
$toUpdate[$i]['optimization_time'] = filemtime($filePath);
|
292 |
+
}
|
293 |
+
|
294 |
+
}
|
295 |
+
|
296 |
+
$resource = Mage::getResourceModel('apptrian_imageoptimizer/file');
|
297 |
+
|
298 |
+
$resultA = $resource->deleteFiles($toDelete);
|
299 |
+
$resultB = $resource->updateFiles($toUpdate);
|
300 |
+
|
301 |
+
if ($resultA === true && $resultB === true) {
|
302 |
+
return true;
|
303 |
+
} else {
|
304 |
+
return false;
|
305 |
+
}
|
306 |
+
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Scan and reindex process.
|
311 |
+
*
|
312 |
+
* @return boolean
|
313 |
+
*/
|
314 |
+
public function scanAndReindex()
|
315 |
+
{
|
316 |
+
|
317 |
+
$collection = Mage::getModel('apptrian_imageoptimizer/file')
|
318 |
+
->getCollection()
|
319 |
+
->addFieldToSelect(array('id', 'file_path', 'optimization_time'))
|
320 |
+
->load();
|
321 |
+
|
322 |
+
$inIndex = array();
|
323 |
+
$toAdd = array();
|
324 |
+
$toUpdate = array();
|
325 |
+
$toDelete = array();
|
326 |
+
$id = 0;
|
327 |
+
$filePath = '';
|
328 |
+
|
329 |
+
foreach ($collection as $item) {
|
330 |
+
|
331 |
+
$id = $item->getId();
|
332 |
+
|
333 |
+
$inIndex[$id] = 0;
|
334 |
+
|
335 |
+
$filePath = realpath($item->getFilePath());
|
336 |
+
|
337 |
+
if (file_exists($filePath)) {
|
338 |
+
if (filemtime($filePath) != $item->getOptimizationTime()) {
|
339 |
+
$toUpdate[] = $id;
|
340 |
+
}
|
341 |
+
} else {
|
342 |
+
$toDelete[] = $id;
|
343 |
+
}
|
344 |
+
|
345 |
+
}
|
346 |
+
|
347 |
+
|
348 |
+
$files = array();
|
349 |
+
$paths = $this->getPaths();
|
350 |
+
|
351 |
+
foreach ($paths as $path) {
|
352 |
+
|
353 |
+
$iterator = new RecursiveIteratorIterator(
|
354 |
+
new RecursiveDirectoryIterator(
|
355 |
+
$this->getBaseDir() . DS . $path,
|
356 |
+
RecursiveDirectoryIterator::FOLLOW_SYMLINKS
|
357 |
+
)
|
358 |
+
);
|
359 |
+
|
360 |
+
foreach ( $iterator as $filename => $file ) {
|
361 |
+
if ($file->isFile()
|
362 |
+
&& preg_match(
|
363 |
+
'/^.+\.(jpe?g|gif|png)$/i', $file->getFilename()
|
364 |
+
)
|
365 |
+
) {
|
366 |
+
$filePath = $file->getRealPath();
|
367 |
+
if (!is_writable($filePath)) {
|
368 |
+
continue;
|
369 |
+
}
|
370 |
+
|
371 |
+
$files[md5($filePath)] = $filePath;
|
372 |
+
|
373 |
+
}
|
374 |
+
}
|
375 |
+
|
376 |
+
}
|
377 |
+
|
378 |
+
|
379 |
+
$toAdd = array_diff_key($files, $inIndex);
|
380 |
+
|
381 |
+
$resource = Mage::getResourceModel('apptrian_imageoptimizer/file');
|
382 |
+
|
383 |
+
$resultA = $resource->deleteFiles($toDelete);
|
384 |
+
$resultB = $resource->updateFilesOptimizedField($toUpdate);
|
385 |
+
$resultC = $resource->addFiles($toAdd);
|
386 |
+
|
387 |
+
if ($resultA === true && $resultB === true && $resultC === true) {
|
388 |
+
return true;
|
389 |
+
} else {
|
390 |
+
return false;
|
391 |
+
}
|
392 |
+
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Checks if server OS is Windows
|
397 |
+
*
|
398 |
+
* @return bool
|
399 |
+
*/
|
400 |
+
public function isWindows()
|
401 |
+
{
|
402 |
+
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
403 |
+
return true;
|
404 |
+
} else {
|
405 |
+
return false;
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Alias for getUtil() and .gif
|
411 |
+
*
|
412 |
+
* @param string $filePath
|
413 |
+
* @return string
|
414 |
+
*/
|
415 |
+
public function getGifUtil($filePath)
|
416 |
+
{
|
417 |
+
return $this->getUtil('gif', $filePath);
|
418 |
+
}
|
419 |
+
|
420 |
+
/**
|
421 |
+
* Alias for getUtil() and .jpg
|
422 |
+
*
|
423 |
+
* @param string $filePath
|
424 |
+
* @return string
|
425 |
+
*/
|
426 |
+
public function getJpgUtil($filePath)
|
427 |
+
{
|
428 |
+
return $this->getUtil('jpg', $filePath);
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Alias for getUtil() and .png
|
433 |
+
*
|
434 |
+
* @param string $filePath
|
435 |
+
* @return string
|
436 |
+
*/
|
437 |
+
public function getPngUtil($filePath)
|
438 |
+
{
|
439 |
+
return $this->getUtil('png', $filePath);
|
440 |
+
}
|
441 |
+
|
442 |
+
/**
|
443 |
+
* Formats and returns the shell command string for an image optimization
|
444 |
+
* utility
|
445 |
+
*
|
446 |
+
* @param string $type - This is image type. Valid values gif|jpg|png
|
447 |
+
* @param string $filePath - Path to the image to be optimized
|
448 |
+
* @return string
|
449 |
+
*/
|
450 |
+
public function getUtil($type, $filePath)
|
451 |
+
{
|
452 |
+
|
453 |
+
$exactPath = $this->getConfig(
|
454 |
+
'apptrian_imageoptimizer/utility/' . $type . '_path'
|
455 |
+
);
|
456 |
+
|
457 |
+
// If utility exact path is set use it
|
458 |
+
if ($exactPath != '') {
|
459 |
+
|
460 |
+
$cmd = $exactPath;
|
461 |
+
|
462 |
+
// Use path to extension's local utilities
|
463 |
+
} else {
|
464 |
+
|
465 |
+
$cmd = $this->getUtilPath() . DS . $this->getConfig(
|
466 |
+
'apptrian_imageoptimizer/utility/' . $type
|
467 |
+
) . $this->getUtilExt();
|
468 |
+
|
469 |
+
}
|
470 |
+
|
471 |
+
$cmd .= ' ' . $this->getConfig(
|
472 |
+
'apptrian_imageoptimizer/utility/' . $type . '_options'
|
473 |
+
);
|
474 |
+
|
475 |
+
return str_replace('%filepath%', $filePath, $cmd);
|
476 |
+
|
477 |
+
}
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Gets and stores utility extension.
|
481 |
+
* Checks server OS and determine utility extension.
|
482 |
+
*
|
483 |
+
* @return string
|
484 |
+
*/
|
485 |
+
public function getUtilExt()
|
486 |
+
{
|
487 |
+
if ($this->_utilExt === null) {
|
488 |
+
|
489 |
+
$this->_utilExt = $this->isWindows() ? '.exe' : '';
|
490 |
+
|
491 |
+
}
|
492 |
+
|
493 |
+
return $this->_utilExt;
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Gets and stores path to utilities.
|
498 |
+
* Checks server OS and config to determine the path where
|
499 |
+
* image optimization utilities are.
|
500 |
+
*
|
501 |
+
* @return string
|
502 |
+
*/
|
503 |
+
public function getUtilPath()
|
504 |
+
{
|
505 |
+
if ($this->_utilPath === null) {
|
506 |
+
|
507 |
+
$useSixtyFourBit = (int) $this->getConfig(
|
508 |
+
'apptrian_imageoptimizer/utility/use64bit'
|
509 |
+
);
|
510 |
+
|
511 |
+
if ($useSixtyFourBit) {
|
512 |
+
$bit = '64';
|
513 |
+
} else {
|
514 |
+
$bit = '32';
|
515 |
+
}
|
516 |
+
|
517 |
+
$os = $this->isWindows() ? 'win' . $bit : 'elf' . $bit;
|
518 |
+
|
519 |
+
$pathString = trim(
|
520 |
+
trim(
|
521 |
+
$this->getConfig('apptrian_imageoptimizer/utility/path')
|
522 |
+
),
|
523 |
+
'/'
|
524 |
+
);
|
525 |
+
|
526 |
+
$dirs = explode('/', $pathString);
|
527 |
+
$path = implode(DS, $dirs);
|
528 |
+
|
529 |
+
$this->_utilPath = $this->getBaseDir() . DS . $path . DS . $os;
|
530 |
+
|
531 |
+
}
|
532 |
+
|
533 |
+
return $this->_utilPath;
|
534 |
+
}
|
535 |
+
|
536 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Helper/Utility.php
DELETED
@@ -1,149 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category Apptrian
|
4 |
-
* @package Apptrian_ImageOptimizer
|
5 |
-
* @author Apptrian
|
6 |
-
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Helper_Utility extends Mage_Core_Helper_Abstract {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Path to utilities.
|
13 |
-
*
|
14 |
-
* @var null|string
|
15 |
-
*/
|
16 |
-
protected $utilPath = null;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* extension (for win binaries)
|
20 |
-
*
|
21 |
-
* @var null|string
|
22 |
-
*/
|
23 |
-
protected $utilExt = null;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Checks if server OS is Windows
|
27 |
-
*
|
28 |
-
* @return bool
|
29 |
-
*/
|
30 |
-
protected function isWindows()
|
31 |
-
{
|
32 |
-
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
33 |
-
return true;
|
34 |
-
} else {
|
35 |
-
return false;
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Alias for getUtil() and .gif
|
41 |
-
*
|
42 |
-
* @param string $filePath
|
43 |
-
* @return string
|
44 |
-
*/
|
45 |
-
public function getGifUtil($filePath)
|
46 |
-
{
|
47 |
-
return $this->getUtil('gif', $filePath);
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Alias for getUtil() and .jpg
|
52 |
-
*
|
53 |
-
* @param string $filePath
|
54 |
-
* @return string
|
55 |
-
*/
|
56 |
-
public function getJpgUtil($filePath)
|
57 |
-
{
|
58 |
-
return $this->getUtil('jpg', $filePath);
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Alias for getUtil() and .png
|
63 |
-
*
|
64 |
-
* @param string $filePath
|
65 |
-
* @return string
|
66 |
-
*/
|
67 |
-
public function getPngUtil($filePath)
|
68 |
-
{
|
69 |
-
return $this->getUtil('png', $filePath);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Formats and returns the shell command string for an image optimization utility
|
74 |
-
*
|
75 |
-
* @param string $type - This is image type. Valid values gif|jpg|png
|
76 |
-
* @param string $filePath - Path to the image to be optimized
|
77 |
-
* @return string
|
78 |
-
*/
|
79 |
-
protected function getUtil($type, $filePath)
|
80 |
-
{
|
81 |
-
|
82 |
-
$exactPath = Mage::getConfig()->getNode('apptrian_imageoptimizer/utility/' . $type . '_path', 'default');
|
83 |
-
|
84 |
-
// If utility exact path is set use it
|
85 |
-
if ($exactPath != '') {
|
86 |
-
|
87 |
-
$cmd = $exactPath;
|
88 |
-
|
89 |
-
// Use path to extension's local utilities
|
90 |
-
} else {
|
91 |
-
|
92 |
-
$cmd = $this->getUtilPath() . DS . Mage::getConfig()->getNode('apptrian_imageoptimizer/utility/' . $type, 'default') . $this->getUtilExt();
|
93 |
-
|
94 |
-
}
|
95 |
-
|
96 |
-
$cmd .= ' ' . Mage::getConfig()->getNode('apptrian_imageoptimizer/utility/' . $type . '_options', 'default');
|
97 |
-
|
98 |
-
return str_replace('%filepath%', $filePath, $cmd);
|
99 |
-
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Gets and stores utility extension.
|
104 |
-
* Checks server OS and determine utility extension.
|
105 |
-
*
|
106 |
-
* @return string
|
107 |
-
*/
|
108 |
-
protected function getUtilExt()
|
109 |
-
{
|
110 |
-
if ($this->utilExt === null) {
|
111 |
-
|
112 |
-
$this->utilExt = $this->isWindows() ? '.exe' : '';
|
113 |
-
|
114 |
-
}
|
115 |
-
|
116 |
-
return $this->utilExt;
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Gets and stores path to utilities.
|
121 |
-
* Checks server OS and config to determine the path where image optimization utilities are.
|
122 |
-
*
|
123 |
-
* @return string
|
124 |
-
*/
|
125 |
-
protected function getUtilPath()
|
126 |
-
{
|
127 |
-
if ($this->utilPath === null) {
|
128 |
-
|
129 |
-
if ((int) Mage::getConfig()->getNode('apptrian_imageoptimizer/utility/use64bit', 'default')) {
|
130 |
-
$bit = '64';
|
131 |
-
} else {
|
132 |
-
$bit = '32';
|
133 |
-
}
|
134 |
-
|
135 |
-
$os = $this->isWindows() ? 'win' . $bit : 'elf' . $bit;
|
136 |
-
|
137 |
-
$pathString = trim(trim(Mage::getConfig()->getNode('apptrian_imageoptimizer/utility/path', 'default')), '/');
|
138 |
-
$dirs = explode('/', $pathString);
|
139 |
-
$path = implode(DS, $dirs);
|
140 |
-
|
141 |
-
$this->utilPath = Mage::getBaseDir() . DS . $path . DS . $os;
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
return $this->utilPath;
|
146 |
-
}
|
147 |
-
|
148 |
-
|
149 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Apptrian/ImageOptimizer/Model/Config/Batchsize.php
CHANGED
@@ -1,50 +1,51 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Model_Config_Batchsize
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$
|
32 |
-
$
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_Config_Batchsize
|
10 |
+
extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
|
13 |
+
public function _beforeSave()
|
14 |
+
{
|
15 |
+
|
16 |
+
$result = $this->validate();
|
17 |
+
|
18 |
+
if ($result !== true) {
|
19 |
+
|
20 |
+
Mage::throwException(implode("\n", $result));
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
return parent::_beforeSave();
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
public function validate()
|
29 |
+
{
|
30 |
+
|
31 |
+
$errors = array();
|
32 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
33 |
+
$value = $this->getValue();
|
34 |
+
|
35 |
+
if (!Zend_Validate::is($value, 'Digits')) {
|
36 |
+
$errors[] = $helper->__('Batch size must be an integer.');
|
37 |
+
}
|
38 |
+
|
39 |
+
if (!Zend_Validate::is($value, 'GreaterThan', array(0))) {
|
40 |
+
$errors[] = $helper->__('Batch size must be greater than 0.');
|
41 |
+
}
|
42 |
+
|
43 |
+
if (empty($errors)) {
|
44 |
+
return true;
|
45 |
+
}
|
46 |
+
|
47 |
+
return $errors;
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Model/Config/Cron.php
DELETED
@@ -1,68 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category Apptrian
|
4 |
-
* @package Apptrian_ImageOptimizer
|
5 |
-
* @author Apptrian
|
6 |
-
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Model_Config_Cron extends Mage_Core_Model_Config_Data
|
10 |
-
{
|
11 |
-
const CRON_STRING_PATH = 'crontab/jobs/apptrian_imageoptimizer_process/schedule/cron_expr';
|
12 |
-
|
13 |
-
protected function _afterSave()
|
14 |
-
{
|
15 |
-
|
16 |
-
$cronExprString = $this->getValue();
|
17 |
-
|
18 |
-
try {
|
19 |
-
|
20 |
-
Mage::getModel('core/config_data')
|
21 |
-
->load(self::CRON_STRING_PATH, 'path')
|
22 |
-
->setValue($cronExprString)
|
23 |
-
->setPath(self::CRON_STRING_PATH)
|
24 |
-
->save();
|
25 |
-
|
26 |
-
} catch (Exception $e) {
|
27 |
-
|
28 |
-
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
|
29 |
-
|
30 |
-
}
|
31 |
-
|
32 |
-
}
|
33 |
-
|
34 |
-
public function _beforeSave()
|
35 |
-
{
|
36 |
-
|
37 |
-
$result = $this->validate();
|
38 |
-
|
39 |
-
if ($result !== true) {
|
40 |
-
|
41 |
-
Mage::throwException(implode("\n", $result));
|
42 |
-
|
43 |
-
}
|
44 |
-
|
45 |
-
return parent::_beforeSave();
|
46 |
-
|
47 |
-
}
|
48 |
-
|
49 |
-
public function validate()
|
50 |
-
{
|
51 |
-
|
52 |
-
$errors = array();
|
53 |
-
$helper = Mage::helper('apptrian_imageoptimizer');
|
54 |
-
$value = $this->getValue();
|
55 |
-
|
56 |
-
if (!Zend_Validate::is($value, 'Regex', array('pattern' => '/^[0-9,\-\?\/\*\ ]+$/'))) {
|
57 |
-
$errors[] = $helper->__('Cron expression is invalid.');
|
58 |
-
}
|
59 |
-
|
60 |
-
if (empty($errors)) {
|
61 |
-
return true;
|
62 |
-
}
|
63 |
-
|
64 |
-
return $errors;
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Apptrian/ImageOptimizer/Model/Config/Cron/Optimize.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_Config_Cron_Optimize
|
10 |
+
extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
const CRON_STRING_PATH =
|
13 |
+
'crontab/jobs/apptrian_imageoptimizer_optimize/schedule/cron_expr';
|
14 |
+
|
15 |
+
protected function _afterSave()
|
16 |
+
{
|
17 |
+
|
18 |
+
$cronExprString = $this->getValue();
|
19 |
+
|
20 |
+
try {
|
21 |
+
|
22 |
+
Mage::getModel('core/config_data')
|
23 |
+
->load(self::CRON_STRING_PATH, 'path')
|
24 |
+
->setValue($cronExprString)
|
25 |
+
->setPath(self::CRON_STRING_PATH)
|
26 |
+
->save();
|
27 |
+
|
28 |
+
} catch (Exception $e) {
|
29 |
+
|
30 |
+
throw new Exception(
|
31 |
+
Mage::helper('cron')->__('Unable to save the cron expression.')
|
32 |
+
);
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
public function _beforeSave()
|
39 |
+
{
|
40 |
+
|
41 |
+
$result = $this->validate();
|
42 |
+
|
43 |
+
if ($result !== true) {
|
44 |
+
|
45 |
+
Mage::throwException(implode("\n", $result));
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
return parent::_beforeSave();
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
public function validate()
|
54 |
+
{
|
55 |
+
|
56 |
+
$errors = array();
|
57 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
58 |
+
$value = $this->getValue();
|
59 |
+
$validator = Zend_Validate::is(
|
60 |
+
$value, 'Regex', array('pattern' => '/^[0-9,\-\?\/\*\ ]+$/')
|
61 |
+
);
|
62 |
+
|
63 |
+
if (!$validator) {
|
64 |
+
$errors[] = $helper->__('Cron expression is invalid.');
|
65 |
+
}
|
66 |
+
|
67 |
+
if (empty($errors)) {
|
68 |
+
return true;
|
69 |
+
}
|
70 |
+
|
71 |
+
return $errors;
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Model/Config/Cron/Scan.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_Config_Cron_Scan
|
10 |
+
extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
const CRON_STRING_PATH =
|
13 |
+
'crontab/jobs/apptrian_imageoptimizer_scan/schedule/cron_expr';
|
14 |
+
|
15 |
+
protected function _afterSave()
|
16 |
+
{
|
17 |
+
|
18 |
+
$cronExprString = $this->getValue();
|
19 |
+
|
20 |
+
try {
|
21 |
+
|
22 |
+
Mage::getModel('core/config_data')
|
23 |
+
->load(self::CRON_STRING_PATH, 'path')
|
24 |
+
->setValue($cronExprString)
|
25 |
+
->setPath(self::CRON_STRING_PATH)
|
26 |
+
->save();
|
27 |
+
|
28 |
+
} catch (Exception $e) {
|
29 |
+
|
30 |
+
throw new Exception(
|
31 |
+
Mage::helper('cron')->__('Unable to save the cron expression.')
|
32 |
+
);
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
public function _beforeSave()
|
39 |
+
{
|
40 |
+
|
41 |
+
$result = $this->validate();
|
42 |
+
|
43 |
+
if ($result !== true) {
|
44 |
+
|
45 |
+
Mage::throwException(implode("\n", $result));
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
return parent::_beforeSave();
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
public function validate()
|
54 |
+
{
|
55 |
+
|
56 |
+
$errors = array();
|
57 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
58 |
+
$value = $this->getValue();
|
59 |
+
$validator = Zend_Validate::is(
|
60 |
+
$value, 'Regex', array('pattern' => '/^[0-9,\-\?\/\*\ ]+$/')
|
61 |
+
);
|
62 |
+
|
63 |
+
if (!$validator) {
|
64 |
+
$errors[] = $helper->__('Cron expression is invalid.');
|
65 |
+
}
|
66 |
+
|
67 |
+
if (empty($errors)) {
|
68 |
+
return true;
|
69 |
+
}
|
70 |
+
|
71 |
+
return $errors;
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Model/Config/Exactpath.php
CHANGED
@@ -1,46 +1,54 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Model_Config_Exactpath
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$
|
32 |
-
$
|
33 |
-
|
34 |
-
|
35 |
-
$
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_Config_Exactpath
|
10 |
+
extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
|
13 |
+
public function _beforeSave()
|
14 |
+
{
|
15 |
+
|
16 |
+
$result = $this->validate();
|
17 |
+
|
18 |
+
if ($result !== true) {
|
19 |
+
|
20 |
+
Mage::throwException(implode("\n", $result));
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
return parent::_beforeSave();
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
public function validate()
|
29 |
+
{
|
30 |
+
|
31 |
+
$errors = array();
|
32 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
33 |
+
$value = $this->getValue();
|
34 |
+
$validator = Zend_Validate::is(
|
35 |
+
$value, 'Regex',
|
36 |
+
array(
|
37 |
+
'pattern'=>'/^[\p{L}\p{N}_,;:!&#\+\*\$\?\|\'\.\-\ \/\\\\]*$/iu'
|
38 |
+
)
|
39 |
+
);
|
40 |
+
|
41 |
+
if (!$validator) {
|
42 |
+
$errors[] = $helper
|
43 |
+
->__('One or more of Utility Exact Path fields are invalid.');
|
44 |
+
}
|
45 |
+
|
46 |
+
if (empty($errors)) {
|
47 |
+
return true;
|
48 |
+
}
|
49 |
+
|
50 |
+
return $errors;
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Model/Config/Options.php
CHANGED
@@ -1,46 +1,54 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Model_Config_Options
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$
|
32 |
-
$
|
33 |
-
|
34 |
-
|
35 |
-
$
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_Config_Options
|
10 |
+
extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
|
13 |
+
public function _beforeSave()
|
14 |
+
{
|
15 |
+
|
16 |
+
$result = $this->validate();
|
17 |
+
|
18 |
+
if ($result !== true) {
|
19 |
+
|
20 |
+
Mage::throwException(implode("\n", $result));
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
return parent::_beforeSave();
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
public function validate()
|
29 |
+
{
|
30 |
+
|
31 |
+
$errors = array();
|
32 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
33 |
+
$value = $this->getValue();
|
34 |
+
$validator = Zend_Validate::is(
|
35 |
+
$value, 'Regex', array(
|
36 |
+
'pattern'
|
37 |
+
=>'/^[\p{L}\p{N}_,;:!%&#\<\>\=\+\*\$\?\|\'\.\-\ \/]+$/iu'
|
38 |
+
)
|
39 |
+
);
|
40 |
+
|
41 |
+
if (!$validator) {
|
42 |
+
$errors[] = $helper
|
43 |
+
->__('One or more of Utility Option fields are invalid.');
|
44 |
+
}
|
45 |
+
|
46 |
+
if (empty($errors)) {
|
47 |
+
return true;
|
48 |
+
}
|
49 |
+
|
50 |
+
return $errors;
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Model/Config/Path.php
CHANGED
@@ -1,46 +1,51 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Model_Config_Path
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$
|
32 |
-
$
|
33 |
-
|
34 |
-
|
35 |
-
$
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_Config_Path
|
10 |
+
extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
|
13 |
+
public function _beforeSave()
|
14 |
+
{
|
15 |
+
|
16 |
+
$result = $this->validate();
|
17 |
+
|
18 |
+
if ($result !== true) {
|
19 |
+
|
20 |
+
Mage::throwException(implode("\n", $result));
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
return parent::_beforeSave();
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
public function validate()
|
29 |
+
{
|
30 |
+
|
31 |
+
$errors = array();
|
32 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
33 |
+
$value = $this->getValue();
|
34 |
+
$validator = Zend_Validate::is(
|
35 |
+
$value, 'Regex',
|
36 |
+
array('pattern' => '/^[\p{L}\p{N}_,;:!&#\+\*\$\?\|\'\.\-\ \/]+$/iu')
|
37 |
+
);
|
38 |
+
|
39 |
+
if (!$validator) {
|
40 |
+
$errors[] = $helper->__('Utility Path is invalid.');
|
41 |
+
}
|
42 |
+
|
43 |
+
if (empty($errors)) {
|
44 |
+
return true;
|
45 |
+
}
|
46 |
+
|
47 |
+
return $errors;
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Model/Config/Paths.php
CHANGED
@@ -1,46 +1,51 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Model_Config_Paths
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$
|
32 |
-
$
|
33 |
-
|
34 |
-
|
35 |
-
$
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_Config_Paths
|
10 |
+
extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
|
13 |
+
public function _beforeSave()
|
14 |
+
{
|
15 |
+
|
16 |
+
$result = $this->validate();
|
17 |
+
|
18 |
+
if ($result !== true) {
|
19 |
+
|
20 |
+
Mage::throwException(implode("\n", $result));
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
return parent::_beforeSave();
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
public function validate()
|
29 |
+
{
|
30 |
+
|
31 |
+
$errors = array();
|
32 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
33 |
+
$value = $this->getValue();
|
34 |
+
$validator = Zend_Validate::is(
|
35 |
+
$value, 'Regex',
|
36 |
+
array('pattern' => '/^[\p{L}\p{N}_,;:!&#\+\*\$\?\|\'\.\-\ \/]+$/iu')
|
37 |
+
);
|
38 |
+
|
39 |
+
if (!$validator) {
|
40 |
+
$errors[] = $helper->__('Paths field is invalid.');
|
41 |
+
}
|
42 |
+
|
43 |
+
if (empty($errors)) {
|
44 |
+
return true;
|
45 |
+
}
|
46 |
+
|
47 |
+
return $errors;
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Model/Config/Permissions.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_Config_Permissions
|
10 |
+
extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
|
13 |
+
public function _beforeSave()
|
14 |
+
{
|
15 |
+
|
16 |
+
$result = $this->validate();
|
17 |
+
|
18 |
+
if ($result !== true) {
|
19 |
+
|
20 |
+
Mage::throwException(implode("\n", $result));
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
return parent::_beforeSave();
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
public function validate()
|
29 |
+
{
|
30 |
+
|
31 |
+
$errors = array();
|
32 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
33 |
+
$value = $this->getValue();
|
34 |
+
$validator = Zend_Validate::is(
|
35 |
+
$value, 'Regex',
|
36 |
+
array('pattern' => '/^[0-7]*$/')
|
37 |
+
);
|
38 |
+
|
39 |
+
if (!$validator) {
|
40 |
+
$errors[] = $helper->__('Force File Permissions field is invalid.');
|
41 |
+
}
|
42 |
+
|
43 |
+
if (empty($errors)) {
|
44 |
+
return true;
|
45 |
+
}
|
46 |
+
|
47 |
+
return $errors;
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Model/Config/Utility.php
CHANGED
@@ -1,46 +1,52 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Model_Config_Utility
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$
|
32 |
-
$
|
33 |
-
|
34 |
-
|
35 |
-
$
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_Config_Utility
|
10 |
+
extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
|
13 |
+
public function _beforeSave()
|
14 |
+
{
|
15 |
+
|
16 |
+
$result = $this->validate();
|
17 |
+
|
18 |
+
if ($result !== true) {
|
19 |
+
|
20 |
+
Mage::throwException(implode("\n", $result));
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
return parent::_beforeSave();
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
public function validate()
|
29 |
+
{
|
30 |
+
|
31 |
+
$errors = array();
|
32 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
33 |
+
$value = $this->getValue();
|
34 |
+
$validator = Zend_Validate::is(
|
35 |
+
$value, 'Regex',
|
36 |
+
array('pattern' => '/^[\p{L}\p{N}_,;:!&#\+\*\$\?\|\'\.\-\ \/]+$/iu')
|
37 |
+
);
|
38 |
+
|
39 |
+
if (!$validator) {
|
40 |
+
$errors[] = $helper
|
41 |
+
->__('One or more of Utility fields are invalid.');
|
42 |
+
}
|
43 |
+
|
44 |
+
if (empty($errors)) {
|
45 |
+
return true;
|
46 |
+
}
|
47 |
+
|
48 |
+
return $errors;
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Model/Cron.php
CHANGED
@@ -1,105 +1,97 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Model_Cron
|
10 |
-
{
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
$m->send();
|
99 |
-
} catch (Exception $e) {
|
100 |
-
// Do nothing
|
101 |
-
}
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_Cron
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Cron method for executing scan and reindex process.
|
14 |
+
*/
|
15 |
+
public function scan()
|
16 |
+
{
|
17 |
+
|
18 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
19 |
+
|
20 |
+
$extensionEnabled = (int) $helper->getConfig(
|
21 |
+
'apptrian_imageoptimizer/general/enabled'
|
22 |
+
);
|
23 |
+
|
24 |
+
$cronJobEnabled = (int) $helper->getConfig(
|
25 |
+
'apptrian_imageoptimizer/cron/enabled_scan'
|
26 |
+
);
|
27 |
+
|
28 |
+
if ($extensionEnabled && $cronJobEnabled) {
|
29 |
+
|
30 |
+
try {
|
31 |
+
|
32 |
+
$result = $helper->scanAndReindex();
|
33 |
+
|
34 |
+
if ($result !== true ) {
|
35 |
+
$mPrefix = 'Image Optimizer Cron: Scan and Reindex process';
|
36 |
+
Mage::log($mPrefix . ' failed.');
|
37 |
+
}
|
38 |
+
|
39 |
+
} catch (Exception $e) {
|
40 |
+
|
41 |
+
Mage::log($e);
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Cron method for executing optmization process.
|
51 |
+
*/
|
52 |
+
public function optimize()
|
53 |
+
{
|
54 |
+
|
55 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
56 |
+
|
57 |
+
$extensionEnabled = (int) $helper->getConfig(
|
58 |
+
'apptrian_imageoptimizer/general/enabled'
|
59 |
+
);
|
60 |
+
|
61 |
+
$cronJobEnabled = (int) $helper->getConfig(
|
62 |
+
'apptrian_imageoptimizer/cron/enabled_optimize'
|
63 |
+
);
|
64 |
+
|
65 |
+
if ($extensionEnabled && $cronJobEnabled) {
|
66 |
+
|
67 |
+
$mPrefix = 'Image Optimizer Cron: Optimization process ';
|
68 |
+
|
69 |
+
if ($helper->isExecFunctionEnabled()) {
|
70 |
+
|
71 |
+
try {
|
72 |
+
|
73 |
+
$result = $helper->optimize();
|
74 |
+
|
75 |
+
if ($result !== true ) {
|
76 |
+
Mage::log($mPrefix . 'failed.');
|
77 |
+
}
|
78 |
+
|
79 |
+
} catch (Exception $e) {
|
80 |
+
|
81 |
+
Mage::log($e);
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
} else {
|
86 |
+
|
87 |
+
Mage::log(
|
88 |
+
$mPrefix . 'failed because PHP exec() function is disabled.'
|
89 |
+
);
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
}
|
96 |
+
|
97 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Apptrian/ImageOptimizer/Model/File.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Model_File extends Mage_Core_Model_Abstract
|
10 |
-
{
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_File extends Mage_Core_Model_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
$this->_init('apptrian_imageoptimizer/file');
|
15 |
+
}
|
16 |
+
|
17 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Model/Resource/File.php
CHANGED
@@ -1,256 +1,264 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Model_Resource_File
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
*
|
20 |
-
*
|
21 |
-
*
|
22 |
-
* @
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
*
|
63 |
-
*
|
64 |
-
*
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_Resource_File
|
10 |
+
extends Mage_Core_Model_Resource_Db_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
protected function _construct()
|
14 |
+
{
|
15 |
+
$this->_init('apptrian_imageoptimizer/file', 'id');
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Adds entries to the db with one query.
|
20 |
+
* Used in scanAndReindex() method.
|
21 |
+
*
|
22 |
+
* @param array $files
|
23 |
+
* @return boolean
|
24 |
+
*/
|
25 |
+
public function addFiles($files)
|
26 |
+
{
|
27 |
+
|
28 |
+
if (count($files) > 0) {
|
29 |
+
|
30 |
+
$resource = Mage::getSingleton('core/resource');
|
31 |
+
$wConn = $resource->getConnection('core_write');
|
32 |
+
$table = $resource->getTableName('apptrian_imageoptimizer/file');
|
33 |
+
|
34 |
+
$query = 'INSERT INTO ' . $table . ' (`id`, `file_path`) VALUES ';
|
35 |
+
|
36 |
+
$values = '';
|
37 |
+
|
38 |
+
foreach ($files as $id => $path) {
|
39 |
+
$values .= '(' . $wConn->quote($id) . ', '
|
40 |
+
. $wConn->quote($path) . '),';
|
41 |
+
}
|
42 |
+
|
43 |
+
$query .= rtrim($values, ',') . ';';
|
44 |
+
|
45 |
+
try {
|
46 |
+
$wConn->query($query);
|
47 |
+
return true;
|
48 |
+
} catch (Exception $e) {
|
49 |
+
Mage::log($e);
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
|
53 |
+
} else {
|
54 |
+
|
55 |
+
return true;
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Updates db entries with new data using only one query.
|
63 |
+
* Used in optimize() method.
|
64 |
+
*
|
65 |
+
* @param array $files
|
66 |
+
* @return boolean
|
67 |
+
*/
|
68 |
+
public function updateFiles($files)
|
69 |
+
{
|
70 |
+
|
71 |
+
if (count($files) > 0) {
|
72 |
+
|
73 |
+
$resource = Mage::getSingleton('core/resource');
|
74 |
+
$wConn = $resource->getConnection('core_write');
|
75 |
+
$table = $resource->getTableName('apptrian_imageoptimizer/file');
|
76 |
+
|
77 |
+
$query = 'UPDATE ' . $table . ' SET';
|
78 |
+
|
79 |
+
$optimized = ' optimized = CASE id ';
|
80 |
+
$optimizationTime = ' optimization_time = CASE id ';
|
81 |
+
$oldFileSize = ' old_file_size = CASE id ';
|
82 |
+
$newFileSize = ' new_file_size = CASE id ';
|
83 |
+
|
84 |
+
$where = ' WHERE id IN (';
|
85 |
+
|
86 |
+
foreach ($files as $id => $f) {
|
87 |
+
|
88 |
+
$qId = $wConn->quote($id);
|
89 |
+
|
90 |
+
$optimized .= 'WHEN ' . $qId . ' THEN 1 ';
|
91 |
+
$optimizationTime .= 'WHEN ' . $qId . ' THEN '
|
92 |
+
. $f['optimization_time'] . ' ';
|
93 |
+
$oldFileSize .= 'WHEN ' . $qId . ' THEN '
|
94 |
+
. $f['old_file_size'] . ' ';
|
95 |
+
$newFileSize .= 'WHEN ' . $qId . ' THEN '
|
96 |
+
. $f['new_file_size'] . ' ';
|
97 |
+
|
98 |
+
$where .= $qId . ',';
|
99 |
+
|
100 |
+
}
|
101 |
+
|
102 |
+
$query .= $optimized . 'END,';
|
103 |
+
$query .= $optimizationTime . 'END,';
|
104 |
+
$query .= $oldFileSize . 'END,';
|
105 |
+
$query .= $newFileSize . 'END';
|
106 |
+
|
107 |
+
$query .= rtrim($where, ',') . ');';
|
108 |
+
|
109 |
+
try {
|
110 |
+
$wConn->query($query);
|
111 |
+
return true;
|
112 |
+
} catch (Exception $e) {
|
113 |
+
Mage::log($e);
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
|
117 |
+
} else {
|
118 |
+
|
119 |
+
return true;
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Updates "optimized" field in db with one query.
|
127 |
+
* Used in scanAndReindex() method.
|
128 |
+
*
|
129 |
+
* @param array $files
|
130 |
+
* @return boolean
|
131 |
+
*/
|
132 |
+
public function updateFilesOptimizedField($files)
|
133 |
+
{
|
134 |
+
|
135 |
+
if (count($files) > 0) {
|
136 |
+
|
137 |
+
$resource = Mage::getSingleton('core/resource');
|
138 |
+
$wConn = $resource->getConnection('core_write');
|
139 |
+
$table = $resource->getTableName('apptrian_imageoptimizer/file');
|
140 |
+
|
141 |
+
$query = 'UPDATE ' . $table . ' SET optimized = 0 WHERE id IN (';
|
142 |
+
|
143 |
+
$values = '';
|
144 |
+
|
145 |
+
foreach ($files as $id) {
|
146 |
+
$values .= $wConn->quote($id) . ',';
|
147 |
+
}
|
148 |
+
|
149 |
+
$query .= rtrim($values, ',') . ');';
|
150 |
+
|
151 |
+
try {
|
152 |
+
$wConn->query($query);
|
153 |
+
return true;
|
154 |
+
} catch (Exception $e) {
|
155 |
+
Mage::log($e);
|
156 |
+
return false;
|
157 |
+
}
|
158 |
+
|
159 |
+
} else {
|
160 |
+
|
161 |
+
return true;
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Deletes entries from db for files that do not exist anymore.
|
169 |
+
* Used in scanAndReindex() and optimize() methods.
|
170 |
+
*
|
171 |
+
* @param array $files
|
172 |
+
* @return boolean
|
173 |
+
*/
|
174 |
+
public function deleteFiles($files)
|
175 |
+
{
|
176 |
+
|
177 |
+
if (count($files) > 0) {
|
178 |
+
|
179 |
+
$resource = Mage::getSingleton('core/resource');
|
180 |
+
$wConn = $resource->getConnection('core_write');
|
181 |
+
$table = $resource->getTableName('apptrian_imageoptimizer/file');
|
182 |
+
|
183 |
+
$query = 'DELETE FROM ' . $table . ' WHERE id IN (';
|
184 |
+
|
185 |
+
$values = '';
|
186 |
+
|
187 |
+
foreach ($files as $id) {
|
188 |
+
$values .= $wConn->quote($id) . ',';
|
189 |
+
}
|
190 |
+
|
191 |
+
$query .= rtrim($values, ',') . ');';
|
192 |
+
|
193 |
+
try {
|
194 |
+
$wConn->query($query);
|
195 |
+
return true;
|
196 |
+
} catch (Exception $e) {
|
197 |
+
Mage::log($e);
|
198 |
+
return false;
|
199 |
+
}
|
200 |
+
|
201 |
+
} else {
|
202 |
+
|
203 |
+
return true;
|
204 |
+
|
205 |
+
}
|
206 |
+
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Returns entry count. If $optimized is provided returns count
|
211 |
+
* of optimized or not optimized files.
|
212 |
+
*
|
213 |
+
* @param int $optimized
|
214 |
+
* @return boolean
|
215 |
+
*/
|
216 |
+
public function getFileCount($optimized = null)
|
217 |
+
{
|
218 |
+
|
219 |
+
$resource = Mage::getSingleton('core/resource');
|
220 |
+
$rConn = $resource->getConnection('core_read');
|
221 |
+
$table = $resource->getTableName('apptrian_imageoptimizer/file');
|
222 |
+
|
223 |
+
$query = 'SELECT COUNT(id) FROM ' . $table;
|
224 |
+
|
225 |
+
if ($optimized !== null) {
|
226 |
+
$query .= ' WHERE optimized = ' . $optimized;
|
227 |
+
}
|
228 |
+
|
229 |
+
$query .= ';';
|
230 |
+
|
231 |
+
try {
|
232 |
+
return $rConn->fetchOne($query);
|
233 |
+
} catch (Exception $e) {
|
234 |
+
Mage::log($e);
|
235 |
+
return false;
|
236 |
+
}
|
237 |
+
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Clear index. (Empty db table apptrian_imageoptimizer_files)
|
242 |
+
*
|
243 |
+
* @return boolean
|
244 |
+
*/
|
245 |
+
public function clearIndex()
|
246 |
+
{
|
247 |
+
|
248 |
+
$resource = Mage::getSingleton('core/resource');
|
249 |
+
$wConn = $resource->getConnection('core_write');
|
250 |
+
$table = $resource->getTableName('apptrian_imageoptimizer/file');
|
251 |
+
|
252 |
+
$query = 'TRUNCATE ' . $table . ';';
|
253 |
+
|
254 |
+
try {
|
255 |
+
$wConn->query($query);
|
256 |
+
return true;
|
257 |
+
} catch (Exception $e) {
|
258 |
+
Mage::log($e);
|
259 |
+
return false;
|
260 |
+
}
|
261 |
+
|
262 |
+
}
|
263 |
+
|
264 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/Model/Resource/File/Collection.php
CHANGED
@@ -1,17 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
-
*/
|
9 |
-
class Apptrian_ImageOptimizer_Model_Resource_File_Collection
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
class Apptrian_ImageOptimizer_Model_Resource_File_Collection
|
10 |
+
extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
protected function _construct()
|
14 |
+
{
|
15 |
+
$this->_init('apptrian_imageoptimizer/file');
|
16 |
+
}
|
17 |
+
|
18 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/controllers/Adminhtml/Apptrian/ImgoptController.php
CHANGED
@@ -1,96 +1,129 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @category
|
4 |
-
* @package
|
5 |
-
* @author
|
6 |
-
* @copyright
|
7 |
-
* @license
|
8 |
*/
|
9 |
-
class Apptrian_ImageOptimizer_Adminhtml_Apptrian_ImgoptController
|
|
|
10 |
{
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
*/
|
9 |
+
class Apptrian_ImageOptimizer_Adminhtml_Apptrian_ImgoptController
|
10 |
+
extends Mage_Adminhtml_Controller_Action
|
11 |
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Check is allowed access to action
|
15 |
+
*
|
16 |
+
* @return bool
|
17 |
+
*/
|
18 |
+
protected function _isAllowed()
|
19 |
+
{
|
20 |
+
return Mage::getSingleton('admin/session')
|
21 |
+
->isAllowed('system/config/apptrian_imageoptimizer');
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Scan and reindex action.
|
26 |
+
*/
|
27 |
+
public function scanAction()
|
28 |
+
{
|
29 |
+
|
30 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
31 |
+
|
32 |
+
try {
|
33 |
+
|
34 |
+
$helper->scanAndReindex();
|
35 |
+
|
36 |
+
$message = $this
|
37 |
+
->__('Scan and reindex operations completed successfully.');
|
38 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
39 |
+
|
40 |
+
} catch (Exception $e) {
|
41 |
+
|
42 |
+
$message = $this->__('Scanning and reindexing failed.');
|
43 |
+
Mage::getSingleton('adminhtml/session')->addError($message);
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
49 |
+
'adminhtml/system_config/edit/section/apptrian_imageoptimizer'
|
50 |
+
);
|
51 |
+
Mage::app()->getResponse()->setRedirect($url);
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Optimize action.
|
57 |
+
*/
|
58 |
+
public function optimizeAction()
|
59 |
+
{
|
60 |
+
|
61 |
+
$helper = Mage::helper('apptrian_imageoptimizer');
|
62 |
+
|
63 |
+
if ($helper->isExecFunctionEnabled()) {
|
64 |
+
|
65 |
+
try {
|
66 |
+
|
67 |
+
$helper->optimize();
|
68 |
+
|
69 |
+
$message = $this
|
70 |
+
->__('Optimization operations completed successfully.');
|
71 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
72 |
+
|
73 |
+
} catch (Exception $e) {
|
74 |
+
|
75 |
+
$message = $this->__('Optimization failed.');
|
76 |
+
Mage::getSingleton('adminhtml/session')->addError($message);
|
77 |
+
Mage::getSingleton('adminhtml/session')
|
78 |
+
->addError($e->getMessage());
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
} else {
|
83 |
+
|
84 |
+
$message = $this->__(
|
85 |
+
'Optimization failed because PHP exec() function is disabled.'
|
86 |
+
);
|
87 |
+
Mage::getSingleton('adminhtml/session')->addError($message);
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
92 |
+
'adminhtml/system_config/edit/section/apptrian_imageoptimizer'
|
93 |
+
);
|
94 |
+
Mage::app()->getResponse()->setRedirect($url);
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Clear index action.
|
100 |
+
*/
|
101 |
+
public function clearAction()
|
102 |
+
{
|
103 |
+
|
104 |
+
$resource = Mage::getResourceModel('apptrian_imageoptimizer/file');
|
105 |
+
|
106 |
+
try {
|
107 |
+
|
108 |
+
$resource->clearIndex();
|
109 |
+
|
110 |
+
$message = $this
|
111 |
+
->__('Clear index operation completed successfully.');
|
112 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
113 |
+
|
114 |
+
} catch (Exception $e) {
|
115 |
+
|
116 |
+
$message = $this->__('Clear index operation failed.');
|
117 |
+
Mage::getSingleton('adminhtml/session')->addError($message);
|
118 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
123 |
+
'adminhtml/system_config/edit/section/apptrian_imageoptimizer'
|
124 |
+
);
|
125 |
+
Mage::app()->getResponse()->setRedirect($url);
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
}
|
app/code/community/Apptrian/ImageOptimizer/etc/config.xml
CHANGED
@@ -1,155 +1,159 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* @category
|
5 |
-
* @package
|
6 |
-
* @author
|
7 |
-
* @copyright
|
8 |
-
* @license
|
9 |
-
*/
|
10 |
-
-->
|
11 |
-
<config>
|
12 |
-
<modules>
|
13 |
-
<Apptrian_ImageOptimizer>
|
14 |
-
<version>
|
15 |
-
</Apptrian_ImageOptimizer>
|
16 |
-
</modules>
|
17 |
-
<global>
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
</entities>
|
30 |
-
|
31 |
-
|
32 |
-
<resources>
|
33 |
-
<apptrian_imageoptimizer_setup>
|
34 |
-
<setup>
|
35 |
-
<module>Apptrian_ImageOptimizer</module>
|
36 |
-
</setup>
|
37 |
-
<connection>
|
38 |
-
<use>core_setup</use>
|
39 |
-
</connection>
|
40 |
-
</apptrian_imageoptimizer_setup>
|
41 |
-
<apptrian_imageoptimizer_write>
|
42 |
-
<connection>
|
43 |
-
<use>core_write</use>
|
44 |
-
</connection>
|
45 |
-
</apptrian_imageoptimizer_write>
|
46 |
-
<apptrian_imageoptimizer_read>
|
47 |
-
<connection>
|
48 |
-
<use>core_read</use>
|
49 |
-
</connection>
|
50 |
-
</apptrian_imageoptimizer_read>
|
51 |
-
</resources>
|
52 |
-
<blocks>
|
53 |
-
<apptrian_imageoptimizer>
|
54 |
-
<class>Apptrian_ImageOptimizer_Block</class>
|
55 |
-
</apptrian_imageoptimizer>
|
56 |
-
</blocks>
|
57 |
-
<helpers>
|
58 |
-
<apptrian_imageoptimizer>
|
59 |
-
<class>Apptrian_ImageOptimizer_Helper</class>
|
60 |
-
</apptrian_imageoptimizer>
|
61 |
-
</helpers>
|
62 |
-
</global>
|
63 |
-
|
64 |
-
<apptrian_imageoptimizer>
|
65 |
-
<general>
|
66 |
-
<enabled>1</enabled>
|
67 |
-
<batch_size>50</batch_size>
|
68 |
-
<paths>media;skin/frontend</paths>
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
<
|
73 |
-
<
|
74 |
-
<
|
75 |
-
|
76 |
-
|
77 |
-
<
|
78 |
-
<
|
79 |
-
<
|
80 |
-
<
|
81 |
-
<
|
82 |
-
<
|
83 |
-
<
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
</
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Apptrian
|
5 |
+
* @package Apptrian_ImageOptimizer
|
6 |
+
* @author Apptrian
|
7 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<modules>
|
13 |
+
<Apptrian_ImageOptimizer>
|
14 |
+
<version>2.0.0</version>
|
15 |
+
</Apptrian_ImageOptimizer>
|
16 |
+
</modules>
|
17 |
+
<global>
|
18 |
+
<models>
|
19 |
+
<apptrian_imageoptimizer>
|
20 |
+
<class>Apptrian_ImageOptimizer_Model</class>
|
21 |
+
<resourceModel>apptrian_imageoptimizer_resource</resourceModel>
|
22 |
+
</apptrian_imageoptimizer>
|
23 |
+
<apptrian_imageoptimizer_resource>
|
24 |
+
<class>Apptrian_ImageOptimizer_Model_Resource</class>
|
25 |
+
<entities>
|
26 |
+
<file>
|
27 |
+
<table>apptrian_imageoptimizer_files</table>
|
28 |
+
</file>
|
29 |
+
</entities>
|
30 |
+
</apptrian_imageoptimizer_resource>
|
31 |
+
</models>
|
32 |
+
<resources>
|
33 |
+
<apptrian_imageoptimizer_setup>
|
34 |
+
<setup>
|
35 |
+
<module>Apptrian_ImageOptimizer</module>
|
36 |
+
</setup>
|
37 |
+
<connection>
|
38 |
+
<use>core_setup</use>
|
39 |
+
</connection>
|
40 |
+
</apptrian_imageoptimizer_setup>
|
41 |
+
<apptrian_imageoptimizer_write>
|
42 |
+
<connection>
|
43 |
+
<use>core_write</use>
|
44 |
+
</connection>
|
45 |
+
</apptrian_imageoptimizer_write>
|
46 |
+
<apptrian_imageoptimizer_read>
|
47 |
+
<connection>
|
48 |
+
<use>core_read</use>
|
49 |
+
</connection>
|
50 |
+
</apptrian_imageoptimizer_read>
|
51 |
+
</resources>
|
52 |
+
<blocks>
|
53 |
+
<apptrian_imageoptimizer>
|
54 |
+
<class>Apptrian_ImageOptimizer_Block</class>
|
55 |
+
</apptrian_imageoptimizer>
|
56 |
+
</blocks>
|
57 |
+
<helpers>
|
58 |
+
<apptrian_imageoptimizer>
|
59 |
+
<class>Apptrian_ImageOptimizer_Helper</class>
|
60 |
+
</apptrian_imageoptimizer>
|
61 |
+
</helpers>
|
62 |
+
</global>
|
63 |
+
<default>
|
64 |
+
<apptrian_imageoptimizer>
|
65 |
+
<general>
|
66 |
+
<enabled>1</enabled>
|
67 |
+
<batch_size>50</batch_size>
|
68 |
+
<paths>media;skin/frontend</paths>
|
69 |
+
</general>
|
70 |
+
<cron>
|
71 |
+
<enabled_scan>1</enabled_scan>
|
72 |
+
<expression_scan>15 4 * * *</expression_scan>
|
73 |
+
<enabled_optimize>1</enabled_optimize>
|
74 |
+
<expression_optimize>0 * * * *</expression_optimize>
|
75 |
+
</cron>
|
76 |
+
<utility>
|
77 |
+
<use64bit>0</use64bit>
|
78 |
+
<log_output>0</log_output>
|
79 |
+
<permissions></permissions>
|
80 |
+
<path>lib/apptrian/imageoptimizer</path>
|
81 |
+
<gif>gifsicle</gif>
|
82 |
+
<gif_path></gif_path>
|
83 |
+
<gif_options>-b -O3 %filepath%</gif_options>
|
84 |
+
<jpg>jpegtran</jpg>
|
85 |
+
<jpg_path></jpg_path>
|
86 |
+
<jpg_options>-copy none -optimize -progressive -outfile %filepath% %filepath%</jpg_options>
|
87 |
+
<png>optipng</png>
|
88 |
+
<png_path></png_path>
|
89 |
+
<png_options>-o7 -strip all %filepath%</png_options>
|
90 |
+
</utility>
|
91 |
+
</apptrian_imageoptimizer>
|
92 |
+
</default>
|
93 |
+
<admin>
|
94 |
+
<routers>
|
95 |
+
<adminhtml>
|
96 |
+
<args>
|
97 |
+
<modules>
|
98 |
+
<apptrian_imageoptimizer after="Mage_Adminhtml">Apptrian_ImageOptimizer_Adminhtml</apptrian_imageoptimizer>
|
99 |
+
</modules>
|
100 |
+
</args>
|
101 |
+
</adminhtml>
|
102 |
+
</routers>
|
103 |
+
</admin>
|
104 |
+
<adminhtml>
|
105 |
+
<acl>
|
106 |
+
<resources>
|
107 |
+
<admin>
|
108 |
+
<children>
|
109 |
+
<system>
|
110 |
+
<children>
|
111 |
+
<config>
|
112 |
+
<children>
|
113 |
+
<apptrian_info>
|
114 |
+
<title>Info</title>
|
115 |
+
</apptrian_info>
|
116 |
+
<apptrian_imageoptimizer>
|
117 |
+
<title>Image Optimizer</title>
|
118 |
+
</apptrian_imageoptimizer>
|
119 |
+
</children>
|
120 |
+
</config>
|
121 |
+
</children>
|
122 |
+
</system>
|
123 |
+
</children>
|
124 |
+
</admin>
|
125 |
+
</resources>
|
126 |
+
</acl>
|
127 |
+
<layout>
|
128 |
+
<updates>
|
129 |
+
<apptrian_imageoptimizer>
|
130 |
+
<file>apptrian_imageoptimizer.xml</file>
|
131 |
+
</apptrian_imageoptimizer>
|
132 |
+
</updates>
|
133 |
+
</layout>
|
134 |
+
<translate>
|
135 |
+
<modules>
|
136 |
+
<Apptrian_ImageOptimizer>
|
137 |
+
<files>
|
138 |
+
<default>Apptrian_ImageOptimizer.csv</default>
|
139 |
+
</files>
|
140 |
+
</Apptrian_ImageOptimizer>
|
141 |
+
</modules>
|
142 |
+
</translate>
|
143 |
+
</adminhtml>
|
144 |
+
<crontab>
|
145 |
+
<jobs>
|
146 |
+
<apptrian_imageoptimizer_scan>
|
147 |
+
<run>
|
148 |
+
<model>apptrian_imageoptimizer/cron::scan</model>
|
149 |
+
</run>
|
150 |
+
</apptrian_imageoptimizer_scan>
|
151 |
+
|
152 |
+
<apptrian_imageoptimizer_optimize>
|
153 |
+
<run>
|
154 |
+
<model>apptrian_imageoptimizer/cron::optimize</model>
|
155 |
+
</run>
|
156 |
+
</apptrian_imageoptimizer_optimize>
|
157 |
+
</jobs>
|
158 |
+
</crontab>
|
159 |
+
</config>
|
app/code/community/Apptrian/ImageOptimizer/etc/system.xml
CHANGED
@@ -1,379 +1,421 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* @category
|
5 |
-
* @package
|
6 |
-
* @author
|
7 |
-
* @copyright
|
8 |
-
* @license
|
9 |
-
*/
|
10 |
-
-->
|
11 |
-
<config>
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
<sections>
|
19 |
-
<apptrian_info translate="label">
|
20 |
-
<label>Info</label>
|
21 |
-
<tab>apptrian_extensions</tab>
|
22 |
-
<frontend_type>text</frontend_type>
|
23 |
-
<sort_order>1000000</sort_order>
|
24 |
-
<show_in_default>1</show_in_default>
|
25 |
-
<show_in_website>1</show_in_website>
|
26 |
-
<show_in_store>1</show_in_store>
|
27 |
-
<groups>
|
28 |
-
<info>
|
29 |
-
<frontend_model>apptrian_imageoptimizer/
|
30 |
-
<sort_order>1</sort_order>
|
31 |
-
<show_in_default>1</show_in_default>
|
32 |
-
<show_in_website>1</show_in_website>
|
33 |
-
<show_in_store>1</show_in_store>
|
34 |
-
</info>
|
35 |
-
</groups>
|
36 |
-
</apptrian_info>
|
37 |
-
<apptrian_imageoptimizer translate="label"
|
38 |
-
<label>Image Optimizer</label>
|
39 |
-
<tab>apptrian_extensions</tab>
|
40 |
-
<frontend_type>text</frontend_type>
|
41 |
-
<sort_order>1</sort_order>
|
42 |
-
<show_in_default>1</show_in_default>
|
43 |
-
<show_in_website>1</show_in_website>
|
44 |
-
<show_in_store>1</show_in_store>
|
45 |
-
<groups>
|
46 |
-
|
47 |
-
|
48 |
-
<
|
49 |
-
<
|
50 |
-
<
|
51 |
-
<
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
<
|
72 |
-
<label>
|
73 |
-
<frontend_type>
|
74 |
-
<
|
75 |
-
<
|
76 |
-
<
|
77 |
-
<
|
78 |
-
<
|
79 |
-
<
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
<
|
87 |
-
<
|
88 |
-
<
|
89 |
-
<
|
90 |
-
<
|
91 |
-
<
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
<
|
101 |
-
<
|
102 |
-
<
|
103 |
-
<
|
104 |
-
<
|
105 |
-
<
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
<
|
112 |
-
<
|
113 |
-
<
|
114 |
-
<
|
115 |
-
<
|
116 |
-
<
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
<
|
124 |
-
<
|
125 |
-
<
|
126 |
-
<
|
127 |
-
<
|
128 |
-
<
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
<
|
135 |
-
<
|
136 |
-
<
|
137 |
-
<
|
138 |
-
<
|
139 |
-
<
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
<
|
147 |
-
<
|
148 |
-
<
|
149 |
-
<
|
150 |
-
<
|
151 |
-
<
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
<
|
158 |
-
<
|
159 |
-
<
|
160 |
-
<
|
161 |
-
<
|
162 |
-
<
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
<
|
170 |
-
<
|
171 |
-
<
|
172 |
-
<
|
173 |
-
<
|
174 |
-
<
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
<
|
181 |
-
<
|
182 |
-
<
|
183 |
-
<
|
184 |
-
<
|
185 |
-
<
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
<
|
202 |
-
<label>
|
203 |
-
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
204 |
-
<sort_order>
|
205 |
-
<show_in_default>1</show_in_default>
|
206 |
-
<show_in_website>0</show_in_website>
|
207 |
-
<show_in_store>0</show_in_store>
|
208 |
-
|
209 |
-
|
210 |
-
</
|
211 |
-
|
212 |
-
|
213 |
-
<
|
214 |
-
<
|
215 |
-
<
|
216 |
-
<
|
217 |
-
<
|
218 |
-
|
219 |
-
|
220 |
-
<
|
221 |
-
<
|
222 |
-
<
|
223 |
-
|
224 |
-
</
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
<
|
238 |
-
<
|
239 |
-
<
|
240 |
-
<
|
241 |
-
<
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
<
|
246 |
-
<
|
247 |
-
<
|
248 |
-
<
|
249 |
-
<
|
250 |
-
<
|
251 |
-
<
|
252 |
-
<
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
<
|
269 |
-
<
|
270 |
-
<
|
271 |
-
<
|
272 |
-
<
|
273 |
-
<
|
274 |
-
</
|
275 |
-
<
|
276 |
-
<label>
|
277 |
-
<frontend_type>
|
278 |
-
<
|
279 |
-
<sort_order>
|
280 |
-
<show_in_default>1</show_in_default>
|
281 |
-
<show_in_website>0</show_in_website>
|
282 |
-
<show_in_store>0</show_in_store>
|
283 |
-
<comment>
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
<
|
288 |
-
<
|
289 |
-
<
|
290 |
-
<
|
291 |
-
<
|
292 |
-
<
|
293 |
-
<
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
<
|
299 |
-
<
|
300 |
-
<
|
301 |
-
<
|
302 |
-
<
|
303 |
-
<
|
304 |
-
<
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
<
|
310 |
-
<
|
311 |
-
<
|
312 |
-
<
|
313 |
-
<
|
314 |
-
<
|
315 |
-
<
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
<
|
321 |
-
<
|
322 |
-
<
|
323 |
-
<
|
324 |
-
<
|
325 |
-
<
|
326 |
-
<
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
<
|
332 |
-
<
|
333 |
-
<
|
334 |
-
<
|
335 |
-
<
|
336 |
-
<
|
337 |
-
<
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
<
|
343 |
-
<
|
344 |
-
<
|
345 |
-
<
|
346 |
-
<
|
347 |
-
<
|
348 |
-
<
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
<
|
354 |
-
<
|
355 |
-
<
|
356 |
-
<
|
357 |
-
<
|
358 |
-
<
|
359 |
-
<
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
<
|
365 |
-
<
|
366 |
-
<
|
367 |
-
<
|
368 |
-
<
|
369 |
-
<
|
370 |
-
<
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Apptrian
|
5 |
+
* @package Apptrian_ImageOptimizer
|
6 |
+
* @author Apptrian
|
7 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<tabs>
|
13 |
+
<apptrian_extensions>
|
14 |
+
<label>Apptrian Extensions</label>
|
15 |
+
<sort_order>100</sort_order>
|
16 |
+
</apptrian_extensions>
|
17 |
+
</tabs>
|
18 |
+
<sections>
|
19 |
+
<apptrian_info translate="label">
|
20 |
+
<label>Info</label>
|
21 |
+
<tab>apptrian_extensions</tab>
|
22 |
+
<frontend_type>text</frontend_type>
|
23 |
+
<sort_order>1000000</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
<show_in_website>1</show_in_website>
|
26 |
+
<show_in_store>1</show_in_store>
|
27 |
+
<groups>
|
28 |
+
<info>
|
29 |
+
<frontend_model>apptrian_imageoptimizer/adminhtml_info</frontend_model>
|
30 |
+
<sort_order>1</sort_order>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>1</show_in_website>
|
33 |
+
<show_in_store>1</show_in_store>
|
34 |
+
</info>
|
35 |
+
</groups>
|
36 |
+
</apptrian_info>
|
37 |
+
<apptrian_imageoptimizer translate="label">
|
38 |
+
<label>Image Optimizer</label>
|
39 |
+
<tab>apptrian_extensions</tab>
|
40 |
+
<frontend_type>text</frontend_type>
|
41 |
+
<sort_order>1</sort_order>
|
42 |
+
<show_in_default>1</show_in_default>
|
43 |
+
<show_in_website>1</show_in_website>
|
44 |
+
<show_in_store>1</show_in_store>
|
45 |
+
<groups>
|
46 |
+
<about>
|
47 |
+
<frontend_model>apptrian_imageoptimizer/adminhtml_about</frontend_model>
|
48 |
+
<sort_order>1</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>1</show_in_website>
|
51 |
+
<show_in_store>1</show_in_store>
|
52 |
+
</about>
|
53 |
+
<general translate="label">
|
54 |
+
<label>General</label>
|
55 |
+
<frontend_type>text</frontend_type>
|
56 |
+
<sort_order>2</sort_order>
|
57 |
+
<show_in_default>1</show_in_default>
|
58 |
+
<show_in_website>0</show_in_website>
|
59 |
+
<show_in_store>0</show_in_store>
|
60 |
+
<fields>
|
61 |
+
<enabled translate="label comment">
|
62 |
+
<label>Enabled</label>
|
63 |
+
<frontend_type>select</frontend_type>
|
64 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
65 |
+
<sort_order>1</sort_order>
|
66 |
+
<show_in_default>1</show_in_default>
|
67 |
+
<show_in_website>0</show_in_website>
|
68 |
+
<show_in_store>0</show_in_store>
|
69 |
+
<comment>Enables or disables extension.</comment>
|
70 |
+
</enabled>
|
71 |
+
<batch_size translate="label comment">
|
72 |
+
<label>Batch Size</label>
|
73 |
+
<frontend_type>text</frontend_type>
|
74 |
+
<validate>validate-digits validate-greater-than-zero</validate>
|
75 |
+
<backend_model>apptrian_imageoptimizer/config_batchsize</backend_model>
|
76 |
+
<sort_order>2</sort_order>
|
77 |
+
<show_in_default>1</show_in_default>
|
78 |
+
<show_in_website>0</show_in_website>
|
79 |
+
<show_in_store>0</show_in_store>
|
80 |
+
<comment>Number of images to be optimized per request.</comment>
|
81 |
+
<depends>
|
82 |
+
<enabled>1</enabled>
|
83 |
+
</depends>
|
84 |
+
</batch_size>
|
85 |
+
<paths translate="label comment tooltip">
|
86 |
+
<label>Paths</label>
|
87 |
+
<frontend_type>textarea</frontend_type>
|
88 |
+
<backend_model>apptrian_imageoptimizer/config_paths</backend_model>
|
89 |
+
<sort_order>3</sort_order>
|
90 |
+
<show_in_default>1</show_in_default>
|
91 |
+
<show_in_website>0</show_in_website>
|
92 |
+
<show_in_store>0</show_in_store>
|
93 |
+
<comment>Paths to be scanned for images.</comment>
|
94 |
+
<tooltip><![CDATA[Paths are relative to your Magento root directory.<br />Use "/" as directory separator.<br />Use ";" to separate paths.]]></tooltip>
|
95 |
+
<depends>
|
96 |
+
<enabled>1</enabled>
|
97 |
+
</depends>
|
98 |
+
</paths>
|
99 |
+
<heading_scan translate="label">
|
100 |
+
<label>1. Scan and Reindex</label>
|
101 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
102 |
+
<sort_order>4</sort_order>
|
103 |
+
<show_in_default>1</show_in_default>
|
104 |
+
<show_in_website>0</show_in_website>
|
105 |
+
<show_in_store>0</show_in_store>
|
106 |
+
<depends>
|
107 |
+
<enabled>1</enabled>
|
108 |
+
</depends>
|
109 |
+
</heading_scan>
|
110 |
+
<scan translate="label">
|
111 |
+
<label>Start Scan and Reindex Process</label>
|
112 |
+
<frontend_type>button</frontend_type>
|
113 |
+
<frontend_model>apptrian_imageoptimizer/adminhtml_button_scan</frontend_model>
|
114 |
+
<sort_order>5</sort_order>
|
115 |
+
<show_in_default>1</show_in_default>
|
116 |
+
<show_in_website>0</show_in_website>
|
117 |
+
<show_in_store>0</show_in_store>
|
118 |
+
<depends>
|
119 |
+
<enabled>1</enabled>
|
120 |
+
</depends>
|
121 |
+
</scan>
|
122 |
+
<heading_optimize translate="label">
|
123 |
+
<label>2. Optimize</label>
|
124 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
125 |
+
<sort_order>6</sort_order>
|
126 |
+
<show_in_default>1</show_in_default>
|
127 |
+
<show_in_website>0</show_in_website>
|
128 |
+
<show_in_store>0</show_in_store>
|
129 |
+
<depends>
|
130 |
+
<enabled>1</enabled>
|
131 |
+
</depends>
|
132 |
+
</heading_optimize>
|
133 |
+
<optimize translate="label">
|
134 |
+
<label>Start Optimization Process</label>
|
135 |
+
<frontend_type>button</frontend_type>
|
136 |
+
<frontend_model>apptrian_imageoptimizer/adminhtml_button_optimize</frontend_model>
|
137 |
+
<sort_order>7</sort_order>
|
138 |
+
<show_in_default>1</show_in_default>
|
139 |
+
<show_in_website>0</show_in_website>
|
140 |
+
<show_in_store>0</show_in_store>
|
141 |
+
<depends>
|
142 |
+
<enabled>1</enabled>
|
143 |
+
</depends>
|
144 |
+
</optimize>
|
145 |
+
<heading_stats translate="label">
|
146 |
+
<label>Progress Bar</label>
|
147 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
148 |
+
<sort_order>8</sort_order>
|
149 |
+
<show_in_default>1</show_in_default>
|
150 |
+
<show_in_website>0</show_in_website>
|
151 |
+
<show_in_store>0</show_in_store>
|
152 |
+
<depends>
|
153 |
+
<enabled>1</enabled>
|
154 |
+
</depends>
|
155 |
+
</heading_stats>
|
156 |
+
<stats translate="label">
|
157 |
+
<label>Bar on the right represents how many images are optimized.</label>
|
158 |
+
<frontend_model>apptrian_imageoptimizer/adminhtml_stats</frontend_model>
|
159 |
+
<sort_order>9</sort_order>
|
160 |
+
<show_in_default>1</show_in_default>
|
161 |
+
<show_in_website>0</show_in_website>
|
162 |
+
<show_in_store>0</show_in_store>
|
163 |
+
<tooltip><![CDATA[Every time you click "Start Optimization Process" (or cron job executes) depending on "Batch Size" value and number of indexed files, progress bar will move.<br />If progress bar does not move most likely reason is file permissions.<br /><strong>Utility binaries located in lib/apptrian/imageoptimizer must be executable which means you have to set right permissions on files inside this directory.</strong><br />If you are getting less than 100% despite you clicked "Start Optimization Process" button more than several times and the percentage is stuck to same value that means some of your files are corrupt. To find out which files are corrupt in "Utility" section for "Log Utility Output" select "Yes". Refresh your cache and click "Start Optimization Process" button again. After it is done you will find a list of corrupt files in<br />var/log/apptrian_imageoptimizer.log<br />You can inspect the log and fix the files yourself. Do not forget to set "Log Utility Output" back to "No".]]></tooltip>
|
164 |
+
<depends>
|
165 |
+
<enabled>1</enabled>
|
166 |
+
</depends>
|
167 |
+
</stats>
|
168 |
+
<heading_clear translate="label">
|
169 |
+
<label>Clear Index</label>
|
170 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
171 |
+
<sort_order>10</sort_order>
|
172 |
+
<show_in_default>1</show_in_default>
|
173 |
+
<show_in_website>0</show_in_website>
|
174 |
+
<show_in_store>0</show_in_store>
|
175 |
+
<depends>
|
176 |
+
<enabled>1</enabled>
|
177 |
+
</depends>
|
178 |
+
</heading_clear>
|
179 |
+
<clear translate="label">
|
180 |
+
<label>This resets above progress bar and you will have to index and optimize all images again.</label>
|
181 |
+
<frontend_type>button</frontend_type>
|
182 |
+
<frontend_model>apptrian_imageoptimizer/adminhtml_button_clear</frontend_model>
|
183 |
+
<sort_order>11</sort_order>
|
184 |
+
<show_in_default>1</show_in_default>
|
185 |
+
<show_in_website>0</show_in_website>
|
186 |
+
<show_in_store>0</show_in_store>
|
187 |
+
<depends>
|
188 |
+
<enabled>1</enabled>
|
189 |
+
</depends>
|
190 |
+
</clear>
|
191 |
+
</fields>
|
192 |
+
</general>
|
193 |
+
<cron translate="label">
|
194 |
+
<label>Cron</label>
|
195 |
+
<frontend_type>text</frontend_type>
|
196 |
+
<sort_order>3</sort_order>
|
197 |
+
<show_in_default>1</show_in_default>
|
198 |
+
<show_in_website>0</show_in_website>
|
199 |
+
<show_in_store>0</show_in_store>
|
200 |
+
<fields>
|
201 |
+
<heading_html translate="label">
|
202 |
+
<label>WARNING! Do not change any options! (Unless you know what you are doing.)</label>
|
203 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
204 |
+
<sort_order>1</sort_order>
|
205 |
+
<show_in_default>1</show_in_default>
|
206 |
+
<show_in_website>0</show_in_website>
|
207 |
+
<show_in_store>0</show_in_store>
|
208 |
+
</heading_html>
|
209 |
+
<enabled_scan translate="label comment">
|
210 |
+
<label>Enable Scan and Reindex Process Cron Job</label>
|
211 |
+
<frontend_type>select</frontend_type>
|
212 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
213 |
+
<sort_order>2</sort_order>
|
214 |
+
<show_in_default>1</show_in_default>
|
215 |
+
<show_in_website>0</show_in_website>
|
216 |
+
<show_in_store>0</show_in_store>
|
217 |
+
<comment>Enables or disables scan and reindex process cron job.</comment>
|
218 |
+
</enabled_scan>
|
219 |
+
<expression_scan translate="label comment tooltip">
|
220 |
+
<label>Cron Expression for Scan and Reindex Process</label>
|
221 |
+
<frontend_type>text</frontend_type>
|
222 |
+
<backend_model>apptrian_imageoptimizer/config_cron_scan</backend_model>
|
223 |
+
<sort_order>3</sort_order>
|
224 |
+
<show_in_default>1</show_in_default>
|
225 |
+
<show_in_website>0</show_in_website>
|
226 |
+
<show_in_store>0</show_in_store>
|
227 |
+
<comment><![CDATA[Cron expression used to trigger scan and reindex process. Example: 15 4 * * * (once a day at 4:15 AM)]]></comment>
|
228 |
+
<tooltip><![CDATA[Examples:<br />*/5 * * * * (every 5 minutes)<br />0,30 * * * * (twice an hour)<br />0 * * * * (once an hour)<br />0 0,12 * * * (twice a day)<br />0 0 * * * (once a day)<br />0 0 * * 0 (once a week)<br />0 0 1,15 * * (1st and 15th)<br />0 0 1 * * (once a month)<br />0 0 1 1 * (once a year)]]></tooltip>
|
229 |
+
<depends>
|
230 |
+
<enabled_scan>1</enabled_scan>
|
231 |
+
</depends>
|
232 |
+
</expression_scan>
|
233 |
+
<enabled_optimize translate="label comment">
|
234 |
+
<label>Enable Optimization Process Cron Job</label>
|
235 |
+
<frontend_type>select</frontend_type>
|
236 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
237 |
+
<sort_order>4</sort_order>
|
238 |
+
<show_in_default>1</show_in_default>
|
239 |
+
<show_in_website>0</show_in_website>
|
240 |
+
<show_in_store>0</show_in_store>
|
241 |
+
<comment>Enables or disables optimization process cron job.</comment>
|
242 |
+
</enabled_optimize>
|
243 |
+
<expression_optimize translate="label comment tooltip">
|
244 |
+
<label>Cron Expression for Optimization Process</label>
|
245 |
+
<frontend_type>text</frontend_type>
|
246 |
+
<backend_model>apptrian_imageoptimizer/config_cron_optimize</backend_model>
|
247 |
+
<sort_order>5</sort_order>
|
248 |
+
<show_in_default>1</show_in_default>
|
249 |
+
<show_in_website>0</show_in_website>
|
250 |
+
<show_in_store>0</show_in_store>
|
251 |
+
<comment><![CDATA[Cron expression used to trigger image optimization process. Example: 0 * * * * (once an hour)]]></comment>
|
252 |
+
<tooltip><![CDATA[Examples:<br />*/5 * * * * (every 5 minutes)<br />0,30 * * * * (twice an hour)<br />0 * * * * (once an hour)<br />0 0,12 * * * (twice a day)<br />0 0 * * * (once a day)<br />0 0 * * 0 (once a week)<br />0 0 1,15 * * (1st and 15th)<br />0 0 1 * * (once a month)<br />0 0 1 1 * (once a year)]]></tooltip>
|
253 |
+
<depends>
|
254 |
+
<enabled_optimize>1</enabled_optimize>
|
255 |
+
</depends>
|
256 |
+
</expression_optimize>
|
257 |
+
</fields>
|
258 |
+
</cron>
|
259 |
+
<utility translate="label">
|
260 |
+
<label>Utility</label>
|
261 |
+
<frontend_type>text</frontend_type>
|
262 |
+
<sort_order>4</sort_order>
|
263 |
+
<show_in_default>1</show_in_default>
|
264 |
+
<show_in_website>0</show_in_website>
|
265 |
+
<show_in_store>0</show_in_store>
|
266 |
+
<fields>
|
267 |
+
<heading_html translate="label">
|
268 |
+
<label>WARNING! Do not change any options! (Unless you know what you are doing.)</label>
|
269 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
270 |
+
<sort_order>1</sort_order>
|
271 |
+
<show_in_default>1</show_in_default>
|
272 |
+
<show_in_website>0</show_in_website>
|
273 |
+
<show_in_store>0</show_in_store>
|
274 |
+
</heading_html>
|
275 |
+
<use64bit translate="label comment">
|
276 |
+
<label>Use 64-bit Utilities</label>
|
277 |
+
<frontend_type>select</frontend_type>
|
278 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
279 |
+
<sort_order>2</sort_order>
|
280 |
+
<show_in_default>1</show_in_default>
|
281 |
+
<show_in_website>0</show_in_website>
|
282 |
+
<show_in_store>0</show_in_store>
|
283 |
+
<comment>Use only if your site is on 64-bit server.</comment>
|
284 |
+
</use64bit>
|
285 |
+
<log_output translate="label comment">
|
286 |
+
<label>Log Utility Output</label>
|
287 |
+
<frontend_type>select</frontend_type>
|
288 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
289 |
+
<sort_order>3</sort_order>
|
290 |
+
<show_in_default>1</show_in_default>
|
291 |
+
<show_in_website>0</show_in_website>
|
292 |
+
<show_in_store>0</show_in_store>
|
293 |
+
<comment>Log output information generated by utilities.</comment>
|
294 |
+
</log_output>
|
295 |
+
<permissions translate="label comment tooltip">
|
296 |
+
<label>Force File Permissions</label>
|
297 |
+
<frontend_type>text</frontend_type>
|
298 |
+
<backend_model>apptrian_imageoptimizer/config_permissions</backend_model>
|
299 |
+
<sort_order>4</sort_order>
|
300 |
+
<show_in_default>1</show_in_default>
|
301 |
+
<show_in_website>0</show_in_website>
|
302 |
+
<show_in_store>0</show_in_store>
|
303 |
+
<comment>Force file permissions after optimization. Example: 0644</comment>
|
304 |
+
<tooltip><![CDATA[Optimization utilities might change permissions of files they optimize (usually to 0644 or 0666). Use this option to force permissions you want. If you do not want to force file permission leave this field empty.]]></tooltip>
|
305 |
+
</permissions>
|
306 |
+
<path translate="label comment tooltip">
|
307 |
+
<label>Utilities Path</label>
|
308 |
+
<frontend_type>text</frontend_type>
|
309 |
+
<backend_model>apptrian_imageoptimizer/config_path</backend_model>
|
310 |
+
<sort_order>5</sort_order>
|
311 |
+
<show_in_default>1</show_in_default>
|
312 |
+
<show_in_website>0</show_in_website>
|
313 |
+
<show_in_store>0</show_in_store>
|
314 |
+
<comment>Path to optimization utilities.</comment>
|
315 |
+
<tooltip><![CDATA[Path is relative to your Magento root directory.<br />Use "/" as directory separator.<br />Inside this directory you must have following directories:<br /><strong>elf32</strong><br /><strong>elf64</strong><br /><strong>win32</strong><br /><strong>win64</strong><br /> Inside these directories put <strong>command line binaries</strong>.]]></tooltip>
|
316 |
+
</path>
|
317 |
+
<gif translate="label comment tooltip">
|
318 |
+
<label>GIF Utility</label>
|
319 |
+
<frontend_type>text</frontend_type>
|
320 |
+
<backend_model>apptrian_imageoptimizer/config_utility</backend_model>
|
321 |
+
<sort_order>6</sort_order>
|
322 |
+
<show_in_default>1</show_in_default>
|
323 |
+
<show_in_website>0</show_in_website>
|
324 |
+
<show_in_store>0</show_in_store>
|
325 |
+
<comment>Optimization utility for .gif files.</comment>
|
326 |
+
<tooltip><![CDATA[Do not include the .exe extension for Windows binaries.<br /><strong>Command line binaries only!</strong>]]></tooltip>
|
327 |
+
</gif>
|
328 |
+
<gif_path translate="label comment tooltip">
|
329 |
+
<label>GIF Utility Exact Path</label>
|
330 |
+
<frontend_type>text</frontend_type>
|
331 |
+
<backend_model>apptrian_imageoptimizer/config_exactpath</backend_model>
|
332 |
+
<sort_order>7</sort_order>
|
333 |
+
<show_in_default>1</show_in_default>
|
334 |
+
<show_in_website>0</show_in_website>
|
335 |
+
<show_in_store>0</show_in_store>
|
336 |
+
<comment>WARNING! Read the tooltip for more information.</comment>
|
337 |
+
<tooltip><![CDATA[If utility you want to use is already installed on your server, you can specify exact path to it. When generating command this exact path to utility will be used and then "Utility Options" will be appended to it. Example:<br/>/usr/bin/gifsicle<br/>If your utility is added to your system path (which means it is accessible from every directory) then type only utility executable filename. If you do not want to use this option leave this field empty. (Do not leave any white space characters.)]]></tooltip>
|
338 |
+
</gif_path>
|
339 |
+
<gif_options translate="label comment tooltip">
|
340 |
+
<label>GIF Utility Options</label>
|
341 |
+
<frontend_type>text</frontend_type>
|
342 |
+
<backend_model>apptrian_imageoptimizer/config_options</backend_model>
|
343 |
+
<sort_order>8</sort_order>
|
344 |
+
<show_in_default>1</show_in_default>
|
345 |
+
<show_in_website>0</show_in_website>
|
346 |
+
<show_in_store>0</show_in_store>
|
347 |
+
<comment>Options for optimization of .gif files.</comment>
|
348 |
+
<tooltip><![CDATA[The <strong>%filepath%</strong> will be substituted with image file path by the extension.]]></tooltip>
|
349 |
+
</gif_options>
|
350 |
+
<jpg translate="label comment tooltip">
|
351 |
+
<label>JPG Utility</label>
|
352 |
+
<frontend_type>text</frontend_type>
|
353 |
+
<backend_model>apptrian_imageoptimizer/config_utility</backend_model>
|
354 |
+
<sort_order>9</sort_order>
|
355 |
+
<show_in_default>1</show_in_default>
|
356 |
+
<show_in_website>0</show_in_website>
|
357 |
+
<show_in_store>0</show_in_store>
|
358 |
+
<comment>Optimization utility for .jpg files.</comment>
|
359 |
+
<tooltip><![CDATA[Do not include the .exe extension for Windows binaries.<br /><strong>Command line binaries only!</strong>]]></tooltip>
|
360 |
+
</jpg>
|
361 |
+
<jpg_path translate="label comment tooltip">
|
362 |
+
<label>JPG Utility Exact Path</label>
|
363 |
+
<frontend_type>text</frontend_type>
|
364 |
+
<backend_model>apptrian_imageoptimizer/config_exactpath</backend_model>
|
365 |
+
<sort_order>10</sort_order>
|
366 |
+
<show_in_default>1</show_in_default>
|
367 |
+
<show_in_website>0</show_in_website>
|
368 |
+
<show_in_store>0</show_in_store>
|
369 |
+
<comment>WARNING! Read the tooltip for more information.</comment>
|
370 |
+
<tooltip><![CDATA[If utility you want to use is already installed on your server, you can specify exact path to it. When generating command this exact path to utility will be used and then "Utility Options" will be appended to it. Example:<br/>/usr/bin/jpegtran<br/>If your utility is added to your system path (which means it is accessible from every directory) then type only utility executable filename. If you do not want to use this option leave this field empty. (Do not leave any white space characters.)]]></tooltip>
|
371 |
+
</jpg_path>
|
372 |
+
<jpg_options translate="label comment tooltip">
|
373 |
+
<label>JPG Utility Options</label>
|
374 |
+
<frontend_type>text</frontend_type>
|
375 |
+
<backend_model>apptrian_imageoptimizer/config_options</backend_model>
|
376 |
+
<sort_order>11</sort_order>
|
377 |
+
<show_in_default>1</show_in_default>
|
378 |
+
<show_in_website>0</show_in_website>
|
379 |
+
<show_in_store>0</show_in_store>
|
380 |
+
<comment>Options for optimization of .jpg files.</comment>
|
381 |
+
<tooltip><![CDATA[The <strong>%filepath%</strong> will be substituted with image file path by the extension.]]></tooltip>
|
382 |
+
</jpg_options>
|
383 |
+
<png translate="label comment tooltip">
|
384 |
+
<label>PNG Utility</label>
|
385 |
+
<frontend_type>text</frontend_type>
|
386 |
+
<backend_model>apptrian_imageoptimizer/config_utility</backend_model>
|
387 |
+
<sort_order>12</sort_order>
|
388 |
+
<show_in_default>1</show_in_default>
|
389 |
+
<show_in_website>0</show_in_website>
|
390 |
+
<show_in_store>0</show_in_store>
|
391 |
+
<comment>Optimization utility for .png files.</comment>
|
392 |
+
<tooltip><![CDATA[Do not include the .exe extension for Windows binaries.<br /><strong>Command line binaries only!</strong>]]></tooltip>
|
393 |
+
</png>
|
394 |
+
<png_path translate="label comment tooltip">
|
395 |
+
<label>PNG Utility Exact Path</label>
|
396 |
+
<frontend_type>text</frontend_type>
|
397 |
+
<backend_model>apptrian_imageoptimizer/config_exactpath</backend_model>
|
398 |
+
<sort_order>13</sort_order>
|
399 |
+
<show_in_default>1</show_in_default>
|
400 |
+
<show_in_website>0</show_in_website>
|
401 |
+
<show_in_store>0</show_in_store>
|
402 |
+
<comment>WARNING! Read the tooltip for more information.</comment>
|
403 |
+
<tooltip><![CDATA[If utility you want to use is already installed on your server, you can specify exact path to it. When generating command this exact path to utility will be used and then "Utility Options" will be appended to it. Example:<br/>/usr/bin/optipng<br/>If your utility is added to your system path (which means it is accessible from every directory) then type only utility executable filename. If you do not want to use this option leave this field empty. (Do not leave any white space characters.)]]></tooltip>
|
404 |
+
</png_path>
|
405 |
+
<png_options translate="label comment tooltip">
|
406 |
+
<label>PNG Utility Options</label>
|
407 |
+
<frontend_type>text</frontend_type>
|
408 |
+
<backend_model>apptrian_imageoptimizer/config_options</backend_model>
|
409 |
+
<sort_order>14</sort_order>
|
410 |
+
<show_in_default>1</show_in_default>
|
411 |
+
<show_in_website>0</show_in_website>
|
412 |
+
<show_in_store>0</show_in_store>
|
413 |
+
<comment>Options for optimization of .png files.</comment>
|
414 |
+
<tooltip><![CDATA[The <strong>%filepath%</strong> will be substituted with image file path by the extension.]]></tooltip>
|
415 |
+
</png_options>
|
416 |
+
</fields>
|
417 |
+
</utility>
|
418 |
+
</groups>
|
419 |
+
</apptrian_imageoptimizer>
|
420 |
+
</sections>
|
421 |
+
</config>
|
app/code/community/Apptrian/ImageOptimizer/sql/apptrian_imageoptimizer_setup/install-1.0.0.php
CHANGED
@@ -1,22 +1,31 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Apptrian
|
4 |
+
* @package Apptrian_ImageOptimizer
|
5 |
+
* @author Apptrian
|
6 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
8 |
+
*/
|
9 |
+
|
10 |
+
$installer = $this;
|
11 |
+
|
12 |
+
$installer->startSetup();
|
13 |
+
|
14 |
+
$installer->run(
|
15 |
+
"
|
16 |
+
|
17 |
+
-- DROP TABLE IF EXISTS {$this->getTable('apptrian_imageoptimizer/file')};
|
18 |
+
CREATE TABLE {$this->getTable('apptrian_imageoptimizer/file')} (
|
19 |
+
`id` varchar(32) NOT NULL default '',
|
20 |
+
`file_path` varchar(255) NOT NULL default '',
|
21 |
+
`optimized` tinyint(1) NOT NULL default '0',
|
22 |
+
`optimization_time` int(11) unsigned NOT NULL default '0',
|
23 |
+
`old_file_size` int(11) unsigned NOT NULL default '0',
|
24 |
+
`new_file_size` int(11) unsigned NOT NULL default '0',
|
25 |
+
PRIMARY KEY (`id`)
|
26 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
27 |
+
|
28 |
+
"
|
29 |
+
);
|
30 |
+
|
31 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/apptrian_imageoptimizer.xml
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* @category
|
5 |
-
* @package
|
6 |
-
* @author
|
7 |
-
* @copyright
|
8 |
-
* @license
|
9 |
-
*/
|
10 |
-
-->
|
11 |
-
<layout version="0.1.0">
|
12 |
-
<adminhtml_system_config_edit>
|
13 |
-
<reference name="head">
|
14 |
-
<action method="addItem" ifconfig="apptrian_imageoptimizer/general/enabled">
|
15 |
-
<type>skin_css</type>
|
16 |
-
<name>css/apptrian_imageoptimizer.css</name>
|
17 |
-
</action>
|
18 |
-
</reference>
|
19 |
-
</adminhtml_system_config_edit>
|
20 |
-
</layout>
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Apptrian
|
5 |
+
* @package Apptrian_ImageOptimizer
|
6 |
+
* @author Apptrian
|
7 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<layout version="0.1.0">
|
12 |
+
<adminhtml_system_config_edit>
|
13 |
+
<reference name="head">
|
14 |
+
<action method="addItem" ifconfig="apptrian_imageoptimizer/general/enabled">
|
15 |
+
<type>skin_css</type>
|
16 |
+
<name>css/apptrian_imageoptimizer.css</name>
|
17 |
+
</action>
|
18 |
+
</reference>
|
19 |
+
</adminhtml_system_config_edit>
|
20 |
+
</layout>
|
app/etc/modules/Apptrian_ImageOptimizer.xml
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* @category
|
5 |
-
* @package
|
6 |
-
* @author
|
7 |
-
* @copyright
|
8 |
-
* @license
|
9 |
-
*/
|
10 |
-
-->
|
11 |
-
<config>
|
12 |
-
<modules>
|
13 |
-
<Apptrian_ImageOptimizer>
|
14 |
-
<active>true</active>
|
15 |
-
<codePool>community</codePool>
|
16 |
-
<depends>
|
17 |
-
<Mage_Core />
|
18 |
-
</depends>
|
19 |
-
</Apptrian_ImageOptimizer>
|
20 |
-
</modules>
|
21 |
-
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Apptrian
|
5 |
+
* @package Apptrian_ImageOptimizer
|
6 |
+
* @author Apptrian
|
7 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<modules>
|
13 |
+
<Apptrian_ImageOptimizer>
|
14 |
+
<active>true</active>
|
15 |
+
<codePool>community</codePool>
|
16 |
+
<depends>
|
17 |
+
<Mage_Core />
|
18 |
+
</depends>
|
19 |
+
</Apptrian_ImageOptimizer>
|
20 |
+
</modules>
|
21 |
+
</config>
|
app/locale/en_US/Apptrian_ImageOptimizer.csv
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
-
"
|
|
|
2 |
"(%s of %s files)","(%s of %s files)"
|
3 |
"Batch size must be an integer.","Batch size must be an integer."
|
4 |
"Batch size must be greater than 0.","Batch size must be greater than 0."
|
@@ -8,18 +9,18 @@
|
|
8 |
"One or more of Utility Option fields are invalid.","One or more of Utility Option fields are invalid."
|
9 |
"Utility Path is invalid.","Utility Path is invalid."
|
10 |
"Paths field is invalid.","Paths field is invalid."
|
|
|
11 |
"One or more of Utility fields are invalid.","One or more of Utility fields are invalid."
|
12 |
"Scan and reindex operations completed successfully.","Scan and reindex operations completed successfully."
|
13 |
"Scanning and reindexing failed.","Scanning and reindexing failed."
|
14 |
"Optimization operations completed successfully.","Optimization operations completed successfully."
|
15 |
"Optimization failed.","Optimization failed."
|
16 |
"Optimization failed because PHP exec() function is disabled.","Optimization failed because PHP exec() function is disabled."
|
17 |
-
"
|
18 |
-
"
|
19 |
"Info","Info"
|
20 |
"Image Optimizer","Image Optimizer"
|
21 |
"Apptrian Extensions","Apptrian Extensions"
|
22 |
-
"About","About"
|
23 |
"General","General"
|
24 |
"Enabled","Enabled"
|
25 |
"Enables or disables extension.","Enables or disables extension."
|
@@ -36,16 +37,25 @@
|
|
36 |
"Bar on the right represents how many images are optimized.","Bar on the right represents how many images are optimized."
|
37 |
"Every time you click ""Start Optimization Process"" (or cron job executes) depending on ""Batch Size"" value and number of indexed files, progress bar will move.<br />If progress bar does not move most likely reason is file permissions.<br /><strong>Utility binaries located in lib/apptrian/imageoptimizer must be executable which means you have to set right permissions on files inside this directory.</strong><br />If you are getting less than 100% despite you clicked ""Start Optimization Process"" button more than several times and the percentage is stuck to same value that means some of your files are corrupt. To find out which files are corrupt in ""Utility"" section for ""Log Utility Output"" select ""Yes"". Refresh your cache and click ""Start Optimization Process"" button again. After it is done you will find a list of corrupt files in<br />var/log/apptrian_imageoptimizer.log<br />You can inspect the log and fix the files yourself. Do not forget to set ""Log Utility Output"" back to ""No"".","Every time you click ""Start Optimization Process"" (or cron job executes) depending on ""Batch Size"" value and number of indexed files, progress bar will move.<br />If progress bar does not move most likely reason is file permissions.<br /><strong>Utility binaries located in lib/apptrian/imageoptimizer must be executable which means you have to set right permissions on files inside this directory.</strong><br />If you are getting less than 100% despite you clicked ""Start Optimization Process"" button more than several times and the percentage is stuck to same value that means some of your files are corrupt. To find out which files are corrupt in ""Utility"" section for ""Log Utility Output"" select ""Yes"". Refresh your cache and click ""Start Optimization Process"" button again. After it is done you will find a list of corrupt files in<br />var/log/apptrian_imageoptimizer.log<br />You can inspect the log and fix the files yourself. Do not forget to set ""Log Utility Output"" back to ""No""."
|
38 |
"This resets above progress bar and you will have to index and optimize all images again.","This resets above progress bar and you will have to index and optimize all images again."
|
39 |
-
"Cron
|
40 |
-
"
|
41 |
-
"
|
|
|
|
|
|
|
42 |
"Examples:<br />*/5 * * * * (every 5 minutes)<br />0,30 * * * * (twice an hour)<br />0 * * * * (once an hour)<br />0 0,12 * * * (twice a day)<br />0 0 * * * (once a day)<br />0 0 * * 0 (once a week)<br />0 0 1,15 * * (1st and 15th)<br />0 0 1 * * (once a month)<br />0 0 1 1 * (once a year)","Examples:<br />*/5 * * * * (every 5 minutes)<br />0,30 * * * * (twice an hour)<br />0 * * * * (once an hour)<br />0 0,12 * * * (twice a day)<br />0 0 * * * (once a day)<br />0 0 * * 0 (once a week)<br />0 0 1,15 * * (1st and 15th)<br />0 0 1 * * (once a month)<br />0 0 1 1 * (once a year)"
|
|
|
|
|
|
|
|
|
43 |
"Utility","Utility"
|
44 |
-
"WARNING! Do not change any options! (Unless you know what you are doing.)","WARNING! Do not change any options! (Unless you know what you are doing.)"
|
45 |
"Use 64-bit Utilities","Use 64-bit Utilities"
|
46 |
"Use only if your site is on 64-bit server.","Use only if your site is on 64-bit server."
|
47 |
"Log Utility Output","Log Utility Output"
|
48 |
"Log output information generated by utilities.","Log output information generated by utilities."
|
|
|
|
|
|
|
49 |
"Utilities Path","Utilities Path"
|
50 |
"Path to optimization utilities.","Path to optimization utilities."
|
51 |
"Path is relative to your Magento root directory.<br />Use ""/"" as directory separator.<br />Inside this directory you must have following directories:<br /><strong>elf32</strong><br /><strong>elf64</strong><br /><strong>win32</strong><br /><strong>win64</strong><br /> Inside these directories put <strong>command line binaries</strong>.","Path is relative to your Magento root directory.<br />Use ""/"" as directory separator.<br />Inside this directory you must have following directories:<br /><strong>elf32</strong><br /><strong>elf64</strong><br /><strong>win32</strong><br /><strong>win64</strong><br /> Inside these directories put <strong>command line binaries</strong>."
|
1 |
+
"Clear Index","Clear Index"
|
2 |
+
"Are you sure you want to do this?","Are you sure you want to do this?"
|
3 |
"(%s of %s files)","(%s of %s files)"
|
4 |
"Batch size must be an integer.","Batch size must be an integer."
|
5 |
"Batch size must be greater than 0.","Batch size must be greater than 0."
|
9 |
"One or more of Utility Option fields are invalid.","One or more of Utility Option fields are invalid."
|
10 |
"Utility Path is invalid.","Utility Path is invalid."
|
11 |
"Paths field is invalid.","Paths field is invalid."
|
12 |
+
"Force File Permissions field is invalid.","Force File Permissions field is invalid."
|
13 |
"One or more of Utility fields are invalid.","One or more of Utility fields are invalid."
|
14 |
"Scan and reindex operations completed successfully.","Scan and reindex operations completed successfully."
|
15 |
"Scanning and reindexing failed.","Scanning and reindexing failed."
|
16 |
"Optimization operations completed successfully.","Optimization operations completed successfully."
|
17 |
"Optimization failed.","Optimization failed."
|
18 |
"Optimization failed because PHP exec() function is disabled.","Optimization failed because PHP exec() function is disabled."
|
19 |
+
"Clear index operation completed successfully.","Clear index operation completed successfully."
|
20 |
+
"Clear index operation failed.","Clear index operation failed."
|
21 |
"Info","Info"
|
22 |
"Image Optimizer","Image Optimizer"
|
23 |
"Apptrian Extensions","Apptrian Extensions"
|
|
|
24 |
"General","General"
|
25 |
"Enabled","Enabled"
|
26 |
"Enables or disables extension.","Enables or disables extension."
|
37 |
"Bar on the right represents how many images are optimized.","Bar on the right represents how many images are optimized."
|
38 |
"Every time you click ""Start Optimization Process"" (or cron job executes) depending on ""Batch Size"" value and number of indexed files, progress bar will move.<br />If progress bar does not move most likely reason is file permissions.<br /><strong>Utility binaries located in lib/apptrian/imageoptimizer must be executable which means you have to set right permissions on files inside this directory.</strong><br />If you are getting less than 100% despite you clicked ""Start Optimization Process"" button more than several times and the percentage is stuck to same value that means some of your files are corrupt. To find out which files are corrupt in ""Utility"" section for ""Log Utility Output"" select ""Yes"". Refresh your cache and click ""Start Optimization Process"" button again. After it is done you will find a list of corrupt files in<br />var/log/apptrian_imageoptimizer.log<br />You can inspect the log and fix the files yourself. Do not forget to set ""Log Utility Output"" back to ""No"".","Every time you click ""Start Optimization Process"" (or cron job executes) depending on ""Batch Size"" value and number of indexed files, progress bar will move.<br />If progress bar does not move most likely reason is file permissions.<br /><strong>Utility binaries located in lib/apptrian/imageoptimizer must be executable which means you have to set right permissions on files inside this directory.</strong><br />If you are getting less than 100% despite you clicked ""Start Optimization Process"" button more than several times and the percentage is stuck to same value that means some of your files are corrupt. To find out which files are corrupt in ""Utility"" section for ""Log Utility Output"" select ""Yes"". Refresh your cache and click ""Start Optimization Process"" button again. After it is done you will find a list of corrupt files in<br />var/log/apptrian_imageoptimizer.log<br />You can inspect the log and fix the files yourself. Do not forget to set ""Log Utility Output"" back to ""No""."
|
39 |
"This resets above progress bar and you will have to index and optimize all images again.","This resets above progress bar and you will have to index and optimize all images again."
|
40 |
+
"Cron","Cron"
|
41 |
+
"WARNING! Do not change any options! (Unless you know what you are doing.)","WARNING! Do not change any options! (Unless you know what you are doing.)"
|
42 |
+
"Enable Scan and Reindex Process Cron Job","Enable Scan and Reindex Process Cron Job"
|
43 |
+
"Enables or disables scan and reindex process cron job.","Enables or disables scan and reindex process cron job."
|
44 |
+
"Cron Expression for Scan and Reindex Process","Cron Expression for Scan and Reindex Process"
|
45 |
+
"Cron expression used to trigger scan and reindex process. Example: 15 4 * * * (once a day at 4:15 AM)","Cron expression used to trigger scan and reindex process. Example: 15 4 * * * (once a day at 4:15 AM)"
|
46 |
"Examples:<br />*/5 * * * * (every 5 minutes)<br />0,30 * * * * (twice an hour)<br />0 * * * * (once an hour)<br />0 0,12 * * * (twice a day)<br />0 0 * * * (once a day)<br />0 0 * * 0 (once a week)<br />0 0 1,15 * * (1st and 15th)<br />0 0 1 * * (once a month)<br />0 0 1 1 * (once a year)","Examples:<br />*/5 * * * * (every 5 minutes)<br />0,30 * * * * (twice an hour)<br />0 * * * * (once an hour)<br />0 0,12 * * * (twice a day)<br />0 0 * * * (once a day)<br />0 0 * * 0 (once a week)<br />0 0 1,15 * * (1st and 15th)<br />0 0 1 * * (once a month)<br />0 0 1 1 * (once a year)"
|
47 |
+
"Enable Optimization Process Cron Job","Enable Optimization Process Cron Job"
|
48 |
+
"Enables or disables optimization process cron job.","Enables or disables optimization process cron job."
|
49 |
+
"Cron Expression for Optimization Process","Cron Expression for Optimization Process"
|
50 |
+
"Cron expression used to trigger image optimization process. Example: 0 * * * * (once an hour)","Cron expression used to trigger image optimization process. Example: 0 * * * * (once an hour)"
|
51 |
"Utility","Utility"
|
|
|
52 |
"Use 64-bit Utilities","Use 64-bit Utilities"
|
53 |
"Use only if your site is on 64-bit server.","Use only if your site is on 64-bit server."
|
54 |
"Log Utility Output","Log Utility Output"
|
55 |
"Log output information generated by utilities.","Log output information generated by utilities."
|
56 |
+
"Force File Permissions","Force File Permissions"
|
57 |
+
"Force file permissions after optimization. Example: 0644","Force file permissions after optimization. Example: 0644"
|
58 |
+
"Optimization utilities might change permissions of files they optimize (usually to 0644 or 0666). Use this option to force permissions you want. If you do not want to force file permission leave this field empty.","Optimization utilities might change permissions of files they optimize (usually to 0644 or 0666). Use this option to force permissions you want. If you do not want to force file permission leave this field empty."
|
59 |
"Utilities Path","Utilities Path"
|
60 |
"Path to optimization utilities.","Path to optimization utilities."
|
61 |
"Path is relative to your Magento root directory.<br />Use ""/"" as directory separator.<br />Inside this directory you must have following directories:<br /><strong>elf32</strong><br /><strong>elf64</strong><br /><strong>win32</strong><br /><strong>win64</strong><br /> Inside these directories put <strong>command line binaries</strong>.","Path is relative to your Magento root directory.<br />Use ""/"" as directory separator.<br />Inside this directory you must have following directories:<br /><strong>elf32</strong><br /><strong>elf64</strong><br /><strong>win32</strong><br /><strong>win64</strong><br /> Inside these directories put <strong>command line binaries</strong>."
|
package.xml
CHANGED
@@ -1,21 +1,23 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Apptrian_Image_Optimizer</name>
|
4 |
-
<version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Optimize your images, reduce their file size without losing image quality and speed up your site.</summary>
|
10 |
-
<description>Apptrian Image Optimizer will optimize your images (GIF, JPG, PNG) reduce their file size without losing image quality and speed up your site. Extension is very easy to install and use. You can optimize images by clicking a button in Magento Admin or automatically by a configurable cron job. If you are an advanced user you will be pleased to know that extension is fully configurable. You can change optimization options even swap utilities used for optimization with the ones you like. (By default our extension is using optimization utilities recommended by Google.)</description>
|
11 |
-
<notes
|
12 |
-
*
|
13 |
-
* Fixed
|
14 |
-
*
|
|
|
|
|
15 |
<authors><author><name>Apptrian</name><user>apptrian</user><email>apptrian@yahoo.com</email></author></authors>
|
16 |
-
<date>2016-
|
17 |
-
<time>15:
|
18 |
-
<contents><target name="magecommunity"><dir name="Apptrian"><dir name="ImageOptimizer"><dir name="Block"><file name="About.php" hash="
|
19 |
<compatible/>
|
20 |
-
<dependencies><required><php><min>5.1.0</min><max>
|
21 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Apptrian_Image_Optimizer</name>
|
4 |
+
<version>2.0.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Optimize your images, reduce their file size without losing image quality and speed up your site.</summary>
|
10 |
+
<description>Apptrian Image Optimizer will optimize your images (GIF, JPG, PNG) reduce their file size without losing image quality and speed up your site. Extension is very easy to install and use. You can optimize images by clicking a button in Magento Admin or automatically by a configurable cron job. If you are an advanced user you will be pleased to know that extension is fully configurable. You can change optimization options even swap utilities used for optimization with the ones you like. (By default our extension is using optimization utilities recommended by Google PageSpeed Insights.)</description>
|
11 |
+
<notes>* Complete rewrite from the ground up
|
12 |
+
* Code standards improvements
|
13 |
+
* Fixed few small issues with admin blocks
|
14 |
+
* Empty Index is renamed to Clear Index including all block and methods
|
15 |
+
+ Added separate cron jobs, one for scanning one for optimization
|
16 |
+
+ Added option to force file permissions after optimization</notes>
|
17 |
<authors><author><name>Apptrian</name><user>apptrian</user><email>apptrian@yahoo.com</email></author></authors>
|
18 |
+
<date>2016-06-05</date>
|
19 |
+
<time>15:25:56</time>
|
20 |
+
<contents><target name="magecommunity"><dir name="Apptrian"><dir name="ImageOptimizer"><dir name="Block"><dir name="Adminhtml"><file name="About.php" hash="eea911933ee3ab8e57430398059828b2"/><dir name="Button"><file name="Clear.php" hash="1ee59b965300d3ca01a7ad51f82d7018"/><file name="Optimize.php" hash="5eab10e4709e7413bb470edb5c290302"/><file name="Scan.php" hash="df9f357ed3f7c27a1c8565a70ca9b74f"/></dir><file name="Info.php" hash="d96973cc7e45776c31ba39b8033159ae"/><file name="Stats.php" hash="6684beb43742aa42e52001e6f88787d8"/></dir></dir><dir name="Helper"><file name="Data.php" hash="0aeeff386d83a7182d110f92e0a0a52d"/></dir><dir name="Model"><dir name="Config"><file name="Batchsize.php" hash="1c72c04544d2444947566ebfa0b0bb4e"/><dir name="Cron"><file name="Optimize.php" hash="a7a1789cf3e8423379d0af4459290380"/><file name="Scan.php" hash="a9c2b3e81fce940a450f953fe19f6da2"/></dir><file name="Exactpath.php" hash="8e5efc5c70d852ee13f600ddd664c301"/><file name="Options.php" hash="7e372a49281ca73c8776aa386562a46e"/><file name="Path.php" hash="a0f04a0b84a6cc0cb455cbc698528bdc"/><file name="Paths.php" hash="85ce5ba99b9cfd253f78fff04e5db54a"/><file name="Permissions.php" hash="e10189c1eb5db46e14a9117582edd7fe"/><file name="Utility.php" hash="df8dbc1337bd53a84edf14acaea749dd"/></dir><file name="Cron.php" hash="ae7e2cf31b16408ffd79226bc1d154a7"/><file name="File.php" hash="aee110649c479fdb2aac2c69b416d07f"/><dir name="Resource"><dir name="File"><file name="Collection.php" hash="71f8258d0ce5c0b312ceb4f27a0aa2fd"/></dir><file name="File.php" hash="d8776a94bc47b8a577b05a0575c84a4e"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Apptrian"><file name="ImgoptController.php" hash="19cd9e95165517650f9f3bc64ace712c"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="7be1811a64c14bacb4e24da25a9aee1f"/><file name="system.xml" hash="251f1c2fbdeb0eccce05e8cf49c581c3"/></dir><dir name="sql"><dir name="apptrian_imageoptimizer_setup"><file name="install-1.0.0.php" hash="9b209f56fbda15ec59c2ef0e8332c2f6"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="apptrian_imageoptimizer.xml" hash="19f08ad048141ae01ee915faa655d1dd"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apptrian_ImageOptimizer.xml" hash="d087a739b0b4a182b7efa4f5037b4e48"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Apptrian_ImageOptimizer.csv" hash="14061fbdc4cbdf7c729ce83458dff5b8"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><file name="apptrian_imageoptimizer.css" hash="0f904cb2116423d1dfd626cfa8cfe39a"/></dir></dir></dir></dir></target><target name="magelib"><dir name="apptrian"><dir name="imageoptimizer"><dir name="elf32"><file name="gifsicle" hash="2583e5ceecf67a058fba2858986bb37f"/><file name="jpegoptim" hash="8a035613dd1a9467e5fe47c88a774104"/><file name="jpegtran" hash="fcef276e1f6b99d42d60abe373f37018"/><file name="optipng" hash="fb1334c73c7a91858a1816b05bfa3133"/></dir><dir name="elf64"><file name="gifsicle" hash="13adc57a621501a27a19443cb587ab2b"/><file name="jpegoptim" hash="8a035613dd1a9467e5fe47c88a774104"/><file name="jpegtran" hash="e6da2f02ac13237f7a8d91f0268ecf85"/><file name="optipng" hash="8fbf61c7e24f90128bbc138ddb671201"/></dir><dir name="win32"><file name="gifsicle.exe" hash="574a9274bbd4aec6a905b64b7da79617"/><file name="jpegoptim.exe" hash="cb4fa736e8b60aebfebff583d0ea6f34"/><file name="jpegtran.exe" hash="2ed29cb5dfb19ad21f3ba3d215f2453e"/><file name="libjpeg-62.dll" hash="48c64a6097bfbe8ca8eaa61ad7936aec"/><file name="optipng.exe" hash="e3d154829ea57a0bdd88b080f6851265"/></dir><dir name="win64"><file name="gifsicle.exe" hash="c7fe0fc6744a4e5303f8d924ee08a8d3"/><file name="jpegoptim.exe" hash="cb4fa736e8b60aebfebff583d0ea6f34"/><file name="jpegtran.exe" hash="dd709e653791c5a9ece818440f0ca089"/><file name="libjpeg-62.dll" hash="b4e05a1406a617e14b2ce7f6c28f382e"/><file name="optipng.exe" hash="e3d154829ea57a0bdd88b080f6851265"/></dir></dir></dir></target></contents>
|
21 |
<compatible/>
|
22 |
+
<dependencies><required><php><min>5.1.0</min><max>8.0.0</max></php></required></dependencies>
|
23 |
</package>
|
skin/adminhtml/default/default/css/apptrian_imageoptimizer.css
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
/*!
|
2 |
-
* @category
|
3 |
-
* @package
|
4 |
-
* @author
|
5 |
-
* @copyright
|
6 |
-
* @license
|
7 |
*/
|
8 |
|
9 |
.apptrian-imageoptimizer-bar-wrapper {
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
}
|
14 |
-
|
15 |
.apptrian-imageoptimizer-bar-outer {
|
16 |
-
|
17 |
background: #eee;
|
18 |
height: 2em;
|
19 |
border: 1px solid #ccc;
|
@@ -24,13 +24,13 @@
|
|
24 |
height: 2em;
|
25 |
border-radius: 4px;
|
26 |
background: rgb(210,255,82);
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
}
|
35 |
|
36 |
.apptrian-imageoptimizer-bar-text {
|
@@ -43,6 +43,6 @@
|
|
43 |
}
|
44 |
|
45 |
.apptrian-imageoptimizer-bar-text span {
|
46 |
-
|
47 |
-
|
48 |
}
|
1 |
/*!
|
2 |
+
* @category Apptrian
|
3 |
+
* @package Apptrian_ImageOptimizer
|
4 |
+
* @author Apptrian
|
5 |
+
* @copyright Copyright (c) 2016 Apptrian (http://www.apptrian.com)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
7 |
*/
|
8 |
|
9 |
.apptrian-imageoptimizer-bar-wrapper {
|
10 |
+
display: inline-block;
|
11 |
+
width: 90%;
|
12 |
+
margin: .4em .4em -0.7em 0;
|
13 |
}
|
14 |
+
|
15 |
.apptrian-imageoptimizer-bar-outer {
|
16 |
+
position: relative;
|
17 |
background: #eee;
|
18 |
height: 2em;
|
19 |
border: 1px solid #ccc;
|
24 |
height: 2em;
|
25 |
border-radius: 4px;
|
26 |
background: rgb(210,255,82);
|
27 |
+
background: -moz-linear-gradient(top, rgba(210,255,82,1) 0%, rgba(145,232,66,1) 100%);
|
28 |
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(210,255,82,1)), color-stop(100%,rgba(145,232,66,1)));
|
29 |
+
background: -webkit-linear-gradient(top, rgba(210,255,82,1) 0%,rgba(145,232,66,1) 100%);
|
30 |
+
background: -o-linear-gradient(top, rgba(210,255,82,1) 0%,rgba(145,232,66,1) 100%);
|
31 |
+
background: -ms-linear-gradient(top, rgba(210,255,82,1) 0%,rgba(145,232,66,1) 100%);
|
32 |
+
background: linear-gradient(to bottom, rgba(210,255,82,1) 0%,rgba(145,232,66,1) 100%);
|
33 |
+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d2ff52', endColorstr='#91e842',GradientType=0 );
|
34 |
}
|
35 |
|
36 |
.apptrian-imageoptimizer-bar-text {
|
43 |
}
|
44 |
|
45 |
.apptrian-imageoptimizer-bar-text span {
|
46 |
+
line-height: 2em;
|
47 |
+
vertical-align: middle;
|
48 |
}
|