boxalino_plugin - Version 1.0.0

Version Notes

Minor changes, thanks everyone for the feedback.

Download this release

Release Info

Developer Marcel Zenger
Extension boxalino_plugin
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (91) hide show
  1. app/code/local/Boxalino/CemSearch/Block/Abstract.php +36 -0
  2. app/code/local/Boxalino/CemSearch/Block/Autocomplete.php +157 -0
  3. app/code/local/Boxalino/CemSearch/Block/Cart/Crosssell.php +89 -0
  4. app/code/local/Boxalino/CemSearch/Block/Head.php +37 -0
  5. app/code/local/Boxalino/CemSearch/Block/Product/List/Related.php +69 -0
  6. app/code/local/Boxalino/CemSearch/Block/Product/List/Upsell.php +67 -0
  7. app/code/local/Boxalino/CemSearch/Helper/Data.php +306 -0
  8. app/code/local/Boxalino/CemSearch/Helper/P13n/Adapter.php +423 -0
  9. app/code/local/Boxalino/CemSearch/Helper/P13n/Client.php +233 -0
  10. app/code/local/Boxalino/CemSearch/Helper/P13n/Config.php +59 -0
  11. app/code/local/Boxalino/CemSearch/Helper/P13n/Recommendation.php +63 -0
  12. app/code/local/Boxalino/CemSearch/Helper/P13n/Sort.php +36 -0
  13. app/code/local/Boxalino/CemSearch/Lib/AbstractThrift.php +28 -0
  14. app/code/local/Boxalino/CemSearch/Lib/P13nService.php +729 -0
  15. app/code/local/Boxalino/CemSearch/Lib/Types.php +4580 -0
  16. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Base/TBase.php +367 -0
  17. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/ClassLoader/ThriftClassLoader.php +223 -0
  18. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Exception/TApplicationException.php +72 -0
  19. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Exception/TException.php +369 -0
  20. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Exception/TProtocolException.php +48 -0
  21. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Exception/TTransportException.php +41 -0
  22. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Factory/TBinaryProtocolFactory.php +43 -0
  23. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Factory/TCompactProtocolFactory.php +39 -0
  24. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Factory/TJSONProtocolFactory.php +41 -0
  25. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Factory/TProtocolFactory.php +35 -0
  26. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Factory/TStringFuncFactory.php +63 -0
  27. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Factory/TTransportFactory.php +16 -0
  28. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/HttpP13n.php +259 -0
  29. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/JSON/BaseContext.php +39 -0
  30. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/JSON/ListContext.php +52 -0
  31. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/JSON/LookaheadReader.php +54 -0
  32. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/JSON/PairContext.php +60 -0
  33. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/TBinaryProtocol.php +396 -0
  34. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/TBinaryProtocolAccelerated.php +47 -0
  35. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/TCompactProtocol.php +669 -0
  36. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/TJSONProtocol.php +694 -0
  37. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/TProtocol.php +346 -0
  38. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Serializer/TBinarySerializer.php +73 -0
  39. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Server/TForkingServer.php +119 -0
  40. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Server/TServer.php +101 -0
  41. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Server/TServerSocket.php +98 -0
  42. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Server/TServerTransport.php +54 -0
  43. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Server/TSimpleServer.php +57 -0
  44. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/StringFunc/Core.php +38 -0
  45. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/StringFunc/Mbstring.php +45 -0
  46. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/StringFunc/TStringFunc.php +27 -0
  47. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/P13nTHttpClient.php +51 -0
  48. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TBufferedTransport.php +165 -0
  49. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TFramedTransport.php +183 -0
  50. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/THttpClient.php +206 -0
  51. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TMemoryBuffer.php +89 -0
  52. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TNullTransport.php +50 -0
  53. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TPhpStream.php +114 -0
  54. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TSocket.php +326 -0
  55. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TSocketPool.php +295 -0
  56. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TTransport.php +93 -0
  57. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Type/TMessageType.php +33 -0
  58. app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Type/TType.php +46 -0
  59. app/code/local/Boxalino/CemSearch/Model/Advanced.php +305 -0
  60. app/code/local/Boxalino/CemSearch/Model/Logger.php +44 -0
  61. app/code/local/Boxalino/CemSearch/Model/Observer.php +111 -0
  62. app/code/local/Boxalino/CemSearch/Model/Resource/Advanced.php +12 -0
  63. app/code/local/Boxalino/CemSearch/Model/Resource/Advanced/Collection.php +30 -0
  64. app/code/local/Boxalino/CemSearch/Model/Resource/Fulltext.php +136 -0
  65. app/code/local/Boxalino/CemSearch/Model/Session.php +32 -0
  66. app/code/local/Boxalino/CemSearch/controllers/AdvancedController.php +158 -0
  67. app/code/local/Boxalino/CemSearch/controllers/AjaxController.php +47 -0
  68. app/code/local/Boxalino/CemSearch/controllers/IndexController.php +27 -0
  69. app/code/local/Boxalino/CemSearch/controllers/ResultController.php +10 -0
  70. app/code/local/Boxalino/CemSearch/etc/adminhtml.xml +26 -0
  71. app/code/local/Boxalino/CemSearch/etc/config.xml +205 -0
  72. app/code/local/Boxalino/CemSearch/etc/system.xml +488 -0
  73. app/code/local/Boxalino/Exporter/Helper/Data.php +155 -0
  74. app/code/local/Boxalino/Exporter/Model/Delta.php +29 -0
  75. app/code/local/Boxalino/Exporter/Model/Indexer.php +29 -0
  76. app/code/local/Boxalino/Exporter/Model/Mysql4/Exporter/Delta.php +118 -0
  77. app/code/local/Boxalino/Exporter/Model/Mysql4/Exporter/Indexer.php +70 -0
  78. app/code/local/Boxalino/Exporter/Model/Mysql4/Indexer.php +1706 -0
  79. app/code/local/Boxalino/Exporter/etc/adminhtml.xml +23 -0
  80. app/code/local/Boxalino/Exporter/etc/config.xml +57 -0
  81. app/code/local/Boxalino/Exporter/etc/system.xml +106 -0
  82. app/design/frontend/base/default/layout/boxalino.xml +18 -0
  83. app/design/frontend/base/default/template/boxalino/catalogsearch/form.mini.phtml +31 -0
  84. app/design/frontend/base/default/template/boxalino/head.phtml +4 -0
  85. app/etc/modules/Boxalino_CemSearch.xml +10 -0
  86. app/etc/modules/Boxalino_Exporter.xml +8 -0
  87. package.xml +26 -0
  88. skin/frontend/base/default/css/boxalinoCemSearch.css +70 -0
  89. skin/frontend/base/default/js/boxalinoAutocomplete.js +67 -0
  90. skin/frontend/base/default/js/jquery-1.10.2.min.js +6 -0
  91. skin/frontend/base/default/js/jquery-noConflict.js +1 -0
app/code/local/Boxalino/CemSearch/Block/Abstract.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Boxalino_CemSearch_Block_Abstract extends Mage_Core_Block_Template
4
+ {
5
+ public function isPluginEnabled()
6
+ {
7
+ return Mage::helper('Boxalino_CemSearch')->isEnabled();
8
+ }
9
+
10
+ public function isPageEnabled($uri)
11
+ {
12
+ return Mage::helper('Boxalino_CemSearch')->isPageEnabled($uri);
13
+ }
14
+
15
+ public function getSearchUrl()
16
+ {
17
+ return $this->getUrl('Boxalino_CemSearch/search');
18
+ }
19
+
20
+ public function getLanguage()
21
+ {
22
+ return Mage::helper('Boxalino_CemSearch')->getLanguage();
23
+ }
24
+
25
+ public function getSuggestUrl()
26
+ {
27
+ return Mage::helper('Boxalino_CemSearch')->getSuggestUrl();
28
+ }
29
+
30
+ public function getSuggestParameters()
31
+ {
32
+ return Mage::helper('Boxalino_CemSearch')->getSuggestParameters();
33
+ }
34
+
35
+
36
+ }
app/code/local/Boxalino/CemSearch/Block/Autocomplete.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_CatalogSearch
23
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Autocomplete queries list
29
+ */
30
+
31
+ require_once "Mage/CatalogSearch/Block/Autocomplete.php";
32
+
33
+ class Boxalino_CemSearch_Block_Autocomplete extends Mage_CatalogSearch_Block_Autocomplete
34
+ {
35
+ protected $_suggestData = null;
36
+ protected $_suggestDataProducts = null;
37
+
38
+
39
+ protected function _toHtml()
40
+ {
41
+
42
+ if (Mage::getStoreConfig('Boxalino_General/general/enabled', 0) == 0) {
43
+ return null;
44
+ }
45
+
46
+ $html = '';
47
+
48
+ if (!$this->_beforeToHtml()) {
49
+ return $html;
50
+ }
51
+
52
+ $suggestData = $this->getSuggestData();
53
+ if (!($count = count($suggestData))) {
54
+ return '<ul><li>' . $this->helper('catalogsearch')->getQueryText() . '</li></ul>';
55
+ }
56
+
57
+ $count--;
58
+
59
+ $html = '<ul><li style="display:none"></li>';
60
+ foreach ($suggestData as $index => $item) {
61
+ if ($index == 0) {
62
+ $item['row_class'] .= ' first';
63
+ }
64
+
65
+ if ($index == $count) {
66
+ $item['row_class'] .= ' last';
67
+ }
68
+
69
+ $html .= '<li data-word="' . $item['id'] . '" title="' . $this->escapeHtml($item['title']) . '" class="' . $item['row_class'] . '">'
70
+ . '<span class="amount">' . $item['num_of_results'] . '</span>' . $this->escapeHtml($item['title']) . '</li>';
71
+ }
72
+ $html .= '</ul><ul>';
73
+
74
+ $first_word = true;
75
+ foreach ($this->_suggestDataProducts as $key => $word) {
76
+ foreach ($word as $product) {
77
+ $product = Mage::getModel('catalog/product')->load($product['id']);
78
+ $class = '';
79
+ if (!$first_word) {
80
+ $class = 'hide';
81
+ }
82
+ $html .= '<li data-word="' . $key . '" class="product-autocomplete ' . $class . '" title="' . $this->escapeHtml($product->getName()) . '">';
83
+ $html .= '<a href="' . $product->getProductUrl() . '" ><table><tr><td>';
84
+ $html .= '<img src="' . $product->getThumbnailUrl() . '" alt="' . $product->getName() . '" />';
85
+ $html .= '</td><td>';
86
+ $html .= '<span>' . $product->getName() . '</span>';
87
+ $html .= '</td></tr></table></a>';
88
+ $html .= '</li>';
89
+ }
90
+ $first_word = false;
91
+ }
92
+
93
+ $html .= '</ul>';
94
+
95
+ return $html;
96
+ }
97
+
98
+ public function getSuggestData()
99
+ {
100
+
101
+ if (Mage::getStoreConfig('Boxalino_General/general/enabled', 0) == 0) {
102
+ return parent::getSuggestData();
103
+ }
104
+
105
+ if (!$this->_suggestData) {
106
+ $query = $this->helper('catalogsearch')->getQueryText();
107
+ $counter = 0;
108
+ $data = array();
109
+
110
+ $storeConfig = Mage::getStoreConfig('Boxalino_General/general');
111
+
112
+ $p13nConfig = new Boxalino_CemSearch_Helper_P13n_Config(
113
+ $storeConfig['host'],
114
+ Mage::helper('Boxalino_CemSearch')->getAccount(),
115
+ $storeConfig['p13n_username'],
116
+ $storeConfig['p13n_password'],
117
+ $storeConfig['domain']
118
+ );
119
+ $p13n = new Boxalino_CemSearch_Helper_P13n_Adapter($p13nConfig);
120
+
121
+ $generalConfig = Mage::getStoreConfig('Boxalino_General/search');
122
+
123
+ if ($query) {
124
+ $p13n->autocomplete('*' . $query . '*', $generalConfig['autocomplete_limit'], $generalConfig['autocomplete_products_limit']);
125
+ $collection = $p13n->getAutocompleteEntities();
126
+ } else {
127
+ $collection = array();
128
+ }
129
+
130
+ foreach ($collection as $item) {
131
+
132
+ if ($item['hits'] <= 0) {
133
+ continue;
134
+ }
135
+
136
+ $_data = array(
137
+ 'id' => substr(md5($item['text']), 0, 10),
138
+ 'title' => $item['text'],
139
+ 'row_class' => (++$counter) % 2 ? 'odd' : 'even',
140
+ 'num_of_results' => $item['hits']
141
+ );
142
+
143
+ if ($item['text'] == $query) {
144
+ array_unshift($data, $_data);
145
+ } else {
146
+ $data[] = $_data;
147
+ }
148
+ }
149
+ $this->_suggestData = $data;
150
+ $this->_suggestDataProducts = $p13n->getAutocompleteProducts();
151
+ }
152
+ return $this->_suggestData;
153
+ }
154
+ /*
155
+ *
156
+ */
157
+ }
app/code/local/Boxalino/CemSearch/Block/Cart/Crosssell.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by: Szymon Nosal <szymon.nosal@codete.com>
5
+ * Created at: 13.06.14 12:25
6
+ */
7
+ class Boxalino_CemSearch_Block_Cart_Crosssell extends Mage_Checkout_Block_Cart_Crosssell
8
+ {
9
+
10
+ /**
11
+ * Items quantity will be capped to this value
12
+ *
13
+ * @var int
14
+ */
15
+ protected $_maxItemCount = 4;
16
+
17
+ /**
18
+ * Get crosssell items
19
+ *
20
+ * @return array
21
+ */
22
+ public function getItems()
23
+ {
24
+
25
+ if (Mage::getStoreConfig('Boxalino_General/general/enabled', 0) == 0) {
26
+ return parent::getItems();
27
+ }
28
+ $name = Mage::getStoreConfig('Boxalino_Recommendation/cart/widget');
29
+ #####################################################################################
30
+
31
+ $cartItems = array();
32
+ foreach ($this->getQuote()->getAllItems() as $item) {
33
+ $productPrice = $item->getProduct()->getPrice();
34
+ $productId = $item->getProductId();
35
+
36
+ if ($item->getProductType() === 'configurable') {
37
+ continue;
38
+ }
39
+
40
+ $cartItems[] = array('id' => $productId, 'price' => $productPrice);
41
+
42
+ }
43
+
44
+ $_REQUEST['basketContent'] = json_encode($cartItems);
45
+
46
+ $p13nRecommendation = Boxalino_CemSearch_Helper_P13n_Recommendation::Instance();
47
+
48
+ $response = $p13nRecommendation->getRecommendation('basket', $name);
49
+ $entityIds = array();
50
+
51
+ if ($response === null) {
52
+ return null;
53
+ }
54
+
55
+ foreach ($response as $item) {
56
+ $entityIds[] = $item[Mage::getStoreConfig('Boxalino_General/search/entity_id')];
57
+ }
58
+
59
+ if (empty($entityIds)) {
60
+ return parent::getItems();
61
+ }
62
+
63
+ #########################################################################################
64
+
65
+ $itemCollection = Mage::getResourceModel('catalog/product_collection')
66
+ ->addFieldToFilter('entity_id', $entityIds)
67
+ ->addAttributeToSelect('*');
68
+
69
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_Checkout')) {
70
+ Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($itemCollection,
71
+ Mage::getSingleton('checkout/session')->getQuoteId()
72
+ );
73
+ $this->_addProductAttributesAndPrices($itemCollection);
74
+ }
75
+ // Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($itemCollection);
76
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($itemCollection);
77
+
78
+ $itemCollection->load();
79
+ $items = array();
80
+ foreach ($itemCollection as $product) {
81
+ $product->setDoNotUseCategoryId(true);
82
+ $items[] = $product;
83
+ }
84
+
85
+
86
+ return $items;
87
+ }
88
+
89
+ }
app/code/local/Boxalino/CemSearch/Block/Head.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Boxalino_CemSearch_Block_Head extends Boxalino_CemSearch_Block_Abstract
4
+ {
5
+ public function printScripts()
6
+ {
7
+ $enabled = Mage::getStoreConfig('Boxalino_General/tracker/enabled');
8
+ if ($enabled == 1) {
9
+ $session = Mage::getSingleton('Boxalino_CemSearch_Model_Session');
10
+ $scripts = $session->getScripts(false);
11
+ Mage::helper('Boxalino_CemSearch')->scriptBegin();
12
+
13
+ foreach ($scripts as $script) {
14
+ echo $script;
15
+ }
16
+ $session->clearScripts();
17
+
18
+ echo Mage::helper('Boxalino_CemSearch')->reportPageView();
19
+
20
+ $route = Mage::app()->getFrontController()->getRequest()->getRouteName();
21
+ $controller = Mage::app()->getFrontController()->getRequest()->getControllerName();
22
+ if ($route == 'catalogsearch' && $controller == 'result') {
23
+ echo Mage::helper('Boxalino_CemSearch')->reportSearch($_GET['q'], Mage::helper('Boxalino_CemSearch')->getFiltersValues($_GET));
24
+ }
25
+
26
+
27
+ Mage::helper('Boxalino_CemSearch')->scriptEnd();
28
+ } else {
29
+ return '';
30
+ }
31
+ }
32
+
33
+ public function addExternalJS($args)
34
+ {
35
+ echo '<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>';
36
+ }
37
+ }
app/code/local/Boxalino/CemSearch/Block/Product/List/Related.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by: Szymon Nosal <szymon.nosal@codete.com>
5
+ * Created at: 16.06.14 12:29
6
+ */
7
+ class Boxalino_CemSearch_Block_Product_List_Related extends Mage_Catalog_Block_Product_List_Related
8
+ {
9
+ /**
10
+ * Default MAP renderer type
11
+ *
12
+ * @var string
13
+ */
14
+ protected $_mapRenderer = 'msrp_noform';
15
+
16
+ protected $_itemCollection;
17
+
18
+ protected function _prepareData()
19
+ {
20
+
21
+ if (Mage::getStoreConfig('Boxalino_General/general/enabled', 0) == 0 || Mage::getStoreConfig('Boxalino_Recommendation/related/status', 0) == 0) {
22
+ return parent::_prepareData();
23
+ }
24
+ $name = Mage::getStoreConfig('Boxalino_Recommendation/related/widget');
25
+
26
+ $product = Mage::registry('product');
27
+ /* @var $product Mage_Catalog_Model_Product */
28
+
29
+ ##################################################################################
30
+
31
+ $_REQUEST['productId'] = $product->getId();
32
+
33
+ $p13nRecommendation = Boxalino_CemSearch_Helper_P13n_Recommendation::Instance();
34
+
35
+ $response = $p13nRecommendation->getRecommendation('product', $name);
36
+ $entityIds = array();
37
+
38
+ if ($response === null) {
39
+ $this->_itemCollection = new Varien_Data_Collection();
40
+ return $this;
41
+ }
42
+
43
+ foreach ($response as $item) {
44
+ $entityIds[] = $item[Mage::getStoreConfig('Boxalino_General/search/entity_id')];
45
+ }
46
+
47
+ ###############################################################
48
+ $this->_itemCollection = Mage::getResourceModel('catalog/product_collection')
49
+ ->addFieldToFilter('entity_id', $entityIds)
50
+ ->addAttributeToSelect('*');
51
+
52
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_Checkout')) {
53
+ Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection,
54
+ Mage::getSingleton('checkout/session')->getQuoteId()
55
+ );
56
+ $this->_addProductAttributesAndPrices($this->_itemCollection);
57
+ }
58
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
59
+
60
+ $this->_itemCollection->load();
61
+
62
+ foreach ($this->_itemCollection as $product) {
63
+ $product->setDoNotUseCategoryId(true);
64
+ }
65
+
66
+ return $this;
67
+ }
68
+
69
+ }
app/code/local/Boxalino/CemSearch/Block/Product/List/Upsell.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by: Szymon Nosal <szymon.nosal@codete.com>
5
+ * Created at: 17.06.14 11:31
6
+ */
7
+ class Boxalino_CemSearch_Block_Product_List_Upsell extends Mage_Catalog_Block_Product_List_Upsell
8
+ {
9
+ /**
10
+ * Default MAP renderer type
11
+ *
12
+ * @var string
13
+ */
14
+ protected $_mapRenderer = 'msrp_noform';
15
+
16
+ protected $_itemCollection;
17
+
18
+ protected function _prepareData()
19
+ {
20
+
21
+ if (Mage::getStoreConfig('Boxalino_General/general/enabled', 0) == 0 || Mage::getStoreConfig('Boxalino_Recommendation/upsell/status', 0) == 0) {
22
+ return parent::_prepareData();
23
+ }
24
+ $name = Mage::getStoreConfig('Boxalino_Recommendation/upsell/widget');
25
+
26
+ $product = Mage::registry('product');
27
+ $_REQUEST['productId'] = $product->getId();
28
+
29
+ $p13nRecommendation = Boxalino_CemSearch_Helper_P13n_Recommendation::Instance();
30
+
31
+ $response = $p13nRecommendation->getRecommendation('product', $name);
32
+ $entityIds = array();
33
+
34
+ if ($response === null) {
35
+ $this->_itemCollection = new Varien_Data_Collection();
36
+ return $this;
37
+ }
38
+
39
+ foreach ($response as $item) {
40
+ $entityIds[] = $item[Mage::getStoreConfig('Boxalino_General/search/entity_id')];
41
+ }
42
+
43
+ $this->_itemCollection = Mage::getResourceModel('catalog/product_collection')
44
+ ->addFieldToFilter('entity_id', $entityIds)
45
+ ->addAttributeToSelect('*');
46
+
47
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_Checkout')) {
48
+ Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection,
49
+ Mage::getSingleton('checkout/session')->getQuoteId()
50
+ );
51
+ $this->_addProductAttributesAndPrices($this->_itemCollection);
52
+ }
53
+
54
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
55
+
56
+ if ($this->getItemLimit('upsell') > 0) {
57
+ $this->_itemCollection->setPageSize($this->getItemLimit('upsell'));
58
+ }
59
+
60
+ $this->_itemCollection->load();
61
+ foreach ($this->_itemCollection as $product) {
62
+ $product->setDoNotUseCategoryId(true);
63
+ }
64
+
65
+ return $this;
66
+ }
67
+ }
app/code/local/Boxalino/CemSearch/Helper/Data.php ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Boxalino_CemSearch_Helper_Data extends Mage_Core_Helper_Data
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ include_once(Mage::getModuleDir('', 'Boxalino_CemSearch') . '/Lib/vendor/Thrift/HttpP13n.php');
8
+ spl_autoload_register(array('Boxalino_CemSearch_Helper_Data', '__loadClass'), TRUE, TRUE);
9
+ }
10
+
11
+ public static function __loadClass($name)
12
+ {
13
+ if(strpos($name, 'Thrift\\') !== false){
14
+ try {
15
+ include_once(Mage::getModuleDir('', 'Boxalino_CemSearch') . '/Lib/vendor/' . str_replace('\\', '/', $name) . '.php');
16
+ } catch (Exception $e) {
17
+ Mage::throwException($e->getMessage());
18
+ }
19
+ }
20
+ }
21
+
22
+ public function getBasketAmount()
23
+ {
24
+ $checkout = Mage::getSingleton('checkout/session');
25
+ $quote = $checkout->getQuote();
26
+ $amount = 0;
27
+ if ($quote) {
28
+ foreach ($quote->getAllVisibleItems() as $item) {
29
+ $amount += $item->getQty() * $item->getPrice();
30
+ }
31
+ }
32
+ return $amount;
33
+ }
34
+
35
+ public function getBasketItems()
36
+ {
37
+ $items = array();
38
+ $checkout = Mage::getSingleton('checkout/session');
39
+ $quote = $checkout->getQuote();
40
+ if ($quote) {
41
+ foreach ($quote->getAllVisibleItems() as $item) {
42
+ $items[] = $item->product_id;
43
+ }
44
+ }
45
+ return $items;
46
+ }
47
+
48
+ public function getBasketContent()
49
+ {
50
+ $checkout = Mage::getSingleton('checkout/session');
51
+ $quote = $checkout->getQuote();
52
+ $items = array();
53
+ if ($quote) {
54
+ foreach ($quote->getAllVisibleItems() as $item) {
55
+ $items[] = array(
56
+ 'id' => $item->product_id,
57
+ 'name' => $item->getProduct()->getName(),
58
+ 'quantity' => $item->getQty(),
59
+ 'price' => $item->getPrice(),
60
+ 'widget' => $this->isProductFacilitated($item->product_id)
61
+ );
62
+ }
63
+ }
64
+ return @json_encode($items);
65
+ }
66
+
67
+ public function isSalesTrackingEnabled()
68
+ {
69
+ $trackSales = Mage::getStoreConfig('Boxalino_General/tracker/analytics');
70
+ return ($trackSales == 1);
71
+ }
72
+
73
+ public function reportPageView()
74
+ {
75
+ if ($this->isAnalyticsEnabled()) {
76
+ $script = "_bxq.push(['trackPageView']);" . PHP_EOL;
77
+ return $script;
78
+ } else {
79
+ return '';
80
+ }
81
+ }
82
+
83
+ public function isAnalyticsEnabled()
84
+ {
85
+ $trackSales = Mage::getStoreConfig('Boxalino_General/tracker/analytics');
86
+ return ($trackSales == 1);
87
+ }
88
+
89
+ public function reportSearch($term, $filters = null)
90
+ {
91
+ if ($this->isAnalyticsEnabled()) {
92
+ $logTerm = addslashes($term);
93
+ $script = "_bxq.push(['trackSearch', '" . $logTerm . "', " . json_encode($filters) . "]);" . PHP_EOL;
94
+ return $script;
95
+ } else {
96
+ return '';
97
+ }
98
+ }
99
+
100
+ public function reportProductView($product)
101
+ {
102
+ if ($this->isAnalyticsEnabled()) {
103
+ $script = "_bxq.push(['trackProductView', '" . $product . "'])" . PHP_EOL;
104
+ return $script;
105
+ } else {
106
+ return '';
107
+ }
108
+ }
109
+
110
+ public function reportAddToBasket($product, $count, $price, $currency)
111
+ {
112
+ if ($this->isAnalyticsEnabled()) {
113
+ $script = "_bxq.push(['trackAddToBasket', '" . $product . "', " . $count . ", " . $price . ", '" . $currency . "']);" . PHP_EOL;
114
+ return $script;
115
+ } else {
116
+ return '';
117
+ }
118
+ }
119
+
120
+ public function reportCategoryView($categoryID)
121
+ {
122
+ if ($this->isAnalyticsEnabled()) {
123
+ $script = "_bxq.push(['trackCategoryView', '" . $categoryID . "'])" . PHP_EOL;
124
+ return $script;
125
+ } else {
126
+ return '';
127
+ }
128
+ }
129
+
130
+ public function reportLogin($customerId)
131
+ {
132
+ if ($this->isAnalyticsEnabled()) {
133
+ $script = "_bxq.push(['trackLogin', '" . $customerId . "'])" . PHP_EOL;
134
+ return $script;
135
+ } else {
136
+ return '';
137
+ }
138
+ }
139
+
140
+
141
+ /**
142
+ * @param $products array example:
143
+ * <code>
144
+ * array(
145
+ * array('product' => 'PRODUCTID1', 'quantity' => 1, 'price' => 59.90),
146
+ * array('product' => 'PRODUCTID2', 'quantity' => 2, 'price' => 10.0)
147
+ * )
148
+ * </code>
149
+ * @param $orderId string
150
+ * @param $price number
151
+ * @param $currency string
152
+ */
153
+ public function reportPurchase($products, $orderId, $price, $currency)
154
+ {
155
+ $trackSales = Mage::getStoreConfig('Boxalino_General/tracker/track_sales');
156
+
157
+ $productsJson = json_encode($products);
158
+ if ($trackSales == 1) {
159
+ $script = "_bxq.push([" . PHP_EOL;
160
+ $script .= "'trackPurchase'," . PHP_EOL;
161
+ $script .= $price . "," . PHP_EOL;
162
+ $script .= "'" . $currency . "'," . PHP_EOL;
163
+ $script .= $productsJson . "," . PHP_EOL;
164
+ $script .= $orderId . "" . PHP_EOL;
165
+ $script .= "]);" . PHP_EOL;
166
+ return $script;
167
+ } else {
168
+ return '';
169
+ }
170
+ }
171
+
172
+ public function getLoggedInUserId()
173
+ {
174
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
175
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
176
+ return $customerData->getId();
177
+ } else {
178
+ return null;
179
+ }
180
+ }
181
+
182
+ public function getAccount()
183
+ {
184
+ $isDev = Mage::getStoreConfig('Boxalino_General/general/account_dev');
185
+ $account = Mage::getStoreConfig('Boxalino_General/general/di_account');
186
+
187
+ if ($isDev) {
188
+ return $account . '_dev';
189
+ }
190
+ return $account;
191
+ }
192
+
193
+ public function scriptBegin()
194
+ {
195
+ $account = Mage::getStoreConfig('Boxalino_General/general/di_account');
196
+
197
+ $script = '<script type="text/javascript">' . PHP_EOL;
198
+ $script .= 'var _bxq = _bxq || [];' . PHP_EOL;
199
+ $script .= "_bxq.push(['setAccount', '" . $account . "']);" . PHP_EOL;
200
+
201
+ echo $script;
202
+ }
203
+
204
+ public function scriptEnd()
205
+ {
206
+ $script = "(function(){
207
+ var s = document.createElement('script');
208
+ s.async = 1;
209
+ s.src = '//cdn.bx-cloud.com/frontend/rc/js/ba.min.js';
210
+ document.getElementsByTagName('head')[0].appendChild(s);
211
+ })();" . PHP_EOL;
212
+
213
+ $script .= '</script>' . PHP_EOL;
214
+
215
+ echo $script;
216
+ }
217
+
218
+ public function getFiltersValues($params)
219
+ {
220
+ $filters = new stdClass();
221
+ if(isset($params['cat'])) {
222
+ $filters->filter_hc_category = '';
223
+ $category = Mage::getModel('catalog/category')->load($params['cat']);
224
+ $categories = explode('/', $category->getPath());
225
+ foreach ($categories as $cat) {
226
+ $name = $category = Mage::getModel('catalog/category')->load($cat)->getName();
227
+ if(strpos($name, '/') !== false) {
228
+ $name = str_replace('/', '\/', $name);
229
+ }
230
+ $filters->filter_hc_category .= '/'.$name;
231
+
232
+ }
233
+ unset($params['cat']);
234
+ }
235
+
236
+ if(isset($params['price'])) {
237
+ $prices = explode('-', $params['price']);
238
+ if(!empty($prices[0])) {
239
+ $filters->filter_from_incl_price = $prices[0];
240
+ }
241
+ if(!empty($prices[1])) {
242
+ $filters->filter_to_incl_price = $prices[1];
243
+ }
244
+ unset($params['price']);
245
+ }
246
+ if(isset($params)) {
247
+ foreach ($params as $param => $values) {
248
+ $getAttribute = Mage::getModel('catalog/product')->getResource()->getAttribute($param);
249
+ if($getAttribute !== false) {
250
+ $values = html_entity_decode($values);
251
+ preg_match_all('!\d+!', $values, $matches);
252
+ if (is_array($matches[0])) {
253
+ $attrValues = array();
254
+ foreach ($matches[0] as $id) {
255
+ $paramName = 'filter_' . $param;
256
+ $attribute = $attribute = $getAttribute->getSource()->getOptionText($id);
257
+ $attrValues[] = $attribute;
258
+ }
259
+ $filters->$paramName = $attrValues;
260
+ }
261
+ }
262
+ }
263
+ }
264
+ return $filters;
265
+ }
266
+
267
+ /**
268
+ * Modifies a string to remove all non ASCII characters and spaces.
269
+ */
270
+ public function sanitizeFieldName($text)
271
+ {
272
+
273
+ $maxLength = 50;
274
+ $delimiter = "_";
275
+
276
+ // replace non letter or digits by -
277
+ $text = preg_replace('~[^\\pL\d]+~u', $delimiter, $text);
278
+
279
+ // trim
280
+ $text = trim($text, $delimiter);
281
+
282
+ // transliterate
283
+ if (function_exists('iconv'))
284
+ {
285
+ $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
286
+ }
287
+
288
+ // lowercase
289
+ $text = strtolower($text);
290
+
291
+ // remove unwanted characters
292
+ $text = preg_replace('~[^_\w]+~', '', $text);
293
+
294
+ if (empty($text))
295
+ {
296
+ return null;
297
+ }
298
+
299
+ // max $maxLength (50) chars
300
+ $text = substr($text, 0, $maxLength);
301
+ $text = trim($text, $delimiter);
302
+
303
+ return $text;
304
+ }
305
+
306
+ }
app/code/local/Boxalino/CemSearch/Helper/P13n/Adapter.php ADDED
@@ -0,0 +1,423 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User: Michal Sordyl
4
+ * Mail: michal.sordyl@codete.co
5
+ * Date: 28.05.14
6
+ */
7
+
8
+ class Boxalino_CemSearch_Helper_P13n_Adapter
9
+ {
10
+ private $config = null;
11
+ private $p13n = null;
12
+ private $autocompleteRequest = null;
13
+ private $choiceRequest = null;
14
+ private $autocompleteResponse = null;
15
+ private $choiceResponse = null;
16
+ private $returnFields = null;
17
+ private $inquiry = null;
18
+ private $searchQuery = null;
19
+ private $filters = array();
20
+ const VISITOR_COOKIE_TIME = 31536000;
21
+
22
+ public function __construct(Boxalino_CemSearch_Helper_P13n_Config $config)
23
+ {
24
+ $this->config = $config;
25
+ $this->p13n = new HttpP13n();
26
+ $this->configureP13n();
27
+ $this->createChoiceRequest();
28
+ }
29
+
30
+ private function configureP13n()
31
+ {
32
+ $this->p13n->setHost($this->config->getHost());
33
+ $this->p13n->setAuthorization($this->config->getUsername(), $this->config->getPassword());
34
+ }
35
+
36
+ private function createChoiceRequest()
37
+ {
38
+ $this->choiceRequest = $this->p13n->getChoiceRequest($this->config->getAccount(), $this->config->getDomain());
39
+ }
40
+
41
+ public function __destruct()
42
+ {
43
+ unset($this->p13n);
44
+ }
45
+
46
+ /**
47
+ * @param String $choiceId can be found on admin page /Recommendations/Widgets
48
+ * @param String test to search, eg 'shirt'
49
+ * @param String $language 2 letter language code, eg 'en'
50
+ * @param array $returnFields of field names, eg array('id', 'name')
51
+ * @param P13nSort $sort array('fieldName' => , 'reverse' =>);
52
+ * @param int $offset products to skip
53
+ * @param int $hitCount how many records
54
+ */
55
+ public function setupInquiry($choiceId, $search, $language, $returnFields, $sort, $offset = 0, $hitCount = 10)
56
+ {
57
+ $this->inquiry = $this->createInquiry();
58
+ $this->returnFields = $returnFields;
59
+ $this->createAndSetUpSearchQuery($search, $language, $returnFields, $offset, $hitCount);
60
+ $this->setUpSorting($sort);
61
+
62
+ $this->inquiry->choiceId = $choiceId;
63
+
64
+ }
65
+
66
+ private function createInquiry()
67
+ {
68
+ $inquiry = new \com\boxalino\p13n\api\thrift\ChoiceInquiry();
69
+ return $inquiry;
70
+ }
71
+
72
+ private function createAndSetUpSearchQuery($search, $language, $returnFields, $offset, $hitCount)
73
+ {
74
+ $this->searchQuery = new \com\boxalino\p13n\api\thrift\SimpleSearchQuery();
75
+ $this->searchQuery->queryText = $search;
76
+ $this->searchQuery->indexId = $this->config->getAccount();
77
+ $this->searchQuery->language = $language;
78
+ $this->searchQuery->returnFields = $returnFields;
79
+ $this->searchQuery->offset = $offset;
80
+ $this->searchQuery->hitCount = $hitCount;
81
+ }
82
+
83
+ private function setUpSorting(Boxalino_CemSearch_Helper_P13n_Sort $sorting)
84
+ {
85
+ $sortFieldsArray = $sorting->getSorts();
86
+ $sortFields = array();
87
+ foreach ($sortFieldsArray as $sortField) {
88
+ $sortFields[] = new \com\boxalino\p13n\api\thrift\SortField(array(
89
+ 'fieldName' => $sortField['fieldName'],
90
+ 'reverse' => $sortField['reverse']
91
+ ));
92
+ }
93
+ if (!empty($sortFields)) {
94
+ $this->searchQuery->sortFields = $sortFields;
95
+ }
96
+ }
97
+
98
+ /**
99
+ * @param int $hierarchyId how deep is category tree in search, starts from 0 for main categories
100
+ * @param array $category names of categories in hierarchy
101
+ *
102
+ * exaples:
103
+ * $hierarchyId = 0;
104
+ * $category = array('Men');
105
+ * will search all products in category 'Men' (with subcategories)
106
+ *
107
+ * $hierarchyId = 1;
108
+ * $category = array('Men', 'Blazers');
109
+ * will search all products in category 'Men' (with subcategories)
110
+ *
111
+ */
112
+ public function addFilterCategories($categoryId)
113
+ {
114
+ $categoryNames = array();
115
+ if (isset($categoryId) && $categoryId > 0) {
116
+ $category = Mage::getModel('catalog/category')->load($categoryId);
117
+ $path = $category->getPath();
118
+ $pathArray = explode('/', $path);
119
+ $skip = -2;
120
+ foreach ($pathArray as $catId) {
121
+ $categoryName = Mage::getModel('catalog/category')->load($catId)->getName();
122
+
123
+ if (++$skip > 0) {
124
+ $categoryNames[] = $categoryName;
125
+ }
126
+ }
127
+ // $categoryDepth = count($categoryNames) - 1;
128
+
129
+ $this->addFilterHierarchy('categories', $categoryId, $categoryNames);
130
+
131
+ }
132
+ }
133
+
134
+ /**
135
+ * @param $categoryId
136
+ */
137
+ public function addFilterCategory($categoryId){
138
+
139
+ if (isset($categoryId) && $categoryId > 0){
140
+ $category = Mage::getModel('catalog/category')->load($categoryId);
141
+
142
+ if($category != null){
143
+ // $this->addFilterHierarchy('categories', $categoryId, $category->getName());
144
+ $filter = new \com\boxalino\p13n\api\thrift\Filter();
145
+
146
+ $filter->fieldName = 'categories';
147
+
148
+ $filter->hierarchyId = $categoryId;
149
+ $filter->hierarchy = array($category->getName());
150
+
151
+ $this->filters[] = $filter;
152
+ }
153
+
154
+ }
155
+
156
+ }
157
+
158
+ /**
159
+ * @param string $field field name for filter
160
+ * @param int $hierarchyId names of categories in hierarchy
161
+ * @param int $hierarchy names of categories in hierarchy
162
+ * @param string|null $lang
163
+ *
164
+ */
165
+ public function addFilterHierarchy($field, $hierarchyId, $hierarchy, $lang = null)
166
+ {
167
+ $filter = new \com\boxalino\p13n\api\thrift\Filter();
168
+
169
+ if ($lang) {
170
+ $filter->fieldName = $field . '_' . substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2);
171
+ } else {
172
+ $filter->fieldName = $field;
173
+ }
174
+
175
+ $filter->hierarchyId = $hierarchyId;
176
+ $filter->hierarchy = $hierarchy;
177
+
178
+ $this->filters[] = $filter;
179
+ }
180
+
181
+ /**
182
+ * @param float $from
183
+ * @param float $to
184
+ */
185
+ public function setupPrice($from, $to)
186
+ {
187
+ $this->filters[] = new \com\boxalino\p13n\api\thrift\Filter(array(
188
+ 'fieldName' => 'discountedPrice',
189
+ 'rangeFrom' => $from,
190
+ 'rangeTo' => $to
191
+ ));
192
+ }
193
+
194
+ /**
195
+ * @param string $field field name for filter
196
+ * @param mixed $value filter value
197
+ * @param string|null $lang
198
+ *
199
+ */
200
+ public function addFilter($field, $value, $lang = null)
201
+ {
202
+ $filter = new \com\boxalino\p13n\api\thrift\Filter();
203
+
204
+ if ($lang) {
205
+ $filter->fieldName = $field . '_' . substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2);
206
+ } else {
207
+ $filter->fieldName = $field;
208
+ }
209
+
210
+ if (is_array($value)) {
211
+ $filter->stringValues = $value;
212
+ } else {
213
+ $filter->stringValues = array($value);
214
+ }
215
+
216
+ $this->filters[] = $filter;
217
+ }
218
+
219
+ /**
220
+ * @param string $field field name for filter
221
+ * @param number $from param from
222
+ * @param number $to param from
223
+ * @param string|null $lang
224
+ *
225
+ */
226
+ public function addFilterFromTo($field, $from, $to, $lang = null)
227
+ {
228
+ $filter = new \com\boxalino\p13n\api\thrift\Filter();
229
+
230
+ if ($lang) {
231
+ $filter->fieldName = $field . '_' . substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2);
232
+ } else {
233
+ $filter->fieldName = $field;
234
+ }
235
+
236
+ $filter->rangeFrom = $from;
237
+ $filter->rangeTo = $to;
238
+
239
+ $this->filters[] = $filter;
240
+ }
241
+
242
+ public function autocomplete($text, $limit, $products_limit = 0)
243
+ {
244
+ $choiceId = 'autocomplete';
245
+ $fields = array(Mage::getStoreConfig('Boxalino_General/search/entity_id'), 'title', 'score');
246
+ $this->autocompleteRequest = $this->getAutocompleteRequest($this->config->getAccount(), $this->config->getDomain());
247
+
248
+ $searchQuery = new \com\boxalino\p13n\api\thrift\SimpleSearchQuery();
249
+ $searchQuery->indexId = $this->config->getAccount();
250
+ $searchQuery->language = substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2);
251
+ $searchQuery->returnFields = $fields;
252
+ $searchQuery->offset = 0;
253
+ $searchQuery->hitCount = $products_limit;
254
+ $searchQuery->queryText = $text;
255
+
256
+ $autocompleteQuery = new \com\boxalino\p13n\api\thrift\AutocompleteQuery();
257
+ $autocompleteQuery->indexId = $this->config->getAccount();
258
+ $autocompleteQuery->language = substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2);
259
+ $autocompleteQuery->queryText = $text;
260
+ $autocompleteQuery->suggestionsHitCount = $limit;
261
+
262
+ $this->autocompleteRequest->choiceId = $choiceId;
263
+ $this->autocompleteRequest->autocompleteQuery = $autocompleteQuery;
264
+ $this->autocompleteRequest->searchChoiceId = $choiceId;
265
+ $this->autocompleteRequest->searchQuery = $searchQuery;
266
+ $this->autocompleteResponse = $this->p13n->autocomplete($this->autocompleteRequest);
267
+
268
+ }
269
+
270
+ public function getAutocompleteEntities()
271
+ {
272
+ $suggestions = array();
273
+
274
+ foreach ($this->autocompleteResponse->hits as $hit) {
275
+ $suggestions[] = array('text' => $hit->suggestion, 'hits' => $hit->searchResult->totalHitCount);
276
+ }
277
+ return $suggestions;
278
+ }
279
+
280
+ public function getAutocompleteProducts()
281
+ {
282
+ $products = array();
283
+
284
+ foreach ($this->autocompleteResponse->hits as $hit) {
285
+ $id = substr(md5($hit->suggestion), 0, 10);
286
+ $products[$id] = array();
287
+ foreach ($hit->searchResult->hits as $productsHit) {
288
+ $products[$id][] = array(
289
+ 'id' => $productsHit->values[Mage::getStoreConfig('Boxalino_General/search/entity_id')][0],
290
+ 'score' => $productsHit->values['score'][0],
291
+ );
292
+ }
293
+ }
294
+ return $products;
295
+ }
296
+
297
+ public function search()
298
+ {
299
+ if (!empty($this->filters)) {
300
+ $this->searchQuery->filters = $this->filters;
301
+ }
302
+ $this->inquiry->simpleSearchQuery = $this->searchQuery;
303
+ $this->choiceRequest->inquiries = array($this->inquiry);
304
+ $this->choiceResponse = $this->p13n->choose($this->choiceRequest);
305
+ }
306
+
307
+ public function getEntitiesIds()
308
+ {
309
+ $result = array();
310
+ foreach ($this->choiceResponse->variants as $variant) {
311
+ /** @var \com\boxalino\p13n\api\thrift\SearchResult $searchResult */
312
+ $searchResult = $variant->searchResult;
313
+ foreach ($searchResult->hits as $item) {
314
+ $result[] = $item->values[Mage::getStoreConfig('Boxalino_General/search/entity_id')][0];
315
+ }
316
+ }
317
+ return $result;
318
+ }
319
+
320
+ public function getEntities()
321
+ {
322
+ $result = array();
323
+ foreach ($this->choiceResponse->variants as $variant) {
324
+ /** @var \com\boxalino\p13n\api\thrift\SearchResult $searchResult */
325
+ $searchResult = $variant->searchResult;
326
+ foreach ($searchResult->hits as $item) {
327
+ $result[] = $item->values;
328
+ }
329
+ }
330
+ return $result;
331
+ }
332
+
333
+ public function printData()
334
+ {
335
+ $results = array();
336
+ /** @var \com\boxalino\p13n\api\thrift\Variant $variant */
337
+ foreach ($this->choiceResponse->variants as $variant) {
338
+ /** @var \com\boxalino\p13n\api\thrift\SearchResult $searchResult */
339
+ $searchResult = $variant->searchResult;
340
+ foreach ($searchResult->hits as $item) {
341
+ $result = array();
342
+ foreach ($item->values as $key => $value) {
343
+ if (is_array($value) && count($value) == 1) {
344
+ $result[$key] = array_shift($value);
345
+ } else {
346
+ $result[$key] = $value;
347
+ }
348
+ }
349
+ // Widget's meta data, mostly used for event tracking
350
+ $result['_widgetTitle'] = $variant->searchResultTitle;
351
+ $results[] = $result;
352
+ }
353
+ }
354
+
355
+ echo '<table border="1">';
356
+ echo '<tr>';
357
+
358
+ foreach ($this->returnFields as $field) {
359
+ echo '<td>' . $field . '</td>';
360
+ }
361
+ echo '</tr>';
362
+
363
+ foreach ($results as $result) {
364
+ echo '<tr>';
365
+ foreach ($this->returnFields as $field) {
366
+ echo '<td>' . $result[$field] . '</td>';
367
+ }
368
+ echo '</tr>';
369
+ }
370
+ echo '</table>';
371
+
372
+ }
373
+
374
+ /**
375
+ * @param string $accountname
376
+ * @param string $cookieDomain
377
+ * @return \com\boxalino\p13n\api\thrift\AutocompleteRequest
378
+ */
379
+ private function getAutocompleteRequest($accountname, $cookieDomain = null)
380
+ {
381
+ $request = new \com\boxalino\p13n\api\thrift\AutocompleteRequest();
382
+
383
+ // Setup information about account
384
+ $userRecord = new \com\boxalino\p13n\api\thrift\UserRecord();
385
+ $userRecord->username = $accountname;
386
+ $request->userRecord = $userRecord;
387
+
388
+ if (empty($_COOKIE['cems'])) {
389
+ $sessionid = session_id();
390
+ if (empty($sessionid)) {
391
+ session_start();
392
+ $sessionid = session_id();
393
+ }
394
+ } else {
395
+ $sessionid = $_COOKIE['cems'];
396
+ }
397
+
398
+ if (empty($_COOKIE['cemv'])) {
399
+ $profileid = '';
400
+ if (function_exists('openssl_random_pseudo_bytes')) {
401
+ $profileid = bin2hex(openssl_random_pseudo_bytes(16));
402
+ }
403
+ if (empty($profileid)) {
404
+ $profileid = uniqid('', true);
405
+ }
406
+ } else {
407
+ $profileid = $_COOKIE['cemv'];
408
+ }
409
+ $request->profileId = $profileid;
410
+
411
+ // Refresh cookies
412
+ if (empty($cookieDomain)) {
413
+ setcookie('cems', $sessionid, 0);
414
+ setcookie('cemv', $profileid, time() + self::VISITOR_COOKIE_TIME);
415
+ } else {
416
+ setcookie('cems', $sessionid, 0, '/', $cookieDomain);
417
+ setcookie('cemv', $profileid, time() + 1800, '/', self::VISITOR_COOKIE_TIME);
418
+ }
419
+
420
+ return $request;
421
+ }
422
+
423
+ }
app/code/local/Boxalino/CemSearch/Helper/P13n/Client.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Boxalino_CemSearch_Helper_P13n_Client
4
+ {
5
+ protected $p13nServerHost = 'cdn.bx-cloud.com';
6
+ protected $p13nServerPort = 443;
7
+ protected $productIdFieldName;
8
+ protected $account;
9
+ protected $password;
10
+ protected $language;
11
+ protected $isDevelopment = false;
12
+ protected $p13n;
13
+
14
+ /**
15
+ * @param string $account
16
+ * @param array $authData
17
+ * @param string $language
18
+ * @param bool $isDevelopment
19
+ * @param int $entityIdFieldName
20
+ */
21
+ public function __construct($account, $authData, $language, $entityIdFieldName, $isDevelopment = false)
22
+ {
23
+
24
+ $this->productIdFieldName = $entityIdFieldName;
25
+
26
+ $this->account = $account;
27
+ $this->language = $language;
28
+ $this->isDevelopment = $isDevelopment;
29
+ // Created here first to load necessary files
30
+ $this->p13n = $this->createP13n($authData);
31
+ }
32
+
33
+ /**
34
+ * @return P13n
35
+ */
36
+ private function createP13n($authData)
37
+ {
38
+ $p13n = new HttpP13n();
39
+ $p13n->setHost($this->p13nServerHost);
40
+ $p13n->setAuthorization($authData['username'], $authData['password']);
41
+ return $p13n;
42
+ }
43
+
44
+ /**
45
+ * @param string $name
46
+ * @param array $returnFields
47
+ * @param int|null $minimumRecommendations
48
+ * @param int|null $maximumRecommendations
49
+ * @param string|null $scenario
50
+ * @return array
51
+ */
52
+ public function getPersonalRecommendations(array $widgets, array $returnFields, $widgetType)
53
+ {
54
+ $variantNames = array();
55
+ $choiceRequest = $this->createChoiceRequest();
56
+ foreach($widgets as $widget) {
57
+ $name = $widget['name'];
58
+ $variantNames[] = $name;
59
+ $minimumRecommendations = (float) $widget['min_recs'];
60
+ $maximumRecommendations = (float) $widget['max_recs'];
61
+ if ($maximumRecommendations === null) {
62
+ $maximumRecommendations = 5;
63
+ }
64
+
65
+ $inquiry = $this->createChoiceInquiry($name);
66
+
67
+ $searchQuery = $this->createSearchQuery($returnFields);
68
+ $searchQuery->offset = 0;
69
+ $searchQuery->hitCount = $maximumRecommendations;
70
+
71
+ $inquiry->simpleSearchQuery = $searchQuery;
72
+ $inquiry->minHitCount = $minimumRecommendations;
73
+ if ($widgetType === 'basket' && $_REQUEST['basketContent']) {
74
+ $basketContent = json_decode($_REQUEST['basketContent'], true);
75
+ if ($basketContent !== false && count($basketContent)) {
76
+ $contextItems = array();
77
+
78
+ // Sort basket content by price
79
+ usort($basketContent, function ($a, $b) {
80
+ if ($a['price'] > $b['price']) {
81
+ return -1;
82
+ } elseif ($b['price'] > $a['price']) {
83
+ return 1;
84
+ }
85
+ return 0;
86
+ });
87
+
88
+ $basketItem = array_shift($basketContent);
89
+
90
+ $contextItem = new \com\boxalino\p13n\api\thrift\ContextItem();
91
+ $contextItem->indexId = $this->account;
92
+ $contextItem->fieldName = $this->productIdFieldName;
93
+ $contextItem->contextItemId = $basketItem['id'];
94
+ $contextItem->role = 'mainProduct';
95
+
96
+ $contextItems[] = $contextItem;
97
+
98
+ foreach ($basketContent as $basketItem) {
99
+ $contextItem = new \com\boxalino\p13n\api\thrift\ContextItem();
100
+ $contextItem->indexId = $this->account;
101
+ $contextItem->fieldName = $this->productIdFieldName;
102
+ $contextItem->contextItemId = $basketItem['id'];
103
+ $contextItem->role = 'subProduct';
104
+
105
+ $contextItems[] = $contextItem;
106
+ }
107
+ $inquiry->contextItems = $contextItems;
108
+ }
109
+ } elseif ($widgetType === 'product' && !empty($_REQUEST['productId'])) {
110
+ $productId = $_REQUEST['productId'];
111
+ $contextItem = new \com\boxalino\p13n\api\thrift\ContextItem();
112
+ $contextItem->indexId = $this->account;
113
+ $contextItem->fieldName = $this->productIdFieldName;
114
+ $contextItem->contextItemId = $productId;
115
+ $contextItem->role = 'mainProduct';
116
+ $inquiry->contextItems = array($contextItem);
117
+ }
118
+ // elseif ($widgetType === 'category' && Utils::requestExists('categoryId')) {
119
+ // $categoryId = Utils::requestString('categoryId');
120
+ // $choiceRequest->requestContext->parameters['category_id'] = array($categoryId);
121
+ // }
122
+ $choiceRequest->inquiries[] = $inquiry;
123
+ }
124
+ $choiceResponse = $this->p13n->choose($choiceRequest);
125
+ $results = array();
126
+ /** @var \com\boxalino\p13n\api\thrift\Variant $variant */
127
+ foreach ($choiceResponse->variants as $variantId => $variant) {
128
+ $name = $variantNames[$variantId];
129
+ foreach ($variant->searchResult->hits as $item) {
130
+ $result = array();
131
+ foreach ($item->values as $key => $value) {
132
+ if (is_array($value) && count($value) == 1) {
133
+ $result[$key] = array_shift($value);
134
+ } else {
135
+ $result[$key] = $value;
136
+ }
137
+ }
138
+ if (!isset($result['name']) && isset($result['title'])) {
139
+ $result['name'] = $result['title'];
140
+ }
141
+
142
+ $result['_rule'] = $name . ':' . $variant->scenarioId . ':' . $variant->variantId;
143
+ $result['_choice'] = $name;
144
+ $result['_scenario'] = $variant->scenarioId;
145
+ $result['_variant'] = $variant->variantId;
146
+ $results[$name][] = $result;
147
+ }
148
+ }
149
+ return $results;
150
+ }
151
+
152
+ /**
153
+ * @return \com\boxalino\p13n\api\thrift\ChoiceRequest
154
+ */
155
+ protected function createChoiceRequest()
156
+ {
157
+ $choiceRequest = new \com\boxalino\p13n\api\thrift\ChoiceRequest();
158
+ $choiceRequest->profileId = $this->getVisitorId();
159
+
160
+ $userRecord = new \com\boxalino\p13n\api\thrift\UserRecord();
161
+ $userRecord->username = $this->account;
162
+
163
+ $choiceRequest->userRecord = $userRecord;
164
+
165
+ return $choiceRequest;
166
+ }
167
+
168
+ /**
169
+ * @return string
170
+ */
171
+ protected function getVisitorId()
172
+ {
173
+ $profileid = null;
174
+ if (empty($_COOKIE['cemv'])) {
175
+ $profileid = '';
176
+ if (function_exists('openssl_random_pseudo_bytes')) {
177
+ $profileid = bin2hex(openssl_random_pseudo_bytes(16));
178
+ }
179
+ if (empty($profileid)) {
180
+ $profileid = uniqid('', true);
181
+ }
182
+ } else {
183
+ $profileid = $_COOKIE['cemv'];
184
+ }
185
+
186
+ return $profileid;
187
+ }
188
+
189
+ /**
190
+ * @param string $name Choice name
191
+ * @param string|null $scope Choice scope (null for default)
192
+ * @return \com\boxalino\p13n\api\thrift\ChoiceInquiry
193
+ */
194
+ protected function createChoiceInquiry($name, $scope = null)
195
+ {
196
+ $inquiry = new \com\boxalino\p13n\api\thrift\ChoiceInquiry();
197
+ $inquiry->choiceId = $name;
198
+ if ($scope !== null) {
199
+ $inquiry->scope = $scope;
200
+ }
201
+ return $inquiry;
202
+ }
203
+
204
+ /**
205
+ * @param array $returnFields
206
+ * @param string|null $query
207
+ * @return \com\boxalino\p13n\api\thrift\SimpleSearchQuery
208
+ */
209
+ protected function createSearchQuery(array $returnFields, $query = null)
210
+ {
211
+ $searchQuery = new \com\boxalino\p13n\api\thrift\SimpleSearchQuery();
212
+ $searchQuery->indexId = $this->account;
213
+ if ($query !== null) {
214
+ $searchQuery->queryText = $query;
215
+ }
216
+ $searchQuery->language = $this->language;
217
+ $searchQuery->returnFields = $returnFields;
218
+
219
+ return $searchQuery;
220
+ }
221
+
222
+ /**
223
+ * @return string
224
+ */
225
+ protected function getBigDataHost()
226
+ {
227
+ $hostname = gethostname();
228
+ if (preg_match('#^c[0-9]+n([0-9]+)$#', $hostname, $match)) {
229
+ return 'bd' . $match[1] . '.bx-cloud.com';
230
+ }
231
+ return $this->p13nServerHost;
232
+ }
233
+ }
app/code/local/Boxalino/CemSearch/Helper/P13n/Config.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * User: Michal Sordyl
5
+ * Mail: michal.sordyl@codete.co
6
+ * Date: 28.05.14
7
+ */
8
+ class Boxalino_CemSearch_Helper_P13n_Config
9
+ {
10
+ private $host;
11
+ private $account;
12
+ private $username;
13
+ private $password;
14
+ private $domain;
15
+ private $indexId;
16
+
17
+ /**
18
+ * @param $host your boxalino server host, eg cdn.bx-cloud.com
19
+ * @param $account name of account
20
+ * @param $username username for API. One user may have many accounts (above).
21
+ * @param $password password for username
22
+ * @param $domain shop domain
23
+ * @param $indexId propably same as account name
24
+ */
25
+ public function __construct($host, $account, $username, $password, $domain)
26
+ {
27
+ $this->host = $host;
28
+ $this->account = $account;
29
+ $this->username = $username;
30
+ $this->password = $password;
31
+ $this->domain = $domain;
32
+ }
33
+
34
+ public function getAccount()
35
+ {
36
+ return $this->account;
37
+ }
38
+
39
+ public function getDomain()
40
+ {
41
+ return $this->domain;
42
+ }
43
+
44
+ public function getHost()
45
+ {
46
+ return $this->host;
47
+ }
48
+
49
+ public function getPassword()
50
+ {
51
+ return $this->password;
52
+ }
53
+
54
+ public function getUsername()
55
+ {
56
+ return $this->username;
57
+ }
58
+
59
+ }
app/code/local/Boxalino/CemSearch/Helper/P13n/Recommendation.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by: Szymon Nosal <szymon.nosal@codete.com>
5
+ * Created at: 12.06.14 16:36
6
+ */
7
+ class Boxalino_CemSearch_Helper_P13n_Recommendation
8
+ {
9
+ private $returnFields = array('id');
10
+ private $results = array();
11
+
12
+ public static function Instance()
13
+ {
14
+ static $inst = null;
15
+ if ($inst === null) {
16
+ $inst = new Boxalino_CemSearch_Helper_P13n_Recommendation();
17
+ }
18
+ return $inst;
19
+ }
20
+
21
+ public function getRecommendation($widgetType, $widgetName)
22
+ {
23
+ if(empty($this->results)) {
24
+ $widgets = $this->prepareWidgets($widgetType);
25
+ if (empty($widgets)) {
26
+ return null;
27
+ }
28
+ $account = Mage::helper('Boxalino_CemSearch')->getAccount();
29
+ $language = substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2);
30
+ $returnFields = $this->returnFields;
31
+
32
+ $entity_id = Mage::getStoreConfig('Boxalino_General/search/entity_id');
33
+ $authData['username'] = Mage::getStoreConfig('Boxalino_General/general/p13n_username');
34
+ $authData['password'] = Mage::getStoreConfig('Boxalino_General/general/p13n_password');
35
+ $entityIdFieldName = 'entity_id';
36
+ if (isset($entity_id) && $entity_id !== '') {
37
+ $entityIdFieldName = $entity_id;
38
+ }
39
+ $p13nClient = new Boxalino_CemSearch_Helper_P13n_Client($account, $authData, $language, $entityIdFieldName, true);
40
+ $this->results = $p13nClient->getPersonalRecommendations($widgets, $returnFields, $widgetType);
41
+ }
42
+ return $this->results[$widgetName];
43
+ }
44
+
45
+ private function prepareWidgets($widgetType)
46
+ {
47
+ $widgets = array();
48
+ $recommendations = Mage::getStoreConfig('Boxalino_Recommendation');
49
+ foreach($recommendations as $recommendation) {
50
+ if(
51
+ (!empty($recommendation['min']) || $recommendation['min'] >= 0) &&
52
+ (!empty($recommendation['max']) || $recommendation['max'] >= 0) &&
53
+ !empty($recommendation['scenario']) &&
54
+ ($recommendation['min'] <= $recommendation['max']) &&
55
+ $recommendation['status'] == true) {
56
+ if ($recommendation['scenario'] == $widgetType) {
57
+ $widgets[] = array('name' => $recommendation['widget'], 'min_recs' => $recommendation['min'], 'max_recs' => $recommendation['max']);
58
+ }
59
+ }
60
+ }
61
+ return $widgets;
62
+ }
63
+ }
app/code/local/Boxalino/CemSearch/Helper/P13n/Sort.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * User: Michal Sordyl
5
+ * Mail: michal.sordyl@codete.co
6
+ * Date: 02.06.14
7
+ */
8
+ class Boxalino_CemSearch_Helper_P13n_Sort
9
+ {
10
+ private $sorts = array();
11
+
12
+ /**
13
+ * @param array $sorts array(array('fieldName' => , 'reverse' => ), ..... )
14
+ */
15
+ public function __construct($sorts = array())
16
+ {
17
+ foreach ($sorts as $sort) {
18
+ $this->push($sort['fieldName'], $sort['order']);
19
+ }
20
+ }
21
+
22
+ /**
23
+ * @param $field name od field to sort by
24
+ * @param $reverse true for ASC, false for DESC
25
+ */
26
+ public function push($field, $reverse)
27
+ {
28
+ $this->sorts[] = array('fieldName' => $field, 'reverse' => $reverse);
29
+ }
30
+
31
+ public function getSorts()
32
+ {
33
+ return $this->sorts;
34
+ }
35
+
36
+ }
app/code/local/Boxalino/CemSearch/Lib/AbstractThrift.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class AbstractThrift
4
+ {
5
+ protected static $thriftClassLoader = null;
6
+
7
+ protected $dependencies = array();
8
+
9
+ public function __construct()
10
+ {
11
+ if (self::$thriftClassLoader === null) {
12
+ $this->initClassLoader();
13
+ }
14
+ }
15
+
16
+ protected function initClassLoader()
17
+ {
18
+ require_once(__DIR__ . '/vendor/Thrift/ClassLoader/ThriftClassLoader.php');
19
+ self::$thriftClassLoader = new \Thrift\ClassLoader\ThriftClassLoader(false);
20
+ self::$thriftClassLoader->registerNamespace('Thrift', __DIR__ . '/vendor');
21
+ self::$thriftClassLoader->register();
22
+ foreach ($this->dependencies as $dependency) {
23
+ require_once($dependency);
24
+ }
25
+ }
26
+
27
+ abstract protected function getClient($clientId = '');
28
+ }
app/code/local/Boxalino/CemSearch/Lib/P13nService.php ADDED
@@ -0,0 +1,729 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace com\boxalino\p13n\api\thrift;
3
+ /**
4
+ * Autogenerated by Thrift Compiler (0.9.0)
5
+ *
6
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
7
+ * @generated
8
+ */
9
+ use Thrift\Base\TBase;
10
+ use Thrift\Type\TType;
11
+ use Thrift\Type\TMessageType;
12
+ use Thrift\Exception\TException;
13
+ use Thrift\Exception\TProtocolException;
14
+ use Thrift\Protocol\TProtocol;
15
+ use Thrift\Exception\TApplicationException;
16
+
17
+
18
+ interface P13nServiceIf {
19
+ public function choose(\com\boxalino\p13n\api\thrift\ChoiceRequest $choiceRequest);
20
+ public function batchChoose(\com\boxalino\p13n\api\thrift\BatchChoiceRequest $batchChoiceRequest);
21
+ public function autocomplete(\com\boxalino\p13n\api\thrift\AutocompleteRequest $request);
22
+ }
23
+
24
+ class P13nServiceClient implements \com\boxalino\p13n\api\thrift\P13nServiceIf {
25
+ protected $input_ = null;
26
+ protected $output_ = null;
27
+
28
+ protected $seqid_ = 0;
29
+
30
+ public function __construct($input, $output=null) {
31
+ $this->input_ = $input;
32
+ $this->output_ = $output ? $output : $input;
33
+ }
34
+
35
+ public function choose(\com\boxalino\p13n\api\thrift\ChoiceRequest $choiceRequest)
36
+ {
37
+ $this->send_choose($choiceRequest);
38
+ return $this->recv_choose();
39
+ }
40
+
41
+ public function send_choose(\com\boxalino\p13n\api\thrift\ChoiceRequest $choiceRequest)
42
+ {
43
+ $args = new \com\boxalino\p13n\api\thrift\P13nService_choose_args();
44
+ $args->choiceRequest = $choiceRequest;
45
+ $bin_accel = ($this->output_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary');
46
+ if ($bin_accel)
47
+ {
48
+ thrift_protocol_write_binary($this->output_, 'choose', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
49
+ }
50
+ else
51
+ {
52
+ $this->output_->writeMessageBegin('choose', TMessageType::CALL, $this->seqid_);
53
+ $args->write($this->output_);
54
+ $this->output_->writeMessageEnd();
55
+ $this->output_->getTransport()->flush();
56
+ }
57
+ }
58
+
59
+ public function recv_choose()
60
+ {
61
+ $bin_accel = ($this->input_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_read_binary');
62
+ if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\com\boxalino\p13n\api\thrift\P13nService_choose_result', $this->input_->isStrictRead());
63
+ else
64
+ {
65
+ $rseqid = 0;
66
+ $fname = null;
67
+ $mtype = 0;
68
+
69
+ $this->input_->readMessageBegin($fname, $mtype, $rseqid);
70
+ if ($mtype == TMessageType::EXCEPTION) {
71
+ $x = new TApplicationException();
72
+ $x->read($this->input_);
73
+ $this->input_->readMessageEnd();
74
+ throw $x;
75
+ }
76
+ $result = new \com\boxalino\p13n\api\thrift\P13nService_choose_result();
77
+ $result->read($this->input_);
78
+ $this->input_->readMessageEnd();
79
+ }
80
+ if ($result->success !== null) {
81
+ return $result->success;
82
+ }
83
+ if ($result->p13nServiceException !== null) {
84
+ throw $result->p13nServiceException;
85
+ }
86
+ throw new \Exception("choose failed: unknown result");
87
+ }
88
+
89
+ public function batchChoose(\com\boxalino\p13n\api\thrift\BatchChoiceRequest $batchChoiceRequest)
90
+ {
91
+ $this->send_batchChoose($batchChoiceRequest);
92
+ return $this->recv_batchChoose();
93
+ }
94
+
95
+ public function send_batchChoose(\com\boxalino\p13n\api\thrift\BatchChoiceRequest $batchChoiceRequest)
96
+ {
97
+ $args = new \com\boxalino\p13n\api\thrift\P13nService_batchChoose_args();
98
+ $args->batchChoiceRequest = $batchChoiceRequest;
99
+ $bin_accel = ($this->output_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary');
100
+ if ($bin_accel)
101
+ {
102
+ thrift_protocol_write_binary($this->output_, 'batchChoose', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
103
+ }
104
+ else
105
+ {
106
+ $this->output_->writeMessageBegin('batchChoose', TMessageType::CALL, $this->seqid_);
107
+ $args->write($this->output_);
108
+ $this->output_->writeMessageEnd();
109
+ $this->output_->getTransport()->flush();
110
+ }
111
+ }
112
+
113
+ public function recv_batchChoose()
114
+ {
115
+ $bin_accel = ($this->input_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_read_binary');
116
+ if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\com\boxalino\p13n\api\thrift\P13nService_batchChoose_result', $this->input_->isStrictRead());
117
+ else
118
+ {
119
+ $rseqid = 0;
120
+ $fname = null;
121
+ $mtype = 0;
122
+
123
+ $this->input_->readMessageBegin($fname, $mtype, $rseqid);
124
+ if ($mtype == TMessageType::EXCEPTION) {
125
+ $x = new TApplicationException();
126
+ $x->read($this->input_);
127
+ $this->input_->readMessageEnd();
128
+ throw $x;
129
+ }
130
+ $result = new \com\boxalino\p13n\api\thrift\P13nService_batchChoose_result();
131
+ $result->read($this->input_);
132
+ $this->input_->readMessageEnd();
133
+ }
134
+ if ($result->success !== null) {
135
+ return $result->success;
136
+ }
137
+ if ($result->p13nServiceException !== null) {
138
+ throw $result->p13nServiceException;
139
+ }
140
+ throw new \Exception("batchChoose failed: unknown result");
141
+ }
142
+
143
+ public function autocomplete(\com\boxalino\p13n\api\thrift\AutocompleteRequest $request)
144
+ {
145
+ $this->send_autocomplete($request);
146
+ return $this->recv_autocomplete();
147
+ }
148
+
149
+ public function send_autocomplete(\com\boxalino\p13n\api\thrift\AutocompleteRequest $request)
150
+ {
151
+ $args = new \com\boxalino\p13n\api\thrift\P13nService_autocomplete_args();
152
+ $args->request = $request;
153
+ $bin_accel = ($this->output_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary');
154
+ if ($bin_accel)
155
+ {
156
+ thrift_protocol_write_binary($this->output_, 'autocomplete', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
157
+ }
158
+ else
159
+ {
160
+ $this->output_->writeMessageBegin('autocomplete', TMessageType::CALL, $this->seqid_);
161
+ $args->write($this->output_);
162
+ $this->output_->writeMessageEnd();
163
+ $this->output_->getTransport()->flush();
164
+ }
165
+ }
166
+
167
+ public function recv_autocomplete()
168
+ {
169
+ $bin_accel = ($this->input_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_read_binary');
170
+ if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\com\boxalino\p13n\api\thrift\P13nService_autocomplete_result', $this->input_->isStrictRead());
171
+ else
172
+ {
173
+ $rseqid = 0;
174
+ $fname = null;
175
+ $mtype = 0;
176
+
177
+ $this->input_->readMessageBegin($fname, $mtype, $rseqid);
178
+ if ($mtype == TMessageType::EXCEPTION) {
179
+ $x = new TApplicationException();
180
+ $x->read($this->input_);
181
+ $this->input_->readMessageEnd();
182
+ throw $x;
183
+ }
184
+ $result = new \com\boxalino\p13n\api\thrift\P13nService_autocomplete_result();
185
+ $result->read($this->input_);
186
+ $this->input_->readMessageEnd();
187
+ }
188
+ if ($result->success !== null) {
189
+ return $result->success;
190
+ }
191
+ if ($result->p13nServiceException !== null) {
192
+ throw $result->p13nServiceException;
193
+ }
194
+ throw new \Exception("autocomplete failed: unknown result");
195
+ }
196
+
197
+ }
198
+
199
+ // HELPER FUNCTIONS AND STRUCTURES
200
+
201
+ class P13nService_choose_args {
202
+ static $_TSPEC;
203
+
204
+ public $choiceRequest = null;
205
+
206
+ public function __construct($vals=null) {
207
+ if (!isset(self::$_TSPEC)) {
208
+ self::$_TSPEC = array(
209
+ -1 => array(
210
+ 'var' => 'choiceRequest',
211
+ 'type' => TType::STRUCT,
212
+ 'class' => '\com\boxalino\p13n\api\thrift\ChoiceRequest',
213
+ ),
214
+ );
215
+ }
216
+ if (is_array($vals)) {
217
+ if (isset($vals['choiceRequest'])) {
218
+ $this->choiceRequest = $vals['choiceRequest'];
219
+ }
220
+ }
221
+ }
222
+
223
+ public function getName() {
224
+ return 'P13nService_choose_args';
225
+ }
226
+
227
+ public function read($input)
228
+ {
229
+ $xfer = 0;
230
+ $fname = null;
231
+ $ftype = 0;
232
+ $fid = 0;
233
+ $xfer += $input->readStructBegin($fname);
234
+ while (true)
235
+ {
236
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
237
+ if ($ftype == TType::STOP) {
238
+ break;
239
+ }
240
+ switch ($fid)
241
+ {
242
+ case -1:
243
+ if ($ftype == TType::STRUCT) {
244
+ $this->choiceRequest = new \com\boxalino\p13n\api\thrift\ChoiceRequest();
245
+ $xfer += $this->choiceRequest->read($input);
246
+ } else {
247
+ $xfer += $input->skip($ftype);
248
+ }
249
+ break;
250
+ default:
251
+ $xfer += $input->skip($ftype);
252
+ break;
253
+ }
254
+ $xfer += $input->readFieldEnd();
255
+ }
256
+ $xfer += $input->readStructEnd();
257
+ return $xfer;
258
+ }
259
+
260
+ public function write($output) {
261
+ $xfer = 0;
262
+ $xfer += $output->writeStructBegin('P13nService_choose_args');
263
+ if ($this->choiceRequest !== null) {
264
+ if (!is_object($this->choiceRequest)) {
265
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
266
+ }
267
+ $xfer += $output->writeFieldBegin('choiceRequest', TType::STRUCT, -1);
268
+ $xfer += $this->choiceRequest->write($output);
269
+ $xfer += $output->writeFieldEnd();
270
+ }
271
+ $xfer += $output->writeFieldStop();
272
+ $xfer += $output->writeStructEnd();
273
+ return $xfer;
274
+ }
275
+
276
+ }
277
+
278
+ class P13nService_choose_result {
279
+ static $_TSPEC;
280
+
281
+ public $success = null;
282
+ public $p13nServiceException = null;
283
+
284
+ public function __construct($vals=null) {
285
+ if (!isset(self::$_TSPEC)) {
286
+ self::$_TSPEC = array(
287
+ 0 => array(
288
+ 'var' => 'success',
289
+ 'type' => TType::STRUCT,
290
+ 'class' => '\com\boxalino\p13n\api\thrift\ChoiceResponse',
291
+ ),
292
+ 1 => array(
293
+ 'var' => 'p13nServiceException',
294
+ 'type' => TType::STRUCT,
295
+ 'class' => '\com\boxalino\p13n\api\thrift\P13nServiceException',
296
+ ),
297
+ );
298
+ }
299
+ if (is_array($vals)) {
300
+ if (isset($vals['success'])) {
301
+ $this->success = $vals['success'];
302
+ }
303
+ if (isset($vals['p13nServiceException'])) {
304
+ $this->p13nServiceException = $vals['p13nServiceException'];
305
+ }
306
+ }
307
+ }
308
+
309
+ public function getName() {
310
+ return 'P13nService_choose_result';
311
+ }
312
+
313
+ public function read($input)
314
+ {
315
+ $xfer = 0;
316
+ $fname = null;
317
+ $ftype = 0;
318
+ $fid = 0;
319
+ $xfer += $input->readStructBegin($fname);
320
+ while (true)
321
+ {
322
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
323
+ if ($ftype == TType::STOP) {
324
+ break;
325
+ }
326
+ switch ($fid)
327
+ {
328
+ case 0:
329
+ if ($ftype == TType::STRUCT) {
330
+ $this->success = new \com\boxalino\p13n\api\thrift\ChoiceResponse();
331
+ $xfer += $this->success->read($input);
332
+ } else {
333
+ $xfer += $input->skip($ftype);
334
+ }
335
+ break;
336
+ case 1:
337
+ if ($ftype == TType::STRUCT) {
338
+ $this->p13nServiceException = new \com\boxalino\p13n\api\thrift\P13nServiceException();
339
+ $xfer += $this->p13nServiceException->read($input);
340
+ } else {
341
+ $xfer += $input->skip($ftype);
342
+ }
343
+ break;
344
+ default:
345
+ $xfer += $input->skip($ftype);
346
+ break;
347
+ }
348
+ $xfer += $input->readFieldEnd();
349
+ }
350
+ $xfer += $input->readStructEnd();
351
+ return $xfer;
352
+ }
353
+
354
+ public function write($output) {
355
+ $xfer = 0;
356
+ $xfer += $output->writeStructBegin('P13nService_choose_result');
357
+ if ($this->success !== null) {
358
+ if (!is_object($this->success)) {
359
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
360
+ }
361
+ $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0);
362
+ $xfer += $this->success->write($output);
363
+ $xfer += $output->writeFieldEnd();
364
+ }
365
+ if ($this->p13nServiceException !== null) {
366
+ $xfer += $output->writeFieldBegin('p13nServiceException', TType::STRUCT, 1);
367
+ $xfer += $this->p13nServiceException->write($output);
368
+ $xfer += $output->writeFieldEnd();
369
+ }
370
+ $xfer += $output->writeFieldStop();
371
+ $xfer += $output->writeStructEnd();
372
+ return $xfer;
373
+ }
374
+
375
+ }
376
+
377
+ class P13nService_batchChoose_args {
378
+ static $_TSPEC;
379
+
380
+ public $batchChoiceRequest = null;
381
+
382
+ public function __construct($vals=null) {
383
+ if (!isset(self::$_TSPEC)) {
384
+ self::$_TSPEC = array(
385
+ -1 => array(
386
+ 'var' => 'batchChoiceRequest',
387
+ 'type' => TType::STRUCT,
388
+ 'class' => '\com\boxalino\p13n\api\thrift\BatchChoiceRequest',
389
+ ),
390
+ );
391
+ }
392
+ if (is_array($vals)) {
393
+ if (isset($vals['batchChoiceRequest'])) {
394
+ $this->batchChoiceRequest = $vals['batchChoiceRequest'];
395
+ }
396
+ }
397
+ }
398
+
399
+ public function getName() {
400
+ return 'P13nService_batchChoose_args';
401
+ }
402
+
403
+ public function read($input)
404
+ {
405
+ $xfer = 0;
406
+ $fname = null;
407
+ $ftype = 0;
408
+ $fid = 0;
409
+ $xfer += $input->readStructBegin($fname);
410
+ while (true)
411
+ {
412
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
413
+ if ($ftype == TType::STOP) {
414
+ break;
415
+ }
416
+ switch ($fid)
417
+ {
418
+ case -1:
419
+ if ($ftype == TType::STRUCT) {
420
+ $this->batchChoiceRequest = new \com\boxalino\p13n\api\thrift\BatchChoiceRequest();
421
+ $xfer += $this->batchChoiceRequest->read($input);
422
+ } else {
423
+ $xfer += $input->skip($ftype);
424
+ }
425
+ break;
426
+ default:
427
+ $xfer += $input->skip($ftype);
428
+ break;
429
+ }
430
+ $xfer += $input->readFieldEnd();
431
+ }
432
+ $xfer += $input->readStructEnd();
433
+ return $xfer;
434
+ }
435
+
436
+ public function write($output) {
437
+ $xfer = 0;
438
+ $xfer += $output->writeStructBegin('P13nService_batchChoose_args');
439
+ if ($this->batchChoiceRequest !== null) {
440
+ if (!is_object($this->batchChoiceRequest)) {
441
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
442
+ }
443
+ $xfer += $output->writeFieldBegin('batchChoiceRequest', TType::STRUCT, -1);
444
+ $xfer += $this->batchChoiceRequest->write($output);
445
+ $xfer += $output->writeFieldEnd();
446
+ }
447
+ $xfer += $output->writeFieldStop();
448
+ $xfer += $output->writeStructEnd();
449
+ return $xfer;
450
+ }
451
+
452
+ }
453
+
454
+ class P13nService_batchChoose_result {
455
+ static $_TSPEC;
456
+
457
+ public $success = null;
458
+ public $p13nServiceException = null;
459
+
460
+ public function __construct($vals=null) {
461
+ if (!isset(self::$_TSPEC)) {
462
+ self::$_TSPEC = array(
463
+ 0 => array(
464
+ 'var' => 'success',
465
+ 'type' => TType::STRUCT,
466
+ 'class' => '\com\boxalino\p13n\api\thrift\BatchChoiceResponse',
467
+ ),
468
+ 1 => array(
469
+ 'var' => 'p13nServiceException',
470
+ 'type' => TType::STRUCT,
471
+ 'class' => '\com\boxalino\p13n\api\thrift\P13nServiceException',
472
+ ),
473
+ );
474
+ }
475
+ if (is_array($vals)) {
476
+ if (isset($vals['success'])) {
477
+ $this->success = $vals['success'];
478
+ }
479
+ if (isset($vals['p13nServiceException'])) {
480
+ $this->p13nServiceException = $vals['p13nServiceException'];
481
+ }
482
+ }
483
+ }
484
+
485
+ public function getName() {
486
+ return 'P13nService_batchChoose_result';
487
+ }
488
+
489
+ public function read($input)
490
+ {
491
+ $xfer = 0;
492
+ $fname = null;
493
+ $ftype = 0;
494
+ $fid = 0;
495
+ $xfer += $input->readStructBegin($fname);
496
+ while (true)
497
+ {
498
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
499
+ if ($ftype == TType::STOP) {
500
+ break;
501
+ }
502
+ switch ($fid)
503
+ {
504
+ case 0:
505
+ if ($ftype == TType::STRUCT) {
506
+ $this->success = new \com\boxalino\p13n\api\thrift\BatchChoiceResponse();
507
+ $xfer += $this->success->read($input);
508
+ } else {
509
+ $xfer += $input->skip($ftype);
510
+ }
511
+ break;
512
+ case 1:
513
+ if ($ftype == TType::STRUCT) {
514
+ $this->p13nServiceException = new \com\boxalino\p13n\api\thrift\P13nServiceException();
515
+ $xfer += $this->p13nServiceException->read($input);
516
+ } else {
517
+ $xfer += $input->skip($ftype);
518
+ }
519
+ break;
520
+ default:
521
+ $xfer += $input->skip($ftype);
522
+ break;
523
+ }
524
+ $xfer += $input->readFieldEnd();
525
+ }
526
+ $xfer += $input->readStructEnd();
527
+ return $xfer;
528
+ }
529
+
530
+ public function write($output) {
531
+ $xfer = 0;
532
+ $xfer += $output->writeStructBegin('P13nService_batchChoose_result');
533
+ if ($this->success !== null) {
534
+ if (!is_object($this->success)) {
535
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
536
+ }
537
+ $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0);
538
+ $xfer += $this->success->write($output);
539
+ $xfer += $output->writeFieldEnd();
540
+ }
541
+ if ($this->p13nServiceException !== null) {
542
+ $xfer += $output->writeFieldBegin('p13nServiceException', TType::STRUCT, 1);
543
+ $xfer += $this->p13nServiceException->write($output);
544
+ $xfer += $output->writeFieldEnd();
545
+ }
546
+ $xfer += $output->writeFieldStop();
547
+ $xfer += $output->writeStructEnd();
548
+ return $xfer;
549
+ }
550
+
551
+ }
552
+
553
+ class P13nService_autocomplete_args {
554
+ static $_TSPEC;
555
+
556
+ public $request = null;
557
+
558
+ public function __construct($vals=null) {
559
+ if (!isset(self::$_TSPEC)) {
560
+ self::$_TSPEC = array(
561
+ -1 => array(
562
+ 'var' => 'request',
563
+ 'type' => TType::STRUCT,
564
+ 'class' => '\com\boxalino\p13n\api\thrift\AutocompleteRequest',
565
+ ),
566
+ );
567
+ }
568
+ if (is_array($vals)) {
569
+ if (isset($vals['request'])) {
570
+ $this->request = $vals['request'];
571
+ }
572
+ }
573
+ }
574
+
575
+ public function getName() {
576
+ return 'P13nService_autocomplete_args';
577
+ }
578
+
579
+ public function read($input)
580
+ {
581
+ $xfer = 0;
582
+ $fname = null;
583
+ $ftype = 0;
584
+ $fid = 0;
585
+ $xfer += $input->readStructBegin($fname);
586
+ while (true)
587
+ {
588
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
589
+ if ($ftype == TType::STOP) {
590
+ break;
591
+ }
592
+ switch ($fid)
593
+ {
594
+ case -1:
595
+ if ($ftype == TType::STRUCT) {
596
+ $this->request = new \com\boxalino\p13n\api\thrift\AutocompleteRequest();
597
+ $xfer += $this->request->read($input);
598
+ } else {
599
+ $xfer += $input->skip($ftype);
600
+ }
601
+ break;
602
+ default:
603
+ $xfer += $input->skip($ftype);
604
+ break;
605
+ }
606
+ $xfer += $input->readFieldEnd();
607
+ }
608
+ $xfer += $input->readStructEnd();
609
+ return $xfer;
610
+ }
611
+
612
+ public function write($output) {
613
+ $xfer = 0;
614
+ $xfer += $output->writeStructBegin('P13nService_autocomplete_args');
615
+ if ($this->request !== null) {
616
+ if (!is_object($this->request)) {
617
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
618
+ }
619
+ $xfer += $output->writeFieldBegin('request', TType::STRUCT, -1);
620
+ $xfer += $this->request->write($output);
621
+ $xfer += $output->writeFieldEnd();
622
+ }
623
+ $xfer += $output->writeFieldStop();
624
+ $xfer += $output->writeStructEnd();
625
+ return $xfer;
626
+ }
627
+
628
+ }
629
+
630
+ class P13nService_autocomplete_result {
631
+ static $_TSPEC;
632
+
633
+ public $success = null;
634
+ public $p13nServiceException = null;
635
+
636
+ public function __construct($vals=null) {
637
+ if (!isset(self::$_TSPEC)) {
638
+ self::$_TSPEC = array(
639
+ 0 => array(
640
+ 'var' => 'success',
641
+ 'type' => TType::STRUCT,
642
+ 'class' => '\com\boxalino\p13n\api\thrift\AutocompleteResponse',
643
+ ),
644
+ 1 => array(
645
+ 'var' => 'p13nServiceException',
646
+ 'type' => TType::STRUCT,
647
+ 'class' => '\com\boxalino\p13n\api\thrift\P13nServiceException',
648
+ ),
649
+ );
650
+ }
651
+ if (is_array($vals)) {
652
+ if (isset($vals['success'])) {
653
+ $this->success = $vals['success'];
654
+ }
655
+ if (isset($vals['p13nServiceException'])) {
656
+ $this->p13nServiceException = $vals['p13nServiceException'];
657
+ }
658
+ }
659
+ }
660
+
661
+ public function getName() {
662
+ return 'P13nService_autocomplete_result';
663
+ }
664
+
665
+ public function read($input)
666
+ {
667
+ $xfer = 0;
668
+ $fname = null;
669
+ $ftype = 0;
670
+ $fid = 0;
671
+ $xfer += $input->readStructBegin($fname);
672
+ while (true)
673
+ {
674
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
675
+ if ($ftype == TType::STOP) {
676
+ break;
677
+ }
678
+ switch ($fid)
679
+ {
680
+ case 0:
681
+ if ($ftype == TType::STRUCT) {
682
+ $this->success = new \com\boxalino\p13n\api\thrift\AutocompleteResponse();
683
+ $xfer += $this->success->read($input);
684
+ } else {
685
+ $xfer += $input->skip($ftype);
686
+ }
687
+ break;
688
+ case 1:
689
+ if ($ftype == TType::STRUCT) {
690
+ $this->p13nServiceException = new \com\boxalino\p13n\api\thrift\P13nServiceException();
691
+ $xfer += $this->p13nServiceException->read($input);
692
+ } else {
693
+ $xfer += $input->skip($ftype);
694
+ }
695
+ break;
696
+ default:
697
+ $xfer += $input->skip($ftype);
698
+ break;
699
+ }
700
+ $xfer += $input->readFieldEnd();
701
+ }
702
+ $xfer += $input->readStructEnd();
703
+ return $xfer;
704
+ }
705
+
706
+ public function write($output) {
707
+ $xfer = 0;
708
+ $xfer += $output->writeStructBegin('P13nService_autocomplete_result');
709
+ if ($this->success !== null) {
710
+ if (!is_object($this->success)) {
711
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
712
+ }
713
+ $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0);
714
+ $xfer += $this->success->write($output);
715
+ $xfer += $output->writeFieldEnd();
716
+ }
717
+ if ($this->p13nServiceException !== null) {
718
+ $xfer += $output->writeFieldBegin('p13nServiceException', TType::STRUCT, 1);
719
+ $xfer += $this->p13nServiceException->write($output);
720
+ $xfer += $output->writeFieldEnd();
721
+ }
722
+ $xfer += $output->writeFieldStop();
723
+ $xfer += $output->writeStructEnd();
724
+ return $xfer;
725
+ }
726
+
727
+ }
728
+
729
+
app/code/local/Boxalino/CemSearch/Lib/Types.php ADDED
@@ -0,0 +1,4580 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace com\boxalino\p13n\api\thrift;
3
+
4
+ /**
5
+ * Autogenerated by Thrift Compiler (0.9.0)
6
+ *
7
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
8
+ * @generated
9
+ */
10
+ use Thrift\Base\TBase;
11
+ use Thrift\Type\TType;
12
+ use Thrift\Type\TMessageType;
13
+ use Thrift\Exception\TException;
14
+ use Thrift\Exception\TProtocolException;
15
+ use Thrift\Protocol\TProtocol;
16
+ use Thrift\Exception\TApplicationException;
17
+
18
+
19
+ final class DateRangeGap {
20
+ const SECOND = 1;
21
+ const MINUTE = 2;
22
+ const HOUR = 3;
23
+ const DAY = 4;
24
+ const WEEK = 5;
25
+ const MONTH = 6;
26
+ const YEAR = 7;
27
+ const DECADE = 8;
28
+ const CENTURY = 9;
29
+ static public $__names = array(
30
+ 1 => 'SECOND',
31
+ 2 => 'MINUTE',
32
+ 3 => 'HOUR',
33
+ 4 => 'DAY',
34
+ 5 => 'WEEK',
35
+ 6 => 'MONTH',
36
+ 7 => 'YEAR',
37
+ 8 => 'DECADE',
38
+ 9 => 'CENTURY',
39
+ );
40
+ }
41
+
42
+ final class FacetSortOrder {
43
+ const POPULATION = 1;
44
+ const COLLATION = 2;
45
+ static public $__names = array(
46
+ 1 => 'POPULATION',
47
+ 2 => 'COLLATION',
48
+ );
49
+ }
50
+
51
+ class Filter {
52
+ static $_TSPEC;
53
+
54
+ public $negative = null;
55
+ public $fieldName = null;
56
+ public $stringValues = null;
57
+ public $prefix = null;
58
+ public $hierarchyId = null;
59
+ public $hierarchy = null;
60
+ public $rangeFrom = null;
61
+ public $rangeFromInclusive = null;
62
+ public $rangeTo = null;
63
+ public $rangeToInclusive = null;
64
+
65
+ public function __construct($vals=null) {
66
+ if (!isset(self::$_TSPEC)) {
67
+ self::$_TSPEC = array(
68
+ 1 => array(
69
+ 'var' => 'negative',
70
+ 'type' => TType::BOOL,
71
+ ),
72
+ 2 => array(
73
+ 'var' => 'fieldName',
74
+ 'type' => TType::STRING,
75
+ ),
76
+ 3 => array(
77
+ 'var' => 'stringValues',
78
+ 'type' => TType::LST,
79
+ 'etype' => TType::STRING,
80
+ 'elem' => array(
81
+ 'type' => TType::STRING,
82
+ ),
83
+ ),
84
+ 4 => array(
85
+ 'var' => 'prefix',
86
+ 'type' => TType::STRING,
87
+ ),
88
+ 41 => array(
89
+ 'var' => 'hierarchyId',
90
+ 'type' => TType::STRING,
91
+ ),
92
+ 5 => array(
93
+ 'var' => 'hierarchy',
94
+ 'type' => TType::LST,
95
+ 'etype' => TType::STRING,
96
+ 'elem' => array(
97
+ 'type' => TType::STRING,
98
+ ),
99
+ ),
100
+ 6 => array(
101
+ 'var' => 'rangeFrom',
102
+ 'type' => TType::STRING,
103
+ ),
104
+ 7 => array(
105
+ 'var' => 'rangeFromInclusive',
106
+ 'type' => TType::BOOL,
107
+ ),
108
+ 8 => array(
109
+ 'var' => 'rangeTo',
110
+ 'type' => TType::STRING,
111
+ ),
112
+ 9 => array(
113
+ 'var' => 'rangeToInclusive',
114
+ 'type' => TType::BOOL,
115
+ ),
116
+ );
117
+ }
118
+ if (is_array($vals)) {
119
+ if (isset($vals['negative'])) {
120
+ $this->negative = $vals['negative'];
121
+ }
122
+ if (isset($vals['fieldName'])) {
123
+ $this->fieldName = $vals['fieldName'];
124
+ }
125
+ if (isset($vals['stringValues'])) {
126
+ $this->stringValues = $vals['stringValues'];
127
+ }
128
+ if (isset($vals['prefix'])) {
129
+ $this->prefix = $vals['prefix'];
130
+ }
131
+ if (isset($vals['hierarchyId'])) {
132
+ $this->hierarchyId = $vals['hierarchyId'];
133
+ }
134
+ if (isset($vals['hierarchy'])) {
135
+ $this->hierarchy = $vals['hierarchy'];
136
+ }
137
+ if (isset($vals['rangeFrom'])) {
138
+ $this->rangeFrom = $vals['rangeFrom'];
139
+ }
140
+ if (isset($vals['rangeFromInclusive'])) {
141
+ $this->rangeFromInclusive = $vals['rangeFromInclusive'];
142
+ }
143
+ if (isset($vals['rangeTo'])) {
144
+ $this->rangeTo = $vals['rangeTo'];
145
+ }
146
+ if (isset($vals['rangeToInclusive'])) {
147
+ $this->rangeToInclusive = $vals['rangeToInclusive'];
148
+ }
149
+ }
150
+ }
151
+
152
+ public function getName() {
153
+ return 'Filter';
154
+ }
155
+
156
+ public function read($input)
157
+ {
158
+ $xfer = 0;
159
+ $fname = null;
160
+ $ftype = 0;
161
+ $fid = 0;
162
+ $xfer += $input->readStructBegin($fname);
163
+ while (true)
164
+ {
165
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
166
+ if ($ftype == TType::STOP) {
167
+ break;
168
+ }
169
+ switch ($fid)
170
+ {
171
+ case 1:
172
+ if ($ftype == TType::BOOL) {
173
+ $xfer += $input->readBool($this->negative);
174
+ } else {
175
+ $xfer += $input->skip($ftype);
176
+ }
177
+ break;
178
+ case 2:
179
+ if ($ftype == TType::STRING) {
180
+ $xfer += $input->readString($this->fieldName);
181
+ } else {
182
+ $xfer += $input->skip($ftype);
183
+ }
184
+ break;
185
+ case 3:
186
+ if ($ftype == TType::LST) {
187
+ $this->stringValues = array();
188
+ $_size0 = 0;
189
+ $_etype3 = 0;
190
+ $xfer += $input->readListBegin($_etype3, $_size0);
191
+ for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
192
+ {
193
+ $elem5 = null;
194
+ $xfer += $input->readString($elem5);
195
+ $this->stringValues []= $elem5;
196
+ }
197
+ $xfer += $input->readListEnd();
198
+ } else {
199
+ $xfer += $input->skip($ftype);
200
+ }
201
+ break;
202
+ case 4:
203
+ if ($ftype == TType::STRING) {
204
+ $xfer += $input->readString($this->prefix);
205
+ } else {
206
+ $xfer += $input->skip($ftype);
207
+ }
208
+ break;
209
+ case 41:
210
+ if ($ftype == TType::STRING) {
211
+ $xfer += $input->readString($this->hierarchyId);
212
+ } else {
213
+ $xfer += $input->skip($ftype);
214
+ }
215
+ break;
216
+ case 5:
217
+ if ($ftype == TType::LST) {
218
+ $this->hierarchy = array();
219
+ $_size6 = 0;
220
+ $_etype9 = 0;
221
+ $xfer += $input->readListBegin($_etype9, $_size6);
222
+ for ($_i10 = 0; $_i10 < $_size6; ++$_i10)
223
+ {
224
+ $elem11 = null;
225
+ $xfer += $input->readString($elem11);
226
+ $this->hierarchy []= $elem11;
227
+ }
228
+ $xfer += $input->readListEnd();
229
+ } else {
230
+ $xfer += $input->skip($ftype);
231
+ }
232
+ break;
233
+ case 6:
234
+ if ($ftype == TType::STRING) {
235
+ $xfer += $input->readString($this->rangeFrom);
236
+ } else {
237
+ $xfer += $input->skip($ftype);
238
+ }
239
+ break;
240
+ case 7:
241
+ if ($ftype == TType::BOOL) {
242
+ $xfer += $input->readBool($this->rangeFromInclusive);
243
+ } else {
244
+ $xfer += $input->skip($ftype);
245
+ }
246
+ break;
247
+ case 8:
248
+ if ($ftype == TType::STRING) {
249
+ $xfer += $input->readString($this->rangeTo);
250
+ } else {
251
+ $xfer += $input->skip($ftype);
252
+ }
253
+ break;
254
+ case 9:
255
+ if ($ftype == TType::BOOL) {
256
+ $xfer += $input->readBool($this->rangeToInclusive);
257
+ } else {
258
+ $xfer += $input->skip($ftype);
259
+ }
260
+ break;
261
+ default:
262
+ $xfer += $input->skip($ftype);
263
+ break;
264
+ }
265
+ $xfer += $input->readFieldEnd();
266
+ }
267
+ $xfer += $input->readStructEnd();
268
+ return $xfer;
269
+ }
270
+
271
+ public function write($output) {
272
+ $xfer = 0;
273
+ $xfer += $output->writeStructBegin('Filter');
274
+ if ($this->negative !== null) {
275
+ $xfer += $output->writeFieldBegin('negative', TType::BOOL, 1);
276
+ $xfer += $output->writeBool($this->negative);
277
+ $xfer += $output->writeFieldEnd();
278
+ }
279
+ if ($this->fieldName !== null) {
280
+ $xfer += $output->writeFieldBegin('fieldName', TType::STRING, 2);
281
+ $xfer += $output->writeString($this->fieldName);
282
+ $xfer += $output->writeFieldEnd();
283
+ }
284
+ if ($this->stringValues !== null) {
285
+ if (!is_array($this->stringValues)) {
286
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
287
+ }
288
+ $xfer += $output->writeFieldBegin('stringValues', TType::LST, 3);
289
+ {
290
+ $output->writeListBegin(TType::STRING, count($this->stringValues));
291
+ {
292
+ foreach ($this->stringValues as $iter12)
293
+ {
294
+ $xfer += $output->writeString($iter12);
295
+ }
296
+ }
297
+ $output->writeListEnd();
298
+ }
299
+ $xfer += $output->writeFieldEnd();
300
+ }
301
+ if ($this->prefix !== null) {
302
+ $xfer += $output->writeFieldBegin('prefix', TType::STRING, 4);
303
+ $xfer += $output->writeString($this->prefix);
304
+ $xfer += $output->writeFieldEnd();
305
+ }
306
+ if ($this->hierarchy !== null) {
307
+ if (!is_array($this->hierarchy)) {
308
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
309
+ }
310
+ $xfer += $output->writeFieldBegin('hierarchy', TType::LST, 5);
311
+ {
312
+ $output->writeListBegin(TType::STRING, count($this->hierarchy));
313
+ {
314
+ foreach ($this->hierarchy as $iter13)
315
+ {
316
+ $xfer += $output->writeString($iter13);
317
+ }
318
+ }
319
+ $output->writeListEnd();
320
+ }
321
+ $xfer += $output->writeFieldEnd();
322
+ }
323
+ if ($this->rangeFrom !== null) {
324
+ $xfer += $output->writeFieldBegin('rangeFrom', TType::STRING, 6);
325
+ $xfer += $output->writeString($this->rangeFrom);
326
+ $xfer += $output->writeFieldEnd();
327
+ }
328
+ if ($this->rangeFromInclusive !== null) {
329
+ $xfer += $output->writeFieldBegin('rangeFromInclusive', TType::BOOL, 7);
330
+ $xfer += $output->writeBool($this->rangeFromInclusive);
331
+ $xfer += $output->writeFieldEnd();
332
+ }
333
+ if ($this->rangeTo !== null) {
334
+ $xfer += $output->writeFieldBegin('rangeTo', TType::STRING, 8);
335
+ $xfer += $output->writeString($this->rangeTo);
336
+ $xfer += $output->writeFieldEnd();
337
+ }
338
+ if ($this->rangeToInclusive !== null) {
339
+ $xfer += $output->writeFieldBegin('rangeToInclusive', TType::BOOL, 9);
340
+ $xfer += $output->writeBool($this->rangeToInclusive);
341
+ $xfer += $output->writeFieldEnd();
342
+ }
343
+ if ($this->hierarchyId !== null) {
344
+ $xfer += $output->writeFieldBegin('hierarchyId', TType::STRING, 41);
345
+ $xfer += $output->writeString($this->hierarchyId);
346
+ $xfer += $output->writeFieldEnd();
347
+ }
348
+ $xfer += $output->writeFieldStop();
349
+ $xfer += $output->writeStructEnd();
350
+ return $xfer;
351
+ }
352
+
353
+ }
354
+
355
+ class FacetValue {
356
+ static $_TSPEC;
357
+
358
+ public $stringValue = null;
359
+ public $rangeFromInclusive = null;
360
+ public $rangeToExclusive = null;
361
+ public $hitCount = null;
362
+ public $hierarchyId = null;
363
+ public $hierarchy = null;
364
+ public $selected = null;
365
+
366
+ public function __construct($vals=null) {
367
+ if (!isset(self::$_TSPEC)) {
368
+ self::$_TSPEC = array(
369
+ 1 => array(
370
+ 'var' => 'stringValue',
371
+ 'type' => TType::STRING,
372
+ ),
373
+ 2 => array(
374
+ 'var' => 'rangeFromInclusive',
375
+ 'type' => TType::STRING,
376
+ ),
377
+ 3 => array(
378
+ 'var' => 'rangeToExclusive',
379
+ 'type' => TType::STRING,
380
+ ),
381
+ 4 => array(
382
+ 'var' => 'hitCount',
383
+ 'type' => TType::I64,
384
+ ),
385
+ 50 => array(
386
+ 'var' => 'hierarchyId',
387
+ 'type' => TType::STRING,
388
+ ),
389
+ 60 => array(
390
+ 'var' => 'hierarchy',
391
+ 'type' => TType::LST,
392
+ 'etype' => TType::STRING,
393
+ 'elem' => array(
394
+ 'type' => TType::STRING,
395
+ ),
396
+ ),
397
+ 70 => array(
398
+ 'var' => 'selected',
399
+ 'type' => TType::BOOL,
400
+ ),
401
+ );
402
+ }
403
+ if (is_array($vals)) {
404
+ if (isset($vals['stringValue'])) {
405
+ $this->stringValue = $vals['stringValue'];
406
+ }
407
+ if (isset($vals['rangeFromInclusive'])) {
408
+ $this->rangeFromInclusive = $vals['rangeFromInclusive'];
409
+ }
410
+ if (isset($vals['rangeToExclusive'])) {
411
+ $this->rangeToExclusive = $vals['rangeToExclusive'];
412
+ }
413
+ if (isset($vals['hitCount'])) {
414
+ $this->hitCount = $vals['hitCount'];
415
+ }
416
+ if (isset($vals['hierarchyId'])) {
417
+ $this->hierarchyId = $vals['hierarchyId'];
418
+ }
419
+ if (isset($vals['hierarchy'])) {
420
+ $this->hierarchy = $vals['hierarchy'];
421
+ }
422
+ if (isset($vals['selected'])) {
423
+ $this->selected = $vals['selected'];
424
+ }
425
+ }
426
+ }
427
+
428
+ public function getName() {
429
+ return 'FacetValue';
430
+ }
431
+
432
+ public function read($input)
433
+ {
434
+ $xfer = 0;
435
+ $fname = null;
436
+ $ftype = 0;
437
+ $fid = 0;
438
+ $xfer += $input->readStructBegin($fname);
439
+ while (true)
440
+ {
441
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
442
+ if ($ftype == TType::STOP) {
443
+ break;
444
+ }
445
+ switch ($fid)
446
+ {
447
+ case 1:
448
+ if ($ftype == TType::STRING) {
449
+ $xfer += $input->readString($this->stringValue);
450
+ } else {
451
+ $xfer += $input->skip($ftype);
452
+ }
453
+ break;
454
+ case 2:
455
+ if ($ftype == TType::STRING) {
456
+ $xfer += $input->readString($this->rangeFromInclusive);
457
+ } else {
458
+ $xfer += $input->skip($ftype);
459
+ }
460
+ break;
461
+ case 3:
462
+ if ($ftype == TType::STRING) {
463
+ $xfer += $input->readString($this->rangeToExclusive);
464
+ } else {
465
+ $xfer += $input->skip($ftype);
466
+ }
467
+ break;
468
+ case 4:
469
+ if ($ftype == TType::I64) {
470
+ $xfer += $input->readI64($this->hitCount);
471
+ } else {
472
+ $xfer += $input->skip($ftype);
473
+ }
474
+ break;
475
+ case 50:
476
+ if ($ftype == TType::STRING) {
477
+ $xfer += $input->readString($this->hierarchyId);
478
+ } else {
479
+ $xfer += $input->skip($ftype);
480
+ }
481
+ break;
482
+ case 60:
483
+ if ($ftype == TType::LST) {
484
+ $this->hierarchy = array();
485
+ $_size14 = 0;
486
+ $_etype17 = 0;
487
+ $xfer += $input->readListBegin($_etype17, $_size14);
488
+ for ($_i18 = 0; $_i18 < $_size14; ++$_i18)
489
+ {
490
+ $elem19 = null;
491
+ $xfer += $input->readString($elem19);
492
+ $this->hierarchy []= $elem19;
493
+ }
494
+ $xfer += $input->readListEnd();
495
+ } else {
496
+ $xfer += $input->skip($ftype);
497
+ }
498
+ break;
499
+ case 70:
500
+ if ($ftype == TType::BOOL) {
501
+ $xfer += $input->readBool($this->selected);
502
+ } else {
503
+ $xfer += $input->skip($ftype);
504
+ }
505
+ break;
506
+ default:
507
+ $xfer += $input->skip($ftype);
508
+ break;
509
+ }
510
+ $xfer += $input->readFieldEnd();
511
+ }
512
+ $xfer += $input->readStructEnd();
513
+ return $xfer;
514
+ }
515
+
516
+ public function write($output) {
517
+ $xfer = 0;
518
+ $xfer += $output->writeStructBegin('FacetValue');
519
+ if ($this->stringValue !== null) {
520
+ $xfer += $output->writeFieldBegin('stringValue', TType::STRING, 1);
521
+ $xfer += $output->writeString($this->stringValue);
522
+ $xfer += $output->writeFieldEnd();
523
+ }
524
+ if ($this->rangeFromInclusive !== null) {
525
+ $xfer += $output->writeFieldBegin('rangeFromInclusive', TType::STRING, 2);
526
+ $xfer += $output->writeString($this->rangeFromInclusive);
527
+ $xfer += $output->writeFieldEnd();
528
+ }
529
+ if ($this->rangeToExclusive !== null) {
530
+ $xfer += $output->writeFieldBegin('rangeToExclusive', TType::STRING, 3);
531
+ $xfer += $output->writeString($this->rangeToExclusive);
532
+ $xfer += $output->writeFieldEnd();
533
+ }
534
+ if ($this->hitCount !== null) {
535
+ $xfer += $output->writeFieldBegin('hitCount', TType::I64, 4);
536
+ $xfer += $output->writeI64($this->hitCount);
537
+ $xfer += $output->writeFieldEnd();
538
+ }
539
+ if ($this->hierarchyId !== null) {
540
+ $xfer += $output->writeFieldBegin('hierarchyId', TType::STRING, 50);
541
+ $xfer += $output->writeString($this->hierarchyId);
542
+ $xfer += $output->writeFieldEnd();
543
+ }
544
+ if ($this->hierarchy !== null) {
545
+ if (!is_array($this->hierarchy)) {
546
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
547
+ }
548
+ $xfer += $output->writeFieldBegin('hierarchy', TType::LST, 60);
549
+ {
550
+ $output->writeListBegin(TType::STRING, count($this->hierarchy));
551
+ {
552
+ foreach ($this->hierarchy as $iter20)
553
+ {
554
+ $xfer += $output->writeString($iter20);
555
+ }
556
+ }
557
+ $output->writeListEnd();
558
+ }
559
+ $xfer += $output->writeFieldEnd();
560
+ }
561
+ if ($this->selected !== null) {
562
+ $xfer += $output->writeFieldBegin('selected', TType::BOOL, 70);
563
+ $xfer += $output->writeBool($this->selected);
564
+ $xfer += $output->writeFieldEnd();
565
+ }
566
+ $xfer += $output->writeFieldStop();
567
+ $xfer += $output->writeStructEnd();
568
+ return $xfer;
569
+ }
570
+
571
+ }
572
+
573
+ class FacetRequest {
574
+ static $_TSPEC;
575
+
576
+ public $fieldName = null;
577
+ public $numerical = null;
578
+ public $range = null;
579
+ public $maxCount = -1;
580
+ public $minPopulation = 1;
581
+ public $dateRangeGap = null;
582
+ public $sortOrder = null;
583
+ public $sortAscending = null;
584
+ public $selectedValues = null;
585
+ public $andSelectedValues = false;
586
+
587
+ public function __construct($vals=null) {
588
+ if (!isset(self::$_TSPEC)) {
589
+ self::$_TSPEC = array(
590
+ 1 => array(
591
+ 'var' => 'fieldName',
592
+ 'type' => TType::STRING,
593
+ ),
594
+ 2 => array(
595
+ 'var' => 'numerical',
596
+ 'type' => TType::BOOL,
597
+ ),
598
+ 3 => array(
599
+ 'var' => 'range',
600
+ 'type' => TType::BOOL,
601
+ ),
602
+ 4 => array(
603
+ 'var' => 'maxCount',
604
+ 'type' => TType::I32,
605
+ ),
606
+ 5 => array(
607
+ 'var' => 'minPopulation',
608
+ 'type' => TType::I32,
609
+ ),
610
+ 6 => array(
611
+ 'var' => 'dateRangeGap',
612
+ 'type' => TType::I32,
613
+ ),
614
+ 7 => array(
615
+ 'var' => 'sortOrder',
616
+ 'type' => TType::I32,
617
+ ),
618
+ 8 => array(
619
+ 'var' => 'sortAscending',
620
+ 'type' => TType::BOOL,
621
+ ),
622
+ 90 => array(
623
+ 'var' => 'selectedValues',
624
+ 'type' => TType::LST,
625
+ 'etype' => TType::STRUCT,
626
+ 'elem' => array(
627
+ 'type' => TType::STRUCT,
628
+ 'class' => '\com\boxalino\p13n\api\thrift\FacetValue',
629
+ ),
630
+ ),
631
+ 100 => array(
632
+ 'var' => 'andSelectedValues',
633
+ 'type' => TType::BOOL,
634
+ ),
635
+ );
636
+ }
637
+ if (is_array($vals)) {
638
+ if (isset($vals['fieldName'])) {
639
+ $this->fieldName = $vals['fieldName'];
640
+ }
641
+ if (isset($vals['numerical'])) {
642
+ $this->numerical = $vals['numerical'];
643
+ }
644
+ if (isset($vals['range'])) {
645
+ $this->range = $vals['range'];
646
+ }
647
+ if (isset($vals['maxCount'])) {
648
+ $this->maxCount = $vals['maxCount'];
649
+ }
650
+ if (isset($vals['minPopulation'])) {
651
+ $this->minPopulation = $vals['minPopulation'];
652
+ }
653
+ if (isset($vals['dateRangeGap'])) {
654
+ $this->dateRangeGap = $vals['dateRangeGap'];
655
+ }
656
+ if (isset($vals['sortOrder'])) {
657
+ $this->sortOrder = $vals['sortOrder'];
658
+ }
659
+ if (isset($vals['sortAscending'])) {
660
+ $this->sortAscending = $vals['sortAscending'];
661
+ }
662
+ if (isset($vals['selectedValues'])) {
663
+ $this->selectedValues = $vals['selectedValues'];
664
+ }
665
+ if (isset($vals['andSelectedValues'])) {
666
+ $this->andSelectedValues = $vals['andSelectedValues'];
667
+ }
668
+ }
669
+ }
670
+
671
+ public function getName() {
672
+ return 'FacetRequest';
673
+ }
674
+
675
+ public function read($input)
676
+ {
677
+ $xfer = 0;
678
+ $fname = null;
679
+ $ftype = 0;
680
+ $fid = 0;
681
+ $xfer += $input->readStructBegin($fname);
682
+ while (true)
683
+ {
684
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
685
+ if ($ftype == TType::STOP) {
686
+ break;
687
+ }
688
+ switch ($fid)
689
+ {
690
+ case 1:
691
+ if ($ftype == TType::STRING) {
692
+ $xfer += $input->readString($this->fieldName);
693
+ } else {
694
+ $xfer += $input->skip($ftype);
695
+ }
696
+ break;
697
+ case 2:
698
+ if ($ftype == TType::BOOL) {
699
+ $xfer += $input->readBool($this->numerical);
700
+ } else {
701
+ $xfer += $input->skip($ftype);
702
+ }
703
+ break;
704
+ case 3:
705
+ if ($ftype == TType::BOOL) {
706
+ $xfer += $input->readBool($this->range);
707
+ } else {
708
+ $xfer += $input->skip($ftype);
709
+ }
710
+ break;
711
+ case 4:
712
+ if ($ftype == TType::I32) {
713
+ $xfer += $input->readI32($this->maxCount);
714
+ } else {
715
+ $xfer += $input->skip($ftype);
716
+ }
717
+ break;
718
+ case 5:
719
+ if ($ftype == TType::I32) {
720
+ $xfer += $input->readI32($this->minPopulation);
721
+ } else {
722
+ $xfer += $input->skip($ftype);
723
+ }
724
+ break;
725
+ case 6:
726
+ if ($ftype == TType::I32) {
727
+ $xfer += $input->readI32($this->dateRangeGap);
728
+ } else {
729
+ $xfer += $input->skip($ftype);
730
+ }
731
+ break;
732
+ case 7:
733
+ if ($ftype == TType::I32) {
734
+ $xfer += $input->readI32($this->sortOrder);
735
+ } else {
736
+ $xfer += $input->skip($ftype);
737
+ }
738
+ break;
739
+ case 8:
740
+ if ($ftype == TType::BOOL) {
741
+ $xfer += $input->readBool($this->sortAscending);
742
+ } else {
743
+ $xfer += $input->skip($ftype);
744
+ }
745
+ break;
746
+ case 90:
747
+ if ($ftype == TType::LST) {
748
+ $this->selectedValues = array();
749
+ $_size21 = 0;
750
+ $_etype24 = 0;
751
+ $xfer += $input->readListBegin($_etype24, $_size21);
752
+ for ($_i25 = 0; $_i25 < $_size21; ++$_i25)
753
+ {
754
+ $elem26 = null;
755
+ $elem26 = new \com\boxalino\p13n\api\thrift\FacetValue();
756
+ $xfer += $elem26->read($input);
757
+ $this->selectedValues []= $elem26;
758
+ }
759
+ $xfer += $input->readListEnd();
760
+ } else {
761
+ $xfer += $input->skip($ftype);
762
+ }
763
+ break;
764
+ case 100:
765
+ if ($ftype == TType::BOOL) {
766
+ $xfer += $input->readBool($this->andSelectedValues);
767
+ } else {
768
+ $xfer += $input->skip($ftype);
769
+ }
770
+ break;
771
+ default:
772
+ $xfer += $input->skip($ftype);
773
+ break;
774
+ }
775
+ $xfer += $input->readFieldEnd();
776
+ }
777
+ $xfer += $input->readStructEnd();
778
+ return $xfer;
779
+ }
780
+
781
+ public function write($output) {
782
+ $xfer = 0;
783
+ $xfer += $output->writeStructBegin('FacetRequest');
784
+ if ($this->fieldName !== null) {
785
+ $xfer += $output->writeFieldBegin('fieldName', TType::STRING, 1);
786
+ $xfer += $output->writeString($this->fieldName);
787
+ $xfer += $output->writeFieldEnd();
788
+ }
789
+ if ($this->numerical !== null) {
790
+ $xfer += $output->writeFieldBegin('numerical', TType::BOOL, 2);
791
+ $xfer += $output->writeBool($this->numerical);
792
+ $xfer += $output->writeFieldEnd();
793
+ }
794
+ if ($this->range !== null) {
795
+ $xfer += $output->writeFieldBegin('range', TType::BOOL, 3);
796
+ $xfer += $output->writeBool($this->range);
797
+ $xfer += $output->writeFieldEnd();
798
+ }
799
+ if ($this->maxCount !== null) {
800
+ $xfer += $output->writeFieldBegin('maxCount', TType::I32, 4);
801
+ $xfer += $output->writeI32($this->maxCount);
802
+ $xfer += $output->writeFieldEnd();
803
+ }
804
+ if ($this->minPopulation !== null) {
805
+ $xfer += $output->writeFieldBegin('minPopulation', TType::I32, 5);
806
+ $xfer += $output->writeI32($this->minPopulation);
807
+ $xfer += $output->writeFieldEnd();
808
+ }
809
+ if ($this->dateRangeGap !== null) {
810
+ $xfer += $output->writeFieldBegin('dateRangeGap', TType::I32, 6);
811
+ $xfer += $output->writeI32($this->dateRangeGap);
812
+ $xfer += $output->writeFieldEnd();
813
+ }
814
+ if ($this->sortOrder !== null) {
815
+ $xfer += $output->writeFieldBegin('sortOrder', TType::I32, 7);
816
+ $xfer += $output->writeI32($this->sortOrder);
817
+ $xfer += $output->writeFieldEnd();
818
+ }
819
+ if ($this->sortAscending !== null) {
820
+ $xfer += $output->writeFieldBegin('sortAscending', TType::BOOL, 8);
821
+ $xfer += $output->writeBool($this->sortAscending);
822
+ $xfer += $output->writeFieldEnd();
823
+ }
824
+ if ($this->selectedValues !== null) {
825
+ if (!is_array($this->selectedValues)) {
826
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
827
+ }
828
+ $xfer += $output->writeFieldBegin('selectedValues', TType::LST, 90);
829
+ {
830
+ $output->writeListBegin(TType::STRUCT, count($this->selectedValues));
831
+ {
832
+ foreach ($this->selectedValues as $iter27)
833
+ {
834
+ $xfer += $iter27->write($output);
835
+ }
836
+ }
837
+ $output->writeListEnd();
838
+ }
839
+ $xfer += $output->writeFieldEnd();
840
+ }
841
+ if ($this->andSelectedValues !== null) {
842
+ $xfer += $output->writeFieldBegin('andSelectedValues', TType::BOOL, 100);
843
+ $xfer += $output->writeBool($this->andSelectedValues);
844
+ $xfer += $output->writeFieldEnd();
845
+ }
846
+ $xfer += $output->writeFieldStop();
847
+ $xfer += $output->writeStructEnd();
848
+ return $xfer;
849
+ }
850
+
851
+ }
852
+
853
+ class SortField {
854
+ static $_TSPEC;
855
+
856
+ public $fieldName = null;
857
+ public $reverse = null;
858
+
859
+ public function __construct($vals=null) {
860
+ if (!isset(self::$_TSPEC)) {
861
+ self::$_TSPEC = array(
862
+ 1 => array(
863
+ 'var' => 'fieldName',
864
+ 'type' => TType::STRING,
865
+ ),
866
+ 2 => array(
867
+ 'var' => 'reverse',
868
+ 'type' => TType::BOOL,
869
+ ),
870
+ );
871
+ }
872
+ if (is_array($vals)) {
873
+ if (isset($vals['fieldName'])) {
874
+ $this->fieldName = $vals['fieldName'];
875
+ }
876
+ if (isset($vals['reverse'])) {
877
+ $this->reverse = $vals['reverse'];
878
+ }
879
+ }
880
+ }
881
+
882
+ public function getName() {
883
+ return 'SortField';
884
+ }
885
+
886
+ public function read($input)
887
+ {
888
+ $xfer = 0;
889
+ $fname = null;
890
+ $ftype = 0;
891
+ $fid = 0;
892
+ $xfer += $input->readStructBegin($fname);
893
+ while (true)
894
+ {
895
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
896
+ if ($ftype == TType::STOP) {
897
+ break;
898
+ }
899
+ switch ($fid)
900
+ {
901
+ case 1:
902
+ if ($ftype == TType::STRING) {
903
+ $xfer += $input->readString($this->fieldName);
904
+ } else {
905
+ $xfer += $input->skip($ftype);
906
+ }
907
+ break;
908
+ case 2:
909
+ if ($ftype == TType::BOOL) {
910
+ $xfer += $input->readBool($this->reverse);
911
+ } else {
912
+ $xfer += $input->skip($ftype);
913
+ }
914
+ break;
915
+ default:
916
+ $xfer += $input->skip($ftype);
917
+ break;
918
+ }
919
+ $xfer += $input->readFieldEnd();
920
+ }
921
+ $xfer += $input->readStructEnd();
922
+ return $xfer;
923
+ }
924
+
925
+ public function write($output) {
926
+ $xfer = 0;
927
+ $xfer += $output->writeStructBegin('SortField');
928
+ if ($this->fieldName !== null) {
929
+ $xfer += $output->writeFieldBegin('fieldName', TType::STRING, 1);
930
+ $xfer += $output->writeString($this->fieldName);
931
+ $xfer += $output->writeFieldEnd();
932
+ }
933
+ if ($this->reverse !== null) {
934
+ $xfer += $output->writeFieldBegin('reverse', TType::BOOL, 2);
935
+ $xfer += $output->writeBool($this->reverse);
936
+ $xfer += $output->writeFieldEnd();
937
+ }
938
+ $xfer += $output->writeFieldStop();
939
+ $xfer += $output->writeStructEnd();
940
+ return $xfer;
941
+ }
942
+
943
+ }
944
+
945
+ class SimpleSearchQuery {
946
+ static $_TSPEC;
947
+
948
+ public $indexId = null;
949
+ public $language = null;
950
+ public $queryText = null;
951
+ public $filters = null;
952
+ public $orFilters = null;
953
+ public $facetRequests = null;
954
+ public $sortFields = null;
955
+ public $offset = null;
956
+ public $hitCount = null;
957
+ public $returnFields = null;
958
+ public $groupBy = null;
959
+ public $groupFacets = true;
960
+ public $groupItemsCount = 1;
961
+ public $groupItemsSort = "score";
962
+ public $groupItemsSortAscending = false;
963
+
964
+ public function __construct($vals=null) {
965
+ if (!isset(self::$_TSPEC)) {
966
+ self::$_TSPEC = array(
967
+ 1 => array(
968
+ 'var' => 'indexId',
969
+ 'type' => TType::STRING,
970
+ ),
971
+ 2 => array(
972
+ 'var' => 'language',
973
+ 'type' => TType::STRING,
974
+ ),
975
+ 3 => array(
976
+ 'var' => 'queryText',
977
+ 'type' => TType::STRING,
978
+ ),
979
+ 4 => array(
980
+ 'var' => 'filters',
981
+ 'type' => TType::LST,
982
+ 'etype' => TType::STRUCT,
983
+ 'elem' => array(
984
+ 'type' => TType::STRUCT,
985
+ 'class' => '\com\boxalino\p13n\api\thrift\Filter',
986
+ ),
987
+ ),
988
+ 5 => array(
989
+ 'var' => 'orFilters',
990
+ 'type' => TType::BOOL,
991
+ ),
992
+ 6 => array(
993
+ 'var' => 'facetRequests',
994
+ 'type' => TType::LST,
995
+ 'etype' => TType::STRUCT,
996
+ 'elem' => array(
997
+ 'type' => TType::STRUCT,
998
+ 'class' => '\com\boxalino\p13n\api\thrift\FacetRequest',
999
+ ),
1000
+ ),
1001
+ 7 => array(
1002
+ 'var' => 'sortFields',
1003
+ 'type' => TType::LST,
1004
+ 'etype' => TType::STRUCT,
1005
+ 'elem' => array(
1006
+ 'type' => TType::STRUCT,
1007
+ 'class' => '\com\boxalino\p13n\api\thrift\SortField',
1008
+ ),
1009
+ ),
1010
+ 8 => array(
1011
+ 'var' => 'offset',
1012
+ 'type' => TType::I64,
1013
+ ),
1014
+ 9 => array(
1015
+ 'var' => 'hitCount',
1016
+ 'type' => TType::I32,
1017
+ ),
1018
+ 10 => array(
1019
+ 'var' => 'returnFields',
1020
+ 'type' => TType::LST,
1021
+ 'etype' => TType::STRING,
1022
+ 'elem' => array(
1023
+ 'type' => TType::STRING,
1024
+ ),
1025
+ ),
1026
+ 20 => array(
1027
+ 'var' => 'groupBy',
1028
+ 'type' => TType::STRING,
1029
+ ),
1030
+ 30 => array(
1031
+ 'var' => 'groupFacets',
1032
+ 'type' => TType::BOOL,
1033
+ ),
1034
+ 40 => array(
1035
+ 'var' => 'groupItemsCount',
1036
+ 'type' => TType::I32,
1037
+ ),
1038
+ 50 => array(
1039
+ 'var' => 'groupItemsSort',
1040
+ 'type' => TType::STRING,
1041
+ ),
1042
+ 60 => array(
1043
+ 'var' => 'groupItemsSortAscending',
1044
+ 'type' => TType::BOOL,
1045
+ ),
1046
+ );
1047
+ }
1048
+ if (is_array($vals)) {
1049
+ if (isset($vals['indexId'])) {
1050
+ $this->indexId = $vals['indexId'];
1051
+ }
1052
+ if (isset($vals['language'])) {
1053
+ $this->language = $vals['language'];
1054
+ }
1055
+ if (isset($vals['queryText'])) {
1056
+ $this->queryText = $vals['queryText'];
1057
+ }
1058
+ if (isset($vals['filters'])) {
1059
+ $this->filters = $vals['filters'];
1060
+ }
1061
+ if (isset($vals['orFilters'])) {
1062
+ $this->orFilters = $vals['orFilters'];
1063
+ }
1064
+ if (isset($vals['facetRequests'])) {
1065
+ $this->facetRequests = $vals['facetRequests'];
1066
+ }
1067
+ if (isset($vals['sortFields'])) {
1068
+ $this->sortFields = $vals['sortFields'];
1069
+ }
1070
+ if (isset($vals['offset'])) {
1071
+ $this->offset = $vals['offset'];
1072
+ }
1073
+ if (isset($vals['hitCount'])) {
1074
+ $this->hitCount = $vals['hitCount'];
1075
+ }
1076
+ if (isset($vals['returnFields'])) {
1077
+ $this->returnFields = $vals['returnFields'];
1078
+ }
1079
+ if (isset($vals['groupBy'])) {
1080
+ $this->groupBy = $vals['groupBy'];
1081
+ }
1082
+ if (isset($vals['groupFacets'])) {
1083
+ $this->groupFacets = $vals['groupFacets'];
1084
+ }
1085
+ if (isset($vals['groupItemsCount'])) {
1086
+ $this->groupItemsCount = $vals['groupItemsCount'];
1087
+ }
1088
+ if (isset($vals['groupItemsSort'])) {
1089
+ $this->groupItemsSort = $vals['groupItemsSort'];
1090
+ }
1091
+ if (isset($vals['groupItemsSortAscending'])) {
1092
+ $this->groupItemsSortAscending = $vals['groupItemsSortAscending'];
1093
+ }
1094
+ }
1095
+ }
1096
+
1097
+ public function getName() {
1098
+ return 'SimpleSearchQuery';
1099
+ }
1100
+
1101
+ public function read($input)
1102
+ {
1103
+ $xfer = 0;
1104
+ $fname = null;
1105
+ $ftype = 0;
1106
+ $fid = 0;
1107
+ $xfer += $input->readStructBegin($fname);
1108
+ while (true)
1109
+ {
1110
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
1111
+ if ($ftype == TType::STOP) {
1112
+ break;
1113
+ }
1114
+ switch ($fid)
1115
+ {
1116
+ case 1:
1117
+ if ($ftype == TType::STRING) {
1118
+ $xfer += $input->readString($this->indexId);
1119
+ } else {
1120
+ $xfer += $input->skip($ftype);
1121
+ }
1122
+ break;
1123
+ case 2:
1124
+ if ($ftype == TType::STRING) {
1125
+ $xfer += $input->readString($this->language);
1126
+ } else {
1127
+ $xfer += $input->skip($ftype);
1128
+ }
1129
+ break;
1130
+ case 3:
1131
+ if ($ftype == TType::STRING) {
1132
+ $xfer += $input->readString($this->queryText);
1133
+ } else {
1134
+ $xfer += $input->skip($ftype);
1135
+ }
1136
+ break;
1137
+ case 4:
1138
+ if ($ftype == TType::LST) {
1139
+ $this->filters = array();
1140
+ $_size28 = 0;
1141
+ $_etype31 = 0;
1142
+ $xfer += $input->readListBegin($_etype31, $_size28);
1143
+ for ($_i32 = 0; $_i32 < $_size28; ++$_i32)
1144
+ {
1145
+ $elem33 = null;
1146
+ $elem33 = new \com\boxalino\p13n\api\thrift\Filter();
1147
+ $xfer += $elem33->read($input);
1148
+ $this->filters []= $elem33;
1149
+ }
1150
+ $xfer += $input->readListEnd();
1151
+ } else {
1152
+ $xfer += $input->skip($ftype);
1153
+ }
1154
+ break;
1155
+ case 5:
1156
+ if ($ftype == TType::BOOL) {
1157
+ $xfer += $input->readBool($this->orFilters);
1158
+ } else {
1159
+ $xfer += $input->skip($ftype);
1160
+ }
1161
+ break;
1162
+ case 6:
1163
+ if ($ftype == TType::LST) {
1164
+ $this->facetRequests = array();
1165
+ $_size34 = 0;
1166
+ $_etype37 = 0;
1167
+ $xfer += $input->readListBegin($_etype37, $_size34);
1168
+ for ($_i38 = 0; $_i38 < $_size34; ++$_i38)
1169
+ {
1170
+ $elem39 = null;
1171
+ $elem39 = new \com\boxalino\p13n\api\thrift\FacetRequest();
1172
+ $xfer += $elem39->read($input);
1173
+ $this->facetRequests []= $elem39;
1174
+ }
1175
+ $xfer += $input->readListEnd();
1176
+ } else {
1177
+ $xfer += $input->skip($ftype);
1178
+ }
1179
+ break;
1180
+ case 7:
1181
+ if ($ftype == TType::LST) {
1182
+ $this->sortFields = array();
1183
+ $_size40 = 0;
1184
+ $_etype43 = 0;
1185
+ $xfer += $input->readListBegin($_etype43, $_size40);
1186
+ for ($_i44 = 0; $_i44 < $_size40; ++$_i44)
1187
+ {
1188
+ $elem45 = null;
1189
+ $elem45 = new \com\boxalino\p13n\api\thrift\SortField();
1190
+ $xfer += $elem45->read($input);
1191
+ $this->sortFields []= $elem45;
1192
+ }
1193
+ $xfer += $input->readListEnd();
1194
+ } else {
1195
+ $xfer += $input->skip($ftype);
1196
+ }
1197
+ break;
1198
+ case 8:
1199
+ if ($ftype == TType::I64) {
1200
+ $xfer += $input->readI64($this->offset);
1201
+ } else {
1202
+ $xfer += $input->skip($ftype);
1203
+ }
1204
+ break;
1205
+ case 9:
1206
+ if ($ftype == TType::I32) {
1207
+ $xfer += $input->readI32($this->hitCount);
1208
+ } else {
1209
+ $xfer += $input->skip($ftype);
1210
+ }
1211
+ break;
1212
+ case 10:
1213
+ if ($ftype == TType::LST) {
1214
+ $this->returnFields = array();
1215
+ $_size46 = 0;
1216
+ $_etype49 = 0;
1217
+ $xfer += $input->readListBegin($_etype49, $_size46);
1218
+ for ($_i50 = 0; $_i50 < $_size46; ++$_i50)
1219
+ {
1220
+ $elem51 = null;
1221
+ $xfer += $input->readString($elem51);
1222
+ $this->returnFields []= $elem51;
1223
+ }
1224
+ $xfer += $input->readListEnd();
1225
+ } else {
1226
+ $xfer += $input->skip($ftype);
1227
+ }
1228
+ break;
1229
+ case 20:
1230
+ if ($ftype == TType::STRING) {
1231
+ $xfer += $input->readString($this->groupBy);
1232
+ } else {
1233
+ $xfer += $input->skip($ftype);
1234
+ }
1235
+ break;
1236
+ case 30:
1237
+ if ($ftype == TType::BOOL) {
1238
+ $xfer += $input->readBool($this->groupFacets);
1239
+ } else {
1240
+ $xfer += $input->skip($ftype);
1241
+ }
1242
+ break;
1243
+ case 40:
1244
+ if ($ftype == TType::I32) {
1245
+ $xfer += $input->readI32($this->groupItemsCount);
1246
+ } else {
1247
+ $xfer += $input->skip($ftype);
1248
+ }
1249
+ break;
1250
+ case 50:
1251
+ if ($ftype == TType::STRING) {
1252
+ $xfer += $input->readString($this->groupItemsSort);
1253
+ } else {
1254
+ $xfer += $input->skip($ftype);
1255
+ }
1256
+ break;
1257
+ case 60:
1258
+ if ($ftype == TType::BOOL) {
1259
+ $xfer += $input->readBool($this->groupItemsSortAscending);
1260
+ } else {
1261
+ $xfer += $input->skip($ftype);
1262
+ }
1263
+ break;
1264
+ default:
1265
+ $xfer += $input->skip($ftype);
1266
+ break;
1267
+ }
1268
+ $xfer += $input->readFieldEnd();
1269
+ }
1270
+ $xfer += $input->readStructEnd();
1271
+ return $xfer;
1272
+ }
1273
+
1274
+ public function write($output) {
1275
+ $xfer = 0;
1276
+ $xfer += $output->writeStructBegin('SimpleSearchQuery');
1277
+ if ($this->indexId !== null) {
1278
+ $xfer += $output->writeFieldBegin('indexId', TType::STRING, 1);
1279
+ $xfer += $output->writeString($this->indexId);
1280
+ $xfer += $output->writeFieldEnd();
1281
+ }
1282
+ if ($this->language !== null) {
1283
+ $xfer += $output->writeFieldBegin('language', TType::STRING, 2);
1284
+ $xfer += $output->writeString($this->language);
1285
+ $xfer += $output->writeFieldEnd();
1286
+ }
1287
+ if ($this->queryText !== null) {
1288
+ $xfer += $output->writeFieldBegin('queryText', TType::STRING, 3);
1289
+ $xfer += $output->writeString($this->queryText);
1290
+ $xfer += $output->writeFieldEnd();
1291
+ }
1292
+ if ($this->filters !== null) {
1293
+ if (!is_array($this->filters)) {
1294
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
1295
+ }
1296
+ $xfer += $output->writeFieldBegin('filters', TType::LST, 4);
1297
+ {
1298
+ $output->writeListBegin(TType::STRUCT, count($this->filters));
1299
+ {
1300
+ foreach ($this->filters as $iter52)
1301
+ {
1302
+ $xfer += $iter52->write($output);
1303
+ }
1304
+ }
1305
+ $output->writeListEnd();
1306
+ }
1307
+ $xfer += $output->writeFieldEnd();
1308
+ }
1309
+ if ($this->orFilters !== null) {
1310
+ $xfer += $output->writeFieldBegin('orFilters', TType::BOOL, 5);
1311
+ $xfer += $output->writeBool($this->orFilters);
1312
+ $xfer += $output->writeFieldEnd();
1313
+ }
1314
+ if ($this->facetRequests !== null) {
1315
+ if (!is_array($this->facetRequests)) {
1316
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
1317
+ }
1318
+ $xfer += $output->writeFieldBegin('facetRequests', TType::LST, 6);
1319
+ {
1320
+ $output->writeListBegin(TType::STRUCT, count($this->facetRequests));
1321
+ {
1322
+ foreach ($this->facetRequests as $iter53)
1323
+ {
1324
+ $xfer += $iter53->write($output);
1325
+ }
1326
+ }
1327
+ $output->writeListEnd();
1328
+ }
1329
+ $xfer += $output->writeFieldEnd();
1330
+ }
1331
+ if ($this->sortFields !== null) {
1332
+ if (!is_array($this->sortFields)) {
1333
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
1334
+ }
1335
+ $xfer += $output->writeFieldBegin('sortFields', TType::LST, 7);
1336
+ {
1337
+ $output->writeListBegin(TType::STRUCT, count($this->sortFields));
1338
+ {
1339
+ foreach ($this->sortFields as $iter54)
1340
+ {
1341
+ $xfer += $iter54->write($output);
1342
+ }
1343
+ }
1344
+ $output->writeListEnd();
1345
+ }
1346
+ $xfer += $output->writeFieldEnd();
1347
+ }
1348
+ if ($this->offset !== null) {
1349
+ $xfer += $output->writeFieldBegin('offset', TType::I64, 8);
1350
+ $xfer += $output->writeI64($this->offset);
1351
+ $xfer += $output->writeFieldEnd();
1352
+ }
1353
+ if ($this->hitCount !== null) {
1354
+ $xfer += $output->writeFieldBegin('hitCount', TType::I32, 9);
1355
+ $xfer += $output->writeI32($this->hitCount);
1356
+ $xfer += $output->writeFieldEnd();
1357
+ }
1358
+ if ($this->returnFields !== null) {
1359
+ if (!is_array($this->returnFields)) {
1360
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
1361
+ }
1362
+ $xfer += $output->writeFieldBegin('returnFields', TType::LST, 10);
1363
+ {
1364
+ $output->writeListBegin(TType::STRING, count($this->returnFields));
1365
+ {
1366
+ foreach ($this->returnFields as $iter55)
1367
+ {
1368
+ $xfer += $output->writeString($iter55);
1369
+ }
1370
+ }
1371
+ $output->writeListEnd();
1372
+ }
1373
+ $xfer += $output->writeFieldEnd();
1374
+ }
1375
+ if ($this->groupBy !== null) {
1376
+ $xfer += $output->writeFieldBegin('groupBy', TType::STRING, 20);
1377
+ $xfer += $output->writeString($this->groupBy);
1378
+ $xfer += $output->writeFieldEnd();
1379
+ }
1380
+ if ($this->groupFacets !== null) {
1381
+ $xfer += $output->writeFieldBegin('groupFacets', TType::BOOL, 30);
1382
+ $xfer += $output->writeBool($this->groupFacets);
1383
+ $xfer += $output->writeFieldEnd();
1384
+ }
1385
+ if ($this->groupItemsCount !== null) {
1386
+ $xfer += $output->writeFieldBegin('groupItemsCount', TType::I32, 40);
1387
+ $xfer += $output->writeI32($this->groupItemsCount);
1388
+ $xfer += $output->writeFieldEnd();
1389
+ }
1390
+ if ($this->groupItemsSort !== null) {
1391
+ $xfer += $output->writeFieldBegin('groupItemsSort', TType::STRING, 50);
1392
+ $xfer += $output->writeString($this->groupItemsSort);
1393
+ $xfer += $output->writeFieldEnd();
1394
+ }
1395
+ if ($this->groupItemsSortAscending !== null) {
1396
+ $xfer += $output->writeFieldBegin('groupItemsSortAscending', TType::BOOL, 60);
1397
+ $xfer += $output->writeBool($this->groupItemsSortAscending);
1398
+ $xfer += $output->writeFieldEnd();
1399
+ }
1400
+ $xfer += $output->writeFieldStop();
1401
+ $xfer += $output->writeStructEnd();
1402
+ return $xfer;
1403
+ }
1404
+
1405
+ }
1406
+
1407
+ class ContextItem {
1408
+ static $_TSPEC;
1409
+
1410
+ public $indexId = null;
1411
+ public $fieldName = null;
1412
+ public $contextItemId = null;
1413
+ public $role = null;
1414
+
1415
+ public function __construct($vals=null) {
1416
+ if (!isset(self::$_TSPEC)) {
1417
+ self::$_TSPEC = array(
1418
+ 1 => array(
1419
+ 'var' => 'indexId',
1420
+ 'type' => TType::STRING,
1421
+ ),
1422
+ 2 => array(
1423
+ 'var' => 'fieldName',
1424
+ 'type' => TType::STRING,
1425
+ ),
1426
+ 3 => array(
1427
+ 'var' => 'contextItemId',
1428
+ 'type' => TType::STRING,
1429
+ ),
1430
+ 4 => array(
1431
+ 'var' => 'role',
1432
+ 'type' => TType::STRING,
1433
+ ),
1434
+ );
1435
+ }
1436
+ if (is_array($vals)) {
1437
+ if (isset($vals['indexId'])) {
1438
+ $this->indexId = $vals['indexId'];
1439
+ }
1440
+ if (isset($vals['fieldName'])) {
1441
+ $this->fieldName = $vals['fieldName'];
1442
+ }
1443
+ if (isset($vals['contextItemId'])) {
1444
+ $this->contextItemId = $vals['contextItemId'];
1445
+ }
1446
+ if (isset($vals['role'])) {
1447
+ $this->role = $vals['role'];
1448
+ }
1449
+ }
1450
+ }
1451
+
1452
+ public function getName() {
1453
+ return 'ContextItem';
1454
+ }
1455
+
1456
+ public function read($input)
1457
+ {
1458
+ $xfer = 0;
1459
+ $fname = null;
1460
+ $ftype = 0;
1461
+ $fid = 0;
1462
+ $xfer += $input->readStructBegin($fname);
1463
+ while (true)
1464
+ {
1465
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
1466
+ if ($ftype == TType::STOP) {
1467
+ break;
1468
+ }
1469
+ switch ($fid)
1470
+ {
1471
+ case 1:
1472
+ if ($ftype == TType::STRING) {
1473
+ $xfer += $input->readString($this->indexId);
1474
+ } else {
1475
+ $xfer += $input->skip($ftype);
1476
+ }
1477
+ break;
1478
+ case 2:
1479
+ if ($ftype == TType::STRING) {
1480
+ $xfer += $input->readString($this->fieldName);
1481
+ } else {
1482
+ $xfer += $input->skip($ftype);
1483
+ }
1484
+ break;
1485
+ case 3:
1486
+ if ($ftype == TType::STRING) {
1487
+ $xfer += $input->readString($this->contextItemId);
1488
+ } else {
1489
+ $xfer += $input->skip($ftype);
1490
+ }
1491
+ break;
1492
+ case 4:
1493
+ if ($ftype == TType::STRING) {
1494
+ $xfer += $input->readString($this->role);
1495
+ } else {
1496
+ $xfer += $input->skip($ftype);
1497
+ }
1498
+ break;
1499
+ default:
1500
+ $xfer += $input->skip($ftype);
1501
+ break;
1502
+ }
1503
+ $xfer += $input->readFieldEnd();
1504
+ }
1505
+ $xfer += $input->readStructEnd();
1506
+ return $xfer;
1507
+ }
1508
+
1509
+ public function write($output) {
1510
+ $xfer = 0;
1511
+ $xfer += $output->writeStructBegin('ContextItem');
1512
+ if ($this->indexId !== null) {
1513
+ $xfer += $output->writeFieldBegin('indexId', TType::STRING, 1);
1514
+ $xfer += $output->writeString($this->indexId);
1515
+ $xfer += $output->writeFieldEnd();
1516
+ }
1517
+ if ($this->fieldName !== null) {
1518
+ $xfer += $output->writeFieldBegin('fieldName', TType::STRING, 2);
1519
+ $xfer += $output->writeString($this->fieldName);
1520
+ $xfer += $output->writeFieldEnd();
1521
+ }
1522
+ if ($this->contextItemId !== null) {
1523
+ $xfer += $output->writeFieldBegin('contextItemId', TType::STRING, 3);
1524
+ $xfer += $output->writeString($this->contextItemId);
1525
+ $xfer += $output->writeFieldEnd();
1526
+ }
1527
+ if ($this->role !== null) {
1528
+ $xfer += $output->writeFieldBegin('role', TType::STRING, 4);
1529
+ $xfer += $output->writeString($this->role);
1530
+ $xfer += $output->writeFieldEnd();
1531
+ }
1532
+ $xfer += $output->writeFieldStop();
1533
+ $xfer += $output->writeStructEnd();
1534
+ return $xfer;
1535
+ }
1536
+
1537
+ }
1538
+
1539
+ class ChoiceInquiry {
1540
+ static $_TSPEC;
1541
+
1542
+ public $choiceId = null;
1543
+ public $simpleSearchQuery = null;
1544
+ public $contextItems = null;
1545
+ public $minHitCount = null;
1546
+ public $excludeVariantIds = null;
1547
+ public $scope = "system_rec";
1548
+ public $withRelaxation = false;
1549
+
1550
+ public function __construct($vals=null) {
1551
+ if (!isset(self::$_TSPEC)) {
1552
+ self::$_TSPEC = array(
1553
+ 1 => array(
1554
+ 'var' => 'choiceId',
1555
+ 'type' => TType::STRING,
1556
+ ),
1557
+ 2 => array(
1558
+ 'var' => 'simpleSearchQuery',
1559
+ 'type' => TType::STRUCT,
1560
+ 'class' => '\com\boxalino\p13n\api\thrift\SimpleSearchQuery',
1561
+ ),
1562
+ 3 => array(
1563
+ 'var' => 'contextItems',
1564
+ 'type' => TType::LST,
1565
+ 'etype' => TType::STRUCT,
1566
+ 'elem' => array(
1567
+ 'type' => TType::STRUCT,
1568
+ 'class' => '\com\boxalino\p13n\api\thrift\ContextItem',
1569
+ ),
1570
+ ),
1571
+ 4 => array(
1572
+ 'var' => 'minHitCount',
1573
+ 'type' => TType::I32,
1574
+ ),
1575
+ 5 => array(
1576
+ 'var' => 'excludeVariantIds',
1577
+ 'type' => TType::SET,
1578
+ 'etype' => TType::STRING,
1579
+ 'elem' => array(
1580
+ 'type' => TType::STRING,
1581
+ ),
1582
+ ),
1583
+ 6 => array(
1584
+ 'var' => 'scope',
1585
+ 'type' => TType::STRING,
1586
+ ),
1587
+ 70 => array(
1588
+ 'var' => 'withRelaxation',
1589
+ 'type' => TType::BOOL,
1590
+ ),
1591
+ );
1592
+ }
1593
+ if (is_array($vals)) {
1594
+ if (isset($vals['choiceId'])) {
1595
+ $this->choiceId = $vals['choiceId'];
1596
+ }
1597
+ if (isset($vals['simpleSearchQuery'])) {
1598
+ $this->simpleSearchQuery = $vals['simpleSearchQuery'];
1599
+ }
1600
+ if (isset($vals['contextItems'])) {
1601
+ $this->contextItems = $vals['contextItems'];
1602
+ }
1603
+ if (isset($vals['minHitCount'])) {
1604
+ $this->minHitCount = $vals['minHitCount'];
1605
+ }
1606
+ if (isset($vals['excludeVariantIds'])) {
1607
+ $this->excludeVariantIds = $vals['excludeVariantIds'];
1608
+ }
1609
+ if (isset($vals['scope'])) {
1610
+ $this->scope = $vals['scope'];
1611
+ }
1612
+ if (isset($vals['withRelaxation'])) {
1613
+ $this->withRelaxation = $vals['withRelaxation'];
1614
+ }
1615
+ }
1616
+ }
1617
+
1618
+ public function getName() {
1619
+ return 'ChoiceInquiry';
1620
+ }
1621
+
1622
+ public function read($input)
1623
+ {
1624
+ $xfer = 0;
1625
+ $fname = null;
1626
+ $ftype = 0;
1627
+ $fid = 0;
1628
+ $xfer += $input->readStructBegin($fname);
1629
+ while (true)
1630
+ {
1631
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
1632
+ if ($ftype == TType::STOP) {
1633
+ break;
1634
+ }
1635
+ switch ($fid)
1636
+ {
1637
+ case 1:
1638
+ if ($ftype == TType::STRING) {
1639
+ $xfer += $input->readString($this->choiceId);
1640
+ } else {
1641
+ $xfer += $input->skip($ftype);
1642
+ }
1643
+ break;
1644
+ case 2:
1645
+ if ($ftype == TType::STRUCT) {
1646
+ $this->simpleSearchQuery = new \com\boxalino\p13n\api\thrift\SimpleSearchQuery();
1647
+ $xfer += $this->simpleSearchQuery->read($input);
1648
+ } else {
1649
+ $xfer += $input->skip($ftype);
1650
+ }
1651
+ break;
1652
+ case 3:
1653
+ if ($ftype == TType::LST) {
1654
+ $this->contextItems = array();
1655
+ $_size56 = 0;
1656
+ $_etype59 = 0;
1657
+ $xfer += $input->readListBegin($_etype59, $_size56);
1658
+ for ($_i60 = 0; $_i60 < $_size56; ++$_i60)
1659
+ {
1660
+ $elem61 = null;
1661
+ $elem61 = new \com\boxalino\p13n\api\thrift\ContextItem();
1662
+ $xfer += $elem61->read($input);
1663
+ $this->contextItems []= $elem61;
1664
+ }
1665
+ $xfer += $input->readListEnd();
1666
+ } else {
1667
+ $xfer += $input->skip($ftype);
1668
+ }
1669
+ break;
1670
+ case 4:
1671
+ if ($ftype == TType::I32) {
1672
+ $xfer += $input->readI32($this->minHitCount);
1673
+ } else {
1674
+ $xfer += $input->skip($ftype);
1675
+ }
1676
+ break;
1677
+ case 5:
1678
+ if ($ftype == TType::SET) {
1679
+ $this->excludeVariantIds = array();
1680
+ $_size62 = 0;
1681
+ $_etype65 = 0;
1682
+ $xfer += $input->readSetBegin($_etype65, $_size62);
1683
+ for ($_i66 = 0; $_i66 < $_size62; ++$_i66)
1684
+ {
1685
+ $elem67 = null;
1686
+ $xfer += $input->readString($elem67);
1687
+ if (is_scalar($elem67)) {
1688
+ $this->excludeVariantIds[$elem67] = true;
1689
+ } else {
1690
+ $this->excludeVariantIds []= $elem67;
1691
+ }
1692
+ }
1693
+ $xfer += $input->readSetEnd();
1694
+ } else {
1695
+ $xfer += $input->skip($ftype);
1696
+ }
1697
+ break;
1698
+ case 6:
1699
+ if ($ftype == TType::STRING) {
1700
+ $xfer += $input->readString($this->scope);
1701
+ } else {
1702
+ $xfer += $input->skip($ftype);
1703
+ }
1704
+ break;
1705
+ case 70:
1706
+ if ($ftype == TType::BOOL) {
1707
+ $xfer += $input->readBool($this->withRelaxation);
1708
+ } else {
1709
+ $xfer += $input->skip($ftype);
1710
+ }
1711
+ break;
1712
+ default:
1713
+ $xfer += $input->skip($ftype);
1714
+ break;
1715
+ }
1716
+ $xfer += $input->readFieldEnd();
1717
+ }
1718
+ $xfer += $input->readStructEnd();
1719
+ return $xfer;
1720
+ }
1721
+
1722
+ public function write($output) {
1723
+ $xfer = 0;
1724
+ $xfer += $output->writeStructBegin('ChoiceInquiry');
1725
+ if ($this->choiceId !== null) {
1726
+ $xfer += $output->writeFieldBegin('choiceId', TType::STRING, 1);
1727
+ $xfer += $output->writeString($this->choiceId);
1728
+ $xfer += $output->writeFieldEnd();
1729
+ }
1730
+ if ($this->simpleSearchQuery !== null) {
1731
+ if (!is_object($this->simpleSearchQuery)) {
1732
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
1733
+ }
1734
+ $xfer += $output->writeFieldBegin('simpleSearchQuery', TType::STRUCT, 2);
1735
+ $xfer += $this->simpleSearchQuery->write($output);
1736
+ $xfer += $output->writeFieldEnd();
1737
+ }
1738
+ if ($this->contextItems !== null) {
1739
+ if (!is_array($this->contextItems)) {
1740
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
1741
+ }
1742
+ $xfer += $output->writeFieldBegin('contextItems', TType::LST, 3);
1743
+ {
1744
+ $output->writeListBegin(TType::STRUCT, count($this->contextItems));
1745
+ {
1746
+ foreach ($this->contextItems as $iter68)
1747
+ {
1748
+ $xfer += $iter68->write($output);
1749
+ }
1750
+ }
1751
+ $output->writeListEnd();
1752
+ }
1753
+ $xfer += $output->writeFieldEnd();
1754
+ }
1755
+ if ($this->minHitCount !== null) {
1756
+ $xfer += $output->writeFieldBegin('minHitCount', TType::I32, 4);
1757
+ $xfer += $output->writeI32($this->minHitCount);
1758
+ $xfer += $output->writeFieldEnd();
1759
+ }
1760
+ if ($this->excludeVariantIds !== null) {
1761
+ if (!is_array($this->excludeVariantIds)) {
1762
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
1763
+ }
1764
+ $xfer += $output->writeFieldBegin('excludeVariantIds', TType::SET, 5);
1765
+ {
1766
+ $output->writeSetBegin(TType::STRING, count($this->excludeVariantIds));
1767
+ {
1768
+ foreach ($this->excludeVariantIds as $iter69 => $iter70)
1769
+ {
1770
+ if (is_scalar($iter70)) {
1771
+ $xfer += $output->writeString($iter69);
1772
+ } else {
1773
+ $xfer += $output->writeString($iter70);
1774
+ }
1775
+ }
1776
+ }
1777
+ $output->writeSetEnd();
1778
+ }
1779
+ $xfer += $output->writeFieldEnd();
1780
+ }
1781
+ if ($this->scope !== null) {
1782
+ $xfer += $output->writeFieldBegin('scope', TType::STRING, 6);
1783
+ $xfer += $output->writeString($this->scope);
1784
+ $xfer += $output->writeFieldEnd();
1785
+ }
1786
+ if ($this->withRelaxation !== null) {
1787
+ $xfer += $output->writeFieldBegin('withRelaxation', TType::BOOL, 70);
1788
+ $xfer += $output->writeBool($this->withRelaxation);
1789
+ $xfer += $output->writeFieldEnd();
1790
+ }
1791
+ $xfer += $output->writeFieldStop();
1792
+ $xfer += $output->writeStructEnd();
1793
+ return $xfer;
1794
+ }
1795
+
1796
+ }
1797
+
1798
+ class RequestContext {
1799
+ static $_TSPEC;
1800
+
1801
+ public $parameters = null;
1802
+
1803
+ public function __construct($vals=null) {
1804
+ if (!isset(self::$_TSPEC)) {
1805
+ self::$_TSPEC = array(
1806
+ 1 => array(
1807
+ 'var' => 'parameters',
1808
+ 'type' => TType::MAP,
1809
+ 'ktype' => TType::STRING,
1810
+ 'vtype' => TType::LST,
1811
+ 'key' => array(
1812
+ 'type' => TType::STRING,
1813
+ ),
1814
+ 'val' => array(
1815
+ 'type' => TType::LST,
1816
+ 'etype' => TType::STRING,
1817
+ 'elem' => array(
1818
+ 'type' => TType::STRING,
1819
+ ),
1820
+ ),
1821
+ ),
1822
+ );
1823
+ }
1824
+ if (is_array($vals)) {
1825
+ if (isset($vals['parameters'])) {
1826
+ $this->parameters = $vals['parameters'];
1827
+ }
1828
+ }
1829
+ }
1830
+
1831
+ public function getName() {
1832
+ return 'RequestContext';
1833
+ }
1834
+
1835
+ public function read($input)
1836
+ {
1837
+ $xfer = 0;
1838
+ $fname = null;
1839
+ $ftype = 0;
1840
+ $fid = 0;
1841
+ $xfer += $input->readStructBegin($fname);
1842
+ while (true)
1843
+ {
1844
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
1845
+ if ($ftype == TType::STOP) {
1846
+ break;
1847
+ }
1848
+ switch ($fid)
1849
+ {
1850
+ case 1:
1851
+ if ($ftype == TType::MAP) {
1852
+ $this->parameters = array();
1853
+ $_size71 = 0;
1854
+ $_ktype72 = 0;
1855
+ $_vtype73 = 0;
1856
+ $xfer += $input->readMapBegin($_ktype72, $_vtype73, $_size71);
1857
+ for ($_i75 = 0; $_i75 < $_size71; ++$_i75)
1858
+ {
1859
+ $key76 = '';
1860
+ $val77 = array();
1861
+ $xfer += $input->readString($key76);
1862
+ $val77 = array();
1863
+ $_size78 = 0;
1864
+ $_etype81 = 0;
1865
+ $xfer += $input->readListBegin($_etype81, $_size78);
1866
+ for ($_i82 = 0; $_i82 < $_size78; ++$_i82)
1867
+ {
1868
+ $elem83 = null;
1869
+ $xfer += $input->readString($elem83);
1870
+ $val77 []= $elem83;
1871
+ }
1872
+ $xfer += $input->readListEnd();
1873
+ $this->parameters[$key76] = $val77;
1874
+ }
1875
+ $xfer += $input->readMapEnd();
1876
+ } else {
1877
+ $xfer += $input->skip($ftype);
1878
+ }
1879
+ break;
1880
+ default:
1881
+ $xfer += $input->skip($ftype);
1882
+ break;
1883
+ }
1884
+ $xfer += $input->readFieldEnd();
1885
+ }
1886
+ $xfer += $input->readStructEnd();
1887
+ return $xfer;
1888
+ }
1889
+
1890
+ public function write($output) {
1891
+ $xfer = 0;
1892
+ $xfer += $output->writeStructBegin('RequestContext');
1893
+ if ($this->parameters !== null) {
1894
+ if (!is_array($this->parameters)) {
1895
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
1896
+ }
1897
+ $xfer += $output->writeFieldBegin('parameters', TType::MAP, 1);
1898
+ {
1899
+ $output->writeMapBegin(TType::STRING, TType::LST, count($this->parameters));
1900
+ {
1901
+ foreach ($this->parameters as $kiter84 => $viter85)
1902
+ {
1903
+ $xfer += $output->writeString($kiter84);
1904
+ {
1905
+ $output->writeListBegin(TType::STRING, count($viter85));
1906
+ {
1907
+ foreach ($viter85 as $iter86)
1908
+ {
1909
+ $xfer += $output->writeString($iter86);
1910
+ }
1911
+ }
1912
+ $output->writeListEnd();
1913
+ }
1914
+ }
1915
+ }
1916
+ $output->writeMapEnd();
1917
+ }
1918
+ $xfer += $output->writeFieldEnd();
1919
+ }
1920
+ $xfer += $output->writeFieldStop();
1921
+ $xfer += $output->writeStructEnd();
1922
+ return $xfer;
1923
+ }
1924
+
1925
+ }
1926
+
1927
+ class UserRecord {
1928
+ static $_TSPEC;
1929
+
1930
+ public $username = null;
1931
+
1932
+ public function __construct($vals=null) {
1933
+ if (!isset(self::$_TSPEC)) {
1934
+ self::$_TSPEC = array(
1935
+ 1 => array(
1936
+ 'var' => 'username',
1937
+ 'type' => TType::STRING,
1938
+ ),
1939
+ );
1940
+ }
1941
+ if (is_array($vals)) {
1942
+ if (isset($vals['username'])) {
1943
+ $this->username = $vals['username'];
1944
+ }
1945
+ }
1946
+ }
1947
+
1948
+ public function getName() {
1949
+ return 'UserRecord';
1950
+ }
1951
+
1952
+ public function read($input)
1953
+ {
1954
+ $xfer = 0;
1955
+ $fname = null;
1956
+ $ftype = 0;
1957
+ $fid = 0;
1958
+ $xfer += $input->readStructBegin($fname);
1959
+ while (true)
1960
+ {
1961
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
1962
+ if ($ftype == TType::STOP) {
1963
+ break;
1964
+ }
1965
+ switch ($fid)
1966
+ {
1967
+ case 1:
1968
+ if ($ftype == TType::STRING) {
1969
+ $xfer += $input->readString($this->username);
1970
+ } else {
1971
+ $xfer += $input->skip($ftype);
1972
+ }
1973
+ break;
1974
+ default:
1975
+ $xfer += $input->skip($ftype);
1976
+ break;
1977
+ }
1978
+ $xfer += $input->readFieldEnd();
1979
+ }
1980
+ $xfer += $input->readStructEnd();
1981
+ return $xfer;
1982
+ }
1983
+
1984
+ public function write($output) {
1985
+ $xfer = 0;
1986
+ $xfer += $output->writeStructBegin('UserRecord');
1987
+ if ($this->username !== null) {
1988
+ $xfer += $output->writeFieldBegin('username', TType::STRING, 1);
1989
+ $xfer += $output->writeString($this->username);
1990
+ $xfer += $output->writeFieldEnd();
1991
+ }
1992
+ $xfer += $output->writeFieldStop();
1993
+ $xfer += $output->writeStructEnd();
1994
+ return $xfer;
1995
+ }
1996
+
1997
+ }
1998
+
1999
+ class ChoiceRequest {
2000
+ static $_TSPEC;
2001
+
2002
+ public $userRecord = null;
2003
+ public $profileId = null;
2004
+ public $inquiries = null;
2005
+ public $requestContext = null;
2006
+
2007
+ public function __construct($vals=null) {
2008
+ if (!isset(self::$_TSPEC)) {
2009
+ self::$_TSPEC = array(
2010
+ 1 => array(
2011
+ 'var' => 'userRecord',
2012
+ 'type' => TType::STRUCT,
2013
+ 'class' => '\com\boxalino\p13n\api\thrift\UserRecord',
2014
+ ),
2015
+ 2 => array(
2016
+ 'var' => 'profileId',
2017
+ 'type' => TType::STRING,
2018
+ ),
2019
+ 3 => array(
2020
+ 'var' => 'inquiries',
2021
+ 'type' => TType::LST,
2022
+ 'etype' => TType::STRUCT,
2023
+ 'elem' => array(
2024
+ 'type' => TType::STRUCT,
2025
+ 'class' => '\com\boxalino\p13n\api\thrift\ChoiceInquiry',
2026
+ ),
2027
+ ),
2028
+ 4 => array(
2029
+ 'var' => 'requestContext',
2030
+ 'type' => TType::STRUCT,
2031
+ 'class' => '\com\boxalino\p13n\api\thrift\RequestContext',
2032
+ ),
2033
+ );
2034
+ }
2035
+ if (is_array($vals)) {
2036
+ if (isset($vals['userRecord'])) {
2037
+ $this->userRecord = $vals['userRecord'];
2038
+ }
2039
+ if (isset($vals['profileId'])) {
2040
+ $this->profileId = $vals['profileId'];
2041
+ }
2042
+ if (isset($vals['inquiries'])) {
2043
+ $this->inquiries = $vals['inquiries'];
2044
+ }
2045
+ if (isset($vals['requestContext'])) {
2046
+ $this->requestContext = $vals['requestContext'];
2047
+ }
2048
+ }
2049
+ }
2050
+
2051
+ public function getName() {
2052
+ return 'ChoiceRequest';
2053
+ }
2054
+
2055
+ public function read($input)
2056
+ {
2057
+ $xfer = 0;
2058
+ $fname = null;
2059
+ $ftype = 0;
2060
+ $fid = 0;
2061
+ $xfer += $input->readStructBegin($fname);
2062
+ while (true)
2063
+ {
2064
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
2065
+ if ($ftype == TType::STOP) {
2066
+ break;
2067
+ }
2068
+ switch ($fid)
2069
+ {
2070
+ case 1:
2071
+ if ($ftype == TType::STRUCT) {
2072
+ $this->userRecord = new \com\boxalino\p13n\api\thrift\UserRecord();
2073
+ $xfer += $this->userRecord->read($input);
2074
+ } else {
2075
+ $xfer += $input->skip($ftype);
2076
+ }
2077
+ break;
2078
+ case 2:
2079
+ if ($ftype == TType::STRING) {
2080
+ $xfer += $input->readString($this->profileId);
2081
+ } else {
2082
+ $xfer += $input->skip($ftype);
2083
+ }
2084
+ break;
2085
+ case 3:
2086
+ if ($ftype == TType::LST) {
2087
+ $this->inquiries = array();
2088
+ $_size87 = 0;
2089
+ $_etype90 = 0;
2090
+ $xfer += $input->readListBegin($_etype90, $_size87);
2091
+ for ($_i91 = 0; $_i91 < $_size87; ++$_i91)
2092
+ {
2093
+ $elem92 = null;
2094
+ $elem92 = new \com\boxalino\p13n\api\thrift\ChoiceInquiry();
2095
+ $xfer += $elem92->read($input);
2096
+ $this->inquiries []= $elem92;
2097
+ }
2098
+ $xfer += $input->readListEnd();
2099
+ } else {
2100
+ $xfer += $input->skip($ftype);
2101
+ }
2102
+ break;
2103
+ case 4:
2104
+ if ($ftype == TType::STRUCT) {
2105
+ $this->requestContext = new \com\boxalino\p13n\api\thrift\RequestContext();
2106
+ $xfer += $this->requestContext->read($input);
2107
+ } else {
2108
+ $xfer += $input->skip($ftype);
2109
+ }
2110
+ break;
2111
+ default:
2112
+ $xfer += $input->skip($ftype);
2113
+ break;
2114
+ }
2115
+ $xfer += $input->readFieldEnd();
2116
+ }
2117
+ $xfer += $input->readStructEnd();
2118
+ return $xfer;
2119
+ }
2120
+
2121
+ public function write($output) {
2122
+ $xfer = 0;
2123
+ $xfer += $output->writeStructBegin('ChoiceRequest');
2124
+ if ($this->userRecord !== null) {
2125
+ if (!is_object($this->userRecord)) {
2126
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
2127
+ }
2128
+ $xfer += $output->writeFieldBegin('userRecord', TType::STRUCT, 1);
2129
+ $xfer += $this->userRecord->write($output);
2130
+ $xfer += $output->writeFieldEnd();
2131
+ }
2132
+ if ($this->profileId !== null) {
2133
+ $xfer += $output->writeFieldBegin('profileId', TType::STRING, 2);
2134
+ $xfer += $output->writeString($this->profileId);
2135
+ $xfer += $output->writeFieldEnd();
2136
+ }
2137
+ if ($this->inquiries !== null) {
2138
+ if (!is_array($this->inquiries)) {
2139
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
2140
+ }
2141
+ $xfer += $output->writeFieldBegin('inquiries', TType::LST, 3);
2142
+ {
2143
+ $output->writeListBegin(TType::STRUCT, count($this->inquiries));
2144
+ {
2145
+ foreach ($this->inquiries as $iter93)
2146
+ {
2147
+ $xfer += $iter93->write($output);
2148
+ }
2149
+ }
2150
+ $output->writeListEnd();
2151
+ }
2152
+ $xfer += $output->writeFieldEnd();
2153
+ }
2154
+ if ($this->requestContext !== null) {
2155
+ if (!is_object($this->requestContext)) {
2156
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
2157
+ }
2158
+ $xfer += $output->writeFieldBegin('requestContext', TType::STRUCT, 4);
2159
+ $xfer += $this->requestContext->write($output);
2160
+ $xfer += $output->writeFieldEnd();
2161
+ }
2162
+ $xfer += $output->writeFieldStop();
2163
+ $xfer += $output->writeStructEnd();
2164
+ return $xfer;
2165
+ }
2166
+
2167
+ }
2168
+
2169
+ class FacetResponse {
2170
+ static $_TSPEC;
2171
+
2172
+ public $fieldName = null;
2173
+ public $values = null;
2174
+
2175
+ public function __construct($vals=null) {
2176
+ if (!isset(self::$_TSPEC)) {
2177
+ self::$_TSPEC = array(
2178
+ 1 => array(
2179
+ 'var' => 'fieldName',
2180
+ 'type' => TType::STRING,
2181
+ ),
2182
+ 2 => array(
2183
+ 'var' => 'values',
2184
+ 'type' => TType::LST,
2185
+ 'etype' => TType::STRUCT,
2186
+ 'elem' => array(
2187
+ 'type' => TType::STRUCT,
2188
+ 'class' => '\com\boxalino\p13n\api\thrift\FacetValue',
2189
+ ),
2190
+ ),
2191
+ );
2192
+ }
2193
+ if (is_array($vals)) {
2194
+ if (isset($vals['fieldName'])) {
2195
+ $this->fieldName = $vals['fieldName'];
2196
+ }
2197
+ if (isset($vals['values'])) {
2198
+ $this->values = $vals['values'];
2199
+ }
2200
+ }
2201
+ }
2202
+
2203
+ public function getName() {
2204
+ return 'FacetResponse';
2205
+ }
2206
+
2207
+ public function read($input)
2208
+ {
2209
+ $xfer = 0;
2210
+ $fname = null;
2211
+ $ftype = 0;
2212
+ $fid = 0;
2213
+ $xfer += $input->readStructBegin($fname);
2214
+ while (true)
2215
+ {
2216
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
2217
+ if ($ftype == TType::STOP) {
2218
+ break;
2219
+ }
2220
+ switch ($fid)
2221
+ {
2222
+ case 1:
2223
+ if ($ftype == TType::STRING) {
2224
+ $xfer += $input->readString($this->fieldName);
2225
+ } else {
2226
+ $xfer += $input->skip($ftype);
2227
+ }
2228
+ break;
2229
+ case 2:
2230
+ if ($ftype == TType::LST) {
2231
+ $this->values = array();
2232
+ $_size94 = 0;
2233
+ $_etype97 = 0;
2234
+ $xfer += $input->readListBegin($_etype97, $_size94);
2235
+ for ($_i98 = 0; $_i98 < $_size94; ++$_i98)
2236
+ {
2237
+ $elem99 = null;
2238
+ $elem99 = new \com\boxalino\p13n\api\thrift\FacetValue();
2239
+ $xfer += $elem99->read($input);
2240
+ $this->values []= $elem99;
2241
+ }
2242
+ $xfer += $input->readListEnd();
2243
+ } else {
2244
+ $xfer += $input->skip($ftype);
2245
+ }
2246
+ break;
2247
+ default:
2248
+ $xfer += $input->skip($ftype);
2249
+ break;
2250
+ }
2251
+ $xfer += $input->readFieldEnd();
2252
+ }
2253
+ $xfer += $input->readStructEnd();
2254
+ return $xfer;
2255
+ }
2256
+
2257
+ public function write($output) {
2258
+ $xfer = 0;
2259
+ $xfer += $output->writeStructBegin('FacetResponse');
2260
+ if ($this->fieldName !== null) {
2261
+ $xfer += $output->writeFieldBegin('fieldName', TType::STRING, 1);
2262
+ $xfer += $output->writeString($this->fieldName);
2263
+ $xfer += $output->writeFieldEnd();
2264
+ }
2265
+ if ($this->values !== null) {
2266
+ if (!is_array($this->values)) {
2267
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
2268
+ }
2269
+ $xfer += $output->writeFieldBegin('values', TType::LST, 2);
2270
+ {
2271
+ $output->writeListBegin(TType::STRUCT, count($this->values));
2272
+ {
2273
+ foreach ($this->values as $iter100)
2274
+ {
2275
+ $xfer += $iter100->write($output);
2276
+ }
2277
+ }
2278
+ $output->writeListEnd();
2279
+ }
2280
+ $xfer += $output->writeFieldEnd();
2281
+ }
2282
+ $xfer += $output->writeFieldStop();
2283
+ $xfer += $output->writeStructEnd();
2284
+ return $xfer;
2285
+ }
2286
+
2287
+ }
2288
+
2289
+ class Hit {
2290
+ static $_TSPEC;
2291
+
2292
+ public $values = null;
2293
+ public $score = null;
2294
+ public $scenarioId = null;
2295
+
2296
+ public function __construct($vals=null) {
2297
+ if (!isset(self::$_TSPEC)) {
2298
+ self::$_TSPEC = array(
2299
+ 1 => array(
2300
+ 'var' => 'values',
2301
+ 'type' => TType::MAP,
2302
+ 'ktype' => TType::STRING,
2303
+ 'vtype' => TType::LST,
2304
+ 'key' => array(
2305
+ 'type' => TType::STRING,
2306
+ ),
2307
+ 'val' => array(
2308
+ 'type' => TType::LST,
2309
+ 'etype' => TType::STRING,
2310
+ 'elem' => array(
2311
+ 'type' => TType::STRING,
2312
+ ),
2313
+ ),
2314
+ ),
2315
+ 2 => array(
2316
+ 'var' => 'score',
2317
+ 'type' => TType::DOUBLE,
2318
+ ),
2319
+ 30 => array(
2320
+ 'var' => 'scenarioId',
2321
+ 'type' => TType::STRING,
2322
+ ),
2323
+ );
2324
+ }
2325
+ if (is_array($vals)) {
2326
+ if (isset($vals['values'])) {
2327
+ $this->values = $vals['values'];
2328
+ }
2329
+ if (isset($vals['score'])) {
2330
+ $this->score = $vals['score'];
2331
+ }
2332
+ if (isset($vals['scenarioId'])) {
2333
+ $this->scenarioId = $vals['scenarioId'];
2334
+ }
2335
+ }
2336
+ }
2337
+
2338
+ public function getName() {
2339
+ return 'Hit';
2340
+ }
2341
+
2342
+ public function read($input)
2343
+ {
2344
+ $xfer = 0;
2345
+ $fname = null;
2346
+ $ftype = 0;
2347
+ $fid = 0;
2348
+ $xfer += $input->readStructBegin($fname);
2349
+ while (true)
2350
+ {
2351
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
2352
+ if ($ftype == TType::STOP) {
2353
+ break;
2354
+ }
2355
+ switch ($fid)
2356
+ {
2357
+ case 1:
2358
+ if ($ftype == TType::MAP) {
2359
+ $this->values = array();
2360
+ $_size101 = 0;
2361
+ $_ktype102 = 0;
2362
+ $_vtype103 = 0;
2363
+ $xfer += $input->readMapBegin($_ktype102, $_vtype103, $_size101);
2364
+ for ($_i105 = 0; $_i105 < $_size101; ++$_i105)
2365
+ {
2366
+ $key106 = '';
2367
+ $val107 = array();
2368
+ $xfer += $input->readString($key106);
2369
+ $val107 = array();
2370
+ $_size108 = 0;
2371
+ $_etype111 = 0;
2372
+ $xfer += $input->readListBegin($_etype111, $_size108);
2373
+ for ($_i112 = 0; $_i112 < $_size108; ++$_i112)
2374
+ {
2375
+ $elem113 = null;
2376
+ $xfer += $input->readString($elem113);
2377
+ $val107 []= $elem113;
2378
+ }
2379
+ $xfer += $input->readListEnd();
2380
+ $this->values[$key106] = $val107;
2381
+ }
2382
+ $xfer += $input->readMapEnd();
2383
+ } else {
2384
+ $xfer += $input->skip($ftype);
2385
+ }
2386
+ break;
2387
+ case 2:
2388
+ if ($ftype == TType::DOUBLE) {
2389
+ $xfer += $input->readDouble($this->score);
2390
+ } else {
2391
+ $xfer += $input->skip($ftype);
2392
+ }
2393
+ break;
2394
+ case 30:
2395
+ if ($ftype == TType::STRING) {
2396
+ $xfer += $input->readString($this->scenarioId);
2397
+ } else {
2398
+ $xfer += $input->skip($ftype);
2399
+ }
2400
+ break;
2401
+ default:
2402
+ $xfer += $input->skip($ftype);
2403
+ break;
2404
+ }
2405
+ $xfer += $input->readFieldEnd();
2406
+ }
2407
+ $xfer += $input->readStructEnd();
2408
+ return $xfer;
2409
+ }
2410
+
2411
+ public function write($output) {
2412
+ $xfer = 0;
2413
+ $xfer += $output->writeStructBegin('Hit');
2414
+ if ($this->values !== null) {
2415
+ if (!is_array($this->values)) {
2416
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
2417
+ }
2418
+ $xfer += $output->writeFieldBegin('values', TType::MAP, 1);
2419
+ {
2420
+ $output->writeMapBegin(TType::STRING, TType::LST, count($this->values));
2421
+ {
2422
+ foreach ($this->values as $kiter114 => $viter115)
2423
+ {
2424
+ $xfer += $output->writeString($kiter114);
2425
+ {
2426
+ $output->writeListBegin(TType::STRING, count($viter115));
2427
+ {
2428
+ foreach ($viter115 as $iter116)
2429
+ {
2430
+ $xfer += $output->writeString($iter116);
2431
+ }
2432
+ }
2433
+ $output->writeListEnd();
2434
+ }
2435
+ }
2436
+ }
2437
+ $output->writeMapEnd();
2438
+ }
2439
+ $xfer += $output->writeFieldEnd();
2440
+ }
2441
+ if ($this->score !== null) {
2442
+ $xfer += $output->writeFieldBegin('score', TType::DOUBLE, 2);
2443
+ $xfer += $output->writeDouble($this->score);
2444
+ $xfer += $output->writeFieldEnd();
2445
+ }
2446
+ if ($this->scenarioId !== null) {
2447
+ $xfer += $output->writeFieldBegin('scenarioId', TType::STRING, 30);
2448
+ $xfer += $output->writeString($this->scenarioId);
2449
+ $xfer += $output->writeFieldEnd();
2450
+ }
2451
+ $xfer += $output->writeFieldStop();
2452
+ $xfer += $output->writeStructEnd();
2453
+ return $xfer;
2454
+ }
2455
+
2456
+ }
2457
+
2458
+ class HitsGroup {
2459
+ static $_TSPEC;
2460
+
2461
+ public $groupValue = null;
2462
+ public $totalHitCount = null;
2463
+ public $hits = null;
2464
+
2465
+ public function __construct($vals=null) {
2466
+ if (!isset(self::$_TSPEC)) {
2467
+ self::$_TSPEC = array(
2468
+ 10 => array(
2469
+ 'var' => 'groupValue',
2470
+ 'type' => TType::STRING,
2471
+ ),
2472
+ 20 => array(
2473
+ 'var' => 'totalHitCount',
2474
+ 'type' => TType::I64,
2475
+ ),
2476
+ 30 => array(
2477
+ 'var' => 'hits',
2478
+ 'type' => TType::LST,
2479
+ 'etype' => TType::STRUCT,
2480
+ 'elem' => array(
2481
+ 'type' => TType::STRUCT,
2482
+ 'class' => '\com\boxalino\p13n\api\thrift\Hit',
2483
+ ),
2484
+ ),
2485
+ );
2486
+ }
2487
+ if (is_array($vals)) {
2488
+ if (isset($vals['groupValue'])) {
2489
+ $this->groupValue = $vals['groupValue'];
2490
+ }
2491
+ if (isset($vals['totalHitCount'])) {
2492
+ $this->totalHitCount = $vals['totalHitCount'];
2493
+ }
2494
+ if (isset($vals['hits'])) {
2495
+ $this->hits = $vals['hits'];
2496
+ }
2497
+ }
2498
+ }
2499
+
2500
+ public function getName() {
2501
+ return 'HitsGroup';
2502
+ }
2503
+
2504
+ public function read($input)
2505
+ {
2506
+ $xfer = 0;
2507
+ $fname = null;
2508
+ $ftype = 0;
2509
+ $fid = 0;
2510
+ $xfer += $input->readStructBegin($fname);
2511
+ while (true)
2512
+ {
2513
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
2514
+ if ($ftype == TType::STOP) {
2515
+ break;
2516
+ }
2517
+ switch ($fid)
2518
+ {
2519
+ case 10:
2520
+ if ($ftype == TType::STRING) {
2521
+ $xfer += $input->readString($this->groupValue);
2522
+ } else {
2523
+ $xfer += $input->skip($ftype);
2524
+ }
2525
+ break;
2526
+ case 20:
2527
+ if ($ftype == TType::I64) {
2528
+ $xfer += $input->readI64($this->totalHitCount);
2529
+ } else {
2530
+ $xfer += $input->skip($ftype);
2531
+ }
2532
+ break;
2533
+ case 30:
2534
+ if ($ftype == TType::LST) {
2535
+ $this->hits = array();
2536
+ $_size117 = 0;
2537
+ $_etype120 = 0;
2538
+ $xfer += $input->readListBegin($_etype120, $_size117);
2539
+ for ($_i121 = 0; $_i121 < $_size117; ++$_i121)
2540
+ {
2541
+ $elem122 = null;
2542
+ $elem122 = new \com\boxalino\p13n\api\thrift\Hit();
2543
+ $xfer += $elem122->read($input);
2544
+ $this->hits []= $elem122;
2545
+ }
2546
+ $xfer += $input->readListEnd();
2547
+ } else {
2548
+ $xfer += $input->skip($ftype);
2549
+ }
2550
+ break;
2551
+ default:
2552
+ $xfer += $input->skip($ftype);
2553
+ break;
2554
+ }
2555
+ $xfer += $input->readFieldEnd();
2556
+ }
2557
+ $xfer += $input->readStructEnd();
2558
+ return $xfer;
2559
+ }
2560
+
2561
+ public function write($output) {
2562
+ $xfer = 0;
2563
+ $xfer += $output->writeStructBegin('HitsGroup');
2564
+ if ($this->groupValue !== null) {
2565
+ $xfer += $output->writeFieldBegin('groupValue', TType::STRING, 10);
2566
+ $xfer += $output->writeString($this->groupValue);
2567
+ $xfer += $output->writeFieldEnd();
2568
+ }
2569
+ if ($this->totalHitCount !== null) {
2570
+ $xfer += $output->writeFieldBegin('totalHitCount', TType::I64, 20);
2571
+ $xfer += $output->writeI64($this->totalHitCount);
2572
+ $xfer += $output->writeFieldEnd();
2573
+ }
2574
+ if ($this->hits !== null) {
2575
+ if (!is_array($this->hits)) {
2576
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
2577
+ }
2578
+ $xfer += $output->writeFieldBegin('hits', TType::LST, 30);
2579
+ {
2580
+ $output->writeListBegin(TType::STRUCT, count($this->hits));
2581
+ {
2582
+ foreach ($this->hits as $iter123)
2583
+ {
2584
+ $xfer += $iter123->write($output);
2585
+ }
2586
+ }
2587
+ $output->writeListEnd();
2588
+ }
2589
+ $xfer += $output->writeFieldEnd();
2590
+ }
2591
+ $xfer += $output->writeFieldStop();
2592
+ $xfer += $output->writeStructEnd();
2593
+ return $xfer;
2594
+ }
2595
+
2596
+ }
2597
+
2598
+ class SearchResult {
2599
+ static $_TSPEC;
2600
+
2601
+ public $hits = null;
2602
+ public $facetResponses = null;
2603
+ public $totalHitCount = null;
2604
+ public $queryText = null;
2605
+ public $hitsGroups = null;
2606
+
2607
+ public function __construct($vals=null) {
2608
+ if (!isset(self::$_TSPEC)) {
2609
+ self::$_TSPEC = array(
2610
+ 1 => array(
2611
+ 'var' => 'hits',
2612
+ 'type' => TType::LST,
2613
+ 'etype' => TType::STRUCT,
2614
+ 'elem' => array(
2615
+ 'type' => TType::STRUCT,
2616
+ 'class' => '\com\boxalino\p13n\api\thrift\Hit',
2617
+ ),
2618
+ ),
2619
+ 2 => array(
2620
+ 'var' => 'facetResponses',
2621
+ 'type' => TType::LST,
2622
+ 'etype' => TType::STRUCT,
2623
+ 'elem' => array(
2624
+ 'type' => TType::STRUCT,
2625
+ 'class' => '\com\boxalino\p13n\api\thrift\FacetResponse',
2626
+ ),
2627
+ ),
2628
+ 3 => array(
2629
+ 'var' => 'totalHitCount',
2630
+ 'type' => TType::I64,
2631
+ ),
2632
+ 40 => array(
2633
+ 'var' => 'queryText',
2634
+ 'type' => TType::STRING,
2635
+ ),
2636
+ 50 => array(
2637
+ 'var' => 'hitsGroups',
2638
+ 'type' => TType::LST,
2639
+ 'etype' => TType::STRUCT,
2640
+ 'elem' => array(
2641
+ 'type' => TType::STRUCT,
2642
+ 'class' => '\com\boxalino\p13n\api\thrift\HitsGroup',
2643
+ ),
2644
+ ),
2645
+ );
2646
+ }
2647
+ if (is_array($vals)) {
2648
+ if (isset($vals['hits'])) {
2649
+ $this->hits = $vals['hits'];
2650
+ }
2651
+ if (isset($vals['facetResponses'])) {
2652
+ $this->facetResponses = $vals['facetResponses'];
2653
+ }
2654
+ if (isset($vals['totalHitCount'])) {
2655
+ $this->totalHitCount = $vals['totalHitCount'];
2656
+ }
2657
+ if (isset($vals['queryText'])) {
2658
+ $this->queryText = $vals['queryText'];
2659
+ }
2660
+ if (isset($vals['hitsGroups'])) {
2661
+ $this->hitsGroups = $vals['hitsGroups'];
2662
+ }
2663
+ }
2664
+ }
2665
+
2666
+ public function getName() {
2667
+ return 'SearchResult';
2668
+ }
2669
+
2670
+ public function read($input)
2671
+ {
2672
+ $xfer = 0;
2673
+ $fname = null;
2674
+ $ftype = 0;
2675
+ $fid = 0;
2676
+ $xfer += $input->readStructBegin($fname);
2677
+ while (true)
2678
+ {
2679
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
2680
+ if ($ftype == TType::STOP) {
2681
+ break;
2682
+ }
2683
+ switch ($fid)
2684
+ {
2685
+ case 1:
2686
+ if ($ftype == TType::LST) {
2687
+ $this->hits = array();
2688
+ $_size124 = 0;
2689
+ $_etype127 = 0;
2690
+ $xfer += $input->readListBegin($_etype127, $_size124);
2691
+ for ($_i128 = 0; $_i128 < $_size124; ++$_i128)
2692
+ {
2693
+ $elem129 = null;
2694
+ $elem129 = new \com\boxalino\p13n\api\thrift\Hit();
2695
+ $xfer += $elem129->read($input);
2696
+ $this->hits []= $elem129;
2697
+ }
2698
+ $xfer += $input->readListEnd();
2699
+ } else {
2700
+ $xfer += $input->skip($ftype);
2701
+ }
2702
+ break;
2703
+ case 2:
2704
+ if ($ftype == TType::LST) {
2705
+ $this->facetResponses = array();
2706
+ $_size130 = 0;
2707
+ $_etype133 = 0;
2708
+ $xfer += $input->readListBegin($_etype133, $_size130);
2709
+ for ($_i134 = 0; $_i134 < $_size130; ++$_i134)
2710
+ {
2711
+ $elem135 = null;
2712
+ $elem135 = new \com\boxalino\p13n\api\thrift\FacetResponse();
2713
+ $xfer += $elem135->read($input);
2714
+ $this->facetResponses []= $elem135;
2715
+ }
2716
+ $xfer += $input->readListEnd();
2717
+ } else {
2718
+ $xfer += $input->skip($ftype);
2719
+ }
2720
+ break;
2721
+ case 3:
2722
+ if ($ftype == TType::I64) {
2723
+ $xfer += $input->readI64($this->totalHitCount);
2724
+ } else {
2725
+ $xfer += $input->skip($ftype);
2726
+ }
2727
+ break;
2728
+ case 40:
2729
+ if ($ftype == TType::STRING) {
2730
+ $xfer += $input->readString($this->queryText);
2731
+ } else {
2732
+ $xfer += $input->skip($ftype);
2733
+ }
2734
+ break;
2735
+ case 50:
2736
+ if ($ftype == TType::LST) {
2737
+ $this->hitsGroups = array();
2738
+ $_size136 = 0;
2739
+ $_etype139 = 0;
2740
+ $xfer += $input->readListBegin($_etype139, $_size136);
2741
+ for ($_i140 = 0; $_i140 < $_size136; ++$_i140)
2742
+ {
2743
+ $elem141 = null;
2744
+ $elem141 = new \com\boxalino\p13n\api\thrift\HitsGroup();
2745
+ $xfer += $elem141->read($input);
2746
+ $this->hitsGroups []= $elem141;
2747
+ }
2748
+ $xfer += $input->readListEnd();
2749
+ } else {
2750
+ $xfer += $input->skip($ftype);
2751
+ }
2752
+ break;
2753
+ default:
2754
+ $xfer += $input->skip($ftype);
2755
+ break;
2756
+ }
2757
+ $xfer += $input->readFieldEnd();
2758
+ }
2759
+ $xfer += $input->readStructEnd();
2760
+ return $xfer;
2761
+ }
2762
+
2763
+ public function write($output) {
2764
+ $xfer = 0;
2765
+ $xfer += $output->writeStructBegin('SearchResult');
2766
+ if ($this->hits !== null) {
2767
+ if (!is_array($this->hits)) {
2768
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
2769
+ }
2770
+ $xfer += $output->writeFieldBegin('hits', TType::LST, 1);
2771
+ {
2772
+ $output->writeListBegin(TType::STRUCT, count($this->hits));
2773
+ {
2774
+ foreach ($this->hits as $iter142)
2775
+ {
2776
+ $xfer += $iter142->write($output);
2777
+ }
2778
+ }
2779
+ $output->writeListEnd();
2780
+ }
2781
+ $xfer += $output->writeFieldEnd();
2782
+ }
2783
+ if ($this->facetResponses !== null) {
2784
+ if (!is_array($this->facetResponses)) {
2785
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
2786
+ }
2787
+ $xfer += $output->writeFieldBegin('facetResponses', TType::LST, 2);
2788
+ {
2789
+ $output->writeListBegin(TType::STRUCT, count($this->facetResponses));
2790
+ {
2791
+ foreach ($this->facetResponses as $iter143)
2792
+ {
2793
+ $xfer += $iter143->write($output);
2794
+ }
2795
+ }
2796
+ $output->writeListEnd();
2797
+ }
2798
+ $xfer += $output->writeFieldEnd();
2799
+ }
2800
+ if ($this->totalHitCount !== null) {
2801
+ $xfer += $output->writeFieldBegin('totalHitCount', TType::I64, 3);
2802
+ $xfer += $output->writeI64($this->totalHitCount);
2803
+ $xfer += $output->writeFieldEnd();
2804
+ }
2805
+ if ($this->queryText !== null) {
2806
+ $xfer += $output->writeFieldBegin('queryText', TType::STRING, 40);
2807
+ $xfer += $output->writeString($this->queryText);
2808
+ $xfer += $output->writeFieldEnd();
2809
+ }
2810
+ if ($this->hitsGroups !== null) {
2811
+ if (!is_array($this->hitsGroups)) {
2812
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
2813
+ }
2814
+ $xfer += $output->writeFieldBegin('hitsGroups', TType::LST, 50);
2815
+ {
2816
+ $output->writeListBegin(TType::STRUCT, count($this->hitsGroups));
2817
+ {
2818
+ foreach ($this->hitsGroups as $iter144)
2819
+ {
2820
+ $xfer += $iter144->write($output);
2821
+ }
2822
+ }
2823
+ $output->writeListEnd();
2824
+ }
2825
+ $xfer += $output->writeFieldEnd();
2826
+ }
2827
+ $xfer += $output->writeFieldStop();
2828
+ $xfer += $output->writeStructEnd();
2829
+ return $xfer;
2830
+ }
2831
+
2832
+ }
2833
+
2834
+ class SearchRelaxation {
2835
+ static $_TSPEC;
2836
+
2837
+ public $suggestionsResults = null;
2838
+ public $subphrasesResults = null;
2839
+
2840
+ public function __construct($vals=null) {
2841
+ if (!isset(self::$_TSPEC)) {
2842
+ self::$_TSPEC = array(
2843
+ 10 => array(
2844
+ 'var' => 'suggestionsResults',
2845
+ 'type' => TType::LST,
2846
+ 'etype' => TType::STRUCT,
2847
+ 'elem' => array(
2848
+ 'type' => TType::STRUCT,
2849
+ 'class' => '\com\boxalino\p13n\api\thrift\SearchResult',
2850
+ ),
2851
+ ),
2852
+ 20 => array(
2853
+ 'var' => 'subphrasesResults',
2854
+ 'type' => TType::LST,
2855
+ 'etype' => TType::STRUCT,
2856
+ 'elem' => array(
2857
+ 'type' => TType::STRUCT,
2858
+ 'class' => '\com\boxalino\p13n\api\thrift\SearchResult',
2859
+ ),
2860
+ ),
2861
+ );
2862
+ }
2863
+ if (is_array($vals)) {
2864
+ if (isset($vals['suggestionsResults'])) {
2865
+ $this->suggestionsResults = $vals['suggestionsResults'];
2866
+ }
2867
+ if (isset($vals['subphrasesResults'])) {
2868
+ $this->subphrasesResults = $vals['subphrasesResults'];
2869
+ }
2870
+ }
2871
+ }
2872
+
2873
+ public function getName() {
2874
+ return 'SearchRelaxation';
2875
+ }
2876
+
2877
+ public function read($input)
2878
+ {
2879
+ $xfer = 0;
2880
+ $fname = null;
2881
+ $ftype = 0;
2882
+ $fid = 0;
2883
+ $xfer += $input->readStructBegin($fname);
2884
+ while (true)
2885
+ {
2886
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
2887
+ if ($ftype == TType::STOP) {
2888
+ break;
2889
+ }
2890
+ switch ($fid)
2891
+ {
2892
+ case 10:
2893
+ if ($ftype == TType::LST) {
2894
+ $this->suggestionsResults = array();
2895
+ $_size145 = 0;
2896
+ $_etype148 = 0;
2897
+ $xfer += $input->readListBegin($_etype148, $_size145);
2898
+ for ($_i149 = 0; $_i149 < $_size145; ++$_i149)
2899
+ {
2900
+ $elem150 = null;
2901
+ $elem150 = new \com\boxalino\p13n\api\thrift\SearchResult();
2902
+ $xfer += $elem150->read($input);
2903
+ $this->suggestionsResults []= $elem150;
2904
+ }
2905
+ $xfer += $input->readListEnd();
2906
+ } else {
2907
+ $xfer += $input->skip($ftype);
2908
+ }
2909
+ break;
2910
+ case 20:
2911
+ if ($ftype == TType::LST) {
2912
+ $this->subphrasesResults = array();
2913
+ $_size151 = 0;
2914
+ $_etype154 = 0;
2915
+ $xfer += $input->readListBegin($_etype154, $_size151);
2916
+ for ($_i155 = 0; $_i155 < $_size151; ++$_i155)
2917
+ {
2918
+ $elem156 = null;
2919
+ $elem156 = new \com\boxalino\p13n\api\thrift\SearchResult();
2920
+ $xfer += $elem156->read($input);
2921
+ $this->subphrasesResults []= $elem156;
2922
+ }
2923
+ $xfer += $input->readListEnd();
2924
+ } else {
2925
+ $xfer += $input->skip($ftype);
2926
+ }
2927
+ break;
2928
+ default:
2929
+ $xfer += $input->skip($ftype);
2930
+ break;
2931
+ }
2932
+ $xfer += $input->readFieldEnd();
2933
+ }
2934
+ $xfer += $input->readStructEnd();
2935
+ return $xfer;
2936
+ }
2937
+
2938
+ public function write($output) {
2939
+ $xfer = 0;
2940
+ $xfer += $output->writeStructBegin('SearchRelaxation');
2941
+ if ($this->suggestionsResults !== null) {
2942
+ if (!is_array($this->suggestionsResults)) {
2943
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
2944
+ }
2945
+ $xfer += $output->writeFieldBegin('suggestionsResults', TType::LST, 10);
2946
+ {
2947
+ $output->writeListBegin(TType::STRUCT, count($this->suggestionsResults));
2948
+ {
2949
+ foreach ($this->suggestionsResults as $iter157)
2950
+ {
2951
+ $xfer += $iter157->write($output);
2952
+ }
2953
+ }
2954
+ $output->writeListEnd();
2955
+ }
2956
+ $xfer += $output->writeFieldEnd();
2957
+ }
2958
+ if ($this->subphrasesResults !== null) {
2959
+ if (!is_array($this->subphrasesResults)) {
2960
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
2961
+ }
2962
+ $xfer += $output->writeFieldBegin('subphrasesResults', TType::LST, 20);
2963
+ {
2964
+ $output->writeListBegin(TType::STRUCT, count($this->subphrasesResults));
2965
+ {
2966
+ foreach ($this->subphrasesResults as $iter158)
2967
+ {
2968
+ $xfer += $iter158->write($output);
2969
+ }
2970
+ }
2971
+ $output->writeListEnd();
2972
+ }
2973
+ $xfer += $output->writeFieldEnd();
2974
+ }
2975
+ $xfer += $output->writeFieldStop();
2976
+ $xfer += $output->writeStructEnd();
2977
+ return $xfer;
2978
+ }
2979
+
2980
+ }
2981
+
2982
+ class Variant {
2983
+ static $_TSPEC;
2984
+
2985
+ public $variantId = null;
2986
+ public $scenarioId = null;
2987
+ public $searchResult = null;
2988
+ public $searchResultTitle = null;
2989
+ public $searchRelaxation = null;
2990
+
2991
+ public function __construct($vals=null) {
2992
+ if (!isset(self::$_TSPEC)) {
2993
+ self::$_TSPEC = array(
2994
+ 1 => array(
2995
+ 'var' => 'variantId',
2996
+ 'type' => TType::STRING,
2997
+ ),
2998
+ 2 => array(
2999
+ 'var' => 'scenarioId',
3000
+ 'type' => TType::STRING,
3001
+ ),
3002
+ 3 => array(
3003
+ 'var' => 'searchResult',
3004
+ 'type' => TType::STRUCT,
3005
+ 'class' => '\com\boxalino\p13n\api\thrift\SearchResult',
3006
+ ),
3007
+ 4 => array(
3008
+ 'var' => 'searchResultTitle',
3009
+ 'type' => TType::STRING,
3010
+ ),
3011
+ 50 => array(
3012
+ 'var' => 'searchRelaxation',
3013
+ 'type' => TType::STRUCT,
3014
+ 'class' => '\com\boxalino\p13n\api\thrift\SearchRelaxation',
3015
+ ),
3016
+ );
3017
+ }
3018
+ if (is_array($vals)) {
3019
+ if (isset($vals['variantId'])) {
3020
+ $this->variantId = $vals['variantId'];
3021
+ }
3022
+ if (isset($vals['scenarioId'])) {
3023
+ $this->scenarioId = $vals['scenarioId'];
3024
+ }
3025
+ if (isset($vals['searchResult'])) {
3026
+ $this->searchResult = $vals['searchResult'];
3027
+ }
3028
+ if (isset($vals['searchResultTitle'])) {
3029
+ $this->searchResultTitle = $vals['searchResultTitle'];
3030
+ }
3031
+ if (isset($vals['searchRelaxation'])) {
3032
+ $this->searchRelaxation = $vals['searchRelaxation'];
3033
+ }
3034
+ }
3035
+ }
3036
+
3037
+ public function getName() {
3038
+ return 'Variant';
3039
+ }
3040
+
3041
+ public function read($input)
3042
+ {
3043
+ $xfer = 0;
3044
+ $fname = null;
3045
+ $ftype = 0;
3046
+ $fid = 0;
3047
+ $xfer += $input->readStructBegin($fname);
3048
+ while (true)
3049
+ {
3050
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
3051
+ if ($ftype == TType::STOP) {
3052
+ break;
3053
+ }
3054
+ switch ($fid)
3055
+ {
3056
+ case 1:
3057
+ if ($ftype == TType::STRING) {
3058
+ $xfer += $input->readString($this->variantId);
3059
+ } else {
3060
+ $xfer += $input->skip($ftype);
3061
+ }
3062
+ break;
3063
+ case 2:
3064
+ if ($ftype == TType::STRING) {
3065
+ $xfer += $input->readString($this->scenarioId);
3066
+ } else {
3067
+ $xfer += $input->skip($ftype);
3068
+ }
3069
+ break;
3070
+ case 3:
3071
+ if ($ftype == TType::STRUCT) {
3072
+ $this->searchResult = new \com\boxalino\p13n\api\thrift\SearchResult();
3073
+ $xfer += $this->searchResult->read($input);
3074
+ } else {
3075
+ $xfer += $input->skip($ftype);
3076
+ }
3077
+ break;
3078
+ case 4:
3079
+ if ($ftype == TType::STRING) {
3080
+ $xfer += $input->readString($this->searchResultTitle);
3081
+ } else {
3082
+ $xfer += $input->skip($ftype);
3083
+ }
3084
+ break;
3085
+ case 50:
3086
+ if ($ftype == TType::STRUCT) {
3087
+ $this->searchRelaxation = new \com\boxalino\p13n\api\thrift\SearchRelaxation();
3088
+ $xfer += $this->searchRelaxation->read($input);
3089
+ } else {
3090
+ $xfer += $input->skip($ftype);
3091
+ }
3092
+ break;
3093
+ default:
3094
+ $xfer += $input->skip($ftype);
3095
+ break;
3096
+ }
3097
+ $xfer += $input->readFieldEnd();
3098
+ }
3099
+ $xfer += $input->readStructEnd();
3100
+ return $xfer;
3101
+ }
3102
+
3103
+ public function write($output) {
3104
+ $xfer = 0;
3105
+ $xfer += $output->writeStructBegin('Variant');
3106
+ if ($this->variantId !== null) {
3107
+ $xfer += $output->writeFieldBegin('variantId', TType::STRING, 1);
3108
+ $xfer += $output->writeString($this->variantId);
3109
+ $xfer += $output->writeFieldEnd();
3110
+ }
3111
+ if ($this->scenarioId !== null) {
3112
+ $xfer += $output->writeFieldBegin('scenarioId', TType::STRING, 2);
3113
+ $xfer += $output->writeString($this->scenarioId);
3114
+ $xfer += $output->writeFieldEnd();
3115
+ }
3116
+ if ($this->searchResult !== null) {
3117
+ if (!is_object($this->searchResult)) {
3118
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
3119
+ }
3120
+ $xfer += $output->writeFieldBegin('searchResult', TType::STRUCT, 3);
3121
+ $xfer += $this->searchResult->write($output);
3122
+ $xfer += $output->writeFieldEnd();
3123
+ }
3124
+ if ($this->searchResultTitle !== null) {
3125
+ $xfer += $output->writeFieldBegin('searchResultTitle', TType::STRING, 4);
3126
+ $xfer += $output->writeString($this->searchResultTitle);
3127
+ $xfer += $output->writeFieldEnd();
3128
+ }
3129
+ if ($this->searchRelaxation !== null) {
3130
+ if (!is_object($this->searchRelaxation)) {
3131
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
3132
+ }
3133
+ $xfer += $output->writeFieldBegin('searchRelaxation', TType::STRUCT, 50);
3134
+ $xfer += $this->searchRelaxation->write($output);
3135
+ $xfer += $output->writeFieldEnd();
3136
+ }
3137
+ $xfer += $output->writeFieldStop();
3138
+ $xfer += $output->writeStructEnd();
3139
+ return $xfer;
3140
+ }
3141
+
3142
+ }
3143
+
3144
+ class ChoiceResponse {
3145
+ static $_TSPEC;
3146
+
3147
+ public $variants = null;
3148
+
3149
+ public function __construct($vals=null) {
3150
+ if (!isset(self::$_TSPEC)) {
3151
+ self::$_TSPEC = array(
3152
+ 1 => array(
3153
+ 'var' => 'variants',
3154
+ 'type' => TType::LST,
3155
+ 'etype' => TType::STRUCT,
3156
+ 'elem' => array(
3157
+ 'type' => TType::STRUCT,
3158
+ 'class' => '\com\boxalino\p13n\api\thrift\Variant',
3159
+ ),
3160
+ ),
3161
+ );
3162
+ }
3163
+ if (is_array($vals)) {
3164
+ if (isset($vals['variants'])) {
3165
+ $this->variants = $vals['variants'];
3166
+ }
3167
+ }
3168
+ }
3169
+
3170
+ public function getName() {
3171
+ return 'ChoiceResponse';
3172
+ }
3173
+
3174
+ public function read($input)
3175
+ {
3176
+ $xfer = 0;
3177
+ $fname = null;
3178
+ $ftype = 0;
3179
+ $fid = 0;
3180
+ $xfer += $input->readStructBegin($fname);
3181
+ while (true)
3182
+ {
3183
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
3184
+ if ($ftype == TType::STOP) {
3185
+ break;
3186
+ }
3187
+ switch ($fid)
3188
+ {
3189
+ case 1:
3190
+ if ($ftype == TType::LST) {
3191
+ $this->variants = array();
3192
+ $_size159 = 0;
3193
+ $_etype162 = 0;
3194
+ $xfer += $input->readListBegin($_etype162, $_size159);
3195
+ for ($_i163 = 0; $_i163 < $_size159; ++$_i163)
3196
+ {
3197
+ $elem164 = null;
3198
+ $elem164 = new \com\boxalino\p13n\api\thrift\Variant();
3199
+ $xfer += $elem164->read($input);
3200
+ $this->variants []= $elem164;
3201
+ }
3202
+ $xfer += $input->readListEnd();
3203
+ } else {
3204
+ $xfer += $input->skip($ftype);
3205
+ }
3206
+ break;
3207
+ default:
3208
+ $xfer += $input->skip($ftype);
3209
+ break;
3210
+ }
3211
+ $xfer += $input->readFieldEnd();
3212
+ }
3213
+ $xfer += $input->readStructEnd();
3214
+ return $xfer;
3215
+ }
3216
+
3217
+ public function write($output) {
3218
+ $xfer = 0;
3219
+ $xfer += $output->writeStructBegin('ChoiceResponse');
3220
+ if ($this->variants !== null) {
3221
+ if (!is_array($this->variants)) {
3222
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
3223
+ }
3224
+ $xfer += $output->writeFieldBegin('variants', TType::LST, 1);
3225
+ {
3226
+ $output->writeListBegin(TType::STRUCT, count($this->variants));
3227
+ {
3228
+ foreach ($this->variants as $iter165)
3229
+ {
3230
+ $xfer += $iter165->write($output);
3231
+ }
3232
+ }
3233
+ $output->writeListEnd();
3234
+ }
3235
+ $xfer += $output->writeFieldEnd();
3236
+ }
3237
+ $xfer += $output->writeFieldStop();
3238
+ $xfer += $output->writeStructEnd();
3239
+ return $xfer;
3240
+ }
3241
+
3242
+ }
3243
+
3244
+ class ProfilePropertyValue {
3245
+ static $_TSPEC;
3246
+
3247
+ public $profileId = null;
3248
+ public $propertyName = null;
3249
+ public $propertyValue = null;
3250
+ public $confidence = null;
3251
+
3252
+ public function __construct($vals=null) {
3253
+ if (!isset(self::$_TSPEC)) {
3254
+ self::$_TSPEC = array(
3255
+ 1 => array(
3256
+ 'var' => 'profileId',
3257
+ 'type' => TType::STRING,
3258
+ ),
3259
+ 2 => array(
3260
+ 'var' => 'propertyName',
3261
+ 'type' => TType::STRING,
3262
+ ),
3263
+ 3 => array(
3264
+ 'var' => 'propertyValue',
3265
+ 'type' => TType::STRING,
3266
+ ),
3267
+ 4 => array(
3268
+ 'var' => 'confidence',
3269
+ 'type' => TType::I32,
3270
+ ),
3271
+ );
3272
+ }
3273
+ if (is_array($vals)) {
3274
+ if (isset($vals['profileId'])) {
3275
+ $this->profileId = $vals['profileId'];
3276
+ }
3277
+ if (isset($vals['propertyName'])) {
3278
+ $this->propertyName = $vals['propertyName'];
3279
+ }
3280
+ if (isset($vals['propertyValue'])) {
3281
+ $this->propertyValue = $vals['propertyValue'];
3282
+ }
3283
+ if (isset($vals['confidence'])) {
3284
+ $this->confidence = $vals['confidence'];
3285
+ }
3286
+ }
3287
+ }
3288
+
3289
+ public function getName() {
3290
+ return 'ProfilePropertyValue';
3291
+ }
3292
+
3293
+ public function read($input)
3294
+ {
3295
+ $xfer = 0;
3296
+ $fname = null;
3297
+ $ftype = 0;
3298
+ $fid = 0;
3299
+ $xfer += $input->readStructBegin($fname);
3300
+ while (true)
3301
+ {
3302
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
3303
+ if ($ftype == TType::STOP) {
3304
+ break;
3305
+ }
3306
+ switch ($fid)
3307
+ {
3308
+ case 1:
3309
+ if ($ftype == TType::STRING) {
3310
+ $xfer += $input->readString($this->profileId);
3311
+ } else {
3312
+ $xfer += $input->skip($ftype);
3313
+ }
3314
+ break;
3315
+ case 2:
3316
+ if ($ftype == TType::STRING) {
3317
+ $xfer += $input->readString($this->propertyName);
3318
+ } else {
3319
+ $xfer += $input->skip($ftype);
3320
+ }
3321
+ break;
3322
+ case 3:
3323
+ if ($ftype == TType::STRING) {
3324
+ $xfer += $input->readString($this->propertyValue);
3325
+ } else {
3326
+ $xfer += $input->skip($ftype);
3327
+ }
3328
+ break;
3329
+ case 4:
3330
+ if ($ftype == TType::I32) {
3331
+ $xfer += $input->readI32($this->confidence);
3332
+ } else {
3333
+ $xfer += $input->skip($ftype);
3334
+ }
3335
+ break;
3336
+ default:
3337
+ $xfer += $input->skip($ftype);
3338
+ break;
3339
+ }
3340
+ $xfer += $input->readFieldEnd();
3341
+ }
3342
+ $xfer += $input->readStructEnd();
3343
+ return $xfer;
3344
+ }
3345
+
3346
+ public function write($output) {
3347
+ $xfer = 0;
3348
+ $xfer += $output->writeStructBegin('ProfilePropertyValue');
3349
+ if ($this->profileId !== null) {
3350
+ $xfer += $output->writeFieldBegin('profileId', TType::STRING, 1);
3351
+ $xfer += $output->writeString($this->profileId);
3352
+ $xfer += $output->writeFieldEnd();
3353
+ }
3354
+ if ($this->propertyName !== null) {
3355
+ $xfer += $output->writeFieldBegin('propertyName', TType::STRING, 2);
3356
+ $xfer += $output->writeString($this->propertyName);
3357
+ $xfer += $output->writeFieldEnd();
3358
+ }
3359
+ if ($this->propertyValue !== null) {
3360
+ $xfer += $output->writeFieldBegin('propertyValue', TType::STRING, 3);
3361
+ $xfer += $output->writeString($this->propertyValue);
3362
+ $xfer += $output->writeFieldEnd();
3363
+ }
3364
+ if ($this->confidence !== null) {
3365
+ $xfer += $output->writeFieldBegin('confidence', TType::I32, 4);
3366
+ $xfer += $output->writeI32($this->confidence);
3367
+ $xfer += $output->writeFieldEnd();
3368
+ }
3369
+ $xfer += $output->writeFieldStop();
3370
+ $xfer += $output->writeStructEnd();
3371
+ return $xfer;
3372
+ }
3373
+
3374
+ }
3375
+
3376
+ class BatchChoiceRequest {
3377
+ static $_TSPEC;
3378
+
3379
+ public $userRecord = null;
3380
+ public $choiceInquiry = null;
3381
+ public $requestContext = null;
3382
+ public $profileIds = null;
3383
+ public $choiceInquiries = null;
3384
+
3385
+ public function __construct($vals=null) {
3386
+ if (!isset(self::$_TSPEC)) {
3387
+ self::$_TSPEC = array(
3388
+ 1 => array(
3389
+ 'var' => 'userRecord',
3390
+ 'type' => TType::STRUCT,
3391
+ 'class' => '\com\boxalino\p13n\api\thrift\UserRecord',
3392
+ ),
3393
+ 2 => array(
3394
+ 'var' => 'choiceInquiry',
3395
+ 'type' => TType::STRUCT,
3396
+ 'class' => '\com\boxalino\p13n\api\thrift\ChoiceInquiry',
3397
+ ),
3398
+ 3 => array(
3399
+ 'var' => 'requestContext',
3400
+ 'type' => TType::STRUCT,
3401
+ 'class' => '\com\boxalino\p13n\api\thrift\RequestContext',
3402
+ ),
3403
+ 4 => array(
3404
+ 'var' => 'profileIds',
3405
+ 'type' => TType::LST,
3406
+ 'etype' => TType::STRING,
3407
+ 'elem' => array(
3408
+ 'type' => TType::STRING,
3409
+ ),
3410
+ ),
3411
+ 5 => array(
3412
+ 'var' => 'choiceInquiries',
3413
+ 'type' => TType::LST,
3414
+ 'etype' => TType::STRUCT,
3415
+ 'elem' => array(
3416
+ 'type' => TType::STRUCT,
3417
+ 'class' => '\com\boxalino\p13n\api\thrift\ChoiceInquiry',
3418
+ ),
3419
+ ),
3420
+ );
3421
+ }
3422
+ if (is_array($vals)) {
3423
+ if (isset($vals['userRecord'])) {
3424
+ $this->userRecord = $vals['userRecord'];
3425
+ }
3426
+ if (isset($vals['choiceInquiry'])) {
3427
+ $this->choiceInquiry = $vals['choiceInquiry'];
3428
+ }
3429
+ if (isset($vals['requestContext'])) {
3430
+ $this->requestContext = $vals['requestContext'];
3431
+ }
3432
+ if (isset($vals['profileIds'])) {
3433
+ $this->profileIds = $vals['profileIds'];
3434
+ }
3435
+ if (isset($vals['choiceInquiries'])) {
3436
+ $this->choiceInquiries = $vals['choiceInquiries'];
3437
+ }
3438
+ }
3439
+ }
3440
+
3441
+ public function getName() {
3442
+ return 'BatchChoiceRequest';
3443
+ }
3444
+
3445
+ public function read($input)
3446
+ {
3447
+ $xfer = 0;
3448
+ $fname = null;
3449
+ $ftype = 0;
3450
+ $fid = 0;
3451
+ $xfer += $input->readStructBegin($fname);
3452
+ while (true)
3453
+ {
3454
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
3455
+ if ($ftype == TType::STOP) {
3456
+ break;
3457
+ }
3458
+ switch ($fid)
3459
+ {
3460
+ case 1:
3461
+ if ($ftype == TType::STRUCT) {
3462
+ $this->userRecord = new \com\boxalino\p13n\api\thrift\UserRecord();
3463
+ $xfer += $this->userRecord->read($input);
3464
+ } else {
3465
+ $xfer += $input->skip($ftype);
3466
+ }
3467
+ break;
3468
+ case 2:
3469
+ if ($ftype == TType::STRUCT) {
3470
+ $this->choiceInquiry = new \com\boxalino\p13n\api\thrift\ChoiceInquiry();
3471
+ $xfer += $this->choiceInquiry->read($input);
3472
+ } else {
3473
+ $xfer += $input->skip($ftype);
3474
+ }
3475
+ break;
3476
+ case 3:
3477
+ if ($ftype == TType::STRUCT) {
3478
+ $this->requestContext = new \com\boxalino\p13n\api\thrift\RequestContext();
3479
+ $xfer += $this->requestContext->read($input);
3480
+ } else {
3481
+ $xfer += $input->skip($ftype);
3482
+ }
3483
+ break;
3484
+ case 4:
3485
+ if ($ftype == TType::LST) {
3486
+ $this->profileIds = array();
3487
+ $_size166 = 0;
3488
+ $_etype169 = 0;
3489
+ $xfer += $input->readListBegin($_etype169, $_size166);
3490
+ for ($_i170 = 0; $_i170 < $_size166; ++$_i170)
3491
+ {
3492
+ $elem171 = null;
3493
+ $xfer += $input->readString($elem171);
3494
+ $this->profileIds []= $elem171;
3495
+ }
3496
+ $xfer += $input->readListEnd();
3497
+ } else {
3498
+ $xfer += $input->skip($ftype);
3499
+ }
3500
+ break;
3501
+ case 5:
3502
+ if ($ftype == TType::LST) {
3503
+ $this->choiceInquiries = array();
3504
+ $_size172 = 0;
3505
+ $_etype175 = 0;
3506
+ $xfer += $input->readListBegin($_etype175, $_size172);
3507
+ for ($_i176 = 0; $_i176 < $_size172; ++$_i176)
3508
+ {
3509
+ $elem177 = null;
3510
+ $elem177 = new \com\boxalino\p13n\api\thrift\ChoiceInquiry();
3511
+ $xfer += $elem177->read($input);
3512
+ $this->choiceInquiries []= $elem177;
3513
+ }
3514
+ $xfer += $input->readListEnd();
3515
+ } else {
3516
+ $xfer += $input->skip($ftype);
3517
+ }
3518
+ break;
3519
+ default:
3520
+ $xfer += $input->skip($ftype);
3521
+ break;
3522
+ }
3523
+ $xfer += $input->readFieldEnd();
3524
+ }
3525
+ $xfer += $input->readStructEnd();
3526
+ return $xfer;
3527
+ }
3528
+
3529
+ public function write($output) {
3530
+ $xfer = 0;
3531
+ $xfer += $output->writeStructBegin('BatchChoiceRequest');
3532
+ if ($this->userRecord !== null) {
3533
+ if (!is_object($this->userRecord)) {
3534
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
3535
+ }
3536
+ $xfer += $output->writeFieldBegin('userRecord', TType::STRUCT, 1);
3537
+ $xfer += $this->userRecord->write($output);
3538
+ $xfer += $output->writeFieldEnd();
3539
+ }
3540
+ if ($this->choiceInquiry !== null) {
3541
+ if (!is_object($this->choiceInquiry)) {
3542
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
3543
+ }
3544
+ $xfer += $output->writeFieldBegin('choiceInquiry', TType::STRUCT, 2);
3545
+ $xfer += $this->choiceInquiry->write($output);
3546
+ $xfer += $output->writeFieldEnd();
3547
+ }
3548
+ if ($this->requestContext !== null) {
3549
+ if (!is_object($this->requestContext)) {
3550
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
3551
+ }
3552
+ $xfer += $output->writeFieldBegin('requestContext', TType::STRUCT, 3);
3553
+ $xfer += $this->requestContext->write($output);
3554
+ $xfer += $output->writeFieldEnd();
3555
+ }
3556
+ if ($this->profileIds !== null) {
3557
+ if (!is_array($this->profileIds)) {
3558
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
3559
+ }
3560
+ $xfer += $output->writeFieldBegin('profileIds', TType::LST, 4);
3561
+ {
3562
+ $output->writeListBegin(TType::STRING, count($this->profileIds));
3563
+ {
3564
+ foreach ($this->profileIds as $iter178)
3565
+ {
3566
+ $xfer += $output->writeString($iter178);
3567
+ }
3568
+ }
3569
+ $output->writeListEnd();
3570
+ }
3571
+ $xfer += $output->writeFieldEnd();
3572
+ }
3573
+ if ($this->choiceInquiries !== null) {
3574
+ if (!is_array($this->choiceInquiries)) {
3575
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
3576
+ }
3577
+ $xfer += $output->writeFieldBegin('choiceInquiries', TType::LST, 5);
3578
+ {
3579
+ $output->writeListBegin(TType::STRUCT, count($this->choiceInquiries));
3580
+ {
3581
+ foreach ($this->choiceInquiries as $iter179)
3582
+ {
3583
+ $xfer += $iter179->write($output);
3584
+ }
3585
+ }
3586
+ $output->writeListEnd();
3587
+ }
3588
+ $xfer += $output->writeFieldEnd();
3589
+ }
3590
+ $xfer += $output->writeFieldStop();
3591
+ $xfer += $output->writeStructEnd();
3592
+ return $xfer;
3593
+ }
3594
+
3595
+ }
3596
+
3597
+ class BatchChoiceResponse {
3598
+ static $_TSPEC;
3599
+
3600
+ public $variants = null;
3601
+ public $selectedVariants = null;
3602
+
3603
+ public function __construct($vals=null) {
3604
+ if (!isset(self::$_TSPEC)) {
3605
+ self::$_TSPEC = array(
3606
+ 1 => array(
3607
+ 'var' => 'variants',
3608
+ 'type' => TType::LST,
3609
+ 'etype' => TType::STRUCT,
3610
+ 'elem' => array(
3611
+ 'type' => TType::STRUCT,
3612
+ 'class' => '\com\boxalino\p13n\api\thrift\Variant',
3613
+ ),
3614
+ ),
3615
+ 2 => array(
3616
+ 'var' => 'selectedVariants',
3617
+ 'type' => TType::LST,
3618
+ 'etype' => TType::LST,
3619
+ 'elem' => array(
3620
+ 'type' => TType::LST,
3621
+ 'etype' => TType::STRUCT,
3622
+ 'elem' => array(
3623
+ 'type' => TType::STRUCT,
3624
+ 'class' => '\com\boxalino\p13n\api\thrift\Variant',
3625
+ ),
3626
+ ),
3627
+ ),
3628
+ );
3629
+ }
3630
+ if (is_array($vals)) {
3631
+ if (isset($vals['variants'])) {
3632
+ $this->variants = $vals['variants'];
3633
+ }
3634
+ if (isset($vals['selectedVariants'])) {
3635
+ $this->selectedVariants = $vals['selectedVariants'];
3636
+ }
3637
+ }
3638
+ }
3639
+
3640
+ public function getName() {
3641
+ return 'BatchChoiceResponse';
3642
+ }
3643
+
3644
+ public function read($input)
3645
+ {
3646
+ $xfer = 0;
3647
+ $fname = null;
3648
+ $ftype = 0;
3649
+ $fid = 0;
3650
+ $xfer += $input->readStructBegin($fname);
3651
+ while (true)
3652
+ {
3653
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
3654
+ if ($ftype == TType::STOP) {
3655
+ break;
3656
+ }
3657
+ switch ($fid)
3658
+ {
3659
+ case 1:
3660
+ if ($ftype == TType::LST) {
3661
+ $this->variants = array();
3662
+ $_size180 = 0;
3663
+ $_etype183 = 0;
3664
+ $xfer += $input->readListBegin($_etype183, $_size180);
3665
+ for ($_i184 = 0; $_i184 < $_size180; ++$_i184)
3666
+ {
3667
+ $elem185 = null;
3668
+ $elem185 = new \com\boxalino\p13n\api\thrift\Variant();
3669
+ $xfer += $elem185->read($input);
3670
+ $this->variants []= $elem185;
3671
+ }
3672
+ $xfer += $input->readListEnd();
3673
+ } else {
3674
+ $xfer += $input->skip($ftype);
3675
+ }
3676
+ break;
3677
+ case 2:
3678
+ if ($ftype == TType::LST) {
3679
+ $this->selectedVariants = array();
3680
+ $_size186 = 0;
3681
+ $_etype189 = 0;
3682
+ $xfer += $input->readListBegin($_etype189, $_size186);
3683
+ for ($_i190 = 0; $_i190 < $_size186; ++$_i190)
3684
+ {
3685
+ $elem191 = null;
3686
+ $elem191 = array();
3687
+ $_size192 = 0;
3688
+ $_etype195 = 0;
3689
+ $xfer += $input->readListBegin($_etype195, $_size192);
3690
+ for ($_i196 = 0; $_i196 < $_size192; ++$_i196)
3691
+ {
3692
+ $elem197 = null;
3693
+ $elem197 = new \com\boxalino\p13n\api\thrift\Variant();
3694
+ $xfer += $elem197->read($input);
3695
+ $elem191 []= $elem197;
3696
+ }
3697
+ $xfer += $input->readListEnd();
3698
+ $this->selectedVariants []= $elem191;
3699
+ }
3700
+ $xfer += $input->readListEnd();
3701
+ } else {
3702
+ $xfer += $input->skip($ftype);
3703
+ }
3704
+ break;
3705
+ default:
3706
+ $xfer += $input->skip($ftype);
3707
+ break;
3708
+ }
3709
+ $xfer += $input->readFieldEnd();
3710
+ }
3711
+ $xfer += $input->readStructEnd();
3712
+ return $xfer;
3713
+ }
3714
+
3715
+ public function write($output) {
3716
+ $xfer = 0;
3717
+ $xfer += $output->writeStructBegin('BatchChoiceResponse');
3718
+ if ($this->variants !== null) {
3719
+ if (!is_array($this->variants)) {
3720
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
3721
+ }
3722
+ $xfer += $output->writeFieldBegin('variants', TType::LST, 1);
3723
+ {
3724
+ $output->writeListBegin(TType::STRUCT, count($this->variants));
3725
+ {
3726
+ foreach ($this->variants as $iter198)
3727
+ {
3728
+ $xfer += $iter198->write($output);
3729
+ }
3730
+ }
3731
+ $output->writeListEnd();
3732
+ }
3733
+ $xfer += $output->writeFieldEnd();
3734
+ }
3735
+ if ($this->selectedVariants !== null) {
3736
+ if (!is_array($this->selectedVariants)) {
3737
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
3738
+ }
3739
+ $xfer += $output->writeFieldBegin('selectedVariants', TType::LST, 2);
3740
+ {
3741
+ $output->writeListBegin(TType::LST, count($this->selectedVariants));
3742
+ {
3743
+ foreach ($this->selectedVariants as $iter199)
3744
+ {
3745
+ {
3746
+ $output->writeListBegin(TType::STRUCT, count($iter199));
3747
+ {
3748
+ foreach ($iter199 as $iter200)
3749
+ {
3750
+ $xfer += $iter200->write($output);
3751
+ }
3752
+ }
3753
+ $output->writeListEnd();
3754
+ }
3755
+ }
3756
+ }
3757
+ $output->writeListEnd();
3758
+ }
3759
+ $xfer += $output->writeFieldEnd();
3760
+ }
3761
+ $xfer += $output->writeFieldStop();
3762
+ $xfer += $output->writeStructEnd();
3763
+ return $xfer;
3764
+ }
3765
+
3766
+ }
3767
+
3768
+ class AutocompleteHit {
3769
+ static $_TSPEC;
3770
+
3771
+ public $suggestion = null;
3772
+ public $highlighted = null;
3773
+ public $searchResult = null;
3774
+ public $score = null;
3775
+
3776
+ public function __construct($vals=null) {
3777
+ if (!isset(self::$_TSPEC)) {
3778
+ self::$_TSPEC = array(
3779
+ 11 => array(
3780
+ 'var' => 'suggestion',
3781
+ 'type' => TType::STRING,
3782
+ ),
3783
+ 21 => array(
3784
+ 'var' => 'highlighted',
3785
+ 'type' => TType::STRING,
3786
+ ),
3787
+ 31 => array(
3788
+ 'var' => 'searchResult',
3789
+ 'type' => TType::STRUCT,
3790
+ 'class' => '\com\boxalino\p13n\api\thrift\SearchResult',
3791
+ ),
3792
+ 41 => array(
3793
+ 'var' => 'score',
3794
+ 'type' => TType::DOUBLE,
3795
+ ),
3796
+ );
3797
+ }
3798
+ if (is_array($vals)) {
3799
+ if (isset($vals['suggestion'])) {
3800
+ $this->suggestion = $vals['suggestion'];
3801
+ }
3802
+ if (isset($vals['highlighted'])) {
3803
+ $this->highlighted = $vals['highlighted'];
3804
+ }
3805
+ if (isset($vals['searchResult'])) {
3806
+ $this->searchResult = $vals['searchResult'];
3807
+ }
3808
+ if (isset($vals['score'])) {
3809
+ $this->score = $vals['score'];
3810
+ }
3811
+ }
3812
+ }
3813
+
3814
+ public function getName() {
3815
+ return 'AutocompleteHit';
3816
+ }
3817
+
3818
+ public function read($input)
3819
+ {
3820
+ $xfer = 0;
3821
+ $fname = null;
3822
+ $ftype = 0;
3823
+ $fid = 0;
3824
+ $xfer += $input->readStructBegin($fname);
3825
+ while (true)
3826
+ {
3827
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
3828
+ if ($ftype == TType::STOP) {
3829
+ break;
3830
+ }
3831
+ switch ($fid)
3832
+ {
3833
+ case 11:
3834
+ if ($ftype == TType::STRING) {
3835
+ $xfer += $input->readString($this->suggestion);
3836
+ } else {
3837
+ $xfer += $input->skip($ftype);
3838
+ }
3839
+ break;
3840
+ case 21:
3841
+ if ($ftype == TType::STRING) {
3842
+ $xfer += $input->readString($this->highlighted);
3843
+ } else {
3844
+ $xfer += $input->skip($ftype);
3845
+ }
3846
+ break;
3847
+ case 31:
3848
+ if ($ftype == TType::STRUCT) {
3849
+ $this->searchResult = new \com\boxalino\p13n\api\thrift\SearchResult();
3850
+ $xfer += $this->searchResult->read($input);
3851
+ } else {
3852
+ $xfer += $input->skip($ftype);
3853
+ }
3854
+ break;
3855
+ case 41:
3856
+ if ($ftype == TType::DOUBLE) {
3857
+ $xfer += $input->readDouble($this->score);
3858
+ } else {
3859
+ $xfer += $input->skip($ftype);
3860
+ }
3861
+ break;
3862
+ default:
3863
+ $xfer += $input->skip($ftype);
3864
+ break;
3865
+ }
3866
+ $xfer += $input->readFieldEnd();
3867
+ }
3868
+ $xfer += $input->readStructEnd();
3869
+ return $xfer;
3870
+ }
3871
+
3872
+ public function write($output) {
3873
+ $xfer = 0;
3874
+ $xfer += $output->writeStructBegin('AutocompleteHit');
3875
+ if ($this->suggestion !== null) {
3876
+ $xfer += $output->writeFieldBegin('suggestion', TType::STRING, 11);
3877
+ $xfer += $output->writeString($this->suggestion);
3878
+ $xfer += $output->writeFieldEnd();
3879
+ }
3880
+ if ($this->highlighted !== null) {
3881
+ $xfer += $output->writeFieldBegin('highlighted', TType::STRING, 21);
3882
+ $xfer += $output->writeString($this->highlighted);
3883
+ $xfer += $output->writeFieldEnd();
3884
+ }
3885
+ if ($this->searchResult !== null) {
3886
+ if (!is_object($this->searchResult)) {
3887
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
3888
+ }
3889
+ $xfer += $output->writeFieldBegin('searchResult', TType::STRUCT, 31);
3890
+ $xfer += $this->searchResult->write($output);
3891
+ $xfer += $output->writeFieldEnd();
3892
+ }
3893
+ if ($this->score !== null) {
3894
+ $xfer += $output->writeFieldBegin('score', TType::DOUBLE, 41);
3895
+ $xfer += $output->writeDouble($this->score);
3896
+ $xfer += $output->writeFieldEnd();
3897
+ }
3898
+ $xfer += $output->writeFieldStop();
3899
+ $xfer += $output->writeStructEnd();
3900
+ return $xfer;
3901
+ }
3902
+
3903
+ }
3904
+
3905
+ class AutocompleteQuery {
3906
+ static $_TSPEC;
3907
+
3908
+ public $indexId = null;
3909
+ public $language = null;
3910
+ public $queryText = null;
3911
+ public $suggestionsHitCount = null;
3912
+ public $highlight = null;
3913
+ public $highlightPre = "<em>";
3914
+ public $highlightPost = "</em>";
3915
+
3916
+ public function __construct($vals=null) {
3917
+ if (!isset(self::$_TSPEC)) {
3918
+ self::$_TSPEC = array(
3919
+ 11 => array(
3920
+ 'var' => 'indexId',
3921
+ 'type' => TType::STRING,
3922
+ ),
3923
+ 21 => array(
3924
+ 'var' => 'language',
3925
+ 'type' => TType::STRING,
3926
+ ),
3927
+ 31 => array(
3928
+ 'var' => 'queryText',
3929
+ 'type' => TType::STRING,
3930
+ ),
3931
+ 41 => array(
3932
+ 'var' => 'suggestionsHitCount',
3933
+ 'type' => TType::I32,
3934
+ ),
3935
+ 51 => array(
3936
+ 'var' => 'highlight',
3937
+ 'type' => TType::BOOL,
3938
+ ),
3939
+ 61 => array(
3940
+ 'var' => 'highlightPre',
3941
+ 'type' => TType::STRING,
3942
+ ),
3943
+ 71 => array(
3944
+ 'var' => 'highlightPost',
3945
+ 'type' => TType::STRING,
3946
+ ),
3947
+ );
3948
+ }
3949
+ if (is_array($vals)) {
3950
+ if (isset($vals['indexId'])) {
3951
+ $this->indexId = $vals['indexId'];
3952
+ }
3953
+ if (isset($vals['language'])) {
3954
+ $this->language = $vals['language'];
3955
+ }
3956
+ if (isset($vals['queryText'])) {
3957
+ $this->queryText = $vals['queryText'];
3958
+ }
3959
+ if (isset($vals['suggestionsHitCount'])) {
3960
+ $this->suggestionsHitCount = $vals['suggestionsHitCount'];
3961
+ }
3962
+ if (isset($vals['highlight'])) {
3963
+ $this->highlight = $vals['highlight'];
3964
+ }
3965
+ if (isset($vals['highlightPre'])) {
3966
+ $this->highlightPre = $vals['highlightPre'];
3967
+ }
3968
+ if (isset($vals['highlightPost'])) {
3969
+ $this->highlightPost = $vals['highlightPost'];
3970
+ }
3971
+ }
3972
+ }
3973
+
3974
+ public function getName() {
3975
+ return 'AutocompleteQuery';
3976
+ }
3977
+
3978
+ public function read($input)
3979
+ {
3980
+ $xfer = 0;
3981
+ $fname = null;
3982
+ $ftype = 0;
3983
+ $fid = 0;
3984
+ $xfer += $input->readStructBegin($fname);
3985
+ while (true)
3986
+ {
3987
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
3988
+ if ($ftype == TType::STOP) {
3989
+ break;
3990
+ }
3991
+ switch ($fid)
3992
+ {
3993
+ case 11:
3994
+ if ($ftype == TType::STRING) {
3995
+ $xfer += $input->readString($this->indexId);
3996
+ } else {
3997
+ $xfer += $input->skip($ftype);
3998
+ }
3999
+ break;
4000
+ case 21:
4001
+ if ($ftype == TType::STRING) {
4002
+ $xfer += $input->readString($this->language);
4003
+ } else {
4004
+ $xfer += $input->skip($ftype);
4005
+ }
4006
+ break;
4007
+ case 31:
4008
+ if ($ftype == TType::STRING) {
4009
+ $xfer += $input->readString($this->queryText);
4010
+ } else {
4011
+ $xfer += $input->skip($ftype);
4012
+ }
4013
+ break;
4014
+ case 41:
4015
+ if ($ftype == TType::I32) {
4016
+ $xfer += $input->readI32($this->suggestionsHitCount);
4017
+ } else {
4018
+ $xfer += $input->skip($ftype);
4019
+ }
4020
+ break;
4021
+ case 51:
4022
+ if ($ftype == TType::BOOL) {
4023
+ $xfer += $input->readBool($this->highlight);
4024
+ } else {
4025
+ $xfer += $input->skip($ftype);
4026
+ }
4027
+ break;
4028
+ case 61:
4029
+ if ($ftype == TType::STRING) {
4030
+ $xfer += $input->readString($this->highlightPre);
4031
+ } else {
4032
+ $xfer += $input->skip($ftype);
4033
+ }
4034
+ break;
4035
+ case 71:
4036
+ if ($ftype == TType::STRING) {
4037
+ $xfer += $input->readString($this->highlightPost);
4038
+ } else {
4039
+ $xfer += $input->skip($ftype);
4040
+ }
4041
+ break;
4042
+ default:
4043
+ $xfer += $input->skip($ftype);
4044
+ break;
4045
+ }
4046
+ $xfer += $input->readFieldEnd();
4047
+ }
4048
+ $xfer += $input->readStructEnd();
4049
+ return $xfer;
4050
+ }
4051
+
4052
+ public function write($output) {
4053
+ $xfer = 0;
4054
+ $xfer += $output->writeStructBegin('AutocompleteQuery');
4055
+ if ($this->indexId !== null) {
4056
+ $xfer += $output->writeFieldBegin('indexId', TType::STRING, 11);
4057
+ $xfer += $output->writeString($this->indexId);
4058
+ $xfer += $output->writeFieldEnd();
4059
+ }
4060
+ if ($this->language !== null) {
4061
+ $xfer += $output->writeFieldBegin('language', TType::STRING, 21);
4062
+ $xfer += $output->writeString($this->language);
4063
+ $xfer += $output->writeFieldEnd();
4064
+ }
4065
+ if ($this->queryText !== null) {
4066
+ $xfer += $output->writeFieldBegin('queryText', TType::STRING, 31);
4067
+ $xfer += $output->writeString($this->queryText);
4068
+ $xfer += $output->writeFieldEnd();
4069
+ }
4070
+ if ($this->suggestionsHitCount !== null) {
4071
+ $xfer += $output->writeFieldBegin('suggestionsHitCount', TType::I32, 41);
4072
+ $xfer += $output->writeI32($this->suggestionsHitCount);
4073
+ $xfer += $output->writeFieldEnd();
4074
+ }
4075
+ if ($this->highlight !== null) {
4076
+ $xfer += $output->writeFieldBegin('highlight', TType::BOOL, 51);
4077
+ $xfer += $output->writeBool($this->highlight);
4078
+ $xfer += $output->writeFieldEnd();
4079
+ }
4080
+ if ($this->highlightPre !== null) {
4081
+ $xfer += $output->writeFieldBegin('highlightPre', TType::STRING, 61);
4082
+ $xfer += $output->writeString($this->highlightPre);
4083
+ $xfer += $output->writeFieldEnd();
4084
+ }
4085
+ if ($this->highlightPost !== null) {
4086
+ $xfer += $output->writeFieldBegin('highlightPost', TType::STRING, 71);
4087
+ $xfer += $output->writeString($this->highlightPost);
4088
+ $xfer += $output->writeFieldEnd();
4089
+ }
4090
+ $xfer += $output->writeFieldStop();
4091
+ $xfer += $output->writeStructEnd();
4092
+ return $xfer;
4093
+ }
4094
+
4095
+ }
4096
+
4097
+ class AutocompleteRequest {
4098
+ static $_TSPEC;
4099
+
4100
+ public $userRecord = null;
4101
+ public $scope = "system_rec";
4102
+ public $choiceId = null;
4103
+ public $profileId = null;
4104
+ public $requestContext = null;
4105
+ public $excludeVariantIds = null;
4106
+ public $autocompleteQuery = null;
4107
+ public $searchChoiceId = null;
4108
+ public $searchQuery = null;
4109
+
4110
+ public function __construct($vals=null) {
4111
+ if (!isset(self::$_TSPEC)) {
4112
+ self::$_TSPEC = array(
4113
+ 11 => array(
4114
+ 'var' => 'userRecord',
4115
+ 'type' => TType::STRUCT,
4116
+ 'class' => '\com\boxalino\p13n\api\thrift\UserRecord',
4117
+ ),
4118
+ 21 => array(
4119
+ 'var' => 'scope',
4120
+ 'type' => TType::STRING,
4121
+ ),
4122
+ 31 => array(
4123
+ 'var' => 'choiceId',
4124
+ 'type' => TType::STRING,
4125
+ ),
4126
+ 41 => array(
4127
+ 'var' => 'profileId',
4128
+ 'type' => TType::STRING,
4129
+ ),
4130
+ 51 => array(
4131
+ 'var' => 'requestContext',
4132
+ 'type' => TType::STRUCT,
4133
+ 'class' => '\com\boxalino\p13n\api\thrift\RequestContext',
4134
+ ),
4135
+ 61 => array(
4136
+ 'var' => 'excludeVariantIds',
4137
+ 'type' => TType::SET,
4138
+ 'etype' => TType::STRING,
4139
+ 'elem' => array(
4140
+ 'type' => TType::STRING,
4141
+ ),
4142
+ ),
4143
+ 71 => array(
4144
+ 'var' => 'autocompleteQuery',
4145
+ 'type' => TType::STRUCT,
4146
+ 'class' => '\com\boxalino\p13n\api\thrift\AutocompleteQuery',
4147
+ ),
4148
+ 81 => array(
4149
+ 'var' => 'searchChoiceId',
4150
+ 'type' => TType::STRING,
4151
+ ),
4152
+ 91 => array(
4153
+ 'var' => 'searchQuery',
4154
+ 'type' => TType::STRUCT,
4155
+ 'class' => '\com\boxalino\p13n\api\thrift\SimpleSearchQuery',
4156
+ ),
4157
+ );
4158
+ }
4159
+ if (is_array($vals)) {
4160
+ if (isset($vals['userRecord'])) {
4161
+ $this->userRecord = $vals['userRecord'];
4162
+ }
4163
+ if (isset($vals['scope'])) {
4164
+ $this->scope = $vals['scope'];
4165
+ }
4166
+ if (isset($vals['choiceId'])) {
4167
+ $this->choiceId = $vals['choiceId'];
4168
+ }
4169
+ if (isset($vals['profileId'])) {
4170
+ $this->profileId = $vals['profileId'];
4171
+ }
4172
+ if (isset($vals['requestContext'])) {
4173
+ $this->requestContext = $vals['requestContext'];
4174
+ }
4175
+ if (isset($vals['excludeVariantIds'])) {
4176
+ $this->excludeVariantIds = $vals['excludeVariantIds'];
4177
+ }
4178
+ if (isset($vals['autocompleteQuery'])) {
4179
+ $this->autocompleteQuery = $vals['autocompleteQuery'];
4180
+ }
4181
+ if (isset($vals['searchChoiceId'])) {
4182
+ $this->searchChoiceId = $vals['searchChoiceId'];
4183
+ }
4184
+ if (isset($vals['searchQuery'])) {
4185
+ $this->searchQuery = $vals['searchQuery'];
4186
+ }
4187
+ }
4188
+ }
4189
+
4190
+ public function getName() {
4191
+ return 'AutocompleteRequest';
4192
+ }
4193
+
4194
+ public function read($input)
4195
+ {
4196
+ $xfer = 0;
4197
+ $fname = null;
4198
+ $ftype = 0;
4199
+ $fid = 0;
4200
+ $xfer += $input->readStructBegin($fname);
4201
+ while (true)
4202
+ {
4203
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
4204
+ if ($ftype == TType::STOP) {
4205
+ break;
4206
+ }
4207
+ switch ($fid)
4208
+ {
4209
+ case 11:
4210
+ if ($ftype == TType::STRUCT) {
4211
+ $this->userRecord = new \com\boxalino\p13n\api\thrift\UserRecord();
4212
+ $xfer += $this->userRecord->read($input);
4213
+ } else {
4214
+ $xfer += $input->skip($ftype);
4215
+ }
4216
+ break;
4217
+ case 21:
4218
+ if ($ftype == TType::STRING) {
4219
+ $xfer += $input->readString($this->scope);
4220
+ } else {
4221
+ $xfer += $input->skip($ftype);
4222
+ }
4223
+ break;
4224
+ case 31:
4225
+ if ($ftype == TType::STRING) {
4226
+ $xfer += $input->readString($this->choiceId);
4227
+ } else {
4228
+ $xfer += $input->skip($ftype);
4229
+ }
4230
+ break;
4231
+ case 41:
4232
+ if ($ftype == TType::STRING) {
4233
+ $xfer += $input->readString($this->profileId);
4234
+ } else {
4235
+ $xfer += $input->skip($ftype);
4236
+ }
4237
+ break;
4238
+ case 51:
4239
+ if ($ftype == TType::STRUCT) {
4240
+ $this->requestContext = new \com\boxalino\p13n\api\thrift\RequestContext();
4241
+ $xfer += $this->requestContext->read($input);
4242
+ } else {
4243
+ $xfer += $input->skip($ftype);
4244
+ }
4245
+ break;
4246
+ case 61:
4247
+ if ($ftype == TType::SET) {
4248
+ $this->excludeVariantIds = array();
4249
+ $_size201 = 0;
4250
+ $_etype204 = 0;
4251
+ $xfer += $input->readSetBegin($_etype204, $_size201);
4252
+ for ($_i205 = 0; $_i205 < $_size201; ++$_i205)
4253
+ {
4254
+ $elem206 = null;
4255
+ $xfer += $input->readString($elem206);
4256
+ if (is_scalar($elem206)) {
4257
+ $this->excludeVariantIds[$elem206] = true;
4258
+ } else {
4259
+ $this->excludeVariantIds []= $elem206;
4260
+ }
4261
+ }
4262
+ $xfer += $input->readSetEnd();
4263
+ } else {
4264
+ $xfer += $input->skip($ftype);
4265
+ }
4266
+ break;
4267
+ case 71:
4268
+ if ($ftype == TType::STRUCT) {
4269
+ $this->autocompleteQuery = new \com\boxalino\p13n\api\thrift\AutocompleteQuery();
4270
+ $xfer += $this->autocompleteQuery->read($input);
4271
+ } else {
4272
+ $xfer += $input->skip($ftype);
4273
+ }
4274
+ break;
4275
+ case 81:
4276
+ if ($ftype == TType::STRING) {
4277
+ $xfer += $input->readString($this->searchChoiceId);
4278
+ } else {
4279
+ $xfer += $input->skip($ftype);
4280
+ }
4281
+ break;
4282
+ case 91:
4283
+ if ($ftype == TType::STRUCT) {
4284
+ $this->searchQuery = new \com\boxalino\p13n\api\thrift\SimpleSearchQuery();
4285
+ $xfer += $this->searchQuery->read($input);
4286
+ } else {
4287
+ $xfer += $input->skip($ftype);
4288
+ }
4289
+ break;
4290
+ default:
4291
+ $xfer += $input->skip($ftype);
4292
+ break;
4293
+ }
4294
+ $xfer += $input->readFieldEnd();
4295
+ }
4296
+ $xfer += $input->readStructEnd();
4297
+ return $xfer;
4298
+ }
4299
+
4300
+ public function write($output) {
4301
+ $xfer = 0;
4302
+ $xfer += $output->writeStructBegin('AutocompleteRequest');
4303
+ if ($this->userRecord !== null) {
4304
+ if (!is_object($this->userRecord)) {
4305
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
4306
+ }
4307
+ $xfer += $output->writeFieldBegin('userRecord', TType::STRUCT, 11);
4308
+ $xfer += $this->userRecord->write($output);
4309
+ $xfer += $output->writeFieldEnd();
4310
+ }
4311
+ if ($this->scope !== null) {
4312
+ $xfer += $output->writeFieldBegin('scope', TType::STRING, 21);
4313
+ $xfer += $output->writeString($this->scope);
4314
+ $xfer += $output->writeFieldEnd();
4315
+ }
4316
+ if ($this->choiceId !== null) {
4317
+ $xfer += $output->writeFieldBegin('choiceId', TType::STRING, 31);
4318
+ $xfer += $output->writeString($this->choiceId);
4319
+ $xfer += $output->writeFieldEnd();
4320
+ }
4321
+ if ($this->profileId !== null) {
4322
+ $xfer += $output->writeFieldBegin('profileId', TType::STRING, 41);
4323
+ $xfer += $output->writeString($this->profileId);
4324
+ $xfer += $output->writeFieldEnd();
4325
+ }
4326
+ if ($this->requestContext !== null) {
4327
+ if (!is_object($this->requestContext)) {
4328
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
4329
+ }
4330
+ $xfer += $output->writeFieldBegin('requestContext', TType::STRUCT, 51);
4331
+ $xfer += $this->requestContext->write($output);
4332
+ $xfer += $output->writeFieldEnd();
4333
+ }
4334
+ if ($this->excludeVariantIds !== null) {
4335
+ if (!is_array($this->excludeVariantIds)) {
4336
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
4337
+ }
4338
+ $xfer += $output->writeFieldBegin('excludeVariantIds', TType::SET, 61);
4339
+ {
4340
+ $output->writeSetBegin(TType::STRING, count($this->excludeVariantIds));
4341
+ {
4342
+ foreach ($this->excludeVariantIds as $iter207 => $iter208)
4343
+ {
4344
+ if (is_scalar($iter208)) {
4345
+ $xfer += $output->writeString($iter207);
4346
+ } else {
4347
+ $xfer += $output->writeString($iter208);
4348
+ }
4349
+ }
4350
+ }
4351
+ $output->writeSetEnd();
4352
+ }
4353
+ $xfer += $output->writeFieldEnd();
4354
+ }
4355
+ if ($this->autocompleteQuery !== null) {
4356
+ if (!is_object($this->autocompleteQuery)) {
4357
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
4358
+ }
4359
+ $xfer += $output->writeFieldBegin('autocompleteQuery', TType::STRUCT, 71);
4360
+ $xfer += $this->autocompleteQuery->write($output);
4361
+ $xfer += $output->writeFieldEnd();
4362
+ }
4363
+ if ($this->searchChoiceId !== null) {
4364
+ $xfer += $output->writeFieldBegin('searchChoiceId', TType::STRING, 81);
4365
+ $xfer += $output->writeString($this->searchChoiceId);
4366
+ $xfer += $output->writeFieldEnd();
4367
+ }
4368
+ if ($this->searchQuery !== null) {
4369
+ if (!is_object($this->searchQuery)) {
4370
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
4371
+ }
4372
+ $xfer += $output->writeFieldBegin('searchQuery', TType::STRUCT, 91);
4373
+ $xfer += $this->searchQuery->write($output);
4374
+ $xfer += $output->writeFieldEnd();
4375
+ }
4376
+ $xfer += $output->writeFieldStop();
4377
+ $xfer += $output->writeStructEnd();
4378
+ return $xfer;
4379
+ }
4380
+
4381
+ }
4382
+
4383
+ class AutocompleteResponse {
4384
+ static $_TSPEC;
4385
+
4386
+ public $hits = null;
4387
+ public $prefixSearchResult = null;
4388
+
4389
+ public function __construct($vals=null) {
4390
+ if (!isset(self::$_TSPEC)) {
4391
+ self::$_TSPEC = array(
4392
+ 11 => array(
4393
+ 'var' => 'hits',
4394
+ 'type' => TType::LST,
4395
+ 'etype' => TType::STRUCT,
4396
+ 'elem' => array(
4397
+ 'type' => TType::STRUCT,
4398
+ 'class' => '\com\boxalino\p13n\api\thrift\AutocompleteHit',
4399
+ ),
4400
+ ),
4401
+ 21 => array(
4402
+ 'var' => 'prefixSearchResult',
4403
+ 'type' => TType::STRUCT,
4404
+ 'class' => '\com\boxalino\p13n\api\thrift\SearchResult',
4405
+ ),
4406
+ );
4407
+ }
4408
+ if (is_array($vals)) {
4409
+ if (isset($vals['hits'])) {
4410
+ $this->hits = $vals['hits'];
4411
+ }
4412
+ if (isset($vals['prefixSearchResult'])) {
4413
+ $this->prefixSearchResult = $vals['prefixSearchResult'];
4414
+ }
4415
+ }
4416
+ }
4417
+
4418
+ public function getName() {
4419
+ return 'AutocompleteResponse';
4420
+ }
4421
+
4422
+ public function read($input)
4423
+ {
4424
+ $xfer = 0;
4425
+ $fname = null;
4426
+ $ftype = 0;
4427
+ $fid = 0;
4428
+ $xfer += $input->readStructBegin($fname);
4429
+ while (true)
4430
+ {
4431
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
4432
+ if ($ftype == TType::STOP) {
4433
+ break;
4434
+ }
4435
+ switch ($fid)
4436
+ {
4437
+ case 11:
4438
+ if ($ftype == TType::LST) {
4439
+ $this->hits = array();
4440
+ $_size209 = 0;
4441
+ $_etype212 = 0;
4442
+ $xfer += $input->readListBegin($_etype212, $_size209);
4443
+ for ($_i213 = 0; $_i213 < $_size209; ++$_i213)
4444
+ {
4445
+ $elem214 = null;
4446
+ $elem214 = new \com\boxalino\p13n\api\thrift\AutocompleteHit();
4447
+ $xfer += $elem214->read($input);
4448
+ $this->hits []= $elem214;
4449
+ }
4450
+ $xfer += $input->readListEnd();
4451
+ } else {
4452
+ $xfer += $input->skip($ftype);
4453
+ }
4454
+ break;
4455
+ case 21:
4456
+ if ($ftype == TType::STRUCT) {
4457
+ $this->prefixSearchResult = new \com\boxalino\p13n\api\thrift\SearchResult();
4458
+ $xfer += $this->prefixSearchResult->read($input);
4459
+ } else {
4460
+ $xfer += $input->skip($ftype);
4461
+ }
4462
+ break;
4463
+ default:
4464
+ $xfer += $input->skip($ftype);
4465
+ break;
4466
+ }
4467
+ $xfer += $input->readFieldEnd();
4468
+ }
4469
+ $xfer += $input->readStructEnd();
4470
+ return $xfer;
4471
+ }
4472
+
4473
+ public function write($output) {
4474
+ $xfer = 0;
4475
+ $xfer += $output->writeStructBegin('AutocompleteResponse');
4476
+ if ($this->hits !== null) {
4477
+ if (!is_array($this->hits)) {
4478
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
4479
+ }
4480
+ $xfer += $output->writeFieldBegin('hits', TType::LST, 11);
4481
+ {
4482
+ $output->writeListBegin(TType::STRUCT, count($this->hits));
4483
+ {
4484
+ foreach ($this->hits as $iter215)
4485
+ {
4486
+ $xfer += $iter215->write($output);
4487
+ }
4488
+ }
4489
+ $output->writeListEnd();
4490
+ }
4491
+ $xfer += $output->writeFieldEnd();
4492
+ }
4493
+ if ($this->prefixSearchResult !== null) {
4494
+ if (!is_object($this->prefixSearchResult)) {
4495
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
4496
+ }
4497
+ $xfer += $output->writeFieldBegin('prefixSearchResult', TType::STRUCT, 21);
4498
+ $xfer += $this->prefixSearchResult->write($output);
4499
+ $xfer += $output->writeFieldEnd();
4500
+ }
4501
+ $xfer += $output->writeFieldStop();
4502
+ $xfer += $output->writeStructEnd();
4503
+ return $xfer;
4504
+ }
4505
+
4506
+ }
4507
+
4508
+ class P13nServiceException extends TException {
4509
+ static $_TSPEC;
4510
+
4511
+ public $message = null;
4512
+
4513
+ public function __construct($vals=null) {
4514
+ if (!isset(self::$_TSPEC)) {
4515
+ self::$_TSPEC = array(
4516
+ 1 => array(
4517
+ 'var' => 'message',
4518
+ 'type' => TType::STRING,
4519
+ ),
4520
+ );
4521
+ }
4522
+ if (is_array($vals)) {
4523
+ if (isset($vals['message'])) {
4524
+ $this->message = $vals['message'];
4525
+ }
4526
+ }
4527
+ }
4528
+
4529
+ public function getName() {
4530
+ return 'P13nServiceException';
4531
+ }
4532
+
4533
+ public function read($input)
4534
+ {
4535
+ $xfer = 0;
4536
+ $fname = null;
4537
+ $ftype = 0;
4538
+ $fid = 0;
4539
+ $xfer += $input->readStructBegin($fname);
4540
+ while (true)
4541
+ {
4542
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
4543
+ if ($ftype == TType::STOP) {
4544
+ break;
4545
+ }
4546
+ switch ($fid)
4547
+ {
4548
+ case 1:
4549
+ if ($ftype == TType::STRING) {
4550
+ $xfer += $input->readString($this->message);
4551
+ } else {
4552
+ $xfer += $input->skip($ftype);
4553
+ }
4554
+ break;
4555
+ default:
4556
+ $xfer += $input->skip($ftype);
4557
+ break;
4558
+ }
4559
+ $xfer += $input->readFieldEnd();
4560
+ }
4561
+ $xfer += $input->readStructEnd();
4562
+ return $xfer;
4563
+ }
4564
+
4565
+ public function write($output) {
4566
+ $xfer = 0;
4567
+ $xfer += $output->writeStructBegin('P13nServiceException');
4568
+ if ($this->message !== null) {
4569
+ $xfer += $output->writeFieldBegin('message', TType::STRING, 1);
4570
+ $xfer += $output->writeString($this->message);
4571
+ $xfer += $output->writeFieldEnd();
4572
+ }
4573
+ $xfer += $output->writeFieldStop();
4574
+ $xfer += $output->writeStructEnd();
4575
+ return $xfer;
4576
+ }
4577
+
4578
+ }
4579
+
4580
+
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Base/TBase.php ADDED
@@ -0,0 +1,367 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift
21
+ */
22
+
23
+ namespace Thrift\Base;
24
+
25
+ use Thrift\Type\TType;
26
+
27
+ /**
28
+ * Base class from which other Thrift structs extend. This is so that we can
29
+ * cut back on the size of the generated code which is turning out to have a
30
+ * nontrivial cost just to load thanks to the wondrously abysmal implementation
31
+ * of PHP. Note that code is intentionally duplicated in here to avoid making
32
+ * function calls for every field or member of a container..
33
+ */
34
+ abstract class TBase {
35
+
36
+ static $tmethod = array(TType::BOOL => 'Bool',
37
+ TType::BYTE => 'Byte',
38
+ TType::I16 => 'I16',
39
+ TType::I32 => 'I32',
40
+ TType::I64 => 'I64',
41
+ TType::DOUBLE => 'Double',
42
+ TType::STRING => 'String');
43
+
44
+ abstract function read($input);
45
+
46
+ abstract function write($output);
47
+
48
+ public function __construct($spec=null, $vals=null) {
49
+ if (is_array($spec) && is_array($vals)) {
50
+ foreach ($spec as $fid => $fspec) {
51
+ $var = $fspec['var'];
52
+ if (isset($vals[$var])) {
53
+ $this->$var = $vals[$var];
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ public function __wakeup()
60
+ {
61
+ $this->__construct(get_object_vars($this));
62
+ }
63
+
64
+ private function _readMap(&$var, $spec, $input) {
65
+ $xfer = 0;
66
+ $ktype = $spec['ktype'];
67
+ $vtype = $spec['vtype'];
68
+ $kread = $vread = null;
69
+ if (isset(TBase::$tmethod[$ktype])) {
70
+ $kread = 'read'.TBase::$tmethod[$ktype];
71
+ } else {
72
+ $kspec = $spec['key'];
73
+ }
74
+ if (isset(TBase::$tmethod[$vtype])) {
75
+ $vread = 'read'.TBase::$tmethod[$vtype];
76
+ } else {
77
+ $vspec = $spec['val'];
78
+ }
79
+ $var = array();
80
+ $_ktype = $_vtype = $size = 0;
81
+ $xfer += $input->readMapBegin($_ktype, $_vtype, $size);
82
+ for ($i = 0; $i < $size; ++$i) {
83
+ $key = $val = null;
84
+ if ($kread !== null) {
85
+ $xfer += $input->$kread($key);
86
+ } else {
87
+ switch ($ktype) {
88
+ case TType::STRUCT:
89
+ $class = $kspec['class'];
90
+ $key = new $class();
91
+ $xfer += $key->read($input);
92
+ break;
93
+ case TType::MAP:
94
+ $xfer += $this->_readMap($key, $kspec, $input);
95
+ break;
96
+ case TType::LST:
97
+ $xfer += $this->_readList($key, $kspec, $input, false);
98
+ break;
99
+ case TType::SET:
100
+ $xfer += $this->_readList($key, $kspec, $input, true);
101
+ break;
102
+ }
103
+ }
104
+ if ($vread !== null) {
105
+ $xfer += $input->$vread($val);
106
+ } else {
107
+ switch ($vtype) {
108
+ case TType::STRUCT:
109
+ $class = $vspec['class'];
110
+ $val = new $class();
111
+ $xfer += $val->read($input);
112
+ break;
113
+ case TType::MAP:
114
+ $xfer += $this->_readMap($val, $vspec, $input);
115
+ break;
116
+ case TType::LST:
117
+ $xfer += $this->_readList($val, $vspec, $input, false);
118
+ break;
119
+ case TType::SET:
120
+ $xfer += $this->_readList($val, $vspec, $input, true);
121
+ break;
122
+ }
123
+ }
124
+ $var[$key] = $val;
125
+ }
126
+ $xfer += $input->readMapEnd();
127
+ return $xfer;
128
+ }
129
+
130
+ private function _readList(&$var, $spec, $input, $set=false) {
131
+ $xfer = 0;
132
+ $etype = $spec['etype'];
133
+ $eread = $vread = null;
134
+ if (isset(TBase::$tmethod[$etype])) {
135
+ $eread = 'read'.TBase::$tmethod[$etype];
136
+ } else {
137
+ $espec = $spec['elem'];
138
+ }
139
+ $var = array();
140
+ $_etype = $size = 0;
141
+ if ($set) {
142
+ $xfer += $input->readSetBegin($_etype, $size);
143
+ } else {
144
+ $xfer += $input->readListBegin($_etype, $size);
145
+ }
146
+ for ($i = 0; $i < $size; ++$i) {
147
+ $elem = null;
148
+ if ($eread !== null) {
149
+ $xfer += $input->$eread($elem);
150
+ } else {
151
+ $espec = $spec['elem'];
152
+ switch ($etype) {
153
+ case TType::STRUCT:
154
+ $class = $espec['class'];
155
+ $elem = new $class();
156
+ $xfer += $elem->read($input);
157
+ break;
158
+ case TType::MAP:
159
+ $xfer += $this->_readMap($elem, $espec, $input);
160
+ break;
161
+ case TType::LST:
162
+ $xfer += $this->_readList($elem, $espec, $input, false);
163
+ break;
164
+ case TType::SET:
165
+ $xfer += $this->_readList($elem, $espec, $input, true);
166
+ break;
167
+ }
168
+ }
169
+ if ($set) {
170
+ $var[$elem] = true;
171
+ } else {
172
+ $var []= $elem;
173
+ }
174
+ }
175
+ if ($set) {
176
+ $xfer += $input->readSetEnd();
177
+ } else {
178
+ $xfer += $input->readListEnd();
179
+ }
180
+ return $xfer;
181
+ }
182
+
183
+ protected function _read($class, $spec, $input) {
184
+ $xfer = 0;
185
+ $fname = null;
186
+ $ftype = 0;
187
+ $fid = 0;
188
+ $xfer += $input->readStructBegin($fname);
189
+ while (true) {
190
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
191
+ if ($ftype == TType::STOP) {
192
+ break;
193
+ }
194
+ if (isset($spec[$fid])) {
195
+ $fspec = $spec[$fid];
196
+ $var = $fspec['var'];
197
+ if ($ftype == $fspec['type']) {
198
+ $xfer = 0;
199
+ if (isset(TBase::$tmethod[$ftype])) {
200
+ $func = 'read'.TBase::$tmethod[$ftype];
201
+ $xfer += $input->$func($this->$var);
202
+ } else {
203
+ switch ($ftype) {
204
+ case TType::STRUCT:
205
+ $class = $fspec['class'];
206
+ $this->$var = new $class();
207
+ $xfer += $this->$var->read($input);
208
+ break;
209
+ case TType::MAP:
210
+ $xfer += $this->_readMap($this->$var, $fspec, $input);
211
+ break;
212
+ case TType::LST:
213
+ $xfer += $this->_readList($this->$var, $fspec, $input, false);
214
+ break;
215
+ case TType::SET:
216
+ $xfer += $this->_readList($this->$var, $fspec, $input, true);
217
+ break;
218
+ }
219
+ }
220
+ } else {
221
+ $xfer += $input->skip($ftype);
222
+ }
223
+ } else {
224
+ $xfer += $input->skip($ftype);
225
+ }
226
+ $xfer += $input->readFieldEnd();
227
+ }
228
+ $xfer += $input->readStructEnd();
229
+ return $xfer;
230
+ }
231
+
232
+ private function _writeMap($var, $spec, $output) {
233
+ $xfer = 0;
234
+ $ktype = $spec['ktype'];
235
+ $vtype = $spec['vtype'];
236
+ $kwrite = $vwrite = null;
237
+ if (isset(TBase::$tmethod[$ktype])) {
238
+ $kwrite = 'write'.TBase::$tmethod[$ktype];
239
+ } else {
240
+ $kspec = $spec['key'];
241
+ }
242
+ if (isset(TBase::$tmethod[$vtype])) {
243
+ $vwrite = 'write'.TBase::$tmethod[$vtype];
244
+ } else {
245
+ $vspec = $spec['val'];
246
+ }
247
+ $xfer += $output->writeMapBegin($ktype, $vtype, count($var));
248
+ foreach ($var as $key => $val) {
249
+ if (isset($kwrite)) {
250
+ $xfer += $output->$kwrite($key);
251
+ } else {
252
+ switch ($ktype) {
253
+ case TType::STRUCT:
254
+ $xfer += $key->write($output);
255
+ break;
256
+ case TType::MAP:
257
+ $xfer += $this->_writeMap($key, $kspec, $output);
258
+ break;
259
+ case TType::LST:
260
+ $xfer += $this->_writeList($key, $kspec, $output, false);
261
+ break;
262
+ case TType::SET:
263
+ $xfer += $this->_writeList($key, $kspec, $output, true);
264
+ break;
265
+ }
266
+ }
267
+ if (isset($vwrite)) {
268
+ $xfer += $output->$vwrite($val);
269
+ } else {
270
+ switch ($vtype) {
271
+ case TType::STRUCT:
272
+ $xfer += $val->write($output);
273
+ break;
274
+ case TType::MAP:
275
+ $xfer += $this->_writeMap($val, $vspec, $output);
276
+ break;
277
+ case TType::LST:
278
+ $xfer += $this->_writeList($val, $vspec, $output, false);
279
+ break;
280
+ case TType::SET:
281
+ $xfer += $this->_writeList($val, $vspec, $output, true);
282
+ break;
283
+ }
284
+ }
285
+ }
286
+ $xfer += $output->writeMapEnd();
287
+ return $xfer;
288
+ }
289
+
290
+ private function _writeList($var, $spec, $output, $set=false) {
291
+ $xfer = 0;
292
+ $etype = $spec['etype'];
293
+ $ewrite = null;
294
+ if (isset(TBase::$tmethod[$etype])) {
295
+ $ewrite = 'write'.TBase::$tmethod[$etype];
296
+ } else {
297
+ $espec = $spec['elem'];
298
+ }
299
+ if ($set) {
300
+ $xfer += $output->writeSetBegin($etype, count($var));
301
+ } else {
302
+ $xfer += $output->writeListBegin($etype, count($var));
303
+ }
304
+ foreach ($var as $key => $val) {
305
+ $elem = $set ? $key : $val;
306
+ if (isset($ewrite)) {
307
+ $xfer += $output->$ewrite($elem);
308
+ } else {
309
+ switch ($etype) {
310
+ case TType::STRUCT:
311
+ $xfer += $elem->write($output);
312
+ break;
313
+ case TType::MAP:
314
+ $xfer += $this->_writeMap($elem, $espec, $output);
315
+ break;
316
+ case TType::LST:
317
+ $xfer += $this->_writeList($elem, $espec, $output, false);
318
+ break;
319
+ case TType::SET:
320
+ $xfer += $this->_writeList($elem, $espec, $output, true);
321
+ break;
322
+ }
323
+ }
324
+ }
325
+ if ($set) {
326
+ $xfer += $output->writeSetEnd();
327
+ } else {
328
+ $xfer += $output->writeListEnd();
329
+ }
330
+ return $xfer;
331
+ }
332
+
333
+ protected function _write($class, $spec, $output) {
334
+ $xfer = 0;
335
+ $xfer += $output->writeStructBegin($class);
336
+ foreach ($spec as $fid => $fspec) {
337
+ $var = $fspec['var'];
338
+ if ($this->$var !== null) {
339
+ $ftype = $fspec['type'];
340
+ $xfer += $output->writeFieldBegin($var, $ftype, $fid);
341
+ if (isset(TBase::$tmethod[$ftype])) {
342
+ $func = 'write'.TBase::$tmethod[$ftype];
343
+ $xfer += $output->$func($this->$var);
344
+ } else {
345
+ switch ($ftype) {
346
+ case TType::STRUCT:
347
+ $xfer += $this->$var->write($output);
348
+ break;
349
+ case TType::MAP:
350
+ $xfer += $this->_writeMap($this->$var, $fspec, $output);
351
+ break;
352
+ case TType::LST:
353
+ $xfer += $this->_writeList($this->$var, $fspec, $output, false);
354
+ break;
355
+ case TType::SET:
356
+ $xfer += $this->_writeList($this->$var, $fspec, $output, true);
357
+ break;
358
+ }
359
+ }
360
+ $xfer += $output->writeFieldEnd();
361
+ }
362
+ }
363
+ $xfer += $output->writeFieldStop();
364
+ $xfer += $output->writeStructEnd();
365
+ return $xfer;
366
+ }
367
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/ClassLoader/ThriftClassLoader.php ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * ClassLoader to load Thrift library and definitions
21
+ * Inspired from UniversalClassLoader from Symfony 2
22
+ *
23
+ * @package thrift.classloader
24
+ */
25
+
26
+ namespace Thrift\ClassLoader;
27
+
28
+ class ThriftClassLoader
29
+ {
30
+ /**
31
+ * Namespaces path
32
+ * @var array
33
+ */
34
+ protected $namespaces = array();
35
+
36
+ /**
37
+ * Thrift definition paths
38
+ * @var type
39
+ */
40
+ protected $definitions = array();
41
+
42
+ /**
43
+ * Do we use APC cache ?
44
+ * @var boolean
45
+ */
46
+ protected $apc = false;
47
+
48
+ /**
49
+ * APC Cache prefix
50
+ * @var string
51
+ */
52
+ protected $apc_prefix;
53
+
54
+ /**
55
+ * Set autoloader to use APC cache
56
+ * @param boolean $apc
57
+ * @param string $apc_prefix
58
+ */
59
+ public function __construct($apc = false, $apc_prefix = null)
60
+ {
61
+ $this->apc = $apc;
62
+ $this->apc_prefix = $apc_prefix;
63
+ }
64
+
65
+ /**
66
+ * Registers a namespace.
67
+ *
68
+ * @param string $namespace The namespace
69
+ * @param array|string $paths The location(s) of the namespace
70
+ */
71
+ public function registerNamespace($namespace, $paths)
72
+ {
73
+ $this->namespaces[$namespace] = (array) $paths;
74
+ }
75
+
76
+ /**
77
+ * Registers a Thrift definition namespace.
78
+ *
79
+ * @param string $namespace The definition namespace
80
+ * @param array|string $paths The location(s) of the definition namespace
81
+ */
82
+ public function registerDefinition($namespace, $paths)
83
+ {
84
+ $this->definitions[$namespace] = (array) $paths;
85
+ }
86
+
87
+ /**
88
+ * Registers this instance as an autoloader.
89
+ *
90
+ * @param Boolean $prepend Whether to prepend the autoloader or not
91
+ */
92
+ public function register($prepend = false)
93
+ {
94
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
95
+ }
96
+
97
+ /**
98
+ * Loads the given class, definition or interface.
99
+ *
100
+ * @param string $class The name of the class
101
+ */
102
+ public function loadClass($class)
103
+ {
104
+ if (
105
+ (true === $this->apc && ($file = $this->findFileInApc($class))) or
106
+ ($file = $this->findFile($class))
107
+ )
108
+ {
109
+ require_once $file;
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Loads the given class or interface in APC.
115
+ * @param string $class The name of the class
116
+ * @return string
117
+ */
118
+ protected function findFileInApc($class)
119
+ {
120
+ if (false === $file = apc_fetch($this->apc_prefix.$class)) {
121
+ apc_store($this->apc_prefix.$class, $file = $this->findFile($class));
122
+ }
123
+
124
+ return $file;
125
+ }
126
+
127
+ /**
128
+ * Find class in namespaces or definitions directories
129
+ * @param string $class
130
+ * @return string
131
+ */
132
+ public function findFile($class)
133
+ {
134
+ // Remove first backslash
135
+ if ('\\' == $class[0])
136
+ {
137
+ $class = substr($class, 1);
138
+ }
139
+
140
+ if (false !== $pos = strrpos($class, '\\'))
141
+ {
142
+ // Namespaced class name
143
+ $namespace = substr($class, 0, $pos);
144
+
145
+ // Iterate in normal namespaces
146
+ foreach ($this->namespaces as $ns => $dirs)
147
+ {
148
+ //Don't interfere with other autoloaders
149
+ if (0 !== strpos($namespace, $ns))
150
+ {
151
+ continue;
152
+ }
153
+
154
+ foreach ($dirs as $dir)
155
+ {
156
+ $className = substr($class, $pos + 1);
157
+
158
+ $file = $dir.DIRECTORY_SEPARATOR.
159
+ str_replace('\\', DIRECTORY_SEPARATOR, $namespace).
160
+ DIRECTORY_SEPARATOR.
161
+ $className.'.php';
162
+
163
+ if (file_exists($file))
164
+ {
165
+ return $file;
166
+ }
167
+ }
168
+ }
169
+
170
+ // Iterate in Thrift namespaces
171
+
172
+ // Remove first part of namespace
173
+ $m = explode('\\', $class);
174
+
175
+ // Ignore wrong call
176
+ if(count($m) <= 1)
177
+ {
178
+ return;
179
+ }
180
+
181
+ $class = array_pop($m);
182
+ $namespace = implode('\\', $m);
183
+
184
+ foreach ($this->definitions as $ns => $dirs)
185
+ {
186
+ //Don't interfere with other autoloaders
187
+ if (0 !== strpos($namespace, $ns))
188
+ {
189
+ continue;
190
+ }
191
+
192
+ foreach ($dirs as $dir)
193
+ {
194
+ /**
195
+ * Available in service: Interface, Client, Processor, Rest
196
+ * And every service methods (_.+)
197
+ */
198
+ if(
199
+ 0 === preg_match('#(.+)(if|client|processor|rest)$#i', $class, $n) and
200
+ 0 === preg_match('#(.+)_[a-z0-9]+_(args|result)$#i', $class, $n)
201
+ )
202
+ {
203
+ $className = 'Types';
204
+ }
205
+ else
206
+ {
207
+ $className = $n[1];
208
+ }
209
+
210
+ $file = $dir.DIRECTORY_SEPARATOR .
211
+ str_replace('\\', DIRECTORY_SEPARATOR, $namespace) .
212
+ DIRECTORY_SEPARATOR .
213
+ $className . '.php';
214
+
215
+ if (file_exists($file))
216
+ {
217
+ return $file;
218
+ }
219
+ }
220
+ }
221
+ }
222
+ }
223
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Exception/TApplicationException.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift
21
+ */
22
+
23
+ namespace Thrift\Exception;
24
+
25
+ use Thrift\Exception\TException;
26
+ use Thrift\Type\TType;
27
+
28
+ class TApplicationException extends TException {
29
+ static $_TSPEC =
30
+ array(1 => array('var' => 'message',
31
+ 'type' => TType::STRING),
32
+ 2 => array('var' => 'code',
33
+ 'type' => TType::I32));
34
+
35
+ const UNKNOWN = 0;
36
+ const UNKNOWN_METHOD = 1;
37
+ const INVALID_MESSAGE_TYPE = 2;
38
+ const WRONG_METHOD_NAME = 3;
39
+ const BAD_SEQUENCE_ID = 4;
40
+ const MISSING_RESULT = 5;
41
+ const INTERNAL_ERROR = 6;
42
+ const PROTOCOL_ERROR = 7;
43
+ const INVALID_TRANSFORM = 8;
44
+ const INVALID_PROTOCOL = 9;
45
+ const UNSUPPORTED_CLIENT_TYPE = 10;
46
+
47
+ function __construct($message=null, $code=0) {
48
+ parent::__construct($message, $code);
49
+ }
50
+
51
+ public function read($output) {
52
+ return $this->_read('TApplicationException', self::$_TSPEC, $output);
53
+ }
54
+
55
+ public function write($output) {
56
+ $xfer = 0;
57
+ $xfer += $output->writeStructBegin('TApplicationException');
58
+ if ($message = $this->getMessage()) {
59
+ $xfer += $output->writeFieldBegin('message', TType::STRING, 1);
60
+ $xfer += $output->writeString($message);
61
+ $xfer += $output->writeFieldEnd();
62
+ }
63
+ if ($code = $this->getCode()) {
64
+ $xfer += $output->writeFieldBegin('type', TType::I32, 2);
65
+ $xfer += $output->writeI32($code);
66
+ $xfer += $output->writeFieldEnd();
67
+ }
68
+ $xfer += $output->writeFieldStop();
69
+ $xfer += $output->writeStructEnd();
70
+ return $xfer;
71
+ }
72
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Exception/TException.php ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift
21
+ */
22
+
23
+ namespace Thrift\Exception;
24
+
25
+ use Thrift\Type\TType;
26
+ use Thrift\Base\TBase;
27
+
28
+ /**
29
+ * NOTE(mcslee): This currently contains a ton of duplicated code from TBase
30
+ * because we need to save CPU cycles and this is not yet in an extension.
31
+ * Ideally we'd multiply-inherit TException from both Exception and Base, but
32
+ * that's not possible in PHP and there are no modules either, so for now we
33
+ * apologetically take a trip to HackTown.
34
+ *
35
+ * Can be called with standard Exception constructor (message, code) or with
36
+ * Thrift Base object constructor (spec, vals).
37
+ *
38
+ * @param mixed $p1 Message (string) or type-spec (array)
39
+ * @param mixed $p2 Code (integer) or values (array)
40
+ */
41
+ class TException extends \Exception {
42
+ function __construct($p1=null, $p2=0) {
43
+ if (is_array($p1) && is_array($p2)) {
44
+ $spec = $p1;
45
+ $vals = $p2;
46
+ foreach ($spec as $fid => $fspec) {
47
+ $var = $fspec['var'];
48
+ if (isset($vals[$var])) {
49
+ $this->$var = $vals[$var];
50
+ }
51
+ }
52
+ } else {
53
+ parent::__construct($p1, $p2);
54
+ }
55
+ }
56
+
57
+ static $tmethod = array(TType::BOOL => 'Bool',
58
+ TType::BYTE => 'Byte',
59
+ TType::I16 => 'I16',
60
+ TType::I32 => 'I32',
61
+ TType::I64 => 'I64',
62
+ TType::DOUBLE => 'Double',
63
+ TType::STRING => 'String');
64
+
65
+ private function _readMap(&$var, $spec, $input) {
66
+ $xfer = 0;
67
+ $ktype = $spec['ktype'];
68
+ $vtype = $spec['vtype'];
69
+ $kread = $vread = null;
70
+ if (isset(TBase::$tmethod[$ktype])) {
71
+ $kread = 'read'.TBase::$tmethod[$ktype];
72
+ } else {
73
+ $kspec = $spec['key'];
74
+ }
75
+ if (isset(TBase::$tmethod[$vtype])) {
76
+ $vread = 'read'.TBase::$tmethod[$vtype];
77
+ } else {
78
+ $vspec = $spec['val'];
79
+ }
80
+ $var = array();
81
+ $_ktype = $_vtype = $size = 0;
82
+ $xfer += $input->readMapBegin($_ktype, $_vtype, $size);
83
+ for ($i = 0; $i < $size; ++$i) {
84
+ $key = $val = null;
85
+ if ($kread !== null) {
86
+ $xfer += $input->$kread($key);
87
+ } else {
88
+ switch ($ktype) {
89
+ case TType::STRUCT:
90
+ $class = $kspec['class'];
91
+ $key = new $class();
92
+ $xfer += $key->read($input);
93
+ break;
94
+ case TType::MAP:
95
+ $xfer += $this->_readMap($key, $kspec, $input);
96
+ break;
97
+ case TType::LST:
98
+ $xfer += $this->_readList($key, $kspec, $input, false);
99
+ break;
100
+ case TType::SET:
101
+ $xfer += $this->_readList($key, $kspec, $input, true);
102
+ break;
103
+ }
104
+ }
105
+ if ($vread !== null) {
106
+ $xfer += $input->$vread($val);
107
+ } else {
108
+ switch ($vtype) {
109
+ case TType::STRUCT:
110
+ $class = $vspec['class'];
111
+ $val = new $class();
112
+ $xfer += $val->read($input);
113
+ break;
114
+ case TType::MAP:
115
+ $xfer += $this->_readMap($val, $vspec, $input);
116
+ break;
117
+ case TType::LST:
118
+ $xfer += $this->_readList($val, $vspec, $input, false);
119
+ break;
120
+ case TType::SET:
121
+ $xfer += $this->_readList($val, $vspec, $input, true);
122
+ break;
123
+ }
124
+ }
125
+ $var[$key] = $val;
126
+ }
127
+ $xfer += $input->readMapEnd();
128
+ return $xfer;
129
+ }
130
+
131
+ private function _readList(&$var, $spec, $input, $set=false) {
132
+ $xfer = 0;
133
+ $etype = $spec['etype'];
134
+ $eread = $vread = null;
135
+ if (isset(TBase::$tmethod[$etype])) {
136
+ $eread = 'read'.TBase::$tmethod[$etype];
137
+ } else {
138
+ $espec = $spec['elem'];
139
+ }
140
+ $var = array();
141
+ $_etype = $size = 0;
142
+ if ($set) {
143
+ $xfer += $input->readSetBegin($_etype, $size);
144
+ } else {
145
+ $xfer += $input->readListBegin($_etype, $size);
146
+ }
147
+ for ($i = 0; $i < $size; ++$i) {
148
+ $elem = null;
149
+ if ($eread !== null) {
150
+ $xfer += $input->$eread($elem);
151
+ } else {
152
+ $espec = $spec['elem'];
153
+ switch ($etype) {
154
+ case TType::STRUCT:
155
+ $class = $espec['class'];
156
+ $elem = new $class();
157
+ $xfer += $elem->read($input);
158
+ break;
159
+ case TType::MAP:
160
+ $xfer += $this->_readMap($elem, $espec, $input);
161
+ break;
162
+ case TType::LST:
163
+ $xfer += $this->_readList($elem, $espec, $input, false);
164
+ break;
165
+ case TType::SET:
166
+ $xfer += $this->_readList($elem, $espec, $input, true);
167
+ break;
168
+ }
169
+ }
170
+ if ($set) {
171
+ $var[$elem] = true;
172
+ } else {
173
+ $var []= $elem;
174
+ }
175
+ }
176
+ if ($set) {
177
+ $xfer += $input->readSetEnd();
178
+ } else {
179
+ $xfer += $input->readListEnd();
180
+ }
181
+ return $xfer;
182
+ }
183
+
184
+ protected function _read($class, $spec, $input) {
185
+ $xfer = 0;
186
+ $fname = null;
187
+ $ftype = 0;
188
+ $fid = 0;
189
+ $xfer += $input->readStructBegin($fname);
190
+ while (true) {
191
+ $xfer += $input->readFieldBegin($fname, $ftype, $fid);
192
+ if ($ftype == TType::STOP) {
193
+ break;
194
+ }
195
+ if (isset($spec[$fid])) {
196
+ $fspec = $spec[$fid];
197
+ $var = $fspec['var'];
198
+ if ($ftype == $fspec['type']) {
199
+ $xfer = 0;
200
+ if (isset(TBase::$tmethod[$ftype])) {
201
+ $func = 'read'.TBase::$tmethod[$ftype];
202
+ $xfer += $input->$func($this->$var);
203
+ } else {
204
+ switch ($ftype) {
205
+ case TType::STRUCT:
206
+ $class = $fspec['class'];
207
+ $this->$var = new $class();
208
+ $xfer += $this->$var->read($input);
209
+ break;
210
+ case TType::MAP:
211
+ $xfer += $this->_readMap($this->$var, $fspec, $input);
212
+ break;
213
+ case TType::LST:
214
+ $xfer += $this->_readList($this->$var, $fspec, $input, false);
215
+ break;
216
+ case TType::SET:
217
+ $xfer += $this->_readList($this->$var, $fspec, $input, true);
218
+ break;
219
+ }
220
+ }
221
+ } else {
222
+ $xfer += $input->skip($ftype);
223
+ }
224
+ } else {
225
+ $xfer += $input->skip($ftype);
226
+ }
227
+ $xfer += $input->readFieldEnd();
228
+ }
229
+ $xfer += $input->readStructEnd();
230
+ return $xfer;
231
+ }
232
+
233
+ private function _writeMap($var, $spec, $output) {
234
+ $xfer = 0;
235
+ $ktype = $spec['ktype'];
236
+ $vtype = $spec['vtype'];
237
+ $kwrite = $vwrite = null;
238
+ if (isset(TBase::$tmethod[$ktype])) {
239
+ $kwrite = 'write'.TBase::$tmethod[$ktype];
240
+ } else {
241
+ $kspec = $spec['key'];
242
+ }
243
+ if (isset(TBase::$tmethod[$vtype])) {
244
+ $vwrite = 'write'.TBase::$tmethod[$vtype];
245
+ } else {
246
+ $vspec = $spec['val'];
247
+ }
248
+ $xfer += $output->writeMapBegin($ktype, $vtype, count($var));
249
+ foreach ($var as $key => $val) {
250
+ if (isset($kwrite)) {
251
+ $xfer += $output->$kwrite($key);
252
+ } else {
253
+ switch ($ktype) {
254
+ case TType::STRUCT:
255
+ $xfer += $key->write($output);
256
+ break;
257
+ case TType::MAP:
258
+ $xfer += $this->_writeMap($key, $kspec, $output);
259
+ break;
260
+ case TType::LST:
261
+ $xfer += $this->_writeList($key, $kspec, $output, false);
262
+ break;
263
+ case TType::SET:
264
+ $xfer += $this->_writeList($key, $kspec, $output, true);
265
+ break;
266
+ }
267
+ }
268
+ if (isset($vwrite)) {
269
+ $xfer += $output->$vwrite($val);
270
+ } else {
271
+ switch ($vtype) {
272
+ case TType::STRUCT:
273
+ $xfer += $val->write($output);
274
+ break;
275
+ case TType::MAP:
276
+ $xfer += $this->_writeMap($val, $vspec, $output);
277
+ break;
278
+ case TType::LST:
279
+ $xfer += $this->_writeList($val, $vspec, $output, false);
280
+ break;
281
+ case TType::SET:
282
+ $xfer += $this->_writeList($val, $vspec, $output, true);
283
+ break;
284
+ }
285
+ }
286
+ }
287
+ $xfer += $output->writeMapEnd();
288
+ return $xfer;
289
+ }
290
+
291
+ private function _writeList($var, $spec, $output, $set=false) {
292
+ $xfer = 0;
293
+ $etype = $spec['etype'];
294
+ $ewrite = null;
295
+ if (isset(TBase::$tmethod[$etype])) {
296
+ $ewrite = 'write'.TBase::$tmethod[$etype];
297
+ } else {
298
+ $espec = $spec['elem'];
299
+ }
300
+ if ($set) {
301
+ $xfer += $output->writeSetBegin($etype, count($var));
302
+ } else {
303
+ $xfer += $output->writeListBegin($etype, count($var));
304
+ }
305
+ foreach ($var as $key => $val) {
306
+ $elem = $set ? $key : $val;
307
+ if (isset($ewrite)) {
308
+ $xfer += $output->$ewrite($elem);
309
+ } else {
310
+ switch ($etype) {
311
+ case TType::STRUCT:
312
+ $xfer += $elem->write($output);
313
+ break;
314
+ case TType::MAP:
315
+ $xfer += $this->_writeMap($elem, $espec, $output);
316
+ break;
317
+ case TType::LST:
318
+ $xfer += $this->_writeList($elem, $espec, $output, false);
319
+ break;
320
+ case TType::SET:
321
+ $xfer += $this->_writeList($elem, $espec, $output, true);
322
+ break;
323
+ }
324
+ }
325
+ }
326
+ if ($set) {
327
+ $xfer += $output->writeSetEnd();
328
+ } else {
329
+ $xfer += $output->writeListEnd();
330
+ }
331
+ return $xfer;
332
+ }
333
+
334
+ protected function _write($class, $spec, $output) {
335
+ $xfer = 0;
336
+ $xfer += $output->writeStructBegin($class);
337
+ foreach ($spec as $fid => $fspec) {
338
+ $var = $fspec['var'];
339
+ if ($this->$var !== null) {
340
+ $ftype = $fspec['type'];
341
+ $xfer += $output->writeFieldBegin($var, $ftype, $fid);
342
+ if (isset(TBase::$tmethod[$ftype])) {
343
+ $func = 'write'.TBase::$tmethod[$ftype];
344
+ $xfer += $output->$func($this->$var);
345
+ } else {
346
+ switch ($ftype) {
347
+ case TType::STRUCT:
348
+ $xfer += $this->$var->write($output);
349
+ break;
350
+ case TType::MAP:
351
+ $xfer += $this->_writeMap($this->$var, $fspec, $output);
352
+ break;
353
+ case TType::LST:
354
+ $xfer += $this->_writeList($this->$var, $fspec, $output, false);
355
+ break;
356
+ case TType::SET:
357
+ $xfer += $this->_writeList($this->$var, $fspec, $output, true);
358
+ break;
359
+ }
360
+ }
361
+ $xfer += $output->writeFieldEnd();
362
+ }
363
+ }
364
+ $xfer += $output->writeFieldStop();
365
+ $xfer += $output->writeStructEnd();
366
+ return $xfer;
367
+ }
368
+
369
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Exception/TProtocolException.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ * @author: rmarin (marin.radu@facebook.com)
22
+ */
23
+
24
+ namespace Thrift\Exception;
25
+
26
+ use Thrift\Exception\TException;
27
+
28
+ /**
29
+ * Protocol module. Contains all the types and definitions needed to implement
30
+ * a protocol encoder/decoder.
31
+ *
32
+ * @package thrift.protocol
33
+ */
34
+
35
+ /**
36
+ * Protocol exceptions
37
+ */
38
+ class TProtocolException extends TException {
39
+ const UNKNOWN = 0;
40
+ const INVALID_DATA = 1;
41
+ const NEGATIVE_SIZE = 2;
42
+ const SIZE_LIMIT = 3;
43
+ const BAD_VERSION = 4;
44
+
45
+ function __construct($message=null, $code=0) {
46
+ parent::__construct($message, $code);
47
+ }
48
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Exception/TTransportException.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.transport
21
+ */
22
+
23
+ namespace Thrift\Exception;
24
+
25
+ use Thrift\Exception\TException;
26
+
27
+ /**
28
+ * Transport exceptions
29
+ */
30
+ class TTransportException extends TException {
31
+
32
+ const UNKNOWN = 0;
33
+ const NOT_OPEN = 1;
34
+ const ALREADY_OPEN = 2;
35
+ const TIMED_OUT = 3;
36
+ const END_OF_FILE = 4;
37
+
38
+ function __construct($message=null, $code=0) {
39
+ parent::__construct($message, $code);
40
+ }
41
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Factory/TBinaryProtocolFactory.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ */
22
+
23
+ namespace Thrift\Factory;
24
+
25
+ use Thrift\Factory\TProtocolFactory;
26
+ use Thrift\Protocol\TBinaryProtocol;
27
+
28
+ /**
29
+ * Binary Protocol Factory
30
+ */
31
+ class TBinaryProtocolFactory implements TProtocolFactory {
32
+ private $strictRead_ = false;
33
+ private $strictWrite_ = false;
34
+
35
+ public function __construct($strictRead=false, $strictWrite=false) {
36
+ $this->strictRead_ = $strictRead;
37
+ $this->strictWrite_ = $strictWrite;
38
+ }
39
+
40
+ public function getProtocol($trans) {
41
+ return new TBinaryProtocol($trans, $this->strictRead_, $this->strictWrite_);
42
+ }
43
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Factory/TCompactProtocolFactory.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ */
22
+
23
+ namespace Thrift\Factory;
24
+
25
+ use Thrift\Factory\TProtocolFactory;
26
+ use Thrift\Protocol\TCompactProtocol;
27
+
28
+ /**
29
+ * Compact Protocol Factory
30
+ */
31
+ class TCompactProtocolFactory implements TProtocolFactory {
32
+
33
+ public function __construct() {
34
+ }
35
+
36
+ public function getProtocol($trans) {
37
+ return new TCompactProtocol($trans);
38
+ }
39
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Factory/TJSONProtocolFactory.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ */
22
+
23
+ namespace Thrift\Factory;
24
+
25
+ use Thrift\Factory\TProtocolFactory;
26
+ use Thrift\Protocol\TJSONProtocol;
27
+
28
+ /**
29
+ * JSON Protocol Factory
30
+ */
31
+ class TJSONProtocolFactory implements TProtocolFactory
32
+ {
33
+ public function __construct()
34
+ {
35
+ }
36
+
37
+ public function getProtocol($trans)
38
+ {
39
+ return new TJSONProtocol($trans);
40
+ }
41
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Factory/TProtocolFactory.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ */
22
+
23
+ namespace Thrift\Factory;
24
+
25
+ /**
26
+ * Protocol factory creates protocol objects from transports
27
+ */
28
+ interface TProtocolFactory {
29
+ /**
30
+ * Build a protocol from the base transport
31
+ *
32
+ * @return Thrift\Protocol\TProtocol protocol
33
+ */
34
+ public function getProtocol($trans);
35
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Factory/TStringFuncFactory.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ */
21
+
22
+ namespace Thrift\Factory;
23
+
24
+ use Thrift\StringFunc\Mbstring;
25
+ use Thrift\StringFunc\Core;
26
+
27
+ class TStringFuncFactory {
28
+ private static $_instance;
29
+
30
+ /**
31
+ * Get the Singleton instance of TStringFunc implementation that is
32
+ * compatible with the current system's mbstring.func_overload settings.
33
+ *
34
+ * @return TStringFunc
35
+ */
36
+ public static function create() {
37
+ if(!self::$_instance) {
38
+ self::_setInstance();
39
+ }
40
+
41
+ return self::$_instance;
42
+ }
43
+
44
+ private static function _setInstance() {
45
+ /**
46
+ * Cannot use str* functions for byte counting because multibyte
47
+ * characters will be read a single bytes.
48
+ *
49
+ * See: http://us.php.net/manual/en/mbstring.overload.php
50
+ */
51
+ if(ini_get('mbstring.func_overload') & 2) {
52
+ self::$_instance = new Mbstring();
53
+ }
54
+ /**
55
+ * mbstring is not installed or does not have function overloading
56
+ * of the str* functions enabled so use PHP core str* functions for
57
+ * byte counting.
58
+ */
59
+ else {
60
+ self::$_instance = new Core();
61
+ }
62
+ }
63
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Factory/TTransportFactory.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Thrift\Factory;
4
+
5
+ use Thrift\Transport\TTransport;
6
+
7
+ class TTransportFactory {
8
+ /**
9
+ * @static
10
+ * @param TTransport $transport
11
+ * @return TTransport
12
+ */
13
+ public static function getTransport(TTransport $transport) {
14
+ return $transport;
15
+ }
16
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/HttpP13n.php ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class P13n
5
+ * @method \com\boxalino\p13n\api\thrift\ChoiceResponse choose(\com\boxalino\p13n\api\thrift\ChoiceRequest $choiceRequest)
6
+ */
7
+ class HttpP13n
8
+ {
9
+ protected static $thriftClassLoader = null;
10
+ protected $dependencies = array(
11
+ '../../P13nService.php',
12
+ '../../Types.php',
13
+ );
14
+ protected $client = null;
15
+ protected $transport = null;
16
+ protected $host;
17
+ protected $port = 443;
18
+ protected $uri = '/p13n.web/p13n';
19
+ protected $schema = 'https';
20
+ protected $username;
21
+ protected $password;
22
+
23
+ /**
24
+ *
25
+ */
26
+ public function __construct()
27
+ {
28
+ if (self::$thriftClassLoader === null) {
29
+ $this->initClassLoader();
30
+ }
31
+ }
32
+
33
+ public function __call($name, $arguments)
34
+ {
35
+ if (method_exists($this->getClient(), $name)) {
36
+ if (isset($arguments[0])) {
37
+ $arguments[0] = $this->addRequestContext($arguments[0]);
38
+ }
39
+
40
+ return call_user_func_array(array($this->getClient(), $name), $arguments);
41
+ } else {
42
+ throw new Exception("Method $name not supported in P13nService");
43
+ }
44
+ }
45
+
46
+ /**
47
+ * @param string $accountname
48
+ * @param string $cookieDomain
49
+ * @return string
50
+ */
51
+ public function getChoiceRequest($accountname, $cookieDomain = null)
52
+ {
53
+ $choiceRequest = new \com\boxalino\p13n\api\thrift\ChoiceRequest();
54
+
55
+ // Setup information about account
56
+ $userRecord = new \com\boxalino\p13n\api\thrift\UserRecord();
57
+ $userRecord->username = $accountname;
58
+ $choiceRequest->userRecord = $userRecord;
59
+
60
+ // Setup request context
61
+ $sessionid = $this->getSessionId();
62
+ $profileid = $this->getVisitorId();
63
+
64
+ $choiceRequest->profileId = $profileid;
65
+
66
+ // Refresh cookies
67
+ if(empty($cookieDomain)) {
68
+ setcookie('cems', $sessionid, 0);
69
+ setcookie('cemv', $profileid, time() + 1800);
70
+ } else {
71
+ setcookie('cems', $sessionid, 0, '/', $cookieDomain);
72
+ setcookie('cemv', $profileid, time() + 1800, '/', $cookieDomain);
73
+ }
74
+
75
+ return $choiceRequest;
76
+ }
77
+
78
+ /**
79
+ * @return \com\boxalino\p13n\api\thrift\P13nServiceClient
80
+ */
81
+ protected function getClient()
82
+ {
83
+ if ($this->client === null || $this->transport === null) {
84
+ $this->transport = new \Thrift\Transport\P13nTHttpClient($this->host, $this->port, $this->uri, $this->schema);
85
+ $this->transport->setAuthorization($this->username, $this->password);
86
+ $this->client = new \com\boxalino\p13n\api\thrift\P13nServiceClient(new \Thrift\Protocol\TCompactProtocol($this->transport));
87
+ }
88
+ return $this->client;
89
+ }
90
+
91
+ /**
92
+ * @param string $username
93
+ * @param string $password
94
+ */
95
+ public function setAuthorization($username, $password)
96
+ {
97
+ $this->username = $username;
98
+ $this->password = $password;
99
+ $this->transport = null;
100
+ }
101
+
102
+ /**
103
+ * @param string $host
104
+ */
105
+ public function setHost($host)
106
+ {
107
+ $this->host = $host;
108
+ $this->transport = null;
109
+ }
110
+
111
+ /**
112
+ * @param int $port
113
+ */
114
+ public function setPort($port)
115
+ {
116
+ $this->port = $port;
117
+ $this->transport = null;
118
+ }
119
+
120
+ /**
121
+ * @param string $schema
122
+ */
123
+ public function setSchema($schema)
124
+ {
125
+ $this->schema = $schema;
126
+ $this->transport = null;
127
+ }
128
+
129
+ /**
130
+ *
131
+ */
132
+ protected function initClassLoader()
133
+ {
134
+ require_once __DIR__ . DIRECTORY_SEPARATOR . 'ClassLoader' . DIRECTORY_SEPARATOR . 'ThriftClassLoader.php';
135
+ self::$thriftClassLoader = new \Thrift\ClassLoader\ThriftClassLoader(false);
136
+ self::$thriftClassLoader->registerNamespace('Thrift', __DIR__ . DIRECTORY_SEPARATOR . '..');
137
+ self::$thriftClassLoader->register();
138
+ foreach ($this->dependencies as $dependency) {
139
+ require_once __DIR__ . DIRECTORY_SEPARATOR . $dependency;
140
+ }
141
+ }
142
+
143
+ /**
144
+ * @return \com\boxalino\p13n\api\thrift\RequestContext
145
+ */
146
+ protected function getRequestContext()
147
+ {
148
+ $requestContext = new \com\boxalino\p13n\api\thrift\RequestContext();
149
+ $requestContext->parameters = array(
150
+ 'User-Agent' => array(@$_SERVER['HTTP_USER_AGENT']),
151
+ 'User-Host' => array($this->getIP()),
152
+ 'User-SessionId' => array($this->getSessionId()),
153
+ 'User-Referer' => array(@$_SERVER['HTTP_REFERER']),
154
+ 'User-URL' => array($this->getCurrentURL())
155
+ );
156
+
157
+ return $requestContext;
158
+ }
159
+
160
+ /**
161
+ * @return string
162
+ */
163
+ protected function getIP()
164
+ {
165
+ $ip = null;
166
+ $clientip = @$_SERVER['HTTP_CLIENT_IP'];
167
+ $forwardedip = @$_SERVER['HTTP_X_FORWARDED_FOR'];
168
+ if (filter_var($clientip, FILTER_VALIDATE_IP)) {
169
+ $ip = $clientip;
170
+ } elseif (filter_var($forwardedip, FILTER_VALIDATE_IP)) {
171
+ $ip = $forwardedip;
172
+ } else {
173
+ $ip = @$_SERVER['REMOTE_ADDR'];
174
+ }
175
+
176
+ return $ip;
177
+ }
178
+
179
+ /**
180
+ * @return string
181
+ */
182
+ protected function getSessionId()
183
+ {
184
+ $sessionid = null;
185
+ if (empty($_COOKIE['cems'])) {
186
+ $sessionid = session_id();
187
+ if (empty($sessionid)) {
188
+ session_start();
189
+ $sessionid = session_id();
190
+ }
191
+ } else {
192
+ $sessionid = $_COOKIE['cems'];
193
+ }
194
+
195
+ return $sessionid;
196
+ }
197
+
198
+ /**
199
+ * @return string
200
+ */
201
+ protected function getVisitorId()
202
+ {
203
+ $profileid = null;
204
+ if (empty($_COOKIE['cemv'])) {
205
+ $profileid = '';
206
+ if (function_exists('openssl_random_pseudo_bytes')) {
207
+ $profileid = bin2hex(openssl_random_pseudo_bytes(16));
208
+ }
209
+ if (empty($profileid)) {
210
+ $profileid = uniqid('', true);
211
+ }
212
+ } else {
213
+ $profileid = $_COOKIE['cemv'];
214
+ }
215
+
216
+ return $profileid;
217
+ }
218
+
219
+ /**
220
+ * @return string
221
+ */
222
+ protected function getCurrentURL()
223
+ {
224
+ $protocol = strpos(strtolower(@$_SERVER['SERVER_PROTOCOL']), 'https') === false ? 'http' : 'https';
225
+ $hostname = @$_SERVER['HTTP_HOST'];
226
+ $requesturi = @$_SERVER['REQUEST_URI'];
227
+
228
+ return $protocol . '://' . $hostname . $requesturi;
229
+ }
230
+
231
+ /**
232
+ * @param \com\boxalino\p13n\api\thrift\AutocompleteRequest|\com\boxalino\p13n\api\thrift\ChoiceRequest|\com\boxalino\p13n\api\thrift\BatchChoiceRequest $request
233
+ * @return \com\boxalino\p13n\api\thrift\AutocompleteRequest|\com\boxalino\p13n\api\thrift\ChoiceRequest|\com\boxalino\p13n\api\thrift\BatchChoiceRequest
234
+ */
235
+ private function addRequestContext($request)
236
+ {
237
+ if (
238
+ $request instanceof \com\boxalino\p13n\api\thrift\AutocompleteRequest ||
239
+ $request instanceof \com\boxalino\p13n\api\thrift\ChoiceRequest ||
240
+ $request instanceof \com\boxalino\p13n\api\thrift\BatchChoiceRequest
241
+ ) {
242
+ if ($request->requestContext === null) {
243
+ $request->requestContext = $this->getRequestContext();
244
+ } else {
245
+ $requestContext = $this->getRequestContext();
246
+ foreach ($requestContext->parameters as $parameterName => $parameterValues) {
247
+ if (isset($request->requestContext->parameters[$parameterName])) {
248
+ continue;
249
+ }
250
+
251
+ $request->requestContext->parameters[$parameterName] = $parameterValues;
252
+ }
253
+ }
254
+ }
255
+
256
+ return $request;
257
+ }
258
+
259
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/JSON/BaseContext.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ */
22
+
23
+ namespace Thrift\Protocol\JSON;
24
+
25
+ class BaseContext
26
+ {
27
+ function escapeNum()
28
+ {
29
+ return false;
30
+ }
31
+
32
+ function write()
33
+ {
34
+ }
35
+
36
+ function read()
37
+ {
38
+ }
39
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/JSON/ListContext.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ */
22
+
23
+ namespace Thrift\Protocol\JSON;
24
+
25
+ use Thrift\Protocol\JSON\BaseContext;
26
+ use Thrift\Protocol\TJSONProtocol;
27
+
28
+ class ListContext extends BaseContext
29
+ {
30
+ private $first_ = true;
31
+ private $p_;
32
+
33
+ public function __construct($p) {
34
+ $this->p_ = $p;
35
+ }
36
+
37
+ public function write() {
38
+ if ($this->first_) {
39
+ $this->first_ = false;
40
+ } else {
41
+ $this->p_->getTransport()->write(TJSONProtocol::COMMA);
42
+ }
43
+ }
44
+
45
+ public function read() {
46
+ if ($this->first_) {
47
+ $this->first_ = false;
48
+ } else {
49
+ $this->p_->readJSONSyntaxChar(TJSONProtocol::COMMA);
50
+ }
51
+ }
52
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/JSON/LookaheadReader.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ */
22
+
23
+ namespace Thrift\Protocol\JSON;
24
+
25
+ class LookaheadReader
26
+ {
27
+ private $hasData_ = false;
28
+ private $data_ = array();
29
+ private $p_;
30
+
31
+ public function __construct($p)
32
+ {
33
+ $this->p_ = $p;
34
+ }
35
+
36
+ public function read() {
37
+ if ($this->hasData_) {
38
+ $this->hasData_ = false;
39
+ } else {
40
+ $this->data_ = $this->p_->getTransport()->readAll(1);
41
+ }
42
+
43
+ return substr($this->data_, 0, 1);
44
+ }
45
+
46
+ public function peek() {
47
+ if (!$this->hasData_) {
48
+ $this->data_ = $this->p_->getTransport()->readAll(1);
49
+ }
50
+
51
+ $this->hasData_ = true;
52
+ return substr($this->data_, 0, 1);
53
+ }
54
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/JSON/PairContext.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ */
22
+
23
+ namespace Thrift\Protocol\JSON;
24
+
25
+ use Thrift\Protocol\JSON\BaseContext;
26
+ use Thrift\Protocol\TJSONProtocol;
27
+
28
+ class PairContext extends BaseContext {
29
+ private $first_ = true;
30
+ private $colon_ = true;
31
+ private $p_ = null;
32
+
33
+ public function __construct($p) {
34
+ $this->p_ = $p;
35
+ }
36
+
37
+ public function write() {
38
+ if ($this->first_) {
39
+ $this->first_ = false;
40
+ $this->colon_ = true;
41
+ } else {
42
+ $this->p_->getTransport()->write($this->colon_ ? TJSONProtocol::COLON : TJSONProtocol::COMMA);
43
+ $this->colon_ = !$this->colon_;
44
+ }
45
+ }
46
+
47
+ public function read() {
48
+ if ($this->first_) {
49
+ $this->first_ = false;
50
+ $this->colon_ = true;
51
+ } else {
52
+ $this->p_->readJSONSyntaxChar($this->colon_ ? TJSONProtocol::COLON : TJSONProtocol::COMMA);
53
+ $this->colon_ = !$this->colon_;
54
+ }
55
+ }
56
+
57
+ public function escapeNum() {
58
+ return $this->colon_;
59
+ }
60
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/TBinaryProtocol.php ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ */
22
+
23
+ namespace Thrift\Protocol;
24
+
25
+ use Thrift\Protocol\TProtocol;
26
+ use Thrift\Type\TType;
27
+ use Thrift\Exception\TProtocolException;
28
+ use Thrift\Factory\TStringFuncFactory;
29
+
30
+ /**
31
+ * Binary implementation of the Thrift protocol.
32
+ *
33
+ */
34
+ class TBinaryProtocol extends TProtocol {
35
+
36
+ const VERSION_MASK = 0xffff0000;
37
+ const VERSION_1 = 0x80010000;
38
+
39
+ protected $strictRead_ = false;
40
+ protected $strictWrite_ = true;
41
+
42
+ public function __construct($trans, $strictRead=false, $strictWrite=true) {
43
+ parent::__construct($trans);
44
+ $this->strictRead_ = $strictRead;
45
+ $this->strictWrite_ = $strictWrite;
46
+ }
47
+
48
+ public function writeMessageBegin($name, $type, $seqid) {
49
+ if ($this->strictWrite_) {
50
+ $version = self::VERSION_1 | $type;
51
+ return
52
+ $this->writeI32($version) +
53
+ $this->writeString($name) +
54
+ $this->writeI32($seqid);
55
+ } else {
56
+ return
57
+ $this->writeString($name) +
58
+ $this->writeByte($type) +
59
+ $this->writeI32($seqid);
60
+ }
61
+ }
62
+
63
+ public function writeMessageEnd() {
64
+ return 0;
65
+ }
66
+
67
+ public function writeStructBegin($name) {
68
+ return 0;
69
+ }
70
+
71
+ public function writeStructEnd() {
72
+ return 0;
73
+ }
74
+
75
+ public function writeFieldBegin($fieldName, $fieldType, $fieldId) {
76
+ return
77
+ $this->writeByte($fieldType) +
78
+ $this->writeI16($fieldId);
79
+ }
80
+
81
+ public function writeFieldEnd() {
82
+ return 0;
83
+ }
84
+
85
+ public function writeFieldStop() {
86
+ return
87
+ $this->writeByte(TType::STOP);
88
+ }
89
+
90
+ public function writeMapBegin($keyType, $valType, $size) {
91
+ return
92
+ $this->writeByte($keyType) +
93
+ $this->writeByte($valType) +
94
+ $this->writeI32($size);
95
+ }
96
+
97
+ public function writeMapEnd() {
98
+ return 0;
99
+ }
100
+
101
+ public function writeListBegin($elemType, $size) {
102
+ return
103
+ $this->writeByte($elemType) +
104
+ $this->writeI32($size);
105
+ }
106
+
107
+ public function writeListEnd() {
108
+ return 0;
109
+ }
110
+
111
+ public function writeSetBegin($elemType, $size) {
112
+ return
113
+ $this->writeByte($elemType) +
114
+ $this->writeI32($size);
115
+ }
116
+
117
+ public function writeSetEnd() {
118
+ return 0;
119
+ }
120
+
121
+ public function writeBool($value) {
122
+ $data = pack('c', $value ? 1 : 0);
123
+ $this->trans_->write($data, 1);
124
+ return 1;
125
+ }
126
+
127
+ public function writeByte($value) {
128
+ $data = pack('c', $value);
129
+ $this->trans_->write($data, 1);
130
+ return 1;
131
+ }
132
+
133
+ public function writeI16($value) {
134
+ $data = pack('n', $value);
135
+ $this->trans_->write($data, 2);
136
+ return 2;
137
+ }
138
+
139
+ public function writeI32($value) {
140
+ $data = pack('N', $value);
141
+ $this->trans_->write($data, 4);
142
+ return 4;
143
+ }
144
+
145
+ public function writeI64($value) {
146
+ // If we are on a 32bit architecture we have to explicitly deal with
147
+ // 64-bit twos-complement arithmetic since PHP wants to treat all ints
148
+ // as signed and any int over 2^31 - 1 as a float
149
+ if (PHP_INT_SIZE == 4) {
150
+ $neg = $value < 0;
151
+
152
+ if ($neg) {
153
+ $value *= -1;
154
+ }
155
+
156
+ $hi = (int)($value / 4294967296);
157
+ $lo = (int)$value;
158
+
159
+ if ($neg) {
160
+ $hi = ~$hi;
161
+ $lo = ~$lo;
162
+ if (($lo & (int)0xffffffff) == (int)0xffffffff) {
163
+ $lo = 0;
164
+ $hi++;
165
+ } else {
166
+ $lo++;
167
+ }
168
+ }
169
+ $data = pack('N2', $hi, $lo);
170
+
171
+ } else {
172
+ $hi = $value >> 32;
173
+ $lo = $value & 0xFFFFFFFF;
174
+ $data = pack('N2', $hi, $lo);
175
+ }
176
+
177
+ $this->trans_->write($data, 8);
178
+ return 8;
179
+ }
180
+
181
+ public function writeDouble($value) {
182
+ $data = pack('d', $value);
183
+ $this->trans_->write(strrev($data), 8);
184
+ return 8;
185
+ }
186
+
187
+ public function writeString($value) {
188
+ $len = TStringFuncFactory::create()->strlen($value);
189
+ $result = $this->writeI32($len);
190
+ if ($len) {
191
+ $this->trans_->write($value, $len);
192
+ }
193
+ return $result + $len;
194
+ }
195
+
196
+ public function readMessageBegin(&$name, &$type, &$seqid) {
197
+ $result = $this->readI32($sz);
198
+ if ($sz < 0) {
199
+ $version = (int) ($sz & self::VERSION_MASK);
200
+ if ($version != (int) self::VERSION_1) {
201
+ throw new TProtocolException('Bad version identifier: '.$sz, TProtocolException::BAD_VERSION);
202
+ }
203
+ $type = $sz & 0x000000ff;
204
+ $result +=
205
+ $this->readString($name) +
206
+ $this->readI32($seqid);
207
+ } else {
208
+ if ($this->strictRead_) {
209
+ throw new TProtocolException('No version identifier, old protocol client?', TProtocolException::BAD_VERSION);
210
+ } else {
211
+ // Handle pre-versioned input
212
+ $name = $this->trans_->readAll($sz);
213
+ $result +=
214
+ $sz +
215
+ $this->readByte($type) +
216
+ $this->readI32($seqid);
217
+ }
218
+ }
219
+ return $result;
220
+ }
221
+
222
+ public function readMessageEnd() {
223
+ return 0;
224
+ }
225
+
226
+ public function readStructBegin(&$name) {
227
+ $name = '';
228
+ return 0;
229
+ }
230
+
231
+ public function readStructEnd() {
232
+ return 0;
233
+ }
234
+
235
+ public function readFieldBegin(&$name, &$fieldType, &$fieldId) {
236
+ $result = $this->readByte($fieldType);
237
+ if ($fieldType == TType::STOP) {
238
+ $fieldId = 0;
239
+ return $result;
240
+ }
241
+ $result += $this->readI16($fieldId);
242
+ return $result;
243
+ }
244
+
245
+ public function readFieldEnd() {
246
+ return 0;
247
+ }
248
+
249
+ public function readMapBegin(&$keyType, &$valType, &$size) {
250
+ return
251
+ $this->readByte($keyType) +
252
+ $this->readByte($valType) +
253
+ $this->readI32($size);
254
+ }
255
+
256
+ public function readMapEnd() {
257
+ return 0;
258
+ }
259
+
260
+ public function readListBegin(&$elemType, &$size) {
261
+ return
262
+ $this->readByte($elemType) +
263
+ $this->readI32($size);
264
+ }
265
+
266
+ public function readListEnd() {
267
+ return 0;
268
+ }
269
+
270
+ public function readSetBegin(&$elemType, &$size) {
271
+ return
272
+ $this->readByte($elemType) +
273
+ $this->readI32($size);
274
+ }
275
+
276
+ public function readSetEnd() {
277
+ return 0;
278
+ }
279
+
280
+ public function readBool(&$value) {
281
+ $data = $this->trans_->readAll(1);
282
+ $arr = unpack('c', $data);
283
+ $value = $arr[1] == 1;
284
+ return 1;
285
+ }
286
+
287
+ public function readByte(&$value) {
288
+ $data = $this->trans_->readAll(1);
289
+ $arr = unpack('c', $data);
290
+ $value = $arr[1];
291
+ return 1;
292
+ }
293
+
294
+ public function readI16(&$value) {
295
+ $data = $this->trans_->readAll(2);
296
+ $arr = unpack('n', $data);
297
+ $value = $arr[1];
298
+ if ($value > 0x7fff) {
299
+ $value = 0 - (($value - 1) ^ 0xffff);
300
+ }
301
+ return 2;
302
+ }
303
+
304
+ public function readI32(&$value) {
305
+ $data = $this->trans_->readAll(4);
306
+ $arr = unpack('N', $data);
307
+ $value = $arr[1];
308
+ if ($value > 0x7fffffff) {
309
+ $value = 0 - (($value - 1) ^ 0xffffffff);
310
+ }
311
+ return 4;
312
+ }
313
+
314
+ public function readI64(&$value) {
315
+ $data = $this->trans_->readAll(8);
316
+
317
+ $arr = unpack('N2', $data);
318
+
319
+ // If we are on a 32bit architecture we have to explicitly deal with
320
+ // 64-bit twos-complement arithmetic since PHP wants to treat all ints
321
+ // as signed and any int over 2^31 - 1 as a float
322
+ if (PHP_INT_SIZE == 4) {
323
+
324
+ $hi = $arr[1];
325
+ $lo = $arr[2];
326
+ $isNeg = $hi < 0;
327
+
328
+ // Check for a negative
329
+ if ($isNeg) {
330
+ $hi = ~$hi & (int)0xffffffff;
331
+ $lo = ~$lo & (int)0xffffffff;
332
+
333
+ if ($lo == (int)0xffffffff) {
334
+ $hi++;
335
+ $lo = 0;
336
+ } else {
337
+ $lo++;
338
+ }
339
+ }
340
+
341
+ // Force 32bit words in excess of 2G to pe positive - we deal wigh sign
342
+ // explicitly below
343
+
344
+ if ($hi & (int)0x80000000) {
345
+ $hi &= (int)0x7fffffff;
346
+ $hi += 0x80000000;
347
+ }
348
+
349
+ if ($lo & (int)0x80000000) {
350
+ $lo &= (int)0x7fffffff;
351
+ $lo += 0x80000000;
352
+ }
353
+
354
+ $value = $hi * 4294967296 + $lo;
355
+
356
+ if ($isNeg) {
357
+ $value = 0 - $value;
358
+ }
359
+ } else {
360
+
361
+ // Upcast negatives in LSB bit
362
+ if ($arr[2] & 0x80000000) {
363
+ $arr[2] = $arr[2] & 0xffffffff;
364
+ }
365
+
366
+ // Check for a negative
367
+ if ($arr[1] & 0x80000000) {
368
+ $arr[1] = $arr[1] & 0xffffffff;
369
+ $arr[1] = $arr[1] ^ 0xffffffff;
370
+ $arr[2] = $arr[2] ^ 0xffffffff;
371
+ $value = 0 - $arr[1]*4294967296 - $arr[2] - 1;
372
+ } else {
373
+ $value = $arr[1]*4294967296 + $arr[2];
374
+ }
375
+ }
376
+
377
+ return 8;
378
+ }
379
+
380
+ public function readDouble(&$value) {
381
+ $data = strrev($this->trans_->readAll(8));
382
+ $arr = unpack('d', $data);
383
+ $value = $arr[1];
384
+ return 8;
385
+ }
386
+
387
+ public function readString(&$value) {
388
+ $result = $this->readI32($len);
389
+ if ($len) {
390
+ $value = $this->trans_->readAll($len);
391
+ } else {
392
+ $value = '';
393
+ }
394
+ return $result + $len;
395
+ }
396
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/TBinaryProtocolAccelerated.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ */
22
+
23
+ namespace Thrift\Protocol;
24
+
25
+ use Thrift\Protocol\TBinaryProtocol;
26
+ use Thrift\Transport\TBufferedTransport;
27
+
28
+ /**
29
+ * Accelerated binary protocol: used in conjunction with the thrift_protocol
30
+ * extension for faster deserialization
31
+ */
32
+ class TBinaryProtocolAccelerated extends TBinaryProtocol {
33
+ public function __construct($trans, $strictRead=false, $strictWrite=true) {
34
+ // If the transport doesn't implement putBack, wrap it in a
35
+ // TBufferedTransport (which does)
36
+ if (!method_exists($trans, 'putBack')) {
37
+ $trans = new TBufferedTransport($trans);
38
+ }
39
+ parent::__construct($trans, $strictRead, $strictWrite);
40
+ }
41
+ public function isStrictRead() {
42
+ return $this->strictRead_;
43
+ }
44
+ public function isStrictWrite() {
45
+ return $this->strictWrite_;
46
+ }
47
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/TCompactProtocol.php ADDED
@@ -0,0 +1,669 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ */
22
+
23
+ namespace Thrift\Protocol;
24
+
25
+ use Thrift\Protocol\TProtocol;
26
+ use Thrift\Type\TType;
27
+ use Thrift\Exception\TProtocolException;
28
+ use Thrift\Factory\TStringFuncFactory;
29
+
30
+ /**
31
+ * Compact implementation of the Thrift protocol.
32
+ *
33
+ */
34
+ class TCompactProtocol extends TProtocol {
35
+
36
+ const COMPACT_STOP = 0x00;
37
+ const COMPACT_TRUE = 0x01;
38
+ const COMPACT_FALSE = 0x02;
39
+ const COMPACT_BYTE = 0x03;
40
+ const COMPACT_I16 = 0x04;
41
+ const COMPACT_I32 = 0x05;
42
+ const COMPACT_I64 = 0x06;
43
+ const COMPACT_DOUBLE = 0x07;
44
+ const COMPACT_BINARY = 0x08;
45
+ const COMPACT_LIST = 0x09;
46
+ const COMPACT_SET = 0x0A;
47
+ const COMPACT_MAP = 0x0B;
48
+ const COMPACT_STRUCT = 0x0C;
49
+
50
+ const STATE_CLEAR = 0;
51
+ const STATE_FIELD_WRITE = 1;
52
+ const STATE_VALUE_WRITE = 2;
53
+ const STATE_CONTAINER_WRITE = 3;
54
+ const STATE_BOOL_WRITE = 4;
55
+ const STATE_FIELD_READ = 5;
56
+ const STATE_CONTAINER_READ = 6;
57
+ const STATE_VALUE_READ = 7;
58
+ const STATE_BOOL_READ = 8;
59
+
60
+ const VERSION_MASK = 0x1f;
61
+ const VERSION = 1;
62
+ const PROTOCOL_ID = 0x82;
63
+ const TYPE_MASK = 0xe0;
64
+ const TYPE_SHIFT_AMOUNT = 5;
65
+
66
+ protected static $ctypes = array(
67
+ TType::STOP => TCompactProtocol::COMPACT_STOP,
68
+ TType::BOOL => TCompactProtocol::COMPACT_TRUE, // used for collection
69
+ TType::BYTE => TCompactProtocol::COMPACT_BYTE,
70
+ TType::I16 => TCompactProtocol::COMPACT_I16,
71
+ TType::I32 => TCompactProtocol::COMPACT_I32,
72
+ TType::I64 => TCompactProtocol::COMPACT_I64,
73
+ TType::DOUBLE => TCompactProtocol::COMPACT_DOUBLE,
74
+ TType::STRING => TCompactProtocol::COMPACT_BINARY,
75
+ TType::STRUCT => TCompactProtocol::COMPACT_STRUCT,
76
+ TType::LST => TCompactProtocol::COMPACT_LIST,
77
+ TType::SET => TCompactProtocol::COMPACT_SET,
78
+ TType::MAP => TCompactProtocol::COMPACT_MAP,
79
+ );
80
+
81
+ protected static $ttypes = array(
82
+ TCompactProtocol::COMPACT_STOP => TType::STOP ,
83
+ TCompactProtocol::COMPACT_TRUE => TType::BOOL, // used for collection
84
+ TCompactProtocol::COMPACT_FALSE => TType::BOOL,
85
+ TCompactProtocol::COMPACT_BYTE => TType::BYTE,
86
+ TCompactProtocol::COMPACT_I16 => TType::I16,
87
+ TCompactProtocol::COMPACT_I32 => TType::I32,
88
+ TCompactProtocol::COMPACT_I64 => TType::I64,
89
+ TCompactProtocol::COMPACT_DOUBLE => TType::DOUBLE,
90
+ TCompactProtocol::COMPACT_BINARY => TType::STRING,
91
+ TCompactProtocol::COMPACT_STRUCT => TType::STRUCT,
92
+ TCompactProtocol::COMPACT_LIST => TType::LST,
93
+ TCompactProtocol::COMPACT_SET => TType::SET,
94
+ TCompactProtocol::COMPACT_MAP => TType::MAP,
95
+ );
96
+
97
+ protected $state = TCompactProtocol::STATE_CLEAR;
98
+ protected $lastFid = 0;
99
+ protected $boolFid = null;
100
+ protected $boolValue = null;
101
+ protected $structs = array();
102
+ protected $containers = array();
103
+
104
+ // Some varint / zigzag helper methods
105
+ public function toZigZag($n, $bits) {
106
+ return ($n << 1) ^ ($n >> ($bits - 1));
107
+ }
108
+
109
+ public function fromZigZag($n) {
110
+ return ($n >> 1) ^ -($n & 1);
111
+ }
112
+
113
+ public function getVarint($data) {
114
+ $out = "";
115
+ while (true) {
116
+ if (($data & ~0x7f) === 0) {
117
+ $out .= chr($data);
118
+ break;
119
+ } else {
120
+ $out .= chr(($data & 0xff) | 0x80);
121
+ $data = $data >> 7;
122
+ }
123
+ }
124
+ return $out;
125
+ }
126
+
127
+ public function writeVarint($data) {
128
+ $out = $this->getVarint($data);
129
+ $result = TStringFuncFactory::create()->strlen($out);
130
+ $this->trans_->write($out, $result);
131
+ return $result;
132
+ }
133
+
134
+ public function readVarint(&$result) {
135
+ $idx = 0;
136
+ $shift = 0;
137
+ $result = 0;
138
+ while (true) {
139
+ $x = $this->trans_->readAll(1);
140
+ $arr = unpack('C', $x);
141
+ $byte = $arr[1];
142
+ $idx += 1;
143
+ $result |= ($byte & 0x7f) << $shift;
144
+ if (($byte >> 7) === 0) {
145
+ return $idx;
146
+ }
147
+ $shift += 7;
148
+ }
149
+
150
+ return $idx;
151
+ }
152
+
153
+ public function __construct($trans) {
154
+ parent::__construct($trans);
155
+ }
156
+
157
+ public function writeMessageBegin($name, $type, $seqid) {
158
+ $written =
159
+ $this->writeUByte(TCompactProtocol::PROTOCOL_ID) +
160
+ $this->writeUByte(TCompactProtocol::VERSION |
161
+ ($type << TCompactProtocol::TYPE_SHIFT_AMOUNT)) +
162
+ $this->writeVarint($seqid) +
163
+ $this->writeString($name);
164
+ $this->state = TCompactProtocol::STATE_VALUE_WRITE;
165
+ return $written;
166
+ }
167
+
168
+ public function writeMessageEnd() {
169
+ $this->state = TCompactProtocol::STATE_CLEAR;
170
+ return 0;
171
+ }
172
+
173
+ public function writeStructBegin($name) {
174
+ $this->structs[] = array($this->state, $this->lastFid);
175
+ $this->state = TCompactProtocol::STATE_FIELD_WRITE;
176
+ $this->lastFid = 0;
177
+ return 0;
178
+ }
179
+
180
+ public function writeStructEnd() {
181
+ $old_values = array_pop($this->structs);
182
+ $this->state = $old_values[0];
183
+ $this->lastFid = $old_values[1];
184
+ return 0;
185
+ }
186
+
187
+ public function writeFieldStop() {
188
+ return $this->writeByte(0);
189
+ }
190
+
191
+ public function writeFieldHeader($type, $fid) {
192
+ $written = 0;
193
+ $delta = $fid - $this->lastFid;
194
+ if (0 < $delta && $delta <= 15) {
195
+ $written = $this->writeUByte(($delta << 4) | $type);
196
+ } else {
197
+ $written = $this->writeByte($type) +
198
+ $this->writeI16($fid);
199
+ }
200
+ $this->lastFid = $fid;
201
+ return $written;
202
+ }
203
+
204
+ public function writeFieldBegin($field_name, $field_type, $field_id) {
205
+ if ($field_type == TTYPE::BOOL) {
206
+ $this->state = TCompactProtocol::STATE_BOOL_WRITE;
207
+ $this->boolFid = $field_id;
208
+ return 0;
209
+ } else {
210
+ $this->state = TCompactProtocol::STATE_VALUE_WRITE;
211
+ return $this->writeFieldHeader(self::$ctypes[$field_type], $field_id);
212
+ }
213
+ }
214
+
215
+ public function writeFieldEnd() {
216
+ $this->state = TCompactProtocol::STATE_FIELD_WRITE;
217
+ return 0;
218
+ }
219
+
220
+ public function writeCollectionBegin($etype, $size) {
221
+ $written = 0;
222
+ if ($size <= 14) {
223
+ $written = $this->writeUByte($size << 4 |
224
+ self::$ctypes[$etype]);
225
+ } else {
226
+ $written = $this->writeUByte(0xf0 |
227
+ self::$ctypes[$etype]) +
228
+ $this->writeVarint($size);
229
+ }
230
+ $this->containers[] = $this->state;
231
+ $this->state = TCompactProtocol::STATE_CONTAINER_WRITE;
232
+
233
+ return $written;
234
+ }
235
+
236
+ public function writeMapBegin($key_type, $val_type, $size) {
237
+ $written = 0;
238
+ if ($size == 0) {
239
+ $written = $this->writeByte(0);
240
+ } else {
241
+ $written = $this->writeVarint($size) +
242
+ $this->writeUByte(self::$ctypes[$key_type] << 4 |
243
+ self::$ctypes[$val_type]);
244
+ }
245
+ $this->containers[] = $this->state;
246
+ return $written;
247
+ }
248
+
249
+ public function writeCollectionEnd() {
250
+ $this->state = array_pop($this->containers);
251
+ return 0;
252
+ }
253
+
254
+ public function writeMapEnd() {
255
+ return $this->writeCollectionEnd();
256
+ }
257
+
258
+ public function writeListBegin($elem_type, $size) {
259
+ return $this->writeCollectionBegin($elem_type, $size);
260
+ }
261
+
262
+ public function writeListEnd() {
263
+ return $this->writeCollectionEnd();
264
+ }
265
+
266
+ public function writeSetBegin($elem_type, $size) {
267
+ return $this->writeCollectionBegin($elem_type, $size);
268
+ }
269
+
270
+ public function writeSetEnd() {
271
+ return $this->writeCollectionEnd();
272
+ }
273
+
274
+ public function writeBool($value) {
275
+ if ($this->state == TCompactProtocol::STATE_BOOL_WRITE) {
276
+ $ctype = TCompactProtocol::COMPACT_FALSE;
277
+ if ($value) {
278
+ $ctype = TCompactProtocol::COMPACT_TRUE;
279
+ }
280
+ return $this->writeFieldHeader($ctype, $this->boolFid);
281
+ } else if ($this->state == TCompactProtocol::STATE_CONTAINER_WRITE) {
282
+ return $this->writeByte($value ? 1 : 0);
283
+ } else {
284
+ throw new TProtocolException('Invalid state in compact protocol');
285
+ }
286
+ }
287
+
288
+ public function writeByte($value) {
289
+ $data = pack('c', $value);
290
+ $this->trans_->write($data, 1);
291
+ return 1;
292
+ }
293
+
294
+ public function writeUByte($byte) {
295
+ $this->trans_->write(pack('C', $byte), 1);
296
+ return 1;
297
+ }
298
+
299
+ public function writeI16($value) {
300
+ $thing = $this->toZigZag($value, 16);
301
+ return $this->writeVarint($thing);
302
+ }
303
+
304
+ public function writeI32($value) {
305
+ $thing = $this->toZigZag($value, 32);
306
+ return $this->writeVarint($thing);
307
+ }
308
+
309
+ public function writeDouble($value) {
310
+ $data = pack('d', $value);
311
+ $this->trans_->write(strrev($data), 8);
312
+ return 8;
313
+ }
314
+
315
+ public function writeString($value) {
316
+ $len = TStringFuncFactory::create()->strlen($value);
317
+ $result = $this->writeVarint($len);
318
+ if ($len) {
319
+ $this->trans_->write($value, $len);
320
+ }
321
+ return $result + $len;
322
+ }
323
+
324
+ public function readFieldBegin(&$name, &$field_type, &$field_id) {
325
+ $result = $this->readUByte($field_type);
326
+
327
+ if (($field_type & 0x0f) == TType::STOP) {
328
+ $field_id = 0;
329
+ return $result;
330
+ }
331
+ $delta = $field_type >> 4;
332
+ if ($delta == 0) {
333
+ $result += $this->readI16($field_id);
334
+ } else {
335
+ $field_id = $this->lastFid + $delta;
336
+ }
337
+ $this->lastFid = $field_id;
338
+ $field_type = $this->getTType($field_type & 0x0f);
339
+ if ($field_type == TCompactProtocol::COMPACT_TRUE) {
340
+ $this->state = TCompactProtocol::STATE_BOOL_READ;
341
+ $this->boolValue = true;
342
+ } else if ($field_type == TCompactProtocol::COMPACT_FALSE) {
343
+ $this->state = TCompactProtocol::STATE_BOOL_READ;
344
+ $this->boolValue = false;
345
+ } else {
346
+ $this->state = TCompactProtocol::STATE_VALUE_READ;
347
+ }
348
+ return $result;
349
+ }
350
+
351
+ public function readFieldEnd() {
352
+ $this->state = TCompactProtocol::STATE_FIELD_READ;
353
+ return 0;
354
+ }
355
+
356
+ public function readUByte(&$value) {
357
+ $data = $this->trans_->readAll(1);
358
+ $arr = unpack('C', $data);
359
+ $value = $arr[1];
360
+ return 1;
361
+ }
362
+
363
+ public function readByte(&$value) {
364
+ $data = $this->trans_->readAll(1);
365
+ $arr = unpack('c', $data);
366
+ $value = $arr[1];
367
+ return 1;
368
+ }
369
+
370
+ public function readZigZag(&$value) {
371
+ $result = $this->readVarint($value);
372
+ $value = $this->fromZigZag($value);
373
+ return $result;
374
+ }
375
+
376
+ public function readMessageBegin(&$name, &$type, &$seqid) {
377
+ $protoId = 0;
378
+ $result = $this->readUByte($protoId);
379
+ if ($protoId != TCompactProtocol::PROTOCOL_ID) {
380
+ throw new TProtocolException('Bad protocol id in TCompact message');
381
+ }
382
+ $verType = 0;
383
+ $result += $this->readUByte($verType);
384
+ $type = ($verType & TCompactProtocol::TYPE_MASK) >>
385
+ TCompactProtocol::TYPE_SHIFT_AMOUNT;
386
+ $version = $verType & TCompactProtocol::VERSION_MASK;
387
+ if ($version != TCompactProtocol::VERSION) {
388
+ throw new TProtocolException('Bad version in TCompact message');
389
+ }
390
+ $result += $this->readVarint($seqId);
391
+ $name += $this->readString($name);
392
+
393
+ return $result;
394
+ }
395
+
396
+ public function readMessageEnd() {
397
+ return 0;
398
+ }
399
+
400
+ public function readStructBegin(&$name) {
401
+ $name = ''; // unused
402
+ $this->structs[] = array($this->state, $this->lastFid);
403
+ $this->state = TCompactProtocol::STATE_FIELD_READ;
404
+ $this->lastFid = 0;
405
+ return 0;
406
+ }
407
+
408
+ public function readStructEnd() {
409
+ $last = array_pop($this->structs);
410
+ $this->state = $last[0];
411
+ $this->lastFid = $last[1];
412
+ return 0;
413
+ }
414
+
415
+ public function readCollectionBegin(&$type, &$size) {
416
+ $sizeType = 0;
417
+ $result = $this->readUByte($sizeType);
418
+ $size = $sizeType >> 4;
419
+ $type = $this->getTType($sizeType);
420
+ if ($size == 15) {
421
+ $result += $this->readVarint($size);
422
+ }
423
+ $this->containers[] = $this->state;
424
+ $this->state = TCompactProtocol::STATE_CONTAINER_READ;
425
+
426
+ return $result;
427
+ }
428
+
429
+ public function readMapBegin(&$key_type, &$val_type, &$size) {
430
+ $result = $this->readVarint($size);
431
+ $types = 0;
432
+ if ($size > 0) {
433
+ $result += $this->readUByte($types);
434
+ }
435
+ $val_type = $this->getTType($types);
436
+ $key_type = $this->getTType($types >> 4);
437
+ $this->containers[] = $this->state;
438
+ $this->state = TCompactProtocol::STATE_CONTAINER_READ;
439
+
440
+ return $result;
441
+ }
442
+
443
+ public function readCollectionEnd() {
444
+ $this->state = array_pop($this->containers);
445
+ return 0;
446
+ }
447
+
448
+ public function readMapEnd() {
449
+ return $this->readCollectionEnd();
450
+ }
451
+
452
+ public function readListBegin(&$elem_type, &$size) {
453
+ return $this->readCollectionBegin($elem_type, $size);
454
+ }
455
+
456
+ public function readListEnd() {
457
+ return $this->readCollectionEnd();
458
+ }
459
+
460
+ public function readSetBegin(&$elem_type, &$size) {
461
+ return $this->readCollectionBegin($elem_type, $size);
462
+ }
463
+
464
+ public function readSetEnd() {
465
+ return $this->readCollectionEnd();
466
+ }
467
+
468
+ public function readBool(&$value) {
469
+ if ($this->state == TCompactProtocol::STATE_BOOL_READ) {
470
+ $value = $this->boolValue;
471
+ return 0;
472
+ } else if ($this->state == TCompactProtocol::STATE_CONTAINER_READ) {
473
+ return $this->readByte($value);
474
+ } else {
475
+ throw new TProtocolException('Invalid state in compact protocol');
476
+ }
477
+ }
478
+
479
+ public function readI16(&$value) {
480
+ return $this->readZigZag($value);
481
+ }
482
+
483
+ public function readI32(&$value) {
484
+ return $this->readZigZag($value);
485
+ }
486
+
487
+ public function readDouble(&$value) {
488
+ $data = strrev($this->trans_->readAll(8));
489
+ $arr = unpack('d', $data);
490
+ $value = $arr[1];
491
+ return 8;
492
+ }
493
+
494
+ public function readString(&$value) {
495
+ $result = $this->readVarint($len);
496
+ if ($len) {
497
+ $value = $this->trans_->readAll($len);
498
+ } else {
499
+ $value = '';
500
+ }
501
+ return $result + $len;
502
+ }
503
+
504
+ public function getTType($byte) {
505
+ return self::$ttypes[$byte & 0x0f];
506
+ }
507
+
508
+ // If we are on a 32bit architecture we have to explicitly deal with
509
+ // 64-bit twos-complement arithmetic since PHP wants to treat all ints
510
+ // as signed and any int over 2^31 - 1 as a float
511
+
512
+ // Read and write I64 as two 32 bit numbers $hi and $lo
513
+
514
+ public function readI64(&$value) {
515
+ // Read varint from wire
516
+ $hi = 0;
517
+ $lo = 0;
518
+
519
+ $idx = 0;
520
+ $shift = 0;
521
+
522
+ while (true) {
523
+ $x = $this->trans_->readAll(1);
524
+ $arr = unpack('C', $x);
525
+ $byte = $arr[1];
526
+ $idx += 1;
527
+ if ($shift < 32) {
528
+ $lo |= (($byte & 0x7f) << $shift) &
529
+ 0x00000000ffffffff;
530
+ }
531
+ // Shift hi and lo together.
532
+ if ($shift >= 32) {
533
+ $hi |= (($byte & 0x7f) << ($shift - 32));
534
+ } else if ($shift > 25) {
535
+ $hi |= (($byte & 0x7f) >> ($shift - 25));
536
+ }
537
+ if (($byte >> 7) === 0) {
538
+ break;
539
+ }
540
+ $shift += 7;
541
+ }
542
+
543
+ // Now, unzig it.
544
+ $xorer = 0;
545
+ if ($lo & 1) {
546
+ $xorer = 0xffffffff;
547
+ }
548
+ $lo = ($lo >> 1) & 0x7fffffff;
549
+ $lo = $lo | (($hi & 1) << 31);
550
+ $hi = ($hi >> 1) ^ $xorer;
551
+ $lo = $lo ^ $xorer;
552
+
553
+ // Now put $hi and $lo back together
554
+ if (true) {
555
+ $isNeg = $hi < 0;
556
+
557
+ // Check for a negative
558
+ if ($isNeg) {
559
+ $hi = ~$hi & (int)0xffffffff;
560
+ $lo = ~$lo & (int)0xffffffff;
561
+
562
+ if ($lo == (int)0xffffffff) {
563
+ $hi++;
564
+ $lo = 0;
565
+ } else {
566
+ $lo++;
567
+ }
568
+ }
569
+
570
+ // Force 32bit words in excess of 2G to be positive - we deal with sign
571
+ // explicitly below
572
+
573
+ if ($hi & (int)0x80000000) {
574
+ $hi &= (int)0x7fffffff;
575
+ $hi += 0x80000000;
576
+ }
577
+
578
+ if ($lo & (int)0x80000000) {
579
+ $lo &= (int)0x7fffffff;
580
+ $lo += 0x80000000;
581
+ }
582
+
583
+ $value = $hi * 4294967296 + $lo;
584
+
585
+ if ($isNeg) {
586
+ $value = 0 - $value;
587
+ }
588
+ } else {
589
+
590
+ // Upcast negatives in LSB bit
591
+ if ($arr[2] & 0x80000000) {
592
+ $arr[2] = $arr[2] & 0xffffffff;
593
+ }
594
+
595
+ // Check for a negative
596
+ if ($arr[1] & 0x80000000) {
597
+ $arr[1] = $arr[1] & 0xffffffff;
598
+ $arr[1] = $arr[1] ^ 0xffffffff;
599
+ $arr[2] = $arr[2] ^ 0xffffffff;
600
+ $value = 0 - $arr[1] * 4294967296 - $arr[2] - 1;
601
+ } else {
602
+ $value = $arr[1] * 4294967296 + $arr[2];
603
+ }
604
+ }
605
+
606
+ return $idx;
607
+ }
608
+
609
+ public function writeI64($value) {
610
+ // If we are in an I32 range, use the easy method below.
611
+ if (($value > 4294967296) || ($value < -4294967296)) {
612
+ // Convert $value to $hi and $lo
613
+ $neg = $value < 0;
614
+
615
+ if ($neg) {
616
+ $value *= -1;
617
+ }
618
+
619
+ $hi = (int)$value >> 32;
620
+ $lo = (int)$value & 0xffffffff;
621
+
622
+ if ($neg) {
623
+ $hi = ~$hi;
624
+ $lo = ~$lo;
625
+ if (($lo & (int)0xffffffff) == (int)0xffffffff) {
626
+ $lo = 0;
627
+ $hi++;
628
+ } else {
629
+ $lo++;
630
+ }
631
+ }
632
+
633
+ // Now do the zigging and zagging.
634
+ $xorer = 0;
635
+ if ($neg) {
636
+ $xorer = 0xffffffff;
637
+ }
638
+ $lowbit = ($lo >> 31) & 1;
639
+ $hi = ($hi << 1) | $lowbit;
640
+ $lo = ($lo << 1);
641
+ $lo = ($lo ^ $xorer) & 0xffffffff;
642
+ $hi = ($hi ^ $xorer) & 0xffffffff;
643
+
644
+ // now write out the varint, ensuring we shift both hi and lo
645
+ $out = "";
646
+ while (true) {
647
+ if (($lo & ~0x7f) === 0 &&
648
+ $hi === 0) {
649
+ $out .= chr($lo);
650
+ break;
651
+ } else {
652
+ $out .= chr(($lo & 0xff) | 0x80);
653
+ $lo = $lo >> 7;
654
+ $lo = $lo | ($hi << 25);
655
+ $hi = $hi >> 7;
656
+ // Right shift carries sign, but we don't want it to.
657
+ $hi = $hi & (127 << 25);
658
+ }
659
+ }
660
+
661
+ $ret = TStringFuncFactory::create()->strlen($out);
662
+ $this->trans_->write($out, $ret);
663
+
664
+ return $ret;
665
+ } else {
666
+ return $this->writeVarint($this->toZigZag($value, 64));
667
+ }
668
+ }
669
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/TJSONProtocol.php ADDED
@@ -0,0 +1,694 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Licensed to the Apache Software Foundation (ASF) under one
5
+ * or more contributor license agreements. See the NOTICE file
6
+ * distributed with this work for additional information
7
+ * regarding copyright ownership. The ASF licenses this file
8
+ * to you under the Apache License, Version 2.0 (the
9
+ * "License"); you may not use this file except in compliance
10
+ * with the License. You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing,
15
+ * software distributed under the License is distributed on an
16
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ * KIND, either express or implied. See the License for the
18
+ * specific language governing permissions and limitations
19
+ * under the License.
20
+ *
21
+ * @package thrift.protocol
22
+ */
23
+
24
+ namespace Thrift\Protocol;
25
+
26
+ use Thrift\Protocol\TProtocol;
27
+ use Thrift\Type\TType;
28
+ use Thrift\Exception\TProtocolException;
29
+ use Thrift\Protocol\JSON\BaseContext;
30
+ use Thrift\Protocol\JSON\LookaheadReader;
31
+ use Thrift\Protocol\JSON\PairContext;
32
+ use Thrift\Protocol\JSON\ListContext;
33
+
34
+ /**
35
+ * JSON implementation of thrift protocol, ported from Java.
36
+ */
37
+ class TJSONProtocol extends TProtocol
38
+ {
39
+ const COMMA = ',';
40
+ const COLON = ':';
41
+ const LBRACE = '{';
42
+ const RBRACE = '}';
43
+ const LBRACKET = '[';
44
+ const RBRACKET = ']';
45
+ const QUOTE = '"';
46
+ const BACKSLASH = '\\';
47
+ const ZERO = '0';
48
+ const ESCSEQ = '\\';
49
+ const DOUBLEESC = '__DOUBLE_ESCAPE_SEQUENCE__';
50
+
51
+ const VERSION = 1;
52
+
53
+ public static $JSON_CHAR_TABLE = array(
54
+ /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
55
+ 0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0, // 0
56
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1
57
+ 1, 1, '"', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2
58
+ );
59
+
60
+ public static $ESCAPE_CHARS = array('"', '\\', "b", "f", "n", "r", "t");
61
+
62
+ public static $ESCAPE_CHAR_VALS = array(
63
+ '"', '\\', "\x08", "\f", "\n", "\r", "\t",
64
+ );
65
+
66
+ const NAME_BOOL = "tf";
67
+ const NAME_BYTE = "i8";
68
+ const NAME_I16 = "i16";
69
+ const NAME_I32 = "i32";
70
+ const NAME_I64 = "i64";
71
+ const NAME_DOUBLE = "dbl";
72
+ const NAME_STRUCT = "rec";
73
+ const NAME_STRING = "str";
74
+ const NAME_MAP = "map";
75
+ const NAME_LIST = "lst";
76
+ const NAME_SET = "set";
77
+
78
+ private function getTypeNameForTypeID($typeID)
79
+ {
80
+ switch ($typeID) {
81
+ case TType::BOOL:
82
+ return self::NAME_BOOL;
83
+ case TType::BYTE:
84
+ return self::NAME_BYTE;
85
+ case TType::I16:
86
+ return self::NAME_I16;
87
+ case TType::I32:
88
+ return self::NAME_I32;
89
+ case TType::I64:
90
+ return self::NAME_I64;
91
+ case TType::DOUBLE:
92
+ return self::NAME_DOUBLE;
93
+ case TType::STRING:
94
+ return self::NAME_STRING;
95
+ case TType::STRUCT:
96
+ return self::NAME_STRUCT;
97
+ case TType::MAP:
98
+ return self::NAME_MAP;
99
+ case TType::SET:
100
+ return self::NAME_SET;
101
+ case TType::LST:
102
+ return self::NAME_LIST;
103
+ default:
104
+ throw new TProtocolException("Unrecognized type", TProtocolException::UNKNOWN);
105
+ }
106
+ }
107
+
108
+ private function getTypeIDForTypeName($name)
109
+ {
110
+ $result = TType::STOP;
111
+
112
+ if (strlen($name) > 1) {
113
+ switch (substr($name, 0, 1)) {
114
+ case 'd':
115
+ $result = TType::DOUBLE;
116
+ break;
117
+ case 'i':
118
+ switch (substr($name, 1, 1)) {
119
+ case '8':
120
+ $result = TType::BYTE;
121
+ break;
122
+ case '1':
123
+ $result = TType::I16;
124
+ break;
125
+ case '3':
126
+ $result = TType::I32;
127
+ break;
128
+ case '6':
129
+ $result = TType::I64;
130
+ break;
131
+ }
132
+ break;
133
+ case 'l':
134
+ $result = TType::LST;
135
+ break;
136
+ case 'm':
137
+ $result = TType::MAP;
138
+ break;
139
+ case 'r':
140
+ $result = TType::STRUCT;
141
+ break;
142
+ case 's':
143
+ if (substr($name, 1, 1) == 't') {
144
+ $result = TType::STRING;
145
+ }
146
+ else if (substr($name, 1, 1) == 'e') {
147
+ $result = TType::SET;
148
+ }
149
+ break;
150
+ case 't':
151
+ $result = TType::BOOL;
152
+ break;
153
+ }
154
+ }
155
+ if ($result == TType::STOP) {
156
+ throw new TProtocolException("Unrecognized type", TProtocolException::INVALID_DATA);
157
+ }
158
+ return $result;
159
+ }
160
+
161
+ public $contextStack_ = array();
162
+ public $context_;
163
+ public $reader_;
164
+
165
+ private function pushContext($c) {
166
+ array_push($this->contextStack_, $this->context_);
167
+ $this->context_ = $c;
168
+ }
169
+
170
+ private function popContext() {
171
+ $this->context_ = array_pop($this->contextStack_);
172
+ }
173
+
174
+ public function __construct($trans) {
175
+ parent::__construct($trans);
176
+ $this->context_ = new BaseContext();
177
+ $this->reader_ = new LookaheadReader($this);
178
+ }
179
+
180
+ public function reset() {
181
+ $this->contextStack_ = array();
182
+ $this->context_ = new BaseContext();
183
+ $this->reader_ = new LookaheadReader($this);
184
+ }
185
+
186
+ private $tmpbuf_ = array(4);
187
+
188
+ public function readJSONSyntaxChar($b) {
189
+ $ch = $this->reader_->read();
190
+
191
+ if (substr($ch, 0, 1) != $b) {
192
+ throw new TProtocolException("Unexpected character: " . $ch, TProtocolException::INVALID_DATA);
193
+ }
194
+ }
195
+
196
+ private function hexVal($s) {
197
+ for ($i = 0; $i < strlen($s); $i++) {
198
+ $ch = substr($s, $i, 1);
199
+
200
+ if (!($ch >= "a" && $ch <= "f") && !($ch >= "0" && $ch <= "9")) {
201
+ throw new TProtocolException("Expected hex character " . $ch, TProtocolException::INVALID_DATA);
202
+ }
203
+ }
204
+
205
+ return hexdec($s);
206
+ }
207
+
208
+ private function hexChar($val) {
209
+ return dechex($val);
210
+ }
211
+
212
+ private function writeJSONString($b) {
213
+ $this->context_->write();
214
+
215
+ if (is_numeric($b) && $this->context_->escapeNum()) {
216
+ $this->trans_->write(self::QUOTE);
217
+ }
218
+
219
+ $this->trans_->write(json_encode($b));
220
+
221
+ if (is_numeric($b) && $this->context_->escapeNum()) {
222
+ $this->trans_->write(self::QUOTE);
223
+ }
224
+ }
225
+
226
+ private function writeJSONInteger($num) {
227
+ $this->context_->write();
228
+
229
+ if ($this->context_->escapeNum()) {
230
+ $this->trans_->write(self::QUOTE);
231
+ }
232
+
233
+ $this->trans_->write($num);
234
+
235
+ if ($this->context_->escapeNum()) {
236
+ $this->trans_->write(self::QUOTE);
237
+ }
238
+ }
239
+
240
+ private function writeJSONDouble($num) {
241
+ $this->context_->write();
242
+
243
+ if ($this->context_->escapeNum()) {
244
+ $this->trans_->write(self::QUOTE);
245
+ }
246
+
247
+ $this->trans_->write(json_encode($num));
248
+
249
+ if ($this->context_->escapeNum()) {
250
+ $this->trans_->write(self::QUOTE);
251
+ }
252
+ }
253
+
254
+ private function writeJSONBase64($data) {
255
+ $this->context_->write();
256
+ $this->trans_->write(self::QUOTE);
257
+ $this->trans_->write(json_encode(base64_encode($data)));
258
+ $this->trans_->write(self::QUOTE);
259
+ }
260
+
261
+ private function writeJSONObjectStart() {
262
+ $this->context_->write();
263
+ $this->trans_->write(self::LBRACE);
264
+ $this->pushContext(new PairContext($this));
265
+ }
266
+
267
+ private function writeJSONObjectEnd() {
268
+ $this->popContext();
269
+ $this->trans_->write(self::RBRACE);
270
+ }
271
+
272
+ private function writeJSONArrayStart() {
273
+ $this->context_->write();
274
+ $this->trans_->write(self::LBRACKET);
275
+ $this->pushContext(new ListContext($this));
276
+ }
277
+
278
+ private function writeJSONArrayEnd() {
279
+ $this->popContext();
280
+ $this->trans_->write(self::RBRACKET);
281
+ }
282
+
283
+ private function readJSONString($skipContext) {
284
+ if (!$skipContext) {
285
+ $this->context_->read();
286
+ }
287
+
288
+ $jsonString = '';
289
+ $lastChar = NULL;
290
+ while (true) {
291
+ $ch = $this->reader_->read();
292
+ $jsonString .= $ch;
293
+ if ($ch == self::QUOTE &&
294
+ $lastChar !== NULL &&
295
+ $lastChar !== self::ESCSEQ) {
296
+ break;
297
+ }
298
+ if ($ch == self::ESCSEQ && $lastChar == self::ESCSEQ) {
299
+ $lastChar = self::DOUBLEESC;
300
+ } else {
301
+ $lastChar = $ch;
302
+ }
303
+ }
304
+ return json_decode($jsonString);
305
+ }
306
+
307
+ private function isJSONNumeric($b) {
308
+ switch ($b) {
309
+ case '+':
310
+ case '-':
311
+ case '.':
312
+ case '0':
313
+ case '1':
314
+ case '2':
315
+ case '3':
316
+ case '4':
317
+ case '5':
318
+ case '6':
319
+ case '7':
320
+ case '8':
321
+ case '9':
322
+ case 'E':
323
+ case 'e':
324
+ return true;
325
+ }
326
+ return false;
327
+ }
328
+
329
+ private function readJSONNumericChars() {
330
+ $strbld = array();
331
+
332
+ while (true) {
333
+ $ch = $this->reader_->peek();
334
+
335
+ if (!$this->isJSONNumeric($ch)) {
336
+ break;
337
+ }
338
+
339
+ $strbld[] = $this->reader_->read();
340
+ }
341
+
342
+ return implode("", $strbld);
343
+ }
344
+
345
+ private function readJSONInteger() {
346
+ $this->context_->read();
347
+
348
+ if ($this->context_->escapeNum()) {
349
+ $this->readJSONSyntaxChar(self::QUOTE);
350
+ }
351
+
352
+ $str = $this->readJSONNumericChars();
353
+
354
+ if ($this->context_->escapeNum()) {
355
+ $this->readJSONSyntaxChar(self::QUOTE);
356
+ }
357
+
358
+ if (!is_numeric($str)) {
359
+ throw new TProtocolException("Invalid data in numeric: " . $str, TProtocolException::INVALID_DATA);
360
+ }
361
+
362
+ return intval($str);
363
+ }
364
+
365
+ /**
366
+ * Identical to readJSONInteger but without the final cast.
367
+ * Needed for proper handling of i64 on 32 bit machines. Why a
368
+ * separate function? So we don't have to force the rest of the
369
+ * use cases through the extra conditional.
370
+ */
371
+ private function readJSONIntegerAsString() {
372
+ $this->context_->read();
373
+
374
+ if ($this->context_->escapeNum()) {
375
+ $this->readJSONSyntaxChar(self::QUOTE);
376
+ }
377
+
378
+ $str = $this->readJSONNumericChars();
379
+
380
+ if ($this->context_->escapeNum()) {
381
+ $this->readJSONSyntaxChar(self::QUOTE);
382
+ }
383
+
384
+ if (!is_numeric($str)) {
385
+ throw new TProtocolException("Invalid data in numeric: " . $str, TProtocolException::INVALID_DATA);
386
+ }
387
+
388
+ return $str;
389
+ }
390
+
391
+ private function readJSONDouble() {
392
+ $this->context_->read();
393
+
394
+ if (substr($this->reader_->peek(), 0, 1) == self::QUOTE) {
395
+ $arr = $this->readJSONString(true);
396
+
397
+ if ($arr == "NaN") {
398
+ return NAN;
399
+ } else if ($arr == "Infinity") {
400
+ return INF;
401
+ } else if (!$this->context_->escapeNum()) {
402
+ throw new TProtocolException("Numeric data unexpectedly quoted " . $arr,
403
+ TProtocolException::INVALID_DATA);
404
+ }
405
+
406
+ return floatval($arr);
407
+ } else {
408
+ if ($this->context_->escapeNum()) {
409
+ $this->readJSONSyntaxChar(self::QUOTE);
410
+ }
411
+
412
+ return floatval($this->readJSONNumericChars());
413
+ }
414
+ }
415
+
416
+ private function readJSONBase64() {
417
+ $arr = $this->readJSONString(false);
418
+ $data = base64_decode($arr, true);
419
+
420
+ if ($data === false) {
421
+ throw new TProtocolException("Invalid base64 data " . $arr, TProtocolException::INVALID_DATA);
422
+ }
423
+
424
+ return $data;
425
+ }
426
+
427
+ private function readJSONObjectStart() {
428
+ $this->context_->read();
429
+ $this->readJSONSyntaxChar(self::LBRACE);
430
+ $this->pushContext(new PairContext($this));
431
+ }
432
+
433
+ private function readJSONObjectEnd() {
434
+ $this->readJSONSyntaxChar(self::RBRACE);
435
+ $this->popContext();
436
+ }
437
+
438
+ private function readJSONArrayStart()
439
+ {
440
+ $this->context_->read();
441
+ $this->readJSONSyntaxChar(self::LBRACKET);
442
+ $this->pushContext(new ListContext($this));
443
+ }
444
+
445
+ private function readJSONArrayEnd() {
446
+ $this->readJSONSyntaxChar(self::RBRACKET);
447
+ $this->popContext();
448
+ }
449
+
450
+ /**
451
+ * Writes the message header
452
+ *
453
+ * @param string $name Function name
454
+ * @param int $type message type TMessageType::CALL or TMessageType::REPLY
455
+ * @param int $seqid The sequence id of this message
456
+ */
457
+ public function writeMessageBegin($name, $type, $seqid) {
458
+ $this->writeJSONArrayStart();
459
+ $this->writeJSONInteger(self::VERSION);
460
+ $this->writeJSONString($name);
461
+ $this->writeJSONInteger($type);
462
+ $this->writeJSONInteger($seqid);
463
+ }
464
+
465
+ /**
466
+ * Close the message
467
+ */
468
+ public function writeMessageEnd() {
469
+ $this->writeJSONArrayEnd();
470
+ }
471
+
472
+ /**
473
+ * Writes a struct header.
474
+ *
475
+ * @param string $name Struct name
476
+ * @throws TException on write error
477
+ * @return int How many bytes written
478
+ */
479
+ public function writeStructBegin($name) {
480
+ $this->writeJSONObjectStart();
481
+ }
482
+
483
+ /**
484
+ * Close a struct.
485
+ *
486
+ * @throws TException on write error
487
+ * @return int How many bytes written
488
+ */
489
+ public function writeStructEnd() {
490
+ $this->writeJSONObjectEnd();
491
+ }
492
+
493
+ public function writeFieldBegin($fieldName, $fieldType, $fieldId) {
494
+ $this->writeJSONInteger($fieldId);
495
+ $this->writeJSONObjectStart();
496
+ $this->writeJSONString($this->getTypeNameForTypeID($fieldType));
497
+ }
498
+
499
+ public function writeFieldEnd() {
500
+ $this->writeJsonObjectEnd();
501
+ }
502
+
503
+ public function writeFieldStop() {
504
+ }
505
+
506
+ public function writeMapBegin($keyType, $valType, $size) {
507
+ $this->writeJSONArrayStart();
508
+ $this->writeJSONString($this->getTypeNameForTypeID($keyType));
509
+ $this->writeJSONString($this->getTypeNameForTypeID($valType));
510
+ $this->writeJSONInteger($size);
511
+ $this->writeJSONObjectStart();
512
+ }
513
+
514
+ public function writeMapEnd() {
515
+ $this->writeJSONObjectEnd();
516
+ $this->writeJSONArrayEnd();
517
+ }
518
+
519
+ public function writeListBegin($elemType, $size) {
520
+ $this->writeJSONArrayStart();
521
+ $this->writeJSONString($this->getTypeNameForTypeID($elemType));
522
+ $this->writeJSONInteger($size);
523
+ }
524
+
525
+ public function writeListEnd() {
526
+ $this->writeJSONArrayEnd();
527
+ }
528
+
529
+ public function writeSetBegin($elemType, $size) {
530
+ $this->writeJSONArrayStart();
531
+ $this->writeJSONString($this->getTypeNameForTypeID($elemType));
532
+ $this->writeJSONInteger($size);
533
+ }
534
+
535
+ public function writeSetEnd() {
536
+ $this->writeJSONArrayEnd();
537
+ }
538
+
539
+ public function writeBool($bool) {
540
+ $this->writeJSONInteger($bool ? 1 : 0);
541
+ }
542
+
543
+ public function writeByte($byte) {
544
+ $this->writeJSONInteger($byte);
545
+ }
546
+
547
+ public function writeI16($i16) {
548
+ $this->writeJSONInteger($i16);
549
+ }
550
+
551
+ public function writeI32($i32) {
552
+ $this->writeJSONInteger($i32);
553
+ }
554
+
555
+ public function writeI64($i64) {
556
+ $this->writeJSONInteger($i64);
557
+ }
558
+
559
+ public function writeDouble($dub) {
560
+ $this->writeJSONDouble($dub);
561
+ }
562
+
563
+ public function writeString($str) {
564
+ $this->writeJSONString($str);
565
+ }
566
+
567
+ /**
568
+ * Reads the message header
569
+ *
570
+ * @param string $name Function name
571
+ * @param int $type message type TMessageType::CALL or TMessageType::REPLY
572
+ * @parem int $seqid The sequence id of this message
573
+ */
574
+ public function readMessageBegin(&$name, &$type, &$seqid) {
575
+ $this->readJSONArrayStart();
576
+
577
+ if ($this->readJSONInteger() != self::VERSION) {
578
+ throw new TProtocolException("Message contained bad version", TProtocolException::BAD_VERSION);
579
+ }
580
+
581
+ $name = $this->readJSONString(false);
582
+ $type = $this->readJSONInteger();
583
+ $seqid = $this->readJSONInteger();
584
+
585
+ return true;
586
+ }
587
+
588
+ /**
589
+ * Read the close of message
590
+ */
591
+ public function readMessageEnd() {
592
+ $this->readJSONArrayEnd();
593
+ }
594
+
595
+ public function readStructBegin(&$name) {
596
+ $this->readJSONObjectStart();
597
+ return 0;
598
+ }
599
+
600
+ public function readStructEnd() {
601
+ $this->readJSONObjectEnd();
602
+ }
603
+
604
+ public function readFieldBegin(&$name, &$fieldType, &$fieldId) {
605
+ $ch = $this->reader_->peek();
606
+ $name = "";
607
+
608
+ if (substr($ch, 0, 1) == self::RBRACE) {
609
+ $fieldType = TType::STOP;
610
+ } else {
611
+ $fieldId = $this->readJSONInteger();
612
+ $this->readJSONObjectStart();
613
+ $fieldType = $this->getTypeIDForTypeName($this->readJSONString(false));
614
+ }
615
+ }
616
+
617
+ public function readFieldEnd() {
618
+ $this->readJSONObjectEnd();
619
+ }
620
+
621
+ public function readMapBegin(&$keyType, &$valType, &$size) {
622
+ $this->readJSONArrayStart();
623
+ $keyType = $this->getTypeIDForTypeName($this->readJSONString(false));
624
+ $valType = $this->getTypeIDForTypeName($this->readJSONString(false));
625
+ $size = $this->readJSONInteger();
626
+ $this->readJSONObjectStart();
627
+ }
628
+
629
+ public function readMapEnd() {
630
+ $this->readJSONObjectEnd();
631
+ $this->readJSONArrayEnd();
632
+ }
633
+
634
+ public function readListBegin(&$elemType, &$size) {
635
+ $this->readJSONArrayStart();
636
+ $elemType = $this->getTypeIDForTypeName($this->readJSONString(false));
637
+ $size = $this->readJSONInteger();
638
+ return true;
639
+ }
640
+
641
+ public function readListEnd() {
642
+ $this->readJSONArrayEnd();
643
+ }
644
+
645
+ public function readSetBegin(&$elemType, &$size) {
646
+ $this->readJSONArrayStart();
647
+ $elemType = $this->getTypeIDForTypeName($this->readJSONString(false));
648
+ $size = $this->readJSONInteger();
649
+ return true;
650
+ }
651
+
652
+ public function readSetEnd() {
653
+ $this->readJSONArrayEnd();
654
+ }
655
+
656
+ public function readBool(&$bool) {
657
+ $bool = $this->readJSONInteger() == 0 ? false : true;
658
+ return true;
659
+ }
660
+
661
+ public function readByte(&$byte) {
662
+ $byte = $this->readJSONInteger();
663
+ return true;
664
+ }
665
+
666
+ public function readI16(&$i16) {
667
+ $i16 = $this->readJSONInteger();
668
+ return true;
669
+ }
670
+
671
+ public function readI32(&$i32) {
672
+ $i32 = $this->readJSONInteger();
673
+ return true;
674
+ }
675
+
676
+ public function readI64(&$i64) {
677
+ if ( PHP_INT_SIZE === 4 ) {
678
+ $i64 = $this->readJSONIntegerAsString();
679
+ } else {
680
+ $i64 = $this->readJSONInteger();
681
+ }
682
+ return true;
683
+ }
684
+
685
+ public function readDouble(&$dub) {
686
+ $dub = $this->readJSONDouble();
687
+ return true;
688
+ }
689
+
690
+ public function readString(&$str) {
691
+ $str = $this->readJSONString(false);
692
+ return true;
693
+ }
694
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Protocol/TProtocol.php ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ */
22
+
23
+ namespace Thrift\Protocol;
24
+
25
+ use Thrift\Type\TType;
26
+ use Thrift\Exception\TProtocolException;
27
+
28
+ /**
29
+ * Protocol base class module.
30
+ */
31
+ abstract class TProtocol {
32
+ // The below may seem silly, but it is to get around the problem that the
33
+ // "instanceof" operator can only take in a T_VARIABLE and not a T_STRING
34
+ // or T_CONSTANT_ENCAPSED_STRING. Using "is_a()" instead of "instanceof" is
35
+ // a workaround but is deprecated in PHP5. This is used in the generated
36
+ // deserialization code.
37
+ static $TBINARYPROTOCOLACCELERATED = 'TBinaryProtocolAccelerated';
38
+
39
+ /**
40
+ * Underlying transport
41
+ *
42
+ * @var TTransport
43
+ */
44
+ protected $trans_;
45
+
46
+ /**
47
+ * Constructor
48
+ */
49
+ protected function __construct($trans) {
50
+ $this->trans_ = $trans;
51
+ }
52
+
53
+ /**
54
+ * Accessor for transport
55
+ *
56
+ * @return TTransport
57
+ */
58
+ public function getTransport() {
59
+ return $this->trans_;
60
+ }
61
+
62
+ /**
63
+ * Writes the message header
64
+ *
65
+ * @param string $name Function name
66
+ * @param int $type message type TMessageType::CALL or TMessageType::REPLY
67
+ * @param int $seqid The sequence id of this message
68
+ */
69
+ public abstract function writeMessageBegin($name, $type, $seqid);
70
+
71
+ /**
72
+ * Close the message
73
+ */
74
+ public abstract function writeMessageEnd();
75
+
76
+ /**
77
+ * Writes a struct header.
78
+ *
79
+ * @param string $name Struct name
80
+ * @throws TException on write error
81
+ * @return int How many bytes written
82
+ */
83
+ public abstract function writeStructBegin($name);
84
+
85
+ /**
86
+ * Close a struct.
87
+ *
88
+ * @throws TException on write error
89
+ * @return int How many bytes written
90
+ */
91
+ public abstract function writeStructEnd();
92
+
93
+ /*
94
+ * Starts a field.
95
+ *
96
+ * @param string $name Field name
97
+ * @param int $type Field type
98
+ * @param int $fid Field id
99
+ * @throws TException on write error
100
+ * @return int How many bytes written
101
+ */
102
+ public abstract function writeFieldBegin($fieldName, $fieldType, $fieldId);
103
+
104
+ public abstract function writeFieldEnd();
105
+
106
+ public abstract function writeFieldStop();
107
+
108
+ public abstract function writeMapBegin($keyType, $valType, $size);
109
+
110
+ public abstract function writeMapEnd();
111
+
112
+ public abstract function writeListBegin($elemType, $size);
113
+
114
+ public abstract function writeListEnd();
115
+
116
+ public abstract function writeSetBegin($elemType, $size);
117
+
118
+ public abstract function writeSetEnd();
119
+
120
+ public abstract function writeBool($bool);
121
+
122
+ public abstract function writeByte($byte);
123
+
124
+ public abstract function writeI16($i16);
125
+
126
+ public abstract function writeI32($i32);
127
+
128
+ public abstract function writeI64($i64);
129
+
130
+ public abstract function writeDouble($dub);
131
+
132
+ public abstract function writeString($str);
133
+
134
+ /**
135
+ * Reads the message header
136
+ *
137
+ * @param string $name Function name
138
+ * @param int $type message type TMessageType::CALL or TMessageType::REPLY
139
+ * @parem int $seqid The sequence id of this message
140
+ */
141
+ public abstract function readMessageBegin(&$name, &$type, &$seqid);
142
+
143
+ /**
144
+ * Read the close of message
145
+ */
146
+ public abstract function readMessageEnd();
147
+
148
+ public abstract function readStructBegin(&$name);
149
+
150
+ public abstract function readStructEnd();
151
+
152
+ public abstract function readFieldBegin(&$name, &$fieldType, &$fieldId);
153
+
154
+ public abstract function readFieldEnd();
155
+
156
+ public abstract function readMapBegin(&$keyType, &$valType, &$size);
157
+
158
+ public abstract function readMapEnd();
159
+
160
+ public abstract function readListBegin(&$elemType, &$size);
161
+
162
+ public abstract function readListEnd();
163
+
164
+ public abstract function readSetBegin(&$elemType, &$size);
165
+
166
+ public abstract function readSetEnd();
167
+
168
+ public abstract function readBool(&$bool);
169
+
170
+ public abstract function readByte(&$byte);
171
+
172
+ public abstract function readI16(&$i16);
173
+
174
+ public abstract function readI32(&$i32);
175
+
176
+ public abstract function readI64(&$i64);
177
+
178
+ public abstract function readDouble(&$dub);
179
+
180
+ public abstract function readString(&$str);
181
+
182
+ /**
183
+ * The skip function is a utility to parse over unrecognized date without
184
+ * causing corruption.
185
+ *
186
+ * @param TType $type What type is it
187
+ */
188
+ public function skip($type) {
189
+ switch ($type) {
190
+ case TType::BOOL:
191
+ return $this->readBool($bool);
192
+ case TType::BYTE:
193
+ return $this->readByte($byte);
194
+ case TType::I16:
195
+ return $this->readI16($i16);
196
+ case TType::I32:
197
+ return $this->readI32($i32);
198
+ case TType::I64:
199
+ return $this->readI64($i64);
200
+ case TType::DOUBLE:
201
+ return $this->readDouble($dub);
202
+ case TType::STRING:
203
+ return $this->readString($str);
204
+ case TType::STRUCT:
205
+ {
206
+ $result = $this->readStructBegin($name);
207
+ while (true) {
208
+ $result += $this->readFieldBegin($name, $ftype, $fid);
209
+ if ($ftype == TType::STOP) {
210
+ break;
211
+ }
212
+ $result += $this->skip($ftype);
213
+ $result += $this->readFieldEnd();
214
+ }
215
+ $result += $this->readStructEnd();
216
+ return $result;
217
+ }
218
+ case TType::MAP:
219
+ {
220
+ $result = $this->readMapBegin($keyType, $valType, $size);
221
+ for ($i = 0; $i < $size; $i++) {
222
+ $result += $this->skip($keyType);
223
+ $result += $this->skip($valType);
224
+ }
225
+ $result += $this->readMapEnd();
226
+ return $result;
227
+ }
228
+ case TType::SET:
229
+ {
230
+ $result = $this->readSetBegin($elemType, $size);
231
+ for ($i = 0; $i < $size; $i++) {
232
+ $result += $this->skip($elemType);
233
+ }
234
+ $result += $this->readSetEnd();
235
+ return $result;
236
+ }
237
+ case TType::LST:
238
+ {
239
+ $result = $this->readListBegin($elemType, $size);
240
+ for ($i = 0; $i < $size; $i++) {
241
+ $result += $this->skip($elemType);
242
+ }
243
+ $result += $this->readListEnd();
244
+ return $result;
245
+ }
246
+ default:
247
+ throw new TProtocolException('Unknown field type: '.$type,
248
+ TProtocolException::INVALID_DATA);
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Utility for skipping binary data
254
+ *
255
+ * @param TTransport $itrans TTransport object
256
+ * @param int $type Field type
257
+ */
258
+ public static function skipBinary($itrans, $type) {
259
+ switch ($type) {
260
+ case TType::BOOL:
261
+ return $itrans->readAll(1);
262
+ case TType::BYTE:
263
+ return $itrans->readAll(1);
264
+ case TType::I16:
265
+ return $itrans->readAll(2);
266
+ case TType::I32:
267
+ return $itrans->readAll(4);
268
+ case TType::I64:
269
+ return $itrans->readAll(8);
270
+ case TType::DOUBLE:
271
+ return $itrans->readAll(8);
272
+ case TType::STRING:
273
+ $len = unpack('N', $itrans->readAll(4));
274
+ $len = $len[1];
275
+ if ($len > 0x7fffffff) {
276
+ $len = 0 - (($len - 1) ^ 0xffffffff);
277
+ }
278
+ return 4 + $itrans->readAll($len);
279
+ case TType::STRUCT:
280
+ {
281
+ $result = 0;
282
+ while (true) {
283
+ $ftype = 0;
284
+ $fid = 0;
285
+ $data = $itrans->readAll(1);
286
+ $arr = unpack('c', $data);
287
+ $ftype = $arr[1];
288
+ if ($ftype == TType::STOP) {
289
+ break;
290
+ }
291
+ // I16 field id
292
+ $result += $itrans->readAll(2);
293
+ $result += self::skipBinary($itrans, $ftype);
294
+ }
295
+ return $result;
296
+ }
297
+ case TType::MAP:
298
+ {
299
+ // Ktype
300
+ $data = $itrans->readAll(1);
301
+ $arr = unpack('c', $data);
302
+ $ktype = $arr[1];
303
+ // Vtype
304
+ $data = $itrans->readAll(1);
305
+ $arr = unpack('c', $data);
306
+ $vtype = $arr[1];
307
+ // Size
308
+ $data = $itrans->readAll(4);
309
+ $arr = unpack('N', $data);
310
+ $size = $arr[1];
311
+ if ($size > 0x7fffffff) {
312
+ $size = 0 - (($size - 1) ^ 0xffffffff);
313
+ }
314
+ $result = 6;
315
+ for ($i = 0; $i < $size; $i++) {
316
+ $result += self::skipBinary($itrans, $ktype);
317
+ $result += self::skipBinary($itrans, $vtype);
318
+ }
319
+ return $result;
320
+ }
321
+ case TType::SET:
322
+ case TType::LST:
323
+ {
324
+ // Vtype
325
+ $data = $itrans->readAll(1);
326
+ $arr = unpack('c', $data);
327
+ $vtype = $arr[1];
328
+ // Size
329
+ $data = $itrans->readAll(4);
330
+ $arr = unpack('N', $data);
331
+ $size = $arr[1];
332
+ if ($size > 0x7fffffff) {
333
+ $size = 0 - (($size - 1) ^ 0xffffffff);
334
+ }
335
+ $result = 5;
336
+ for ($i = 0; $i < $size; $i++) {
337
+ $result += self::skipBinary($itrans, $vtype);
338
+ }
339
+ return $result;
340
+ }
341
+ default:
342
+ throw new TProtocolException('Unknown field type: '.$type,
343
+ TProtocolException::INVALID_DATA);
344
+ }
345
+ }
346
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Serializer/TBinarySerializer.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.protocol
21
+ * @author: rmarin (marin.radu@facebook.com)
22
+ */
23
+
24
+ namespace Thrift\Serializer;
25
+
26
+ use Thrift\Transport\TMemoryBuffer;
27
+ use Thrift\Protocol\TBinaryProtocolAccelerated;
28
+ use Thrift\Type\TMessageType;
29
+
30
+ /**
31
+ * Utility class for serializing and deserializing
32
+ * a thrift object using TBinaryProtocolAccelerated.
33
+ */
34
+ class TBinarySerializer {
35
+
36
+ // NOTE(rmarin): Because thrift_protocol_write_binary
37
+ // adds a begin message prefix, you cannot specify
38
+ // a transport in which to serialize an object. It has to
39
+ // be a string. Otherwise we will break the compatibility with
40
+ // normal deserialization.
41
+ public static function serialize($object) {
42
+ $transport = new TMemoryBuffer();
43
+ $protocol = new TBinaryProtocolAccelerated($transport);
44
+ if (function_exists('thrift_protocol_write_binary')) {
45
+ thrift_protocol_write_binary($protocol, $object->getName(),
46
+ TMessageType::REPLY, $object,
47
+ 0, $protocol->isStrictWrite());
48
+
49
+ $protocol->readMessageBegin($unused_name, $unused_type,
50
+ $unused_seqid);
51
+ } else {
52
+ $object->write($protocol);
53
+ }
54
+ $protocol->getTransport()->flush();
55
+ return $transport->getBuffer();
56
+ }
57
+
58
+ public static function deserialize($string_object, $class_name) {
59
+ $transport = new TMemoryBuffer();
60
+ $protocol = new TBinaryProtocolAccelerated($transport);
61
+ if (function_exists('thrift_protocol_read_binary')) {
62
+ $protocol->writeMessageBegin('', TMessageType::REPLY, 0);
63
+ $transport->write($string_object);
64
+ return thrift_protocol_read_binary($protocol, $class_name,
65
+ $protocol->isStrictRead());
66
+ } else {
67
+ $transport->write($string_object);
68
+ $object = new $class_name();
69
+ $object->read($protocol);
70
+ return $object;
71
+ }
72
+ }
73
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Server/TForkingServer.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Thrift\Server;
4
+
5
+ use Thrift\Server\TServer;
6
+ use Thrift\Transport\TTransport;
7
+ use Thrift\Exception\TException;
8
+ use Thrift\Exception\TTransportException;
9
+
10
+ /**
11
+ * A forking implementation of a Thrift server.
12
+ *
13
+ * @package thrift.server
14
+ */
15
+ class TForkingServer extends TServer {
16
+ /**
17
+ * Flag for the main serving loop
18
+ *
19
+ * @var bool
20
+ */
21
+ private $stop_ = false;
22
+
23
+ /**
24
+ * List of children.
25
+ *
26
+ * @var array
27
+ */
28
+ protected $children_ = array();
29
+
30
+ /**
31
+ * Listens for new client using the supplied
32
+ * transport. We fork when a new connection
33
+ * arrives.
34
+ *
35
+ * @return void
36
+ */
37
+ public function serve() {
38
+ $this->transport_->listen();
39
+
40
+ while (!$this->stop_) {
41
+ try {
42
+ $transport = $this->transport_->accept();
43
+
44
+ if ($transport != null) {
45
+ $pid = pcntl_fork();
46
+
47
+ if ($pid > 0) {
48
+ $this->handleParent($transport, $pid);
49
+ }
50
+ else if ($pid === 0) {
51
+ $this->handleChild($transport);
52
+ }
53
+ else {
54
+ throw new TException('Failed to fork');
55
+ }
56
+ }
57
+ }
58
+ catch (TTransportException $e) { }
59
+
60
+ $this->collectChildren();
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Code run by the parent
66
+ *
67
+ * @param TTransport $transport
68
+ * @param int $pid
69
+ * @return void
70
+ */
71
+ private function handleParent(TTransport $transport, $pid) {
72
+ $this->children_[$pid] = $transport;
73
+ }
74
+
75
+ /**
76
+ * Code run by the child.
77
+ *
78
+ * @param TTransport $transport
79
+ * @return void
80
+ */
81
+ private function handleChild(TTransport $transport) {
82
+ try {
83
+ $inputTransport = $this->inputTransportFactory_->getTransport($transport);
84
+ $outputTransport = $this->outputTransportFactory_->getTransport($transport);
85
+ $inputProtocol = $this->inputProtocolFactory_->getProtocol($inputTransport);
86
+ $outputProtocol = $this->outputProtocolFactory_->getProtocol($outputTransport);
87
+ while ($this->processor_->process($inputProtocol, $outputProtocol)) { }
88
+ @$transport->close();
89
+ }
90
+ catch (TTransportException $e) { }
91
+
92
+ exit(0);
93
+ }
94
+
95
+ /**
96
+ * Collects any children we may have
97
+ *
98
+ * @return void
99
+ */
100
+ private function collectChildren() {
101
+ foreach ($this->children_ as $pid => $transport) {
102
+ if (pcntl_waitpid($pid, $status, WNOHANG) > 0) {
103
+ unset($this->children_[$pid]);
104
+ if ($transport) @$transport->close();
105
+ }
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Stops the server running. Kills the transport
111
+ * and then stops the main serving loop
112
+ *
113
+ * @return void
114
+ */
115
+ public function stop() {
116
+ $this->transport_->close();
117
+ $this->stop_ = true;
118
+ }
119
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Server/TServer.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Thrift\Server;
4
+
5
+ use Thrift\Server\TServerTransport;
6
+ use Thrift\Factory\TTransportFactory;
7
+ use Thrift\Factory\TProtocolFactory;
8
+
9
+ /**
10
+ * Generic class for a Thrift server.
11
+ *
12
+ * @package thrift.server
13
+ */
14
+ abstract class TServer {
15
+
16
+ /**
17
+ * Processor to handle new clients
18
+ *
19
+ * @var TProcessor
20
+ */
21
+ protected $processor_;
22
+
23
+ /**
24
+ * Server transport to be used for listening
25
+ * and accepting new clients
26
+ *
27
+ * @var TServerTransport
28
+ */
29
+ protected $transport_;
30
+
31
+ /**
32
+ * Input transport factory
33
+ *
34
+ * @var TTransportFactory
35
+ */
36
+ protected $inputTransportFactory_;
37
+
38
+ /**
39
+ * Output transport factory
40
+ *
41
+ * @var TTransportFactory
42
+ */
43
+ protected $outputTransportFactory_;
44
+
45
+ /**
46
+ * Input protocol factory
47
+ *
48
+ * @var TProtocolFactory
49
+ */
50
+ protected $inputProtocolFactory_;
51
+
52
+ /**
53
+ * Output protocol factory
54
+ *
55
+ * @var TProtocolFactory
56
+ */
57
+ protected $outputProtocolFactory_;
58
+
59
+ /**
60
+ * Sets up all the factories, etc
61
+ *
62
+ * @param object $processor
63
+ * @param TServerTransport $transport
64
+ * @param TTransportFactory $inputTransportFactory
65
+ * @param TTransportFactory $outputTransportFactory
66
+ * @param TProtocolFactory $inputProtocolFactory
67
+ * @param TProtocolFactory $outputProtocolFactory
68
+ * @return void
69
+ */
70
+ public function __construct($processor,
71
+ TServerTransport $transport,
72
+ TTransportFactory $inputTransportFactory,
73
+ TTransportFactory $outputTransportFactory,
74
+ TProtocolFactory $inputProtocolFactory,
75
+ TProtocolFactory $outputProtocolFactory) {
76
+ $this->processor_ = $processor;
77
+ $this->transport_ = $transport;
78
+ $this->inputTransportFactory_ = $inputTransportFactory;
79
+ $this->outputTransportFactory_ = $outputTransportFactory;
80
+ $this->inputProtocolFactory_ = $inputProtocolFactory;
81
+ $this->outputProtocolFactory_ = $outputProtocolFactory;
82
+ }
83
+
84
+ /**
85
+ * Serves the server. This should never return
86
+ * unless a problem permits it to do so or it
87
+ * is interrupted intentionally
88
+ *
89
+ * @abstract
90
+ * @return void
91
+ */
92
+ abstract public function serve();
93
+
94
+ /**
95
+ * Stops the server serving
96
+ *
97
+ * @abstract
98
+ * @return void
99
+ */
100
+ abstract public function stop();
101
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Server/TServerSocket.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Thrift\Server;
4
+
5
+ use Thrift\Server\TServerTransport;
6
+ use Thrift\Transport\TSocket;
7
+
8
+ /**
9
+ * Socket implementation of a server agent.
10
+ *
11
+ * @package thrift.transport
12
+ */
13
+ class TServerSocket extends TServerTransport {
14
+
15
+ /**
16
+ * Handle for the listener socket
17
+ *
18
+ * @var resource
19
+ */
20
+ private $listener_;
21
+
22
+ /**
23
+ * Port for the listener to listen on
24
+ *
25
+ * @var int
26
+ */
27
+ private $port_;
28
+
29
+ /**
30
+ * Timeout when listening for a new client
31
+ *
32
+ * @var int
33
+ */
34
+ private $acceptTimeout_ = 30000;
35
+
36
+ /**
37
+ * Host to listen on
38
+ *
39
+ * @var string
40
+ */
41
+ private $host_;
42
+
43
+ /**
44
+ * ServerSocket constructor
45
+ *
46
+ * @param string $host Host to listen on
47
+ * @param int $port Port to listen on
48
+ * @return void
49
+ */
50
+ public function __construct($host = 'localhost', $port = 9090) {
51
+ $this->host_ = $host;
52
+ $this->port_ = $port;
53
+ }
54
+
55
+ /**
56
+ * Sets the accept timeout
57
+ *
58
+ * @param int $acceptTimeout
59
+ * @return void
60
+ */
61
+ public function setAcceptTimeout($acceptTimeout) {
62
+ $this->acceptTimeout_ = $acceptTimeout;
63
+ }
64
+
65
+ /**
66
+ * Opens a new socket server handle
67
+ *
68
+ * @return void
69
+ */
70
+ public function listen() {
71
+ $this->listener_ = stream_socket_server('tcp://' . $this->host_ . ':' . $this->port_);
72
+ }
73
+
74
+ /**
75
+ * Closes the socket server handle
76
+ *
77
+ * @return void
78
+ */
79
+ public function close() {
80
+ @fclose($this->listener_);
81
+ $this->listener_ = null;
82
+ }
83
+
84
+ /**
85
+ * Implementation of accept. If not client is accepted in the given time
86
+ *
87
+ * @return TSocket
88
+ */
89
+ protected function acceptImpl() {
90
+ $handle = @stream_socket_accept($this->listener_, $this->acceptTimeout_ / 1000.0);
91
+ if(!$handle) return null;
92
+
93
+ $socket = new TSocket();
94
+ $socket->setHandle($handle);
95
+
96
+ return $socket;
97
+ }
98
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Server/TServerTransport.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Thrift\Server;
4
+
5
+ use Thrift\Exception\TTransportException;
6
+
7
+ /**
8
+ * Generic class for Server agent.
9
+ *
10
+ * @package thrift.transport
11
+ */
12
+ abstract class TServerTransport {
13
+ /**
14
+ * List for new clients
15
+ *
16
+ * @abstract
17
+ * @return void
18
+ */
19
+ abstract public function listen();
20
+
21
+ /**
22
+ * Close the server
23
+ *
24
+ * @abstract
25
+ * @return void
26
+ */
27
+ abstract public function close();
28
+
29
+ /**
30
+ * Subclasses should use this to implement
31
+ * accept.
32
+ *
33
+ * @abstract
34
+ * @return TTransport
35
+ */
36
+ protected abstract function acceptImpl();
37
+
38
+ /**
39
+ * Uses the accept implemtation. If null is returned, an
40
+ * exception is thrown.
41
+ *
42
+ * @throws TTransportException
43
+ * @return TTransport
44
+ */
45
+ public function accept() {
46
+ $transport = $this->acceptImpl();
47
+
48
+ if ($transport == null) {
49
+ throw new TTransportException("accept() may not return NULL");
50
+ }
51
+
52
+ return $transport;
53
+ }
54
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Server/TSimpleServer.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Thrift\Server;
4
+
5
+ use Thrift\Server\TServer;
6
+ use Thrift\Exception\TTransportException;
7
+
8
+ /**
9
+ * Simple implemtation of a Thrift server.
10
+ *
11
+ * @package thrift.server
12
+ */
13
+ class TSimpleServer extends TServer {
14
+ /**
15
+ * Flag for the main serving loop
16
+ *
17
+ * @var bool
18
+ */
19
+ private $stop_ = false;
20
+
21
+ /**
22
+ * Listens for new client using the supplied
23
+ * transport. It handles TTransportExceptions
24
+ * to avoid timeouts etc killing it
25
+ *
26
+ * @return void
27
+ */
28
+ public function serve() {
29
+ $this->transport_->listen();
30
+
31
+ while (!$this->stop_) {
32
+ try {
33
+ $transport = $this->transport_->accept();
34
+
35
+ if ($transport != null) {
36
+ $inputTransport = $this->inputTransportFactory_->getTransport($transport);
37
+ $outputTransport = $this->outputTransportFactory_->getTransport($transport);
38
+ $inputProtocol = $this->inputProtocolFactory_->getProtocol($inputTransport);
39
+ $outputProtocol = $this->outputProtocolFactory_->getProtocol($outputTransport);
40
+ while ($this->processor_->process($inputProtocol, $outputProtocol)) { }
41
+ }
42
+ }
43
+ catch (TTransportException $e) { }
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Stops the server running. Kills the transport
49
+ * and then stops the main serving loop
50
+ *
51
+ * @return void
52
+ */
53
+ public function stop() {
54
+ $this->transport_->close();
55
+ $this->stop_ = true;
56
+ }
57
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/StringFunc/Core.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ */
21
+
22
+ namespace Thrift\StringFunc;
23
+
24
+ use Thrift\StringFunc\TStringFunc;
25
+
26
+ class Core implements TStringFunc {
27
+ public function substr($str, $start, $length = null) {
28
+ // specifying a null $length would return an empty string
29
+ if($length === null) {
30
+ return substr($str, $start);
31
+ }
32
+ return substr($str, $start, $length);
33
+ }
34
+
35
+ public function strlen($str) {
36
+ return strlen($str);
37
+ }
38
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/StringFunc/Mbstring.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ */
21
+
22
+ namespace Thrift\StringFunc;
23
+
24
+ use Thrift\StringFunc\TStringFunc;
25
+
26
+ class Mbstring implements TStringFunc {
27
+ public function substr($str, $start, $length = null) {
28
+ /**
29
+ * We need to set the charset parameter, which is the second
30
+ * optional parameter and the first optional parameter can't
31
+ * be null or false as a "magic" value because that would
32
+ * cause an empty string to be returned, so we need to
33
+ * actually calculate the proper length value.
34
+ */
35
+ if($length === null) {
36
+ $length = $this->strlen($str) - $start;
37
+ }
38
+
39
+ return mb_substr($str, $start, $length, '8bit');
40
+ }
41
+
42
+ public function strlen($str) {
43
+ return mb_strlen($str, '8bit');
44
+ }
45
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/StringFunc/TStringFunc.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ */
21
+
22
+ namespace Thrift\StringFunc;
23
+
24
+ interface TStringFunc {
25
+ public function substr($str, $start, $length = null);
26
+ public function strlen($str);
27
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/P13nTHttpClient.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Thrift\Transport;
3
+
4
+ use Thrift\Transport\TTransport;
5
+ use Thrift\Exception\TTransportException;
6
+ use Thrift\Factory\TStringFuncFactory;
7
+
8
+ class P13nTHttpClient extends THttpClient {
9
+
10
+ protected $authorizationString;
11
+
12
+ /**
13
+ * Opens and sends the actual request over the HTTP connection
14
+ *
15
+ * @throws TTransportException if a writing error occurs
16
+ */
17
+ public function flush() {
18
+ // God, PHP really has some esoteric ways of doing simple things.
19
+ $host = $this->host_.($this->port_ != 80 ? ':'.$this->port_ : '');
20
+
21
+ $headers = array('Host: '.$host,
22
+ 'Accept: application/x-thrift',
23
+ 'User-Agent: PHP/THttpClient',
24
+ 'Content-Type: application/x-thrift',
25
+ 'Content-Length: '.TStringFuncFactory::create()->strlen($this->buf_),
26
+ 'Authorization: Basic '.$this->authorizationString);
27
+
28
+ $options = array('method' => 'POST',
29
+ 'header' => implode("\r\n", $headers),
30
+ 'max_redirects' => 1,
31
+ 'content' => $this->buf_);
32
+ if ($this->timeout_ > 0) {
33
+ $options['timeout'] = $this->timeout_;
34
+ }
35
+ $this->buf_ = '';
36
+
37
+ $contextid = stream_context_create(array('http' => $options));
38
+ $this->handle_ = @fopen($this->scheme_.'://'.$host.$this->uri_, 'r', false, $contextid);
39
+
40
+ // Connect failed?
41
+ if ($this->handle_ === FALSE) {
42
+ $this->handle_ = null;
43
+ $error = 'P13nTHttpClient: Could not connect to '.$host.$this->uri_;
44
+ throw new TTransportException($error, TTransportException::NOT_OPEN);
45
+ }
46
+ }
47
+
48
+ public function setAuthorization($username, $password) {
49
+ $this->authorizationString = base64_encode($username.':'.$password);
50
+ }
51
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TBufferedTransport.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.transport
21
+ */
22
+
23
+ namespace Thrift\Transport;
24
+
25
+ use Thrift\Transport\TTransport;
26
+ use Thrift\Factory\TStringFuncFactory;
27
+
28
+ /**
29
+ * Buffered transport. Stores data to an internal buffer that it doesn't
30
+ * actually write out until flush is called. For reading, we do a greedy
31
+ * read and then serve data out of the internal buffer.
32
+ *
33
+ * @package thrift.transport
34
+ */
35
+ class TBufferedTransport extends TTransport {
36
+
37
+ /**
38
+ * Constructor. Creates a buffered transport around an underlying transport
39
+ */
40
+ public function __construct($transport=null, $rBufSize=512, $wBufSize=512) {
41
+ $this->transport_ = $transport;
42
+ $this->rBufSize_ = $rBufSize;
43
+ $this->wBufSize_ = $wBufSize;
44
+ }
45
+
46
+ /**
47
+ * The underlying transport
48
+ *
49
+ * @var TTransport
50
+ */
51
+ protected $transport_ = null;
52
+
53
+ /**
54
+ * The receive buffer size
55
+ *
56
+ * @var int
57
+ */
58
+ protected $rBufSize_ = 512;
59
+
60
+ /**
61
+ * The write buffer size
62
+ *
63
+ * @var int
64
+ */
65
+ protected $wBufSize_ = 512;
66
+
67
+ /**
68
+ * The write buffer.
69
+ *
70
+ * @var string
71
+ */
72
+ protected $wBuf_ = '';
73
+
74
+ /**
75
+ * The read buffer.
76
+ *
77
+ * @var string
78
+ */
79
+ protected $rBuf_ = '';
80
+
81
+ public function isOpen() {
82
+ return $this->transport_->isOpen();
83
+ }
84
+
85
+ public function open() {
86
+ $this->transport_->open();
87
+ }
88
+
89
+ public function close() {
90
+ $this->transport_->close();
91
+ }
92
+
93
+ public function putBack($data) {
94
+ if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) {
95
+ $this->rBuf_ = $data;
96
+ } else {
97
+ $this->rBuf_ = ($data . $this->rBuf_);
98
+ }
99
+ }
100
+
101
+ /**
102
+ * The reason that we customize readAll here is that the majority of PHP
103
+ * streams are already internally buffered by PHP. The socket stream, for
104
+ * example, buffers internally and blocks if you call read with $len greater
105
+ * than the amount of data available, unlike recv() in C.
106
+ *
107
+ * Therefore, use the readAll method of the wrapped transport inside
108
+ * the buffered readAll.
109
+ */
110
+ public function readAll($len) {
111
+ $have = TStringFuncFactory::create()->strlen($this->rBuf_);
112
+ if ($have == 0) {
113
+ $data = $this->transport_->readAll($len);
114
+ } else if ($have < $len) {
115
+ $data = $this->rBuf_;
116
+ $this->rBuf_ = '';
117
+ $data .= $this->transport_->readAll($len - $have);
118
+ } else if ($have == $len) {
119
+ $data = $this->rBuf_;
120
+ $this->rBuf_ = '';
121
+ } else if ($have > $len) {
122
+ $data = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len);
123
+ $this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len);
124
+ }
125
+ return $data;
126
+ }
127
+
128
+ public function read($len) {
129
+ if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) {
130
+ $this->rBuf_ = $this->transport_->read($this->rBufSize_);
131
+ }
132
+
133
+ if (TStringFuncFactory::create()->strlen($this->rBuf_) <= $len) {
134
+ $ret = $this->rBuf_;
135
+ $this->rBuf_ = '';
136
+ return $ret;
137
+ }
138
+
139
+ $ret = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len);
140
+ $this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len);
141
+ return $ret;
142
+ }
143
+
144
+ public function write($buf) {
145
+ $this->wBuf_ .= $buf;
146
+ if (TStringFuncFactory::create()->strlen($this->wBuf_) >= $this->wBufSize_) {
147
+ $out = $this->wBuf_;
148
+
149
+ // Note that we clear the internal wBuf_ prior to the underlying write
150
+ // to ensure we're in a sane state (i.e. internal buffer cleaned)
151
+ // if the underlying write throws up an exception
152
+ $this->wBuf_ = '';
153
+ $this->transport_->write($out);
154
+ }
155
+ }
156
+
157
+ public function flush() {
158
+ if (TStringFuncFactory::create()->strlen($this->wBuf_) > 0) {
159
+ $this->transport_->write($this->wBuf_);
160
+ $this->wBuf_ = '';
161
+ }
162
+ $this->transport_->flush();
163
+ }
164
+
165
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TFramedTransport.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.transport
21
+ */
22
+
23
+ namespace Thrift\Transport;
24
+
25
+ use Thrift\Transport\TTransport;
26
+ use Thrift\Factory\TStringFuncFactory;
27
+
28
+ /**
29
+ * Framed transport. Writes and reads data in chunks that are stamped with
30
+ * their length.
31
+ *
32
+ * @package thrift.transport
33
+ */
34
+ class TFramedTransport extends TTransport {
35
+
36
+ /**
37
+ * Underlying transport object.
38
+ *
39
+ * @var TTransport
40
+ */
41
+ private $transport_;
42
+
43
+ /**
44
+ * Buffer for read data.
45
+ *
46
+ * @var string
47
+ */
48
+ private $rBuf_;
49
+
50
+ /**
51
+ * Buffer for queued output data
52
+ *
53
+ * @var string
54
+ */
55
+ private $wBuf_;
56
+
57
+ /**
58
+ * Whether to frame reads
59
+ *
60
+ * @var bool
61
+ */
62
+ private $read_;
63
+
64
+ /**
65
+ * Whether to frame writes
66
+ *
67
+ * @var bool
68
+ */
69
+ private $write_;
70
+
71
+ /**
72
+ * Constructor.
73
+ *
74
+ * @param TTransport $transport Underlying transport
75
+ */
76
+ public function __construct($transport=null, $read=true, $write=true) {
77
+ $this->transport_ = $transport;
78
+ $this->read_ = $read;
79
+ $this->write_ = $write;
80
+ }
81
+
82
+ public function isOpen() {
83
+ return $this->transport_->isOpen();
84
+ }
85
+
86
+ public function open() {
87
+ $this->transport_->open();
88
+ }
89
+
90
+ public function close() {
91
+ $this->transport_->close();
92
+ }
93
+
94
+ /**
95
+ * Reads from the buffer. When more data is required reads another entire
96
+ * chunk and serves future reads out of that.
97
+ *
98
+ * @param int $len How much data
99
+ */
100
+ public function read($len) {
101
+ if (!$this->read_) {
102
+ return $this->transport_->read($len);
103
+ }
104
+
105
+ if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) {
106
+ $this->readFrame();
107
+ }
108
+
109
+ // Just return full buff
110
+ if ($len >= TStringFuncFactory::create()->strlen($this->rBuf_)) {
111
+ $out = $this->rBuf_;
112
+ $this->rBuf_ = null;
113
+ return $out;
114
+ }
115
+
116
+ // Return TStringFuncFactory::create()->substr
117
+ $out = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len);
118
+ $this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len);
119
+ return $out;
120
+ }
121
+
122
+ /**
123
+ * Put previously read data back into the buffer
124
+ *
125
+ * @param string $data data to return
126
+ */
127
+ public function putBack($data) {
128
+ if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) {
129
+ $this->rBuf_ = $data;
130
+ } else {
131
+ $this->rBuf_ = ($data . $this->rBuf_);
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Reads a chunk of data into the internal read buffer.
137
+ */
138
+ private function readFrame() {
139
+ $buf = $this->transport_->readAll(4);
140
+ $val = unpack('N', $buf);
141
+ $sz = $val[1];
142
+
143
+ $this->rBuf_ = $this->transport_->readAll($sz);
144
+ }
145
+
146
+ /**
147
+ * Writes some data to the pending output buffer.
148
+ *
149
+ * @param string $buf The data
150
+ * @param int $len Limit of bytes to write
151
+ */
152
+ public function write($buf, $len=null) {
153
+ if (!$this->write_) {
154
+ return $this->transport_->write($buf, $len);
155
+ }
156
+
157
+ if ($len !== null && $len < TStringFuncFactory::create()->strlen($buf)) {
158
+ $buf = TStringFuncFactory::create()->substr($buf, 0, $len);
159
+ }
160
+ $this->wBuf_ .= $buf;
161
+ }
162
+
163
+ /**
164
+ * Writes the output buffer to the stream in the format of a 4-byte length
165
+ * followed by the actual data.
166
+ */
167
+ public function flush() {
168
+ if (!$this->write_ || TStringFuncFactory::create()->strlen($this->wBuf_) == 0) {
169
+ return $this->transport_->flush();
170
+ }
171
+
172
+ $out = pack('N', TStringFuncFactory::create()->strlen($this->wBuf_));
173
+ $out .= $this->wBuf_;
174
+
175
+ // Note that we clear the internal wBuf_ prior to the underlying write
176
+ // to ensure we're in a sane state (i.e. internal buffer cleaned)
177
+ // if the underlying write throws up an exception
178
+ $this->wBuf_ = '';
179
+ $this->transport_->write($out);
180
+ $this->transport_->flush();
181
+ }
182
+
183
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/THttpClient.php ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.transport
21
+ */
22
+
23
+ namespace Thrift\Transport;
24
+
25
+ use Thrift\Transport\TTransport;
26
+ use Thrift\Exception\TTransportException;
27
+ use Thrift\Factory\TStringFuncFactory;
28
+
29
+ /**
30
+ * HTTP client for Thrift
31
+ *
32
+ * @package thrift.transport
33
+ */
34
+ class THttpClient extends TTransport {
35
+
36
+ /**
37
+ * The host to connect to
38
+ *
39
+ * @var string
40
+ */
41
+ protected $host_;
42
+
43
+ /**
44
+ * The port to connect on
45
+ *
46
+ * @var int
47
+ */
48
+ protected $port_;
49
+
50
+ /**
51
+ * The URI to request
52
+ *
53
+ * @var string
54
+ */
55
+ protected $uri_;
56
+
57
+ /**
58
+ * The scheme to use for the request, i.e. http, https
59
+ *
60
+ * @var string
61
+ */
62
+ protected $scheme_;
63
+
64
+ /**
65
+ * Buffer for the HTTP request data
66
+ *
67
+ * @var string
68
+ */
69
+ protected $buf_;
70
+
71
+ /**
72
+ * Input socket stream.
73
+ *
74
+ * @var resource
75
+ */
76
+ protected $handle_;
77
+
78
+ /**
79
+ * Read timeout
80
+ *
81
+ * @var float
82
+ */
83
+ protected $timeout_;
84
+
85
+ /**
86
+ * Make a new HTTP client.
87
+ *
88
+ * @param string $host
89
+ * @param int $port
90
+ * @param string $uri
91
+ */
92
+ public function __construct($host, $port=80, $uri='', $scheme = 'http') {
93
+ if ((TStringFuncFactory::create()->strlen($uri) > 0) && ($uri{0} != '/')) {
94
+ $uri = '/'.$uri;
95
+ }
96
+ $this->scheme_ = $scheme;
97
+ $this->host_ = $host;
98
+ $this->port_ = $port;
99
+ $this->uri_ = $uri;
100
+ $this->buf_ = '';
101
+ $this->handle_ = null;
102
+ $this->timeout_ = null;
103
+ }
104
+
105
+ /**
106
+ * Set read timeout
107
+ *
108
+ * @param float $timeout
109
+ */
110
+ public function setTimeoutSecs($timeout) {
111
+ $this->timeout_ = $timeout;
112
+ }
113
+
114
+ /**
115
+ * Whether this transport is open.
116
+ *
117
+ * @return boolean true if open
118
+ */
119
+ public function isOpen() {
120
+ return true;
121
+ }
122
+
123
+ /**
124
+ * Open the transport for reading/writing
125
+ *
126
+ * @throws TTransportException if cannot open
127
+ */
128
+ public function open() {}
129
+
130
+ /**
131
+ * Close the transport.
132
+ */
133
+ public function close() {
134
+ if ($this->handle_) {
135
+ @fclose($this->handle_);
136
+ $this->handle_ = null;
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Read some data into the array.
142
+ *
143
+ * @param int $len How much to read
144
+ * @return string The data that has been read
145
+ * @throws TTransportException if cannot read any more data
146
+ */
147
+ public function read($len) {
148
+ $data = @fread($this->handle_, $len);
149
+ if ($data === FALSE || $data === '') {
150
+ $md = stream_get_meta_data($this->handle_);
151
+ if ($md['timed_out']) {
152
+ throw new TTransportException('THttpClient: timed out reading '.$len.' bytes from '.$this->host_.':'.$this->port_.$this->uri_, TTransportException::TIMED_OUT);
153
+ } else {
154
+ throw new TTransportException('THttpClient: Could not read '.$len.' bytes from '.$this->host_.':'.$this->port_.$this->uri_, TTransportException::UNKNOWN);
155
+ }
156
+ }
157
+ return $data;
158
+ }
159
+
160
+ /**
161
+ * Writes some data into the pending buffer
162
+ *
163
+ * @param string $buf The data to write
164
+ * @throws TTransportException if writing fails
165
+ */
166
+ public function write($buf) {
167
+ $this->buf_ .= $buf;
168
+ }
169
+
170
+ /**
171
+ * Opens and sends the actual request over the HTTP connection
172
+ *
173
+ * @throws TTransportException if a writing error occurs
174
+ */
175
+ public function flush() {
176
+ // God, PHP really has some esoteric ways of doing simple things.
177
+ $host = $this->host_.($this->port_ != 80 ? ':'.$this->port_ : '');
178
+
179
+ $headers = array('Host: '.$host,
180
+ 'Accept: application/x-thrift',
181
+ 'User-Agent: PHP/THttpClient',
182
+ 'Content-Type: application/x-thrift',
183
+ 'Content-Length: '.TStringFuncFactory::create()->strlen($this->buf_),
184
+ 'Authorization: Basic Z2VzY2hlbmtpZGVlOlRoYWViOG9vdG9vWA==');
185
+
186
+ $options = array('method' => 'POST',
187
+ 'header' => implode("\r\n", $headers),
188
+ 'max_redirects' => 1,
189
+ 'content' => $this->buf_);
190
+ if ($this->timeout_ > 0) {
191
+ $options['timeout'] = $this->timeout_;
192
+ }
193
+ $this->buf_ = '';
194
+
195
+ $contextid = stream_context_create(array('http' => $options));
196
+ $this->handle_ = @fopen($this->scheme_.'://'.$host.$this->uri_, 'r', false, $contextid);
197
+
198
+ // Connect failed?
199
+ if ($this->handle_ === FALSE) {
200
+ $this->handle_ = null;
201
+ $error = 'THttpClient: Could not connect to '.$host.$this->uri_;
202
+ throw new TTransportException($error, TTransportException::NOT_OPEN);
203
+ }
204
+ }
205
+
206
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TMemoryBuffer.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.transport
21
+ */
22
+
23
+ namespace Thrift\Transport;
24
+
25
+ use Thrift\Transport\TTransport;
26
+ use Thrift\Exception\TTransportException;
27
+ use Thrift\Factory\TStringFuncFactory;
28
+
29
+ /**
30
+ * A memory buffer is a tranpsort that simply reads from and writes to an
31
+ * in-memory string buffer. Anytime you call write on it, the data is simply
32
+ * placed into a buffer, and anytime you call read, data is read from that
33
+ * buffer.
34
+ *
35
+ * @package thrift.transport
36
+ */
37
+ class TMemoryBuffer extends TTransport {
38
+
39
+ /**
40
+ * Constructor. Optionally pass an initial value
41
+ * for the buffer.
42
+ */
43
+ public function __construct($buf = '') {
44
+ $this->buf_ = $buf;
45
+ }
46
+
47
+ protected $buf_ = '';
48
+
49
+ public function isOpen() {
50
+ return true;
51
+ }
52
+
53
+ public function open() {}
54
+
55
+ public function close() {}
56
+
57
+ public function write($buf) {
58
+ $this->buf_ .= $buf;
59
+ }
60
+
61
+ public function read($len) {
62
+ $bufLength = TStringFuncFactory::create()->strlen($this->buf_);
63
+
64
+ if ($bufLength === 0) {
65
+ throw new TTransportException('TMemoryBuffer: Could not read ' .
66
+ $len . ' bytes from buffer.',
67
+ TTransportException::UNKNOWN);
68
+ }
69
+
70
+ if ($bufLength <= $len) {
71
+ $ret = $this->buf_;
72
+ $this->buf_ = '';
73
+ return $ret;
74
+ }
75
+
76
+ $ret = TStringFuncFactory::create()->substr($this->buf_, 0, $len);
77
+ $this->buf_ = TStringFuncFactory::create()->substr($this->buf_, $len);
78
+
79
+ return $ret;
80
+ }
81
+
82
+ function getBuffer() {
83
+ return $this->buf_;
84
+ }
85
+
86
+ public function available() {
87
+ return TStringFuncFactory::create()->strlen($this->buf_);
88
+ }
89
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TNullTransport.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.transport
21
+ */
22
+
23
+ namespace Thrift\Transport;
24
+
25
+ use Thrift\Transport\TTransport;
26
+ use Thrift\Exception\TTransportException;
27
+
28
+ /**
29
+ * Transport that only accepts writes and ignores them.
30
+ * This is useful for measuring the serialized size of structures.
31
+ *
32
+ * @package thrift.transport
33
+ */
34
+ class TNullTransport extends TTransport {
35
+
36
+ public function isOpen() {
37
+ return true;
38
+ }
39
+
40
+ public function open() {}
41
+
42
+ public function close() {}
43
+
44
+ public function read($len) {
45
+ throw new TTransportException("Can't read from TNullTransport.");
46
+ }
47
+
48
+ public function write($buf) {}
49
+
50
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TPhpStream.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.transport
21
+ */
22
+
23
+ namespace Thrift\Transport;
24
+
25
+ use Thrift\Transport\TTransport;
26
+ use Thrift\Exception\TException;
27
+ use Thrift\Factory\TStringFuncFactory;
28
+
29
+ /**
30
+ * Php stream transport. Reads to and writes from the php standard streams
31
+ * php://input and php://output
32
+ *
33
+ * @package thrift.transport
34
+ */
35
+ class TPhpStream extends TTransport {
36
+
37
+ const MODE_R = 1;
38
+ const MODE_W = 2;
39
+
40
+ private $inStream_ = null;
41
+
42
+ private $outStream_ = null;
43
+
44
+ private $read_ = false;
45
+
46
+ private $write_ = false;
47
+
48
+ public function __construct($mode) {
49
+ $this->read_ = $mode & self::MODE_R;
50
+ $this->write_ = $mode & self::MODE_W;
51
+ }
52
+
53
+ public function open() {
54
+ if ($this->read_) {
55
+ $this->inStream_ = @fopen(self::inStreamName(), 'r');
56
+ if (!is_resource($this->inStream_)) {
57
+ throw new TException('TPhpStream: Could not open php://input');
58
+ }
59
+ }
60
+ if ($this->write_) {
61
+ $this->outStream_ = @fopen('php://output', 'w');
62
+ if (!is_resource($this->outStream_)) {
63
+ throw new TException('TPhpStream: Could not open php://output');
64
+ }
65
+ }
66
+ }
67
+
68
+ public function close() {
69
+ if ($this->read_) {
70
+ @fclose($this->inStream_);
71
+ $this->inStream_ = null;
72
+ }
73
+ if ($this->write_) {
74
+ @fclose($this->outStream_);
75
+ $this->outStream_ = null;
76
+ }
77
+ }
78
+
79
+ public function isOpen() {
80
+ return
81
+ (!$this->read_ || is_resource($this->inStream_)) &&
82
+ (!$this->write_ || is_resource($this->outStream_));
83
+ }
84
+
85
+ public function read($len) {
86
+ $data = @fread($this->inStream_, $len);
87
+ if ($data === FALSE || $data === '') {
88
+ throw new TException('TPhpStream: Could not read '.$len.' bytes');
89
+ }
90
+ return $data;
91
+ }
92
+
93
+ public function write($buf) {
94
+ while (TStringFuncFactory::create()->strlen($buf) > 0) {
95
+ $got = @fwrite($this->outStream_, $buf);
96
+ if ($got === 0 || $got === FALSE) {
97
+ throw new TException('TPhpStream: Could not write '.TStringFuncFactory::create()->strlen($buf).' bytes');
98
+ }
99
+ $buf = TStringFuncFactory::create()->substr($buf, $got);
100
+ }
101
+ }
102
+
103
+ public function flush() {
104
+ @fflush($this->outStream_);
105
+ }
106
+
107
+ private static function inStreamName() {
108
+ if (php_sapi_name() == 'cli') {
109
+ return 'php://stdin';
110
+ }
111
+ return 'php://input';
112
+ }
113
+
114
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TSocket.php ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.transport
21
+ */
22
+
23
+ namespace Thrift\Transport;
24
+
25
+ use Thrift\Transport\TTransport;
26
+ use Thrift\Exception\TException;
27
+ use Thrift\Exception\TTransportException;
28
+ use Thrift\Factory\TStringFuncFactory;
29
+
30
+ /**
31
+ * Sockets implementation of the TTransport interface.
32
+ *
33
+ * @package thrift.transport
34
+ */
35
+ class TSocket extends TTransport {
36
+
37
+ /**
38
+ * Handle to PHP socket
39
+ *
40
+ * @var resource
41
+ */
42
+ private $handle_ = null;
43
+
44
+ /**
45
+ * Remote hostname
46
+ *
47
+ * @var string
48
+ */
49
+ protected $host_ = 'localhost';
50
+
51
+ /**
52
+ * Remote port
53
+ *
54
+ * @var int
55
+ */
56
+ protected $port_ = '9090';
57
+
58
+ /**
59
+ * Send timeout in seconds.
60
+ *
61
+ * Combined with sendTimeoutUsec this is used for send timeouts.
62
+ *
63
+ * @var int
64
+ */
65
+ private $sendTimeoutSec_ = 0;
66
+
67
+ /**
68
+ * Send timeout in microseconds.
69
+ *
70
+ * Combined with sendTimeoutSec this is used for send timeouts.
71
+ *
72
+ * @var int
73
+ */
74
+ private $sendTimeoutUsec_ = 100000;
75
+
76
+ /**
77
+ * Recv timeout in seconds
78
+ *
79
+ * Combined with recvTimeoutUsec this is used for recv timeouts.
80
+ *
81
+ * @var int
82
+ */
83
+ private $recvTimeoutSec_ = 0;
84
+
85
+ /**
86
+ * Recv timeout in microseconds
87
+ *
88
+ * Combined with recvTimeoutSec this is used for recv timeouts.
89
+ *
90
+ * @var int
91
+ */
92
+ private $recvTimeoutUsec_ = 750000;
93
+
94
+ /**
95
+ * Persistent socket or plain?
96
+ *
97
+ * @var bool
98
+ */
99
+ protected $persist_ = FALSE;
100
+
101
+ /**
102
+ * Debugging on?
103
+ *
104
+ * @var bool
105
+ */
106
+ protected $debug_ = FALSE;
107
+
108
+ /**
109
+ * Debug handler
110
+ *
111
+ * @var mixed
112
+ */
113
+ protected $debugHandler_ = null;
114
+
115
+ /**
116
+ * Socket constructor
117
+ *
118
+ * @param string $host Remote hostname
119
+ * @param int $port Remote port
120
+ * @param bool $persist Whether to use a persistent socket
121
+ * @param string $debugHandler Function to call for error logging
122
+ */
123
+ public function __construct($host='localhost',
124
+ $port=9090,
125
+ $persist=FALSE,
126
+ $debugHandler=null) {
127
+ $this->host_ = $host;
128
+ $this->port_ = $port;
129
+ $this->persist_ = $persist;
130
+ $this->debugHandler_ = $debugHandler ? $debugHandler : 'error_log';
131
+ }
132
+
133
+ /**
134
+ * @param resource $handle
135
+ * @return void
136
+ */
137
+ public function setHandle($handle) {
138
+ $this->handle_ = $handle;
139
+ }
140
+
141
+ /**
142
+ * Sets the send timeout.
143
+ *
144
+ * @param int $timeout Timeout in milliseconds.
145
+ */
146
+ public function setSendTimeout($timeout) {
147
+ $this->sendTimeoutSec_ = floor($timeout / 1000);
148
+ $this->sendTimeoutUsec_ =
149
+ ($timeout - ($this->sendTimeoutSec_ * 1000)) * 1000;
150
+ }
151
+
152
+ /**
153
+ * Sets the receive timeout.
154
+ *
155
+ * @param int $timeout Timeout in milliseconds.
156
+ */
157
+ public function setRecvTimeout($timeout) {
158
+ $this->recvTimeoutSec_ = floor($timeout / 1000);
159
+ $this->recvTimeoutUsec_ =
160
+ ($timeout - ($this->recvTimeoutSec_ * 1000)) * 1000;
161
+ }
162
+
163
+ /**
164
+ * Sets debugging output on or off
165
+ *
166
+ * @param bool $debug
167
+ */
168
+ public function setDebug($debug) {
169
+ $this->debug_ = $debug;
170
+ }
171
+
172
+ /**
173
+ * Get the host that this socket is connected to
174
+ *
175
+ * @return string host
176
+ */
177
+ public function getHost() {
178
+ return $this->host_;
179
+ }
180
+
181
+ /**
182
+ * Get the remote port that this socket is connected to
183
+ *
184
+ * @return int port
185
+ */
186
+ public function getPort() {
187
+ return $this->port_;
188
+ }
189
+
190
+ /**
191
+ * Tests whether this is open
192
+ *
193
+ * @return bool true if the socket is open
194
+ */
195
+ public function isOpen() {
196
+ return is_resource($this->handle_);
197
+ }
198
+
199
+ /**
200
+ * Connects the socket.
201
+ */
202
+ public function open() {
203
+ if ($this->isOpen()) {
204
+ throw new TTransportException('Socket already connected', TTransportException::ALREADY_OPEN);
205
+ }
206
+
207
+ if (empty($this->host_)) {
208
+ throw new TTransportException('Cannot open null host', TTransportException::NOT_OPEN);
209
+ }
210
+
211
+ if ($this->port_ <= 0) {
212
+ throw new TTransportException('Cannot open without port', TTransportException::NOT_OPEN);
213
+ }
214
+
215
+ if ($this->persist_) {
216
+ $this->handle_ = @pfsockopen($this->host_,
217
+ $this->port_,
218
+ $errno,
219
+ $errstr,
220
+ $this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000));
221
+ } else {
222
+ $this->handle_ = @fsockopen($this->host_,
223
+ $this->port_,
224
+ $errno,
225
+ $errstr,
226
+ $this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000));
227
+ }
228
+
229
+ // Connect failed?
230
+ if ($this->handle_ === FALSE) {
231
+ $error = 'TSocket: Could not connect to '.$this->host_.':'.$this->port_.' ('.$errstr.' ['.$errno.'])';
232
+ if ($this->debug_) {
233
+ call_user_func($this->debugHandler_, $error);
234
+ }
235
+ throw new TException($error);
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Closes the socket.
241
+ */
242
+ public function close() {
243
+ if (!$this->persist_) {
244
+ @fclose($this->handle_);
245
+ $this->handle_ = null;
246
+ }
247
+ }
248
+
249
+ /**
250
+ * Read from the socket at most $len bytes.
251
+ *
252
+ * This method will not wait for all the requested data, it will return as
253
+ * soon as any data is received.
254
+ *
255
+ * @param int $len Maximum number of bytes to read.
256
+ * @return string Binary data
257
+ */
258
+ public function read($len) {
259
+ $null = null;
260
+ $read = array($this->handle_);
261
+ $readable = @stream_select($read, $null, $null, $this->recvTimeoutSec_, $this->recvTimeoutUsec_);
262
+
263
+ if ($readable > 0) {
264
+ $data = @stream_socket_recvfrom($this->handle_, $len);
265
+ if ($data === false) {
266
+ throw new TTransportException('TSocket: Could not read '.$len.' bytes from '.
267
+ $this->host_.':'.$this->port_);
268
+ } elseif($data == '' && feof($this->handle_)) {
269
+ throw new TTransportException('TSocket read 0 bytes');
270
+ }
271
+
272
+ return $data;
273
+ } else if ($readable === 0) {
274
+ throw new TTransportException('TSocket: timed out reading '.$len.' bytes from '.
275
+ $this->host_.':'.$this->port_);
276
+ } else {
277
+ throw new TTransportException('TSocket: Could not read '.$len.' bytes from '.
278
+ $this->host_.':'.$this->port_);
279
+ }
280
+ }
281
+
282
+ /**
283
+ * Write to the socket.
284
+ *
285
+ * @param string $buf The data to write
286
+ */
287
+ public function write($buf) {
288
+ $null = null;
289
+ $write = array($this->handle_);
290
+
291
+ // keep writing until all the data has been written
292
+ while (TStringFuncFactory::create()->strlen($buf) > 0) {
293
+ // wait for stream to become available for writing
294
+ $writable = @stream_select($null, $write, $null, $this->sendTimeoutSec_, $this->sendTimeoutUsec_);
295
+ if ($writable > 0) {
296
+ // write buffer to stream
297
+ $written = @stream_socket_sendto($this->handle_, $buf);
298
+ if ($written === -1 || $written === false) {
299
+ throw new TTransportException('TSocket: Could not write '.TStringFuncFactory::create()->strlen($buf).' bytes '.
300
+ $this->host_.':'.$this->port_);
301
+ }
302
+ // determine how much of the buffer is left to write
303
+ $buf = TStringFuncFactory::create()->substr($buf, $written);
304
+ } else if ($writable === 0) {
305
+ throw new TTransportException('TSocket: timed out writing '.TStringFuncFactory::create()->strlen($buf).' bytes from '.
306
+ $this->host_.':'.$this->port_);
307
+ } else {
308
+ throw new TTransportException('TSocket: Could not write '.TStringFuncFactory::create()->strlen($buf).' bytes '.
309
+ $this->host_.':'.$this->port_);
310
+ }
311
+ }
312
+ }
313
+
314
+ /**
315
+ * Flush output to the socket.
316
+ *
317
+ * Since read(), readAll() and write() operate on the sockets directly,
318
+ * this is a no-op
319
+ *
320
+ * If you wish to have flushable buffering behaviour, wrap this TSocket
321
+ * in a TBufferedTransport.
322
+ */
323
+ public function flush() {
324
+ // no-op
325
+ }
326
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TSocketPool.php ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.transport
21
+ */
22
+
23
+ namespace Thrift\Transport;
24
+
25
+ use Thrift\Transport\TSocket;
26
+ use Thrift\Exception\TException;
27
+
28
+ /**
29
+ * This library makes use of APC cache to make hosts as down in a web
30
+ * environment. If you are running from the CLI or on a system without APC
31
+ * installed, then these null functions will step in and act like cache
32
+ * misses.
33
+ */
34
+ if (!function_exists('apc_fetch')) {
35
+ function apc_fetch($key) { return FALSE; }
36
+ function apc_store($key, $var, $ttl=0) { return FALSE; }
37
+ }
38
+
39
+ /**
40
+ * Sockets implementation of the TTransport interface that allows connection
41
+ * to a pool of servers.
42
+ *
43
+ * @package thrift.transport
44
+ */
45
+ class TSocketPool extends TSocket {
46
+
47
+ /**
48
+ * Remote servers. Array of associative arrays with 'host' and 'port' keys
49
+ */
50
+ private $servers_ = array();
51
+
52
+ /**
53
+ * How many times to retry each host in connect
54
+ *
55
+ * @var int
56
+ */
57
+ private $numRetries_ = 1;
58
+
59
+ /**
60
+ * Retry interval in seconds, how long to not try a host if it has been
61
+ * marked as down.
62
+ *
63
+ * @var int
64
+ */
65
+ private $retryInterval_ = 60;
66
+
67
+ /**
68
+ * Max consecutive failures before marking a host down.
69
+ *
70
+ * @var int
71
+ */
72
+ private $maxConsecutiveFailures_ = 1;
73
+
74
+ /**
75
+ * Try hosts in order? or Randomized?
76
+ *
77
+ * @var bool
78
+ */
79
+ private $randomize_ = TRUE;
80
+
81
+ /**
82
+ * Always try last host, even if marked down?
83
+ *
84
+ * @var bool
85
+ */
86
+ private $alwaysTryLast_ = TRUE;
87
+
88
+ /**
89
+ * Socket pool constructor
90
+ *
91
+ * @param array $hosts List of remote hostnames
92
+ * @param mixed $ports Array of remote ports, or a single common port
93
+ * @param bool $persist Whether to use a persistent socket
94
+ * @param mixed $debugHandler Function for error logging
95
+ */
96
+ public function __construct($hosts=array('localhost'),
97
+ $ports=array(9090),
98
+ $persist=FALSE,
99
+ $debugHandler=null) {
100
+ parent::__construct(null, 0, $persist, $debugHandler);
101
+
102
+ if (!is_array($ports)) {
103
+ $port = $ports;
104
+ $ports = array();
105
+ foreach ($hosts as $key => $val) {
106
+ $ports[$key] = $port;
107
+ }
108
+ }
109
+
110
+ foreach ($hosts as $key => $host) {
111
+ $this->servers_ []= array('host' => $host,
112
+ 'port' => $ports[$key]);
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Add a server to the pool
118
+ *
119
+ * This function does not prevent you from adding a duplicate server entry.
120
+ *
121
+ * @param string $host hostname or IP
122
+ * @param int $port port
123
+ */
124
+ public function addServer($host, $port) {
125
+ $this->servers_[] = array('host' => $host, 'port' => $port);
126
+ }
127
+
128
+ /**
129
+ * Sets how many time to keep retrying a host in the connect function.
130
+ *
131
+ * @param int $numRetries
132
+ */
133
+ public function setNumRetries($numRetries) {
134
+ $this->numRetries_ = $numRetries;
135
+ }
136
+
137
+ /**
138
+ * Sets how long to wait until retrying a host if it was marked down
139
+ *
140
+ * @param int $numRetries
141
+ */
142
+ public function setRetryInterval($retryInterval) {
143
+ $this->retryInterval_ = $retryInterval;
144
+ }
145
+
146
+ /**
147
+ * Sets how many time to keep retrying a host before marking it as down.
148
+ *
149
+ * @param int $numRetries
150
+ */
151
+ public function setMaxConsecutiveFailures($maxConsecutiveFailures) {
152
+ $this->maxConsecutiveFailures_ = $maxConsecutiveFailures;
153
+ }
154
+
155
+ /**
156
+ * Turns randomization in connect order on or off.
157
+ *
158
+ * @param bool $randomize
159
+ */
160
+ public function setRandomize($randomize) {
161
+ $this->randomize_ = $randomize;
162
+ }
163
+
164
+ /**
165
+ * Whether to always try the last server.
166
+ *
167
+ * @param bool $alwaysTryLast
168
+ */
169
+ public function setAlwaysTryLast($alwaysTryLast) {
170
+ $this->alwaysTryLast_ = $alwaysTryLast;
171
+ }
172
+
173
+
174
+ /**
175
+ * Connects the socket by iterating through all the servers in the pool
176
+ * and trying to find one that works.
177
+ */
178
+ public function open() {
179
+ // Check if we want order randomization
180
+ if ($this->randomize_) {
181
+ shuffle($this->servers_);
182
+ }
183
+
184
+ // Count servers to identify the "last" one
185
+ $numServers = count($this->servers_);
186
+
187
+ for ($i = 0; $i < $numServers; ++$i) {
188
+
189
+ // This extracts the $host and $port variables
190
+ extract($this->servers_[$i]);
191
+
192
+ // Check APC cache for a record of this server being down
193
+ $failtimeKey = 'thrift_failtime:'.$host.':'.$port.'~';
194
+
195
+ // Cache miss? Assume it's OK
196
+ $lastFailtime = apc_fetch($failtimeKey);
197
+ if ($lastFailtime === FALSE) {
198
+ $lastFailtime = 0;
199
+ }
200
+
201
+ $retryIntervalPassed = FALSE;
202
+
203
+ // Cache hit...make sure enough the retry interval has elapsed
204
+ if ($lastFailtime > 0) {
205
+ $elapsed = time() - $lastFailtime;
206
+ if ($elapsed > $this->retryInterval_) {
207
+ $retryIntervalPassed = TRUE;
208
+ if ($this->debug_) {
209
+ call_user_func($this->debugHandler_,
210
+ 'TSocketPool: retryInterval '.
211
+ '('.$this->retryInterval_.') '.
212
+ 'has passed for host '.$host.':'.$port);
213
+ }
214
+ }
215
+ }
216
+
217
+ // Only connect if not in the middle of a fail interval, OR if this
218
+ // is the LAST server we are trying, just hammer away on it
219
+ $isLastServer = FALSE;
220
+ if ($this->alwaysTryLast_) {
221
+ $isLastServer = ($i == ($numServers - 1));
222
+ }
223
+
224
+ if (($lastFailtime === 0) ||
225
+ ($isLastServer) ||
226
+ ($lastFailtime > 0 && $retryIntervalPassed)) {
227
+
228
+ // Set underlying TSocket params to this one
229
+ $this->host_ = $host;
230
+ $this->port_ = $port;
231
+
232
+ // Try up to numRetries_ connections per server
233
+ for ($attempt = 0; $attempt < $this->numRetries_; $attempt++) {
234
+ try {
235
+ // Use the underlying TSocket open function
236
+ parent::open();
237
+
238
+ // Only clear the failure counts if required to do so
239
+ if ($lastFailtime > 0) {
240
+ apc_store($failtimeKey, 0);
241
+ }
242
+
243
+ // Successful connection, return now
244
+ return;
245
+
246
+ } catch (TException $tx) {
247
+ // Connection failed
248
+ }
249
+ }
250
+
251
+ // Mark failure of this host in the cache
252
+ $consecfailsKey = 'thrift_consecfails:'.$host.':'.$port.'~';
253
+
254
+ // Ignore cache misses
255
+ $consecfails = apc_fetch($consecfailsKey);
256
+ if ($consecfails === FALSE) {
257
+ $consecfails = 0;
258
+ }
259
+
260
+ // Increment by one
261
+ $consecfails++;
262
+
263
+ // Log and cache this failure
264
+ if ($consecfails >= $this->maxConsecutiveFailures_) {
265
+ if ($this->debug_) {
266
+ call_user_func($this->debugHandler_,
267
+ 'TSocketPool: marking '.$host.':'.$port.
268
+ ' as down for '.$this->retryInterval_.' secs '.
269
+ 'after '.$consecfails.' failed attempts.');
270
+ }
271
+ // Store the failure time
272
+ apc_store($failtimeKey, time());
273
+
274
+ // Clear the count of consecutive failures
275
+ apc_store($consecfailsKey, 0);
276
+ } else {
277
+ apc_store($consecfailsKey, $consecfails);
278
+ }
279
+ }
280
+ }
281
+
282
+ // Oh no; we failed them all. The system is totally ill!
283
+ $error = 'TSocketPool: All hosts in pool are down. ';
284
+ $hosts = array();
285
+ foreach ($this->servers_ as $server) {
286
+ $hosts []= $server['host'].':'.$server['port'];
287
+ }
288
+ $hostlist = implode(',', $hosts);
289
+ $error .= '('.$hostlist.')';
290
+ if ($this->debug_) {
291
+ call_user_func($this->debugHandler_, $error);
292
+ }
293
+ throw new TException($error);
294
+ }
295
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Transport/TTransport.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift.transport
21
+ */
22
+
23
+ namespace Thrift\Transport;
24
+
25
+ use Thrift\Factory\TStringFuncFactory;
26
+
27
+ /**
28
+ * Base interface for a transport agent.
29
+ *
30
+ * @package thrift.transport
31
+ */
32
+ abstract class TTransport {
33
+
34
+ /**
35
+ * Whether this transport is open.
36
+ *
37
+ * @return boolean true if open
38
+ */
39
+ public abstract function isOpen();
40
+
41
+ /**
42
+ * Open the transport for reading/writing
43
+ *
44
+ * @throws TTransportException if cannot open
45
+ */
46
+ public abstract function open();
47
+
48
+ /**
49
+ * Close the transport.
50
+ */
51
+ public abstract function close();
52
+
53
+ /**
54
+ * Read some data into the array.
55
+ *
56
+ * @param int $len How much to read
57
+ * @return string The data that has been read
58
+ * @throws TTransportException if cannot read any more data
59
+ */
60
+ public abstract function read($len);
61
+
62
+ /**
63
+ * Guarantees that the full amount of data is read.
64
+ *
65
+ * @return string The data, of exact length
66
+ * @throws TTransportException if cannot read data
67
+ */
68
+ public function readAll($len) {
69
+ // return $this->read($len);
70
+
71
+ $data = '';
72
+ $got = 0;
73
+ while (($got = TStringFuncFactory::create()->strlen($data)) < $len) {
74
+ $data .= $this->read($len - $got);
75
+ }
76
+ return $data;
77
+ }
78
+
79
+ /**
80
+ * Writes the given data out.
81
+ *
82
+ * @param string $buf The data to write
83
+ * @throws TTransportException if writing fails
84
+ */
85
+ public abstract function write($buf);
86
+
87
+ /**
88
+ * Flushes any pending data out of a buffer
89
+ *
90
+ * @throws TTransportException if a writing error occurs
91
+ */
92
+ public function flush() {}
93
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Type/TMessageType.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift
21
+ */
22
+
23
+ namespace Thrift\Type;
24
+
25
+ /**
26
+ * Message types for RPC
27
+ */
28
+ class TMessageType {
29
+ const CALL = 1;
30
+ const REPLY = 2;
31
+ const EXCEPTION = 3;
32
+ const ONEWAY = 4;
33
+ }
app/code/local/Boxalino/CemSearch/Lib/vendor/Thrift/Type/TType.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ * @package thrift
21
+ */
22
+
23
+ namespace Thrift\Type;
24
+
25
+ /**
26
+ * Data types that can be sent via Thrift
27
+ */
28
+ class TType {
29
+ const STOP = 0;
30
+ const VOID = 1;
31
+ const BOOL = 2;
32
+ const BYTE = 3;
33
+ const I08 = 3;
34
+ const DOUBLE = 4;
35
+ const I16 = 6;
36
+ const I32 = 8;
37
+ const I64 = 10;
38
+ const STRING = 11;
39
+ const UTF7 = 11;
40
+ const STRUCT = 12;
41
+ const MAP = 13;
42
+ const SET = 14;
43
+ const LST = 15; // N.B. cannot use LIST keyword in PHP!
44
+ const UTF8 = 16;
45
+ const UTF16 = 17;
46
+ }
app/code/local/Boxalino/CemSearch/Model/Advanced.php ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by: Szymon Nosal <szymon.nosal@codete.com>
4
+ * Created at: 06.06.14 11:45
5
+ */
6
+
7
+ require_once "Mage/CatalogSearch/Model/Advanced.php";
8
+
9
+ /**
10
+ *
11
+ * @category Mage
12
+ * @package Mage_CatalogSearch
13
+ * @author Szymon Nosal <szymon.nosal@codete.com>
14
+ */
15
+ //class Boxalino_CemSearch_Model_Advanced extends Mage_Core_Model_Abstract
16
+ class Boxalino_CemSearch_Model_Advanced extends Mage_CatalogSearch_Model_Advanced
17
+ {
18
+ /**
19
+ * User friendly search criteria list
20
+ *
21
+ * @var array
22
+ */
23
+ protected $_searchCriterias = array();
24
+
25
+ /**
26
+ * Current search engine
27
+ *
28
+ * @var object|Mage_CatalogSearch_Model_Resource_Fulltext_Engine
29
+ */
30
+ protected $_engine;
31
+
32
+ /**
33
+ * Found products collection
34
+ *
35
+ * @var Mage_CatalogSearch_Model_Resource_Advanced_Collection
36
+ */
37
+ protected $_productCollection;
38
+
39
+ /**
40
+ * Add advanced search filters to product collection
41
+ *
42
+ * @param array $values
43
+ * @return Mage_CatalogSearch_Model_Advanced
44
+ */
45
+ public function addFilters($values, $ids = null)
46
+ {
47
+
48
+ if (Mage::getStoreConfig('Boxalino_General/general/enabled', 0) == 0) {
49
+ return parent::addFilters($values, $ids);
50
+ }
51
+
52
+ $attributes = $this->getAttributes();
53
+ $hasConditions = true;
54
+ $allConditions = array();
55
+
56
+ foreach ($attributes as $attribute) {
57
+ /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
58
+ if (!isset($values[$attribute->getAttributeCode()])) {
59
+ continue;
60
+ }
61
+ $value = $values[$attribute->getAttributeCode()];
62
+ if (!is_array($value)) {
63
+ $value = trim($value);
64
+ }
65
+
66
+ if ($attribute->getAttributeCode() == 'price') {
67
+ $value['from'] = isset($value['from']) ? trim($value['from']) : '';
68
+ $value['to'] = isset($value['to']) ? trim($value['to']) : '';
69
+ if (is_numeric($value['from']) || is_numeric($value['to'])) {
70
+ if (!empty($value['currency'])) {
71
+ $rate = Mage::app()->getStore()->getBaseCurrency()->getRate($value['currency']);
72
+ } else {
73
+ $rate = 1;
74
+ }
75
+ // if ($this->_getResource()->addRatedPriceFilter(
76
+ // $this->getProductCollection(), $attribute, $value, $rate)
77
+ // ) {
78
+ // $hasConditions = true;
79
+ // $this->_addSearchCriteria($attribute, $value);
80
+ // }
81
+ $this->_addSearchCriteria($attribute, $value);
82
+ }
83
+ } else if ($attribute->isIndexable()) {
84
+ if (!is_string($value) || strlen($value) != 0) {
85
+ // if ($this->_getResource()->addIndexableAttributeModifiedFilter(
86
+ // $this->getProductCollection(), $attribute, $value)) {
87
+ // $hasConditions = true;
88
+ // $this->_addSearchCriteria($attribute, $value);
89
+ // }
90
+ $this->_addSearchCriteria($attribute, $value);
91
+ }
92
+ } else {
93
+ $condition = $this->_prepareCondition($attribute, $value);
94
+ if ($condition === false) {
95
+ continue;
96
+ }
97
+
98
+ $this->_addSearchCriteria($attribute, $value);
99
+
100
+ // $table = $attribute->getBackend()->getTable();
101
+ // if ($attribute->getBackendType() == 'static'){
102
+ // $attributeId = $attribute->getAttributeCode();
103
+ // } else {
104
+ // $attributeId = $attribute->getId();
105
+ // }
106
+ // $allConditions[$table][$attributeId] = $condition;
107
+ }
108
+ }
109
+ // $allConditions = array();
110
+ //Add id from boxalino
111
+ $this->getProductCollection()->addIdFromBoxalino($ids);
112
+ if ($allConditions) {
113
+ $this->getProductCollection()->addIdFromBoxalino($allConditions);
114
+ } else if (!$hasConditions) {
115
+ Mage::throwException(Mage::helper('catalogsearch')->__('Please specify at least one search term.'));
116
+ }
117
+
118
+ return $this;
119
+ }
120
+
121
+ /**
122
+ * Retrieve array of attributes used in advanced search
123
+ *
124
+ * @return array
125
+ */
126
+ public function getAttributes()
127
+ {
128
+ /* @var $attributes Mage_Catalog_Model_Resource_Eav_Resource_Product_Attribute_Collection */
129
+ $attributes = $this->getData('attributes');
130
+ if (is_null($attributes)) {
131
+ $product = Mage::getModel('catalog/product');
132
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
133
+ ->addHasOptionsFilter()
134
+ ->addDisplayInAdvancedSearchFilter()
135
+ ->addStoreLabel(Mage::app()->getStore()->getId())
136
+ ->setOrder('main_table.attribute_id', 'asc')
137
+ ->load();
138
+ foreach ($attributes as $attribute) {
139
+ $attribute->setEntity($product->getResource());
140
+ }
141
+ $this->setData('attributes', $attributes);
142
+ }
143
+ return $attributes;
144
+ }
145
+
146
+ /**
147
+ * Add data about search criteria to object state
148
+ *
149
+ * @param Mage_Eav_Model_Entity_Attribute $attribute
150
+ * @param mixed $value
151
+ * @return Mage_CatalogSearch_Model_Advanced
152
+ */
153
+ protected function _addSearchCriteria($attribute, $value)
154
+ {
155
+ $name = $attribute->getStoreLabel();
156
+
157
+ if (is_array($value)) {
158
+ if (isset($value['from']) && isset($value['to'])) {
159
+ if (!empty($value['from']) || !empty($value['to'])) {
160
+ if (isset($value['currency'])) {
161
+ $currencyModel = Mage::getModel('directory/currency')->load($value['currency']);
162
+ $from = $currencyModel->format($value['from'], array(), false);
163
+ $to = $currencyModel->format($value['to'], array(), false);
164
+ } else {
165
+ $currencyModel = null;
166
+ }
167
+
168
+ if (strlen($value['from']) > 0 && strlen($value['to']) > 0) {
169
+ // -
170
+ $value = sprintf('%s - %s',
171
+ ($currencyModel ? $from : $value['from']), ($currencyModel ? $to : $value['to']));
172
+ } elseif (strlen($value['from']) > 0) {
173
+ // and more
174
+ $value = Mage::helper('catalogsearch')->__('%s and greater', ($currencyModel ? $from : $value['from']));
175
+ } elseif (strlen($value['to']) > 0) {
176
+ // to
177
+ $value = Mage::helper('catalogsearch')->__('up to %s', ($currencyModel ? $to : $value['to']));
178
+ }
179
+ } else {
180
+ return $this;
181
+ }
182
+ }
183
+ }
184
+
185
+ if (($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'multiselect')
186
+ && is_array($value)
187
+ ) {
188
+ foreach ($value as $key => $val) {
189
+ $value[$key] = $attribute->getSource()->getOptionText($val);
190
+
191
+ if (is_array($value[$key])) {
192
+ $value[$key] = $value[$key]['label'];
193
+ }
194
+ }
195
+ $value = implode(', ', $value);
196
+ } else if ($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'multiselect') {
197
+ $value = $attribute->getSource()->getOptionText($value);
198
+ if (is_array($value))
199
+ $value = $value['label'];
200
+ } else if ($attribute->getFrontendInput() == 'boolean') {
201
+ $value = $value == 1
202
+ ? Mage::helper('catalogsearch')->__('Yes')
203
+ : Mage::helper('catalogsearch')->__('No');
204
+ }
205
+
206
+ $this->_searchCriterias[] = array('name' => $name, 'value' => $value);
207
+ return $this;
208
+ }
209
+
210
+ /**
211
+ * Prepare search condition for attribute
212
+ *
213
+ * @deprecated after 1.4.1.0 - use Mage_CatalogSearch_Model_Resource_Advanced->_prepareCondition()
214
+ *
215
+ * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
216
+ * @param string|array $value
217
+ * @return mixed
218
+ */
219
+ protected function _prepareCondition($attribute, $value)
220
+ {
221
+ return $this->_getResource()->prepareCondition($attribute, $value, $this->getProductCollection());
222
+ }
223
+
224
+ /**
225
+ * Retrieve resource instance wrapper
226
+ *
227
+ * @return Mage_CatalogSearch_Model_Resource_Advanced
228
+ */
229
+ protected function _getResource()
230
+ {
231
+ $resourceName = $this->_engine->getResourceName();
232
+ if ($resourceName) {
233
+ $this->_resourceName = $resourceName;
234
+ }
235
+ return parent::_getResource();
236
+ }
237
+
238
+ /**
239
+ * Retrieve advanced search product collection
240
+ *
241
+ * @return Mage_CatalogSearch_Model_Resource_Advanced_Collection
242
+ */
243
+ public function getProductCollection()
244
+ {
245
+
246
+ if (is_null($this->_productCollection)) {
247
+ $collection = $this->_engine->getAdvancedResultCollection();
248
+ $this->prepareProductCollection($collection);
249
+ if (!$collection) {
250
+ return $collection;
251
+ }
252
+ $this->_productCollection = $collection;
253
+ }
254
+
255
+ return $this->_productCollection;
256
+ }
257
+
258
+ /**
259
+ * Prepare product collection
260
+ *
261
+ * @param Mage_CatalogSearch_Model_Resource_Advanced_Collection $collection
262
+ * @return Mage_Catalog_Model_Layer
263
+ */
264
+ public function prepareProductCollection($collection)
265
+ {
266
+ $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
267
+ ->setStore(Mage::app()->getStore())
268
+ ->addMinimalPrice()
269
+ ->addTaxPercents()
270
+ ->addStoreFilter();
271
+
272
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
273
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
274
+ return $this;
275
+ }
276
+
277
+ /**
278
+ * Returns prepared search criterias in text
279
+ *
280
+ * @return array
281
+ */
282
+ public function getSearchCriterias()
283
+ {
284
+ return $this->_searchCriterias;
285
+ }
286
+
287
+ /**
288
+ * Initialize resource model
289
+ *
290
+ */
291
+ protected function _construct()
292
+ {
293
+ $this->_getEngine();
294
+ $this->_init('catalogsearch/advanced');
295
+ }
296
+
297
+ protected function _getEngine()
298
+ {
299
+ if ($this->_engine == null) {
300
+ $this->_engine = Mage::helper('catalogsearch')->getEngine();
301
+ }
302
+
303
+ return $this->_engine;
304
+ }
305
+ }
app/code/local/Boxalino/CemSearch/Model/Logger.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Boxalino_CemSearch_Model_Logger
4
+ {
5
+ static private $_lastMemory = 0;
6
+ static private $_startLogging = null;
7
+ static private $_fileName = null;
8
+
9
+ /**
10
+ * @param string $type Error, Warning, Info, Success
11
+ * @param array $data array('memory_usage' => '', 'method' => '', 'description' => ''),
12
+ */
13
+ static public function saveMemoryTracking($type, $loggedAction, array $data)
14
+ {
15
+ if(Mage::getStoreConfig('Boxalino_General/general/logs_saving')) {
16
+ if (self::$_startLogging == null) {
17
+ self::$_startLogging = date('d-m-Y_H:i:s');
18
+ }
19
+ if (self::$_fileName == null) {
20
+ self::initFile($loggedAction . '-' . self::$_startLogging . '.txt');
21
+ }
22
+ $difference = $data['memory_usage'] - self::$_lastMemory;
23
+ $line = date('d-m-Y H:i:s').' '.strtoupper($type).': '.$loggedAction.' / '.$data['method'].' / '.$data['description'].'. Memory usage: '.$data['memory_usage']. ' - Difference='. $difference . "\n";
24
+ file_put_contents(self::$_fileName, $line, FILE_APPEND);
25
+ self::$_lastMemory = $data['memory_usage'];
26
+ }
27
+ }
28
+
29
+ static private function initFile($name)
30
+ {
31
+ $logDir = Mage::getBaseDir('var') . DS . 'boxalino_logs';
32
+ self::$_fileName = $logDir . DS . $name;
33
+
34
+ if (!is_dir($logDir)) {
35
+ mkdir($logDir);
36
+ chmod($logDir, 0777);
37
+ }
38
+
39
+ if (!file_exists(self::$_fileName)) {
40
+ file_put_contents(self::$_fileName, '');
41
+ chmod(self::$_fileName, 0777);
42
+ }
43
+ }
44
+ }
app/code/local/Boxalino/CemSearch/Model/Observer.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Boxalino CemExport event observer
5
+ *
6
+ * @author nitro@boxalino.com
7
+ */
8
+ class Boxalino_CemSearch_Model_Observer
9
+ {
10
+ public function onProductAddedToCart(Varien_Event_Observer $event)
11
+ {
12
+ try {
13
+ $session = Mage::getSingleton('Boxalino_CemSearch_Model_Session');
14
+ $script = Mage::helper('Boxalino_CemSearch')->reportAddToBasket(
15
+ $event->getProduct()->getId(),
16
+ $event->getQuoteItem()->getQty(),
17
+ $event->getProduct()->getSpecialPrice() > 0 ? $event->getProduct()->getSpecialPrice() : $event->getProduct()->getPrice(),
18
+ Mage::app()->getStore()->getCurrentCurrencyCode()
19
+ );
20
+ $session->addScript($script);
21
+ } catch (Exception $e) {
22
+ if (Mage::helper('Boxalino_CemSearch')->isDebugEnabled()) {
23
+ echo($e);
24
+ exit;
25
+ }
26
+ }
27
+ }
28
+
29
+ public function onOrderSuccessPageView(Varien_Event_Observer $event)
30
+ {
31
+ try {
32
+ $orders = Mage::getModel('sales/order')->getCollection()
33
+ ->setOrder('entity_id','DESC')
34
+ ->setPageSize(1)
35
+ ->setCurPage(1);
36
+ $order = $orders->getFirstItem();
37
+ $orderData = $order->getData();
38
+ $transactionId = $orderData['entity_id'];
39
+ $products = array();
40
+ $fullPrice = 0;
41
+ foreach ($order->getAllItems() as $item) {
42
+ if ($item->getPrice() > 0) {
43
+ $products[] = array(
44
+ 'product' => $item->getProduct()->getId(),
45
+ 'quantity' => $item->getData('qty_ordered'),
46
+ 'price' => $item->getPrice()
47
+ );
48
+ $fullPrice = $fullPrice + $item->getPrice();
49
+ }
50
+ }
51
+ $script = Mage::helper('Boxalino_CemSearch')->reportPurchase($products, $transactionId, $fullPrice, Mage::app()->getStore()->getCurrentCurrencyCode());
52
+
53
+ $session = Mage::getSingleton('Boxalino_CemSearch_Model_Session');
54
+ $session->addScript($script);
55
+ } catch (Exception $e) {
56
+ if (Mage::helper('Boxalino_CemSearch')->isDebugEnabled()) {
57
+ echo($e);
58
+ exit;
59
+ }
60
+ }
61
+ }
62
+
63
+ public function onProductPageView(Varien_Event_Observer $event)
64
+ {
65
+ try {
66
+ $productId = $event['product']->getId();
67
+ $script = Mage::helper('Boxalino_CemSearch')->reportProductView($productId);
68
+
69
+ $session = Mage::getSingleton('Boxalino_CemSearch_Model_Session');
70
+ $session->addScript($script);
71
+ } catch (Exception $e) {
72
+ if (Mage::helper('Boxalino_CemSearch')->isDebugEnabled()) {
73
+ echo($e);
74
+ exit;
75
+ }
76
+ }
77
+ }
78
+
79
+ public function onCategoryPageView(Varien_Event_Observer $event)
80
+ {
81
+
82
+ try {
83
+ $categoryId = $event['category']['entity_id'];
84
+ $script = Mage::helper('Boxalino_CemSearch')->reportCategoryView($categoryId);
85
+
86
+ $session = Mage::getSingleton('Boxalino_CemSearch_Model_Session');
87
+ $session->addScript($script);
88
+ } catch (Exception $e) {
89
+ if (Mage::helper('Boxalino_CemSearch')->isDebugEnabled()) {
90
+ echo($e);
91
+ exit;
92
+ }
93
+ }
94
+ }
95
+
96
+ public function onLogin(Varien_Event_Observer $event)
97
+ {
98
+ try {
99
+ $userId = $event['customer']['entity_id'];
100
+ $script = Mage::helper('Boxalino_CemSearch')->reportLogin($userId);
101
+
102
+ $session = Mage::getSingleton('Boxalino_CemSearch_Model_Session');
103
+ $session->addScript($script);
104
+ } catch (Exception $e) {
105
+ if (Mage::helper('Boxalino_CemSearch')->isDebugEnabled()) {
106
+ echo($e);
107
+ exit;
108
+ }
109
+ }
110
+ }
111
+ }
app/code/local/Boxalino/CemSearch/Model/Resource/Advanced.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by: Szymon Nosal <szymon.nosal@codete.com>
4
+ * Created at: 05.06.14 13:57
5
+ */
6
+
7
+ require_once "Mage/CatalogSearch/Model/Resource/Advanced";
8
+
9
+ class Boxalino_CemSearch_Model_Resource_Advanced extends Mage_CatalogSearch_Model_Resource_Advanced
10
+ {
11
+
12
+ }
app/code/local/Boxalino/CemSearch/Model/Resource/Advanced/Collection.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by: Szymon Nosal <szymon.nosal@codete.com>
4
+ * Created at: 06.06.14 11:36
5
+ */
6
+
7
+ /**
8
+ * Collection Advanced
9
+ *
10
+ * @category Mage
11
+ * @package Mage_CatalogSearch
12
+ * @author Magento Core Team <core@magentocommerce.com>
13
+ */
14
+ class Boxalino_CemSearch_Model_Resource_Advanced_Collection extends Mage_Catalog_Model_Resource_Product_Collection
15
+ {
16
+ /**
17
+ * Add products id to search
18
+ *
19
+ * @param array $ids
20
+ * @return Mage_CatalogSearch_Model_Resource_Advanced_Collection
21
+ */
22
+ public function addIdFromBoxalino($ids)
23
+ {
24
+
25
+ $this->addFieldToFilter('entity_id', array('in' => $ids));
26
+
27
+ return $this;
28
+ }
29
+
30
+ }
app/code/local/Boxalino/CemSearch/Model/Resource/Fulltext.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once "Mage/CatalogSearch/Model/Resource/Fulltext.php";
3
+
4
+ class Boxalino_CemSearch_Model_Resource_Fulltext extends Mage_CatalogSearch_Model_Resource_Fulltext
5
+ {
6
+
7
+ public function prepareResult($object, $queryText, $query)
8
+ {
9
+
10
+ if (Mage::getStoreConfig('Boxalino_General/general/enabled', 0) == 0) {
11
+ return parent::prepareResult($object, $queryText, $query);
12
+ }
13
+
14
+ $storeConfig = Mage::getStoreConfig('Boxalino_General/general');
15
+
16
+ $p13nConfig = new Boxalino_CemSearch_Helper_P13n_Config(
17
+ $storeConfig['host'],
18
+ Mage::helper('Boxalino_CemSearch')->getAccount(),
19
+ $storeConfig['p13n_username'],
20
+ $storeConfig['p13n_password'],
21
+ $storeConfig['domain']
22
+ );
23
+ $p13nSort = new Boxalino_CemSearch_Helper_P13n_Sort();
24
+ $p13nSort->push('score', true); // score / discountedPrice / title_en
25
+ $p13n = new Boxalino_CemSearch_Helper_P13n_Adapter($p13nConfig);
26
+
27
+ $generalConfig = Mage::getStoreConfig('Boxalino_General/search');
28
+ $lang = substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2);
29
+
30
+ $limit = $generalConfig['quick_search_limit'] == 0 ? 1000 : $generalConfig['quick_search_limit'];
31
+
32
+ $p13n->setupInquiry(
33
+ $generalConfig['quick_search'],
34
+ $query->getQueryText(),
35
+ $lang,
36
+ array($generalConfig['entity_id'], 'categories'),
37
+ $p13nSort,
38
+ 0, $limit
39
+ );
40
+
41
+ if (isset($_GET['cat'])) {
42
+ $p13n->addFilterCategory($_GET['cat']);
43
+ }
44
+ $p13n->search();
45
+ $entity_ids = $p13n->getEntitiesIds();
46
+ unset($p13n); // !!!!!
47
+
48
+ $adapter = $this->_getWriteAdapter();
49
+
50
+ $this->resetSearchResults($query);
51
+
52
+ if($entity_ids === null || count($entity_ids) < 1){
53
+ return $this;
54
+ }
55
+
56
+ if (!$query->getIsProcessed() || true) {
57
+
58
+ $searchType = $object->getSearchType($query->getStoreId());
59
+
60
+ $preparedTerms = Mage::getResourceHelper('catalogsearch')
61
+ ->prepareTerms($queryText, $query->getMaxQueryWords());
62
+
63
+ $bind = array();
64
+ $like = array();
65
+ $likeCond = '';
66
+ if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE
67
+ || $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE
68
+ ) {
69
+ $helper = Mage::getResourceHelper('core');
70
+ $words = Mage::helper('core/string')->splitWords($queryText, true, $query->getMaxQueryWords());
71
+ foreach ($words as $word) {
72
+ $like[] = $helper->getCILike('s.data_index', $word, array('position' => 'any'));
73
+ }
74
+ if ($like) {
75
+ $likeCond = '(' . join(' OR ', $like) . ')';
76
+ }
77
+ }
78
+ $mainTableAlias = 's';
79
+ $fields = array(
80
+ 'query_id' => new Zend_Db_Expr($query->getId()),
81
+ 'product_id',
82
+ );
83
+ $select = $adapter->select()
84
+ ->from(array($mainTableAlias => $this->getMainTable()), $fields)
85
+ ->joinInner(array('e' => $this->getTable('catalog/product')),
86
+ 'e.entity_id = s.product_id',
87
+ array())
88
+ ->where($mainTableAlias . '.store_id = ?', (int)$query->getStoreId());
89
+
90
+ if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_FULLTEXT
91
+ || $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE
92
+ ) {
93
+ $bind[':query'] = implode(' ', $preparedTerms[0]);
94
+ $where = Mage::getResourceHelper('catalogsearch')
95
+ ->chooseFulltext($this->getMainTable(), $mainTableAlias, $select);
96
+ }
97
+
98
+ if ($likeCond != '' && $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE) {
99
+ $where .= ($where ? ' OR ' : '') . $likeCond;
100
+ } elseif ($likeCond != '' && $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE) {
101
+ $select->columns(array('relevance' => new Zend_Db_Expr(0)));
102
+ $where = $likeCond;
103
+ }
104
+
105
+ $where = '( `e`.`entity_id` IN (' . implode(',', $entity_ids) . ') )';
106
+ if (count($entity_ids) > 0) {
107
+ $select->where($where);
108
+ }
109
+
110
+ $sql = $adapter->insertFromSelect($select,
111
+ $this->getTable('catalogsearch/result'),
112
+ array(),
113
+ Varien_Db_Adapter_Interface::INSERT_ON_DUPLICATE);
114
+ $adapter->query($sql, $bind);
115
+
116
+ //$query->setIsProcessed(1);
117
+ }
118
+
119
+
120
+ return $this;
121
+
122
+ }
123
+
124
+ public function resetSearchResults($query = null)
125
+ {
126
+ $adapter = $this->_getWriteAdapter();
127
+ $adapter->update($this->getTable('catalogsearch/search_query'), array('is_processed' => 0));
128
+
129
+ if (!is_null($query)) {
130
+ $adapter->delete($this->getTable('catalogsearch/result'), 'query_id=' . $query->getId());
131
+ }
132
+ Mage::dispatchEvent('catalogsearch_reset_search_result');
133
+
134
+ return $this;
135
+ }
136
+ }
app/code/local/Boxalino/CemSearch/Model/Session.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Boxalino_CemSearch_Model_Session extends Mage_Core_Model_Session_Abstract
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ $this->init('checkout');
9
+ }
10
+
11
+ public function addScript($script)
12
+ {
13
+ if (!isset($this->_data['scipts']) || !is_array($this->_data['scipts'])) {
14
+ $this->_data['scipts'] = array();
15
+ }
16
+ $this->_data['scipts'][] = $script;
17
+ }
18
+
19
+ public function getScripts()
20
+ {
21
+ $scripts = array();
22
+ if (isset($this->_data['scipts']) && is_array($this->_data['scipts'])) {
23
+ $scripts = $this->_data['scipts'];
24
+ }
25
+ return $scripts;
26
+ }
27
+
28
+ public function clearScripts()
29
+ {
30
+ $this->_data['scipts'] = array();
31
+ }
32
+ }
app/code/local/Boxalino/CemSearch/controllers/AdvancedController.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by: Szymon Nosal <szymon.nosal@codete.com>
4
+ * Created at: 06.06.14 11:36
5
+ */
6
+
7
+ require_once "Mage/CatalogSearch/controllers/AdvancedController.php";
8
+
9
+ /**
10
+ * Catalog Search Controller
11
+ *
12
+ * @category Mage
13
+ * @package Mage_CatalogSearch
14
+ * @module Catalog
15
+ */
16
+ class Boxalino_CemSearch_AdvancedController extends Mage_CatalogSearch_AdvancedController
17
+ {
18
+
19
+ public function indexAction()
20
+ {
21
+ $this->loadLayout();
22
+ $this->_initLayoutMessages('catalogsearch/session');
23
+ $this->renderLayout();
24
+ }
25
+
26
+ public function resultAction()
27
+ {
28
+
29
+ $queryAttribute = array();
30
+
31
+ if (Mage::getStoreConfig('Boxalino_General/general/enabled', 0) == 0) {
32
+ return parent::resultAction();
33
+ }
34
+
35
+ $this->loadLayout();
36
+
37
+ $params = $this->getRequest()->getQuery();
38
+
39
+ $tmp = Mage::getModel('catalogsearch/advanced');
40
+ try {
41
+ $tmp->addFilters($params);
42
+ } catch (Mage_Core_Exception $e) {
43
+ Mage::getSingleton('catalogsearch/session')->addError($e->getMessage());
44
+ $this->_redirectError(
45
+ Mage::getModel('core/url')
46
+ ->setQueryParams($params)
47
+ ->getUrl('*/*/')
48
+ );
49
+ }
50
+
51
+ foreach($tmp->getAttributes() as $at){
52
+ $queryAttribute[$at->getStoreLabel()] = $at->getAttributeCode();
53
+ }
54
+
55
+ $criteria = $tmp->getSearchCriterias();
56
+ unset($tmp);
57
+ $lang = substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2);
58
+
59
+ //setUp Boxalino
60
+ $storeConfig = Mage::getStoreConfig('Boxalino_General/general');
61
+ $generalConfig = Mage::getStoreConfig('Boxalino_General/search');
62
+
63
+ $p13nConfig = new Boxalino_CemSearch_Helper_P13n_Config(
64
+ $storeConfig['host'],
65
+ Mage::helper('Boxalino_CemSearch')->getAccount(),
66
+ $storeConfig['p13n_username'],
67
+ $storeConfig['p13n_password'],
68
+ $storeConfig['domain']
69
+ );
70
+ $p13nSort = new Boxalino_CemSearch_Helper_P13n_Sort();
71
+ $p13nSort->push('score', true);
72
+
73
+ $p13n = new Boxalino_CemSearch_Helper_P13n_Adapter($p13nConfig);
74
+
75
+ $limit = $generalConfig['advanced_search_limit'] == 0 ? 1000 : $generalConfig['advanced_search_limit'];
76
+
77
+ //setup search
78
+ $p13n->setupInquiry(
79
+ $generalConfig['advanced_search'],
80
+ $params['name'],
81
+ $lang,
82
+ array($generalConfig['entity_id'], 'discountedPrice', 'title_' . $lang, 'score'),
83
+ $p13nSort,
84
+ 0, $limit
85
+ );
86
+ ## ADD FILTERS
87
+
88
+ $skip = array('name');
89
+
90
+ foreach ($params as $key => $value) {
91
+
92
+ if (isset($value['from']) || isset($value['to'])) {
93
+ $from = null;
94
+ $to = null;
95
+
96
+ if (isset($params[$key]['from']) && $params[$key]['from'] != '' /* && $params['price']['from'] >= 0*/) {
97
+ $from = $params[$key]['from'];
98
+ }
99
+ if (isset($params[$key]['to']) && $params[$key]['to'] != '' /*&& $params['price']['to'] >= 0*/) {
100
+ $to = $params[$key]['to'];
101
+ }
102
+
103
+ $skip[] = $key;
104
+
105
+ if ($key == 'price') {
106
+ $key = 'discountedPrice';
107
+ }
108
+
109
+ if ($from == null && $to == null) {
110
+ continue;
111
+ }
112
+ $p13n->addFilterFromTo($key, $from, $to);
113
+
114
+ }
115
+ }
116
+
117
+ foreach ($criteria as $criterium) {
118
+
119
+ // $name = strtolower($criterium['name']);
120
+ $name = Mage::helper("Boxalino_CemSearch")->sanitizeFieldName($queryAttribute[$criterium['name']]);
121
+
122
+ if (in_array($name, $skip)) {
123
+ continue;
124
+ }
125
+
126
+ $values = explode(", ", $criterium['value']);
127
+
128
+ if ($name == 'description') {
129
+ $name = 'body';
130
+ } else {
131
+ $name = 'products_' . $name;
132
+ }
133
+
134
+ $p13n->addFilter($name, $values, null);
135
+ }
136
+
137
+ //get result from boxalino
138
+ $p13n->search();
139
+ $entity_ids = $p13n->getEntitiesIds();
140
+ unset($p13n);
141
+
142
+ try {
143
+ Mage::getSingleton('catalogsearch/advanced')->addFilters($params, $entity_ids);
144
+ } catch (Mage_Core_Exception $e) {
145
+ Mage::getSingleton('catalogsearch/session')->addError($e->getMessage());
146
+ $this->_redirectError(
147
+ Mage::getModel('core/url')
148
+ ->setQueryParams($this->getRequest()->getQuery())
149
+ ->getUrl('*/*/')
150
+ );
151
+ }
152
+
153
+ $this->_initLayoutMessages('catalog/session');
154
+ $this->renderLayout();
155
+
156
+ }
157
+
158
+ }
app/code/local/Boxalino/CemSearch/controllers/AjaxController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_CatalogSearch
23
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Catalog Search Controller
29
+ *
30
+ * @category Mage
31
+ * @package Mage_CatalogSearch
32
+ * @module Catalog
33
+ */
34
+
35
+ require_once "Mage/CatalogSearch/controllers/AjaxController.php";
36
+
37
+ class Boxalino_CemSearch_AjaxController extends Mage_CatalogSearch_AjaxController
38
+ {
39
+ public function suggestAction()
40
+ {
41
+ if (!$this->getRequest()->getParam('q', false)) {
42
+ $this->getResponse()->setRedirect(Mage::getSingleton('core/url')->getBaseUrl());
43
+ }
44
+
45
+ $this->getResponse()->setBody($this->getLayout()->createBlock('catalogsearch/autocomplete')->toHtml());
46
+ }
47
+ }
app/code/local/Boxalino/CemSearch/controllers/IndexController.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Boxalino_CemSearch_IndexController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ $this->loadLayout();
8
+ $this->renderLayout();
9
+ }
10
+
11
+ public function saveAction()
12
+ {
13
+ $name = '' . $this->getRequest()->getPost('name');
14
+ $surname = '' . $this->getRequest()->getPost('surname');
15
+ $phone = '' . $this->getRequest()->getPost('phone');
16
+ if (isset($name) && ($name != '') && isset($surname) && ($surname != '') && isset($phone) && ($phone != '')) {
17
+ $contact = Mage::getModel('test/test');
18
+ $contact->setData('name', $name);
19
+ $contact->setData('surname', $surname);
20
+ $contact->setData('phone', $phone);
21
+ $contact->save();
22
+ }
23
+ $this->_redirect('test/index/index');
24
+ }
25
+ }
26
+
27
+ ?>
app/code/local/Boxalino/CemSearch/controllers/ResultController.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once "Mage/CatalogSearch/controllers/ResultController.php";
3
+
4
+ class Boxalino_CemSearch_ResultController extends Mage_CatalogSearch_ResultController
5
+ {
6
+ public function indexAction()
7
+ {
8
+ parent::indexAction();
9
+ }
10
+ }
app/code/local/Boxalino/CemSearch/etc/adminhtml.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <acl>
5
+ <resources>
6
+ <admin>
7
+ <children>
8
+ <system>
9
+ <children>
10
+ <config>
11
+ <children>
12
+ <Boxalino_General>
13
+ <title>Boxalino CEM Search</title>
14
+ </Boxalino_General>
15
+ <Boxalino_Recommendation>
16
+ <title>Boxalino Recommendation</title>
17
+ </Boxalino_Recommendation>
18
+ </children>
19
+ </config>
20
+ </children>
21
+ </system>
22
+ </children>
23
+ </admin>
24
+ </resources>
25
+ </acl>
26
+ </config>
app/code/local/Boxalino/CemSearch/etc/config.xml ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Boxalino_CemSearch>
5
+ <version>1.0.0</version>
6
+ </Boxalino_CemSearch>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <catalogsearch>
11
+ <args>
12
+ <modules>
13
+ <Boxalino_CemSearch before="Mage_CatalogSearch">Boxalino_CemSearch</Boxalino_CemSearch>
14
+ </modules>
15
+ </args>
16
+ </catalogsearch>
17
+ <routeurfrontend>
18
+ <use>standard</use>
19
+ <args>
20
+ <module>Boxalino_CemSearch</module>
21
+ <frontName>cemsearch</frontName>
22
+ </args>
23
+ </routeurfrontend>
24
+ <routers>
25
+ <boxalinocem>
26
+ <use>standard</use>
27
+ <args>
28
+ <module>Boxalino_Cem</module>
29
+ <frontName>cem</frontName>
30
+ </args>
31
+ </boxalinocem>
32
+ </routers>
33
+ </routers>
34
+ <layout>
35
+ <updates>
36
+ <boxalino>
37
+ <file>boxalino.xml</file>
38
+ </boxalino>
39
+ </updates>
40
+ </layout>
41
+ <events>
42
+ <checkout_cart_product_add_after>
43
+ <observers>
44
+ <boxalinocem_cart_add>
45
+ <class>Boxalino_CemSearch_Model_Observer</class>
46
+ <method>onProductAddedToCart</method>
47
+ </boxalinocem_cart_add>
48
+ </observers>
49
+ </checkout_cart_product_add_after>
50
+ <checkout_onepage_controller_success_action>
51
+ <observers>
52
+ <boxalinocem_order_success>
53
+ <class>Boxalino_CemSearch_Model_Observer</class>
54
+ <method>onOrderSuccessPageView</method>
55
+ </boxalinocem_order_success>
56
+ </observers>
57
+ </checkout_onepage_controller_success_action>
58
+ <checkout_multishipping_controller_success_action>
59
+ <observers>
60
+ <boxalinocem_order_success>
61
+ <class>Boxalino_CemSearch_Model_Observer</class>
62
+ <method>onOrderSuccessPageView</method>
63
+ </boxalinocem_order_success>
64
+ </observers>
65
+ </checkout_multishipping_controller_success_action>
66
+ <catalog_controller_product_view>
67
+ <observers>
68
+ <boxalinocem_product_view>
69
+ <class>Boxalino_CemSearch_Model_Observer</class>
70
+ <method>onProductPageView</method>
71
+ </boxalinocem_product_view>
72
+ </observers>
73
+ </catalog_controller_product_view>
74
+ <catalog_controller_category_init_after>
75
+ <observers>
76
+ <boxalinocem_category_view>
77
+ <class>Boxalino_CemSearch_Model_Observer</class>
78
+ <method>onCategoryPageView</method>
79
+ </boxalinocem_category_view>
80
+ </observers>
81
+ </catalog_controller_category_init_after>
82
+ <customer_login>
83
+ <observers>
84
+ <boxalinocem_login>
85
+ <class>Boxalino_CemSearch_Model_Observer</class>
86
+ <method>onLogin</method>
87
+ </boxalinocem_login>
88
+ </observers>
89
+ </customer_login>
90
+ </events>
91
+ </frontend>
92
+ <global>
93
+ <helpers>
94
+ <Boxalino_CemSearch>
95
+ <class>Boxalino_CemSearch_Helper</class>
96
+ </Boxalino_CemSearch>
97
+ </helpers>
98
+ <models>
99
+ <boxalino_cemsearch>
100
+ <class>Boxalino_CemSearch_Model</class>
101
+ </boxalino_cemsearch>
102
+ <catalogsearch_resource>
103
+ <rewrite>
104
+ <fulltext>Boxalino_CemSearch_Model_Resource_Fulltext</fulltext>
105
+ </rewrite>
106
+ <rewrite>
107
+ <advanced_collection>Boxalino_CemSearch_Model_Resource_Advanced_Collection</advanced_collection>
108
+ </rewrite>
109
+ </catalogsearch_resource>
110
+
111
+ <catalogsearch>
112
+ <rewrite>
113
+ <advanced>Boxalino_CemSearch_Model_Advanced</advanced>
114
+ </rewrite>
115
+ </catalogsearch>
116
+ </models>
117
+ <resources>
118
+ <test_write>
119
+ <connection>
120
+ <use>core_write</use>
121
+ </connection>
122
+ </test_write>
123
+ <test_read>
124
+ <connection>
125
+ <use>core_read</use>
126
+ </connection>
127
+ </test_read>
128
+ </resources>
129
+ <blocks>
130
+ <boxalino>
131
+ <class>Boxalino_CemSearch_Block</class>
132
+ </boxalino>
133
+ <catalogsearch>
134
+ <rewrite>
135
+ <autocomplete>Boxalino_CemSearch_Block_Autocomplete</autocomplete>
136
+ </rewrite>
137
+ </catalogsearch>
138
+ <checkout>
139
+ <rewrite>
140
+ <cart_crosssell>Boxalino_CemSearch_Block_Cart_Crosssell</cart_crosssell>
141
+ </rewrite>
142
+ </checkout>
143
+ <catalog>
144
+ <rewrite>
145
+ <product_list_related>Boxalino_CemSearch_Block_Product_List_Related</product_list_related>
146
+ <product_list_upsell>Boxalino_CemSearch_Block_Product_List_Upsell</product_list_upsell>
147
+ </rewrite>
148
+ </catalog>
149
+ </blocks>
150
+ </global>
151
+ <default>
152
+ <Boxalino_General>
153
+ <general>
154
+ <enabled>1</enabled>
155
+ <account_dev>0</account_dev>
156
+ <host>cdn.bx-cloud.com</host>
157
+ <logs_saving>0</logs_saving>
158
+ </general>
159
+ <search>
160
+ <quick_search>search</quick_search>
161
+ <quick_search_limit>0</quick_search_limit>
162
+ <advanced_search>search</advanced_search>
163
+ <advanced_search_limit>0</advanced_search_limit>
164
+ <autocomplete>autocomplete</autocomplete>
165
+ <autocomplete_limit>6</autocomplete_limit>
166
+ <autocomplete_products_limit>3</autocomplete_products_limit>
167
+ <entity_id>id</entity_id>
168
+ </search>
169
+ <tracker>
170
+ <charset>UTF-8</charset>
171
+ <enabled>1</enabled>
172
+ <debug>1</debug>
173
+ <analytics>1</analytics>
174
+ <track_sales>1</track_sales>
175
+ </tracker>
176
+ </Boxalino_General>
177
+
178
+ <Boxalino_Recommendation>
179
+ <!-- CART -->
180
+ <cart>
181
+ <status>1</status>
182
+ <widget>recommendation_cart</widget>
183
+ <min>0</min>
184
+ <max>3</max>
185
+ <scenario>basket</scenario>
186
+ </cart>
187
+ <!-- RELATED -->
188
+ <related>
189
+ <status>1</status>
190
+ <widget>recommendation_related</widget>
191
+ <min>0</min>
192
+ <max>3</max>
193
+ <scenario>product</scenario>
194
+ </related>
195
+ <!-- UPSELL -->
196
+ <upsell>
197
+ <status>1</status>
198
+ <widget>recommendation_upsell</widget>
199
+ <min>0</min>
200
+ <max>3</max>
201
+ <scenario>product</scenario>
202
+ </upsell>
203
+ </Boxalino_Recommendation>
204
+ </default>
205
+ </config>
app/code/local/Boxalino/CemSearch/etc/system.xml ADDED
@@ -0,0 +1,488 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <tabs>
5
+ <boxalino translate="label" module="Boxalino_CemSearch">
6
+ <label>Boxalino Extensions</label>
7
+ <sort_order>100</sort_order>
8
+ </boxalino>
9
+ </tabs>
10
+ <sections>
11
+ <Boxalino_General translate="label" module="Boxalino_CemSearch">
12
+ <class>separator-top</class>
13
+ <label>Boxalino General Configuration</label>
14
+ <tab>boxalino</tab>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>200</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <groups>
21
+ <general translate="label">
22
+ <label>Boxalino General Configuration</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>10</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <fields>
29
+ <!-- ENABLED -->
30
+ <enabled translate="label">
31
+ <label>Enabled plugin</label>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>1</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>0</show_in_store>
37
+ <frontend_type>select</frontend_type>
38
+ <source_model>adminhtml/system_config_source_yesno</source_model>
39
+ </enabled>
40
+ <!-- MEMORY logging-->
41
+ <logs_saving translate="label">
42
+ <label>Logs Saving</label>
43
+ <frontend_type>text</frontend_type>
44
+ <sort_order>1</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>0</show_in_website>
47
+ <show_in_store>0</show_in_store>
48
+ <frontend_type>select</frontend_type>
49
+ <source_model>adminhtml/system_config_source_yesno</source_model>
50
+ </logs_saving>
51
+ <!-- ACCOUNT DEV -->
52
+ <account_dev translate="label">
53
+ <label>Development environment</label>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>10</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>0</show_in_store>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_yesno</source_model>
61
+ </account_dev>
62
+ <!-- DOMAIN -->
63
+ <domain translate="label">
64
+ <label>Domain</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>20</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>0</show_in_store>
70
+ <validate>required-entry</validate>
71
+ </domain>
72
+ <!-- HOST -->
73
+ <host translate="label">
74
+ <label>Host</label>
75
+ <frontend_type>text</frontend_type>
76
+ <sort_order>30</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>0</show_in_store>
80
+ <validate>required-entry</validate>
81
+ </host>
82
+ <di_username translate="label">
83
+ <label>Data Intelligence Username</label>
84
+ <frontend_type>text</frontend_type>
85
+ <sort_order>40</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>0</show_in_store>
89
+ <validate>required-entry</validate>
90
+ </di_username>
91
+ <di_password translate="label">
92
+ <label>Data Intelligence Password</label>
93
+ <frontend_type>text</frontend_type>
94
+ <sort_order>50</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>0</show_in_store>
98
+ <validate>required-entry</validate>
99
+ </di_password>
100
+ <!-- ACCOUNT -->
101
+ <di_account translate="label">
102
+ <label>Data Intelligence Account</label>
103
+ <frontend_type>text</frontend_type>
104
+ <sort_order>60</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>0</show_in_store>
108
+ <validate>required-entry</validate>
109
+ </di_account>
110
+ <!-- USERNAME -->
111
+ <p13n_username translate="label">
112
+ <label>P13n Username</label>
113
+ <frontend_type>text</frontend_type>
114
+ <sort_order>70</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>0</show_in_store>
118
+ <validate>required-entry</validate>
119
+ </p13n_username>
120
+ <!-- PASSWORD -->
121
+ <p13n_password translate="label">
122
+ <label>P13n Password</label>
123
+ <frontend_type>text</frontend_type>
124
+ <sort_order>80</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>0</show_in_store>
128
+ <validate>required-entry</validate>
129
+ </p13n_password>
130
+ </fields>
131
+ </general>
132
+
133
+ <search translate="label" module="Boxalino_CemSearch">
134
+ <!--<label>Recommendations Widgets</label>-->
135
+ <label>Search Configuration</label>
136
+ <frontend_type>text</frontend_type>
137
+ <sort_order>51</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ <show_in_store>0</show_in_store>
141
+ <fields>
142
+ <!-- QUICK SEARCH -->
143
+ <quick_search translate="label">
144
+ <label>Quick search</label>
145
+ <frontend_type>text</frontend_type>
146
+ <sort_order>1</sort_order>
147
+ <show_in_default>1</show_in_default>
148
+ <show_in_website>1</show_in_website>
149
+ <show_in_store>0</show_in_store>
150
+ </quick_search>
151
+ <quick_search_limit translate="label">
152
+ <label>Quick search limit</label>
153
+ <comment><![CDATA[ 0 = without limit ]]></comment>
154
+ <frontend_type>text</frontend_type>
155
+ <sort_order>2</sort_order>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>0</show_in_store>
159
+ </quick_search_limit>
160
+ <!-- ADVANCED SEARCH -->
161
+ <advanced_search translate="label">
162
+ <label>Advanced search</label>
163
+ <frontend_type>text</frontend_type>
164
+ <sort_order>10</sort_order>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>0</show_in_store>
168
+ </advanced_search>
169
+ <advanced_search_limit translate="label">
170
+ <label>Advanced search limit</label>
171
+ <comment><![CDATA[ 0 = without limit ]]></comment>
172
+ <frontend_type>text</frontend_type>
173
+ <sort_order>11</sort_order>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>0</show_in_store>
177
+ </advanced_search_limit>
178
+ <!-- AUTOCOMPLETE -->
179
+ <autocomplete translate="label">
180
+ <label>Autocomplete</label>
181
+ <frontend_type>text</frontend_type>
182
+ <sort_order>20</sort_order>
183
+ <show_in_default>1</show_in_default>
184
+ <show_in_website>1</show_in_website>
185
+ <show_in_store>0</show_in_store>
186
+ </autocomplete>
187
+ <!-- AUTOCOMPLETE LIMIT-->
188
+ <autocomplete_limit translate="label">
189
+ <label>Autocomplete limit</label>
190
+ <frontend_type>text</frontend_type>
191
+ <sort_order>21</sort_order>
192
+ <show_in_default>1</show_in_default>
193
+ <show_in_website>1</show_in_website>
194
+ <show_in_store>0</show_in_store>
195
+ </autocomplete_limit>
196
+ <!-- AUTOCOMPLETE PRODUCTS LIMIT-->
197
+ <autocomplete_products_limit translate="label">
198
+ <label>Autocomplete products limit</label>
199
+ <frontend_type>text</frontend_type>
200
+ <sort_order>22</sort_order>
201
+ <show_in_default>1</show_in_default>
202
+ <show_in_website>1</show_in_website>
203
+ <show_in_store>0</show_in_store>
204
+ </autocomplete_products_limit>
205
+ <!-- Entity Id -->
206
+ <entity_id translate="label">
207
+ <label>Id field name</label>
208
+ <frontend_type>text</frontend_type>
209
+ <sort_order>30</sort_order>
210
+ <show_in_default>1</show_in_default>
211
+ <show_in_website>1</show_in_website>
212
+ <show_in_store>0</show_in_store>
213
+ </entity_id>
214
+ </fields>
215
+ </search>
216
+ <tracker translate="label" module="Boxalino_CemSearch">
217
+ <label>Tracking</label>
218
+ <frontend_type>text</frontend_type>
219
+ <sort_order>60</sort_order>
220
+ <show_in_default>1</show_in_default>
221
+ <show_in_website>1</show_in_website>
222
+ <show_in_store>1</show_in_store>
223
+ <fields>
224
+ <enabled translate="label">
225
+ <label>Enable plugin</label>
226
+ <frontend_type>select</frontend_type>
227
+ <source_model>adminhtml/system_config_source_yesno</source_model>
228
+ <sort_order>1</sort_order>
229
+ <show_in_default>1</show_in_default>
230
+ <show_in_website>1</show_in_website>
231
+ <show_in_store>0</show_in_store>
232
+ </enabled>
233
+ <track_sales translate="label">
234
+ <label>Enable Sales Tracking</label>
235
+ <frontend_type>select</frontend_type>
236
+ <source_model>adminhtml/system_config_source_yesno</source_model>
237
+ <sort_order>2</sort_order>
238
+ <show_in_default>1</show_in_default>
239
+ <show_in_website>1</show_in_website>
240
+ <show_in_store>0</show_in_store>
241
+ </track_sales>
242
+ <analytics translate="label">
243
+ <label>Enable Analytics</label>
244
+ <frontend_type>select</frontend_type>
245
+ <source_model>adminhtml/system_config_source_yesno</source_model>
246
+ <sort_order>3</sort_order>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>1</show_in_website>
249
+ <show_in_store>0</show_in_store>
250
+ </analytics>
251
+ <charset translate="label">
252
+ <label>Character encoding</label>
253
+ <frontend_type>text</frontend_type>
254
+ <sort_order>20</sort_order>
255
+ <show_in_default>1</show_in_default>
256
+ <show_in_website>1</show_in_website>
257
+ <show_in_store>0</show_in_store>
258
+ </charset>
259
+ </fields>
260
+ </tracker>
261
+ <jquery translate="label" module="Boxalino_CemSearch">
262
+ <label>jQuery Configuration</label>
263
+ <frontend_type>text</frontend_type>
264
+ <sort_order>71</sort_order>
265
+ <show_in_default>1</show_in_default>
266
+ <show_in_website>1</show_in_website>
267
+ <show_in_store>0</show_in_store>
268
+ <fields>
269
+ <jquery_file translate="label">
270
+ <label>Load jQuery File</label>
271
+ <frontend_type>select</frontend_type>
272
+ <source_model>adminhtml/system_config_source_yesno</source_model>
273
+ <sort_order>1</sort_order>
274
+ <show_in_default>1</show_in_default>
275
+ <show_in_website>1</show_in_website>
276
+ <show_in_store>0</show_in_store>
277
+ </jquery_file>
278
+ <noconflict_file translate="label">
279
+ <label>Load jQuery noConflict File</label>
280
+ <frontend_type>select</frontend_type>
281
+ <source_model>adminhtml/system_config_source_yesno</source_model>
282
+ <sort_order>2</sort_order>
283
+ <show_in_default>1</show_in_default>
284
+ <show_in_website>1</show_in_website>
285
+ <show_in_store>0</show_in_store>
286
+ </noconflict_file>
287
+ </fields>
288
+ </jquery>
289
+ </groups>
290
+ </Boxalino_General>
291
+
292
+ <Boxalino_Recommendation translate="label" module="Boxalino_CemSearch">
293
+ <class>separator-top</class>
294
+ <label>Boxalino Recommendation</label>
295
+ <tab>boxalino</tab>
296
+ <frontend_type>text</frontend_type>
297
+ <sort_order>300</sort_order>
298
+ <show_in_default>1</show_in_default>
299
+ <show_in_website>1</show_in_website>
300
+ <show_in_store>1</show_in_store>
301
+ <groups>
302
+ <!-- CART -->
303
+ <cart translate="label" module="Boxalino_CemSearch">
304
+ <label>Cart Configuration</label>
305
+ <comment><![CDATA[ Widget configuration for recommendation on basket page. ]]></comment>
306
+ <frontend_type>text</frontend_type>
307
+ <sort_order>100</sort_order>
308
+ <show_in_default>1</show_in_default>
309
+ <show_in_website>1</show_in_website>
310
+ <show_in_store>0</show_in_store>
311
+ <fields>
312
+ <!-- STATUS -->
313
+ <status translate="label">
314
+ <label>Widgets enabled</label>
315
+ <frontend_type>text</frontend_type>
316
+ <sort_order>10</sort_order>
317
+ <show_in_default>1</show_in_default>
318
+ <show_in_website>1</show_in_website>
319
+ <show_in_store>0</show_in_store>
320
+ <frontend_type>select</frontend_type>
321
+ <source_model>adminhtml/system_config_source_yesno</source_model>
322
+ </status>
323
+ <!-- WIDGET NAME -->
324
+ <widget translate="label">
325
+ <label>Widget name</label>
326
+ <frontend_type>text</frontend_type>
327
+ <sort_order>12</sort_order>
328
+ <show_in_default>1</show_in_default>
329
+ <show_in_website>1</show_in_website>
330
+ <show_in_store>0</show_in_store>
331
+ </widget>
332
+ <!-- MINIMUM -->
333
+ <min translate="label">
334
+ <label>Minimum recommendations</label>
335
+ <frontend_type>text</frontend_type>
336
+ <sort_order>16</sort_order>
337
+ <show_in_default>1</show_in_default>
338
+ <show_in_website>1</show_in_website>
339
+ <show_in_store>0</show_in_store>
340
+ </min>
341
+ <!-- MAXIMUM -->
342
+ <max translate="label">
343
+ <label>Maximum recommendations</label>
344
+ <frontend_type>text</frontend_type>
345
+ <sort_order>18</sort_order>
346
+ <show_in_default>1</show_in_default>
347
+ <show_in_website>1</show_in_website>
348
+ <show_in_store>0</show_in_store>
349
+ </max>
350
+ <!-- SCENARIO -->
351
+ <scenario translate="label">
352
+ <label>Scenario</label>
353
+ <frontend_type>text</frontend_type>
354
+ <sort_order>20</sort_order>
355
+ <show_in_default>1</show_in_default>
356
+ <show_in_website>1</show_in_website>
357
+ <show_in_store>0</show_in_store>
358
+ </scenario>
359
+ </fields>
360
+ </cart>
361
+ <!-- CART END -->
362
+ <!-- RELATED -->
363
+ <related translate="label" module="Boxalino_CemSearch">
364
+ <label>Related Configuration</label>
365
+ <comment><![CDATA[ Widget configuration for related recommendation on product page. ]]></comment>
366
+ <frontend_type>text</frontend_type>
367
+ <sort_order>200</sort_order>
368
+ <show_in_default>1</show_in_default>
369
+ <show_in_website>1</show_in_website>
370
+ <show_in_store>0</show_in_store>
371
+ <fields>
372
+ <!-- STATUS -->
373
+ <status translate="label">
374
+ <label>Widget enabled</label>
375
+ <frontend_type>text</frontend_type>
376
+ <sort_order>20</sort_order>
377
+ <show_in_default>1</show_in_default>
378
+ <show_in_website>1</show_in_website>
379
+ <show_in_store>0</show_in_store>
380
+ <frontend_type>select</frontend_type>
381
+ <source_model>adminhtml/system_config_source_yesno</source_model>
382
+ </status>
383
+ <!-- WIDGET NAME -->
384
+ <widget translate="label">
385
+ <label>Widgets name</label>
386
+ <frontend_type>text</frontend_type>
387
+ <sort_order>22</sort_order>
388
+ <show_in_default>1</show_in_default>
389
+ <show_in_website>1</show_in_website>
390
+ <show_in_store>0</show_in_store>
391
+ </widget>
392
+ <!-- MINIMUM -->
393
+ <min translate="label">
394
+ <label>Minimum recommendations</label>
395
+ <frontend_type>text</frontend_type>
396
+ <sort_order>26</sort_order>
397
+ <show_in_default>1</show_in_default>
398
+ <show_in_website>1</show_in_website>
399
+ <show_in_store>0</show_in_store>
400
+ </min>
401
+ <!-- MAXIMUM -->
402
+ <max translate="label">
403
+ <label>Maximum recommendations</label>
404
+ <frontend_type>text</frontend_type>
405
+ <sort_order>28</sort_order>
406
+ <show_in_default>1</show_in_default>
407
+ <show_in_website>1</show_in_website>
408
+ <show_in_store>0</show_in_store>
409
+ </max>
410
+ <!-- SCENARIO -->
411
+ <scenario translate="label">
412
+ <label>Scenario</label>
413
+ <frontend_type>text</frontend_type>
414
+ <sort_order>30</sort_order>
415
+ <show_in_default>1</show_in_default>
416
+ <show_in_website>1</show_in_website>
417
+ <show_in_store>0</show_in_store>
418
+ </scenario>
419
+ </fields>
420
+ </related>
421
+ <!-- RELATED END -->
422
+
423
+ <!-- UPSELL -->
424
+ <upsell translate="label" module="Boxalino_CemSearch">
425
+ <label>Upsell Configuration</label>
426
+ <comment><![CDATA[ Widget configuration for upsell recommendation on product page. ]]></comment>
427
+ <frontend_type>text</frontend_type>
428
+ <sort_order>300</sort_order>
429
+ <show_in_default>1</show_in_default>
430
+ <show_in_website>1</show_in_website>
431
+ <show_in_store>0</show_in_store>
432
+ <fields>
433
+ <!-- STATUS -->
434
+ <status translate="label">
435
+ <label>Widgets enabled</label>
436
+ <frontend_type>text</frontend_type>
437
+ <sort_order>30</sort_order>
438
+ <show_in_default>1</show_in_default>
439
+ <show_in_website>1</show_in_website>
440
+ <show_in_store>0</show_in_store>
441
+ <frontend_type>select</frontend_type>
442
+ <source_model>adminhtml/system_config_source_yesno</source_model>
443
+ </status>
444
+ <!-- WIDGET NAME -->
445
+ <widget translate="label">
446
+ <label>Widget name</label>
447
+ <frontend_type>text</frontend_type>
448
+ <sort_order>32</sort_order>
449
+ <show_in_default>1</show_in_default>
450
+ <show_in_website>1</show_in_website>
451
+ <show_in_store>0</show_in_store>
452
+ </widget>
453
+ <!-- MINIMUM -->
454
+ <min translate="label">
455
+ <label>Minimum recommendations</label>
456
+ <frontend_type>text</frontend_type>
457
+ <sort_order>36</sort_order>
458
+ <show_in_default>1</show_in_default>
459
+ <show_in_website>1</show_in_website>
460
+ <show_in_store>0</show_in_store>
461
+ </min>
462
+ <!-- MAXIMUM -->
463
+ <max translate="label">
464
+ <label>Maximum recommendations</label>
465
+ <frontend_type>text</frontend_type>
466
+ <sort_order>38</sort_order>
467
+ <show_in_default>1</show_in_default>
468
+ <show_in_website>1</show_in_website>
469
+ <show_in_store>0</show_in_store>
470
+ </max>
471
+ <!-- SCENARIO -->
472
+ <scenario translate="label">
473
+ <label>Scenario</label>
474
+ <frontend_type>text</frontend_type>
475
+ <sort_order>40</sort_order>
476
+ <show_in_default>1</show_in_default>
477
+ <show_in_website>1</show_in_website>
478
+ <show_in_store>0</show_in_store>
479
+ </scenario>
480
+ </fields>
481
+ </upsell>
482
+ <!-- UPSELL END -->
483
+ </groups>
484
+ </Boxalino_Recommendation>
485
+
486
+ </sections>
487
+
488
+ </config>
app/code/local/Boxalino/Exporter/Helper/Data.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Boxalino_Exporter_Helper_Data extends Mage_Core_Helper_Data
4
+ {
5
+ const URL_XML = 'http://di1.bx-cloud.com/frontend/dbmind/en/dbmind/api/data/source/update';
6
+ const URL_XML_DEV = 'http://di1.bx-cloud.com/frontend/dbmind/_/en/dbmind/api/data/source/update';
7
+ const URL_ZIP = "http://di1.bx-cloud.com/frontend/dbmind/en/dbmind/api/data/push";
8
+ const URL_ZIP_DEV = "http://di1.bx-cloud.com/frontend/dbmind/_/en/dbmind/api/data/push";
9
+ /**
10
+ * Array of parent_id for specified products.
11
+ * IMPORTANT: We assume that every simple product has at most one configurable parent.
12
+ *
13
+ * @var null
14
+ */
15
+ /**
16
+ * Array of variants ids for specified products.
17
+ *
18
+ * @var null
19
+ */
20
+ public $XML_DELIMITER = ',';
21
+ public $XML_ENCLOSURE = '"';
22
+ public $XML_ENCLOSURE_TEXT = "&quot;"; // it's $XML_ENCLOSURE
23
+ public $XML_NEWLINE = '\n';
24
+ public $XML_ESCAPE = '\\\\';
25
+ public $XML_ENCODE = 'UTF-8';
26
+ public $XML_FORMAT = 'CSV';
27
+ protected $_attributesWithIds = array();
28
+ protected $_allTags = array();
29
+ protected $_countries = array();
30
+
31
+ public function defaultAttributes()
32
+ {
33
+ $attributes = array(
34
+ 'entity_id',
35
+ 'name',
36
+ 'description',
37
+ 'short_description',
38
+ 'sku',
39
+ 'price',
40
+ 'special_price',
41
+ 'visibility',
42
+ 'category_ids',
43
+ );
44
+
45
+ return $attributes;
46
+ }
47
+
48
+ /**
49
+ * @param $language
50
+ * @return bool
51
+ */
52
+ public function isAvailableLanguages($language)
53
+ {
54
+ $languages = array(
55
+ 'en',
56
+ 'fr',
57
+ 'de',
58
+ 'it',
59
+ 'es',
60
+ 'zh',
61
+ 'cz',
62
+ 'ru',
63
+ );
64
+
65
+ if (array_search($language, $languages) !== false) {
66
+ return true;
67
+ }
68
+
69
+ return false;
70
+ }
71
+
72
+ /**
73
+ * @return array Return array with attributes which have connect optionId = optionValue
74
+ */
75
+ public function attributesWithIds()
76
+ {
77
+ if (empty($this->_attributesWithIds)) {
78
+ $attributes = Mage::getResourceModel('eav/entity_attribute_collection')->getData();
79
+ foreach ($attributes as $attribute) {
80
+ if ($attribute['frontend_input'] == 'select' || $attribute['frontend_input'] == 'multiselect') {
81
+ $this->_attributesWithIds[] = $attribute['attribute_code'];
82
+ }
83
+ }
84
+ $attributes = null;
85
+ }
86
+ return $this->_attributesWithIds;
87
+ }
88
+
89
+ /**
90
+ * @return array Array of all tags array('tag_id' => 'value');
91
+ */
92
+ public function getAllTags()
93
+ {
94
+ if (empty($this->_allTags)) {
95
+ $tagsModel = Mage::getModel('tag/tag');
96
+ $tags = $tagsModel->getCollection()->addStatusFilter($tagsModel->getApprovedStatus())->getData();
97
+ foreach ($tags as $tag) {
98
+ $this->_allTags[$tag['tag_id']] = $tag['name'];
99
+ }
100
+ $tags = null;
101
+ $tagsModel = null;
102
+ }
103
+
104
+ return $this->_allTags;
105
+ }
106
+
107
+ /**
108
+ * @return string URL to normal data sync
109
+ * @param $dev
110
+ */
111
+ public function getZIPSyncUrl($dev = false)
112
+ {
113
+ if ($dev) {
114
+ return self::URL_ZIP_DEV;
115
+ } else {
116
+ return self::URL_ZIP;
117
+ }
118
+ }
119
+
120
+ /**
121
+ * @return string URL to delta sync
122
+ * @param $dev
123
+ */
124
+ public function getXMLSyncUrl($dev = false)
125
+ {
126
+ if ($dev) {
127
+ return self::URL_XML_DEV;
128
+ } else {
129
+ return self::URL_XML;
130
+ }
131
+
132
+ }
133
+
134
+ public function getError($responseBody)
135
+ {
136
+ $htmlTagsToReplace = array('body', 'p', 'br');
137
+ $startPosition = strpos($responseBody, '<p>');
138
+ $endPosition = strpos($responseBody, '&lt;br&gt;') + 3;
139
+ $error = html_entity_decode(substr($responseBody, $startPosition, $endPosition));
140
+ foreach ($htmlTagsToReplace as $tag) {
141
+ $error = str_replace('<' . $tag . '>', PHP_EOL, $error);
142
+ }
143
+ return $error;
144
+ }
145
+
146
+ public function getCountry($countryCode)
147
+ {
148
+ if(!isset($this->_countries[$countryCode])) {
149
+ $this->_countries[$countryCode] = Mage::getSingleton('directory/country')->loadByCode($countryCode);
150
+ }
151
+
152
+ return $this->_countries[$countryCode];
153
+ }
154
+
155
+ }
app/code/local/Boxalino/Exporter/Model/Delta.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Boxalino_Exporter_Model_Delta extends Mage_Index_Model_Indexer_Abstract
4
+ {
5
+ public function getName()
6
+ {
7
+ return Mage::helper('boxalinoexporter')->__('Boxalino Delta Data Export');
8
+ }
9
+
10
+ public function getDescription()
11
+ {
12
+ return Mage::helper('boxalinoexporter')->__('Send latest data to Boxalino');
13
+ }
14
+
15
+ protected function _construct()
16
+ {
17
+ $this->_init('boxalinoexporter/exporter_delta');
18
+ }
19
+
20
+ protected function _registerEvent(Mage_Index_Model_Event $event)
21
+ {
22
+ }
23
+
24
+ protected function _processEvent(Mage_Index_Model_Event $event)
25
+ {
26
+ }
27
+
28
+
29
+ }
app/code/local/Boxalino/Exporter/Model/Indexer.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Boxalino_Exporter_Model_Indexer extends Mage_Index_Model_Indexer_Abstract
4
+ {
5
+ public function getName()
6
+ {
7
+ return Mage::helper('boxalinoexporter')->__('Boxalino Full Data Export');
8
+ }
9
+
10
+ public function getDescription()
11
+ {
12
+ return Mage::helper('boxalinoexporter')->__('Send all data to Boxalino');
13
+ }
14
+
15
+ protected function _construct()
16
+ {
17
+ $this->_init('boxalinoexporter/exporter_indexer');
18
+ }
19
+
20
+ protected function _registerEvent(Mage_Index_Model_Event $event)
21
+ {
22
+ }
23
+
24
+ protected function _processEvent(Mage_Index_Model_Event $event)
25
+ {
26
+ }
27
+
28
+
29
+ }
app/code/local/Boxalino/Exporter/Model/Mysql4/Exporter/Delta.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Boxalino_Exporter_Model_Mysql4_Exporter_Delta extends Boxalino_Exporter_Model_Mysql4_Indexer
4
+ {
5
+ const INDEX_TYPE = 'delta';
6
+ /** @var date Date of last data sync */
7
+ protected $_lastIndex = 0;
8
+
9
+ /**
10
+ * @description Declare where Indexer should start
11
+ * @return void
12
+ */
13
+ protected function _construct()
14
+ {
15
+ $this->_init('boxalinoexporter/delta', '');
16
+ }
17
+
18
+ /**
19
+ * @description Get date of last data sync
20
+ */
21
+ protected function _getLastIndex()
22
+ {
23
+ if ($this->_lastIndex == 0) {
24
+ $this->_setLastIndex();
25
+ }
26
+ return $this->_lastIndex;
27
+ }
28
+
29
+ /**
30
+ * @description set when was last data sync
31
+ */
32
+ protected function _setLastIndex()
33
+ {
34
+ $dates = array();
35
+ $indexes = Mage::getModel('index/indexer')->getProcessesCollection()->getData();
36
+ foreach ($indexes as $index) {
37
+ if ($index['indexer_code'] == 'boxalinoexporter_indexer' && !empty($index['started_at'])) {
38
+ $dates[] = DateTime::createFromFormat('Y-m-d H:i:s', $index['started_at']);
39
+ } elseif ($index['indexer_code'] == 'boxalinoexporter_delta' && !empty($index['ended_at'])) {
40
+ $dates[] = DateTime::createFromFormat('Y-m-d H:i:s', $index['ended_at']);
41
+ }
42
+ }
43
+ if (count($dates) == 2) {
44
+ if ($dates[0] > $dates[1]) {
45
+ $date = $dates[0]->format('Y-m-d H:i:s');
46
+ } else {
47
+ $date = $dates[1]->format('Y-m-d H:i:s');
48
+ }
49
+ } else {
50
+ $date = $dates[0]->format('Y-m-d H:i:s');
51
+ }
52
+
53
+ $this->_lastIndex = $date;
54
+ }
55
+
56
+ /**
57
+ * @description Get all transactions from Magento
58
+ * @return object All transactions for store
59
+ */
60
+ protected function _getTransactions()
61
+ {
62
+ $transaction = Mage::getModel('sales/order')->setStoreId($this->_storeId)->getCollection()->addAttributeToFilter('updated_at', array('from' => $this->_getLastIndex(), 'date' => true))->addAttributeToSelect('*');
63
+ return $transaction;
64
+ }
65
+
66
+ /**
67
+ * @description Get all customers from Magento
68
+ * @return object All customers
69
+ */
70
+ protected function _getCustomers()
71
+ {
72
+ $customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToFilter('updated_at', array('from' => $this->_getLastIndex(), 'date' => true))->addAttributeToSelect('*');
73
+ return $customers;
74
+ }
75
+
76
+ /**
77
+ * @description Get list of all categories
78
+ * @return object All categories for Store
79
+ */
80
+ protected function _getCategories()
81
+ {
82
+ $categories = Mage::getModel('catalog/category')->setStoreId($this->_storeId)->getCollection()->addAttributeToSelect('*');
83
+ return $categories;
84
+ }
85
+
86
+ /**
87
+ * @description Get list of products with their tags
88
+ * @return object List of products with their tags
89
+ */
90
+ protected function _getProductTags()
91
+ {
92
+ if (empty($this->_allProductTags)) {
93
+ $tags = Mage::getResourceModel('tag/product_collection')->addAttributeToFilter('updated_at', array('from' => $this->_getLastIndex(), 'date' => true))->getData();
94
+ foreach ($tags as $tag) {
95
+ $this->_allProductTags[$tag['entity_id']] = $tag['tag_id'];
96
+ }
97
+ }
98
+ return $this->_allProductTags;
99
+ }
100
+
101
+ /**
102
+ * @description Get products for store by storeId
103
+ * @return object All products of magento for store
104
+ */
105
+ protected function _getStoreProducts()
106
+ {
107
+ $products = Mage::getModel('catalog/product')->setStoreId($this->_storeId)->getCollection()->addAttributeToFilter('updated_at', array('from' => $this->_getLastIndex(), 'date' => true))->addAttributeToSelect($this->_listOfAttributes);
108
+ return $products;
109
+ }
110
+
111
+ /**
112
+ * @return string Index type
113
+ */
114
+ protected function _getIndexType()
115
+ {
116
+ return self::INDEX_TYPE;
117
+ }
118
+ }
app/code/local/Boxalino/Exporter/Model/Mysql4/Exporter/Indexer.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Boxalino_Exporter_Model_Mysql4_Exporter_Indexer extends Boxalino_Exporter_Model_Mysql4_Indexer
4
+ {
5
+ const INDEX_TYPE = 'full';
6
+
7
+ /**
8
+ * @description Declare where Indexer should start
9
+ * @return void
10
+ */
11
+ protected function _construct()
12
+ {
13
+ $this->_init('boxalinoexporter/indexer', '');
14
+ }
15
+
16
+ protected function _prepareFiles($website,&$categories = null, &$tags = null)
17
+ {
18
+ }
19
+
20
+ /**
21
+ * @description Get all transactions from Magento
22
+ * @return object All transactions for store
23
+ */
24
+ protected function _getTransactions()
25
+ {
26
+ // $transaction = Mage::getModel('sales/order')->setStoreId($this->_storeId)->getCollection()->addAttributeToSelect('*');
27
+ //
28
+ // return $transaction;
29
+ }
30
+
31
+ /**
32
+ * @description Get all customers from Magento
33
+ * @return object All customers
34
+ */
35
+ protected function _getCustomers()
36
+ {
37
+ // $customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
38
+ //
39
+ // return $customers;
40
+ }
41
+
42
+ /**
43
+ * @description Get list of all categories
44
+ * @return object All categories for Store
45
+ */
46
+ protected function _getCategories()
47
+ {
48
+ $categories = Mage::getModel('catalog/category')->setStoreId($this->_storeId)->getCollection()->addAttributeToSelect('*');
49
+
50
+ return $categories;
51
+ }
52
+
53
+ /**
54
+ * @description Get products for store by storeId
55
+ * @return object All products of magento for store
56
+ */
57
+ protected function _getStoreProducts()
58
+ {
59
+ // $products = Mage::getModel('catalog/product')->setStoreId($this->_storeId)->getCollection()->addAttributeToSelect($this->_listOfAttributes);
60
+ // return $products;
61
+ }
62
+
63
+ /**
64
+ * @return string Index type
65
+ */
66
+ protected function _getIndexType()
67
+ {
68
+ return self::INDEX_TYPE;
69
+ }
70
+ }
app/code/local/Boxalino/Exporter/Model/Mysql4/Indexer.php ADDED
@@ -0,0 +1,1706 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //ini_set('memory_limit', '-1');
4
+
5
+ abstract class Boxalino_Exporter_Model_Mysql4_Indexer extends Mage_Core_Model_Mysql4_Abstract
6
+ {
7
+ /** @var array Configuration for each Store View */
8
+ protected $_storeConfig = array();
9
+
10
+ /** @var array Values of attributes where array('storeId' => array('attrName' => array('id' => 'value'))) */
11
+ protected $_attributesValues = array();
12
+
13
+ /** @var array Number of stockQty for all products. Example: array('productId' => 'qty') */
14
+ protected $productsStockQty = array();
15
+
16
+ /** @var array List of attributes which module export to our server */
17
+ protected $_listOfAttributes = array();
18
+
19
+ /** @var array All tags of products */
20
+ protected $_allProductTags = array();
21
+
22
+ protected $_transformedCategories = array();
23
+
24
+ protected $_transformedTags = array();
25
+
26
+ protected $_transformedProducts = array();
27
+
28
+ protected $_categoryParent = array();
29
+
30
+ protected $_countries = null;
31
+
32
+ protected $_availableLanguages = array();
33
+
34
+ protected $_attributesValuesByName = array();
35
+
36
+ protected $_tmp = array();
37
+
38
+ protected $_files = array();
39
+
40
+ protected $_count = 0;
41
+
42
+ protected $_attrProdCount = array();
43
+
44
+ /** @var int Actually used storeId */
45
+ protected $_storeId = 0;
46
+
47
+ protected $_dir = '/tmp/boxalino';
48
+
49
+ protected $group = null;
50
+
51
+ protected $_helperExporter = null;
52
+ protected $_helperSearch = null;
53
+
54
+ private $_parentId = null;
55
+ private $_simpleIds = null;
56
+ private $_isLoad = false;
57
+ private $logger = null;
58
+
59
+ /**
60
+ * @description Start of apocalypse
61
+ */
62
+ public function reindexAll()
63
+ {
64
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Indexer init'));
65
+ $this->_websiteExport();
66
+ $this->_closeExport();
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ * @description Declare what code have to do for Website scope
72
+ * @return void
73
+ */
74
+ protected function _websiteExport()
75
+ {
76
+ $this->_helperExporter = Mage::helper('boxalinoexporter');
77
+ $this->_helperSearch = Mage::helper("Boxalino_CemSearch");
78
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Helpers init'));
79
+ foreach (Mage::app()->getWebsites() as $website) {
80
+
81
+ $this->delTree($this->_dir);
82
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'After delTree'));
83
+
84
+ if (!$this->_isEnabled()) {
85
+ continue;
86
+ }
87
+
88
+ $data = $this->_storeExport($website);
89
+
90
+ // if ($this->_getIndexType() == 'delta' && count($data['products']) == 0 && count($data['customers']) == 0 && count($data['transactions']) == 0) {
91
+ // continue;
92
+ // }
93
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'something with attributes - before'));
94
+
95
+ foreach($this->_listOfAttributes as $k => $attr){
96
+ if(
97
+ !isset($this->_attributesValuesByName[$attr]) ||
98
+ (isset($this->_attrProdCount[$attr]) &&
99
+ $this->_attrProdCount[$attr])
100
+ ){
101
+ continue;
102
+ } else{
103
+ unset($this->_attributesValuesByName[$attr]);
104
+ unset($this->_listOfAttributes[$k]);
105
+ }
106
+ }
107
+
108
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'something with attributes - after'));
109
+ $file = $this->prepareFiles($website, $data['categories'], $data['tags']);
110
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Push files'));
111
+
112
+ $this->pushXML($file);
113
+ $this->pushZip($file);
114
+
115
+ $this->_transformedCategories = array();
116
+ $this->_transformedTags = array();
117
+ $this->_transformedProducts = array();
118
+ $this->_categoryParent = array();
119
+ $this->_availableLanguages = array();
120
+ $this->_tmp = array();
121
+ $this->_attrProdCount = array();
122
+ $this->_count = 0;
123
+
124
+ }
125
+ }
126
+
127
+ /**
128
+ * @description Declare what code have to do for Website scope
129
+ * @param $website object Object of currently working Website
130
+ * @return array Data prepared for save to file
131
+ */
132
+ protected function _storeExport($website)
133
+ {
134
+ $products = array();
135
+ $categories = array();
136
+ // $customers = array();
137
+ $tags = array();
138
+ // $transactions = array();
139
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Preparing data for website start'));
140
+ foreach ($website->getGroups() as $group) {
141
+
142
+ $this->group = $group;
143
+
144
+ foreach ($group->getStores() as $store) {
145
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Start store:'.$store->getId()));
146
+ $this->_prepareStoreConfig($store->getId());
147
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Configuration for store loaded'));
148
+ if ($this->_isEnabled()) {
149
+ $categories = $this->_exportCategories();
150
+ $tags = $this->_exportTags();
151
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Without available languages'));
152
+ $this->_availableLanguages[] = $this->_storeConfig['language'];
153
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'With available languages'));
154
+
155
+ }
156
+ }
157
+
158
+ if ($this->_isEnabled()) {
159
+ $this->_exportCustomers();
160
+ $this->_exportTransactions();
161
+ $products = $this->_exportProducts();
162
+ }
163
+
164
+ }
165
+
166
+ return array(
167
+ 'products' => $products,
168
+ 'categories' => $categories,
169
+ 'tags' => $tags,
170
+ );
171
+ }
172
+
173
+ /**
174
+ * @description Get configs for store by storeId
175
+ * @param int $storeId
176
+ * @return void
177
+ */
178
+ protected function _prepareStoreConfig($storeId)
179
+ {
180
+ $this->_storeId = $storeId;
181
+ $this->_storeConfig = array_merge(Mage::app()->getStore($this->_storeId)->getConfig('boxalinoexporter/export_data'), Mage::app()->getStore($this->_storeId)->getConfig('Boxalino_General/general'));
182
+
183
+ $tmp = Mage::app()->getStore($this->_storeId)->getConfig('Boxalino_CemSearch/backend');
184
+ $this->_storeConfig['username'] = $tmp['username'];
185
+ $this->_storeConfig['password'] = $tmp['password'];
186
+ if (!$this->_helperExporter->isAvailableLanguages($this->_storeConfig['language'])) {
187
+ Mage::throwException($this->_helperExporter->__('Language "' . $this->_storeConfig['language'] . '" is not available.'));
188
+ }
189
+ $this->_mergeAllAttributes();
190
+ $this->_getAllAttributesValues();
191
+ }
192
+
193
+ /**
194
+ * @description Merge default attributes with attributes added by user
195
+ * @return void
196
+ */
197
+ protected function _mergeAllAttributes()
198
+ {
199
+ $this->_listOfAttributes = $this->_helperExporter->defaultAttributes();
200
+
201
+ $attributes = array();
202
+
203
+ foreach(Mage::getResourceModel('catalog/product_attribute_collection')->getItems() as $at){
204
+ $attributes[] = $at->getAttributeCode();
205
+ }
206
+
207
+ if (isset($this->_storeConfig['additional_attributes']) && $this->_storeConfig['additional_attributes'] != '') {
208
+ $fields = explode(',', $this->_storeConfig['additional_attributes']);
209
+ foreach ($fields as $field) {
210
+
211
+ if(!in_array($field, $attributes)){
212
+ Mage::throwException("Attribute \"$field\" not exist!" );
213
+ }
214
+
215
+ if($field != null && strlen($field) > 0){
216
+ $this->_listOfAttributes[] = $field;
217
+ }
218
+
219
+ }
220
+ unset($fields);
221
+ }
222
+
223
+ }
224
+
225
+ /**
226
+ * @description Get labels for all Attributes where is optionsId = optionValue
227
+ * @return void
228
+ */
229
+ protected function _getAllAttributesValues()
230
+ {
231
+ $attributesWithId = $this->_helperExporter->attributesWithIds();
232
+ foreach ($this->_listOfAttributes as $attribute) {
233
+ if (array_search($attribute, $attributesWithId) == true) {
234
+ $options = Mage::getModel('eav/config')->getAttribute('catalog_product', $attribute)->setStoreId($this->_storeId)->getSource()->getAllOptions();
235
+ foreach ($options as $option) {
236
+ if (!empty($option['value'])) {
237
+ $this->_attributesValues[$this->_storeId][$attribute][$option['value']] = $this->escapeString($option['label']);
238
+
239
+ $value = intval($option['value']);
240
+ $name = 'value_' . $this->_storeConfig['language'];
241
+
242
+ if (isset($this->_attributesValuesByName[$attribute])) {
243
+
244
+ if (isset($this->_attributesValuesByName[$attribute][$value])) {
245
+ $this->_attributesValuesByName[$attribute][$value][$name] = /*strtolower*/
246
+ $this->escapeString($option['label']);
247
+ } else {
248
+ $this->_attributesValuesByName[$attribute][$value] = array($attribute . '_id' => $value, $name => /*strtolower*/
249
+ $this->escapeString($option['label']));
250
+ }
251
+
252
+ } else {
253
+ $this->_attributesValuesByName[$attribute] = array($value => array($attribute . '_id' => $value, $name => /*strtolower*/
254
+ $this->escapeString($option['label'])));
255
+ }
256
+
257
+ }
258
+ }
259
+ unset($options);
260
+ }
261
+ }
262
+ unset($attributesWithId);
263
+ }
264
+
265
+ /**
266
+ * @description check if export is enabled for website
267
+ * @return bool
268
+ */
269
+ protected function _isEnabled()
270
+ {
271
+ if (isset($this->_storeConfig['enabled']) && $this->_storeConfig['enabled']) {
272
+ return true;
273
+ } else if(!isset($this->_storeConfig['enabled']) && Mage::getStoreConfig('Boxalino_General/general/enabled')){
274
+ return true;
275
+ }
276
+
277
+ return false;
278
+ }
279
+
280
+ /**
281
+ * @description Preparing categories to export
282
+ * @return array Cateroies
283
+ */
284
+ protected function _exportCategories()
285
+ {
286
+ if ($this->_storeConfig['export_categories']) {
287
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Categories are not loaded'));
288
+ $categories = $this->_getCategories();
289
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Categories are loaded'));
290
+ foreach ($categories as $category) {
291
+
292
+ if ($category->getParentId() == null) {
293
+ continue;
294
+ }
295
+
296
+ if (isset($this->_transformedCategories[$category->getId()])) {
297
+ $this->_transformedCategories[$category->getId()]['value_' . $this->_storeConfig['language']] = $this->escapeString($category->getName());
298
+ } else {
299
+ $parentId = null;
300
+ if ($category->getParentId() != 0) {
301
+ $parentId = $category->getParentId();
302
+ }
303
+ $this->_transformedCategories[$category->getId()] = array('category_id' => $category->getId(), 'parent_id' => $parentId, 'value_' . $this->_storeConfig['language'] => $this->escapeString($category->getName()));
304
+ }
305
+ }
306
+ $categories = null;;
307
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Categories are returned for data saving'));
308
+ return $this->_transformedCategories;
309
+ }
310
+
311
+
312
+ return null;
313
+
314
+ }
315
+
316
+ abstract protected function _getCategories();
317
+
318
+ /**
319
+ * @description Preparing tags to export
320
+ * @return array Tags
321
+ *
322
+ */
323
+ protected function _exportTags()
324
+ {
325
+
326
+ if ($this->_storeConfig['export_tags']) {
327
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Tags are not loaded'));
328
+ $tags = $this->_helperExporter->getAllTags();
329
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Tags are loaded'));
330
+
331
+ foreach ($tags as $id => $tag) {
332
+ if (isset($this->_transformedTags[$id])) {
333
+ $this->_transformedTags[$id]['value_' . $this->_storeConfig['language']] = $tag;
334
+ } else {
335
+ $this->_transformedTags[$id] = array('tag_id' => $id, 'value_' . $this->_storeConfig['language'] => $tag);
336
+ }
337
+ }
338
+
339
+ $tags = null;
340
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Tags are returned for data saving'));
341
+ return $this->_transformedTags;
342
+ }
343
+
344
+ return null;
345
+ }
346
+
347
+ /**
348
+ * @description Preparing products to export
349
+ * @return array Products
350
+ */
351
+ protected function _exportProducts()
352
+ {
353
+
354
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - start of export'));
355
+ $attrs = $this->_listOfAttributes;
356
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - get info about attributes - before'));
357
+ $query = "
358
+ SELECT `main_table`.`attribute_id`, `main_table`.`entity_type_id`, `main_table`.`attribute_code`, `main_table`.`attribute_model`, `main_table`.`backend_model`, `main_table`.`backend_type`, `main_table`.`backend_table`, `main_table`.`frontend_input`, `main_table`.`source_model`, `additional_table`.`is_global`, `additional_table`.`is_html_allowed_on_front`, `additional_table`.`is_wysiwyg_enabled` FROM `eav_attribute` AS `main_table`
359
+ INNER JOIN `catalog_eav_attribute` AS `additional_table` ON additional_table.attribute_id = main_table.attribute_id WHERE (main_table.entity_type_id = 4) AND (attribute_code IN('" .
360
+ implode('\',\'', $this->_listOfAttributes) .
361
+ "'))
362
+ ";
363
+
364
+ $config = Mage::getConfig()->getResourceConnectionConfig("default_setup");
365
+
366
+ $dbinfo = array('host' => $config->host,
367
+ 'user' => $config->username,
368
+ 'pass' => $config->password,
369
+ 'dbname' => $config->dbname
370
+ );
371
+ unset($config);
372
+
373
+ $pdo = new PDO('mysql:host=' . $dbinfo['host'] .';dbname=' . $dbinfo['dbname'], $dbinfo['user'], $dbinfo['pass']);
374
+
375
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - connected to DB'));
376
+ $readConnection = $pdo->prepare($query);
377
+ $readConnection->execute();
378
+ $results = $readConnection->fetchAll();
379
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - get info about attributes - after'));
380
+ $attrFDB = array();
381
+ $attrsFromDb = array(
382
+ "int" => array(),
383
+ "varchar" => array(),
384
+ "text" => array(),
385
+ "decimal" => array(),
386
+ );
387
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - attributes preparing'));
388
+ foreach($results as $r){
389
+ $type = $r['backend_type'];
390
+ if(isset($attrsFromDb[$type])){
391
+ $attrsFromDb[$type][] = $r['attribute_id'];
392
+ $attrFDB[$r['attribute_id']] = $r['attribute_code'];
393
+ }
394
+ }
395
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - attributes preparing done'));
396
+ $countMax = $this->_storeConfig['maximum_population'];
397
+ $localeCount = 0;
398
+
399
+ $limit = $this->_storeConfig['export_chunk'];
400
+ $count = $limit;
401
+ $page = 1;
402
+ $header = true;
403
+
404
+ while($count >= $limit){
405
+
406
+
407
+ if ($countMax > 0 && $this->_count >= $countMax) {
408
+ break;
409
+ }
410
+
411
+ foreach ($this->group->getStores() as $store) {
412
+
413
+ $storeId = $store->getId();
414
+
415
+ $lang = Mage::app()->getStore($store->getId())->getConfig('boxalinoexporter/export_data/language');
416
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - fetch products - before'));
417
+ $query = "SELECT `e`.* FROM `catalog_product_entity` AS `e` LIMIT $limit OFFSET " . (($page-1) * $limit);
418
+ $readConnection = $pdo->prepare($query);
419
+ $readConnection->execute();
420
+ $results = $readConnection->fetchAll();
421
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - fetch products - after'));
422
+
423
+ $products = array();
424
+ $ids = "";
425
+ foreach($results as $r){
426
+ $products[$r['entity_id']] = $r;
427
+ $ids .= $r['entity_id'] . ',';
428
+ $products[$r['entity_id']]['website'] = array();
429
+ $products[$r['entity_id']]['categories'] = array();
430
+ }
431
+
432
+ $count = count($results);
433
+
434
+ $results = null;
435
+ $readConnection = null;
436
+
437
+ $ids = substr($ids, 0, -1);
438
+ $query = "
439
+ SELECT `t_d`.`entity_id`, `t_d`.`attribute_id`, `t_d`.`value` AS `default_value`, `t_s`.`value` AS `store_value`, IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS `value` FROM `catalog_product_entity_varchar` AS `t_d`
440
+ LEFT JOIN `catalog_product_entity_varchar` AS `t_s` ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = $storeId WHERE (t_d.entity_type_id = 4) AND (t_d.entity_id IN (" . $ids . ")) AND (t_d.attribute_id IN ('" . implode('\',\'', $attrsFromDb['varchar']) . "')) AND (t_d.store_id = 0) UNION ALL SELECT `t_d`.`entity_id`, `t_d`.`attribute_id`, `t_d`.`value` AS `default_value`, `t_s`.`value` AS `store_value`, IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS `value` FROM `catalog_product_entity_text` AS `t_d`
441
+ LEFT JOIN `catalog_product_entity_text` AS `t_s` ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = $storeId WHERE (t_d.entity_type_id = 4) AND (t_d.entity_id IN (" . $ids . ")) AND (t_d.attribute_id IN ('" . implode('\',\'', $attrsFromDb['text']) . "')) AND (t_d.store_id = 0) UNION ALL SELECT `t_d`.`entity_id`, `t_d`.`attribute_id`, `t_d`.`value` AS `default_value`, `t_s`.`value` AS `store_value`, IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS `value` FROM `catalog_product_entity_decimal` AS `t_d`
442
+ LEFT JOIN `catalog_product_entity_decimal` AS `t_s` ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = $storeId WHERE (t_d.entity_type_id = 4) AND (t_d.entity_id IN (" . $ids . ")) AND (t_d.attribute_id IN ('" . implode('\',\'', $attrsFromDb['decimal']) . "')) AND (t_d.store_id = 0) UNION ALL SELECT `t_d`.`entity_id`, `t_d`.`attribute_id`, `t_d`.`value` AS `default_value`, `t_s`.`value` AS `store_value`, IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS `value` FROM `catalog_product_entity_int` AS `t_d`
443
+ LEFT JOIN `catalog_product_entity_int` AS `t_s` ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = $storeId WHERE (t_d.entity_type_id = 4) AND (t_d.entity_id IN (" . $ids . ")) AND (t_d.attribute_id IN ('" . implode('\',\'', $attrsFromDb['int']) . "')) AND (t_d.store_id = 0)
444
+ ";
445
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - get attributes - before'));
446
+ $readConnection = $pdo->prepare($query);
447
+ $readConnection->execute();
448
+ $results = $readConnection->fetchAll();
449
+
450
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - get attributes - after'));
451
+ foreach($results as $r){
452
+
453
+ $products[$r['entity_id']][$attrFDB[$r['attribute_id']]] = $r['value'];
454
+
455
+ }
456
+
457
+ $results = null;
458
+ $readConnection = null;
459
+
460
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - get stock - before'));
461
+ $query = "SELECT `cataloginventory_stock_status`.`product_id`, `cataloginventory_stock_status`.`stock_status` FROM `cataloginventory_stock_status` WHERE (product_id IN(" . $ids .")) AND (stock_id=1) AND (website_id=1)";
462
+
463
+ $readConnection = $pdo->prepare($query);
464
+ $readConnection->execute();
465
+ $results = $readConnection->fetchAll();
466
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - get stock - after'));
467
+
468
+
469
+ foreach($results as $r){
470
+
471
+ $products[$r['product_id']]['stock_status'] = $r['stock_status'];
472
+
473
+ }
474
+
475
+ $results = null;
476
+ $readConnection = null;
477
+
478
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - get products from website - before'));
479
+ $query = "SELECT `catalog_product_website`.* FROM `catalog_product_website` WHERE (product_id IN (" . $ids ."))";
480
+
481
+ $readConnection = $pdo->prepare($query);
482
+ $readConnection->execute();
483
+ $results = $readConnection->fetchAll();
484
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - get products from website - after'));
485
+
486
+ foreach($results as $r){
487
+
488
+ $products[$r['product_id']]['website'][] = $r['website_id'];
489
+
490
+ }
491
+
492
+ $results = null;
493
+ $readConnection = null;
494
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - get products connections - before'));
495
+
496
+ $query = "select * from catalog_product_super_link WHERE (product_id IN (" . $ids ."))";
497
+ $readConnection = $pdo->prepare($query);
498
+ $readConnection->execute();
499
+ $results = $readConnection->fetchAll();
500
+
501
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - get products connections - after'));
502
+ foreach($results as $r){
503
+
504
+ $products[$r['product_id']]['parent_id'] = $r['parent_id'];
505
+
506
+ }
507
+
508
+ $results = null;
509
+ $readConnection = null;
510
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - get categories - before'));
511
+
512
+ $query = "select * from catalog_category_product WHERE (product_id IN (" . $ids ."))";
513
+ $readConnection = $pdo->prepare($query);
514
+ $readConnection->execute();
515
+ $results = $readConnection->fetchAll();
516
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - get categories - after'));
517
+
518
+ foreach($results as $r){
519
+
520
+ $products[$r['product_id']]['categories'][] = $r['category_id'];
521
+
522
+ }
523
+
524
+ foreach ($products as $pr) {
525
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - start transform'));
526
+
527
+ $product = new stdClass();
528
+ foreach ($pr as $key => $value)
529
+ {
530
+ $product->$key = $value;
531
+ }
532
+
533
+ $pr = null;
534
+
535
+ if (count($product->website) == 0) {
536
+
537
+ $products = null;
538
+ continue;
539
+ }
540
+
541
+ $id = $product->entity_id;
542
+
543
+ $productParam = array();
544
+ $haveParent = false;
545
+
546
+ if ($this->getParentId($id) != null && $product->type_id == 'simple') {
547
+ $id = $this->getParentId($id);
548
+ $haveParent = true;
549
+ } else if ($product->visibility == 1 && $this->getParentId($id) == null) {
550
+ $product = null;
551
+ continue;
552
+ }
553
+
554
+ foreach ($attrs as $attr) {
555
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - start attributes transform'));
556
+
557
+ if (isset($this->_attributesValuesByName[$attr])) {
558
+
559
+ $val = $this->escapeString($this->getFromClass($product, $attr));
560
+
561
+ $attr = $this->_helperSearch->sanitizeFieldName($attr);
562
+
563
+ if ($val == null) {
564
+ continue;
565
+ }
566
+
567
+ $this->_attrProdCount[$attr] = true;
568
+
569
+ if (isset($this->_tmp[$attr][$id]) && in_array($val, $this->_tmp[$attr][$id])) {
570
+ continue;
571
+ }
572
+
573
+ if (isset($this->_transformedProducts['productsMtM'][$attr])) {
574
+ // If visibility is set everywhere (have value "4"), then we split it for value "2" and "3" (search and catalog separately)
575
+ if ($attr == 'visibility' && $val == '4') {
576
+ $this->_transformedProducts['productsMtM'][$attr][] = array(/*'id' => count($this->_transformedProducts['productsMtM'][$attr])+1,*/
577
+ 0 => $id, 1 => '2');
578
+ $this->_transformedProducts['productsMtM'][$attr][] = array(/*'id' => count($this->_transformedProducts['productsMtM'][$attr])+1,*/
579
+ 0 => $id, 1 => '3');
580
+ $this->_tmp[$attr][$id][] = $val;
581
+ } else {
582
+ $this->_transformedProducts['productsMtM'][$attr][] = array(/*'id' => count($this->_transformedProducts['productsMtM'][$attr])+1,*/
583
+ 0 => $id, 1 => $val);
584
+ $this->_tmp[$attr][$id][] = $val;
585
+ }
586
+ } else {
587
+ $this->_transformedProducts['productsMtM'][$attr] = array();
588
+ // If visibility is set everywhere (have value "4"), then we split it for value "2" and "3" (search and catalog separately)
589
+ if ($attr == 'visibility' && $val == '4') {
590
+ $this->_transformedProducts['productsMtM'][$attr][] = array(/*'id' => 1,*/
591
+ 0 => $id, 1 => '2');
592
+ $this->_transformedProducts['productsMtM'][$attr][] = array(/*'id' => 2,*/
593
+ 0 => $id, 1 => '3');
594
+ $this->_tmp[$attr][$id] = array($val);
595
+ } else {
596
+ $this->_transformedProducts['productsMtM'][$attr][] = array(/*'id' => 1,*/
597
+ 0 => $id, 1 => $val);
598
+ $this->_tmp[$attr][$id] = array($val);
599
+ }
600
+ }
601
+
602
+ continue;
603
+ }
604
+
605
+
606
+ switch ($attr) {
607
+ case 'description':
608
+ case 'short_description':
609
+ case 'name':
610
+ $productParam[$attr . '_' . $lang] = $this->escapeString($this->getFromClass($product, $attr));
611
+ break;
612
+ case 'category_ids':
613
+ break;
614
+ default:
615
+ $productParam[$attr] = $this->escapeString($this->getFromClass($product, $attr));
616
+ break;
617
+ }
618
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - end attributes transform'));
619
+
620
+ }
621
+
622
+ if ($haveParent) {
623
+ continue;
624
+ }
625
+
626
+ if (!isset($this->_transformedProducts['products'][$id])) {
627
+ if ($countMax > 0 && $this->_count >= $countMax) {
628
+ break;
629
+ }
630
+ $productParam['entity_id'] = $id;
631
+ $this->_transformedProducts['products'][$id] = $productParam;
632
+
633
+ //Add categories
634
+ if(isset($product->categories) && count($product->categories) > 0){
635
+ foreach ($product->categories as $cat) {
636
+
637
+ while ($cat != null) {
638
+ $this->_transformedProducts['productsMtM']['categories'][] = array(0 => $id, 1 => $cat);
639
+ if (isset($this->_transformedCategories[$cat]['parent_id'])) {
640
+ $cat = $this->_transformedCategories[$cat]['parent_id'];
641
+ } else {
642
+ $cat = null;
643
+ }
644
+ }
645
+ }
646
+ }
647
+ $this->_count++;
648
+ $localeCount++;
649
+
650
+ } elseif (isset($this->_transformedProducts['products'][$id])) {
651
+ $this->_transformedProducts['products'][$id] = array_merge($this->_transformedProducts['products'][$id], $productParam);
652
+
653
+ }
654
+ $productParam = null;
655
+ $product = null;
656
+
657
+ ksort($this->_transformedProducts['products'][$id]);
658
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - end transform'));
659
+
660
+ }
661
+ }
662
+
663
+ if(isset($this->_transformedProducts['products']) && count($this->_transformedProducts['products']) > 0){
664
+
665
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - validate names start'));
666
+
667
+ $data = $this->_transformedProducts['products'];
668
+
669
+ foreach ($this->_transformedProducts['productsMtM'] as $key => $val) {
670
+
671
+ $dataMtM = $val;
672
+
673
+ if($header){
674
+
675
+ if($key == 'categories'){
676
+ $dataMtM = array_merge(array(array("entity_id", "category_id")), $dataMtM);
677
+ } else{
678
+ $dataMtM = array_merge(array(array("entity_id", $key . "_id")), $dataMtM);
679
+ }
680
+ /** @TODO UNUSED! */
681
+ $csvFiles[] = "product_" . $this->_helperSearch->sanitizeFieldName($key);
682
+ }
683
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - validate names end'));
684
+
685
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - save to file with corrected name'));
686
+ $this->savePartToCsv( "product_" . $this->_helperSearch->sanitizeFieldName($key) . '.csv' , $dataMtM);
687
+ $this->_transformedProducts['productsMtM'][$key] = null;
688
+ }
689
+
690
+ if($header && count($data) > 0){
691
+ $data = array_merge(array(array_keys(end($data))), $data);
692
+ $header = false;
693
+ }
694
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Products - save to file'));
695
+ $this->savePartToCsv('products.csv', $data);
696
+
697
+ $data = null;
698
+
699
+ $this->_transformedProducts['products'] = array();
700
+ $this->_transformedProducts['productsMtM'] = array();
701
+
702
+ }
703
+
704
+ $page++;
705
+
706
+ $products = null;
707
+
708
+ }
709
+
710
+ $this->_transformedProducts = null;
711
+ $this->_parentId = null;
712
+ $this->_simpleIds = null;
713
+
714
+
715
+ return $this->_transformedProducts;
716
+ }
717
+
718
+ abstract protected function _getStoreProducts();
719
+
720
+ /**
721
+ * @description Preparing customers to export
722
+ * @return array Customers
723
+ *
724
+ */
725
+ protected function _exportCustomers()
726
+ {
727
+
728
+ if ($this->_storeConfig['export_customers']) {
729
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Customers - Countries are not loaded'));
730
+ $collection = Mage::getModel('directory/country')->getCollection();
731
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Customers - Countries are loaded'));
732
+
733
+ if ($this->_countries == null) {
734
+ foreach ($collection as $country) {
735
+ $this->_countries[$country->getId()] = $country->getName();
736
+ }
737
+ }
738
+
739
+ $limit = $this->_storeConfig['export_chunk'];
740
+ $count = $limit;
741
+ $page = 1;
742
+ $header = true;
743
+
744
+ do{
745
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Customers - load page '.$page));
746
+ $customers_to_save = array();
747
+ $customers = Mage::getModel('customer/customer')
748
+ ->getCollection()
749
+ ->setPageSize($limit)
750
+ ->setCurPage($page)
751
+ ->addAttributeToSelect('*');
752
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Customers - loaded page '.$page));
753
+
754
+ foreach ($customers as $customer) {
755
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Customers - Load billing address '));
756
+ $billing = $customer->getPrimaryBillingAddress();
757
+ if(!empty($billing)) {
758
+ $countryCode = $billing->getCountry();
759
+ }
760
+
761
+ switch ($customer->getGender()) {
762
+ case 1:
763
+ $gender = 'male';
764
+ break;
765
+ case 2:
766
+ $gender = 'female';
767
+ break;
768
+ default:
769
+ $gender = null;
770
+ break;
771
+ }
772
+
773
+ $customers_to_save[] = array(
774
+ 'customer_id' => $customer->getId(),
775
+ 'gender' => $gender,
776
+ 'dob' => $customer->getDob(),
777
+ 'country' => !empty($countryCode) ? $this->_helperExporter->getCountry($countryCode)->getName() : '',
778
+ 'zip' => !empty($billing) ? $billing->getPostcode() : ''
779
+ );
780
+
781
+ }
782
+
783
+ $data = $customers_to_save;
784
+
785
+ if($header){
786
+ $data = array_merge(array(array_keys(end($customers_to_save))), $customers_to_save);
787
+ $header = false;
788
+ }
789
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Customers - save to file'));
790
+ $this->savePartToCsv('customers.csv', $data);
791
+
792
+ $count = count($customers_to_save);
793
+ $page++;
794
+
795
+ } while($count >= $limit);
796
+ $customers = null;
797
+ }
798
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Customers - end of exporting '));
799
+ return null;
800
+ }
801
+
802
+ abstract protected function _getCustomers();
803
+
804
+ /**
805
+ * @description Preparing transactions to export
806
+ * @return array Transaction
807
+ */
808
+ protected function _exportTransactions()
809
+ {
810
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Transactions - start of export'));
811
+ if ($this->_storeConfig['export_transactions']) {
812
+
813
+ $limit = $this->_storeConfig['export_chunk'];
814
+ $count = $limit;
815
+ $page = 1;
816
+ $header = true;
817
+
818
+ while($count >= $limit){
819
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Transactions - load page '.$page));
820
+
821
+ $transactions_to_save = array();
822
+ $transactions = Mage::getModel('sales/order')
823
+ // ->setStoreId($this->_storeId)
824
+ ->getCollection()
825
+ ->setPageSize($limit)
826
+ ->setCurPage($page)
827
+ ->addAttributeToSelect('*');
828
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Transactions - loaded page '.$page));
829
+
830
+ foreach ($transactions as $transaction) {
831
+
832
+ if ($transaction->getStatus() == 'canceled') {
833
+ continue;
834
+ }
835
+
836
+ $configurable = array();
837
+
838
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Transactions - get all items - before'));
839
+ $products = ($transaction->getAllItems());
840
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Transactions - get all items - after'));
841
+
842
+ foreach ($products as $product) {
843
+
844
+ //is configurable
845
+ if ($product->getParentItemId() == null && $product->getProductType() != 'simple') {
846
+ $configurable[$product->getId()] = $product;
847
+ continue;
848
+ }
849
+
850
+ //is configurable - simple product
851
+ if (intval($product->getPrice()) == 0) {
852
+ if(isset($configurable[$product->getParentItemId()])){
853
+ $pid = $configurable[$product->getParentItemId()];
854
+ } else{
855
+ $pid = Mage::getModel('catalog/product')->load($product->getParentItemId());
856
+ }
857
+ $product->setOriginalPrice($pid->getOriginalPrice());
858
+ $product->setPrice($pid->getPrice());
859
+ }
860
+
861
+ $status = 0; // 0 - pending, 1 - confirmed, 2 - shipping
862
+
863
+ if ($transaction->getUpdatedAt() != $transaction->getCreatedAt()) {
864
+
865
+ switch ($transaction->getStatus()) {
866
+ case 'canceled':
867
+ continue;
868
+ continue;
869
+ break;
870
+ case 'processing':
871
+ $status = 1;
872
+ break;
873
+ case 'complete':
874
+ $status = 2;
875
+ break;
876
+ }
877
+ }
878
+ $transactions_to_save[] = array(
879
+ 'order_id' => $transaction->getId(),
880
+ 'entity_id' => $product->getProductId(),
881
+ 'customer_id' => $transaction->getCustomerId(),
882
+ 'price' => $product->getOriginalPrice(),
883
+ 'discounted_price' => $product->getPrice(),
884
+ 'quantity' => $product->getQtyOrdered(),
885
+ 'total_order_value' => ($transaction->getBaseSubtotal() + $transaction->getShippingAmount()),
886
+ 'shipping_costs' => $transaction->getShippingAmount(),
887
+ 'order_date' => $transaction->getCreatedAt(),
888
+ 'confirmation_date' => $status == 1 ? $transaction->getUpdatedAt() : null,
889
+ 'shipping_date' => $status == 2 ? $transaction->getUpdatedAt() : null,
890
+ 'status' => $transaction->getStatus()
891
+ );
892
+ }
893
+
894
+ $configurable = null;
895
+ $products = null;
896
+ }
897
+
898
+ $data = $transactions_to_save;
899
+ $count = count($transactions);
900
+
901
+ if($header){
902
+ $data = array_merge(array(array_keys(end($transactions_to_save))), $transactions_to_save);
903
+ $header = false;
904
+ }
905
+
906
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Transactions - save to file'));
907
+ $this->savePartToCsv('transactions.csv', $data);
908
+
909
+ $page++;
910
+
911
+ $transactions = null;
912
+
913
+ }
914
+
915
+ }
916
+
917
+ Boxalino_CemSearch_Model_Logger::saveMemoryTracking('info', 'Indexer', array('memory_usage' => memory_get_usage(true), 'method' => __METHOD__, 'description' => 'Transactions - end of export'));
918
+ return null;
919
+ }
920
+
921
+ abstract protected function _getTransactions();
922
+
923
+ abstract protected function _getIndexType();
924
+
925
+ /**
926
+ * @description Preparing files to send
927
+ */
928
+ protected function prepareFiles($website, &$categories = null, &$tags = null )
929
+ {
930
+
931
+ //Prepare attributes
932
+ $csvFiles = array();
933
+ if (!file_exists("/tmp/boxalino")) {
934
+ mkdir("/tmp/boxalino");
935
+ }
936
+
937
+ //create csv
938
+ //save attributes
939
+ foreach ($this->_attributesValuesByName as $attrName => $attrValues) {
940
+ $csvFiles[] = $this->createCsv($this->_helperSearch->sanitizeFieldName($attrName), $attrValues);
941
+ }
942
+
943
+ //save categories
944
+ if ($categories != null) {
945
+ $csvFiles[] = $this->createCsv('categories', $categories);
946
+ $categories = null;
947
+ }
948
+
949
+ //save tags
950
+ if ($tags != null) {
951
+ $csvFiles[] = $this->createCsv('tag', $tags);
952
+
953
+ $loop = 1;
954
+ foreach ($this->_getProductTags() as $product_id => $tag_id) {
955
+ $csvdata[] = array('id' => $loop++, 'entity_id' => $product_id, 'tag_id' => $tag_id);
956
+ }
957
+
958
+ $csvFiles[] = $this->createCsv('product_tag', $csvdata);
959
+
960
+ }
961
+
962
+ // csv done
963
+
964
+ //Create name for file
965
+ $exportFile = '/tmp/boxalino/' . $this->_storeConfig['di_username'];
966
+
967
+ $csvFiles = array_filter($csvFiles);
968
+
969
+ //Create xml
970
+ $this->createXML($exportFile . '.xml');
971
+
972
+ //Create zip
973
+
974
+ $this->createZip($exportFile . '.zip', array_filter($this->_files), $exportFile . '.xml');
975
+
976
+ return $exportFile;
977
+
978
+ //
979
+
980
+ }
981
+
982
+ /**
983
+ * @param $name
984
+ * @param $data
985
+ * @param $csv
986
+ * @return string
987
+ */
988
+ protected function createCsv($name, &$data)
989
+ {
990
+ $file = $name . '.csv';
991
+
992
+ if(!is_array($data) || count($data) == 0){
993
+ Mage::getModel('adminhtml/session')->addWarning("Data for $file have wrong format or is empty. " . "[" . gettype($data) . "]");
994
+ }
995
+
996
+ $csvdata = array_merge(array(array_keys(end($data))), $data);
997
+ $csvdata[0][0] = $this->_helperSearch->sanitizeFieldName($csvdata[0][0]);
998
+
999
+ $fh = fopen($this->_dir . '/' . $file, 'a');
1000
+ foreach ($csvdata as $dataRow) {
1001
+ fputcsv($fh, $dataRow, $this->_helperExporter->XML_DELIMITER, $this->_helperExporter->XML_ENCLOSURE);
1002
+ }
1003
+ fclose($fh);
1004
+
1005
+ $this->_files[] = $file;
1006
+
1007
+ return $file;
1008
+
1009
+
1010
+ }
1011
+
1012
+ /**
1013
+ * @description Get list of products with their tags
1014
+ * @return object List of products with their tags array('product_id' => 'tag_id');
1015
+ */
1016
+ protected function _getProductTags()
1017
+ {
1018
+ if (empty($this->_allProductTags)) {
1019
+ $tags = Mage::getResourceModel('tag/product_collection')->getData();
1020
+ foreach ($tags as $tag) {
1021
+ $this->_allProductTags[$tag['entity_id']] = $tag['tag_id'];
1022
+ }
1023
+ $tags = null;
1024
+ }
1025
+
1026
+ return $this->_allProductTags;
1027
+ }
1028
+
1029
+ protected function createXML($name)
1030
+ {
1031
+
1032
+ $xml = new SimpleXMLElement('<root/>');
1033
+
1034
+ $languages = $xml->addChild('languages');
1035
+ $containers = $xml->addChild('containers');
1036
+
1037
+ //languages
1038
+ foreach ($this->_availableLanguages as $lang) {
1039
+ $language = $languages->addChild('language');
1040
+ $language->addAttribute('id', $lang);
1041
+ }
1042
+
1043
+ //customers
1044
+ $tmp = $this->_helperExporter;
1045
+ $customerString = <<<XML
1046
+ <container id="customers" type="customers">
1047
+ <sources>
1048
+ <source type="item_data_file" id="customer_vals">
1049
+ <file value="customers.csv"/>
1050
+ <itemIdColumn value="customer_id"/>
1051
+ <format value="$tmp->XML_FORMAT"/>
1052
+ <encoding value="$tmp->XML_ENCODE"/>
1053
+ <delimiter value="$tmp->XML_DELIMITER"/>
1054
+ <enclosure value="$tmp->XML_ENCLOSURE_TEXT"/>
1055
+ <escape value="$tmp->XML_ESCAPE"/>
1056
+ <lineSeparator value="$tmp->XML_NEWLINE"/>
1057
+ </source>
1058
+ </sources>
1059
+ <properties>
1060
+ <property id="id" type="id">
1061
+ <transform>
1062
+ <logic source="customer_vals" type="direct">
1063
+ <field column="customer_id"/>
1064
+ </logic>
1065
+ </transform>
1066
+ <params/>
1067
+ </property>
1068
+ <property id="customer_id" type="string">
1069
+ <transform>
1070
+ <logic source="customer_vals" type="direct">
1071
+ <field column="customer_id"/>
1072
+ </logic>
1073
+ </transform>
1074
+ <params/>
1075
+ </property>
1076
+ <property id="gender" type="string">
1077
+ <transform>
1078
+ <logic source="customer_vals" type="direct">
1079
+ <field column="gender"/>
1080
+ </logic>
1081
+ </transform>
1082
+ <params/>
1083
+ </property>
1084
+ <property id="dob" type="date">
1085
+ <transform>
1086
+ <logic source="customer_vals" type="direct">
1087
+ <field column="dob"/>
1088
+ </logic>
1089
+ </transform>
1090
+ <params/>
1091
+ </property>
1092
+ <property id="country" type="string">
1093
+ <transform>
1094
+ <logic source="customer_vals" type="direct">
1095
+ <field column="country"/>
1096
+ </logic>
1097
+ </transform>
1098
+ <params/>
1099
+ </property>
1100
+ <property id="zip" type="string">
1101
+ <transform>
1102
+ <logic source="customer_vals" type="direct">
1103
+ <field column="zip"/>
1104
+ </logic>
1105
+ </transform>
1106
+ <params/>
1107
+ </property>
1108
+ </properties>
1109
+ </container>
1110
+ XML;
1111
+
1112
+ //transaction
1113
+ $transactionString = <<<XML
1114
+ <container id="transactions" type="transactions">
1115
+ <sources>
1116
+ <source type="transactions" id="transactions">
1117
+ <file value="transactions.csv"/>
1118
+ <orderIdColumn value="order_id"/>
1119
+ <customerIdColumn value="customer_id" customer_property_id="customer_id"/>
1120
+ <productIdColumn value="entity_id" product_property_id="product_entity_id"/>
1121
+ <productListPriceColumn value="price"/>
1122
+ <productDiscountedPriceColumn value="discounted_price"/>
1123
+ <totalOrderValueColumn value="total_order_value"/>
1124
+ <shippingCostsColumn value="shipping_costs"/>
1125
+ <orderReceptionDateColumn value="order_date"/>
1126
+ <orderReceptionDateColumn value="confirmation_date"/>
1127
+ <orderShippingDateColumn value="shipping_date"/>
1128
+ <orderStatusColumn value="status"/>
1129
+ <format value="$tmp->XML_FORMAT"/>
1130
+ <encoding value="$tmp->XML_ENCODE"/>
1131
+ <delimiter value="$tmp->XML_DELIMITER"/>
1132
+ <enclosure value="$tmp->XML_ENCLOSURE_TEXT"/>
1133
+ <escape value="$tmp->XML_ESCAPE"/>
1134
+ <lineSeparator value="$tmp->XML_NEWLINE"/>
1135
+ </source>
1136
+ </sources>
1137
+ </container>
1138
+ XML;
1139
+
1140
+ //product
1141
+ $products = $containers->addChild('container');
1142
+ $products->addAttribute('id', 'products');
1143
+ $products->addAttribute('type', 'products');
1144
+
1145
+ $sources = $products->addChild('sources');
1146
+
1147
+ //product source
1148
+ #########################################################################
1149
+ $source = $sources->addChild('source');
1150
+ $source->addAttribute('id', 'item_vals');
1151
+ $source->addAttribute('type', 'item_data_file');
1152
+
1153
+ $source->addChild('file')->addAttribute('value', 'products.csv');
1154
+ $source->addChild('itemIdColumn')->addAttribute('value', 'entity_id');
1155
+
1156
+ $this->sxml_append_options($source);
1157
+ #########################################################################
1158
+
1159
+ $attrs = array_keys($this->_attributesValuesByName);
1160
+ if ($this->_storeConfig['export_tags']) {
1161
+ $attrs[] = 'tag';
1162
+
1163
+ }
1164
+
1165
+ foreach ($attrs as $attr) {
1166
+
1167
+ // if(!array_key_exists($attr . '.csv', $this->_files)){
1168
+ // continue;
1169
+ // }
1170
+
1171
+ $attr = $this->_helperSearch->sanitizeFieldName($attr);
1172
+
1173
+ //attribute
1174
+ $source = $sources->addChild('source');
1175
+ $source->addAttribute('type', 'resource');
1176
+ $source->addAttribute('id', 'resource_' . $attr);
1177
+
1178
+ $source->addChild('file')->addAttribute('value', $attr . '.csv');
1179
+ $source->addChild('referenceIdColumn')->addAttribute('value', $attr . '_id');
1180
+ $source->addChild('itemIdColumn')->addAttribute('value', $attr . '_id');
1181
+
1182
+ $labelColumns = $source->addChild('labelColumns');
1183
+ foreach ($this->_availableLanguages as $lang) {
1184
+ $label = $labelColumns->addChild('language');
1185
+ $label->addAttribute('name', $lang);
1186
+ $label->addAttribute('value', 'value_' . $lang);
1187
+ }
1188
+
1189
+ $this->sxml_append_options($source);
1190
+
1191
+ //product & attribute
1192
+ $source = $sources->addChild('source');
1193
+ $source->addAttribute('type', 'item_data_file');
1194
+ $source->addAttribute('id', 'item_' . $attr);
1195
+
1196
+ $source->addChild('file')->addAttribute('value', 'product_' . $attr . '.csv');
1197
+ $source->addChild('itemIdColumn')->addAttribute('value', 'entity_id');
1198
+
1199
+ $this->sxml_append_options($source);
1200
+
1201
+ }
1202
+
1203
+ ########################################################################
1204
+ if ($this->_storeConfig['export_categories']) {
1205
+ //categories
1206
+ $sourceCategory = $sources->addChild('source');
1207
+ $sourceCategory->addAttribute('type', 'hierarchical');
1208
+ $sourceCategory->addAttribute('id', 'resource_categories');
1209
+
1210
+
1211
+ $sourceCategory->addChild('file')->addAttribute('value', 'categories.csv');
1212
+ $sourceCategory->addChild('referenceIdColumn')->addAttribute('value', 'category_id');
1213
+ $sourceCategory->addChild('parentIdColumn')->addAttribute('value', 'parent_id');
1214
+
1215
+ $labelColumns = $sourceCategory->addChild('labelColumns');
1216
+ foreach ($this->_availableLanguages as $lang) {
1217
+ $label = $labelColumns->addChild('language');
1218
+ $label->addAttribute('name', $lang);
1219
+ $label->addAttribute('value', 'value_' . $lang);
1220
+ }
1221
+
1222
+ $this->sxml_append_options($sourceCategory);
1223
+
1224
+ //categories & products
1225
+ $source = $sources->addChild('source');
1226
+ $source->addAttribute('type', 'item_data_file');
1227
+ $source->addAttribute('id', 'item_categories');
1228
+
1229
+
1230
+ $source->addChild('file')->addAttribute('value', 'product_categories.csv');
1231
+ $source->addChild('itemIdColumn')->addAttribute('value', 'entity_id');
1232
+
1233
+ $this->sxml_append_options($source);
1234
+ }
1235
+ #########################################################################
1236
+
1237
+ //property
1238
+ $properties = $products->addChild('properties');
1239
+ $props = $this->prepareProperties();
1240
+
1241
+ foreach ($props as $prop) {
1242
+ if ($prop['id'] == 'entity_id') {
1243
+
1244
+ }
1245
+
1246
+ // if($prop['type'] == 'reference' && !array_key_exists($prop['name'], $this->_files)){
1247
+ // continue;
1248
+ // }
1249
+
1250
+ $property = $properties->addChild('property');
1251
+ $property->addAttribute('id', $this->_helperSearch->sanitizeFieldName($prop['id']));
1252
+ $property->addAttribute('type', $prop['ptype']);
1253
+
1254
+ $transform = $property->addChild('transform');
1255
+ $logic = $transform->addChild('logic');
1256
+ $ls = $prop['name'] == null ? 'item_vals' : 'item_' . $prop['name'];
1257
+ $logic->addAttribute('source', $this->_helperSearch->sanitizeFieldName($ls));
1258
+ $logic->addAttribute('type', $prop['type']);
1259
+ if ($prop['has_lang'] == true) {
1260
+ foreach ($this->_availableLanguages as $lang) {
1261
+ $field = $logic->addChild('field');
1262
+ $field->addAttribute('column', $this->_helperSearch->sanitizeFieldName($prop['field']) . '_' . $lang);
1263
+ $field->addAttribute('language', $lang);
1264
+ }
1265
+ } else {
1266
+ $logic->addChild('field')->addAttribute('column', $this->_helperSearch->sanitizeFieldName($prop['field']));
1267
+ }
1268
+
1269
+ $params = $property->addChild('params');
1270
+ if ($prop['type'] != 'direct') {
1271
+ $params->addChild('referenceSource')->addAttribute('value', 'resource_' . $this->_helperSearch->sanitizeFieldName($prop['reference']));
1272
+ }
1273
+
1274
+ }
1275
+ ##################################
1276
+
1277
+ ##################################
1278
+
1279
+ if ($this->_storeConfig['export_customers']) {
1280
+ $customer = simplexml_load_string($customerString);
1281
+ $this->sxml_append($containers, $customer);
1282
+ }
1283
+
1284
+ if ($this->_storeConfig['export_transactions']) {
1285
+ $transaction = simplexml_load_string($transactionString);
1286
+ $this->sxml_append($containers, $transaction);
1287
+ }
1288
+
1289
+ $dom = new DOMDocument("1.0");
1290
+ $dom->preserveWhiteSpace = false;
1291
+ $dom->formatOutput = true;
1292
+ $dom->loadXML($xml->asXML());
1293
+ $saveXML = $dom->saveXML();
1294
+ file_put_contents($name, $saveXML);
1295
+ // $dom->save($name);
1296
+
1297
+
1298
+ }
1299
+
1300
+ /**
1301
+ * desciption: add default xmlElements
1302
+ * @param SimpleXMLElement $xml
1303
+ */
1304
+ function sxml_append_options(SimpleXMLElement &$xml)
1305
+ {
1306
+ $xml->addChild('format')->addAttribute('value', $this->_helperExporter->XML_FORMAT);
1307
+ $xml->addChild('encoding')->addAttribute('value', $this->_helperExporter->XML_ENCODE);
1308
+ $xml->addChild('delimiter')->addAttribute('value', $this->_helperExporter->XML_DELIMITER);
1309
+ $xml->addChild('enclosure')->addAttribute('value', $this->_helperExporter->XML_ENCLOSURE);
1310
+ $xml->addChild('escape')->addAttribute('value', $this->_helperExporter->XML_ESCAPE);
1311
+ $xml->addChild('lineSeparator')->addAttribute('value', $this->_helperExporter->XML_NEWLINE);
1312
+ }
1313
+
1314
+ /**
1315
+ * @return array
1316
+ */
1317
+ function prepareProperties()
1318
+ {
1319
+
1320
+ $properties = array();
1321
+
1322
+ $attrs = $this->_listOfAttributes;
1323
+ // $attrs[] = 'parent_id';
1324
+
1325
+ foreach ($attrs as $attr) {
1326
+
1327
+ $ptype = 'string';
1328
+
1329
+ // set property type
1330
+ switch ($attr) {
1331
+ case 'name':
1332
+ $ptype = 'title';
1333
+ break;
1334
+ case 'description':
1335
+ $ptype = 'body';
1336
+ break;
1337
+ case 'price':
1338
+ $ptype = 'price';
1339
+ break;
1340
+ case 'special_price':
1341
+ $ptype = 'discounted';
1342
+ break;
1343
+ case 'entity_id':
1344
+ $ptype = 'id';
1345
+ break;
1346
+ case 'short_description':
1347
+ $ptype = 'text';
1348
+ break;
1349
+ case 'weight':
1350
+ case 'width':
1351
+ case 'height':
1352
+ case 'length':
1353
+ $ptype = 'number';
1354
+ break;
1355
+
1356
+ }
1357
+
1358
+ if (isset($this->_attributesValuesByName[$attr])) {
1359
+ $properties[] = array(
1360
+ 'id' => $attr,
1361
+ 'name' => $attr,
1362
+ 'ptype' => 'text',
1363
+ 'type' => 'reference',
1364
+ 'field' => $attr . '_id',
1365
+ 'has_lang' => false,
1366
+ 'reference' => $attr
1367
+ );
1368
+ } elseif ($attr == 'category_ids') {
1369
+ continue;
1370
+ } else {
1371
+ $ref = null;
1372
+ $type = 'direct';
1373
+ $field = $attr;
1374
+ switch ($attr) {
1375
+ case 'description':
1376
+ case 'short_description':
1377
+ case 'name':
1378
+ $lang = true;
1379
+ break;
1380
+ default:
1381
+ $lang = false;
1382
+ break;
1383
+ }
1384
+ $properties[] = array(
1385
+ 'id' => $attr,
1386
+ 'name' => null,
1387
+ 'ptype' => $ptype,
1388
+ 'type' => $type,
1389
+ 'field' => $field,
1390
+ 'has_lang' => $lang,
1391
+ 'reference' => $ref
1392
+ );
1393
+ }
1394
+ }
1395
+ //tag
1396
+ if ($this->_storeConfig['export_tags']) {
1397
+ $properties[] = array(
1398
+ 'id' => 'tag',
1399
+ 'name' => 'tag',
1400
+ 'ptype' => 'text',
1401
+ 'type' => 'reference',
1402
+ 'field' => 'tag_id',
1403
+ 'has_lang' => false,
1404
+ 'reference' => 'tag'
1405
+ );
1406
+ }
1407
+
1408
+ //categories
1409
+ if ($this->_storeConfig['export_categories']) {
1410
+ $properties[] = array(
1411
+ 'id' => 'category',
1412
+ 'name' => 'categories', //property id
1413
+ 'ptype' => 'hierarchical', //property type
1414
+ 'type' => 'reference', //logic type
1415
+ 'field' => 'category_id', //field colummn
1416
+ 'has_lang' => false,
1417
+ 'reference' => 'categories'
1418
+ );
1419
+ }
1420
+ $properties[] = array('id' => 'product_entity_id', 'name' => null, 'ptype' => 'string', 'type' => 'direct', 'field' => 'entity_id', 'has_lang' => false, 'reference' => null);
1421
+
1422
+ return $properties;
1423
+
1424
+ }
1425
+
1426
+ /**
1427
+ *
1428
+ * description: add xmlElement to other xmlElement
1429
+ * @param SimpleXMLElement $to
1430
+ * @param SimpleXMLElement $from
1431
+ */
1432
+ function sxml_append(SimpleXMLElement $to, SimpleXMLElement $from)
1433
+ {
1434
+ $toDom = dom_import_simplexml($to);
1435
+ $fromDom = dom_import_simplexml($from);
1436
+ $toDom->appendChild($toDom->ownerDocument->importNode($fromDom, true));
1437
+ }
1438
+
1439
+ /**
1440
+ * @param $name
1441
+ * @param $csvFiles
1442
+ */
1443
+ protected function createZip($name, $csvFiles, $xml)
1444
+ {
1445
+ if (file_exists($name)) {
1446
+ @unlink($name);
1447
+ };
1448
+
1449
+ $zip = new ZipArchive();
1450
+ if ($zip->open($name, ZIPARCHIVE::CREATE)) {
1451
+
1452
+ foreach ($csvFiles as $f) {
1453
+ if (!$zip->addFile('/tmp/boxalino/' . $f, $f)) {
1454
+ throw new Exception('Synchronization failure. Please try again.');
1455
+ }
1456
+ }
1457
+
1458
+ if (!$zip->addFile($xml, 'properties.xml')) {
1459
+ throw new Exception('Synchronization failure. Please try again.');
1460
+ }
1461
+
1462
+ if (!$zip->close()) {
1463
+ throw new Exception('Synchronization failure. Please try again.');
1464
+ }
1465
+
1466
+ } else {
1467
+ throw new Exception('Synchronization failure. Please try again.');
1468
+ }
1469
+ }
1470
+
1471
+ protected function pushXML($file)
1472
+ {
1473
+
1474
+ $fields = array(
1475
+ "username" => $this->_storeConfig['di_username'],
1476
+ "password" => $this->_storeConfig['di_password'],
1477
+ "account" => $this->_storeConfig['di_account'],
1478
+ "template" => 'standard_source',
1479
+ "xml" => file_get_contents($file . '.xml')
1480
+ );
1481
+
1482
+ $url = $this->_helperExporter->getXMLSyncUrl($this->_storeConfig['account_dev']);
1483
+
1484
+ return $this->pushFile($fields, $url, 'xml');
1485
+
1486
+ }
1487
+
1488
+ protected function pushFile($fields, $url, $type)
1489
+ {
1490
+
1491
+ $s = curl_init();
1492
+
1493
+ curl_setopt($s, CURLOPT_URL, $url);
1494
+ curl_setopt($s, CURLOPT_TIMEOUT, 35000);
1495
+ curl_setopt($s, CURLOPT_POST, true);
1496
+ curl_setopt($s, CURLOPT_ENCODING, "");
1497
+ curl_setopt($s, CURLOPT_RETURNTRANSFER, true);
1498
+ curl_setopt($s, CURLOPT_POSTFIELDS, $fields);
1499
+
1500
+ $responseBody = curl_exec($s);
1501
+ curl_close($s);
1502
+ if (strpos($responseBody, 'Internal Server Error') !== false) {
1503
+ Mage::throwException($this->_helperExporter->getError($responseBody));;
1504
+ }
1505
+ return $responseBody;
1506
+ }
1507
+
1508
+ /**
1509
+ * @param $zip
1510
+ */
1511
+ protected function pushZip($file)
1512
+ {
1513
+ $fields = array(
1514
+ "username" => $this->_storeConfig['di_username'],
1515
+ "password" => $this->_storeConfig['di_password'],
1516
+ "account" => $this->_storeConfig['di_account'],
1517
+ "dev" => $this->_storeConfig['account_dev'] == 0 ? 'false' : 'true',
1518
+ "delta" => $this->_getIndexType() == 'delta' ? "true" : "false", // I know...
1519
+ "data" => '@' . $file . '.zip;type=application/zip'
1520
+ );
1521
+
1522
+ $url = $this->_helperExporter->getZIPSyncUrl($this->_storeConfig['account_dev']);
1523
+
1524
+ return $this->pushFile($fields, $url, 'zip');
1525
+ }
1526
+
1527
+ /**
1528
+ * @description Closing sync to export
1529
+ */
1530
+ protected function _closeExport()
1531
+ {
1532
+ $this->delTree($this->_dir);
1533
+ }
1534
+
1535
+ function getmicrotime($mt, $string = true)
1536
+ {
1537
+ list($usec, $sec) = explode(" ", $mt);
1538
+
1539
+ if ($string)
1540
+ return date('Y-m-d H:i:s', (float)$usec + (float)$sec) . '.' . $usec;
1541
+ else
1542
+ return ((float)$usec + (float)$sec);
1543
+ }
1544
+
1545
+ /**
1546
+ * @description Get stock of all products
1547
+ * @return array List of stocks qty for products
1548
+ */
1549
+ protected function _getProductsStockQty()
1550
+ {
1551
+ if (empty($this->_productsStockQty)) {
1552
+ $products = Mage::getModel('cataloginventory/stock_item')->getCollection();
1553
+ foreach ($products as $product) {
1554
+ $this->_productsStockQty[$product->getProductId()] = $product->getQty();
1555
+ }
1556
+ $products = null;
1557
+ }
1558
+
1559
+ return $this->_productsStockQty;
1560
+ }
1561
+
1562
+ protected function savePartToCsv($file, &$data){
1563
+
1564
+ if (!file_exists("/tmp/boxalino")) {
1565
+ mkdir("/tmp/boxalino");
1566
+ }
1567
+
1568
+ //save
1569
+ if(!in_array($file, $this->_files)){
1570
+ $this->_files[] = $file;
1571
+ }
1572
+
1573
+ $fh = fopen($this->_dir . '/' . $file, 'a');
1574
+ foreach ($data as $dataRow) {
1575
+ fputcsv($fh, $dataRow, $this->_helperExporter->XML_DELIMITER, $this->_helperExporter->XML_ENCLOSURE);
1576
+ }
1577
+ fclose($fh);
1578
+ $data = null;
1579
+ $fh = null;
1580
+
1581
+ }
1582
+
1583
+ public static function delTree($dir) {
1584
+ if(!file_exists($dir)){
1585
+ return;
1586
+ }
1587
+ $files = array_diff(scandir($dir), array('.','..'));
1588
+ foreach ($files as $file) {
1589
+ if(is_dir("$dir/$file")){
1590
+ delTree("$dir/$file");
1591
+ } else if(file_exists("$dir/$file")){
1592
+ @unlink("$dir/$file");
1593
+ }
1594
+ // (is_dir("$dir/$file")) ? delTree("$dir/$file") : @unlink("$dir/$file");
1595
+ }
1596
+ return rmdir($dir);
1597
+ }
1598
+
1599
+ protected function escapeString($string){
1600
+
1601
+ return htmlspecialchars(trim(preg_replace('/\s+/', ' ', $string)));
1602
+
1603
+ }
1604
+
1605
+ private static function clearMemory(&$obj){
1606
+ $obj = null;
1607
+ }
1608
+
1609
+ private static function getFromClass(&$class, $val){
1610
+
1611
+ if(isset($class->$val)){
1612
+ return $class->$val;
1613
+ } else{
1614
+ return '';
1615
+ }
1616
+
1617
+ }
1618
+
1619
+ /**
1620
+ * Load connection arrays if necessary.
1621
+ */
1622
+ private function loadProductLinks()
1623
+ {
1624
+
1625
+ // If arrays already set - nothing to do here.
1626
+ if ($this->_isLoad) {
1627
+ return;
1628
+ }
1629
+
1630
+ // Get database connection
1631
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
1632
+ $tableName = $connection->getTableName('catalog_product_super_link');
1633
+ // Get all data from `catalog_product_super_link`
1634
+ $query = 'select * from ' . $tableName;
1635
+ $this->_simples = array();
1636
+ $this->_configurables = array();
1637
+
1638
+ // Iterate through collection
1639
+ foreach ($connection->fetchAll($query) as $row) {
1640
+ $productId = $row['product_id'];
1641
+ $parentId = $row['parent_id'];
1642
+
1643
+ // Set simpleIds array if not set yet for specified parent.
1644
+ if (!isset($this->_simpleIds[$parentId])) {
1645
+ $this->_simpleIds[$parentId] = array();
1646
+ }
1647
+ // Add simple product to collection of parent.
1648
+ $this->_simpleIds[$parentId][] = $productId;
1649
+ // Add parent to simple product.
1650
+ $this->_parentId[$productId] = $parentId;
1651
+ }
1652
+ unset($connection);
1653
+ $this->_isLoad = true;
1654
+ }
1655
+
1656
+ /**
1657
+ * Return parent id.
1658
+ *
1659
+ * @param null $productId
1660
+ * @return null|int|array
1661
+ */
1662
+ public function getParentId($productId = null)
1663
+ {
1664
+ // Load connections if necessary.
1665
+ $this->loadProductLinks();
1666
+
1667
+ // If no product is specified - return whole array.
1668
+ if (!isset($productId)) {
1669
+ return $this->_parentId;
1670
+ }
1671
+
1672
+ // If we have parent id for specified product - return it.
1673
+ if (isset($this->_parentId[$productId])) {
1674
+ return $this->_parentId[$productId];
1675
+ }
1676
+
1677
+ // No parent - return null.
1678
+ return null;
1679
+ }
1680
+
1681
+ /**
1682
+ * Return simple ids.
1683
+ *
1684
+ * @param null $productId
1685
+ * @return null|int|array
1686
+ */
1687
+ public function getSimpleIds($productId = null)
1688
+ {
1689
+
1690
+ // Load connections if necessary.
1691
+ $this->loadProductLinks();
1692
+
1693
+ // If no product is specified - return whole array.
1694
+ if (!isset($productId)) {
1695
+ return $this->_simpleIds;
1696
+ }
1697
+
1698
+ // If we have simple ids for specified product - return it.
1699
+ if (isset($this->_simpleIds[$productId])) {
1700
+ return $this->_simpleIds[$productId];
1701
+ }
1702
+ // No simple ids - return null.
1703
+ return null;
1704
+ }
1705
+
1706
+ }
app/code/local/Boxalino/Exporter/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <acl>
5
+ <resources>
6
+ <admin>
7
+ <children>
8
+ <system>
9
+ <children>
10
+ <config>
11
+ <children>
12
+ <boxalinoexporter translate="title" module="boxalinoexporter">
13
+ <title>Boxalino Exporter</title>
14
+ </boxalinoexporter>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/local/Boxalino/Exporter/etc/config.xml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Boxalino_Exporter>
4
+ <version>1.0</version>
5
+ </Boxalino_Exporter>
6
+ </modules>
7
+ <global>
8
+ <index>
9
+ <indexer>
10
+ <boxalinoexporter_indexer>
11
+ <model>boxalinoexporter/indexer</model>
12
+ </boxalinoexporter_indexer>
13
+ <boxalinoexporter_delta>
14
+ <model>boxalinoexporter/delta</model>
15
+ </boxalinoexporter_delta>
16
+ </indexer>
17
+ </index>
18
+ <helpers>
19
+ <boxalinoexporter>
20
+ <class>Boxalino_Exporter_Helper</class>
21
+ </boxalinoexporter>
22
+ </helpers>
23
+ <models>
24
+ <boxalinoexporter>
25
+ <class>Boxalino_Exporter_Model</class>
26
+ <resourceModel>boxalinoexporter_mysql4</resourceModel>
27
+ </boxalinoexporter>
28
+ <boxalinoexporter_mysql4>
29
+ <class>Boxalino_Exporter_Model_Mysql4</class>
30
+ </boxalinoexporter_mysql4>
31
+ </models>
32
+ </global>
33
+ <adminhtml>
34
+ <translate>
35
+ <modules>
36
+ <Boxalino_Exporter>
37
+ <files>
38
+ <default>Boxalino_Exporter.csv</default>
39
+ </files>
40
+ </Boxalino_Exporter>
41
+ </modules>
42
+ </translate>
43
+ </adminhtml>
44
+ <default>
45
+ <boxalinoexporter>
46
+ <export_data>
47
+ <maximum_population>0</maximum_population>
48
+ <language>en</language>
49
+ <export_categories>1</export_categories>
50
+ <export_tags>1</export_tags>
51
+ <export_customers>1</export_customers>
52
+ <export_transactions>1</export_transactions>
53
+ <export_chunk>200</export_chunk>
54
+ </export_data>
55
+ </boxalinoexporter>
56
+ </default>
57
+ </config>
app/code/local/Boxalino/Exporter/etc/system.xml ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <tabs>
5
+ <boxalino translate="label" module="boxalinoexporter">
6
+ <label>Boxalino Extensions</label>
7
+ <sort_order>100</sort_order>
8
+ </boxalino>
9
+ </tabs>
10
+ <sections>
11
+ <boxalinoexporter translate="label" module="boxalinoexporter">
12
+ <class>separator-top</class>
13
+ <label>Boxalino Exporter</label>
14
+ <tab>boxalino</tab>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>800</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <groups>
21
+ <export_data translate="label" module="boxalinoexporter">
22
+ <label>Export Data Configuration</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>20</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <fields>
29
+ <language translate="label">
30
+ <label>Language</label>
31
+ <frontend_type>text</frontend_type>
32
+ <comment>Set language of your store view
33
+ <![CDATA[<br />Available: en, fr, de, it, es, zh, cz, ru]]></comment>
34
+ <sort_order>1</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </language>
39
+ <additional_attributes translate="label">
40
+ <label>Additional Attributes</label>
41
+ <comment>Write here comma-separated names of attributes which you want to export</comment>
42
+ <frontend_type>text</frontend_type>
43
+ <sort_order>10</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>0</show_in_store>
47
+ </additional_attributes>
48
+ <maximum_population translate="label">
49
+ <label>Maximum amount of product to export</label>
50
+ <comment>0=all</comment>
51
+ <frontend_type>text</frontend_type>
52
+ <sort_order>20</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>0</show_in_store>
56
+ </maximum_population>
57
+ <export_categories translate="label">
58
+ <label>Export Categories</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_yesno</source_model>
61
+ <sort_order>30</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>0</show_in_store>
65
+ </export_categories>
66
+ <export_tags translate="label">
67
+ <label>Export Tags</label>
68
+ <frontend_type>select</frontend_type>
69
+ <source_model>adminhtml/system_config_source_yesno</source_model>
70
+ <sort_order>40</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>0</show_in_store>
74
+ </export_tags>
75
+ <export_customers translate="label">
76
+ <label>Export Customers</label>
77
+ <frontend_type>select</frontend_type>
78
+ <source_model>adminhtml/system_config_source_yesno</source_model>
79
+ <sort_order>50</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>0</show_in_store>
83
+ </export_customers>
84
+ <export_transactions translate="label">
85
+ <label>Export Transactions</label>
86
+ <frontend_type>select</frontend_type>
87
+ <source_model>adminhtml/system_config_source_yesno</source_model>
88
+ <sort_order>60</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>0</show_in_store>
92
+ </export_transactions>
93
+ <export_chunk translate="label">
94
+ <label>Chunk size</label>
95
+ <frontend_type>text</frontend_type>
96
+ <sort_order>70</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>0</show_in_store>
100
+ </export_chunk>
101
+ </fields>
102
+ </export_data>
103
+ </groups>
104
+ </boxalinoexporter>
105
+ </sections>
106
+ </config>
app/design/frontend/base/default/layout/boxalino.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="0.1.0">
4
+ <default>
5
+ <reference name="head">
6
+ <action method="addItem"><type>skin_css</type><name>css/boxalinoCemSearch.css</name></action>
7
+ <action method="addItem"><type>skin_js</type><name>js/boxalinoAutocomplete.js</name></action>
8
+ <action method="addItem" ifconfig="Boxalino_General/jquery/jquery_file"><type>skin_js</type><name>js/jquery-1.10.2.min.js</name></action>
9
+ <action method="addItem" ifconfig="Boxalino_General/jquery/noconflict_file"><type>skin_js</type><name>js/jquery-noConflict.js</name></action>
10
+ <!--<action method="addItem"><type>skin_js</type><name>js/ba.js</name></action>-->
11
+
12
+ <block type="boxalino/head" name="boxalino_head" as="boxalino_head" template="boxalino/head.phtml"/>
13
+ </reference>
14
+ <reference name="top.search">
15
+ <action method="setTemplate"><template>boxalino/catalogsearch/form.mini.phtml</template></action>
16
+ </reference>
17
+ </default>
18
+ </layout>
app/design/frontend/base/default/template/boxalino/catalogsearch/form.mini.phtml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $catalogSearchHelper Mage_Catalogsearch_Helper_Data */
3
+ $catalogSearchHelper = $this->helper('catalogsearch');
4
+ ?>
5
+ <form id="search_mini_form" action="<?php echo $catalogSearchHelper->getResultUrl() ?>" method="get">
6
+ <div class="input-box">
7
+ <label for="search"><?php echo $this->__('Search:') ?></label>
8
+ <input
9
+ id="search"
10
+ type="search"
11
+ name="<?php echo $catalogSearchHelper->getQueryParamName() ?>"
12
+ value="<?php echo $catalogSearchHelper->getEscapedQueryText() ?>"
13
+ class="input-text required-entry"
14
+ maxlength="<?php echo $catalogSearchHelper->getMaxQueryLength();?>"
15
+ placeholder="<?php echo $this->__('Search entire store here...') ?>" />
16
+ <button type="submit" title="<?php echo $this->__('Search') ?>" class="button search-button">
17
+ <span>
18
+ <span><?php echo $this->__('Search') ?>
19
+ </span>
20
+ </span>
21
+ </button>
22
+ </div>
23
+
24
+ <div id="search_autocomplete" class="search-autocomplete"></div>
25
+ <script type="text/javascript">
26
+ //<![CDATA[
27
+ var searchForm = new Varien.searchForm('search_mini_form', 'search', '');
28
+ searchForm.initAutocomplete('<?php echo $catalogSearchHelper->getSuggestUrl() ?>', 'search_autocomplete');
29
+ //]]>
30
+ </script>
31
+ </form>
app/design/frontend/base/default/template/boxalino/head.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ $this->printScripts();
3
+ ?>
4
+
app/etc/modules/Boxalino_CemSearch.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Boxalino_CemSearch>
6
+ <active>true</active>
7
+ <codePool>local</codePool>
8
+ </Boxalino_CemSearch>
9
+ </modules>
10
+ </config>
app/etc/modules/Boxalino_Exporter.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Boxalino_Exporter>
4
+ <active>true</active>
5
+ <codePool>local</codePool>
6
+ </Boxalino_Exporter>
7
+ </modules>
8
+ </config>
package.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>boxalino_plugin</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.boxalino.com">Custom License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension connects your magento shop to the boxalino personalisation and testing engine. </summary>
10
+ <description>This extension connects your magento shop to the boxalino engine. &#xD;
11
+ &#xD;
12
+ Boxalino is the intelligent engine for realtime personalization with modules for Landingpages, Search, Recommendations, E-Mail Personalisation and Apps.&#xD;
13
+ &#xD;
14
+ Boxalino increases the online success of e-commerce companies on the mobile and the web by providing a highly engaging and personalized experience to all their customers.&#xD;
15
+ &#xD;
16
+ Boxalino is the best solution for Conversion Optimization on the market that integrates Testing, AI and Reporting in a way that is really usable for E-Commerce Teams.&#xD;
17
+ &#xD;
18
+ Check out www.boxalino.com for details or give us a shout at sales@boxalino.com.</description>
19
+ <notes>Minor changes, thanks everyone for the feedback.</notes>
20
+ <authors><author><name>Boxalino</name><user>Boxalino</user><email>support@boxalino.com</email></author></authors>
21
+ <date>2014-10-22</date>
22
+ <time>14:50:14</time>
23
+ <contents><target name="magelocal"><dir name="Boxalino"><dir name="CemSearch"><dir name="Block"><file name="Abstract.php" hash="45253ec10623b07c67cd623c626ad5f4"/><file name="Autocomplete.php" hash="aeaac0c28363bd9202c9daa620cab986"/><dir name="Cart"><file name="Crosssell.php" hash="fabc21793a718693a3d5a2db345dd638"/></dir><file name="Head.php" hash="5bbb03b8b0e8371559f4de05942183e3"/><dir name="Product"><dir name="List"><file name="Related.php" hash="fbef1af7977e15dd7e7e8063fdca5f49"/><file name="Upsell.php" hash="ebc3d467479811012e155371b97a69e3"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="1c7101bfe4cbc861c6490013539cd5de"/><dir name="P13n"><file name="Adapter.php" hash="5b011b673b67d90e99bc0d2213363022"/><file name="Client.php" hash="a4d0dd78a9c35b4d0ba1c32e1cff3231"/><file name="Config.php" hash="82597fa7e5fc6695137ad2f96267378a"/><file name="Recommendation.php" hash="cf23dac423edc4a46454546f6fad4534"/><file name="Sort.php" hash="83ab4da66d6e8122f4c28a9da3576d19"/></dir></dir><dir name="Lib"><file name="AbstractThrift.php" hash="d6c88b8524dbd810d51ca9b568ca64ee"/><file name="P13nService.php" hash="5e3f956a5cd75bc64e53df92f02597eb"/><file name="Types.php" hash="a6b956aff5a57a95042234bfb88f7556"/><dir name="vendor"><dir name="Thrift"><dir name="Base"><file name="TBase.php" hash="b383bf43ac76a57e3b1168cfacffbf22"/></dir><dir name="ClassLoader"><file name="ThriftClassLoader.php" hash="13159566c8b2dcc5b260ef9a0844167e"/></dir><dir name="Exception"><file name="TApplicationException.php" hash="1ee65cc5fb3dc82550a85cc18a31850c"/><file name="TException.php" hash="756e6a847c9e6bd1560c24b9a7373d2c"/><file name="TProtocolException.php" hash="148ebd5d8eba2587cd6e039cf70e04ab"/><file name="TTransportException.php" hash="aca39eea001fcbfd452db9ca7d5c218c"/></dir><dir name="Factory"><file name="TBinaryProtocolFactory.php" hash="bcd6e0555d6e2670a3bc7dd39ff3dbaf"/><file name="TCompactProtocolFactory.php" hash="0118b6363e09080548de3c6daf153290"/><file name="TJSONProtocolFactory.php" hash="28af1d10b4133df7f8ad8022ca39d703"/><file name="TProtocolFactory.php" hash="300bf2d805fa4a227cc3dc2b6ed0200c"/><file name="TStringFuncFactory.php" hash="242f32ade732f9c0d9b62a81b6901cd4"/><file name="TTransportFactory.php" hash="8347271458aea0453e774170a5b3e9fd"/></dir><file name="HttpP13n.php" hash="d066d652e7b24e593b389c4374e256aa"/><dir name="Protocol"><dir name="JSON"><file name="BaseContext.php" hash="ed1d83fba59a1d04c07416094ece8ee1"/><file name="ListContext.php" hash="9c8a970f54c30be1299c2d38da60ed56"/><file name="LookaheadReader.php" hash="315a96446f0f530ed1b0b1350b37f58d"/><file name="PairContext.php" hash="3fa06b3f7c9698642aefe00cd322f68b"/></dir><file name="TBinaryProtocol.php" hash="933d2be5503504cddd544992a4af0ee3"/><file name="TBinaryProtocolAccelerated.php" hash="444ba8026d73b83fbcf303d9a550cb70"/><file name="TCompactProtocol.php" hash="6e68904415f43e7575b00e6e93448faf"/><file name="TJSONProtocol.php" hash="fac76e10fbc711cbfbcf6bdbc0b60191"/><file name="TProtocol.php" hash="d9c9a8105ad160bf0b87e8053d4b9d7c"/></dir><dir name="Serializer"><file name="TBinarySerializer.php" hash="e1fef75686b1fbadc28242b7f3697397"/></dir><dir name="Server"><file name="TForkingServer.php" hash="6e319d0d7f45350a03e387fc2f22473d"/><file name="TServer.php" hash="dc87f6a299fb4fb9ab76206f3b6bec72"/><file name="TServerSocket.php" hash="468fc875e7a5e4899e502e95f823455d"/><file name="TServerTransport.php" hash="ca2ab3e25a0760d37eb3538274dfaccb"/><file name="TSimpleServer.php" hash="38d5685001585a0d9f31b9d8c46656d2"/></dir><dir name="StringFunc"><file name="Core.php" hash="4493a096c73f5922316d95cc2c5fb687"/><file name="Mbstring.php" hash="b5ee27dd6bdceee0f2133df01c8d4fcd"/><file name="TStringFunc.php" hash="89fd7900f1b258391e4d4fdc924bc0f0"/></dir><dir name="Transport"><file name="P13nTHttpClient.php" hash="8223e00845b717bb55981649d9ce6616"/><file name="TBufferedTransport.php" hash="7ace771173641cf47b3b11ca0bfebcfa"/><file name="TFramedTransport.php" hash="c6fc032e990e4cf3507741ef1d5b83b2"/><file name="THttpClient.php" hash="b299d30eecc318d7dde4d012ebe8a512"/><file name="TMemoryBuffer.php" hash="7367faa512ec8d25489819ca2ed8848f"/><file name="TNullTransport.php" hash="82d683d7d76ef2938fad1c58878f45e5"/><file name="TPhpStream.php" hash="44769e5da4709a4b6c2025137e4898b3"/><file name="TSocket.php" hash="d689b1f877eda19f7caaa9cb46788f96"/><file name="TSocketPool.php" hash="73d86dbd017130fe2aa0778132b42b26"/><file name="TTransport.php" hash="9185e82d3a440d1db97c6983573bd1ab"/></dir><dir name="Type"><file name="TMessageType.php" hash="20a9fb9a1de1ffe03bfac3057c913101"/><file name="TType.php" hash="261cc40ce2573ebf414c0ec06a2ee093"/></dir></dir></dir></dir><dir name="Model"><file name="Advanced.php" hash="d9c87128bd8e25dd1e401e3e0a837d10"/><file name="Logger.php" hash="a222e0461ade14b41012d416d2a3a45c"/><file name="Observer.php" hash="55476eeb88a30b69a99f878e7abcb5fc"/><dir name="Resource"><dir name="Advanced"><file name="Collection.php" hash="db5c45e391512f25198195d25f1f09f7"/></dir><file name="Advanced.php" hash="9373a9e12a268ab37f1d111f8b77cd57"/><file name="Fulltext.php" hash="0b333b366e433d778891441c67b35f65"/></dir><file name="Session.php" hash="f5f6948355cfc10882dd7a4f80e2713f"/></dir><dir name="controllers"><file name="AdvancedController.php" hash="084f9b0a5cdf1594b95fbcad5250256b"/><file name="AjaxController.php" hash="8331416b6beee0fb635da991790b8f40"/><file name="IndexController.php" hash="0f9ba5d1ee9bf4d7f9d6868a502738cd"/><file name="ResultController.php" hash="e43539a5921da7db3364b8e70dac2bdc"/></dir><dir name="etc"><file name="adminhtml.xml" hash="13af90d012dc3871c9af59c804d3588f"/><file name="config.xml" hash="61fb6a31b4702c39beaaf32490cf791f"/><file name="system.xml" hash="b420dcb3910abbaa251a8b3b68285c00"/></dir></dir><dir name="Exporter"><dir name="Helper"><file name="Data.php" hash="e284068074518b3126a4ea720cc94f71"/></dir><dir name="Model"><file name="Delta.php" hash="664b8a733751dd7e85169f3c9d99322f"/><file name="Indexer.php" hash="d9c10401971e9544992fbf34594fb600"/><dir name="Mysql4"><dir name="Exporter"><file name="Delta.php" hash="298628009eb4bf5afca7d12cb28d2a79"/><file name="Indexer.php" hash="9cd98755bdd03146a9661ecdd3f62e76"/></dir><file name="Indexer.php" hash="ff84d7a1116d07bd42c5e899a77bfb2d"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="57e26697c6d9b55a58f6da88b5a8d822"/><file name="config.xml" hash="c46f60130d206e165fd3d84c2b1915a1"/><file name="system.xml" hash="0cc11c40a20d5e3102fa72e02c536e97"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="boxalino.xml" hash="03575b20bf1e91b9307fad66cdfdabf4"/></dir><dir name="template"><dir name="boxalino"><dir name="catalogsearch"><file name="form.mini.phtml" hash="19b7d2c8d3fbe8fb6f7481bcc5747eb5"/></dir><file name="head.phtml" hash="a7246e26d2e98cdac6a2d4664058b926"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Boxalino_CemSearch.xml" hash="94c2434b422de7dfaac195298310f56d"/><file name="Boxalino_Exporter.xml" hash="b50cc52bc40c36b25677b6ef60bbf376"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><file name="boxalinoAutocomplete.js" hash="ea1f943c034c0dcc79c3615e01531297"/><file name="jquery-1.10.2.min.js" hash="628072e7212db1e8cdacb22b21752cda"/><file name="jquery-noConflict.js" hash="6932bbddf488374a70b55fbb62052fd2"/></dir><dir name="css"><file name="boxalinoCemSearch.css" hash="799e9fb003952533360ac38bea3e7bc0"/></dir></dir></dir></dir></target></contents>
24
+ <compatible/>
25
+ <dependencies><required><php><min>5.3.0</min><max>5.5.0</max></php></required></dependencies>
26
+ </package>
skin/frontend/base/default/css/boxalinoCemSearch.css ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .search-autocomplete .autocomplete-suggestions {
2
+ border: 1px solid #999;
3
+ background: #FFFFFF;
4
+ cursor: default;
5
+ overflow: auto;
6
+ -webkit-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
7
+ -moz-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
8
+ box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
9
+ }
10
+
11
+ .search-autocomplete .autocomplete-suggestion {
12
+ padding: 0px 5px;
13
+ white-space: nowrap;
14
+ overflow: hidden;
15
+ }
16
+
17
+ .search-autocomplete .autocomplete-selected {
18
+ background: #F0F0F0;
19
+ }
20
+
21
+ .search-autocomplete .autocomplete-suggestions strong {
22
+ font-weight: normal;
23
+ color: #3399FF;
24
+ }
25
+
26
+ .search-autocomplete .product-autocomplete span{
27
+ display: block;
28
+ padding-left: 10px;
29
+ }
30
+
31
+ .search-autocomplete .product-autocomplete.hide{
32
+ display: none;
33
+ }
34
+
35
+ .search-autocomplete ul{
36
+ position: relative !important;
37
+ background: #ffffff;
38
+
39
+ }
40
+ .search-autocomplete ul li{
41
+ text-align: left;
42
+ }
43
+ .search-autocomplete ul li.selected{
44
+ background: #bbbbbb;
45
+ }
46
+ .search-autocomplete .amount{
47
+ float: right;
48
+ display: block;
49
+ padding: 0 10px;
50
+ }
51
+ .search-autocomplete ul:first-child{
52
+ border-bottom: none !important;
53
+ -webkit-border-bottom-right-radius: 0px !important;
54
+ -webkit-border-bottom-left-radius: 0px !important;
55
+ -moz-border-radius-bottomright: 0px !important;
56
+ -moz-border-radius-bottomleft: 0px !important;
57
+ border-bottom-right-radius: 0px !important;
58
+ border-bottom-left-radius: 0px !important;
59
+ }
60
+ .search-autocomplete ul:last-child{
61
+ top: -1px !important;
62
+ border-top: none !important;
63
+ -webkit-border-top-left-radius: 0px !important;
64
+ -webkit-border-top-right-radius: 0px !important;
65
+ -moz-border-radius-topleft: 0px !important;
66
+ -moz-border-radius-topright: 0px !important;
67
+ border-top-left-radius: 0px !important;
68
+ border-top-right-radius: 0px !important;
69
+ }
70
+
skin/frontend/base/default/js/boxalinoAutocomplete.js ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Autocompleter.Base.prototype.onKeyPress = function(event) {
2
+ if(this.active)
3
+ switch(event.keyCode) {
4
+ case Event.KEY_TAB:
5
+ case Event.KEY_RETURN:
6
+ this.selectEntry();
7
+ Event.stop(event);
8
+ case Event.KEY_ESC:
9
+ this.hide();
10
+ this.active = false;
11
+ Event.stop(event);
12
+ return;
13
+ case Event.KEY_LEFT:
14
+ case Event.KEY_RIGHT:
15
+ return;
16
+ case Event.KEY_UP:
17
+ this.markPrevious();
18
+ this.render(true);
19
+ Event.stop(event);
20
+ return;
21
+ case Event.KEY_DOWN:
22
+ this.markNext();
23
+ this.render(true);
24
+ Event.stop(event);
25
+ return;
26
+ }
27
+ else
28
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
29
+ (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
30
+
31
+ this.changed = true;
32
+ this.hasFocus = true;
33
+
34
+ if(this.observer) clearTimeout(this.observer);
35
+ this.observer =
36
+ setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
37
+ }
38
+
39
+ var originalAddClassMethod = Autocompleter.Base.prototype.render;
40
+ Autocompleter.Base.prototype.render = function(key){
41
+ var result = originalAddClassMethod.apply( this, arguments );
42
+ if(typeof key != 'undefined' && key == true){
43
+ element = jQuery('#search_autocomplete .selected');
44
+ word = element.data('word')
45
+
46
+ jQuery('#search_autocomplete .product-autocomplete').each(function(){
47
+ if(jQuery(this).data('word') == word){
48
+ jQuery(this).removeClass('hide')
49
+ jQuery(this).show();
50
+ }else{
51
+ jQuery(this).addClass('hide')
52
+ jQuery(this).hide();
53
+ }
54
+ })
55
+
56
+ }
57
+
58
+ return result;
59
+ }
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
skin/frontend/base/default/js/jquery-1.10.2.min.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ /*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
2
+ //@ sourceMappingURL=jquery-1.10.2.min.map
3
+ */
4
+ (function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(D,"ms-").replace(L,H)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:b&&!b.call("\ufeff\u00a0")?function(e){return null==e?"":b.call(e)}:function(e){return null==e?"":(e+"").replace(C,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(m)return m.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return d.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),x.isFunction(e)?(r=g.call(arguments,2),i=function(){return e.apply(n||this,r.concat(g.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):t},access:function(e,n,r,i,o,a,s){var l=0,u=e.length,c=null==r;if("object"===x.type(r)){o=!0;for(l in r)x.access(e,n,l,r[l],!0,a,s)}else if(i!==t&&(o=!0,x.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(x(e),n)})),n))for(;u>l;l++)n(e[l],r,s?i:i.call(e[l],l,n(e[l],r)));return o?e:c?n.call(e):u?n(e[0],r):a},now:function(){return(new Date).getTime()},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),x.ready.promise=function(t){if(!n)if(n=x.Deferred(),"complete"===a.readyState)setTimeout(x.ready);else if(a.addEventListener)a.addEventListener("DOMContentLoaded",q,!1),e.addEventListener("load",q,!1);else{a.attachEvent("onreadystatechange",q),e.attachEvent("onload",q);var r=!1;try{r=null==e.frameElement&&a.documentElement}catch(i){}r&&r.doScroll&&function o(){if(!x.isReady){try{r.doScroll("left")}catch(e){return setTimeout(o,50)}_(),x.ready()}}()}return n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){c["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=x(a),function(e,t){var n,r,i,o,a,s,l,u,c,p,f,d,h,g,m,y,v,b="sizzle"+-new Date,w=e.document,T=0,C=0,N=st(),k=st(),E=st(),S=!1,A=function(e,t){return e===t?(S=!0,0):0},j=typeof t,D=1<<31,L={}.hasOwnProperty,H=[],q=H.pop,_=H.push,M=H.push,O=H.slice,F=H.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},B="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",P="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=R.replace("w","w#"),$="\\["+P+"*("+R+")"+P+"*(?:([*^$|!~]?=)"+P+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+P+"*\\]",I=":("+R+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",z=RegExp("^"+P+"+|((?:^|[^\\\\])(?:\\\\.)*)"+P+"+$","g"),X=RegExp("^"+P+"*,"+P+"*"),U=RegExp("^"+P+"*([>+~]|"+P+")"+P+"*"),V=RegExp(P+"*[+~]"),Y=RegExp("="+P+"*([^\\]'\"]*)"+P+"*\\]","g"),J=RegExp(I),G=RegExp("^"+W+"$"),Q={ID:RegExp("^#("+R+")"),CLASS:RegExp("^\\.("+R+")"),TAG:RegExp("^("+R.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+I),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+P+"*(even|odd|(([+-]|)(\\d*)n|)"+P+"*(?:([+-]|)"+P+"*(\\d+)|))"+P+"*\\)|)","i"),bool:RegExp("^(?:"+B+")$","i"),needsContext:RegExp("^"+P+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+P+"*((?:-\\d)?\\d*)"+P+"*\\)|)(?=[^-]|$)","i")},K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,et=/^(?:input|select|textarea|button)$/i,tt=/^h\d$/i,nt=/'|\\/g,rt=RegExp("\\\\([\\da-f]{1,6}"+P+"?|("+P+")|.)","ig"),it=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(55296|r>>10,56320|1023&r)};try{M.apply(H=O.call(w.childNodes),w.childNodes),H[w.childNodes.length].nodeType}catch(ot){M={apply:H.length?function(e,t){_.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function at(e,t,n,i){var o,a,s,l,u,c,d,m,y,x;if((t?t.ownerDocument||t:w)!==f&&p(t),t=t||f,n=n||[],!e||"string"!=typeof e)return n;if(1!==(l=t.nodeType)&&9!==l)return[];if(h&&!i){if(o=Z.exec(e))if(s=o[1]){if(9===l){if(a=t.getElementById(s),!a||!a.parentNode)return n;if(a.id===s)return n.push(a),n}else if(t.ownerDocument&&(a=t.ownerDocument.getElementById(s))&&v(t,a)&&a.id===s)return n.push(a),n}else{if(o[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=o[3])&&r.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(r.qsa&&(!g||!g.test(e))){if(m=d=b,y=t,x=9===l&&e,1===l&&"object"!==t.nodeName.toLowerCase()){c=mt(e),(d=t.getAttribute("id"))?m=d.replace(nt,"\\$&"):t.setAttribute("id",m),m="[id='"+m+"'] ",u=c.length;while(u--)c[u]=m+yt(c[u]);y=V.test(e)&&t.parentNode||t,x=c.join(",")}if(x)try{return M.apply(n,y.querySelectorAll(x)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return kt(e.replace(z,"$1"),t,n,i)}function st(){var e=[];function t(n,r){return e.push(n+=" ")>o.cacheLength&&delete t[e.shift()],t[n]=r}return t}function lt(e){return e[b]=!0,e}function ut(e){var t=f.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ct(e,t){var n=e.split("|"),r=e.length;while(r--)o.attrHandle[n[r]]=t}function pt(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function ft(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function dt(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function ht(e){return lt(function(t){return t=+t,lt(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}s=at.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},r=at.support={},p=at.setDocument=function(e){var n=e?e.ownerDocument||e:w,i=n.defaultView;return n!==f&&9===n.nodeType&&n.documentElement?(f=n,d=n.documentElement,h=!s(n),i&&i.attachEvent&&i!==i.top&&i.attachEvent("onbeforeunload",function(){p()}),r.attributes=ut(function(e){return e.className="i",!e.getAttribute("className")}),r.getElementsByTagName=ut(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),r.getElementsByClassName=ut(function(e){return e.innerHTML="<div class='a'></div><div class='a i'></div>",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),r.getById=ut(function(e){return d.appendChild(e).id=b,!n.getElementsByName||!n.getElementsByName(b).length}),r.getById?(o.find.ID=function(e,t){if(typeof t.getElementById!==j&&h){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){return e.getAttribute("id")===t}}):(delete o.find.ID,o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),o.find.TAG=r.getElementsByTagName?function(e,n){return typeof n.getElementsByTagName!==j?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},o.find.CLASS=r.getElementsByClassName&&function(e,n){return typeof n.getElementsByClassName!==j&&h?n.getElementsByClassName(e):t},m=[],g=[],(r.qsa=K.test(n.querySelectorAll))&&(ut(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||g.push("\\["+P+"*(?:value|"+B+")"),e.querySelectorAll(":checked").length||g.push(":checked")}),ut(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&g.push("[*^$]="+P+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||g.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),g.push(",.*:")})),(r.matchesSelector=K.test(y=d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ut(function(e){r.disconnectedMatch=y.call(e,"div"),y.call(e,"[s!='']:x"),m.push("!=",I)}),g=g.length&&RegExp(g.join("|")),m=m.length&&RegExp(m.join("|")),v=K.test(d.contains)||d.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},A=d.compareDocumentPosition?function(e,t){if(e===t)return S=!0,0;var i=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t);return i?1&i||!r.sortDetached&&t.compareDocumentPosition(e)===i?e===n||v(w,e)?-1:t===n||v(w,t)?1:c?F.call(c,e)-F.call(c,t):0:4&i?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return S=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:c?F.call(c,e)-F.call(c,t):0;if(o===a)return pt(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?pt(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},n):f},at.matches=function(e,t){return at(e,null,null,t)},at.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&p(e),t=t.replace(Y,"='$1']"),!(!r.matchesSelector||!h||m&&m.test(t)||g&&g.test(t)))try{var n=y.call(e,t);if(n||r.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(i){}return at(t,f,null,[e]).length>0},at.contains=function(e,t){return(e.ownerDocument||e)!==f&&p(e),v(e,t)},at.attr=function(e,n){(e.ownerDocument||e)!==f&&p(e);var i=o.attrHandle[n.toLowerCase()],a=i&&L.call(o.attrHandle,n.toLowerCase())?i(e,n,!h):t;return a===t?r.attributes||!h?e.getAttribute(n):(a=e.getAttributeNode(n))&&a.specified?a.value:null:a},at.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},at.uniqueSort=function(e){var t,n=[],i=0,o=0;if(S=!r.detectDuplicates,c=!r.sortStable&&e.slice(0),e.sort(A),S){while(t=e[o++])t===e[o]&&(i=n.push(o));while(i--)e.splice(n[i],1)}return e},a=at.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=a(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=a(t);return n},o=at.selectors={cacheLength:50,createPseudo:lt,match:Q,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(rt,it),e[3]=(e[4]||e[5]||"").replace(rt,it),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||at.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&at.error(e[0]),e},PSEUDO:function(e){var n,r=!e[5]&&e[2];return Q.CHILD.test(e[0])?null:(e[3]&&e[4]!==t?e[2]=e[4]:r&&J.test(r)&&(n=mt(r,!0))&&(n=r.indexOf(")",r.length-n)-r.length)&&(e[0]=e[0].slice(0,n),e[2]=r.slice(0,n)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(rt,it).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=N[e+" "];return t||(t=RegExp("(^|"+P+")"+e+"("+P+"|$)"))&&N(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=at.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var u,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!l&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[b]||(m[b]={}),u=c[e]||[],d=u[0]===T&&u[1],f=u[0]===T&&u[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[T,d,f];break}}else if(v&&(u=(t[b]||(t[b]={}))[e])&&u[0]===T)f=u[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[b]||(p[b]={}))[e]=[T,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=o.pseudos[e]||o.setFilters[e.toLowerCase()]||at.error("unsupported pseudo: "+e);return r[b]?r(t):r.length>1?(n=[e,e,"",t],o.setFilters.hasOwnProperty(e.toLowerCase())?lt(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=F.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:lt(function(e){var t=[],n=[],r=l(e.replace(z,"$1"));return r[b]?lt(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:lt(function(e){return function(t){return at(e,t).length>0}}),contains:lt(function(e){return function(t){return(t.textContent||t.innerText||a(t)).indexOf(e)>-1}}),lang:lt(function(e){return G.test(e||"")||at.error("unsupported lang: "+e),e=e.replace(rt,it).toLowerCase(),function(t){var n;do if(n=h?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===d},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!o.pseudos.empty(e)},header:function(e){return tt.test(e.nodeName)},input:function(e){return et.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:ht(function(){return[0]}),last:ht(function(e,t){return[t-1]}),eq:ht(function(e,t,n){return[0>n?n+t:n]}),even:ht(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:ht(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:ht(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:ht(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}},o.pseudos.nth=o.pseudos.eq;for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})o.pseudos[n]=ft(n);for(n in{submit:!0,reset:!0})o.pseudos[n]=dt(n);function gt(){}gt.prototype=o.filters=o.pseudos,o.setFilters=new gt;function mt(e,t){var n,r,i,a,s,l,u,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,l=[],u=o.preFilter;while(s){(!n||(r=X.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),l.push(i=[])),n=!1,(r=U.exec(s))&&(n=r.shift(),i.push({value:n,type:r[0].replace(z," ")}),s=s.slice(n.length));for(a in o.filter)!(r=Q[a].exec(s))||u[a]&&!(r=u[a](r))||(n=r.shift(),i.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?at.error(e):k(e,l).slice(0)}function yt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function vt(e,t,n){var r=t.dir,o=n&&"parentNode"===r,a=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||o)return e(t,n,i)}:function(t,n,s){var l,u,c,p=T+" "+a;if(s){while(t=t[r])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[r])if(1===t.nodeType||o)if(c=t[b]||(t[b]={}),(u=c[r])&&u[0]===p){if((l=u[1])===!0||l===i)return l===!0}else if(u=c[r]=[p],u[1]=e(t,n,s)||i,u[1]===!0)return!0}}function bt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function xt(e,t,n,r,i){var o,a=[],s=0,l=e.length,u=null!=t;for(;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),u&&t.push(s));return a}function wt(e,t,n,r,i,o){return r&&!r[b]&&(r=wt(r)),i&&!i[b]&&(i=wt(i,o)),lt(function(o,a,s,l){var u,c,p,f=[],d=[],h=a.length,g=o||Nt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:xt(g,f,e,s,l),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,l),r){u=xt(y,d),r(u,[],s,l),c=u.length;while(c--)(p=u[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){u=[],c=y.length;while(c--)(p=y[c])&&u.push(m[c]=p);i(null,y=[],u,l)}c=y.length;while(c--)(p=y[c])&&(u=i?F.call(o,p):f[c])>-1&&(o[u]=!(a[u]=p))}}else y=xt(y===a?y.splice(h,y.length):y),i?i(null,a,y,l):M.apply(a,y)})}function Tt(e){var t,n,r,i=e.length,a=o.relative[e[0].type],s=a||o.relative[" "],l=a?1:0,c=vt(function(e){return e===t},s,!0),p=vt(function(e){return F.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==u)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;i>l;l++)if(n=o.relative[e[l].type])f=[vt(bt(f),n)];else{if(n=o.filter[e[l].type].apply(null,e[l].matches),n[b]){for(r=++l;i>r;r++)if(o.relative[e[r].type])break;return wt(l>1&&bt(f),l>1&&yt(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(z,"$1"),n,r>l&&Tt(e.slice(l,r)),i>r&&Tt(e=e.slice(r)),i>r&&yt(e))}f.push(n)}return bt(f)}function Ct(e,t){var n=0,r=t.length>0,a=e.length>0,s=function(s,l,c,p,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,C=u,N=s||a&&o.find.TAG("*",d&&l.parentNode||l),k=T+=null==C?1:Math.random()||.1;for(w&&(u=l!==f&&l,i=n);null!=(h=N[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,l,c)){p.push(h);break}w&&(T=k,i=++n)}r&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,r&&b!==v){g=0;while(m=t[g++])m(x,y,l,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=q.call(p));y=xt(y)}M.apply(p,y),w&&!s&&y.length>0&&v+t.length>1&&at.uniqueSort(p)}return w&&(T=k,u=C),x};return r?lt(s):s}l=at.compile=function(e,t){var n,r=[],i=[],o=E[e+" "];if(!o){t||(t=mt(e)),n=t.length;while(n--)o=Tt(t[n]),o[b]?r.push(o):i.push(o);o=E(e,Ct(i,r))}return o};function Nt(e,t,n){var r=0,i=t.length;for(;i>r;r++)at(e,t[r],n);return n}function kt(e,t,n,i){var a,s,u,c,p,f=mt(e);if(!i&&1===f.length){if(s=f[0]=f[0].slice(0),s.length>2&&"ID"===(u=s[0]).type&&r.getById&&9===t.nodeType&&h&&o.relative[s[1].type]){if(t=(o.find.ID(u.matches[0].replace(rt,it),t)||[])[0],!t)return n;e=e.slice(s.shift().value.length)}a=Q.needsContext.test(e)?0:s.length;while(a--){if(u=s[a],o.relative[c=u.type])break;if((p=o.find[c])&&(i=p(u.matches[0].replace(rt,it),V.test(s[0].type)&&t.parentNode||t))){if(s.splice(a,1),e=i.length&&yt(s),!e)return M.apply(n,i),n;break}}}return l(e,f)(i,t,!h,n,V.test(e)),n}r.sortStable=b.split("").sort(A).join("")===b,r.detectDuplicates=S,p(),r.sortDetached=ut(function(e){return 1&e.compareDocumentPosition(f.createElement("div"))}),ut(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||ct("type|href|height|width",function(e,n,r){return r?t:e.getAttribute(n,"type"===n.toLowerCase()?1:2)}),r.attributes&&ut(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||ct("value",function(e,n,r){return r||"input"!==e.nodeName.toLowerCase()?t:e.defaultValue}),ut(function(e){return null==e.getAttribute("disabled")})||ct(B,function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&i.specified?i.value:e[n]===!0?n.toLowerCase():null}),x.find=at,x.expr=at.selectors,x.expr[":"]=x.expr.pseudos,x.unique=at.uniqueSort,x.text=at.getText,x.isXMLDoc=at.isXML,x.contains=at.contains}(e);var O={};function F(e){var t=O[e]={};return x.each(e.match(T)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?O[e]||F(e):x.extend({},e);var n,r,i,o,a,s,l=[],u=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=l.length,n=!0;l&&o>a;a++)if(l[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,l&&(u?u.length&&c(u.shift()):r?l=[]:p.disable())},p={add:function(){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this},remove:function(){return l&&x.each(arguments,function(e,t){var r;while((r=x.inArray(t,l,r))>-1)l.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?x.inArray(e,l)>-1:!(!l||!l.length)},empty:function(){return l=[],o=0,this},disable:function(){return l=u=r=t,this},disabled:function(){return!l},lock:function(){return u=t,r||p.disable(),this},locked:function(){return!u},fireWith:function(e,t){return!l||i&&!u||(t=t||[],t=[e,t.slice?t.slice():t],n?u.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=g.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?g.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,l,u;if(r>1)for(s=Array(r),l=Array(r),u=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(a(t,u,n)).fail(o.reject).progress(a(t,l,s)):--i;return i||o.resolveWith(u,n),o.promise()}}),x.support=function(t){var n,r,o,s,l,u,c,p,f,d=a.createElement("div");if(d.setAttribute("className","t"),d.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=d.getElementsByTagName("*")||[],r=d.getElementsByTagName("a")[0],!r||!r.style||!n.length)return t;s=a.createElement("select"),u=s.appendChild(a.createElement("option")),o=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==d.className,t.leadingWhitespace=3===d.firstChild.nodeType,t.tbody=!d.getElementsByTagName("tbody").length,t.htmlSerialize=!!d.getElementsByTagName("link").length,t.style=/top/.test(r.getAttribute("style")),t.hrefNormalized="/a"===r.getAttribute("href"),t.opacity=/^0.5/.test(r.style.opacity),t.cssFloat=!!r.style.cssFloat,t.checkOn=!!o.value,t.optSelected=u.selected,t.enctype=!!a.createElement("form").enctype,t.html5Clone="<:nav></:nav>"!==a.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,o.checked=!0,t.noCloneChecked=o.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!u.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}o=a.createElement("input"),o.setAttribute("value",""),t.input=""===o.getAttribute("value"),o.value="t",o.setAttribute("type","radio"),t.radioValue="t"===o.value,o.setAttribute("checked","t"),o.setAttribute("name","t"),l=a.createDocumentFragment(),l.appendChild(o),t.appendChecked=o.checked,t.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip;for(f in x(t))break;return t.ownLast="0"!==f,x(function(){var n,r,o,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",l=a.getElementsByTagName("body")[0];l&&(n=a.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",l.appendChild(n).appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",o=d.getElementsByTagName("td"),o[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===o[0].offsetHeight,o[0].style.display="",o[1].style.display="none",t.reliableHiddenOffsets=p&&0===o[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",x.swap(l,null!=l.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===d.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(a.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="<div></div>",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(l.style.zoom=1)),l.removeChild(n),n=d=o=r=null)}),n=s=l=u=r=o=null,t
5
+ }({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var t,r=0,o=x(this),a=e.match(T)||[];while(t=a[r++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else(n===i||"boolean"===n)&&(this.className&&x._data(this,"__className__",this.className),this.className=this.className||e===!1?"":x._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(U," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=x.isFunction(e),this.each(function(n){var o;1===this.nodeType&&(o=i?e.call(this,n,x(this).val()):e,null==o?o="":"number"==typeof o?o+="":x.isArray(o)&&(o=x.map(o,function(e){return null==e?"":e+""})),r=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=x.valHooks[o.type]||x.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(V,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=x.find.attr(e,"value");return null!=t?t:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,l=0>i?s:o?i:0;for(;s>l;l++)if(n=r[l],!(!n.selected&&l!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),a=i.length;while(a--)r=i[a],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,n,r){var o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===i?x.prop(e,n,r):(1===s&&x.isXMLDoc(e)||(n=n.toLowerCase(),o=x.attrHooks[n]||(x.expr.match.bool.test(n)?X:z)),r===t?o&&"get"in o&&null!==(a=o.get(e,n))?a:(a=x.find.attr(e,n),null==a?t:a):null!==r?o&&"set"in o&&(a=o.set(e,r,n))!==t?a:(e.setAttribute(n,r+""),r):(x.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(T);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.bool.test(n)?K&&Q||!G.test(n)?e[r]=!1:e[x.camelCase("default-"+n)]=e[r]=!1:x.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!x.isXMLDoc(e),a&&(n=x.propFix[n]||n,o=x.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var t=x.find.attr(e,"tabindex");return t?parseInt(t,10):Y.test(e.nodeName)||J.test(e.nodeName)&&e.href?0:-1}}}}),X={set:function(e,t,n){return t===!1?x.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&x.propFix[n]||n,n):e[x.camelCase("default-"+n)]=e[n]=!0,n}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,n){var r=x.expr.attrHandle[n]||x.find.attr;x.expr.attrHandle[n]=K&&Q||!G.test(n)?function(e,n,i){var o=x.expr.attrHandle[n],a=i?t:(x.expr.attrHandle[n]=t)!=r(e,n,i)?n.toLowerCase():null;return x.expr.attrHandle[n]=o,a}:function(e,n,r){return r?t:e[x.camelCase("default-"+n)]?n.toLowerCase():null}}),K&&Q||(x.attrHooks.value={set:function(e,n,r){return x.nodeName(e,"input")?(e.defaultValue=n,t):z&&z.set(e,n,r)}}),Q||(z={set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},x.expr.attrHandle.id=x.expr.attrHandle.name=x.expr.attrHandle.coords=function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&""!==i.value?i.value:null},x.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&r.specified?r.value:t},set:z.set},x.attrHooks.contenteditable={set:function(e,t,n){z.set(e,""===t?!1:t,n)}},x.each(["width","height"],function(e,n){x.attrHooks[n]={set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}}})),x.support.hrefNormalized||x.each(["href","src"],function(e,t){x.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),x.support.style||(x.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.support.enctype||(x.propFix.enctype="encoding"),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,n){return x.isArray(n)?e.checked=x.inArray(x(e).val(),n)>=0:t}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}function at(){try{return a.activeElement}catch(e){}}x.event={global:{},add:function(e,n,r,o,a){var s,l,u,c,p,f,d,h,g,m,y,v=x._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=x.guid++),(l=v.events)||(l=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof x===i||e&&x.event.triggered===e.type?t:x.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(T)||[""],u=n.length;while(u--)s=rt.exec(n[u])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),g&&(p=x.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=x.event.special[g]||{},d=x.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&x.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=l[g])||(h=l[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),x.event.global[g]=!0);e=null}},remove:function(e,t,n,r,i){var o,a,s,l,u,c,p,f,d,h,g,m=x.hasData(e)&&x._data(e);if(m&&(c=m.events)){t=(t||"").match(T)||[""],u=t.length;while(u--)if(s=rt.exec(t[u])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=x.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));l&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||x.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)x.event.remove(e,d+t[u],n,r,!0);x.isEmptyObject(c)&&(delete m.handle,x._removeData(e,"events"))}},trigger:function(n,r,i,o){var s,l,u,c,p,f,d,h=[i||a],g=v.call(n,"type")?n.type:n,m=v.call(n,"namespace")?n.namespace.split("."):[];if(u=f=i=i||a,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+x.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),l=0>g.indexOf(":")&&"on"+g,n=n[x.expando]?n:new x.Event(g,"object"==typeof n&&n),n.isTrigger=o?2:3,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:x.makeArray(r,[n]),p=x.event.special[g]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!x.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(u=u.parentNode);u;u=u.parentNode)h.push(u),f=u;f===(i.ownerDocument||a)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((u=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(x._data(u,"events")||{})[n.type]&&x._data(u,"handle"),s&&s.apply(u,r),s=l&&u[l],s&&x.acceptData(u)&&s.apply&&s.apply(u,r)===!1&&n.preventDefault();if(n.type=g,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(h.pop(),r)===!1)&&x.acceptData(i)&&l&&i[g]&&!x.isWindow(i)){f=i[l],f&&(i[l]=null),x.event.triggered=g;try{i[g]()}catch(y){}x.event.triggered=t,f&&(i[l]=f)}return n.result}},dispatch:function(e){e=x.event.fix(e);var n,r,i,o,a,s=[],l=g.call(arguments),u=(x._data(this,"events")||{})[e.type]||[],c=x.event.special[e.type]||{};if(l[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((x.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,l),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],l=n.delegateCount,u=e.target;if(l&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(o=[],a=0;l>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?x(r,this).index(u)>=0:x.find(r,this,null,[u]).length),o[r]&&o.push(i);o.length&&s.push({elem:u,handlers:o})}return n.length>l&&s.push({elem:this,handlers:n.slice(l)}),s},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return e.target||(e.target=o.srcElement||a),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,o):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,o,s=n.button,l=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||a,o=i.documentElement,r=i.body,e.pageX=n.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&l&&(e.relatedTarget=l===e.target?n.toElement:l),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==at()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===at()&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},click:{trigger:function(){return x.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=a.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},x.Event=function(e,n){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&x.extend(this,n),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,t):new x.Event(e,n)},x.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.submitBubbles||(x.event.special.submit={setup:function(){return x.nodeName(this,"form")?!1:(x.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=x.nodeName(n,"input")||x.nodeName(n,"button")?n.form:t;r&&!x._data(r,"submitBubbles")&&(x.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),x._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&x.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return x.nodeName(this,"form")?!1:(x.event.remove(this,"._submit"),t)}}),x.support.changeBubbles||(x.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(x.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),x.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),x.event.simulate("change",this,e,!0)})),!1):(x.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!x._data(t,"changeBubbles")&&(x.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||x.event.simulate("change",this.parentNode,e,!0)}),x._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return x.event.remove(this,"._change"),!Z.test(this.nodeName)}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&a.addEventListener(e,r,!0)},teardown:function(){0===--n&&a.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return x().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=x.guid++)),this.each(function(){x.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,x(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){x.event.remove(this,e,r,n)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?x.event.trigger(e,n,r,!0):t}});var st=/^.[^:#\[\.,]*$/,lt=/^(?:parents|prev(?:Until|All))/,ut=x.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(t=0;i>t;t++)if(x.contains(r[t],this))return!0}));for(t=0;i>t;t++)x.find(e,r[t],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},has:function(e){var t,n=x(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(x.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e||[],!0))},filter:function(e){return this.pushStack(ft(this,e||[],!1))},is:function(e){return!!ft(this,"string"==typeof e&&ut.test(e)?x(e):e||[],!1).length},closest:function(e,t){var n,r=0,i=this.length,o=[],a=ut.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(a?a.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?x.inArray(this[0],x(e)):x.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(ct[e]||(i=x.unique(i)),lt.test(e)&&(i=i.reverse())),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!x(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(st.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return x.inArray(e,t)>=0!==n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/<tbody/i,wt=/<|&#?\w+;/,Tt=/<(?:script|style|link)/i,Ct=/^(?:checkbox|radio)$/i,Nt=/checked\s*(?:[^=]|=\s*.checked.)/i,kt=/^$|\/(?:java|ecma)script/i,Et=/^true\/(.*)/,St=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,At={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:x.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},jt=dt(a),Dt=jt.appendChild(a.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===t?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||a).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(Ft(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&_t(Ft(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&x.cleanData(Ft(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&x.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!x.support.htmlSerialize&&mt.test(e)||!x.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1></$2>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(x.cleanData(Ft(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(r&&r.parentNode!==i&&(r=this.nextSibling),x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=d.apply([],e);var r,i,o,a,s,l,u=0,c=this.length,p=this,f=c-1,h=e[0],g=x.isFunction(h);if(g||!(1>=c||"string"!=typeof h||x.support.checkClone)&&Nt.test(h))return this.each(function(r){var i=p.eq(r);g&&(e[0]=h.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(l=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),r=l.firstChild,1===l.childNodes.length&&(l=r),r)){for(a=x.map(Ft(l,"script"),Ht),o=a.length;c>u;u++)i=l,u!==f&&(i=x.clone(i,!0,!0),o&&x.merge(a,Ft(i,"script"))),t.call(this[u],i,u);if(o)for(s=a[a.length-1].ownerDocument,x.map(a,qt),u=0;o>u;u++)i=a[u],kt.test(i.type||"")&&!x._data(i,"globalEval")&&x.contains(s,i)&&(i.src?x._evalUrl(i.src):x.globalEval((i.text||i.textContent||i.innerHTML||"").replace(St,"")));l=r=null}return this}});function Lt(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function Ht(e){return e.type=(null!==x.find.attr(e,"type"))+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function _t(e,t){var n,r=0;for(;null!=(n=e[r]);r++)x._data(n,"globalEval",!t||x._data(t[r],"globalEval"))}function Mt(e,t){if(1===t.nodeType&&x.hasData(e)){var n,r,i,o=x._data(e),a=x._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)x.event.add(t,n,s[n][r])}a.data&&(a.data=x.extend({},a.data))}}function Ot(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!x.support.noCloneEvent&&t[x.expando]){i=x._data(t);for(r in i.events)x.removeEvent(t,r,i.handle);t.removeAttribute(x.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),x.support.html5Clone&&e.innerHTML&&!x.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Ct.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=0,i=[],o=x(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),x(o[r])[t](n),h.apply(i,n.get());return this.pushStack(i)}});function Ft(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||x.nodeName(o,n)?s.push(o):x.merge(s,Ft(o,n));return n===t||n&&x.nodeName(e,n)?x.merge([e],s):s}function Bt(e){Ct.test(e.type)&&(e.defaultChecked=e.checked)}x.extend({clone:function(e,t,n){var r,i,o,a,s,l=x.contains(e.ownerDocument,e);if(x.support.html5Clone||x.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(x.support.noCloneEvent&&x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(r=Ft(o),s=Ft(e),a=0;null!=(i=s[a]);++a)r[a]&&Ot(i,r[a]);if(t)if(n)for(s=s||Ft(e),r=r||Ft(o),a=0;null!=(i=s[a]);a++)Mt(i,r[a]);else Mt(e,o);return r=Ft(o,"script"),r.length>0&&_t(r,!l&&Ft(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,l,u,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===x.type(o))x.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),l=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[l]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1></$2>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!x.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!x.support.tbody){o="table"!==l||xt.test(o)?"<table>"!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)x.nodeName(u=o.childNodes[i],"tbody")&&!u.childNodes.length&&o.removeChild(u)}x.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),x.support.appendChecked||x.grep(Ft(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===x.inArray(o,r))&&(a=x.contains(o.ownerDocument,o),s=Ft(f.appendChild(o),"script"),a&&_t(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,l=x.expando,u=x.cache,c=x.support.deleteExpando,f=x.event.special;for(;null!=(n=e[s]);s++)if((t||x.acceptData(n))&&(o=n[l],a=o&&u[o])){if(a.events)for(r in a.events)f[r]?x.event.remove(n,r):x.removeEvent(n,r,a.handle);
6
+ u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){nn(this)?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function ln(e){var t=a,n=Gt[e];return n||(n=un(e,t),"none"!==n&&n||(Pt=(Pt||x("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(t.documentElement),t=(Pt[0].contentWindow||Pt[0].contentDocument).document,t.write("<!doctype html><html><body>"),t.close(),n=un(e,t),Pt.detach()),Gt[e]=n),n}function un(e,t){var n=x(t.createElement(e)).appendTo(t.body),r=x.css(n[0],"display");return n.remove(),r}x.each(["height","width"],function(e,n){x.cssHooks[n]={get:function(e,r,i){return r?0===e.offsetWidth&&Xt.test(x.css(e,"display"))?x.swap(e,Qt,function(){return sn(e,n,i)}):sn(e,n,i):t},set:function(e,t,r){var i=r&&Rt(e);return on(e,t,r?an(e,n,r,x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,i),i):0)}}}),x.support.opacity||(x.cssHooks.opacity={get:function(e,t){return It.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=x.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===x.trim(o.replace($t,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=$t.test(o)?o.replace($t,i):o+" "+i)}}),x(function(){x.support.reliableMarginRight||(x.cssHooks.marginRight={get:function(e,n){return n?x.swap(e,{display:"inline-block"},Wt,[e,"marginRight"]):t}}),!x.support.pixelPosition&&x.fn.position&&x.each(["top","left"],function(e,n){x.cssHooks[n]={get:function(e,r){return r?(r=Wt(e,n),Yt.test(r)?x(e).position()[n]+"px":r):t}}})}),x.expr&&x.expr.filters&&(x.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight||!x.support.reliableHiddenOffsets&&"none"===(e.style&&e.style.display||x.css(e,"display"))},x.expr.filters.visible=function(e){return!x.expr.filters.hidden(e)}),x.each({margin:"",padding:"",border:"Width"},function(e,t){x.cssHooks[e+t]={expand:function(n){var r=0,i={},o="string"==typeof n?n.split(" "):[n];for(;4>r;r++)i[e+Zt[r]+t]=o[r]||o[r-2]||o[0];return i}},Ut.test(e)||(x.cssHooks[e+t].set=on)});var cn=/%20/g,pn=/\[\]$/,fn=/\r?\n/g,dn=/^(?:submit|button|image|reset|file)$/i,hn=/^(?:input|select|textarea|keygen)/i;x.fn.extend({serialize:function(){return x.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=x.prop(this,"elements");return e?x.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!x(this).is(":disabled")&&hn.test(this.nodeName)&&!dn.test(e)&&(this.checked||!Ct.test(e))}).map(function(e,t){var n=x(this).val();return null==n?null:x.isArray(n)?x.map(n,function(e){return{name:t.name,value:e.replace(fn,"\r\n")}}):{name:t.name,value:n.replace(fn,"\r\n")}}).get()}}),x.param=function(e,n){var r,i=[],o=function(e,t){t=x.isFunction(t)?t():null==t?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(n===t&&(n=x.ajaxSettings&&x.ajaxSettings.traditional),x.isArray(e)||e.jquery&&!x.isPlainObject(e))x.each(e,function(){o(this.name,this.value)});else for(r in e)gn(r,e[r],n,o);return i.join("&").replace(cn,"+")};function gn(e,t,n,r){var i;if(x.isArray(t))x.each(t,function(t,i){n||pn.test(e)?r(e,i):gn(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==x.type(t))r(e,t);else for(i in t)gn(e+"["+i+"]",t[i],n,r)}x.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 contextmenu".split(" "),function(e,t){x.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),x.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}});var mn,yn,vn=x.now(),bn=/\?/,xn=/#.*$/,wn=/([?&])_=[^&]*/,Tn=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Cn=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Nn=/^(?:GET|HEAD)$/,kn=/^\/\//,En=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Sn=x.fn.load,An={},jn={},Dn="*/".concat("*");try{yn=o.href}catch(Ln){yn=a.createElement("a"),yn.href="",yn=yn.href}mn=En.exec(yn.toLowerCase())||[];function Hn(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(T)||[];if(x.isFunction(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function qn(e,n,r,i){var o={},a=e===jn;function s(l){var u;return o[l]=!0,x.each(e[l]||[],function(e,l){var c=l(n,r,i);return"string"!=typeof c||a||o[c]?a?!(u=c):t:(n.dataTypes.unshift(c),s(c),!1)}),u}return s(n.dataTypes[0])||!o["*"]&&s("*")}function _n(e,n){var r,i,o=x.ajaxSettings.flatOptions||{};for(i in n)n[i]!==t&&((o[i]?e:r||(r={}))[i]=n[i]);return r&&x.extend(!0,e,r),e}x.fn.load=function(e,n,r){if("string"!=typeof e&&Sn)return Sn.apply(this,arguments);var i,o,a,s=this,l=e.indexOf(" ");return l>=0&&(i=e.slice(l,e.length),e=e.slice(0,l)),x.isFunction(n)?(r=n,n=t):n&&"object"==typeof n&&(a="POST"),s.length>0&&x.ajax({url:e,type:a,dataType:"html",data:n}).done(function(e){o=arguments,s.html(i?x("<div>").append(x.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Cn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?_n(_n(e,x.ajaxSettings),t):_n(x.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,l,u,c,p=x.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),g=x.Callbacks("once memory"),m=p.statusCode||{},y={},v={},b=0,w="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return b||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this},abort:function(e){var t=e||w;return u&&u.abort(t),k(0,t),this}};if(h.promise(C).complete=g.add,C.success=C.done,C.error=C.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=x.trim(p.dataType||"*").toLowerCase().match(T)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(mn[3]||("http:"===mn[1]?"80":"443")))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=x.param(p.data,p.traditional)),qn(An,p,n,C),2===b)return C;l=p.global,l&&0===x.active++&&x.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Nn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(x.lastModified[o]&&C.setRequestHeader("If-Modified-Since",x.lastModified[o]),x.etag[o]&&C.setRequestHeader("If-None-Match",x.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)C.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,C,p)===!1||2===b))return C.abort();w="abort";for(i in{success:1,error:1,complete:1})C[i](p[i]);if(u=qn(jn,p,n,C)){C.readyState=1,l&&d.trigger("ajaxSend",[C,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){C.abort("timeout")},p.timeout));try{b=1,u.send(y,k)}catch(N){if(!(2>b))throw N;k(-1,N)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,N=n;2!==b&&(b=2,s&&clearTimeout(s),u=t,a=i||"",C.readyState=e>0?4:0,c=e>=200&&300>e||304===e,r&&(w=Mn(p,C,r)),w=On(p,w,C,c),c?(p.ifModified&&(T=C.getResponseHeader("Last-Modified"),T&&(x.lastModified[o]=T),T=C.getResponseHeader("etag"),T&&(x.etag[o]=T)),204===e||"HEAD"===p.type?N="nocontent":304===e?N="notmodified":(N=w.state,y=w.data,v=w.error,c=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),C.status=e,C.statusText=(n||N)+"",c?h.resolveWith(f,[y,N,C]):h.rejectWith(f,[C,N,v]),C.statusCode(m),m=t,l&&d.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?y:v]),g.fireWith(f,[C,N]),l&&(d.trigger("ajaxComplete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,n){return x.get(e,t,n,"script")}}),x.each(["get","post"],function(e,n){x[n]=function(e,r,i,o){return x.isFunction(r)&&(o=o||i,i=r,r=t),x.ajax({url:e,type:n,dataType:o,data:r,success:i})}});function Mn(e,n,r){var i,o,a,s,l=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in l)if(l[s]&&l[s].test(o)){u.unshift(s);break}if(u[0]in r)a=u[0];else{for(s in r){if(!u[0]||e.converters[s+" "+u[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==u[0]&&u.unshift(a),r[a]):t}function On(e,t,n,r){var i,o,a,s,l,u={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)u[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=u[l+" "+o]||u["* "+o],!a)for(i in u)if(s=i.split(" "),s[1]===o&&(a=u[l+" "+s[0]]||u["* "+s[0]])){a===!0?a=u[i]:u[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(p){return{state:"parsererror",error:a?p:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),x.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=a.head||x("head")[0]||a.documentElement;return{send:function(t,i){n=a.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Fn=[],Bn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Fn.pop()||x.expando+"_"+vn++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,l=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return l||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=x.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,l?n[l]=n[l].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||x.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Fn.push(o)),s&&x.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}x.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=x.ajaxSettings.xhr(),x.support.cors=!!Rn&&"withCredentials"in Rn,Rn=x.support.ajax=!!Rn,Rn&&x.ajaxTransport(function(n){if(!n.crossDomain||x.support.cors){var r;return{send:function(i,o){var a,s,l=n.xhr();if(n.username?l.open(n.type,n.url,n.async,n.username,n.password):l.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)l[s]=n.xhrFields[s];n.mimeType&&l.overrideMimeType&&l.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)l.setRequestHeader(s,i[s])}catch(u){}l.send(n.hasContent&&n.data||null),r=function(e,i){var s,u,c,p;try{if(r&&(i||4===l.readyState))if(r=t,a&&(l.onreadystatechange=x.noop,$n&&delete Pn[a]),i)4!==l.readyState&&l.abort();else{p={},s=l.status,u=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(p.text=l.responseText);try{c=l.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,u)},n.async?4===l.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},x(e).unload($n)),Pn[a]=r),l.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+w+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Yn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),a=(x.cssNumber[e]||"px"!==o&&+r)&&Yn.exec(x.css(n.elem,e)),s=1,l=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,x.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--l)}return i&&(a=n.start=+a||+r||0,n.unit=o,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=x.now()}function Zn(e,t,n){var r,i=(Qn[t]||[]).concat(Qn["*"]),o=0,a=i.length;for(;a>o;o++)if(r=i[o].call(n,t,e))return r}function er(e,t,n){var r,i,o=0,a=Gn.length,s=x.Deferred().always(function(){delete l.elem}),l=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,u.startTime+u.duration-t),r=n/u.duration||0,o=1-r,a=0,l=u.tweens.length;for(;l>a;a++)u.tweens[a].run(o);return s.notifyWith(e,[u,o,n]),1>o&&l?n:(s.resolveWith(e,[u]),!1)},u=s.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,u.opts,t,n,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(r),r},stop:function(t){var n=0,r=t?u.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)u.tweens[n].run(1);return t?s.resolveWith(e,[u,t]):s.rejectWith(e,[u,t]),this}}),c=u.props;for(tr(c,u.opts.specialEasing);a>o;o++)if(r=Gn[o].call(u,e,c,u.opts))return r;return x.map(c,Zn,u),x.isFunction(u.opts.start)&&u.opts.start.call(e,u),x.fx.timer(x.extend(l,{elem:e,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function tr(e,t){var n,r,i,o,a;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=x.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(er,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,l,u=this,c={},p=e.style,f=e.nodeType&&nn(e),d=x._data(e,"fxshow");n.queue||(s=x._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,l=s.empty.fire,s.empty.fire=function(){s.unqueued||l()}),s.unqueued++,u.always(function(){u.always(function(){s.unqueued--,x.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(x.support.inlineBlockNeedsLayout&&"inline"!==ln(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",x.support.shrinkWrapBlocks||u.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],Vn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show"))continue;c[r]=d&&d[r]||x.style(e,r)}if(!x.isEmptyObject(c)){d?"hidden"in d&&(f=d.hidden):d=x._data(e,"fxshow",{}),o&&(d.hidden=!f),f?x(e).show():u.done(function(){x(e).hide()}),u.done(function(){var t;x._removeData(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)a=Zn(f?d[r]:0,r,u),r in d||(d[r]=a.start,f&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}x.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),a=function(){var t=er(this,x.extend({},e),o);(i||x._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=x.timers,a=x._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=x._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,a=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=rr.prototype.init,x.fx.tick=function(){var e,n=x.timers,r=0;for(Xn=x.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||x.fx.stop(),Xn=t},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){Un||(Un=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(Un),Un=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){x.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,x.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},x.offset={setOffset:function(e,t,n){var r=x.css(e,"position");"static"===r&&(e.style.position="relative");var i=x(e),o=i.offset(),a=x.css(e,"top"),s=x.css(e,"left"),l=("absolute"===r||"fixed"===r)&&x.inArray("auto",[a,s])>-1,u={},c={},p,f;l?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),x.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(u.top=t.top-o.top+p),null!=t.left&&(u.left=t.left-o.left+f),"using"in t?t.using.call(e,u):i.css(u)}},x.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===x.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(n=e.offset()),n.top+=x.css(e[0],"borderTopWidth",!0),n.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-x.css(r,"marginTop",!0),left:t.left-n.left-x.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);x.fn[e]=function(i){return x.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?x(a).scrollLeft():o,r?o:x(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return x.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}x.each({Height:"height",Width:"width"},function(e,n){x.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){x.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return x.access(this,function(n,r,i){var o;return x.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?x.css(n,r,s):x.style(n,r,i,s)},n,a?i:t,a,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=x:(e.jQuery=e.$=x,"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}))})(window);
skin/frontend/base/default/js/jquery-noConflict.js ADDED
@@ -0,0 +1 @@
 
1
+ $.noConflict();