Print_Science_Designer_Web_to_Print - Version 1.0.0

Version Notes

-

Download this release

Release Info

Developer John Weissberg
Extension Print_Science_Designer_Web_to_Print
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (53) hide show
  1. app/code/local/PrintScience/Personalization/Block/Adminhtml/Sales/Order/View/Items/Renderer.php +30 -0
  2. app/code/local/PrintScience/Personalization/Block/Checkout/Cart/Item/Renderer.php +60 -0
  3. app/code/local/PrintScience/Personalization/Helper/Output.php +30 -0
  4. app/code/local/PrintScience/Personalization/Helper/Quote.php +60 -0
  5. app/code/local/PrintScience/Personalization/Helper/Session.php +69 -0
  6. app/code/local/PrintScience/Personalization/Model/ApiGateway.php +72 -0
  7. app/code/local/PrintScience/Personalization/Model/ApiGateway/Response/Abstract.php +44 -0
  8. app/code/local/PrintScience/Personalization/Model/ApiGateway/Response/Begin.php +38 -0
  9. app/code/local/PrintScience/Personalization/Model/ApiGateway/Response/GetPreview.php +45 -0
  10. app/code/local/PrintScience/Personalization/Model/Observer.php +267 -0
  11. app/code/local/PrintScience/Personalization/Model/Resource/Eav/Mysql4/Setup.php +102 -0
  12. app/code/local/PrintScience/Personalization/Model/System/Config/Backend/ApiUrl.php +24 -0
  13. app/code/local/PrintScience/Personalization/controllers/IndexController.php +202 -0
  14. app/code/local/PrintScience/Personalization/etc/config.xml +129 -0
  15. app/code/local/PrintScience/Personalization/etc/system.xml +44 -0
  16. app/code/local/PrintScience/Personalization/sql/printscience_personalization_setup/Mysql4-install-0.1.0.php +3 -0
  17. app/design/adminhtml/default/default/layout/printscience_personalization.xml +10 -0
  18. app/design/adminhtml/default/default/template/printscience_personalization/sales/order/view/items/renderer/default.phtml +224 -0
  19. app/design/frontend/base/default/layout/printscience_personalization.xml +24 -0
  20. app/design/frontend/base/default/template/printscience_personalization/catalog/product/list.phtml +139 -0
  21. app/design/frontend/base/default/template/printscience_personalization/catalog/product/view/addtocart.phtml +19 -0
  22. app/design/frontend/base/default/template/printscience_personalization/checkout/cart/item/default.phtml +245 -0
  23. app/etc/modules/PrintScience_Personalization.xml +9 -0
  24. js/printscience_personalization/gallery.css +11 -0
  25. js/printscience_personalization/gallery.js +28 -0
  26. js/printscience_personalization/jquery/fancybox/blank.gif +0 -0
  27. js/printscience_personalization/jquery/fancybox/fancy_close.png +0 -0
  28. js/printscience_personalization/jquery/fancybox/fancy_loading.png +0 -0
  29. js/printscience_personalization/jquery/fancybox/fancy_nav_left.png +0 -0
  30. js/printscience_personalization/jquery/fancybox/fancy_nav_right.png +0 -0
  31. js/printscience_personalization/jquery/fancybox/fancy_shadow_e.png +0 -0
  32. js/printscience_personalization/jquery/fancybox/fancy_shadow_n.png +0 -0
  33. js/printscience_personalization/jquery/fancybox/fancy_shadow_ne.png +0 -0
  34. js/printscience_personalization/jquery/fancybox/fancy_shadow_nw.png +0 -0
  35. js/printscience_personalization/jquery/fancybox/fancy_shadow_s.png +0 -0
  36. js/printscience_personalization/jquery/fancybox/fancy_shadow_se.png +0 -0
  37. js/printscience_personalization/jquery/fancybox/fancy_shadow_sw.png +0 -0
  38. js/printscience_personalization/jquery/fancybox/fancy_shadow_w.png +0 -0
  39. js/printscience_personalization/jquery/fancybox/fancy_title_left.png +0 -0
  40. js/printscience_personalization/jquery/fancybox/fancy_title_main.png +0 -0
  41. js/printscience_personalization/jquery/fancybox/fancy_title_over.png +0 -0
  42. js/printscience_personalization/jquery/fancybox/fancy_title_right.png +0 -0
  43. js/printscience_personalization/jquery/fancybox/fancybox-x.png +0 -0
  44. js/printscience_personalization/jquery/fancybox/fancybox-y.png +0 -0
  45. js/printscience_personalization/jquery/fancybox/fancybox.png +0 -0
  46. js/printscience_personalization/jquery/fancybox/jquery.easing-1.3.pack.js +72 -0
  47. js/printscience_personalization/jquery/fancybox/jquery.fancybox-1.3.4.css +359 -0
  48. js/printscience_personalization/jquery/fancybox/jquery.fancybox-1.3.4.pack.js +46 -0
  49. js/printscience_personalization/jquery/fancybox/jquery.mousewheel-3.0.4.pack.js +14 -0
  50. js/printscience_personalization/jquery/jquery-1.4.2.min.js +155 -0
  51. js/printscience_personalization/jquery/jquery.cycle/jquery.cycle.lite.min.js +11 -0
  52. lib/xmlrpc/xmlrpc.inc +3776 -0
  53. package.xml +18 -0
