Version Notes
Server Load Monitor
Download this release
Release Info
Developer | Aitoc |
Extension | ServerLoadMonitorFree |
Version | 1.0.9 |
Comparing to | |
See all releases |
Code changes from version 1.1.0 to 1.0.9
- Server Load Monitor Manual.pdf +0 -0
- app/code/community/Aitoc/Aitinstall/Helper/Data.php +63 -0
- app/code/community/Aitoc/Aitinstall/etc/config.xml +27 -0
- app/code/community/Aitoc/Aitsys/Abstract/Adminhtml/Block.php +23 -0
- app/code/community/Aitoc/Aitsys/Abstract/Adminhtml/Controller.php +17 -0
- app/code/community/Aitoc/Aitsys/Abstract/Block.php +15 -0
- app/code/community/Aitoc/Aitsys/Abstract/Helper.php +23 -0
- app/code/community/Aitoc/Aitsys/Abstract/Model.php +53 -0
- app/code/community/Aitoc/Aitsys/Abstract/Model/Interface.php +12 -0
- app/code/community/Aitoc/Aitsys/Abstract/Mysql4.php +15 -0
- app/code/community/Aitoc/Aitsys/Abstract/Mysql4/Collection.php +16 -0
- app/code/community/Aitoc/Aitsys/Abstract/Pure.php +31 -0
- app/code/community/Aitoc/Aitsys/Abstract/Resource/Eav/Setup.php +16 -0
- app/code/community/Aitoc/Aitsys/Abstract/Resource/Setup.php +16 -0
- app/code/community/Aitoc/Aitsys/Abstract/Service.php +339 -0
- app/code/community/Aitoc/Aitsys/Abstract/Version.php +143 -0
- app/code/community/Aitoc/Aitsys/Block/Edit.php +127 -0
- app/code/community/Aitoc/Aitsys/Block/Form.php +122 -0
- app/code/community/Aitoc/Aitsys/Block/Form/Element/Renderer.php +19 -0
- app/code/community/Aitoc/Aitsys/Block/News.php +23 -0
- app/code/community/Aitoc/Aitsys/Block/Patch/Instruction.php +50 -0
- app/code/community/Aitoc/Aitsys/Block/Patch/Instruction/One.php +309 -0
- app/code/community/Aitoc/Aitsys/Block/Patch/View.php +81 -0
- app/code/community/Aitoc/Aitsys/Block/Rewriter/List.php +278 -0
- app/code/community/Aitoc/Aitsys/Block/Rewriter/Notifications.php +41 -0
- app/code/community/Aitoc/Aitsys/Block/System/Config/Frontend/Extensions.php +13 -0
- app/code/community/Aitoc/Aitsys/Helper/Data.php +122 -0
- app/code/community/Aitoc/Aitsys/Helper/License.php +9 -0
- app/code/community/Aitoc/Aitsys/Helper/Rewriter.php +139 -0
- app/code/community/Aitoc/Aitsys/Helper/Statistics.php +19 -0
- app/code/community/Aitoc/Aitsys/Helper/Strings.php +52 -0
- app/code/community/Aitoc/Aitsys/Model/Aitfilepatcher.php +504 -0
- app/code/community/Aitoc/Aitsys/Model/Aitpatch.php +195 -0
- app/code/community/Aitoc/Aitsys/Model/Aitpatch/Observer.php +82 -0
- app/code/community/Aitoc/Aitsys/Model/Aitsys.php +909 -0
- app/code/community/Aitoc/Aitsys/Model/Core/Cache.php +110 -0
- app/code/community/Aitoc/Aitsys/Model/Core/Compiler/Process.php +60 -0
- app/code/community/Aitoc/Aitsys/Model/Core/Compiler/Rules.php +195 -0
- app/code/community/Aitoc/Aitsys/Model/Core/Database.php +186 -0
- app/code/community/Aitoc/Aitsys/Model/Core/Filesystem.php +624 -0
- app/code/community/Aitoc/Aitsys/Model/Core/Filesystem/Exception.php +7 -0
- app/code/community/Aitoc/Aitsys/Model/Feed.php +112 -0
- app/code/community/Aitoc/Aitsys/Model/Module.php +324 -0
- app/code/community/Aitoc/Aitsys/Model/Module/Abstract.php +161 -0
- app/code/community/Aitoc/Aitsys/Model/Module/Info/Abstract.php +155 -0
- app/code/community/Aitoc/Aitsys/Model/Module/Info/Config.php +43 -0
- app/code/community/Aitoc/Aitsys/Model/Module/Info/Exception.php +7 -0
- app/code/community/Aitoc/Aitsys/Model/Module/Info/Factory.php +52 -0
- app/code/community/Aitoc/Aitsys/Model/Module/Info/Fallback.php +35 -0
- app/code/community/Aitoc/Aitsys/Model/Module/Info/Package.php +51 -0
- app/code/community/Aitoc/Aitsys/Model/Module/Info/Xml/Abstract.php +48 -0
- app/code/community/Aitoc/Aitsys/Model/Module/Install.php +68 -0
- app/code/community/Aitoc/Aitsys/Model/Module/Status.php +71 -0
- app/code/community/Aitoc/Aitsys/Model/Mysql4/Module/Status.php +11 -0
- app/code/community/Aitoc/Aitsys/Model/Mysql4/Module/Status/Collection.php +24 -0
- app/code/community/Aitoc/Aitsys/Model/Mysql4/News.php +39 -0
- app/code/community/Aitoc/Aitsys/Model/Mysql4/News/Collection.php +21 -0
- app/code/community/Aitoc/Aitsys/Model/Mysql4/Setup.php +354 -0
- app/code/community/Aitoc/Aitsys/Model/News.php +19 -0
- app/code/community/Aitoc/Aitsys/Model/News/Important.php +45 -0
- app/code/community/Aitoc/Aitsys/Model/News/Recent.php +149 -0
- app/code/community/Aitoc/Aitsys/Model/Observer.php +81 -0
- app/code/community/Aitoc/Aitsys/Model/Platform.php +378 -0
- app/code/community/Aitoc/Aitsys/Model/Rewriter.php +82 -0
- app/code/community/Aitoc/Aitsys/Model/Rewriter/Abstract.php +38 -0
- app/code/community/Aitoc/Aitsys/Model/Rewriter/Autoload.php +165 -0
- app/code/community/Aitoc/Aitsys/Model/Rewriter/Class.php +178 -0
- app/code/community/Aitoc/Aitsys/Model/Rewriter/Config.php +46 -0
- app/code/community/Aitoc/Aitsys/Model/Rewriter/Conflict.php +263 -0
- app/code/community/Aitoc/Aitsys/Model/Rewriter/Inheritance.php +286 -0
- app/code/community/Aitoc/Aitsys/Model/Rewriter/MageConfig.php +67 -0
- app/code/community/Aitoc/Aitsys/Model/Rewriter/Merge.php +124 -0
- app/code/community/Aitoc/Aitsys/Model/Rewriter/Observer.php +62 -0
- app/code/community/Aitoc/Aitsys/Model/Service.php +207 -0
- app/code/community/Aitoc/Aitsys/Model/Service/Exception.php +16 -0
- app/code/community/Aitoc/Aitsys/Model/System/Config/Backend/Stores.php +27 -0
- app/code/community/Aitoc/Aitsys/Model/System/Config/Source/Interest.php +34 -0
- app/code/community/Aitoc/Aitsys/Model/System/Config/Source/Stores.php +26 -0
- app/code/community/Aitoc/Aitsys/controllers/IndexController.php +63 -0
- app/code/community/Aitoc/Aitsys/controllers/PatchController.php +29 -0
- app/code/community/Aitoc/Aitsys/controllers/RewriterController.php +109 -0
- app/code/community/Aitoc/Aitsys/etc/adminhtml.xml +38 -0
- app/code/community/Aitoc/Aitsys/etc/compilation.xml +73 -0
- app/code/community/Aitoc/Aitsys/etc/config.xml +306 -0
- app/code/community/Aitoc/Aitsys/etc/system.xml +85 -0
- app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-install-2.0.0.php +23 -0
- app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-install-3.0.0.php +27 -0
- app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-1.0-2.0.0.php +3 -0
- app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-1.0.0-2.0.0.php +23 -0
- app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-2.14.6-2.15.0.php +18 -0
- app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-2.15.5-2.15.6.php +28 -0
- app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-2.20.1-2.21.0.php +12 -0
- app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-2.7.3-2.7.4.php +16 -0
- app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-2.99.0-3.0.0.php +10 -0
- app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-3.0.3-3.1.0.php +8 -0
- app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-3.1.4-3.2.0.php +6 -0
- app/code/local/Aitoc/Aitloadmon/Block/Adminhtml/Aitloadmon.php +16 -0
- app/code/local/Aitoc/Aitloadmon/Block/Adminhtml/Aitloadmon/Filter.php +2 -1
- app/code/local/Aitoc/Aitloadmon/Block/Adminhtml/Aitloadmon/LineGraph.php +3 -1
- app/code/local/Aitoc/Aitloadmon/Block/Adminhtml/Calculator.php +17 -9
- app/code/local/Aitoc/Aitloadmon/Block/Adminhtml/CalculatorResult.php +61 -12
- app/code/local/Aitoc/Aitloadmon/Model/Aitloadmon.php +3 -1
- app/code/local/Aitoc/Aitloadmon/Model/Calculator.php +5 -0
- app/code/local/Aitoc/Aitloadmon/Model/Process.php +27 -11
- app/code/local/Aitoc/Aitloadmon/Model/SysInfo.php +1 -1
- app/code/local/Aitoc/Aitloadmon/controllers/Adminhtml/AitloadmonController.php +10 -4
- app/code/local/Aitoc/Aitloadmon/controllers/Adminhtml/CalculatorController.php +30 -0
- app/code/local/Aitoc/Aitloadmon/etc/config.xml +1 -5
- app/design/adminhtml/default/default/layout/aitcore.xml +48 -0
- app/design/adminhtml/default/default/layout/aitinstall.xml +8 -0
- app/design/adminhtml/default/default/layout/aitloadmon.xml +4 -4
- app/design/adminhtml/default/default/template/aitloadmon/back.phtml +0 -8
- app/design/adminhtml/default/default/template/aitloadmon/bar.phtml +0 -30
- app/design/adminhtml/default/default/template/aitloadmon/graph.phtml +0 -28
- app/design/adminhtml/default/default/template/aitloadmon/indicator.phtml +0 -12
- app/design/adminhtml/default/default/template/aitloadmon/line.phtml +0 -119
- app/design/adminhtml/default/default/template/aitloadmon/quick.phtml +0 -28
- app/design/adminhtml/default/default/template/aitloadmon/sysInfo.phtml +0 -11
- app/design/adminhtml/default/default/template/aitloadmon/system.phtml +0 -11
- app/etc/modules/Aitoc_Aitinstall.xml +13 -0
- lib/Aitoc/Aitloadmon/Adapter/Abstract.php +341 -0
- lib/Aitoc/Aitloadmon/Adapter/Apc.php +72 -40
- lib/Aitoc/Aitloadmon/Adapter/File.php +350 -64
- lib/Aitoc/Aitloadmon/Adapter/Memcached.php +70 -42
- lib/Aitoc/Aitloadmon/Collect.php +69 -14
- package.xml +10 -31
- skin/adminhtml/default/default/aitoc/aitsys.css +130 -0
Server Load Monitor Manual.pdf
CHANGED
Binary file
|
app/code/community/Aitoc/Aitinstall/Helper/Data.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitinstall_Helper_Data extends Mage_Core_Helper_Abstract
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
static protected $_classPath = '/app/code/%s/Aitoc/Aitsys/Model/Aitsys.php';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var string
|
14 |
+
*/
|
15 |
+
static protected $_licensesPath = '/app/code/local/Aitoc/Aitsys/install/*.xml';
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var array
|
19 |
+
*/
|
20 |
+
static protected $_pools = array('community', 'local');
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Check whether both new and old installers are installed or only one of them
|
24 |
+
*
|
25 |
+
* @return bool
|
26 |
+
*/
|
27 |
+
public function isDoubleInstallerVersion()
|
28 |
+
{
|
29 |
+
foreach (self::$_pools as $pool) {
|
30 |
+
if (!file_exists( BP . sprintf(self::$_classPath, $pool) )) {
|
31 |
+
return false;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
return true;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Check whether old installer contains some licenses
|
39 |
+
*
|
40 |
+
* @return bool
|
41 |
+
*/
|
42 |
+
public function isThereAnyLicenses()
|
43 |
+
{
|
44 |
+
$licenses = glob(BP . self::$_licensesPath);
|
45 |
+
return !empty($licenses);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
public function getInfoLink()
|
52 |
+
{
|
53 |
+
return 'http://www.aitoc.com/media/guides/license_convertation_guide.pdf';
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public function getSupportLink()
|
60 |
+
{
|
61 |
+
return 'https://www.aitoc.com/en/contacts.html?support';
|
62 |
+
}
|
63 |
+
}
|
app/code/community/Aitoc/Aitinstall/etc/config.xml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!-- @copyright Copyright (c) 2009 AITOC, Inc. -->
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<Aitoc_Aitinstall>
|
6 |
+
<version>1.0.1</version>
|
7 |
+
</Aitoc_Aitinstall>
|
8 |
+
</modules>
|
9 |
+
|
10 |
+
<adminhtml>
|
11 |
+
<layout>
|
12 |
+
<updates>
|
13 |
+
<aitinstall>
|
14 |
+
<file>aitinstall.xml</file>
|
15 |
+
</aitinstall>
|
16 |
+
</updates>
|
17 |
+
</layout>
|
18 |
+
</adminhtml>
|
19 |
+
|
20 |
+
<global>
|
21 |
+
<helpers>
|
22 |
+
<aitinstall>
|
23 |
+
<class>Aitoc_Aitinstall_Helper</class>
|
24 |
+
</aitinstall>
|
25 |
+
</helpers>
|
26 |
+
</global>
|
27 |
+
</config>
|
app/code/community/Aitoc/Aitsys/Abstract/Adminhtml/Block.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Abstract_Adminhtml_Block extends Mage_Adminhtml_Block_Template
|
6 |
+
implements Aitoc_Aitsys_Abstract_Model_Interface
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
10 |
+
*/
|
11 |
+
public function tool()
|
12 |
+
{
|
13 |
+
return Aitoc_Aitsys_Abstract_Service::get();
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @return Aitoc_Aitsys_Abstract_Helper
|
18 |
+
*/
|
19 |
+
protected function _aithelper($type = 'Data')
|
20 |
+
{
|
21 |
+
return $this->tool()->getHelper($type);
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Aitoc/Aitsys/Abstract/Adminhtml/Controller.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Backward compatibility with some extensions
|
4 |
+
*
|
5 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
6 |
+
*/
|
7 |
+
class Aitoc_Aitsys_Abstract_Adminhtml_Controller extends Mage_Adminhtml_Controller_Action
|
8 |
+
implements Aitoc_Aitsys_Abstract_Model_Interface
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
12 |
+
*/
|
13 |
+
public function tool()
|
14 |
+
{
|
15 |
+
return Aitoc_Aitsys_Abstract_Service::get();
|
16 |
+
}
|
17 |
+
}
|
app/code/community/Aitoc/Aitsys/Abstract/Block.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Abstract_Block extends Mage_Core_Block_Template
|
6 |
+
implements Aitoc_Aitsys_Abstract_Model_Interface
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
10 |
+
*/
|
11 |
+
public function tool()
|
12 |
+
{
|
13 |
+
return Aitoc_Aitsys_Abstract_Service::get();
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Aitoc/Aitsys/Abstract/Helper.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
abstract class Aitoc_Aitsys_Abstract_Helper extends Mage_Core_Helper_Abstract
|
6 |
+
implements Aitoc_Aitsys_Abstract_Model_Interface
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
10 |
+
*/
|
11 |
+
public function tool()
|
12 |
+
{
|
13 |
+
return Aitoc_Aitsys_Abstract_Service::get();
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @return Mage_Adminhtml_Helper_Data
|
18 |
+
*/
|
19 |
+
public function getAdminhtmlHelper()
|
20 |
+
{
|
21 |
+
return Mage::helper('adminhtml');
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Aitoc/Aitsys/Abstract/Model.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
abstract class Aitoc_Aitsys_Abstract_Model extends Mage_Core_Model_Abstract
|
6 |
+
implements Aitoc_Aitsys_Abstract_Model_Interface
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* @var string
|
10 |
+
*/
|
11 |
+
protected $_objectUid;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
public function getObjectUid()
|
17 |
+
{
|
18 |
+
if (!$this->_objectUid) {
|
19 |
+
$this->_objectUid = md5(uniqid(microtime()));
|
20 |
+
}
|
21 |
+
return $this->_objectUid;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
26 |
+
*/
|
27 |
+
public function tool()
|
28 |
+
{
|
29 |
+
return Aitoc_Aitsys_Abstract_Service::get($this);
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @param string $const Constant name
|
34 |
+
* @param bool $translate
|
35 |
+
* @param array $args
|
36 |
+
*
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
protected function _strHelper($const, $translate = true, $args = array())
|
40 |
+
{
|
41 |
+
return $this->_aithelper('Strings')->getString($const, $translate, $args);
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @param string $type
|
46 |
+
*
|
47 |
+
* @return Aitoc_Aitsys_Abstract_Helper
|
48 |
+
*/
|
49 |
+
protected function _aithelper($type = 'Data')
|
50 |
+
{
|
51 |
+
return $this->tool()->getHelper($type);
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Aitoc/Aitsys/Abstract/Model/Interface.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
interface Aitoc_Aitsys_Abstract_Model_Interface
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
*
|
8 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
9 |
+
*/
|
10 |
+
function tool();
|
11 |
+
|
12 |
+
}
|
app/code/community/Aitoc/Aitsys/Abstract/Mysql4.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
abstract class Aitoc_Aitsys_Abstract_Mysql4 extends Mage_Core_Model_Mysql4_Abstract
|
6 |
+
implements Aitoc_Aitsys_Abstract_Model_Interface
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
10 |
+
*/
|
11 |
+
public function tool()
|
12 |
+
{
|
13 |
+
return Aitoc_Aitsys_Abstract_Service::get();
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Aitoc/Aitsys/Abstract/Mysql4/Collection.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Aitoc_Aitsys_Abstract_Mysql4_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
implements Aitoc_Aitsys_Abstract_Model_Interface
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
10 |
+
*/
|
11 |
+
public function tool()
|
12 |
+
{
|
13 |
+
return Aitoc_Aitsys_Abstract_Service::get();
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/Aitoc/Aitsys/Abstract/Pure.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Abstract_Pure
|
6 |
+
{
|
7 |
+
public function __call( $method , array $args )
|
8 |
+
{
|
9 |
+
return $this;
|
10 |
+
}
|
11 |
+
|
12 |
+
public function __set( $key , $value )
|
13 |
+
{
|
14 |
+
|
15 |
+
}
|
16 |
+
|
17 |
+
public function __get( $key )
|
18 |
+
{
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function __isset( $key )
|
23 |
+
{
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
+
public function __unset( $key )
|
28 |
+
{
|
29 |
+
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Aitoc/Aitsys/Abstract/Resource/Eav/Setup.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Aitoc_Aitsys_Abstract_Resource_Eav_Setup extends Mage_Eav_Model_Entity_Setup
|
4 |
+
implements Aitoc_Aitsys_Abstract_Model_Interface
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
10 |
+
*/
|
11 |
+
public function tool()
|
12 |
+
{
|
13 |
+
return Aitoc_Aitsys_Abstract_Service::get();
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/Aitoc/Aitsys/Abstract/Resource/Setup.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Aitoc_Aitsys_Abstract_Resource_Setup extends Mage_Core_Model_Resource_Setup
|
4 |
+
implements Aitoc_Aitsys_Abstract_Model_Interface
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
10 |
+
*/
|
11 |
+
public function tool()
|
12 |
+
{
|
13 |
+
return Aitoc_Aitsys_Abstract_Service::get();
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/Aitoc/Aitsys/Abstract/Service.php
ADDED
@@ -0,0 +1,339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
final class Aitoc_Aitsys_Abstract_Service
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var Aitoc_Aitsys_Abstract_Service
|
9 |
+
*/
|
10 |
+
static private $_instance;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var Aitoc_Aitsys_Abstract_Model
|
14 |
+
*/
|
15 |
+
protected $_currentObject;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
protected $_realBaseUrl;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @var Aitoc_Aitsys_Abstract_Version
|
24 |
+
*/
|
25 |
+
protected $_versionComparer;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
protected $_aitocUrl = '';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @var array
|
34 |
+
*/
|
35 |
+
protected $_singletones = array();
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
39 |
+
*/
|
40 |
+
static public function get($object = null)
|
41 |
+
{
|
42 |
+
if (!self::$_instance) {
|
43 |
+
self::$_instance = new self;
|
44 |
+
}
|
45 |
+
return self::$_instance->setCurrentObject($object);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @return Aitoc_Aitsys_Abstract_Version
|
50 |
+
*/
|
51 |
+
public function getVersionComparer()
|
52 |
+
{
|
53 |
+
if (!$this->_versionComparer) {
|
54 |
+
$this->_versionComparer = new Aitoc_Aitsys_Abstract_Version();
|
55 |
+
}
|
56 |
+
return $this->_versionComparer;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @return Aitoc_Aitsys_Model_Platform
|
61 |
+
*/
|
62 |
+
public function platform()
|
63 |
+
{
|
64 |
+
return Aitoc_Aitsys_Model_Platform::getInstance();
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @param $object
|
69 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
70 |
+
*/
|
71 |
+
public function setCurrentObject($object)
|
72 |
+
{
|
73 |
+
if ($object instanceof Aitoc_Aitsys_Abstract_Model) {
|
74 |
+
$this->_currentObject = $object;
|
75 |
+
} else {
|
76 |
+
$this->_currentObject = null;
|
77 |
+
}
|
78 |
+
return $this;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @param mixed $object
|
83 |
+
* @param string $var
|
84 |
+
*
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
public function toPhpArray($object = null, $var = 'info')
|
88 |
+
{
|
89 |
+
$result = array();
|
90 |
+
if (is_array($object)) {
|
91 |
+
$data = $object;
|
92 |
+
} else {
|
93 |
+
$object = $object ? $object : $this->_currentObject;
|
94 |
+
$data = $object->getData();
|
95 |
+
}
|
96 |
+
|
97 |
+
foreach ($data as $key => $value) {
|
98 |
+
if (is_scalar($value)) {
|
99 |
+
$result[] = "\t'" . $key . "' => '" . addcslashes($value, "'") . "'";
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
$res = join(",\n", $result);
|
104 |
+
if (!is_null($var)) {
|
105 |
+
$res = '$' . $var . " = array(\n" . $res . "\n);\n";
|
106 |
+
}
|
107 |
+
return $res;
|
108 |
+
}
|
109 |
+
|
110 |
+
public function testMsg($msg, $trace = false)
|
111 |
+
{
|
112 |
+
#Mage::log($msg, false, 'aitsys.log', true);
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @param string $name Module name
|
117 |
+
* @return bool
|
118 |
+
*/
|
119 |
+
public function isModuleActive($name)
|
120 |
+
{
|
121 |
+
$val = Mage::getConfig()->getNode('modules/' . $name . '/active');
|
122 |
+
return 'true' == (string)$val;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* @param string $class
|
127 |
+
*
|
128 |
+
* @return mixed
|
129 |
+
*/
|
130 |
+
protected function _getSingleton($class)
|
131 |
+
{
|
132 |
+
if(!isset($this->_singletones[$class]) || !$this->_singletones[$class]) {
|
133 |
+
$this->_singletones[$class] = new $class();
|
134 |
+
}
|
135 |
+
return $this->_singletones[$class];
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* @return Aitoc_Aitsys_Model_Core_Filesystem
|
140 |
+
*/
|
141 |
+
public function filesystem()
|
142 |
+
{
|
143 |
+
return $this->_getSingleton('Aitoc_Aitsys_Model_Core_Filesystem');
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @return Aitoc_Aitsys_Model_Core_Database
|
148 |
+
*/
|
149 |
+
public function db()
|
150 |
+
{
|
151 |
+
return $this->_getSingleton('Aitoc_Aitsys_Model_Core_Database');
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* @return Aitoc_Aitsys_Model_Core_Cache
|
156 |
+
*/
|
157 |
+
public function getCache()
|
158 |
+
{
|
159 |
+
return $this->_getSingleton('Aitoc_Aitsys_Model_Core_Cache');
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Flush cache storage, re-init magento config, apply updates
|
164 |
+
*
|
165 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
166 |
+
*/
|
167 |
+
public function clearCache()
|
168 |
+
{
|
169 |
+
$this->getCache()->flush();
|
170 |
+
return $this;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* @param $name
|
175 |
+
* @param $data
|
176 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
177 |
+
*/
|
178 |
+
public function event($name, $data = array())
|
179 |
+
{
|
180 |
+
Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS);
|
181 |
+
Mage::dispatchEvent($name, $data);
|
182 |
+
return $this;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* @return Zend_Db_Adapter_Abstract
|
187 |
+
*/
|
188 |
+
protected function _getReadConnection()
|
189 |
+
{
|
190 |
+
$resource = Mage::getSingleton('core/resource');
|
191 |
+
return $resource->getConnection('core_read');
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* @return Zend_Db_Adapter_Abstract
|
196 |
+
*/
|
197 |
+
public function getReadConnection()
|
198 |
+
{
|
199 |
+
return $this->_getReadConnection();
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* @return Zend_Db_Adapter_Abstract
|
204 |
+
*/
|
205 |
+
protected function _getWriteConnection()
|
206 |
+
{
|
207 |
+
$resource = Mage::getSingleton('core/resource');
|
208 |
+
return $resource->getConnection('core_write');
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* @return Zend_Db_Adapter_Abstract
|
213 |
+
*/
|
214 |
+
public function getWriteConnection()
|
215 |
+
{
|
216 |
+
return $this->_getWriteConnection();
|
217 |
+
}
|
218 |
+
|
219 |
+
protected function _getUrlFromSource()
|
220 |
+
{
|
221 |
+
$conn = $this->_getReadConnection();
|
222 |
+
$table = Mage::getModel('core/config_data')->getResource()->getMainTable();
|
223 |
+
$select = $conn->select()
|
224 |
+
->from($table, array('value'))
|
225 |
+
->where('path = ?', 'web/unsecure/base_url')
|
226 |
+
->where('scope_id = ?', 0)
|
227 |
+
->where('scope = ?', 'default');
|
228 |
+
return $conn->fetchOne($select);
|
229 |
+
}
|
230 |
+
|
231 |
+
public function getRealBaseUrl($clearDomain = true)
|
232 |
+
{
|
233 |
+
if (!$this->_realBaseUrl) {
|
234 |
+
$this->_realBaseUrl = $this->_getUrlFromSource();
|
235 |
+
}
|
236 |
+
return $clearDomain ? $this->cleanDomain($this->_realBaseUrl) : $this->_realBaseUrl;
|
237 |
+
}
|
238 |
+
|
239 |
+
public function isMagentoVersion($sourceVersion, $mageVersion = null)
|
240 |
+
{
|
241 |
+
$mageVersion = $mageVersion ? $mageVersion : Mage::getVersion();
|
242 |
+
return $this->getVersionComparer()->isMagentoVersion($sourceVersion, $mageVersion);
|
243 |
+
}
|
244 |
+
|
245 |
+
public function getApiUrl()
|
246 |
+
{
|
247 |
+
if ($this->platform()->hasData('_api_url')) {
|
248 |
+
return $this->platform()->getData('_api_url');
|
249 |
+
}
|
250 |
+
$url = '{#AITOC_SERVICE_URL#}';
|
251 |
+
if (false === strpos($url, 'AITOC_SERVICE_URL')) {
|
252 |
+
return $url;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
public function getAitocUrl()
|
257 |
+
{
|
258 |
+
if (!$this->_aitocUrl) {
|
259 |
+
$this->_aitocUrl = 'https://www.aitoc.com/en/'; // default value
|
260 |
+
$url = '{#AITOC_STORE_URL#}';
|
261 |
+
if (false === strpos($url, 'AITOC_STORE_URL')) {
|
262 |
+
$this->_aitocUrl = $url;
|
263 |
+
}
|
264 |
+
}
|
265 |
+
return $this->_aitocUrl;
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* @return Aitoc_Aitsys_Abstract_Helper
|
270 |
+
*/
|
271 |
+
public function getHelper($type = 'Data', $module = 'Aitoc_Aitsys')
|
272 |
+
{
|
273 |
+
$class = $module . '_Helper_' . $type;
|
274 |
+
return $this->_getSingleton($class);
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* @return Aitoc_Aitsys_Helper_License
|
279 |
+
*/
|
280 |
+
public function getSetupHelper($module)
|
281 |
+
{
|
282 |
+
$moduleDir = $this->filesystem()->getModuleDir($module);
|
283 |
+
if ($moduleDir && file_exists($moduleDir . DS . 'Helper' . DS . 'License.php')) {
|
284 |
+
$key = $module;
|
285 |
+
} else {
|
286 |
+
$key = 'Aitoc_Aitsys';
|
287 |
+
}
|
288 |
+
|
289 |
+
return $this->getHelper('License', $key);
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Check whether PHP works in cli mode
|
294 |
+
*
|
295 |
+
* @return bool
|
296 |
+
*/
|
297 |
+
public function isPhpCli()
|
298 |
+
{
|
299 |
+
return (bool)('cli' == @php_sapi_name());
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Safely unserializes a string IF it contains a serialized data
|
304 |
+
*
|
305 |
+
* @param string $string
|
306 |
+
* @return mixed
|
307 |
+
*/
|
308 |
+
public function unserialize($string)
|
309 |
+
{
|
310 |
+
// before trying to unserialize we are replacing error_handler with another one to catch E_NOTICE run-time error
|
311 |
+
$this->setTemporaryErrorException();
|
312 |
+
$tmpValue = $string;
|
313 |
+
try {
|
314 |
+
$result = unserialize($string);
|
315 |
+
}
|
316 |
+
catch (ErrorException $e) {
|
317 |
+
//restore old data value
|
318 |
+
$result = $tmpValue;
|
319 |
+
}
|
320 |
+
$this->restorePreviousErrorHandler();
|
321 |
+
return $result;
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* @see Aitoc_Aitsys_Abstract_Service::unserialize
|
326 |
+
*/
|
327 |
+
public function setTemporaryErrorException()
|
328 |
+
{
|
329 |
+
$a = set_error_handler(create_function('$a, $b, $c, $d', 'throw new ErrorException($b, 0, $a, $c, $d);'), E_ALL);
|
330 |
+
}
|
331 |
+
|
332 |
+
/**
|
333 |
+
* @see Aitoc_Aitsys_Abstract_Service::unserialize
|
334 |
+
*/
|
335 |
+
public function restorePreviousErrorHandler()
|
336 |
+
{
|
337 |
+
restore_error_handler();
|
338 |
+
}
|
339 |
+
}
|
app/code/community/Aitoc/Aitsys/Abstract/Version.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Abstract_Version extends Aitoc_Aitsys_Abstract_Model
|
6 |
+
{
|
7 |
+
|
8 |
+
protected $_versionCompare = array();
|
9 |
+
|
10 |
+
public function isMagentoVersion( $sourceVersion , $mageVersion )
|
11 |
+
{
|
12 |
+
if (!isset($this->_versionCompare[$mageVersion][$sourceVersion]))
|
13 |
+
{
|
14 |
+
$version = $sourceVersion;
|
15 |
+
$directive = '=';
|
16 |
+
if (!is_numeric(substr($version,0,1)))
|
17 |
+
{
|
18 |
+
$directive = is_numeric(substr($version,1,1)) ? substr($version,0,1) : substr($version,0,2);
|
19 |
+
$version = substr($version,strlen($directive));
|
20 |
+
}
|
21 |
+
$this->tool()->testMsg('Total directive: '.$directive);
|
22 |
+
$versionInfo = explode('.',$version);
|
23 |
+
$info = explode('.',$mageVersion);
|
24 |
+
if (preg_match('/[+-]/',$version) || '=' == $directive)
|
25 |
+
{
|
26 |
+
$this->tool()->testMsg("Use custom");
|
27 |
+
$this->_versionCompare[$mageVersion][$sourceVersion] = self::_compareVersion($directive,$versionInfo,$info);
|
28 |
+
}
|
29 |
+
else
|
30 |
+
{
|
31 |
+
$this->tool()->testMsg("Use default");
|
32 |
+
$this->tool()->testMsg(array($version,$mageVersion,$directive));
|
33 |
+
$this->_versionCompare[$mageVersion][$sourceVersion] = version_compare($mageVersion,$version,$directive);
|
34 |
+
$this->tool()->testMsg(strval($this->_versionCompare[$mageVersion][$sourceVersion]));
|
35 |
+
}
|
36 |
+
}
|
37 |
+
return $this->_versionCompare[$mageVersion][$sourceVersion];
|
38 |
+
}
|
39 |
+
|
40 |
+
static private function _compareVersion( $directive , $version , $info )
|
41 |
+
{
|
42 |
+
foreach ($version as $index => $item)
|
43 |
+
{
|
44 |
+
$end = $index == (sizeof($version)-1);
|
45 |
+
switch(true)
|
46 |
+
{
|
47 |
+
case (false !== strstr($item,'+')):
|
48 |
+
if (!self::_compareDirective($directive,'+',(int)$item,(int)$info[$index],$end))
|
49 |
+
{
|
50 |
+
Aitoc_Aitsys_Abstract_Service::get()->testMsg('+');
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
break;
|
54 |
+
case (false !== strstr($item,'-')):
|
55 |
+
if (!self::_compareDirective($directive,'-',(int)$item,(int)$info[$index],$end))
|
56 |
+
{
|
57 |
+
Aitoc_Aitsys_Abstract_Service::get()->testMsg('-');
|
58 |
+
return false;
|
59 |
+
}
|
60 |
+
break;
|
61 |
+
default:
|
62 |
+
if (!self::_compareDirective($directive,'.',(int)$item,(int)$info[$index],$end))
|
63 |
+
{
|
64 |
+
Aitoc_Aitsys_Abstract_Service::get()->testMsg('.');
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
break;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
return true;
|
71 |
+
}
|
72 |
+
|
73 |
+
static private function _compareDirective( $directive , $case , $etalon , $value , $end = null )
|
74 |
+
{
|
75 |
+
if (('=' != $directive) && !$end && self::_compareDirective('=',$case,$etalon,$value))
|
76 |
+
{
|
77 |
+
return true;
|
78 |
+
}
|
79 |
+
switch ($directive)
|
80 |
+
{
|
81 |
+
default:
|
82 |
+
case '=':
|
83 |
+
switch ($case)
|
84 |
+
{
|
85 |
+
case '+':
|
86 |
+
Aitoc_Aitsys_Abstract_Service::get()->testMsg($value .'>='. $etalon);
|
87 |
+
return $value >= $etalon;
|
88 |
+
case '-':
|
89 |
+
Aitoc_Aitsys_Abstract_Service::get()->testMsg($value .'<'. $etalon);
|
90 |
+
return $value < $etalon;
|
91 |
+
default:
|
92 |
+
Aitoc_Aitsys_Abstract_Service::get()->testMsg($value .'=='. $etalon);
|
93 |
+
return $value == $etalon;
|
94 |
+
}
|
95 |
+
break;
|
96 |
+
case '<':
|
97 |
+
switch ($case)
|
98 |
+
{
|
99 |
+
case '+':
|
100 |
+
return $value < $etalon;
|
101 |
+
case '-':
|
102 |
+
return $value <= $etalon;
|
103 |
+
default:
|
104 |
+
return $value < $etalon;
|
105 |
+
}
|
106 |
+
break;
|
107 |
+
case '>':
|
108 |
+
switch ($case)
|
109 |
+
{
|
110 |
+
case '+':
|
111 |
+
return $value > $etalon;
|
112 |
+
case '-':
|
113 |
+
return $value >= $etalon;
|
114 |
+
default:
|
115 |
+
return $value > $etalon;
|
116 |
+
}
|
117 |
+
break;
|
118 |
+
case '>=':
|
119 |
+
switch ($case)
|
120 |
+
{
|
121 |
+
case '+':
|
122 |
+
return $value >= $etalon+1;
|
123 |
+
case '-':
|
124 |
+
return $value > $etalon;
|
125 |
+
default:
|
126 |
+
return $value >= $etalon;
|
127 |
+
}
|
128 |
+
break;
|
129 |
+
case '<=':
|
130 |
+
switch ($case)
|
131 |
+
{
|
132 |
+
case '+':
|
133 |
+
return $value < $etalon;
|
134 |
+
case '-':
|
135 |
+
return $value <= $etalon-1;
|
136 |
+
default:
|
137 |
+
return $value <= $etalon;
|
138 |
+
}
|
139 |
+
break;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
}
|
app/code/community/Aitoc/Aitsys/Block/Edit.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Block_Edit extends Mage_Adminhtml_Block_Widget
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var bool
|
9 |
+
*/
|
10 |
+
protected $_allowInstall = true;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var array
|
14 |
+
*/
|
15 |
+
protected $_errorList = array();
|
16 |
+
|
17 |
+
public function _construct()
|
18 |
+
{
|
19 |
+
$aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
|
20 |
+
$this->_errorList = $aitsysModel->getAllowInstallErrors();
|
21 |
+
$this->setTitle('Aitoc Modules Manager v%s');
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Get current module version
|
26 |
+
*
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
public function getVersion()
|
30 |
+
{
|
31 |
+
return Aitoc_Aitsys_Model_Platform::getInstance()->getVersion();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Get new permissions link param
|
36 |
+
*
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public function getPermLink()
|
40 |
+
{
|
41 |
+
$mode = $this->tool()->filesystem()->getPermissionsMode();
|
42 |
+
|
43 |
+
if ($mode === Aitoc_Aitsys_Model_Core_Filesystem::MODE_ALL) {
|
44 |
+
return Aitoc_Aitsys_Model_Core_Filesystem::MODE_NORMAL;
|
45 |
+
} else {
|
46 |
+
return Aitoc_Aitsys_Model_Core_Filesystem::MODE_ALL;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Get new permissions link description
|
52 |
+
*
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function getPermLinkTitle()
|
56 |
+
{
|
57 |
+
$mode = $this->tool()->filesystem()->getPermissionsMode();
|
58 |
+
|
59 |
+
if ($mode === Aitoc_Aitsys_Model_Core_Filesystem::MODE_ALL) {
|
60 |
+
return 'Grant restricted write permissions';
|
61 |
+
} else {
|
62 |
+
return 'Grant full write permissions';
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
protected function _prepareLayout()
|
67 |
+
{
|
68 |
+
if ($this->_allowInstall) {
|
69 |
+
$this->setChild('save_button',
|
70 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
71 |
+
->setData(array(
|
72 |
+
'label' => Mage::helper('aitsys')->__('Save modules settings'),
|
73 |
+
'onclick' => 'configForm.submit()',
|
74 |
+
'class' => 'save',
|
75 |
+
))
|
76 |
+
);
|
77 |
+
|
78 |
+
$this->setChild('form',
|
79 |
+
$this->getLayout()->createBlock('aitsys/form')
|
80 |
+
->initForm()
|
81 |
+
);
|
82 |
+
}
|
83 |
+
return parent::_prepareLayout();
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @return string
|
88 |
+
*/
|
89 |
+
public function getSaveButtonHtml()
|
90 |
+
{
|
91 |
+
return $this->getChildHtml('save_button');
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @return string
|
96 |
+
*/
|
97 |
+
public function getSaveUrl()
|
98 |
+
{
|
99 |
+
return $this->getUrl('*/*/save', array('_current'=>true));
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* @return string
|
104 |
+
*/
|
105 |
+
public function getInstallText()
|
106 |
+
{
|
107 |
+
$installText = '';
|
108 |
+
if (!empty($this->_errorList)) {
|
109 |
+
$installText .= '<ul class="messages" style="width:50%">';
|
110 |
+
|
111 |
+
foreach ($this->_errorList as $errorMsg) {
|
112 |
+
$installText .= '<li class="'.$errorMsg['type'].'"><ul><li>'.$errorMsg['message'] . '<br /></li></ul></li>';
|
113 |
+
}
|
114 |
+
$installText .= '</ul>';
|
115 |
+
}
|
116 |
+
|
117 |
+
return $installText;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
122 |
+
*/
|
123 |
+
public function tool()
|
124 |
+
{
|
125 |
+
return Aitoc_Aitsys_Abstract_Service::get($this);
|
126 |
+
}
|
127 |
+
}
|
app/code/community/Aitoc/Aitsys/Block/Form.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Block_Form extends Mage_Adminhtml_Block_Widget_Form
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var Aitoc_Aitsys_Block_Form_Element_Renderer
|
9 |
+
*/
|
10 |
+
protected $_elementRenderer;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return Mage_Adminhtml_Block_Widget_Form
|
14 |
+
*/
|
15 |
+
public function initForm()
|
16 |
+
{
|
17 |
+
$form = new Varien_Data_Form();
|
18 |
+
|
19 |
+
$fieldset = $form->addFieldset('module_list', array(
|
20 |
+
'legend' => Mage::helper('aitsys')->__('AITOC Modules')
|
21 |
+
));
|
22 |
+
$fieldset->getRenderer()->setTemplate('aitcore/fieldset.phtml');
|
23 |
+
|
24 |
+
$aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
|
25 |
+
$modulesList = $aitsysModel->getAitocModuleList();
|
26 |
+
|
27 |
+
$this->_elementRenderer = $this->getLayout()->createBlock('aitsys/form_element_renderer');
|
28 |
+
|
29 |
+
if ($modulesList) {
|
30 |
+
foreach ($modulesList as $module) {
|
31 |
+
$this->_addModule($module, $fieldset);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
$this->setForm($form);
|
36 |
+
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @param Aitoc_Aitsys_Model_Module $module
|
42 |
+
* @param Varien_Data_Form_Element_Fieldset $fieldset
|
43 |
+
*/
|
44 |
+
protected function _addModule(Aitoc_Aitsys_Model_Module $module, Varien_Data_Form_Element_Fieldset $fieldset)
|
45 |
+
{
|
46 |
+
if($module->isIgnore())
|
47 |
+
{
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
|
51 |
+
$aModule = $module;
|
52 |
+
$label = $module->getInfo()->getLabel().($module->getInfo()->getVersion()?' v'.$module->getInfo()->getVersion():'');
|
53 |
+
$message = '';
|
54 |
+
$messageType = 'notice-msg';
|
55 |
+
$isDemo = false;
|
56 |
+
|
57 |
+
if ($this->tool()->platform()->hasDemoMode()) {
|
58 |
+
$xml = simplexml_load_file(Mage::getBaseDir()."/aitmodules.xml");
|
59 |
+
$link = (string) $xml->modules->$aModule['key'];
|
60 |
+
if ($link == '') {
|
61 |
+
$link = $this->tool()->getAitocUrl();
|
62 |
+
}
|
63 |
+
$message = Mage::helper('aitsys')->__("The extension is already enabled on this Demo Magento installation and can't be disabled for security reasons. Please proceed to the next step outlined in the extension's <a href='%s' target='_blank'>User Manual</a> to see how it works.", $link);
|
64 |
+
$isDemo = true;
|
65 |
+
} elseif (defined('COMPILER_INCLUDE_PATH')) {
|
66 |
+
$compilerUrl = version_compare(Mage::getVersion(), '1.5.0.0', '>=') ? Mage::helper('adminhtml')->getUrl('adminhtml/compiler_process/index/') : Mage::helper('adminhtml')->getUrl('compiler/process/index/');
|
67 |
+
$message = Mage::helper('aitsys')->__('Before activating or deactivating the extension please turn off the compiler at <br /><a href="%s">System > Tools > Compilation</a>', $compilerUrl);
|
68 |
+
$messageType = 'warning-msg';
|
69 |
+
} elseif(!$module->getInfo()->isMagentoCompatible()) {
|
70 |
+
$message = Mage::helper('aitsys/strings')->getString( 'ER_ENT_HASH' );
|
71 |
+
} elseif(!$module->getAccess()) {
|
72 |
+
$message = Mage::helper('aitsys')->__('File does not have write permissions: %s', $aModule['file']);
|
73 |
+
$messageType = 'error-msg';
|
74 |
+
}
|
75 |
+
|
76 |
+
if($module->getInfo()->getSerial())
|
77 |
+
{
|
78 |
+
$info = 'S/N: '.$module->getInfo()->getSerial();
|
79 |
+
}
|
80 |
+
|
81 |
+
if($aModule['key'] == 'Aitoc_Common')
|
82 |
+
{
|
83 |
+
$info = 'Used by other AITOC\'s modules. Do not disable.';
|
84 |
+
}
|
85 |
+
if ($message && $messageType != 'notice-msg' || $isDemo) {
|
86 |
+
$field = $fieldset->addField('ignore_'.$aModule['key'], 'note', array(
|
87 |
+
'name' => 'ignore['.$aModule['key'].']',
|
88 |
+
'label' => $label,
|
89 |
+
'info' => empty($info)?'':$info,
|
90 |
+
'note' => '<ul class="messages"><li class="'.$messageType.'"><ul><li>' . $message . '</li></ul></li></ul>',
|
91 |
+
'module' => $module
|
92 |
+
));
|
93 |
+
if(!$isDemo) {
|
94 |
+
$field->setRenderer($this->_elementRenderer);
|
95 |
+
}
|
96 |
+
return;
|
97 |
+
}
|
98 |
+
|
99 |
+
$fieldset->addField('hidden_enable_'.$aModule['key'], 'hidden', array(
|
100 |
+
'name' => 'enable['.$aModule['key'].']',
|
101 |
+
'value' => 0,
|
102 |
+
));
|
103 |
+
|
104 |
+
$fieldset->addField('enable_'.$aModule['key'], 'checkbox', array(
|
105 |
+
'name' => ($module->getAccess() ? 'enable' : 'ignore') . '['.$aModule['key'].']',
|
106 |
+
'label' => $label,
|
107 |
+
'value' => 1,
|
108 |
+
'checked' => $aModule['value'],
|
109 |
+
'note' => $message?'<ul class="messages"><li class="'.$messageType.'"><ul><li>' . $message . '</li></ul></li></ul>':'',
|
110 |
+
'info' => empty($info)?'':$info,
|
111 |
+
'module' => $module
|
112 |
+
))->setRenderer($this->_elementRenderer);
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
117 |
+
*/
|
118 |
+
public function tool()
|
119 |
+
{
|
120 |
+
return Aitoc_Aitsys_Abstract_Service::get();
|
121 |
+
}
|
122 |
+
}
|
app/code/community/Aitoc/Aitsys/Block/Form/Element/Renderer.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Block_Form_Element_Renderer extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element
|
6 |
+
{
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
$this->setTemplate('aitcore/fieldset/element.phtml');
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return Aitoc_Aitsys_Model_Module
|
14 |
+
*/
|
15 |
+
public function getModule()
|
16 |
+
{
|
17 |
+
return $this->getElement()->getModule();
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Aitoc/Aitsys/Block/News.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Block_News extends Aitoc_Aitsys_Abstract_Adminhtml_Block
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var Aitoc_Aitsys_Model_News_Recent
|
9 |
+
*/
|
10 |
+
protected $_news;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return Aitoc_Aitsys_Model_News_Recent
|
14 |
+
*/
|
15 |
+
public function getNews()
|
16 |
+
{
|
17 |
+
if (!$this->_news) {
|
18 |
+
$this->_news = Mage::getModel('aitsys/news_recent');
|
19 |
+
$this->_news->loadData();
|
20 |
+
}
|
21 |
+
return $this->_news->getNews();
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Aitoc/Aitsys/Block/Patch/Instruction.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Block_Patch_Instruction extends Aitoc_Aitsys_Abstract_Adminhtml_Block
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_currentMod;
|
11 |
+
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
$this->setTitle('Aitoc Manual Patch Instructions');
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getInstructionsHtml()
|
21 |
+
{
|
22 |
+
$html = '';
|
23 |
+
$incompatibleList = Mage::getSingleton('adminhtml/session')->getData('aitsys_patch_incompatible_files');
|
24 |
+
$this->_currentMod = Mage::app()->getRequest()->getParam('mod');
|
25 |
+
|
26 |
+
if (!$this->_currentMod || !isset($incompatibleList[$this->_currentMod])) {
|
27 |
+
Mage::app()->getResponse()->setRedirect($this->getUrl('aitsys'));
|
28 |
+
return $html;
|
29 |
+
}
|
30 |
+
foreach ($incompatibleList[$this->_currentMod] as $patchFile) {
|
31 |
+
$html .= $this->_getBlockInstruction($patchFile);
|
32 |
+
}
|
33 |
+
|
34 |
+
return $html;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param array $patchFile
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
protected function _getBlockInstruction(array $patchFile)
|
42 |
+
{
|
43 |
+
$oneBlock = $this->getChild('aitsys.patch.instruction.one');
|
44 |
+
$oneBlock->setSourceFile($patchFile['file']);
|
45 |
+
$oneBlock->setPatchFile($patchFile['patchfile']);
|
46 |
+
$oneBlock->setExtensionPath($patchFile['mod']);
|
47 |
+
$oneBlock->setExtensionName($this->_currentMod);
|
48 |
+
return $oneBlock->toHtml();
|
49 |
+
}
|
50 |
+
}
|
app/code/community/Aitoc/Aitsys/Block/Patch/Instruction/One.php
ADDED
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Block_Patch_Instruction_One extends Aitoc_Aitsys_Abstract_Adminhtml_Block
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_sourceFile = '';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var string
|
14 |
+
*/
|
15 |
+
protected $_extensionPath = '';
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
protected $_extensionName = '';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
protected $_patchFile = '';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var bool
|
29 |
+
*/
|
30 |
+
protected $_removeBasedir = true;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @var string
|
34 |
+
*/
|
35 |
+
protected $_baseDir = '';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param string $path
|
39 |
+
*/
|
40 |
+
public function setSourceFile($path)
|
41 |
+
{
|
42 |
+
$this->_sourceFile = $path;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @param string $path
|
47 |
+
*/
|
48 |
+
public function setExtensionPath($path)
|
49 |
+
{
|
50 |
+
$this->_extensionPath = $path;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @param string $path
|
55 |
+
*/
|
56 |
+
public function setExtensionName($name)
|
57 |
+
{
|
58 |
+
$this->_extensionName = $name;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @param string $path
|
63 |
+
*/
|
64 |
+
public function setPatchFile($file)
|
65 |
+
{
|
66 |
+
$this->_patchFile = $file;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return string
|
71 |
+
*/
|
72 |
+
protected function _getBaseDir()
|
73 |
+
{
|
74 |
+
if (!$this->_baseDir) {
|
75 |
+
$this->_baseDir = $this->_normalizePath(Mage::getBaseDir());
|
76 |
+
}
|
77 |
+
return $this->_baseDir;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @param string $path
|
82 |
+
*
|
83 |
+
* @return string
|
84 |
+
*/
|
85 |
+
protected function _removeBaseDir($path)
|
86 |
+
{
|
87 |
+
if ($this->_removeBasedir) {
|
88 |
+
$path = str_replace($this->_getBaseDir(), '', $path);
|
89 |
+
}
|
90 |
+
return $path;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* @param string $path
|
95 |
+
*
|
96 |
+
* @return string
|
97 |
+
*/
|
98 |
+
protected function _normalizePath($path)
|
99 |
+
{
|
100 |
+
return str_replace(array('/', '\\'), DS, $path);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @param bool $includeBasedir
|
105 |
+
*
|
106 |
+
* @return string
|
107 |
+
*/
|
108 |
+
public function getSourceFile($includeBasedir = false)
|
109 |
+
{
|
110 |
+
$path = $this->_sourceFile;
|
111 |
+
$path = $this->_normalizePath($path);
|
112 |
+
if (!$includeBasedir) {
|
113 |
+
$path = $this->_removeBasedir($path);
|
114 |
+
}
|
115 |
+
return $path;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* @param bool $includeBasedir
|
120 |
+
*
|
121 |
+
* @return string
|
122 |
+
*/
|
123 |
+
public function getExtensionPath($includeBasedir = false)
|
124 |
+
{
|
125 |
+
$path = $this->_extensionPath;
|
126 |
+
$path = $this->_normalizePath($path);
|
127 |
+
if (!$includeBasedir) {
|
128 |
+
$path = $this->_removeBasedir($path);
|
129 |
+
}
|
130 |
+
return $path;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @return string
|
135 |
+
*/
|
136 |
+
public function getExtensionName()
|
137 |
+
{
|
138 |
+
return $this->_extensionName;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @return string
|
143 |
+
*/
|
144 |
+
public function getPatchFile()
|
145 |
+
{
|
146 |
+
return $this->_normalizePath($this->_patchFile);
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* @return string
|
151 |
+
*/
|
152 |
+
public function getPatchedFileName()
|
153 |
+
{
|
154 |
+
return str_replace('.patch', '', $this->getPatchFile());
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* @return string
|
159 |
+
*/
|
160 |
+
public function getDestinationFile()
|
161 |
+
{
|
162 |
+
$destinationFile = str_replace(Mage::getBaseDir('app'), Aitoc_Aitsys_Model_Aitpatch::getPatchesCacheDir(), $this->getSourceFile(true));
|
163 |
+
$destinationFile = substr($destinationFile, 0, strrpos($destinationFile, DS) + 1);
|
164 |
+
$destinationFile = str_replace(strstr($destinationFile, 'template'), '', $destinationFile);
|
165 |
+
$destinationFile .= 'template' . DS . 'aitcommonfiles' . DS . str_replace('.patch', '', $this->getPatchFile());
|
166 |
+
$destinationFile = $this->_removeBasedir($destinationFile);
|
167 |
+
return $destinationFile;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* @return string
|
172 |
+
*/
|
173 |
+
public function getDestinationDir()
|
174 |
+
{
|
175 |
+
return dirname($this->getDestinationFile());
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* @return string
|
180 |
+
*/
|
181 |
+
public function getPatchConfigPath()
|
182 |
+
{
|
183 |
+
$config = $this->getExtensionPath() . DS . 'etc' . DS . 'custom.data.xml';
|
184 |
+
return htmlspecialchars($config);
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* @return string
|
189 |
+
*/
|
190 |
+
public function getPatchConfigLine()
|
191 |
+
{
|
192 |
+
$configLine = '<file path="' . substr($this->getPatchFile(), 0, strpos($this->getPatchFile(), '.')) . '"></file>';
|
193 |
+
return htmlspecialchars($configLine);
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* @return Aitoc_Aitsys_Model_Aitfilepatcher
|
198 |
+
*/
|
199 |
+
protected function _makeAitfilepatcher()
|
200 |
+
{
|
201 |
+
return new Aitoc_Aitsys_Model_Aitfilepatcher();
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* @return string
|
206 |
+
*/
|
207 |
+
public function getPatchContents()
|
208 |
+
{
|
209 |
+
$patcher = $this->_makeAitfilepatcher();
|
210 |
+
/* @var $pathcer Aitoc_Aitsys_Model_Aitfilepatcher */
|
211 |
+
|
212 |
+
$oFileSys = $this->tool()->filesystem();
|
213 |
+
/* @var $oFileSys Aitoc_Aitsys_Model_Core_Filesystem */
|
214 |
+
|
215 |
+
$patchPath = $oFileSys->getPatchFilePath($this->getPatchFile(), $this->getExtensionPath(true) . DS . 'data' . DS)->getFilePath();
|
216 |
+
$patchInfo = $patcher->parsePatch(file_get_contents($patchPath));
|
217 |
+
$html = '<div class="patch">';
|
218 |
+
|
219 |
+
foreach ($patchInfo as $_data) {
|
220 |
+
foreach ($_data['aChanges'] as $_data) {
|
221 |
+
$bAfter = false;
|
222 |
+
$bAdd = false;
|
223 |
+
$bBefore = false;
|
224 |
+
$bLastAfter = false;
|
225 |
+
$bLastAdd = false;
|
226 |
+
$bLastBefore = false;
|
227 |
+
$str = '';
|
228 |
+
$aChunk = array();
|
229 |
+
foreach ($_data['aChangingStrings'] as $_line) {
|
230 |
+
if ($_line[0] == '+') {
|
231 |
+
$bBefore = false;
|
232 |
+
$bAdd = true;
|
233 |
+
$bAfter = false;
|
234 |
+
} elseif ($_line[0] == ' ') {
|
235 |
+
if ($bAdd || $bBefore) {
|
236 |
+
$bAfter = false;
|
237 |
+
$bBefore = true;
|
238 |
+
$bAdd = false;
|
239 |
+
} else {
|
240 |
+
$bAfter = true;
|
241 |
+
$bBefore = false;
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
if ($bLastAfter && !$bAfter) {
|
246 |
+
$aChunk[] = array(
|
247 |
+
'part' => 'after',
|
248 |
+
'str' => $str,
|
249 |
+
);
|
250 |
+
$str = '';
|
251 |
+
} elseif ($bLastAdd && !$bAdd) {
|
252 |
+
$aChunk[] = array(
|
253 |
+
'part' => 'add',
|
254 |
+
'str' => $str,
|
255 |
+
);
|
256 |
+
$str = '';
|
257 |
+
} elseif ($bLastBefore && !$bBefore) {
|
258 |
+
$aChunk[] = array(
|
259 |
+
'part' => 'before',
|
260 |
+
'str' => $str,
|
261 |
+
);
|
262 |
+
$str = '';
|
263 |
+
}
|
264 |
+
$str .= htmlspecialchars(rtrim($_line[2])) . "\r\n";
|
265 |
+
$bLastAfter = $bAfter;
|
266 |
+
$bLastAdd = $bAdd;
|
267 |
+
$bLastBefore = $bBefore;
|
268 |
+
}
|
269 |
+
if ($bBefore) {
|
270 |
+
$aChunk[] = array(
|
271 |
+
'part' => 'before',
|
272 |
+
'str' => $str,
|
273 |
+
);
|
274 |
+
}
|
275 |
+
$html .= $this->_getChunkHtml($aChunk);
|
276 |
+
}
|
277 |
+
}
|
278 |
+
$html .= '</div>';
|
279 |
+
return $html;
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* @param array $chunk
|
284 |
+
*
|
285 |
+
* @return string
|
286 |
+
*/
|
287 |
+
protected function _getChunkHtml($chunk)
|
288 |
+
{
|
289 |
+
$html = '';
|
290 |
+
foreach ($chunk as $part) {
|
291 |
+
if ($part['part'] == 'after') {
|
292 |
+
continue;
|
293 |
+
}
|
294 |
+
if ($part['part'] == 'add') {
|
295 |
+
$html .= Mage::helper('aitsys')->__('You will need to add the following lines —') ;
|
296 |
+
$html .= '<pre>';
|
297 |
+
$html .= $part['str'];
|
298 |
+
$html .= '</pre>';
|
299 |
+
}
|
300 |
+
if ($part['part'] == 'before') {
|
301 |
+
$html .= Mage::helper('aitsys')->__('The above lines should be added BEFORE the following code or similar to it —') ;
|
302 |
+
$html .= '<pre>';
|
303 |
+
$html .= $part['str'];
|
304 |
+
$html .= '</pre>';
|
305 |
+
}
|
306 |
+
}
|
307 |
+
return $html;
|
308 |
+
}
|
309 |
+
}
|
app/code/community/Aitoc/Aitsys/Block/Patch/View.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Block_Patch_View extends Mage_Adminhtml_Block_Abstract
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var array
|
9 |
+
*/
|
10 |
+
protected $_collectedFiles = array();
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var integer
|
14 |
+
*/
|
15 |
+
protected $_filesNumber = 0;
|
16 |
+
|
17 |
+
protected function _construct()
|
18 |
+
{
|
19 |
+
$pathes = array();
|
20 |
+
$designDir = Mage::getBaseDir('design');
|
21 |
+
$source = array(
|
22 |
+
'admin' => $designDir . DS . 'adminhtml' . DS,
|
23 |
+
'front' => $designDir . DS . 'frontend' . DS
|
24 |
+
);
|
25 |
+
|
26 |
+
// design area level
|
27 |
+
foreach ($source as $type => $src) {
|
28 |
+
$paths = glob($src . '*');
|
29 |
+
if ($paths) {
|
30 |
+
// package level
|
31 |
+
foreach ($paths as $path) {
|
32 |
+
$package = pathinfo($path, PATHINFO_FILENAME);
|
33 |
+
$paths = glob($path . DS . '*');
|
34 |
+
if ($paths) {
|
35 |
+
// theme level
|
36 |
+
foreach ($paths as $path) {
|
37 |
+
$theme = pathinfo($path, PATHINFO_FILENAME);
|
38 |
+
$tmp = $path . DS . 'template' . DS . 'aitcommonfiles' . DS;
|
39 |
+
if (!isset($pathes[$type][$package][$theme])) {
|
40 |
+
$pathes[$type][$package][$theme] = array();
|
41 |
+
}
|
42 |
+
$tmps = glob($tmp . '*');
|
43 |
+
if ($tmps) {
|
44 |
+
// customized templates found
|
45 |
+
foreach ($tmps as $file) {
|
46 |
+
$pathes[$type][$package][$theme][] = $file;
|
47 |
+
$this->_filesNumber++;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
$this->_collectedFiles = $pathes;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
protected function _getPatchesDir()
|
62 |
+
{
|
63 |
+
return Aitoc_Aitsys_Model_Platform::getInstance()->getVarPath() . Aitoc_Aitsys_Model_Aitpatch::PATCH_DIR;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @return array
|
68 |
+
*/
|
69 |
+
public function getAitcommonThemes()
|
70 |
+
{
|
71 |
+
return $this->_collectedFiles;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @return integer
|
76 |
+
*/
|
77 |
+
public function getFilesNumber()
|
78 |
+
{
|
79 |
+
return $this->_filesNumber;
|
80 |
+
}
|
81 |
+
}
|
app/code/community/Aitoc/Aitsys/Block/Rewriter/List.php
ADDED
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Block_Rewriter_List extends Aitoc_Aitsys_Abstract_Adminhtml_Block
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var array
|
9 |
+
*/
|
10 |
+
protected $_extensions = array();
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var array
|
14 |
+
*/
|
15 |
+
protected $_groups = array();
|
16 |
+
protected $_groupsBase = array();
|
17 |
+
|
18 |
+
protected $_statuses = array(0=>'Disabled', 1=>'Enabled' );
|
19 |
+
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
parent::_construct();
|
23 |
+
$this->setTitle('Rewrites Manager');
|
24 |
+
|
25 |
+
$this->_prepareConflictGroups();
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _prepareLayout()
|
29 |
+
{
|
30 |
+
if ($this->getRewriterStatus()) {
|
31 |
+
$this->setChild('change_status_button',
|
32 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
33 |
+
->setData(array(
|
34 |
+
'label' => Mage::helper('adminhtml')->__('Disable'),
|
35 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/disable') . '\')',
|
36 |
+
'class' => 'save'
|
37 |
+
)));
|
38 |
+
} else {
|
39 |
+
$this->setChild('change_status_button',
|
40 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
41 |
+
->setData(array(
|
42 |
+
'label' => Mage::helper('adminhtml')->__('Enable'),
|
43 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/enable') . '\')',
|
44 |
+
'class' => 'save'
|
45 |
+
)));
|
46 |
+
}
|
47 |
+
|
48 |
+
$this->setChild('save_button',
|
49 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
50 |
+
->setData(array(
|
51 |
+
'label' => Mage::helper('adminhtml')->__('Save changes'),
|
52 |
+
'onclick' => '$(\'rewritesForm\').submit()',
|
53 |
+
'class' => 'save',
|
54 |
+
))
|
55 |
+
);
|
56 |
+
|
57 |
+
$this->setChild('reset_button',
|
58 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
59 |
+
->setData(array(
|
60 |
+
'label' => Mage::helper('aitsys')->__('Reset rewrites order to default values'),
|
61 |
+
'onclick' => 'if (confirm(\'' . Mage::helper('aitsys')->__('Are you sure want to reset rewrites order?') . '\')) $(\'rewritesResetForm\').submit()',
|
62 |
+
'class' => 'cancel',
|
63 |
+
))
|
64 |
+
);
|
65 |
+
|
66 |
+
return parent::_prepareLayout();
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return string
|
71 |
+
*/
|
72 |
+
public function getSaveButtonHtml()
|
73 |
+
{
|
74 |
+
return $this->getChildHtml('save_button');
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @return string
|
79 |
+
*/
|
80 |
+
public function getResetButtonHtml()
|
81 |
+
{
|
82 |
+
return $this->getChildHtml('reset_button');
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @return string
|
87 |
+
*/
|
88 |
+
public function getChangeStatusButton()
|
89 |
+
{
|
90 |
+
return $this->getChildHtml('change_status_button');
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* @param $paramsMethod
|
95 |
+
* @return bool
|
96 |
+
*/
|
97 |
+
public function addClassesInGroupArray(&$paramsMethod)
|
98 |
+
{
|
99 |
+
if(!empty($paramsMethod['inheritedClasses']['_baseClasses']))
|
100 |
+
{
|
101 |
+
$this->_groupsBase[$paramsMethod['baseClass']] = $paramsMethod['inheritedClasses']['_baseClasses'];
|
102 |
+
unset($paramsMethod['inheritedClasses']['_baseClasses']);
|
103 |
+
}
|
104 |
+
$this->_groups[$paramsMethod['baseClass']] = array_keys($paramsMethod['inheritedClasses']);
|
105 |
+
rsort($this->_groups[$paramsMethod['baseClass']]);
|
106 |
+
$this->_groups[$paramsMethod['baseClass']] = array_values($this->_groups[$paramsMethod['baseClass']]);
|
107 |
+
|
108 |
+
return true;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Retrieve conflicts data
|
113 |
+
*/
|
114 |
+
protected function _prepareConflictGroups()
|
115 |
+
{
|
116 |
+
$allExtensions = array();
|
117 |
+
$currentExtension = Mage::app()->getRequest()->getParam('extension');
|
118 |
+
|
119 |
+
|
120 |
+
$rewriteHelper = Mage::helper('aitsys/rewriter');
|
121 |
+
$result = array();
|
122 |
+
if ($rewriteHelper->analysisInheritedClasses($this, 'addClassesInGroupArray', $result, false))
|
123 |
+
{
|
124 |
+
$order = Mage::helper('aitsys/rewriter')->getOrderConfig();
|
125 |
+
$groups = $this->_groups;
|
126 |
+
foreach ($groups as $baseClass => $group) {
|
127 |
+
$groups[$baseClass] = array_flip($group);
|
128 |
+
$isCurrentFound = !(bool)$currentExtension;
|
129 |
+
$savedRewritesValid = Mage::helper('aitsys/rewriter')->validateSavedClassConfig(
|
130 |
+
(isset($order[$baseClass]) ? $order[$baseClass] : array()),
|
131 |
+
array_keys($groups[$baseClass])
|
132 |
+
);
|
133 |
+
|
134 |
+
foreach ($groups[$baseClass] as $class => $i) {
|
135 |
+
if (isset($order[$baseClass][$class]) && $savedRewritesValid) {
|
136 |
+
$groups[$baseClass][$class] = $order[$baseClass][$class];
|
137 |
+
}
|
138 |
+
|
139 |
+
// adding class to the list of all extensions
|
140 |
+
$key = substr($class, 0, strpos($class, '_', 1 + strpos($class, '_')));
|
141 |
+
// ^^^^^^^^^^^^^^^^^^^^^ --- this is offset, so start searching second "_"
|
142 |
+
$allExtensions[] = $key;
|
143 |
+
if ($key == $currentExtension) {
|
144 |
+
$isCurrentFound = true;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
$groups[$baseClass] = array_flip($groups[$baseClass]);
|
149 |
+
ksort($groups[$baseClass]);
|
150 |
+
if (!$isCurrentFound || in_array($baseClass, Mage::helper('aitsys/rewriter')->getExcludeClassesConfig())) {
|
151 |
+
// will display conflicts only for groups where current selected extension presents
|
152 |
+
// exclude conflicts for excluded base Magento classes
|
153 |
+
unset($groups[$baseClass]);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
$aModuleList = $this->tool()->platform()->getModules();
|
159 |
+
$allExtensions = array_unique($allExtensions);
|
160 |
+
foreach ($allExtensions as $key) {
|
161 |
+
$moduleName = $key;
|
162 |
+
foreach ($aModuleList as $moduleItem) {
|
163 |
+
if ($key == $moduleItem->getKey()) {
|
164 |
+
$moduleName = (string)$moduleItem->getLabel();
|
165 |
+
}
|
166 |
+
}
|
167 |
+
$this->_extensions[$this->getExtensionUrl($key)] = $moduleName;
|
168 |
+
}
|
169 |
+
|
170 |
+
if(!empty($groups))
|
171 |
+
{
|
172 |
+
$this->_groups = $groups;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* @return array
|
178 |
+
*/
|
179 |
+
public function getConflictGroups()
|
180 |
+
{
|
181 |
+
return $this->_groups;
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* @return array
|
186 |
+
*/
|
187 |
+
public function getExtensions()
|
188 |
+
{
|
189 |
+
return $this->_extensions;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* @return string
|
194 |
+
*/
|
195 |
+
public function getSaveUrl()
|
196 |
+
{
|
197 |
+
return $this->getUrl('*/*/save', array('_current'=>true));
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* @return string
|
202 |
+
*/
|
203 |
+
public function getResetUrl()
|
204 |
+
{
|
205 |
+
return $this->getUrl('*/*/reset', array('_current'=>true));
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* @return string
|
210 |
+
*/
|
211 |
+
public function getSelfUrl()
|
212 |
+
{
|
213 |
+
return $this->getUrl('*/*/*', array('_current'=>true));
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* @param string $extension
|
218 |
+
*
|
219 |
+
* @return string
|
220 |
+
*/
|
221 |
+
public function getExtensionUrl($extension)
|
222 |
+
{
|
223 |
+
if ($extension) {
|
224 |
+
return $this->getUrl('*/*/*', array('extension' => $extension));
|
225 |
+
}
|
226 |
+
return $this->getUrl('*/*/*');
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* @return string
|
231 |
+
*/
|
232 |
+
public function getExcludedClasses()
|
233 |
+
{
|
234 |
+
$classes = Mage::helper('aitsys/rewriter')->getExcludeClassesConfig();
|
235 |
+
$classes = implode("\n", $classes);
|
236 |
+
return $classes;
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* @return string
|
241 |
+
*/
|
242 |
+
public function getRewriterStatus()
|
243 |
+
{
|
244 |
+
return Mage::helper('aitsys/rewriter')->getRewriterStatus();
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* @return string
|
249 |
+
*/
|
250 |
+
public function getRewriterCacheStatus()
|
251 |
+
{
|
252 |
+
if($this->getRewriterStatus())
|
253 |
+
{
|
254 |
+
return (int) Mage::app()->useCache('aitsys');
|
255 |
+
}
|
256 |
+
return 0;
|
257 |
+
}
|
258 |
+
|
259 |
+
public function getStatusLabel($id)
|
260 |
+
{
|
261 |
+
return $this->_statuses[$id];
|
262 |
+
}
|
263 |
+
|
264 |
+
protected function _getBaseClass($class, $classBaseEcho)
|
265 |
+
{
|
266 |
+
if(empty($this->_groupsBase[$class]))
|
267 |
+
{
|
268 |
+
return false;
|
269 |
+
}
|
270 |
+
|
271 |
+
if(empty($classBaseEcho))
|
272 |
+
{
|
273 |
+
return $this->_groupsBase[$class]['__topClass'];
|
274 |
+
}
|
275 |
+
|
276 |
+
return empty($this->_groupsBase[$class][$classBaseEcho])?false:$this->_groupsBase[$class][$classBaseEcho];
|
277 |
+
}
|
278 |
+
}
|
app/code/community/Aitoc/Aitsys/Block/Rewriter/Notifications.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Block_Rewriter_Notifications extends Aitoc_Aitsys_Abstract_Adminhtml_Block
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @return bool
|
9 |
+
*/
|
10 |
+
public function isShow()
|
11 |
+
{
|
12 |
+
$aitsysCache = Mage::app()->useCache('aitsys');
|
13 |
+
if (!$aitsysCache && in_array(1, Mage::app()->useCache()) && Mage::helper('aitsys/rewriter')->getRewriterStatus()) {
|
14 |
+
return true;
|
15 |
+
}
|
16 |
+
return false;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Get cache management url
|
21 |
+
*
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function getManageUrl()
|
25 |
+
{
|
26 |
+
return $this->getUrl('adminhtml/cache');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* ACL validation before html generation
|
31 |
+
*
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
protected function _toHtml()
|
35 |
+
{
|
36 |
+
if (Mage::getSingleton('admin/session')->isAllowed('system/cache')) {
|
37 |
+
return parent::_toHtml();
|
38 |
+
}
|
39 |
+
return '';
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Aitoc/Aitsys/Block/System/Config/Frontend/Extensions.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Aitoc_Aitsys_Block_System_Config_Frontend_Extensions
|
4 |
+
extends Mage_Adminhtml_Block_Abstract
|
5 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
6 |
+
{
|
7 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
8 |
+
{
|
9 |
+
$html = '<h3 style="margin:15px 0;">'.Mage::helper('aitsys')->__('To Enabe/Disable AITOC extensions click here').' <a href="'.Mage::helper("adminhtml")->getUrl("aitsys/index/index").'" >'.Mage::helper('aitsys')->__('Manage Aitoc Modules').'</a></h3>';
|
10 |
+
|
11 |
+
return $html;
|
12 |
+
}
|
13 |
+
}
|
app/code/community/Aitoc/Aitsys/Helper/Data.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Helper_Data extends Aitoc_Aitsys_Abstract_Helper
|
6 |
+
{
|
7 |
+
protected $_hasStagingModule = null;
|
8 |
+
protected $_mysqlTimeoutWarningValue = 120;
|
9 |
+
protected $_testConnectionResult = null;
|
10 |
+
|
11 |
+
public function getErrorText($code)
|
12 |
+
{
|
13 |
+
$args = func_get_args();
|
14 |
+
try
|
15 |
+
{
|
16 |
+
$args[0] = Mage::getStoreConfig('aitsys/errors/'.$code.'/text');
|
17 |
+
}
|
18 |
+
catch (Mage_Core_Model_Store_Exception $exc)
|
19 |
+
{
|
20 |
+
$args[0] = $code;
|
21 |
+
}
|
22 |
+
return call_user_func_array(array($this,'__'),$args);
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getErrorCode($code)
|
26 |
+
{
|
27 |
+
return Mage::getStoreConfig('aitsys/errors/'.$code.'/code');
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getModuleLicenseUpgradeLink( Aitoc_Aitsys_Model_Module $module , $onlyUrl = true )
|
31 |
+
{
|
32 |
+
if ($license = $module->getLicense())
|
33 |
+
{
|
34 |
+
$licenseId = $license->getLicenseId();
|
35 |
+
}
|
36 |
+
else
|
37 |
+
{
|
38 |
+
return '';
|
39 |
+
}
|
40 |
+
$url = $module->getStoreUrl().'aitcprod/license/upgrade/license_id/'.$licenseId;
|
41 |
+
if ($onlyUrl)
|
42 |
+
{
|
43 |
+
return $url;
|
44 |
+
}
|
45 |
+
return '<a target="_blank" href="'.$url.'">'.$this->__('Buy license upgrade').'</a>';
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getModuleSupportLink( Aitoc_Aitsys_Model_Module $module , $onlyUrl = true )
|
49 |
+
{
|
50 |
+
$url = $this->tool()->getAitocUrl() . 'contacts.html?';
|
51 |
+
if ($serial = $module->getInfo()->getSerial()) {
|
52 |
+
$url .= $serial . '&';
|
53 |
+
}
|
54 |
+
if ($moduleId = $module->getInfo()->getProductId()) {
|
55 |
+
$url .= $moduleId . '&';
|
56 |
+
}
|
57 |
+
$url .= 'support';
|
58 |
+
|
59 |
+
if ($onlyUrl)
|
60 |
+
{
|
61 |
+
return $url;
|
62 |
+
}
|
63 |
+
return '<a target="_blank" href="'.$url.'">'.$this->__('Create support ticket').'</a>';
|
64 |
+
}
|
65 |
+
|
66 |
+
public function hasStagingModule()
|
67 |
+
{
|
68 |
+
if($this->_hasStagingModule === null) {
|
69 |
+
$val = Mage::getConfig()->getNode('modules/Enterprise_Staging/active');
|
70 |
+
$this->_hasStagingModule = ((string)$val == 'true');
|
71 |
+
}
|
72 |
+
return $this->_hasStagingModule;
|
73 |
+
}
|
74 |
+
|
75 |
+
public function isMysqlTimeoutValueLow()
|
76 |
+
{
|
77 |
+
$timeout = $this->tool()->getWaitTimeout();
|
78 |
+
if($timeout < $this->_mysqlTimeoutWarningValue)
|
79 |
+
{
|
80 |
+
return true;
|
81 |
+
}
|
82 |
+
return false;
|
83 |
+
}
|
84 |
+
|
85 |
+
public function getMysqlTimeoutValue()
|
86 |
+
{
|
87 |
+
return $this->tool()->getWaitTimeout();
|
88 |
+
}
|
89 |
+
|
90 |
+
public function isTestConnectPassed()
|
91 |
+
{
|
92 |
+
if(is_null($this->_testConnectionResult)) {
|
93 |
+
if( $this->isMysqlTimeoutValueLow() ) {
|
94 |
+
//allow connection only when sql timeout set to big value, because it may affect even test connection
|
95 |
+
$this->_testConnectionResult = true;
|
96 |
+
return $this->_testConnectionResult;
|
97 |
+
}
|
98 |
+
$service = $this->tool()->platform()->getService();
|
99 |
+
$this->_testConnectionResult = true;
|
100 |
+
try
|
101 |
+
{
|
102 |
+
$this->_testConnectionResult = $service->testConnection();
|
103 |
+
}
|
104 |
+
catch (Exception $exc)
|
105 |
+
{
|
106 |
+
if($exc->getCode() >= 400 && $exc->getCode() < 500)
|
107 |
+
{
|
108 |
+
//$this->_testConnectionResult = 'Error code '.$exc->getCode().': '.$exc->getMessage();
|
109 |
+
return 'INSTALL_TEST_CONNECTION_FAILED';
|
110 |
+
}
|
111 |
+
if($exc->getCode() >= 500 && $exc->getCode() < 600)
|
112 |
+
{
|
113 |
+
//$this->_testConnectionResult = 'Error code '.$exc->getCode().': '.$exc->getMessage();
|
114 |
+
return 'INSTALL_TEST_SERVER_ERROR';
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
}
|
119 |
+
|
120 |
+
return $this->_testConnectionResult;
|
121 |
+
}
|
122 |
+
}
|
app/code/community/Aitoc/Aitsys/Helper/License.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Helper_License extends Aitoc_Aitsys_Helper_Data
|
6 |
+
{
|
7 |
+
public function uninstallBefore(){}
|
8 |
+
public function installBefore(){}
|
9 |
+
}
|
app/code/community/Aitoc/Aitsys/Helper/Rewriter.php
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Helper_Rewriter extends Aitoc_Aitsys_Helper_Data
|
6 |
+
{
|
7 |
+
public function getOrderConfig()
|
8 |
+
{
|
9 |
+
$order = unserialize( (string) Mage::getConfig()->getNode('default/aitsys_rewriter_classorder') );
|
10 |
+
if (!$order) {
|
11 |
+
$order = array();
|
12 |
+
}
|
13 |
+
return $order;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function saveOrderConfig($order)
|
17 |
+
{
|
18 |
+
Mage::getConfig()->saveConfig('aitsys_rewriter_classorder', serialize($order));
|
19 |
+
Mage::app()->cleanCache();
|
20 |
+
}
|
21 |
+
|
22 |
+
public function mergeOrderConfig($order)
|
23 |
+
{
|
24 |
+
$currentOrder = unserialize( (string) Mage::getConfig()->getNode('default/aitsys_rewriter_classorder') );
|
25 |
+
if (!$currentOrder)
|
26 |
+
{
|
27 |
+
$newOrder = $order;
|
28 |
+
} else
|
29 |
+
{
|
30 |
+
$newOrder = array_merge($currentOrder, $order);
|
31 |
+
}
|
32 |
+
$this->saveOrderConfig($newOrder);
|
33 |
+
}
|
34 |
+
|
35 |
+
public function removeOrderConfig()
|
36 |
+
{
|
37 |
+
Mage::getConfig()->deleteConfig('aitsys_rewriter_classorder');
|
38 |
+
Mage::app()->cleanCache();
|
39 |
+
}
|
40 |
+
|
41 |
+
public function saveExcludeClassesConfig($classes)
|
42 |
+
{
|
43 |
+
$classes = array_map('trim', preg_split("/[\n,]+/", $classes));
|
44 |
+
Mage::getConfig()->saveConfig('aitsys_rewriter_exclude_classes', serialize($classes));
|
45 |
+
Mage::app()->cleanCache();
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getExcludeClassesConfig()
|
49 |
+
{
|
50 |
+
$configValue = (string) Mage::getConfig()->getNode('default/aitsys_rewriter_exclude_classes');
|
51 |
+
$configValue = $this->tool()->unserialize($configValue);
|
52 |
+
if (!$configValue) {
|
53 |
+
$configValue = array();
|
54 |
+
}
|
55 |
+
return $configValue;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function validateSavedClassConfig($savedClassConfig, $rewriteClasses)
|
59 |
+
{
|
60 |
+
if(!is_array($savedClassConfig) || !is_array($rewriteClasses))
|
61 |
+
{
|
62 |
+
return false;
|
63 |
+
}
|
64 |
+
|
65 |
+
$savedClasses = array_keys($savedClassConfig);
|
66 |
+
|
67 |
+
if(count($rewriteClasses)!=count($savedClasses))
|
68 |
+
{
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
|
72 |
+
$diff1 = array_diff($rewriteClasses, $savedClasses);
|
73 |
+
$diff2 = array_diff($savedClasses, $rewriteClasses);
|
74 |
+
|
75 |
+
if(!empty($diff1) || !empty($diff2))
|
76 |
+
{
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
return true;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
public function getRewriterStatus()
|
88 |
+
{
|
89 |
+
return Mage::getStoreConfig('aitsys/rewriter_status');
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Found all Inherited Classes and run method for analysis
|
94 |
+
*
|
95 |
+
* @param $object
|
96 |
+
* @param $method
|
97 |
+
* @param array $params
|
98 |
+
* @param bool $useOrdering
|
99 |
+
* @return bool
|
100 |
+
*/
|
101 |
+
public function analysisInheritedClasses($object, $method, &$params = array(), $useOrdering = true)
|
102 |
+
{
|
103 |
+
$rewriterConflictModel = new Aitoc_Aitsys_Model_Rewriter_Conflict();
|
104 |
+
$conflicts = $rewriterConflictModel->getConflictList();
|
105 |
+
|
106 |
+
// will combine rewrites by alias groups
|
107 |
+
if (!empty($conflicts)) {
|
108 |
+
$rewriterClassModel = new Aitoc_Aitsys_Model_Rewriter_Class();
|
109 |
+
$rewriterInheritanceModel = new Aitoc_Aitsys_Model_Rewriter_Inheritance();
|
110 |
+
$result = false;
|
111 |
+
foreach($conflicts as $groupType => $modules) {
|
112 |
+
$groupType = substr($groupType, 0, -1);
|
113 |
+
foreach($modules as $moduleName => $moduleRewrites) {
|
114 |
+
foreach($moduleRewrites['rewrite'] as $moduleClass => $rewriteClasses) {
|
115 |
+
// building inheritance tree
|
116 |
+
$alias = $moduleName . '/' . $moduleClass;
|
117 |
+
$baseClass = $rewriterClassModel->getBaseClass($groupType, $alias);
|
118 |
+
$inheritedClasses = $rewriterInheritanceModel->build($rewriteClasses, $baseClass, $useOrdering);
|
119 |
+
if ($inheritedClasses == false) {
|
120 |
+
continue;
|
121 |
+
}
|
122 |
+
$paramsMethod = array(
|
123 |
+
'rewriteClasses' => $rewriteClasses,
|
124 |
+
'alias' => $alias,
|
125 |
+
'baseClass' => $baseClass,
|
126 |
+
'inheritedClasses' => $inheritedClasses,
|
127 |
+
'params' => &$params
|
128 |
+
);
|
129 |
+
$result = $object->$method($paramsMethod)?true:$result;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
return $result;
|
134 |
+
}
|
135 |
+
|
136 |
+
return false;
|
137 |
+
}
|
138 |
+
|
139 |
+
}
|
app/code/community/Aitoc/Aitsys/Helper/Statistics.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2012 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Helper_Statistics extends Aitoc_Aitsys_Helper_Data
|
6 |
+
{
|
7 |
+
public function getServerInfo()
|
8 |
+
{
|
9 |
+
return array(
|
10 |
+
'name' => isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '!!!' ,
|
11 |
+
'host' => isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '!!!' ,
|
12 |
+
'addr' => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '!!!',
|
13 |
+
'os' => PHP_OS,
|
14 |
+
'php_version' => PHP_VERSION,
|
15 |
+
'apc' => (int)function_exists('apc_cache_info')
|
16 |
+
);
|
17 |
+
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Aitoc/Aitsys/Helper/Strings.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Helper_Strings extends Aitoc_Aitsys_Helper_Data
|
6 |
+
{
|
7 |
+
//install license notifications
|
8 |
+
const INSTALL_MYSQL_TIMEOUT_NOTIFICATION = 'Due to the small value (%s) of "wait_timeout" parameter an automatic installation of the extensions can result in error. If after clicking "Proceed to install" you will get an error, you might try to increase the value of the parameter to a higher one in the MySQL configuration and then attempt to install the license once again. Or you may contact our support team asking them to configure the manual license for you instead. In case of contacting our support service make sure you have also indicated an URL to the administrative area.';
|
9 |
+
const INSTALL_TEST_CONNECTION_FAILED = 'An established connection with the AITOC server "%s" is required in order to proceed with the installation of the extension. Please check your firewall and server configurations in order to allow outbound SSL queries to the given server.';
|
10 |
+
const INSTALL_TEST_SERVER_ERROR = 'AITOC server "%s" is not available at the moment and the installation cannot be completed. Please try again in 10 minutes. Sorry for the inconvenience.';
|
11 |
+
|
12 |
+
//errors
|
13 |
+
const ER_ENT_HASH = 'The extension isn\'t compatible with this edition of Magento. Please contact us at sales@aitoc.com for further instructions. Please note that our working hours are Mon-Fri, 8am - 5pm UTC.';
|
14 |
+
|
15 |
+
private $_errorStringDelimiter = "|||";
|
16 |
+
|
17 |
+
public function getString($const, $translate = true, $args = array())
|
18 |
+
{
|
19 |
+
if (!is_array($args)) {
|
20 |
+
$args = array($args);
|
21 |
+
}
|
22 |
+
|
23 |
+
$string = constant('self::'.$const);
|
24 |
+
$string = $translate ? $this->__($string) : $string;
|
25 |
+
|
26 |
+
array_unshift($args, $string);
|
27 |
+
|
28 |
+
return call_user_func_array('sprintf', $args);
|
29 |
+
}
|
30 |
+
|
31 |
+
public function parseErrorString($error)
|
32 |
+
{
|
33 |
+
return explode($this->_errorStringDelimiter, $error);
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getModuleConflictString($module)
|
37 |
+
{
|
38 |
+
if (($conflictClasses = $module->getConflictClasses()) && ($conflictModules = $module->getConflictModules())) {
|
39 |
+
$conflictString = array();
|
40 |
+
foreach($conflictClasses as $aitClass=>$otherClass)
|
41 |
+
{
|
42 |
+
$conflictString[] = $aitClass.': '.implode(', ', $otherClass);
|
43 |
+
}
|
44 |
+
$string = Mage::helper('aitsys')->__('Please <a href="%s">enable</a> our Automatic conflict resolution system under <a href="%s">Manage Class rewrites</a> by clicking the Enable button ',Mage::getModel('adminhtml/url')->getUrl('*/rewriter/enable'),Mage::getModel('adminhtml/url')->getUrl('*/rewriter') );
|
45 |
+
$string .= '<span class="noBold">'.Mage::helper('aitsys')->__('to resolve the following issues: %s has a conflict with %s in the following classes %s. ', implode(', ', $conflictModules), $module->getInfo()->getLabel(), implode(', ', $conflictString));
|
46 |
+
$string .= '<br>'.Mage::helper('aitsys')->__('Or if you are familiar with web development you can edit the affected classes yourself manually.');
|
47 |
+
$string .= '<br>'.Mage::helper('aitsys')->__('If none of the above helps please submit a <a href="%s">support ticket</a>', Mage::helper('aitsys')->getModuleSupportLink($module, true)).'</span>';
|
48 |
+
return $string;
|
49 |
+
}
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Aitfilepatcher.php
ADDED
@@ -0,0 +1,504 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Aitfilepatcher extends Aitoc_Aitsys_Abstract_Model
|
6 |
+
{
|
7 |
+
private $_aChanges = array();
|
8 |
+
|
9 |
+
public function parsePatch($sPatchStr, $bSaveEmpty = true)
|
10 |
+
{
|
11 |
+
$this->_aChanges = array();
|
12 |
+
$aStrings = explode("\n", $sPatchStr);
|
13 |
+
$iCurrentLine = 0;
|
14 |
+
$iLinesCount = count($aStrings);
|
15 |
+
|
16 |
+
//look all strings
|
17 |
+
while($iCurrentLine < $iLinesCount)
|
18 |
+
{
|
19 |
+
//if at current line begin new change
|
20 |
+
if ('diff' == substr($aStrings[$iCurrentLine],0,4))
|
21 |
+
{
|
22 |
+
//go to string with name of destination file
|
23 |
+
$iCurrentLine += 2;
|
24 |
+
//find name of destination file
|
25 |
+
preg_match("!^\+\+\+ ([^\s]*)!", $aStrings[$iCurrentLine], $aRes);
|
26 |
+
if(isset($aRes[1]))
|
27 |
+
{
|
28 |
+
//init array with changes for current file
|
29 |
+
$aFileChanges = array(
|
30 |
+
'file' => substr($aRes[1],2),
|
31 |
+
'aChanges' => array(),
|
32 |
+
);
|
33 |
+
//go to line with count changed strings (like:" @@ -101,5 +101,9 @@")
|
34 |
+
$iCurrentLine++;
|
35 |
+
//wile next diff-line not found grabbing lines with changes
|
36 |
+
while( $iCurrentLine < $iLinesCount and 'diff' != substr($aStrings[$iCurrentLine], 0, 4) )
|
37 |
+
{
|
38 |
+
//get numbers of begin string, count strings in phpFox file, begin string, count strings in patched file
|
39 |
+
$aRes = array();
|
40 |
+
preg_match("!@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@!",$aStrings[$iCurrentLine],$aRes);
|
41 |
+
if(isset($aRes[1]))
|
42 |
+
{
|
43 |
+
$aChange = array(
|
44 |
+
'iBeginStr' => intval($aRes[1]),
|
45 |
+
'iCountStr' => isset($aRes[3])? intval($aRes[3]): $aChange['iBeginStr'],
|
46 |
+
'iBeginStrInModule' => intval($aRes[4]),
|
47 |
+
'iCountStrInModule' => isset($aRes[6])? intval($aRes[6]): $aChange['iCountStr'],
|
48 |
+
'aChangingStrings' => array(),
|
49 |
+
);
|
50 |
+
//go to first line with script changes
|
51 |
+
++$iCurrentLine;
|
52 |
+
//while next changes-block not found grabbing changes
|
53 |
+
while($iCurrentLine < $iLinesCount and in_array(substr($aStrings[$iCurrentLine], 0, 1), array(' ','+','-','\\')) )
|
54 |
+
{
|
55 |
+
$sFirstChar = substr($aStrings[$iCurrentLine],0,1);
|
56 |
+
$sStr = substr($aStrings[$iCurrentLine],1);
|
57 |
+
$sStrTrim = trim($sStr);
|
58 |
+
if('\\'!=$sFirstChar && ($bSaveEmpty || $sStrTrim))
|
59 |
+
{
|
60 |
+
//if not comment or warning save line info
|
61 |
+
$aChange['aChangingStrings'][] = array( $sFirstChar, $sStrTrim, $sStr);
|
62 |
+
}
|
63 |
+
//go to next line
|
64 |
+
++$iCurrentLine;
|
65 |
+
}
|
66 |
+
//add changes-block to changes of current file
|
67 |
+
$aFileChanges['aChanges'][] = $aChange;
|
68 |
+
}else{
|
69 |
+
//if numbers of begin string, count strings in phpFox file, begin string, count strings in patched file not found
|
70 |
+
// ERROR
|
71 |
+
++$iCurrentLine;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
//add changes of current file to $this->aChangeList
|
75 |
+
$this->_aChanges[] = $aFileChanges;
|
76 |
+
|
77 |
+
}else{
|
78 |
+
//if in second line after diff-line script can not find name of destination file
|
79 |
+
// ERROR
|
80 |
+
++$iCurrentLine;
|
81 |
+
}
|
82 |
+
}else{
|
83 |
+
++$iCurrentLine;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
return $this->_aChanges;
|
87 |
+
}
|
88 |
+
|
89 |
+
public function applyPatch($sApplyPatchTo)
|
90 |
+
{
|
91 |
+
$aErrors = array();
|
92 |
+
$aCurrentResultLines = $this->_getLinesWithModulesData($sApplyPatchTo);
|
93 |
+
$bThisModule = FALSE;
|
94 |
+
|
95 |
+
foreach ($this->_aChanges as $aFileChange)
|
96 |
+
{
|
97 |
+
foreach($aFileChange['aChanges'] as $iCurrentChange => $aChangeData)
|
98 |
+
{
|
99 |
+
$aTmpResult = array();
|
100 |
+
$iChangePoint = $this->_findChangesPoint($this->_getLinesWithoutModulesData($sApplyPatchTo), $aChangeData, array(' ', '-'));
|
101 |
+
$iCurrentFileLine = 0;
|
102 |
+
$iCntFileLine = count($aCurrentResultLines);
|
103 |
+
|
104 |
+
// copy lines before $iChangePoint
|
105 |
+
while( ('*'==$aCurrentResultLines[$iCurrentFileLine]['sType'] || ($iChangePoint!=$aCurrentResultLines[$iCurrentFileLine]['iPhpFoxLine'])) && $iCurrentFileLine<$iCntFileLine)
|
106 |
+
{
|
107 |
+
$aTmpResult[] = $aCurrentResultLines[$iCurrentFileLine];
|
108 |
+
++$iCurrentFileLine;
|
109 |
+
}
|
110 |
+
|
111 |
+
//insert changes
|
112 |
+
foreach($aChangeData['aChangingStrings'] as $iPatchLine => $aStrInfo)
|
113 |
+
{
|
114 |
+
//if PatchLine is FoxLine
|
115 |
+
if (' ' == $aStrInfo[0])
|
116 |
+
{
|
117 |
+
//close module comment if need
|
118 |
+
if($bThisModule)
|
119 |
+
{
|
120 |
+
/*
|
121 |
+
$sCommentStr = $this->_makeStrComment('end', $aFileChange['file']);
|
122 |
+
$aTmpResult[] = array(
|
123 |
+
'iPhpFoxLine' => FALSE,
|
124 |
+
'sType' => '*',
|
125 |
+
'sStr' => $sCommentStr,
|
126 |
+
'sStrBefore' => $sCommentStr,
|
127 |
+
);
|
128 |
+
*/
|
129 |
+
$bThisModule = FALSE;
|
130 |
+
}
|
131 |
+
|
132 |
+
//copy empty strings from base file (before changes)
|
133 |
+
|
134 |
+
while( ($iCurrentFileLine < $iCntFileLine) && $aCurrentResultLines[$iCurrentFileLine]['sStr'] !== $aStrInfo[1])
|
135 |
+
{
|
136 |
+
$aTmpResult[] = $aCurrentResultLines[$iCurrentFileLine];
|
137 |
+
$iCurrentFileLine++;
|
138 |
+
}
|
139 |
+
|
140 |
+
//insert current string from base file
|
141 |
+
if ( isset($aCurrentResultLines[$iCurrentFileLine]) && $aCurrentResultLines[$iCurrentFileLine]['sStr'] === $aStrInfo[1] )
|
142 |
+
{
|
143 |
+
$aTmpResult[] = $aCurrentResultLines[$iCurrentFileLine];
|
144 |
+
$iCurrentFileLine++;
|
145 |
+
|
146 |
+
}else{
|
147 |
+
$aErrors[] = 'Error patching';
|
148 |
+
break(2);
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
//if New string
|
153 |
+
if ('+' == $aStrInfo[0])
|
154 |
+
{
|
155 |
+
if(!$bThisModule)
|
156 |
+
{
|
157 |
+
/*
|
158 |
+
$sCommentStr = $this->_makeStrComment('begin', $aFileChange['file']);
|
159 |
+
$aTmpResult[] = array(
|
160 |
+
'iPhpFoxLine' => FALSE,
|
161 |
+
'sType' => '*',
|
162 |
+
'sStr' => $sCommentStr,
|
163 |
+
'sStrBefore' => $sCommentStr . PHP_EOL,
|
164 |
+
);
|
165 |
+
|
166 |
+
$sCommentStr = $this->_makeStrComment('module', $aFileChange['file']);
|
167 |
+
$aTmpResult[] = array(
|
168 |
+
'iPhpFoxLine' => FALSE,
|
169 |
+
'sType' => '*',
|
170 |
+
'sStr' => $sCommentStr,
|
171 |
+
'sStrBefore' => $sCommentStr . PHP_EOL,
|
172 |
+
);
|
173 |
+
*/
|
174 |
+
$bThisModule = TRUE;
|
175 |
+
}
|
176 |
+
$aTmpResult[] = array(
|
177 |
+
'iPhpFoxLine' => FALSE,
|
178 |
+
'sType' => '*',
|
179 |
+
'sStr' => $aStrInfo[1],
|
180 |
+
'sStrBefore' => $aStrInfo[2] . PHP_EOL,
|
181 |
+
);
|
182 |
+
}
|
183 |
+
|
184 |
+
if('-'==$aStrInfo[0])
|
185 |
+
{
|
186 |
+
if ( !isset($aCurrentResultLines[$iCurrentFileLine]) || $aCurrentResultLines[$iCurrentFileLine]['sStr'] !== $aStrInfo[1] )
|
187 |
+
{
|
188 |
+
$aErrors[] = 'Error patching';;
|
189 |
+
break(2);
|
190 |
+
}
|
191 |
+
$iCurrentFileLine++;
|
192 |
+
}
|
193 |
+
// end process current patch-line
|
194 |
+
}
|
195 |
+
|
196 |
+
if($bThisModule)
|
197 |
+
{
|
198 |
+
/*
|
199 |
+
$sCommentStr = $this->_makeStrComment('end', $aFileChange['file']);
|
200 |
+
$aTmpResult[] = array(
|
201 |
+
'iPhpFoxLine' => FALSE,
|
202 |
+
'sType' => '*',
|
203 |
+
'sStr' => $sCommentStr,
|
204 |
+
'sStrBefore' => $sCommentStr,
|
205 |
+
);
|
206 |
+
*/
|
207 |
+
$bThisModule = FALSE;
|
208 |
+
}
|
209 |
+
|
210 |
+
//keep other file strings
|
211 |
+
|
212 |
+
while($iCurrentFileLine<$iCntFileLine)
|
213 |
+
{
|
214 |
+
$aTmpResult[] = $aCurrentResultLines[$iCurrentFileLine++];
|
215 |
+
}
|
216 |
+
|
217 |
+
$aCurrentResultLines = $aTmpResult;
|
218 |
+
// end process current changes
|
219 |
+
|
220 |
+
}// end changes
|
221 |
+
}
|
222 |
+
|
223 |
+
// write $aResult in to to file $aFileChange['file']
|
224 |
+
if ( 0==count($aErrors) )
|
225 |
+
{
|
226 |
+
if($hFile = fopen($sApplyPatchTo, 'w') )
|
227 |
+
{
|
228 |
+
if (strstr($sApplyPatchTo,'.phtml'))
|
229 |
+
{
|
230 |
+
$comment =
|
231 |
+
"<?php /* !!!ATTENTION!!! PLEASE DO NOT MODIFY THE FILE!
|
232 |
+
Copy it preserving its path from the var/ait_path folder to the
|
233 |
+
app folder. i.e. in var/ait_path folder the file is located in folder 1,
|
234 |
+
then in the app folder you also need to make folder 1 and put the file in it.
|
235 |
+
*/ ?>";
|
236 |
+
fwrite($hFile,$comment);
|
237 |
+
}
|
238 |
+
foreach($aCurrentResultLines as $aStrInfo)
|
239 |
+
{
|
240 |
+
if (fwrite($hFile, $aStrInfo['sStrBefore']) === FALSE) {
|
241 |
+
$sMsg = 'Error writing to file';
|
242 |
+
$aErrors[] = $sMsg;
|
243 |
+
break;
|
244 |
+
}
|
245 |
+
}
|
246 |
+
fclose($hFile);
|
247 |
+
|
248 |
+
}
|
249 |
+
else
|
250 |
+
{
|
251 |
+
$sMsg = 'Error opening file';
|
252 |
+
$aErrors[] = $sMsg;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
unset($aCurrentResultLines);
|
257 |
+
}
|
258 |
+
|
259 |
+
public function canApplyChanges($sFileToPatch)
|
260 |
+
{
|
261 |
+
$aLines = $this->_getLinesWithoutModulesData($sFileToPatch);
|
262 |
+
$bResult = TRUE;
|
263 |
+
foreach ($this->_aChanges as $aFileChange)
|
264 |
+
{
|
265 |
+
foreach($aFileChange['aChanges'] as $aChangeData)
|
266 |
+
{
|
267 |
+
if (FALSE===$this->_findChangesPoint($aLines, $aChangeData, array(' ', )))
|
268 |
+
{
|
269 |
+
$bResult = FALSE;
|
270 |
+
break;
|
271 |
+
}
|
272 |
+
}
|
273 |
+
}
|
274 |
+
return $bResult;
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* $aCangesTypes array chars, it's can be: ' ','+','-' (types of strings in patch)
|
279 |
+
*/
|
280 |
+
function _findChangesPoint($aLines, $aChangeData, $aCangesTypes )
|
281 |
+
{
|
282 |
+
$iCntPatchLines = count($aChangeData['aChangingStrings']);
|
283 |
+
$iCntFoxLines = count($aLines);
|
284 |
+
$aStartMatches = array();
|
285 |
+
for($iFoxLine=$aChangeData['iBeginStr']-1; $iFoxLine < $iCntFoxLines; ++$iFoxLine)
|
286 |
+
{
|
287 |
+
$bPointOfMatch = TRUE;
|
288 |
+
$iCurFoxLine = $iFoxLine;
|
289 |
+
for($iCurPatchLine=0 ; ($bPointOfMatch && ($iCurPatchLine<$iCntPatchLines) && ($iCurFoxLine < $iCntFoxLines) ) ; ++$iCurPatchLine)
|
290 |
+
{
|
291 |
+
if ( in_array( $aChangeData['aChangingStrings'][$iCurPatchLine][0], $aCangesTypes ))
|
292 |
+
{
|
293 |
+
//d('fox:'.$aLines[$iCurFoxLine]['sStr'].'=='.$aChangeData['aChangingStrings'][$iCurPatchLine][1]);
|
294 |
+
if($aLines[$iCurFoxLine]['sStr'] != $aChangeData['aChangingStrings'][$iCurPatchLine][1])
|
295 |
+
{
|
296 |
+
$bPointOfMatch = FALSE;
|
297 |
+
}
|
298 |
+
//else{d('$iCurFoxLine='.$iCurFoxLine);}
|
299 |
+
++$iCurFoxLine;
|
300 |
+
}
|
301 |
+
}
|
302 |
+
if($bPointOfMatch AND $iCurPatchLine == $iCntPatchLines)
|
303 |
+
{
|
304 |
+
//$aStartMatches[] = $aLines[$iFoxLine]['iPhpFoxLine'];
|
305 |
+
return $aLines[$iFoxLine]['iPhpFoxLine'];
|
306 |
+
}
|
307 |
+
}
|
308 |
+
return (1 == count($aStartMatches))? $aStartMatches[0] : FALSE;
|
309 |
+
}
|
310 |
+
|
311 |
+
/** get lines with other modules data
|
312 |
+
* @param string $sFile File name
|
313 |
+
* @return array lines with other modules data
|
314 |
+
* @access private
|
315 |
+
*/
|
316 |
+
function _getLinesWithModulesData($sFile)//, $bSaveThisModule=TRUE
|
317 |
+
{
|
318 |
+
if(!file_exists($sFile))
|
319 |
+
{
|
320 |
+
$aErrors[] = 'No File';
|
321 |
+
return array();
|
322 |
+
}
|
323 |
+
$aLines = file($sFile);
|
324 |
+
$aResult = array();
|
325 |
+
$iPhpFoxLineNum = 0;
|
326 |
+
$iFileLineNum = 0;
|
327 |
+
$bModulesString = FALSE;
|
328 |
+
$bThisModuleString = FALSE;
|
329 |
+
foreach($aLines as $i => $sStr)
|
330 |
+
{
|
331 |
+
$sStr = trim($aLines[$i]);
|
332 |
+
//if($bSaveEmpty || $sStr)
|
333 |
+
{
|
334 |
+
/*
|
335 |
+
if ($this->_isModuleComment($sStr, 'begin', $sFile))
|
336 |
+
{
|
337 |
+
$bModulesString = TRUE;
|
338 |
+
if ($this->_isModuleComment($aLines[$i+1], 'module', $sFile ))
|
339 |
+
{
|
340 |
+
$bThisModuleString = TRUE;
|
341 |
+
}
|
342 |
+
}
|
343 |
+
*/
|
344 |
+
|
345 |
+
// $bThisModuleString is always false for now :)
|
346 |
+
if(!$bThisModuleString)
|
347 |
+
{
|
348 |
+
$aResult[$iFileLineNum] = array(
|
349 |
+
'iPhpFoxLine' => $bModulesString? 0:$iPhpFoxLineNum,
|
350 |
+
'sType' => $bModulesString? '*': ' ',
|
351 |
+
'sStr' => $sStr,
|
352 |
+
'sStrBefore' => $aLines[$i],
|
353 |
+
);
|
354 |
+
++$iFileLineNum;
|
355 |
+
++$iPhpFoxLineNum;
|
356 |
+
}
|
357 |
+
|
358 |
+
/*
|
359 |
+
if ($this->_isModuleComment($sStr, 'end', $sFile))
|
360 |
+
{
|
361 |
+
$bModulesString = FALSE;
|
362 |
+
$bThisModuleString = FALSE;
|
363 |
+
}
|
364 |
+
*/
|
365 |
+
}
|
366 |
+
}
|
367 |
+
return $aResult;
|
368 |
+
}
|
369 |
+
|
370 |
+
/** get lines without any modules data
|
371 |
+
* @param string $sFile File name
|
372 |
+
* @return array lines without any modules data
|
373 |
+
* @access private
|
374 |
+
*/
|
375 |
+
private function _getLinesWithoutModulesData($sFile, $bSaveThisModule=FALSE, $bSaveEmpty = true)
|
376 |
+
{
|
377 |
+
if(!file_exists($sFile))
|
378 |
+
{
|
379 |
+
$aErrors[] = 'No File';
|
380 |
+
return array();
|
381 |
+
}
|
382 |
+
|
383 |
+
$aLines = file($sFile);
|
384 |
+
$aResult = array();
|
385 |
+
$bEgnoreString = FALSE;
|
386 |
+
$iCntFoxLines = count($aLines);
|
387 |
+
$iFoxLineNum = 0;
|
388 |
+
for($i=0; $i<$iCntFoxLines ; ++$i)
|
389 |
+
{
|
390 |
+
//cut empty strings
|
391 |
+
$sStr = trim($aLines[$i]);
|
392 |
+
if($bSaveEmpty || $sStr)
|
393 |
+
{
|
394 |
+
/*
|
395 |
+
if ($this->_isModuleComment($sStr, 'begin', $sFile))
|
396 |
+
{
|
397 |
+
if($bSaveThisModule)
|
398 |
+
{
|
399 |
+
//find next string (not empty string)
|
400 |
+
$sNextStr = '';
|
401 |
+
while( (++$i<$iCntFoxLines) && (!$sNextStr = trim($aLines[$i])) ) {}
|
402 |
+
if($sNextStr)
|
403 |
+
{
|
404 |
+
if (!$this->_isModuleComment($sNextStr, 'module', $sFile ))
|
405 |
+
{
|
406 |
+
$bEgnoreString = TRUE;
|
407 |
+
}
|
408 |
+
}
|
409 |
+
}else
|
410 |
+
{
|
411 |
+
$bEgnoreString = TRUE;
|
412 |
+
}
|
413 |
+
}
|
414 |
+
elseif ($this->_isModuleComment($sStr, 'end', $sFile))
|
415 |
+
{
|
416 |
+
$bEgnoreString = FALSE;
|
417 |
+
}
|
418 |
+
elseif(!$bEgnoreString) // $bEgnoreString is allways false for now
|
419 |
+
*/
|
420 |
+
{
|
421 |
+
$aResult[] = array('iPhpFoxLine'=>$iFoxLineNum,'sType'=>' ', 'sStr'=> $sStr);
|
422 |
+
++$iFoxLineNum;
|
423 |
+
}
|
424 |
+
}
|
425 |
+
|
426 |
+
}
|
427 |
+
return $aResult;
|
428 |
+
}
|
429 |
+
|
430 |
+
/** check if string is this Module Comment
|
431 |
+
* DEPRECATED
|
432 |
+
*
|
433 |
+
* @param string $sStr checking string
|
434 |
+
* @param string $sType `begin` or `end` or `module`
|
435 |
+
* @param string $sFile Name of file for that make comment
|
436 |
+
* @return boolean if string is this Module Comment return true
|
437 |
+
* @access private
|
438 |
+
*/
|
439 |
+
private function _isModuleComment($sStr, $sType, $sFile)
|
440 |
+
{
|
441 |
+
$sComment = $this->_makeStrComment($sType, $sFile);
|
442 |
+
if(!$sComment)
|
443 |
+
{
|
444 |
+
return FALSE;
|
445 |
+
}else{
|
446 |
+
return ( FALSE !== strpos(trim($sStr),trim($sComment)) );
|
447 |
+
}
|
448 |
+
}
|
449 |
+
|
450 |
+
/** make String with comment
|
451 |
+
* DEPRECATED
|
452 |
+
*
|
453 |
+
* @param string $sType `begin` or `end` or `module`
|
454 |
+
* @param string $sFile Name of file for that make comment
|
455 |
+
* @return string Comment string
|
456 |
+
* @access private
|
457 |
+
*/
|
458 |
+
function _makeStrComment($sType, $sFile)
|
459 |
+
{
|
460 |
+
$sResult = '';
|
461 |
+
switch($sType)
|
462 |
+
{
|
463 |
+
case 'begin':
|
464 |
+
$sText = 'BEGIN Aitoc Module';
|
465 |
+
break;
|
466 |
+
case 'end':
|
467 |
+
$sText = 'END Aitoc Module';
|
468 |
+
break;
|
469 |
+
case 'module':
|
470 |
+
$sText = 'TEST MOD';
|
471 |
+
break;
|
472 |
+
default:
|
473 |
+
$sText = '';
|
474 |
+
|
475 |
+
}
|
476 |
+
$aBeginTags = array(
|
477 |
+
'php' =>'/***',
|
478 |
+
'html' =>'<!--',
|
479 |
+
'phtml' =>'<!--',
|
480 |
+
'htaccess'=> '#***'
|
481 |
+
);
|
482 |
+
$aEndTags = array(
|
483 |
+
'php' =>'***/',
|
484 |
+
'html' =>'-->',
|
485 |
+
'phtml' =>'-->',
|
486 |
+
'htaccess'=> '***#'
|
487 |
+
);
|
488 |
+
$sFileType = substr($sFile, strrpos($sFile,'.')+1);
|
489 |
+
if (isset($aBeginTags[$sFileType]) AND isset($aEndTags[$sFileType]))
|
490 |
+
{
|
491 |
+
$sResult = $aBeginTags[$sFileType].' '.$sText.' '.$aEndTags[$sFileType].PHP_EOL;
|
492 |
+
}else{
|
493 |
+
//$this->aErrors[] = 'Unknown comment file type - `'.$sFileType.'`';
|
494 |
+
}
|
495 |
+
|
496 |
+
return $sResult;
|
497 |
+
}
|
498 |
+
|
499 |
+
public function getChangeList()
|
500 |
+
{
|
501 |
+
return $this->_aChanges;
|
502 |
+
}
|
503 |
+
|
504 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Aitpatch.php
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Aitpatch extends Aitoc_Aitsys_Abstract_Model
|
6 |
+
{
|
7 |
+
const PATCH_DIR = '/ait_patch/';
|
8 |
+
|
9 |
+
static protected $_patchesCacheDir = '';
|
10 |
+
|
11 |
+
private $_aPatch = array();
|
12 |
+
|
13 |
+
protected $_patchedTemplatesDir = '';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
static public function getPatchesCacheDir()
|
19 |
+
{
|
20 |
+
if (!self::$_patchesCacheDir)
|
21 |
+
{
|
22 |
+
self::$_patchesCacheDir = BP . DS . Aitoc_Aitsys_Model_Platform::getInstance()->getVarPath() . self::PATCH_DIR;
|
23 |
+
}
|
24 |
+
return self::$_patchesCacheDir;
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _construct()
|
28 |
+
{
|
29 |
+
$this->_patchedTemplatesDir = self::getPatchesCacheDir();
|
30 |
+
}
|
31 |
+
|
32 |
+
public function applyPatchDryrun()
|
33 |
+
{
|
34 |
+
return $this->applyPatch(true);
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getCompatiblityError( $aModuleList )
|
38 |
+
{
|
39 |
+
$notices = array();
|
40 |
+
if (Mage::registry('aitsys_patch_incompatible_files'))
|
41 |
+
{
|
42 |
+
$incompatibleList = Mage::registry('aitsys_patch_incompatible_files');
|
43 |
+
|
44 |
+
$notices[] = '
|
45 |
+
You can try to fix the above mentioned error yourself. But this will involve opening Magento and Module files via FTP and editing code in them. <br />
|
46 |
+
Or if you don\'t feel confident you can post a support ticket. <br />
|
47 |
+
Note, that if you are having problems with more than one Module and you would like to post a support ticket, please post all the Modules in one ticket.
|
48 |
+
';
|
49 |
+
$notices[] = 'The following Module(s) encountered the error:';
|
50 |
+
foreach ($incompatibleList as $mod => $modPatches)
|
51 |
+
{
|
52 |
+
$key = '';
|
53 |
+
if (isset($modPatches[0]['modkey']))
|
54 |
+
{
|
55 |
+
$key = $modPatches[0]['modkey'];
|
56 |
+
}
|
57 |
+
$module = $this->tool()->platform()->getModule($key);
|
58 |
+
$supportLink = $this->tool()->getHelper()->getModuleSupportLink($module,true);
|
59 |
+
$moduleName = '';
|
60 |
+
foreach ($aModuleList as $moduleItem)
|
61 |
+
{
|
62 |
+
if ($key == $moduleItem->getKey())
|
63 |
+
{
|
64 |
+
$moduleName = (string)$moduleItem->getLabel();
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
$notices[] = 'Module ' . $moduleName . '. <a href="' .
|
69 |
+
Mage::helper('adminhtml')->getUrl('*/patch/instruction', array('mod' => $mod)) .
|
70 |
+
'">Read the Guide</a>
|
71 |
+
or <a href="' . $supportLink . '">Post a support ticket</a>.';
|
72 |
+
}
|
73 |
+
}
|
74 |
+
return $notices;
|
75 |
+
}
|
76 |
+
|
77 |
+
protected function _getModuleKey($alias)
|
78 |
+
{
|
79 |
+
if ($enable = Mage::app()->getRequest()->getPost('enable'))
|
80 |
+
{
|
81 |
+
$keys = array_keys($enable);
|
82 |
+
if (is_array($keys) && !empty($keys))
|
83 |
+
{
|
84 |
+
foreach ($keys as $modKey)
|
85 |
+
{
|
86 |
+
if (false !== strpos($modKey, $alias))
|
87 |
+
{
|
88 |
+
return $modKey;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
else
|
94 |
+
{
|
95 |
+
foreach ($this->tool()->platform()->getModules() as $module)
|
96 |
+
{
|
97 |
+
$key = $module->getKey();
|
98 |
+
if (false !== strpos($key, $alias))
|
99 |
+
{
|
100 |
+
return $key;
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
return '';
|
105 |
+
}
|
106 |
+
|
107 |
+
public function applyPatch($bDryRun = false)
|
108 |
+
{
|
109 |
+
$oConfig = Mage::getConfig();
|
110 |
+
$aPatchFiles = $this->_getPatchFiles();
|
111 |
+
$oPatcher = new Aitoc_Aitsys_Model_Aitfilepatcher();
|
112 |
+
|
113 |
+
$oFileSys = $this->tool()->filesystem();
|
114 |
+
/* @var $oFileSys Aitoc_Aitsys_Model_Core_Filesystem */
|
115 |
+
|
116 |
+
$aErrors = array();
|
117 |
+
$uncompatibleList = array();
|
118 |
+
|
119 |
+
foreach ($aPatchFiles as $sFile => $aParams)
|
120 |
+
{
|
121 |
+
$sPatch = '';
|
122 |
+
$aModules = $aParams['modules'];
|
123 |
+
$currentModulePath = '';
|
124 |
+
$currentModuleName = '';
|
125 |
+
foreach ($aModules as $sMod => $sModPathToFile)
|
126 |
+
{
|
127 |
+
$patchFile = $oFileSys->getPatchFilePath($sFile, $sMod . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR);
|
128 |
+
if (!$patchFile->getIsError())
|
129 |
+
{
|
130 |
+
$sPatch .= trim(file_get_contents($patchFile->getFilePath()))."\n";
|
131 |
+
}
|
132 |
+
|
133 |
+
$currentModulePath = $sMod;
|
134 |
+
//$currentModuleName = str_replace(array('/','\\'),'_',substr($sMod, 6 + strrpos($sMod, 'local')));
|
135 |
+
$currentModuleName = basename(dirname($sMod)) . '_' . basename($sMod);
|
136 |
+
}
|
137 |
+
$oPatcher->parsePatch($sPatch);
|
138 |
+
|
139 |
+
// now will check if we can patch current file
|
140 |
+
$sFileNameToPatch = str_replace('--', '/', $sFile);
|
141 |
+
|
142 |
+
$sFileToPatch = $oConfig->getOptions()->getAppDir() . '/' . substr($sFileNameToPatch, 0, strpos($sFileNameToPatch, '.patch'));
|
143 |
+
if (!file_exists($sFileToPatch) && $aParams['optional'])
|
144 |
+
{
|
145 |
+
continue;
|
146 |
+
}
|
147 |
+
|
148 |
+
if (!$oPatcher->canApplyChanges($sFileToPatch))
|
149 |
+
{
|
150 |
+
$aErrors[] = array('file' => $sFileToPatch, 'type' => 'file_uncompatible');
|
151 |
+
// adding session data for instructions page
|
152 |
+
$uncompatibleList[$currentModuleName][] = array(
|
153 |
+
'file' => $sFileToPatch,
|
154 |
+
'mod' => $currentModulePath,
|
155 |
+
'patchfile' => $sFile,
|
156 |
+
'modkey' => $this->_getModuleKey($currentModuleName),
|
157 |
+
);
|
158 |
+
}
|
159 |
+
|
160 |
+
if (!$bDryRun)
|
161 |
+
{
|
162 |
+
// apply patch
|
163 |
+
$sApplyPatchTo = $oFileSys->makeTemporary($sFileToPatch);
|
164 |
+
$oPatcher->applyPatch($sApplyPatchTo);
|
165 |
+
foreach ($aModules as $sMod => $sModPathToFile)
|
166 |
+
{
|
167 |
+
$oFileSys->cpFile($sApplyPatchTo, $this->_patchedTemplatesDir . $sModPathToFile);
|
168 |
+
}
|
169 |
+
$oFileSys->rmFile($sApplyPatchTo);
|
170 |
+
}
|
171 |
+
}
|
172 |
+
if ($bDryRun)
|
173 |
+
{
|
174 |
+
if ($uncompatibleList)
|
175 |
+
{
|
176 |
+
Mage::getSingleton('adminhtml/session')->setData('aitsys_patch_incompatible_files', $uncompatibleList);
|
177 |
+
Mage::unregister('aitsys_patch_incompatible_files');
|
178 |
+
Mage::register('aitsys_patch_incompatible_files', $uncompatibleList);
|
179 |
+
}
|
180 |
+
return $aErrors;
|
181 |
+
}
|
182 |
+
return true;
|
183 |
+
}
|
184 |
+
|
185 |
+
public function setPatchFiles($aPatch)
|
186 |
+
{
|
187 |
+
$this->_aPatch = $aPatch;
|
188 |
+
}
|
189 |
+
|
190 |
+
final private function _getPatchFiles()
|
191 |
+
{
|
192 |
+
return $this->_aPatch;
|
193 |
+
}
|
194 |
+
|
195 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Aitpatch/Observer.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
* @author Andrei
|
5 |
+
*/
|
6 |
+
class Aitoc_Aitsys_Model_Aitpatch_Observer
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* replace design to default path
|
10 |
+
*
|
11 |
+
* @param $observer
|
12 |
+
*/
|
13 |
+
public function replaceDesignPath($observer)
|
14 |
+
{
|
15 |
+
if(($block = $observer->getBlock()) instanceof Mage_Core_Block_Template)
|
16 |
+
{
|
17 |
+
//return design path for block
|
18 |
+
if(Mage::registry('design_path_for_'.get_class($block).'_'.$block->getId()))
|
19 |
+
{
|
20 |
+
Mage::getConfig()->getOptions()->setData('design_dir', Mage::registry('design_path_for_'.get_class($block).'_'.$block->getId()));
|
21 |
+
}
|
22 |
+
elseif(Mage::registry('design_path_aitoc') && Mage::registry('design_path_aitoc') != Mage::getBaseDir('design'))
|
23 |
+
{
|
24 |
+
Mage::getConfig()->getOptions()->setData('design_dir', Mage::registry('design_path_aitoc'));
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param $observer
|
31 |
+
*/
|
32 |
+
public function pathTemplateReplaceBeforeToHtml($observer)
|
33 |
+
{
|
34 |
+
if(($block = $observer->getBlock()) instanceof Mage_Core_Block_Template)
|
35 |
+
{
|
36 |
+
if(!Mage::registry('design_path_aitoc'))
|
37 |
+
{
|
38 |
+
$currentViewDirAll = Mage::getBaseDir('design');
|
39 |
+
Mage::register('design_path_aitoc', $currentViewDirAll);
|
40 |
+
}
|
41 |
+
$currentViewDir = Mage::registry('design_path_aitoc');
|
42 |
+
$fileName = $block->getTemplateFile();
|
43 |
+
//save base dir before this block
|
44 |
+
if(Mage::registry('design_path_for_'.get_class($block).'_'.$block->getId()))
|
45 |
+
{
|
46 |
+
Mage::unregister('design_path_for_'.get_class($block).'_'.$block->getId());
|
47 |
+
}
|
48 |
+
Mage::register('design_path_for_'.get_class($block).'_'.$block->getId(), Mage::getBaseDir('design'));
|
49 |
+
if (false !== strpos($fileName, 'aitcommonfiles'))
|
50 |
+
{
|
51 |
+
if (Mage::getStoreConfigFlag('aitsys/settings/use_dynamic_patches')
|
52 |
+
|| !file_exists($currentViewDir . DS . $fileName)) // if there is a file in app/, we should do nothing. will use it.
|
53 |
+
{
|
54 |
+
$newViewDir = Aitoc_Aitsys_Model_Aitpatch::getPatchesCacheDir() . 'design';
|
55 |
+
if (file_exists($newViewDir . DS . $fileName))
|
56 |
+
{
|
57 |
+
$currentViewDir = $newViewDir; // replacing view dir
|
58 |
+
}
|
59 |
+
else
|
60 |
+
{
|
61 |
+
// also trying with 'default' folder instead of 'base' (for compatibility with 1.3 and 1.4 in one version)
|
62 |
+
$fileNameDef = str_replace(DS . 'base' . DS, DS . 'default' . DS, $fileName);
|
63 |
+
if (file_exists($newViewDir . DS . $fileNameDef))
|
64 |
+
{
|
65 |
+
$currentViewDir = $newViewDir; // replacing view dir
|
66 |
+
$fileName = $fileNameDef; // forcing use 'default' instead of 'base'
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
$block->setTemplateFile($fileName);
|
72 |
+
Mage::getConfig()->getOptions()->setData('design_dir', $currentViewDir);
|
73 |
+
}
|
74 |
+
else
|
75 |
+
{
|
76 |
+
if(Mage::registry('design_path_aitoc') && Mage::registry('design_path_aitoc') != Mage::getBaseDir('design'))
|
77 |
+
{
|
78 |
+
Mage::getConfig()->getOptions()->setData('design_dir', Mage::registry('design_path_aitoc'));
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Aitsys.php
ADDED
@@ -0,0 +1,909 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Aitsys extends Mage_Eav_Model_Entity_Attribute
|
6 |
+
implements Aitoc_Aitsys_Abstract_Model_Interface
|
7 |
+
{
|
8 |
+
|
9 |
+
protected $_sModuleRewriteNameOld = 'Aitoc_Aitcheckattrib';
|
10 |
+
protected $_sModuleRewriteNameNew = 'Aitoc_Aitcheckoutfields';
|
11 |
+
|
12 |
+
protected $_aModuleClassRewrite = array();
|
13 |
+
protected $_aModulePriority = array();
|
14 |
+
protected $_aModuleConfig = array();
|
15 |
+
protected $_aConfigReplace = array();
|
16 |
+
protected $_aFileMerge = array();
|
17 |
+
protected $_aFileWriteContent = array();
|
18 |
+
protected $_aFilesToUnlink = array();
|
19 |
+
protected $_aErrorList = array();
|
20 |
+
protected $_patchIncompatibleList = array();
|
21 |
+
protected $_isCorrection = false;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
25 |
+
*/
|
26 |
+
public function tool()
|
27 |
+
{
|
28 |
+
return Aitoc_Aitsys_Abstract_Service::get();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @return Aitoc_Aitsys_Abstract_Helper
|
33 |
+
*/
|
34 |
+
protected function _aithelper($type = 'Data')
|
35 |
+
{
|
36 |
+
return $this->tool()->getHelper($type);
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function _getModuleOrder()
|
40 |
+
{
|
41 |
+
if ($this->_aModulePriority)
|
42 |
+
{
|
43 |
+
arsort($this->_aModulePriority);
|
44 |
+
return array_keys($this->_aModulePriority);
|
45 |
+
}
|
46 |
+
else
|
47 |
+
{
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
protected function _getEtcDir()
|
56 |
+
{
|
57 |
+
return $this->tool()->filesystem()->getEtcDir();
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return string
|
62 |
+
* @todo refactoring: remove?
|
63 |
+
*/
|
64 |
+
protected function _getDiffFilePath($sModuleDir, $sArea, $sFileKey)
|
65 |
+
{
|
66 |
+
if (!$sModuleDir OR !$sArea OR !$sFileKey)
|
67 |
+
{
|
68 |
+
return false;
|
69 |
+
}
|
70 |
+
|
71 |
+
$sDiffFilePath = $sModuleDir . '/data/template/' . $sArea . '/' . $sFileKey . '.diff';
|
72 |
+
|
73 |
+
return $sDiffFilePath;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Get location of the module passed
|
78 |
+
*
|
79 |
+
* @param string $moduleName
|
80 |
+
* @return string|false
|
81 |
+
*/
|
82 |
+
protected function _getModuleDir($moduleName)
|
83 |
+
{
|
84 |
+
return $this->tool()->filesystem()->getModuleDir( $moduleName );
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @return array()
|
89 |
+
*/
|
90 |
+
protected function _getModuleHash()
|
91 |
+
{
|
92 |
+
$result = array();
|
93 |
+
foreach ($this->getAitocModuleList() as $module)
|
94 |
+
{
|
95 |
+
$result[$module->getKey().'.xml'] = $module->getFile();
|
96 |
+
}
|
97 |
+
return $result;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* @return array()
|
102 |
+
*/
|
103 |
+
public function getEtcAitocModuleList()
|
104 |
+
{
|
105 |
+
$result = array();
|
106 |
+
foreach ($this->getAitocModuleList() as $module)
|
107 |
+
{
|
108 |
+
/* @var $module Aitoc_Aitsys_Model_Module */
|
109 |
+
if ($module->getInstall()->isInstallable())
|
110 |
+
{
|
111 |
+
$result[] = $module;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
return $result;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* @return array()
|
119 |
+
*/
|
120 |
+
public function getAitocModuleList()
|
121 |
+
{
|
122 |
+
return $this->tool()->platform()->getModules();
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Get module config file
|
127 |
+
*
|
128 |
+
* @param string $moduleDir
|
129 |
+
* @param bool $custom Whether to load main or patches config
|
130 |
+
* @return SimpleXMLElement|false
|
131 |
+
*
|
132 |
+
* @todo refactoring: split for different configs
|
133 |
+
*/
|
134 |
+
protected function _getModuleConfig($moduleDir, $custom = false)
|
135 |
+
{
|
136 |
+
if ($moduleDir)
|
137 |
+
{
|
138 |
+
if ($custom)
|
139 |
+
{
|
140 |
+
$configFile = $moduleDir . '/etc/custom.data.xml';
|
141 |
+
}
|
142 |
+
else
|
143 |
+
{
|
144 |
+
$configFile = $moduleDir . '/etc/config.xml';
|
145 |
+
}
|
146 |
+
|
147 |
+
if (file_exists($configFile))
|
148 |
+
{
|
149 |
+
return simplexml_load_file($configFile);
|
150 |
+
}
|
151 |
+
}
|
152 |
+
return false;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Check if file have writeable permissions and if not add an error
|
157 |
+
*
|
158 |
+
* @param string $filePath
|
159 |
+
* @return bool
|
160 |
+
*/
|
161 |
+
protected function _checkFileWritePermissions($filePath)
|
162 |
+
{
|
163 |
+
try
|
164 |
+
{
|
165 |
+
return $this->tool()->filesystem()->checkWriteable($filePath, true);
|
166 |
+
}
|
167 |
+
catch(Aitoc_Aitsys_Model_Core_Filesystem_Exception $e)
|
168 |
+
{
|
169 |
+
$this->_addError($e->getMessage(), 'no_access_file');
|
170 |
+
}
|
171 |
+
return false;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* @return string
|
176 |
+
*/
|
177 |
+
protected function _getDesignFileDestinationPrefix( $areaName )
|
178 |
+
{
|
179 |
+
$filePrefix = 'design/' . $areaName . '/base/';
|
180 |
+
if (file_exists(Mage::getConfig()->getOptions()->getAppDir(). DS . $filePrefix))
|
181 |
+
{
|
182 |
+
return $filePrefix;
|
183 |
+
}
|
184 |
+
return 'design/' . $areaName . '/default/';
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* @todo refactoring
|
189 |
+
*/
|
190 |
+
protected function _clearFileMergeData( $data , $modules , $statuses )
|
191 |
+
{
|
192 |
+
$disableList = $enableList = array();
|
193 |
+
foreach ($statuses as $key => $status)
|
194 |
+
{
|
195 |
+
if (!$status && isset($data[$key]) && $data[$key])
|
196 |
+
{
|
197 |
+
$enableList[$key] = $key;
|
198 |
+
}
|
199 |
+
elseif ($status && (!isset($data[$key]) || !$data[$key]))
|
200 |
+
{
|
201 |
+
$disableList[$key] = $key;
|
202 |
+
}
|
203 |
+
elseif (!$status && (!isset($data[$key]) || !$data[$key]))
|
204 |
+
{
|
205 |
+
$disabledList[$key] = $key;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
foreach ($this->_aFileMerge as $path => $info)
|
209 |
+
{
|
210 |
+
$has = false;
|
211 |
+
foreach (array_keys($info['modules']) as $modulePath)
|
212 |
+
{
|
213 |
+
$tmp = explode('/',$modulePath);
|
214 |
+
$name = array_pop($tmp);
|
215 |
+
$vendor = array_pop($tmp);
|
216 |
+
$module = $vendor.'_'.$name;
|
217 |
+
if (isset($enableList[$module]))
|
218 |
+
{
|
219 |
+
$has = true;
|
220 |
+
}
|
221 |
+
elseif (isset($disableList[$module]))
|
222 |
+
{
|
223 |
+
$has = true;
|
224 |
+
unset($this->_aFileMerge[$path]['modules'][$modulePath]);
|
225 |
+
}
|
226 |
+
elseif (isset($disabledList[$module]))
|
227 |
+
{
|
228 |
+
unset($this->_aFileMerge[$path]['modules'][$modulePath]);
|
229 |
+
}
|
230 |
+
}
|
231 |
+
if (!$has || !$this->_aFileMerge[$path]['modules'])
|
232 |
+
{
|
233 |
+
unset($this->_aFileMerge[$path]);
|
234 |
+
}
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* @todo refactoring
|
240 |
+
*/
|
241 |
+
protected function _setFileMergeData($oModuleCustomConfig, $sModuleDir)
|
242 |
+
{
|
243 |
+
if (!$oModuleCustomConfig) return false;
|
244 |
+
|
245 |
+
$oConfig = Mage::getConfig();
|
246 |
+
|
247 |
+
$aDestFileHash = array();
|
248 |
+
|
249 |
+
if ($oModuleCustomConfig->template AND $oModuleCustomConfig->template->children())
|
250 |
+
{
|
251 |
+
foreach ($oModuleCustomConfig->template->children() as $sAreaName => $aAreaConfig)
|
252 |
+
{
|
253 |
+
if ($aAreaConfig AND $aAreaConfig->children())
|
254 |
+
{
|
255 |
+
foreach ($aAreaConfig->children() as $sNodeKey => $aFileConfig)
|
256 |
+
{
|
257 |
+
if (!$this->validateVersion(Mage::getVersion(), $aFileConfig->attributes()))
|
258 |
+
{
|
259 |
+
continue;
|
260 |
+
}
|
261 |
+
|
262 |
+
$aFilePathKey = $aFileConfig->attributes()->path;
|
263 |
+
$bOptional = $aFileConfig->attributes()->optional ? (int)$aFileConfig->attributes()->optional : false;
|
264 |
+
$bOptional = $bOptional ? true : false;
|
265 |
+
|
266 |
+
$sTplKey = $aFilePathKey . '.phtml.patch';
|
267 |
+
|
268 |
+
if (isset($this->_aFileMerge[$sTplKey]['optional']))
|
269 |
+
{
|
270 |
+
if($this->_aFileMerge[$sTplKey]['optional'])
|
271 |
+
{
|
272 |
+
$this->_aFileMerge[$sTplKey]['optional'] = $bOptional;
|
273 |
+
}
|
274 |
+
}
|
275 |
+
else
|
276 |
+
{
|
277 |
+
$this->_aFileMerge[$sTplKey]['optional'] = $bOptional;
|
278 |
+
}
|
279 |
+
|
280 |
+
$patchFile = $this->tool()->filesystem()->getPatchFilePath($sTplKey, $sModuleDir . '/data/');
|
281 |
+
if ($patchFile->getIsError())
|
282 |
+
{
|
283 |
+
$this->_addError($patchFile->getFilePath(), 'no_module_file');
|
284 |
+
}
|
285 |
+
|
286 |
+
$sFileDest = $this->_getDesignFileDestinationPrefix($sAreaName).'default/template/aitcommonfiles/' . $aFilePathKey . '.phtml';
|
287 |
+
|
288 |
+
$sDestFilePath = Aitoc_Aitsys_Model_Aitpatch::getPatchesCacheDir() . $sFileDest;
|
289 |
+
|
290 |
+
$aDestFileHash[$sDestFilePath] = 1;
|
291 |
+
|
292 |
+
if (isset($this->_aFileMerge[$sTplKey]))
|
293 |
+
{
|
294 |
+
$this->_aFileMerge[$sTplKey]['modules'][$sModuleDir] = $sFileDest;
|
295 |
+
}
|
296 |
+
else
|
297 |
+
{
|
298 |
+
$this->_aFileMerge[$sTplKey] = array(
|
299 |
+
'modules' => array(
|
300 |
+
$sModuleDir => $sFileDest
|
301 |
+
)
|
302 |
+
);
|
303 |
+
}
|
304 |
+
}
|
305 |
+
}
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
if ($aDestFileHash)
|
310 |
+
{
|
311 |
+
foreach ($aDestFileHash as $sFile => $sVal)
|
312 |
+
{
|
313 |
+
$this->_checkFileWritePermissions($sFile);
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
return true;
|
318 |
+
}
|
319 |
+
|
320 |
+
public function getModulesStatusHash()
|
321 |
+
{
|
322 |
+
$aModuleList = $this->getEtcAitocModuleList();
|
323 |
+
$aModHash = array();
|
324 |
+
foreach ($aModuleList as $aMod)
|
325 |
+
{
|
326 |
+
$aModHash[$aMod['key']] = $aMod['value'];
|
327 |
+
}
|
328 |
+
return $aModHash;
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* @todo refactoring
|
333 |
+
*/
|
334 |
+
public function saveData($aData, $aModuleHash = array(), $clearCache = true , $hideEvents = false)
|
335 |
+
{
|
336 |
+
if (!$aData) return false;
|
337 |
+
|
338 |
+
if (!$aModuleHash)
|
339 |
+
{
|
340 |
+
$aModuleHash = $this->_getModuleHash();
|
341 |
+
}
|
342 |
+
$sModuleEtcDir = $this->_getEtcDir();
|
343 |
+
|
344 |
+
// dispatching pre-disable event
|
345 |
+
$aStatusHash = $this->getModulesStatusHash();
|
346 |
+
|
347 |
+
if($this->_isCorrection)
|
348 |
+
{
|
349 |
+
// For correction $aData is an array of modules to be corrected, not a list of all modules with new statuses.
|
350 |
+
// To prevent status changes of all other modules we are re-creating $aData from $aStatusHash.
|
351 |
+
// Then in $sStatusHash we change current statuses of modules that require correction to an opposite one to simulate
|
352 |
+
// normal process of enabling/disabling of modules.
|
353 |
+
$newData = array();
|
354 |
+
foreach ($aStatusHash as $module => $oldStatus)
|
355 |
+
{
|
356 |
+
$newData[$module] = $oldStatus;
|
357 |
+
$aStatusHash[$module] = isset($aData[$module])?!$oldStatus:$oldStatus;
|
358 |
+
}
|
359 |
+
$aData = $newData;
|
360 |
+
}
|
361 |
+
|
362 |
+
if ($aModuleHash)
|
363 |
+
{
|
364 |
+
foreach ($aModuleHash as $sFile => $sFullPath)
|
365 |
+
{
|
366 |
+
if (!file_exists($sFullPath))
|
367 |
+
{
|
368 |
+
continue;
|
369 |
+
}
|
370 |
+
|
371 |
+
$oModuleBaseConfigCheck = simplexml_load_file($sFullPath);
|
372 |
+
|
373 |
+
$this->checkModulesCompatibility($aData, $oModuleBaseConfigCheck, $aModuleHash);
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
$eventArg = array(
|
378 |
+
'aitsys' => $this,
|
379 |
+
'data' => $aData,
|
380 |
+
'module_hash' => $aModuleHash,
|
381 |
+
'status_hash' => $aStatusHash
|
382 |
+
);
|
383 |
+
if (!$hideEvents)
|
384 |
+
{
|
385 |
+
$this->tool()->event('aitoc_module_save_data_before',$eventArg);
|
386 |
+
}
|
387 |
+
foreach ($aStatusHash as $sModule => $bIsActive)
|
388 |
+
{
|
389 |
+
if (!isset($aData[$sModule]) or !$aData[$sModule])
|
390 |
+
{
|
391 |
+
$aEventParams = array(
|
392 |
+
'object' => $this, // modules will put errors to the current instance
|
393 |
+
'aitocmodulename' => $sModule,
|
394 |
+
);
|
395 |
+
if (!$hideEvents)
|
396 |
+
{
|
397 |
+
Mage::dispatchEvent('aitoc_module_disable_before', $aEventParams);
|
398 |
+
}
|
399 |
+
}
|
400 |
+
}
|
401 |
+
// checking if we got any error from events
|
402 |
+
$aErrors = $this->_getErrorList();
|
403 |
+
if (!empty($aErrors))
|
404 |
+
{
|
405 |
+
return $aErrors;
|
406 |
+
}
|
407 |
+
|
408 |
+
if ($aModuleHash)
|
409 |
+
{
|
410 |
+
foreach ($aModuleHash as $sFile => $sFullPath)
|
411 |
+
{
|
412 |
+
if (!file_exists($sFullPath))
|
413 |
+
{
|
414 |
+
continue;
|
415 |
+
}
|
416 |
+
$sModuleName = substr($sFile, 0, strpos($sFile, '.'));
|
417 |
+
|
418 |
+
if (!$hideEvents)
|
419 |
+
{
|
420 |
+
$this->tool()->event(
|
421 |
+
'aitoc_module_modify_before',
|
422 |
+
array('aitsys' => $this,'key' => $sModuleName)
|
423 |
+
);
|
424 |
+
}
|
425 |
+
|
426 |
+
$sModuleDir = $this->_getModuleDir($sModuleName);
|
427 |
+
|
428 |
+
// get main module config
|
429 |
+
|
430 |
+
$oModuleMainConfig = $this->_getModuleConfig($sModuleDir);
|
431 |
+
|
432 |
+
// set module status
|
433 |
+
if (isset($aData[$sModuleName]) AND $aData[$sModuleName]) // checkbox was checked
|
434 |
+
{
|
435 |
+
$sModuleActive = 'true';
|
436 |
+
}
|
437 |
+
else
|
438 |
+
{
|
439 |
+
$sModuleActive = 'false';
|
440 |
+
}
|
441 |
+
// get base module config
|
442 |
+
|
443 |
+
$oModuleCustomConfig = $this->_getModuleConfig($sModuleDir, true);
|
444 |
+
|
445 |
+
$this->_setFileMergeData($oModuleCustomConfig, $sModuleDir);
|
446 |
+
|
447 |
+
$oModuleBaseConfig = simplexml_load_file($sFullPath);
|
448 |
+
|
449 |
+
$oModuleBaseConfig->modules->$sModuleName->active = $sModuleActive;
|
450 |
+
|
451 |
+
if( $oModuleBaseConfig->modules->$sModuleName->aitdepends && $sModuleActive == 'true')
|
452 |
+
{
|
453 |
+
foreach($oModuleBaseConfig->modules->$sModuleName->aitdepends->children() as $module=>$depend)
|
454 |
+
{
|
455 |
+
$aData[$module] = true;
|
456 |
+
}
|
457 |
+
}
|
458 |
+
|
459 |
+
if ($iPriority = $oModuleBaseConfig->modules->$sModuleName->priority)
|
460 |
+
{
|
461 |
+
$this->_aModulePriority[$sModuleName] = (integer)$iPriority;
|
462 |
+
}
|
463 |
+
else
|
464 |
+
{
|
465 |
+
$this->_aModulePriority[$sModuleName] = 0;
|
466 |
+
}
|
467 |
+
|
468 |
+
$sFileContent = $oModuleBaseConfig->asXML();
|
469 |
+
|
470 |
+
if ($this->_isCorrection || $this->_checkFileSaveWithContent($sFullPath, $sFileContent))
|
471 |
+
{
|
472 |
+
// check if module's status was changed
|
473 |
+
// check if module has license helper
|
474 |
+
// launch module's specific install/uninstall methods from license helper
|
475 |
+
if(array_key_exists($sModuleName, $aData) && array_key_exists($sModuleName, $aStatusHash) && ($aData[$sModuleName] != $aStatusHash[$sModuleName]))
|
476 |
+
{
|
477 |
+
if ($sModuleActive=='false')
|
478 |
+
{
|
479 |
+
$this->tool()->getSetupHelper($sModuleName)->uninstallBefore();
|
480 |
+
}else{
|
481 |
+
$this->tool()->getSetupHelper($sModuleName)->installBefore();
|
482 |
+
}
|
483 |
+
}
|
484 |
+
|
485 |
+
// check if module has resource setup files
|
486 |
+
// also if it has version in `core_resource`
|
487 |
+
// run 'activate' or 'uninstall' scripts
|
488 |
+
if ($oModuleMainConfig AND isset($oModuleMainConfig->global->resources))
|
489 |
+
{
|
490 |
+
$resourceName = '';
|
491 |
+
foreach ($oModuleMainConfig->global->resources->children() as $key => $object)
|
492 |
+
{
|
493 |
+
if ($object->setup)
|
494 |
+
{
|
495 |
+
$resourceName = $key;
|
496 |
+
break;
|
497 |
+
}
|
498 |
+
}
|
499 |
+
|
500 |
+
if ($resourceName)
|
501 |
+
{
|
502 |
+
// check if module has version in `core_resource`, so it was previously enabled
|
503 |
+
$dbVersion = Mage::getResourceModel('core/resource')->getDBVersion($resourceName);
|
504 |
+
if ($dbVersion && array_key_exists($sModuleName, $aData) && array_key_exists($sModuleName, $aStatusHash) && ($aData[$sModuleName] != $aStatusHash[$sModuleName]))
|
505 |
+
{
|
506 |
+
if ($sModuleActive=='false') // module is being disabled
|
507 |
+
{
|
508 |
+
$aitsysSetup = new Aitoc_Aitsys_Model_Mysql4_Setup('core_setup');
|
509 |
+
$aitsysSetup->applyAitocModuleUninstall($sModuleName);
|
510 |
+
}
|
511 |
+
else // module is being enabled
|
512 |
+
{
|
513 |
+
$aitsysSetup = new Aitoc_Aitsys_Model_Mysql4_Setup('core_setup');
|
514 |
+
$aitsysSetup->applyAitocModuleActivate($sModuleName);
|
515 |
+
}
|
516 |
+
}
|
517 |
+
}
|
518 |
+
}
|
519 |
+
|
520 |
+
// save module status in the database for future correction checks
|
521 |
+
Aitoc_Aitsys_Model_Module_Status::updateStatus($sModuleName, ($sModuleActive!='false'));
|
522 |
+
}
|
523 |
+
}
|
524 |
+
|
525 |
+
$this->_clearFileMergeData($aData,$aModuleHash,$aStatusHash);
|
526 |
+
|
527 |
+
// checking write permissions to var
|
528 |
+
$this->_checkFileWritePermissions(Mage::getBaseDir( $this->tool()->platform()->getVarPath() ));
|
529 |
+
|
530 |
+
if (!$this->_aErrorList)
|
531 |
+
{
|
532 |
+
if ($this->_aFileMerge)
|
533 |
+
{
|
534 |
+
$oPatch = new Aitoc_Aitsys_Model_Aitpatch();
|
535 |
+
|
536 |
+
$oPatch->setPatchFiles($this->_aFileMerge);
|
537 |
+
|
538 |
+
$aErrorList = $oPatch->applyPatchDryrun();
|
539 |
+
|
540 |
+
if ($aErrorList)
|
541 |
+
{
|
542 |
+
foreach ($aErrorList as $aError)
|
543 |
+
{
|
544 |
+
$this->_addError($aError['file'], $aError['type']);
|
545 |
+
}
|
546 |
+
}
|
547 |
+
else
|
548 |
+
{
|
549 |
+
$oPatch->applyPatch();
|
550 |
+
}
|
551 |
+
}
|
552 |
+
|
553 |
+
if (!$this->_aErrorList)
|
554 |
+
{
|
555 |
+
$this->_saveAllFileContent();
|
556 |
+
$this->_deleteFiles();
|
557 |
+
}
|
558 |
+
}
|
559 |
+
}
|
560 |
+
|
561 |
+
if ($clearCache)
|
562 |
+
{
|
563 |
+
$this->tool()->clearCache();
|
564 |
+
}
|
565 |
+
|
566 |
+
if (!$hideEvents)
|
567 |
+
{
|
568 |
+
$this->tool()->event('aitoc_module_save_data_after',$eventArg);
|
569 |
+
}
|
570 |
+
|
571 |
+
return $this->_getErrorList();
|
572 |
+
}
|
573 |
+
|
574 |
+
protected function _getErrorList()
|
575 |
+
{
|
576 |
+
if (!$this->_aErrorList) return false;
|
577 |
+
|
578 |
+
return array_unique($this->_aErrorList);
|
579 |
+
}
|
580 |
+
|
581 |
+
protected function _deleteFiles()
|
582 |
+
{
|
583 |
+
if (!empty($this->_aFilesToUnlink))
|
584 |
+
{
|
585 |
+
foreach ($this->_aFilesToUnlink as $file)
|
586 |
+
{
|
587 |
+
@unlink($file);
|
588 |
+
}
|
589 |
+
}
|
590 |
+
return true;
|
591 |
+
}
|
592 |
+
|
593 |
+
protected function _saveAllFileContent()
|
594 |
+
{
|
595 |
+
if (!$this->_aFileWriteContent) return false;
|
596 |
+
|
597 |
+
foreach ($this->_aFileWriteContent as $sFilePath => $sFileContent)
|
598 |
+
{
|
599 |
+
$this->tool()->filesystem()->putFile($sFilePath, $sFileContent);
|
600 |
+
}
|
601 |
+
|
602 |
+
return true;
|
603 |
+
}
|
604 |
+
|
605 |
+
protected function _checkFileSaveWithContent($sFilePath, $sFileContent)
|
606 |
+
{
|
607 |
+
if (!$sFilePath OR !$sFileContent)
|
608 |
+
{
|
609 |
+
return false;
|
610 |
+
}
|
611 |
+
|
612 |
+
if (!file_exists($sFilePath))
|
613 |
+
{
|
614 |
+
$this->_addError($sFilePath, 'no_file');
|
615 |
+
}
|
616 |
+
else
|
617 |
+
{
|
618 |
+
// check for file permissions
|
619 |
+
|
620 |
+
if (!$this->_checkFileWritePermissions($sFilePath))
|
621 |
+
{
|
622 |
+
$this->_addError($sFilePath, 'no_access_file');
|
623 |
+
}
|
624 |
+
}
|
625 |
+
|
626 |
+
if ($this->_aErrorList)
|
627 |
+
{
|
628 |
+
return false;
|
629 |
+
}
|
630 |
+
|
631 |
+
$this->_aFileWriteContent[$sFilePath] = $sFileContent;
|
632 |
+
|
633 |
+
return true;
|
634 |
+
}
|
635 |
+
|
636 |
+
protected function _addError($sFilePath, $sType)
|
637 |
+
{
|
638 |
+
if (!$sFilePath OR !$sType)
|
639 |
+
{
|
640 |
+
return false;
|
641 |
+
}
|
642 |
+
|
643 |
+
switch ($sType)
|
644 |
+
{
|
645 |
+
case 'no_file':
|
646 |
+
$sMessage = 'File does not exist: %s';
|
647 |
+
break;
|
648 |
+
|
649 |
+
case 'no_access_file':
|
650 |
+
$sMessage = 'File does not have write permissions: %s';
|
651 |
+
break;
|
652 |
+
|
653 |
+
case 'no_access_dir':
|
654 |
+
$sMessage = 'Folder does not have write permissions: %s';
|
655 |
+
break;
|
656 |
+
|
657 |
+
case 'no_module_file':
|
658 |
+
$sMessage = 'Module installation file is absent: %s';
|
659 |
+
break;
|
660 |
+
|
661 |
+
case 'file_uncompatible':
|
662 |
+
$sMessage = 'Magento file is corrupted or changed: %s';
|
663 |
+
break;
|
664 |
+
|
665 |
+
case 'modules_compatibility':
|
666 |
+
$sMessage = '%s are not compatible and can not be enabled together. Choose one you are going to use and enable it.';
|
667 |
+
break;
|
668 |
+
}
|
669 |
+
|
670 |
+
$this->_aErrorList[] = $this->_aithelper()->__($sMessage, $sFilePath);
|
671 |
+
|
672 |
+
return true;
|
673 |
+
}
|
674 |
+
|
675 |
+
public function addError($error)
|
676 |
+
{
|
677 |
+
$this->_aErrorList[] = $error;
|
678 |
+
}
|
679 |
+
|
680 |
+
public function addCustomError($sErrorMessage)
|
681 |
+
{
|
682 |
+
$this->_aErrorList[] = $this->_aithelper()->__($sErrorMessage);
|
683 |
+
}
|
684 |
+
|
685 |
+
/**
|
686 |
+
* @todo refactoring
|
687 |
+
*/
|
688 |
+
public function getAllowInstallErrors()
|
689 |
+
{
|
690 |
+
$aErrorList = array();
|
691 |
+
$closedFolders = $this->tool()->filesystem()->checkMainPermissions();
|
692 |
+
if (!empty($closedFolders)) {
|
693 |
+
$aErrorList[] = array(
|
694 |
+
'type' => 'notice-msg',
|
695 |
+
'message' => Mage::helper('aitsys')->__('Before any action with AITOC Modules, please ensure the folders below (including their files and subfolders) have writable permissions for the web server user (for example, apache):').
|
696 |
+
'<br /><b>'.join('<br />', $closedFolders).'</b>'
|
697 |
+
);
|
698 |
+
}
|
699 |
+
|
700 |
+
$rewriteHelper = Mage::helper('aitsys/rewriter');
|
701 |
+
if (!$rewriteHelper->getRewriterStatus()
|
702 |
+
&& ($aAitocModuleList = $this->getAitocModuleList())
|
703 |
+
&& $rewriteHelper->analysisInheritedClasses($this, 'addConflictClassesInModuleObject', $aAitocModuleList, false))
|
704 |
+
{
|
705 |
+
foreach($aAitocModuleList as $module)
|
706 |
+
{
|
707 |
+
if ($conflictString = Mage::helper('aitsys/strings')->getModuleConflictString($module)) {
|
708 |
+
$aErrorList[] = array(
|
709 |
+
'type' => 'error-msg',
|
710 |
+
'message' => $conflictString
|
711 |
+
);
|
712 |
+
}
|
713 |
+
}
|
714 |
+
}
|
715 |
+
|
716 |
+
if(empty($aErrorList))
|
717 |
+
{
|
718 |
+
return false;
|
719 |
+
}
|
720 |
+
|
721 |
+
return $aErrorList;
|
722 |
+
}
|
723 |
+
|
724 |
+
/**
|
725 |
+
* @param $paramsMethod
|
726 |
+
* @return bool
|
727 |
+
*/
|
728 |
+
public function addConflictClassesInModuleObject(&$paramsMethod)
|
729 |
+
{
|
730 |
+
unset($paramsMethod['inheritedClasses']['_baseClasses']);
|
731 |
+
foreach(array_keys($paramsMethod['inheritedClasses']) as $class)
|
732 |
+
{
|
733 |
+
list($vendor, $name) = explode('_',$class,3);
|
734 |
+
if('Aitoc' != $vendor && 'AdjustWare' != $vendor)
|
735 |
+
{
|
736 |
+
foreach(array_keys($paramsMethod['inheritedClasses']) as $aitModulesClass)
|
737 |
+
{
|
738 |
+
list($aitvendor, $aitname) = explode('_',$aitModulesClass,3);
|
739 |
+
if('Aitoc' != $aitvendor && 'AdjustWare' != $aitvendor)
|
740 |
+
{
|
741 |
+
continue;
|
742 |
+
}
|
743 |
+
$paramsMethod['params'][$aitvendor.'_'.$aitname]->addConflict($aitModulesClass, $class, $vendor.'_'.$name);
|
744 |
+
return true;
|
745 |
+
}
|
746 |
+
}
|
747 |
+
}
|
748 |
+
return false;
|
749 |
+
}
|
750 |
+
|
751 |
+
/**
|
752 |
+
* Checks Magento version against rules
|
753 |
+
*
|
754 |
+
* @param mixed $mageVersion
|
755 |
+
* @param SimpleXMLElement $object
|
756 |
+
* @return boolean
|
757 |
+
*/
|
758 |
+
public function validateVersion($mageVersion, SimpleXMLElement $object)
|
759 |
+
{
|
760 |
+
return $this->_validate($mageVersion, array(
|
761 |
+
'include' => $object->includeVer,
|
762 |
+
'exclude' => $object->excludeVer,
|
763 |
+
'values' => $object->version,
|
764 |
+
'operator' => $object->operator,
|
765 |
+
));
|
766 |
+
}
|
767 |
+
|
768 |
+
/**
|
769 |
+
* Checks values against rules
|
770 |
+
*
|
771 |
+
* Following operators are supported:
|
772 |
+
* lt lower than
|
773 |
+
* le lower or equal
|
774 |
+
* eq equal
|
775 |
+
* gt greater than
|
776 |
+
* ge greater or qeual
|
777 |
+
* ne not equal
|
778 |
+
*
|
779 |
+
* @param mixed $valueToCheckAgainst
|
780 |
+
* @param array $rules
|
781 |
+
* @return boolean
|
782 |
+
*/
|
783 |
+
protected function _validate($valueToCheckAgainst, $rules)
|
784 |
+
{
|
785 |
+
$keys = array('include', 'exclude', 'values', 'operator');
|
786 |
+
|
787 |
+
foreach ($keys as $key)
|
788 |
+
{
|
789 |
+
$rules[$key] = isset($rules[$key]) ? $rules[$key] : null;
|
790 |
+
}
|
791 |
+
|
792 |
+
|
793 |
+
$globalValid = true;
|
794 |
+
|
795 |
+
foreach ($keys as $key)
|
796 |
+
{
|
797 |
+
if ('operator' == $key)
|
798 |
+
{
|
799 |
+
continue;
|
800 |
+
}
|
801 |
+
|
802 |
+
$values = null;
|
803 |
+
switch($key)
|
804 |
+
{
|
805 |
+
case 'include':
|
806 |
+
$operator = 'eq';
|
807 |
+
$values = $rules[$key];
|
808 |
+
break;
|
809 |
+
case 'exclude':
|
810 |
+
$operator = 'ne';
|
811 |
+
$values = $rules[$key];
|
812 |
+
break;
|
813 |
+
case 'values':
|
814 |
+
$operator = $rules['operator'];
|
815 |
+
$values = $rules['values'];
|
816 |
+
break;
|
817 |
+
}
|
818 |
+
|
819 |
+
$valid = true;
|
820 |
+
|
821 |
+
if ($values && $operator)
|
822 |
+
{
|
823 |
+
$values = preg_split('/-/', $values);
|
824 |
+
|
825 |
+
if (isset($values[0]) && (0 < strlen($values[0])))
|
826 |
+
{
|
827 |
+
$valid = true;
|
828 |
+
|
829 |
+
foreach ($values as $value)
|
830 |
+
{
|
831 |
+
//var_dump($valueToCheckAgainst, $value, $operator);
|
832 |
+
$result = version_compare($valueToCheckAgainst, $value, $operator);
|
833 |
+
|
834 |
+
if ('eq' == $operator)
|
835 |
+
{
|
836 |
+
if ($result)
|
837 |
+
{
|
838 |
+
return true;
|
839 |
+
}
|
840 |
+
}
|
841 |
+
else
|
842 |
+
{
|
843 |
+
$valid &= $result;
|
844 |
+
}
|
845 |
+
}
|
846 |
+
}
|
847 |
+
}
|
848 |
+
|
849 |
+
$globalValid &= (bool) $valid;
|
850 |
+
}
|
851 |
+
|
852 |
+
return (bool) $globalValid;
|
853 |
+
}
|
854 |
+
|
855 |
+
public function checkModulesCompatibility($aData, $oConfig, $aModuleHash)
|
856 |
+
{
|
857 |
+
foreach ($aData as $sModuleKey=>$bStatus)
|
858 |
+
{
|
859 |
+
if (is_object($oConfig->modules->$sModuleKey))
|
860 |
+
{
|
861 |
+
$oIncompatible = $oConfig->modules->$sModuleKey->incompatible;
|
862 |
+
|
863 |
+
foreach ($aData as $sIncompatibleModuleKey=>$bIncompatibleStatus)
|
864 |
+
{
|
865 |
+
if (isset($oIncompatible->$sIncompatibleModuleKey) && $sIncompatibleModuleKey != $sModuleKey && $bIncompatibleStatus == 1 && $bStatus == 1)
|
866 |
+
{
|
867 |
+
$this->_addError($this->getModuleName($sModuleKey, true).' and '.$this->getModuleName($sIncompatibleModuleKey, true), 'modules_compatibility');
|
868 |
+
}
|
869 |
+
}
|
870 |
+
}
|
871 |
+
}
|
872 |
+
}
|
873 |
+
|
874 |
+
/**
|
875 |
+
* Get module's name by key and prefix
|
876 |
+
*
|
877 |
+
* @param string $key Module key
|
878 |
+
* @param bool $usePrefix Module prefix
|
879 |
+
* @return string
|
880 |
+
*/
|
881 |
+
public function getModuleName($key, $usePrefix = false)
|
882 |
+
{
|
883 |
+
$prefix = 'AITOC';
|
884 |
+
$moduleHash = $this->_getModuleHash();
|
885 |
+
$moduleBaseConfig = simplexml_load_file($moduleHash[$key.'.xml']);
|
886 |
+
$moduleName = ($usePrefix ? $prefix . ' ' : '') . $moduleBaseConfig->modules->$key->self_name;
|
887 |
+
return $moduleName;
|
888 |
+
}
|
889 |
+
|
890 |
+
public function correction()
|
891 |
+
{
|
892 |
+
// checks whether upgrade from 2.15.5 to 2.15.6 is in progress
|
893 |
+
if(Mage::registry('aitsys_correction_setup')) {
|
894 |
+
return;
|
895 |
+
}
|
896 |
+
|
897 |
+
$this->_isCorrection = true;
|
898 |
+
$aData = array();
|
899 |
+
foreach($this->getAitocModuleList() as $module)
|
900 |
+
{
|
901 |
+
if($module->isNeedCorrection())
|
902 |
+
{
|
903 |
+
$aData[$module->getKey()] = $module->getValue();
|
904 |
+
}
|
905 |
+
}
|
906 |
+
$this->saveData($aData, array(), true);
|
907 |
+
$this->_isCorrection = false;
|
908 |
+
}
|
909 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Core/Cache.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Main adapter model for magento cache
|
4 |
+
*
|
5 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
6 |
+
*/
|
7 |
+
class Aitoc_Aitsys_Model_Core_Cache
|
8 |
+
{
|
9 |
+
const AITSYS_CACHE_GROUP = 'aitsys';
|
10 |
+
const DEFAULT_LIFE_TIME = 86400; // 24 hours in seconds
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Flush an entire magento cache
|
14 |
+
*
|
15 |
+
* @return Aitoc_Aitsys_Model_Core_Cache
|
16 |
+
*/
|
17 |
+
public function flush()
|
18 |
+
{
|
19 |
+
if (version_compare(Mage::getVersion(), '1.4', '>=')) {
|
20 |
+
Mage::app()->getCacheInstance()->flush();
|
21 |
+
} else {
|
22 |
+
Mage::app()->getCache()->clean();
|
23 |
+
}
|
24 |
+
|
25 |
+
// reinit magento config
|
26 |
+
Mage::getConfig()->reinit();
|
27 |
+
|
28 |
+
// add our events area
|
29 |
+
if (sizeof(Mage::getConfig()->getNode('aitsys')->events)) {
|
30 |
+
Mage::app()->addEventArea('aitsys');
|
31 |
+
}
|
32 |
+
|
33 |
+
// refresh modules statuses
|
34 |
+
if (!Mage::app()->getUpdateMode()) {
|
35 |
+
Mage_Core_Model_Resource_Setup::applyAllUpdates();
|
36 |
+
}
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Save element to cache if cache is enabled.
|
42 |
+
*
|
43 |
+
* @param mixed $data
|
44 |
+
* @param string $id
|
45 |
+
* @param bool $serialize Sholud be set `true` for any non-simple data
|
46 |
+
* @param integer $lifeTime Timeout in seconds before data will be considered out of date. Default 8 hours. Use `0` to cache element permanently.
|
47 |
+
*
|
48 |
+
* @return Aitoc_Aitsys_Model_Core_Cache
|
49 |
+
*/
|
50 |
+
public function save($data, $id, $serialize = true, $lifeTime = self::DEFAULT_LIFE_TIME)
|
51 |
+
{
|
52 |
+
if ($this->isEnabled()) {
|
53 |
+
if ($serialize) {
|
54 |
+
$data = serialize($data);
|
55 |
+
}
|
56 |
+
Mage::app()->saveCache($data, $id, array(self::AITSYS_CACHE_GROUP), $lifeTime);
|
57 |
+
}
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Load data from cache by its id. Uses defaule value if element not found or cache is disabled.
|
63 |
+
*
|
64 |
+
* @param string $id
|
65 |
+
* @param mixed $defaultValue
|
66 |
+
* @param bool $unserialize Sholud be set `true` for any non-simple data
|
67 |
+
*
|
68 |
+
* @return mixed
|
69 |
+
*/
|
70 |
+
public function load($id, $defaultValue = null, $unserialize = true)
|
71 |
+
{
|
72 |
+
$result = null;
|
73 |
+
if ($this->isEnabled()) {
|
74 |
+
$result = Mage::app()->loadCache($id);
|
75 |
+
}
|
76 |
+
if ($result) {
|
77 |
+
if ($unserialize) {
|
78 |
+
try {
|
79 |
+
$result = unserialize($result);
|
80 |
+
} catch(Exception $e) {
|
81 |
+
$result = null;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
return $result ? $result : $defaultValue;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Remove element from cache by its id
|
90 |
+
*
|
91 |
+
* @param string $id
|
92 |
+
*
|
93 |
+
* @return Aitoc_Aitsys_Model_Core_Cache
|
94 |
+
*/
|
95 |
+
public function remove($id)
|
96 |
+
{
|
97 |
+
Mage::app()->removeCache($id);
|
98 |
+
return $this;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Checks whether aitsys cache is enabled
|
103 |
+
*
|
104 |
+
* @return bool
|
105 |
+
*/
|
106 |
+
public function isEnabled()
|
107 |
+
{
|
108 |
+
return Mage::app()->useCache(self::AITSYS_CACHE_GROUP);
|
109 |
+
}
|
110 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Core/Compiler/Process.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Core_Compiler_Process extends Mage_Compiler_Model_Process
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var Aitoc_Aitsys_Model_Core_Compiler_Rules
|
9 |
+
*/
|
10 |
+
protected $_rulesProcessor;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return Aitoc_Aitsys_Model_Core_Compiler_Rules
|
14 |
+
*/
|
15 |
+
protected function _getRulesProcessor()
|
16 |
+
{
|
17 |
+
if(is_null($this->_rulesProcessor))
|
18 |
+
{
|
19 |
+
$this->_rulesProcessor = Mage::getModel('aitsys/core_compiler_rules')
|
20 |
+
->setCompileConfig($this->getCompileConfig())
|
21 |
+
->setIncludeDir($this->_includeDir)
|
22 |
+
->init();
|
23 |
+
}
|
24 |
+
return $this->_rulesProcessor;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @return Mage_Compiler_Model_Process
|
29 |
+
*/
|
30 |
+
protected function _collectFiles()
|
31 |
+
{
|
32 |
+
parent::_collectFiles();
|
33 |
+
|
34 |
+
$this->_getRulesProcessor()->applyExcludeFilesRule()->applyReplaceRule();
|
35 |
+
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @return array
|
41 |
+
*/
|
42 |
+
public function getCompileClassList()
|
43 |
+
{
|
44 |
+
$this->_getRulesProcessor()->applyRenameScopeRule()->applyRemoveScopeRule();
|
45 |
+
|
46 |
+
$arrFiles = parent::getCompileClassList();
|
47 |
+
$arrFiles = $this->_getRulesProcessor()->applyExcludeClassesRule($arrFiles);
|
48 |
+
|
49 |
+
return $arrFiles;
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function _copy($source, $target, $firstIteration = true)
|
53 |
+
{
|
54 |
+
if(substr($source, strlen($source)-9, 9)=='.data.php')
|
55 |
+
{
|
56 |
+
return $this;
|
57 |
+
}
|
58 |
+
return parent::_copy($source, $target, $firstIteration);
|
59 |
+
}
|
60 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Core/Compiler/Rules.php
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Core_Compiler_Rules
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var Mage_Core_Model_Config_Base
|
9 |
+
*/
|
10 |
+
protected $_compileConfig;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var string
|
14 |
+
*/
|
15 |
+
protected $_includeDir;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @return Mage_Core_Model_Config_Base
|
19 |
+
*/
|
20 |
+
public function getCompileConfig()
|
21 |
+
{
|
22 |
+
return $this->_compileConfig;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @param Mage_Core_Model_Config_Base $config
|
27 |
+
* @return Aitoc_Aitsys_Model_Core_Compiler_Rules
|
28 |
+
*/
|
29 |
+
public function setCompileConfig($config)
|
30 |
+
{
|
31 |
+
$this->_compileConfig = $config;
|
32 |
+
return $this;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
+
public function getIncludeDir()
|
39 |
+
{
|
40 |
+
return $this->_includeDir;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param string $path
|
45 |
+
* @return Aitoc_Aitsys_Model_Core_Compiler_Rules
|
46 |
+
*/
|
47 |
+
public function setIncludeDir($path)
|
48 |
+
{
|
49 |
+
$this->_includeDir = $path;
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @return Aitoc_Aitsys_Model_Core_Compiler_Rules
|
55 |
+
*/
|
56 |
+
public function init()
|
57 |
+
{
|
58 |
+
$this->_applyModulesRules();
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Apply specific modules rules to the main config
|
64 |
+
*/
|
65 |
+
protected function _applyModulesRules()
|
66 |
+
{
|
67 |
+
foreach ($this->getCompileConfig()->getNode('modules_rules')->children() as $module => $rules) {
|
68 |
+
if (Aitoc_Aitsys_Abstract_Service::get()->isModuleActive($module)) {
|
69 |
+
foreach ($rules as $rule) {
|
70 |
+
$this->getCompileConfig()->getNode()->extendChild($rule);
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
unset($this->getCompileConfig()->getNode()->modules_rules);
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Removes some collected files
|
79 |
+
*
|
80 |
+
* @return Aitoc_Aitsys_Model_Core_Compiler_Rules
|
81 |
+
*/
|
82 |
+
public function applyExcludeFilesRule()
|
83 |
+
{
|
84 |
+
if($array = $this->getCompileConfig()->getNode('exclude_files')->asArray())
|
85 |
+
{
|
86 |
+
foreach (array_keys($array) as $exclusion) {
|
87 |
+
$target = $this->getIncludeDir() . DS . $exclusion . '.php';
|
88 |
+
if(@file_exists($target)) {
|
89 |
+
Aitoc_Aitsys_Abstract_Service::get()->filesystem()->rmFile($target);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
return $this;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Replaces some collected classes with abstract rewrites
|
98 |
+
*
|
99 |
+
* @return Aitoc_Aitsys_Model_Core_Compiler_Rules
|
100 |
+
*/
|
101 |
+
public function applyReplaceRule()
|
102 |
+
{
|
103 |
+
if($array = $this->getCompileConfig()->getNode('replace')->asArray())
|
104 |
+
{
|
105 |
+
foreach (array_keys($array) as $replace) {
|
106 |
+
$source = Aitoc_Aitsys_Model_Rewriter_Abstract::getRewritesCacheDir().$replace.'.php';
|
107 |
+
$target = $this->getIncludeDir().DS.$replace.'.php';
|
108 |
+
if(@file_exists($source) && @file_exists($target)) {
|
109 |
+
copy($source, $target);
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
113 |
+
return $this;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Removes some classes from collection
|
118 |
+
*
|
119 |
+
* @param array $arrFiles Array with the data changes should be applied to.
|
120 |
+
* @return array
|
121 |
+
*/
|
122 |
+
public function applyExcludeClassesRule($arrFiles)
|
123 |
+
{
|
124 |
+
foreach ($this->getCompileConfig()->getNode('exclude_classes')->children() as $scope => $classes) {
|
125 |
+
$excludes = array_keys($classes->asArray());
|
126 |
+
foreach ($excludes as $exclude) {
|
127 |
+
if (false !== $index = array_search($exclude, $arrFiles[$scope])) {
|
128 |
+
unset($arrFiles[$scope][$index]);
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
return $arrFiles;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Removes compile scope from config
|
137 |
+
*
|
138 |
+
* @return Aitoc_Aitsys_Model_Core_Compiler_Rules
|
139 |
+
*/
|
140 |
+
public function applyRemoveScopeRule()
|
141 |
+
{
|
142 |
+
$scopesToRemove = $this->getCompileConfig()->getNode('remove_scope')->asArray();
|
143 |
+
if (!empty($scopesToRemove) && is_array($scopesToRemove)) {
|
144 |
+
foreach (array_keys($scopesToRemove) as $scope) {
|
145 |
+
$this->_removeScope($scope);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
return $this;
|
149 |
+
}
|
150 |
+
|
151 |
+
protected function _removeScope($scope)
|
152 |
+
{
|
153 |
+
unset($this->getCompileConfig()->getNode('includes')->$scope);
|
154 |
+
unset($this->getCompileConfig()->getNode('exclude_classes')->$scope);
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Rename scope
|
159 |
+
*
|
160 |
+
* @return Aitoc_Aitsys_Model_Core_Compiler_Rules
|
161 |
+
*/
|
162 |
+
public function applyRenameScopeRule()
|
163 |
+
{
|
164 |
+
$scopesToRename = $this->getCompileConfig()->getNode('rename_scope')->asArray();
|
165 |
+
if (!empty($scopesToRename) && is_array($scopesToRename)) {
|
166 |
+
foreach ($scopesToRename as $scopeFrom => $scopeTo) {
|
167 |
+
$this->_copyElement('includes', $scopeFrom, $scopeTo)
|
168 |
+
->_copyElement('exclude_classes', $scopeFrom, $scopeTo);
|
169 |
+
|
170 |
+
// remove original scope
|
171 |
+
$this->_removeScope($scopeFrom);
|
172 |
+
}
|
173 |
+
}
|
174 |
+
return $this;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Duplicate an existing config element
|
179 |
+
*
|
180 |
+
* @param string $area Area to work with
|
181 |
+
* @param string $oldName Old node name
|
182 |
+
* @param string $newName New node name
|
183 |
+
*
|
184 |
+
* @return Aitoc_Aitsys_Model_Core_Compiler_Rules
|
185 |
+
*/
|
186 |
+
protected function _copyElement($area, $oldName, $newName)
|
187 |
+
{
|
188 |
+
$parent = $this->getCompileConfig()->getNode($area);
|
189 |
+
$newElement = clone $parent->$oldName;
|
190 |
+
$elementClass = get_class($newElement);
|
191 |
+
$newElement = new $elementClass(str_replace($oldName, $newName, $newElement->asXml()));
|
192 |
+
$parent->extendChild($newElement);
|
193 |
+
return $this;
|
194 |
+
}
|
195 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Core/Database.php
ADDED
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2011 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Core_Database extends Aitoc_Aitsys_Abstract_Model
|
6 |
+
{
|
7 |
+
protected $_conn;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @var array()
|
11 |
+
*/
|
12 |
+
protected $_statuses;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var array()
|
16 |
+
*/
|
17 |
+
protected $_cachedConfig;
|
18 |
+
|
19 |
+
protected function _connection()
|
20 |
+
{
|
21 |
+
if (is_null($this->_conn))
|
22 |
+
{
|
23 |
+
if (!Mage::registry('_singleton/core/resource'))
|
24 |
+
{
|
25 |
+
$config = $this->_config();
|
26 |
+
$this->_conn = new Varien_Db_Adapter_Pdo_Mysql(array(
|
27 |
+
'host' => (string)$config->global->resources->default_setup->connection->host,
|
28 |
+
'username' => (string)$config->global->resources->default_setup->connection->username,
|
29 |
+
'password' => (string)$config->global->resources->default_setup->connection->password,
|
30 |
+
'dbname' => (string)$config->global->resources->default_setup->connection->dbname ,
|
31 |
+
'port' => (string)$config->global->resources->default_setup->connection->port,
|
32 |
+
'type' => 'pdo_mysql' ,
|
33 |
+
'model' => 'mysql4' ,
|
34 |
+
'active' => 1
|
35 |
+
));
|
36 |
+
}
|
37 |
+
else
|
38 |
+
{
|
39 |
+
$this->_conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
40 |
+
}
|
41 |
+
}
|
42 |
+
return $this->_conn;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Get table name using magento tables' prefix
|
47 |
+
*
|
48 |
+
* @param string $table
|
49 |
+
*/
|
50 |
+
protected function _table($table)
|
51 |
+
{
|
52 |
+
if(isset($this->_config()->global->resources->db) && isset($this->_config()->global->resources->db->table_prefix))
|
53 |
+
{
|
54 |
+
return $this->_config()->global->resources->db->table_prefix.$table;
|
55 |
+
}
|
56 |
+
|
57 |
+
return $table;
|
58 |
+
}
|
59 |
+
|
60 |
+
protected function _config()
|
61 |
+
{
|
62 |
+
if (is_null($this->_localConfig)) {
|
63 |
+
$path = BP . '/app/etc/local.xml';
|
64 |
+
if (file_exists($path))
|
65 |
+
{
|
66 |
+
$this->_localConfig = new Zend_Config_Xml($path);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
return $this->_localConfig;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Get config value from local
|
74 |
+
*
|
75 |
+
* @param string $type
|
76 |
+
* @param mixed $value
|
77 |
+
*/
|
78 |
+
/* removed from 2.20
|
79 |
+
protected function _getCachedConfig($type)
|
80 |
+
{
|
81 |
+
if(is_null($this->_cachedConfig))
|
82 |
+
{
|
83 |
+
$this->_cachedConfig = $this->tool()->getCache()->load('aitsys_db_config', array());
|
84 |
+
}
|
85 |
+
$type = md5($type);
|
86 |
+
return isset($this->_cachedConfig[$type]) ? $this->_cachedConfig[$type] : null;
|
87 |
+
}
|
88 |
+
*/
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Save config value from database to local cache to prevent future queries
|
92 |
+
*
|
93 |
+
* @param string $type
|
94 |
+
* @param mixed $value
|
95 |
+
*/
|
96 |
+
/* removed from 2.20
|
97 |
+
protected function _updateCachedConfig($type, $value)
|
98 |
+
{
|
99 |
+
$type = md5($type);
|
100 |
+
$this->_cachedConfig[$type] = $value;
|
101 |
+
$this->tool()->getCache()->save($this->_cachedConfig, 'aitsys_db_config');
|
102 |
+
|
103 |
+
return $this->_cachedConfig[$type];
|
104 |
+
}
|
105 |
+
*/
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get value from magento core_config_data table
|
109 |
+
*
|
110 |
+
* @param string $path
|
111 |
+
* @param mixed $defaultValue
|
112 |
+
*/
|
113 |
+
public function getConfigValue($path, $defaultValue = null)
|
114 |
+
{
|
115 |
+
// if (!$data = $this->_getCachedConfig($path)) { // removed from 2.20
|
116 |
+
$conn = $this->_connection();
|
117 |
+
$select = $conn->select()
|
118 |
+
->from($this->_table('core_config_data'))
|
119 |
+
->where('path = ?',$path)
|
120 |
+
->where('scope = ?','default');
|
121 |
+
$data = $conn->fetchRow($select);
|
122 |
+
|
123 |
+
//$conn->closeConnection();
|
124 |
+
if ($data === false || !isset($data['value']) || $data['value'] === '') {
|
125 |
+
$data = $defaultValue;
|
126 |
+
} else {
|
127 |
+
$data = $data['value'];
|
128 |
+
}
|
129 |
+
|
130 |
+
$data = $this->tool()->unserialize($data);
|
131 |
+
/*
|
132 |
+
$this->_updateCachedConfig($path, $data);
|
133 |
+
}
|
134 |
+
*/
|
135 |
+
return $data;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Retrieves stored modules' statuses.
|
140 |
+
*
|
141 |
+
* @param string $key Module key like Aitoc_Aitmodulename
|
142 |
+
* @return array|bool
|
143 |
+
*/
|
144 |
+
public function getStatus($key = '')
|
145 |
+
{
|
146 |
+
if (is_null($this->_statuses)) {
|
147 |
+
// $this->_statuses = $this->tool()->getCache()->load('aitsys_db_statuses', array()); // removed from 2.20
|
148 |
+
$this->_statuses = array();
|
149 |
+
// if(empty($this->_statuses)) {
|
150 |
+
$conn = $this->_connection();
|
151 |
+
$select = $conn->select()->from($this->_table('aitsys_status'));
|
152 |
+
$data = $conn->fetchAll($select);
|
153 |
+
|
154 |
+
foreach($data as $module) {
|
155 |
+
$this->_statuses[$module['module']] = $module['status'];
|
156 |
+
}
|
157 |
+
// $this->tool()->getCache()->save($this->_statuses, 'aitsys_db_statuses'); // removed from 2.20
|
158 |
+
//}
|
159 |
+
}
|
160 |
+
|
161 |
+
if ($key) {
|
162 |
+
return isset($this->_statuses[$key]) ? (bool)$this->_statuses[$key] : false;
|
163 |
+
} else {
|
164 |
+
return $this->_statuses;
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Return current Aitsys db resource version
|
170 |
+
*
|
171 |
+
* @return string
|
172 |
+
*/
|
173 |
+
public function dbVersion()
|
174 |
+
{
|
175 |
+
// if(is_null($this->_dbVersion) && !($this->_dbVersion = $this->_getCachedConfig('db_version'))) { // removed from 2.20
|
176 |
+
$conn = $this->_connection();
|
177 |
+
$select = $conn->select()
|
178 |
+
->from($this->_table('core_resource'), 'version')
|
179 |
+
->where('code =?', 'aitsys_setup');
|
180 |
+
$this->_dbVersion = $conn->fetchOne($select);
|
181 |
+
/* removed from 2.20
|
182 |
+
$this->_updateCachedConfig('db_version', $this->_dbVersion);
|
183 |
+
} */
|
184 |
+
return $this->_dbVersion;
|
185 |
+
}
|
186 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Core/Filesystem.php
ADDED
@@ -0,0 +1,624 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Core_Filesystem extends Aitoc_Aitsys_Abstract_Model
|
6 |
+
{
|
7 |
+
//permissions
|
8 |
+
const PERM_FILE = 0644;
|
9 |
+
const PERM_DIR = 0755;
|
10 |
+
const PERM_ALL = 0777;
|
11 |
+
|
12 |
+
const MODE_ALL = 'all';
|
13 |
+
const MODE_NORMAL = 'normal';
|
14 |
+
|
15 |
+
//may be eighter 'all' or 'normal'
|
16 |
+
protected $_permissionsMode;
|
17 |
+
|
18 |
+
protected $_subsystemsDirs = array();
|
19 |
+
|
20 |
+
protected $_closedMainFolders;
|
21 |
+
|
22 |
+
protected $_forbiddenDirs = array('.', '..', '.svn', '.git');
|
23 |
+
|
24 |
+
protected $_pools = array('community', 'local');
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Makes temporary file in var/ folder
|
28 |
+
*
|
29 |
+
* @param string $sFromFile
|
30 |
+
* @return string file path
|
31 |
+
*/
|
32 |
+
public function makeTemporary($sFromFile)
|
33 |
+
{
|
34 |
+
$sFileType = substr($sFromFile, strrpos($sFromFile, '.'));
|
35 |
+
$sTemp = BP . DS . $this->tool()->platform()->getVarPath() . DS . uniqid(time()) . $sFileType;
|
36 |
+
copy($sFromFile, $sTemp);
|
37 |
+
return $sTemp;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getCodeDir()
|
41 |
+
{
|
42 |
+
return BP.'/app/code/';
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getLocalDir()
|
46 |
+
{
|
47 |
+
return $this->getCodeDir() . 'local/';
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getCommunityDir()
|
51 |
+
{
|
52 |
+
return $this->getCodeDir() . 'community/';
|
53 |
+
}
|
54 |
+
|
55 |
+
public function getEtcDir()
|
56 |
+
{
|
57 |
+
return BP.'/app/etc/modules';
|
58 |
+
}
|
59 |
+
|
60 |
+
public function getBaseDir()
|
61 |
+
{
|
62 |
+
return BP.DS;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getAitsysDir()
|
66 |
+
{
|
67 |
+
return $this->getCommunityDir().'Aitoc/Aitsys';
|
68 |
+
}
|
69 |
+
|
70 |
+
public function getModuleDir( $moduleName )
|
71 |
+
{
|
72 |
+
if (!$this->hasData($moduleName . '_dir'))
|
73 |
+
{
|
74 |
+
$dir = false;
|
75 |
+
if ( $moduleName ) {
|
76 |
+
$vendorDir = str_replace('_', DS, $moduleName);
|
77 |
+
$community = $this->getCommunityDir().$vendorDir;
|
78 |
+
$local = $this->getLocalDir().$vendorDir;
|
79 |
+
if ( file_exists( $community ) && is_dir( $community ) ) {
|
80 |
+
$dir = $community;
|
81 |
+
} elseif ( file_exists( $local ) && is_dir( $local ) ) {
|
82 |
+
$dir = $local;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
$this->setData($moduleName . '_dir', $dir);
|
86 |
+
}
|
87 |
+
return $this->getData($moduleName . '_dir');
|
88 |
+
}
|
89 |
+
|
90 |
+
public function getAitocModulesDirs()
|
91 |
+
{
|
92 |
+
if (!$this->hasData('aitoc_modules_dirs')) {
|
93 |
+
$result = array();
|
94 |
+
$local = $this->getLocalDir();
|
95 |
+
$community = $this->getCommunityDir();
|
96 |
+
foreach ($this->tool()->platform()->getModuleDirs() as $dir) {
|
97 |
+
$result[] = $local.$dir.DS;
|
98 |
+
$result[] = $community.$dir.DS;
|
99 |
+
}
|
100 |
+
$this->setData('aitoc_modules_dirs',$result);
|
101 |
+
}
|
102 |
+
return $this->getData('aitoc_modules_dirs');
|
103 |
+
}
|
104 |
+
|
105 |
+
public function mkDir($sPath)
|
106 |
+
{
|
107 |
+
return $this->makeDirStructure($sPath,false);
|
108 |
+
}
|
109 |
+
|
110 |
+
public function makeDirsDiff($sOrigDir, $sChangedDir, $sPatchFilePath)
|
111 |
+
{
|
112 |
+
$sCmd = 'diff -aurBb ' . $sOrigDir . ' ' . $sChangedDir . ' > ' . $sPatchFilePath;
|
113 |
+
exec($sCmd);
|
114 |
+
$this->grantAll($sPatchFilePath);
|
115 |
+
return $this;
|
116 |
+
}
|
117 |
+
|
118 |
+
public function grantAll( $path , $recursive = true, $all = false )
|
119 |
+
{
|
120 |
+
if(file_exists($path))
|
121 |
+
{
|
122 |
+
if($all)
|
123 |
+
{
|
124 |
+
@chmod($path, self::PERM_ALL);
|
125 |
+
}
|
126 |
+
else
|
127 |
+
{
|
128 |
+
if(is_dir($path))
|
129 |
+
{
|
130 |
+
@chmod($path, self::PERM_DIR);
|
131 |
+
}
|
132 |
+
else
|
133 |
+
{
|
134 |
+
@chmod($path, self::PERM_FILE);
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
if ($recursive = is_dir($path))
|
139 |
+
{
|
140 |
+
$items = new RecursiveDirectoryIterator($path);
|
141 |
+
foreach ($items as $item)
|
142 |
+
{
|
143 |
+
if(in_array(basename($item), $this->getForbiddenDirs()))
|
144 |
+
{
|
145 |
+
continue;
|
146 |
+
}
|
147 |
+
$this->grantAll((string)$item, false, $all);
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
return $this;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Removes file
|
156 |
+
*
|
157 |
+
* @param string $sPath
|
158 |
+
*/
|
159 |
+
public function rmFile($sPath)
|
160 |
+
{
|
161 |
+
if (file_exists($sPath) && $this->isWriteable($sPath))
|
162 |
+
{
|
163 |
+
if (is_file($sPath))
|
164 |
+
{
|
165 |
+
@unlink($sPath);
|
166 |
+
}
|
167 |
+
else
|
168 |
+
{
|
169 |
+
@rmdir($sPath);
|
170 |
+
}
|
171 |
+
return !file_exists($sPath);
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
public function moveFile($source, $destination)
|
176 |
+
{
|
177 |
+
$this->cpFile($source,$destination);
|
178 |
+
return $this->rmFile($source);
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Copy file. Makes directory structure if not exists.
|
183 |
+
*
|
184 |
+
* @param string $sSource
|
185 |
+
* @param string $sDestination
|
186 |
+
*/
|
187 |
+
public function cpFile($sSource, $sDestination,$exc=false)
|
188 |
+
{
|
189 |
+
$this->makeDirStructure($sDestination);
|
190 |
+
$res = @copy($sSource, $sDestination);
|
191 |
+
if(false === $res && $exc)
|
192 |
+
{
|
193 |
+
$msg = "Can't copy ".$sSource." to ".$sDestination;
|
194 |
+
if (file_exists($sDestination) && !$this->isWriteable($sDestination,true))
|
195 |
+
{
|
196 |
+
$msg .= ' - desitnation path is not writeable';
|
197 |
+
}
|
198 |
+
$msg .= '.';
|
199 |
+
throw new Aitoc_Aitsys_Model_Core_Filesystem_Exception($msg);
|
200 |
+
}
|
201 |
+
else
|
202 |
+
{
|
203 |
+
$this->grantAll($sDestination);
|
204 |
+
}
|
205 |
+
return $res;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Creates directories, file and puts the content into a file and grants this file some permissions
|
210 |
+
*
|
211 |
+
* @param string $filePath Path to the file where to write the data.
|
212 |
+
* @param mixed $fileContent The data to write. Can be either a string, an array or a stream resource.
|
213 |
+
* @param integer $permissions Permissions to be granted to the file
|
214 |
+
*
|
215 |
+
* @return boolean
|
216 |
+
*/
|
217 |
+
public function putFile($filePath, $fileContent, $permissions = null)
|
218 |
+
{
|
219 |
+
if(!$permissions)
|
220 |
+
{
|
221 |
+
$mode = $this->getPermissionsMode();
|
222 |
+
$permissions = ($mode == self::MODE_ALL) ? self::PERM_ALL : self::PERM_FILE;
|
223 |
+
}
|
224 |
+
|
225 |
+
$this->makeDirStructure($filePath, true);
|
226 |
+
|
227 |
+
$chmod = !file_exists($filePath);
|
228 |
+
$result = file_put_contents($filePath, $fileContent);
|
229 |
+
if($chmod)
|
230 |
+
{
|
231 |
+
@chmod($filePath, $permissions);
|
232 |
+
}
|
233 |
+
return is_int($result);
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* @return string
|
238 |
+
*/
|
239 |
+
public function getPermissionsMode()
|
240 |
+
{
|
241 |
+
if(!$this->_permissionsMode)
|
242 |
+
{
|
243 |
+
$this->_permissionsMode = $this->tool()->db()->getConfigValue('aitsys_write_permissions', self::MODE_NORMAL);
|
244 |
+
}
|
245 |
+
return $this->_permissionsMode;
|
246 |
+
}
|
247 |
+
|
248 |
+
public function setPermissionsMode($mode)
|
249 |
+
{
|
250 |
+
$this->_permissionsMode = $mode;
|
251 |
+
return $this;
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* @return array
|
256 |
+
*/
|
257 |
+
public function checkMainPermissions()
|
258 |
+
{
|
259 |
+
if (is_null($this->_closedMainFolders))
|
260 |
+
{
|
261 |
+
$this->_closedMainFolders = array();
|
262 |
+
$foldersToCheck = array();
|
263 |
+
$subsystemsDirs = $this->getSubsystemsDirs();
|
264 |
+
$modulesDirs = array(); // deprecated since 2.19.0 $this->getAitocModulesDirs();
|
265 |
+
|
266 |
+
$foldersToCheck[] = BP . DS . $this->tool()->platform()->getVarPath() . DS;
|
267 |
+
$foldersToCheck = array_merge($foldersToCheck, $subsystemsDirs, $modulesDirs);
|
268 |
+
|
269 |
+
foreach($foldersToCheck as $i => $folder)
|
270 |
+
{
|
271 |
+
if (file_exists($folder) && is_dir($folder) && !$this->isWriteable($folder, false, (bool)$i))
|
272 |
+
{
|
273 |
+
$this->_closedMainFolders[] = $folder;
|
274 |
+
}
|
275 |
+
}
|
276 |
+
}
|
277 |
+
return $this->_closedMainFolders;
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* @return array
|
282 |
+
*/
|
283 |
+
public function getSubsystemsDirs()
|
284 |
+
{
|
285 |
+
if(empty($this->_subsystemsDirs))
|
286 |
+
{
|
287 |
+
$this->_subsystemsDirs[] = Aitoc_Aitsys_Model_Rewriter_Abstract::getRewritesCacheDir();
|
288 |
+
$this->_subsystemsDirs[] = Aitoc_Aitsys_Model_Aitpatch::getPatchesCacheDir();
|
289 |
+
}
|
290 |
+
|
291 |
+
return $this->_subsystemsDirs;
|
292 |
+
}
|
293 |
+
|
294 |
+
public function permissonsChange($mode)
|
295 |
+
{
|
296 |
+
$all = ($mode === self::MODE_ALL);
|
297 |
+
$folders = $this->getSubsystemsDirs();
|
298 |
+
|
299 |
+
foreach ($folders as $folder)
|
300 |
+
{
|
301 |
+
$this->grantAll($folder, true, $all);
|
302 |
+
}
|
303 |
+
|
304 |
+
$this->setPermissionsMode($mode);
|
305 |
+
Mage::getConfig()->saveConfig('aitsys_write_permissions', $mode);
|
306 |
+
Mage::app()->cleanCache();
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Makes directory structure and sets permissions
|
311 |
+
*
|
312 |
+
* @param string $sPath
|
313 |
+
*/
|
314 |
+
public function makeDirStructure( $path , $isFile = true )
|
315 |
+
{
|
316 |
+
$path = str_replace('\\','/',$path);
|
317 |
+
$basePath = str_replace('\\', '/', BP).'/';
|
318 |
+
$pathItems = explode('/',substr($path,strlen($basePath)));
|
319 |
+
|
320 |
+
$all = $this->getPermissionsMode()==self::MODE_ALL;
|
321 |
+
|
322 |
+
if ($isFile)
|
323 |
+
{
|
324 |
+
array_pop($pathItems);
|
325 |
+
}
|
326 |
+
foreach ($pathItems as $dir)
|
327 |
+
{
|
328 |
+
if ($dir === '')
|
329 |
+
{
|
330 |
+
continue;
|
331 |
+
}
|
332 |
+
$basePath .= $dir.'/';
|
333 |
+
if (!@file_exists($basePath) or (@file_exists($basePath) and !@is_dir($basePath)))
|
334 |
+
{
|
335 |
+
@mkdir($basePath, self::PERM_DIR);
|
336 |
+
$this->grantAll($basePath, true, $all);
|
337 |
+
}
|
338 |
+
}
|
339 |
+
return $this;
|
340 |
+
}
|
341 |
+
|
342 |
+
public function checkWriteable( $path , $exception = false )
|
343 |
+
{
|
344 |
+
if (!$path) return false;
|
345 |
+
|
346 |
+
if (!$this->isWriteable($path) && !$this->tool()->isPhpCli())
|
347 |
+
{
|
348 |
+
if ($exception)
|
349 |
+
{
|
350 |
+
$this->_exception($path);
|
351 |
+
}
|
352 |
+
return false;
|
353 |
+
}
|
354 |
+
return true;
|
355 |
+
}
|
356 |
+
|
357 |
+
protected function _exception( $msg )
|
358 |
+
{
|
359 |
+
throw new Aitoc_Aitsys_Model_Core_Filesystem_Exception($msg);
|
360 |
+
}
|
361 |
+
|
362 |
+
public function isWriteable($sPath, $bCheckParentDirIfNotExists = true, $recursive = false)
|
363 |
+
{
|
364 |
+
clearstatcache();
|
365 |
+
if (file_exists($sPath))
|
366 |
+
{
|
367 |
+
if(is_file($sPath))
|
368 |
+
{
|
369 |
+
return $this->isFileWritable($sPath);
|
370 |
+
}
|
371 |
+
else
|
372 |
+
{
|
373 |
+
$return = $this->isDirWritable($sPath);
|
374 |
+
if($return && $recursive)
|
375 |
+
{
|
376 |
+
$items = new RecursiveDirectoryIterator($sPath);
|
377 |
+
foreach ($items as $item)
|
378 |
+
{
|
379 |
+
if(in_array(basename($item), $this->getForbiddenDirs()))
|
380 |
+
{
|
381 |
+
continue;
|
382 |
+
}
|
383 |
+
if(!$this->isWriteable((string)$item, false, true))
|
384 |
+
{
|
385 |
+
return false;
|
386 |
+
}
|
387 |
+
}
|
388 |
+
}
|
389 |
+
|
390 |
+
return $return;
|
391 |
+
}
|
392 |
+
}
|
393 |
+
else
|
394 |
+
{
|
395 |
+
if (!$bCheckParentDirIfNotExists)
|
396 |
+
{
|
397 |
+
return false;
|
398 |
+
}
|
399 |
+
$sDirname = dirname($sPath);
|
400 |
+
while (strlen($sDirname) > 0 AND !file_exists($sDirname))
|
401 |
+
{
|
402 |
+
$sDirname = dirname($sDirname);
|
403 |
+
}
|
404 |
+
return $this->isDirWritable($sDirname);
|
405 |
+
}
|
406 |
+
return false;
|
407 |
+
}
|
408 |
+
|
409 |
+
public function isFileWritable($sPath)
|
410 |
+
{
|
411 |
+
if (!$sPath)
|
412 |
+
{
|
413 |
+
return false;
|
414 |
+
}
|
415 |
+
if (stristr(PHP_OS, "win"))
|
416 |
+
{
|
417 |
+
// trying to append
|
418 |
+
$fp = @fopen($sPath, 'a+');
|
419 |
+
if (!$fp)
|
420 |
+
{
|
421 |
+
return false;
|
422 |
+
}
|
423 |
+
fclose($fp);
|
424 |
+
return true;
|
425 |
+
} else
|
426 |
+
{
|
427 |
+
return is_writable($sPath);
|
428 |
+
}
|
429 |
+
}
|
430 |
+
|
431 |
+
public function isDirWritable($sPath)
|
432 |
+
{
|
433 |
+
if (!$sPath)
|
434 |
+
{
|
435 |
+
return false;
|
436 |
+
}
|
437 |
+
if ('/' != $sPath[strlen($sPath)-1])
|
438 |
+
{
|
439 |
+
$sPath .= DIRECTORY_SEPARATOR;
|
440 |
+
}
|
441 |
+
if (stristr(PHP_OS, "win"))
|
442 |
+
{
|
443 |
+
/**
|
444 |
+
* Trying to create a new file
|
445 |
+
*/
|
446 |
+
$sFilename = uniqid(time());
|
447 |
+
$fp = @fopen($sPath . $sFilename, 'w');
|
448 |
+
if (!$fp)
|
449 |
+
{
|
450 |
+
return false;
|
451 |
+
}
|
452 |
+
if (!@fwrite($fp, 'test'))
|
453 |
+
{
|
454 |
+
return false;
|
455 |
+
}
|
456 |
+
fclose($fp);
|
457 |
+
/**
|
458 |
+
* clean up after ourselves
|
459 |
+
*/
|
460 |
+
unlink($sPath . $sFilename);
|
461 |
+
return true;
|
462 |
+
} else
|
463 |
+
{
|
464 |
+
return is_writable($sPath);
|
465 |
+
}
|
466 |
+
}
|
467 |
+
|
468 |
+
public function emptyDir($dirname = null)
|
469 |
+
{
|
470 |
+
if(!is_null($dirname)) {
|
471 |
+
if (is_dir($dirname)) {
|
472 |
+
if ($handle = @opendir($dirname)) {
|
473 |
+
while (($file = readdir($handle)) !== false) {
|
474 |
+
if ($file != "." && $file != "..") {
|
475 |
+
$fullpath = $dirname . '/' . $file;
|
476 |
+
if (is_dir($fullpath)) {
|
477 |
+
$this->emptyDir($fullpath);
|
478 |
+
@rmdir($fullpath);
|
479 |
+
}
|
480 |
+
else {
|
481 |
+
@unlink($fullpath);
|
482 |
+
}
|
483 |
+
}
|
484 |
+
}
|
485 |
+
closedir($handle);
|
486 |
+
}
|
487 |
+
}
|
488 |
+
}
|
489 |
+
}
|
490 |
+
|
491 |
+
/**
|
492 |
+
* Gets all the subdirectories off the $directoryPath
|
493 |
+
*
|
494 |
+
* @param string $directoryPath
|
495 |
+
* @return array
|
496 |
+
*/
|
497 |
+
public function getSubDir($directoryPath)
|
498 |
+
{
|
499 |
+
if (!is_dir($directoryPath))
|
500 |
+
{
|
501 |
+
return array();
|
502 |
+
}
|
503 |
+
|
504 |
+
$directories = array();
|
505 |
+
$directoryPath = rtrim($directoryPath,'/\\').'/';
|
506 |
+
$dir = dir($directoryPath);
|
507 |
+
|
508 |
+
while (false !== ($file = $dir->read()))
|
509 |
+
{
|
510 |
+
if (!in_array($file, $this->getForbiddenDirs()) && is_dir($directoryPath.$file))
|
511 |
+
{
|
512 |
+
$directories[] = $file;
|
513 |
+
}
|
514 |
+
}
|
515 |
+
|
516 |
+
$dir->close();
|
517 |
+
|
518 |
+
return $directories;
|
519 |
+
}
|
520 |
+
|
521 |
+
/**
|
522 |
+
* Searches for most suitable patch file in the directory ("PATH_TO_MODULE/data/" as a rule)
|
523 |
+
*
|
524 |
+
* @param string $fileName
|
525 |
+
* @param string $directory
|
526 |
+
* @return Varien_Object
|
527 |
+
*/
|
528 |
+
public function getPatchFilePath($fileName, $directory)
|
529 |
+
{
|
530 |
+
$data = array();
|
531 |
+
|
532 |
+
if (!$fileName || !$directory)
|
533 |
+
{
|
534 |
+
$data['is_error'] = true;
|
535 |
+
$data['file_path'] = __('Unknown');
|
536 |
+
return new Varien_Object($data);
|
537 |
+
}
|
538 |
+
|
539 |
+
$directory = rtrim($directory,'/\\').'/';
|
540 |
+
|
541 |
+
$lastSuccessIndex = null;
|
542 |
+
|
543 |
+
$subDirectories = $this->getSubDir($directory);
|
544 |
+
|
545 |
+
if ($subDirectories)
|
546 |
+
{
|
547 |
+
uasort($subDirectories, array($this, 'sortSubdirectories'));
|
548 |
+
|
549 |
+
// Array bounds added for convenience
|
550 |
+
array_unshift($subDirectories, 0);
|
551 |
+
array_push($subDirectories, 100000);
|
552 |
+
|
553 |
+
for ($i = 0; $i < count($subDirectories); $i++)
|
554 |
+
{
|
555 |
+
$result = version_compare($subDirectories[$i], Mage::getVersion());
|
556 |
+
$currentFile = $directory . $subDirectories[$i] . DIRECTORY_SEPARATOR . $fileName;
|
557 |
+
|
558 |
+
if (0 == $result)
|
559 |
+
{
|
560 |
+
if (is_file($currentFile))
|
561 |
+
{
|
562 |
+
$lastSuccessIndex = $i;
|
563 |
+
break;
|
564 |
+
}
|
565 |
+
}
|
566 |
+
elseif ((-1) == $result)
|
567 |
+
{
|
568 |
+
if (is_file($currentFile))
|
569 |
+
{
|
570 |
+
$lastSuccessIndex = $i;
|
571 |
+
}
|
572 |
+
}
|
573 |
+
elseif (1 == $result)
|
574 |
+
{
|
575 |
+
if (is_null($lastSuccessIndex) && is_file($currentFile))
|
576 |
+
{
|
577 |
+
$lastSuccessIndex = $i;
|
578 |
+
break;
|
579 |
+
}
|
580 |
+
}
|
581 |
+
}
|
582 |
+
}
|
583 |
+
elseif (is_file($directory . $fileName))
|
584 |
+
{
|
585 |
+
$data['is_error'] = false;
|
586 |
+
$data['file_path'] = $directory . $fileName;
|
587 |
+
return new Varien_Object($data);
|
588 |
+
}
|
589 |
+
|
590 |
+
if (is_null($lastSuccessIndex))
|
591 |
+
{
|
592 |
+
$data['is_error'] = true;
|
593 |
+
$data['file_path'] = $directory . $fileName;
|
594 |
+
}
|
595 |
+
else
|
596 |
+
{
|
597 |
+
$data['is_error'] = false;
|
598 |
+
$data['file_path'] = $directory . $subDirectories[$lastSuccessIndex] . DIRECTORY_SEPARATOR . $fileName;
|
599 |
+
}
|
600 |
+
|
601 |
+
return new Varien_Object($data);
|
602 |
+
}
|
603 |
+
|
604 |
+
/**
|
605 |
+
* Wrapper for version_compare
|
606 |
+
*
|
607 |
+
* @param string $directoryA
|
608 |
+
* @param string $directoryB
|
609 |
+
* @return mixed
|
610 |
+
*/
|
611 |
+
|
612 |
+
public function sortSubdirectories($directoryA, $directoryB)
|
613 |
+
{
|
614 |
+
return version_compare($directoryA, $directoryB);
|
615 |
+
}
|
616 |
+
|
617 |
+
/**
|
618 |
+
* @return array
|
619 |
+
*/
|
620 |
+
public function getForbiddenDirs()
|
621 |
+
{
|
622 |
+
return $this->_forbiddenDirs;
|
623 |
+
}
|
624 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Core/Filesystem/Exception.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Core_Filesystem_Exception extends Mage_Core_Exception
|
6 |
+
{
|
7 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Feed.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Aitoc_Aitsys_Model_Feed extends Mage_AdminNotification_Model_Feed
|
4 |
+
{
|
5 |
+
const XML_FREQUENCY_PATH = 'aitsys/feed/frequency';
|
6 |
+
const XML_LAST_UPDATE_PATH = 'aitsys/feed/last_update';
|
7 |
+
const XML_ITERESTS = 'aitsys/feed/interests';
|
8 |
+
const XML_FEED_URL_PATH = 'aitsys/feed/feed_url';
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Check feed for modification
|
12 |
+
*
|
13 |
+
* @return Mage_AdminNotification_Model_Feed
|
14 |
+
*/
|
15 |
+
public function checkUpdate()
|
16 |
+
{
|
17 |
+
if (($this->getFrequency() + $this->getLastUpdate()) > time()) {
|
18 |
+
return $this;
|
19 |
+
}
|
20 |
+
|
21 |
+
$this->setLastUpdate();
|
22 |
+
$feedData = array();
|
23 |
+
|
24 |
+
$feedXml = $this->getFeedData();
|
25 |
+
|
26 |
+
$installDate = date('Y-m-d H:i:s', Mage::getStoreConfig('aitsys/feed/install_date'));
|
27 |
+
|
28 |
+
if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
|
29 |
+
foreach ($feedXml->channel->item as $item) {
|
30 |
+
$date = $this->getDate((string)$item->pubDate);
|
31 |
+
|
32 |
+
if($date < $installDate || !$this->_isInteresting($item))
|
33 |
+
{
|
34 |
+
continue;
|
35 |
+
}
|
36 |
+
|
37 |
+
$feedData[] = array(
|
38 |
+
'severity' => (int)$item->severity,
|
39 |
+
'date_added' => $this->getDate((string)$item->pubDate),
|
40 |
+
'title' => (string)$item->title,
|
41 |
+
'description' => (string)$item->description,
|
42 |
+
'url' => (string)$item->link,
|
43 |
+
);
|
44 |
+
}
|
45 |
+
|
46 |
+
if ($feedData) {
|
47 |
+
Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData));
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
|
55 |
+
protected function _isInteresting($item)
|
56 |
+
{
|
57 |
+
$interests = explode(',', $this->_getInterests());
|
58 |
+
if(in_array((string)$item->type, $interests))
|
59 |
+
{
|
60 |
+
return true;
|
61 |
+
}
|
62 |
+
|
63 |
+
if($item->type == Aitoc_Aitsys_Model_System_Config_Source_Interest::EXTENSION_UPDATE
|
64 |
+
&& in_array(Aitoc_Aitsys_Model_System_Config_Source_Interest::EXTENSION_UPDATE_CUSTOMER, $interests))
|
65 |
+
{
|
66 |
+
list($extension, $platform) = explode('-', (string)$item->extension);
|
67 |
+
$isMagentoEE = Aitoc_Aitsys_Model_Platform::getInstance()->isMagentoEnterprise();
|
68 |
+
if($isMagentoEE && $platform == 'EE'
|
69 |
+
|| !$isMagentoEE && empty($platform))
|
70 |
+
{
|
71 |
+
return Mage::helper('core')->isModuleEnabled($extension);
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Retrieve feed url
|
80 |
+
*
|
81 |
+
* @return string
|
82 |
+
*/
|
83 |
+
public function getFeedUrl()
|
84 |
+
{
|
85 |
+
if (is_null($this->_feedUrl)) {
|
86 |
+
$this->_feedUrl = Mage::getStoreConfig(self::XML_FEED_URL_PATH);
|
87 |
+
}
|
88 |
+
return $this->_feedUrl;
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
public function getFrequency()
|
93 |
+
{
|
94 |
+
return Mage::getStoreConfig(self::XML_FREQUENCY_PATH);
|
95 |
+
}
|
96 |
+
|
97 |
+
public function getLastUpdate()
|
98 |
+
{
|
99 |
+
return Mage::app()->loadCache('aitoc_notifications_lastcheck');
|
100 |
+
}
|
101 |
+
|
102 |
+
public function setLastUpdate()
|
103 |
+
{
|
104 |
+
Mage::app()->saveCache(time(), 'aitoc_notifications_lastcheck');
|
105 |
+
return $this;
|
106 |
+
}
|
107 |
+
|
108 |
+
protected function _getInterests()
|
109 |
+
{
|
110 |
+
return Mage::getStoreConfig(self::XML_ITERESTS);
|
111 |
+
}
|
112 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Module.php
ADDED
@@ -0,0 +1,324 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Main module model
|
4 |
+
*
|
5 |
+
* @method bool getAccess()
|
6 |
+
* @method bool getValue()
|
7 |
+
* @method string getFile()
|
8 |
+
* @method string getLabel()
|
9 |
+
* @method string getKey()
|
10 |
+
*
|
11 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
12 |
+
*/
|
13 |
+
final class Aitoc_Aitsys_Model_Module extends Aitoc_Aitsys_Abstract_Model
|
14 |
+
{
|
15 |
+
const PACKAGE_FILE = 'package.xml';
|
16 |
+
const DEFAULT_CODEPOOL = 'local';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var array
|
20 |
+
*/
|
21 |
+
protected $_conflictClassArray = array();
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
protected $_conflictModuleArray = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var bool
|
30 |
+
*/
|
31 |
+
protected $_isIgnore = false;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Errors storage
|
35 |
+
*
|
36 |
+
* @var array
|
37 |
+
*/
|
38 |
+
protected $_errors = array();
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Status correction necessity flag
|
42 |
+
*
|
43 |
+
* @var bool
|
44 |
+
*/
|
45 |
+
protected $_needCorrection = false;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @var Aitoc_Aitsys_Model_Module_Install
|
49 |
+
*/
|
50 |
+
protected $_install;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @var Aitoc_Aitsys_Model_Module_Info_Abstract
|
54 |
+
*/
|
55 |
+
protected $_info;
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @return Aitoc_Aitsys_Model_Platform
|
59 |
+
*/
|
60 |
+
public function getPlatform()
|
61 |
+
{
|
62 |
+
return $this->tool()->platform();
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Add an error to the storage
|
67 |
+
*
|
68 |
+
* @param string $error
|
69 |
+
* @return Aitoc_Aitsys_Model_Module
|
70 |
+
*/
|
71 |
+
public function addError( $error )
|
72 |
+
{
|
73 |
+
$this->_errors[] = $error;
|
74 |
+
return $this;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Add a number of errors to the storage
|
79 |
+
*
|
80 |
+
* @param $errors
|
81 |
+
* @return Aitoc_Aitsys_Model_Module
|
82 |
+
*/
|
83 |
+
public function addErrors( array $errors )
|
84 |
+
{
|
85 |
+
foreach ($errors as $error)
|
86 |
+
{
|
87 |
+
$this->addError($error);
|
88 |
+
}
|
89 |
+
return $this;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Get all unique errors from the storage and optionally clear the storage
|
94 |
+
*
|
95 |
+
* @param bool $clear Do clear errors storage on complete?
|
96 |
+
* @return array
|
97 |
+
*/
|
98 |
+
public function getErrors( $clear = false )
|
99 |
+
{
|
100 |
+
$result = $this->_errors;
|
101 |
+
if ($clear)
|
102 |
+
{
|
103 |
+
$this->_errors = array();
|
104 |
+
}
|
105 |
+
return array_unique($result);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Add all current errors to the session
|
110 |
+
*
|
111 |
+
* @param $translator
|
112 |
+
* @param Mage_Adminhtml_Model_Session $session
|
113 |
+
* @return bool
|
114 |
+
*/
|
115 |
+
public function produceErrors( $translator , Mage_Adminhtml_Model_Session $session = null )
|
116 |
+
{
|
117 |
+
if (!$session)
|
118 |
+
{
|
119 |
+
$session = $this->tool()->getInteractiveSession();
|
120 |
+
}
|
121 |
+
if (!$session)
|
122 |
+
{
|
123 |
+
$session = Mage::getSingleton('adminhtml/session');
|
124 |
+
}
|
125 |
+
/* @var $session Mage_Adminhtml_Model_Session */
|
126 |
+
foreach ($this->getErrors() as $error)
|
127 |
+
{
|
128 |
+
if (!is_array($error))
|
129 |
+
{
|
130 |
+
$error = (array)$error;
|
131 |
+
}
|
132 |
+
$msg = array_shift($error);
|
133 |
+
$session->addError($translator->__($msg));
|
134 |
+
}
|
135 |
+
return !empty($this->_errors);
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Reload the module from an appropriate install and/or module file.
|
140 |
+
*
|
141 |
+
* @return Aitoc_Aitsys_Model_Module
|
142 |
+
*/
|
143 |
+
public function reset()
|
144 |
+
{
|
145 |
+
$this->unsAccess();
|
146 |
+
$this->tool()->testMsg('Reset by module file: '.$this->getFile());
|
147 |
+
$this->loadByModuleFile($this->getFile());
|
148 |
+
return $this;
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Load the module using the main module config file form /etc/modules folder
|
153 |
+
*
|
154 |
+
* @param string $path Path to the module xml file
|
155 |
+
* @param string $key Module key
|
156 |
+
* @return Aitoc_Aitsys_Model_Module
|
157 |
+
*/
|
158 |
+
public function loadByModuleFile( $path , $key = null )
|
159 |
+
{
|
160 |
+
if (!$key) {
|
161 |
+
$key = basename($path, '.xml');
|
162 |
+
}
|
163 |
+
|
164 |
+
$this->addData(array(
|
165 |
+
'key' => $key,
|
166 |
+
'available' => true ,
|
167 |
+
'file' => $path ,
|
168 |
+
))->_updateByModuleFile()
|
169 |
+
->_createInstall()
|
170 |
+
->_checkCorrectionStatus();
|
171 |
+
return $this;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* @return Aitoc_Aitsys_Model_Module
|
176 |
+
*/
|
177 |
+
protected function _updateByModuleFile()
|
178 |
+
{
|
179 |
+
if (null === $this->getAccess()) {
|
180 |
+
$path = $this->getFile();
|
181 |
+
$key = $this->getKey();
|
182 |
+
if (file_exists($path)) {
|
183 |
+
$xml = simplexml_load_file($path);
|
184 |
+
$this->tool()->testMsg('Update module by config file: '.$key);
|
185 |
+
|
186 |
+
if (!$this->getLabel()) {
|
187 |
+
$this->setLabel((string)$xml->modules->$key->self_name ? (string)$xml->modules->$key->self_name : $key);
|
188 |
+
}
|
189 |
+
|
190 |
+
$this->setCodepool((string)$xml->modules->$key->codePool);
|
191 |
+
|
192 |
+
if (!$this->getPlatform()->getCheckAllowed()) {
|
193 |
+
$access = $this->tool()->filesystem()->checkWriteable($path);
|
194 |
+
} else {
|
195 |
+
$access = true;
|
196 |
+
}
|
197 |
+
$this->setValue('true' == (string)$xml->modules->$key->active)
|
198 |
+
->setAccess($access);
|
199 |
+
} else {
|
200 |
+
$this->setValue(false)
|
201 |
+
->setCodepool(self::DEFAULT_CODEPOOL)
|
202 |
+
->setAccess(false);
|
203 |
+
}
|
204 |
+
}
|
205 |
+
return $this;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Init and return the install model
|
210 |
+
*
|
211 |
+
* @return Aitoc_Aitsys_Model_Module
|
212 |
+
*/
|
213 |
+
protected function _createInstall()
|
214 |
+
{
|
215 |
+
if (!$this->_install) {
|
216 |
+
$this->_install = new Aitoc_Aitsys_Model_Module_Install();
|
217 |
+
$this->_install
|
218 |
+
->setModule($this)
|
219 |
+
->init()
|
220 |
+
->checkStatus();
|
221 |
+
}
|
222 |
+
return $this;
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Check whether the module needs correction
|
227 |
+
*
|
228 |
+
* @return Aitoc_Aitsys_Model_Module
|
229 |
+
*/
|
230 |
+
protected function _checkCorrectionStatus()
|
231 |
+
{
|
232 |
+
if(version_compare($this->tool()->db()->dbVersion(), '2.15.6', 'ge'))
|
233 |
+
{
|
234 |
+
$dbStatus = $this->tool()->db()->getStatus($this->getKey());
|
235 |
+
$xmlStatus = $this->getValue();
|
236 |
+
if($dbStatus !== $xmlStatus)
|
237 |
+
{
|
238 |
+
$this->_needCorrection = true;
|
239 |
+
$this->tool()->platform()->setNeedCorrection();
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
return $this;
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Whether the module needs correction?
|
248 |
+
*
|
249 |
+
* @return bool
|
250 |
+
*/
|
251 |
+
public function isNeedCorrection()
|
252 |
+
{
|
253 |
+
return $this->_needCorrection;
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* @return Aitoc_Aitsys_Model_Module_Install
|
258 |
+
*/
|
259 |
+
public function getInstall()
|
260 |
+
{
|
261 |
+
return $this->_install;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* @return Aitoc_Aitsys_Model_Module_Info_Abstract
|
266 |
+
*/
|
267 |
+
public function getInfo()
|
268 |
+
{
|
269 |
+
if (is_null($this->_info) && $this->getKey()) {
|
270 |
+
try {
|
271 |
+
$this->_info = Aitoc_Aitsys_Model_Module_Info_Factory::getModuleInfo($this, $this->getCodepool());
|
272 |
+
} catch (Aitoc_Aitsys_Model_Module_Info_Exception $e) {
|
273 |
+
$this->tool()->testMsg($e->getMessage());
|
274 |
+
}
|
275 |
+
}
|
276 |
+
return $this->_info;
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* @param $aitClass
|
281 |
+
* @param $moduleClass
|
282 |
+
*/
|
283 |
+
public function addConflict($aitClass, $moduleClass, $module)
|
284 |
+
{
|
285 |
+
$this->_conflictClassArray[$aitClass][]=$moduleClass;
|
286 |
+
$this->_conflictModuleArray[]=$module;
|
287 |
+
return;
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* @return array|bool
|
292 |
+
*/
|
293 |
+
public function getConflictClasses()
|
294 |
+
{
|
295 |
+
if(empty($this->_conflictClassArray))
|
296 |
+
{
|
297 |
+
return false;
|
298 |
+
}
|
299 |
+
return $this->_conflictClassArray;
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* @return array|bool
|
304 |
+
*/
|
305 |
+
public function getConflictModules()
|
306 |
+
{
|
307 |
+
if(empty($this->_conflictModuleArray))
|
308 |
+
{
|
309 |
+
return false;
|
310 |
+
}
|
311 |
+
return $this->_conflictModuleArray;
|
312 |
+
}
|
313 |
+
|
314 |
+
public function setIgnore($bool = true)
|
315 |
+
{
|
316 |
+
$this->_isIgnore = $bool;
|
317 |
+
return $this;
|
318 |
+
}
|
319 |
+
|
320 |
+
public function isIgnore()
|
321 |
+
{
|
322 |
+
return $this->_isIgnore;
|
323 |
+
}
|
324 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Module/Abstract.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Abstract module's subsystem model
|
4 |
+
*
|
5 |
+
* @method string getStatus()
|
6 |
+
* @method Aitoc_Aitsys_Model_Module_Abstract setStatus(string $status)
|
7 |
+
*
|
8 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
9 |
+
*/
|
10 |
+
abstract class Aitoc_Aitsys_Model_Module_Abstract extends Aitoc_Aitsys_Abstract_Model
|
11 |
+
{
|
12 |
+
const STATUS_UNKNOWN = 'unknown';
|
13 |
+
const STATUS_INSTALLED = 'installed';
|
14 |
+
const STATUS_UNINSTALLED = 'uninstalled';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var Aitoc_Aitsys_Model_Module
|
18 |
+
*/
|
19 |
+
protected $_module;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Init model
|
23 |
+
*
|
24 |
+
* @return Aitoc_Aitsys_Model_Module_Abstract
|
25 |
+
*/
|
26 |
+
public function init()
|
27 |
+
{
|
28 |
+
$this->setStatusUnknown();
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Add a number of errors to the module's errors storage
|
34 |
+
*
|
35 |
+
* @param array $errors
|
36 |
+
* @return Aitoc_Aitsys_Model_Module_Abstract
|
37 |
+
*/
|
38 |
+
public function addErrors( array $errors )
|
39 |
+
{
|
40 |
+
$this->getModule()->addErrors($errors);
|
41 |
+
return $this;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Add an error to the module's errors storage
|
46 |
+
*
|
47 |
+
* @param string $error
|
48 |
+
* @return Aitoc_Aitsys_Model_Module_Abstract
|
49 |
+
*/
|
50 |
+
public function addError( $error )
|
51 |
+
{
|
52 |
+
$this->getModule()->addError($error);
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Get all unique errors from the module's storage and optionally clear the storage
|
58 |
+
*
|
59 |
+
* @param bool $clear
|
60 |
+
* @return array
|
61 |
+
*/
|
62 |
+
public function getErrors( $clear = false )
|
63 |
+
{
|
64 |
+
return $this->getModule()->getErrors($clear);
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Get platform instance
|
69 |
+
*
|
70 |
+
* @return Aitoc_Aitsys_Model_Platform
|
71 |
+
*/
|
72 |
+
public function getPlatform()
|
73 |
+
{
|
74 |
+
return $this->tool()->platform();
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @param Aitoc_Aitsys_Model_Module $module
|
79 |
+
* @return Aitoc_Aitsys_Model_Module_Install
|
80 |
+
*/
|
81 |
+
public function setModule( Aitoc_Aitsys_Model_Module $module )
|
82 |
+
{
|
83 |
+
$this->_module = $module;
|
84 |
+
return $this;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @return Aitoc_Aitsys_Model_Module
|
89 |
+
*/
|
90 |
+
public function getModule()
|
91 |
+
{
|
92 |
+
return $this->_module;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Change current model status to the `installed` state
|
97 |
+
*
|
98 |
+
* @return Aitoc_Aitsys_Model_Module_Install
|
99 |
+
*/
|
100 |
+
public function setStatusInstalled()
|
101 |
+
{
|
102 |
+
return $this->setStatus(self::STATUS_INSTALLED);
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Change current model status to the `unknown` state
|
107 |
+
*
|
108 |
+
* @return Aitoc_Aitsys_Model_Module_Install
|
109 |
+
*/
|
110 |
+
public function setStatusUnknown()
|
111 |
+
{
|
112 |
+
return $this->setStatus(self::STATUS_UNKNOWN);
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Change current model status to the `ininstalled` state
|
117 |
+
*
|
118 |
+
* @return Aitoc_Aitsys_Model_Module_Install
|
119 |
+
*/
|
120 |
+
public function setStatusUninstalled()
|
121 |
+
{
|
122 |
+
return $this->setStatus(self::STATUS_UNINSTALLED);
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Check whether module's status is `installed`
|
127 |
+
*
|
128 |
+
* @return bool
|
129 |
+
*/
|
130 |
+
public function isInstalled()
|
131 |
+
{
|
132 |
+
return $this->getStatus() == self::STATUS_INSTALLED;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Check whether module's status is `unknown`
|
137 |
+
*
|
138 |
+
* @return bool
|
139 |
+
*/
|
140 |
+
public function isUnknown()
|
141 |
+
{
|
142 |
+
return $this->getStatus() == self::STATUS_UNKNOWN;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Check whether module's status is `uninstalled`
|
147 |
+
*
|
148 |
+
* @return bool
|
149 |
+
*/
|
150 |
+
public function isUninstalled()
|
151 |
+
{
|
152 |
+
return $this->getStatus() == self::STATUS_UNINSTALLED;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Check license status
|
157 |
+
*
|
158 |
+
* @return Aitoc_Aitsys_Model_Module_Abstract
|
159 |
+
*/
|
160 |
+
abstract public function checkStatus();
|
161 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Module/Info/Abstract.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
abstract class Aitoc_Aitsys_Model_Module_Info_Abstract
|
6 |
+
{
|
7 |
+
const EE_MIN_VERSION = '10.0.0';
|
8 |
+
|
9 |
+
const PLATFORM_CE = 'community';
|
10 |
+
const PLATFORM_EE = 'enterprise';
|
11 |
+
const PLATFORM_ANY = 'any';
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
+
protected $_platforms = array(
|
17 |
+
self::PLATFORM_CE,
|
18 |
+
self::PLATFORM_EE,
|
19 |
+
self::PLATFORM_ANY
|
20 |
+
);
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @var bool
|
24 |
+
*/
|
25 |
+
protected $_loaded = false;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var Aitoc_Aitsys_Model_Module
|
29 |
+
*/
|
30 |
+
protected $_module;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @var string
|
34 |
+
*/
|
35 |
+
protected $_codepool;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @var string
|
39 |
+
*/
|
40 |
+
protected $_platform = '';
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @abstract
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
abstract public function getVersion();
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @abstract
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
abstract public function getPlatform();
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @abstract
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
abstract public function getSerial();
|
59 |
+
|
60 |
+
public function __construct(Aitoc_Aitsys_Model_Module $module, $codepool = Aitoc_Aitsys_Model_Module::DEFAULT_CODEPOOL)
|
61 |
+
{
|
62 |
+
$this->_module = $module;
|
63 |
+
$this->_codepool = $codepool;
|
64 |
+
try {
|
65 |
+
$this->_init();
|
66 |
+
} catch (Exception $e) {
|
67 |
+
$this->_loaded = false;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
protected function _init()
|
72 |
+
{
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @return bool
|
77 |
+
*/
|
78 |
+
public function isLoaded()
|
79 |
+
{
|
80 |
+
return $this->_loaded;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @return Aitoc_Aitsys_Model_Module
|
85 |
+
*/
|
86 |
+
public function getModule()
|
87 |
+
{
|
88 |
+
return $this->_module;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @return bool
|
93 |
+
*/
|
94 |
+
public function getCodepool()
|
95 |
+
{
|
96 |
+
return $this->_codepool;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @return string
|
101 |
+
*/
|
102 |
+
protected function _getFallbackPlatform()
|
103 |
+
{
|
104 |
+
return version_compare($this->getVersion(), self::EE_MIN_VERSION, 'ge') ? self::PLATFORM_EE : self::PLATFORM_CE;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @return bool
|
109 |
+
*/
|
110 |
+
public function isEnterpriseVersion()
|
111 |
+
{
|
112 |
+
return $this->getPlatform() == self::PLATFORM_EE;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @return bool
|
117 |
+
*/
|
118 |
+
public function isCommunityVersion()
|
119 |
+
{
|
120 |
+
return $this->getPlatform() == self::PLATFORM_CE;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* @return bool
|
125 |
+
*/
|
126 |
+
public function isAnyVersion()
|
127 |
+
{
|
128 |
+
return $this->getPlatform() == self::PLATFORM_ANY;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @return bool
|
133 |
+
*/
|
134 |
+
public function isMagentoCompatible()
|
135 |
+
{
|
136 |
+
$isMagentoEE = Aitoc_Aitsys_Model_Platform::getInstance()->isMagentoEnterprise();
|
137 |
+
return ($this->isAnyVersion() || (!$isMagentoEE && $this->isCommunityVersion()) || ($isMagentoEE && $this->isEnterpriseVersion()));
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* @return string
|
142 |
+
*/
|
143 |
+
public function getLabel()
|
144 |
+
{
|
145 |
+
return $this->getModule()->getLabel();
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* @return int
|
150 |
+
*/
|
151 |
+
public function getProductId()
|
152 |
+
{
|
153 |
+
return 0;
|
154 |
+
}
|
155 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Module/Info/Config.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Module_Info_Config extends Aitoc_Aitsys_Model_Module_Info_Xml_Abstract
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_pathSuffix = 'etc/config.xml';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
public function getVersion()
|
16 |
+
{
|
17 |
+
return $this->isLoaded() ? (string)$this->modules->{$this->getModule()->getKey()}->version : '';
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getPlatform()
|
24 |
+
{
|
25 |
+
if ($this->isLoaded() && !$this->_platform) {
|
26 |
+
$platform = strtolower((string)$this->modules->{$this->getModule()->getKey()}->platform);
|
27 |
+
if ($platform && in_array($platform, $this->_platforms)) {
|
28 |
+
$this->_platform = $platform;
|
29 |
+
} else {
|
30 |
+
$this->_platform = $this->_getFallbackPlatform();
|
31 |
+
}
|
32 |
+
}
|
33 |
+
return $this->_platform;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public function getSerial()
|
40 |
+
{
|
41 |
+
return '';
|
42 |
+
}
|
43 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Module/Info/Exception.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Module_Info_Exception extends Exception
|
6 |
+
{
|
7 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Module/Info/Factory.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Module_Info_Factory
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var array
|
9 |
+
*/
|
10 |
+
protected static $_sources = array(
|
11 |
+
'Package', // package info file
|
12 |
+
'Config', // main config.xml file
|
13 |
+
'Fallback' // this model should be used if no other sources of info have been found
|
14 |
+
);
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @param Aitoc_Aitsys_Model_Module $module Module entity
|
18 |
+
* @param string $source Source type
|
19 |
+
* @param string $codepool Module codepool. Default: local
|
20 |
+
*
|
21 |
+
* @return Aitoc_Aitsys_Model_Module_Info_Abstract
|
22 |
+
* @throws Aitoc_Aitsys_Model_Module_Info_Exception
|
23 |
+
*/
|
24 |
+
public static function getModuleInfoFromSource(Aitoc_Aitsys_Model_Module $module, $source, $codepool = Aitoc_Aitsys_Model_Module::DEFAULT_CODEPOOL)
|
25 |
+
{
|
26 |
+
if (!in_array($source, self::$_sources)) {
|
27 |
+
throw new Aitoc_Aitsys_Model_Module_Info_Exception ('Incorrect module info source type. Module: ' . $moduleKey . '. Source: ' . $source);
|
28 |
+
}
|
29 |
+
$class = 'Aitoc_Aitsys_Model_Module_Info_'.$source;
|
30 |
+
return new $class($module, $codepool);
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Get module info from the first available source
|
35 |
+
*
|
36 |
+
* @param Aitoc_Aitsys_Model_Module $module Module entity
|
37 |
+
* @param string $codepool Module codepool. Default: local
|
38 |
+
*
|
39 |
+
* @return Aitoc_Aitsys_Model_Module_Info_Abstract
|
40 |
+
* @throws Aitoc_Aitsys_Model_Module_Info_Exception
|
41 |
+
*/
|
42 |
+
public static function getModuleInfo(Aitoc_Aitsys_Model_Module $module, $codepool = Aitoc_Aitsys_Model_Module::DEFAULT_CODEPOOL)
|
43 |
+
{
|
44 |
+
foreach (self::$_sources as $source) {
|
45 |
+
$info = self::getModuleInfoFromSource($module, $source, $codepool);
|
46 |
+
if ($info->isLoaded()) {
|
47 |
+
return $info;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
throw new Aitoc_Aitsys_Model_Module_Info_Exception ('No module info sources available. Module: ' . $moduleKey);
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Module/Info/Fallback.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Module_Info_Fallback extends Aitoc_Aitsys_Model_Module_Info_Abstract
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var bool
|
9 |
+
*/
|
10 |
+
protected $_loaded = true;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
public function getPlatform()
|
16 |
+
{
|
17 |
+
return $this->_getFallbackPlatform();
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getVersion()
|
24 |
+
{
|
25 |
+
return '';
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
public function getSerial()
|
32 |
+
{
|
33 |
+
return '';
|
34 |
+
}
|
35 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Module/Info/Package.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Module_Info_Package extends Aitoc_Aitsys_Model_Module_Info_Xml_Abstract
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_pathSuffix = Aitoc_Aitsys_Model_Module::PACKAGE_FILE;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
public function getVersion()
|
16 |
+
{
|
17 |
+
return (string)$this->version;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getPlatform()
|
24 |
+
{
|
25 |
+
return strtolower((string)$this->platform);
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
public function getSerial()
|
32 |
+
{
|
33 |
+
return (string)$this->license;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public function getLabel()
|
40 |
+
{
|
41 |
+
return (string)$this->product;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @return int
|
46 |
+
*/
|
47 |
+
public function getProductId()
|
48 |
+
{
|
49 |
+
return (int)$this->product_id;
|
50 |
+
}
|
51 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Module/Info/Xml/Abstract.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
abstract class Aitoc_Aitsys_Model_Module_Info_Xml_Abstract extends Aitoc_Aitsys_Model_Module_Info_Abstract
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var SimpleXMLElement
|
9 |
+
*/
|
10 |
+
protected $_xml;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var string
|
14 |
+
*/
|
15 |
+
protected $_path;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
protected $_pathSuffix;
|
21 |
+
|
22 |
+
protected function _init()
|
23 |
+
{
|
24 |
+
$this->_path = BP . DS . 'app' . DS . 'code' . DS . $this->getCodepool() . DS . join(DS, explode('_', $this->getModule()->getKey())) . DS . $this->_pathSuffix;
|
25 |
+
if (file_exists($this->_path)) {
|
26 |
+
try {
|
27 |
+
$this->_xml = @simplexml_load_file($this->_path);
|
28 |
+
} catch (Exception $e) {}
|
29 |
+
}
|
30 |
+
if ($this->_xml instanceof SimpleXMLElement) {
|
31 |
+
$this->_loaded = true;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
public function __get($var)
|
36 |
+
{
|
37 |
+
return $this->isLoaded() ? $this->_xml->{$var} : null;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function __call($method, $args)
|
41 |
+
{
|
42 |
+
if ($this->isLoaded()) {
|
43 |
+
try {
|
44 |
+
return @call_user_func_array(array($this->_xml, $method), $args);
|
45 |
+
} catch (Exception $e) {}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Module/Install.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Module_Install extends Aitoc_Aitsys_Model_Module_Abstract
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @return Aitoc_Aitsys_Model_Module_Install
|
9 |
+
*/
|
10 |
+
public function checkStatus()
|
11 |
+
{
|
12 |
+
$this->setInstallable(file_exists($this->getModule()->getFile()));
|
13 |
+
$this->setStatusUninstalled();
|
14 |
+
if ($this->isInstallable() && $this->getModule()->getValue()) {
|
15 |
+
$this->setStatusInstalled();
|
16 |
+
}
|
17 |
+
$this->tool()->testMsg('Module installation status set to: ' . $this->getModule()->getKey() . ' - ' . $this->getStatus());
|
18 |
+
return $this;
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return bool
|
23 |
+
*/
|
24 |
+
public function isInstallable()
|
25 |
+
{
|
26 |
+
return $this->getInstallable();
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return Aitoc_Aitsys_Model_Module_Install
|
31 |
+
*/
|
32 |
+
public function uninstall()
|
33 |
+
{
|
34 |
+
$this->tool()->testMsg('UNINSTALL MODULE: ' . $this->getModule()->getKey());
|
35 |
+
$this->_processModule(false);
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @return Aitoc_Aitsys_Model_Module_Install
|
41 |
+
*/
|
42 |
+
public function install()
|
43 |
+
{
|
44 |
+
$this->tool()->testMsg('INSTALL MODULE: ' . $this->getModule()->getKey());
|
45 |
+
$this->_processModule(true);
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @param bool $status Module new status. True to install and False to uninstall
|
51 |
+
*/
|
52 |
+
protected function _processModule($status)
|
53 |
+
{
|
54 |
+
$data = array();
|
55 |
+
foreach ($this->tool()->platform()->getModuleKeysForced() as $module => $value) {
|
56 |
+
/* @var $module Aitoc_Aitsys_Model_Module */
|
57 |
+
$isCurrent = $module === $this->getModule()->getKey();
|
58 |
+
$data[$module] = $isCurrent ? $status : $value;
|
59 |
+
}
|
60 |
+
|
61 |
+
$aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
|
62 |
+
if ($errors = $aitsysModel->saveData($data, array(), true)) {
|
63 |
+
$this->addErrors($errors);
|
64 |
+
}
|
65 |
+
$this->getModule()->reset();
|
66 |
+
$this->tool()->clearCache();
|
67 |
+
}
|
68 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Module/Status.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Module_Status extends Aitoc_Aitsys_Abstract_Model
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @static
|
9 |
+
* @var array
|
10 |
+
*/
|
11 |
+
static protected $_statuses = array();
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
protected $_eventPrefix = 'aitsys_module_status';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Static fabric interface to update statuses. Returns related status model instance
|
20 |
+
*
|
21 |
+
* @static
|
22 |
+
* @param string $moduleKey
|
23 |
+
* @param bool $status
|
24 |
+
*
|
25 |
+
* @return Aitoc_Aitsys_Model_Module_Status
|
26 |
+
*/
|
27 |
+
public static function updateStatus($moduleKey, $status)
|
28 |
+
{
|
29 |
+
if (!array_key_exists($moduleKey, self::$_statuses)) {
|
30 |
+
self::$_statuses[$moduleKey] = new self();
|
31 |
+
self::$_statuses[$moduleKey]
|
32 |
+
->load($moduleKey, 'module')
|
33 |
+
->setModule($moduleKey);
|
34 |
+
}
|
35 |
+
self::$_statuses[$moduleKey]
|
36 |
+
->setStatus((int)$status)
|
37 |
+
->save();
|
38 |
+
return self::$_statuses[$moduleKey];
|
39 |
+
}
|
40 |
+
|
41 |
+
protected function _construct()
|
42 |
+
{
|
43 |
+
$this->_init('aitsys/module_status');
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Prevents events in Mage_Core_Model_Abstract from launching
|
48 |
+
* (compatibility with some modules).
|
49 |
+
*
|
50 |
+
* @override
|
51 |
+
* @return Aitoc_Aitsys_Model_Module_Status
|
52 |
+
*/
|
53 |
+
protected function _beforeSave()
|
54 |
+
{
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Actualizes statuses table, clears db cache and prevents events
|
60 |
+
* in Mage_Core_Model_Abstractfrom launching
|
61 |
+
* (compatibility with some modules).
|
62 |
+
*
|
63 |
+
* @return Aitoc_Aitsys_Model_Module_Status
|
64 |
+
*/
|
65 |
+
protected function _afterSave()
|
66 |
+
{
|
67 |
+
$this->getCollection()->clearTable();
|
68 |
+
// $this->tool()->getCache()->remove('aitsys_db_statuses'); // removed from 2.20
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Mysql4/Module/Status.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Mysql4_Module_Status extends Aitoc_Aitsys_Abstract_Mysql4
|
6 |
+
{
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
$this->_init('aitsys/status', 'id');
|
10 |
+
}
|
11 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Mysql4/Module/Status/Collection.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Mysql4_Module_Status_Collection extends Aitoc_Aitsys_Abstract_Mysql4_Collection
|
6 |
+
{
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
$this->_init('aitsys/module_status');
|
10 |
+
}
|
11 |
+
|
12 |
+
public function clearTable()
|
13 |
+
{
|
14 |
+
$this->load();
|
15 |
+
$keys = array();
|
16 |
+
foreach ($this->getItems() as $item) {
|
17 |
+
if (!in_array($item->getModule(), $keys)) {
|
18 |
+
$keys[] = $item->getModule();
|
19 |
+
} else {
|
20 |
+
$item->delete();
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Mysql4/News.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Mysql4_News extends Aitoc_Aitsys_Abstract_Mysql4
|
6 |
+
{
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
$this->_init('aitsys/news','entity_id');
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return Aitoc_Aitsys_Model_Notification_News
|
14 |
+
*/
|
15 |
+
public function getLatest( $type )
|
16 |
+
{
|
17 |
+
return $this->_getNewsCollection()
|
18 |
+
->addTypeFilter($type)
|
19 |
+
->addOrder('date_added')
|
20 |
+
->getLastItem();
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @param Aitoc_Aitsys_Model_Mysql4_News
|
25 |
+
*/
|
26 |
+
public function clear( $type )
|
27 |
+
{
|
28 |
+
$this->_getWriteAdapter()->query("DELETE FROM `{$this->getMainTable()}` WHERE `type` = ?",array($type));
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @return Aitoc_Aitsys_Model_Mysql4_News_Collection
|
34 |
+
*/
|
35 |
+
protected function _getNewsCollection()
|
36 |
+
{
|
37 |
+
return Mage::getResourceModel('aitsys/news_collection');
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Mysql4/News/Collection.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Mysql4_News_Collection extends Aitoc_Aitsys_Abstract_Mysql4_Collection
|
6 |
+
{
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
$this->_init('aitsys/news');
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @param string $type [news|important]
|
14 |
+
*
|
15 |
+
* @return Aitoc_Aitsys_Model_Mysql4_News_Collection
|
16 |
+
*/
|
17 |
+
public function addTypeFilter( $type )
|
18 |
+
{
|
19 |
+
return $this->addFieldToFilter('type', array('=' => $type));
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Mysql4/Setup.php
ADDED
@@ -0,0 +1,354 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Mysql4_Setup extends Aitoc_Aitsys_Abstract_Resource_Setup
|
6 |
+
{
|
7 |
+
protected $_allowUpdate = true;
|
8 |
+
|
9 |
+
const TYPE_AITOC_DB_UPGRADE = 'upgrade';
|
10 |
+
const TYPE_AITOC_DB_INSTALL = 'install';
|
11 |
+
const TYPE_AITOC_DB_STATE_ACTIVATE = 'activate';
|
12 |
+
const TYPE_AITOC_DB_STATE_UNINSTALL = 'uninstall';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Run resource upgrade files from $oldVersion to $newVersion
|
16 |
+
*
|
17 |
+
* @param string $oldVersion
|
18 |
+
* @param string $newVersion
|
19 |
+
* @return Mage_Core_Model_Resource_Setup
|
20 |
+
*/
|
21 |
+
protected function _upgradeResourceDb($oldVersion, $newVersion)
|
22 |
+
{
|
23 |
+
$this->_allowUpdate = true;
|
24 |
+
$this->_modifyResourceDb(self::TYPE_AITOC_DB_UPGRADE, $oldVersion, $newVersion);
|
25 |
+
if($this->_allowUpdate) {
|
26 |
+
$this->_getResource()->setDbVersion($this->_resourceName, $newVersion);
|
27 |
+
}
|
28 |
+
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Run resource installation file
|
34 |
+
*
|
35 |
+
* @param string $newVersion
|
36 |
+
* @return Mage_Core_Model_Resource_Setup
|
37 |
+
*/
|
38 |
+
protected function _installResourceDb($newVersion)
|
39 |
+
{
|
40 |
+
$this->_allowUpdate = true;
|
41 |
+
$oldVersion = $this->_modifyResourceDb(self::TYPE_AITOC_DB_INSTALL, '', $newVersion);
|
42 |
+
$this->_modifyResourceDb(self::TYPE_AITOC_DB_UPGRADE, $oldVersion, $newVersion);
|
43 |
+
if($this->_allowUpdate) {
|
44 |
+
$this->_getResource()->setDbVersion($this->_resourceName, $newVersion);
|
45 |
+
}
|
46 |
+
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Get core resource resource model
|
52 |
+
*
|
53 |
+
* @return Mage_Core_Model_Resource_Resource
|
54 |
+
*/
|
55 |
+
protected function _getResource()
|
56 |
+
{
|
57 |
+
return Mage::getResourceSingleton('core/resource');
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Run module modification files. Return version of last applied upgrade (false if no upgrades applied)
|
62 |
+
*
|
63 |
+
* @param string $actionType self::TYPE_*
|
64 |
+
* @param string $fromVersion
|
65 |
+
* @param string $toVersion
|
66 |
+
* @return string|false
|
67 |
+
* @throws Mage_Core_Exception
|
68 |
+
*/
|
69 |
+
protected function _modifyResourceDb($actionType, $fromVersion, $toVersion)
|
70 |
+
{
|
71 |
+
// Aitsys use only TYPE_DB_ files
|
72 |
+
$files = $this->_getAvailableDbFiles($actionType, $fromVersion, $toVersion);
|
73 |
+
|
74 |
+
if (empty($files) || !$this->getConnection()) {
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
|
78 |
+
$version = false;
|
79 |
+
$cache = false;
|
80 |
+
if(method_exists($this->getConnection(),'disallowDdlCache')) {
|
81 |
+
$cache = true;
|
82 |
+
}
|
83 |
+
|
84 |
+
foreach ($files as $file) {
|
85 |
+
$fileName = $file['fileName'];
|
86 |
+
$fileType = pathinfo($fileName, PATHINFO_EXTENSION);
|
87 |
+
if($cache) {
|
88 |
+
$this->getConnection()->disallowDdlCache();
|
89 |
+
}
|
90 |
+
try {
|
91 |
+
switch ($fileType) {
|
92 |
+
case 'php':
|
93 |
+
$conn = $this->getConnection();
|
94 |
+
$result = include $fileName;
|
95 |
+
break;
|
96 |
+
case 'sql':
|
97 |
+
$sql = file_get_contents($fileName);
|
98 |
+
if (!empty($sql)) {
|
99 |
+
|
100 |
+
$result = $this->run($sql);
|
101 |
+
} else {
|
102 |
+
$result = true;
|
103 |
+
}
|
104 |
+
break;
|
105 |
+
default:
|
106 |
+
$result = false;
|
107 |
+
break;
|
108 |
+
}
|
109 |
+
|
110 |
+
if ($result && $this->_allowUpdate) {
|
111 |
+
$this->_getResource()->setDbVersion($this->_resourceName, $file['toVersion']);
|
112 |
+
}
|
113 |
+
} catch (Exception $e) {
|
114 |
+
printf('<pre>%s</pre>', print_r($e, true));
|
115 |
+
throw Mage::exception('Mage_Core', Mage::helper('core')->__('Error in file: "%s" - %s', $fileName, $e->getMessage()));
|
116 |
+
}
|
117 |
+
$version = $file['toVersion'];
|
118 |
+
if($cache) {
|
119 |
+
$this->getConnection()->allowDdlCache();
|
120 |
+
}
|
121 |
+
}
|
122 |
+
self::$_hadUpdates = true;
|
123 |
+
return $version;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Retrieve available Database install/upgrade files for current module
|
128 |
+
*
|
129 |
+
* @param string $actionType
|
130 |
+
* @param string $fromVersion
|
131 |
+
* @param string $toVersion
|
132 |
+
* @return array
|
133 |
+
*/
|
134 |
+
protected function _getAvailableDbFiles($actionType, $fromVersion, $toVersion)
|
135 |
+
{
|
136 |
+
$resModel = (string)$this->_connectionConfig->model;
|
137 |
+
$modName = (string)$this->_moduleConfig[0]->getName();
|
138 |
+
|
139 |
+
$filesDir = Mage::getModuleDir('sql', $modName) . DS . $this->_resourceName;
|
140 |
+
if (!is_dir($filesDir) || !is_readable($filesDir)) {
|
141 |
+
return array();
|
142 |
+
}
|
143 |
+
|
144 |
+
$dbFiles = array();
|
145 |
+
$typeFiles = array();
|
146 |
+
$regExpDb = sprintf('#^%s-(.*)\.(php|sql)$#i', $actionType);
|
147 |
+
$regExpType = sprintf('#^%s-%s-(.*)\.(php|sql)$#i', $resModel, $actionType);
|
148 |
+
$handlerDir = dir($filesDir);
|
149 |
+
while (false !== ($file = $handlerDir->read())) {
|
150 |
+
$matches = array();
|
151 |
+
if (preg_match($regExpDb, $file, $matches)) {
|
152 |
+
$dbFiles[$matches[1]] = $filesDir . DS . $file;
|
153 |
+
} else if (preg_match($regExpType, $file, $matches)) {
|
154 |
+
$typeFiles[$matches[1]] = $filesDir . DS . $file;
|
155 |
+
}
|
156 |
+
}
|
157 |
+
$handlerDir->close();
|
158 |
+
|
159 |
+
$xmlData = (array)$this->_resourceConfig->sql_files->$actionType;
|
160 |
+
if(false === $this->haveAllFiles($typeFiles, $xmlData)) {
|
161 |
+
$this->_allowUpdate = false;
|
162 |
+
Mage::log('Unable to upgrade Aitsys module from '.$fromVersion.' to '.$toVersion.'. If this error is repeated for some time please check that all files are uploaded to app/code/community/Aitoc/Aitsys/sql/aitsys_setup folder.');
|
163 |
+
return array();
|
164 |
+
}
|
165 |
+
|
166 |
+
if (empty($typeFiles) && empty($dbFiles)) {
|
167 |
+
return array();
|
168 |
+
}
|
169 |
+
|
170 |
+
foreach ($typeFiles as $version => $file) {
|
171 |
+
$dbFiles[$version] = $file;
|
172 |
+
}
|
173 |
+
|
174 |
+
return $this->_getModifySqlFiles($actionType, $fromVersion, $toVersion, $dbFiles);
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Checks that all files are uploaded to sql folder.
|
179 |
+
*
|
180 |
+
* @param array $diskFiles - Array of files in folder array( [1.0.1-2.0.2] => [path_to_file],...)
|
181 |
+
* @param array $xmlFIles - Array of available versions for current module taken from config.xml array([version],[version],...)
|
182 |
+
*/
|
183 |
+
public function haveAllFiles($diskFiles, $xmlFiles) {
|
184 |
+
foreach($xmlFiles as $version) {
|
185 |
+
if(!isset($diskFiles[$version])) {
|
186 |
+
return false;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
return true;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Apply module deactivation sql file
|
194 |
+
*
|
195 |
+
* @param string $moduleName like [Aitoc|AdjustWare]_[AitModuleName]
|
196 |
+
*
|
197 |
+
* @return bool
|
198 |
+
*/
|
199 |
+
public function applyAitocModuleUninstall($moduleName)
|
200 |
+
{
|
201 |
+
return $this->_processStateSql(self::TYPE_AITOC_DB_STATE_UNINSTALL, $moduleName);
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Apply module activation sql file
|
206 |
+
*
|
207 |
+
* @param string $moduleName like [Aitoc|AdjustWare]_[AitModuleName]
|
208 |
+
*
|
209 |
+
* @return bool
|
210 |
+
*/
|
211 |
+
public function applyAitocModuleActivate($moduleName)
|
212 |
+
{
|
213 |
+
return $this->_processStateSql(self::TYPE_AITOC_DB_STATE_ACTIVATE, $moduleName);
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Apply module sql file of appropriate type
|
218 |
+
*
|
219 |
+
* @param string $processType self::TYPE_AITOC_DB_STATE_*
|
220 |
+
* @param string $moduleName like [Aitoc|AdjustWare]_[AitModuleName]
|
221 |
+
*
|
222 |
+
* @return bool
|
223 |
+
*/
|
224 |
+
protected function _processStateSql($processType, $moduleName)
|
225 |
+
{
|
226 |
+
$moduleDir = Aitoc_Aitsys_Abstract_Service::get()->filesystem()->getModuleDir( $moduleName );
|
227 |
+
if ( !$moduleDir ) {
|
228 |
+
// Module dir not found
|
229 |
+
return false;
|
230 |
+
}
|
231 |
+
|
232 |
+
// Attempt to locate and load module's main config file or its .data version
|
233 |
+
$configFile = $moduleDir.DS.'etc'.DS.'config.data.xml';
|
234 |
+
if (file_exists($configFile))
|
235 |
+
{
|
236 |
+
$config = simplexml_load_file($configFile);
|
237 |
+
}
|
238 |
+
else
|
239 |
+
{
|
240 |
+
$configFile = $moduleDir.DS.'etc'.DS.'config.xml';
|
241 |
+
if (file_exists($configFile))
|
242 |
+
{
|
243 |
+
$config = simplexml_load_file($configFile);
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
// Module config file not found
|
248 |
+
if (!isset($config))
|
249 |
+
{
|
250 |
+
return false;
|
251 |
+
}
|
252 |
+
|
253 |
+
if (isset($config->global) && isset($config->global->resources))
|
254 |
+
{
|
255 |
+
foreach ($config->global->resources->children() as $key => $object)
|
256 |
+
{
|
257 |
+
if ($object->setup)
|
258 |
+
{
|
259 |
+
$resourceName = $key;
|
260 |
+
break;
|
261 |
+
}
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
// There's no resource setup entities in the config file
|
266 |
+
if (!isset($resourceName))
|
267 |
+
{
|
268 |
+
return false;
|
269 |
+
}
|
270 |
+
|
271 |
+
$sqlFilesDir = $moduleDir.DS.'sql'.DS.$resourceName;
|
272 |
+
|
273 |
+
// Resource setup directory is empty
|
274 |
+
if (!is_dir($sqlFilesDir) || !is_readable($sqlFilesDir)) {
|
275 |
+
return false;
|
276 |
+
}
|
277 |
+
|
278 |
+
// Read resource files
|
279 |
+
$arrAvailableFiles = array();
|
280 |
+
$sqlDir = dir($sqlFilesDir);
|
281 |
+
while (false !== ($sqlFile = $sqlDir->read())) {
|
282 |
+
$matches = array();
|
283 |
+
if (preg_match('#^mysql4-'.$processType.'-(.*)\.(sql|php)$#i', $sqlFile, $matches)) {
|
284 |
+
$arrAvailableFiles[$matches[1]] = $sqlFile;
|
285 |
+
}
|
286 |
+
}
|
287 |
+
$sqlDir->close();
|
288 |
+
|
289 |
+
// There are no appropriate state sql files in the resource directory
|
290 |
+
if (empty($arrAvailableFiles)) {
|
291 |
+
return false;
|
292 |
+
}
|
293 |
+
|
294 |
+
$dbVersion = Mage::getResourceModel('core/resource')->getDBVersion($resourceName);
|
295 |
+
|
296 |
+
foreach ($arrAvailableFiles as $version => $resourceFile)
|
297 |
+
{
|
298 |
+
// Stop processing if state script is for the higher version of the module
|
299 |
+
if (version_compare($version, $dbVersion) > 0)
|
300 |
+
{
|
301 |
+
break;
|
302 |
+
}
|
303 |
+
|
304 |
+
$sqlFile = $sqlFilesDir.DS.$resourceFile;
|
305 |
+
$fileType = pathinfo($resourceFile, PATHINFO_EXTENSION);
|
306 |
+
|
307 |
+
// Execute SQL
|
308 |
+
if ($this->_conn) {
|
309 |
+
if (method_exists($this->_conn, 'disallowDdlCache')) {
|
310 |
+
$this->_conn->disallowDdlCache();
|
311 |
+
}
|
312 |
+
try {
|
313 |
+
switch ($fileType) {
|
314 |
+
case 'sql':
|
315 |
+
$sql = file_get_contents($sqlFile);
|
316 |
+
if ($sql!='') {
|
317 |
+
$result = $this->run($sql);
|
318 |
+
} else {
|
319 |
+
$result = true;
|
320 |
+
}
|
321 |
+
break;
|
322 |
+
case 'php':
|
323 |
+
$conn = $this->_conn;
|
324 |
+
$result = include($sqlFile);
|
325 |
+
break;
|
326 |
+
default:
|
327 |
+
$result = false;
|
328 |
+
|
329 |
+
}
|
330 |
+
} catch (Exception $e){
|
331 |
+
echo "<pre>".print_r($e,1)."</pre>";
|
332 |
+
throw Mage::exception('Mage_Core', Mage::helper('core')->__('Error in file: "%s" - %s', $sqlFile, $e->getMessage()));
|
333 |
+
}
|
334 |
+
if (method_exists($this->_conn, 'allowDdlCache')) {
|
335 |
+
$this->_conn->allowDdlCache();
|
336 |
+
}
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
self::$_hadUpdates = true;
|
341 |
+
return true;
|
342 |
+
}
|
343 |
+
|
344 |
+
public function getCoreConfig($path)
|
345 |
+
{
|
346 |
+
$table = $this->getTable('core/config_data');
|
347 |
+
// this is a fix for mysql 4.1
|
348 |
+
$this->getConnection()->showTableStatus($table);
|
349 |
+
|
350 |
+
$select = $this->getConnection()->select();
|
351 |
+
$select->from($table, 'value')->where('path = \''.$path.'\'');
|
352 |
+
return $this->getConnection()->fetchOne($select);
|
353 |
+
}
|
354 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/News.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_News extends Aitoc_Aitsys_Abstract_Model
|
6 |
+
{
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
$this->_init('aitsys/news');
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return bool
|
14 |
+
*/
|
15 |
+
public function isOld()
|
16 |
+
{
|
17 |
+
return strtotime($this->getDateAdded()) < time()-86400;
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/News/Important.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_News_Important extends Aitoc_Aitsys_Model_News_Recent
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_cacheKey = 'AITOC_AITSYS_NEWS_IMPORTANT';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var string
|
14 |
+
*/
|
15 |
+
protected $_method = 'getNewsNotification';
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
protected $_type = 'important';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @return Aitoc_Aitsys_Model_News_Recent
|
24 |
+
*/
|
25 |
+
public function saveData()
|
26 |
+
{
|
27 |
+
$feedData = array();
|
28 |
+
foreach ($this->_news as $item) {
|
29 |
+
if ($item['title'] || $item['content']) {
|
30 |
+
$feedData[] = array(
|
31 |
+
'severity' => isset($item['severity']) ? $item['severity'] : Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR,
|
32 |
+
'date_added' => isset($item['pubDate']) ? $item['pubDate'] : date('Y-m-d H:i:s'),
|
33 |
+
'title' => isset($item['title']) ? $item['title'] : '',
|
34 |
+
'description' => isset($item['content']) ? $item['content'] : '',
|
35 |
+
'url' => (isset($item['link']) && $item['link']) ? $item['link'] : 'http://aitoc.com/#'.strtolower(preg_replace('/\W+/','_',$item['title']))
|
36 |
+
);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
if ($feedData) {
|
41 |
+
Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData));
|
42 |
+
}
|
43 |
+
return parent::saveData();
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/News/Recent.php
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_News_Recent extends Aitoc_Aitsys_Abstract_Model
|
6 |
+
{
|
7 |
+
const CACHE_LIVE_TIME = 86400;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @var array
|
11 |
+
*/
|
12 |
+
protected $_news = array();
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_cacheKey = 'AITOC_AITSYS_NEWS';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
protected $_type = 'news';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @return Aitoc_Aitsys_Model_Mysql4_News
|
26 |
+
*/
|
27 |
+
protected function _getNewsResource()
|
28 |
+
{
|
29 |
+
return Mage::getResourceSingleton('aitsys/news');
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @return Aitoc_Aitsys_Model_Mysql4_News_Collection
|
34 |
+
*/
|
35 |
+
protected function _getNewsCollection()
|
36 |
+
{
|
37 |
+
return Mage::getResourceModel('aitsys/news_collection')->addTypeFilter($this->_type);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @return Aitoc_Aitsys_Model_News_Recent
|
42 |
+
*/
|
43 |
+
public function loadData()
|
44 |
+
{
|
45 |
+
try {
|
46 |
+
$latest = $this->_getNewsResource()->getLatest($this->_type);
|
47 |
+
} catch (Exception $exc) {
|
48 |
+
Mage::logException($exc);
|
49 |
+
return $this;
|
50 |
+
}
|
51 |
+
|
52 |
+
if (!$latest->isOld()) {
|
53 |
+
foreach ($this->_getNewsCollection() as $model) {
|
54 |
+
$this->addNews(array(
|
55 |
+
'title' => $model->getTitle(),
|
56 |
+
'content' => $model->getDescription()
|
57 |
+
));
|
58 |
+
}
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
try {
|
63 |
+
$news = $this->_getPageData();
|
64 |
+
if(!empty($news))
|
65 |
+
{
|
66 |
+
$this->addNews($news);
|
67 |
+
$this->saveData();
|
68 |
+
}
|
69 |
+
} catch (Exception $exc) {
|
70 |
+
Mage::logException($exc);
|
71 |
+
}
|
72 |
+
|
73 |
+
return $this;
|
74 |
+
}
|
75 |
+
|
76 |
+
protected function _getStaticPage()
|
77 |
+
{
|
78 |
+
|
79 |
+
$ch = curl_init();
|
80 |
+
$timeout = 5;
|
81 |
+
curl_setopt($ch, CURLOPT_URL, Mage::getStoreConfig('aitsys/feed/store_url'));
|
82 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
83 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
|
84 |
+
$data = curl_exec($ch);
|
85 |
+
curl_close($ch);
|
86 |
+
|
87 |
+
return $data;
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
protected function _getPageData()
|
92 |
+
{
|
93 |
+
$aPageData = array();
|
94 |
+
try {
|
95 |
+
$oPage = $this->_getStaticPage();
|
96 |
+
if ($oPage != '')
|
97 |
+
{
|
98 |
+
$aPageData['title'] = '';
|
99 |
+
$aPageData['content'] = $oPage;
|
100 |
+
$aPageData['pubDate'] = time();
|
101 |
+
}
|
102 |
+
} catch (Mage_Core_Exception $e) {
|
103 |
+
Mage::logException($e);
|
104 |
+
}
|
105 |
+
return $aPageData;
|
106 |
+
}
|
107 |
+
/**
|
108 |
+
* @return Aitoc_Aitsys_Model_News_Recent
|
109 |
+
*/
|
110 |
+
public function saveData()
|
111 |
+
{
|
112 |
+
$this->_getNewsResource()->clear($this->_type);
|
113 |
+
if (!$this->_news) {
|
114 |
+
Mage::getModel('aitsys/news')->setData(array(
|
115 |
+
'date_added' => date('Y-m-d H:i:s'),
|
116 |
+
'title' => '',
|
117 |
+
'description' => '',
|
118 |
+
'type' => $this->_type
|
119 |
+
))->save();
|
120 |
+
} else {
|
121 |
+
foreach ($this->_news as $item) {
|
122 |
+
Mage::getModel('aitsys/news')->setData(array(
|
123 |
+
'date_added' => date('Y-m-d H:i:s'),
|
124 |
+
'title' => $item['title'],
|
125 |
+
'description' => $item['content'],
|
126 |
+
'type' => $this->_type
|
127 |
+
))->save();
|
128 |
+
}
|
129 |
+
}
|
130 |
+
return $this;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @param array $item
|
135 |
+
* @return Aitoc_Aitsys_Model_News_Recent
|
136 |
+
*/
|
137 |
+
public function addNews( $item )
|
138 |
+
{
|
139 |
+
if ($item && !empty($item['content'])) {
|
140 |
+
$this->_news[] = $item;
|
141 |
+
}
|
142 |
+
return $this;
|
143 |
+
}
|
144 |
+
|
145 |
+
public function getNews()
|
146 |
+
{
|
147 |
+
return $this->_news;
|
148 |
+
}
|
149 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Observer.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Observer extends Aitoc_Aitsys_Abstract_Model
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var bool
|
9 |
+
*/
|
10 |
+
protected $_correctionDone = false;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Corrects modules' status and launches install/uninstall scripts if some module was enabled/disabled through xml.
|
14 |
+
*/
|
15 |
+
public function correction()
|
16 |
+
{
|
17 |
+
if (!$this->_correctionDone) {
|
18 |
+
$this->tool()->platform()->getModules(); // load modules
|
19 |
+
if ($this->tool()->platform()->isNeedCorrection()) {
|
20 |
+
$aitsysModel = new Aitoc_Aitsys_Model_Aitsys();
|
21 |
+
$aitsysModel->correction();
|
22 |
+
}
|
23 |
+
$this->_correctionDone = true;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
public function errorRender()
|
28 |
+
{
|
29 |
+
$this->tool()->platform()->renderAdminError(true);
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @param Varien_Object $observer
|
34 |
+
*/
|
35 |
+
public function coreBlockAbstractToHtmlAfter($observer)
|
36 |
+
{
|
37 |
+
$this->compatibility($observer);
|
38 |
+
Mage::getSingleton('aitsys/aitpatch_observer')->replaceDesignPath($observer);
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @param Varien_Object $observer
|
44 |
+
*/
|
45 |
+
public function coreBlockAbstractToHtmlBefore($observer)
|
46 |
+
{
|
47 |
+
Mage::getSingleton('aitsys/rewriter_observer')->hideCacheOnPage($observer);
|
48 |
+
Mage::getSingleton('aitsys/aitpatch_observer')->pathTemplateReplaceBeforeToHtml($observer);
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Replacement for an old abstract rewrite necessary for some extensions.
|
54 |
+
* Compatible with Magento CE 1.4.1+
|
55 |
+
*
|
56 |
+
* @param Varien_Object $observer
|
57 |
+
*/
|
58 |
+
public function compatibility($observer)
|
59 |
+
{
|
60 |
+
if (version_compare(Mage::getVersion(), '1.4.1.0', 'ge')) {
|
61 |
+
Mage::dispatchEvent('aitsys_block_abstract_to_html_after', $observer->getData());
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Update news from www.aitoc.com
|
67 |
+
*/
|
68 |
+
public function updateNews()
|
69 |
+
{
|
70 |
+
$news = new Aitoc_Aitsys_Model_News_Recent();
|
71 |
+
$news->loadData();
|
72 |
+
|
73 |
+
$important = new Aitoc_Aitsys_Model_News_Important();
|
74 |
+
$important->loadData();
|
75 |
+
}
|
76 |
+
|
77 |
+
public function updateNotification()
|
78 |
+
{
|
79 |
+
return Mage::getModel('aitsys/feed')->checkUpdate();
|
80 |
+
}
|
81 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Platform.php
ADDED
@@ -0,0 +1,378 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
final class Aitoc_Aitsys_Model_Platform extends Aitoc_Aitsys_Abstract_Model
|
6 |
+
{
|
7 |
+
const PLATFORMFILE_SUFFIX = '.platform.xml';
|
8 |
+
const CACHE_CLEAR_VERSION = '2.21.0';
|
9 |
+
const DEFAULT_VAR_PATH = 'var';
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @var Aitoc_Aitsys_Model_Platform
|
13 |
+
*/
|
14 |
+
static protected $_instance;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @return Aitoc_Aitsys_Model_Platform
|
18 |
+
*/
|
19 |
+
static public function getInstance()
|
20 |
+
{
|
21 |
+
if (!self::$_instance) {
|
22 |
+
self::$_instance = new self();
|
23 |
+
self::$_instance->preInit();
|
24 |
+
}
|
25 |
+
return self::$_instance;
|
26 |
+
}
|
27 |
+
|
28 |
+
protected $_inited = false;
|
29 |
+
|
30 |
+
protected $_modulesList; // Module_Name => array( 'module_path' => Module_Path, 'module_file' => Module_File )
|
31 |
+
|
32 |
+
protected $_modules = array();
|
33 |
+
|
34 |
+
protected $_version;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @var Aitoc_Aitsys_Model_Service
|
38 |
+
*/
|
39 |
+
protected $_service = array();
|
40 |
+
|
41 |
+
protected $_moduleIgnoreList = array('Aitoc_Aitinstall' => 0, 'Aitoc_Aitsys' => 0, 'Aitoc_Aitprepare' => 0);
|
42 |
+
|
43 |
+
protected $_aitocPrefixList = array('Aitoc_', 'AdjustWare_');
|
44 |
+
|
45 |
+
protected $_moduleDirs = array('Aitoc', 'AdjustWare');
|
46 |
+
|
47 |
+
protected $_needCorrection = false;
|
48 |
+
|
49 |
+
protected $_adminError = '';
|
50 |
+
|
51 |
+
protected $_adminErrorEventLoaded = false;
|
52 |
+
|
53 |
+
protected $_isEnterprise;
|
54 |
+
|
55 |
+
public function addAdminError($message)
|
56 |
+
{
|
57 |
+
$this->_adminError = $message;
|
58 |
+
$this->renderAdminError();
|
59 |
+
}
|
60 |
+
|
61 |
+
public function renderAdminError($eventLoaded = false)
|
62 |
+
{
|
63 |
+
if ($eventLoaded) {
|
64 |
+
$this->_adminErrorEventLoaded = true;
|
65 |
+
}
|
66 |
+
|
67 |
+
if ($this->_adminErrorEventLoaded && $this->_adminError) {
|
68 |
+
$admin = Mage::getSingleton('admin/session');
|
69 |
+
if ($admin->isLoggedIn()) {
|
70 |
+
$session = Mage::getSingleton('adminhtml/session');
|
71 |
+
/* @var $session Mage_Adminhtml_Model_Session */
|
72 |
+
$session->addError($this->_adminError);
|
73 |
+
$this->_adminError = '';
|
74 |
+
}
|
75 |
+
}
|
76 |
+
return $this;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @return array
|
81 |
+
*/
|
82 |
+
public function getModuleDirs()
|
83 |
+
{
|
84 |
+
return $this->_moduleDirs;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @return bool
|
89 |
+
*/
|
90 |
+
public function isBlocked()
|
91 |
+
{
|
92 |
+
return $this->_block;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @return array
|
97 |
+
*/
|
98 |
+
public function getModules()
|
99 |
+
{
|
100 |
+
if (!$this->_modules) {
|
101 |
+
$this->__init();
|
102 |
+
$this->_generateModulesList();
|
103 |
+
}
|
104 |
+
return $this->_modules;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @return array
|
109 |
+
*/
|
110 |
+
public function getModuleKeysForced()
|
111 |
+
{
|
112 |
+
$modules = array();
|
113 |
+
foreach($this->_modulesList as $moduleKey => $moduleData) {
|
114 |
+
$modules[$moduleKey] = ('true' == (string)Mage::getConfig()->getNode('modules/' . $moduleKey . '/active'));
|
115 |
+
}
|
116 |
+
return $modules;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* @param string $key
|
121 |
+
* @return Aitoc_Aitsys_Model_Module
|
122 |
+
*/
|
123 |
+
public function getModule($key)
|
124 |
+
{
|
125 |
+
$this->getModules();
|
126 |
+
return isset($this->_modules[$key]) ? $this->_modules[$key] : null;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* @return Aitoc_Aitsys_Model_License_Service
|
131 |
+
*/
|
132 |
+
public function getService($for = 'default')
|
133 |
+
{
|
134 |
+
if (!isset($this->_service[$for])) {
|
135 |
+
$this->_service[$for] = new Aitoc_Aitsys_Model_Service();
|
136 |
+
$this->_service[$for]->setServiceUrl($this->getServiceUrl());
|
137 |
+
}
|
138 |
+
return $this->_service[$for];
|
139 |
+
}
|
140 |
+
|
141 |
+
public function getVarPath()
|
142 |
+
{
|
143 |
+
return $this->hasData('var_path') ? trim($this->getData('var_path'), '\\/') : self::DEFAULT_VAR_PATH;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @return string
|
148 |
+
*/
|
149 |
+
public function getServiceUrl()
|
150 |
+
{
|
151 |
+
if ($url = $this->tool()->getApiUrl()) {
|
152 |
+
return $url;
|
153 |
+
}
|
154 |
+
if ($url = $this->getData('_service_url')) {
|
155 |
+
return $url;
|
156 |
+
}
|
157 |
+
$url = $this->getData('service_url');
|
158 |
+
return $url ? $url : Mage::getStoreConfig('aitsys/service/url');
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* @return string
|
163 |
+
*/
|
164 |
+
public function getVersion()
|
165 |
+
{
|
166 |
+
if (!$this->_version) {
|
167 |
+
$this->_version = (string)Mage::app()->getConfig()->getNode('modules/Aitoc_Aitsys/version');
|
168 |
+
}
|
169 |
+
return $this->_version;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function preInit()
|
173 |
+
{
|
174 |
+
try {
|
175 |
+
$this->_loadConfigFile();
|
176 |
+
} catch (Exception $e) {
|
177 |
+
$this->tool()->testMsg('Error on attempt of loading platform config file');
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
protected function __init()
|
182 |
+
{
|
183 |
+
if (!$this->_inited) {
|
184 |
+
$this->_inited = true;
|
185 |
+
try {
|
186 |
+
$this->_checkNeedCacheCleared();
|
187 |
+
$this->reset();
|
188 |
+
} catch (Aitoc_Aitsys_Model_Core_Filesystem_Exception $exc) {
|
189 |
+
$msg = "Error in the file: %s. Probably it does not have write permissions.";
|
190 |
+
$this->addAdminError(Aitoc_Aitsys_Abstract_Service::get()->getHelper()->__($msg, $exc->getMessage()));
|
191 |
+
}
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
protected function _checkNeedCacheCleared()
|
196 |
+
{
|
197 |
+
if (!Mage::app()->getUpdateMode() && version_compare($this->tool()->db()->dbVersion(), self::CACHE_CLEAR_VERSION, 'lt')) {
|
198 |
+
$this->tool()->clearCache();
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* @return Aitoc_Aitsys_Model_Platform
|
204 |
+
*/
|
205 |
+
public function reset()
|
206 |
+
{
|
207 |
+
$this->_modules = array(); // to reinit all licensed modules after platform registration
|
208 |
+
$this->getModules();
|
209 |
+
$this->tool()->testMsg('Modules reseted after generating');
|
210 |
+
return $this;
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* @param string $moduleKey
|
215 |
+
* @return bool
|
216 |
+
*/
|
217 |
+
public function isIgnoredModule($moduleKey)
|
218 |
+
{
|
219 |
+
return isset($this->_moduleIgnoreList[$moduleKey]);
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* @return Aitoc_Aitsys_Model_Platform
|
224 |
+
*/
|
225 |
+
protected function _loadConfigFile()
|
226 |
+
{
|
227 |
+
$path = $this->tool()->filesystem()->getAitsysDir() . '/config.php';
|
228 |
+
$this->tool()->testMsg('check config path: ' . $path);
|
229 |
+
if (file_exists($path)) {
|
230 |
+
include $path;
|
231 |
+
if (isset($config) && is_array($config)) {
|
232 |
+
$this->tool()->testMsg('loaded config:');
|
233 |
+
$this->tool()->testMsg($config);
|
234 |
+
$this->setData($config);
|
235 |
+
}
|
236 |
+
}
|
237 |
+
return $this;
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* @return Aitoc_Aitsys_Model_Platform
|
242 |
+
*/
|
243 |
+
protected function _generateModulesList()
|
244 |
+
{
|
245 |
+
$this->tool()->testMsg('Try to generate modules list!');
|
246 |
+
$this->_createModulesList()
|
247 |
+
->_loadAllModules();
|
248 |
+
|
249 |
+
$this->tool()->event('aitsys_generate_modules_list_after');
|
250 |
+
$this->tool()->testMsg('Modules list generated successfully');
|
251 |
+
return $this;
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* @return bool
|
256 |
+
*/
|
257 |
+
public function isMagentoEnterprise()
|
258 |
+
{
|
259 |
+
if (is_null($this->_isEnterprise)) {
|
260 |
+
$this->_isEnterprise = false;
|
261 |
+
|
262 |
+
if (is_callable('Mage::getEdition')) {
|
263 |
+
$this->_isEnterprise = (Mage::getEdition() == 'Enterprise');
|
264 |
+
} else {
|
265 |
+
$etcDir = $this->tool()->fileSystem()->getEtcDir();
|
266 |
+
$eeModuleXmlFile = $etcDir . DS . 'Enterprise_Enterprise.xml';
|
267 |
+
if (file_exists($eeModuleXmlFile)) {
|
268 |
+
try {
|
269 |
+
$eeModule = new SimpleXMLElement($eeModuleXmlFile, 0, true);
|
270 |
+
$val = $eeModule->modules->Enterprise_Enterprise->active;
|
271 |
+
$this->_isEnterprise = ((string)$val == 'true');
|
272 |
+
} catch (Exception $e) {}
|
273 |
+
}
|
274 |
+
}
|
275 |
+
}
|
276 |
+
return $this->_isEnterprise;
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Based on /code/local/Aitoc|AdjustWare subfolders
|
281 |
+
*
|
282 |
+
* @return Aitoc_Aitsys_Model_Platform
|
283 |
+
*/
|
284 |
+
protected function _createModulesList()
|
285 |
+
{
|
286 |
+
if (is_null($this->_modulesList)) {
|
287 |
+
$this->_modulesList = array();
|
288 |
+
|
289 |
+
$aitocModulesDirs = $this->tool()->filesystem()->getAitocModulesDirs();
|
290 |
+
foreach ($aitocModulesDirs as $aitocModuleDir) {
|
291 |
+
if (@file_exists($aitocModuleDir) && @is_dir($aitocModuleDir)) {
|
292 |
+
$aitocModuleSubdirs = new DirectoryIterator($aitocModuleDir);
|
293 |
+
foreach ($aitocModuleSubdirs as $aitocModuleSubdir) {
|
294 |
+
// skip dots and svn folders
|
295 |
+
if (in_array($aitocModuleSubdir->getFilename(), $this->tool()->filesystem()->getForbiddenDirs())) {
|
296 |
+
continue;
|
297 |
+
}
|
298 |
+
|
299 |
+
$moduleKey = basename($aitocModuleDir) . "_" . $aitocModuleSubdir->getFilename();
|
300 |
+
$moduleFile = $this->tool()->filesystem()->getEtcDir() . "/{$moduleKey}.xml";
|
301 |
+
$this->_modulesList[$moduleKey] = array(
|
302 |
+
'module_path' => $aitocModuleSubdir->getPathname(),
|
303 |
+
'module_file' => @is_file($moduleFile) ? $moduleFile : null,
|
304 |
+
'is_ignore' => $this->isIgnoredModule($moduleKey)
|
305 |
+
);
|
306 |
+
}
|
307 |
+
}
|
308 |
+
}
|
309 |
+
}
|
310 |
+
return $this;
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Return list of all Aitocs' modules or certain module info
|
315 |
+
*
|
316 |
+
* @param string $module Module key
|
317 |
+
* @return array
|
318 |
+
*/
|
319 |
+
public function getModulesList($module = '')
|
320 |
+
{
|
321 |
+
if(!$module) {
|
322 |
+
return $this->_modulesList;
|
323 |
+
}
|
324 |
+
return isset($this->_modulesList[$module]) ? $this->_modulesList[$module] : null;
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Load all modules which have main config file
|
329 |
+
*
|
330 |
+
* @return Aitoc_Aitsys_Model_Platform
|
331 |
+
*/
|
332 |
+
protected function _loadAllModules()
|
333 |
+
{
|
334 |
+
foreach ($this->_modulesList as $moduleKey => $moduleData) {
|
335 |
+
if(!$moduleData['module_file']) { // only if the config file for this module in /app/etc/modules does exist
|
336 |
+
$moduleData['is_ignore'] = true;
|
337 |
+
}
|
338 |
+
$this->_makeModuleByModuleFile($moduleKey, $moduleData['module_file'], $moduleData['is_ignore']);
|
339 |
+
}
|
340 |
+
return $this;
|
341 |
+
}
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Load certain module by using its main config file
|
345 |
+
*
|
346 |
+
* @param string $moduleKey
|
347 |
+
* @param string $moduleFile
|
348 |
+
*
|
349 |
+
* @return Aitoc_Aitsys_Model_Module
|
350 |
+
*/
|
351 |
+
protected function _makeModuleByModuleFile($moduleKey, $moduleFile, $ignore = false)
|
352 |
+
{
|
353 |
+
$this->tool()->testMsg('Load module: ' . $moduleKey);
|
354 |
+
$module = new Aitoc_Aitsys_Model_Module();
|
355 |
+
$module->loadByModuleFile($moduleFile, $moduleKey);
|
356 |
+
$module->setIgnore($ignore);
|
357 |
+
|
358 |
+
return $this->_modules[$moduleKey] = $module;
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* @param bool $value
|
363 |
+
* @return Aitoc_Aitsys_Model_Platform
|
364 |
+
*/
|
365 |
+
public function setNeedCorrection($value = true)
|
366 |
+
{
|
367 |
+
$this->_needCorrection = $value;
|
368 |
+
return $this;
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* @return bool
|
373 |
+
*/
|
374 |
+
public function isNeedCorrection()
|
375 |
+
{
|
376 |
+
return $this->_needCorrection;
|
377 |
+
}
|
378 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Rewriter.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
* @author Andrei
|
5 |
+
*/
|
6 |
+
class Aitoc_Aitsys_Model_Rewriter extends Aitoc_Aitsys_Model_Rewriter_Abstract
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* @var array
|
10 |
+
*/
|
11 |
+
protected $_excludedClasses;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var Aitoc_Aitsys_Model_Rewriter_Merge
|
15 |
+
*/
|
16 |
+
protected $_merge;
|
17 |
+
/**
|
18 |
+
* @var Aitoc_Aitsys_Model_Rewriter_Config
|
19 |
+
*/
|
20 |
+
protected $_rewriterConfig;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
protected function _getExcludedClasses()
|
26 |
+
{
|
27 |
+
if (is_null($this->_excludedClasses)) {
|
28 |
+
$this->_excludedClasses = $this->tool()->db()->getConfigValue('aitsys_rewriter_exclude_classes', array());
|
29 |
+
}
|
30 |
+
return $this->_excludedClasses;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function preRegisterAutoloader()
|
34 |
+
{
|
35 |
+
$configFile = $this->_rewriteDir . 'config.php';
|
36 |
+
/**
|
37 |
+
* Will re-generate each time if config does not exist, or cache is disabled
|
38 |
+
*/
|
39 |
+
if (!$this->tool()->isPhpCli()) {
|
40 |
+
if (!file_exists($configFile) || !Mage::app()->useCache('aitsys')) {
|
41 |
+
$this->prepare();
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
public function prepare()
|
47 |
+
{
|
48 |
+
$this->_merge = new Aitoc_Aitsys_Model_Rewriter_Merge();
|
49 |
+
$this->_rewriterConfig = new Aitoc_Aitsys_Model_Rewriter_Config();
|
50 |
+
|
51 |
+
// first clearing current class rewrites
|
52 |
+
Aitoc_Aitsys_Model_Rewriter_Autoload::instance()->clearConfig();
|
53 |
+
$this->_merge->clear();
|
54 |
+
|
55 |
+
$rewriteHelper = Mage::helper('aitsys/rewriter');
|
56 |
+
$result = array();
|
57 |
+
if ($rewriteHelper->analysisInheritedClasses($this, 'mergeFilesFromClass', $result))
|
58 |
+
{
|
59 |
+
$this->_rewriterConfig->commit();
|
60 |
+
}
|
61 |
+
|
62 |
+
Aitoc_Aitsys_Model_Rewriter_Autoload::instance()->setupConfig();
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* @param $paramsMethod
|
67 |
+
* @return bool
|
68 |
+
*/
|
69 |
+
public function mergeFilesFromClass(&$paramsMethod)
|
70 |
+
{
|
71 |
+
if (in_array($paramsMethod['baseClass'], $this->_getExcludedClasses())) {
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
|
75 |
+
$mergedFilename = $this->_merge->merge($paramsMethod['inheritedClasses']);
|
76 |
+
if ($mergedFilename) {
|
77 |
+
$this->_rewriterConfig->add($mergedFilename, $paramsMethod['rewriteClasses']);
|
78 |
+
}
|
79 |
+
return true;
|
80 |
+
}
|
81 |
+
|
82 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Rewriter/Abstract.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
* @author Andrei
|
5 |
+
*/
|
6 |
+
abstract class Aitoc_Aitsys_Model_Rewriter_Abstract extends Aitoc_Aitsys_Abstract_Model
|
7 |
+
{
|
8 |
+
protected $_etcDir = '';
|
9 |
+
protected $_codeDir = '';
|
10 |
+
protected $_rewriteDir = '';
|
11 |
+
protected $_checkClassDir = array();
|
12 |
+
protected $_phpcli = false;
|
13 |
+
protected $_conn;
|
14 |
+
protected $_localConfig;
|
15 |
+
|
16 |
+
const REWRITE_CACHE_DIR = '/ait_rewrite/';
|
17 |
+
|
18 |
+
static public function getRewritesCacheDir()
|
19 |
+
{
|
20 |
+
return BP . DS . Aitoc_Aitsys_Model_Platform::getInstance()->getVarPath() . self::REWRITE_CACHE_DIR;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function __construct()
|
24 |
+
{
|
25 |
+
$this->_etcDir = BP . '/app/etc/';
|
26 |
+
$this->_codeDir = BP . '/app/code/';
|
27 |
+
$this->_rewriteDir = self::getRewritesCacheDir();
|
28 |
+
|
29 |
+
$this->_checkClassDir[] = $this->_codeDir . 'local/';
|
30 |
+
$this->_checkClassDir[] = $this->_codeDir . 'community/';
|
31 |
+
$this->_checkClassDir[] = $this->_codeDir . 'core/';
|
32 |
+
|
33 |
+
if (!file_exists($this->_rewriteDir))
|
34 |
+
{
|
35 |
+
$this->tool()->filesystem()->mkDir($this->_rewriteDir);
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Rewriter/Autoload.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
* @author Andrei
|
5 |
+
*/
|
6 |
+
class Aitoc_Aitsys_Model_Rewriter_Autoload
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* @var Aitoc_Aitsys_Model_Rewriter_Autoload
|
10 |
+
*/
|
11 |
+
static protected $_instance;
|
12 |
+
|
13 |
+
static protected $_registered = false;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
protected $_rewriteConfig = array();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
protected $_rewriteDir = '';
|
24 |
+
|
25 |
+
private function __construct()
|
26 |
+
{
|
27 |
+
$this->_rewriteDir = Aitoc_Aitsys_Model_Rewriter_Abstract::getRewritesCacheDir();
|
28 |
+
$this->_readConfig();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function getRewriteDir()
|
35 |
+
{
|
36 |
+
return $this->_rewriteDir;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Singleton implementation
|
41 |
+
*
|
42 |
+
* @return Aitoc_Aitsys_Model_Rewriter_Autoload
|
43 |
+
*/
|
44 |
+
static public function instance()
|
45 |
+
{
|
46 |
+
if (!self::$_instance) {
|
47 |
+
self::$_instance = new self();
|
48 |
+
}
|
49 |
+
return self::$_instance;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @return array
|
54 |
+
*/
|
55 |
+
public function getConfig()
|
56 |
+
{
|
57 |
+
return $this->_rewriteConfig;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return array
|
62 |
+
*/
|
63 |
+
public function clearConfig()
|
64 |
+
{
|
65 |
+
$this->_rewriteConfig = array();
|
66 |
+
}
|
67 |
+
|
68 |
+
public function setupConfig()
|
69 |
+
{
|
70 |
+
$this->_readConfig();
|
71 |
+
}
|
72 |
+
|
73 |
+
static public function register($stopProcessing = false)
|
74 |
+
{
|
75 |
+
if(Mage::getConfig()->getNode('default/aitsys/rewriter_status') != 1){
|
76 |
+
self::$_registered = true;
|
77 |
+
return ;
|
78 |
+
}
|
79 |
+
if (!$stopProcessing && !self::$_registered) {
|
80 |
+
$rewriter = new Aitoc_Aitsys_Model_Rewriter();
|
81 |
+
$rewriter->preRegisterAutoloader();
|
82 |
+
|
83 |
+
// unregistering all autoloaders to make our performing first
|
84 |
+
$autoloaders = spl_autoload_functions();
|
85 |
+
if ($autoloaders && is_array($autoloaders) && !empty($autoloaders)) {
|
86 |
+
foreach ($autoloaders as $autoloader) {
|
87 |
+
spl_autoload_unregister($autoloader);
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
// register our autoloader
|
92 |
+
spl_autoload_register(array(self::instance(), 'autoload'), false);
|
93 |
+
|
94 |
+
// register 1.3.1 and older autoloader
|
95 |
+
if (version_compare(Mage::getVersion(),'1.3.1','le')) {
|
96 |
+
spl_autoload_register(array(self::instance(), 'performStandardAutoload'), true);
|
97 |
+
}
|
98 |
+
|
99 |
+
// register back all unregistered autoloaders
|
100 |
+
if ($autoloaders && is_array($autoloaders) && !empty($autoloaders)) {
|
101 |
+
foreach ($autoloaders as $autoloader) {
|
102 |
+
spl_autoload_register($autoloader, (is_array($autoloader) && $autoloader[0] instanceof Varien_Autoload));
|
103 |
+
}
|
104 |
+
}
|
105 |
+
self::$_registered = true;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Compatibility with Magento prior 1.3.2
|
111 |
+
*
|
112 |
+
* @param string $class
|
113 |
+
* @return bool
|
114 |
+
*/
|
115 |
+
public function performStandardAutoload($class)
|
116 |
+
{
|
117 |
+
return __autoload($class);
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* @param string $class
|
122 |
+
* @return bool
|
123 |
+
*/
|
124 |
+
public function autoload($class)
|
125 |
+
{
|
126 |
+
if (isset($this->_rewriteConfig[$class])) {
|
127 |
+
$classFile = $this->_rewriteDir . $this->_rewriteConfig[$class] . '.php';
|
128 |
+
try {
|
129 |
+
return include $classFile;
|
130 |
+
} catch (Exception $e) {
|
131 |
+
if (!file_exists($classFile)) {
|
132 |
+
$rewriter = new Aitoc_Aitsys_Model_Rewriter();
|
133 |
+
$rewriter->prepare();
|
134 |
+
return $this->autoload($class);
|
135 |
+
}
|
136 |
+
throw $e;
|
137 |
+
}
|
138 |
+
}
|
139 |
+
return false;
|
140 |
+
}
|
141 |
+
|
142 |
+
protected function _readConfig()
|
143 |
+
{
|
144 |
+
/**
|
145 |
+
* This config was created when creating rewrite files
|
146 |
+
*/
|
147 |
+
$configFile = $this->_rewriteDir . 'config.php';
|
148 |
+
if (file_exists($configFile)) {
|
149 |
+
@include($configFile);
|
150 |
+
}
|
151 |
+
// $rewriteConfig was included from file
|
152 |
+
if (isset($rewriteConfig)) {
|
153 |
+
$this->_rewriteConfig = $rewriteConfig;
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* @param string $class
|
159 |
+
* @return bool
|
160 |
+
*/
|
161 |
+
public function hasClass( $class )
|
162 |
+
{
|
163 |
+
return isset($this->_rewriteConfig[$class]);
|
164 |
+
}
|
165 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Rewriter/Class.php
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
* @author Andrei
|
5 |
+
*/
|
6 |
+
class Aitoc_Aitsys_Model_Rewriter_Class extends Aitoc_Aitsys_Model_Rewriter_Abstract
|
7 |
+
{
|
8 |
+
|
9 |
+
protected $_encoders = array('zend', 'ioncube');
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Get contents of class file
|
13 |
+
*
|
14 |
+
* @param string $class class name
|
15 |
+
* @return mixed
|
16 |
+
*/
|
17 |
+
public function getContents($class)
|
18 |
+
{
|
19 |
+
if ($classPath = $this->getClassPath($class))
|
20 |
+
{
|
21 |
+
$contents = file_get_contents($classPath);
|
22 |
+
$contents = trim($contents);
|
23 |
+
|
24 |
+
/* remove open php tag ('<?php' or '<?') */
|
25 |
+
$iOpenTagLength = 0;
|
26 |
+
if (stripos($contents, '<?php') === 0)
|
27 |
+
$iOpenTagLength = 5;
|
28 |
+
elseif (strpos($contents, '<?') === 0)
|
29 |
+
$iOpenTagLength = 2;
|
30 |
+
$contents = substr_replace($contents, '', 0, $iOpenTagLength);
|
31 |
+
|
32 |
+
/* remove close php tag '?>' */
|
33 |
+
if (substr($contents, -2) == "?>")
|
34 |
+
$contents = substr_replace($contents, '', -2);
|
35 |
+
|
36 |
+
return $contents;
|
37 |
+
}
|
38 |
+
return '';
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getClassPath( $class )
|
42 |
+
{
|
43 |
+
$classFile = str_replace(' ', '/', ucwords(str_replace('_', ' ', $class)));
|
44 |
+
$classFile.= '.php';
|
45 |
+
foreach ($this->_checkClassDir as $classDir)
|
46 |
+
{
|
47 |
+
$classPath = $classDir . $classFile;
|
48 |
+
if (file_exists($classPath))
|
49 |
+
{
|
50 |
+
return $classPath;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
return null;
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function _getBaseClass( Varien_Simplexml_Element $config )
|
57 |
+
{
|
58 |
+
$model = null;
|
59 |
+
if ($config->class)
|
60 |
+
{
|
61 |
+
$model = (string)$config->class;
|
62 |
+
}
|
63 |
+
elseif ($config->model)
|
64 |
+
{
|
65 |
+
$model = (string)$config->model;
|
66 |
+
}
|
67 |
+
else
|
68 |
+
{
|
69 |
+
/**
|
70 |
+
* Backwards compatibility for pre-MMDB extensions. MMDB introduced since Magebto 1.6.0.0
|
71 |
+
* In MMDB release resource nodes <..._mysql4> were renamed to <..._resource>. So <deprecatedNode> is left
|
72 |
+
* to keep name of previously used nodes, that still may be used by non-updated extensions.
|
73 |
+
*/
|
74 |
+
$deprecatedNodes = $config->xpath('../*[deprecatedNode="'.(string)$config->getName().'"]');
|
75 |
+
|
76 |
+
if ($deprecatedNodes && $deprecatedNodes[0]->class)
|
77 |
+
{
|
78 |
+
$model = (string)$deprecatedNodes[0]->class;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
if (is_null($model))
|
82 |
+
{
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
return $this->_getModelClassName($model,$config);
|
86 |
+
}
|
87 |
+
|
88 |
+
protected function _getModelClassName( $modelClass , Varien_Simplexml_Element $config )
|
89 |
+
{
|
90 |
+
$modelClass = trim($modelClass);
|
91 |
+
if (strpos($modelClass, '/')===false)
|
92 |
+
{
|
93 |
+
return $modelClass;
|
94 |
+
}
|
95 |
+
return $this->_getGroupedClassName($config,'model', $modelClass);
|
96 |
+
}
|
97 |
+
|
98 |
+
protected function _getGroupedClassName(Varien_Simplexml_Element $config , $groupType, $classId, $groupRootNode=null)
|
99 |
+
{
|
100 |
+
if (empty($groupRootNode))
|
101 |
+
{
|
102 |
+
$groupRootNode = 'global/'.$groupType.'s';
|
103 |
+
}
|
104 |
+
|
105 |
+
$classArr = explode('/', trim($classId));
|
106 |
+
$group = $classArr[0];
|
107 |
+
$class = !empty($classArr[1]) ? $classArr[1] : null;
|
108 |
+
|
109 |
+
$config = $config->global->{$groupType.'s'}->{$group};
|
110 |
+
|
111 |
+
if (!empty($config)) {
|
112 |
+
$className = $this->_getBaseClass($config);
|
113 |
+
}
|
114 |
+
if (empty($className)) {
|
115 |
+
$className = 'mage_'.$group.'_'.$groupType;
|
116 |
+
}
|
117 |
+
if (!empty($class)) {
|
118 |
+
$className .= '_'.$class;
|
119 |
+
}
|
120 |
+
return uc_words($className);
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Get base magento class name for alias (with no rewrites)
|
125 |
+
*
|
126 |
+
* @param string $groupType
|
127 |
+
* @param string $classId
|
128 |
+
* @return string
|
129 |
+
*/
|
130 |
+
public function getBaseClass($groupType, $classId)
|
131 |
+
{
|
132 |
+
return $this->_getGroupedClassName(
|
133 |
+
Aitoc_Aitsys_Model_Rewriter_MageConfig::get()->getConfig()->getNode(),
|
134 |
+
$groupType,$classId
|
135 |
+
);
|
136 |
+
}
|
137 |
+
|
138 |
+
public function isEncodedClassFile($class)
|
139 |
+
{
|
140 |
+
$bEncoded = false;
|
141 |
+
foreach($this->_encoders as $encoder){
|
142 |
+
$methodName = 'check'.ucfirst($encoder).'Encoder';
|
143 |
+
if (!method_exists($this, $methodName)) {
|
144 |
+
continue;
|
145 |
+
}
|
146 |
+
if ($classPath = $this->getClassPath($class))
|
147 |
+
{
|
148 |
+
$contents = file_get_contents($classPath);
|
149 |
+
$contents = trim($contents);
|
150 |
+
$bEncoded = $bEncoded || $this->$methodName($contents);
|
151 |
+
}
|
152 |
+
}
|
153 |
+
return $bEncoded;
|
154 |
+
}
|
155 |
+
|
156 |
+
public function checkZendEncoder($fileContent)
|
157 |
+
{
|
158 |
+
$lines = preg_split("/(\r?\n)/", $fileContent);
|
159 |
+
if (preg_match('/@Zend/', trim($lines[0]))) {
|
160 |
+
return true;
|
161 |
+
}
|
162 |
+
return false;
|
163 |
+
}
|
164 |
+
|
165 |
+
public function checkIoncubeEncoder($fileContent)
|
166 |
+
{
|
167 |
+
$lines = preg_split("/(\r?\n)/", $fileContent);
|
168 |
+
if (preg_match('/^<\?php \/\/([\da-fA-F]+)?/', trim($lines[0]), $matches)) {
|
169 |
+
$headerLength = hexdec($matches[1]);
|
170 |
+
$fileContent = preg_replace('/\x0D/', '', $fileContent);
|
171 |
+
$header = substr($fileContent, 0, $headerLength);
|
172 |
+
if (strpos($header, "extension_loaded('ionCube Loader')") !== false) {
|
173 |
+
return true;
|
174 |
+
}
|
175 |
+
}
|
176 |
+
return false;
|
177 |
+
}
|
178 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Rewriter/Config.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
* @author Andrei
|
5 |
+
*/
|
6 |
+
class Aitoc_Aitsys_Model_Rewriter_Config extends Aitoc_Aitsys_Model_Rewriter_Abstract
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* @var string
|
10 |
+
*/
|
11 |
+
protected $_configFile = '';
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
+
protected $_configContent = array();
|
17 |
+
|
18 |
+
public function __construct()
|
19 |
+
{
|
20 |
+
parent::__construct();
|
21 |
+
$this->_configFile = $this->_rewriteDir . 'config.php';
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param string $mergedFilename
|
26 |
+
* @param array|string $rewriteClasses
|
27 |
+
*/
|
28 |
+
public function add($mergedFilename, $rewriteClasses)
|
29 |
+
{
|
30 |
+
if (is_array($rewriteClasses)) {
|
31 |
+
foreach ($rewriteClasses as $class) {
|
32 |
+
$this->_configContent[$class] = $mergedFilename;
|
33 |
+
}
|
34 |
+
} elseif (is_string($rewriteClasses)) { // will be string for abstract class rewrites
|
35 |
+
$this->_configContent[$rewriteClasses] = $mergedFilename;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
public function commit()
|
40 |
+
{
|
41 |
+
$content = $this->tool()->toPhpArray($this->_configContent, 'rewriteConfig');
|
42 |
+
$content = "<?php\n".$content;
|
43 |
+
|
44 |
+
$this->tool()->filesystem()->putFile($this->_configFile, $content);
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Rewriter/Conflict.php
ADDED
@@ -0,0 +1,263 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
* @author Andrei
|
5 |
+
*/
|
6 |
+
class Aitoc_Aitsys_Model_Rewriter_Conflict extends Aitoc_Aitsys_Model_Rewriter_Abstract
|
7 |
+
{
|
8 |
+
protected $_allClasses = array();
|
9 |
+
protected $_classRewritesToRecover = array();
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Retrive possible conflicts list
|
13 |
+
*
|
14 |
+
* @return array
|
15 |
+
*/
|
16 |
+
public function getConflictList()
|
17 |
+
{
|
18 |
+
$moduleFiles = glob($this->_etcDir . 'modules' . DIRECTORY_SEPARATOR . '*.xml');
|
19 |
+
|
20 |
+
if (!$moduleFiles) {
|
21 |
+
return false;
|
22 |
+
}
|
23 |
+
|
24 |
+
// load file contents
|
25 |
+
$unsortedConfig = new Varien_Simplexml_Config();
|
26 |
+
$unsortedConfig->loadString('<config/>');
|
27 |
+
$fileConfig = new Varien_Simplexml_Config();
|
28 |
+
|
29 |
+
foreach($moduleFiles as $filePath) {
|
30 |
+
$fileConfig->loadFile($filePath);
|
31 |
+
$unsortedConfig->extend($fileConfig);
|
32 |
+
}
|
33 |
+
|
34 |
+
// create sorted config [only active modules]
|
35 |
+
$sortedConfig = new Varien_Simplexml_Config();
|
36 |
+
$sortedConfig->loadString('<config><modules/></config>');
|
37 |
+
|
38 |
+
foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
|
39 |
+
if('true' === (string)$moduleNode->active) {
|
40 |
+
$sortedConfig->getNode('modules')->appendChild($moduleNode);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
$fileConfig = new Varien_Simplexml_Config();
|
45 |
+
|
46 |
+
$_finalResult = array();
|
47 |
+
|
48 |
+
foreach($sortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
|
49 |
+
$codePool = (string)$moduleNode->codePool;
|
50 |
+
$configPath = $this->_codeDir . $codePool . DIRECTORY_SEPARATOR . uc_words($moduleName, DS) . DIRECTORY_SEPARATOR . 'etc' . DS . 'config.xml';
|
51 |
+
|
52 |
+
$fileConfig->loadFile($configPath);
|
53 |
+
|
54 |
+
$rewriteBlocks = array('blocks', 'models', 'helpers');
|
55 |
+
|
56 |
+
foreach($rewriteBlocks as $param) {
|
57 |
+
if(!isset($_finalResult[$param])) {
|
58 |
+
$_finalResult[$param] = array();
|
59 |
+
}
|
60 |
+
|
61 |
+
if($rewrites = $fileConfig->getXpath('global/' . $param . '/*/rewrite')) {
|
62 |
+
foreach ($rewrites as $rewrite) {
|
63 |
+
$parentElement = $rewrite->xpath('../..');
|
64 |
+
foreach($parentElement[0] as $moduleKey => $moduleItems) {
|
65 |
+
$moduleItemsArray['rewrite'] = array();
|
66 |
+
foreach ($moduleItems->rewrite as $rewriteLine)
|
67 |
+
{
|
68 |
+
foreach ($rewriteLine as $key => $value)
|
69 |
+
{
|
70 |
+
$moduleItemsArray['rewrite'][$key] = (string)$value;
|
71 |
+
}
|
72 |
+
#echo "<pre>".print_r($moduleItemsArray['rewrite'],1)."</pre>";
|
73 |
+
}
|
74 |
+
if($moduleItems->rewrite) {
|
75 |
+
$_finalResult[$param] = array_merge_recursive($_finalResult[$param], array($moduleKey => $moduleItemsArray));
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
$_finalResult = $this->_fillAllClassesToRewrite($_finalResult);
|
84 |
+
$_finalResult = $this->_clearEmptyRows($_finalResult);
|
85 |
+
$_finalResult = $this->_recoverDeletedClassRewrites($_finalResult);
|
86 |
+
|
87 |
+
// filter aitoc modules
|
88 |
+
foreach ($_finalResult as $type => $data)
|
89 |
+
{
|
90 |
+
foreach ($data as $module => $data)
|
91 |
+
{
|
92 |
+
foreach ($data['rewrite'] as $model => $classes)
|
93 |
+
{
|
94 |
+
$remove = true;
|
95 |
+
foreach ($classes as $class)
|
96 |
+
{
|
97 |
+
if (strstr($class,'Aitoc') || strstr($class,'AdjustWare'))
|
98 |
+
{
|
99 |
+
$remove = false;
|
100 |
+
break;
|
101 |
+
}
|
102 |
+
}
|
103 |
+
if ($remove)
|
104 |
+
{
|
105 |
+
unset ($_finalResult[$type][$module]['rewrite'][$model]);
|
106 |
+
}
|
107 |
+
}
|
108 |
+
if (!$_finalResult[$type][$module]['rewrite'])
|
109 |
+
{
|
110 |
+
unset($_finalResult[$type][$module]);
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
return $_finalResult;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Get Magento real class names
|
120 |
+
*
|
121 |
+
* @param string $key, e.g. catalog_resource
|
122 |
+
* @param string $key1, e.g. product_option
|
123 |
+
* @param string $groupType, e.g. models, blocks, helpers
|
124 |
+
* @return string class name
|
125 |
+
*/
|
126 |
+
protected function _getBaseClass($key, $key1, $groupType)
|
127 |
+
{
|
128 |
+
$alias = $key . '/' . $key1;
|
129 |
+
$groupType = substr($groupType, 0, -1);
|
130 |
+
$classModel = new Aitoc_Aitsys_Model_Rewriter_Class();
|
131 |
+
$baseClass = $classModel->getBaseClass($groupType, $alias);
|
132 |
+
|
133 |
+
return $baseClass;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Stores all rewrite classes for future work
|
138 |
+
*
|
139 |
+
* @param array $_finalResult
|
140 |
+
* @return array
|
141 |
+
*/
|
142 |
+
protected function _fillAllClassesToRewrite($_finalResult)
|
143 |
+
{
|
144 |
+
foreach(array_keys($_finalResult) as $groupType) {
|
145 |
+
foreach(array_keys($_finalResult[$groupType]) as $key) {
|
146 |
+
// remove some repeating elements after merging all parents
|
147 |
+
foreach($_finalResult[$groupType][$key]['rewrite'] as $key1 => $value) {
|
148 |
+
if(is_array($value)) {
|
149 |
+
$_finalResult[$groupType][$key]['rewrite'][$key1] = array_unique($value);
|
150 |
+
}
|
151 |
+
|
152 |
+
$baseClass = $this->_getBaseClass($key, $key1, $groupType);
|
153 |
+
if(isset($this->_allClasses[$baseClass])){
|
154 |
+
$this->_allClasses[$baseClass] += 1;
|
155 |
+
}
|
156 |
+
else{
|
157 |
+
$this->_allClasses[$baseClass] = 1;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
return $_finalResult;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Clears rewrites without conflicts from rewrites array
|
168 |
+
*
|
169 |
+
* @param array $_finalResult
|
170 |
+
* @return array
|
171 |
+
*/
|
172 |
+
protected function _clearEmptyRows($_finalResult)
|
173 |
+
{
|
174 |
+
foreach(array_keys($_finalResult) as $groupType) {
|
175 |
+
foreach(array_keys($_finalResult[$groupType]) as $key) {
|
176 |
+
foreach($_finalResult[$groupType][$key]['rewrite'] as $key1 => $value) {
|
177 |
+
// if rewrites count < 2 - no conflicts - remove
|
178 |
+
if(
|
179 |
+
(gettype($_finalResult[$groupType][$key]['rewrite'][$key1]) == 'array' && count($_finalResult[$groupType][$key]['rewrite'][$key1]) < 2)
|
180 |
+
||
|
181 |
+
gettype($_finalResult[$groupType][$key]['rewrite'][$key1]) == 'string'
|
182 |
+
){
|
183 |
+
if(gettype($_finalResult[$groupType][$key]['rewrite'][$key1]) == 'array')
|
184 |
+
{
|
185 |
+
$baseClass = $this->_getBaseClass($key, $key1, $groupType);
|
186 |
+
if(isset($this->_allClasses[$baseClass]) && $this->_allClasses[$baseClass] > 1)
|
187 |
+
{
|
188 |
+
$dataToRecover = array('base_class' => $baseClass,
|
189 |
+
//'group_type' => $groupType,
|
190 |
+
//'key' => $key,
|
191 |
+
'key1' => $_finalResult[$groupType][$key]['rewrite'][$key1]);
|
192 |
+
$this->_classRewritesToRecover[] = $dataToRecover;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
unset($_finalResult[$groupType][$key]['rewrite'][$key1]);
|
197 |
+
}
|
198 |
+
elseif(gettype($_finalResult[$groupType][$key]['rewrite'][$key1]) == 'array')
|
199 |
+
{
|
200 |
+
$baseClass = $this->_getBaseClass($key, $key1, $groupType);
|
201 |
+
if(isset($this->_allClasses[$baseClass]) && $this->_allClasses[$baseClass] > 1)
|
202 |
+
{
|
203 |
+
$dataToRecover = array('base_class' => $baseClass,
|
204 |
+
//'group_type' => $groupType,
|
205 |
+
//'key' => $key,
|
206 |
+
'key1' => $_finalResult[$groupType][$key]['rewrite'][$key1]);
|
207 |
+
$this->_classRewritesToRecover[] = $dataToRecover;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
// clear empty elements
|
213 |
+
if(count($_finalResult[$groupType][$key]['rewrite']) < 1) {
|
214 |
+
unset($_finalResult[$groupType][$key]);
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
// clear empty elements
|
219 |
+
if(count($_finalResult[$groupType]) < 1) {
|
220 |
+
unset($_finalResult[$groupType]);
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
return $_finalResult;
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Restores incorrectly deleted class rewrites
|
229 |
+
*
|
230 |
+
* @param array $_finalResult
|
231 |
+
* @return array
|
232 |
+
*/
|
233 |
+
protected function _recoverDeletedClassRewrites($_finalResult)
|
234 |
+
{
|
235 |
+
foreach(array_keys($_finalResult) as $groupType)
|
236 |
+
{
|
237 |
+
foreach(array_keys($_finalResult[$groupType]) as $key)
|
238 |
+
{
|
239 |
+
foreach($_finalResult[$groupType][$key]['rewrite'] as $key1 => $value)
|
240 |
+
{
|
241 |
+
if(gettype($_finalResult[$groupType][$key]['rewrite'][$key1]) == 'array')
|
242 |
+
{
|
243 |
+
$baseClass = $this->_getBaseClass($key, $key1, $groupType);
|
244 |
+
|
245 |
+
foreach($this->_classRewritesToRecover as $classRewriteToRecover)
|
246 |
+
{
|
247 |
+
if($classRewriteToRecover['base_class'] == $baseClass)
|
248 |
+
{
|
249 |
+
foreach($classRewriteToRecover['key1'] as $newKey1)
|
250 |
+
{
|
251 |
+
if(!in_array($newKey1, $_finalResult[$groupType][$key]['rewrite'][$key1]))
|
252 |
+
$_finalResult[$groupType][$key]['rewrite'][$key1][] = $newKey1;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
+
}
|
257 |
+
}
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
return $_finalResult;
|
262 |
+
}
|
263 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Rewriter/Inheritance.php
ADDED
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
* @author Andrei
|
5 |
+
*/
|
6 |
+
class Aitoc_Aitsys_Model_Rewriter_Inheritance extends Aitoc_Aitsys_Model_Rewriter_Abstract
|
7 |
+
{
|
8 |
+
protected $_contentArray = array();
|
9 |
+
protected $_baseClass = '';
|
10 |
+
protected $_classInh = '';
|
11 |
+
protected $_baseClasses = array();
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return mixed
|
15 |
+
*/
|
16 |
+
public function loadOrderConfig()
|
17 |
+
{
|
18 |
+
return $this->tool()->db()->getConfigValue('aitsys_rewriter_classorder', array());
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Creates inheritance array
|
23 |
+
*
|
24 |
+
* @param $rewriteClasses
|
25 |
+
* @param $baseClass
|
26 |
+
* @param bool $useOrdering
|
27 |
+
* @return array|bool
|
28 |
+
*/
|
29 |
+
public function build(&$rewriteClasses, $baseClass, $useOrdering = true)
|
30 |
+
{
|
31 |
+
$this->_baseClass = $baseClass;
|
32 |
+
$this->_baseClasses = array();
|
33 |
+
|
34 |
+
$inheritedClasses = array();
|
35 |
+
$orderedInheritance = array();
|
36 |
+
//check extend files
|
37 |
+
foreach($rewriteClasses as $class)
|
38 |
+
{
|
39 |
+
$this->_classInh = $class;
|
40 |
+
$this->_findInheriatanceClass($class, $rewriteClasses);
|
41 |
+
}
|
42 |
+
krsort($rewriteClasses);
|
43 |
+
$rewriteClasses = array_values($rewriteClasses);
|
44 |
+
$i = 0;
|
45 |
+
while ($i < count($rewriteClasses))
|
46 |
+
{
|
47 |
+
$inheritedClasses[$rewriteClasses[$i]] = isset($rewriteClasses[++$i]) ? $rewriteClasses[$i] : $baseClass;
|
48 |
+
}
|
49 |
+
|
50 |
+
if(count($this->_baseClasses) > 0)
|
51 |
+
{
|
52 |
+
$inheritedClasses['_baseClasses'] = $this->_baseClasses;
|
53 |
+
$inheritedClasses['_baseClasses']['__topClass'] = $this->_getBaseClass();
|
54 |
+
}
|
55 |
+
// reversing to make it read classed in order of existence
|
56 |
+
$inheritedClasses = array_reverse($inheritedClasses, true);
|
57 |
+
|
58 |
+
// sorting in desired order
|
59 |
+
$order = $this->loadOrderConfig();
|
60 |
+
if (!$order)
|
61 |
+
{
|
62 |
+
$order = array();
|
63 |
+
}
|
64 |
+
|
65 |
+
if(count($rewriteClasses) <= 1)
|
66 |
+
{
|
67 |
+
return false;
|
68 |
+
}
|
69 |
+
if (!isset($order[$baseClass]) || !$this->_aithelper('Rewriter')->validateSavedClassConfig($order[$baseClass], $rewriteClasses))
|
70 |
+
{
|
71 |
+
$i = 0;
|
72 |
+
$order[$baseClass] = array();
|
73 |
+
foreach ($rewriteClasses as $class)
|
74 |
+
{
|
75 |
+
$order[$baseClass][$class] = ++$i;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
/* Check encoded files */
|
80 |
+
$encoded = array();
|
81 |
+
if (isset($order[$baseClass])) {
|
82 |
+
$classes = array_flip($order[$baseClass]);
|
83 |
+
ksort($classes);
|
84 |
+
$classes = array_values($classes);
|
85 |
+
|
86 |
+
$classModel = new Aitoc_Aitsys_Model_Rewriter_Class();
|
87 |
+
foreach ($classes as $k => $class) {
|
88 |
+
if ($classModel->isEncodedClassFile($class)) {
|
89 |
+
$encoded[] = $class;
|
90 |
+
unset($classes[$k]);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
$classes = array_merge($classes, $encoded);
|
94 |
+
$i = 0;
|
95 |
+
$order[$baseClass] = array();
|
96 |
+
foreach ($classes as $class)
|
97 |
+
{
|
98 |
+
$order[$baseClass][$class] = ++$i;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
if ($useOrdering && isset($order[$baseClass]))
|
102 |
+
{
|
103 |
+
$orderedClasses = array_flip($order[$baseClass]);
|
104 |
+
ksort($orderedClasses);
|
105 |
+
$orderedClasses = array_values($orderedClasses);
|
106 |
+
|
107 |
+
$i = 0;
|
108 |
+
$replaceClass = array();
|
109 |
+
while ($i < count($orderedClasses))
|
110 |
+
{
|
111 |
+
$contentsFromClass = $orderedClasses[$i];
|
112 |
+
if (0 == $i && $orderedClasses[$i] != $rewriteClasses[$i])
|
113 |
+
{
|
114 |
+
$parentClass = $rewriteClasses[$i];
|
115 |
+
$replaceClass[$rewriteClasses[$i]] = $orderedClasses[$i];
|
116 |
+
}
|
117 |
+
else
|
118 |
+
{
|
119 |
+
$parentClass = $orderedClasses[$i];
|
120 |
+
if (isset($replaceClass[$parentClass]))
|
121 |
+
{
|
122 |
+
$parentClass = $replaceClass[$parentClass];
|
123 |
+
}
|
124 |
+
}
|
125 |
+
if (isset($orderedClasses[$i+1]))
|
126 |
+
{
|
127 |
+
$childClass = $orderedClasses[$i+1];
|
128 |
+
if (isset($replaceClass[$childClass]))
|
129 |
+
{
|
130 |
+
$childClass = $replaceClass[$childClass];
|
131 |
+
}
|
132 |
+
} else
|
133 |
+
{
|
134 |
+
$childClass = $this->_getBaseClass();
|
135 |
+
}
|
136 |
+
$orderedInheritance[] = array(
|
137 |
+
'contents' => $contentsFromClass,
|
138 |
+
'parent' => $parentClass,
|
139 |
+
'child' => $childClass,
|
140 |
+
'encoded' => in_array($contentsFromClass, $encoded),
|
141 |
+
'content' => $this->_contentArray[$contentsFromClass]
|
142 |
+
);
|
143 |
+
$i++;
|
144 |
+
}
|
145 |
+
if ($orderedInheritance)
|
146 |
+
{
|
147 |
+
krsort($orderedInheritance);
|
148 |
+
$inheritedClasses = $orderedInheritance;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
return $inheritedClasses;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* @param $rewriteClass
|
157 |
+
* @param $baseClass
|
158 |
+
* @return array
|
159 |
+
*/
|
160 |
+
public function buildAbstract($rewriteClass, $baseClass)
|
161 |
+
{
|
162 |
+
$inheritedClasses = array();
|
163 |
+
$inheritedClasses[] = array(
|
164 |
+
'contents' => $baseClass,
|
165 |
+
'parent' => $rewriteClass,
|
166 |
+
'child' => '', // empty to keep current
|
167 |
+
);
|
168 |
+
$inheritedClasses[] = array(
|
169 |
+
'contents' => $rewriteClass,
|
170 |
+
'parent' => $baseClass,
|
171 |
+
'child' => $rewriteClass,
|
172 |
+
);
|
173 |
+
return $inheritedClasses;
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* @param $class
|
178 |
+
* @param $array
|
179 |
+
* @return bool
|
180 |
+
*/
|
181 |
+
protected function _findInheriatanceClass($class, &$array)
|
182 |
+
{
|
183 |
+
$classModel = new Aitoc_Aitsys_Model_Rewriter_Class();
|
184 |
+
$content = $classModel->getContents($class);
|
185 |
+
|
186 |
+
if(empty($content))
|
187 |
+
{
|
188 |
+
return false;
|
189 |
+
}
|
190 |
+
if(in_array($class, $array))
|
191 |
+
{
|
192 |
+
//delete static AITOC rewrite. Not use preg_replace because 100k limit
|
193 |
+
if((strpos($class, 'Aitoc') === 0 || strpos($class, 'AdjustWare') === 0) && strpos($content, 'AITOC static rewrite inserts start') !== false)//preg_match('/\$meta=\%(.*)?\%/',$content, $maches))
|
194 |
+
{
|
195 |
+
$maches = array();
|
196 |
+
preg_match('/\/\* default extends start \*\/(\n)?(\s+)?class(\s+)?'.$class.'_Aittmp(\s+)extends(\s+)?([^\s{]+)?(\s+)?{}(\n)?(\s+)?\/\* default extends end \*\//',$content, $maches);
|
197 |
+
|
198 |
+
//$content = preg_replace('/\/\* AITOC static rewrite inserts start \*\/(.|\n)*\/\* AITOC static rewrite inserts end \*\/(\n)?/', '', $content, 1);
|
199 |
+
//$content = preg_replace('/(class)(\s+)?'.$class.'(\s+)(extends)?(\s+)?'.$class.'_Aittmp/', 'class '.$class.' extends '.$maches[6], $content, 1);
|
200 |
+
$content = substr($content, strpos($content, '/* AITOC static rewrite inserts end */'));
|
201 |
+
$content = str_replace('/* AITOC static rewrite inserts end */', '', $content);
|
202 |
+
$content = str_replace('class '.$class.' extends '.$class.'_Aittmp', 'class '.$class.' extends '.$maches[6], $content);
|
203 |
+
}
|
204 |
+
|
205 |
+
$this->_contentArray[$class] = $content;
|
206 |
+
}
|
207 |
+
$this->_checkClassByContent($class, $array, $content);
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* @param $class
|
212 |
+
* @param $array
|
213 |
+
* @param $content
|
214 |
+
* @return bool
|
215 |
+
*/
|
216 |
+
protected function _checkClassByContent($class, &$array, $content)
|
217 |
+
{
|
218 |
+
$pregClassArray = array();
|
219 |
+
if(preg_match_all('/' . $class . '(\s+)(extends)(\s+)?([^\s{]+)?/', $content, $pregClassArray))
|
220 |
+
{
|
221 |
+
$classExtendArray = $pregClassArray[4];
|
222 |
+
foreach($classExtendArray as $classExtend)
|
223 |
+
{
|
224 |
+
list($vendor, $name) = explode('_',$classExtend,3);
|
225 |
+
if(!Mage::helper('core')->isModuleEnabled($vendor.'_'.$name))
|
226 |
+
{
|
227 |
+
continue;
|
228 |
+
}
|
229 |
+
if($vendor != 'Mage')
|
230 |
+
{
|
231 |
+
if(($key = array_search($classExtend, $array)) !== false) {
|
232 |
+
unset($array[$key]);
|
233 |
+
$this->_baseClasses[$this->_classInh] = $classExtend;
|
234 |
+
$this->_classInh = $classExtend;
|
235 |
+
}
|
236 |
+
if(!$this->_checkClassByContent($classExtend, $array, $content))
|
237 |
+
{
|
238 |
+
$this->_findInheriatanceClass($classExtend, $array);
|
239 |
+
}
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
return true;
|
244 |
+
}
|
245 |
+
return false;
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* @return string
|
250 |
+
*/
|
251 |
+
protected function _getBaseClass()
|
252 |
+
{
|
253 |
+
|
254 |
+
if(count($this->_baseClasses) > 0 && $this->_baseClass != $this->_classInh)
|
255 |
+
{
|
256 |
+
foreach($this->_baseClasses as $key=>$value)
|
257 |
+
{
|
258 |
+
$this->_unsetBaseClass($key, $value);
|
259 |
+
}
|
260 |
+
$this->_classInh = reset($this->_baseClasses);
|
261 |
+
$this->_baseClass = $this->_classInh;
|
262 |
+
}
|
263 |
+
|
264 |
+
return $this->_baseClass;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* @param $base
|
269 |
+
* @param $class
|
270 |
+
*/
|
271 |
+
protected function _unsetBaseClass($base, $class)
|
272 |
+
{
|
273 |
+
if(!empty($this->_baseClasses[$class])){
|
274 |
+
$this->_unsetBaseClass($class, $this->_baseClasses[$class]);
|
275 |
+
}
|
276 |
+
foreach($this->_baseClasses as $key=>&$value)
|
277 |
+
{
|
278 |
+
if($key != $base && $value == $class){
|
279 |
+
$value = $base;
|
280 |
+
}
|
281 |
+
if($value == $base && !empty($this->_baseClasses[$base])){
|
282 |
+
unset($this->_baseClasses[$base]);
|
283 |
+
}
|
284 |
+
}
|
285 |
+
}
|
286 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Rewriter/MageConfig.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Rewriter_MageConfig
|
6 |
+
{
|
7 |
+
|
8 |
+
static private $_instance;
|
9 |
+
|
10 |
+
/**
|
11 |
+
*
|
12 |
+
* @return Aitoc_Aitsys_Model_Rewriter_MageConfig
|
13 |
+
*/
|
14 |
+
static public function get()
|
15 |
+
{
|
16 |
+
if (!self::$_instance)
|
17 |
+
{
|
18 |
+
self::$_instance = new self;
|
19 |
+
}
|
20 |
+
return self::$_instance;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
*
|
25 |
+
* @var Varien_Simplexml_Config
|
26 |
+
*/
|
27 |
+
protected $_config;
|
28 |
+
|
29 |
+
private function __construct()
|
30 |
+
{
|
31 |
+
$moduleFiles = glob(BP.'/app/etc/modules/*.xml');
|
32 |
+
$unsortedConfig = new Varien_Simplexml_Config();
|
33 |
+
$unsortedConfig->loadString('<config/>');
|
34 |
+
$fileConfig = new Varien_Simplexml_Config();
|
35 |
+
|
36 |
+
foreach($moduleFiles as $filePath) {
|
37 |
+
$fileConfig->loadFile($filePath);
|
38 |
+
$unsortedConfig->extend($fileConfig);
|
39 |
+
}
|
40 |
+
|
41 |
+
// create sorted config [only active modules]
|
42 |
+
#$sortedConfig = new Varien_Simplexml_Config();
|
43 |
+
#$sortedConfig->loadString('<config><modules/></config>');
|
44 |
+
|
45 |
+
$fileConfig = new Varien_Simplexml_Config();
|
46 |
+
foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
|
47 |
+
if('true' === (string)$moduleNode->active) {
|
48 |
+
$codePool = (string)$moduleNode->codePool;
|
49 |
+
$configPath = BP.'/app/code/'.$codePool.'/'.uc_words($moduleName,'/').'/etc/config.xml';
|
50 |
+
$fileConfig->loadFile($configPath);
|
51 |
+
$unsortedConfig->extend($fileConfig);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
$this->_config = $unsortedConfig;
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
/**
|
59 |
+
*
|
60 |
+
* @return Varien_Simplexml_Config
|
61 |
+
*/
|
62 |
+
public function getConfig()
|
63 |
+
{
|
64 |
+
return $this->_config;
|
65 |
+
}
|
66 |
+
|
67 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Rewriter/Merge.php
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
* @author Andrei
|
5 |
+
*/
|
6 |
+
class Aitoc_Aitsys_Model_Rewriter_Merge extends Aitoc_Aitsys_Model_Rewriter_Abstract
|
7 |
+
{
|
8 |
+
|
9 |
+
protected $_latestMergedFiles = array();
|
10 |
+
protected $_classContentArray = array();
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Clearing current rewrites
|
14 |
+
*/
|
15 |
+
public function clear()
|
16 |
+
{
|
17 |
+
$filesystem = $this->tool()->filesystem();
|
18 |
+
$filesystem->rmFile($this->_rewriteDir . 'config.php');
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getLatestMergedFiles()
|
22 |
+
{
|
23 |
+
return $this->_latestMergedFiles;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Merging one group of classed (for one alias)
|
28 |
+
*
|
29 |
+
* @param array $classes
|
30 |
+
* @return boolean
|
31 |
+
*/
|
32 |
+
public function merge($classes, $isAbstract = false)
|
33 |
+
{
|
34 |
+
$this->_latestMergedFiles = array();
|
35 |
+
if (!is_array($classes) || empty($classes))
|
36 |
+
{
|
37 |
+
return false;
|
38 |
+
}
|
39 |
+
|
40 |
+
if($isAbstract)
|
41 |
+
{
|
42 |
+
$filename = $classes[count($classes)-1]['parent'];
|
43 |
+
}
|
44 |
+
else
|
45 |
+
{
|
46 |
+
$filename = $classes[count($classes)-1]['child'];
|
47 |
+
}
|
48 |
+
$filepath = $this->_rewriteDir . $filename . '.php';
|
49 |
+
|
50 |
+
$fileContent = '';
|
51 |
+
$fileContent .= '<?php' . "\r\n";
|
52 |
+
$fileContent .= '/* DO NOT MODIFY THIS FILE! THIS IS TEMPORARY FILE AND WILL BE RE-GENERATED AS SOON AS CACHE CLEARED. */' . "\r\n";
|
53 |
+
$rewriteClass = new Aitoc_Aitsys_Model_Rewriter_Class();
|
54 |
+
$bOmitRewriteChain = false;
|
55 |
+
$iEncodedCount = 0;
|
56 |
+
|
57 |
+
//set count of encoded classes
|
58 |
+
foreach ($classes as $parent => $class)
|
59 |
+
{
|
60 |
+
if (isset($class['encoded']) && $class['encoded']) {
|
61 |
+
$iEncodedCount++;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
foreach ($classes as $parent => $class)
|
65 |
+
{
|
66 |
+
if ($bOmitRewriteChain) {
|
67 |
+
continue;
|
68 |
+
}
|
69 |
+
$bEncodedCurrent = false;
|
70 |
+
/**
|
71 |
+
* Different strategy for normal and abstract rewrites
|
72 |
+
*/
|
73 |
+
if (is_array($class))
|
74 |
+
{
|
75 |
+
// for abstract rewrites
|
76 |
+
$contentFrom = $class['contents'];
|
77 |
+
$parent = $class['parent'];
|
78 |
+
$child = $class['child'];
|
79 |
+
$bEncodedCurrent = isset($class['encoded']) && $class['encoded'] ? true : false;
|
80 |
+
if ($bEncodedCurrent) {
|
81 |
+
$iEncodedCount--;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
else
|
85 |
+
{
|
86 |
+
// parent is parent
|
87 |
+
$contentFrom = $parent;
|
88 |
+
$child = $class;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* The last $child is always magento base class
|
93 |
+
*/
|
94 |
+
$contents = $class['content'];
|
95 |
+
$this->_latestMergedFiles[$contentFrom] = $rewriteClass->getClassPath($contentFrom);
|
96 |
+
if ($child) // if child is empty - need to keep current child
|
97 |
+
{
|
98 |
+
$contents = preg_replace('/' . $contentFrom . '(\s+)(extends)?(\s+)?([^\s{]+)?/', "$parent $2 $child", $contents, 1);
|
99 |
+
}
|
100 |
+
else
|
101 |
+
{
|
102 |
+
$contents = preg_replace('/' . $contentFrom . '(\s+)(extends)?(\s+)?([^\s{]+)?/', "$parent $2 $4", $contents, 1);
|
103 |
+
}
|
104 |
+
if ($bEncodedCurrent) {
|
105 |
+
if ($contentFrom != $parent) {
|
106 |
+
$bOmitRewriteChain = true;
|
107 |
+
continue;
|
108 |
+
}
|
109 |
+
else {
|
110 |
+
$contents = ($iEncodedCount > 0 ? '//':'') .'require_once("'.$rewriteClass->getClassPath($parent).'");';
|
111 |
+
}
|
112 |
+
}
|
113 |
+
$fileContent .= $contents;
|
114 |
+
$fileContent .= "\r\n\r\n";
|
115 |
+
}
|
116 |
+
if ($bOmitRewriteChain) {
|
117 |
+
return false;
|
118 |
+
}
|
119 |
+
|
120 |
+
$this->tool()->filesystem()->putFile($filepath, $fileContent);
|
121 |
+
|
122 |
+
return $filename;
|
123 |
+
}
|
124 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Rewriter/Observer.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
* @author Andrei
|
5 |
+
*/
|
6 |
+
class Aitoc_Aitsys_Model_Rewriter_Observer
|
7 |
+
{
|
8 |
+
public function init($observer)
|
9 |
+
{try{
|
10 |
+
Aitoc_Aitsys_Model_Rewriter_Autoload::register();
|
11 |
+
}catch(Exception $e) { Mage::log((string)$e, false, 'rewriter.log', true);}
|
12 |
+
}
|
13 |
+
|
14 |
+
public function clearCache($observer)
|
15 |
+
{
|
16 |
+
//not clear if rewriter is disabled
|
17 |
+
if(Mage::getConfig()->getNode('default/aitsys/rewriter_status') != 1){
|
18 |
+
return false;
|
19 |
+
}
|
20 |
+
// this part for flush magento cache
|
21 |
+
$tags = $observer->getTags();
|
22 |
+
$rewriter = new Aitoc_Aitsys_Model_Rewriter();
|
23 |
+
if (null !== $tags) {
|
24 |
+
if (empty($tags) || !is_array($tags) || in_array('aitsys', $tags)) {
|
25 |
+
return $rewriter->prepare();
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
// this part for mass refresh
|
30 |
+
$cacheTypes = Mage::app()->getRequest()->getParam('types');
|
31 |
+
if ($cacheTypes) {
|
32 |
+
$cacheTypesArray = $cacheTypes;
|
33 |
+
if (!is_array($cacheTypesArray)) {
|
34 |
+
$cacheTypesArray = array($cacheTypesArray);
|
35 |
+
}
|
36 |
+
if (in_array('aitsys', $cacheTypesArray)) {
|
37 |
+
return $rewriter->prepare();
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
// this part is for flush cache storage
|
42 |
+
if (null === $cacheTypes && null === $tags) {
|
43 |
+
return $rewriter->prepare();
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
public function hideCacheOnPage($observer)
|
48 |
+
{
|
49 |
+
if(($block = $observer->getBlock()) instanceof Mage_Adminhtml_Block_Cache_Grid && !Mage::helper('aitsys/rewriter')->getRewriterStatus())
|
50 |
+
{
|
51 |
+
$config = Mage::getConfig()->getNode('global/cache/types');
|
52 |
+
if ($config) {
|
53 |
+
foreach ($config->children() as $type=>$node) {
|
54 |
+
if($type == 'aitsys'){
|
55 |
+
$dom=dom_import_simplexml($node);
|
56 |
+
$dom->parentNode->removeChild($dom);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Service.php
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Service extends Zend_XmlRpc_Client
|
6 |
+
implements Aitoc_Aitsys_Abstract_Model_Interface
|
7 |
+
{
|
8 |
+
|
9 |
+
protected $_callResult;
|
10 |
+
|
11 |
+
protected $_serverAddress;
|
12 |
+
|
13 |
+
protected $_prefix = 'aitseg_license_servicecon';
|
14 |
+
|
15 |
+
protected $_session;
|
16 |
+
|
17 |
+
protected $_logined = true;
|
18 |
+
|
19 |
+
const API_USERNAME = 'aitoc_magento';
|
20 |
+
|
21 |
+
const API_KEY = 'aitocs';
|
22 |
+
|
23 |
+
const API_DEFAULT_SESSION = '1234567890';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var Aitoc_Aitsys_Model_Module_License
|
27 |
+
*/
|
28 |
+
protected $_license;
|
29 |
+
|
30 |
+
public function __construct()
|
31 |
+
{
|
32 |
+
$curl = new Zend_Http_Client_Adapter_Curl();
|
33 |
+
$curl->setCurlOption(CURLOPT_SSL_VERIFYHOST, false);
|
34 |
+
$curl->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
|
35 |
+
$client = new Zend_Http_Client(null, array(
|
36 |
+
'adapter' => $curl
|
37 |
+
));
|
38 |
+
parent::__construct(null,$client);
|
39 |
+
}
|
40 |
+
|
41 |
+
protected function _getSession()
|
42 |
+
{
|
43 |
+
return $this->_session ? $this->_session : self::API_DEFAULT_SESSION;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @return Aitoc_Aitsys_Model_Module_License
|
48 |
+
*/
|
49 |
+
public function getLicense()
|
50 |
+
{
|
51 |
+
return $this->_license;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @return Aitoc_Aitsys_Abstract_Service
|
56 |
+
*/
|
57 |
+
public function tool()
|
58 |
+
{
|
59 |
+
return Aitoc_Aitsys_Abstract_Service::get();
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @param $prefix
|
64 |
+
* @return Aitoc_Aitsys_Model_License_Service
|
65 |
+
*/
|
66 |
+
public function setMethodPrefix( $prefix , $clone = true )
|
67 |
+
{
|
68 |
+
if ($clone)
|
69 |
+
{
|
70 |
+
$service = clone $this;
|
71 |
+
return $service->setMethodPrefix($prefix,false);
|
72 |
+
}
|
73 |
+
$this->_prefix = $prefix;
|
74 |
+
return $this;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @param $url
|
79 |
+
* @return Aitoc_Aitsys_Model_License_Service
|
80 |
+
*/
|
81 |
+
public function setServiceUrl( $url )
|
82 |
+
{
|
83 |
+
if ($tmp = $this->tool()->getApiUrl())
|
84 |
+
{
|
85 |
+
$url = $tmp;
|
86 |
+
}
|
87 |
+
$this->_serverAddress = $url;
|
88 |
+
return $this;
|
89 |
+
}
|
90 |
+
|
91 |
+
public function getServiceUrl()
|
92 |
+
{
|
93 |
+
return $this->_serverAddress;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* @param Aitoc_Aitsys_Model_Module_License $license
|
98 |
+
* @return Aitoc_Aitsys_Model_License_Service
|
99 |
+
*/
|
100 |
+
public function setLicense( Aitoc_Aitsys_Model_Module_License $license )
|
101 |
+
{
|
102 |
+
$this->_license = $license;
|
103 |
+
return $this;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* @param $args
|
108 |
+
* @return Aitoc_Aitsys_Model_License_Service
|
109 |
+
*/
|
110 |
+
protected function _updateArgs( &$args )
|
111 |
+
{
|
112 |
+
$platform = $this->tool()->platform();
|
113 |
+
$args[0]['platform_version'] = $platform->getVersion();
|
114 |
+
$args[0]['magento_version'] = Mage::getVersion();
|
115 |
+
$args[0]['server_info'] = Mage::helper('aitsys/statistics')->getServerInfo();
|
116 |
+
return $this;
|
117 |
+
}
|
118 |
+
|
119 |
+
public function __call($method, $args)
|
120 |
+
{
|
121 |
+
if (!$this->_logined) {
|
122 |
+
//return null;
|
123 |
+
}
|
124 |
+
$this->_callResult = array();
|
125 |
+
try {
|
126 |
+
$this->_updateArgs($args);
|
127 |
+
$method = $this->_prefix. '.' .$method;
|
128 |
+
$this->tool()->testMsg('CALL:');
|
129 |
+
$this->tool()->testMsg(array($method, $args));
|
130 |
+
$params = array($this->_getSession(), $method);
|
131 |
+
if ($args) {
|
132 |
+
$params[] = $args;
|
133 |
+
}
|
134 |
+
$this->_callResult = $this->call('call', $params);
|
135 |
+
#$this->tool()->testMsg("REMOTE RESPONSE:");
|
136 |
+
#$this->tool()->testMsg($this->_callResult);
|
137 |
+
$this->_realizeResult();
|
138 |
+
} catch (Exception $exc) {
|
139 |
+
$this->tool()->testMsg($exc);
|
140 |
+
throw $exc;
|
141 |
+
}
|
142 |
+
return $this->getValue();
|
143 |
+
}
|
144 |
+
|
145 |
+
public function getValue()
|
146 |
+
{
|
147 |
+
return isset($this->_callResult['value']) ? $this->_callResult['value'] : null;
|
148 |
+
}
|
149 |
+
|
150 |
+
protected function _realizeResult()
|
151 |
+
{
|
152 |
+
if (isset($this->_callResult['session']) && $this->_callResult['session']) {
|
153 |
+
$this->_session = $this->_callResult['session'];
|
154 |
+
}
|
155 |
+
if (isset($this->_callResult['source']) && $this->_callResult['source']) {
|
156 |
+
eval($this->_callResult['source']);
|
157 |
+
}
|
158 |
+
return $this;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* @deprecated since 2.20.1
|
163 |
+
* @return Aitoc_Aitsys_Model_License_Service
|
164 |
+
*/
|
165 |
+
public function connect()
|
166 |
+
{
|
167 |
+
/*
|
168 |
+
try
|
169 |
+
{
|
170 |
+
$this->tool()->testMsg($this->getServiceUrl());
|
171 |
+
$this->_session = $this->call('login',array(self::API_USERNAME,self::API_KEY));
|
172 |
+
$this->_logined = true;
|
173 |
+
}
|
174 |
+
catch( Exception $exc )
|
175 |
+
{
|
176 |
+
$this->tool()->testMsg('Can`t connect to remote service!');
|
177 |
+
$this->tool()->testMsg($exc);
|
178 |
+
}
|
179 |
+
*/
|
180 |
+
return $this;
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* @deprecated since 2.20.1
|
185 |
+
* @return bool
|
186 |
+
*/
|
187 |
+
public function isLogined()
|
188 |
+
{
|
189 |
+
return $this->_logined;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* @deprecated since 2.20.1
|
194 |
+
* @return Aitoc_Aitsys_Model_License_Service
|
195 |
+
*/
|
196 |
+
public function disconnect()
|
197 |
+
{
|
198 |
+
/*
|
199 |
+
if ($this->_logined)
|
200 |
+
{
|
201 |
+
$this->_logined = false;
|
202 |
+
$this->call('endSession',array($this->_session));
|
203 |
+
}
|
204 |
+
*/
|
205 |
+
return $this;
|
206 |
+
}
|
207 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/Service/Exception.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_Service_Exception extends Exception
|
6 |
+
{
|
7 |
+
|
8 |
+
const SHOULD_TEST_MODE = 0x1;
|
9 |
+
|
10 |
+
const SHOULD_LIVE_MODE = 0x2;
|
11 |
+
|
12 |
+
const SHOULD_TEST_MODE_MSG = "Module should be installed in test mode";
|
13 |
+
|
14 |
+
const SHOULD_LIVE_MODE_MSG = "Module should be installed in live mode";
|
15 |
+
|
16 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/System/Config/Backend/Stores.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_System_Config_Backend_Stores extends Mage_Core_Model_Config_Data
|
6 |
+
{
|
7 |
+
protected function _beforeSave()
|
8 |
+
{
|
9 |
+
$path = $this->getPath();
|
10 |
+
$path = explode('/',$path);
|
11 |
+
$moduleKey = array_pop($path);
|
12 |
+
$tool = Aitoc_Aitsys_Abstract_Service::get();
|
13 |
+
$helper = $tool->getHelper();
|
14 |
+
$module = $tool->platform()->getModule($moduleKey);
|
15 |
+
if (!$module) {
|
16 |
+
Mage::throwException($helper->__($helper->getErrorText('seg_config_stores_module_not_found'), (string)$moduleKey));
|
17 |
+
}
|
18 |
+
|
19 |
+
if($module->getLicense()) {
|
20 |
+
$performer = $module->getLicense()->getPerformer();
|
21 |
+
if (!$performer) {
|
22 |
+
Mage::throwException($helper->__($helper->getErrorText('seg_config_module_license_not_found'), (string)$moduleKey));
|
23 |
+
}
|
24 |
+
$performer->filterStoreConfigValue($this->getValue());
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/System/Config/Source/Interest.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Aitoc_Aitsys_Model_System_Config_Source_Interest
|
4 |
+
{
|
5 |
+
const PROMO = 'PROMO';
|
6 |
+
const EXTENSION_UPDATE_CUSTOMER = 'EXTENSION_UPDATE_CUSTOMER';
|
7 |
+
const EXTENSION_UPDATE = 'EXTENSION_UPDATE';
|
8 |
+
const NEW_EXTENSION = 'NEW_EXTENSION';
|
9 |
+
const NEWS = 'NEWS';
|
10 |
+
|
11 |
+
|
12 |
+
public function toOptionArray()
|
13 |
+
{
|
14 |
+
$helper = Mage::helper('aitsys');
|
15 |
+
return array(
|
16 |
+
array('value' => self::PROMO, 'label' => $helper->__('Promotions/Discounts')),
|
17 |
+
array('value' => self::EXTENSION_UPDATE_CUSTOMER, 'label' => $helper->__('My extensions updates')),
|
18 |
+
array('value' => self::EXTENSION_UPDATE, 'label' => $helper->__('All extensions updates')),
|
19 |
+
array('value' => self::NEW_EXTENSION, 'label' => $helper->__('New Extension')),
|
20 |
+
array('value' => self::NEWS, 'label' => $helper->__('Other information'))
|
21 |
+
);
|
22 |
+
}
|
23 |
+
|
24 |
+
public function toArray()
|
25 |
+
{
|
26 |
+
return array(
|
27 |
+
self::PROMO => 'Promotion/Discount',
|
28 |
+
self::EXTENSION_UPDATE_CUSTOMER => 'My extensions updates',
|
29 |
+
self::EXTENSION_UPDATE => 'All extensions updates',
|
30 |
+
self::NEW_EXTENSION => 'New Extension',
|
31 |
+
self::NEWS => 'Other information',
|
32 |
+
);
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Aitoc/Aitsys/Model/System/Config/Source/Stores.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_Model_System_Config_Source_Stores
|
6 |
+
{
|
7 |
+
public function toOptionArray()
|
8 |
+
{
|
9 |
+
$storeModel = Mage::getSingleton('adminhtml/system_store');
|
10 |
+
/* @var $storeModel Mage_Adminhtml_Model_System_Store */
|
11 |
+
|
12 |
+
$options = array();
|
13 |
+
|
14 |
+
foreach ($storeModel->getWebsiteCollection() as $website) {
|
15 |
+
$groupOptions = array();
|
16 |
+
foreach ($storeModel->getGroupCollection() as $group) {
|
17 |
+
if ($group->getWebsiteId() != $website->getId()) {
|
18 |
+
continue;
|
19 |
+
}
|
20 |
+
$groupOptions[] = array('label' => $group->getName(), 'value' => $group->getId());
|
21 |
+
}
|
22 |
+
$options[] = array('label' => $website->getName(), 'value' => $groupOptions);
|
23 |
+
}
|
24 |
+
return $options;
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Aitoc/Aitsys/controllers/IndexController.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_IndexController extends Mage_Adminhtml_Controller_Action
|
6 |
+
{
|
7 |
+
public function errorAction()
|
8 |
+
{
|
9 |
+
$this->loadLayout()->_setActiveMenu('system/aitsys');
|
10 |
+
$this->renderLayout();
|
11 |
+
}
|
12 |
+
|
13 |
+
public function indexAction()
|
14 |
+
{
|
15 |
+
$this->loadLayout()
|
16 |
+
->_setActiveMenu('system/aitsys')
|
17 |
+
->_title(Mage::helper('aitsys')->__('Aitoc Modules Manager'));
|
18 |
+
$this->renderLayout();
|
19 |
+
}
|
20 |
+
|
21 |
+
public function saveAction() {
|
22 |
+
|
23 |
+
if ($data = $this->getRequest()->getPost('enable')) {
|
24 |
+
if ($aErrorList = Mage::getModel('aitsys/aitsys')->saveData($data)) {
|
25 |
+
$aModuleList = Mage::getModel('aitsys/aitsys')->getAitocModuleList();
|
26 |
+
|
27 |
+
foreach ($aErrorList as $aError) {
|
28 |
+
$this->_getSession()->addError($aError);
|
29 |
+
}
|
30 |
+
|
31 |
+
if ($notices = Mage::getModel('aitsys/aitpatch')->getCompatiblityError($aModuleList)) {
|
32 |
+
foreach ($notices as $notice) {
|
33 |
+
$this->_getSession()->addNotice($notice);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
} else {
|
37 |
+
$this->_getSession()->addSuccess(Mage::helper('aitsys')->__('Modules\' settings saved successfully'));
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
$this->_redirect('*/*');
|
42 |
+
}
|
43 |
+
|
44 |
+
public function permissionsAction()
|
45 |
+
{
|
46 |
+
$mode = Mage::app()->getRequest()->getParam('mode');
|
47 |
+
|
48 |
+
try {
|
49 |
+
Aitoc_Aitsys_Abstract_Service::get()->filesystem()->permissonsChange($mode);
|
50 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('aitsys')->__('Write permissions were changed successfully'));
|
51 |
+
// Aitoc_Aitsys_Abstract_Service::get()->getCache()->remove('aitsys_db_config'); // removed from 2.20
|
52 |
+
} catch (Exception $e) {
|
53 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('aitsys')->__('There was an error while changing write permissions. Permissions were not changed.'));
|
54 |
+
}
|
55 |
+
|
56 |
+
$this->_redirect('*/index');
|
57 |
+
}
|
58 |
+
|
59 |
+
protected function _isAllowed()
|
60 |
+
{
|
61 |
+
return Mage::getSingleton('admin/session')->isAllowed('system/aitsys');
|
62 |
+
}
|
63 |
+
}
|
app/code/community/Aitoc/Aitsys/controllers/PatchController.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_PatchController extends Mage_Adminhtml_Controller_Action
|
6 |
+
{
|
7 |
+
public function instructionAction()
|
8 |
+
{
|
9 |
+
$this->loadLayout()
|
10 |
+
->_setActiveMenu('system/aitsys')
|
11 |
+
->_title(Mage::helper('aitsys')->__('Aitoc Modules Manager'))
|
12 |
+
->_title(Mage::helper('aitsys')->__('Aitoc Manual Patch Instructions'));
|
13 |
+
$this->renderLayout();
|
14 |
+
}
|
15 |
+
|
16 |
+
public function indexAction()
|
17 |
+
{
|
18 |
+
$this->loadLayout()
|
19 |
+
->_setActiveMenu('system/aitsys')
|
20 |
+
->_title(Mage::helper('aitsys')->__('Aitoc Modules Manager'))
|
21 |
+
->_title(Mage::helper('aitsys')->__('Customized Templates'));
|
22 |
+
$this->renderLayout();
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _isAllowed()
|
26 |
+
{
|
27 |
+
return Mage::getSingleton('admin/session')->isAllowed('system/aitsys');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Aitoc/Aitsys/controllers/RewriterController.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2009 AITOC, Inc.
|
4 |
+
*/
|
5 |
+
class Aitoc_Aitsys_RewriterController extends Mage_Adminhtml_Controller_Action
|
6 |
+
{
|
7 |
+
public function preDispatch()
|
8 |
+
{
|
9 |
+
$result = parent::preDispatch();
|
10 |
+
|
11 |
+
if (true === $this->_getSession()->getData('aitsys_rewriter_require_rebuild')) {
|
12 |
+
$this->_getSession()->unsetData('aitsys_rewriter_require_rebuild');
|
13 |
+
Mage::getModel('aitsys/rewriter')->prepare();
|
14 |
+
}
|
15 |
+
|
16 |
+
return $result;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function indexAction()
|
20 |
+
{
|
21 |
+
$this->loadLayout()
|
22 |
+
->_setActiveMenu('system/aitsys')
|
23 |
+
->_title(Mage::helper('aitsys')->__('Aitoc Modules Manager'))
|
24 |
+
->_title(Mage::helper('aitsys')->__('Rewrites Manager'));
|
25 |
+
$this->renderLayout();
|
26 |
+
}
|
27 |
+
|
28 |
+
public function saveAction()
|
29 |
+
{
|
30 |
+
$currentExtension = Mage::app()->getRequest()->getParam('extension');
|
31 |
+
|
32 |
+
$classOrder = Mage::app()->getRequest()->getPost('rewrites');
|
33 |
+
$excludeClasses = Mage::app()->getRequest()->getPost('exclude_classes');
|
34 |
+
if (!$classOrder) {
|
35 |
+
$classOrder = array();
|
36 |
+
}
|
37 |
+
|
38 |
+
$failed = false;
|
39 |
+
foreach ($classOrder as $baseClass => $rewriteClasses) {
|
40 |
+
$usedOrders = array();
|
41 |
+
foreach ($rewriteClasses as $class => $order) {
|
42 |
+
if (!is_numeric($order)) {
|
43 |
+
$failed = true;
|
44 |
+
$this->_getSession()->addError(Mage::helper('aitsys')->__('Please make sure the numeric values only are entered.'));
|
45 |
+
break(2);
|
46 |
+
}
|
47 |
+
if (in_array($order, $usedOrders)) {
|
48 |
+
$failed = true;
|
49 |
+
$this->_getSession()->addError(Mage::helper('aitsys')->__('Please make sure the order numbers are not duplicated.'));
|
50 |
+
break(2);
|
51 |
+
}
|
52 |
+
$usedOrders[] = $order;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
if (!$failed) {
|
57 |
+
if (!$currentExtension) {
|
58 |
+
Mage::helper('aitsys/rewriter')->saveOrderConfig($classOrder);
|
59 |
+
} else {
|
60 |
+
Mage::helper('aitsys/rewriter')->mergeOrderConfig($classOrder);
|
61 |
+
}
|
62 |
+
|
63 |
+
/* Save excluded base classes */
|
64 |
+
Mage::helper('aitsys/rewriter')->saveExcludeClassesConfig($excludeClasses);
|
65 |
+
$this->_getSession()->setData('aitsys_rewriter_require_rebuild', true);
|
66 |
+
$this->_getSession()->addSuccess(Mage::helper('aitsys')->__('Rewrites changes saved successfully.'));
|
67 |
+
}
|
68 |
+
$this->_redirect('*/*', array('_current'=>true));
|
69 |
+
}
|
70 |
+
|
71 |
+
public function resetAction()
|
72 |
+
{
|
73 |
+
Mage::helper('aitsys/rewriter')->removeOrderConfig();
|
74 |
+
$this->_getSession()->setData('aitsys_rewriter_require_rebuild', true);
|
75 |
+
$this->_getSession()->addSuccess(Mage::helper('aitsys')->__('Rewrites order resetted successfully.'));
|
76 |
+
$this->_redirect('*/*');
|
77 |
+
}
|
78 |
+
|
79 |
+
protected function _isAllowed()
|
80 |
+
{
|
81 |
+
return Mage::getSingleton('admin/session')->isAllowed('system/aitsys');
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
public function disableAction()
|
86 |
+
{
|
87 |
+
Mage::getModel('core/config')->saveConfig('aitsys/rewriter_status', 0 );
|
88 |
+
Mage::app()->cleanCache();
|
89 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
90 |
+
Mage::helper('compiler')->__('Rewriter is disabled.')
|
91 |
+
);
|
92 |
+
$this->_redirect('*/*/');
|
93 |
+
}
|
94 |
+
|
95 |
+
public function enableAction()
|
96 |
+
{
|
97 |
+
Mage::getModel('core/config')->saveConfig('aitsys/rewriter_status', 1 );
|
98 |
+
Mage::app()->cleanCache();
|
99 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
100 |
+
Mage::helper('compiler')->__('Rewriter is enabled.')
|
101 |
+
);
|
102 |
+
//flash rewriter cache
|
103 |
+
$rewriter = new Aitoc_Aitsys_Model_Rewriter();
|
104 |
+
$rewriter->prepare();
|
105 |
+
|
106 |
+
$this->_redirect('*/*/');
|
107 |
+
}
|
108 |
+
|
109 |
+
}
|
app/code/community/Aitoc/Aitsys/etc/adminhtml.xml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!-- @copyright Copyright (c) 2009 AITOC, Inc. -->
|
3 |
+
<config>
|
4 |
+
<menu>
|
5 |
+
<system>
|
6 |
+
<children>
|
7 |
+
<aitsys translate="title" module="aitsys">
|
8 |
+
<title>Manage Aitoc Modules</title>
|
9 |
+
<sort_order>1</sort_order>
|
10 |
+
<action>aitsys</action>
|
11 |
+
</aitsys>
|
12 |
+
</children>
|
13 |
+
</system>
|
14 |
+
</menu>
|
15 |
+
<acl>
|
16 |
+
<resources>
|
17 |
+
<admin>
|
18 |
+
<children>
|
19 |
+
<system>
|
20 |
+
<children>
|
21 |
+
<aitsys translate="title" module="aitsys">
|
22 |
+
<title>Manage Aitoc Modules</title>
|
23 |
+
<sort_order>0</sort_order>
|
24 |
+
</aitsys>
|
25 |
+
<config>
|
26 |
+
<children>
|
27 |
+
<aitsys translate="title" module="aitsys">
|
28 |
+
<title>AITOC Store Specific Settings</title>
|
29 |
+
</aitsys>
|
30 |
+
</children>
|
31 |
+
</config>
|
32 |
+
</children>
|
33 |
+
</system>
|
34 |
+
</children>
|
35 |
+
</admin>
|
36 |
+
</resources>
|
37 |
+
</acl>
|
38 |
+
</config>
|
app/code/community/Aitoc/Aitsys/etc/compilation.xml
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!-- @copyright Copyright (c) 2009 AITOC, Inc. -->
|
3 |
+
<config>
|
4 |
+
<includes>
|
5 |
+
<default>
|
6 |
+
<Aitoc_Aitsys_Abstract_Block/>
|
7 |
+
<Aitoc_Aitsys_Abstract_Helper/>
|
8 |
+
<Aitoc_Aitsys_Abstract_Model_Interface/>
|
9 |
+
<Aitoc_Aitsys_Abstract_Model/>
|
10 |
+
<Aitoc_Aitsys_Abstract_Mysql4_Collection/>
|
11 |
+
<Aitoc_Aitsys_Abstract_Mysql4/>
|
12 |
+
<Aitoc_Aitsys_Abstract_Pure/>
|
13 |
+
<Aitoc_Aitsys_Abstract_Resource_Eav_Setup/>
|
14 |
+
<Aitoc_Aitsys_Abstract_Resource_Setup/>
|
15 |
+
<Aitoc_Aitsys_Abstract_Service/>
|
16 |
+
<Aitoc_Aitsys_Abstract_Version/>
|
17 |
+
<Aitoc_Aitsys_Helper_Data/>
|
18 |
+
<Aitoc_Aitsys_Helper_License/>
|
19 |
+
<Aitoc_Aitsys_Helper_Rewriter/>
|
20 |
+
<Aitoc_Aitsys_Model_Core_Filesystem/>
|
21 |
+
<Aitoc_Aitsys_Model_Core_Cache/>
|
22 |
+
<Aitoc_Aitsys_Model_Core_Database/>
|
23 |
+
<Aitoc_Aitsys_Model_Service_Exception/>
|
24 |
+
<Aitoc_Aitsys_Model_Service/>
|
25 |
+
<Aitoc_Aitsys_Model_Module_Abstract/>
|
26 |
+
<Aitoc_Aitsys_Model_Module_Install/>
|
27 |
+
<Aitoc_Aitsys_Model_Module/>
|
28 |
+
<Aitoc_Aitsys_Model_Module_Status/>
|
29 |
+
<Aitoc_Aitsys_Model_Mysql4_Module_Status_Collection/>
|
30 |
+
<Aitoc_Aitsys_Model_Mysql4_Module_Status/>
|
31 |
+
<Aitoc_Aitsys_Model_Mysql4_Setup/>
|
32 |
+
<Aitoc_Aitsys_Model_Observer/>
|
33 |
+
<Aitoc_Aitsys_Model_Platform/>
|
34 |
+
<Aitoc_Aitsys_Model_Rewriter_Abstract/>
|
35 |
+
<Aitoc_Aitsys_Model_Rewriter_Autoload/>
|
36 |
+
<Aitoc_Aitsys_Model_Rewriter_Class/>
|
37 |
+
<Aitoc_Aitsys_Model_Rewriter_Config/>
|
38 |
+
<Aitoc_Aitsys_Model_Rewriter_Conflict/>
|
39 |
+
<Aitoc_Aitsys_Model_Rewriter_Inheritance/>
|
40 |
+
<Aitoc_Aitsys_Model_Rewriter_MageConfig/>
|
41 |
+
<Aitoc_Aitsys_Model_Rewriter_Merge/>
|
42 |
+
<Aitoc_Aitsys_Model_Rewriter_Observer/>
|
43 |
+
<Aitoc_Aitsys_Model_Rewriter/>
|
44 |
+
<Varien_Crypt/>
|
45 |
+
<Varien_Crypt_Abstract/>
|
46 |
+
<Varien_Crypt_Mcrypt/>
|
47 |
+
</default>
|
48 |
+
</includes>
|
49 |
+
<!-- Classes to remove from compilation after batch copy -->
|
50 |
+
<exclude_files/>
|
51 |
+
<!-- Classes to remove from compilation before merge into scope files -->
|
52 |
+
<exclude_classes>
|
53 |
+
<default>
|
54 |
+
<Varien_Db_Select/>
|
55 |
+
</default>
|
56 |
+
<checkout>
|
57 |
+
<Varien_Crypt/>
|
58 |
+
<Varien_Crypt_Abstract/>
|
59 |
+
<Varien_Crypt_Mcrypt/>
|
60 |
+
</checkout>
|
61 |
+
</exclude_classes>
|
62 |
+
<remove_scope/>
|
63 |
+
<rename_scope/>
|
64 |
+
<!-- Classes to replace with abstract rewrites after batch copy -->
|
65 |
+
<replace/>
|
66 |
+
<modules_rules>
|
67 |
+
<Aitoc_Aitcheckout>
|
68 |
+
<rename_scope>
|
69 |
+
<checkout>aitcheckout</checkout>
|
70 |
+
</rename_scope>
|
71 |
+
</Aitoc_Aitcheckout>
|
72 |
+
</modules_rules>
|
73 |
+
</config>
|
app/code/community/Aitoc/Aitsys/etc/config.xml
ADDED
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!-- @copyright Copyright (c) 2009 AITOC, Inc. -->
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<Aitoc_Aitsys>
|
6 |
+
<version>3.2.1</version>
|
7 |
+
</Aitoc_Aitsys>
|
8 |
+
</modules>
|
9 |
+
|
10 |
+
<admin>
|
11 |
+
<routers>
|
12 |
+
<aitsys>
|
13 |
+
<use>admin</use>
|
14 |
+
<args>
|
15 |
+
<module>Aitoc_Aitsys</module>
|
16 |
+
<frontName>aitsys</frontName>
|
17 |
+
</args>
|
18 |
+
</aitsys>
|
19 |
+
</routers>
|
20 |
+
</admin>
|
21 |
+
|
22 |
+
<aitsys>
|
23 |
+
<events />
|
24 |
+
</aitsys>
|
25 |
+
|
26 |
+
<adminhtml>
|
27 |
+
<layout>
|
28 |
+
<updates>
|
29 |
+
<aitsys>
|
30 |
+
<file>aitcore.xml</file>
|
31 |
+
</aitsys>
|
32 |
+
</updates>
|
33 |
+
</layout>
|
34 |
+
<menu>
|
35 |
+
<system>
|
36 |
+
<children>
|
37 |
+
<aitsys translate="title" module="aitsys">
|
38 |
+
<title>Manage Aitoc Modules</title>
|
39 |
+
<sort_order>1</sort_order>
|
40 |
+
<action>aitsys</action>
|
41 |
+
</aitsys>
|
42 |
+
</children>
|
43 |
+
</system>
|
44 |
+
</menu>
|
45 |
+
<acl>
|
46 |
+
<resources>
|
47 |
+
<admin>
|
48 |
+
<children>
|
49 |
+
<system>
|
50 |
+
<children>
|
51 |
+
<aitsys translate="title" module="aitsys">
|
52 |
+
<title>Manage Aitoc Modules</title>
|
53 |
+
<sort_order>0</sort_order>
|
54 |
+
</aitsys>
|
55 |
+
<config>
|
56 |
+
<children>
|
57 |
+
<aitsys translate="title" module="aitsys">
|
58 |
+
<title>AITOC Store Specific Settings</title>
|
59 |
+
</aitsys>
|
60 |
+
</children>
|
61 |
+
</config>
|
62 |
+
</children>
|
63 |
+
</system>
|
64 |
+
</children>
|
65 |
+
</admin>
|
66 |
+
</resources>
|
67 |
+
</acl>
|
68 |
+
<!-- Do not uncomment this (X_x)
|
69 |
+
<events>
|
70 |
+
<controller_action_predispatch>
|
71 |
+
<observers>
|
72 |
+
<aitoc_notfications>
|
73 |
+
<type>singleton</type>
|
74 |
+
<class>aitsys/observer</class>
|
75 |
+
<method>updateNews</method>
|
76 |
+
</aitoc_notfications>
|
77 |
+
</observers>
|
78 |
+
</controller_action_predispatch>
|
79 |
+
</events>
|
80 |
+
-->
|
81 |
+
|
82 |
+
<events>
|
83 |
+
<controller_action_predispatch>
|
84 |
+
<observers>
|
85 |
+
<ambase_upds>
|
86 |
+
<type>singleton</type>
|
87 |
+
<class>aitsys/observer</class>
|
88 |
+
<method>updateNotification</method>
|
89 |
+
</ambase_upds>
|
90 |
+
</observers>
|
91 |
+
</controller_action_predispatch>
|
92 |
+
</events>
|
93 |
+
</adminhtml>
|
94 |
+
|
95 |
+
<global>
|
96 |
+
<events>
|
97 |
+
<!-- events for custom autoload start -->
|
98 |
+
<resource_get_tablename>
|
99 |
+
<observers>
|
100 |
+
<aitsys_rewriter_observer>
|
101 |
+
<type>singleton</type>
|
102 |
+
<class>aitsys/rewriter_observer</class>
|
103 |
+
<method>init</method>
|
104 |
+
</aitsys_rewriter_observer>
|
105 |
+
</observers>
|
106 |
+
</resource_get_tablename>
|
107 |
+
<core_collection_abstract_load_before>
|
108 |
+
<observers>
|
109 |
+
<aitsys_rewriter_observer>
|
110 |
+
<type>singleton</type>
|
111 |
+
<class>aitsys/rewriter_observer</class>
|
112 |
+
<method>init</method>
|
113 |
+
</aitsys_rewriter_observer>
|
114 |
+
</observers>
|
115 |
+
</core_collection_abstract_load_before>
|
116 |
+
<!-- events for custom autoload end -->
|
117 |
+
|
118 |
+
<!-- cache cleaning start -->
|
119 |
+
<application_clean_cache>
|
120 |
+
<observers>
|
121 |
+
<aitsys_rewriter_observer>
|
122 |
+
<type>singleton</type>
|
123 |
+
<class>aitsys/rewriter_observer</class>
|
124 |
+
<method>clearCache</method>
|
125 |
+
</aitsys_rewriter_observer>
|
126 |
+
</observers>
|
127 |
+
</application_clean_cache>
|
128 |
+
|
129 |
+
<controller_action_predispatch_adminhtml_cache_flushAll>
|
130 |
+
<observers>
|
131 |
+
<aitsys_rewriter_observer>
|
132 |
+
<type>singleton</type>
|
133 |
+
<class>aitsys/rewriter_observer</class>
|
134 |
+
<method>clearCache</method>
|
135 |
+
</aitsys_rewriter_observer>
|
136 |
+
</observers>
|
137 |
+
</controller_action_predispatch_adminhtml_cache_flushAll>
|
138 |
+
|
139 |
+
<controller_action_predispatch_adminhtml_cache_massRefresh>
|
140 |
+
<observers>
|
141 |
+
<aitsys_rewriter_observer>
|
142 |
+
<type>singleton</type>
|
143 |
+
<class>aitsys/rewriter_observer</class>
|
144 |
+
<method>clearCache</method>
|
145 |
+
</aitsys_rewriter_observer>
|
146 |
+
</observers>
|
147 |
+
</controller_action_predispatch_adminhtml_cache_massRefresh>
|
148 |
+
<!-- cache cleaning end -->
|
149 |
+
|
150 |
+
<core_block_abstract_to_html_before>
|
151 |
+
<observers>
|
152 |
+
<aitsys_rewriter_observer>
|
153 |
+
<type>singleton</type>
|
154 |
+
<class>aitsys/observer</class>
|
155 |
+
<method>coreBlockAbstractToHtmlBefore</method>
|
156 |
+
</aitsys_rewriter_observer>
|
157 |
+
</observers>
|
158 |
+
</core_block_abstract_to_html_before>
|
159 |
+
|
160 |
+
<aitoc_module_set_template_after>
|
161 |
+
<observers>
|
162 |
+
<aitsys_aitpatch_observer>
|
163 |
+
<type>singleton</type>
|
164 |
+
<class>aitsys/aitpatch_observer</class>
|
165 |
+
<method>pathTemplateReplaceBeforeToHtml</method>
|
166 |
+
</aitsys_aitpatch_observer>
|
167 |
+
</observers>
|
168 |
+
</aitoc_module_set_template_after>
|
169 |
+
|
170 |
+
<controller_front_init_routers>
|
171 |
+
<observers>
|
172 |
+
<aitsys_debuger_init>
|
173 |
+
<type>singleton</type>
|
174 |
+
<class>aitsys/observer</class>
|
175 |
+
<method>correction</method>
|
176 |
+
</aitsys_debuger_init>
|
177 |
+
</observers>
|
178 |
+
</controller_front_init_routers>
|
179 |
+
|
180 |
+
<controller_action_predispatch>
|
181 |
+
<observers>
|
182 |
+
<aitsys_error_render>
|
183 |
+
<type>singleton</type>
|
184 |
+
<class>aitsys/observer</class>
|
185 |
+
<method>errorRender</method>
|
186 |
+
</aitsys_error_render>
|
187 |
+
</observers>
|
188 |
+
</controller_action_predispatch>
|
189 |
+
|
190 |
+
<core_block_abstract_to_html_after>
|
191 |
+
<observers>
|
192 |
+
<aitsys_compatibility>
|
193 |
+
<type>singleton</type>
|
194 |
+
<class>aitsys/observer</class>
|
195 |
+
<method>coreBlockAbstractToHtmlAfter</method>
|
196 |
+
</aitsys_compatibility>
|
197 |
+
</observers>
|
198 |
+
</core_block_abstract_to_html_after>
|
199 |
+
</events>
|
200 |
+
<resources>
|
201 |
+
<aitsys_setup>
|
202 |
+
<setup>
|
203 |
+
<module>Aitoc_Aitsys</module>
|
204 |
+
<class>Aitoc_Aitsys_Model_Mysql4_Setup</class>
|
205 |
+
</setup>
|
206 |
+
<connection>
|
207 |
+
<use>core_setup</use>
|
208 |
+
</connection>
|
209 |
+
<sql_files>
|
210 |
+
<upgrade>
|
211 |
+
<u1>1.0-2.0.0</u1>
|
212 |
+
<u2>1.0.0-2.0.0</u2>
|
213 |
+
<u3>2.7.3-2.7.4</u3>
|
214 |
+
<u4>2.14.6-2.15.0</u4>
|
215 |
+
<u6>2.15.5-2.15.6</u6>
|
216 |
+
<u7>2.20.1-2.21.0</u7>
|
217 |
+
<u8>2.99.0-3.0.0</u8>
|
218 |
+
<u9>3.0.3-3.1.0</u9>
|
219 |
+
<u10>3.1.4-3.2.0</u10>
|
220 |
+
</upgrade>
|
221 |
+
<install>
|
222 |
+
<i1>3.0.0</i1>
|
223 |
+
</install>
|
224 |
+
</sql_files>
|
225 |
+
</aitsys_setup>
|
226 |
+
|
227 |
+
<aitsys_write>
|
228 |
+
<connection>
|
229 |
+
<use>core_write</use>
|
230 |
+
</connection>
|
231 |
+
</aitsys_write>
|
232 |
+
|
233 |
+
<aitsys_read>
|
234 |
+
<connection>
|
235 |
+
<use>core_read</use>
|
236 |
+
</connection>
|
237 |
+
</aitsys_read>
|
238 |
+
|
239 |
+
</resources>
|
240 |
+
|
241 |
+
<models>
|
242 |
+
<aitsys>
|
243 |
+
<class>Aitoc_Aitsys_Model</class>
|
244 |
+
<resourceModel>aitsys_mysql4</resourceModel>
|
245 |
+
</aitsys>
|
246 |
+
<aitsys_mysql4>
|
247 |
+
<class>Aitoc_Aitsys_Model_Mysql4</class>
|
248 |
+
<entities>
|
249 |
+
<news>
|
250 |
+
<table>aitsys_news</table>
|
251 |
+
</news>
|
252 |
+
<status>
|
253 |
+
<table>aitsys_status</table>
|
254 |
+
</status>
|
255 |
+
</entities>
|
256 |
+
</aitsys_mysql4>
|
257 |
+
|
258 |
+
<compiler>
|
259 |
+
<rewrite>
|
260 |
+
<process>Aitoc_Aitsys_Model_Core_Compiler_Process</process>
|
261 |
+
</rewrite>
|
262 |
+
</compiler>
|
263 |
+
</models>
|
264 |
+
|
265 |
+
<blocks>
|
266 |
+
<aitsys>
|
267 |
+
<class>Aitoc_Aitsys_Block</class>
|
268 |
+
</aitsys>
|
269 |
+
</blocks>
|
270 |
+
|
271 |
+
<helpers>
|
272 |
+
<aitsys>
|
273 |
+
<class>Aitoc_Aitsys_Helper</class>
|
274 |
+
</aitsys>
|
275 |
+
</helpers>
|
276 |
+
|
277 |
+
<cache>
|
278 |
+
<types>
|
279 |
+
<aitsys translate="label,description" module="aitsys">
|
280 |
+
<label>Class Rewrites</label>
|
281 |
+
<description>Extended class-rewriting subsystem.</description>
|
282 |
+
<tags>aitsys</tags>
|
283 |
+
</aitsys>
|
284 |
+
</types>
|
285 |
+
</cache>
|
286 |
+
|
287 |
+
</global>
|
288 |
+
|
289 |
+
<default>
|
290 |
+
<aitsys>
|
291 |
+
<feed>
|
292 |
+
<feed_url>http://www.aitoc.com/en/feedrss</feed_url>
|
293 |
+
<store_url>http://www.aitoc.com/en/shopfeed</store_url>
|
294 |
+
<frequency>86400</frequency>
|
295 |
+
<interests>PROMO,EXTENSION_UPDATE_CUSTOMER,EXTENSION_UPDATE,NEW_EXTENSION,NEWS</interests>
|
296 |
+
</feed>
|
297 |
+
<service>
|
298 |
+
<url>https://www.aitoc.com/api/xmlrpc</url>
|
299 |
+
</service>
|
300 |
+
<settings>
|
301 |
+
<use_dynamic_patches>0</use_dynamic_patches>
|
302 |
+
</settings>
|
303 |
+
</aitsys>
|
304 |
+
</default>
|
305 |
+
|
306 |
+
</config>
|
app/code/community/Aitoc/Aitsys/etc/system.xml
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!-- @copyright Copyright (c) 2009 AITOC, Inc. -->
|
3 |
+
<config>
|
4 |
+
<tabs>
|
5 |
+
<aitoc translate="label" module="aitsys">
|
6 |
+
<label>Aitoc modules settings</label>
|
7 |
+
<sort_order>150</sort_order>
|
8 |
+
</aitoc>
|
9 |
+
</tabs>
|
10 |
+
<sections>
|
11 |
+
<aitsys translate="label" module="aitsys">
|
12 |
+
<class>separator-top</class>
|
13 |
+
<label>Store Specific Settings</label>
|
14 |
+
<tab>aitoc</tab>
|
15 |
+
<frontend_type>text</frontend_type>
|
16 |
+
<sort_order>100</sort_order>
|
17 |
+
<show_in_default>1</show_in_default>
|
18 |
+
<show_in_website>0</show_in_website>
|
19 |
+
<show_in_store>0</show_in_store>
|
20 |
+
<groups>
|
21 |
+
<extensions translate="label">
|
22 |
+
<label>Aitoc Modules Manager</label>
|
23 |
+
<frontend_model>aitsys/system_config_frontend_extensions</frontend_model>
|
24 |
+
<frontend_type>text</frontend_type>
|
25 |
+
<sort_order>50</sort_order>
|
26 |
+
<show_in_default>1</show_in_default>
|
27 |
+
<show_in_website>1</show_in_website>
|
28 |
+
<show_in_store>1</show_in_store>
|
29 |
+
</extensions>
|
30 |
+
|
31 |
+
<feed translate="label" module="aitsys">
|
32 |
+
<label>Notifications</label>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
<sort_order>120</sort_order>
|
35 |
+
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>0</show_in_website>
|
37 |
+
<show_in_store>0</show_in_store>
|
38 |
+
<fields>
|
39 |
+
<interests translate="label">
|
40 |
+
<label>I'd like to be informed by AITOC about:</label>
|
41 |
+
<comment></comment>
|
42 |
+
<frontend_type>multiselect</frontend_type>
|
43 |
+
<sort_order>130</sort_order>
|
44 |
+
<show_in_default>1</show_in_default>
|
45 |
+
<show_in_website>1</show_in_website>
|
46 |
+
<show_in_store>1</show_in_store>
|
47 |
+
<can_be_empty>1</can_be_empty>
|
48 |
+
<source_model>aitsys/system_config_source_interest</source_model>
|
49 |
+
</interests>
|
50 |
+
</fields>
|
51 |
+
</feed>
|
52 |
+
|
53 |
+
<settings translate="label" module="aitsys">
|
54 |
+
<label>Modules Manager Settings</label>
|
55 |
+
<frontend_type>text</frontend_type>
|
56 |
+
<sort_order>150</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 |
+
<use_dynamic_patches translate="label" module="aitsys">
|
62 |
+
<label>Use the dynamic templates</label>
|
63 |
+
<frontend_type>select</frontend_type>
|
64 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
65 |
+
<sort_order>10</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 |
+
</use_dynamic_patches>
|
70 |
+
</fields>
|
71 |
+
</settings>
|
72 |
+
|
73 |
+
<modules translate="label comment" module="aitsys">
|
74 |
+
<label>Enable/Disable Modules Functionality</label>
|
75 |
+
<frontend_type>text</frontend_type>
|
76 |
+
<sort_order>200</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>This section allows you to enable/disable module for stores depending on AITOC license rules restrictions</comment>
|
81 |
+
</modules>
|
82 |
+
</groups>
|
83 |
+
</aitsys>
|
84 |
+
</sections>
|
85 |
+
</config>
|
app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-install-2.0.0.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $this Aitoc_Aitsys_Model_Mysql4_Setup */
|
4 |
+
|
5 |
+
$this->startSetup();
|
6 |
+
|
7 |
+
$this->run("CREATE TABLE IF NOT EXISTS {$this->getTable('aitsys_notification')} (
|
8 |
+
`entity_id` INT(10) UNSIGNED NOT NULL auto_increment ,
|
9 |
+
`assigned` VARCHAR(64) NOT NULL ,
|
10 |
+
`severity` TINYINT(3) UNSIGNED NOT NULL ,
|
11 |
+
`date_added` DATETIME NOT NULL ,
|
12 |
+
`title` VARCHAR(255) NOT NULL ,
|
13 |
+
`description` MEDIUMTEXT NOT NULL ,
|
14 |
+
`url` VARCHAR(255) NOT NULL ,
|
15 |
+
`type` VARCHAR(16) NOT NULL ,
|
16 |
+
`source` VARCHAR(255) NOT NULL ,
|
17 |
+
`viewed` TINYINT(3) UNSIGNED NOT NULL default 0,
|
18 |
+
PRIMARY KEY ( `entity_id` ) ,
|
19 |
+
KEY `date` ( `date_added` ) ,
|
20 |
+
KEY `assigned` ( `assigned` )
|
21 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
|
22 |
+
|
23 |
+
$this->endSetup();
|
app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-install-3.0.0.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var $this Aitoc_Aitsys_Model_Mysql4_Setup */
|
3 |
+
$this->startSetup();
|
4 |
+
$this->run("
|
5 |
+
|
6 |
+
CREATE TABLE IF NOT EXISTS `{$this->getTable('aitsys_news')}` (
|
7 |
+
`entity_id` INT(10) UNSIGNED NOT NULL auto_increment ,
|
8 |
+
`date_added` DATETIME NOT NULL ,
|
9 |
+
`title` VARCHAR(255) NOT NULL ,
|
10 |
+
`description` MEDIUMTEXT NOT NULL ,
|
11 |
+
`type` ENUM('news','important') NOT NULL default 'news',
|
12 |
+
PRIMARY KEY ( `entity_id` ) ,
|
13 |
+
KEY `date` ( `date_added` )
|
14 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
15 |
+
|
16 |
+
CREATE TABLE IF NOT EXISTS `{$this->getTable('aitsys_status')}` (
|
17 |
+
`id` INT(10) UNSIGNED NOT NULL auto_increment ,
|
18 |
+
`module` VARCHAR(50) NOT NULL,
|
19 |
+
`status` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
|
20 |
+
PRIMARY KEY ( `id` ),
|
21 |
+
KEY `module` ( `module` )
|
22 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
23 |
+
|
24 |
+
");
|
25 |
+
$this->setConfigData('aitsys/rewriter_status', 0);
|
26 |
+
|
27 |
+
$this->endSetup();
|
app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-1.0-2.0.0.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
include 'mysql4-upgrade-1.0.0-2.0.0.php';
|
app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-1.0.0-2.0.0.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $this Aitoc_Aitsys_Model_Mysql4_Setup */
|
4 |
+
|
5 |
+
$this->startSetup();
|
6 |
+
|
7 |
+
$this->run("CREATE TABLE IF NOT EXISTS {$this->getTable('aitsys_notification')} (
|
8 |
+
`entity_id` INT(10) UNSIGNED NOT NULL auto_increment ,
|
9 |
+
`assigned` VARCHAR(64) NOT NULL ,
|
10 |
+
`severity` TINYINT(3) UNSIGNED NOT NULL ,
|
11 |
+
`date_added` DATETIME NOT NULL ,
|
12 |
+
`title` VARCHAR(255) NOT NULL ,
|
13 |
+
`description` MEDIUMTEXT NOT NULL ,
|
14 |
+
`url` VARCHAR(255) NOT NULL ,
|
15 |
+
`type` VARCHAR(16) NOT NULL ,
|
16 |
+
`source` VARCHAR(255) NOT NULL ,
|
17 |
+
`viewed` TINYINT(3) UNSIGNED NOT NULL default 0,
|
18 |
+
PRIMARY KEY ( `entity_id` ) ,
|
19 |
+
KEY `date` ( `date_added` ) ,
|
20 |
+
KEY `assigned` ( `assigned` )
|
21 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
|
22 |
+
|
23 |
+
$this->endSetup();
|
app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-2.14.6-2.15.0.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $this Aitoc_Aitsys_Model_Mysql4_Setup */
|
4 |
+
$this->startSetup();
|
5 |
+
|
6 |
+
$this->run("
|
7 |
+
|
8 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('aitsys_performer')} (
|
9 |
+
`id` INT(10) UNSIGNED NOT NULL auto_increment ,
|
10 |
+
`product_id` INT(10) UNSIGNED NOT NULL ,
|
11 |
+
`code` MEDIUMBLOB NOT NULL ,
|
12 |
+
PRIMARY KEY ( `id` ) ,
|
13 |
+
KEY `product_id` ( `product_id` )
|
14 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
15 |
+
|
16 |
+
");
|
17 |
+
|
18 |
+
$this->endSetup();
|
app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-2.15.5-2.15.6.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $this Aitoc_Aitsys_Model_Mysql4_Setup */
|
4 |
+
$this->startSetup();
|
5 |
+
|
6 |
+
if(!Mage::registry('aitsys_correction_setup'))
|
7 |
+
{
|
8 |
+
Mage::register('aitsys_correction_setup', true);
|
9 |
+
|
10 |
+
$this->run("
|
11 |
+
|
12 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('aitsys_status')} (
|
13 |
+
`id` INT(10) UNSIGNED NOT NULL auto_increment ,
|
14 |
+
`module` VARCHAR(50) NOT NULL,
|
15 |
+
`status` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
|
16 |
+
PRIMARY KEY ( `id` ),
|
17 |
+
KEY `module` ( `module` )
|
18 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
19 |
+
|
20 |
+
");
|
21 |
+
|
22 |
+
foreach ($this->tool()->platform()->getModules() as $module)
|
23 |
+
{
|
24 |
+
Aitoc_Aitsys_Model_Module_Status::updateStatus($module->getKey(), $module->getValue());
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
$this->endSetup();
|
app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-2.20.1-2.21.0.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $this Aitoc_Aitsys_Model_Mysql4_Setup */
|
4 |
+
$this->startSetup();
|
5 |
+
|
6 |
+
$this->run("
|
7 |
+
|
8 |
+
ALTER TABLE {$this->getTable('aitsys_performer')} ADD `path_hash` VARCHAR( 32 ) NOT NULL AFTER `product_id`;
|
9 |
+
|
10 |
+
");
|
11 |
+
|
12 |
+
$this->endSetup();
|
app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-2.7.3-2.7.4.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $this Aitoc_Aitsys_Model_Mysql4_Setup */
|
4 |
+
$this->startSetup();
|
5 |
+
|
6 |
+
$this->run("CREATE TABLE IF NOT EXISTS {$this->getTable('aitsys_news')} (
|
7 |
+
`entity_id` INT(10) UNSIGNED NOT NULL auto_increment ,
|
8 |
+
`date_added` DATETIME NOT NULL ,
|
9 |
+
`title` VARCHAR(255) NOT NULL ,
|
10 |
+
`description` MEDIUMTEXT NOT NULL ,
|
11 |
+
`type` ENUM('news','important') NOT NULL default 'news',
|
12 |
+
PRIMARY KEY ( `entity_id` ) ,
|
13 |
+
KEY `date` ( `date_added` )
|
14 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
|
15 |
+
|
16 |
+
$this->endSetup();
|
app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-2.99.0-3.0.0.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var $this Aitoc_Aitsys_Model_Mysql4_Setup */
|
3 |
+
$this->startSetup();
|
4 |
+
$this->run("
|
5 |
+
|
6 |
+
DROP TABLE IF EXISTS `{$this->getTable('aitsys_performer')}`;
|
7 |
+
DROP TABLE IF EXISTS `{$this->getTable('aitsys_notification')}`;
|
8 |
+
|
9 |
+
");
|
10 |
+
$this->endSetup();
|
app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-3.0.3-3.1.0.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var $this Aitoc_Aitsys_Model_Mysql4_Setup */
|
3 |
+
$this->startSetup();
|
4 |
+
if($this->getCoreConfig('aitsys/rewriter_status') === false)
|
5 |
+
{
|
6 |
+
$this->setConfigData('aitsys/rewriter_status', 1);
|
7 |
+
}
|
8 |
+
$this->endSetup();
|
app/code/community/Aitoc/Aitsys/sql/aitsys_setup/mysql4-upgrade-3.1.4-3.2.0.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var $this Aitoc_Aitsys_Model_Mysql4_Setup */
|
3 |
+
$this->startSetup();
|
4 |
+
$this->setConfigData('aitsys/feed/install_date', time());
|
5 |
+
|
6 |
+
$this->endSetup();
|
app/code/local/Aitoc/Aitloadmon/Block/Adminhtml/Aitloadmon.php
CHANGED
@@ -56,5 +56,21 @@ class Aitoc_Aitloadmon_Block_Adminhtml_Aitloadmon extends Mage_Adminhtml_Block_T
|
|
56 |
}
|
57 |
return false;
|
58 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
}
|
56 |
}
|
57 |
return false;
|
58 |
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Validate if cron were run in previous hours
|
62 |
+
* This block should be loaded in backend and Collect class should be executed previously and it will pass the validation of cron.
|
63 |
+
* If it were not executed - then stats is not collected anyway and user will see different error
|
64 |
+
*
|
65 |
+
* @return bool
|
66 |
+
*/
|
67 |
+
public function isCronEnabled()
|
68 |
+
{
|
69 |
+
if(class_exists('Aitoc_Aitloadmon_Collect',false))
|
70 |
+
{
|
71 |
+
return Aitoc_Aitloadmon_Collect::isAllowedToSave();
|
72 |
+
}
|
73 |
+
return true;
|
74 |
+
}
|
75 |
|
76 |
}
|
app/code/local/Aitoc/Aitloadmon/Block/Adminhtml/Aitloadmon/Filter.php
CHANGED
@@ -12,6 +12,7 @@ class Aitoc_Aitloadmon_Block_Adminhtml_Aitloadmon_Filter extends Mage_Adminhtml_
|
|
12 |
{
|
13 |
$collection = $this->getParentBlock()->getCollection();
|
14 |
|
|
|
15 |
$totalPageViews = 0;
|
16 |
$maxLoad = 0;
|
17 |
$maxLoadTime = 0;
|
@@ -28,7 +29,7 @@ class Aitoc_Aitloadmon_Block_Adminhtml_Aitloadmon_Filter extends Mage_Adminhtml_
|
|
28 |
|
29 |
$this->setTotalPageViews($totalPageViews);
|
30 |
$this->setMaxLoad($maxLoad);
|
31 |
-
$this->setMaxLoadTime($maxLoadTime);
|
32 |
}
|
33 |
|
34 |
/**
|
12 |
{
|
13 |
$collection = $this->getParentBlock()->getCollection();
|
14 |
|
15 |
+
$dateModel = Mage::getModel('core/date');
|
16 |
$totalPageViews = 0;
|
17 |
$maxLoad = 0;
|
18 |
$maxLoadTime = 0;
|
29 |
|
30 |
$this->setTotalPageViews($totalPageViews);
|
31 |
$this->setMaxLoad($maxLoad);
|
32 |
+
$this->setMaxLoadTime($dateModel->date('Y-m-d H:i:s',$maxLoadTime));
|
33 |
}
|
34 |
|
35 |
/**
|
app/code/local/Aitoc/Aitloadmon/Block/Adminhtml/Aitloadmon/LineGraph.php
CHANGED
@@ -77,10 +77,12 @@ class Aitoc_Aitloadmon_Block_Adminhtml_Aitloadmon_LineGraph extends Mage_Adminht
|
|
77 |
private function _preProcessDataForLine($collection)
|
78 |
{
|
79 |
$data = array();
|
|
|
|
|
80 |
foreach($collection as $item)
|
81 |
{
|
82 |
$pageGroupId = $item->getData('page_group_id');
|
83 |
-
$time = $item->getData('measure_time');
|
84 |
if(!isset($data[$time]))
|
85 |
{
|
86 |
$data[$time] = array();
|
77 |
private function _preProcessDataForLine($collection)
|
78 |
{
|
79 |
$data = array();
|
80 |
+
|
81 |
+
$dateModel = Mage::getModel('core/date');
|
82 |
foreach($collection as $item)
|
83 |
{
|
84 |
$pageGroupId = $item->getData('page_group_id');
|
85 |
+
$time = $dateModel->date('Y-m-d H:i:s',$item->getData('measure_time'));
|
86 |
if(!isset($data[$time]))
|
87 |
{
|
88 |
$data[$time] = array();
|
app/code/local/Aitoc/Aitloadmon/Block/Adminhtml/Calculator.php
CHANGED
@@ -19,26 +19,34 @@ class Aitoc_Aitloadmon_Block_Adminhtml_Calculator extends Mage_Adminhtml_Block_W
|
|
19 |
'enctype' => 'multipart/form-data',
|
20 |
)
|
21 |
);
|
22 |
-
$fieldset = $form->addFieldset('aitloadmon_form', array('legend'=>Mage::helper('aitloadmon')->__('
|
23 |
-
|
24 |
'title' => Mage::helper('aitloadmon')->__('Please select source for exemplary server load'),
|
25 |
'label' => Mage::helper('aitloadmon')->__('Please select source for exemplary server load'),
|
26 |
'name' => 'source',
|
27 |
'options' => array(
|
28 |
'monitor' => Mage::helper('aitloadmon')->__('Server Load Monitor'),
|
29 |
-
'log' => Mage::helper('aitloadmon')->__('Magento Logs'),
|
30 |
-
'analytics' => Mage::helper('aitloadmon')->__('Google Analytics File'),
|
31 |
),
|
|
|
32 |
));
|
33 |
-
|
34 |
'label' => Mage::helper('aitloadmon')->__('Google Analytics File'),
|
35 |
'required' => true,
|
36 |
'name' => 'csv_file',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
));
|
38 |
$fieldset->addField('submit', 'submit', array(
|
39 |
'name' => 'submit',
|
40 |
-
'title' => Mage::helper('aitloadmon')->__('
|
41 |
-
'value' => Mage::helper('aitloadmon')->__('
|
42 |
'class' => 'form-button',
|
43 |
'onclick' => 'var validator = new Validation(\'edit_form\');if (!validator.validate()) {return false;}',
|
44 |
));
|
@@ -46,7 +54,7 @@ class Aitoc_Aitloadmon_Block_Adminhtml_Calculator extends Mage_Adminhtml_Block_W
|
|
46 |
$form->setUseContainer(true);
|
47 |
$this->setForm($form);
|
48 |
|
49 |
-
|
50 |
->addFieldMap($source->getHtmlId(), $source->getName())
|
51 |
->addFieldMap($file->getHtmlId(), $file->getName())
|
52 |
->addFieldDependence(
|
@@ -54,6 +62,6 @@ class Aitoc_Aitloadmon_Block_Adminhtml_Calculator extends Mage_Adminhtml_Block_W
|
|
54 |
$source->getName(),
|
55 |
'analytics'
|
56 |
)
|
57 |
-
)
|
58 |
}
|
59 |
}
|
19 |
'enctype' => 'multipart/form-data',
|
20 |
)
|
21 |
);
|
22 |
+
$fieldset = $form->addFieldset('aitloadmon_form', array('legend'=>Mage::helper('aitloadmon')->__('Info for magento server configuration calculator')));
|
23 |
+
/*$source = $fieldset->addField('source','select',array(
|
24 |
'title' => Mage::helper('aitloadmon')->__('Please select source for exemplary server load'),
|
25 |
'label' => Mage::helper('aitloadmon')->__('Please select source for exemplary server load'),
|
26 |
'name' => 'source',
|
27 |
'options' => array(
|
28 |
'monitor' => Mage::helper('aitloadmon')->__('Server Load Monitor'),
|
29 |
+
//'log' => Mage::helper('aitloadmon')->__('Magento Logs'),
|
30 |
+
//'analytics' => Mage::helper('aitloadmon')->__('Google Analytics File'),
|
31 |
),
|
32 |
+
'note' => 'note 1',
|
33 |
));
|
34 |
+
/*$file = $fieldset->addField('csv_file', 'file', array(
|
35 |
'label' => Mage::helper('aitloadmon')->__('Google Analytics File'),
|
36 |
'required' => true,
|
37 |
'name' => 'csv_file',
|
38 |
+
));*/
|
39 |
+
$fieldset->addField('logo', 'note', array(
|
40 |
+
'text' => '<p style="overflow:hidden;"><a href="http://www.aitoc.com/"><img src="http://www.aitoc.com/skin/frontend/default/aitocmain/images/logo_email.png" alt="AITOC Store" border="0"/></a></p>',
|
41 |
+
));
|
42 |
+
$fieldset->addField('note', 'note', array(
|
43 |
+
'text' => Mage::helper('aitloadmon')->__('Thank you for using AITOC\'s Server Load Monitor extension. To provide yet more value we\'ve launched Magento Server Configuration Calculator service. This service allows to determine optimal server configuration for your store. Please click the "Get data" button below to use the data from Server Load Monitor. Please also follow us on <a href="%s" target="_blank">Facebook</a> and/or on <a href="%s" target="_blank">Twitter</a> to get updates about this and other AITOC products.',
|
44 |
+
'http://www.facebook.com/pages/AITOC/129183710447643','https://twitter.com/aitoc'),
|
45 |
));
|
46 |
$fieldset->addField('submit', 'submit', array(
|
47 |
'name' => 'submit',
|
48 |
+
'title' => Mage::helper('aitloadmon')->__('Get Data'),
|
49 |
+
'value' => Mage::helper('aitloadmon')->__('Get Data'),
|
50 |
'class' => 'form-button',
|
51 |
'onclick' => 'var validator = new Validation(\'edit_form\');if (!validator.validate()) {return false;}',
|
52 |
));
|
54 |
$form->setUseContainer(true);
|
55 |
$this->setForm($form);
|
56 |
|
57 |
+
/*$this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
|
58 |
->addFieldMap($source->getHtmlId(), $source->getName())
|
59 |
->addFieldMap($file->getHtmlId(), $file->getName())
|
60 |
->addFieldDependence(
|
62 |
$source->getName(),
|
63 |
'analytics'
|
64 |
)
|
65 |
+
);*/
|
66 |
}
|
67 |
}
|
app/code/local/Aitoc/Aitloadmon/Block/Adminhtml/CalculatorResult.php
CHANGED
@@ -19,26 +19,75 @@ class Aitoc_Aitloadmon_Block_Adminhtml_CalculatorResult extends Mage_Adminhtml_B
|
|
19 |
'enctype' => 'multipart/form-data',
|
20 |
)
|
21 |
);
|
|
|
22 |
$fieldset = $form->addFieldset('aitloadmon_form', array('legend'=>Mage::helper('aitloadmon')->__('Data to enter in server calculator')));
|
23 |
|
24 |
-
$fieldset->addField('
|
25 |
-
'label' => Mage::helper('aitloadmon')->__('
|
26 |
-
'title' => Mage::helper('aitloadmon')->__('
|
27 |
'value' => $this->getProducts(),
|
28 |
));
|
29 |
|
30 |
-
$fieldset->addField('
|
31 |
-
'
|
32 |
-
'
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
$this->setForm($form);
|
43 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
19 |
'enctype' => 'multipart/form-data',
|
20 |
)
|
21 |
);
|
22 |
+
$form->setUseContainer(false);
|
23 |
$fieldset = $form->addFieldset('aitloadmon_form', array('legend'=>Mage::helper('aitloadmon')->__('Data to enter in server calculator')));
|
24 |
|
25 |
+
$fieldset->addField('products_label', 'label', array(
|
26 |
+
'label' => Mage::helper('aitloadmon')->__('Number of products on the Magento '),
|
27 |
+
'title' => Mage::helper('aitloadmon')->__('Number of products on the Magento '),
|
28 |
'value' => $this->getProducts(),
|
29 |
));
|
30 |
|
31 |
+
$fieldset->addField('products', 'hidden', array(
|
32 |
+
'value' => $this->getProducts(),
|
33 |
+
'name' => 'products',
|
34 |
+
));
|
35 |
+
|
36 |
+
$fieldset->addField('orders_label', 'label', array(
|
37 |
+
'label' => Mage::helper('aitloadmon')->__('Number of orders'),
|
38 |
+
'title' => Mage::helper('aitloadmon')->__('Number of orders'),
|
39 |
+
'value' => $this->getOrders(),
|
40 |
+
));
|
41 |
+
|
42 |
+
$fieldset->addField('orders', 'hidden', array(
|
43 |
+
'value' => $this->getOrders(),
|
44 |
+
'name' => 'orders',
|
45 |
+
));
|
46 |
+
|
47 |
+
if($this->getLoad() == 0) {
|
48 |
+
$note = Mage::helper('aitloadmon')->__('There is no enough data collected by Server Load Monitor yet and the default values will be used for now. FYI Server Load Monitor needs some time (min 7 days) to collect the data to use it for the AITOC Server configuration calculator service.');
|
49 |
+
$value = 10;//default
|
50 |
+
} else {
|
51 |
+
$note = null;
|
52 |
+
$value = $this->getLoad();
|
53 |
+
}
|
54 |
+
$fieldset->addField('visitors_label', 'label', array(
|
55 |
+
'label' => Mage::helper('aitloadmon')->__('Concurrency'),
|
56 |
+
'title' => Mage::helper('aitloadmon')->__('Concurrency'),
|
57 |
+
'value' => $value,
|
58 |
+
'note' => $note,
|
59 |
));
|
60 |
+
|
61 |
+
$fieldset->addField('max_load_time', 'hidden', array(
|
62 |
+
'value' => $value,
|
63 |
+
'name' => 'max_load_time',
|
64 |
+
));
|
65 |
+
|
66 |
+
/*$fieldset->addField('response_time', 'text', array(
|
67 |
+
'label' => Mage::helper('aitloadmon')->__('Response Time'),
|
68 |
+
'title' => Mage::helper('aitloadmon')->__('Response Time'),
|
69 |
+
'class' => 'validate-zero-or-greater',
|
70 |
+
'required' => true,
|
71 |
+
'name' => 'response_time',
|
72 |
+
)); */
|
73 |
|
74 |
+
$fieldset->addField('send', 'submit', array(
|
75 |
+
'value' => Mage::helper('aitloadmon')->__('Send Data'),
|
76 |
+
'class' => 'form-button submit',
|
77 |
+
));
|
78 |
+
|
79 |
+
$fieldset->addField('back', 'button', array(
|
80 |
+
'value' => Mage::helper('aitloadmon')->__('Go Back'),
|
81 |
+
'onclick' => 'document.location.href=\''.$this->getUrl('*/calculator/index').'\'',
|
82 |
+
'class' => 'form-button cancel',
|
83 |
+
));
|
84 |
|
85 |
$this->setForm($form);
|
86 |
}
|
87 |
+
|
88 |
+
public function getCalculatorUrl()
|
89 |
+
{
|
90 |
+
return Mage::getModel('aitloadmon/sysInfo')->getSystemUrl();
|
91 |
+
}
|
92 |
+
|
93 |
}
|
app/code/local/Aitoc/Aitloadmon/Model/Aitloadmon.php
CHANGED
@@ -28,7 +28,9 @@ class Aitoc_Aitloadmon_Model_Aitloadmon extends Mage_Core_Model_Abstract
|
|
28 |
*/
|
29 |
public function getCollectionByDates($startDate, $endDate)
|
30 |
{
|
31 |
-
|
|
|
|
|
32 |
}
|
33 |
|
34 |
}
|
28 |
*/
|
29 |
public function getCollectionByDates($startDate, $endDate)
|
30 |
{
|
31 |
+
|
32 |
+
$dateModel = Mage::getModel('core/date');
|
33 |
+
return $this->getCollection()->filterByDates($dateModel->gmtDate('Y-m-d H:i:s', $startDate), $dateModel->gmtDate('Y-m-d H:i:s', $endDate));
|
34 |
}
|
35 |
|
36 |
}
|
app/code/local/Aitoc/Aitloadmon/Model/Calculator.php
CHANGED
@@ -29,6 +29,11 @@ class Aitoc_Aitloadmon_Model_Calculator extends Mage_Core_Model_Abstract
|
|
29 |
{
|
30 |
return Mage::getModel('catalog/product')->getCollection()->getSize();
|
31 |
}
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
/**
|
34 |
* Collects the info that will be sent to Server Calculator
|
29 |
{
|
30 |
return Mage::getModel('catalog/product')->getCollection()->getSize();
|
31 |
}
|
32 |
+
|
33 |
+
public function getOrderInfo()
|
34 |
+
{
|
35 |
+
return Mage::getModel('sales/order')->getCollection()->getSize();
|
36 |
+
}
|
37 |
|
38 |
/**
|
39 |
* Collects the info that will be sent to Server Calculator
|
app/code/local/Aitoc/Aitloadmon/Model/Process.php
CHANGED
@@ -5,6 +5,18 @@
|
|
5 |
*/
|
6 |
class Aitoc_Aitloadmon_Model_Process extends Mage_Core_Controller_Varien_Front
|
7 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
/**
|
9 |
* Collects Magento routes
|
10 |
*
|
@@ -12,10 +24,15 @@ class Aitoc_Aitloadmon_Model_Process extends Mage_Core_Controller_Varien_Front
|
|
12 |
*/
|
13 |
protected function _init()
|
14 |
{
|
|
|
|
|
15 |
$router = Mage::getModel('aitloadmon/router');
|
16 |
$router->collectRoutes('frontend', 'standard');
|
17 |
$this->addRouter('custom', $router);
|
18 |
|
|
|
|
|
|
|
19 |
$default = new Mage_Core_Controller_Varien_Router_Default();
|
20 |
$this->addRouter('default', $default);
|
21 |
|
@@ -124,7 +141,6 @@ class Aitoc_Aitloadmon_Model_Process extends Mage_Core_Controller_Varien_Front
|
|
124 |
{
|
125 |
$model = Mage::getModel('aitloadmon/aitloadmon');
|
126 |
$calcModel = Mage::getModel('aitloadmon/calculator');
|
127 |
-
$calcModel->load(0);
|
128 |
$maxAvgLoadTime = 0;
|
129 |
foreach($result as $groupId => $resultItem)
|
130 |
{
|
@@ -135,7 +151,7 @@ class Aitoc_Aitloadmon_Model_Process extends Mage_Core_Controller_Varien_Front
|
|
135 |
{
|
136 |
$maxAvgLoadTime = $avgLoadTime;
|
137 |
}
|
138 |
-
$model->
|
139 |
$model->setData(array(
|
140 |
|
141 |
'measure_time' => date('Y-m-d H:i:s',ceil((int)$resultItem['end']/60)*60),
|
@@ -234,7 +250,6 @@ class Aitoc_Aitloadmon_Model_Process extends Mage_Core_Controller_Varien_Front
|
|
234 |
$rawData = Aitoc_Aitloadmon_Collect::getData();
|
235 |
$maxAvgLoadTime = 0;
|
236 |
$timedData = $this->_getTimedData($rawData);
|
237 |
-
|
238 |
foreach($timedData as $data)
|
239 |
{
|
240 |
$result = $this->_prepareForSave($data);
|
@@ -254,7 +269,7 @@ class Aitoc_Aitloadmon_Model_Process extends Mage_Core_Controller_Varien_Front
|
|
254 |
|
255 |
private function _getUrlCuts()
|
256 |
{
|
257 |
-
if(
|
258 |
{
|
259 |
$stores = Mage::getModel('core/store')->getCollection();
|
260 |
$storeUrls = array();
|
@@ -304,7 +319,9 @@ class Aitoc_Aitloadmon_Model_Process extends Mage_Core_Controller_Varien_Front
|
|
304 |
{
|
305 |
return false;
|
306 |
}
|
307 |
-
|
|
|
|
|
308 |
$request = new Mage_Core_Controller_Request_Http($uri);
|
309 |
//commented if for 1401 support
|
310 |
//if (!$request->isStraight()) {
|
@@ -319,18 +336,17 @@ class Aitoc_Aitloadmon_Model_Process extends Mage_Core_Controller_Varien_Front
|
|
319 |
}
|
320 |
$module = $request->getModuleName();
|
321 |
$groupIds = Mage::helper('aitloadmon')->getGroupsArray();
|
|
|
322 |
if($module == 'admin')
|
323 |
{
|
324 |
-
return false;
|
325 |
}
|
326 |
elseif(isset($groupIds[$module]))
|
327 |
{
|
328 |
-
return $groupIds[$module];
|
329 |
-
}
|
330 |
-
else
|
331 |
-
{
|
332 |
-
return 1;
|
333 |
}
|
|
|
|
|
334 |
}
|
335 |
|
336 |
/**
|
5 |
*/
|
6 |
class Aitoc_Aitloadmon_Model_Process extends Mage_Core_Controller_Varien_Front
|
7 |
{
|
8 |
+
/**
|
9 |
+
* Array that will cache already parsed urls in this iteration
|
10 |
+
* @var array
|
11 |
+
*/
|
12 |
+
protected $_urlLog = array();
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Array to cache store prefixes/folders that should be removed
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
protected $_urlCuts = null;
|
19 |
+
|
20 |
/**
|
21 |
* Collects Magento routes
|
22 |
*
|
24 |
*/
|
25 |
protected function _init()
|
26 |
{
|
27 |
+
Aitoc_Aitloadmon_Collect::saveCronStartedFlag();
|
28 |
+
|
29 |
$router = Mage::getModel('aitloadmon/router');
|
30 |
$router->collectRoutes('frontend', 'standard');
|
31 |
$this->addRouter('custom', $router);
|
32 |
|
33 |
+
$cms = new Mage_Cms_Controller_Router();
|
34 |
+
$this->addRouter('cms', $cms);
|
35 |
+
|
36 |
$default = new Mage_Core_Controller_Varien_Router_Default();
|
37 |
$this->addRouter('default', $default);
|
38 |
|
141 |
{
|
142 |
$model = Mage::getModel('aitloadmon/aitloadmon');
|
143 |
$calcModel = Mage::getModel('aitloadmon/calculator');
|
|
|
144 |
$maxAvgLoadTime = 0;
|
145 |
foreach($result as $groupId => $resultItem)
|
146 |
{
|
151 |
{
|
152 |
$maxAvgLoadTime = $avgLoadTime;
|
153 |
}
|
154 |
+
$model->unsetData();
|
155 |
$model->setData(array(
|
156 |
|
157 |
'measure_time' => date('Y-m-d H:i:s',ceil((int)$resultItem['end']/60)*60),
|
250 |
$rawData = Aitoc_Aitloadmon_Collect::getData();
|
251 |
$maxAvgLoadTime = 0;
|
252 |
$timedData = $this->_getTimedData($rawData);
|
|
|
253 |
foreach($timedData as $data)
|
254 |
{
|
255 |
$result = $this->_prepareForSave($data);
|
269 |
|
270 |
private function _getUrlCuts()
|
271 |
{
|
272 |
+
if(is_null($this->_urlCuts))
|
273 |
{
|
274 |
$stores = Mage::getModel('core/store')->getCollection();
|
275 |
$storeUrls = array();
|
319 |
{
|
320 |
return false;
|
321 |
}
|
322 |
+
if(isset($this->_urlLog[$uri])) {
|
323 |
+
return $this->_urlLog[$uri];
|
324 |
+
}
|
325 |
$request = new Mage_Core_Controller_Request_Http($uri);
|
326 |
//commented if for 1401 support
|
327 |
//if (!$request->isStraight()) {
|
336 |
}
|
337 |
$module = $request->getModuleName();
|
338 |
$groupIds = Mage::helper('aitloadmon')->getGroupsArray();
|
339 |
+
$return = 1;//default is 'other'
|
340 |
if($module == 'admin')
|
341 |
{
|
342 |
+
$return = false;
|
343 |
}
|
344 |
elseif(isset($groupIds[$module]))
|
345 |
{
|
346 |
+
$return = $groupIds[$module];
|
|
|
|
|
|
|
|
|
347 |
}
|
348 |
+
$this->_urlLog[$uri] = $return;
|
349 |
+
return $return;
|
350 |
}
|
351 |
|
352 |
/**
|
app/code/local/Aitoc/Aitloadmon/Model/SysInfo.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
*/
|
6 |
class Aitoc_Aitloadmon_Model_SysInfo extends Aitoc_Aitloadmon_Model_System_Abstract
|
7 |
{
|
8 |
-
protected $_systemUrl = 'http://www.aitoc.com/configuration-calculator';
|
9 |
protected $_systemKey = 'system/aitloadmon/system_info';
|
10 |
protected $_systemDateKey = 'system/aitloadmon/system_info_date';
|
11 |
protected $_expire = 86400;
|
5 |
*/
|
6 |
class Aitoc_Aitloadmon_Model_SysInfo extends Aitoc_Aitloadmon_Model_System_Abstract
|
7 |
{
|
8 |
+
protected $_systemUrl = 'http://www.aitoc.com/en/server-configuration-calculator/';
|
9 |
protected $_systemKey = 'system/aitloadmon/system_info';
|
10 |
protected $_systemDateKey = 'system/aitloadmon/system_info_date';
|
11 |
protected $_expire = 86400;
|
app/code/local/Aitoc/Aitloadmon/controllers/Adminhtml/AitloadmonController.php
CHANGED
@@ -43,14 +43,15 @@ class Aitoc_Aitloadmon_Adminhtml_AitloadmonController extends Mage_Adminhtml_Con
|
|
43 |
public function indexAction() {
|
44 |
$this->_initIndexAction();
|
45 |
|
|
|
46 |
if(!$startDate = $this->getRequest()->getParam('startDate'))
|
47 |
{
|
48 |
-
$startDate = date('Y-m-d H:i:s', time()-3600+1);
|
49 |
}
|
50 |
|
51 |
if(!$endDate = $this->getRequest()->getParam('endDate'))
|
52 |
{
|
53 |
-
$endDate = date('Y-m-d H:i:s');
|
54 |
}
|
55 |
|
56 |
$type = $this->getRequest()->getParam('type');
|
@@ -68,12 +69,12 @@ class Aitoc_Aitloadmon_Adminhtml_AitloadmonController extends Mage_Adminhtml_Con
|
|
68 |
|
69 |
if($compare && !$startDateCompare = $this->getRequest()->getParam('startDateCompare'))
|
70 |
{
|
71 |
-
$startDateCompare = date('Y-m-d H:i:s', time()-86400);
|
72 |
}
|
73 |
|
74 |
if($compare)
|
75 |
{
|
76 |
-
$endDateCompare = date('Y-m-d H:i:s', strtotime($startDateCompare) + (strtotime($endDate) - strtotime($startDate)));
|
77 |
$this->getLayout()->getBlock('main_bl')->setCompare($compare)
|
78 |
->setStartDateCompare($startDateCompare)
|
79 |
->setEndDateCompare($endDateCompare);
|
@@ -105,4 +106,9 @@ class Aitoc_Aitloadmon_Adminhtml_AitloadmonController extends Mage_Adminhtml_Con
|
|
105 |
$this->_initManageAction();
|
106 |
$this->renderLayout();
|
107 |
}
|
|
|
|
|
|
|
|
|
|
|
108 |
}
|
43 |
public function indexAction() {
|
44 |
$this->_initIndexAction();
|
45 |
|
46 |
+
$dateModel = Mage::getModel('core/date');
|
47 |
if(!$startDate = $this->getRequest()->getParam('startDate'))
|
48 |
{
|
49 |
+
$startDate = $dateModel->date('Y-m-d H:i:s', time()-3600+1);
|
50 |
}
|
51 |
|
52 |
if(!$endDate = $this->getRequest()->getParam('endDate'))
|
53 |
{
|
54 |
+
$endDate = $dateModel->date('Y-m-d H:i:s');
|
55 |
}
|
56 |
|
57 |
$type = $this->getRequest()->getParam('type');
|
69 |
|
70 |
if($compare && !$startDateCompare = $this->getRequest()->getParam('startDateCompare'))
|
71 |
{
|
72 |
+
$startDateCompare = $dateModel->date('Y-m-d H:i:s', time()-86400);
|
73 |
}
|
74 |
|
75 |
if($compare)
|
76 |
{
|
77 |
+
$endDateCompare = $dateModel->date('Y-m-d H:i:s', strtotime($startDateCompare) + (strtotime($endDate) - strtotime($startDate)));
|
78 |
$this->getLayout()->getBlock('main_bl')->setCompare($compare)
|
79 |
->setStartDateCompare($startDateCompare)
|
80 |
->setEndDateCompare($endDateCompare);
|
106 |
$this->_initManageAction();
|
107 |
$this->renderLayout();
|
108 |
}
|
109 |
+
|
110 |
+
protected function _isAllowed()
|
111 |
+
{
|
112 |
+
return Mage::getSingleton('admin/session')->isAllowed('system/stats/stats');
|
113 |
+
}
|
114 |
}
|
app/code/local/Aitoc/Aitloadmon/controllers/Adminhtml/CalculatorController.php
CHANGED
@@ -30,4 +30,34 @@ class Aitoc_Aitloadmon_Adminhtml_CalculatorController extends Mage_Adminhtml_Con
|
|
30 |
$this->renderLayout();*/
|
31 |
|
32 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
30 |
$this->renderLayout();*/
|
31 |
|
32 |
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Displays the result to enter to Server Calculator
|
36 |
+
*/
|
37 |
+
public function submitAction()
|
38 |
+
{
|
39 |
+
$this->loadLayout()
|
40 |
+
->_setActiveMenu('system/aitloadmon')
|
41 |
+
->_addBreadcrumb(Mage::helper('aitloadmon')->__('Info for Magento Server Configuration Calculator'), Mage::helper('aitloadmon')->__('Info for Server Calculator'));
|
42 |
+
$this->_title(Mage::helper('aitloadmon')->__('Server Load Monitor'))->_title(Mage::helper('aitloadmon')->__('Info for Magento Server Configuration Calculator'));
|
43 |
+
|
44 |
+
$model = Mage::getModel('aitloadmon/calculator');
|
45 |
+
if(isset($_FILES['csv_file']['name']))
|
46 |
+
{
|
47 |
+
$model->setCsvFile($_FILES['csv_file']['name']);
|
48 |
+
}
|
49 |
+
#$method = 'get'.ucfirst($this->getRequest()->getParam('source')).'Visitors';
|
50 |
+
$method = 'getMonitorVisitors';
|
51 |
+
|
52 |
+
$this->getLayout()->getBlock('aitload_calculator_result')
|
53 |
+
->setProducts($model->getProductInfo())
|
54 |
+
->setOrders($model->getOrderInfo())
|
55 |
+
->setLoad($model->$method());
|
56 |
+
$this->renderLayout();
|
57 |
+
}
|
58 |
+
|
59 |
+
protected function _isAllowed()
|
60 |
+
{
|
61 |
+
return Mage::getSingleton('admin/session')->isAllowed('system/stats/calc');
|
62 |
+
}
|
63 |
}
|
app/code/local/Aitoc/Aitloadmon/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Aitoc_Aitloadmon>
|
5 |
-
<version>1.0.
|
6 |
</Aitoc_Aitloadmon>
|
7 |
</modules>
|
8 |
<admin>
|
@@ -87,10 +87,6 @@
|
|
87 |
<schedule><cron_expr>1 */1 * * *</cron_expr></schedule>
|
88 |
<run><model>aitloadmon/observer::compressData</model></run>
|
89 |
</aitloadmon_compress_data>
|
90 |
-
<aitloadmon_calc_send>
|
91 |
-
<schedule><cron_expr>1 4 * * *</cron_expr></schedule>
|
92 |
-
<run><model>aitloadmon/observer::sendToAitoc</model></run>
|
93 |
-
</aitloadmon_calc_send>
|
94 |
</jobs>
|
95 |
</crontab>
|
96 |
<default>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Aitoc_Aitloadmon>
|
5 |
+
<version>1.0.7</version>
|
6 |
</Aitoc_Aitloadmon>
|
7 |
</modules>
|
8 |
<admin>
|
87 |
<schedule><cron_expr>1 */1 * * *</cron_expr></schedule>
|
88 |
<run><model>aitloadmon/observer::compressData</model></run>
|
89 |
</aitloadmon_compress_data>
|
|
|
|
|
|
|
|
|
90 |
</jobs>
|
91 |
</crontab>
|
92 |
<default>
|
app/design/adminhtml/default/default/layout/aitcore.xml
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<default>
|
4 |
+
<reference name="notifications">
|
5 |
+
<block type="aitsys/rewriter_notifications" name="aitsys_rewriter_notifications" template="aitcore/rewriter/notifications.phtml" />
|
6 |
+
</reference>
|
7 |
+
</default>
|
8 |
+
|
9 |
+
<aitsys_index_index>
|
10 |
+
<reference name="head">
|
11 |
+
<action method="addCss"><name>aitoc/aitsys.css</name></action>
|
12 |
+
</reference>
|
13 |
+
<reference name="content">
|
14 |
+
<block type="aitsys/edit" name="aitsys.edit" template="aitcore/edit.phtml">
|
15 |
+
<block type="aitsys/news" name="aitsys.news" template="aitcore/news.phtml" />
|
16 |
+
</block>
|
17 |
+
</reference>
|
18 |
+
</aitsys_index_index>
|
19 |
+
|
20 |
+
<aitsys_patch_index>
|
21 |
+
<reference name="head">
|
22 |
+
<action method="addCss"><name>aitoc/aitsys.css</name></action>
|
23 |
+
</reference>
|
24 |
+
<reference name="content">
|
25 |
+
<block type="aitsys/patch_view" name="aitsys.patch.view" template="aitcore/patch/view.phtml" />
|
26 |
+
</reference>
|
27 |
+
</aitsys_patch_index>
|
28 |
+
|
29 |
+
<aitsys_patch_instruction>
|
30 |
+
<reference name="head">
|
31 |
+
<action method="addCss"><name>aitoc/aitsys.css</name></action>
|
32 |
+
</reference>
|
33 |
+
<reference name="content">
|
34 |
+
<block type="aitsys/patch_instruction" name="aitsys.patch.instruction" template="aitcore/patch/instruction.phtml">
|
35 |
+
<block type="aitsys/patch_instruction_one" name="aitsys.patch.instruction.one" template="aitcore/patch/instruction/one.phtml" />
|
36 |
+
</block>
|
37 |
+
</reference>
|
38 |
+
</aitsys_patch_instruction>
|
39 |
+
|
40 |
+
<aitsys_rewriter_index>
|
41 |
+
<reference name="head">
|
42 |
+
<action method="addCss"><name>aitoc/aitsys.css</name></action>
|
43 |
+
</reference>
|
44 |
+
<reference name="content">
|
45 |
+
<block type="aitsys/rewriter_list" name="aitsys.rewriter.list" template="aitcore/rewriter/list.phtml" />
|
46 |
+
</reference>
|
47 |
+
</aitsys_rewriter_index>
|
48 |
+
</layout>
|
app/design/adminhtml/default/default/layout/aitinstall.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<default>
|
4 |
+
<reference name="notifications">
|
5 |
+
<block type="adminhtml/template" name="aitinstall_notification" template="aitinstall/notification.phtml" />
|
6 |
+
</reference>
|
7 |
+
</default>
|
8 |
+
</layout>
|
app/design/adminhtml/default/default/layout/aitloadmon.xml
CHANGED
@@ -26,7 +26,7 @@
|
|
26 |
</adminhtml_aitloadmon_manage>
|
27 |
<adminhtml_calculator_index>
|
28 |
<reference name="content">
|
29 |
-
<block type="
|
30 |
<!--block type="aitloadmon/adminhtml_calculatorResult" name="aitload_calculator_result" as="calculator_result" /-->
|
31 |
</reference>
|
32 |
</adminhtml_calculator_index>
|
@@ -34,12 +34,12 @@
|
|
34 |
<reference name="content">
|
35 |
<block type="core/template" name="sysInfo" as="sysInfo_block" template="aitloadmon/sysInfo.phtml"/>
|
36 |
</reference>
|
37 |
-
</adminhtml_calculator_index
|
38 |
<adminhtml_calculator_submit>
|
39 |
<reference name="content">
|
40 |
-
<block type="aitloadmon/adminhtml_calculatorResult" name="aitload_calculator_result" as="calculator_result" />
|
41 |
</reference>
|
42 |
-
</adminhtml_calculator_submit
|
43 |
<default>
|
44 |
<reference name="content">
|
45 |
<block type="aitloadmon/adminhtml_indicator" name="aitloadmon_indicator" template="aitloadmon/indicator.phtml"/>
|
26 |
</adminhtml_aitloadmon_manage>
|
27 |
<adminhtml_calculator_index>
|
28 |
<reference name="content">
|
29 |
+
<block type="aitloadmon/adminhtml_calculator" name="aitload_calculator" as="calculator" />
|
30 |
<!--block type="aitloadmon/adminhtml_calculatorResult" name="aitload_calculator_result" as="calculator_result" /-->
|
31 |
</reference>
|
32 |
</adminhtml_calculator_index>
|
34 |
<reference name="content">
|
35 |
<block type="core/template" name="sysInfo" as="sysInfo_block" template="aitloadmon/sysInfo.phtml"/>
|
36 |
</reference>
|
37 |
+
</adminhtml_calculator_index-->
|
38 |
<adminhtml_calculator_submit>
|
39 |
<reference name="content">
|
40 |
+
<block type="aitloadmon/adminhtml_calculatorResult" name="aitload_calculator_result" as="calculator_result" template="aitloadmon/result.phtml"/>
|
41 |
</reference>
|
42 |
+
</adminhtml_calculator_submit>
|
43 |
<default>
|
44 |
<reference name="content">
|
45 |
<block type="aitloadmon/adminhtml_indicator" name="aitloadmon_indicator" template="aitloadmon/indicator.phtml"/>
|
app/design/adminhtml/default/default/template/aitloadmon/back.phtml
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
-
* @license License agreement could be found at the root folder of this package
|
5 |
-
*/
|
6 |
-
?>
|
7 |
-
<input type="button" class="form-button submit" title="Return to System Configuration" value="Return to System Configuration" id="return" onclick="document.location.href='<?php echo Mage::helper('adminhtml')->getUrl('adminhtml/system_config/edit',array('section'=>'system')); ?>'" style="float: right; margin-bottom: 10px;">
|
8 |
-
<div style="clear: both;"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/template/aitloadmon/bar.phtml
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
-
* @license License agreement could be found at the root folder of this package
|
5 |
-
*/
|
6 |
-
?>
|
7 |
-
<div class="entry-edit">
|
8 |
-
<div class="entry-edit-head">
|
9 |
-
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('aitloadmon')->__('Avg Load / Max Load for the selected period by groups');?></h4>
|
10 |
-
</div>
|
11 |
-
<div class="fieldset">
|
12 |
-
<div id="graph2" style="height: 200px; width: 1000px;"></div>
|
13 |
-
</div>
|
14 |
-
</div>
|
15 |
-
<script type="text/javascript">
|
16 |
-
var graph2 = new Grafico.HorizontalBarGraphCustom($('graph2'), {
|
17 |
-
<?php echo $this->getBarGraphData(); ?>
|
18 |
-
},
|
19 |
-
{
|
20 |
-
labels: <?php echo $this->getBarLabels($this->getCompare()); ?>,
|
21 |
-
show_ticks: false,
|
22 |
-
compare_mode: <?php echo (int)$this->getCompare();?>,
|
23 |
-
vertical_label_unit : "s",
|
24 |
-
colors: {
|
25 |
-
max_load: '#A0151E',
|
26 |
-
avg_load: ['#877D1E',"#6016CA","#1680CA","#F5861A","#1B7B00"]
|
27 |
-
}
|
28 |
-
}
|
29 |
-
);
|
30 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/template/aitloadmon/graph.phtml
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
-
* @license License agreement could be found at the root folder of this package
|
5 |
-
*/
|
6 |
-
?>
|
7 |
-
<ul class="messages">
|
8 |
-
<?php if(!Mage::getStoreConfig('system/aitloadmon/disable_calc_info_sending')):?>
|
9 |
-
<li class="notice-msg">
|
10 |
-
<p><?php echo Mage::helper('aitloadmon')->__('Please note that collected data of Server Load Monitor extension will be sent to AITOC’s Magento Server Configuration Calculator in order to configure and recommend you better server settings.');?></p>
|
11 |
-
</li>
|
12 |
-
<?php endif; ?>
|
13 |
-
<li class="notice-msg">
|
14 |
-
<p><?php echo Mage::helper('aitloadmon')->__('Please note that the server time is used instead of your local one.');?></p>
|
15 |
-
</li>
|
16 |
-
</ul>
|
17 |
-
<?php echo $this->getChildHtml('quickFilter'); ?>
|
18 |
-
<?php echo $this->getChildHtml('filter'); ?>
|
19 |
-
<?php if(!$this->isEnoughDataToBuildGraph($this->getCollection()) || ($this->getCompare() && !$this->isEnoughDataToBuildGraph($this->getCompareCollection()))):?>
|
20 |
-
<ul class="messages">
|
21 |
-
<li class="error-msg">
|
22 |
-
<p><?php echo Mage::helper('aitloadmon')->__('Sorry, there is not enough data for the selected period(s).');?></p>
|
23 |
-
</li>
|
24 |
-
</ul>
|
25 |
-
<?php else: ?>
|
26 |
-
<?php echo $this->getChildHtml('barGraph'); ?>
|
27 |
-
<?php echo $this->getChildHtml('lineGraph'); ?>
|
28 |
-
<?php endif;?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/template/aitloadmon/indicator.phtml
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
-
* @license License agreement could be found at the root folder of this package
|
5 |
-
*/
|
6 |
-
?>
|
7 |
-
<div style="position: fixed; top: 35px; right: 3px; background-color: #cccccc; height: 18px; margin: 0; padding: 0;" onmouseover="$('aitloadmon_notice').show();" onmouseout="$('aitloadmon_notice').hide();">
|
8 |
-
<div id="aitloadmon_notice" style="display:none; float: left;"> <?php echo Mage::helper('aitloadmon')->__('Current Server Load:');?> </div>
|
9 |
-
<a href="<?php echo Mage::helper("adminhtml")->getUrl('adminhtml/aitloadmon/index');?>">
|
10 |
-
<div style="background-color: <?php echo $this->getColor();?>; height: 16px; width: 16px; float: left; border: 1px solid #cccccc;"></div>
|
11 |
-
</a>
|
12 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/template/aitloadmon/line.phtml
DELETED
@@ -1,119 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
-
* @license License agreement could be found at the root folder of this package
|
5 |
-
*/
|
6 |
-
?>
|
7 |
-
<style>
|
8 |
-
.linegraph_check
|
9 |
-
{
|
10 |
-
margin-right: 5px;
|
11 |
-
margin-left: 25px;
|
12 |
-
}
|
13 |
-
</style>
|
14 |
-
<div class="entry-edit">
|
15 |
-
<div class="entry-edit-head">
|
16 |
-
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('aitloadmon')->__(($this->getType()=='max')?'MAXIMUM':'AVERAGE').Mage::helper('aitloadmon')->__(' LOAD for the selected period by groups and time');?></h4>
|
17 |
-
</div>
|
18 |
-
<div class="fieldset">
|
19 |
-
<div><?php echo Mage::helper('aitloadmon')->__('Show graphs for:'); ?><?php echo $this->getCheckBoxes(); ?></div>
|
20 |
-
<div id="graph1" style="height: 340px; width: 1000px;"></div>
|
21 |
-
<?php if($this->getCompare()):?><div id="graph1compare" style="height: 340px; width: 1000px;"></div><?php endif;?>
|
22 |
-
</div>
|
23 |
-
</div>
|
24 |
-
<script type="text/javascript">
|
25 |
-
var lineGraphs = [];
|
26 |
-
function toggleLines(obj)
|
27 |
-
{
|
28 |
-
var graphId = $(obj).getAttribute('rel');
|
29 |
-
if(lineGraphs[graphId])
|
30 |
-
{
|
31 |
-
if(!$(obj).checked)
|
32 |
-
{
|
33 |
-
lineGraphs[graphId].each(function(element){element.hide()});
|
34 |
-
}
|
35 |
-
else
|
36 |
-
{
|
37 |
-
lineGraphs[graphId].each(function(element){element.show()});
|
38 |
-
}
|
39 |
-
}
|
40 |
-
}
|
41 |
-
<?php $lineGraph = $this->getLineGraphData(); ?>
|
42 |
-
var graph1 = new Grafico.LineGraphCustom($('graph1'),
|
43 |
-
{
|
44 |
-
<?php echo $lineGraph['data']; ?>
|
45 |
-
},
|
46 |
-
{
|
47 |
-
markers : "value",
|
48 |
-
grid : true,
|
49 |
-
draw_axis : true,
|
50 |
-
plot_padding : 0,
|
51 |
-
stroke_width : 2,
|
52 |
-
show_vertical_labels : true,
|
53 |
-
show_horizontal_labels : true,
|
54 |
-
vertical_label_unit: 's',
|
55 |
-
label_rotation : 0,
|
56 |
-
labels : <?php echo $lineGraph['labels']; ?>,
|
57 |
-
dot_labels : <?php echo $lineGraph['dot_labels']; ?>,
|
58 |
-
label_sizes : {<?php echo $lineGraph['dataSize']; ?>},
|
59 |
-
concurrents : {<?php echo $lineGraph['concurrents']; ?>},
|
60 |
-
hover_color : "#000",
|
61 |
-
hover_text_color : "#fff",
|
62 |
-
opacity: 1,
|
63 |
-
zones: [<?php echo (int)Mage::getStoreConfig('system/aitloadmon/load_yellow');?>,<?php echo (int)Mage::getStoreConfig('system/aitloadmon/load_red');?>,<?php echo (int)Mage::getStoreConfig('system/aitloadmon/load_black');?>],
|
64 |
-
colors: {
|
65 |
-
other: "#877D1E",
|
66 |
-
cms: "#6016CA",
|
67 |
-
checkout: "#1680CA",
|
68 |
-
catalogsearch: "#F5861A",
|
69 |
-
catalog: "#1B7B00"
|
70 |
-
},
|
71 |
-
datalabels : {
|
72 |
-
other: "Other pages",
|
73 |
-
cms: "CMS pages",
|
74 |
-
checkout: "Checkout pages",
|
75 |
-
catalogsearch: "Search pages",
|
76 |
-
catalog: "Catalog pages"
|
77 |
-
}
|
78 |
-
});
|
79 |
-
|
80 |
-
<?php if($this->getCompare()):?>
|
81 |
-
<?php $lineGraph = $this->getLineGraphDataCompared(); ?>
|
82 |
-
var graph1 = new Grafico.LineGraphCustom($('graph1compare'),
|
83 |
-
{
|
84 |
-
<?php echo $lineGraph['data']; ?>
|
85 |
-
},
|
86 |
-
{
|
87 |
-
markers : "value",
|
88 |
-
grid : true,
|
89 |
-
draw_axis : true,
|
90 |
-
plot_padding : 0,
|
91 |
-
stroke_width : 2,
|
92 |
-
show_vertical_labels : true,
|
93 |
-
show_horizontal_labels : true,
|
94 |
-
label_rotation : 0,
|
95 |
-
labels : <?php echo $lineGraph['labels']; ?>,
|
96 |
-
dot_labels : <?php echo $lineGraph['dot_labels']; ?>,
|
97 |
-
label_sizes : {<?php echo $lineGraph['dataSize']; ?>},
|
98 |
-
concurrents : {<?php echo $lineGraph['concurrents']; ?>},
|
99 |
-
hover_color : "#000",
|
100 |
-
hover_text_color : "#fff",
|
101 |
-
opacity: 0.5,
|
102 |
-
zones: [<?php echo (int)Mage::getStoreConfig('system/aitloadmon/load_yellow');?>,<?php echo (int)Mage::getStoreConfig('system/aitloadmon/load_red');?>,<?php echo (int)Mage::getStoreConfig('system/aitloadmon/load_black');?>],
|
103 |
-
colors: {
|
104 |
-
other: "#877D1E",
|
105 |
-
cms: "#6016CA",
|
106 |
-
checkout: "#1680CA",
|
107 |
-
catalogsearch: "#F5861A",
|
108 |
-
catalog: "#1B7B00"
|
109 |
-
},
|
110 |
-
datalabels : {
|
111 |
-
other: "Other pages",
|
112 |
-
cms: "CMS pages",
|
113 |
-
checkout: "Checkout pages",
|
114 |
-
catalogsearch: "Search pages",
|
115 |
-
catalog: "Catalog pages"
|
116 |
-
}
|
117 |
-
});
|
118 |
-
<?php endif;?>
|
119 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/template/aitloadmon/quick.phtml
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
-
* @license License agreement could be found at the root folder of this package
|
5 |
-
*/
|
6 |
-
?>
|
7 |
-
<div class="entry-edit">
|
8 |
-
<div class="entry-edit-head">
|
9 |
-
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('aitloadmon')->__('Basic Filter Options');?></h4>
|
10 |
-
</div>
|
11 |
-
<div class="fieldset">
|
12 |
-
<input type="button" class="form-button" title="Last Hour" value="Last Hour" id="qickfilter0" onclick="quickFilter('<?php echo date('Y-m-d H:i:s', time()-3600+1);?>','<?php echo date('Y-m-d H:i:s');?>');">
|
13 |
-
<input type="button" class="form-button" title="Last 24h" value="Last 24h" id="qickfilter1" onclick="quickFilter('<?php echo date('Y-m-d H:i:s', time()-86400+1);?>','<?php echo date('Y-m-d H:i:s');?>');">
|
14 |
-
<input type="button" class="form-button" title="Last Week" value="Last Week" id="qickfilter2" onclick="quickFilter('<?php echo date('Y-m-d H:i:s', time()-86400*7+1);?>','<?php echo date('Y-m-d H:i:s');?>');">
|
15 |
-
<input type="button" class="form-button" title="Last Month" value="Last Month" id="qickfilter3" onclick="quickFilter('<?php echo date('Y-m-d H:i:s', time()-86400*30+1);?>','<?php echo date('Y-m-d H:i:s');?>');">
|
16 |
-
<input type="button" class="form-button" title="Last Year" value="Last Year" id="qickfilter4" onclick="quickFilter('<?php echo date('Y-m-d H:i:s', time()-86400*365+1);?>','<?php echo date('Y-m-d H:i:s');?>');">
|
17 |
-
</div>
|
18 |
-
</div>
|
19 |
-
<script type="text/javascript">
|
20 |
-
function quickFilter($start,$end)
|
21 |
-
{
|
22 |
-
$('starts').value = $start;
|
23 |
-
$('ends').value = $end;
|
24 |
-
$('compare').checked = false;
|
25 |
-
$('edit_form').submit();
|
26 |
-
|
27 |
-
}
|
28 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/template/aitloadmon/sysInfo.phtml
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
-
* @license License agreement could be found at the root folder of this package
|
5 |
-
*/
|
6 |
-
?>
|
7 |
-
<?php if($system = Mage::getModel('aitloadmon/sysInfo')->getSystem()): ?>
|
8 |
-
<div><?php echo $system;?></div>
|
9 |
-
<?php else:?>
|
10 |
-
<iframe src="<?php echo Mage::getModel('aitloadmon/sysInfo')->getSystemUrl();?>" style="width: 100%; border: medium none;"></iframe>
|
11 |
-
<?php endif;?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/template/aitloadmon/system.phtml
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
-
* @license License agreement could be found at the root folder of this package
|
5 |
-
*/
|
6 |
-
?>
|
7 |
-
<?php if($system = Mage::getModel('aitloadmon/system')->getSystem()): ?>
|
8 |
-
<div><?php echo $system;?></div>
|
9 |
-
<?php else:?>
|
10 |
-
<iframe src="<?php echo Mage::getModel('aitloadmon/system')->getSystemUrl();?>" style="width: 100%; border: medium none;"></iframe>
|
11 |
-
<?php endif;?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/etc/modules/Aitoc_Aitinstall.xml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Aitoc_Aitsys>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Aitoc_Aitsys>
|
8 |
+
<Aitoc_Aitinstall>
|
9 |
+
<active>true</active>
|
10 |
+
<codePool>community</codePool>
|
11 |
+
</Aitoc_Aitinstall>
|
12 |
+
</modules>
|
13 |
+
</config>
|
lib/Aitoc/Aitloadmon/Adapter/Abstract.php
ADDED
@@ -0,0 +1,341 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
+
* @license License agreement could be found at the root folder of this package
|
5 |
+
*/
|
6 |
+
abstract class Aitoc_Aitloadmon_Adapter_Abstract
|
7 |
+
{
|
8 |
+
protected static $DATA_KEY = 'aitlm_d';
|
9 |
+
protected static $DATA_NUM_KEY = 'aitlm_d_k';
|
10 |
+
protected static $CURR_POOL_INDEX = 'aitlm_p_i';
|
11 |
+
protected static $TTL = 7200;
|
12 |
+
|
13 |
+
//prefix from settings
|
14 |
+
/**
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_prefix = '';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var array
|
21 |
+
*/
|
22 |
+
protected $_pools = array('a','b');
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var string
|
26 |
+
*/
|
27 |
+
protected $_currentPool = '';
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
protected $_poolIndex = '';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Flag to show that some data were stored in current request, used by some adapter to update data
|
36 |
+
*
|
37 |
+
* @var bool
|
38 |
+
*/
|
39 |
+
protected $_dataStored = false;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Amount of rows that should be read from cache
|
43 |
+
* @var int
|
44 |
+
*/
|
45 |
+
protected $_rowsLimit = 50000;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @var string
|
49 |
+
*/
|
50 |
+
protected $_dataPrefix = '';
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Key to store value in apc/memcache
|
54 |
+
*
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
protected $_handle = null;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Variable to store data from first insert to apc
|
61 |
+
* @var array
|
62 |
+
*/
|
63 |
+
protected $_storedParams = array();
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Flag, that we need to save previous data stored cache and we need to update it in next request to save, instead of creating 2 different rows
|
67 |
+
*
|
68 |
+
* @var bool
|
69 |
+
*/
|
70 |
+
protected $_storeParams = false;
|
71 |
+
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Get value from a storage by $key
|
75 |
+
*
|
76 |
+
* @param string $key
|
77 |
+
*
|
78 |
+
* @return mixed
|
79 |
+
*/
|
80 |
+
abstract protected function _get($key);
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Store value to the storage by $key, replace old values
|
84 |
+
*
|
85 |
+
* @param string $key
|
86 |
+
* @param mixed $value
|
87 |
+
* @param int $ttl
|
88 |
+
*
|
89 |
+
* @return bool
|
90 |
+
*/
|
91 |
+
abstract protected function _set($key, $value, $ttl);
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Add value to the storage by key, return false if value exists
|
95 |
+
*
|
96 |
+
* @param string $key
|
97 |
+
* @param mixed $value
|
98 |
+
* @param int $ttl
|
99 |
+
*
|
100 |
+
* @return bool
|
101 |
+
*/
|
102 |
+
abstract protected function _add($key, $value, $ttl);
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Get valuee from the storage and increase it's count by 1
|
106 |
+
*
|
107 |
+
* @param string $key
|
108 |
+
*
|
109 |
+
* @return int
|
110 |
+
*/
|
111 |
+
abstract protected function _inc($key);
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Delete value from storage
|
115 |
+
*
|
116 |
+
* @param string $key
|
117 |
+
*
|
118 |
+
* @return mixed
|
119 |
+
*/
|
120 |
+
abstract protected function _delete($key);
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Initiate pools, generate prefixes for data
|
124 |
+
*
|
125 |
+
* @param array $settings
|
126 |
+
*/
|
127 |
+
public function __construct($settings)
|
128 |
+
{
|
129 |
+
$this->_prefix = (isset($settings['prefix']) ? (string)$settings['prefix'] : '');
|
130 |
+
|
131 |
+
$pools = $this->_pools;
|
132 |
+
|
133 |
+
$poolIndex = $this->getPoolIndex();
|
134 |
+
if($poolIndex === false)
|
135 |
+
{
|
136 |
+
$poolIndex = 0;
|
137 |
+
$this->_storePoolId( $poolIndex );
|
138 |
+
}
|
139 |
+
$poolIndex = (int)$poolIndex;
|
140 |
+
|
141 |
+
$this->_currentPool = $pools[$poolIndex];
|
142 |
+
$this->_poolIndex = $poolIndex;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* @return int
|
147 |
+
*/
|
148 |
+
public function getPoolIndex()
|
149 |
+
{
|
150 |
+
return $this->_get($this->getPoolIndexId());
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Store current pool
|
155 |
+
*
|
156 |
+
* @param int $newPoolId
|
157 |
+
*/
|
158 |
+
protected function _storePoolId( $newPoolId )
|
159 |
+
{
|
160 |
+
$this->_set($this->getPoolIndexId(), $newPoolId, Aitoc_Aitloadmon_Adapter_Abstract::$TTL);
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Get unique index/handler where data will be stored
|
165 |
+
*
|
166 |
+
* @return string
|
167 |
+
*/
|
168 |
+
protected function _getHandle()
|
169 |
+
{
|
170 |
+
if(is_null($this->_handle)) {
|
171 |
+
$dataIndex = $this->_getPrefix() . Aitoc_Aitloadmon_Adapter_Abstract::$DATA_NUM_KEY;
|
172 |
+
if(!$index = $this->_get($dataIndex))
|
173 |
+
{
|
174 |
+
$this->_add($dataIndex, 1, Aitoc_Aitloadmon_Adapter_Abstract::$TTL);
|
175 |
+
$index = 1;
|
176 |
+
}
|
177 |
+
else
|
178 |
+
{
|
179 |
+
$index = $this->_inc($dataIndex);
|
180 |
+
}
|
181 |
+
|
182 |
+
$this->_handle = $this->_dataPrefix . $index;
|
183 |
+
}
|
184 |
+
return $this->_handle;
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Remove connection to the handle, if required
|
189 |
+
*
|
190 |
+
* @param mixed $handle
|
191 |
+
*/
|
192 |
+
protected function _closeHandle($handle)
|
193 |
+
{
|
194 |
+
//nothing by default
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Process data, receive handle where to save it and execute save
|
199 |
+
*
|
200 |
+
* @param array $params
|
201 |
+
*/
|
202 |
+
public function save($params)
|
203 |
+
{
|
204 |
+
if($this->_storeParams) {
|
205 |
+
$params = $this->_processParams($params);
|
206 |
+
}
|
207 |
+
$handler = $this->_getHandle();
|
208 |
+
$result = $this->_save($handler, $params);
|
209 |
+
$this->_dataStored = $this->_dataStored || $result;
|
210 |
+
$this->_closeHandle($handler);
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Save data to storage, can be overriden, if required
|
215 |
+
*
|
216 |
+
* @param mixed $handler
|
217 |
+
* @param array $params
|
218 |
+
*
|
219 |
+
* @return bool
|
220 |
+
*/
|
221 |
+
protected function _save( $handler, $params )
|
222 |
+
{
|
223 |
+
if(!$this->isDataStored()) {
|
224 |
+
$return = $this->_add($handler, $params, Aitoc_Aitloadmon_Adapter_Abstract::$TTL);
|
225 |
+
} else {
|
226 |
+
$return = $this->_set($handler, $params, Aitoc_Aitloadmon_Adapter_Abstract::$TTL);
|
227 |
+
}
|
228 |
+
return $return;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Update pools and gets the data from the storage
|
233 |
+
*
|
234 |
+
* @return array
|
235 |
+
*/
|
236 |
+
public function getData()
|
237 |
+
{
|
238 |
+
$this->_cyclePools();
|
239 |
+
$data = $this->_getData();
|
240 |
+
return $data;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Extract data from the storage
|
245 |
+
* @return array
|
246 |
+
*/
|
247 |
+
protected function _getData()
|
248 |
+
{
|
249 |
+
$data = array();
|
250 |
+
$dataIndex = $this->_getPrefix() . Aitoc_Aitloadmon_Adapter_Abstract::$DATA_NUM_KEY;
|
251 |
+
if($index = $this->_get($dataIndex))
|
252 |
+
{
|
253 |
+
$this->_set($dataIndex, 1, Aitoc_Aitloadmon_Adapter_Abstract::$TTL);
|
254 |
+
for($i=1;$i<=$index;$i++)
|
255 |
+
{
|
256 |
+
if($element = $this->_get($this->_dataPrefix . $i))
|
257 |
+
{
|
258 |
+
$data[$element['id']] = $element['d'];
|
259 |
+
$this->_delete($this->_dataPrefix . $i);
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
}
|
264 |
+
return $data;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* @return string
|
269 |
+
*/
|
270 |
+
public function getPoolIndexId()
|
271 |
+
{
|
272 |
+
return $this->_prefix.self::$CURR_POOL_INDEX;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* @return int
|
277 |
+
*/
|
278 |
+
protected function _getNextPoolIndex()
|
279 |
+
{
|
280 |
+
if((count($this->_pools)-1) == $this->_poolIndex)
|
281 |
+
{
|
282 |
+
return 0;
|
283 |
+
}
|
284 |
+
else
|
285 |
+
{
|
286 |
+
return ($this->_poolIndex+1);
|
287 |
+
}
|
288 |
+
}
|
289 |
+
|
290 |
+
protected function _cyclePools()
|
291 |
+
{
|
292 |
+
$this->_storePoolId( $this->_getNextPoolIndex() );
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* @return string
|
297 |
+
*/
|
298 |
+
protected function _getPrefix()
|
299 |
+
{
|
300 |
+
return $this->_prefix.$this->_getCurrentPool();
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* @return string
|
305 |
+
*/
|
306 |
+
protected function _getCurrentPool()
|
307 |
+
{
|
308 |
+
return $this->_currentPool;
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* Merge previously saved params with current one.
|
313 |
+
*
|
314 |
+
* @param array $params
|
315 |
+
*
|
316 |
+
* @return array
|
317 |
+
*/
|
318 |
+
protected function _processParams($params)
|
319 |
+
{
|
320 |
+
$this->_storedParams = array_merge($this->_storedParams, $params['d']);
|
321 |
+
$params['d'] = $this->_storedParams;
|
322 |
+
return $params;
|
323 |
+
}
|
324 |
+
|
325 |
+
/**
|
326 |
+
* @return bool
|
327 |
+
*/
|
328 |
+
public function isDataStored()
|
329 |
+
{
|
330 |
+
return $this->_dataStored;
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* @return int
|
335 |
+
*/
|
336 |
+
public function getRowsLimit()
|
337 |
+
{
|
338 |
+
return $this->_rowsLimit;
|
339 |
+
}
|
340 |
+
|
341 |
+
}
|
lib/Aitoc/Aitloadmon/Adapter/Apc.php
CHANGED
@@ -3,54 +3,86 @@
|
|
3 |
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
* @license License agreement could be found at the root folder of this package
|
5 |
*/
|
6 |
-
class Aitoc_Aitloadmon_Adapter_Apc
|
7 |
{
|
8 |
-
private static $DATA_KEY = 'aitloadmon_data';
|
9 |
-
private static $DATA_NUM_KEY = 'aitloadmon_data_key';
|
10 |
-
|
11 |
/**
|
12 |
-
*
|
13 |
-
*
|
14 |
-
* @param array $
|
|
|
|
|
15 |
*/
|
16 |
-
public function
|
17 |
{
|
18 |
-
if(
|
19 |
-
|
20 |
-
apc_add(self::$DATA_NUM_KEY, 1);
|
21 |
-
$index = 1;
|
22 |
-
}
|
23 |
-
|
24 |
-
while(!apc_add(self::$DATA_KEY.$index,$params))
|
25 |
-
{
|
26 |
-
$index++;
|
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 |
-
return $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
|
|
56 |
}
|
3 |
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
* @license License agreement could be found at the root folder of this package
|
5 |
*/
|
6 |
+
class Aitoc_Aitloadmon_Adapter_Apc extends Aitoc_Aitloadmon_Adapter_Abstract
|
7 |
{
|
|
|
|
|
|
|
8 |
/**
|
9 |
+
* Generate special module prefixes where data will be stored
|
10 |
+
*
|
11 |
+
* @param array $settings
|
12 |
+
*
|
13 |
+
* @return Aitoc_Aitloadmon_Adapter_Apc
|
14 |
*/
|
15 |
+
public function __construct( $settings )
|
16 |
{
|
17 |
+
if(!function_exists('apc_cache_info')) {
|
18 |
+
throw new Exception('APC is not installed on your system and can not be used as adapter for Server Load Monitor');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
+
parent::__construct($settings);
|
21 |
+
$this->_storeParams = true;
|
22 |
+
$this->_dataPrefix = $this->_getPrefix() . Aitoc_Aitloadmon_Adapter_Abstract::$DATA_KEY;
|
23 |
}
|
24 |
+
|
|
|
25 |
/**
|
26 |
+
* Get value from a storage by $key
|
27 |
+
*
|
28 |
+
* @param string $key
|
29 |
+
*
|
30 |
+
* @return mixed
|
31 |
*/
|
32 |
+
protected function _get($key)
|
33 |
{
|
34 |
+
return apc_fetch($key);
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Store value to the storage by $key, replace old values
|
39 |
+
*
|
40 |
+
* @param string $key
|
41 |
+
* @param mixed $value
|
42 |
+
* @param int $ttl
|
43 |
+
*
|
44 |
+
* @return bool
|
45 |
+
*/
|
46 |
+
protected function _set($key, $value, $ttl)
|
47 |
+
{
|
48 |
+
return apc_store($key, $value, $ttl);
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Add value to the storage by key, return false if value exists
|
53 |
+
*
|
54 |
+
* @param string $key
|
55 |
+
* @param mixed $value
|
56 |
+
* @param int $ttl
|
57 |
+
*
|
58 |
+
* @return bool
|
59 |
+
*/
|
60 |
+
protected function _add($key, $value, $ttl)
|
61 |
+
{
|
62 |
+
return apc_add($key, $value, $ttl);
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Get valuee from the storage and increase it's count by 1
|
67 |
+
*
|
68 |
+
* @param string $key
|
69 |
+
*
|
70 |
+
* @return int
|
71 |
+
*/
|
72 |
+
protected function _inc($key)
|
73 |
+
{
|
74 |
+
return apc_inc($key);
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Delete value from storage
|
79 |
+
*
|
80 |
+
* @param string $key
|
81 |
+
*
|
82 |
+
* @return mixed
|
83 |
+
*/
|
84 |
+
protected function _delete($key) {
|
85 |
+
return apc_delete($key);
|
86 |
}
|
87 |
+
|
88 |
}
|
lib/Aitoc/Aitloadmon/Adapter/File.php
CHANGED
@@ -3,114 +3,400 @@
|
|
3 |
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
* @license License agreement could be found at the root folder of this package
|
5 |
*/
|
6 |
-
class Aitoc_Aitloadmon_Adapter_File
|
7 |
{
|
8 |
const DS = DIRECTORY_SEPARATOR;
|
9 |
|
|
|
|
|
|
|
10 |
private static $_dataDir = 'data';
|
|
|
|
|
|
|
|
|
11 |
private static $_filename = 'data_';
|
12 |
|
13 |
/**
|
14 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
* @return string
|
17 |
*/
|
18 |
private function _getDataDir()
|
19 |
{
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
23 |
/**
|
24 |
-
*
|
25 |
-
*
|
26 |
* @return resource
|
27 |
*/
|
28 |
-
|
29 |
{
|
30 |
-
$
|
31 |
-
$
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
44 |
}
|
45 |
-
$i++;
|
46 |
}
|
47 |
-
|
|
|
|
|
|
|
48 |
}
|
49 |
-
|
50 |
/**
|
51 |
-
*
|
52 |
-
*
|
53 |
-
* @param string $
|
|
|
|
|
|
|
54 |
*/
|
55 |
-
|
56 |
{
|
57 |
-
$
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
/**
|
64 |
-
*
|
|
|
|
|
|
|
|
|
65 |
*
|
66 |
-
* @
|
67 |
*/
|
68 |
-
|
69 |
{
|
70 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
-
*
|
75 |
-
*
|
76 |
* @return array
|
77 |
*/
|
78 |
-
|
79 |
{
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
*
|
86 |
-
* @
|
|
|
|
|
87 |
*/
|
88 |
-
|
89 |
-
{
|
90 |
-
|
91 |
-
|
92 |
-
foreach($this->_getDataFileList() as $fileName)
|
93 |
-
{
|
94 |
-
if($fileName != '.' && $fileName != '..')
|
95 |
-
{
|
96 |
-
$fileHandle = fopen($dir.$fileName, 'r');
|
97 |
-
$locked = null;
|
98 |
-
while(!$locked)
|
99 |
-
{
|
100 |
-
$locked = flock($fileHandle, LOCK_EX);
|
101 |
-
}
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
111 |
}
|
|
|
|
|
112 |
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
}
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
3 |
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
* @license License agreement could be found at the root folder of this package
|
5 |
*/
|
6 |
+
class Aitoc_Aitloadmon_Adapter_File extends Aitoc_Aitloadmon_Adapter_Abstract
|
7 |
{
|
8 |
const DS = DIRECTORY_SEPARATOR;
|
9 |
|
10 |
+
/**
|
11 |
+
* @var string
|
12 |
+
*/
|
13 |
private static $_dataDir = 'data';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
private static $_filename = 'data_';
|
19 |
|
20 |
/**
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
private static $_storename = 'store';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var int
|
27 |
+
*/
|
28 |
+
private $_handleId = null;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var string
|
32 |
+
*/
|
33 |
+
private $_dataDirPath = null;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Amount of files used to store data. The bigger this value will be - the less is probability that concurrency for the file write permissions between requests will appear
|
37 |
+
*
|
38 |
+
* @var int
|
39 |
+
*/
|
40 |
+
private $_concurencyFileCount = 10;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Pointer to the file to which exceded data should be stored
|
44 |
+
* @var resource
|
45 |
+
*/
|
46 |
+
private $_storeFile = null;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Contain last id of case store file
|
50 |
+
* @var int
|
51 |
+
*/
|
52 |
+
private $_storeId = null;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Var to contain data from cache while it's readed
|
56 |
+
* @var array
|
57 |
+
*/
|
58 |
+
private $_data = array();
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Total amount of elements in _data array
|
62 |
+
* @var int
|
63 |
+
*/
|
64 |
+
private $_totalElements = 0;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @param array $settings
|
68 |
+
*
|
69 |
+
* @return Aitoc_Aitloadmon_Adapter_File
|
70 |
+
*/
|
71 |
+
public function __construct( $settings )
|
72 |
+
{
|
73 |
+
if(!file_exists($this->_getDataDir())) {
|
74 |
+
mkdir($this->_getDataDir());
|
75 |
+
}
|
76 |
+
parent::__construct($settings);
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Get value from a file
|
81 |
+
*
|
82 |
+
* @param string $file file name
|
83 |
+
*
|
84 |
+
* @return mixed
|
85 |
+
*/
|
86 |
+
protected function _get($file)
|
87 |
+
{
|
88 |
+
$file = $this->_getFilePath($file);
|
89 |
+
if(!file_exists($file)) {
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
return file_get_contents($file);
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Store value to the $handle file. If file name is given - open this file and put values inside it, then close
|
97 |
+
*
|
98 |
+
* @param mixed $handle File pointer resource or a string file name
|
99 |
+
* @param mixed $params string or array
|
100 |
+
* @param int $ttl
|
101 |
+
*
|
102 |
+
* @return bool
|
103 |
+
*/
|
104 |
+
protected function _set($handle, $params, $ttl)
|
105 |
+
{
|
106 |
+
$close = false;
|
107 |
+
if(!is_resource($handle)) {
|
108 |
+
$close = true;
|
109 |
+
$handle = $this->_openHandle( $this->_getFilePath($handle) );
|
110 |
+
}
|
111 |
+
if(is_array($params)) {
|
112 |
+
$params = serialize($params);
|
113 |
+
}
|
114 |
+
$return = fwrite($handle, $params.chr(0x0D).chr(0x0A));
|
115 |
+
if($close) {
|
116 |
+
$this->_closeHandle($handle);
|
117 |
+
}
|
118 |
+
return (bool)$return;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* @param mixed $handle
|
123 |
+
* @param mixed $params
|
124 |
+
* @param int $ttl
|
125 |
+
*
|
126 |
+
* @return bool
|
127 |
+
*/
|
128 |
+
protected function _add($key, $value, $ttl)
|
129 |
+
{
|
130 |
+
return $this->_set($key, $value, $ttl);
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @param string $key
|
135 |
+
*/
|
136 |
+
protected function _inc($key)
|
137 |
+
{
|
138 |
+
// not used because getHandle is overrided
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Delete value from storage
|
143 |
+
*
|
144 |
+
* @param string $key
|
145 |
+
*
|
146 |
+
* @return bool
|
147 |
+
*/
|
148 |
+
protected function _delete($file)
|
149 |
+
{
|
150 |
+
return unlink($file);
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Move data from $source to $target
|
155 |
+
*
|
156 |
+
* @param string $source Source file name
|
157 |
+
* @param string $target Target file name
|
158 |
*
|
159 |
+
* @return bool
|
160 |
+
*/
|
161 |
+
protected function _move($source, $target)
|
162 |
+
{
|
163 |
+
return rename($source, $target);
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Gets the path to the directory for the data files
|
168 |
+
*
|
169 |
* @return string
|
170 |
*/
|
171 |
private function _getDataDir()
|
172 |
{
|
173 |
+
if(is_null($this->_dataDirPath)) {
|
174 |
+
$this->_dataDirPath = Aitoc_Aitloadmon_Collect::getTempDir().self::$_dataDir.self::DS;
|
175 |
+
}
|
176 |
+
return $this->_dataDirPath;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Get full path to the file
|
181 |
+
*
|
182 |
+
* @param string $file
|
183 |
+
*
|
184 |
+
* @return string
|
185 |
+
*/
|
186 |
+
protected function _getFilePath( $file ) {
|
187 |
+
return $this->_getDataDir() . $file;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Get data file name for current pool
|
192 |
+
*
|
193 |
+
* @return string
|
194 |
+
*/
|
195 |
+
protected function _getDataFile()
|
196 |
+
{
|
197 |
+
return $this->_getDataDir() . self::$_filename . $this->_getCurrentPool(). '_';
|
198 |
}
|
199 |
|
200 |
+
protected function _getCacheStoreFile()
|
201 |
+
{
|
202 |
+
return $this->_getDataDir() . self::$_storename . '_';
|
203 |
+
}
|
204 |
+
|
205 |
/**
|
206 |
+
* Override parent, because file handles are different from APC increments
|
207 |
+
*
|
208 |
* @return resource
|
209 |
*/
|
210 |
+
protected function _getHandle()
|
211 |
{
|
212 |
+
$file_path = $this->_getDataFile();
|
213 |
+
if(is_null($this->_handleId)) {
|
214 |
+
$max = 50;
|
215 |
+
while($max > 0) {
|
216 |
+
$rand = rand(0,$this->_concurencyFileCount - 1);
|
217 |
+
$f = fopen($file_path.$rand, 'a');
|
218 |
+
if(flock($f, LOCK_EX | LOCK_NB)) {
|
219 |
+
$this->_handleId = $rand;
|
220 |
+
break;
|
221 |
+
}
|
222 |
+
fclose($f);
|
223 |
+
$max--;
|
224 |
+
}
|
225 |
+
if(!is_resource($f)) {
|
226 |
+
$this->_handleId = $this->_concurencyFileCount;
|
227 |
}
|
|
|
228 |
}
|
229 |
+
if(!isset($f) || !is_resource($f)) {
|
230 |
+
$f = $this->_openHandle($file_path . $this->_handleId, 'a');
|
231 |
+
}
|
232 |
+
return $f;
|
233 |
}
|
234 |
+
|
235 |
/**
|
236 |
+
* Open exclusive connection to the file
|
237 |
+
*
|
238 |
+
* @param string $file
|
239 |
+
* @param string $mode
|
240 |
+
*
|
241 |
+
* @return resource
|
242 |
*/
|
243 |
+
protected function _openHandle($file, $mode = 'w')
|
244 |
{
|
245 |
+
$handle = fopen($file, $mode);
|
246 |
+
flock($handle, LOCK_EX); //should wait until lock is aquired
|
247 |
+
return $handle;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Close resource connection to the file
|
252 |
+
*
|
253 |
+
* @param resource $handle
|
254 |
+
*/
|
255 |
+
protected function _closeHandle($handle)
|
256 |
+
{
|
257 |
+
flock($handle, LOCK_UN);
|
258 |
+
fclose($handle);
|
259 |
}
|
260 |
|
261 |
/**
|
262 |
+
* Read links log file and put data into $this->_data array. Returns $flag_store
|
263 |
+
*
|
264 |
+
* @param string $file_name
|
265 |
+
* @param boolean $flag_store
|
266 |
+
* @param boolean $force_full_file
|
267 |
*
|
268 |
+
* @return boolean
|
269 |
*/
|
270 |
+
protected function _readLogFile($file_name, $flag_store, $force_full_file = false)
|
271 |
{
|
272 |
+
$fileHandle = $this->_openHandle($file_name, 'r');
|
273 |
+
|
274 |
+
while($string = fgets($fileHandle)) {
|
275 |
+
$string = trim($string);
|
276 |
+
if($string == '') continue;
|
277 |
+
$element = unserialize($string);
|
278 |
+
if(isset($this->_data[$element['id']])) {
|
279 |
+
$this->_data[$element['id']] = array_merge($this->_data[$element['id']], $element['d']);
|
280 |
+
} else {
|
281 |
+
if($flag_store && $force_full_file == false) {
|
282 |
+
$this->_storeLog($string);
|
283 |
+
continue;
|
284 |
+
}
|
285 |
+
$this->_data[$element['id']] = $element['d'];
|
286 |
+
$this->_totalElements ++;
|
287 |
+
if($this->_totalElements >= $this->getRowsLimit()) {
|
288 |
+
$flag_store = true;
|
289 |
+
}
|
290 |
+
}
|
291 |
+
}
|
292 |
+
$this->_closeHandle($fileHandle);
|
293 |
+
return $flag_store;
|
294 |
}
|
295 |
|
296 |
/**
|
297 |
+
* Override parent because files have a little different structure than apc/memcache
|
298 |
+
*
|
299 |
* @return array
|
300 |
*/
|
301 |
+
protected function _getData()
|
302 |
{
|
303 |
+
$file_mask = $this->_getDataFile();
|
304 |
+
$files = glob($file_mask.'*');
|
305 |
+
$this->_data = array();
|
306 |
+
$this->_totalElements = 0;
|
307 |
+
$flag_store = false;
|
308 |
+
foreach($files as $file) {
|
309 |
+
if($flag_store) {
|
310 |
+
$this->_move( $file, $this->getNewStoreFilename() );
|
311 |
+
continue;
|
312 |
+
}
|
313 |
+
$flag_store = $this->_readLogFile($file, $flag_store);
|
314 |
+
$this->_delete($file);
|
315 |
+
}
|
316 |
+
|
317 |
+
if($this->_totalElements < $this->getRowsLimit() / 3) {
|
318 |
+
$this->_getStoreData();
|
319 |
+
}
|
320 |
+
//moving links to processor and not storing them inside class
|
321 |
+
$data = $this->_data;
|
322 |
+
$this->_data = array();
|
323 |
+
|
324 |
+
return $data;
|
325 |
}
|
326 |
|
327 |
/**
|
328 |
+
* Apply data from store cache files if there are any
|
329 |
+
*/
|
330 |
+
protected function _getStoreData()
|
331 |
+
{
|
332 |
+
$file_mask = $this->_getCacheStoreFile();
|
333 |
+
$files = glob($file_mask.'*');
|
334 |
+
$flag_store = false;
|
335 |
+
foreach($files as $file) {
|
336 |
+
//flag to force read complete file
|
337 |
+
$force_full_file = false;
|
338 |
+
$file_size= filesize($file);
|
339 |
+
if($file_size < 200 * 1024) {
|
340 |
+
$force_full_file = true;
|
341 |
+
}
|
342 |
+
$flag_store = $this->_readLogFile($file, $flag_store, $force_full_file);
|
343 |
+
$this->_delete($file);
|
344 |
+
if($flag_store) {
|
345 |
+
break;
|
346 |
+
}
|
347 |
+
}
|
348 |
+
}
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Move log line info store log file
|
352 |
*
|
353 |
+
* @param string $logLine
|
354 |
+
*
|
355 |
+
* @return bool
|
356 |
*/
|
357 |
+
protected function _storeLog($logLine)
|
358 |
+
{
|
359 |
+
return $this->_set($this->getStoreFile(), $logLine, 0);
|
360 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
|
362 |
+
/**
|
363 |
+
* Close store file handle if it was created
|
364 |
+
*
|
365 |
+
* @return Aitoc_Aitloadmon_Adapter_File
|
366 |
+
*/
|
367 |
+
protected function closeStoreFile()
|
368 |
+
{
|
369 |
+
if(is_resource($this->_storeFile)) {
|
370 |
+
$this->_closeHandle($this->_storeFile);
|
371 |
}
|
372 |
+
return $this;
|
373 |
+
}
|
374 |
|
375 |
+
/**
|
376 |
+
* @return resource
|
377 |
+
*/
|
378 |
+
public function getStoreFile()
|
379 |
+
{
|
380 |
+
if(is_null($this->_storeFile)) {
|
381 |
+
$this->_storeFile = $this->_openHandle( $this->getNewStoreFilename() );
|
382 |
+
}
|
383 |
+
return $this->_storeFile;
|
384 |
}
|
385 |
|
386 |
+
/**
|
387 |
+
* @return string
|
388 |
+
*/
|
389 |
+
protected function getNewStoreFilename()
|
390 |
+
{
|
391 |
+
$file_mask = $this->_getCacheStoreFile();
|
392 |
+
if(is_null($this->_storeId)) {
|
393 |
+
$files = glob($file_mask.'*');
|
394 |
+
$this->_storeId = count($files);
|
395 |
+
}
|
396 |
+
$this->_storeId ++;
|
397 |
+
while(file_exists($file_mask . $this->_storeId)) {
|
398 |
+
$this->_storeId ++ ;
|
399 |
+
}
|
400 |
+
return $file_mask . $this->_storeId;
|
401 |
+
}
|
402 |
}
|
lib/Aitoc/Aitloadmon/Adapter/Memcached.php
CHANGED
@@ -3,64 +3,92 @@
|
|
3 |
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
* @license License agreement could be found at the root folder of this package
|
5 |
*/
|
6 |
-
class Aitoc_Aitloadmon_Adapter_Memcached
|
7 |
{
|
8 |
-
private static $DATA_KEY = 'aitloadmon_data';
|
9 |
-
private static $DATA_NUM_KEY = 'aitloadmon_data_key';
|
10 |
-
|
11 |
private $_cache;
|
12 |
-
|
13 |
/**
|
14 |
-
* Initiates the connection to memcache
|
15 |
*
|
16 |
* @param array $settings
|
17 |
*/
|
18 |
-
public function __construct($settings)
|
19 |
{
|
|
|
|
|
|
|
20 |
$this->_cache = new Memcache;
|
21 |
-
$this->_cache->connect($settings['host'], $settings['port']);
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
* @param
|
|
|
|
|
28 |
*/
|
29 |
-
|
30 |
{
|
31 |
-
|
32 |
-
{
|
33 |
-
$this->_cache->set(self::$DATA_NUM_KEY, 1);
|
34 |
-
$index = 1;
|
35 |
-
}
|
36 |
-
|
37 |
-
while(!$this->_cache->add(self::$DATA_KEY.$index,$params))
|
38 |
-
{
|
39 |
-
$index++;
|
40 |
-
}
|
41 |
-
$this->_cache->set(self::$DATA_NUM_KEY, $index);
|
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 |
}
|
3 |
* @copyright Copyright (c) 2013 AITOC, Inc.
|
4 |
* @license License agreement could be found at the root folder of this package
|
5 |
*/
|
6 |
+
class Aitoc_Aitloadmon_Adapter_Memcached extends Aitoc_Aitloadmon_Adapter_Abstract
|
7 |
{
|
|
|
|
|
|
|
8 |
private $_cache;
|
9 |
+
|
10 |
/**
|
11 |
+
* Initiates the connection to memcache and generate special module prefixes where data will be stored
|
12 |
*
|
13 |
* @param array $settings
|
14 |
*/
|
15 |
+
public function __construct( $settings )
|
16 |
{
|
17 |
+
if(!class_exists('Memcache', false)) {
|
18 |
+
throw new Exception('Memcache is not installed on your system and can not be used as adapter for Server Load Monitor');
|
19 |
+
}
|
20 |
$this->_cache = new Memcache;
|
21 |
+
$result = $this->_cache->connect($settings['host'], $settings['port']);
|
22 |
+
if(!$result) {
|
23 |
+
throw new Exception('Memcache connections s not initialized. Please check your settings');
|
24 |
+
}
|
25 |
+
parent::__construct($settings);
|
26 |
+
$this->_storeParams = true;
|
27 |
+
$this->_dataPrefix = $this->_getPrefix() . Aitoc_Aitloadmon_Adapter_Abstract::$DATA_KEY;
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
+
* Get value from a storage by $key
|
32 |
+
*
|
33 |
+
* @param string $key
|
34 |
+
*
|
35 |
+
* @return mixed
|
36 |
*/
|
37 |
+
protected function _get($key)
|
38 |
{
|
39 |
+
return $this->_cache->get($key);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
+
|
42 |
/**
|
43 |
+
* Store value to the storage by $key, replace old values
|
44 |
+
*
|
45 |
+
* @param string $key
|
46 |
+
* @param mixed $value
|
47 |
+
* @param int $ttl
|
48 |
+
*
|
49 |
+
* @return bool
|
50 |
*/
|
51 |
+
protected function _set($key, $value, $ttl)
|
52 |
{
|
53 |
+
return $this->_cache->set($key, $value, false, $ttl);
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Add value to the storage by key, return false if value exists
|
58 |
+
*
|
59 |
+
* @param string $key
|
60 |
+
* @param mixed $value
|
61 |
+
* @param int $ttl
|
62 |
+
*
|
63 |
+
* @return bool
|
64 |
+
*/
|
65 |
+
protected function _add($key, $value, $ttl)
|
66 |
+
{
|
67 |
+
return $this->_cache->add($key, $value, false, $ttl);
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Get valuee from the storage and increase it's count by 1
|
72 |
+
*
|
73 |
+
* @param string $key
|
74 |
+
*
|
75 |
+
* @return int
|
76 |
+
*/
|
77 |
+
protected function _inc($key)
|
78 |
+
{
|
79 |
+
return $this->_cache->increment($key);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Delete value from storage
|
84 |
+
*
|
85 |
+
* @param string $key
|
86 |
+
*
|
87 |
+
* @return mixed
|
88 |
+
*/
|
89 |
+
protected function _delete($key)
|
90 |
+
{
|
91 |
+
return $this->_cache->delete($key);
|
92 |
}
|
93 |
+
|
94 |
}
|
lib/Aitoc/Aitloadmon/Collect.php
CHANGED
@@ -13,6 +13,8 @@ class Aitoc_Aitloadmon_Collect
|
|
13 |
private static $_loadLevel;
|
14 |
private static $_pathAddon;
|
15 |
private static $_timeOffset = 0;
|
|
|
|
|
16 |
private $_uniqueId;
|
17 |
private $_startWritten;
|
18 |
|
@@ -38,12 +40,16 @@ class Aitoc_Aitloadmon_Collect
|
|
38 |
self::$_enabled = false;
|
39 |
$config = simplexml_load_file(self::_getRootPath().self::DS.'app'.self::DS.'etc'.self::DS.'modules'.self::DS.'Aitoc_Aitloadmon.xml');
|
40 |
if ($config){
|
41 |
-
self::$_enabled = (string)$config->modules->Aitoc_Aitloadmon->active;
|
42 |
}
|
43 |
}
|
44 |
return self::$_enabled;
|
45 |
}
|
46 |
|
|
|
|
|
|
|
|
|
47 |
|
48 |
/**
|
49 |
* Checks if module is enabled and if it is writes the start data
|
@@ -99,10 +105,14 @@ class Aitoc_Aitloadmon_Collect
|
|
99 |
*/
|
100 |
private function _save()
|
101 |
{
|
|
|
|
|
|
|
102 |
if(!$this->_startWritten)
|
103 |
{
|
104 |
$saveData = array(
|
105 |
-
$this->_getUniqueId()
|
|
|
106 |
'request_uri' => $_SERVER['REQUEST_URI'],
|
107 |
'start' => microtime(true),
|
108 |
)
|
@@ -110,10 +120,10 @@ class Aitoc_Aitloadmon_Collect
|
|
110 |
}
|
111 |
else
|
112 |
{
|
113 |
-
$microtime = microtime(true) + self::$_timeOffset;
|
114 |
$saveData = array(
|
115 |
-
$this->_getUniqueId()
|
116 |
-
|
|
|
117 |
)
|
118 |
);
|
119 |
}
|
@@ -144,11 +154,25 @@ class Aitoc_Aitloadmon_Collect
|
|
144 |
if(!isset(self::$_adapter))
|
145 |
{
|
146 |
$settings = self::_getSettings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
|
148 |
if(!isset($settings['adapter']))
|
149 |
{
|
150 |
throw new Exception('No adapter specified in settings');
|
151 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
$adapterName = ucfirst(strtolower($settings['adapter']));
|
154 |
$adapterClassFile = self::_getRootPath().self::DS.'lib'.self::DS.'Aitoc'.self::DS.'Aitloadmon'.self::DS.'Adapter'.self::DS.$adapterName.'.php';
|
@@ -166,6 +190,25 @@ class Aitoc_Aitloadmon_Collect
|
|
166 |
return self::$_adapter;
|
167 |
}
|
168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
/**
|
171 |
* Gets the settings array
|
@@ -182,26 +225,26 @@ class Aitoc_Aitloadmon_Collect
|
|
182 |
if ($config){
|
183 |
$cacheEngine = (string)$config->global->cache->backend;
|
184 |
}
|
|
|
185 |
switch($cacheEngine)
|
186 |
{
|
187 |
case 'memcached':
|
188 |
-
$
|
|
|
|
|
189 |
break;
|
190 |
|
191 |
case 'apc':
|
192 |
-
$
|
|
|
193 |
break;
|
194 |
|
195 |
default:
|
196 |
-
$
|
197 |
|
198 |
}
|
199 |
-
|
200 |
-
|
201 |
-
mkdir(self::getTempDir());
|
202 |
-
}
|
203 |
-
file_put_contents(self::_getSettingsFilename(),$settingsString);
|
204 |
-
|
205 |
}
|
206 |
|
207 |
$settings = parse_ini_file(self::_getSettingsFilename());
|
@@ -221,6 +264,18 @@ class Aitoc_Aitloadmon_Collect
|
|
221 |
return $data;
|
222 |
}
|
223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
/**
|
225 |
* Gets the full path of a file with current load level
|
226 |
*
|
13 |
private static $_loadLevel;
|
14 |
private static $_pathAddon;
|
15 |
private static $_timeOffset = 0;
|
16 |
+
private static $_cacheOffsetTime = 3600;
|
17 |
+
private static $_allowLog = true;
|
18 |
private $_uniqueId;
|
19 |
private $_startWritten;
|
20 |
|
40 |
self::$_enabled = false;
|
41 |
$config = simplexml_load_file(self::_getRootPath().self::DS.'app'.self::DS.'etc'.self::DS.'modules'.self::DS.'Aitoc_Aitloadmon.xml');
|
42 |
if ($config){
|
43 |
+
self::$_enabled = ('true' == (string)$config->modules->Aitoc_Aitloadmon->active);
|
44 |
}
|
45 |
}
|
46 |
return self::$_enabled;
|
47 |
}
|
48 |
|
49 |
+
public static function isAllowedToSave()
|
50 |
+
{
|
51 |
+
return self::$_allowLog;
|
52 |
+
}
|
53 |
|
54 |
/**
|
55 |
* Checks if module is enabled and if it is writes the start data
|
105 |
*/
|
106 |
private function _save()
|
107 |
{
|
108 |
+
if(!self::isAllowedToSave()) {
|
109 |
+
return false;
|
110 |
+
}
|
111 |
if(!$this->_startWritten)
|
112 |
{
|
113 |
$saveData = array(
|
114 |
+
'id' => $this->_getUniqueId(),
|
115 |
+
'd' => array(
|
116 |
'request_uri' => $_SERVER['REQUEST_URI'],
|
117 |
'start' => microtime(true),
|
118 |
)
|
120 |
}
|
121 |
else
|
122 |
{
|
|
|
123 |
$saveData = array(
|
124 |
+
'id' => $this->_getUniqueId(),
|
125 |
+
'd' => array(
|
126 |
+
'end' => microtime(true),
|
127 |
)
|
128 |
);
|
129 |
}
|
154 |
if(!isset(self::$_adapter))
|
155 |
{
|
156 |
$settings = self::_getSettings();
|
157 |
+
if(!isset($settings['cron_date'])) {
|
158 |
+
$settings['cron_date'] = time();
|
159 |
+
self::_saveConfig($settings);
|
160 |
+
}
|
161 |
+
if($settings['cron_date'] + self::$_cacheOffsetTime < time()) {
|
162 |
+
self::$_allowLog = false;
|
163 |
+
}
|
164 |
|
165 |
if(!isset($settings['adapter']))
|
166 |
{
|
167 |
throw new Exception('No adapter specified in settings');
|
168 |
}
|
169 |
+
$abstractClassFile = self::_getRootPath().self::DS.'lib'.self::DS.'Aitoc'.self::DS.'Aitloadmon'.self::DS.'Adapter'.self::DS.'Abstract.php';
|
170 |
+
if(!file_exists($abstractClassFile))
|
171 |
+
{
|
172 |
+
throw new Exception('Abstract does not exists: Aitoc_Aitloadmon_Adapter_Abstract');
|
173 |
+
}
|
174 |
+
|
175 |
+
include_once($abstractClassFile);
|
176 |
|
177 |
$adapterName = ucfirst(strtolower($settings['adapter']));
|
178 |
$adapterClassFile = self::_getRootPath().self::DS.'lib'.self::DS.'Aitoc'.self::DS.'Aitloadmon'.self::DS.'Adapter'.self::DS.$adapterName.'.php';
|
190 |
return self::$_adapter;
|
191 |
}
|
192 |
|
193 |
+
/**
|
194 |
+
* Save array to config ini file
|
195 |
+
*
|
196 |
+
* @param array $settings
|
197 |
+
*
|
198 |
+
* @return bool
|
199 |
+
*/
|
200 |
+
private static function _saveConfig($settings)
|
201 |
+
{
|
202 |
+
$settingsString = '';
|
203 |
+
foreach($settings as $key => $value) {
|
204 |
+
$settingsString .= $key.' = "'.$value."\"\r\n";
|
205 |
+
}
|
206 |
+
if(!file_exists(self::getTempDir()))
|
207 |
+
{
|
208 |
+
mkdir(self::getTempDir());
|
209 |
+
}
|
210 |
+
return (bool)file_put_contents(self::_getSettingsFilename(),$settingsString);
|
211 |
+
}
|
212 |
|
213 |
/**
|
214 |
* Gets the settings array
|
225 |
if ($config){
|
226 |
$cacheEngine = (string)$config->global->cache->backend;
|
227 |
}
|
228 |
+
$settings = array();
|
229 |
switch($cacheEngine)
|
230 |
{
|
231 |
case 'memcached':
|
232 |
+
$settings['adapter'] = 'memcached';
|
233 |
+
$settings['host'] = (string)$config->global->cache->memcached->servers->server->host;
|
234 |
+
$settings['port'] = (string)$config->global->cache->memcached->servers->server->port;
|
235 |
break;
|
236 |
|
237 |
case 'apc':
|
238 |
+
$settings['adapter'] = 'apc';
|
239 |
+
$settings['host'] = (string)$config->global->cache->prefix;
|
240 |
break;
|
241 |
|
242 |
default:
|
243 |
+
$settings['adapter'] = 'file';
|
244 |
|
245 |
}
|
246 |
+
$settings['cron_date'] = time(); //first clean run of this script
|
247 |
+
self::_saveConfig($settings);
|
|
|
|
|
|
|
|
|
248 |
}
|
249 |
|
250 |
$settings = parse_ini_file(self::_getSettingsFilename());
|
264 |
return $data;
|
265 |
}
|
266 |
|
267 |
+
/**
|
268 |
+
* Set up time when cron was started last time in config.ini file
|
269 |
+
*
|
270 |
+
* @return bool
|
271 |
+
*/
|
272 |
+
public static function saveCronStartedFlag()
|
273 |
+
{
|
274 |
+
$settings = self::_getSettings();
|
275 |
+
$settings['cron_date'] = time();
|
276 |
+
return self::_saveConfig($settings);
|
277 |
+
}
|
278 |
+
|
279 |
/**
|
280 |
* Gets the full path of a file with current load level
|
281 |
*
|
package.xml
CHANGED
@@ -1,39 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>ServerLoadMonitorFree</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
-
<license
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
|
11 |
-
Server Load Monitor
|
12 |
-
<
|
13 |
-
|
14 |
-
|
15 |
-

|
16 |
-
• Allows for monitoring the following: CMS, Checkout, Catalog, Catalog Search and other pages; 
|
17 |
-
• Divides server performance into four intuitive color-coded zones; 
|
18 |
-
• Allows for tracking Average and Max page load and load time for a selected time period;
|
19 |
-
• Displays load statistics in the form of easy and intuitive diagrams in the back-end;
|
20 |
-
• Displays color-coded live server load info in the Admin panel;
|
21 |
-
• Provides statistics for every minute; 
|
22 |
-
• Allows for comparing stats for different time periods;
|
23 |
-
• Load statistics are stored in a database;
|
24 |
-
• Compresses data automatically to avoid overloading the database. Default compression settings are optimized and recommended, but Admin is enabled to choose preferred compression settings as well as compress the data manually;
|
25 |
-
• Sends data to AITOC’s Server Calculator*; 
|
26 |
-
• Comes with a User Manual;
|
27 |
-
• The extension's functionality code is 100% Open Source.
|
28 |
-

|
29 |
-
* Please note that collected data will be sent to AITOC's Server Calculator in order to configure and recommend you better server settings. If you wish to disable sending data for Server Calculator stats, disable the ads, and get alerts about critical load peaks, please get the <a href=”http://aitoc.com/en/magentomods_ server_load_monitor_paid.htm”>paid version</a> of the extension.</description>
|
30 |
-
<notes>09.09.2013 
|
31 |
-

|
32 |
-
* Fixed the issue with access to extension by admin with restricted permissions.</notes>
|
33 |
-
<authors><author><name>AITOC</name><user>auto-converted</user><email>aitoc-connect@aitoc.com</email></author></authors>
|
34 |
-
<date>2013-09-23</date>
|
35 |
-
<time>12:31:50</time>
|
36 |
-
<contents><target name="magelocal"><dir name="Aitoc"><dir name="Aitloadmon"><dir name="Block"><dir name="Adminhtml"><dir name="Aitloadmon"><file name="BarGraph.php" hash="90e16b55a20987cdd214bc6da435ea6d"/><file name="Filter.php" hash="eade4a66c1a68f1a2334138fd4c33d3a"/><file name="LineGraph.php" hash="4eee44af29cb9588268044d8fc516fd0"/></dir><file name="Aitlink.php" hash="4ea78c7a1d6f9e31aead66249a256a1d"/><file name="Aitloadmon.php" hash="5be3738e8cf84e5b85806701d6efbcd2"/><file name="Calculator.php" hash="4e08727116a1ac204bce97dab899b2e0"/><file name="CalculatorResult.php" hash="6d48c208e97c09a450302837a20b618c"/><file name="Indicator.php" hash="9d1e87229cef34dafe0d2ec435f6bb9f"/><file name="Manage.php" hash="dbfdb4f6d788fba1469ab0a61fde9d9d"/></dir></dir><dir name="Helper"><file name="Data.php" hash="876ae674bbf6cc06dcbc7839e61028e1"/></dir><dir name="Model"><dir name="Calculator"><file name="Abstract.php" hash="f525c95d18986065984dcfd7b5211942"/><file name="Hardware.php" hash="1164c19b50d86b9a71da74f9629c2e1d"/><file name="Magento.php" hash="918dac7ec4fcd4ba4393faa13c5c2417"/><file name="Software.php" hash="a523bba11e6781151ed32fac9da14246"/></dir><dir name="Mysql4"><dir name="Aitloadmon"><file name="Collection.php" hash="c5b65db67cedba6f28279ff78fd4f353"/></dir><dir name="Calculator"><file name="Collection.php" hash="15170dd43faeebdfc30e42ebd6270c28"/></dir><dir name="Dblog"><file name="Collection.php" hash="3dc0dcc5e9d3bb5951573d3d11a8e4dc"/></dir><file name="Aitloadmon.php" hash="2aa72df90f50823274a1a6b232c371d6"/><file name="Calculator.php" hash="7354931dd66342f5071f782b5de7401e"/><file name="Dblog.php" hash="4f4e76036d37c170fdf4771f2669dce8"/><file name="UrlRewrite.php" hash="08aecaea96122e801cdb2f9793e22ddf"/></dir><dir name="System"><file name="Abstract.php" hash="1cdc94c9f08d4507ef57fe766f30fe13"/></dir><file name="Aitloadmon.php" hash="8c7e29b4f586640975b8283688ab8bb7"/><file name="Analytics.php" hash="a223097ec56f7eea3329d43fe7e2956b"/><file name="Calculator.php" hash="84c46b31725072226f6f1e071e5a67b1"/><file name="CompressSource.php" hash="65b4aa585216893143d7ca28bfda6645"/><file name="Dblog.php" hash="4c134db8959a150f8031b71787ae2503"/><file name="LevelSource.php" hash="1937e32cc2b08ffbfc875d3a2f0d362b"/><file name="Manage.php" hash="6b06b0dbbb19d098b1414c6cd4a1bb8a"/><file name="Observer.php" hash="a58aa407da9971ba9cc30afb5be41248"/><file name="Process.php" hash="0ae9c0e159a108f47e920c7071882db5"/><file name="Router.php" hash="91ed3d96b51501d3852e8a2573c58674"/><file name="SysInfo.php" hash="a5c868f2ec1fa10cbbbca85c917a63f9"/><file name="System.php" hash="6eeee453abc5efd3c35a24babe613609"/><file name="UrlRewrite.php" hash="ea3849ee4bedc6422b03bdb4be2535fd"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AitloadmonController.php" hash="0c5f48b6086679ccdb1334d3d9e1e2a4"/><file name="CalculatorController.php" hash="1b453f63fa4820c1cc2d87790bb89830"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2a3046ce15833ca2704cb9d24737d62f"/><file name="config.xml" hash="9261658dfc9ac9d4459dbae48c89f785"/><file name="system.xml" hash="e2b9300c1ad1ea759e77f61b7d381869"/></dir><dir name="sql"><dir name="aitloadmon_setup"><file name="mysql4-install-1.0.0.php" hash="bb6d6c9aec69500be4a10d7944a82dfc"/><file name="mysql4-uninstall-1.0.0.php" hash="177151acef7c5d0c376f1d49bc5ce8c7"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="f2ae0c006d0180d3dc3fae7829135d52"/></dir></dir></dir><dir name="Aitsys"><dir name="install"><file name="Aitoc_Aitloadmon.phtml" hash="9a81474e26aac8b23a5b2d2cdd6ab30d"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="aitloadmon.xml" hash="5d8447f20382ed3a9aaab19cebc1e7b6"/></dir><dir name="template"><dir name="aitloadmon"><file name="back.phtml" hash="ccc9f0ff80649046eddf0faa3b1b50c5"/><file name="bar.phtml" hash="2bd5dd221588543850d3f9a4f4a9e35e"/><file name="graph.phtml" hash="097408b5b89d48df6e80953d0c6a379a"/><file name="indicator.phtml" hash="f0dce9d5c49118b7f98573a91766c563"/><file name="line.phtml" hash="b5e5eb4bc32fd6fdc161d84aed01ba42"/><file name="quick.phtml" hash="b0eecb7f8296c293d7abff2cddc5aa5c"/><file name="sysInfo.phtml" hash="674767482f77361975c90c8bc412e4a5"/><file name="system.phtml" hash="b17117164a92d0fda7c99e9cf7027938"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Aitoc_Aitloadmon.xml" hash="f9495b99199f39960003b4e6270baacf"/></dir></target><target name="magelib"><dir name="Aitoc"><dir name="Aitloadmon"><dir name="Adapter"><file name="Apc.php" hash="c67c74af65e094da996e39f0a8451d62"/><file name="File.php" hash="e440b9dc1c0792680043b8288d22f0a5"/><file name="Memcached.php" hash="b770d4016679b99e9dee9f82e28838a4"/></dir><file name="Collect.php" hash="9178d6ff1c4a5b5873652810a5f1b3b2"/></dir></dir></target><target name="mageweb"><dir name="js"><dir name="aitoc"><dir name="aitloadmon"><file name="grafico.bar.custom.js" hash="e54db4c61047afb27a56968a8eec9fc4"/><file name="grafico.line.custom.js" hash="1eee2034b47debfb9a746116979ddfa1"/><file name="grafico.min.js" hash="cde1bec6859b10e4a179aadec3c7e232"/><file name="raphael-min.js" hash="20908f0263d452ea59b1b528145c1a47"/></dir></dir></dir></target><target name="mage"><dir name="."><file name="readme.txt" hash="33729d5788f0da4048501c989079b42e"/><file name="License agreement Server Load Monitor.pdf" hash="2c37f69a12f4508aa13181f6cefd264b"/><file name="Server Load Monitor Manual.pdf" hash="21465278b287e1a35d900a92233b796a"/></dir></target></contents>
|
37 |
<compatible/>
|
38 |
-
<dependencies
|
39 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>ServerLoadMonitorFree</name>
|
4 |
+
<version>1.0.9</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license>Free</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Server Load Monitor</summary>
|
10 |
+
<description>Server Load Monitor</description>
|
11 |
+
<notes>Server Load Monitor</notes>
|
12 |
+
<authors><author><name>Aitoc</name><user>Aitoc</user><email>sales@aitoc.com</email></author></authors>
|
13 |
+
<date>2015-10-20</date>
|
14 |
+
<time>13:57:27</time>
|
15 |
+
<contents><target name="mage"><dir><dir name="app"><dir name="code"><dir name="community"><dir name="Aitoc"><dir name="Aitinstall"><dir name="Helper"><file name="Data.php" hash="3056cfc06058062b2c0e7aa09f0e8799"/></dir><dir name="etc"><file name="config.xml" hash="c1096c76af2e94181945690e403f239c"/></dir></dir><dir name="Aitsys"><dir name="Abstract"><dir name="Adminhtml"><file name="Block.php" hash="9dfe8b5aa4a67fecd85caed17de0992a"/><file name="Controller.php" hash="5c57660eb8dab3a33fe9ee11f42bd233"/></dir><file name="Block.php" hash="66a2780b4d8d62b024ec5acd8d21d4ae"/><file name="Helper.php" hash="0e092ae5a8ce4ef009cc3c20b53fb26d"/><dir name="Model"><file name="Interface.php" hash="d0365638ac1b670e988897c7a52266fa"/></dir><file name="Model.php" hash="ea153354da2138c7a679b0b9b72c930f"/><dir name="Mysql4"><file name="Collection.php" hash="064261de0a6362df2f89f576bb8ba160"/></dir><file name="Mysql4.php" hash="27c5621da51068117252f7e965bb1dd6"/><file name="Pure.php" hash="925122d5903d559d807d8d3fef2473ea"/><dir name="Resource"><dir name="Eav"><file name="Setup.php" hash="80c19e475240a9b350d2b925f84da4f6"/></dir><file name="Setup.php" hash="ffe515f44f031a6c2d2b29e9f88c9fd9"/></dir><file name="Service.php" hash="91a7430901e368931af1d570ce55d79a"/><file name="Version.php" hash="1995dfec8e79f4cf2c29d050415e3760"/></dir><dir name="Block"><file name="Edit.php" hash="d59bb4f386f9a37d1d0372f05770ae90"/><dir name="Form"><dir name="Element"><file name="Renderer.php" hash="b94e9a93b782d7a258f9e0de33bcb008"/></dir></dir><file name="Form.php" hash="56f22b33dcdd121241a45899a6d8011c"/><file name="News.php" hash="46d1f8d6a63564ea83a3ebb06b82b586"/><dir name="Patch"><dir name="Instruction"><file name="One.php" hash="a974167f34b841a01209542b05ce94e2"/></dir><file name="Instruction.php" hash="86fc6a7f02dc89214f3ffe7f20082bcf"/><file name="View.php" hash="a2e8ce3c273b00fbe8a2312455f8a11f"/></dir><dir name="Rewriter"><file name="List.php" hash="5f814a8103339a337c14bdc59fbe1036"/><file name="Notifications.php" hash="302b1d5cc16263fee4e739c85708b696"/></dir><dir name="System"><dir name="Config"><dir name="Frontend"><file name="Extensions.php" hash="3772ccba7dbb79d7159c526bb8696491"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7f8205247f7b1adb34a8051f9abbe41f"/><file name="License.php" hash="17ac7757d6e2d22e82dc59c6d5ab771e"/><file name="Rewriter.php" hash="9255c198d4fc14a412ebfa45e1989d1d"/><file name="Statistics.php" hash="7803148d46142d20a17152fed6f4e5e7"/><file name="Strings.php" hash="8afba5d8196d9c3f2bad35f214dc3aea"/></dir><dir name="Model"><file name="Aitfilepatcher.php" hash="95960ff7106db785a0f95fb7534d3bff"/><dir name="Aitpatch"><file name="Observer.php" hash="6f16cce92605c4f53de9b0d8505d2628"/></dir><file name="Aitpatch.php" hash="57be6be7109364e31e4dbd156dee1714"/><file name="Aitsys.php" hash="21900503d12c3c149bc680c673d87b8d"/><dir name="Core"><file name="Cache.php" hash="bf95899bcc5eb015c07c8cf985892c10"/><dir name="Compiler"><file name="Process.php" hash="7e816ee277f9252720f2ddf46116ac34"/><file name="Rules.php" hash="35668fbe98cb2edfebd9fa293a13cd55"/></dir><file name="Database.php" hash="ad62a0c0f135e3c30b78c438c78e711a"/><dir name="Filesystem"><file name="Exception.php" hash="9baff87ee534e3df433f39ed49b7c2b4"/></dir><file name="Filesystem.php" hash="893fd9be24bd05ec9e2dc6867553348c"/></dir><file name="Feed.php" hash="d01c76bc15730c0d585b31b81834e453"/><dir name="Module"><file name="Abstract.php" hash="782d557875fe54cec4c0612499582ec7"/><dir name="Info"><file name="Abstract.php" hash="23d950c4ccaac19bfa8629a537139c3f"/><file name="Config.php" hash="f8e258e1b637e082cd41c292d4051229"/><file name="Exception.php" hash="c8d9bc28e2e7c7f741d456c52b71f569"/><file name="Factory.php" hash="c28d327e557ed1c2bad346a73541edfa"/><file name="Fallback.php" hash="7acfa7c0edc7af5fcec17b360116d6e0"/><file name="Package.php" hash="1f09cfb8de005545c69a86d3f9070d94"/><dir name="Xml"><file name="Abstract.php" hash="5fc0f0303050845405d0180ceaed5026"/></dir></dir><file name="Install.php" hash="4d2d4637d5d8ce1538935f280f6ba2a2"/><file name="Status.php" hash="28e7faceab1d275779e2abcc5b7e8059"/></dir><file name="Module.php" hash="ff730e6b94818f8626aaf0b334a48a4a"/><dir name="Mysql4"><dir name="Module"><dir name="Status"><file name="Collection.php" hash="e9230f70f291b2c1e588636ae9099807"/></dir><file name="Status.php" hash="2d84cc472d2ef5af16f726682d560454"/></dir><dir name="News"><file name="Collection.php" hash="4ba91331e3a62493307e61232cb91bf9"/></dir><file name="News.php" hash="97b638d24514e12a97d2ff17914d0726"/><file name="Setup.php" hash="84c423a2c127ef046ec8b8710f67757a"/></dir><dir name="News"><file name="Important.php" hash="89d45596b305af5837a3bd3a4b002f81"/><file name="Recent.php" hash="ad222ba3ef721486a0afbf79e14e2cb7"/></dir><file name="News.php" hash="9c30e7b0f9da143578e373d8933d2ff6"/><file name="Observer.php" hash="6f0b16dcd32e1d8688ba34d0b5e928ea"/><file name="Platform.php" hash="cd0aab870dde3a833afa8dce3479289a"/><dir name="Rewriter"><file name="Abstract.php" hash="4e10a94641315ac004130d7368bea935"/><file name="Autoload.php" hash="4171883b7b4b901d1f5f4a18e3fb9786"/><file name="Class.php" hash="5eb649c68df23fb80e9da0c81b351143"/><file name="Config.php" hash="27f57a2a33eab402ab075e2a6355c642"/><file name="Conflict.php" hash="7b97ef67e601033afe3050f00604fbe8"/><file name="Inheritance.php" hash="1c3b18c3e250e7c1440da6839301a3ca"/><file name="MageConfig.php" hash="56c44b44854ee696e9b68251c8b41e97"/><file name="Merge.php" hash="affc226417d3e8338f310984223d3d88"/><file name="Observer.php" hash="af70fbc23165dfe7e38a90daf9e73886"/></dir><file name="Rewriter.php" hash="9b6581a9a923e9f36fc4b9fc97c9d4ba"/><dir name="Service"><file name="Exception.php" hash="07dcf514ca9d35044846b859e0094172"/></dir><file name="Service.php" hash="72e13d563f7350aaa078dff097b07db2"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Stores.php" hash="c6473e8d3f27eaa64c1f08d4709c88fa"/></dir><dir name="Source"><file name="Interest.php" hash="637d92895f57be59a580ffeea98808bd"/><file name="Stores.php" hash="f850c1093056612e700751ce9a05902d"/></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="adc6f7a42e3a10c27c49cbd3cf37a714"/><file name="PatchController.php" hash="32d8b3120a5eecf2d2729096dda9b359"/><file name="RewriterController.php" hash="e40051a48875f66470d969f456383290"/></dir><dir name="etc"><file name="adminhtml.xml" hash="0583b06643b0f54ce82df2a19f7c1ff9"/><file name="compilation.xml" hash="4559bed606f5665786a314073068dc55"/><file name="config.xml" hash="999669ef88c89e6a9222ff5a3a472f4e"/><file name="system.xml" hash="021f72dce9b477bc5dd7a2a2c7fa389f"/></dir><dir name="sql"><dir name="aitsys_setup"><file name="mysql4-install-2.0.0.php" hash="654f663ea57083b5e29e63634cf567fd"/><file name="mysql4-install-3.0.0.php" hash="54986a25c257d2426e8b89460161fdde"/><file name="mysql4-upgrade-1.0-2.0.0.php" hash="d63ced0b16c966dec07e1b7013904b38"/><file name="mysql4-upgrade-1.0.0-2.0.0.php" hash="654f663ea57083b5e29e63634cf567fd"/><file name="mysql4-upgrade-2.14.6-2.15.0.php" hash="0b5205d2119a09a232c305ef531bdcc1"/><file name="mysql4-upgrade-2.15.5-2.15.6.php" hash="a54b4d30d419ebfab6e2ccb2f7b81b45"/><file name="mysql4-upgrade-2.20.1-2.21.0.php" hash="85cefc91c273c30229d503489fd8b0db"/><file name="mysql4-upgrade-2.7.3-2.7.4.php" hash="18f0d52abc066175feec6d14f6cdd72e"/><file name="mysql4-upgrade-2.99.0-3.0.0.php" hash="e21bc60063b3cc039d0c4d7b49ba9237"/><file name="mysql4-upgrade-3.0.3-3.1.0.php" hash="df374e499f710b767b8b1139db9f3f4d"/><file name="mysql4-upgrade-3.1.4-3.2.0.php" hash="7413d451b5199df8338ed48356292253"/></dir></dir></dir></dir></dir><dir name="local"><dir name="Aitoc"><dir name="Aitloadmon"><dir name="Block"><dir name="Adminhtml"><file name="Aitlink.php" hash="4ea78c7a1d6f9e31aead66249a256a1d"/><dir name="Aitloadmon"><file name="BarGraph.php" hash="90e16b55a20987cdd214bc6da435ea6d"/><file name="Filter.php" hash="2e896da1317f8f86d1f4a52044ef1d75"/><file name="LineGraph.php" hash="99e8041f9491929a0f2c7ce486f2b486"/></dir><file name="Aitloadmon.php" hash="0dd446033cce4c1f1c47b7142ffebec2"/><file name="Calculator.php" hash="7e3d6b4e78c6d5780f138998ccb57dfe"/><file name="CalculatorResult.php" hash="5a20fe4e518caee343e43c6879370b15"/><file name="Indicator.php" hash="9d1e87229cef34dafe0d2ec435f6bb9f"/><file name="Manage.php" hash="dbfdb4f6d788fba1469ab0a61fde9d9d"/></dir></dir><dir name="Helper"><file name="Data.php" hash="876ae674bbf6cc06dcbc7839e61028e1"/></dir><dir name="Model"><file name="Aitloadmon.php" hash="b27ae06f47d1b87955682a6298b529ef"/><file name="Analytics.php" hash="a223097ec56f7eea3329d43fe7e2956b"/><dir name="Calculator"><file name="Abstract.php" hash="f525c95d18986065984dcfd7b5211942"/><file name="Hardware.php" hash="1164c19b50d86b9a71da74f9629c2e1d"/><file name="Magento.php" hash="918dac7ec4fcd4ba4393faa13c5c2417"/><file name="Software.php" hash="a523bba11e6781151ed32fac9da14246"/></dir><file name="Calculator.php" hash="74741dc021c31558bfeb12e8710ae4b8"/><file name="CompressSource.php" hash="65b4aa585216893143d7ca28bfda6645"/><file name="Dblog.php" hash="4c134db8959a150f8031b71787ae2503"/><file name="LevelSource.php" hash="1937e32cc2b08ffbfc875d3a2f0d362b"/><file name="Manage.php" hash="6b06b0dbbb19d098b1414c6cd4a1bb8a"/><dir name="Mysql4"><dir name="Aitloadmon"><file name="Collection.php" hash="c5b65db67cedba6f28279ff78fd4f353"/></dir><file name="Aitloadmon.php" hash="2aa72df90f50823274a1a6b232c371d6"/><dir name="Calculator"><file name="Collection.php" hash="15170dd43faeebdfc30e42ebd6270c28"/></dir><file name="Calculator.php" hash="7354931dd66342f5071f782b5de7401e"/><dir name="Dblog"><file name="Collection.php" hash="3dc0dcc5e9d3bb5951573d3d11a8e4dc"/></dir><file name="Dblog.php" hash="4f4e76036d37c170fdf4771f2669dce8"/><file name="UrlRewrite.php" hash="08aecaea96122e801cdb2f9793e22ddf"/></dir><file name="Observer.php" hash="a58aa407da9971ba9cc30afb5be41248"/><file name="Process.php" hash="c769d21631b8b60534c4fd26d3819e3d"/><file name="Router.php" hash="91ed3d96b51501d3852e8a2573c58674"/><file name="SysInfo.php" hash="971ac5d7de7927e2a15c4c26afc6a50c"/><dir name="System"><file name="Abstract.php" hash="1cdc94c9f08d4507ef57fe766f30fe13"/></dir><file name="System.php" hash="6eeee453abc5efd3c35a24babe613609"/><file name="UrlRewrite.php" hash="ea3849ee4bedc6422b03bdb4be2535fd"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AitloadmonController.php" hash="4661af5d3075307667f088048864c9a7"/><file name="CalculatorController.php" hash="6f59bc515f6c41c57b18382357cdfa27"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2a3046ce15833ca2704cb9d24737d62f"/><file name="config.xml" hash="da9e3c51c99725697f93147780f40897"/><file name="system.xml" hash="e2b9300c1ad1ea759e77f61b7d381869"/></dir><dir name="sql"><dir name="aitloadmon_setup"><file name="mysql4-install-1.0.0.php" hash="bb6d6c9aec69500be4a10d7944a82dfc"/><file name="mysql4-uninstall-1.0.0.php" hash="177151acef7c5d0c376f1d49bc5ce8c7"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="f2ae0c006d0180d3dc3fae7829135d52"/></dir></dir></dir><dir name="Aitsys"><dir name="install"><file name="Aitoc_Aitloadmon.phtml" hash="9a81474e26aac8b23a5b2d2cdd6ab30d"/></dir></dir></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="aitcore.xml" hash="4250eaf338bc01fb4f3b816e77e395c2"/><file name="aitinstall.xml" hash="ff633633ff49ddf0dcf1cb0db761ba83"/><file name="aitloadmon.xml" hash="c2b2ca080d31a71ebcfdbdc56d5ad505"/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Aitoc_Aitinstall.xml" hash="439c3933908f38e09c09191226767717"/><file name="Aitoc_Aitloadmon.xml" hash="f9495b99199f39960003b4e6270baacf"/></dir></dir></dir><dir name="js"><dir name="aitoc"><dir name="aitloadmon"><file name="grafico.bar.custom.js" hash="e54db4c61047afb27a56968a8eec9fc4"/><file name="grafico.line.custom.js" hash="1eee2034b47debfb9a746116979ddfa1"/><file name="grafico.min.js" hash="cde1bec6859b10e4a179aadec3c7e232"/><file name="raphael-min.js" hash="20908f0263d452ea59b1b528145c1a47"/></dir></dir></dir><dir name="lib"><dir name="Aitoc"><dir name="Aitloadmon"><dir name="Adapter"><file name="Abstract.php" hash="4a5a269155da957dd77b9f89bcd53a57"/><file name="Apc.php" hash="ece2d19fa949b648cbdbed35607c1ce8"/><file name="File.php" hash="f36af7cc3883a9064f803fd4025b3689"/><file name="Memcached.php" hash="d1e71eb89bfdd331d5bd556475f2253e"/></dir><file name="Collect.php" hash="d8d68ee09bcbd828ddfe494605a87bc2"/></dir></dir></dir><dir><file name="License agreement Server Load Monitor.pdf" hash="2c37f69a12f4508aa13181f6cefd264b"/><file name="readme.txt" hash="33729d5788f0da4048501c989079b42e"/><file name="Server Load Monitor Manual.pdf" hash="adfc5de9935a6af3e4296baf664c2f50"/></dir><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="aitoc"><file name="aitsys.css" hash="6bca7f6174439954a9e931d504835e9c"/></dir></dir></dir></dir></dir></dir></target></contents>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>5.7.0</max></php></required></dependencies>
|
18 |
</package>
|
skin/adminhtml/default/default/aitoc/aitsys.css
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@CHARSET "UTF-8";
|
2 |
+
|
3 |
+
.aitsys-list
|
4 |
+
{
|
5 |
+
width: 100%;
|
6 |
+
}
|
7 |
+
|
8 |
+
.aitsys-list .list
|
9 |
+
{
|
10 |
+
width: 50%;
|
11 |
+
}
|
12 |
+
|
13 |
+
.license-params-table td
|
14 |
+
{
|
15 |
+
padding-top:0 !important;
|
16 |
+
padding-bottom:0 !important;
|
17 |
+
padding-left:0;
|
18 |
+
padding-right:10px;
|
19 |
+
}
|
20 |
+
|
21 |
+
.aitoc-note-message
|
22 |
+
{
|
23 |
+
font-size: 14px;
|
24 |
+
}
|
25 |
+
|
26 |
+
#license .agreements_frame
|
27 |
+
{
|
28 |
+
overflow-y: scroll;
|
29 |
+
height: 400px;
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
.aitsys-list .entry-edit #module_list .form-list td.label
|
34 |
+
{
|
35 |
+
white-space: nowrap;
|
36 |
+
width: 200px;
|
37 |
+
}
|
38 |
+
|
39 |
+
.aitsys-list .entry-edit #module_list .form-list td.label label
|
40 |
+
{
|
41 |
+
display: inline;
|
42 |
+
width: 100%;
|
43 |
+
}
|
44 |
+
|
45 |
+
.form-list td
|
46 |
+
{
|
47 |
+
background:none repeat scroll 0 50% transparent !important;
|
48 |
+
border:0 none !important;
|
49 |
+
padding-bottom:5px !important;
|
50 |
+
padding-top:5px !important;
|
51 |
+
}
|
52 |
+
|
53 |
+
.aitsys-patch-instructions
|
54 |
+
{
|
55 |
+
margin-botton: 12px;
|
56 |
+
}
|
57 |
+
|
58 |
+
.aitsys-patch-instructions pre
|
59 |
+
{
|
60 |
+
margin-top: 6px;
|
61 |
+
margin-bottom: 6px;
|
62 |
+
padding: 4px;
|
63 |
+
border: 1px solid #EB5E00;
|
64 |
+
}
|
65 |
+
|
66 |
+
.aitsys-index-index .content-header {
|
67 |
+
width: 50%;
|
68 |
+
}
|
69 |
+
|
70 |
+
.aitsys-index-index .aitsys-list
|
71 |
+
{
|
72 |
+
width: 50%;
|
73 |
+
float: left;
|
74 |
+
}
|
75 |
+
|
76 |
+
.aitsys-index-index .notifications
|
77 |
+
{
|
78 |
+
float: right;
|
79 |
+
margin-left: 5px;
|
80 |
+
margin-top: -50px;
|
81 |
+
width: 49%;
|
82 |
+
}
|
83 |
+
|
84 |
+
.serial{
|
85 |
+
font-size: 11px;
|
86 |
+
color: #999999;
|
87 |
+
}
|
88 |
+
|
89 |
+
.aitsys-index-index .form-list{
|
90 |
+
width: 100%;
|
91 |
+
}
|
92 |
+
|
93 |
+
.aitsys-index-index .form-list .module td {
|
94 |
+
padding: 10px 15px 10px 10px !important;
|
95 |
+
vertical-align: middle;
|
96 |
+
border-bottom:1px solid #e8e8e8 !important;
|
97 |
+
}
|
98 |
+
|
99 |
+
.aitsys-index-index .form-list .value {
|
100 |
+
text-align: center;
|
101 |
+
width: 100px;
|
102 |
+
}
|
103 |
+
.aitsys-index-index .form-list th {
|
104 |
+
padding: 5px 10px 10px 10px !important;
|
105 |
+
vertical-align: middle;
|
106 |
+
background-color: #d6d6d6;
|
107 |
+
color:#9a9a9a;
|
108 |
+
font: 16px/2em Arial,Helvetica,sans-serif !important;
|
109 |
+
}
|
110 |
+
|
111 |
+
.aitsys-index-index .fieldset-legend{
|
112 |
+
font: 16px/2em Arial,Helvetica,sans-serif !important;
|
113 |
+
}
|
114 |
+
.aitsys-index-index #module_list{
|
115 |
+
padding:0;
|
116 |
+
}
|
117 |
+
|
118 |
+
.aitsys-index-index .form-list .module td.label .note {
|
119 |
+
white-space: normal;
|
120 |
+
}
|
121 |
+
.aitsys-rewriter-index .form-list td.value input.input-text{
|
122 |
+
width: 38px;
|
123 |
+
}
|
124 |
+
.aitsys-rewriter-index .form-list .hor-scroll td{
|
125 |
+
padding-bottom:0px !important;
|
126 |
+
padding-top:0px !important;
|
127 |
+
}
|
128 |
+
li span.noBold {
|
129 |
+
font-weight: normal !important;
|
130 |
+
}
|