app/code/local/PrintScience/Personalization/Block/Adminhtml/Sales/Order/View/Items/Renderer.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Custom adminhtml sales order item renderer
4
+ *
5
+ */
6
+ class PrintScience_Personalization_Block_Adminhtml_Sales_Order_View_Items_Renderer
7
+ extends Mage_Adminhtml_Block_Sales_Order_View_Items_Renderer_Default
8
+ {
9
+ /**
10
+ * Get URL to personalization preview PDF file of order item
11
+ *
12
+ * @return string
13
+ */
14
+ public function getPersonalizationPreviewPdfUrl()
15
+ {
16
+ $quoteItemOptions = Mage::getModel('sales/quote_item_option')->getCollection()
17
+ ->addItemFilter($this->getItem()->getQuoteItemId());
18
+ if (!count($quoteItemOptions)) {
19
+ return false;
20
+ }
21
+ $quoteItem = Mage::getModel('sales/quote_item')->load($this->getItem()->getQuoteItemId())
22
+ ->setOptions($quoteItemOptions);
23
+ $data = Mage::helper('printscience_personalization/quote')
24
+ ->getItemData($quoteItem);
25
+ if (!$data) {
26
+ return false;
27
+ }
28
+ return $data['preview_pdf_url'];
29
+ }
30
+ }
app/code/local/PrintScience/Personalization/Block/Checkout/Cart/Item/Renderer.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Custom shopping cart item render block
4
+ *
5
+ */
6
+ class PrintScience_Personalization_Block_Checkout_Cart_Item_Renderer extends Mage_Checkout_Block_Cart_Item_Renderer
7
+ {
8
+ /**
9
+ * Get personalization api session key of the cart item
10
+ *
11
+ * @return unknown
12
+ */
13
+ public function getPersonalizationApiSessionKey()
14
+ {
15
+ $data = Mage::helper('printscience_personalization/quote')
16
+ ->getItemData($this->getItem());
17
+ if (!$data) {
18
+ return false;
19
+ }
20
+ return $data['apiSessionKey'];
21
+ }
22
+
23
+ /**
24
+ * Get personalization URL for cart item
25
+ *
26
+ * @return string | false
27
+ */
28
+ public function getPersonalizationUrl()
29
+ {
30
+ $apiSessionKey = $this->getPersonalizationApiSessionKey();
31
+ if (!$apiSessionKey) {
32
+ return false;
33
+ }
34
+ $url = Mage::getUrl('personalization/index/startShoppingCart', array(
35
+ 'api_session_key' => $apiSessionKey
36
+ ));
37
+ return $url;
38
+ }
39
+
40
+ /**
41
+ * Get URLs of personalization preview images
42
+ *
43
+ * @return array | false
44
+ */
45
+ public function getPersonalizationPreviews()
46
+ {
47
+ $default = array();
48
+
49
+ $apiSessionKey = $this->getPersonalizationApiSessionKey();
50
+ if (!$apiSessionKey) {
51
+ return $default;
52
+ }
53
+ $apiResponse = Mage::getModel('printscience_personalization/apiGateway')
54
+ ->getPreview($apiSessionKey);
55
+ if ((!$apiResponse) || ($apiResponse->getFaultCode())) {
56
+ return $default;
57
+ }
58
+ return $apiResponse->getPeviewUrls();
59
+ }
60
+ }
app/code/local/PrintScience/Personalization/Helper/Output.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Print Science personalization quote helper
4
+ *
5
+ */
6
+ class PrintScience_Personalization_Helper_Output extends Mage_Core_Helper_Abstract
7
+ {
8
+ /**
9
+ * Check if personalization is enabled for this product or
10
+ * for at least one of its subproducts.
11
+ *
12
+ * @param Mage_Catalog_Model_Product $product
13
+ * @return boolean
14
+ */
15
+ public function isPersonalizationEnabled($product)
16
+ {
17
+ $productTypeId = $product->getTypeId();
18
+ if ($productTypeId == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
19
+ return $product->getPersonalizationEnabled();
20
+ } elseif ($productTypeId == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
21
+ $subproducts = $product->getTypeInstance()->getUsedProducts();
22
+ foreach ($subproducts as $product) {
23
+ if (!$product->getPersonalizationEnabled()) {
24
+ return false;
25
+ }
26
+ }
27
+ return true;
28
+ }
29
+ }
30
+ }
app/code/local/PrintScience/Personalization/Helper/Quote.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Print Science personalization quote helper
4
+ *
5
+ */
6
+ class PrintScience_Personalization_Helper_Quote extends Mage_Core_Helper_Abstract
7
+ {
8
+ /**
9
+ * Get shopping cart quote item by personalization API session key
10
+ *
11
+ * @param string $apiSessionKey
12
+ * @return Mage_Sales_Model_Quote_Item | false
13
+ */
14
+ public function getCartItemByApiSessionKey($apiSessionKey)
15
+ {
16
+ $cartItems = Mage::getModel('checkout/cart')->getItems();
17
+ if (empty($cartItems)) {
18
+ return false;
19
+ }
20
+ foreach ($cartItems as $item) {
21
+ $data = $this->getItemData($item);
22
+ if (($data) && ($data['apiSessionKey'] == $apiSessionKey)) {
23
+ return $item;
24
+ }
25
+ }
26
+ return false;
27
+ }
28
+
29
+ /**
30
+ * Get personalization data of shopping cart quote item
31
+ *
32
+ * @param Mage_Sales_Model_Quote_Item $item
33
+ * @return array | false
34
+ */
35
+ public function getItemData($item)
36
+ {
37
+ $option = $item->getOptionByCode('personalization');
38
+ if (!$option) {
39
+ return false;
40
+ }
41
+ return unserialize($option->getValue());
42
+ }
43
+
44
+ /**
45
+ * Add personalization data to shopping cart quote item
46
+ *
47
+ * @param Mage_Sales_Model_Quote_Item $item
48
+ * @param array $data
49
+ */
50
+ public function addItemData($item, $data)
51
+ {
52
+ $option = Mage::getModel('catalog/product_configuration_item_option')->addData(array(
53
+ 'product_id' => $item->getProductId(),
54
+ 'product' => $item->getProduct(),
55
+ 'code' => 'personalization',
56
+ 'value' => serialize($data)
57
+ ));
58
+ $item->addOption($option);
59
+ }
60
+ }
app/code/local/PrintScience/Personalization/Helper/Session.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Print Science personalization session data helper
4
+ *
5
+ */
6
+ class PrintScience_Personalization_Helper_Session extends Mage_Core_Helper_Abstract
7
+ {
8
+ /**
9
+ * Generate and return personalization session key
10
+ *
11
+ * @return string
12
+ */
13
+ public function generateKey()
14
+ {
15
+ return md5(uniqid(null, true));
16
+ }
17
+
18
+ /**
19
+ * Get personalization session data that corresponds to provided key
20
+ *
21
+ * @param string $key
22
+ * @return array | false
23
+ */
24
+ public function getData($key)
25
+ {
26
+ $session = Mage::getSingleton('core/session');
27
+
28
+ if ($session->hasData('productPersonalization')) {
29
+ $data = $session->getData('productPersonalization');
30
+ if (isset($data[$key])) {
31
+ return $data[$key];
32
+ }
33
+ }
34
+ return false;
35
+ }
36
+
37
+ /**
38
+ * Add personalization session data to session object
39
+ *
40
+ * @param string $key
41
+ * @param array $data
42
+ */
43
+ public function addData($key, $data)
44
+ {
45
+ $session = Mage::getSingleton('core/session');
46
+
47
+ $currentData = $session->getData('productPersonalization');
48
+ $currentData[$key] = $data;
49
+ $session->setData('productPersonalization', $currentData);
50
+ }
51
+
52
+ /**
53
+ * Remove personalization session data from session object
54
+ *
55
+ * @param string $key
56
+ */
57
+ public function unsetData($key)
58
+ {
59
+ $session = Mage::getSingleton('core/session');
60
+
61
+ if ($session->hasData('productPersonalization')) {
62
+ $data = $session->getData('productPersonalization');
63
+ if (isset($data[$key])) {
64
+ unset($data[$key]);
65
+ $session->setData('productPersonalization', $data);
66
+ }
67
+ }
68
+ }
69
+ }
app/code/local/PrintScience/Personalization/Model/ApiGateway.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'xmlrpc/xmlrpc.inc';
3
+
4
+ /**
5
+ * Gateway to Print Science personalization API
6
+ *
7
+ */
8
+ class PrintScience_Personalization_Model_ApiGateway
9
+ {
10
+ /**
11
+ * Calls beginPersonalization API function and returns response.
12
+ *
13
+ * @param int $templateId
14
+ * @param string $successUrl
15
+ * @param string $failUrl
16
+ * @param string $cancelUrl
17
+ * @return PrintScience_Personalization_Model_ApiGateway_Response_Begin
18
+ */
19
+ public function beginPersonalization($templateId, $successUrl, $failUrl, $cancelUrl)
20
+ {
21
+ $client = new xmlrpc_client(Mage::getStoreConfig('catalog/personalization/api_url'));
22
+
23
+ $function = new xmlrpcmsg('beginPersonalization', array(
24
+ php_xmlrpc_encode(Mage::getStoreConfig('catalog/personalization/api_username')),
25
+ php_xmlrpc_encode(Mage::getStoreConfig('catalog/personalization/api_password')),
26
+ php_xmlrpc_encode($templateId),
27
+ php_xmlrpc_encode($successUrl),
28
+ php_xmlrpc_encode($failUrl),
29
+ php_xmlrpc_encode($cancelUrl),
30
+ php_xmlrpc_encode('')
31
+ ));
32
+
33
+ $response = $client->send($function);
34
+
35
+ return new PrintScience_Personalization_Model_ApiGateway_Response_Begin($response);
36
+ }
37
+
38
+ /**
39
+ * Calls getPreview API function and returns response.
40
+ *
41
+ * @param string $sessionKey
42
+ * @return PrintScience_Personalization_Model_ApiGateway_Response_GetPreview
43
+ */
44
+ public function getPreview($sessionKey)
45
+ {
46
+ $client = new xmlrpc_client(Mage::getStoreConfig('catalog/personalization/api_url'));
47
+
48
+ $function = new xmlrpcmsg('getPreview', array(
49
+ php_xmlrpc_encode($sessionKey)
50
+ ));
51
+
52
+ $response = $client->send($function);
53
+
54
+ return new PrintScience_Personalization_Model_ApiGateway_Response_GetPreview($response);
55
+ }
56
+
57
+ /**
58
+ * Calls endPersonalization API function.
59
+ *
60
+ * @param string $sessionKey
61
+ */
62
+ public function endPersonalization($sessionKey)
63
+ {
64
+ $client = new xmlrpc_client(Mage::getStoreConfig('catalog/personalization/api_url'));
65
+
66
+ $function = new xmlrpcmsg('endPersonalization', array(
67
+ php_xmlrpc_encode($sessionKey)
68
+ ));
69
+
70
+ $client->send($function);
71
+ }
72
+ }
app/code/local/PrintScience/Personalization/Model/ApiGateway/Response/Abstract.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Base class for Print Science personalization API responses
4
+ *
5
+ */
6
+ class PrintScience_Personalization_Model_ApiGateway_Response_Abstract
7
+ {
8
+ /**
9
+ * Response returned by personalization API function
10
+ *
11
+ * @var xmlrpcresp
12
+ */
13
+ protected $response;
14
+
15
+ /**
16
+ * Constructor
17
+ *
18
+ * @param xmlrpcresp $response
19
+ */
20
+ public function __construct($response)
21
+ {
22
+ $this->response = $response;
23
+ }
24
+
25
+ /**
26
+ * Returns response fault code
27
+ *
28
+ * @return int
29
+ */
30
+ public function getFaultCode()
31
+ {
32
+ return $this->response->faultCode();
33
+ }
34
+
35
+ /**
36
+ * Returns response fault string
37
+ *
38
+ * @return string
39
+ */
40
+ public function getFaultString()
41
+ {
42
+ return $this->response->faultString();
43
+ }
44
+ }
app/code/local/PrintScience/Personalization/Model/ApiGateway/Response/Begin.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Print Science personalization API response on beginPersonalization function
4
+ *
5
+ */
6
+ class PrintScience_Personalization_Model_ApiGateway_Response_Begin
7
+ extends PrintScience_Personalization_Model_ApiGateway_Response_Abstract
8
+ {
9
+ /**
10
+ * Constructor
11
+ *
12
+ * @param xmlrpcresp $response
13
+ */
14
+ public function __construct($response)
15
+ {
16
+ parent::__construct($response);
17
+ }
18
+
19
+ /**
20
+ * Extracts session key from response.
21
+ *
22
+ * @return string
23
+ */
24
+ public function getSessionKey()
25
+ {
26
+ return $this->response->value()->arrayMem(0)->scalarval();
27
+ }
28
+
29
+ /**
30
+ * Extracts personalization app URL from response.
31
+ *
32
+ * @return string
33
+ */
34
+ public function getAppUrl()
35
+ {
36
+ return $this->response->value()->arrayMem(1)->scalarval();
37
+ }
38
+ }
app/code/local/PrintScience/Personalization/Model/ApiGateway/Response/GetPreview.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Print Science personalization API response on getPreview function
4
+ *
5
+ */
6
+ class PrintScience_Personalization_Model_ApiGateway_Response_GetPreview
7
+ extends PrintScience_Personalization_Model_ApiGateway_Response_Abstract
8
+ {
9
+ /**
10
+ * Constructor
11
+ *
12
+ * @param xmlrpcresp $response
13
+ */
14
+ public function __construct($response)
15
+ {
16
+ parent::__construct($response);
17
+ }
18
+
19
+ /**
20
+ * Extracts URL to the PDF proof from response
21
+ *
22
+ * @return string
23
+ */
24
+ public function getPdfUrl()
25
+ {
26
+ return $this->response->value()->structMem('pdf_url')->scalarval();
27
+ }
28
+
29
+ /**
30
+ * Extracts URLs to preview images from response
31
+ *
32
+ * @return array
33
+ */
34
+ public function getPeviewUrls()
35
+ {
36
+ $previewUrlMember = $this->response->value()->structMem('preview_url');
37
+
38
+ $previewUrls = array();
39
+ for ($i = 0; $i < $previewUrlMember->arraySize(); $i++) {
40
+ $previewUrls[] = $previewUrlMember->arrayMem($i)->scalarval();
41
+ }
42
+
43
+ return $previewUrls;
44
+ }
45
+ }
app/code/local/PrintScience/Personalization/Model/Observer.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Print Science personalization observer
4
+ *
5
+ */
6
+ class PrintScience_Personalization_Model_Observer extends Mage_Core_Model_Observer
7
+ {
8
+ /**
9
+ * Event observer
10
+ *
11
+ * @var Varien_Event_Observer
12
+ */
13
+ private $_observer;
14
+
15
+ /**
16
+ * Check if current action is 'checkout_cart_add' and start personalization process
17
+ *
18
+ * @param Varien_Event_Observer $observer
19
+ */
20
+ public function checkForCheckoutCartAddAction($observer)
21
+ {
22
+ $this->_observer = $observer;
23
+
24
+ $controller = $observer->getControllerAction();
25
+ if (($controller->getFullActionName() == 'checkout_cart_add')
26
+ && (!Mage::registry('PrintScience_Personalization_calledFromSuccessAction'))) {
27
+ $this->startPersonalization();
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Start personalization process
33
+ *
34
+ * @param Mage_Core_Controller_Request_Http $product
35
+ */
36
+ private function startPersonalization()
37
+ {
38
+ $controller = $this->_observer->getControllerAction();
39
+ $request = Mage::app()->getRequest();
40
+ $response = Mage::app()->getResponse();
41
+ $session = Mage::getSingleton('core/session');
42
+
43
+ $productId = intval($request->getParam('product'));
44
+ $product = Mage::getModel('catalog/product')
45
+ ->setStoreId(Mage::app()->getStore()->getId())
46
+ ->load($productId);
47
+ if (!$product->getId()) {
48
+ return false;
49
+ }
50
+
51
+ $errorUrl = $product->getProductUrl();
52
+
53
+ /**
54
+ * Check if personalization is enabled for this product.
55
+ * If this is simple product then we need to check its 'personalization_enabled' attribute.
56
+ * If this is configurable product then we need to check 'personalization_enabled' attribute of its subproduct.
57
+ * No other product types are supported.
58
+ */
59
+ $productTypeId = $product->getTypeId();
60
+ if ($productTypeId == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
61
+ if (!$product->getPersonalizationEnabled()) {
62
+ return false;
63
+ }
64
+ } elseif ($productTypeId == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
65
+ $attributes = $request->getParam('super_attribute');
66
+ $product = $product->getTypeInstance()->getProductByAttributes($attributes);
67
+ if ((!$product) || (!$product->getPersonalizationEnabled())) {
68
+ return false;
69
+ }
70
+ } else {
71
+ return false;
72
+ }
73
+
74
+ // check if template ID is valid
75
+ $templateId = $product->getPersonalizationTemplateId();
76
+ if (!$templateId) {
77
+ $session->addError($controller->__('Unable to start personalization: template ID is empty.'));
78
+ $response->setRedirect($errorUrl)->sendHeaders();
79
+ exit();
80
+ }
81
+
82
+ $sessionHelper = Mage::helper('printscience_personalization/session');
83
+ $sessionKey = $sessionHelper->generateKey();
84
+
85
+ $buyRequestParams = $request->getParams();
86
+ if (isset($buyRequestParams['uenc'])) {
87
+ unset($buyRequestParams['uenc']);
88
+ }
89
+ $returnUrlParams['_query'] = $buyRequestParams;
90
+ if (isset($returnUrlParams['uenc'])) {
91
+ unset($returnUrlParams['uenc']);
92
+ }
93
+ $returnUrlParams['personalization_session_key'] = $sessionKey;
94
+
95
+ $successUrl = Mage::getUrl('personalization/index/success', $returnUrlParams);
96
+ $failUrl = Mage::getUrl('personalization/index/fail', $returnUrlParams);
97
+ $cancelUrl = Mage::getUrl('personalization/index/cancel', $returnUrlParams);
98
+
99
+ // begin personalization
100
+ $apiGateway = Mage::getModel('printscience_personalization/apiGateway');
101
+ $apiResponse = $apiGateway->beginPersonalization($templateId, $successUrl, $failUrl, $cancelUrl);
102
+ if (!$apiResponse) {
103
+ $session->addError($controller->__('Unable to start personalization: API response was empty.'));
104
+ $response->setRedirect($errorUrl)->sendHeaders();
105
+ exit();
106
+ }
107
+ if ($apiResponse->getFaultCode()) {
108
+ $session->addError($controller->__('Unable to start personalization: ' . $apiResponse->getFaultString()));
109
+ $response->setRedirect($errorUrl)->sendHeaders();
110
+ exit();
111
+ }
112
+ $apiSessionKey = $apiResponse->getSessionKey();
113
+ $appUrl = $apiResponse->getAppUrl();
114
+
115
+ $sessionHelper->addData($sessionKey, array(
116
+ 'apiSessionKey' => $apiSessionKey,
117
+ 'appUrl' => $appUrl,
118
+ 'buyRequest' => serialize($buyRequestParams)
119
+ ));
120
+
121
+ $response->setRedirect($appUrl)->sendHeaders();
122
+ exit();
123
+ }
124
+
125
+ /**
126
+ * End personalization process when item is deleted from shopping cart
127
+ *
128
+ * @param Varien_Event_Observer $observer
129
+ */
130
+ public function endPersonalization($observer)
131
+ {
132
+ $this->_observer = $observer;
133
+
134
+ $quoteHelper = Mage::helper('printscience_personalization/quote');
135
+ $apiGateway = Mage::getModel('printscience_personalization/apiGateway');
136
+
137
+ $quoteItem = $observer->getEvent()->getData('quote_item');
138
+ $data = $quoteHelper->getItemData($quoteItem);
139
+ if ($data) {
140
+ $apiGateway->endPersonalization($data['apiSessionKey']);
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Add personalization options to cart item
146
+ *
147
+ * @param Varien_Event_Observer $observer
148
+ */
149
+ public function addOptionsToCartItem($observer)
150
+ {
151
+ $this->_observer = $observer;
152
+
153
+ $request = Mage::app()->getRequest();
154
+
155
+ $sessionKey = $request->getParam('personalization_session_key');
156
+
157
+ $quoteItem = $observer->getEvent()->getData('quote_item');
158
+ if ((!$quoteItem->getProduct()->getPersonalizationEnabled()) || (!$sessionKey)) {
159
+ return false;
160
+ }
161
+
162
+ $sessionHelper = Mage::helper('printscience_personalization/session');
163
+ $sessionData = $sessionHelper->getData($sessionKey);
164
+ if (!$sessionData) {
165
+ return false;
166
+ }
167
+ unset($sessionData['buyRequest']);
168
+ $sessionData['sessionKey'] = $sessionKey;
169
+
170
+ $parentItem = $quoteItem->getParentItem();
171
+ if ($parentItem) {
172
+ $quoteItem = $parentItem;
173
+ }
174
+ $quoteHelper = Mage::helper('printscience_personalization/quote');
175
+ $quoteHelper->addItemData($quoteItem, $sessionData);
176
+ }
177
+
178
+ /**
179
+ * Add personalization options to order items
180
+ *
181
+ * @param Varien_Event_Observer $observer
182
+ */
183
+ public function addOptionsToOrderItems($observer)
184
+ {
185
+ $this->_observer = $observer;
186
+
187
+ $quoteHelper = Mage::helper('printscience_personalization/quote');
188
+ $apiGateway = Mage::getModel('printscience_personalization/apiGateway');
189
+
190
+ $order = $observer->getEvent()->getData('order');
191
+ $qouteItems = $order->getQuote()->getItemsCollection();
192
+ foreach ($qouteItems as $item) {
193
+ $itemData = $quoteHelper->getItemData($item);
194
+ if (!$itemData) {
195
+ continue;
196
+ }
197
+ $apiResponse = $apiGateway->getPreview($itemData['apiSessionKey']);
198
+ if ((!$apiResponse) || ($apiResponse->getFaultCode())) {
199
+ continue;
200
+ }
201
+ $quoteHelper->addItemData($item, array(
202
+ 'preview_pdf_url' => $apiResponse->getPdfUrl()
203
+ ));
204
+ $apiGateway->endPersonalization($itemData['apiSessionKey']);
205
+ }
206
+ }
207
+
208
+ /**
209
+ * Intialize personalization gallery on shopping cart
210
+ *
211
+ * @param Varien_Event_Observer $observer
212
+ * @return boolean
213
+ */
214
+ public function initGallery($observer)
215
+ {
216
+ $this->_observer = $observer;
217
+
218
+ $layout = Mage::app()->getLayout();
219
+ $quoteHelper = Mage::helper('printscience_personalization/quote');
220
+
221
+ $cartItems = Mage::getModel('checkout/cart')->getItems();
222
+ if (!$cartItems) {
223
+ return false;
224
+ }
225
+ $containsPersonalizedItems = false;
226
+ foreach ($cartItems as $item) {
227
+ if ($quoteHelper->getItemData($item)) {
228
+ $containsPersonalizedItems = true;
229
+ break;
230
+ }
231
+ }
232
+ if ($containsPersonalizedItems) {
233
+ $layout->getBlock('head')
234
+ ->addJs('printscience_personalization/jquery/jquery-1.4.2.min.js')
235
+ ->addJs('printscience_personalization/jquery/jquery.cycle/jquery.cycle.lite.min.js')
236
+ ->addJs('printscience_personalization/jquery/fancybox/jquery.fancybox-1.3.4.pack.js')
237
+ ->addItem('js_css', 'printscience_personalization/jquery/fancybox/jquery.fancybox-1.3.4.css')
238
+ ->addJs('printscience_personalization/gallery.js')
239
+ ->addItem('js_css', 'printscience_personalization/gallery.css');
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Ensure that all personalized items in shopping cart have proper API session key
245
+ *
246
+ * @param Varien_Event_Observer $observer
247
+ */
248
+ public function checkCartItems($observer)
249
+ {
250
+ $this->_observer = $observer;
251
+
252
+ $quoteHelper = Mage::helper('printscience_personalization/quote');
253
+ $apiGateway = Mage::getModel('printscience_personalization/apiGateway');
254
+
255
+ $quote = $observer->getEvent()->getData('data_object');
256
+ $quoteItems = $quote->getItemsCollection();
257
+ foreach ($quoteItems as $item) {
258
+ $data = $quoteHelper->getItemData($item);
259
+ if (($data) && (isset($data['apiSessionKey']))) {
260
+ $apiResponse = $apiGateway->getPreview($data['apiSessionKey']);
261
+ if ((!$apiResponse) || ($apiResponse->getFaultCode())) {
262
+ $quote->removeItem($item->getItemId());
263
+ }
264
+ }
265
+ }
266
+ }
267
+ }
app/code/local/PrintScience/Personalization/Model/Resource/Eav/Mysql4/Setup.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Print Science Product Personalization setup
4
+ *
5
+ */
6
+ class PrintScience_Personalization_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
7
+ {
8
+ /**
9
+ * Prepare personalization attribute values to save
10
+ *
11
+ * @param array $attr
12
+ * @return array
13
+ */
14
+ protected function _prepareValues($attr)
15
+ {
16
+ $data = parent::_prepareValues($attr);
17
+ $data = array_merge($data, array(
18
+ 'frontend_input_renderer' => $this->_getValue($attr, 'input_renderer', ''),
19
+ 'is_global' => $this->_getValue($attr, 'global', 1),
20
+ 'is_visible' => $this->_getValue($attr, 'visible', 1),
21
+ 'is_searchable' => $this->_getValue($attr, 'searchable', 0),
22
+ 'is_filterable' => $this->_getValue($attr, 'filterable', 0),
23
+ 'is_comparable' => $this->_getValue($attr, 'comparable', 0),
24
+ 'is_visible_on_front' => $this->_getValue($attr, 'visible_on_front', 0),
25
+ 'is_wysiwyg_enabled' => $this->_getValue($attr, 'wysiwyg_enabled', 0),
26
+ 'is_html_allowed_on_front' => $this->_getValue($attr, 'is_html_allowed_on_front', 0),
27
+ 'is_visible_in_advanced_search'
28
+ => $this->_getValue($attr, 'visible_in_advanced_search', 0),
29
+ 'is_filterable_in_search' => $this->_getValue($attr, 'filterable_in_search', 0),
30
+ 'used_in_product_listing' => $this->_getValue($attr, 'used_in_product_listing', 0),
31
+ 'used_for_sort_by' => $this->_getValue($attr, 'used_for_sort_by', 0),
32
+ 'apply_to' => $this->_getValue($attr, 'apply_to', ''),
33
+ 'position' => $this->_getValue($attr, 'position', 0),
34
+ 'is_configurable' => $this->_getValue($attr, 'is_configurable', 1),
35
+ 'is_used_for_promo_rules' => $this->_getValue($attr, 'used_for_promo_rules', 0)
36
+ ));
37
+ return $data;
38
+ }
39
+
40
+ /**
41
+ * Get entities to setup
42
+ *
43
+ * @return array
44
+ */
45
+ public function getDefaultEntities()
46
+ {
47
+ return array(
48
+ 'catalog_product' => array(
49
+ 'entity_model' => 'catalog/product',
50
+ 'attribute_model' => 'catalog/resource_eav_attribute',
51
+ 'table' => 'catalog/product',
52
+ 'additional_attribute_table' => 'catalog/eav_attribute',
53
+ 'entity_attribute_collection' => 'catalog/product_attribute_collection',
54
+ 'attributes' => array(
55
+ 'personalization_enabled' => array(
56
+ 'group' => 'Personalization',
57
+ 'type' => 'int',
58
+ 'backend' => '',
59
+ 'frontend' => '',
60
+ 'label' => 'Enable Personalization',
61
+ 'input' => 'boolean',
62
+ 'class' => '',
63
+ 'source' => '',
64
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
65
+ 'visible' => true,
66
+ 'required' => false,
67
+ 'user_defined' => false,
68
+ 'default' => '',
69
+ 'searchable' => false,
70
+ 'filterable' => false,
71
+ 'comparable' => false,
72
+ 'visible_on_front' => false,
73
+ 'unique' => false,
74
+ 'apply_to' => 'simple',
75
+ 'used_in_product_listing' => 1
76
+ ),
77
+ 'personalization_template_id' => array(
78
+ 'group' => 'Personalization',
79
+ 'type' => 'varchar',
80
+ 'backend' => '',
81
+ 'frontend' => '',
82
+ 'label' => 'Template ID',
83
+ 'input' => 'text',
84
+ 'class' => '',
85
+ 'source' => '',
86
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
87
+ 'visible' => true,
88
+ 'required' => false,
89
+ 'user_defined' => false,
90
+ 'default' => '',
91
+ 'searchable' => false,
92
+ 'filterable' => false,
93
+ 'comparable' => false,
94
+ 'visible_on_front' => false,
95
+ 'unique' => false,
96
+ 'apply_to' => 'simple'
97
+ )
98
+ )
99
+ )
100
+ );
101
+ }
102
+ }
app/code/local/PrintScience/Personalization/Model/System/Config/Backend/ApiUrl.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Personalization API URL backend
4
+ *
5
+ */
6
+ class PrintScience_Personalization_Model_System_Config_Backend_ApiUrl extends Mage_Core_Model_Config_Data
7
+ {
8
+ /**
9
+ * Check if API URL has trailing '/'. If not, then add it.
10
+ *
11
+ * @return PrintScience_Personalization_Model_System_Config_Backend_ApiUrl
12
+ */
13
+ protected function _beforeSave()
14
+ {
15
+ $apiUrl = $this->getValue();
16
+ if (($apiUrl) && ($apiUrl[strlen($apiUrl) - 1] != '/')) {
17
+ $apiUrl .= '/';
18
+ $this->setValue($apiUrl);
19
+ }
20
+
21
+ return $this;
22
+ }
23
+ }
24
+ ?>
app/code/local/PrintScience/Personalization/controllers/IndexController.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Personalization controller
4
+ *
5
+ */
6
+ class PrintScience_Personalization_IndexController extends Mage_Core_Controller_Front_Action
7
+ {
8
+ /**
9
+ * Personalization startShoppingCart action handler
10
+ *
11
+ * @return boolean
12
+ */
13
+ public function startShoppingCartAction()
14
+ {
15
+ $session = Mage::getSingleton('core/session');
16
+ $sessionHelper = Mage::helper('printscience_personalization/session');
17
+ $quoteHelper = Mage::helper('printscience_personalization/quote');
18
+ $request = $this->getRequest();
19
+
20
+ $apiSessionKey = $request->getParam('api_session_key');
21
+ $isValidRequest = false;
22
+ if ($apiSessionKey) {
23
+ $cartItem = $quoteHelper->getCartItemByApiSessionKey($apiSessionKey);
24
+ if ($cartItem) {
25
+ $isValidRequest = true;
26
+ }
27
+ }
28
+ if (!$isValidRequest) {
29
+ $session->addError($this->__('Invalid request.'));
30
+ $this->_redirect('home');
31
+ return false;
32
+ }
33
+
34
+ $cartItemData = $quoteHelper->getItemData($cartItem);
35
+
36
+ $sessionHelper->addData($cartItemData['sessionKey'], array(
37
+ 'apiSessionKey' => $cartItemData['apiSessionKey'],
38
+ ));
39
+
40
+ $this->_redirectUrl($cartItemData['appUrl']);
41
+ }
42
+
43
+ /**
44
+ * Personalization success action handler.
45
+ *
46
+ * @return boolean
47
+ */
48
+ public function successAction()
49
+ {
50
+ $session = Mage::getSingleton('core/session');
51
+ $request = $this->getRequest();
52
+
53
+ if (!$this->_isValidRequest()) {
54
+ $session->addError($this->__('Invalid request.'));
55
+ $this->_redirect('home');
56
+ return false;
57
+ }
58
+
59
+ $product = $this->_initProduct();
60
+ if (!$product) {
61
+ $session->addError($this->__('Personalization error: product not found.'));
62
+ $this->_redirect('home');
63
+ return false;
64
+ }
65
+
66
+ $sessionHelper = Mage::helper('printscience_personalization/session');
67
+ $quoteHelper = Mage::helper('printscience_personalization/quote');
68
+ $apiGateway = Mage::getModel('printscience_personalization/apiGateway');
69
+
70
+ $sessionKey = $request->getParam('personalization_session_key');
71
+ $sessionData = $sessionHelper->getData($sessionKey);
72
+ $apiSessionKey = $sessionData['apiSessionKey'];
73
+
74
+ // is item with this API session key already in cart?
75
+ $cartItem = $quoteHelper->getCartItemByApiSessionKey($apiSessionKey);
76
+
77
+ if (!$cartItem) {
78
+ $errorUrl = $product->getProductUrl();
79
+ } else {
80
+ $errorUrl = Mage::getUrl('checkout/cart');
81
+ }
82
+
83
+ $apiResponse = $apiGateway->getPreview($apiSessionKey);
84
+ if ($apiResponse->getFaultCode()) {
85
+ $session->addError($this->__('Personalization was not completed.'));
86
+ $this->_redirectUrl($errorUrl);
87
+ return false;
88
+ }
89
+
90
+ if (!$cartItem) {
91
+ Mage::register('PrintScience_Personalization_calledFromSuccessAction', true);
92
+ $this->_forward('add', 'cart', 'checkout');
93
+ } else {
94
+ $this->_redirect('checkout/cart');
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Personalization cancel action handler
100
+ *
101
+ * @return boolean
102
+ */
103
+ public function cancelAction()
104
+ {
105
+ $session = Mage::getSingleton('core/session');
106
+ $request = $this->getRequest();
107
+
108
+ if (!$this->_isValidRequest()) {
109
+ $session->addError($this->__('Invalid request.'));
110
+ $this->_redirect('home');
111
+ return false;
112
+ }
113
+
114
+ $product = $this->_initProduct();
115
+ if (!$product) {
116
+ $session->addError($this->__('Personalization error: product not found.'));
117
+ $this->_redirect('home');
118
+ return false;
119
+ }
120
+
121
+ $apiGateway = Mage::getModel('printscience_personalization/apiGateway');
122
+ $sessionHelper = Mage::helper('printscience_personalization/session');
123
+ $quoteHelper = Mage::helper('printscience_personalization/quote');
124
+
125
+ $sessionKey = $request->getParam('personalization_session_key');
126
+ $sessionData = $sessionHelper->getData($sessionKey);
127
+ $apiSessionKey = $sessionData['apiSessionKey'];
128
+
129
+ // is item with this API session key already in cart?
130
+ $cartItem = $quoteHelper->getCartItemByApiSessionKey($apiSessionKey);
131
+
132
+ if (!$cartItem) {
133
+ $apiGateway->endPersonalization($apiSessionKey);
134
+ $sessionHelper->unsetData($sessionKey);
135
+ $redirectUrl = $product->getProductUrl();
136
+ } else {
137
+ $redirectUrl = Mage::getUrl('checkout/cart');
138
+ }
139
+
140
+ $this->_redirectUrl($redirectUrl);
141
+ }
142
+
143
+ /**
144
+ * Personalization fail action handler
145
+ *
146
+ */
147
+ public function failAction()
148
+ {
149
+ $this->_forward('cancel');
150
+ }
151
+
152
+ /**
153
+ * Initialize product instance from request data
154
+ *
155
+ * @return Mage_Catalog_Model_Product | false
156
+ */
157
+ private function _initProduct()
158
+ {
159
+ $productId = (int) $this->getRequest()->getParam('product');
160
+ if ($productId) {
161
+ $product = Mage::getModel('catalog/product')
162
+ ->setStoreId(Mage::app()->getStore()->getId())
163
+ ->load($productId);
164
+ if ($product->getId()) {
165
+ return $product;
166
+ }
167
+ }
168
+ return false;
169
+ }
170
+
171
+ /**
172
+ * Check if current request to Success, Cancel or Fail action is valid
173
+ *
174
+ * @return boolean
175
+ */
176
+ private function _isValidRequest()
177
+ {
178
+ $request = $this->getRequest();
179
+ $sessionHelper = Mage::helper('printscience_personalization/session');
180
+ $quoteHelper = Mage::helper('printscience_personalization/quote');
181
+
182
+ $sessionKey = $request->getParam('personalization_session_key');
183
+
184
+ if ($sessionKey) {
185
+ $sessionData = $sessionHelper->getData($sessionKey);
186
+ if ($sessionData) {
187
+ // no need to validate buyRequest params if item is already in cart
188
+ $cartItem = $quoteHelper->getCartItemByApiSessionKey($sessionData['apiSessionKey']);
189
+ if ($cartItem) {
190
+ return true;
191
+ } else {
192
+ $buyRequestParams = $request->getParams();
193
+ unset($buyRequestParams['personalization_session_key']);
194
+ if (unserialize($sessionData['buyRequest']) == $buyRequestParams) {
195
+ return true;
196
+ }
197
+ }
198
+ }
199
+ }
200
+ return false;
201
+ }
202
+ }
app/code/local/PrintScience/Personalization/etc/config.xml ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <PrintScience_Personalization>
5
+ <version>0.1.0</version>
6
+ </PrintScience_Personalization>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <printscience_personalization>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>PrintScience_Personalization</module>
14
+ <frontName>personalization</frontName>
15
+ </args>
16
+ </printscience_personalization>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <printscience_personalization>
21
+ <file>printscience_personalization.xml</file>
22
+ </printscience_personalization>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <adminhtml>
27
+ <layout>
28
+ <updates>
29
+ <printscience_personalization>
30
+ <file>printscience_personalization.xml</file>
31
+ </printscience_personalization>
32
+ </updates>
33
+ </layout>
34
+ </adminhtml>
35
+ <global>
36
+ <models>
37
+ <printscience_personalization>
38
+ <class>PrintScience_Personalization_Model</class>
39
+ </printscience_personalization>
40
+ </models>
41
+ <helpers>
42
+ <printscience_personalization>
43
+ <class>PrintScience_Personalization_Helper</class>
44
+ </printscience_personalization>
45
+ </helpers>
46
+ <blocks>
47
+ <printscience_personalization>
48
+ <class>PrintScience_Personalization_Block</class>
49
+ </printscience_personalization>
50
+ </blocks>
51
+ <events>
52
+ <controller_action_predispatch>
53
+ <observers>
54
+ <printscience_personalization_model_observer>
55
+ <type>singleton</type>
56
+ <class>printscience_personalization/observer</class>
57
+ <method>checkForCheckoutCartAddAction</method>
58
+ </printscience_personalization_model_observer>
59
+ </observers>
60
+ </controller_action_predispatch>
61
+ <checkout_cart_product_add_after>
62
+ <observers>
63
+ <printscience_personalization_model_observer>
64
+ <type>singleton</type>
65
+ <class>printscience_personalization/observer</class>
66
+ <method>addOptionsToCartItem</method>
67
+ </printscience_personalization_model_observer>
68
+ </observers>
69
+ </checkout_cart_product_add_after>
70
+ <sales_order_place_before>
71
+ <observers>
72
+ <printscience_personalization_model_observer>
73
+ <type>singleton</type>
74
+ <class>printscience_personalization/observer</class>
75
+ <method>addOptionsToOrderItems</method>
76
+ </printscience_personalization_model_observer>
77
+ </observers>
78
+ </sales_order_place_before>
79
+ <controller_action_layout_render_before_checkout_cart_index>
80
+ <observers>
81
+ <printscience_personalization_model_observer>
82
+ <type>singleton</type>
83
+ <class>printscience_personalization/observer</class>
84
+ <method>initGallery</method>
85
+ </printscience_personalization_model_observer>
86
+ </observers>
87
+ </controller_action_layout_render_before_checkout_cart_index>
88
+ <sales_quote_remove_item>
89
+ <observers>
90
+ <printscience_personalization_model_observer>
91
+ <type>singleton</type>
92
+ <class>printscience_personalization/observer</class>
93
+ <method>endPersonalization</method>
94
+ </printscience_personalization_model_observer>
95
+ </observers>
96
+ </sales_quote_remove_item>
97
+ <sales_quote_load_after>
98
+ <observers>
99
+ <printscience_personalization_model_observer>
100
+ <type>singleton</type>
101
+ <class>printscience_personalization/observer</class>
102
+ <method>checkCartItems</method>
103
+ </printscience_personalization_model_observer>
104
+ </observers>
105
+ </sales_quote_load_after>
106
+ </events>
107
+ <resources>
108
+ <printscience_personalization_setup>
109
+ <setup>
110
+ <module>PrintScience_Personalization</module>
111
+ <class>PrintScience_Personalization_Model_Resource_Eav_Mysql4_Setup</class>
112
+ </setup>
113
+ <connection>
114
+ <use>core_setup</use>
115
+ </connection>
116
+ </printscience_personalization_setup>
117
+ <printscience_personalization_write>
118
+ <connection>
119
+ <use>core_write</use>
120
+ </connection>
121
+ </printscience_personalization_write>
122
+ <printscience_personalization_read>
123
+ <connection>
124
+ <use>core_read</use>
125
+ </connection>
126
+ </printscience_personalization_read>
127
+ </resources>
128
+ </global>
129
+ </config>
app/code/local/PrintScience/Personalization/etc/system.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <catalog translate="label" module="catalog">
5
+ <groups>
6
+ <personalization translate="label">
7
+ <label>Product Personalization</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>310</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>0</show_in_website>
12
+ <show_in_store>0</show_in_store>
13
+ <fields>
14
+ <api_username transalte="label">
15
+ <label>API Username</label>
16
+ <frontend_type>text</frontend_type>
17
+ <sort_order>1</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>0</show_in_website>
20
+ <show_in_store>0</show_in_store>
21
+ </api_username>
22
+ <api_password transalte="label">
23
+ <label>API Key</label>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>2</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>0</show_in_website>
28
+ <show_in_store>0</show_in_store>
29
+ </api_password>
30
+ <api_url transalte="label">
31
+ <label>API URL</label>
32
+ <frontend_type>text</frontend_type>
33
+ <backend_model>printscience_personalization/system_config_backend_apiUrl</backend_model>
34
+ <sort_order>3</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>0</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ </api_url>
39
+ </fields>
40
+ </personalization>
41
+ </groups>
42
+ </catalog>
43
+ </sections>
44
+ </config>
app/code/local/PrintScience/Personalization/sql/printscience_personalization_setup/Mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->installEntities();
app/design/adminhtml/default/default/layout/printscience_personalization.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_sales_order_view>
4
+ <reference name="order_items">
5
+ <action method="addItemRender"><type>simple</type><block>printscience_personalization/adminhtml_sales_order_view_items_renderer</block><template>printscience_personalization/sales/order/view/items/renderer/default.phtml</template></action>
6
+ <action method="addItemRender"><type>configurable</type><block>printscience_personalization/adminhtml_sales_order_view_items_renderer</block><template>printscience_personalization/sales/order/view/items/renderer/default.phtml</template></action>
7
+ <action method="addItemRender"><type>default</type><block>printscience_personalization/adminhtml_sales_order_view_items_renderer</block><template>printscience_personalization/sales/order/view/items/renderer/default.phtml</template></action>
8
+ </reference>
9
+ </adminhtml_sales_order_view>
10
+ </layout>
app/design/adminhtml/default/default/template/printscience_personalization/sales/order/view/items/renderer/default.phtml ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_item = $this->getItem() ?>
2
+ <?php $this->setPriceDataObject($_item) ?>
3
+ <tr<?php if (!$this->canDisplayGiftmessage()): ?> class="border"<?php endif; ?>>
4
+ <td>
5
+ <?php if ($this->canDisplayContainer()): ?>
6
+ <div id="<?php echo $this->getHtmlId() ?>" class="item-container">
7
+ <?php endif; ?>
8
+ <div class="item-text">
9
+ <?php echo $this->getColumnHtml($_item, 'name') ?>
10
+ <?php $personalizationPdfUrl = $this->getPersonalizationPreviewPdfUrl() ?>
11
+ <?php if ($personalizationPdfUrl): ?>
12
+ <a href="<?php echo $personalizationPdfUrl; ?>" target="_blank"><?php echo $this->__('PDF file'); ?></a>
13
+ <?php endif; ?>
14
+ </div>
15
+ <?php if ($this->canDisplayContainer()): ?>
16
+ </div>
17
+ <?php endif ?>
18
+ </td>
19
+ <td class="a-center"><?php echo $_item->getStatus() ?></td>
20
+ <td class="a-right"><?php echo $this->displayPriceAttribute('original_price') ?></td>
21
+ <td class="a-right">
22
+ <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceExclTax()): ?>
23
+ <span class="price-excl-tax">
24
+ <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
25
+ <span class="label"><?php echo $this->__('Excl. Tax'); ?>:</span>
26
+ <?php endif; ?>
27
+
28
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
29
+ <?php
30
+ echo $this->displayPrices(
31
+ $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(),
32
+ $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()
33
+ );
34
+ ?>
35
+ <?php else: ?>
36
+ <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?>
37
+ <?php endif; ?>
38
+
39
+
40
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
41
+ <br />
42
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?>
43
+ <small>
44
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
45
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span>
46
+ <?php endforeach; ?>
47
+ </small>
48
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
49
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
50
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span>
51
+ <?php endforeach; ?>
52
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?>
53
+ <small>
54
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
55
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span>
56
+ <?php endforeach; ?>
57
+ </small>
58
+ <?php endif; ?>
59
+
60
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
61
+ <br />
62
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br />
63
+ <?php
64
+ echo $this->displayPrices(
65
+ $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(),
66
+ $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()
67
+ );
68
+ ?>
69
+ </span>
70
+ <?php endif; ?>
71
+ <?php endif; ?>
72
+ </span>
73
+ <br />
74
+ <?php endif; ?>
75
+ <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceInclTax()): ?>
76
+ <span class="price-incl-tax">
77
+ <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
78
+ <span class="label"><?php echo $this->__('Incl. Tax'); ?>:</span>
79
+ <?php endif; ?>
80
+ <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
81
+ <?php $_baseIncl = $this->helper('checkout')->getBasePriceInclTax($_item); ?>
82
+
83
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
84
+ <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?>
85
+ <?php else: ?>
86
+ <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?>
87
+ <?php endif; ?>
88
+
89
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
90
+ <br />
91
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?>
92
+ <small>
93
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
94
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span>
95
+ <?php endforeach; ?>
96
+ </small>
97
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
98
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
99
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span>
100
+ <?php endforeach; ?>
101
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?>
102
+ <small>
103
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
104
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span>
105
+ <?php endforeach; ?>
106
+ </small>
107
+ <?php endif; ?>
108
+
109
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
110
+ <br />
111
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?></span>
112
+ <?php endif; ?>
113
+ <?php endif; ?>
114
+ </span>
115
+ <?php endif; ?>
116
+
117
+ </td>
118
+ <td><?php echo $this->getColumnHtml($_item, 'qty') ?></td>
119
+
120
+ <td class="a-right">
121
+ <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceExclTax()): ?>
122
+ <span class="price-excl-tax">
123
+ <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
124
+ <span class="label"><?php echo $this->__('Excl. Tax'); ?>:</span>
125
+ <?php endif; ?>
126
+
127
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
128
+ <?php
129
+ echo $this->displayPrices(
130
+ $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmount()+$_item->getBaseWeeeTaxRowDisposition(),
131
+ $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()
132
+ );
133
+ ?>
134
+ <?php else: ?>
135
+ <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?>
136
+ <?php endif; ?>
137
+
138
+
139
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
140
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?>
141
+ <small>
142
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
143
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span>
144
+ <?php endforeach; ?>
145
+ </small>
146
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
147
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
148
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span>
149
+ <?php endforeach; ?>
150
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?>
151
+ <small>
152
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
153
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span>
154
+ <?php endforeach; ?>
155
+ </small>
156
+ <?php endif; ?>
157
+
158
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
159
+ <br />
160
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br />
161
+ <?php
162
+ echo $this->displayPrices(
163
+ $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmount()+$_item->getBaseWeeeTaxRowDisposition(),
164
+ $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()
165
+ );
166
+ ?>
167
+ </span>
168
+ <?php endif; ?>
169
+ <?php endif; ?>
170
+ </span>
171
+ <br />
172
+ <?php endif; ?>
173
+ <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceInclTax()): ?>
174
+ <span class="price-incl-tax">
175
+ <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
176
+ <span class="label"><?php echo $this->__('Incl. Tax'); ?>:</span>
177
+ <?php endif; ?>
178
+ <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
179
+ <?php $_baseIncl = $this->helper('checkout')->getBaseSubtotalInclTax($_item); ?>
180
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
181
+ <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmount(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
182
+ <?php else: ?>
183
+ <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?>
184
+ <?php endif; ?>
185
+
186
+
187
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
188
+
189
+ <br />
190
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?>
191
+ <small>
192
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
193
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span>
194
+ <?php endforeach; ?>
195
+ </small>
196
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
197
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
198
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span>
199
+ <?php endforeach; ?>
200
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?>
201
+ <small>
202
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
203
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span>
204
+ <?php endforeach; ?>
205
+ </small>
206
+ <?php endif; ?>
207
+
208
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
209
+ <br /><span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmount(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span>
210
+ <?php endif; ?>
211
+ <?php endif; ?>
212
+ </span>
213
+ <?php endif; ?>
214
+ </td>
215
+ <td class="a-right"><?php echo $this->displayPriceAttribute('tax_amount') ?></td>
216
+ <td class="a-right"><?php echo $this->displayTaxPercent($_item) ?></td>
217
+ <td class="a-right"><?php echo $this->displayPriceAttribute('discount_amount') ?></td>
218
+ <td class="a-right last">
219
+ <?php echo $this->displayPrices(
220
+ $_item->getBaseRowTotal() - $_item->getBaseDiscountAmount() + $_item->getBaseTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmount(),
221
+ $_item->getRowTotal() - $_item->getDiscountAmount() + $_item->getTaxAmount() + $_item->getWeeeTaxAppliedRowAmount()
222
+ ); ?>
223
+ </td>
224
+ </tr>
app/design/frontend/base/default/layout/printscience_personalization.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <catalog_product_view>
4
+ <reference name="product.info.addtocart">
5
+ <action method="setTemplate"><template>printscience_personalization/catalog/product/view/addtocart.phtml</template></action>
6
+ </reference>
7
+ </catalog_product_view>
8
+ <checkout_cart_index>
9
+ <reference name="checkout.cart">
10
+ <action method="addItemRender"><type>simple</type><block>printscience_personalization/checkout_cart_item_renderer</block><template>printscience_personalization/checkout/cart/item/default.phtml</template></action>
11
+ <action method="addItemRender"><type>configurable</type><block>printscience_personalization/checkout_cart_item_renderer</block><template>printscience_personalization/checkout/cart/item/default.phtml</template></action>
12
+ </reference>
13
+ </checkout_cart_index>
14
+ <catalog_category_layered>
15
+ <reference name="product_list">
16
+ <action method="setTemplate"><template>printscience_personalization/catalog/product/list.phtml</template></action>
17
+ </reference>
18
+ </catalog_category_layered>
19
+ <catalog_category_default>
20
+ <reference name="product_list">
21
+ <action method="setTemplate"><template>printscience_personalization/catalog/product/list.phtml</template></action>
22
+ </reference>
23
+ </catalog_category_default>
24
+ </layout>
app/design/frontend/base/default/template/printscience_personalization/catalog/product/list.phtml ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Product list template
30
+ *
31
+ * @see Mage_Catalog_Block_Product_List
32
+ */
33
+ ?>
34
+ <?php
35
+ $_productCollection = $this->getLoadedProductCollection();
36
+ $_helper = $this->helper('catalog/output');
37
+ $_personalizationHelper = $this->helper('printscience_personalization/output');
38
+ ?>
39
+ <?php if(!$_productCollection->count()): ?>
40
+ <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
41
+ <?php else: ?>
42
+ <div class="category-products">
43
+ <?php echo $this->getToolbarHtml() ?>
44
+ <?php // List mode ?>
45
+ <?php if($this->getMode()!='grid'): ?>
46
+ <?php $_iterator = 0; ?>
47
+ <ol class="products-list" id="products-list">
48
+ <?php foreach ($_productCollection as $_product): ?>
49
+ <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
50
+ <?php // Product Image ?>
51
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
52
+ <?php // Product description ?>
53
+ <div class="product-shop">
54
+ <div class="f-fix">
55
+ <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
56
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
57
+ <?php if($_product->getRatingSummary()): ?>
58
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
59
+ <?php endif; ?>
60
+ <?php echo $this->getPriceHtml($_product, true) ?>
61
+ <?php if ($_personalizationHelper->isPersonalizationEnabled($_product)): ?>
62
+ <?php $buttonTitle = $this->__('Personalize'); ?>
63
+ <?php else: ?>
64
+ <?php $buttonTitle = $this->__('Add to Cart'); ?>
65
+ <?php endif; ?>
66
+ <?php if($_product->isSaleable()): ?>
67
+ <p><button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $buttonTitle ?></span></span></button></p>
68
+ <?php else: ?>
69
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
70
+ <?php endif; ?>
71
+ <div class="desc std">
72
+ <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
73
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
74
+ </div>
75
+ <ul class="add-to-links">
76
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
77
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
78
+ <?php endif; ?>
79
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
80
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
81
+ <?php endif; ?>
82
+ </ul>
83
+ </div>
84
+ </div>
85
+ </li>
86
+ <?php endforeach; ?>
87
+ </ol>
88
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
89
+
90
+ <?php else: ?>
91
+
92
+ <?php // Grid Mode ?>
93
+
94
+ <?php $_collectionSize = $_productCollection->count() ?>
95
+ <?php $_columnCount = $this->getColumnCount(); ?>
96
+ <?php $i=0; foreach ($_productCollection as $_product): ?>
97
+ <?php if ($i++%$_columnCount==0): ?>
98
+ <ul class="products-grid">
99
+ <?php endif ?>
100
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
101
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
102
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
103
+ <?php if($_product->getRatingSummary()): ?>
104
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
105
+ <?php endif; ?>
106
+ <?php echo $this->getPriceHtml($_product, true) ?>
107
+ <div class="actions">
108
+ <?php if ($_personalizationHelper->isPersonalizationEnabled($_product)): ?>
109
+ <?php $buttonTitle = $this->__('Personalize'); ?>
110
+ <?php else: ?>
111
+ <?php $buttonTitle = $this->__('Add to Cart'); ?>
112
+ <?php endif; ?>
113
+ <?php if($_product->isSaleable()): ?>
114
+ <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $buttonTitle ?></span></span></button>
115
+ <?php else: ?>
116
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
117
+ <?php endif; ?>
118
+ <ul class="add-to-links">
119
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
120
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
121
+ <?php endif; ?>
122
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
123
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
124
+ <?php endif; ?>
125
+ </ul>
126
+ </div>
127
+ </li>
128
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
129
+ </ul>
130
+ <?php endif ?>
131
+ <?php endforeach ?>
132
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
133
+ <?php endif; ?>
134
+
135
+ <div class="toolbar-bottom">
136
+ <?php echo $this->getToolbarHtml() ?>
137
+ </div>
138
+ </div>
139
+ <?php endif; ?>
app/design/frontend/base/default/template/printscience_personalization/catalog/product/view/addtocart.phtml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_personalizationHelper = $this->helper('printscience_personalization/output');
3
+ $_product = $this->getProduct();
4
+ ?>
5
+ <?php if ($_personalizationHelper->isPersonalizationEnabled($_product)): ?>
6
+ <?php $buttonTitle = $this->__('Personalize'); ?>
7
+ <?php else: ?>
8
+ <?php $buttonTitle = $this->__('Add to Cart'); ?>
9
+ <?php endif; ?>
10
+ <?php if($_product->isSaleable()): ?>
11
+ <div class="add-to-cart">
12
+ <?php if(!$_product->isGrouped()): ?>
13
+ <label for="qty"><?php echo $this->__('Qty:') ?></label>
14
+ <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
15
+ <?php endif; ?>
16
+ <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
17
+ <?php echo $this->getChildHtml('', true, true) ?>
18
+ </div>
19
+ <?php endif; ?>
app/design/frontend/base/default/template/printscience_personalization/checkout/cart/item/default.phtml ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_item = $this->getItem();
3
+ $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
4
+ ?>
5
+ <tr>
6
+ <td>
7
+ <?php $apiSessionKey = $this->getPersonalizationApiSessionKey() ?>
8
+ <?php if ($apiSessionKey):?>
9
+ <?php $personalizationPreviews = $this->getPersonalizationPreviews() ?>
10
+ <div class="personalizationGallery">
11
+ <?php $class = '' ?>
12
+ <?php foreach ($personalizationPreviews as $previewImage): ?>
13
+ <?php if (!$class) { $class = 'class="first"'; } ?>
14
+ <a href="<?php echo $previewImage ?>" rel="fancybox[<?php echo $apiSessionKey ?>]" class="pgImg" target="_blank"><img src="<?php echo $previewImage ?>" width="75" alt="<?php echo $this->htmlEscape($this->getProductName()) ?>" <?php echo $class ?> /></a>
15
+ <?php endforeach; ?>
16
+ </div>
17
+ <div>
18
+ <button type="button" title="<?php echo $this->__('Personalize') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getPersonalizationUrl() ?>')"><span><span><?php echo $this->__('Personalize') ?></span></span></button>
19
+ </div>
20
+ <?php else: ?>
21
+ <?php if ($this->hasProductUrl()):?><a href="<?php echo $this->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getProductName()) ?>" class="product-image"><?php endif;?><img src="<?php echo $this->getProductThumbnail()->resize(75); ?>" width="75" height="75" alt="<?php echo $this->htmlEscape($this->getProductName()) ?>" /><?php if ($this->hasProductUrl()):?></a><?php endif;?>
22
+ <?php endif; ?>
23
+ </td>
24
+ <td>
25
+ <h2 class="product-name">
26
+ <?php if ($this->hasProductUrl()):?>
27
+ <a href="<?php echo $this->getProductUrl() ?>"><?php echo $this->htmlEscape($this->getProductName()) ?></a>
28
+ <?php else: ?>
29
+ <?php echo $this->htmlEscape($this->getProductName()) ?>
30
+ <?php endif; ?>
31
+ </h2>
32
+ <?php if ($_options = $this->getOptionList()):?>
33
+ <dl class="item-options">
34
+ <?php foreach ($_options as $_option) : ?>
35
+ <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
36
+ <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
37
+ <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
38
+ <?php if (isset($_formatedOptionValue['full_view'])): ?>
39
+ <div class="truncated_full_value">
40
+ <dl class="item-options">
41
+ <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
42
+ <dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
43
+ </dl>
44
+ </div>
45
+ <?php endif; ?>
46
+ </dd>
47
+ <?php endforeach; ?>
48
+ </dl>
49
+ <?php endif;?>
50
+ <?php if ($messages = $this->getMessages()): ?>
51
+ <?php foreach ($messages as $message): ?>
52
+ <p class="item-msg <?php echo $message['type'] ?>">* <?php echo $message['text'] ?></p>
53
+ <?php endforeach; ?>
54
+ <?php endif; ?>
55
+ <?php if ($addtInfoBlock = $this->getProductAdditionalInformationBlock()):?>
56
+ <?php echo $addtInfoBlock->setItem($_item)->toHtml() ?>
57
+ <?php endif;?>
58
+ </td>
59
+ <td class="a-center">
60
+ <?php if ($isVisibleProduct): ?>
61
+ <a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item parameters') ?>"><?php echo $this->__('Edit') ?></a>
62
+ <?php endif ?>
63
+ </td>
64
+ <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
65
+ <td class="a-center">
66
+ <?php if ($isVisibleProduct): ?>
67
+ <input type="checkbox" value="1" name="cart[<?php echo $_item->getId() ?>][wishlist]" title="<?php echo $this->__('Move to Wishlist') ?>" class="checkbox" />
68
+ <?php endif ?>
69
+ </td>
70
+ <?php endif ?>
71
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
72
+ <td class="a-right">
73
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
74
+ <span class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
75
+ <?php else: ?>
76
+ <span class="cart-price">
77
+ <?php endif; ?>
78
+
79
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
80
+ <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
81
+ <?php else: ?>
82
+ <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>
83
+ <?php endif; ?>
84
+
85
+ </span>
86
+
87
+
88
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
89
+
90
+ <div class="cart-tax-info" id="eunit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
91
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
92
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
93
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
94
+ <?php endforeach; ?>
95
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
96
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
97
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
98
+ <?php endforeach; ?>
99
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
100
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
101
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
102
+ <?php endforeach; ?>
103
+ <?php endif; ?>
104
+ </div>
105
+
106
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
107
+ <div class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
108
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
109
+ </div>
110
+ <?php endif; ?>
111
+ <?php endif; ?>
112
+ </td>
113
+ <?php endif; ?>
114
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
115
+ <td>
116
+ <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
117
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
118
+ <span class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
119
+ <?php else: ?>
120
+ <span class="cart-price">
121
+ <?php endif; ?>
122
+
123
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
124
+ <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?>
125
+ <?php else: ?>
126
+ <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
127
+ <?php endif; ?>
128
+
129
+ </span>
130
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
131
+
132
+ <div class="cart-tax-info" id="unit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
133
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
134
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
135
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
136
+ <?php endforeach; ?>
137
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
138
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
139
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
140
+ <?php endforeach; ?>
141
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
142
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
143
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
144
+ <?php endforeach; ?>
145
+ <?php endif; ?>
146
+ </div>
147
+
148
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
149
+ <div class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
150
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?></span>
151
+ </div>
152
+ <?php endif; ?>
153
+ <?php endif; ?>
154
+ </td>
155
+ <?php endif; ?>
156
+ <td class="a-center">
157
+ <input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" />
158
+ </td>
159
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
160
+ <td class="a-right">
161
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
162
+ <span class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
163
+ <?php else: ?>
164
+ <span class="cart-price">
165
+ <?php endif; ?>
166
+
167
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
168
+ <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
169
+ <?php else: ?>
170
+ <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()) ?>
171
+ <?php endif; ?>
172
+
173
+ </span>
174
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
175
+
176
+ <div class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
177
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
178
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
179
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
180
+ <?php endforeach; ?>
181
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
182
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
183
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
184
+ <?php endforeach; ?>
185
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
186
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
187
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
188
+ <?php endforeach; ?>
189
+ <?php endif; ?>
190
+ </div>
191
+
192
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
193
+ <div class="cart-tax-total" onclick="taxToggle('esubtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
194
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
195
+ </div>
196
+ <?php endif; ?>
197
+ <?php endif; ?>
198
+ </td>
199
+ <?php endif; ?>
200
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
201
+ <td>
202
+ <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
203
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
204
+ <span class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
205
+ <?php else: ?>
206
+ <span class="cart-price">
207
+ <?php endif; ?>
208
+
209
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
210
+ <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
211
+ <?php else: ?>
212
+ <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?>
213
+ <?php endif; ?>
214
+
215
+ </span>
216
+
217
+
218
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
219
+
220
+ <div class="cart-tax-info" id="subtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
221
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
222
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
223
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount'],true,true); ?></span>
224
+ <?php endforeach; ?>
225
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
226
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
227
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
228
+ <?php endforeach; ?>
229
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
230
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
231
+ <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span>
232
+ <?php endforeach; ?>
233
+ <?php endif; ?>
234
+ </div>
235
+
236
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
237
+ <div class="cart-tax-total" onclick="taxToggle('subtotal-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
238
+ <span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span>
239
+ </div>
240
+ <?php endif; ?>
241
+ <?php endif; ?>
242
+ </td>
243
+ <?php endif; ?>
244
+ <td class="a-center"><a href="<?php echo $this->getDeleteUrl()?>" title="<?php echo $this->__('Remove item')?>" class="btn-remove btn-remove2"><?php echo $this->__('Remove item')?></a></td>
245
+ </tr>
app/etc/modules/PrintScience_Personalization.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <PrintScience_Personalization>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </PrintScience_Personalization>
8
+ </modules>
9
+ </config>
js/printscience_personalization/gallery.css ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ .personalizationGallery {
2
+ width: 75px;
3
+ margin-bottom: 10px;
4
+ }
5
+ .personalizationGallery img {
6
+ width: 75px;
7
+ display: none;
8
+ }
9
+ .personalizationGallery img.first {
10
+ display: block;
11
+ }
js/printscience_personalization/gallery.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($) {
2
+ $(window).load(function() {
3
+ $('.personalizationGallery').each(function(index, el) {
4
+ var imgHeightList = [];
5
+
6
+ $(el).find('img').each(function(index, el) {
7
+ $(el).css('display', 'block');
8
+ imgHeightList.push($(el).height());
9
+ });
10
+
11
+ $(el).data('tmpHeight', Math.max.apply(null, imgHeightList));
12
+ });
13
+
14
+ $('.personalizationGallery').cycle({
15
+ fx: 'fade',
16
+ speed: 300,
17
+ timeout: 3000,
18
+ pause: 1
19
+ });
20
+
21
+ $('.personalizationGallery').each(function(index, el) {
22
+ $(el).css('height', $(el).data('tmpHeight'));
23
+ });
24
+ })
25
+ $(document).ready(function() {
26
+ $("a.pgImg").fancybox();
27
+ })
28
+ })(jQuery)
js/printscience_personalization/jquery/fancybox/blank.gif ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_close.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_loading.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_nav_left.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_nav_right.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_shadow_e.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_shadow_n.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_shadow_ne.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_shadow_nw.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_shadow_s.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_shadow_se.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_shadow_sw.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_shadow_w.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_title_left.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_title_main.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_title_over.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancy_title_right.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancybox-x.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancybox-y.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/fancybox.png ADDED
Binary file
js/printscience_personalization/jquery/fancybox/jquery.easing-1.3.pack.js ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
3
+ *
4
+ * Uses the built in easing capabilities added In jQuery 1.1
5
+ * to offer multiple easing options
6
+ *
7
+ * TERMS OF USE - jQuery Easing
8
+ *
9
+ * Open source under the BSD License.
10
+ *
11
+ * Copyright © 2008 George McGinley Smith
12
+ * All rights reserved.
13
+ *
14
+ * Redistribution and use in source and binary forms, with or without modification,
15
+ * are permitted provided that the following conditions are met:
16
+ *
17
+ * Redistributions of source code must retain the above copyright notice, this list of
18
+ * conditions and the following disclaimer.
19
+ * Redistributions in binary form must reproduce the above copyright notice, this list
20
+ * of conditions and the following disclaimer in the documentation and/or other materials
21
+ * provided with the distribution.
22
+ *
23
+ * Neither the name of the author nor the names of contributors may be used to endorse
24
+ * or promote products derived from this software without specific prior written permission.
25
+ *
26
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
27
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
31
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
32
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
34
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
35
+ *
36
+ */
37
+
38
+ // t: current time, b: begInnIng value, c: change In value, d: duration
39
+ eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h.i[\'1a\']=h.i[\'z\'];h.O(h.i,{y:\'D\',z:9(x,t,b,c,d){6 h.i[h.i.y](x,t,b,c,d)},17:9(x,t,b,c,d){6 c*(t/=d)*t+b},D:9(x,t,b,c,d){6-c*(t/=d)*(t-2)+b},13:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t+b;6-c/2*((--t)*(t-2)-1)+b},X:9(x,t,b,c,d){6 c*(t/=d)*t*t+b},U:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t+1)+b},R:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t+b;6 c/2*((t-=2)*t*t+2)+b},N:9(x,t,b,c,d){6 c*(t/=d)*t*t*t+b},M:9(x,t,b,c,d){6-c*((t=t/d-1)*t*t*t-1)+b},L:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t+b;6-c/2*((t-=2)*t*t*t-2)+b},K:9(x,t,b,c,d){6 c*(t/=d)*t*t*t*t+b},J:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t*t*t+1)+b},I:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t*t+b;6 c/2*((t-=2)*t*t*t*t+2)+b},G:9(x,t,b,c,d){6-c*8.C(t/d*(8.g/2))+c+b},15:9(x,t,b,c,d){6 c*8.n(t/d*(8.g/2))+b},12:9(x,t,b,c,d){6-c/2*(8.C(8.g*t/d)-1)+b},Z:9(x,t,b,c,d){6(t==0)?b:c*8.j(2,10*(t/d-1))+b},Y:9(x,t,b,c,d){6(t==d)?b+c:c*(-8.j(2,-10*t/d)+1)+b},W:9(x,t,b,c,d){e(t==0)6 b;e(t==d)6 b+c;e((t/=d/2)<1)6 c/2*8.j(2,10*(t-1))+b;6 c/2*(-8.j(2,-10*--t)+2)+b},V:9(x,t,b,c,d){6-c*(8.o(1-(t/=d)*t)-1)+b},S:9(x,t,b,c,d){6 c*8.o(1-(t=t/d-1)*t)+b},Q:9(x,t,b,c,d){e((t/=d/2)<1)6-c/2*(8.o(1-t*t)-1)+b;6 c/2*(8.o(1-(t-=2)*t)+1)+b},P:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6-(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b},H:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6 a*8.j(2,-10*t)*8.n((t*d-s)*(2*8.g)/p)+c+b},T:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d/2)==2)6 b+c;e(!p)p=d*(.3*1.5);e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);e(t<1)6-.5*(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b;6 a*8.j(2,-10*(t-=1))*8.n((t*d-s)*(2*8.g)/p)*.5+c+b},F:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*(t/=d)*t*((s+1)*t-s)+b},E:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},16:9(x,t,b,c,d,s){e(s==u)s=1.l;e((t/=d/2)<1)6 c/2*(t*t*(((s*=(1.B))+1)*t-s))+b;6 c/2*((t-=2)*t*(((s*=(1.B))+1)*t+s)+2)+b},A:9(x,t,b,c,d){6 c-h.i.v(x,d-t,0,c,d)+b},v:9(x,t,b,c,d){e((t/=d)<(1/2.k)){6 c*(7.q*t*t)+b}m e(t<(2/2.k)){6 c*(7.q*(t-=(1.5/2.k))*t+.k)+b}m e(t<(2.5/2.k)){6 c*(7.q*(t-=(2.14/2.k))*t+.11)+b}m{6 c*(7.q*(t-=(2.18/2.k))*t+.19)+b}},1b:9(x,t,b,c,d){e(t<d/2)6 h.i.A(x,t*2,0,c,d)*.5+b;6 h.i.v(x,t*2-d,0,c,d)*.5+c*.5+b}});',62,74,'||||||return||Math|function|||||if|var|PI|jQuery|easing|pow|75|70158|else|sin|sqrt||5625|asin|||undefined|easeOutBounce|abs||def|swing|easeInBounce|525|cos|easeOutQuad|easeOutBack|easeInBack|easeInSine|easeOutElastic|easeInOutQuint|easeOutQuint|easeInQuint|easeInOutQuart|easeOutQuart|easeInQuart|extend|easeInElastic|easeInOutCirc|easeInOutCubic|easeOutCirc|easeInOutElastic|easeOutCubic|easeInCirc|easeInOutExpo|easeInCubic|easeOutExpo|easeInExpo||9375|easeInOutSine|easeInOutQuad|25|easeOutSine|easeInOutBack|easeInQuad|625|984375|jswing|easeInOutBounce'.split('|'),0,{}))
40
+
41
+ /*
42
+ *
43
+ * TERMS OF USE - EASING EQUATIONS
44
+ *
45
+ * Open source under the BSD License.
46
+ *
47
+ * Copyright © 2001 Robert Penner
48
+ * All rights reserved.
49
+ *
50
+ * Redistribution and use in source and binary forms, with or without modification,
51
+ * are permitted provided that the following conditions are met:
52
+ *
53
+ * Redistributions of source code must retain the above copyright notice, this list of
54
+ * conditions and the following disclaimer.
55
+ * Redistributions in binary form must reproduce the above copyright notice, this list
56
+ * of conditions and the following disclaimer in the documentation and/or other materials
57
+ * provided with the distribution.
58
+ *
59
+ * Neither the name of the author nor the names of contributors may be used to endorse
60
+ * or promote products derived from this software without specific prior written permission.
61
+ *
62
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
63
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
64
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
65
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
66
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
67
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
68
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
69
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
71
+ *
72
+ */
js/printscience_personalization/jquery/fancybox/jquery.fancybox-1.3.4.css ADDED
@@ -0,0 +1,359 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * FancyBox - jQuery Plugin
3
+ * Simple and fancy lightbox alternative
4
+ *
5
+ * Examples and documentation at: http://fancybox.net
6
+ *
7
+ * Copyright (c) 2008 - 2010 Janis Skarnelis
8
+ * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
9
+ *
10
+ * Version: 1.3.4 (11/11/2010)
11
+ * Requires: jQuery v1.3+
12
+ *
13
+ * Dual licensed under the MIT and GPL licenses:
14
+ * http://www.opensource.org/licenses/mit-license.php
15
+ * http://www.gnu.org/licenses/gpl.html
16
+ */
17
+
18
+ #fancybox-loading {
19
+ position: fixed;
20
+ top: 50%;
21
+ left: 50%;
22
+ width: 40px;
23
+ height: 40px;
24
+ margin-top: -20px;
25
+ margin-left: -20px;
26
+ cursor: pointer;
27
+ overflow: hidden;
28
+ z-index: 1104;
29
+ display: none;
30
+ }
31
+
32
+ #fancybox-loading div {
33
+ position: absolute;
34
+ top: 0;
35
+ left: 0;
36
+ width: 40px;
37
+ height: 480px;
38
+ background-image: url('fancybox.png');
39
+ }
40
+
41
+ #fancybox-overlay {
42
+ position: absolute;
43
+ top: 0;
44
+ left: 0;
45
+ width: 100%;
46
+ z-index: 1100;
47
+ display: none;
48
+ }
49
+
50
+ #fancybox-tmp {
51
+ padding: 0;
52
+ margin: 0;
53
+ border: 0;
54
+ overflow: auto;
55
+ display: none;
56
+ }
57
+
58
+ #fancybox-wrap {
59
+ position: absolute;
60
+ top: 0;
61
+ left: 0;
62
+ padding: 20px;
63
+ z-index: 1101;
64
+ outline: none;
65
+ display: none;
66
+ }
67
+
68
+ #fancybox-outer {
69
+ position: relative;
70
+ width: 100%;
71
+ height: 100%;
72
+ background: #fff;
73
+ }
74
+
75
+ #fancybox-content {
76
+ width: 0;
77
+ height: 0;
78
+ padding: 0;
79
+ outline: none;
80
+ position: relative;
81
+ overflow: hidden;
82
+ z-index: 1102;
83
+ border: 0px solid #fff;
84
+ }
85
+
86
+ #fancybox-hide-sel-frame {
87
+ position: absolute;
88
+ top: 0;
89
+ left: 0;
90
+ width: 100%;
91
+ height: 100%;
92
+ background: transparent;
93
+ z-index: 1101;
94
+ }
95
+
96
+ #fancybox-close {
97
+ position: absolute;
98
+ top: -15px;
99
+ right: -15px;
100
+ width: 30px;
101
+ height: 30px;
102
+ background: transparent url('fancybox.png') -40px 0px;
103
+ cursor: pointer;
104
+ z-index: 1103;
105
+ display: none;
106
+ }
107
+
108
+ #fancybox-error {
109
+ color: #444;
110
+ font: normal 12px/20px Arial;
111
+ padding: 14px;
112
+ margin: 0;
113
+ }
114
+
115
+ #fancybox-img {
116
+ width: 100%;
117
+ height: 100%;
118
+ padding: 0;
119
+ margin: 0;
120
+ border: none;
121
+ outline: none;
122
+ line-height: 0;
123
+ vertical-align: top;
124
+ }
125
+
126
+ #fancybox-frame {
127
+ width: 100%;
128
+ height: 100%;
129
+ border: none;
130
+ display: block;
131
+ }
132
+
133
+ #fancybox-left, #fancybox-right {
134
+ position: absolute;
135
+ bottom: 0px;
136
+ height: 100%;
137
+ width: 35%;
138
+ cursor: pointer;
139
+ outline: none;
140
+ background: transparent url('blank.gif');
141
+ z-index: 1102;
142
+ display: none;
143
+ }
144
+
145
+ #fancybox-left {
146
+ left: 0px;
147
+ }
148
+
149
+ #fancybox-right {
150
+ right: 0px;
151
+ }
152
+
153
+ #fancybox-left-ico, #fancybox-right-ico {
154
+ position: absolute;
155
+ top: 50%;
156
+ left: -9999px;
157
+ width: 30px;
158
+ height: 30px;
159
+ margin-top: -15px;
160
+ cursor: pointer;
161
+ z-index: 1102;
162
+ display: block;
163
+ }
164
+
165
+ #fancybox-left-ico {
166
+ background-image: url('fancybox.png');
167
+ background-position: -40px -30px;
168
+ }
169
+
170
+ #fancybox-right-ico {
171
+ background-image: url('fancybox.png');
172
+ background-position: -40px -60px;
173
+ }
174
+
175
+ #fancybox-left:hover, #fancybox-right:hover {
176
+ visibility: visible; /* IE6 */
177
+ }
178
+
179
+ #fancybox-left:hover span {
180
+ left: 20px;
181
+ }
182
+
183
+ #fancybox-right:hover span {
184
+ left: auto;
185
+ right: 20px;
186
+ }
187
+
188
+ .fancybox-bg {
189
+ position: absolute;
190
+ padding: 0;
191
+ margin: 0;
192
+ border: 0;
193
+ width: 20px;
194
+ height: 20px;
195
+ z-index: 1001;
196
+ }
197
+
198
+ #fancybox-bg-n {
199
+ top: -20px;
200
+ left: 0;
201
+ width: 100%;
202
+ background-image: url('fancybox-x.png');
203
+ }
204
+
205
+ #fancybox-bg-ne {
206
+ top: -20px;
207
+ right: -20px;
208
+ background-image: url('fancybox.png');
209
+ background-position: -40px -162px;
210
+ }
211
+
212
+ #fancybox-bg-e {
213
+ top: 0;
214
+ right: -20px;
215
+ height: 100%;
216
+ background-image: url('fancybox-y.png');
217
+ background-position: -20px 0px;
218
+ }
219
+
220
+ #fancybox-bg-se {
221
+ bottom: -20px;
222
+ right: -20px;
223
+ background-image: url('fancybox.png');
224
+ background-position: -40px -182px;
225
+ }
226
+
227
+ #fancybox-bg-s {
228
+ bottom: -20px;
229
+ left: 0;
230
+ width: 100%;
231
+ background-image: url('fancybox-x.png');
232
+ background-position: 0px -20px;
233
+ }
234
+
235
+ #fancybox-bg-sw {
236
+ bottom: -20px;
237
+ left: -20px;
238
+ background-image: url('fancybox.png');
239
+ background-position: -40px -142px;
240
+ }
241
+
242
+ #fancybox-bg-w {
243
+ top: 0;
244
+ left: -20px;
245
+ height: 100%;
246
+ background-image: url('fancybox-y.png');
247
+ }
248
+
249
+ #fancybox-bg-nw {
250
+ top: -20px;
251
+ left: -20px;
252
+ background-image: url('fancybox.png');
253
+ background-position: -40px -122px;
254
+ }
255
+
256
+ #fancybox-title {
257
+ font-family: Helvetica;
258
+ font-size: 12px;
259
+ z-index: 1102;
260
+ }
261
+
262
+ .fancybox-title-inside {
263
+ padding-bottom: 10px;
264
+ text-align: center;
265
+ color: #333;
266
+ background: #fff;
267
+ position: relative;
268
+ }
269
+
270
+ .fancybox-title-outside {
271
+ padding-top: 10px;
272
+ color: #fff;
273
+ }
274
+
275
+ .fancybox-title-over {
276
+ position: absolute;
277
+ bottom: 0;
278
+ left: 0;
279
+ color: #FFF;
280
+ text-align: left;
281
+ }
282
+
283
+ #fancybox-title-over {
284
+ padding: 10px;
285
+ background-image: url('fancy_title_over.png');
286
+ display: block;
287
+ }
288
+
289
+ .fancybox-title-float {
290
+ position: absolute;
291
+ left: 0;
292
+ bottom: -20px;
293
+ height: 32px;
294
+ }
295
+
296
+ #fancybox-title-float-wrap {
297
+ border: none;
298
+ border-collapse: collapse;
299
+ width: auto;
300
+ }
301
+
302
+ #fancybox-title-float-wrap td {
303
+ border: none;
304
+ white-space: nowrap;
305
+ }
306
+
307
+ #fancybox-title-float-left {
308
+ padding: 0 0 0 15px;
309
+ background: url('fancybox.png') -40px -90px no-repeat;
310
+ }
311
+
312
+ #fancybox-title-float-main {
313
+ color: #FFF;
314
+ line-height: 29px;
315
+ font-weight: bold;
316
+ padding: 0 0 3px 0;
317
+ background: url('fancybox-x.png') 0px -40px;
318
+ }
319
+
320
+ #fancybox-title-float-right {
321
+ padding: 0 0 0 15px;
322
+ background: url('fancybox.png') -55px -90px no-repeat;
323
+ }
324
+
325
+ /* IE6 */
326
+
327
+ .fancybox-ie6 #fancybox-close { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_close.png', sizingMethod='scale'); }
328
+
329
+ .fancybox-ie6 #fancybox-left-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_nav_left.png', sizingMethod='scale'); }
330
+ .fancybox-ie6 #fancybox-right-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_nav_right.png', sizingMethod='scale'); }
331
+
332
+ .fancybox-ie6 #fancybox-title-over { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_over.png', sizingMethod='scale'); zoom: 1; }
333
+ .fancybox-ie6 #fancybox-title-float-left { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_left.png', sizingMethod='scale'); }
334
+ .fancybox-ie6 #fancybox-title-float-main { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_main.png', sizingMethod='scale'); }
335
+ .fancybox-ie6 #fancybox-title-float-right { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_right.png', sizingMethod='scale'); }
336
+
337
+ .fancybox-ie6 #fancybox-bg-w, .fancybox-ie6 #fancybox-bg-e, .fancybox-ie6 #fancybox-left, .fancybox-ie6 #fancybox-right, #fancybox-hide-sel-frame {
338
+ height: expression(this.parentNode.clientHeight + "px");
339
+ }
340
+
341
+ #fancybox-loading.fancybox-ie6 {
342
+ position: absolute; margin-top: 0;
343
+ top: expression( (-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px');
344
+ }
345
+
346
+ #fancybox-loading.fancybox-ie6 div { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_loading.png', sizingMethod='scale'); }
347
+
348
+ /* IE6, IE7, IE8 */
349
+
350
+ .fancybox-ie .fancybox-bg { background: transparent !important; }
351
+
352
+ .fancybox-ie #fancybox-bg-n { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_n.png', sizingMethod='scale'); }
353
+ .fancybox-ie #fancybox-bg-ne { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_ne.png', sizingMethod='scale'); }
354
+ .fancybox-ie #fancybox-bg-e { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_e.png', sizingMethod='scale'); }
355
+ .fancybox-ie #fancybox-bg-se { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_se.png', sizingMethod='scale'); }
356
+ .fancybox-ie #fancybox-bg-s { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_s.png', sizingMethod='scale'); }
357
+ .fancybox-ie #fancybox-bg-sw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_sw.png', sizingMethod='scale'); }
358
+ .fancybox-ie #fancybox-bg-w { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_w.png', sizingMethod='scale'); }
359
+ .fancybox-ie #fancybox-bg-nw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_nw.png', sizingMethod='scale'); }
js/printscience_personalization/jquery/fancybox/jquery.fancybox-1.3.4.pack.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * FancyBox - jQuery Plugin
3
+ * Simple and fancy lightbox alternative
4
+ *
5
+ * Examples and documentation at: http://fancybox.net
6
+ *
7
+ * Copyright (c) 2008 - 2010 Janis Skarnelis
8
+ * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
9
+ *
10
+ * Version: 1.3.4 (11/11/2010)
11
+ * Requires: jQuery v1.3+
12
+ *
13
+ * Dual licensed under the MIT and GPL licenses:
14
+ * http://www.opensource.org/licenses/mit-license.php
15
+ * http://www.gnu.org/licenses/gpl.html
16
+ */
17
+
18
+ ;(function(b){var m,t,u,f,D,j,E,n,z,A,q=0,e={},o=[],p=0,d={},l=[],G=null,v=new Image,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,W=/[^\.]\.(swf)\s*$/i,K,L=1,y=0,s="",r,i,h=false,B=b.extend(b("<div/>")[0],{prop:0}),M=b.browser.msie&&b.browser.version<7&&!window.XMLHttpRequest,N=function(){t.hide();v.onerror=v.onload=null;G&&G.abort();m.empty()},O=function(){if(false===e.onError(o,q,e)){t.hide();h=false}else{e.titleShow=false;e.width="auto";e.height="auto";m.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');
19
+ F()}},I=function(){var a=o[q],c,g,k,C,P,w;N();e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));w=e.onStart(o,q,e);if(w===false)h=false;else{if(typeof w=="object")e=b.extend(e,w);k=e.title||(a.nodeName?b(a).attr("title"):a.title)||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(k===""&&e.orig&&e.titleFromAlt)k=e.orig.attr("alt");c=e.href||(a.nodeName?b(a).attr("href"):a.href)||null;if(/^(?:javascript)/i.test(c)||
20
+ c=="#")c=null;if(e.type){g=e.type;if(!c)c=e.content}else if(e.content)g="html";else if(c)g=c.match(J)?"image":c.match(W)?"swf":b(a).hasClass("iframe")?"iframe":c.indexOf("#")===0?"inline":"ajax";if(g){if(g=="inline"){a=c.substr(c.indexOf("#"));g=b(a).length>0?"inline":"ajax"}e.type=g;e.href=c;e.title=k;if(e.autoDimensions)if(e.type=="html"||e.type=="inline"||e.type=="ajax"){e.width="auto";e.height="auto"}else e.autoDimensions=false;if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=
21
+ false;e.enableEscapeButton=false;e.showCloseButton=false}e.padding=parseInt(e.padding,10);e.margin=parseInt(e.margin,10);m.css("padding",e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(j.children())});switch(g){case "html":m.html(e.content);F();break;case "inline":if(b(a).parent().is("#fancybox-content")===true){h=false;break}b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(j.children())}).bind("fancybox-cancel",
22
+ function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();v=new Image;v.onerror=function(){O()};v.onload=function(){h=true;v.onerror=v.onload=null;e.width=v.width;e.height=v.height;b("<img />").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+c+
23
+ '"></param>';P="";b.each(e.swf,function(x,H){C+='<param name="'+x+'" value="'+H+'"></param>';P+=" "+x+'="'+H+'"'});C+='<embed src="'+c+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+P+"></embed></object>";m.html(C);F();break;case "ajax":h=false;b.fancybox.showActivity();e.ajax.win=e.ajax.success;G=b.ajax(b.extend({},e.ajax,{url:c,data:e.ajax.data||{},error:function(x){x.status>0&&O()},success:function(x,H,R){if((typeof R=="object"?R:G).status==200){if(typeof e.ajax.win==
24
+ "function"){w=e.ajax.win(c,x,H,R);if(w===false){t.hide();return}else if(typeof w=="string"||typeof w=="object")x=w}m.html(x);F()}}}));break;case "iframe":Q()}}else O()}},F=function(){var a=e.width,c=e.height;a=a.toString().indexOf("%")>-1?parseInt((b(window).width()-e.margin*2)*parseFloat(a)/100,10)+"px":a=="auto"?"auto":a+"px";c=c.toString().indexOf("%")>-1?parseInt((b(window).height()-e.margin*2)*parseFloat(c)/100,10)+"px":c=="auto"?"auto":c+"px";m.wrapInner('<div style="width:'+a+";height:"+c+
25
+ ";overflow: "+(e.scrolling=="auto"?"auto":e.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');e.width=m.width();e.height=m.height();Q()},Q=function(){var a,c;t.hide();if(f.is(":visible")&&false===d.onCleanup(l,p,d)){b.event.trigger("fancybox-cancel");h=false}else{h=true;b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");f.is(":visible")&&d.titlePosition!=="outside"&&f.css("height",f.height());l=o;p=q;d=e;if(d.overlayShow){u.css({"background-color":d.overlayColor,
26
+ opacity:d.overlayOpacity,cursor:d.hideOnOverlayClick?"pointer":"auto",height:b(document).height()});if(!u.is(":visible")){M&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});u.show()}}else u.hide();i=X();s=d.title||"";y=0;n.empty().removeAttr("style").removeClass();if(d.titleShow!==false){if(b.isFunction(d.titleFormat))a=d.titleFormat(s,l,p,d);else a=s&&s.length?
27
+ d.titlePosition=="float"?'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+s+'</td><td id="fancybox-title-float-right"></td></tr></table>':'<div id="fancybox-title-'+d.titlePosition+'">'+s+"</div>":false;s=a;if(!(!s||s==="")){n.addClass("fancybox-title-"+d.titlePosition).html(s).appendTo("body").show();switch(d.titlePosition){case "inside":n.css({width:i.width-d.padding*2,marginLeft:d.padding,marginRight:d.padding});
28
+ y=n.outerHeight(true);n.appendTo(D);i.height+=y;break;case "over":n.css({marginLeft:d.padding,width:i.width-d.padding*2,bottom:d.padding}).appendTo(D);break;case "float":n.css("left",parseInt((n.width()-i.width-40)/2,10)*-1).appendTo(f);break;default:n.css({width:i.width-d.padding*2,paddingLeft:d.padding,paddingRight:d.padding}).appendTo(f)}}}n.hide();if(f.is(":visible")){b(E.add(z).add(A)).hide();a=f.position();r={top:a.top,left:a.left,width:f.width(),height:f.height()};c=r.width==i.width&&r.height==
29
+ i.height;j.fadeTo(d.changeFade,0.3,function(){var g=function(){j.html(m.contents()).fadeTo(d.changeFade,1,S)};b.event.trigger("fancybox-change");j.empty().removeAttr("filter").css({"border-width":d.padding,width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2});if(c)g();else{B.prop=0;b(B).animate({prop:1},{duration:d.changeSpeed,easing:d.easingChange,step:T,complete:g})}})}else{f.removeAttr("style");j.css("border-width",d.padding);if(d.transitionIn=="elastic"){r=V();j.html(m.contents());
30
+ f.show();if(d.opacity)i.opacity=0;B.prop=0;b(B).animate({prop:1},{duration:d.speedIn,easing:d.easingIn,step:T,complete:S})}else{d.titlePosition=="inside"&&y>0&&n.show();j.css({width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2}).html(m.contents());f.css(i).fadeIn(d.transitionIn=="none"?0:d.speedIn,S)}}}},Y=function(){if(d.enableEscapeButton||d.enableKeyboardNav)b(document).bind("keydown.fb",function(a){if(a.keyCode==27&&d.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if((a.keyCode==
31
+ 37||a.keyCode==39)&&d.enableKeyboardNav&&a.target.tagName!=="INPUT"&&a.target.tagName!=="TEXTAREA"&&a.target.tagName!=="SELECT"){a.preventDefault();b.fancybox[a.keyCode==37?"prev":"next"]()}});if(d.showNavArrows){if(d.cyclic&&l.length>1||p!==0)z.show();if(d.cyclic&&l.length>1||p!=l.length-1)A.show()}else{z.hide();A.hide()}},S=function(){if(!b.support.opacity){j.get(0).style.removeAttribute("filter");f.get(0).style.removeAttribute("filter")}e.autoDimensions&&j.css("height","auto");f.css("height","auto");
32
+ s&&s.length&&n.show();d.showCloseButton&&E.show();Y();d.hideOnContentClick&&j.bind("click",b.fancybox.close);d.hideOnOverlayClick&&u.bind("click",b.fancybox.close);b(window).bind("resize.fb",b.fancybox.resize);d.centerOnScroll&&b(window).bind("scroll.fb",b.fancybox.center);if(d.type=="iframe")b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" '+(b.browser.msie?'allowtransparency="true""':"")+' scrolling="'+e.scrolling+'" src="'+d.href+'"></iframe>').appendTo(j);
33
+ f.show();h=false;b.fancybox.center();d.onComplete(l,p,d);var a,c;if(l.length-1>p){a=l[p+1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}if(p>0){a=l[p-1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}},T=function(a){var c={width:parseInt(r.width+(i.width-r.width)*a,10),height:parseInt(r.height+(i.height-r.height)*a,10),top:parseInt(r.top+(i.top-r.top)*a,10),left:parseInt(r.left+(i.left-r.left)*a,10)};if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c);
34
+ j.css({width:c.width-d.padding*2,height:c.height-y*a-d.padding*2})},U=function(){return[b(window).width()-d.margin*2,b(window).height()-d.margin*2,b(document).scrollLeft()+d.margin,b(document).scrollTop()+d.margin]},X=function(){var a=U(),c={},g=d.autoScale,k=d.padding*2;c.width=d.width.toString().indexOf("%")>-1?parseInt(a[0]*parseFloat(d.width)/100,10):d.width+k;c.height=d.height.toString().indexOf("%")>-1?parseInt(a[1]*parseFloat(d.height)/100,10):d.height+k;if(g&&(c.width>a[0]||c.height>a[1]))if(e.type==
35
+ "image"||e.type=="swf"){g=d.width/d.height;if(c.width>a[0]){c.width=a[0];c.height=parseInt((c.width-k)/g+k,10)}if(c.height>a[1]){c.height=a[1];c.width=parseInt((c.height-k)*g+k,10)}}else{c.width=Math.min(c.width,a[0]);c.height=Math.min(c.height,a[1])}c.top=parseInt(Math.max(a[3]-20,a[3]+(a[1]-c.height-40)*0.5),10);c.left=parseInt(Math.max(a[2]-20,a[2]+(a[0]-c.width-40)*0.5),10);return c},V=function(){var a=e.orig?b(e.orig):false,c={};if(a&&a.length){c=a.offset();c.top+=parseInt(a.css("paddingTop"),
36
+ 10)||0;c.left+=parseInt(a.css("paddingLeft"),10)||0;c.top+=parseInt(a.css("border-top-width"),10)||0;c.left+=parseInt(a.css("border-left-width"),10)||0;c.width=a.width();c.height=a.height();c={width:c.width+d.padding*2,height:c.height+d.padding*2,top:c.top-d.padding-20,left:c.left-d.padding-20}}else{a=U();c={width:d.padding*2,height:d.padding*2,top:parseInt(a[3]+a[1]*0.5,10),left:parseInt(a[2]+a[0]*0.5,10)}}return c},Z=function(){if(t.is(":visible")){b("div",t).css("top",L*-40+"px");L=(L+1)%12}else clearInterval(K)};
37
+ b.fn.fancybox=function(a){if(!b(this).length)return this;b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(c){c.preventDefault();if(!h){h=true;b(this).blur();o=[];q=0;c=b(this).attr("rel")||"";if(!c||c==""||c==="nofollow")o.push(this);else{o=b("a[rel="+c+"], area[rel="+c+"]");q=o.index(this)}I()}});return this};b.fancybox=function(a,c){var g;if(!h){h=true;g=typeof c!=="undefined"?c:{};o=[];q=parseInt(g.index,10)||0;if(b.isArray(a)){for(var k=
38
+ 0,C=a.length;k<C;k++)if(typeof a[k]=="object")b(a[k]).data("fancybox",b.extend({},g,a[k]));else a[k]=b({}).data("fancybox",b.extend({content:a[k]},g));o=jQuery.merge(o,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},g,a));else a=b({}).data("fancybox",b.extend({content:a},g));o.push(a)}if(q>o.length||q<0)q=0;I()}};b.fancybox.showActivity=function(){clearInterval(K);t.show();K=setInterval(Z,66)};b.fancybox.hideActivity=function(){t.hide()};b.fancybox.next=function(){return b.fancybox.pos(p+
39
+ 1)};b.fancybox.prev=function(){return b.fancybox.pos(p-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a);o=l;if(a>-1&&a<l.length){q=a;I()}else if(d.cyclic&&l.length>1){q=a>=l.length?0:l.length-1;I()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");N();e.onCancel(o,q,e);h=false}};b.fancybox.close=function(){function a(){u.fadeOut("fast");n.empty().hide();f.hide();b.event.trigger("fancybox-cleanup");j.empty();d.onClosed(l,p,d);l=e=[];p=q=0;d=e={};h=false}if(!(h||f.is(":hidden"))){h=
40
+ true;if(d&&false===d.onCleanup(l,p,d))h=false;else{N();b(E.add(z).add(A)).hide();b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");j.find("iframe").attr("src",M&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");d.titlePosition!=="inside"&&n.empty();f.stop();if(d.transitionOut=="elastic"){r=V();var c=f.position();i={top:c.top,left:c.left,width:f.width(),height:f.height()};if(d.opacity)i.opacity=1;n.empty().hide();B.prop=1;
41
+ b(B).animate({prop:0},{duration:d.speedOut,easing:d.easingOut,step:T,complete:a})}else f.fadeOut(d.transitionOut=="none"?0:d.speedOut,a)}}};b.fancybox.resize=function(){u.is(":visible")&&u.css("height",b(document).height());b.fancybox.center(true)};b.fancybox.center=function(a){var c,g;if(!h){g=a===true?1:0;c=U();!g&&(f.width()>c[0]||f.height()>c[1])||f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+(c[1]-j.height()-40)*0.5-d.padding)),left:parseInt(Math.max(c[2]-20,c[2]+(c[0]-j.width()-40)*0.5-
42
+ d.padding))},typeof a=="number"?a:200)}};b.fancybox.init=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),t=b('<div id="fancybox-loading"><div></div></div>'),u=b('<div id="fancybox-overlay"></div>'),f=b('<div id="fancybox-wrap"></div>'));D=b('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(f);
43
+ D.append(j=b('<div id="fancybox-content"></div>'),E=b('<a id="fancybox-close"></a>'),n=b('<div id="fancybox-title"></div>'),z=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),A=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));E.click(b.fancybox.close);t.click(b.fancybox.cancel);z.click(function(a){a.preventDefault();b.fancybox.prev()});A.click(function(a){a.preventDefault();b.fancybox.next()});
44
+ b.fn.mousewheel&&f.bind("mousewheel.fb",function(a,c){if(h)a.preventDefault();else if(b(a.target).get(0).clientHeight==0||b(a.target).get(0).scrollHeight===b(a.target).get(0).clientHeight){a.preventDefault();b.fancybox[c>0?"prev":"next"]()}});b.support.opacity||f.addClass("fancybox-ie");if(M){t.addClass("fancybox-ie6");f.addClass("fancybox-ie6");b('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank")+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(D)}}};
45
+ b.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#777",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",
46
+ easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};b(document).ready(function(){b.fancybox.init()})})(jQuery);
js/printscience_personalization/jquery/fancybox/jquery.mousewheel-3.0.4.pack.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
2
+ * Licensed under the MIT License (LICENSE.txt).
3
+ *
4
+ * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
5
+ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
6
+ * Thanks to: Seamus Leahy for adding deltaX and deltaY
7
+ *
8
+ * Version: 3.0.4
9
+ *
10
+ * Requires: 1.2.2+
11
+ */
12
+
13
+ (function(d){function g(a){var b=a||window.event,i=[].slice.call(arguments,1),c=0,h=0,e=0;a=d.event.fix(b);a.type="mousewheel";if(a.wheelDelta)c=a.wheelDelta/120;if(a.detail)c=-a.detail/3;e=c;if(b.axis!==undefined&&b.axis===b.HORIZONTAL_AXIS){e=0;h=-1*c}if(b.wheelDeltaY!==undefined)e=b.wheelDeltaY/120;if(b.wheelDeltaX!==undefined)h=-1*b.wheelDeltaX/120;i.unshift(a,c,h,e);return d.event.handle.apply(this,i)}var f=["DOMMouseScroll","mousewheel"];d.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=
14
+ f.length;a;)this.addEventListener(f[--a],g,false);else this.onmousewheel=g},teardown:function(){if(this.removeEventListener)for(var a=f.length;a;)this.removeEventListener(f[--a],g,false);else this.onmousewheel=null}};d.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);
js/printscience_personalization/jquery/jquery-1.4.2.min.js ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * jQuery JavaScript Library v1.4.2
3
+ * http://jquery.com/
4
+ *
5
+ * Copyright 2010, John Resig
6
+ * Dual licensed under the MIT or GPL Version 2 licenses.
7
+ * http://jquery.org/license
8
+ *
9
+ * Includes Sizzle.js
10
+ * http://sizzlejs.com/
11
+ * Copyright 2010, The Dojo Foundation
12
+ * Released under the MIT, BSD, and GPL Licenses.
13
+ *
14
+ * Date: Sat Feb 13 22:33:48 2010 -0500
15
+ */
16
+ (function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o<i;o++)e(a[o],b,f?d.call(a[o],o,e(a[o],b)):d,j);return a}return i?
17
+ e(a[0],b):w}function J(){return(new Date).getTime()}function Y(){return false}function Z(){return true}function na(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function oa(a){var b,d=[],f=[],e=arguments,j,i,o,k,n,r;i=c.data(this,"events");if(!(a.liveFired===this||!i||!i.live||a.button&&a.type==="click")){a.liveFired=this;var u=i.live.slice(0);for(k=0;k<u.length;k++){i=u[k];i.origType.replace(O,"")===a.type?f.push(i.selector):u.splice(k--,1)}j=c(a.target).closest(f,a.currentTarget);n=0;for(r=
18
+ j.length;n<r;n++)for(k=0;k<u.length;k++){i=u[k];if(j[n].selector===i.selector){o=j[n].elem;f=null;if(i.preType==="mouseenter"||i.preType==="mouseleave")f=c(a.relatedTarget).closest(i.selector)[0];if(!f||f!==o)d.push({elem:o,handleObj:i})}}n=0;for(r=d.length;n<r;n++){j=d[n];a.currentTarget=j.elem;a.data=j.handleObj.data;a.handleObj=j.handleObj;if(j.handleObj.origHandler.apply(j.elem,e)===false){b=false;break}}return b}}function pa(a,b){return"live."+(a&&a!=="*"?a+".":"")+b.replace(/\./g,"`").replace(/ /g,
19
+ "&")}function qa(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function ra(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var j in f)for(var i in f[j])c.event.add(this,j,f[j][i],f[j][i].data)}}})}function sa(a,b,d){var f,e,j;b=b&&b[0]?b[0].ownerDocument||b[0]:s;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===s&&!ta.test(a[0])&&(c.support.checkClone||!ua.test(a[0]))){e=
20
+ true;if(j=c.fragments[a[0]])if(j!==1)f=j}if(!f){f=b.createDocumentFragment();c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=j?f:1;return{fragment:f,cacheable:e}}function K(a,b){var d={};c.each(va.concat.apply([],va.slice(0,b)),function(){d[this]=a});return d}function wa(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Ra=A.jQuery,Sa=A.$,s=A.document,T,Ta=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/,
21
+ Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&&
22
+ (d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this,
23
+ a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b===
24
+ "find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,
25
+ function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b<d;b++)if((e=arguments[b])!=null)for(j in e){i=a[j];o=e[j];if(a!==o)if(f&&o&&(c.isPlainObject(o)||c.isArray(o))){i=i&&(c.isPlainObject(i)||
26
+ c.isArray(i))?i:c.isArray(o)?[]:{};a[j]=c.extend(f,i,o)}else if(o!==w)a[j]=o}return a};c.extend({noConflict:function(a){A.$=Sa;if(a)A.jQuery=Ra;return c},isReady:false,ready:function(){if(!c.isReady){if(!s.body)return setTimeout(c.ready,13);c.isReady=true;if(Q){for(var a,b=0;a=Q[b++];)a.call(s,c);Q=null}c.fn.triggerHandler&&c(s).triggerHandler("ready")}},bindReady:function(){if(!xa){xa=true;if(s.readyState==="complete")return c.ready();if(s.addEventListener){s.addEventListener("DOMContentLoaded",
27
+ L,false);A.addEventListener("load",c.ready,false)}else if(s.attachEvent){s.attachEvent("onreadystatechange",L);A.attachEvent("onload",c.ready);var a=false;try{a=A.frameElement==null}catch(b){}s.documentElement.doScroll&&a&&ma()}}},isFunction:function(a){return $.call(a)==="[object Function]"},isArray:function(a){return $.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||$.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!aa.call(a,"constructor")&&!aa.call(a.constructor.prototype,
28
+ "isPrototypeOf"))return false;var b;for(b in a);return b===w||aa.call(a,b)},isEmptyObject:function(a){for(var b in a)return false;return true},error:function(a){throw a;},parseJSON:function(a){if(typeof a!=="string"||!a)return null;a=c.trim(a);if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return A.JSON&&A.JSON.parse?A.JSON.parse(a):(new Function("return "+
29
+ a))();else c.error("Invalid JSON: "+a)},noop:function(){},globalEval:function(a){if(a&&Va.test(a)){var b=s.getElementsByTagName("head")[0]||s.documentElement,d=s.createElement("script");d.type="text/javascript";if(c.support.scriptEval)d.appendChild(s.createTextNode(a));else d.text=a;b.insertBefore(d,b.firstChild);b.removeChild(d)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,b,d){var f,e=0,j=a.length,i=j===w||c.isFunction(a);if(d)if(i)for(f in a){if(b.apply(a[f],
30
+ d)===false)break}else for(;e<j;){if(b.apply(a[e++],d)===false)break}else if(i)for(f in a){if(b.call(a[f],f,a[f])===false)break}else for(d=a[0];e<j&&b.call(d,e,d)!==false;d=a[++e]);return a},trim:function(a){return(a||"").replace(Wa,"")},makeArray:function(a,b){b=b||[];if(a!=null)a.length==null||typeof a==="string"||c.isFunction(a)||typeof a!=="function"&&a.setInterval?ba.call(b,a):c.merge(b,a);return b},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var d=0,f=b.length;d<f;d++)if(b[d]===
31
+ a)return d;return-1},merge:function(a,b){var d=a.length,f=0;if(typeof b.length==="number")for(var e=b.length;f<e;f++)a[d++]=b[f];else for(;b[f]!==w;)a[d++]=b[f++];a.length=d;return a},grep:function(a,b,d){for(var f=[],e=0,j=a.length;e<j;e++)!d!==!b(a[e],e)&&f.push(a[e]);return f},map:function(a,b,d){for(var f=[],e,j=0,i=a.length;j<i;j++){e=b(a[j],j,d);if(e!=null)f[f.length]=e}return f.concat.apply([],f)},guid:1,proxy:function(a,b,d){if(arguments.length===2)if(typeof b==="string"){d=a;a=d[b];b=w}else if(b&&
32
+ !c.isFunction(b)){d=b;b=w}if(!b&&a)b=function(){return a.apply(d||this,arguments)};if(a)b.guid=a.guid=a.guid||b.guid||c.guid++;return b},uaMatch:function(a){a=a.toLowerCase();a=/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||!/compatible/.test(a)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},browser:{}});P=c.uaMatch(P);if(P.browser){c.browser[P.browser]=true;c.browser.version=P.version}if(c.browser.webkit)c.browser.safari=
33
+ true;if(ya)c.inArray=function(a,b){return ya.call(b,a)};T=c(s);if(s.addEventListener)L=function(){s.removeEventListener("DOMContentLoaded",L,false);c.ready()};else if(s.attachEvent)L=function(){if(s.readyState==="complete"){s.detachEvent("onreadystatechange",L);c.ready()}};(function(){c.support={};var a=s.documentElement,b=s.createElement("script"),d=s.createElement("div"),f="script"+J();d.style.display="none";d.innerHTML=" <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
34
+ var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected,
35
+ parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent=
36
+ false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n=
37
+ s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,
38
+ applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando];
39
+ else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,
40
+ a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===
41
+ w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i,
42
+ cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1)if(e.className){for(var j=" "+e.className+" ",
43
+ i=e.className,o=0,k=b.length;o<k;o++)if(j.indexOf(" "+b[o]+" ")<0)i+=" "+b[o];e.className=c.trim(i)}else e.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(k){var n=c(this);n.removeClass(a.call(this,k,n.attr("class")))});if(a&&typeof a==="string"||a===w)for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1&&e.className)if(a){for(var j=(" "+e.className+" ").replace(Aa," "),i=0,o=b.length;i<o;i++)j=j.replace(" "+b[i]+" ",
44
+ " ");e.className=c.trim(j)}else e.className=""}return this},toggleClass:function(a,b){var d=typeof a,f=typeof b==="boolean";if(c.isFunction(a))return this.each(function(e){var j=c(this);j.toggleClass(a.call(this,e,j.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var e,j=0,i=c(this),o=b,k=a.split(ca);e=k[j++];){o=f?o:!i.hasClass(e);i[o?"addClass":"removeClass"](e)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=
45
+ this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(Aa," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j<d;j++){var i=
46
+ e[j];if(i.selected){a=c(i).val();if(b)return a;f.push(a)}}return f}if(Ba.test(b.type)&&!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Za,"")}return w}var o=c.isFunction(a);return this.each(function(k){var n=c(this),r=a;if(this.nodeType===1){if(o)r=a.call(this,k,n.val());if(typeof r==="number")r+="";if(c.isArray(r)&&Ba.test(this.type))this.checked=c.inArray(n.val(),r)>=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected=
47
+ c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");
48
+ a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g,
49
+ function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split(".");
50
+ k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a),
51
+ C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B<r.length;B++){u=r[B];if(d.guid===u.guid){if(i||k.test(u.namespace)){f==null&&r.splice(B--,1);n.remove&&n.remove.call(a,u)}if(f!=
52
+ null)break}}if(r.length===0||f!=null&&r.length===1){if(!n.teardown||n.teardown.call(a,o)===false)Ca(a,e,z.handle);delete C[e]}}else for(var B=0;B<r.length;B++){u=r[B];if(i||k.test(u.namespace)){c.event.remove(a,n,u.handler,B);r.splice(B--,1)}}}if(c.isEmptyObject(C)){if(b=z.handle)b.elem=null;delete z.events;delete z.handle;c.isEmptyObject(z)&&c.removeData(a)}}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[G]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=
53
+ e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&&
54
+ f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;
55
+ if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e<j;e++){var i=d[e];if(b||f.test(i.namespace)){a.handler=i.handler;a.data=i.data;a.handleObj=i;i=i.handler.apply(this,arguments);if(i!==w){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
56
+ fix:function(a){if(a[G])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||s;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=s.documentElement;d=s.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
57
+ d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==w)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a){c.event.add(this,a.origType,c.extend({},a,{handler:oa}))},remove:function(a){var b=true,d=a.origType.replace(O,"");c.each(c.data(this,
58
+ "events").live||[],function(){if(d===this.origType.replace(O,""))return b=false});b&&c.event.remove(this,a.origType,oa)}},beforeunload:{setup:function(a,b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};var Ca=s.removeEventListener?function(a,b,d){a.removeEventListener(b,d,false)}:function(a,b,d){a.detachEvent("on"+b,d)};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=
59
+ a;this.type=a.type}else this.type=a;this.timeStamp=J();this[G]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=Z;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=Z;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z;this.stopPropagation()},isDefaultPrevented:Y,isPropagationStopped:Y,
60
+ isImmediatePropagationStopped:Y};var Da=function(a){var b=a.relatedTarget;try{for(;b&&b!==this;)b=b.parentNode;if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}}catch(d){}},Ea=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ea:Da,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ea:Da)}}});if(!c.support.submitBubbles)c.event.special.submit=
61
+ {setup:function(){if(this.nodeName.toLowerCase()!=="form"){c.event.add(this,"click.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="submit"||d==="image")&&c(b).closest("form").length)return na("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="text"||d==="password")&&c(b).closest("form").length&&a.keyCode===13)return na("submit",this,arguments)})}else return false},teardown:function(){c.event.remove(this,".specialSubmit")}};
62
+ if(!c.support.changeBubbles){var da=/textarea|input|select/i,ea,Fa=function(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",
63
+ e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,
64
+ "_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a,
65
+ d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j<o;j++)c.event.add(this[j],d,i,f)}return this}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&
66
+ !a.preventDefault)for(var d in a)this.unbind(d,a[d]);else{d=0;for(var f=this.length;d<f;d++)c.event.remove(this[d],a,b)}return this},delegate:function(a,b,d,f){return this.live(b,d,f,a)},undelegate:function(a,b,d){return arguments.length===0?this.unbind("live"):this.die(b,null,d,a)},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},
67
+ toggle:function(a){for(var b=arguments,d=1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(f){var e=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,e+1);f.preventDefault();return b[e].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var Ga={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};c.each(["live","die"],function(a,b){c.fn[b]=function(d,f,e,j){var i,o=0,k,n,r=j||this.selector,
68
+ u=j?this:c(this.context);if(c.isFunction(f)){e=f;f=w}for(d=(d||"").split(" ");(i=d[o++])!=null;){j=O.exec(i);k="";if(j){k=j[0];i=i.replace(O,"")}if(i==="hover")d.push("mouseenter"+k,"mouseleave"+k);else{n=i;if(i==="focus"||i==="blur"){d.push(Ga[i]+k);i+=k}else i=(Ga[i]||i)+k;b==="live"?u.each(function(){c.event.add(this,pa(i,r),{data:f,selector:r,handler:e,origType:i,origHandler:e,preType:n})}):u.unbind(pa(i,r),e)}}return this}});c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),
69
+ function(a,b){c.fn[b]=function(d){return d?this.bind(b,d):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});A.attachEvent&&!A.addEventListener&&A.attachEvent("onunload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});(function(){function a(g){for(var h="",l,m=0;g[m];m++){l=g[m];if(l.nodeType===3||l.nodeType===4)h+=l.nodeValue;else if(l.nodeType!==8)h+=a(l.childNodes)}return h}function b(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];
70
+ if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1&&!p){t.sizcache=l;t.sizset=q}if(t.nodeName.toLowerCase()===h){y=t;break}t=t[g]}m[q]=y}}}function d(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1){if(!p){t.sizcache=l;t.sizset=q}if(typeof h!=="string"){if(t===h){y=true;break}}else if(k.filter(h,[t]).length>0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
71
+ e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift();
72
+ t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D||
73
+ g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h<g.length;h++)g[h]===g[h-1]&&g.splice(h--,1)}return g};k.matches=function(g,h){return k(g,null,null,h)};k.find=function(g,h,l){var m,q;if(!g)return[];
74
+ for(var p=0,v=n.order.length;p<v;p++){var t=n.order[p];if(q=n.leftMatch[t].exec(g)){var y=q[1];q.splice(1,1);if(y.substr(y.length-1)!=="\\"){q[1]=(q[1]||"").replace(/\\/g,"");m=n.find[t](q,h,l);if(m!=null){g=g.replace(n.match[t],"");break}}}}m||(m=h.getElementsByTagName("*"));return{set:m,expr:g}};k.filter=function(g,h,l,m){for(var q=g,p=[],v=h,t,y,S=h&&h[0]&&x(h[0]);g&&h.length;){for(var H in n.filter)if((t=n.leftMatch[H].exec(g))!=null&&t[2]){var M=n.filter[H],I,D;D=t[1];y=false;t.splice(1,1);if(D.substr(D.length-
75
+ 1)!=="\\"){if(v===p)p=[];if(n.preFilter[H])if(t=n.preFilter[H](t,v,l,p,m,S)){if(t===true)continue}else y=I=true;if(t)for(var U=0;(D=v[U])!=null;U++)if(D){I=M(D,t,U,v);var Ha=m^!!I;if(l&&I!=null)if(Ha)y=true;else v[U]=false;else if(Ha){p.push(D);y=true}}if(I!==w){l||(v=p);g=g.replace(n.match[H],"");if(!y)return[];break}}}if(g===q)if(y==null)k.error(g);else break;q=g}return v};k.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var n=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
76
+ CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},
77
+ relative:{"+":function(g,h){var l=typeof h==="string",m=l&&!/\W/.test(h);l=l&&!m;if(m)h=h.toLowerCase();m=0;for(var q=g.length,p;m<q;m++)if(p=g[m]){for(;(p=p.previousSibling)&&p.nodeType!==1;);g[m]=l||p&&p.nodeName.toLowerCase()===h?p||false:p===h}l&&k.filter(h,g,true)},">":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m<q;m++){var p=g[m];if(p){l=p.parentNode;g[m]=l.nodeName.toLowerCase()===h?l:false}}}else{m=0;for(q=g.length;m<q;m++)if(p=g[m])g[m]=
78
+ l?p.parentNode:p.parentNode===h;l&&k.filter(h,g,true)}},"":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("parentNode",h,m,g,p,l)},"~":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("previousSibling",h,m,g,p,l)}},find:{ID:function(g,h,l){if(typeof h.getElementById!=="undefined"&&!l)return(g=h.getElementById(g[1]))?[g]:[]},NAME:function(g,h){if(typeof h.getElementsByName!=="undefined"){var l=[];
79
+ h=h.getElementsByName(g[1]);for(var m=0,q=h.length;m<q;m++)h[m].getAttribute("name")===g[1]&&l.push(h[m]);return l.length===0?null:l}},TAG:function(g,h){return h.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,h,l,m,q,p){g=" "+g[1].replace(/\\/g,"")+" ";if(p)return g;p=0;for(var v;(v=h[p])!=null;p++)if(v)if(q^(v.className&&(" "+v.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},
80
+ CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m,
81
+ g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},
82
+ text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},
83
+ setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return h<l[3]-0},gt:function(g,h,l){return h>l[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=
84
+ h[3];l=0;for(m=h.length;l<m;l++)if(h[l]===g)return false;return true}else k.error("Syntax error, unrecognized expression: "+q)},CHILD:function(g,h){var l=h[1],m=g;switch(l){case "only":case "first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(l==="first")return true;m=g;case "last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case "nth":l=h[2];var q=h[3];if(l===1&&q===0)return true;h=h[0];var p=g.parentNode;if(p&&(p.sizcache!==h||!g.nodeIndex)){var v=0;for(m=p.firstChild;m;m=
85
+ m.nextSibling)if(m.nodeType===1)m.nodeIndex=++v;p.sizcache=h}g=g.nodeIndex-q;return l===0?g===0:g%l===0&&g/l>=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m===
86
+ "="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g,
87
+ h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l<m;l++)h.push(g[l]);else for(l=0;g[l];l++)h.push(g[l]);return h}}var B;if(s.documentElement.compareDocumentPosition)B=function(g,h){if(!g.compareDocumentPosition||
88
+ !h.compareDocumentPosition){if(g==h)i=true;return g.compareDocumentPosition?-1:1}g=g.compareDocumentPosition(h)&4?-1:g===h?0:1;if(g===0)i=true;return g};else if("sourceIndex"in s.documentElement)B=function(g,h){if(!g.sourceIndex||!h.sourceIndex){if(g==h)i=true;return g.sourceIndex?-1:1}g=g.sourceIndex-h.sourceIndex;if(g===0)i=true;return g};else if(s.createRange)B=function(g,h){if(!g.ownerDocument||!h.ownerDocument){if(g==h)i=true;return g.ownerDocument?-1:1}var l=g.ownerDocument.createRange(),m=
89
+ h.ownerDocument.createRange();l.setStart(g,0);l.setEnd(g,0);m.setStart(h,0);m.setEnd(h,0);g=l.compareBoundaryPoints(Range.START_TO_END,m);if(g===0)i=true;return g};(function(){var g=s.createElement("div"),h="script"+(new Date).getTime();g.innerHTML="<a name='"+h+"'/>";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&&
90
+ q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML="<a href='#'></a>";
91
+ if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="<p class='TEST'></p>";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}();
92
+ (function(){var g=s.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}:
93
+ function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q<p;q++)k(g,h[q],l);return k.filter(m,l)};c.find=k;c.expr=k.selectors;c.expr[":"]=c.expr.filters;c.unique=k.uniqueSort;c.text=a;c.isXMLDoc=x;c.contains=E})();var eb=/Until$/,fb=/^(?:parents|prevUntil|prevAll)/,
94
+ gb=/,/;R=Array.prototype.slice;var Ia=function(a,b,d){if(c.isFunction(b))return c.grep(a,function(e,j){return!!b.call(e,j,e)===d});else if(b.nodeType)return c.grep(a,function(e){return e===b===d});else if(typeof b==="string"){var f=c.grep(a,function(e){return e.nodeType===1});if(Ua.test(b))return c.filter(b,f,!d);else b=c.filter(b,f)}return c.grep(a,function(e){return c.inArray(e,b)>=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f<e;f++){d=b.length;
95
+ c.find(a,this[f],b);if(f>0)for(var j=d;j<b.length;j++)for(var i=0;i<d;i++)if(b[i]===b[j]){b.splice(j--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,f=b.length;d<f;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(Ia(this,a,false),"not",a)},filter:function(a){return this.pushStack(Ia(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j=
96
+ {},i;if(f&&a.length){e=0;for(var o=a.length;e<o;e++){i=a[e];j[i]||(j[i]=c.expr.match.POS.test(i)?c(i,b||this.context):i)}for(;f&&f.ownerDocument&&f!==b;){for(i in j){e=j[i];if(e.jquery?e.index(f)>-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a===
97
+ "string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",
98
+ d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?
99
+ a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType===
100
+ 1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/<tbody/i,jb=/<|&#?\w+;/,ta=/<script|<object|<embed|<option|<style/i,ua=/checked\s*(?:[^=]|=\s*.checked.)/i,Ma=function(a,b,d){return hb.test(d)?
101
+ a:b+"></"+d+">"},F={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=
102
+ c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},
103
+ wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},
104
+ prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,
105
+ this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);
106
+ return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja,
107
+ ""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}}else c.isFunction(a)?this.each(function(e){var j=c(this),i=j.html();j.empty().append(function(){return a.call(this,e,i)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&
108
+ this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=c(this),f=d.html();d.replaceWith(a.call(this,b,f))});if(typeof a!=="string")a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){function f(u){return c.nodeName(u,"table")?u.getElementsByTagName("tbody")[0]||
109
+ u.appendChild(u.ownerDocument.createElement("tbody")):u}var e,j,i=a[0],o=[],k;if(!c.support.checkClone&&arguments.length===3&&typeof i==="string"&&ua.test(i))return this.each(function(){c(this).domManip(a,b,d,true)});if(c.isFunction(i))return this.each(function(u){var z=c(this);a[0]=i.call(this,u,b?z.html():w);z.domManip(a,b,d)});if(this[0]){e=i&&i.parentNode;e=c.support.parentNode&&e&&e.nodeType===11&&e.childNodes.length===this.length?{fragment:e}:sa(a,this,o);k=e.fragment;if(j=k.childNodes.length===
110
+ 1?(k=k.firstChild):k.firstChild){b=b&&c.nodeName(j,"tr");for(var n=0,r=this.length;n<r;n++)d.call(b?f(this[n],j):this[n],n>0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]);
111
+ return this}else{e=0;for(var j=d.length;e<j;e++){var i=(e>0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["",
112
+ ""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]==="<table>"&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e=
113
+ c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]?
114
+ c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja=
115
+ function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=
116
+ Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,
117
+ "border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=
118
+ a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=
119
+ a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=/<script(.|\s)*?\/script>/gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!==
120
+ "string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("<div />").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this},
121
+ serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),
122
+ function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,
123
+ global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&&
124
+ e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)?
125
+ "&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache===
126
+ false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B=
127
+ false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since",
128
+ c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E||
129
+ d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x);
130
+ g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===
131
+ 1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b===
132
+ "json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional;
133
+ if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");
134
+ this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(la[d])f=la[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b){if(a||a===0)return this.animate(K("hide",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");!d&&d!=="none"&&c.data(this[a],
135
+ "olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments);else a==null||d?this.each(function(){var f=d?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(K("toggle",3),a,b);return this},fadeTo:function(a,b,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d)},
136
+ animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var j=c.extend({},e),i,o=this.nodeType===1&&c(this).is(":hidden"),k=this;for(i in a){var n=i.replace(ia,ja);if(i!==n){a[n]=a[i];delete a[i];i=n}if(a[i]==="hide"&&o||a[i]==="show"&&!o)return j.complete.call(this);if((i==="height"||i==="width")&&this.style){j.display=c.css(this,"display");j.overflow=this.style.overflow}if(c.isArray(a[i])){(j.specialEasing=
137
+ j.specialEasing||{})[i]=a[i][1];a[i]=a[i][0]}}if(j.overflow!=null)this.style.overflow="hidden";j.curAnim=c.extend({},a);c.each(a,function(r,u){var z=new c.fx(k,j,r);if(Ab.test(u))z[u==="toggle"?o?"show":"hide":u](a);else{var C=Bb.exec(u),B=z.cur(true)||0;if(C){u=parseFloat(C[2]);var E=C[3]||"px";if(E!=="px"){k.style[r]=(u||1)+E;B=(u||1)/z.cur(true)*B;k.style[r]=B+E}if(C[1])u=(C[1]==="-="?-1:1)*u+B;z.custom(B,u,E)}else z.custom(B,u,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);
138
+ this.each(function(){for(var f=d.length-1;f>=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration===
139
+ "number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||
140
+ c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;
141
+ this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=
142
+ this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem,
143
+ e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||
144
+ c.fx.stop()},stop:function(){clearInterval(W);W=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===b.elem}).length};c.fn.offset="getBoundingClientRect"in s.documentElement?
145
+ function(a){var b=this[0];if(a)return this.each(function(e){c.offset.setOffset(this,a,e)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);var d=b.getBoundingClientRect(),f=b.ownerDocument;b=f.body;f=f.documentElement;return{top:d.top+(self.pageYOffset||c.support.boxModel&&f.scrollTop||b.scrollTop)-(f.clientTop||b.clientTop||0),left:d.left+(self.pageXOffset||c.support.boxModel&&f.scrollLeft||b.scrollLeft)-(f.clientLeft||b.clientLeft||0)}}:function(a){var b=
146
+ this[0];if(a)return this.each(function(r){c.offset.setOffset(this,a,r)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,f=b,e=b.ownerDocument,j,i=e.documentElement,o=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;for(var k=b.offsetTop,n=b.offsetLeft;(b=b.parentNode)&&b!==o&&b!==i;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;j=e?e.getComputedStyle(b,null):b.currentStyle;
147
+ k-=b.scrollTop;n-=b.scrollLeft;if(b===d){k+=b.offsetTop;n+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(b.nodeName))){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=d;d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&j.overflow!=="visible"){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=j}if(f.position==="relative"||f.position==="static"){k+=o.offsetTop;n+=o.offsetLeft}if(c.offset.supportsFixedPosition&&
148
+ f.position==="fixed"){k+=Math.max(i.scrollTop,o.scrollTop);n+=Math.max(i.scrollLeft,o.scrollLeft)}return{top:k,left:n}};c.offset={initialize:function(){var a=s.body,b=s.createElement("div"),d,f,e,j=parseFloat(c.curCSS(a,"marginTop",true))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
149
+ a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b);
150
+ c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a,
151
+ d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top-
152
+ f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset":
153
+ "pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in
154
+ e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window);
155
+ jQuery.noConflict();
js/printscience_personalization/jquery/jquery.cycle/jquery.cycle.lite.min.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * jQuery Cycle Lite Plugin
3
+ * http://malsup.com/jquery/cycle/lite/
4
+ * Copyright (c) 2008 M. Alsup
5
+ * Version: 1.0 (06/08/2008)
6
+ * Dual licensed under the MIT and GPL licenses:
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ * http://www.gnu.org/licenses/gpl.html
9
+ * Requires: jQuery v1.2.3 or later
10
+ */
11
+ ;(function(D){var A="Lite-1.0";D.fn.cycle=function(E){return this.each(function(){E=E||{};if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=0;this.cyclePause=0;var I=D(this);var J=E.slideExpr?D(E.slideExpr,this):I.children();var G=J.get();if(G.length<2){if(window.console&&window.console.log){window.console.log("terminating; too few slides: "+G.length)}return }var H=D.extend({},D.fn.cycle.defaults,E||{},D.metadata?I.metadata():D.meta?I.data():{});H.before=H.before?[H.before]:[];H.after=H.after?[H.after]:[];H.after.unshift(function(){H.busy=0});var F=this.className;H.width=parseInt((F.match(/w:(\d+)/)||[])[1])||H.width;H.height=parseInt((F.match(/h:(\d+)/)||[])[1])||H.height;H.timeout=parseInt((F.match(/t:(\d+)/)||[])[1])||H.timeout;if(I.css("position")=="static"){I.css("position","relative")}if(H.width){I.width(H.width)}if(H.height&&H.height!="auto"){I.height(H.height)}var K=0;J.css({position:"absolute",top:0,left:0}).hide().each(function(M){D(this).css("z-index",G.length-M)});D(G[K]).css("opacity",1).show();if(D.browser.msie){G[K].style.removeAttribute("filter")}if(H.fit&&H.width){J.width(H.width)}if(H.fit&&H.height&&H.height!="auto"){J.height(H.height)}if(H.pause){I.hover(function(){this.cyclePause=1},function(){this.cyclePause=0})}D.fn.cycle.transitions.fade(I,J,H);J.each(function(){var M=D(this);this.cycleH=(H.fit&&H.height)?H.height:M.height();this.cycleW=(H.fit&&H.width)?H.width:M.width()});J.not(":eq("+K+")").css({opacity:0});if(H.cssFirst){D(J[K]).css(H.cssFirst)}if(H.timeout){if(H.speed.constructor==String){H.speed={slow:600,fast:200}[H.speed]||400}if(!H.sync){H.speed=H.speed/2}while((H.timeout-H.speed)<250){H.timeout+=H.speed}}H.speedIn=H.speed;H.speedOut=H.speed;H.slideCount=G.length;H.currSlide=K;H.nextSlide=1;var L=J[K];if(H.before.length){H.before[0].apply(L,[L,L,H,true])}if(H.after.length>1){H.after[1].apply(L,[L,L,H,true])}if(H.click&&!H.next){H.next=H.click}if(H.next){D(H.next).bind("click",function(){return C(G,H,H.rev?-1:1)})}if(H.prev){D(H.prev).bind("click",function(){return C(G,H,H.rev?1:-1)})}if(H.timeout){this.cycleTimeout=setTimeout(function(){B(G,H,0,!H.rev)},H.timeout+(H.delay||0))}})};function B(J,E,I,K){if(E.busy){return }var H=J[0].parentNode,M=J[E.currSlide],L=J[E.nextSlide];if(H.cycleTimeout===0&&!I){return }if(I||!H.cyclePause){if(E.before.length){D.each(E.before,function(N,O){O.apply(L,[M,L,E,K])})}var F=function(){if(D.browser.msie){this.style.removeAttribute("filter")}D.each(E.after,function(N,O){O.apply(L,[M,L,E,K])})};if(E.nextSlide!=E.currSlide){E.busy=1;D.fn.cycle.custom(M,L,E,F)}var G=(E.nextSlide+1)==J.length;E.nextSlide=G?0:E.nextSlide+1;E.currSlide=G?J.length-1:E.nextSlide-1}if(E.timeout){H.cycleTimeout=setTimeout(function(){B(J,E,0,!E.rev)},E.timeout)}}function C(E,F,I){var H=E[0].parentNode,G=H.cycleTimeout;if(G){clearTimeout(G);H.cycleTimeout=0}F.nextSlide=F.currSlide+I;if(F.nextSlide<0){F.nextSlide=E.length-1}else{if(F.nextSlide>=E.length){F.nextSlide=0}}B(E,F,1,I>=0);return false}D.fn.cycle.custom=function(K,H,I,E){var J=D(K),G=D(H);G.css({opacity:0});var F=function(){G.animate({opacity:1},I.speedIn,I.easeIn,E)};J.animate({opacity:0},I.speedOut,I.easeOut,function(){J.css({display:"none"});if(!I.sync){F()}});if(I.sync){F()}};D.fn.cycle.transitions={fade:function(F,G,E){G.not(":eq(0)").css("opacity",0);E.before.push(function(){D(this).show()})}};D.fn.cycle.ver=function(){return A};D.fn.cycle.defaults={timeout:4000,speed:1000,next:null,prev:null,before:null,after:null,height:"auto",sync:1,fit:0,pause:0,delay:0,slideExpr:null}})(jQuery);
lib/xmlrpc/xmlrpc.inc ADDED
@@ -0,0 +1,3776 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // by Edd Dumbill (C) 1999-2002
3
+ // <edd@usefulinc.com>
4
+ // $Id: xmlrpc.inc,v 1.174 2009/03/16 19:36:38 ggiunta Exp $
5
+
6
+ // Copyright (c) 1999,2000,2002 Edd Dumbill.
7
+ // All rights reserved.
8
+ //
9
+ // Redistribution and use in source and binary forms, with or without
10
+ // modification, are permitted provided that the following conditions
11
+ // are met:
12
+ //
13
+ // * Redistributions of source code must retain the above copyright
14
+ // notice, this list of conditions and the following disclaimer.
15
+ //
16
+ // * Redistributions in binary form must reproduce the above
17
+ // copyright notice, this list of conditions and the following
18
+ // disclaimer in the documentation and/or other materials provided
19
+ // with the distribution.
20
+ //
21
+ // * Neither the name of the "XML-RPC for PHP" nor the names of its
22
+ // contributors may be used to endorse or promote products derived
23
+ // from this software without specific prior written permission.
24
+ //
25
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28
+ // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29
+ // REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30
+ // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31
+ // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32
+ // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33
+ // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34
+ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35
+ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
36
+ // OF THE POSSIBILITY OF SUCH DAMAGE.
37
+
38
+ if(!function_exists('xml_parser_create'))
39
+ {
40
+ // For PHP 4 onward, XML functionality is always compiled-in on windows:
41
+ // no more need to dl-open it. It might have been compiled out on *nix...
42
+ if(strtoupper(substr(PHP_OS, 0, 3) != 'WIN'))
43
+ {
44
+ dl('xml.so');
45
+ }
46
+ }
47
+
48
+ // G. Giunta 2005/01/29: declare global these variables,
49
+ // so that xmlrpc.inc will work even if included from within a function
50
+ // Milosch: 2005/08/07 - explicitly request these via $GLOBALS where used.
51
+ $GLOBALS['xmlrpcI4']='i4';
52
+ $GLOBALS['xmlrpcInt']='int';
53
+ $GLOBALS['xmlrpcBoolean']='boolean';
54
+ $GLOBALS['xmlrpcDouble']='double';
55
+ $GLOBALS['xmlrpcString']='string';
56
+ $GLOBALS['xmlrpcDateTime']='dateTime.iso8601';
57
+ $GLOBALS['xmlrpcBase64']='base64';
58
+ $GLOBALS['xmlrpcArray']='array';
59
+ $GLOBALS['xmlrpcStruct']='struct';
60
+ $GLOBALS['xmlrpcValue']='undefined';
61
+
62
+ $GLOBALS['xmlrpcTypes']=array(
63
+ $GLOBALS['xmlrpcI4'] => 1,
64
+ $GLOBALS['xmlrpcInt'] => 1,
65
+ $GLOBALS['xmlrpcBoolean'] => 1,
66
+ $GLOBALS['xmlrpcString'] => 1,
67
+ $GLOBALS['xmlrpcDouble'] => 1,
68
+ $GLOBALS['xmlrpcDateTime'] => 1,
69
+ $GLOBALS['xmlrpcBase64'] => 1,
70
+ $GLOBALS['xmlrpcArray'] => 2,
71
+ $GLOBALS['xmlrpcStruct'] => 3
72
+ );
73
+
74
+ $GLOBALS['xmlrpc_valid_parents'] = array(
75
+ 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'),
76
+ 'BOOLEAN' => array('VALUE'),
77
+ 'I4' => array('VALUE'),
78
+ 'INT' => array('VALUE'),
79
+ 'STRING' => array('VALUE'),
80
+ 'DOUBLE' => array('VALUE'),
81
+ 'DATETIME.ISO8601' => array('VALUE'),
82
+ 'BASE64' => array('VALUE'),
83
+ 'MEMBER' => array('STRUCT'),
84
+ 'NAME' => array('MEMBER'),
85
+ 'DATA' => array('ARRAY'),
86
+ 'ARRAY' => array('VALUE'),
87
+ 'STRUCT' => array('VALUE'),
88
+ 'PARAM' => array('PARAMS'),
89
+ 'METHODNAME' => array('METHODCALL'),
90
+ 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),
91
+ 'FAULT' => array('METHODRESPONSE'),
92
+ 'NIL' => array('VALUE'), // only used when extension activated
93
+ 'EX:NIL' => array('VALUE') // only used when extension activated
94
+ );
95
+
96
+ // define extra types for supporting NULL (useful for json or <NIL/>)
97
+ $GLOBALS['xmlrpcNull']='null';
98
+ $GLOBALS['xmlrpcTypes']['null']=1;
99
+
100
+ // Not in use anymore since 2.0. Shall we remove it?
101
+ /// @deprecated
102
+ $GLOBALS['xmlEntities']=array(
103
+ 'amp' => '&',
104
+ 'quot' => '"',
105
+ 'lt' => '<',
106
+ 'gt' => '>',
107
+ 'apos' => "'"
108
+ );
109
+
110
+ // tables used for transcoding different charsets into us-ascii xml
111
+
112
+ $GLOBALS['xml_iso88591_Entities']=array();
113
+ $GLOBALS['xml_iso88591_Entities']['in'] = array();
114
+ $GLOBALS['xml_iso88591_Entities']['out'] = array();
115
+ for ($i = 0; $i < 32; $i++)
116
+ {
117
+ $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i);
118
+ $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';';
119
+ }
120
+ for ($i = 160; $i < 256; $i++)
121
+ {
122
+ $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i);
123
+ $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';';
124
+ }
125
+
126
+ /// @todo add to iso table the characters from cp_1252 range, i.e. 128 to 159?
127
+ /// These will NOT be present in true ISO-8859-1, but will save the unwary
128
+ /// windows user from sending junk (though no luck when reciving them...)
129
+ /*
130
+ $GLOBALS['xml_cp1252_Entities']=array();
131
+ for ($i = 128; $i < 160; $i++)
132
+ {
133
+ $GLOBALS['xml_cp1252_Entities']['in'][] = chr($i);
134
+ }
135
+ $GLOBALS['xml_cp1252_Entities']['out'] = array(
136
+ '&#x20AC;', '?', '&#x201A;', '&#x0192;',
137
+ '&#x201E;', '&#x2026;', '&#x2020;', '&#x2021;',
138
+ '&#x02C6;', '&#x2030;', '&#x0160;', '&#x2039;',
139
+ '&#x0152;', '?', '&#x017D;', '?',
140
+ '?', '&#x2018;', '&#x2019;', '&#x201C;',
141
+ '&#x201D;', '&#x2022;', '&#x2013;', '&#x2014;',
142
+ '&#x02DC;', '&#x2122;', '&#x0161;', '&#x203A;',
143
+ '&#x0153;', '?', '&#x017E;', '&#x0178;'
144
+ );
145
+ */
146
+
147
+ $GLOBALS['xmlrpcerr'] = array(
148
+ 'unknown_method'=>1,
149
+ 'invalid_return'=>2,
150
+ 'incorrect_params'=>3,
151
+ 'introspect_unknown'=>4,
152
+ 'http_error'=>5,
153
+ 'no_data'=>6,
154
+ 'no_ssl'=>7,
155
+ 'curl_fail'=>8,
156
+ 'invalid_request'=>15,
157
+ 'no_curl'=>16,
158
+ 'server_error'=>17,
159
+ 'multicall_error'=>18,
160
+ 'multicall_notstruct'=>9,
161
+ 'multicall_nomethod'=>10,
162
+ 'multicall_notstring'=>11,
163
+ 'multicall_recursion'=>12,
164
+ 'multicall_noparams'=>13,
165
+ 'multicall_notarray'=>14,
166
+
167
+ 'cannot_decompress'=>103,
168
+ 'decompress_fail'=>104,
169
+ 'dechunk_fail'=>105,
170
+ 'server_cannot_decompress'=>106,
171
+ 'server_decompress_fail'=>107
172
+ );
173
+
174
+ $GLOBALS['xmlrpcstr'] = array(
175
+ 'unknown_method'=>'Unknown method',
176
+ 'invalid_return'=>'Invalid return payload: enable debugging to examine incoming payload',
177
+ 'incorrect_params'=>'Incorrect parameters passed to method',
178
+ 'introspect_unknown'=>"Can't introspect: method unknown",
179
+ 'http_error'=>"Didn't receive 200 OK from remote server.",
180
+ 'no_data'=>'No data received from server.',
181
+ 'no_ssl'=>'No SSL support compiled in.',
182
+ 'curl_fail'=>'CURL error',
183
+ 'invalid_request'=>'Invalid request payload',
184
+ 'no_curl'=>'No CURL support compiled in.',
185
+ 'server_error'=>'Internal server error',
186
+ 'multicall_error'=>'Received from server invalid multicall response',
187
+ 'multicall_notstruct'=>'system.multicall expected struct',
188
+ 'multicall_nomethod'=>'missing methodName',
189
+ 'multicall_notstring'=>'methodName is not a string',
190
+ 'multicall_recursion'=>'recursive system.multicall forbidden',
191
+ 'multicall_noparams'=>'missing params',
192
+ 'multicall_notarray'=>'params is not an array',
193
+
194
+ 'cannot_decompress'=>'Received from server compressed HTTP and cannot decompress',
195
+ 'decompress_fail'=>'Received from server invalid compressed HTTP',
196
+ 'dechunk_fail'=>'Received from server invalid chunked HTTP',
197
+ 'server_cannot_decompress'=>'Received from client compressed HTTP request and cannot decompress',
198
+ 'server_decompress_fail'=>'Received from client invalid compressed HTTP request'
199
+ );
200
+
201
+ // The charset encoding used by the server for received messages and
202
+ // by the client for received responses when received charset cannot be determined
203
+ // or is not supported
204
+ $GLOBALS['xmlrpc_defencoding']='UTF-8';
205
+
206
+ // The encoding used internally by PHP.
207
+ // String values received as xml will be converted to this, and php strings will be converted to xml
208
+ // as if having been coded with this
209
+ $GLOBALS['xmlrpc_internalencoding']='ISO-8859-1';
210
+
211
+ $GLOBALS['xmlrpcName']='XML-RPC for PHP';
212
+ $GLOBALS['xmlrpcVersion']='3.0.0.beta';
213
+
214
+ // let user errors start at 800
215
+ $GLOBALS['xmlrpcerruser']=800;
216
+ // let XML parse errors start at 100
217
+ $GLOBALS['xmlrpcerrxml']=100;
218
+
219
+ // formulate backslashes for escaping regexp
220
+ // Not in use anymore since 2.0. Shall we remove it?
221
+ /// @deprecated
222
+ $GLOBALS['xmlrpc_backslash']=chr(92).chr(92);
223
+
224
+ // set to TRUE to enable correct decoding of <NIL/> and <EX:NIL/> values
225
+ $GLOBALS['xmlrpc_null_extension']=false;
226
+
227
+ // set to TRUE to enable encoding of php NULL values to <EX:NIL/> instead of <NIL/>
228
+ $GLOBALS['xmlrpc_null_apache_encoding']=false;
229
+
230
+ // used to store state during parsing
231
+ // quick explanation of components:
232
+ // ac - used to accumulate values
233
+ // isf - used to indicate a parsing fault (2) or xmlrpcresp fault (1)
234
+ // isf_reason - used for storing xmlrpcresp fault string
235
+ // lv - used to indicate "looking for a value": implements
236
+ // the logic to allow values with no types to be strings
237
+ // params - used to store parameters in method calls
238
+ // method - used to store method name
239
+ // stack - array with genealogy of xml elements names:
240
+ // used to validate nesting of xmlrpc elements
241
+ $GLOBALS['_xh']=null;
242
+
243
+ /**
244
+ * Convert a string to the correct XML representation in a target charset
245
+ * To help correct communication of non-ascii chars inside strings, regardless
246
+ * of the charset used when sending requests, parsing them, sending responses
247
+ * and parsing responses, an option is to convert all non-ascii chars present in the message
248
+ * into their equivalent 'charset entity'. Charset entities enumerated this way
249
+ * are independent of the charset encoding used to transmit them, and all XML
250
+ * parsers are bound to understand them.
251
+ * Note that in the std case we are not sending a charset encoding mime type
252
+ * along with http headers, so we are bound by RFC 3023 to emit strict us-ascii.
253
+ *
254
+ * @todo do a bit of basic benchmarking (strtr vs. str_replace)
255
+ * @todo make usage of iconv() or recode_string() or mb_string() where available
256
+ */
257
+ function xmlrpc_encode_entitites($data, $src_encoding='', $dest_encoding='')
258
+ {
259
+ if ($src_encoding == '')
260
+ {
261
+ // lame, but we know no better...
262
+ $src_encoding = $GLOBALS['xmlrpc_internalencoding'];
263
+ }
264
+
265
+ switch(strtoupper($src_encoding.'_'.$dest_encoding))
266
+ {
267
+ case 'ISO-8859-1_':
268
+ case 'ISO-8859-1_US-ASCII':
269
+ $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
270
+ $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data);
271
+ break;
272
+ case 'ISO-8859-1_UTF-8':
273
+ $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
274
+ $escaped_data = utf8_encode($escaped_data);
275
+ break;
276
+ case 'ISO-8859-1_ISO-8859-1':
277
+ case 'US-ASCII_US-ASCII':
278
+ case 'US-ASCII_UTF-8':
279
+ case 'US-ASCII_':
280
+ case 'US-ASCII_ISO-8859-1':
281
+ case 'UTF-8_UTF-8':
282
+ //case 'CP1252_CP1252':
283
+ $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
284
+ break;
285
+ case 'UTF-8_':
286
+ case 'UTF-8_US-ASCII':
287
+ case 'UTF-8_ISO-8859-1':
288
+ // NB: this will choke on invalid UTF-8, going most likely beyond EOF
289
+ $escaped_data = '';
290
+ // be kind to users creating string xmlrpcvals out of different php types
291
+ $data = (string) $data;
292
+ $ns = strlen ($data);
293
+ for ($nn = 0; $nn < $ns; $nn++)
294
+ {
295
+ $ch = $data[$nn];
296
+ $ii = ord($ch);
297
+ //1 7 0bbbbbbb (127)
298
+ if ($ii < 128)
299
+ {
300
+ /// @todo shall we replace this with a (supposedly) faster str_replace?
301
+ switch($ii){
302
+ case 34:
303
+ $escaped_data .= '&quot;';
304
+ break;
305
+ case 38:
306
+ $escaped_data .= '&amp;';
307
+ break;
308
+ case 39:
309
+ $escaped_data .= '&apos;';
310
+ break;
311
+ case 60:
312
+ $escaped_data .= '&lt;';
313
+ break;
314
+ case 62:
315
+ $escaped_data .= '&gt;';
316
+ break;
317
+ default:
318
+ $escaped_data .= $ch;
319
+ } // switch
320
+ }
321
+ //2 11 110bbbbb 10bbbbbb (2047)
322
+ else if ($ii>>5 == 6)
323
+ {
324
+ $b1 = ($ii & 31);
325
+ $ii = ord($data[$nn+1]);
326
+ $b2 = ($ii & 63);
327
+ $ii = ($b1 * 64) + $b2;
328
+ $ent = sprintf ('&#%d;', $ii);
329
+ $escaped_data .= $ent;
330
+ $nn += 1;
331
+ }
332
+ //3 16 1110bbbb 10bbbbbb 10bbbbbb
333
+ else if ($ii>>4 == 14)
334
+ {
335
+ $b1 = ($ii & 15);
336
+ $ii = ord($data[$nn+1]);
337
+ $b2 = ($ii & 63);
338
+ $ii = ord($data[$nn+2]);
339
+ $b3 = ($ii & 63);
340
+ $ii = ((($b1 * 64) + $b2) * 64) + $b3;
341
+ $ent = sprintf ('&#%d;', $ii);
342
+ $escaped_data .= $ent;
343
+ $nn += 2;
344
+ }
345
+ //4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
346
+ else if ($ii>>3 == 30)
347
+ {
348
+ $b1 = ($ii & 7);
349
+ $ii = ord($data[$nn+1]);
350
+ $b2 = ($ii & 63);
351
+ $ii = ord($data[$nn+2]);
352
+ $b3 = ($ii & 63);
353
+ $ii = ord($data[$nn+3]);
354
+ $b4 = ($ii & 63);
355
+ $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4;
356
+ $ent = sprintf ('&#%d;', $ii);
357
+ $escaped_data .= $ent;
358
+ $nn += 3;
359
+ }
360
+ }
361
+ break;
362
+ /*
363
+ case 'CP1252_':
364
+ case 'CP1252_US-ASCII':
365
+ $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
366
+ $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data);
367
+ $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data);
368
+ break;
369
+ case 'CP1252_UTF-8':
370
+ $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
371
+ /// @todo we could use real UTF8 chars here instead of xml entities... (note that utf_8 encode all allone will NOT convert them)
372
+ $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data);
373
+ $escaped_data = utf8_encode($escaped_data);
374
+ break;
375
+ case 'CP1252_ISO-8859-1':
376
+ $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
377
+ // we might as well replave all funky chars with a '?' here, but we are kind and leave it to the receiving application layer to decide what to do with these weird entities...
378
+ $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data);
379
+ break;
380
+ */
381
+ default:
382
+ $escaped_data = '';
383
+ error_log("Converting from $src_encoding to $dest_encoding: not supported...");
384
+ }
385
+ return $escaped_data;
386
+ }
387
+
388
+ /// xml parser handler function for opening element tags
389
+ function xmlrpc_se($parser, $name, $attrs, $accept_single_vals=false)
390
+ {
391
+ // if invalid xmlrpc already detected, skip all processing
392
+ if ($GLOBALS['_xh']['isf'] < 2)
393
+ {
394
+ // check for correct element nesting
395
+ // top level element can only be of 2 types
396
+ /// @todo optimization creep: save this check into a bool variable, instead of using count() every time:
397
+ /// there is only a single top level element in xml anyway
398
+ if (count($GLOBALS['_xh']['stack']) == 0)
399
+ {
400
+ if ($name != 'METHODRESPONSE' && $name != 'METHODCALL' && (
401
+ $name != 'VALUE' && !$accept_single_vals))
402
+ {
403
+ $GLOBALS['_xh']['isf'] = 2;
404
+ $GLOBALS['_xh']['isf_reason'] = 'missing top level xmlrpc element';
405
+ return;
406
+ }
407
+ else
408
+ {
409
+ $GLOBALS['_xh']['rt'] = strtolower($name);
410
+ $GLOBALS['_xh']['rt'] = strtolower($name);
411
+ }
412
+ }
413
+ else
414
+ {
415
+ // not top level element: see if parent is OK
416
+ $parent = end($GLOBALS['_xh']['stack']);
417
+ if (!array_key_exists($name, $GLOBALS['xmlrpc_valid_parents']) || !in_array($parent, $GLOBALS['xmlrpc_valid_parents'][$name]))
418
+ {
419
+ $GLOBALS['_xh']['isf'] = 2;
420
+ $GLOBALS['_xh']['isf_reason'] = "xmlrpc element $name cannot be child of $parent";
421
+ return;
422
+ }
423
+ }
424
+
425
+ switch($name)
426
+ {
427
+ // optimize for speed switch cases: most common cases first
428
+ case 'VALUE':
429
+ /// @todo we could check for 2 VALUE elements inside a MEMBER or PARAM element
430
+ $GLOBALS['_xh']['vt']='value'; // indicator: no value found yet
431
+ $GLOBALS['_xh']['ac']='';
432
+ $GLOBALS['_xh']['lv']=1;
433
+ $GLOBALS['_xh']['php_class']=null;
434
+ break;
435
+ case 'I4':
436
+ case 'INT':
437
+ case 'STRING':
438
+ case 'BOOLEAN':
439
+ case 'DOUBLE':
440
+ case 'DATETIME.ISO8601':
441
+ case 'BASE64':
442
+ if ($GLOBALS['_xh']['vt']!='value')
443
+ {
444
+ //two data elements inside a value: an error occurred!
445
+ $GLOBALS['_xh']['isf'] = 2;
446
+ $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value";
447
+ return;
448
+ }
449
+ $GLOBALS['_xh']['ac']=''; // reset the accumulator
450
+ break;
451
+ case 'STRUCT':
452
+ case 'ARRAY':
453
+ if ($GLOBALS['_xh']['vt']!='value')
454
+ {
455
+ //two data elements inside a value: an error occurred!
456
+ $GLOBALS['_xh']['isf'] = 2;
457
+ $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value";
458
+ return;
459
+ }
460
+ // create an empty array to hold child values, and push it onto appropriate stack
461
+ $cur_val = array();
462
+ $cur_val['values'] = array();
463
+ $cur_val['type'] = $name;
464
+ // check for out-of-band information to rebuild php objs
465
+ // and in case it is found, save it
466
+ if (@isset($attrs['PHP_CLASS']))
467
+ {
468
+ $cur_val['php_class'] = $attrs['PHP_CLASS'];
469
+ }
470
+ $GLOBALS['_xh']['valuestack'][] = $cur_val;
471
+ $GLOBALS['_xh']['vt']='data'; // be prepared for a data element next
472
+ break;
473
+ case 'DATA':
474
+ if ($GLOBALS['_xh']['vt']!='data')
475
+ {
476
+ //two data elements inside a value: an error occurred!
477
+ $GLOBALS['_xh']['isf'] = 2;
478
+ $GLOBALS['_xh']['isf_reason'] = "found two data elements inside an array element";
479
+ return;
480
+ }
481
+ case 'METHODCALL':
482
+ case 'METHODRESPONSE':
483
+ case 'PARAMS':
484
+ // valid elements that add little to processing
485
+ break;
486
+ case 'METHODNAME':
487
+ case 'NAME':
488
+ /// @todo we could check for 2 NAME elements inside a MEMBER element
489
+ $GLOBALS['_xh']['ac']='';
490
+ break;
491
+ case 'FAULT':
492
+ $GLOBALS['_xh']['isf']=1;
493
+ break;
494
+ case 'MEMBER':
495
+ $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name']=''; // set member name to null, in case we do not find in the xml later on
496
+ //$GLOBALS['_xh']['ac']='';
497
+ // Drop trough intentionally
498
+ case 'PARAM':
499
+ // clear value type, so we can check later if no value has been passed for this param/member
500
+ $GLOBALS['_xh']['vt']=null;
501
+ break;
502
+ case 'NIL':
503
+ case 'EX:NIL':
504
+ if ($GLOBALS['xmlrpc_null_extension'])
505
+ {
506
+ if ($GLOBALS['_xh']['vt']!='value')
507
+ {
508
+ //two data elements inside a value: an error occurred!
509
+ $GLOBALS['_xh']['isf'] = 2;
510
+ $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value";
511
+ return;
512
+ }
513
+ $GLOBALS['_xh']['ac']=''; // reset the accumulator
514
+ break;
515
+ }
516
+ // we do not support the <NIL/> extension, so
517
+ // drop through intentionally
518
+ default:
519
+ /// INVALID ELEMENT: RAISE ISF so that it is later recognized!!!
520
+ $GLOBALS['_xh']['isf'] = 2;
521
+ $GLOBALS['_xh']['isf_reason'] = "found not-xmlrpc xml element $name";
522
+ break;
523
+ }
524
+
525
+ // Save current element name to stack, to validate nesting
526
+ $GLOBALS['_xh']['stack'][] = $name;
527
+
528
+ /// @todo optimization creep: move this inside the big switch() above
529
+ if($name!='VALUE')
530
+ {
531
+ $GLOBALS['_xh']['lv']=0;
532
+ }
533
+ }
534
+ }
535
+
536
+ /// Used in decoding xml chunks that might represent single xmlrpc values
537
+ function xmlrpc_se_any($parser, $name, $attrs)
538
+ {
539
+ xmlrpc_se($parser, $name, $attrs, true);
540
+ }
541
+
542
+ /// xml parser handler function for close element tags
543
+ function xmlrpc_ee($parser, $name, $rebuild_xmlrpcvals = true)
544
+ {
545
+ if ($GLOBALS['_xh']['isf'] < 2)
546
+ {
547
+ // push this element name from stack
548
+ // NB: if XML validates, correct opening/closing is guaranteed and
549
+ // we do not have to check for $name == $curr_elem.
550
+ // we also checked for proper nesting at start of elements...
551
+ $curr_elem = array_pop($GLOBALS['_xh']['stack']);
552
+
553
+ switch($name)
554
+ {
555
+ case 'VALUE':
556
+ // This if() detects if no scalar was inside <VALUE></VALUE>
557
+ if ($GLOBALS['_xh']['vt']=='value')
558
+ {
559
+ $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
560
+ $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcString'];
561
+ }
562
+
563
+ if ($rebuild_xmlrpcvals)
564
+ {
565
+ // build the xmlrpc val out of the data received, and substitute it
566
+ $temp = new xmlrpcval($GLOBALS['_xh']['value'], $GLOBALS['_xh']['vt']);
567
+ // in case we got info about underlying php class, save it
568
+ // in the object we're rebuilding
569
+ if (isset($GLOBALS['_xh']['php_class']))
570
+ $temp->_php_class = $GLOBALS['_xh']['php_class'];
571
+ // check if we are inside an array or struct:
572
+ // if value just built is inside an array, let's move it into array on the stack
573
+ $vscount = count($GLOBALS['_xh']['valuestack']);
574
+ if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY')
575
+ {
576
+ $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $temp;
577
+ }
578
+ else
579
+ {
580
+ $GLOBALS['_xh']['value'] = $temp;
581
+ }
582
+ }
583
+ else
584
+ {
585
+ /// @todo this needs to treat correctly php-serialized objects,
586
+ /// since std deserializing is done by php_xmlrpc_decode,
587
+ /// which we will not be calling...
588
+ if (isset($GLOBALS['_xh']['php_class']))
589
+ {
590
+ }
591
+
592
+ // check if we are inside an array or struct:
593
+ // if value just built is inside an array, let's move it into array on the stack
594
+ $vscount = count($GLOBALS['_xh']['valuestack']);
595
+ if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY')
596
+ {
597
+ $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $GLOBALS['_xh']['value'];
598
+ }
599
+ }
600
+ break;
601
+ case 'BOOLEAN':
602
+ case 'I4':
603
+ case 'INT':
604
+ case 'STRING':
605
+ case 'DOUBLE':
606
+ case 'DATETIME.ISO8601':
607
+ case 'BASE64':
608
+ $GLOBALS['_xh']['vt']=strtolower($name);
609
+ /// @todo: optimization creep - remove the if/elseif cycle below
610
+ /// since the case() in which we are already did that
611
+ if ($name=='STRING')
612
+ {
613
+ $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
614
+ }
615
+ elseif ($name=='DATETIME.ISO8601')
616
+ {
617
+ if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $GLOBALS['_xh']['ac']))
618
+ {
619
+ error_log('XML-RPC: invalid value received in DATETIME: '.$GLOBALS['_xh']['ac']);
620
+ }
621
+ $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcDateTime'];
622
+ $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
623
+ }
624
+ elseif ($name=='BASE64')
625
+ {
626
+ /// @todo check for failure of base64 decoding / catch warnings
627
+ $GLOBALS['_xh']['value']=base64_decode($GLOBALS['_xh']['ac']);
628
+ }
629
+ elseif ($name=='BOOLEAN')
630
+ {
631
+ // special case here: we translate boolean 1 or 0 into PHP
632
+ // constants true or false.
633
+ // Strings 'true' and 'false' are accepted, even though the
634
+ // spec never mentions them (see eg. Blogger api docs)
635
+ // NB: this simple checks helps a lot sanitizing input, ie no
636
+ // security problems around here
637
+ if ($GLOBALS['_xh']['ac']=='1' || strcasecmp($GLOBALS['_xh']['ac'], 'true') == 0)
638
+ {
639
+ $GLOBALS['_xh']['value']=true;
640
+ }
641
+ else
642
+ {
643
+ // log if receiveing something strange, even though we set the value to false anyway
644
+ if ($GLOBALS['_xh']['ac']!='0' && strcasecmp($GLOBALS['_xh']['ac'], 'false') != 0)
645
+ error_log('XML-RPC: invalid value received in BOOLEAN: '.$GLOBALS['_xh']['ac']);
646
+ $GLOBALS['_xh']['value']=false;
647
+ }
648
+ }
649
+ elseif ($name=='DOUBLE')
650
+ {
651
+ // we have a DOUBLE
652
+ // we must check that only 0123456789-.<space> are characters here
653
+ // NOTE: regexp could be much stricter than this...
654
+ if (!preg_match('/^[+-eE0123456789 \t.]+$/', $GLOBALS['_xh']['ac']))
655
+ {
656
+ /// @todo: find a better way of throwing an error than this!
657
+ error_log('XML-RPC: non numeric value received in DOUBLE: '.$GLOBALS['_xh']['ac']);
658
+ $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND';
659
+ }
660
+ else
661
+ {
662
+ // it's ok, add it on
663
+ $GLOBALS['_xh']['value']=(double)$GLOBALS['_xh']['ac'];
664
+ }
665
+ }
666
+ else
667
+ {
668
+ // we have an I4/INT
669
+ // we must check that only 0123456789-<space> are characters here
670
+ if (!preg_match('/^[+-]?[0123456789 \t]+$/', $GLOBALS['_xh']['ac']))
671
+ {
672
+ /// @todo find a better way of throwing an error than this!
673
+ error_log('XML-RPC: non numeric value received in INT: '.$GLOBALS['_xh']['ac']);
674
+ $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND';
675
+ }
676
+ else
677
+ {
678
+ // it's ok, add it on
679
+ $GLOBALS['_xh']['value']=(int)$GLOBALS['_xh']['ac'];
680
+ }
681
+ }
682
+ //$GLOBALS['_xh']['ac']=''; // is this necessary?
683
+ $GLOBALS['_xh']['lv']=3; // indicate we've found a value
684
+ break;
685
+ case 'NAME':
686
+ $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name'] = $GLOBALS['_xh']['ac'];
687
+ break;
688
+ case 'MEMBER':
689
+ //$GLOBALS['_xh']['ac']=''; // is this necessary?
690
+ // add to array in the stack the last element built,
691
+ // unless no VALUE was found
692
+ if ($GLOBALS['_xh']['vt'])
693
+ {
694
+ $vscount = count($GLOBALS['_xh']['valuestack']);
695
+ $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][$GLOBALS['_xh']['valuestack'][$vscount-1]['name']] = $GLOBALS['_xh']['value'];
696
+ } else
697
+ error_log('XML-RPC: missing VALUE inside STRUCT in received xml');
698
+ break;
699
+ case 'DATA':
700
+ //$GLOBALS['_xh']['ac']=''; // is this necessary?
701
+ $GLOBALS['_xh']['vt']=null; // reset this to check for 2 data elements in a row - even if they're empty
702
+ break;
703
+ case 'STRUCT':
704
+ case 'ARRAY':
705
+ // fetch out of stack array of values, and promote it to current value
706
+ $curr_val = array_pop($GLOBALS['_xh']['valuestack']);
707
+ $GLOBALS['_xh']['value'] = $curr_val['values'];
708
+ $GLOBALS['_xh']['vt']=strtolower($name);
709
+ if (isset($curr_val['php_class']))
710
+ {
711
+ $GLOBALS['_xh']['php_class'] = $curr_val['php_class'];
712
+ }
713
+ break;
714
+ case 'PARAM':
715
+ // add to array of params the current value,
716
+ // unless no VALUE was found
717
+ if ($GLOBALS['_xh']['vt'])
718
+ {
719
+ $GLOBALS['_xh']['params'][]=$GLOBALS['_xh']['value'];
720
+ $GLOBALS['_xh']['pt'][]=$GLOBALS['_xh']['vt'];
721
+ }
722
+ else
723
+ error_log('XML-RPC: missing VALUE inside PARAM in received xml');
724
+ break;
725
+ case 'METHODNAME':
726
+ $GLOBALS['_xh']['method']=preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']);
727
+ break;
728
+ case 'NIL':
729
+ case 'EX:NIL':
730
+ if ($GLOBALS['xmlrpc_null_extension'])
731
+ {
732
+ $GLOBALS['_xh']['vt']='null';
733
+ $GLOBALS['_xh']['value']=null;
734
+ $GLOBALS['_xh']['lv']=3;
735
+ break;
736
+ }
737
+ // drop through intentionally if nil extension not enabled
738
+ case 'PARAMS':
739
+ case 'FAULT':
740
+ case 'METHODCALL':
741
+ case 'METHORESPONSE':
742
+ break;
743
+ default:
744
+ // End of INVALID ELEMENT!
745
+ // shall we add an assert here for unreachable code???
746
+ break;
747
+ }
748
+ }
749
+ }
750
+
751
+ /// Used in decoding xmlrpc requests/responses without rebuilding xmlrpc values
752
+ function xmlrpc_ee_fast($parser, $name)
753
+ {
754
+ xmlrpc_ee($parser, $name, false);
755
+ }
756
+
757
+ /// xml parser handler function for character data
758
+ function xmlrpc_cd($parser, $data)
759
+ {
760
+ // skip processing if xml fault already detected
761
+ if ($GLOBALS['_xh']['isf'] < 2)
762
+ {
763
+ // "lookforvalue==3" means that we've found an entire value
764
+ // and should discard any further character data
765
+ if($GLOBALS['_xh']['lv']!=3)
766
+ {
767
+ // G. Giunta 2006-08-23: useless change of 'lv' from 1 to 2
768
+ //if($GLOBALS['_xh']['lv']==1)
769
+ //{
770
+ // if we've found text and we're just in a <value> then
771
+ // say we've found a value
772
+ //$GLOBALS['_xh']['lv']=2;
773
+ //}
774
+ // we always initialize the accumulator before starting parsing, anyway...
775
+ //if(!@isset($GLOBALS['_xh']['ac']))
776
+ //{
777
+ // $GLOBALS['_xh']['ac'] = '';
778
+ //}
779
+ $GLOBALS['_xh']['ac'].=$data;
780
+ }
781
+ }
782
+ }
783
+
784
+ /// xml parser handler function for 'other stuff', ie. not char data or
785
+ /// element start/end tag. In fact it only gets called on unknown entities...
786
+ function xmlrpc_dh($parser, $data)
787
+ {
788
+ // skip processing if xml fault already detected
789
+ if ($GLOBALS['_xh']['isf'] < 2)
790
+ {
791
+ if(substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';')
792
+ {
793
+ // G. Giunta 2006-08-25: useless change of 'lv' from 1 to 2
794
+ //if($GLOBALS['_xh']['lv']==1)
795
+ //{
796
+ // $GLOBALS['_xh']['lv']=2;
797
+ //}
798
+ $GLOBALS['_xh']['ac'].=$data;
799
+ }
800
+ }
801
+ return true;
802
+ }
803
+
804
+ class xmlrpc_client
805
+ {
806
+ var $path;
807
+ var $server;
808
+ var $port=0;
809
+ var $method='http';
810
+ var $errno;
811
+ var $errstr;
812
+ var $debug=0;
813
+ var $username='';
814
+ var $password='';
815
+ var $authtype=1;
816
+ var $cert='';
817
+ var $certpass='';
818
+ var $cacert='';
819
+ var $cacertdir='';
820
+ var $key='';
821
+ var $keypass='';
822
+ var $verifypeer=true;
823
+ var $verifyhost=1;
824
+ var $no_multicall=false;
825
+ var $proxy='';
826
+ var $proxyport=0;
827
+ var $proxy_user='';
828
+ var $proxy_pass='';
829
+ var $proxy_authtype=1;
830
+ var $cookies=array();
831
+ var $extracurlopts=array();
832
+
833
+ /**
834
+ * List of http compression methods accepted by the client for responses.
835
+ * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib
836
+ *
837
+ * NNB: you can set it to any non-empty array for HTTP11 and HTTPS, since
838
+ * in those cases it will be up to CURL to decide the compression methods
839
+ * it supports. You might check for the presence of 'zlib' in the output of
840
+ * curl_version() to determine wheter compression is supported or not
841
+ */
842
+ var $accepted_compression = array();
843
+ /**
844
+ * Name of compression scheme to be used for sending requests.
845
+ * Either null, gzip or deflate
846
+ */
847
+ var $request_compression = '';
848
+ /**
849
+ * CURL handle: used for keep-alive connections (PHP 4.3.8 up, see:
850
+ * http://curl.haxx.se/docs/faq.html#7.3)
851
+ */
852
+ var $xmlrpc_curl_handle = null;
853
+ /// Wheter to use persistent connections for http 1.1 and https
854
+ var $keepalive = false;
855
+ /// Charset encodings that can be decoded without problems by the client
856
+ var $accepted_charset_encodings = array();
857
+ /// Charset encoding to be used in serializing request. NULL = use ASCII
858
+ var $request_charset_encoding = '';
859
+ /**
860
+ * Decides the content of xmlrpcresp objects returned by calls to send()
861
+ * valid strings are 'xmlrpcvals', 'phpvals' or 'xml'
862
+ */
863
+ var $return_type = 'xmlrpcvals';
864
+ /**
865
+ * Sent to servers in http headers
866
+ */
867
+ var $user_agent;
868
+
869
+ /**
870
+ * @param string $path either the complete server URL or the PATH part of the xmlrc server URL, e.g. /xmlrpc/server.php
871
+ * @param string $server the server name / ip address
872
+ * @param integer $port the port the server is listening on, defaults to 80 or 443 depending on protocol used
873
+ * @param string $method the http protocol variant: defaults to 'http', 'https' and 'http11' can be used if CURL is installed
874
+ */
875
+ function xmlrpc_client($path, $server='', $port='', $method='')
876
+ {
877
+ // allow user to specify all params in $path
878
+ if($server == '' and $port == '' and $method == '')
879
+ {
880
+ $parts = parse_url($path);
881
+ $server = $parts['host'];
882
+ $path = isset($parts['path']) ? $parts['path'] : '';
883
+ if(isset($parts['query']))
884
+ {
885
+ $path .= '?'.$parts['query'];
886
+ }
887
+ if(isset($parts['fragment']))
888
+ {
889
+ $path .= '#'.$parts['fragment'];
890
+ }
891
+ if(isset($parts['port']))
892
+ {
893
+ $port = $parts['port'];
894
+ }
895
+ if(isset($parts['scheme']))
896
+ {
897
+ $method = $parts['scheme'];
898
+ }
899
+ if(isset($parts['user']))
900
+ {
901
+ $this->username = $parts['user'];
902
+ }
903
+ if(isset($parts['pass']))
904
+ {
905
+ $this->password = $parts['pass'];
906
+ }
907
+ }
908
+ if($path == '' || $path[0] != '/')
909
+ {
910
+ $this->path='/'.$path;
911
+ }
912
+ else
913
+ {
914
+ $this->path=$path;
915
+ }
916
+ $this->server=$server;
917
+ if($port != '')
918
+ {
919
+ $this->port=$port;
920
+ }
921
+ if($method != '')
922
+ {
923
+ $this->method=$method;
924
+ }
925
+
926
+ // if ZLIB is enabled, let the client by default accept compressed responses
927
+ if(function_exists('gzinflate') || (
928
+ function_exists('curl_init') && (($info = curl_version()) &&
929
+ ((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version'])))
930
+ ))
931
+ {
932
+ $this->accepted_compression = array('gzip', 'deflate');
933
+ }
934
+
935
+ // keepalives: enabled by default
936
+ $this->keepalive = true;
937
+
938
+ // by default the xml parser can support these 3 charset encodings
939
+ $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII');
940
+
941
+ // initialize user_agent string
942
+ $this->user_agent = $GLOBALS['xmlrpcName'] . ' ' . $GLOBALS['xmlrpcVersion'];
943
+ }
944
+
945
+ /**
946
+ * Enables/disables the echoing to screen of the xmlrpc responses received
947
+ * @param integer $debug values 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
948
+ * @access public
949
+ */
950
+ function setDebug($in)
951
+ {
952
+ $this->debug=$in;
953
+ }
954
+
955
+ /**
956
+ * Add some http BASIC AUTH credentials, used by the client to authenticate
957
+ * @param string $u username
958
+ * @param string $p password
959
+ * @param integer $t auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC (basic auth)
960
+ * @access public
961
+ */
962
+ function setCredentials($u, $p, $t=1)
963
+ {
964
+ $this->username=$u;
965
+ $this->password=$p;
966
+ $this->authtype=$t;
967
+ }
968
+
969
+ /**
970
+ * Add a client-side https certificate
971
+ * @param string $cert
972
+ * @param string $certpass
973
+ * @access public
974
+ */
975
+ function setCertificate($cert, $certpass)
976
+ {
977
+ $this->cert = $cert;
978
+ $this->certpass = $certpass;
979
+ }
980
+
981
+ /**
982
+ * Add a CA certificate to verify server with (see man page about
983
+ * CURLOPT_CAINFO for more details
984
+ * @param string $cacert certificate file name (or dir holding certificates)
985
+ * @param bool $is_dir set to true to indicate cacert is a dir. defaults to false
986
+ * @access public
987
+ */
988
+ function setCaCertificate($cacert, $is_dir=false)
989
+ {
990
+ if ($is_dir)
991
+ {
992
+ $this->cacertdir = $cacert;
993
+ }
994
+ else
995
+ {
996
+ $this->cacert = $cacert;
997
+ }
998
+ }
999
+
1000
+ /**
1001
+ * Set attributes for SSL communication: private SSL key
1002
+ * NB: does not work in older php/curl installs
1003
+ * Thanks to Daniel Convissor
1004
+ * @param string $key The name of a file containing a private SSL key
1005
+ * @param string $keypass The secret password needed to use the private SSL key
1006
+ * @access public
1007
+ */
1008
+ function setKey($key, $keypass)
1009
+ {
1010
+ $this->key = $key;
1011
+ $this->keypass = $keypass;
1012
+ }
1013
+
1014
+ /**
1015
+ * Set attributes for SSL communication: verify server certificate
1016
+ * @param bool $i enable/disable verification of peer certificate
1017
+ * @access public
1018
+ */
1019
+ function setSSLVerifyPeer($i)
1020
+ {
1021
+ $this->verifypeer = $i;
1022
+ }
1023
+
1024
+ /**
1025
+ * Set attributes for SSL communication: verify match of server cert w. hostname
1026
+ * @param int $i
1027
+ * @access public
1028
+ */
1029
+ function setSSLVerifyHost($i)
1030
+ {
1031
+ $this->verifyhost = $i;
1032
+ }
1033
+
1034
+ /**
1035
+ * Set proxy info
1036
+ * @param string $proxyhost
1037
+ * @param string $proxyport Defaults to 8080 for HTTP and 443 for HTTPS
1038
+ * @param string $proxyusername Leave blank if proxy has public access
1039
+ * @param string $proxypassword Leave blank if proxy has public access
1040
+ * @param int $proxyauthtype set to constant CURLAUTH_NTLM to use NTLM auth with proxy
1041
+ * @access public
1042
+ */
1043
+ function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1)
1044
+ {
1045
+ $this->proxy = $proxyhost;
1046
+ $this->proxyport = $proxyport;
1047
+ $this->proxy_user = $proxyusername;
1048
+ $this->proxy_pass = $proxypassword;
1049
+ $this->proxy_authtype = $proxyauthtype;
1050
+ }
1051
+
1052
+ /**
1053
+ * Enables/disables reception of compressed xmlrpc responses.
1054
+ * Note that enabling reception of compressed responses merely adds some standard
1055
+ * http headers to xmlrpc requests. It is up to the xmlrpc server to return
1056
+ * compressed responses when receiving such requests.
1057
+ * @param string $compmethod either 'gzip', 'deflate', 'any' or ''
1058
+ * @access public
1059
+ */
1060
+ function setAcceptedCompression($compmethod)
1061
+ {
1062
+ if ($compmethod == 'any')
1063
+ $this->accepted_compression = array('gzip', 'deflate');
1064
+ else
1065
+ $this->accepted_compression = array($compmethod);
1066
+ }
1067
+
1068
+ /**
1069
+ * Enables/disables http compression of xmlrpc request.
1070
+ * Take care when sending compressed requests: servers might not support them
1071
+ * (and automatic fallback to uncompressed requests is not yet implemented)
1072
+ * @param string $compmethod either 'gzip', 'deflate' or ''
1073
+ * @access public
1074
+ */
1075
+ function setRequestCompression($compmethod)
1076
+ {
1077
+ $this->request_compression = $compmethod;
1078
+ }
1079
+
1080
+ /**
1081
+ * Adds a cookie to list of cookies that will be sent to server.
1082
+ * NB: setting any param but name and value will turn the cookie into a 'version 1' cookie:
1083
+ * do not do it unless you know what you are doing
1084
+ * @param string $name
1085
+ * @param string $value
1086
+ * @param string $path
1087
+ * @param string $domain
1088
+ * @param int $port
1089
+ * @access public
1090
+ *
1091
+ * @todo check correctness of urlencoding cookie value (copied from php way of doing it...)
1092
+ */
1093
+ function setCookie($name, $value='', $path='', $domain='', $port=null)
1094
+ {
1095
+ $this->cookies[$name]['value'] = urlencode($value);
1096
+ if ($path || $domain || $port)
1097
+ {
1098
+ $this->cookies[$name]['path'] = $path;
1099
+ $this->cookies[$name]['domain'] = $domain;
1100
+ $this->cookies[$name]['port'] = $port;
1101
+ $this->cookies[$name]['version'] = 1;
1102
+ }
1103
+ else
1104
+ {
1105
+ $this->cookies[$name]['version'] = 0;
1106
+ }
1107
+ }
1108
+
1109
+ /**
1110
+ * Directly set cURL options, for extra flexibility
1111
+ * It allows eg. to bind client to a specific IP interface / address
1112
+ * @param $options array
1113
+ */
1114
+ function SetCurlOptions( $options )
1115
+ {
1116
+ $this->extracurlopts = $options;
1117
+ }
1118
+
1119
+ /**
1120
+ * Set user-agent string that will be used by this client instance
1121
+ * in http headers sent to the server
1122
+ */
1123
+ function SetUserAgent( $agentstring )
1124
+ {
1125
+ $this->user_agent = $agentstring;
1126
+ }
1127
+
1128
+ /**
1129
+ * Send an xmlrpc request
1130
+ * @param mixed $msg The message object, or an array of messages for using multicall, or the complete xml representation of a request
1131
+ * @param integer $timeout Connection timeout, in seconds, If unspecified, a platform specific timeout will apply
1132
+ * @param string $method if left unspecified, the http protocol chosen during creation of the object will be used
1133
+ * @return xmlrpcresp
1134
+ * @access public
1135
+ */
1136
+ function& send($msg, $timeout=0, $method='')
1137
+ {
1138
+ // if user deos not specify http protocol, use native method of this client
1139
+ // (i.e. method set during call to constructor)
1140
+ if($method == '')
1141
+ {
1142
+ $method = $this->method;
1143
+ }
1144
+
1145
+ if(is_array($msg))
1146
+ {
1147
+ // $msg is an array of xmlrpcmsg's
1148
+ $r = $this->multicall($msg, $timeout, $method);
1149
+ return $r;
1150
+ }
1151
+ elseif(is_string($msg))
1152
+ {
1153
+ $n = new xmlrpcmsg('');
1154
+ $n->payload = $msg;
1155
+ $msg = $n;
1156
+ }
1157
+
1158
+ // where msg is an xmlrpcmsg
1159
+ $msg->debug=$this->debug;
1160
+
1161
+ if($method == 'https')
1162
+ {
1163
+ $r =& $this->sendPayloadHTTPS(
1164
+ $msg,
1165
+ $this->server,
1166
+ $this->port,
1167
+ $timeout,
1168
+ $this->username,
1169
+ $this->password,
1170
+ $this->authtype,
1171
+ $this->cert,
1172
+ $this->certpass,
1173
+ $this->cacert,
1174
+ $this->cacertdir,
1175
+ $this->proxy,
1176
+ $this->proxyport,
1177
+ $this->proxy_user,
1178
+ $this->proxy_pass,
1179
+ $this->proxy_authtype,
1180
+ $this->keepalive,
1181
+ $this->key,
1182
+ $this->keypass
1183
+ );
1184
+ }
1185
+ elseif($method == 'http11')
1186
+ {
1187
+ $r =& $this->sendPayloadCURL(
1188
+ $msg,
1189
+ $this->server,
1190
+ $this->port,
1191
+ $timeout,
1192
+ $this->username,
1193
+ $this->password,
1194
+ $this->authtype,
1195
+ null,
1196
+ null,
1197
+ null,
1198
+ null,
1199
+ $this->proxy,
1200
+ $this->proxyport,
1201
+ $this->proxy_user,
1202
+ $this->proxy_pass,
1203
+ $this->proxy_authtype,
1204
+ 'http',
1205
+ $this->keepalive
1206
+ );
1207
+ }
1208
+ else
1209
+ {
1210
+ $r =& $this->sendPayloadHTTP10(
1211
+ $msg,
1212
+ $this->server,
1213
+ $this->port,
1214
+ $timeout,
1215
+ $this->username,
1216
+ $this->password,
1217
+ $this->authtype,
1218
+ $this->proxy,
1219
+ $this->proxyport,
1220
+ $this->proxy_user,
1221
+ $this->proxy_pass,
1222
+ $this->proxy_authtype
1223
+ );
1224
+ }
1225
+
1226
+ return $r;
1227
+ }
1228
+
1229
+ /**
1230
+ * @access private
1231
+ */
1232
+ function &sendPayloadHTTP10($msg, $server, $port, $timeout=0,
1233
+ $username='', $password='', $authtype=1, $proxyhost='',
1234
+ $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1)
1235
+ {
1236
+ if($port==0)
1237
+ {
1238
+ $port=80;
1239
+ }
1240
+
1241
+ // Only create the payload if it was not created previously
1242
+ if(empty($msg->payload))
1243
+ {
1244
+ $msg->createPayload($this->request_charset_encoding);
1245
+ }
1246
+
1247
+ $payload = $msg->payload;
1248
+ // Deflate request body and set appropriate request headers
1249
+ if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate'))
1250
+ {
1251
+ if($this->request_compression == 'gzip')
1252
+ {
1253
+ $a = @gzencode($payload);
1254
+ if($a)
1255
+ {
1256
+ $payload = $a;
1257
+ $encoding_hdr = "Content-Encoding: gzip\r\n";
1258
+ }
1259
+ }
1260
+ else
1261
+ {
1262
+ $a = @gzcompress($payload);
1263
+ if($a)
1264
+ {
1265
+ $payload = $a;
1266
+ $encoding_hdr = "Content-Encoding: deflate\r\n";
1267
+ }
1268
+ }
1269
+ }
1270
+ else
1271
+ {
1272
+ $encoding_hdr = '';
1273
+ }
1274
+
1275
+ // thanks to Grant Rauscher <grant7@firstworld.net> for this
1276
+ $credentials='';
1277
+ if($username!='')
1278
+ {
1279
+ $credentials='Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n";
1280
+ if ($authtype != 1)
1281
+ {
1282
+ error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0');
1283
+ }
1284
+ }
1285
+
1286
+ $accepted_encoding = '';
1287
+ if(is_array($this->accepted_compression) && count($this->accepted_compression))
1288
+ {
1289
+ $accepted_encoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n";
1290
+ }
1291
+
1292
+ $proxy_credentials = '';
1293
+ if($proxyhost)
1294
+ {
1295
+ if($proxyport == 0)
1296
+ {
1297
+ $proxyport = 8080;
1298
+ }
1299
+ $connectserver = $proxyhost;
1300
+ $connectport = $proxyport;
1301
+ $uri = 'http://'.$server.':'.$port.$this->path;
1302
+ if($proxyusername != '')
1303
+ {
1304
+ if ($proxyauthtype != 1)
1305
+ {
1306
+ error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0');
1307
+ }
1308
+ $proxy_credentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyusername.':'.$proxypassword) . "\r\n";
1309
+ }
1310
+ }
1311
+ else
1312
+ {
1313
+ $connectserver = $server;
1314
+ $connectport = $port;
1315
+ $uri = $this->path;
1316
+ }
1317
+
1318
+ // Cookie generation, as per rfc2965 (version 1 cookies) or
1319
+ // netscape's rules (version 0 cookies)
1320
+ $cookieheader='';
1321
+ if (count($this->cookies))
1322
+ {
1323
+ $version = '';
1324
+ foreach ($this->cookies as $name => $cookie)
1325
+ {
1326
+ if ($cookie['version'])
1327
+ {
1328
+ $version = ' $Version="' . $cookie['version'] . '";';
1329
+ $cookieheader .= ' ' . $name . '="' . $cookie['value'] . '";';
1330
+ if ($cookie['path'])
1331
+ $cookieheader .= ' $Path="' . $cookie['path'] . '";';
1332
+ if ($cookie['domain'])
1333
+ $cookieheader .= ' $Domain="' . $cookie['domain'] . '";';
1334
+ if ($cookie['port'])
1335
+ $cookieheader .= ' $Port="' . $cookie['port'] . '";';
1336
+ }
1337
+ else
1338
+ {
1339
+ $cookieheader .= ' ' . $name . '=' . $cookie['value'] . ";";
1340
+ }
1341
+ }
1342
+ $cookieheader = 'Cookie:' . $version . substr($cookieheader, 0, -1) . "\r\n";
1343
+ }
1344
+
1345
+ $op= 'POST ' . $uri. " HTTP/1.0\r\n" .
1346
+ 'User-Agent: ' . $this->user_agent . "\r\n" .
1347
+ 'Host: '. $server . ':' . $port . "\r\n" .
1348
+ $credentials .
1349
+ $proxy_credentials .
1350
+ $accepted_encoding .
1351
+ $encoding_hdr .
1352
+ 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" .
1353
+ $cookieheader .
1354
+ 'Content-Type: ' . $msg->content_type . "\r\nContent-Length: " .
1355
+ strlen($payload) . "\r\n\r\n" .
1356
+ $payload;
1357
+
1358
+ if($this->debug > 1)
1359
+ {
1360
+ print "<PRE>\n---SENDING---\n" . htmlentities($op) . "\n---END---\n</PRE>";
1361
+ // let the client see this now in case http times out...
1362
+ flush();
1363
+ }
1364
+
1365
+ if($timeout>0)
1366
+ {
1367
+ $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout);
1368
+ }
1369
+ else
1370
+ {
1371
+ $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr);
1372
+ }
1373
+ if($fp)
1374
+ {
1375
+ if($timeout>0 && function_exists('stream_set_timeout'))
1376
+ {
1377
+ stream_set_timeout($fp, $timeout);
1378
+ }
1379
+ }
1380
+ else
1381
+ {
1382
+ $this->errstr='Connect error: '.$this->errstr;
1383
+ $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr . ' (' . $this->errno . ')');
1384
+ return $r;
1385
+ }
1386
+
1387
+ if(!fputs($fp, $op, strlen($op)))
1388
+ {
1389
+ fclose($fp);
1390
+ $this->errstr='Write error';
1391
+ $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr);
1392
+ return $r;
1393
+ }
1394
+ else
1395
+ {
1396
+ // reset errno and errstr on succesful socket connection
1397
+ $this->errstr = '';
1398
+ }
1399
+ // G. Giunta 2005/10/24: close socket before parsing.
1400
+ // should yeld slightly better execution times, and make easier recursive calls (e.g. to follow http redirects)
1401
+ $ipd='';
1402
+ do
1403
+ {
1404
+ // shall we check for $data === FALSE?
1405
+ // as per the manual, it signals an error
1406
+ $ipd.=fread($fp, 32768);
1407
+ } while(!feof($fp));
1408
+ fclose($fp);
1409
+ $r =& $msg->parseResponse($ipd, false, $this->return_type);
1410
+ return $r;
1411
+
1412
+ }
1413
+
1414
+ /**
1415
+ * @access private
1416
+ */
1417
+ function &sendPayloadHTTPS($msg, $server, $port, $timeout=0, $username='',
1418
+ $password='', $authtype=1, $cert='',$certpass='', $cacert='', $cacertdir='',
1419
+ $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1,
1420
+ $keepalive=false, $key='', $keypass='')
1421
+ {
1422
+ $r =& $this->sendPayloadCURL($msg, $server, $port, $timeout, $username,
1423
+ $password, $authtype, $cert, $certpass, $cacert, $cacertdir, $proxyhost, $proxyport,
1424
+ $proxyusername, $proxypassword, $proxyauthtype, 'https', $keepalive, $key, $keypass);
1425
+ return $r;
1426
+ }
1427
+
1428
+ /**
1429
+ * Contributed by Justin Miller <justin@voxel.net>
1430
+ * Requires curl to be built into PHP
1431
+ * NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers!
1432
+ * @access private
1433
+ */
1434
+ function &sendPayloadCURL($msg, $server, $port, $timeout=0, $username='',
1435
+ $password='', $authtype=1, $cert='', $certpass='', $cacert='', $cacertdir='',
1436
+ $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, $method='https',
1437
+ $keepalive=false, $key='', $keypass='')
1438
+ {
1439
+ if(!function_exists('curl_init'))
1440
+ {
1441
+ $this->errstr='CURL unavailable on this install';
1442
+ $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_curl'], $GLOBALS['xmlrpcstr']['no_curl']);
1443
+ return $r;
1444
+ }
1445
+ if($method == 'https')
1446
+ {
1447
+ if(($info = curl_version()) &&
1448
+ ((is_string($info) && strpos($info, 'OpenSSL') === null) || (is_array($info) && !isset($info['ssl_version']))))
1449
+ {
1450
+ $this->errstr='SSL unavailable on this install';
1451
+ $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_ssl'], $GLOBALS['xmlrpcstr']['no_ssl']);
1452
+ return $r;
1453
+ }
1454
+ }
1455
+
1456
+ if($port == 0)
1457
+ {
1458
+ if($method == 'http')
1459
+ {
1460
+ $port = 80;
1461
+ }
1462
+ else
1463
+ {
1464
+ $port = 443;
1465
+ }
1466
+ }
1467
+
1468
+ // Only create the payload if it was not created previously
1469
+ if(empty($msg->payload))
1470
+ {
1471
+ $msg->createPayload($this->request_charset_encoding);
1472
+ }
1473
+
1474
+ // Deflate request body and set appropriate request headers
1475
+ $payload = $msg->payload;
1476
+ if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate'))
1477
+ {
1478
+ if($this->request_compression == 'gzip')
1479
+ {
1480
+ $a = @gzencode($payload);
1481
+ if($a)
1482
+ {
1483
+ $payload = $a;
1484
+ $encoding_hdr = 'Content-Encoding: gzip';
1485
+ }
1486
+ }
1487
+ else
1488
+ {
1489
+ $a = @gzcompress($payload);
1490
+ if($a)
1491
+ {
1492
+ $payload = $a;
1493
+ $encoding_hdr = 'Content-Encoding: deflate';
1494
+ }
1495
+ }
1496
+ }
1497
+ else
1498
+ {
1499
+ $encoding_hdr = '';
1500
+ }
1501
+
1502
+ if($this->debug > 1)
1503
+ {
1504
+ print "<PRE>\n---SENDING---\n" . htmlentities($payload) . "\n---END---\n</PRE>";
1505
+ // let the client see this now in case http times out...
1506
+ flush();
1507
+ }
1508
+
1509
+ if(!$keepalive || !$this->xmlrpc_curl_handle)
1510
+ {
1511
+ $curl = curl_init($method . '://' . $server . ':' . $port . $this->path);
1512
+ if($keepalive)
1513
+ {
1514
+ $this->xmlrpc_curl_handle = $curl;
1515
+ }
1516
+ }
1517
+ else
1518
+ {
1519
+ $curl = $this->xmlrpc_curl_handle;
1520
+ }
1521
+
1522
+ // results into variable
1523
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
1524
+
1525
+ if($this->debug)
1526
+ {
1527
+ curl_setopt($curl, CURLOPT_VERBOSE, 1);
1528
+ }
1529
+ curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
1530
+ // required for XMLRPC: post the data
1531
+ curl_setopt($curl, CURLOPT_POST, 1);
1532
+ // the data
1533
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
1534
+
1535
+ // return the header too
1536
+ curl_setopt($curl, CURLOPT_HEADER, 1);
1537
+
1538
+ // will only work with PHP >= 5.0
1539
+ // NB: if we set an empty string, CURL will add http header indicating
1540
+ // ALL methods it is supporting. This is possibly a better option than
1541
+ // letting the user tell what curl can / cannot do...
1542
+ if(is_array($this->accepted_compression) && count($this->accepted_compression))
1543
+ {
1544
+ //curl_setopt($curl, CURLOPT_ENCODING, implode(',', $this->accepted_compression));
1545
+ // empty string means 'any supported by CURL' (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
1546
+ if (count($this->accepted_compression) == 1)
1547
+ {
1548
+ curl_setopt($curl, CURLOPT_ENCODING, $this->accepted_compression[0]);
1549
+ }
1550
+ else
1551
+ curl_setopt($curl, CURLOPT_ENCODING, '');
1552
+ }
1553
+ // extra headers
1554
+ $headers = array('Content-Type: ' . $msg->content_type , 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
1555
+ // if no keepalive is wanted, let the server know it in advance
1556
+ if(!$keepalive)
1557
+ {
1558
+ $headers[] = 'Connection: close';
1559
+ }
1560
+ // request compression header
1561
+ if($encoding_hdr)
1562
+ {
1563
+ $headers[] = $encoding_hdr;
1564
+ }
1565
+
1566
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
1567
+ // timeout is borked
1568
+ if($timeout)
1569
+ {
1570
+ curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1);
1571
+ }
1572
+
1573
+ if($username && $password)
1574
+ {
1575
+ curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password);
1576
+ if (defined('CURLOPT_HTTPAUTH'))
1577
+ {
1578
+ curl_setopt($curl, CURLOPT_HTTPAUTH, $authtype);
1579
+ }
1580
+ else if ($authtype != 1)
1581
+ {
1582
+ error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install');
1583
+ }
1584
+ }
1585
+
1586
+ if($method == 'https')
1587
+ {
1588
+ // set cert file
1589
+ if($cert)
1590
+ {
1591
+ curl_setopt($curl, CURLOPT_SSLCERT, $cert);
1592
+ }
1593
+ // set cert password
1594
+ if($certpass)
1595
+ {
1596
+ curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $certpass);
1597
+ }
1598
+ // whether to verify remote host's cert
1599
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifypeer);
1600
+ // set ca certificates file/dir
1601
+ if($cacert)
1602
+ {
1603
+ curl_setopt($curl, CURLOPT_CAINFO, $cacert);
1604
+ }
1605
+ if($cacertdir)
1606
+ {
1607
+ curl_setopt($curl, CURLOPT_CAPATH, $cacertdir);
1608
+ }
1609
+ // set key file (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
1610
+ if($key)
1611
+ {
1612
+ curl_setopt($curl, CURLOPT_SSLKEY, $key);
1613
+ }
1614
+ // set key password (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
1615
+ if($keypass)
1616
+ {
1617
+ curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $keypass);
1618
+ }
1619
+ // whether to verify cert's common name (CN); 0 for no, 1 to verify that it exists, and 2 to verify that it matches the hostname used
1620
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, $this->verifyhost);
1621
+ }
1622
+
1623
+ // proxy info
1624
+ if($proxyhost)
1625
+ {
1626
+ if($proxyport == 0)
1627
+ {
1628
+ $proxyport = 8080; // NB: even for HTTPS, local connection is on port 8080
1629
+ }
1630
+ curl_setopt($curl, CURLOPT_PROXY, $proxyhost.':'.$proxyport);
1631
+ //curl_setopt($curl, CURLOPT_PROXYPORT,$proxyport);
1632
+ if($proxyusername)
1633
+ {
1634
+ curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyusername.':'.$proxypassword);
1635
+ if (defined('CURLOPT_PROXYAUTH'))
1636
+ {
1637
+ curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyauthtype);
1638
+ }
1639
+ else if ($proxyauthtype != 1)
1640
+ {
1641
+ error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
1642
+ }
1643
+ }
1644
+ }
1645
+
1646
+ // NB: should we build cookie http headers by hand rather than let CURL do it?
1647
+ // the following code does not honour 'expires', 'path' and 'domain' cookie attributes
1648
+ // set to client obj the the user...
1649
+ if (count($this->cookies))
1650
+ {
1651
+ $cookieheader = '';
1652
+ foreach ($this->cookies as $name => $cookie)
1653
+ {
1654
+ $cookieheader .= $name . '=' . $cookie['value'] . '; ';
1655
+ }
1656
+ curl_setopt($curl, CURLOPT_COOKIE, substr($cookieheader, 0, -2));
1657
+ }
1658
+
1659
+ foreach ($this->extracurlopts as $opt => $val)
1660
+ {
1661
+ curl_setopt($curl, $opt, $val);
1662
+ }
1663
+
1664
+ $result = curl_exec($curl);
1665
+
1666
+ if ($this->debug > 1)
1667
+ {
1668
+ print "<PRE>\n---CURL INFO---\n";
1669
+ foreach(curl_getinfo($curl) as $name => $val)
1670
+ print $name . ': ' . htmlentities($val). "\n";
1671
+ print "---END---\n</PRE>";
1672
+ }
1673
+
1674
+ if(!$result) /// @todo we should use a better check here - what if we get back '' or '0'?
1675
+ {
1676
+ $this->errstr='no response';
1677
+ $resp=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['curl_fail'], $GLOBALS['xmlrpcstr']['curl_fail']. ': '. curl_error($curl));
1678
+ curl_close($curl);
1679
+ if($keepalive)
1680
+ {
1681
+ $this->xmlrpc_curl_handle = null;
1682
+ }
1683
+ }
1684
+ else
1685
+ {
1686
+ if(!$keepalive)
1687
+ {
1688
+ curl_close($curl);
1689
+ }
1690
+ $resp =& $msg->parseResponse($result, true, $this->return_type);
1691
+ }
1692
+ return $resp;
1693
+ }
1694
+
1695
+ /**
1696
+ * Send an array of request messages and return an array of responses.
1697
+ * Unless $this->no_multicall has been set to true, it will try first
1698
+ * to use one single xmlrpc call to server method system.multicall, and
1699
+ * revert to sending many successive calls in case of failure.
1700
+ * This failure is also stored in $this->no_multicall for subsequent calls.
1701
+ * Unfortunately, there is no server error code universally used to denote
1702
+ * the fact that multicall is unsupported, so there is no way to reliably
1703
+ * distinguish between that and a temporary failure.
1704
+ * If you are sure that server supports multicall and do not want to
1705
+ * fallback to using many single calls, set the fourth parameter to FALSE.
1706
+ *
1707
+ * NB: trying to shoehorn extra functionality into existing syntax has resulted
1708
+ * in pretty much convoluted code...
1709
+ *
1710
+ * @param array $msgs an array of xmlrpcmsg objects
1711
+ * @param integer $timeout connection timeout (in seconds)
1712
+ * @param string $method the http protocol variant to be used
1713
+ * @param boolean fallback When true, upon receiveing an error during multicall, multiple single calls will be attempted
1714
+ * @return array
1715
+ * @access public
1716
+ */
1717
+ function multicall($msgs, $timeout=0, $method='', $fallback=true)
1718
+ {
1719
+ if ($method == '')
1720
+ {
1721
+ $method = $this->method;
1722
+ }
1723
+ if(!$this->no_multicall)
1724
+ {
1725
+ $results = $this->_try_multicall($msgs, $timeout, $method);
1726
+ if(is_array($results))
1727
+ {
1728
+ // System.multicall succeeded
1729
+ return $results;
1730
+ }
1731
+ else
1732
+ {
1733
+ // either system.multicall is unsupported by server,
1734
+ // or call failed for some other reason.
1735
+ if ($fallback)
1736
+ {
1737
+ // Don't try it next time...
1738
+ $this->no_multicall = true;
1739
+ }
1740
+ else
1741
+ {
1742
+ if ($results instanceof xmlrpcresp)
1743
+ {
1744
+ $result = $results;
1745
+ }
1746
+ else
1747
+ {
1748
+ $result = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['multicall_error'], $GLOBALS['xmlrpcstr']['multicall_error']);
1749
+ }
1750
+ }
1751
+ }
1752
+ }
1753
+ else
1754
+ {
1755
+ // override fallback, in case careless user tries to do two
1756
+ // opposite things at the same time
1757
+ $fallback = true;
1758
+ }
1759
+
1760
+ $results = array();
1761
+ if ($fallback)
1762
+ {
1763
+ // system.multicall is (probably) unsupported by server:
1764
+ // emulate multicall via multiple requests
1765
+ foreach($msgs as $msg)
1766
+ {
1767
+ $results[] =& $this->send($msg, $timeout, $method);
1768
+ }
1769
+ }
1770
+ else
1771
+ {
1772
+ // user does NOT want to fallback on many single calls:
1773
+ // since we should always return an array of responses,
1774
+ // return an array with the same error repeated n times
1775
+ foreach($msgs as $msg)
1776
+ {
1777
+ $results[] = $result;
1778
+ }
1779
+ }
1780
+ return $results;
1781
+ }
1782
+
1783
+ /**
1784
+ * Attempt to boxcar $msgs via system.multicall.
1785
+ * Returns either an array of xmlrpcreponses, an xmlrpc error response
1786
+ * or false (when received response does not respect valid multicall syntax)
1787
+ * @access private
1788
+ */
1789
+ function _try_multicall($msgs, $timeout, $method)
1790
+ {
1791
+ // Construct multicall message
1792
+ $calls = array();
1793
+ foreach($msgs as $msg)
1794
+ {
1795
+ $call['methodName'] = new xmlrpcval($msg->method(),'string');
1796
+ $numParams = $msg->getNumParams();
1797
+ $params = array();
1798
+ for($i = 0; $i < $numParams; $i++)
1799
+ {
1800
+ $params[$i] = $msg->getParam($i);
1801
+ }
1802
+ $call['params'] = new xmlrpcval($params, 'array');
1803
+ $calls[] = new xmlrpcval($call, 'struct');
1804
+ }
1805
+ $multicall = new xmlrpcmsg('system.multicall');
1806
+ $multicall->addParam(new xmlrpcval($calls, 'array'));
1807
+
1808
+ // Attempt RPC call
1809
+ $result =& $this->send($multicall, $timeout, $method);
1810
+
1811
+ if($result->faultCode() != 0)
1812
+ {
1813
+ // call to system.multicall failed
1814
+ return $result;
1815
+ }
1816
+
1817
+ // Unpack responses.
1818
+ $rets = $result->value();
1819
+
1820
+ if ($this->return_type == 'xml')
1821
+ {
1822
+ return $rets;
1823
+ }
1824
+ else if ($this->return_type == 'phpvals')
1825
+ {
1826
+ ///@todo test this code branch...
1827
+ $rets = $result->value();
1828
+ if(!is_array($rets))
1829
+ {
1830
+ return false; // bad return type from system.multicall
1831
+ }
1832
+ $numRets = count($rets);
1833
+ if($numRets != count($msgs))
1834
+ {
1835
+ return false; // wrong number of return values.
1836
+ }
1837
+
1838
+ $response = array();
1839
+ for($i = 0; $i < $numRets; $i++)
1840
+ {
1841
+ $val = $rets[$i];
1842
+ if (!is_array($val)) {
1843
+ return false;
1844
+ }
1845
+ switch(count($val))
1846
+ {
1847
+ case 1:
1848
+ if(!isset($val[0]))
1849
+ {
1850
+ return false; // Bad value
1851
+ }
1852
+ // Normal return value
1853
+ $response[$i] = new xmlrpcresp($val[0], 0, '', 'phpvals');
1854
+ break;
1855
+ case 2:
1856
+ /// @todo remove usage of @: it is apparently quite slow
1857
+ $code = @$val['faultCode'];
1858
+ if(!is_int($code))
1859
+ {
1860
+ return false;
1861
+ }
1862
+ $str = @$val['faultString'];
1863
+ if(!is_string($str))
1864
+ {
1865
+ return false;
1866
+ }
1867
+ $response[$i] = new xmlrpcresp(0, $code, $str);
1868
+ break;
1869
+ default:
1870
+ return false;
1871
+ }
1872
+ }
1873
+ return $response;
1874
+ }
1875
+ else // return type == 'xmlrpcvals'
1876
+ {
1877
+ $rets = $result->value();
1878
+ if($rets->kindOf() != 'array')
1879
+ {
1880
+ return false; // bad return type from system.multicall
1881
+ }
1882
+ $numRets = $rets->arraysize();
1883
+ if($numRets != count($msgs))
1884
+ {
1885
+ return false; // wrong number of return values.
1886
+ }
1887
+
1888
+ $response = array();
1889
+ for($i = 0; $i < $numRets; $i++)
1890
+ {
1891
+ $val = $rets->arraymem($i);
1892
+ switch($val->kindOf())
1893
+ {
1894
+ case 'array':
1895
+ if($val->arraysize() != 1)
1896
+ {
1897
+ return false; // Bad value
1898
+ }
1899
+ // Normal return value
1900
+ $response[$i] = new xmlrpcresp($val->arraymem(0));
1901
+ break;
1902
+ case 'struct':
1903
+ $code = $val->structmem('faultCode');
1904
+ if($code->kindOf() != 'scalar' || $code->scalartyp() != 'int')
1905
+ {
1906
+ return false;
1907
+ }
1908
+ $str = $val->structmem('faultString');
1909
+ if($str->kindOf() != 'scalar' || $str->scalartyp() != 'string')
1910
+ {
1911
+ return false;
1912
+ }
1913
+ $response[$i] = new xmlrpcresp(0, $code->scalarval(), $str->scalarval());
1914
+ break;
1915
+ default:
1916
+ return false;
1917
+ }
1918
+ }
1919
+ return $response;
1920
+ }
1921
+ }
1922
+ } // end class xmlrpc_client
1923
+
1924
+ class xmlrpcresp
1925
+ {
1926
+ var $val = 0;
1927
+ var $valtyp;
1928
+ var $errno = 0;
1929
+ var $errstr = '';
1930
+ var $payload;
1931
+ var $hdrs = array();
1932
+ var $_cookies = array();
1933
+ var $content_type = 'text/xml';
1934
+ var $raw_data = '';
1935
+
1936
+ /**
1937
+ * @param mixed $val either an xmlrpcval obj, a php value or the xml serialization of an xmlrpcval (a string)
1938
+ * @param integer $fcode set it to anything but 0 to create an error response
1939
+ * @param string $fstr the error string, in case of an error response
1940
+ * @param string $valtyp either 'xmlrpcvals', 'phpvals' or 'xml'
1941
+ *
1942
+ * @todo add check that $val / $fcode / $fstr is of correct type???
1943
+ * NB: as of now we do not do it, since it might be either an xmlrpcval or a plain
1944
+ * php val, or a complete xml chunk, depending on usage of xmlrpc_client::send() inside which creator is called...
1945
+ */
1946
+ function xmlrpcresp($val, $fcode = 0, $fstr = '', $valtyp='')
1947
+ {
1948
+ if($fcode != 0)
1949
+ {
1950
+ // error response
1951
+ $this->errno = $fcode;
1952
+ $this->errstr = $fstr;
1953
+ //$this->errstr = htmlspecialchars($fstr); // XXX: encoding probably shouldn't be done here; fix later.
1954
+ }
1955
+ else
1956
+ {
1957
+ // successful response
1958
+ $this->val = $val;
1959
+ if ($valtyp == '')
1960
+ {
1961
+ // user did not declare type of response value: try to guess it
1962
+ if (is_object($this->val) && ($this->val instanceof xmlrpcval))
1963
+ {
1964
+ $this->valtyp = 'xmlrpcvals';
1965
+ }
1966
+ else if (is_string($this->val))
1967
+ {
1968
+ $this->valtyp = 'xml';
1969
+
1970
+ }
1971
+ else
1972
+ {
1973
+ $this->valtyp = 'phpvals';
1974
+ }
1975
+ }
1976
+ else
1977
+ {
1978
+ // user declares type of resp value: believe him
1979
+ $this->valtyp = $valtyp;
1980
+ }
1981
+ }
1982
+ }
1983
+
1984
+ /**
1985
+ * Returns the error code of the response.
1986
+ * @return integer the error code of this response (0 for not-error responses)
1987
+ * @access public
1988
+ */
1989
+ function faultCode()
1990
+ {
1991
+ return $this->errno;
1992
+ }
1993
+
1994
+ /**
1995
+ * Returns the error code of the response.
1996
+ * @return string the error string of this response ('' for not-error responses)
1997
+ * @access public
1998
+ */
1999
+ function faultString()
2000
+ {
2001
+ return $this->errstr;
2002
+ }
2003
+
2004
+ /**
2005
+ * Returns the value received by the server.
2006
+ * @return mixed the xmlrpcval object returned by the server. Might be an xml string or php value if the response has been created by specially configured xmlrpc_client objects
2007
+ * @access public
2008
+ */
2009
+ function value()
2010
+ {
2011
+ return $this->val;
2012
+ }
2013
+
2014
+ /**
2015
+ * Returns an array with the cookies received from the server.
2016
+ * Array has the form: $cookiename => array ('value' => $val, $attr1 => $val1, $attr2 = $val2, ...)
2017
+ * with attributes being e.g. 'expires', 'path', domain'.
2018
+ * NB: cookies sent as 'expired' by the server (i.e. with an expiry date in the past)
2019
+ * are still present in the array. It is up to the user-defined code to decide
2020
+ * how to use the received cookies, and wheter they have to be sent back with the next
2021
+ * request to the server (using xmlrpc_client::setCookie) or not
2022
+ * @return array array of cookies received from the server
2023
+ * @access public
2024
+ */
2025
+ function cookies()
2026
+ {
2027
+ return $this->_cookies;
2028
+ }
2029
+
2030
+ /**
2031
+ * Returns xml representation of the response. XML prologue not included
2032
+ * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed
2033
+ * @return string the xml representation of the response
2034
+ * @access public
2035
+ */
2036
+ function serialize($charset_encoding='')
2037
+ {
2038
+ if ($charset_encoding != '')
2039
+ $this->content_type = 'text/xml; charset=' . $charset_encoding;
2040
+ else
2041
+ $this->content_type = 'text/xml';
2042
+ $result = "<methodResponse>\n";
2043
+ if($this->errno)
2044
+ {
2045
+ // G. Giunta 2005/2/13: let non-ASCII response messages be tolerated by clients
2046
+ // by xml-encoding non ascii chars
2047
+ $result .= "<fault>\n" .
2048
+ "<value>\n<struct><member><name>faultCode</name>\n<value><int>" . $this->errno .
2049
+ "</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" .
2050
+ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</string></value>\n</member>\n" .
2051
+ "</struct>\n</value>\n</fault>";
2052
+ }
2053
+ else
2054
+ {
2055
+ if(!is_object($this->val) || !($this->val instanceof xmlrpcval))
2056
+ {
2057
+ if (is_string($this->val) && $this->valtyp == 'xml')
2058
+ {
2059
+ $result .= "<params>\n<param>\n" .
2060
+ $this->val .
2061
+ "</param>\n</params>";
2062
+ }
2063
+ else
2064
+ {
2065
+ /// @todo try to build something serializable?
2066
+ die('cannot serialize xmlrpcresp objects whose content is native php values');
2067
+ }
2068
+ }
2069
+ else
2070
+ {
2071
+ $result .= "<params>\n<param>\n" .
2072
+ $this->val->serialize($charset_encoding) .
2073
+ "</param>\n</params>";
2074
+ }
2075
+ }
2076
+ $result .= "\n</methodResponse>";
2077
+ $this->payload = $result;
2078
+ return $result;
2079
+ }
2080
+ }
2081
+
2082
+ class xmlrpcmsg
2083
+ {
2084
+ var $payload;
2085
+ var $methodname;
2086
+ var $params=array();
2087
+ var $debug=0;
2088
+ var $content_type = 'text/xml';
2089
+
2090
+ /**
2091
+ * @param string $meth the name of the method to invoke
2092
+ * @param array $pars array of parameters to be paased to the method (xmlrpcval objects)
2093
+ */
2094
+ function xmlrpcmsg($meth, $pars=0)
2095
+ {
2096
+ $this->methodname=$meth;
2097
+ if(is_array($pars) && count($pars)>0)
2098
+ {
2099
+ for($i=0; $i<count($pars); $i++)
2100
+ {
2101
+ $this->addParam($pars[$i]);
2102
+ }
2103
+ }
2104
+ }
2105
+
2106
+ /**
2107
+ * @access private
2108
+ */
2109
+ function xml_header($charset_encoding='')
2110
+ {
2111
+ if ($charset_encoding != '')
2112
+ {
2113
+ return "<?xml version=\"1.0\" encoding=\"$charset_encoding\" ?" . ">\n<methodCall>\n";
2114
+ }
2115
+ else
2116
+ {
2117
+ return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n";
2118
+ }
2119
+ }
2120
+
2121
+ /**
2122
+ * @access private
2123
+ */
2124
+ function xml_footer()
2125
+ {
2126
+ return '</methodCall>';
2127
+ }
2128
+
2129
+ /**
2130
+ * @access private
2131
+ */
2132
+ function kindOf()
2133
+ {
2134
+ return 'msg';
2135
+ }
2136
+
2137
+ /**
2138
+ * @access private
2139
+ */
2140
+ function createPayload($charset_encoding='')
2141
+ {
2142
+ if ($charset_encoding != '')
2143
+ $this->content_type = 'text/xml; charset=' . $charset_encoding;
2144
+ else
2145
+ $this->content_type = 'text/xml';
2146
+ $this->payload=$this->xml_header($charset_encoding);
2147
+ $this->payload.='<methodName>' . $this->methodname . "</methodName>\n";
2148
+ $this->payload.="<params>\n";
2149
+ for($i=0; $i<count($this->params); $i++)
2150
+ {
2151
+ $p=$this->params[$i];
2152
+ $this->payload.="<param>\n" . $p->serialize($charset_encoding) .
2153
+ "</param>\n";
2154
+ }
2155
+ $this->payload.="</params>\n";
2156
+ $this->payload.=$this->xml_footer();
2157
+ }
2158
+
2159
+ /**
2160
+ * Gets/sets the xmlrpc method to be invoked
2161
+ * @param string $meth the method to be set (leave empty not to set it)
2162
+ * @return string the method that will be invoked
2163
+ * @access public
2164
+ */
2165
+ function method($meth='')
2166
+ {
2167
+ if($meth!='')
2168
+ {
2169
+ $this->methodname=$meth;
2170
+ }
2171
+ return $this->methodname;
2172
+ }
2173
+
2174
+ /**
2175
+ * Returns xml representation of the message. XML prologue included
2176
+ * @return string the xml representation of the message, xml prologue included
2177
+ * @access public
2178
+ */
2179
+ function serialize($charset_encoding='')
2180
+ {
2181
+ $this->createPayload($charset_encoding);
2182
+ return $this->payload;
2183
+ }
2184
+
2185
+ /**
2186
+ * Add a parameter to the list of parameters to be used upon method invocation
2187
+ * @param xmlrpcval $par
2188
+ * @return boolean false on failure
2189
+ * @access public
2190
+ */
2191
+ function addParam($par)
2192
+ {
2193
+ // add check: do not add to self params which are not xmlrpcvals
2194
+ if(is_object($par) && ($par instanceof xmlrpcval))
2195
+ {
2196
+ $this->params[]=$par;
2197
+ return true;
2198
+ }
2199
+ else
2200
+ {
2201
+ return false;
2202
+ }
2203
+ }
2204
+
2205
+ /**
2206
+ * Returns the nth parameter in the message. The index zero-based.
2207
+ * @param integer $i the index of the parameter to fetch (zero based)
2208
+ * @return xmlrpcval the i-th parameter
2209
+ * @access public
2210
+ */
2211
+ function getParam($i) { return $this->params[$i]; }
2212
+
2213
+ /**
2214
+ * Returns the number of parameters in the messge.
2215
+ * @return integer the number of parameters currently set
2216
+ * @access public
2217
+ */
2218
+ function getNumParams() { return count($this->params); }
2219
+
2220
+ /**
2221
+ * Given an open file handle, read all data available and parse it as axmlrpc response.
2222
+ * NB: the file handle is not closed by this function.
2223
+ * NNB: might have trouble in rare cases to work on network streams, as we
2224
+ * check for a read of 0 bytes instead of feof($fp).
2225
+ * But since checking for feof(null) returns false, we would risk an
2226
+ * infinite loop in that case, because we cannot trust the caller
2227
+ * to give us a valid pointer to an open file...
2228
+ * @access public
2229
+ * @return xmlrpcresp
2230
+ * @todo add 2nd & 3rd param to be passed to ParseResponse() ???
2231
+ */
2232
+ function &parseResponseFile($fp)
2233
+ {
2234
+ $ipd='';
2235
+ while($data=fread($fp, 32768))
2236
+ {
2237
+ $ipd.=$data;
2238
+ }
2239
+ //fclose($fp);
2240
+ $r =& $this->parseResponse($ipd);
2241
+ return $r;
2242
+ }
2243
+
2244
+ /**
2245
+ * Parses HTTP headers and separates them from data.
2246
+ * @access private
2247
+ */
2248
+ function &parseResponseHeaders(&$data, $headers_processed=false)
2249
+ {
2250
+ // Support "web-proxy-tunelling" connections for https through proxies
2251
+ if(preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data))
2252
+ {
2253
+ // Look for CR/LF or simple LF as line separator,
2254
+ // (even though it is not valid http)
2255
+ $pos = strpos($data,"\r\n\r\n");
2256
+ if($pos || is_int($pos))
2257
+ {
2258
+ $bd = $pos+4;
2259
+ }
2260
+ else
2261
+ {
2262
+ $pos = strpos($data,"\n\n");
2263
+ if($pos || is_int($pos))
2264
+ {
2265
+ $bd = $pos+2;
2266
+ }
2267
+ else
2268
+ {
2269
+ // No separation between response headers and body: fault?
2270
+ $bd = 0;
2271
+ }
2272
+ }
2273
+ if ($bd)
2274
+ {
2275
+ // this filters out all http headers from proxy.
2276
+ // maybe we could take them into account, too?
2277
+ $data = substr($data, $bd);
2278
+ }
2279
+ else
2280
+ {
2281
+ error_log('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed');
2282
+ $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (HTTPS via proxy error, tunnel connection possibly failed)');
2283
+ return $r;
2284
+ }
2285
+ }
2286
+
2287
+ // Strip HTTP 1.1 100 Continue header if present
2288
+ while(preg_match('/^HTTP\/1\.1 1[0-9]{2} /', $data))
2289
+ {
2290
+ $pos = strpos($data, 'HTTP', 12);
2291
+ // server sent a Continue header without any (valid) content following...
2292
+ // give the client a chance to know it
2293
+ if(!$pos && !is_int($pos)) // works fine in php 3, 4 and 5
2294
+ {
2295
+ break;
2296
+ }
2297
+ $data = substr($data, $pos);
2298
+ }
2299
+ if(!preg_match('/^HTTP\/[0-9.]+ 200 /', $data))
2300
+ {
2301
+ $errstr= substr($data, 0, strpos($data, "\n")-1);
2302
+ error_log('XML-RPC: '.__METHOD__.': HTTP error, got response: ' .$errstr);
2303
+ $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (' . $errstr . ')');
2304
+ return $r;
2305
+ }
2306
+
2307
+ $GLOBALS['_xh']['headers'] = array();
2308
+ $GLOBALS['_xh']['cookies'] = array();
2309
+
2310
+ // be tolerant to usage of \n instead of \r\n to separate headers and data
2311
+ // (even though it is not valid http)
2312
+ $pos = strpos($data,"\r\n\r\n");
2313
+ if($pos || is_int($pos))
2314
+ {
2315
+ $bd = $pos+4;
2316
+ }
2317
+ else
2318
+ {
2319
+ $pos = strpos($data,"\n\n");
2320
+ if($pos || is_int($pos))
2321
+ {
2322
+ $bd = $pos+2;
2323
+ }
2324
+ else
2325
+ {
2326
+ // No separation between response headers and body: fault?
2327
+ // we could take some action here instead of going on...
2328
+ $bd = 0;
2329
+ }
2330
+ }
2331
+ // be tolerant to line endings, and extra empty lines
2332
+ $ar = preg_split("/\r?\n/", trim(substr($data, 0, $pos)));
2333
+ while(list(,$line) = @each($ar))
2334
+ {
2335
+ // take care of multi-line headers and cookies
2336
+ $arr = explode(':',$line,2);
2337
+ if(count($arr) > 1)
2338
+ {
2339
+ $header_name = strtolower(trim($arr[0]));
2340
+ /// @todo some other headers (the ones that allow a CSV list of values)
2341
+ /// do allow many values to be passed using multiple header lines.
2342
+ /// We should add content to $GLOBALS['_xh']['headers'][$header_name]
2343
+ /// instead of replacing it for those...
2344
+ if ($header_name == 'set-cookie' || $header_name == 'set-cookie2')
2345
+ {
2346
+ if ($header_name == 'set-cookie2')
2347
+ {
2348
+ // version 2 cookies:
2349
+ // there could be many cookies on one line, comma separated
2350
+ $cookies = explode(',', $arr[1]);
2351
+ }
2352
+ else
2353
+ {
2354
+ $cookies = array($arr[1]);
2355
+ }
2356
+ foreach ($cookies as $cookie)
2357
+ {
2358
+ // glue together all received cookies, using a comma to separate them
2359
+ // (same as php does with getallheaders())
2360
+ if (isset($GLOBALS['_xh']['headers'][$header_name]))
2361
+ $GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie);
2362
+ else
2363
+ $GLOBALS['_xh']['headers'][$header_name] = trim($cookie);
2364
+ // parse cookie attributes, in case user wants to correctly honour them
2365
+ // feature creep: only allow rfc-compliant cookie attributes?
2366
+ // @todo support for server sending multiple time cookie with same name, but using different PATHs
2367
+ $cookie = explode(';', $cookie);
2368
+ foreach ($cookie as $pos => $val)
2369
+ {
2370
+ $val = explode('=', $val, 2);
2371
+ $tag = trim($val[0]);
2372
+ $val = trim(@$val[1]);
2373
+ /// @todo with version 1 cookies, we should strip leading and trailing " chars
2374
+ if ($pos == 0)
2375
+ {
2376
+ $cookiename = $tag;
2377
+ $GLOBALS['_xh']['cookies'][$tag] = array();
2378
+ $GLOBALS['_xh']['cookies'][$cookiename]['value'] = urldecode($val);
2379
+ }
2380
+ else
2381
+ {
2382
+ if ($tag != 'value')
2383
+ {
2384
+ $GLOBALS['_xh']['cookies'][$cookiename][$tag] = $val;
2385
+ }
2386
+ }
2387
+ }
2388
+ }
2389
+ }
2390
+ else
2391
+ {
2392
+ $GLOBALS['_xh']['headers'][$header_name] = trim($arr[1]);
2393
+ }
2394
+ }
2395
+ elseif(isset($header_name))
2396
+ {
2397
+ /// @todo version1 cookies might span multiple lines, thus breaking the parsing above
2398
+ $GLOBALS['_xh']['headers'][$header_name] .= ' ' . trim($line);
2399
+ }
2400
+ }
2401
+
2402
+ $data = substr($data, $bd);
2403
+
2404
+ if($this->debug && count($GLOBALS['_xh']['headers']))
2405
+ {
2406
+ print '<PRE>';
2407
+ foreach($GLOBALS['_xh']['headers'] as $header => $value)
2408
+ {
2409
+ print htmlentities("HEADER: $header: $value\n");
2410
+ }
2411
+ foreach($GLOBALS['_xh']['cookies'] as $header => $value)
2412
+ {
2413
+ print htmlentities("COOKIE: $header={$value['value']}\n");
2414
+ }
2415
+ print "</PRE>\n";
2416
+ }
2417
+
2418
+ // if CURL was used for the call, http headers have been processed,
2419
+ // and dechunking + reinflating have been carried out
2420
+ if(!$headers_processed)
2421
+ {
2422
+ // Decode chunked encoding sent by http 1.1 servers
2423
+ if(isset($GLOBALS['_xh']['headers']['transfer-encoding']) && $GLOBALS['_xh']['headers']['transfer-encoding'] == 'chunked')
2424
+ {
2425
+ if(!$data = decode_chunked($data))
2426
+ {
2427
+ error_log('XML-RPC: '.__METHOD__.': errors occurred when trying to rebuild the chunked data received from server');
2428
+ $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['dechunk_fail'], $GLOBALS['xmlrpcstr']['dechunk_fail']);
2429
+ return $r;
2430
+ }
2431
+ }
2432
+
2433
+ // Decode gzip-compressed stuff
2434
+ // code shamelessly inspired from nusoap library by Dietrich Ayala
2435
+ if(isset($GLOBALS['_xh']['headers']['content-encoding']))
2436
+ {
2437
+ $GLOBALS['_xh']['headers']['content-encoding'] = str_replace('x-', '', $GLOBALS['_xh']['headers']['content-encoding']);
2438
+ if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' || $GLOBALS['_xh']['headers']['content-encoding'] == 'gzip')
2439
+ {
2440
+ // if decoding works, use it. else assume data wasn't gzencoded
2441
+ if(function_exists('gzinflate'))
2442
+ {
2443
+ if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data))
2444
+ {
2445
+ $data = $degzdata;
2446
+ if($this->debug)
2447
+ print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2448
+ }
2449
+ elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10)))
2450
+ {
2451
+ $data = $degzdata;
2452
+ if($this->debug)
2453
+ print "<PRE>---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END---</PRE>";
2454
+ }
2455
+ else
2456
+ {
2457
+ error_log('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server');
2458
+ $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['decompress_fail'], $GLOBALS['xmlrpcstr']['decompress_fail']);
2459
+ return $r;
2460
+ }
2461
+ }
2462
+ else
2463
+ {
2464
+ error_log('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
2465
+ $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['cannot_decompress'], $GLOBALS['xmlrpcstr']['cannot_decompress']);
2466
+ return $r;
2467
+ }
2468
+ }
2469
+ }
2470
+ } // end of 'if needed, de-chunk, re-inflate response'
2471
+
2472
+ // real stupid hack to avoid PHP complaining about returning NULL by ref
2473
+ $r = null;
2474
+ $r =& $r;
2475
+ return $r;
2476
+ }
2477
+
2478
+ /**
2479
+ * Parse the xmlrpc response contained in the string $data and return an xmlrpcresp object.
2480
+ * @param string $data the xmlrpc response, eventually including http headers
2481
+ * @param bool $headers_processed when true prevents parsing HTTP headers for interpretation of content-encoding and consequent decoding
2482
+ * @param string $return_type decides return type, i.e. content of response->value(). Either 'xmlrpcvals', 'xml' or 'phpvals'
2483
+ * @return xmlrpcresp
2484
+ * @access public
2485
+ */
2486
+ function &parseResponse($data='', $headers_processed=false, $return_type='xmlrpcvals')
2487
+ {
2488
+ if($this->debug)
2489
+ {
2490
+ //by maHo, replaced htmlspecialchars with htmlentities
2491
+ print "<PRE>---GOT---\n" . htmlentities($data) . "\n---END---\n</PRE>";
2492
+ }
2493
+
2494
+ if($data == '')
2495
+ {
2496
+ error_log('XML-RPC: '.__METHOD__.': no response received from server.');
2497
+ $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_data'], $GLOBALS['xmlrpcstr']['no_data']);
2498
+ return $r;
2499
+ }
2500
+
2501
+ $GLOBALS['_xh']=array();
2502
+
2503
+ $raw_data = $data;
2504
+ // parse the HTTP headers of the response, if present, and separate them from data
2505
+ if(substr($data, 0, 4) == 'HTTP')
2506
+ {
2507
+ $r =& $this->parseResponseHeaders($data, $headers_processed);
2508
+ if ($r)
2509
+ {
2510
+ // failed processing of HTTP response headers
2511
+ // save into response obj the full payload received, for debugging
2512
+ $r->raw_data = $data;
2513
+ return $r;
2514
+ }
2515
+ }
2516
+ else
2517
+ {
2518
+ $GLOBALS['_xh']['headers'] = array();
2519
+ $GLOBALS['_xh']['cookies'] = array();
2520
+ }
2521
+
2522
+ if($this->debug)
2523
+ {
2524
+ $start = strpos($data, '<!-- SERVER DEBUG INFO (BASE64 ENCODED):');
2525
+ if ($start)
2526
+ {
2527
+ $start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):');
2528
+ $end = strpos($data, '-->', $start);
2529
+ $comments = substr($data, $start, $end-$start);
2530
+ print "<PRE>---SERVER DEBUG INFO (DECODED) ---\n\t".htmlentities(str_replace("\n", "\n\t", base64_decode($comments)))."\n---END---\n</PRE>";
2531
+ }
2532
+ }
2533
+
2534
+ // be tolerant of extra whitespace in response body
2535
+ $data = trim($data);
2536
+
2537
+ /// @todo return an error msg if $data=='' ?
2538
+
2539
+ // be tolerant of junk after methodResponse (e.g. javascript ads automatically inserted by free hosts)
2540
+ // idea from Luca Mariano <luca.mariano@email.it> originally in PEARified version of the lib
2541
+ $pos = strrpos($data, '</methodResponse>');
2542
+ if($pos !== false)
2543
+ {
2544
+ $data = substr($data, 0, $pos+17);
2545
+ }
2546
+
2547
+ // if user wants back raw xml, give it to him
2548
+ if ($return_type == 'xml')
2549
+ {
2550
+ $r = new xmlrpcresp($data, 0, '', 'xml');
2551
+ $r->hdrs = $GLOBALS['_xh']['headers'];
2552
+ $r->_cookies = $GLOBALS['_xh']['cookies'];
2553
+ $r->raw_data = $raw_data;
2554
+ return $r;
2555
+ }
2556
+
2557
+ // try to 'guestimate' the character encoding of the received response
2558
+ $resp_encoding = guess_encoding(@$GLOBALS['_xh']['headers']['content-type'], $data);
2559
+
2560
+ $GLOBALS['_xh']['ac']='';
2561
+ //$GLOBALS['_xh']['qt']=''; //unused...
2562
+ $GLOBALS['_xh']['stack'] = array();
2563
+ $GLOBALS['_xh']['valuestack'] = array();
2564
+ $GLOBALS['_xh']['isf']=0; // 0 = OK, 1 for xmlrpc fault responses, 2 = invalid xmlrpc
2565
+ $GLOBALS['_xh']['isf_reason']='';
2566
+ $GLOBALS['_xh']['rt']=''; // 'methodcall or 'methodresponse'
2567
+
2568
+ // if response charset encoding is not known / supported, try to use
2569
+ // the default encoding and parse the xml anyway, but log a warning...
2570
+ if (!in_array($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
2571
+ // the following code might be better for mb_string enabled installs, but
2572
+ // makes the lib about 200% slower...
2573
+ //if (!is_valid_charset($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
2574
+ {
2575
+ error_log('XML-RPC: '.__METHOD__.': invalid charset encoding of received response: '.$resp_encoding);
2576
+ $resp_encoding = $GLOBALS['xmlrpc_defencoding'];
2577
+ }
2578
+ $parser = xml_parser_create($resp_encoding);
2579
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
2580
+ // G. Giunta 2005/02/13: PHP internally uses ISO-8859-1, so we have to tell
2581
+ // the xml parser to give us back data in the expected charset.
2582
+ // What if internal encoding is not in one of the 3 allowed?
2583
+ // we use the broadest one, ie. utf8
2584
+ // This allows to send data which is native in various charset,
2585
+ // by extending xmlrpc_encode_entitites() and setting xmlrpc_internalencoding
2586
+ if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
2587
+ {
2588
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
2589
+ }
2590
+ else
2591
+ {
2592
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
2593
+ }
2594
+
2595
+ if ($return_type == 'phpvals')
2596
+ {
2597
+ xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast');
2598
+ }
2599
+ else
2600
+ {
2601
+ xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
2602
+ }
2603
+
2604
+ xml_set_character_data_handler($parser, 'xmlrpc_cd');
2605
+ xml_set_default_handler($parser, 'xmlrpc_dh');
2606
+
2607
+ // first error check: xml not well formed
2608
+ if(!xml_parse($parser, $data, count($data)))
2609
+ {
2610
+ // thanks to Peter Kocks <peter.kocks@baygate.com>
2611
+ if((xml_get_current_line_number($parser)) == 1)
2612
+ {
2613
+ $errstr = 'XML error at line 1, check URL';
2614
+ }
2615
+ else
2616
+ {
2617
+ $errstr = sprintf('XML error: %s at line %d, column %d',
2618
+ xml_error_string(xml_get_error_code($parser)),
2619
+ xml_get_current_line_number($parser), xml_get_current_column_number($parser));
2620
+ }
2621
+ error_log($errstr);
2622
+ $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], $GLOBALS['xmlrpcstr']['invalid_return'].' ('.$errstr.')');
2623
+ xml_parser_free($parser);
2624
+ if($this->debug)
2625
+ {
2626
+ print $errstr;
2627
+ }
2628
+ $r->hdrs = $GLOBALS['_xh']['headers'];
2629
+ $r->_cookies = $GLOBALS['_xh']['cookies'];
2630
+ $r->raw_data = $raw_data;
2631
+ return $r;
2632
+ }
2633
+ xml_parser_free($parser);
2634
+ // second error check: xml well formed but not xml-rpc compliant
2635
+ if ($GLOBALS['_xh']['isf'] > 1)
2636
+ {
2637
+ if ($this->debug)
2638
+ {
2639
+ /// @todo echo something for user?
2640
+ }
2641
+
2642
+ $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'],
2643
+ $GLOBALS['xmlrpcstr']['invalid_return'] . ' ' . $GLOBALS['_xh']['isf_reason']);
2644
+ }
2645
+ // third error check: parsing of the response has somehow gone boink.
2646
+ // NB: shall we omit this check, since we trust the parsing code?
2647
+ elseif ($return_type == 'xmlrpcvals' && !is_object($GLOBALS['_xh']['value']))
2648
+ {
2649
+ // something odd has happened
2650
+ // and it's time to generate a client side error
2651
+ // indicating something odd went on
2652
+ $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'],
2653
+ $GLOBALS['xmlrpcstr']['invalid_return']);
2654
+ }
2655
+ else
2656
+ {
2657
+ if ($this->debug)
2658
+ {
2659
+ print "<PRE>---PARSED---\n";
2660
+ // somehow htmlentities chokes on var_export, and some full html string...
2661
+ //print htmlentitites(var_export($GLOBALS['_xh']['value'], true));
2662
+ print htmlspecialchars(var_export($GLOBALS['_xh']['value'], true));
2663
+ print "\n---END---</PRE>";
2664
+ }
2665
+
2666
+ // note that using =& will raise an error if $GLOBALS['_xh']['st'] does not generate an object.
2667
+ $v =& $GLOBALS['_xh']['value'];
2668
+
2669
+ if($GLOBALS['_xh']['isf'])
2670
+ {
2671
+ /// @todo we should test here if server sent an int and a string,
2672
+ /// and/or coerce them into such...
2673
+ if ($return_type == 'xmlrpcvals')
2674
+ {
2675
+ $errno_v = $v->structmem('faultCode');
2676
+ $errstr_v = $v->structmem('faultString');
2677
+ $errno = $errno_v->scalarval();
2678
+ $errstr = $errstr_v->scalarval();
2679
+ }
2680
+ else
2681
+ {
2682
+ $errno = $v['faultCode'];
2683
+ $errstr = $v['faultString'];
2684
+ }
2685
+
2686
+ if($errno == 0)
2687
+ {
2688
+ // FAULT returned, errno needs to reflect that
2689
+ $errno = -1;
2690
+ }
2691
+
2692
+ $r = new xmlrpcresp(0, $errno, $errstr);
2693
+ }
2694
+ else
2695
+ {
2696
+ $r=new xmlrpcresp($v, 0, '', $return_type);
2697
+ }
2698
+ }
2699
+
2700
+ $r->hdrs = $GLOBALS['_xh']['headers'];
2701
+ $r->_cookies = $GLOBALS['_xh']['cookies'];
2702
+ $r->raw_data = $raw_data;
2703
+ return $r;
2704
+ }
2705
+ }
2706
+
2707
+ class xmlrpcval
2708
+ {
2709
+ var $me=array();
2710
+ var $mytype=0;
2711
+ var $_php_class=null;
2712
+
2713
+ /**
2714
+ * @param mixed $val
2715
+ * @param string $type any valid xmlrpc type name (lowercase). If null, 'string' is assumed
2716
+ */
2717
+ function xmlrpcval($val=-1, $type='')
2718
+ {
2719
+ /// @todo: optimization creep - do not call addXX, do it all inline.
2720
+ /// downside: booleans will not be coerced anymore
2721
+ if($val!==-1 || $type!='')
2722
+ {
2723
+ // optimization creep: inlined all work done by constructor
2724
+ switch($type)
2725
+ {
2726
+ case '':
2727
+ $this->mytype=1;
2728
+ $this->me['string']=$val;
2729
+ break;
2730
+ case 'i4':
2731
+ case 'int':
2732
+ case 'double':
2733
+ case 'string':
2734
+ case 'boolean':
2735
+ case 'dateTime.iso8601':
2736
+ case 'base64':
2737
+ case 'null':
2738
+ $this->mytype=1;
2739
+ $this->me[$type]=$val;
2740
+ break;
2741
+ case 'array':
2742
+ $this->mytype=2;
2743
+ $this->me['array']=$val;
2744
+ break;
2745
+ case 'struct':
2746
+ $this->mytype=3;
2747
+ $this->me['struct']=$val;
2748
+ break;
2749
+ default:
2750
+ error_log("XML-RPC: ".__METHOD__.": not a known type ($type)");
2751
+ }
2752
+ /*if($type=='')
2753
+ {
2754
+ $type='string';
2755
+ }
2756
+ if($GLOBALS['xmlrpcTypes'][$type]==1)
2757
+ {
2758
+ $this->addScalar($val,$type);
2759
+ }
2760
+ elseif($GLOBALS['xmlrpcTypes'][$type]==2)
2761
+ {
2762
+ $this->addArray($val);
2763
+ }
2764
+ elseif($GLOBALS['xmlrpcTypes'][$type]==3)
2765
+ {
2766
+ $this->addStruct($val);
2767
+ }*/
2768
+ }
2769
+ }
2770
+
2771
+ /**
2772
+ * Add a single php value to an (unitialized) xmlrpcval
2773
+ * @param mixed $val
2774
+ * @param string $type
2775
+ * @return int 1 or 0 on failure
2776
+ */
2777
+ function addScalar($val, $type='string')
2778
+ {
2779
+ $typeof=@$GLOBALS['xmlrpcTypes'][$type];
2780
+ if($typeof!=1)
2781
+ {
2782
+ error_log("XML-RPC: ".__METHOD__.": not a scalar type ($type)");
2783
+ return 0;
2784
+ }
2785
+
2786
+ // coerce booleans into correct values
2787
+ // NB: we should either do it for datetimes, integers and doubles, too,
2788
+ // or just plain remove this check, implemented on booleans only...
2789
+ if($type==$GLOBALS['xmlrpcBoolean'])
2790
+ {
2791
+ if(strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false')))
2792
+ {
2793
+ $val=true;
2794
+ }
2795
+ else
2796
+ {
2797
+ $val=false;
2798
+ }
2799
+ }
2800
+
2801
+ switch($this->mytype)
2802
+ {
2803
+ case 1:
2804
+ error_log('XML-RPC: '.__METHOD__.': scalar xmlrpcval can have only one value');
2805
+ return 0;
2806
+ case 3:
2807
+ error_log('XML-RPC: '.__METHOD__.': cannot add anonymous scalar to struct xmlrpcval');
2808
+ return 0;
2809
+ case 2:
2810
+ // we're adding a scalar value to an array here
2811
+ //$ar=$this->me['array'];
2812
+ //$ar[]=new xmlrpcval($val, $type);
2813
+ //$this->me['array']=$ar;
2814
+ // Faster (?) avoid all the costly array-copy-by-val done here...
2815
+ $this->me['array'][]=new xmlrpcval($val, $type);
2816
+ return 1;
2817
+ default:
2818
+ // a scalar, so set the value and remember we're scalar
2819
+ $this->me[$type]=$val;
2820
+ $this->mytype=$typeof;
2821
+ return 1;
2822
+ }
2823
+ }
2824
+
2825
+ /**
2826
+ * Add an array of xmlrpcval objects to an xmlrpcval
2827
+ * @param array $vals
2828
+ * @return int 1 or 0 on failure
2829
+ * @access public
2830
+ *
2831
+ * @todo add some checking for $vals to be an array of xmlrpcvals?
2832
+ */
2833
+ function addArray($vals)
2834
+ {
2835
+ if($this->mytype==0)
2836
+ {
2837
+ $this->mytype=$GLOBALS['xmlrpcTypes']['array'];
2838
+ $this->me['array']=$vals;
2839
+ return 1;
2840
+ }
2841
+ elseif($this->mytype==2)
2842
+ {
2843
+ // we're adding to an array here
2844
+ $this->me['array'] = array_merge($this->me['array'], $vals);
2845
+ return 1;
2846
+ }
2847
+ else
2848
+ {
2849
+ error_log('XML-RPC: '.__METHOD__.': already initialized as a [' . $this->kindOf() . ']');
2850
+ return 0;
2851
+ }
2852
+ }
2853
+
2854
+ /**
2855
+ * Add an array of named xmlrpcval objects to an xmlrpcval
2856
+ * @param array $vals
2857
+ * @return int 1 or 0 on failure
2858
+ * @access public
2859
+ *
2860
+ * @todo add some checking for $vals to be an array?
2861
+ */
2862
+ function addStruct($vals)
2863
+ {
2864
+ if($this->mytype==0)
2865
+ {
2866
+ $this->mytype=$GLOBALS['xmlrpcTypes']['struct'];
2867
+ $this->me['struct']=$vals;
2868
+ return 1;
2869
+ }
2870
+ elseif($this->mytype==3)
2871
+ {
2872
+ // we're adding to a struct here
2873
+ $this->me['struct'] = array_merge($this->me['struct'], $vals);
2874
+ return 1;
2875
+ }
2876
+ else
2877
+ {
2878
+ error_log('XML-RPC: '.__METHOD__.': already initialized as a [' . $this->kindOf() . ']');
2879
+ return 0;
2880
+ }
2881
+ }
2882
+
2883
+ // poor man's version of print_r ???
2884
+ // DEPRECATED!
2885
+ function dump($ar)
2886
+ {
2887
+ foreach($ar as $key => $val)
2888
+ {
2889
+ echo "$key => $val<br />";
2890
+ if($key == 'array')
2891
+ {
2892
+ while(list($key2, $val2) = each($val))
2893
+ {
2894
+ echo "-- $key2 => $val2<br />";
2895
+ }
2896
+ }
2897
+ }
2898
+ }
2899
+
2900
+ /**
2901
+ * Returns a string containing "struct", "array" or "scalar" describing the base type of the value
2902
+ * @return string
2903
+ * @access public
2904
+ */
2905
+ function kindOf()
2906
+ {
2907
+ switch($this->mytype)
2908
+ {
2909
+ case 3:
2910
+ return 'struct';
2911
+ break;
2912
+ case 2:
2913
+ return 'array';
2914
+ break;
2915
+ case 1:
2916
+ return 'scalar';
2917
+ break;
2918
+ default:
2919
+ return 'undef';
2920
+ }
2921
+ }
2922
+
2923
+ /**
2924
+ * @access private
2925
+ */
2926
+ function serializedata($typ, $val, $charset_encoding='')
2927
+ {
2928
+ $rs='';
2929
+ switch(@$GLOBALS['xmlrpcTypes'][$typ])
2930
+ {
2931
+ case 1:
2932
+ switch($typ)
2933
+ {
2934
+ case $GLOBALS['xmlrpcBase64']:
2935
+ $rs.="<${typ}>" . base64_encode($val) . "</${typ}>";
2936
+ break;
2937
+ case $GLOBALS['xmlrpcBoolean']:
2938
+ $rs.="<${typ}>" . ($val ? '1' : '0') . "</${typ}>";
2939
+ break;
2940
+ case $GLOBALS['xmlrpcString']:
2941
+ // G. Giunta 2005/2/13: do NOT use htmlentities, since
2942
+ // it will produce named html entities, which are invalid xml
2943
+ $rs.="<${typ}>" . xmlrpc_encode_entitites($val, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding). "</${typ}>";
2944
+ break;
2945
+ case $GLOBALS['xmlrpcInt']:
2946
+ case $GLOBALS['xmlrpcI4']:
2947
+ $rs.="<${typ}>".(int)$val."</${typ}>";
2948
+ break;
2949
+ case $GLOBALS['xmlrpcDouble']:
2950
+ // avoid using standard conversion of float to string because it is locale-dependent,
2951
+ // and also because the xmlrpc spec forbids exponential notation.
2952
+ // sprintf('%F') could be most likely ok but it fails eg. on 2e-14.
2953
+ // The code below tries its best at keeping max precision while avoiding exp notation,
2954
+ // but there is of course no limit in the number of decimal places to be used...
2955
+ $rs.="<${typ}>".preg_replace('/\\.?0+$/','',number_format((double)$val, 128, '.', ''))."</${typ}>";
2956
+ break;
2957
+ case $GLOBALS['xmlrpcDateTime']:
2958
+ if (is_string($val))
2959
+ {
2960
+ $rs.="<${typ}>${val}</${typ}>";
2961
+ }
2962
+ else if($val instanceof DateTime)
2963
+ {
2964
+ $rs.="<${typ}>".$val->format('Ymd\TH:i:s')."</${typ}>";
2965
+ }
2966
+ else if(is_int($val))
2967
+ {
2968
+ $rs.="<${typ}>".strftime("%Y%m%dT%H:%M:%S", $val)."</${typ}>";
2969
+ }
2970
+ else
2971
+ {
2972
+ // not really a good idea here: but what shall we output anyway? left for backward compat...
2973
+ $rs.="<${typ}>${val}</${typ}>";
2974
+ }
2975
+ break;
2976
+ case $GLOBALS['xmlrpcNull']:
2977
+ if ($GLOBALS['xmlrpc_null_apache_encoding'])
2978
+ {
2979
+ $rs.="<ex:nil/>";
2980
+ }
2981
+ else
2982
+ {
2983
+ $rs.="<nil/>";
2984
+ }
2985
+ break;
2986
+ default:
2987
+ // no standard type value should arrive here, but provide a possibility
2988
+ // for xmlrpcvals of unknown type...
2989
+ $rs.="<${typ}>${val}</${typ}>";
2990
+ }
2991
+ break;
2992
+ case 3:
2993
+ // struct
2994
+ if ($this->_php_class)
2995
+ {
2996
+ $rs.='<struct php_class="' . $this->_php_class . "\">\n";
2997
+ }
2998
+ else
2999
+ {
3000
+ $rs.="<struct>\n";
3001
+ }
3002
+ foreach($val as $key2 => $val2)
3003
+ {
3004
+ $rs.='<member><name>'.xmlrpc_encode_entitites($key2, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)."</name>\n";
3005
+ //$rs.=$this->serializeval($val2);
3006
+ $rs.=$val2->serialize($charset_encoding);
3007
+ $rs.="</member>\n";
3008
+ }
3009
+ $rs.='</struct>';
3010
+ break;
3011
+ case 2:
3012
+ // array
3013
+ $rs.="<array>\n<data>\n";
3014
+ for($i=0; $i<count($val); $i++)
3015
+ {
3016
+ //$rs.=$this->serializeval($val[$i]);
3017
+ $rs.=$val[$i]->serialize($charset_encoding);
3018
+ }
3019
+ $rs.="</data>\n</array>";
3020
+ break;
3021
+ default:
3022
+ break;
3023
+ }
3024
+ return $rs;
3025
+ }
3026
+
3027
+ /**
3028
+ * Returns xml representation of the value. XML prologue not included
3029
+ * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed
3030
+ * @return string
3031
+ * @access public
3032
+ */
3033
+ function serialize($charset_encoding='')
3034
+ {
3035
+ // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals...
3036
+ //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
3037
+ //{
3038
+ reset($this->me);
3039
+ list($typ, $val) = each($this->me);
3040
+ return '<value>' . $this->serializedata($typ, $val, $charset_encoding) . "</value>\n";
3041
+ //}
3042
+ }
3043
+
3044
+ // DEPRECATED
3045
+ function serializeval($o)
3046
+ {
3047
+ // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals...
3048
+ //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
3049
+ //{
3050
+ $ar=$o->me;
3051
+ reset($ar);
3052
+ list($typ, $val) = each($ar);
3053
+ return '<value>' . $this->serializedata($typ, $val) . "</value>\n";
3054
+ //}
3055
+ }
3056
+
3057
+ /**
3058
+ * Checks wheter a struct member with a given name is present.
3059
+ * Works only on xmlrpcvals of type struct.
3060
+ * @param string $m the name of the struct member to be looked up
3061
+ * @return boolean
3062
+ * @access public
3063
+ */
3064
+ function structmemexists($m)
3065
+ {
3066
+ return array_key_exists($m, $this->me['struct']);
3067
+ }
3068
+
3069
+ /**
3070
+ * Returns the value of a given struct member (an xmlrpcval object in itself).
3071
+ * Will raise a php warning if struct member of given name does not exist
3072
+ * @param string $m the name of the struct member to be looked up
3073
+ * @return xmlrpcval
3074
+ * @access public
3075
+ */
3076
+ function structmem($m)
3077
+ {
3078
+ return $this->me['struct'][$m];
3079
+ }
3080
+
3081
+ /**
3082
+ * Reset internal pointer for xmlrpcvals of type struct.
3083
+ * @access public
3084
+ */
3085
+ function structreset()
3086
+ {
3087
+ reset($this->me['struct']);
3088
+ }
3089
+
3090
+ /**
3091
+ * Return next member element for xmlrpcvals of type struct.
3092
+ * @return xmlrpcval
3093
+ * @access public
3094
+ */
3095
+ function structeach()
3096
+ {
3097
+ return each($this->me['struct']);
3098
+ }
3099
+
3100
+ // DEPRECATED! this code looks like it is very fragile and has not been fixed
3101
+ // for a long long time. Shall we remove it for 2.0?
3102
+ function getval()
3103
+ {
3104
+ // UNSTABLE
3105
+ reset($this->me);
3106
+ list($a,$b)=each($this->me);
3107
+ // contributed by I Sofer, 2001-03-24
3108
+ // add support for nested arrays to scalarval
3109
+ // i've created a new method here, so as to
3110
+ // preserve back compatibility
3111
+
3112
+ if(is_array($b))
3113
+ {
3114
+ @reset($b);
3115
+ while(list($id,$cont) = @each($b))
3116
+ {
3117
+ $b[$id] = $cont->scalarval();
3118
+ }
3119
+ }
3120
+
3121
+ // add support for structures directly encoding php objects
3122
+ if(is_object($b))
3123
+ {
3124
+ $t = get_object_vars($b);
3125
+ @reset($t);
3126
+ while(list($id,$cont) = @each($t))
3127
+ {
3128
+ $t[$id] = $cont->scalarval();
3129
+ }
3130
+ @reset($t);
3131
+ while(list($id,$cont) = @each($t))
3132
+ {
3133
+ @$b->$id = $cont;
3134
+ }
3135
+ }
3136
+ // end contrib
3137
+ return $b;
3138
+ }
3139
+
3140
+ /**
3141
+ * Returns the value of a scalar xmlrpcval
3142
+ * @return mixed
3143
+ * @access public
3144
+ */
3145
+ function scalarval()
3146
+ {
3147
+ reset($this->me);
3148
+ list(,$b)=each($this->me);
3149
+ return $b;
3150
+ }
3151
+
3152
+ /**
3153
+ * Returns the type of the xmlrpcval.
3154
+ * For integers, 'int' is always returned in place of 'i4'
3155
+ * @return string
3156
+ * @access public
3157
+ */
3158
+ function scalartyp()
3159
+ {
3160
+ reset($this->me);
3161
+ list($a,)=each($this->me);
3162
+ if($a==$GLOBALS['xmlrpcI4'])
3163
+ {
3164
+ $a=$GLOBALS['xmlrpcInt'];
3165
+ }
3166
+ return $a;
3167
+ }
3168
+
3169
+ /**
3170
+ * Returns the m-th member of an xmlrpcval of struct type
3171
+ * @param integer $m the index of the value to be retrieved (zero based)
3172
+ * @return xmlrpcval
3173
+ * @access public
3174
+ */
3175
+ function arraymem($m)
3176
+ {
3177
+ return $this->me['array'][$m];
3178
+ }
3179
+
3180
+ /**
3181
+ * Returns the number of members in an xmlrpcval of array type
3182
+ * @return integer
3183
+ * @access public
3184
+ */
3185
+ function arraysize()
3186
+ {
3187
+ return count($this->me['array']);
3188
+ }
3189
+
3190
+ /**
3191
+ * Returns the number of members in an xmlrpcval of struct type
3192
+ * @return integer
3193
+ * @access public
3194
+ */
3195
+ function structsize()
3196
+ {
3197
+ return count($this->me['struct']);
3198
+ }
3199
+ }
3200
+
3201
+
3202
+ // date helpers
3203
+
3204
+ /**
3205
+ * Given a timestamp, return the corresponding ISO8601 encoded string.
3206
+ *
3207
+ * Really, timezones ought to be supported
3208
+ * but the XML-RPC spec says:
3209
+ *
3210
+ * "Don't assume a timezone. It should be specified by the server in its
3211
+ * documentation what assumptions it makes about timezones."
3212
+ *
3213
+ * These routines always assume localtime unless
3214
+ * $utc is set to 1, in which case UTC is assumed
3215
+ * and an adjustment for locale is made when encoding
3216
+ *
3217
+ * @param int $timet (timestamp)
3218
+ * @param int $utc (0 or 1)
3219
+ * @return string
3220
+ */
3221
+ function iso8601_encode($timet, $utc=0)
3222
+ {
3223
+ if(!$utc)
3224
+ {
3225
+ $t=strftime("%Y%m%dT%H:%M:%S", $timet);
3226
+ }
3227
+ else
3228
+ {
3229
+ if(function_exists('gmstrftime'))
3230
+ {
3231
+ // gmstrftime doesn't exist in some versions
3232
+ // of PHP
3233
+ $t=gmstrftime("%Y%m%dT%H:%M:%S", $timet);
3234
+ }
3235
+ else
3236
+ {
3237
+ $t=strftime("%Y%m%dT%H:%M:%S", $timet-date('Z'));
3238
+ }
3239
+ }
3240
+ return $t;
3241
+ }
3242
+
3243
+ /**
3244
+ * Given an ISO8601 date string, return a timet in the localtime, or UTC
3245
+ * @param string $idate
3246
+ * @param int $utc either 0 or 1
3247
+ * @return int (datetime)
3248
+ */
3249
+ function iso8601_decode($idate, $utc=0)
3250
+ {
3251
+ $t=0;
3252
+ if(preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $idate, $regs))
3253
+ {
3254
+ if($utc)
3255
+ {
3256
+ $t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
3257
+ }
3258
+ else
3259
+ {
3260
+ $t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
3261
+ }
3262
+ }
3263
+ return $t;
3264
+ }
3265
+
3266
+ /**
3267
+ * Takes an xmlrpc value in PHP xmlrpcval object format and translates it into native PHP types.
3268
+ *
3269
+ * Works with xmlrpc message objects as input, too.
3270
+ *
3271
+ * Given proper options parameter, can rebuild generic php object instances
3272
+ * (provided those have been encoded to xmlrpc format using a corresponding
3273
+ * option in php_xmlrpc_encode())
3274
+ * PLEASE NOTE that rebuilding php objects involves calling their constructor function.
3275
+ * This means that the remote communication end can decide which php code will
3276
+ * get executed on your server, leaving the door possibly open to 'php-injection'
3277
+ * style of attacks (provided you have some classes defined on your server that
3278
+ * might wreak havoc if instances are built outside an appropriate context).
3279
+ * Make sure you trust the remote server/client before eanbling this!
3280
+ *
3281
+ * @author Dan Libby (dan@libby.com)
3282
+ *
3283
+ * @param xmlrpcval $xmlrpc_val
3284
+ * @param array $options if 'decode_php_objs' is set in the options array, xmlrpc structs can be decoded into php objects; if 'dates_as_objects' is set xmlrpc datetimes are decoded as php DateTime objects (standard is
3285
+ * @return mixed
3286
+ */
3287
+ function php_xmlrpc_decode($xmlrpc_val, $options=array())
3288
+ {
3289
+ switch($xmlrpc_val->kindOf())
3290
+ {
3291
+ case 'scalar':
3292
+ if (in_array('extension_api', $options))
3293
+ {
3294
+ reset($xmlrpc_val->me);
3295
+ list($typ,$val) = each($xmlrpc_val->me);
3296
+ switch ($typ)
3297
+ {
3298
+ case 'dateTime.iso8601':
3299
+ $xmlrpc_val->scalar = $val;
3300
+ $xmlrpc_val->xmlrpc_type = 'datetime';
3301
+ $xmlrpc_val->timestamp = iso8601_decode($val);
3302
+ return $xmlrpc_val;
3303
+ case 'base64':
3304
+ $xmlrpc_val->scalar = $val;
3305
+ $xmlrpc_val->type = $typ;
3306
+ return $xmlrpc_val;
3307
+ default:
3308
+ return $xmlrpc_val->scalarval();
3309
+ }
3310
+ }
3311
+ if (in_array('dates_as_objects', $options) && $xmlrpc_val->scalartyp() == 'dateTime.iso8601')
3312
+ {
3313
+ // we return a Datetime object instead of a string
3314
+ // since now the constructor of xmlrpcval accepts safely strings, ints and datetimes,
3315
+ // we cater to all 3 cases here
3316
+ $out = $xmlrpc_val->scalarval();
3317
+ if (is_string($out))
3318
+ {
3319
+ $out = strtotime($out);
3320
+ }
3321
+ if (is_int($out))
3322
+ {
3323
+ $result = new Datetime();
3324
+ $result->setTimestamp($out);
3325
+ return $result;
3326
+ }
3327
+ elseif ($out instanceof Datetime)
3328
+ {
3329
+ return $out;
3330
+ }
3331
+ }
3332
+ return $xmlrpc_val->scalarval();
3333
+ case 'array':
3334
+ $size = $xmlrpc_val->arraysize();
3335
+ $arr = array();
3336
+ for($i = 0; $i < $size; $i++)
3337
+ {
3338
+ $arr[] = php_xmlrpc_decode($xmlrpc_val->arraymem($i), $options);
3339
+ }
3340
+ return $arr;
3341
+ case 'struct':
3342
+ $xmlrpc_val->structreset();
3343
+ // If user said so, try to rebuild php objects for specific struct vals.
3344
+ /// @todo should we raise a warning for class not found?
3345
+ // shall we check for proper subclass of xmlrpcval instead of
3346
+ // presence of _php_class to detect what we can do?
3347
+ if (in_array('decode_php_objs', $options) && $xmlrpc_val->_php_class != ''
3348
+ && class_exists($xmlrpc_val->_php_class))
3349
+ {
3350
+ $obj = @new $xmlrpc_val->_php_class;
3351
+ while(list($key,$value)=$xmlrpc_val->structeach())
3352
+ {
3353
+ $obj->$key = php_xmlrpc_decode($value, $options);
3354
+ }
3355
+ return $obj;
3356
+ }
3357
+ else
3358
+ {
3359
+ $arr = array();
3360
+ while(list($key,$value)=$xmlrpc_val->structeach())
3361
+ {
3362
+ $arr[$key] = php_xmlrpc_decode($value, $options);
3363
+ }
3364
+ return $arr;
3365
+ }
3366
+ case 'msg':
3367
+ $paramcount = $xmlrpc_val->getNumParams();
3368
+ $arr = array();
3369
+ for($i = 0; $i < $paramcount; $i++)
3370
+ {
3371
+ $arr[] = php_xmlrpc_decode($xmlrpc_val->getParam($i));
3372
+ }
3373
+ return $arr;
3374
+ }
3375
+ }
3376
+
3377
+ // This constant left here only for historical reasons...
3378
+ // it was used to decide if we have to define xmlrpc_encode on our own, but
3379
+ // we do not do it anymore
3380
+ if(function_exists('xmlrpc_decode'))
3381
+ {
3382
+ define('XMLRPC_EPI_ENABLED','1');
3383
+ }
3384
+ else
3385
+ {
3386
+ define('XMLRPC_EPI_ENABLED','0');
3387
+ }
3388
+
3389
+ /**
3390
+ * Takes native php types and encodes them into xmlrpc PHP object format.
3391
+ * It will not re-encode xmlrpcval objects.
3392
+ *
3393
+ * Feature creep -- could support more types via optional type argument
3394
+ * (string => datetime support has been added, ??? => base64 not yet)
3395
+ *
3396
+ * If given a proper options parameter, php object instances will be encoded
3397
+ * into 'special' xmlrpc values, that can later be decoded into php objects
3398
+ * by calling php_xmlrpc_decode() with a corresponding option
3399
+ *
3400
+ * @author Dan Libby (dan@libby.com)
3401
+ *
3402
+ * @param mixed $php_val the value to be converted into an xmlrpcval object
3403
+ * @param array $options can include 'encode_php_objs', 'auto_dates', 'null_extension' or 'extension_api'
3404
+ * @return xmlrpcval
3405
+ */
3406
+ function php_xmlrpc_encode($php_val, $options=array())
3407
+ {
3408
+ $type = gettype($php_val);
3409
+ switch($type)
3410
+ {
3411
+ case 'string':
3412
+ if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val))
3413
+ $xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']);
3414
+ else
3415
+ $xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcString']);
3416
+ break;
3417
+ case 'integer':
3418
+ $xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcInt']);
3419
+ break;
3420
+ case 'double':
3421
+ $xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDouble']);
3422
+ break;
3423
+ // <G_Giunta_2001-02-29>
3424
+ // Add support for encoding/decoding of booleans, since they are supported in PHP
3425
+ case 'boolean':
3426
+ $xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcBoolean']);
3427
+ break;
3428
+ // </G_Giunta_2001-02-29>
3429
+ case 'array':
3430
+ // PHP arrays can be encoded to either xmlrpc structs or arrays,
3431
+ // depending on wheter they are hashes or plain 0..n integer indexed
3432
+ // A shorter one-liner would be
3433
+ // $tmp = array_diff(array_keys($php_val), range(0, count($php_val)-1));
3434
+ // but execution time skyrockets!
3435
+ $j = 0;
3436
+ $arr = array();
3437
+ $ko = false;
3438
+ foreach($php_val as $key => $val)
3439
+ {
3440
+ $arr[$key] = php_xmlrpc_encode($val, $options);
3441
+ if(!$ko && $key !== $j)
3442
+ {
3443
+ $ko = true;
3444
+ }
3445
+ $j++;
3446
+ }
3447
+ if($ko)
3448
+ {
3449
+ $xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']);
3450
+ }
3451
+ else
3452
+ {
3453
+ $xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcArray']);
3454
+ }
3455
+ break;
3456
+ case 'object':
3457
+ if($php_val instanceof xmlrpcval)
3458
+ {
3459
+ $xmlrpc_val = $php_val;
3460
+ }
3461
+ else if($php_val instanceof DateTime)
3462
+ {
3463
+ $xmlrpc_val = new xmlrpcval($php_val->format('Ymd\TH:i:s'), $GLOBALS['xmlrpcStruct']);
3464
+ }
3465
+ else
3466
+ {
3467
+ $arr = array();
3468
+ reset($php_val);
3469
+ while(list($k,$v) = each($php_val))
3470
+ {
3471
+ $arr[$k] = php_xmlrpc_encode($v, $options);
3472
+ }
3473
+ $xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']);
3474
+ if (in_array('encode_php_objs', $options))
3475
+ {
3476
+ // let's save original class name into xmlrpcval:
3477
+ // might be useful later on...
3478
+ $xmlrpc_val->_php_class = get_class($php_val);
3479
+ }
3480
+ }
3481
+ break;
3482
+ case 'NULL':
3483
+ if (in_array('extension_api', $options))
3484
+ {
3485
+ $xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcString']);
3486
+ }
3487
+ else if (in_array('null_extension', $options))
3488
+ {
3489
+ $xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcNull']);
3490
+ }
3491
+ else
3492
+ {
3493
+ $xmlrpc_val = new xmlrpcval();
3494
+ }
3495
+ break;
3496
+ case 'resource':
3497
+ if (in_array('extension_api', $options))
3498
+ {
3499
+ $xmlrpc_val = new xmlrpcval((int)$php_val, $GLOBALS['xmlrpcInt']);
3500
+ }
3501
+ else
3502
+ {
3503
+ $xmlrpc_val = new xmlrpcval();
3504
+ }
3505
+ // catch "user function", "unknown type"
3506
+ default:
3507
+ // giancarlo pinerolo <ping@alt.it>
3508
+ // it has to return
3509
+ // an empty object in case, not a boolean.
3510
+ $xmlrpc_val = new xmlrpcval();
3511
+ break;
3512
+ }
3513
+ return $xmlrpc_val;
3514
+ }
3515
+
3516
+ /**
3517
+ * Convert the xml representation of a method response, method request or single
3518
+ * xmlrpc value into the appropriate object (a.k.a. deserialize)
3519
+ * @param string $xml_val
3520
+ * @param array $options
3521
+ * @return mixed false on error, or an instance of either xmlrpcval, xmlrpcmsg or xmlrpcresp
3522
+ */
3523
+ function php_xmlrpc_decode_xml($xml_val, $options=array())
3524
+ {
3525
+ $GLOBALS['_xh'] = array();
3526
+ $GLOBALS['_xh']['ac'] = '';
3527
+ $GLOBALS['_xh']['stack'] = array();
3528
+ $GLOBALS['_xh']['valuestack'] = array();
3529
+ $GLOBALS['_xh']['params'] = array();
3530
+ $GLOBALS['_xh']['pt'] = array();
3531
+ $GLOBALS['_xh']['isf'] = 0;
3532
+ $GLOBALS['_xh']['isf_reason'] = '';
3533
+ $GLOBALS['_xh']['method'] = false;
3534
+ $GLOBALS['_xh']['rt'] = '';
3535
+ /// @todo 'guestimate' encoding
3536
+ $parser = xml_parser_create();
3537
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
3538
+ // What if internal encoding is not in one of the 3 allowed?
3539
+ // we use the broadest one, ie. utf8!
3540
+ if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
3541
+ {
3542
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
3543
+ }
3544
+ else
3545
+ {
3546
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
3547
+ }
3548
+ xml_set_element_handler($parser, 'xmlrpc_se_any', 'xmlrpc_ee');
3549
+ xml_set_character_data_handler($parser, 'xmlrpc_cd');
3550
+ xml_set_default_handler($parser, 'xmlrpc_dh');
3551
+ if(!xml_parse($parser, $xml_val, 1))
3552
+ {
3553
+ $errstr = sprintf('XML error: %s at line %d, column %d',
3554
+ xml_error_string(xml_get_error_code($parser)),
3555
+ xml_get_current_line_number($parser), xml_get_current_column_number($parser));
3556
+ error_log($errstr);
3557
+ xml_parser_free($parser);
3558
+ return false;
3559
+ }
3560
+ xml_parser_free($parser);
3561
+ if ($GLOBALS['_xh']['isf'] > 1) // test that $GLOBALS['_xh']['value'] is an obj, too???
3562
+ {
3563
+ error_log($GLOBALS['_xh']['isf_reason']);
3564
+ return false;
3565
+ }
3566
+ switch ($GLOBALS['_xh']['rt'])
3567
+ {
3568
+ case 'methodresponse':
3569
+ $v =& $GLOBALS['_xh']['value'];
3570
+ if ($GLOBALS['_xh']['isf'] == 1)
3571
+ {
3572
+ $vc = $v->structmem('faultCode');
3573
+ $vs = $v->structmem('faultString');
3574
+ $r = new xmlrpcresp(0, $vc->scalarval(), $vs->scalarval());
3575
+ }
3576
+ else
3577
+ {
3578
+ $r = new xmlrpcresp($v);
3579
+ }
3580
+ return $r;
3581
+ case 'methodcall':
3582
+ $m = new xmlrpcmsg($GLOBALS['_xh']['method']);
3583
+ for($i=0; $i < count($GLOBALS['_xh']['params']); $i++)
3584
+ {
3585
+ $m->addParam($GLOBALS['_xh']['params'][$i]);
3586
+ }
3587
+ return $m;
3588
+ case 'value':
3589
+ return $GLOBALS['_xh']['value'];
3590
+ default:
3591
+ return false;
3592
+ }
3593
+ }
3594
+
3595
+ /**
3596
+ * decode a string that is encoded w/ "chunked" transfer encoding
3597
+ * as defined in rfc2068 par. 19.4.6
3598
+ * code shamelessly stolen from nusoap library by Dietrich Ayala
3599
+ *
3600
+ * @param string $buffer the string to be decoded
3601
+ * @return string
3602
+ */
3603
+ function decode_chunked($buffer)
3604
+ {
3605
+ // length := 0
3606
+ $length = 0;
3607
+ $new = '';
3608
+
3609
+ // read chunk-size, chunk-extension (if any) and crlf
3610
+ // get the position of the linebreak
3611
+ $chunkend = strpos($buffer,"\r\n") + 2;
3612
+ $temp = substr($buffer,0,$chunkend);
3613
+ $chunk_size = hexdec( trim($temp) );
3614
+ $chunkstart = $chunkend;
3615
+ while($chunk_size > 0)
3616
+ {
3617
+ $chunkend = strpos($buffer, "\r\n", $chunkstart + $chunk_size);
3618
+
3619
+ // just in case we got a broken connection
3620
+ if($chunkend == false)
3621
+ {
3622
+ $chunk = substr($buffer,$chunkstart);
3623
+ // append chunk-data to entity-body
3624
+ $new .= $chunk;
3625
+ $length += strlen($chunk);
3626
+ break;
3627
+ }
3628
+
3629
+ // read chunk-data and crlf
3630
+ $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
3631
+ // append chunk-data to entity-body
3632
+ $new .= $chunk;
3633
+ // length := length + chunk-size
3634
+ $length += strlen($chunk);
3635
+ // read chunk-size and crlf
3636
+ $chunkstart = $chunkend + 2;
3637
+
3638
+ $chunkend = strpos($buffer,"\r\n",$chunkstart)+2;
3639
+ if($chunkend == false)
3640
+ {
3641
+ break; //just in case we got a broken connection
3642
+ }
3643
+ $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
3644
+ $chunk_size = hexdec( trim($temp) );
3645
+ $chunkstart = $chunkend;
3646
+ }
3647
+ return $new;
3648
+ }
3649
+
3650
+ /**
3651
+ * xml charset encoding guessing helper function.
3652
+ * Tries to determine the charset encoding of an XML chunk received over HTTP.
3653
+ * NB: according to the spec (RFC 3023), if text/xml content-type is received over HTTP without a content-type,
3654
+ * we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of unconforming (legacy?) clients/servers,
3655
+ * which will be most probably using UTF-8 anyway...
3656
+ *
3657
+ * @param string $httpheaders the http Content-type header
3658
+ * @param string $xmlchunk xml content buffer
3659
+ * @param string $encoding_prefs comma separated list of character encodings to be used as default (when mb extension is enabled)
3660
+ *
3661
+ * @todo explore usage of mb_http_input(): does it detect http headers + post data? if so, use it instead of hand-detection!!!
3662
+ */
3663
+ function guess_encoding($httpheader='', $xmlchunk='', $encoding_prefs=null)
3664
+ {
3665
+ // discussion: see http://www.yale.edu/pclt/encoding/
3666
+ // 1 - test if encoding is specified in HTTP HEADERS
3667
+
3668
+ //Details:
3669
+ // LWS: (\13\10)?( |\t)+
3670
+ // token: (any char but excluded stuff)+
3671
+ // quoted string: " (any char but double quotes and cointrol chars)* "
3672
+ // header: Content-type = ...; charset=value(; ...)*
3673
+ // where value is of type token, no LWS allowed between 'charset' and value
3674
+ // Note: we do not check for invalid chars in VALUE:
3675
+ // this had better be done using pure ereg as below
3676
+ // Note 2: we might be removing whitespace/tabs that ought to be left in if
3677
+ // the received charset is a quoted string. But nobody uses such charset names...
3678
+
3679
+ /// @todo this test will pass if ANY header has charset specification, not only Content-Type. Fix it?
3680
+ $matches = array();
3681
+ if(preg_match('/;\s*charset\s*=([^;]+)/i', $httpheader, $matches))
3682
+ {
3683
+ return strtoupper(trim($matches[1], " \t\""));
3684
+ }
3685
+
3686
+ // 2 - scan the first bytes of the data for a UTF-16 (or other) BOM pattern
3687
+ // (source: http://www.w3.org/TR/2000/REC-xml-20001006)
3688
+ // NOTE: actually, according to the spec, even if we find the BOM and determine
3689
+ // an encoding, we should check if there is an encoding specified
3690
+ // in the xml declaration, and verify if they match.
3691
+ /// @todo implement check as described above?
3692
+ /// @todo implement check for first bytes of string even without a BOM? (It sure looks harder than for cases WITH a BOM)
3693
+ if(preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk))
3694
+ {
3695
+ return 'UCS-4';
3696
+ }
3697
+ elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk))
3698
+ {
3699
+ return 'UTF-16';
3700
+ }
3701
+ elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk))
3702
+ {
3703
+ return 'UTF-8';
3704
+ }
3705
+
3706
+ // 3 - test if encoding is specified in the xml declaration
3707
+ // Details:
3708
+ // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+
3709
+ // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
3710
+ if (preg_match('/^<\?xml\s+version\s*=\s*'. "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))".
3711
+ '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
3712
+ $xmlchunk, $matches))
3713
+ {
3714
+ return strtoupper(substr($matches[2], 1, -1));
3715
+ }
3716
+
3717
+ // 4 - if mbstring is available, let it do the guesswork
3718
+ // NB: we favour finding an encoding that is compatible with what we can process
3719
+ if(extension_loaded('mbstring'))
3720
+ {
3721
+ if($encoding_prefs)
3722
+ {
3723
+ $enc = mb_detect_encoding($xmlchunk, $encoding_prefs);
3724
+ }
3725
+ else
3726
+ {
3727
+ $enc = mb_detect_encoding($xmlchunk);
3728
+ }
3729
+ // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII...
3730
+ // IANA also likes better US-ASCII, so go with it
3731
+ if($enc == 'ASCII')
3732
+ {
3733
+ $enc = 'US-'.$enc;
3734
+ }
3735
+ return $enc;
3736
+ }
3737
+ else
3738
+ {
3739
+ // no encoding specified: as per HTTP1.1 assume it is iso-8859-1?
3740
+ // Both RFC 2616 (HTTP 1.1) and 1945 (HTTP 1.0) clearly state that for text/xxx content types
3741
+ // this should be the standard. And we should be getting text/xml as request and response.
3742
+ // BUT we have to be backward compatible with the lib, which always used UTF-8 as default...
3743
+ return $GLOBALS['xmlrpc_defencoding'];
3744
+ }
3745
+ }
3746
+
3747
+ /**
3748
+ * Checks if a given charset encoding is present in a list of encodings or
3749
+ * if it is a valid subset of any encoding in the list
3750
+ * @param string $encoding charset to be tested
3751
+ * @param mixed $validlist comma separated list of valid charsets (or array of charsets)
3752
+ */
3753
+ function is_valid_charset($encoding, $validlist)
3754
+ {
3755
+ $charset_supersets = array(
3756
+ 'US-ASCII' => array ('ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4',
3757
+ 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8',
3758
+ 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-11', 'ISO-8859-12',
3759
+ 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8',
3760
+ 'EUC-JP', 'EUC-', 'EUC-KR', 'EUC-CN')
3761
+ );
3762
+ if (is_string($validlist))
3763
+ $validlist = explode(',', $validlist);
3764
+ if (@in_array(strtoupper($encoding), $validlist))
3765
+ return true;
3766
+ else
3767
+ {
3768
+ if (array_key_exists($encoding, $charset_supersets))
3769
+ foreach ($validlist as $allowed)
3770
+ if (in_array($allowed, $charset_supersets[$encoding]))
3771
+ return true;
3772
+ return false;
3773
+ }
3774
+ }
3775
+
3776
+ ?>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Print_Science_Designer_Web_to_Print</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Print Science designer component</summary>
10
+ <description>Print Science designer component</description>
11
+ <notes>-</notes>
12
+ <authors><author><name>John Weissberg</name><user>johnwwweissberg</user><email>jw@print-science.com</email></author></authors>
13
+ <date>2011-06-30</date>
14
+ <time>09:11:50</time>
15
+ <contents><target name="magelocal"><dir name="PrintScience"><dir><dir name="Personalization"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Items"><file name="Renderer.php" hash="a95c2f0db7c89b611b36b22daa88dbcb"/></dir></dir></dir></dir></dir><dir name="Checkout"><dir name="Cart"><dir name="Item"><file name="Renderer.php" hash="f9245751c49c5373dd0a73530478980c"/></dir></dir></dir></dir><dir name="Helper"><file name="Output.php" hash="a85fc623811e1f749f42a6a290fd840f"/><file name="Quote.php" hash="b9f7a8d51f11602746963ee19366c541"/><file name="Session.php" hash="0236f26208780df75ca780d40edbe351"/></dir><dir name="Model"><dir name="ApiGateway"><dir name="Response"><file name="Abstract.php" hash="66667fce4c92782faf1d1a92f4c3e339"/><file name="Begin.php" hash="451d64c86ef6aa542ae7cf5949b1b627"/><file name="GetPreview.php" hash="bbf2885274837015a49787f7685a2bd6"/></dir></dir><file name="ApiGateway.php" hash="e47fcab5f5ac4a71962a3e13a3acaaee"/><file name="Observer.php" hash="0a4a2f2648b9349399b87433f3533dc9"/><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="0b1f152cf26c58a92efe4165dc9b3803"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="ApiUrl.php" hash="34eb488ef178104966397f425625534d"/></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="740659b1a6f85789fe68fe963d0d8643"/></dir><dir name="etc"><file name="config.xml" hash="c080f22e1017d3089f75722c258276a3"/><file name="system.xml" hash="9808dd3a40e7a7c24e210b5d95f78507"/></dir><dir name="sql"><dir name="printscience_personalization_setup"><file name="Mysql4-install-0.1.0.php" hash="7895f0369177cb6dab9911d7820647b4"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PrintScience_Personalization.xml" hash="5f5c39c5b01e828137125d057d04a655"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="printscience_personalization.xml" hash="6dbb5084dc5bce33ee476dae547795f4"/></dir><dir name="template"><dir name="printscience_personalization"><dir><dir name="catalog"><dir name="product"><file name="list.phtml" hash="ed9facdc48754e923c89b206003abe8a"/><dir name="view"><file name="addtocart.phtml" hash="c46ece2a25fa12658938f3f2be6a6790"/></dir></dir></dir><dir name="checkout"><dir name="cart"><dir name="item"><file name="default.phtml" hash="c56ff26e1f96fa068f2e143fa6805872"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="printscience_personalization.xml" hash="02bbc420d579eceee5b83b3fb41a73af"/></dir><dir name="template"><dir name="printscience_personalization"><dir><dir name="sales"><dir name="order"><dir name="view"><dir name="items"><dir name="renderer"><file name="default.phtml" hash="5b6bcdd9bd94afda867429707dd786d3"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="xmlrpc"><file name="xmlrpc.inc" hash="55ecb2a9f7fc20d53a7b4da9d885e26b"/></dir></target><target name="mage"><dir name="js"><dir name="printscience_personalization"><file name="gallery.css" hash="eccacd49a35d68ef25bc1bf8e292fe98"/><file name="gallery.js" hash="2157199d26c64a051f3b62530e068401"/><dir><dir name="jquery"><dir name="fancybox"><file name="blank.gif" hash="325472601571f31e1bf00674c368d335"/><file name="fancy_close.png" hash="6e2879a324a76e9972ebc98201aae1d8"/><file name="fancy_loading.png" hash="b1d54c240cf06e7f41e372d56919b738"/><file name="fancy_nav_left.png" hash="3f3e406102152cd8236383568a40ba35"/><file name="fancy_nav_right.png" hash="216e4bde5bddeeaa60dc3d692890a68e"/><file name="fancy_shadow_e.png" hash="fd4f491080d29fade5080877f1ba4c8b"/><file name="fancy_shadow_n.png" hash="18cde16379b2ceadef714d9b346d09ec"/><file name="fancy_shadow_ne.png" hash="63adf788acf193d4e4f3642d7d793125"/><file name="fancy_shadow_nw.png" hash="c820c878aedb7a7f9ebd7135a58e7c65"/><file name="fancy_shadow_s.png" hash="9b9e5c888028aaef40fe5b6a363f1e29"/><file name="fancy_shadow_se.png" hash="a8afd5a008884380ee712d177105268f"/><file name="fancy_shadow_sw.png" hash="f81cc0fee5581d76ad3cebe47e7e791b"/><file name="fancy_shadow_w.png" hash="59b0e63eb059e58d932cfd53da4d87e6"/><file name="fancy_title_left.png" hash="1582ac2d3bef6a6445bf02ceca2741cd"/><file name="fancy_title_main.png" hash="38dad6c1ed4bdc81c0bec721b2deb8c2"/><file name="fancy_title_over.png" hash="b886fd165d4b7ac77d41fb52d87ffc60"/><file name="fancy_title_right.png" hash="6cbe0c935511e7f9a2555ccb6a7324c4"/><file name="fancybox-x.png" hash="168696d8a694214090ef90e029cdf393"/><file name="fancybox-y.png" hash="36a58859beb9a6b19322a37466b9f78e"/><file name="fancybox.png" hash="11e57e492ee0311540967cc7a1e6e3e2"/><file name="jquery.easing-1.3.pack.js" hash="def257dbb0ab805c4996fd8abb1a6b49"/><file name="jquery.fancybox-1.3.4.css" hash="4638ce99ef00cf62bfb22d230f9924b8"/><file name="jquery.fancybox-1.3.4.pack.js" hash="8bc36a08c46719377528d962966ce37c"/><file name="jquery.mousewheel-3.0.4.pack.js" hash="3b0a821567b463e70bcc1e90ed2bc9b6"/></dir><file name="jquery-1.4.2.min.js" hash="b80a2154ce061c8242031d9a4892c5a6"/><dir name="jquery.cycle"><file name="jquery.cycle.lite.min.js" hash="0c4a7571c05a6ada90b93e826e7f9f6e"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>