wp_custom_menu - Version 2.6.0

Version Notes

Скрыл попап окна от поисковых систем через отложенную инициализацию (по клику или наведению). Убрал параметры Display standard menu in IE6 browser (иначе поисковым ботам, представляющимся как ие6 показывается стандартное меню). Убрал параметр Move content to the bottom (теперь исходный код меню всегда в конце исходного кода страницы, либо его вообще нет, если подгрузка осуществляется аяксом). Если исходный код меню подгружается сразу, а не через аякс, то он кодируется в base64 для однозначного скрытия содержимого меню от любопытных поисковых ботов.

Download this release

Release Info

Developer WebAndPeople
Extension wp_custom_menu
Version 2.6.0
Comparing to
See all releases


Code changes from version 2.5.8 to 2.6.0

app/code/community/WP/CustomMenu/Block/Navigation.php CHANGED
@@ -4,7 +4,9 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
4
  {
5
  const CUSTOM_BLOCK_TEMPLATE = "wp_custom_menu_%d";
6
 
7
- private $_productsCount = null;
 
 
8
 
9
  public function drawCustomMenuMobileItem($category, $level = 0, $last = false)
10
  {
@@ -44,10 +46,20 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
44
  return $html;
45
  }
46
 
 
 
 
 
 
 
 
 
 
 
47
  public function drawCustomMenuItem($category, $level = 0, $last = false)
48
  {
49
- if (!$category->getIsActive()) return '';
50
- $html = array();
51
  $id = $category->getId();
52
  // --- Static Block ---
53
  $blockId = sprintf(self::CUSTOM_BLOCK_TEMPLATE, $id); // --- static block key
@@ -65,47 +77,48 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
65
  // --- Popup functions for show ---
66
  $drawPopup = ($blockHtml || count($activeChildren));
67
  if ($drawPopup) {
68
- $html[] = '<div id="menu' . $id . '" class="menu' . $active . '" onmouseover="wpShowMenuPopup(this, event, \'popup' . $id . '\');" onmouseout="wpHideMenuPopup(this, event, \'popup' . $id . '\', \'menu' . $id . '\')">';
69
  } else {
70
- $html[] = '<div id="menu' . $id . '" class="menu' . $active . '">';
71
  }
72
  // --- Top Menu Item ---
73
- $html[] = '<div class="parentMenu">';
74
  if ($level == 0 && $drawPopup) {
75
- $html[] = '<a href="javascript:void(0);" rel="'.$this->getCategoryUrl($category).'">';
76
  } else {
77
- $html[] = '<a href="'.$this->getCategoryUrl($category).'">';
78
  }
79
  $name = $this->escapeHtml($category->getName());
80
  if (Mage::getStoreConfig('custom_menu/general/non_breaking_space')) {
81
  $name = str_replace(' ', '&nbsp;', $name);
82
  }
83
- $html[] = '<span>' . $name . '</span>';
84
- $html[] = '</a>';
85
- $html[] = '</div>';
86
- $html[] = '</div>';
 
87
  // --- Add Popup block (hidden) ---
88
  if ($drawPopup) {
 
89
  // --- Popup function for hide ---
90
- $html[] = '<div id="popup' . $id . '" class="wp-custom-menu-popup" onmouseout="wpHideMenuPopup(this, event, \'popup' . $id . '\', \'menu' . $id . '\')" onmouseover="wpPopupOver(this, event, \'popup' . $id . '\', \'menu' . $id . '\')">';
91
  // --- draw Sub Categories ---
92
  if (count($activeChildren)) {
93
  $columns = (int)Mage::getStoreConfig('custom_menu/columns/count');
94
- $html[] = '<div class="block1">';
95
- $html[] = $this->drawColumns($activeChildren, $columns);
96
- $html[] = '<div class="clearBoth"></div>';
97
- $html[] = '</div>';
98
  }
99
  // --- draw Custom User Block ---
100
  if ($blockHtml) {
101
- $html[] = '<div id="' . $blockId . '" class="block2">';
102
- $html[] = $blockHtml;
103
- $html[] = '</div>';
104
  }
105
- $html[] = '</div>';
 
106
  }
107
- $html = implode("\n", $html);
108
- return $html;
109
  }
110
 
111
  public function drawMobileMenuItem($children, $level = 1)
@@ -148,25 +161,20 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
148
  {
149
  $html = '<div class="itemMenu level' . $level . '">';
150
  $keyCurrent = $this->getCurrentCategory()->getId();
151
- foreach ($children as $child)
152
- {
153
- if (is_object($child) && $child->getIsActive())
154
- {
155
  // --- class for active category ---
156
  $active = '';
157
- if ($this->isCategoryActive($child))
158
- {
159
  $active = ' actParent';
160
  if ($child->getId() == $keyCurrent) $active = ' act';
161
  }
162
  // --- format category name ---
163
  $name = $this->escapeHtml($child->getName());
164
- if (Mage::getStoreConfig('custom_menu/general/non_breaking_space'))
165
- $name = str_replace(' ', '&nbsp;', $name);
166
  $html.= '<a class="itemMenuName level' . $level . $active . '" href="' . $this->getCategoryUrl($child) . '"><span>' . $name . '</span></a>';
167
  $activeChildren = $this->_getActiveChildren($child, $level);
168
- if (count($activeChildren) > 0)
169
- {
170
  $html.= '<div class="itemSubMenu level' . $level . '">';
171
  $html.= $this->drawMenuItem($activeChildren, $level + 1);
172
  $html.= '</div>';
@@ -186,8 +194,7 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
186
  // --- draw columns ---
187
  $lastColumnNumber = count($chunks);
188
  $i = 1;
189
- foreach ($chunks as $key => $value)
190
- {
191
  if (!count($value)) continue;
192
  $class = '';
193
  if ($i == 1) $class.= ' first';
@@ -206,28 +213,21 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
206
  $activeChildren = array();
207
  // --- check level ---
208
  $maxLevel = (int)Mage::getStoreConfig('custom_menu/general/max_level');
209
- if ($maxLevel > 0)
210
- {
211
  if ($level >= ($maxLevel - 1)) return $activeChildren;
212
  }
213
  // --- / check level ---
214
- if (Mage::helper('catalog/category_flat')->isEnabled())
215
- {
216
  $children = $parent->getChildrenNodes();
217
  $childrenCount = count($children);
218
- }
219
- else
220
- {
221
  $children = $parent->getChildren();
222
  $childrenCount = $children->count();
223
  }
224
  $hasChildren = $children && $childrenCount;
225
- if ($hasChildren)
226
- {
227
- foreach ($children as $child)
228
- {
229
- if ($this->_isCategoryDisplayed($child))
230
- {
231
  array_push($activeChildren, $child);
232
  }
233
  }
@@ -240,8 +240,7 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
240
  if (!$child->getIsActive()) return false;
241
  // === check products count ===
242
  // --- get collection info ---
243
- if (!Mage::getStoreConfig('custom_menu/general/display_empty_categories'))
244
- {
245
  $data = $this->_getProductsCountData();
246
  // --- check by id ---
247
  $id = $child->getId();
@@ -254,8 +253,7 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
254
 
255
  private function _getProductsCountData()
256
  {
257
- if (is_null($this->_productsCount))
258
- {
259
  $collection = Mage::getModel('catalog/category')->getCollection();
260
  $storeId = Mage::app()->getStore()->getId();
261
  /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
@@ -265,8 +263,7 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
265
  ->setLoadProductCount(true)
266
  ->setStoreId($storeId);
267
  $productsCount = array();
268
- foreach($collection as $cat)
269
- {
270
  $productsCount[$cat->getId()] = array(
271
  'name' => $cat->getName(),
272
  'product_count' => $cat->getProductCount(),
@@ -286,13 +283,11 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
286
  $target = self::_explodeArrayByColumnsVertical($target, $num);
287
  }
288
  #return $target;
289
- if ((int)Mage::getStoreConfig('custom_menu/columns/integrate') && count($target))
290
- {
291
  // --- combine consistently numerically small column ---
292
  // --- 1. calc length of each column ---
293
  $max = 0; $columnsLength = array();
294
- foreach ($target as $key => $child)
295
- {
296
  $count = 0;
297
  $this->_countChild($child, 1, $count);
298
  if ($max < $count) $max = $count;
@@ -301,11 +296,9 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
301
  // --- 2. merge small columns with next ---
302
  $xColumns = array(); $column = array(); $cnt = 0;
303
  $xColumnsLength = array(); $k = 0;
304
- foreach ($columnsLength as $key => $count)
305
- {
306
  $cnt+= $count;
307
- if ($cnt > $max && count($column))
308
- {
309
  $xColumns[$k] = $column;
310
  $xColumnsLength[$k] = $cnt - $count;
311
  $k++; $column = array(); $cnt = $count;
@@ -316,17 +309,13 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
316
  $xColumnsLength[$k] = $cnt - $count;
317
  // --- 3. integrate columns of one element ---
318
  $target = $xColumns; $xColumns = array(); $nextKey = -1;
319
- if ($max > 1 && count($target) > 1)
320
- {
321
- foreach($target as $key => $column)
322
- {
323
  if ($key == $nextKey) continue;
324
- if ($xColumnsLength[$key] == 1)
325
- {
326
  // --- merge with next column ---
327
  $nextKey = $key + 1;
328
- if (isset($target[$nextKey]) && count($target[$nextKey]))
329
- {
330
  $xColumns[] = array_merge($column, $target[$nextKey]);
331
  continue;
332
  }
@@ -345,10 +334,8 @@ class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
345
 
346
  private function _countChild($children, $level, &$count)
347
  {
348
- foreach ($children as $child)
349
- {
350
- if ($child->getIsActive())
351
- {
352
  $count++; $activeChildren = $this->_getActiveChildren($child, $level);
353
  if (count($activeChildren) > 0) $this->_countChild($activeChildren, $level + 1, $count);
354
  }
4
  {
5
  const CUSTOM_BLOCK_TEMPLATE = "wp_custom_menu_%d";
6
 
7
+ private $_productsCount = null;
8
+ private $_topMenu = array();
9
+ private $_popupMenu = array();
10
 
11
  public function drawCustomMenuMobileItem($category, $level = 0, $last = false)
12
  {
46
  return $html;
47
  }
48
 
49
+ public function getTopMenuArray()
50
+ {
51
+ return $this->_topMenu;
52
+ }
53
+
54
+ public function getPopupMenuArray()
55
+ {
56
+ return $this->_popupMenu;
57
+ }
58
+
59
  public function drawCustomMenuItem($category, $level = 0, $last = false)
60
  {
61
+ if (!$category->getIsActive()) return;
62
+ $htmlTop = array();
63
  $id = $category->getId();
64
  // --- Static Block ---
65
  $blockId = sprintf(self::CUSTOM_BLOCK_TEMPLATE, $id); // --- static block key
77
  // --- Popup functions for show ---
78
  $drawPopup = ($blockHtml || count($activeChildren));
79
  if ($drawPopup) {
80
+ $htmlTop[] = '<div id="menu' . $id . '" class="menu' . $active . '" onmouseover="wpShowMenuPopup(this, event, \'popup' . $id . '\');" onmouseout="wpHideMenuPopup(this, event, \'popup' . $id . '\', \'menu' . $id . '\')">';
81
  } else {
82
+ $htmlTop[] = '<div id="menu' . $id . '" class="menu' . $active . '">';
83
  }
84
  // --- Top Menu Item ---
85
+ $htmlTop[] = '<div class="parentMenu">';
86
  if ($level == 0 && $drawPopup) {
87
+ $htmlTop[] = '<a href="javascript:void(0);" rel="'.$this->getCategoryUrl($category).'">';
88
  } else {
89
+ $htmlTop[] = '<a href="'.$this->getCategoryUrl($category).'">';
90
  }
91
  $name = $this->escapeHtml($category->getName());
92
  if (Mage::getStoreConfig('custom_menu/general/non_breaking_space')) {
93
  $name = str_replace(' ', '&nbsp;', $name);
94
  }
95
+ $htmlTop[] = '<span>' . $name . '</span>';
96
+ $htmlTop[] = '</a>';
97
+ $htmlTop[] = '</div>';
98
+ $htmlTop[] = '</div>';
99
+ $this->_topMenu[] = implode("\n", $htmlTop);
100
  // --- Add Popup block (hidden) ---
101
  if ($drawPopup) {
102
+ $htmlPopup = array();
103
  // --- Popup function for hide ---
104
+ $htmlPopup[] = '<div id="popup' . $id . '" class="wp-custom-menu-popup" onmouseout="wpHideMenuPopup(this, event, \'popup' . $id . '\', \'menu' . $id . '\')" onmouseover="wpPopupOver(this, event, \'popup' . $id . '\', \'menu' . $id . '\')">';
105
  // --- draw Sub Categories ---
106
  if (count($activeChildren)) {
107
  $columns = (int)Mage::getStoreConfig('custom_menu/columns/count');
108
+ $htmlPopup[] = '<div class="block1">';
109
+ $htmlPopup[] = $this->drawColumns($activeChildren, $columns);
110
+ $htmlPopup[] = '<div class="clearBoth"></div>';
111
+ $htmlPopup[] = '</div>';
112
  }
113
  // --- draw Custom User Block ---
114
  if ($blockHtml) {
115
+ $htmlPopup[] = '<div id="' . $blockId . '" class="block2">';
116
+ $htmlPopup[] = $blockHtml;
117
+ $htmlPopup[] = '</div>';
118
  }
119
+ $htmlPopup[] = '</div>';
120
+ $this->_popupMenu[] = implode("\n", $htmlPopup);
121
  }
 
 
122
  }
123
 
124
  public function drawMobileMenuItem($children, $level = 1)
161
  {
162
  $html = '<div class="itemMenu level' . $level . '">';
163
  $keyCurrent = $this->getCurrentCategory()->getId();
164
+ foreach ($children as $child) {
165
+ if (is_object($child) && $child->getIsActive()) {
 
 
166
  // --- class for active category ---
167
  $active = '';
168
+ if ($this->isCategoryActive($child)) {
 
169
  $active = ' actParent';
170
  if ($child->getId() == $keyCurrent) $active = ' act';
171
  }
172
  // --- format category name ---
173
  $name = $this->escapeHtml($child->getName());
174
+ if (Mage::getStoreConfig('custom_menu/general/non_breaking_space')) $name = str_replace(' ', '&nbsp;', $name);
 
175
  $html.= '<a class="itemMenuName level' . $level . $active . '" href="' . $this->getCategoryUrl($child) . '"><span>' . $name . '</span></a>';
176
  $activeChildren = $this->_getActiveChildren($child, $level);
177
+ if (count($activeChildren) > 0) {
 
178
  $html.= '<div class="itemSubMenu level' . $level . '">';
179
  $html.= $this->drawMenuItem($activeChildren, $level + 1);
180
  $html.= '</div>';
194
  // --- draw columns ---
195
  $lastColumnNumber = count($chunks);
196
  $i = 1;
197
+ foreach ($chunks as $key => $value) {
 
198
  if (!count($value)) continue;
199
  $class = '';
200
  if ($i == 1) $class.= ' first';
213
  $activeChildren = array();
214
  // --- check level ---
215
  $maxLevel = (int)Mage::getStoreConfig('custom_menu/general/max_level');
216
+ if ($maxLevel > 0) {
 
217
  if ($level >= ($maxLevel - 1)) return $activeChildren;
218
  }
219
  // --- / check level ---
220
+ if (Mage::helper('catalog/category_flat')->isEnabled()) {
 
221
  $children = $parent->getChildrenNodes();
222
  $childrenCount = count($children);
223
+ } else {
 
 
224
  $children = $parent->getChildren();
225
  $childrenCount = $children->count();
226
  }
227
  $hasChildren = $children && $childrenCount;
228
+ if ($hasChildren) {
229
+ foreach ($children as $child) {
230
+ if ($this->_isCategoryDisplayed($child)) {
 
 
 
231
  array_push($activeChildren, $child);
232
  }
233
  }
240
  if (!$child->getIsActive()) return false;
241
  // === check products count ===
242
  // --- get collection info ---
243
+ if (!Mage::getStoreConfig('custom_menu/general/display_empty_categories')) {
 
244
  $data = $this->_getProductsCountData();
245
  // --- check by id ---
246
  $id = $child->getId();
253
 
254
  private function _getProductsCountData()
255
  {
256
+ if (is_null($this->_productsCount)) {
 
257
  $collection = Mage::getModel('catalog/category')->getCollection();
258
  $storeId = Mage::app()->getStore()->getId();
259
  /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
263
  ->setLoadProductCount(true)
264
  ->setStoreId($storeId);
265
  $productsCount = array();
266
+ foreach($collection as $cat) {
 
267
  $productsCount[$cat->getId()] = array(
268
  'name' => $cat->getName(),
269
  'product_count' => $cat->getProductCount(),
283
  $target = self::_explodeArrayByColumnsVertical($target, $num);
284
  }
285
  #return $target;
286
+ if ((int)Mage::getStoreConfig('custom_menu/columns/integrate') && count($target)) {
 
287
  // --- combine consistently numerically small column ---
288
  // --- 1. calc length of each column ---
289
  $max = 0; $columnsLength = array();
290
+ foreach ($target as $key => $child) {
 
291
  $count = 0;
292
  $this->_countChild($child, 1, $count);
293
  if ($max < $count) $max = $count;
296
  // --- 2. merge small columns with next ---
297
  $xColumns = array(); $column = array(); $cnt = 0;
298
  $xColumnsLength = array(); $k = 0;
299
+ foreach ($columnsLength as $key => $count) {
 
300
  $cnt+= $count;
301
+ if ($cnt > $max && count($column)) {
 
302
  $xColumns[$k] = $column;
303
  $xColumnsLength[$k] = $cnt - $count;
304
  $k++; $column = array(); $cnt = $count;
309
  $xColumnsLength[$k] = $cnt - $count;
310
  // --- 3. integrate columns of one element ---
311
  $target = $xColumns; $xColumns = array(); $nextKey = -1;
312
+ if ($max > 1 && count($target) > 1) {
313
+ foreach($target as $key => $column) {
 
 
314
  if ($key == $nextKey) continue;
315
+ if ($xColumnsLength[$key] == 1) {
 
316
  // --- merge with next column ---
317
  $nextKey = $key + 1;
318
+ if (isset($target[$nextKey]) && count($target[$nextKey])) {
 
319
  $xColumns[] = array_merge($column, $target[$nextKey]);
320
  continue;
321
  }
334
 
335
  private function _countChild($children, $level, &$count)
336
  {
337
+ foreach ($children as $child) {
338
+ if ($child->getIsActive()) {
 
 
339
  $count++; $activeChildren = $this->_getActiveChildren($child, $level);
340
  if (count($activeChildren) > 0) $this->_countChild($activeChildren, $level + 1, $count);
341
  }
app/code/community/WP/CustomMenu/Block/Toggle.php CHANGED
@@ -5,12 +5,12 @@ class WP_CustomMenu_Block_Toggle extends Mage_Core_Block_Template
5
  public function _prepareLayout()
6
  {
7
  if (!Mage::getStoreConfig('custom_menu/general/enabled')) return;
8
- if (Mage::getStoreConfig('custom_menu/general/ie6_ignore') && Mage::helper('custommenu')->isIE6()) return;
9
  $layout = $this->getLayout();
10
  $topnav = $layout->getBlock('catalog.topnav');
11
  if (is_object($topnav)) {
12
  $topnav->setTemplate('webandpeople/custommenu/top.phtml');
13
  $head = $layout->getBlock('head');
 
14
  $head->addItem('skin_js', 'js/webandpeople/custommenu/custommenu.js');
15
  $head->addItem('skin_css', 'css/webandpeople/custommenu/custommenu.css');
16
  // --- Insert menu content ---
@@ -20,12 +20,7 @@ class WP_CustomMenu_Block_Toggle extends Mage_Core_Block_Template
20
  $menuContent = $layout->createBlock('core/template', 'custommenu-content')
21
  ->setTemplate('webandpeople/custommenu/menucontent.phtml');
22
  }
23
- if (Mage::getStoreConfig('custom_menu/general/move_code_to_bottom')) {
24
- $positionTargetName = 'before_body_end';
25
- } else {
26
- $positionTargetName = 'content';
27
- }
28
- $positionTarget = $layout->getBlock($positionTargetName);
29
  if (is_object($positionTarget)) $positionTarget->append($menuContent);
30
  }
31
  }
5
  public function _prepareLayout()
6
  {
7
  if (!Mage::getStoreConfig('custom_menu/general/enabled')) return;
 
8
  $layout = $this->getLayout();
9
  $topnav = $layout->getBlock('catalog.topnav');
10
  if (is_object($topnav)) {
11
  $topnav->setTemplate('webandpeople/custommenu/top.phtml');
12
  $head = $layout->getBlock('head');
13
+ $head->addItem('skin_js', 'js/webandpeople/custommenu/webtoolkit.base64.js');
14
  $head->addItem('skin_js', 'js/webandpeople/custommenu/custommenu.js');
15
  $head->addItem('skin_css', 'css/webandpeople/custommenu/custommenu.css');
16
  // --- Insert menu content ---
20
  $menuContent = $layout->createBlock('core/template', 'custommenu-content')
21
  ->setTemplate('webandpeople/custommenu/menucontent.phtml');
22
  }
23
+ $positionTarget = $layout->getBlock('before_body_end');
 
 
 
 
 
24
  if (is_object($positionTarget)) $positionTarget->append($menuContent);
25
  }
26
  }
app/code/community/WP/CustomMenu/Block/Topmenu.php CHANGED
@@ -1,16 +1,8 @@
1
  <?php
2
 
3
- if (!Mage::getStoreConfig('custom_menu/general/enabled') ||
4
- (Mage::getStoreConfig('custom_menu/general/ie6_ignore') && Mage::helper('custommenu')->isIE6()))
5
- {
6
- class WP_CustomMenu_Block_Topmenu extends Mage_Page_Block_Html_Topmenu
7
- {
8
-
9
- }
10
  return;
11
  }
12
 
13
- class WP_CustomMenu_Block_Topmenu extends WP_CustomMenu_Block_Navigation
14
- {
15
-
16
- }
1
  <?php
2
 
3
+ if (!Mage::getStoreConfig('custom_menu/general/enabled')) {
4
+ class WP_CustomMenu_Block_Topmenu extends Mage_Page_Block_Html_Topmenu {}
 
 
 
 
 
5
  return;
6
  }
7
 
8
+ class WP_CustomMenu_Block_Topmenu extends WP_CustomMenu_Block_Navigation {}
 
 
 
app/code/community/WP/CustomMenu/Helper/Data.php CHANGED
@@ -4,27 +4,13 @@ class WP_CustomMenu_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
5
  private $_menuData = null;
6
 
7
- public function isIE6()
8
- {
9
- if (!isset($_SERVER['HTTP_USER_AGENT'])) return;
10
- $userAgent = $_SERVER['HTTP_USER_AGENT'];
11
- preg_match('/MSIE ([0-9]{1,}[\.0-9]{0,})/', $userAgent, $matches);
12
- if (!isset($matches[1])) return;
13
- $version = floatval($matches[1]); #Mage::log($version);
14
- $flag = false; if ($version <= 6.0) $flag = true;
15
- return $flag;
16
- }
17
-
18
  public function getMenuData()
19
  {
20
  if (!is_null($this->_menuData)) return $this->_menuData;
21
-
22
  $blockClassName = Mage::getConfig()->getBlockClassName('custommenu/navigation');
23
  $block = new $blockClassName();
24
-
25
  $categories = $block->getStoreCategories();
26
  if (is_object($categories)) $categories = $block->getStoreCategories()->getNodes();
27
-
28
  if (Mage::getStoreConfig('custom_menu/general/ajax_load_content')) {
29
  $_moblieMenuAjaxUrl = str_replace('http:', '', Mage::getUrl('custommenu/ajaxmobilemenucontent'));
30
  $_menuAjaxUrl = str_replace('http:', '', Mage::getUrl('custommenu/ajaxmenucontent'));
@@ -32,7 +18,6 @@ class WP_CustomMenu_Helper_Data extends Mage_Core_Helper_Abstract
32
  $_moblieMenuAjaxUrl = '';
33
  $_menuAjaxUrl = '';
34
  }
35
-
36
  $this->_menuData = array(
37
  '_block' => $block,
38
  '_categories' => $categories,
@@ -46,7 +31,6 @@ class WP_CustomMenu_Helper_Data extends Mage_Core_Helper_Abstract
46
  '_rtl' => Mage::getStoreConfig('custom_menu/general/rtl') + 0,
47
  '_mobileMenuEnabled' => Mage::getStoreConfig('custom_menu/general/mobile_menu') + 0,
48
  );
49
-
50
  return $this->_menuData;
51
  }
52
 
@@ -54,6 +38,7 @@ class WP_CustomMenu_Helper_Data extends Mage_Core_Helper_Abstract
54
  {
55
  $menuData = Mage::helper('custommenu')->getMenuData();
56
  extract($menuData);
 
57
  // --- Home Link ---
58
  $homeLinkUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
59
  $homeLinkText = $this->__('Home');
@@ -110,17 +95,22 @@ HTML;
110
  $menuContent = '';
111
  $menuContentArray = array();
112
  foreach ($_categories as $_category) {
113
- $menuContentArray[] = $_block->drawCustomMenuItem($_category);
 
 
 
 
114
  }
115
- if (count($menuContentArray)) {
116
- $menuContent = implode("\n", $menuContentArray);
 
117
  }
118
  // --- Result ---
119
- $menu = <<<HTML
120
  $homeLink
121
- $menuContent
122
  <div class="clearBoth"></div>
123
  HTML;
124
- return $menu;
125
  }
126
  }
4
  {
5
  private $_menuData = null;
6
 
 
 
 
 
 
 
 
 
 
 
 
7
  public function getMenuData()
8
  {
9
  if (!is_null($this->_menuData)) return $this->_menuData;
 
10
  $blockClassName = Mage::getConfig()->getBlockClassName('custommenu/navigation');
11
  $block = new $blockClassName();
 
12
  $categories = $block->getStoreCategories();
13
  if (is_object($categories)) $categories = $block->getStoreCategories()->getNodes();
 
14
  if (Mage::getStoreConfig('custom_menu/general/ajax_load_content')) {
15
  $_moblieMenuAjaxUrl = str_replace('http:', '', Mage::getUrl('custommenu/ajaxmobilemenucontent'));
16
  $_menuAjaxUrl = str_replace('http:', '', Mage::getUrl('custommenu/ajaxmenucontent'));
18
  $_moblieMenuAjaxUrl = '';
19
  $_menuAjaxUrl = '';
20
  }
 
21
  $this->_menuData = array(
22
  '_block' => $block,
23
  '_categories' => $categories,
31
  '_rtl' => Mage::getStoreConfig('custom_menu/general/rtl') + 0,
32
  '_mobileMenuEnabled' => Mage::getStoreConfig('custom_menu/general/mobile_menu') + 0,
33
  );
 
34
  return $this->_menuData;
35
  }
36
 
38
  {
39
  $menuData = Mage::helper('custommenu')->getMenuData();
40
  extract($menuData);
41
+ if (!$_mobileMenuEnabled) return '';
42
  // --- Home Link ---
43
  $homeLinkUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
44
  $homeLinkText = $this->__('Home');
95
  $menuContent = '';
96
  $menuContentArray = array();
97
  foreach ($_categories as $_category) {
98
+ $_block->drawCustomMenuItem($_category);
99
+ }
100
+ $topMenuArray = $_block->getTopMenuArray();
101
+ if (count($topMenuArray)) {
102
+ $topMenuContent = implode("\n", $topMenuArray);
103
  }
104
+ $popupMenuArray = $_block->getPopupMenuArray();
105
+ if (count($popupMenuArray)) {
106
+ $popupMenuContent = implode("\n", $popupMenuArray);
107
  }
108
  // --- Result ---
109
+ $topMenu = <<<HTML
110
  $homeLink
111
+ $topMenuContent
112
  <div class="clearBoth"></div>
113
  HTML;
114
+ return array('topMenu' => $topMenu, 'popupMenu' => $popupMenuContent);
115
  }
116
  }
app/code/community/WP/CustomMenu/controllers/AjaxmenucontentController.php CHANGED
@@ -5,6 +5,6 @@ class WP_CustomMenu_AjaxmenucontentController extends Mage_Core_Controller_Front
5
  public function indexAction()
6
  {
7
  $menu = Mage::helper('custommenu')->getMenuContent();
8
- $this->getResponse()->setBody($menu);
9
  }
10
  }
5
  public function indexAction()
6
  {
7
  $menu = Mage::helper('custommenu')->getMenuContent();
8
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($menu));
9
  }
10
  }
app/code/community/WP/CustomMenu/controllers/AjaxmobilemenucontentController.php CHANGED
@@ -5,6 +5,6 @@ class WP_CustomMenu_AjaxmobilemenucontentController extends Mage_Core_Controller
5
  public function indexAction()
6
  {
7
  $menu = Mage::helper('custommenu')->getMobileMenuContent();
8
- $this->getResponse()->setBody($menu);
9
  }
10
  }
5
  public function indexAction()
6
  {
7
  $menu = Mage::helper('custommenu')->getMobileMenuContent();
8
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($menu));
9
  }
10
  }
app/code/community/WP/CustomMenu/etc/config.xml CHANGED
@@ -2,10 +2,9 @@
2
  <config>
3
  <modules>
4
  <WP_CustomMenu>
5
- <version>2.5.8</version>
6
  </WP_CustomMenu>
7
  </modules>
8
-
9
  <frontend>
10
  <routers>
11
  <custommenu>
@@ -24,7 +23,6 @@
24
  </updates>
25
  </layout>
26
  </frontend>
27
-
28
  <adminhtml>
29
  <acl>
30
  <resources>
@@ -50,7 +48,6 @@
50
  </resources>
51
  </acl>
52
  </adminhtml>
53
-
54
  <global>
55
  <blocks>
56
  <catalog>
@@ -73,21 +70,18 @@
73
  </custommenu>
74
  </helpers>
75
  </global>
76
-
77
  <default>
78
  <custom_menu>
79
  <general>
80
  <enabled>1</enabled>
81
  <ajax_load_content>0</ajax_load_content>
82
- <move_code_to_bottom>0</move_code_to_bottom>
83
  <mobile_menu>1</mobile_menu>
84
  <display_empty_categories>1</display_empty_categories>
85
  <max_level>3</max_level>
86
  <show_home_link>1</show_home_link>
87
  <non_breaking_space>0</non_breaking_space>
88
- <ie6_ignore>1</ie6_ignore>
89
  <rtl>0</rtl>
90
- <version>2.5.8</version>
91
  </general>
92
  <columns>
93
  <count>3</count>
2
  <config>
3
  <modules>
4
  <WP_CustomMenu>
5
+ <version>2.6.0</version>
6
  </WP_CustomMenu>
7
  </modules>
 
8
  <frontend>
9
  <routers>
10
  <custommenu>
23
  </updates>
24
  </layout>
25
  </frontend>
 
26
  <adminhtml>
27
  <acl>
28
  <resources>
48
  </resources>
49
  </acl>
50
  </adminhtml>
 
51
  <global>
52
  <blocks>
53
  <catalog>
70
  </custommenu>
71
  </helpers>
72
  </global>
 
73
  <default>
74
  <custom_menu>
75
  <general>
76
  <enabled>1</enabled>
77
  <ajax_load_content>0</ajax_load_content>
 
78
  <mobile_menu>1</mobile_menu>
79
  <display_empty_categories>1</display_empty_categories>
80
  <max_level>3</max_level>
81
  <show_home_link>1</show_home_link>
82
  <non_breaking_space>0</non_breaking_space>
 
83
  <rtl>0</rtl>
84
+ <version>2.6.0</version>
85
  </general>
86
  <columns>
87
  <count>3</count>
app/code/community/WP/CustomMenu/etc/system.xml CHANGED
@@ -43,19 +43,6 @@
43
  <show_in_website>1</show_in_website>
44
  <show_in_store>1</show_in_store>
45
  </ajax_load_content>
46
- <move_code_to_bottom translate="label">
47
- <label>Move content to the bottom</label>
48
- <comment>Move the menu source code to the bottom of a page</comment>
49
- <frontend_type>select</frontend_type>
50
- <source_model>adminhtml/system_config_source_yesno</source_model>
51
- <sort_order>3</sort_order>
52
- <show_in_default>1</show_in_default>
53
- <show_in_website>1</show_in_website>
54
- <show_in_store>1</show_in_store>
55
- <depends>
56
- <ajax_load_content>0</ajax_load_content>
57
- </depends>
58
- </move_code_to_bottom>
59
  <mobile_menu translate="label comment">
60
  <label>Mobile menu</label>
61
  <frontend_type>select</frontend_type>
@@ -103,15 +90,6 @@
103
  <show_in_website>1</show_in_website>
104
  <show_in_store>1</show_in_store>
105
  </non_breaking_space>
106
- <ie6_ignore translate="label">
107
- <label>Display standard menu in IE6 browser</label>
108
- <frontend_type>select</frontend_type>
109
- <source_model>adminhtml/system_config_source_yesno</source_model>
110
- <sort_order>30</sort_order>
111
- <show_in_default>1</show_in_default>
112
- <show_in_website>1</show_in_website>
113
- <show_in_store>1</show_in_store>
114
- </ie6_ignore>
115
  <rtl translate="label">
116
  <label>Enable RTL Text mode</label>
117
  <frontend_type>select</frontend_type>
43
  <show_in_website>1</show_in_website>
44
  <show_in_store>1</show_in_store>
45
  </ajax_load_content>
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  <mobile_menu translate="label comment">
47
  <label>Mobile menu</label>
48
  <frontend_type>select</frontend_type>
90
  <show_in_website>1</show_in_website>
91
  <show_in_store>1</show_in_store>
92
  </non_breaking_space>
 
 
 
 
 
 
 
 
 
93
  <rtl translate="label">
94
  <label>Enable RTL Text mode</label>
95
  <frontend_type>select</frontend_type>
app/design/frontend/default/default/template/webandpeople/custommenu/menucontent.phtml CHANGED
@@ -1,12 +1,13 @@
1
  <?php $menuContent = Mage::helper('custommenu')->getMenuContent(); ?>
2
  <script type="text/javascript">
3
  //<![CDATA[
4
- if ($('custommenu')) $('custommenu').update(<?php echo Zend_Json::encode($menuContent); ?>);
 
5
  //]]>
6
  </script>
7
  <?php $mobileMenuContent = Mage::helper('custommenu')->getMobileMenuContent(); ?>
8
  <script type="text/javascript">
9
  //<![CDATA[
10
- if ($('menu-content')) $('menu-content').update(<?php echo Zend_Json::encode($mobileMenuContent); ?>);
11
  //]]>
12
  </script>
1
  <?php $menuContent = Mage::helper('custommenu')->getMenuContent(); ?>
2
  <script type="text/javascript">
3
  //<![CDATA[
4
+ if ($('custommenu')) $('custommenu').update(Base64.decode('<?php echo base64_encode($menuContent['topMenu']); ?>'));
5
+ wpPopupMenuContent = Base64.decode('<?php echo base64_encode($menuContent['popupMenu']); ?>');
6
  //]]>
7
  </script>
8
  <?php $mobileMenuContent = Mage::helper('custommenu')->getMobileMenuContent(); ?>
9
  <script type="text/javascript">
10
  //<![CDATA[
11
+ wpMobileMenuContent = Base64.decode('<?php echo base64_encode($mobileMenuContent); ?>');
12
  //]]>
13
  </script>
app/design/frontend/default/default/template/webandpeople/custommenu/top.phtml CHANGED
@@ -51,6 +51,8 @@ var wpActiveMenu = null;
51
  var wpMobileMenuEnabled = <?php echo $_mobileMenuEnabled; ?>;
52
  var wpMenuAjaxUrl = '<?php echo $_menuAjaxUrl; ?>';
53
  var wpMoblieMenuAjaxUrl = '<?php echo $_moblieMenuAjaxUrl; ?>';
 
 
54
  wpCustomMenuMobileToggle();
55
  Event.observe(window, 'resize', function() {
56
  wpCustomMenuMobileToggle();
51
  var wpMobileMenuEnabled = <?php echo $_mobileMenuEnabled; ?>;
52
  var wpMenuAjaxUrl = '<?php echo $_menuAjaxUrl; ?>';
53
  var wpMoblieMenuAjaxUrl = '<?php echo $_moblieMenuAjaxUrl; ?>';
54
+ var wpPopupMenuContent = '';
55
+ var wpMobileMenuContent = '';
56
  wpCustomMenuMobileToggle();
57
  Event.observe(window, 'resize', function() {
58
  wpCustomMenuMobileToggle();
package.xml CHANGED
@@ -1,14 +1,14 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <package>
3
  <name>wp_custom_menu</name>
4
- <version>2.5.8</version>
5
  <stability>stable</stability>
6
  <license uri="http://web-experiment.info/regular_free_license">Web-Experiment.Info Regular Free License</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Magento Extension - Magento Custom Menu (Web-Experiment.Info)</summary>
10
  <description>Magento Extension - Magento Custom Menu (Web-Experiment.Info)</description>
11
- <notes>Изменил расположение папки расширния, переместив из local в community</notes>
12
  <authors>
13
  <author>
14
  <name>WebAndPeople</name>
@@ -21,8 +21,8 @@
21
  <email>y.gerassimenko@webandpeople.com</email>
22
  </author>
23
  </authors>
24
- <date>2014-03-20</date>
25
- <time>12:36:01</time>
26
  <contents>
27
  <target name="mageweb">
28
  <dir name="app">
@@ -31,20 +31,20 @@
31
  <dir name="WP">
32
  <dir name="CustomMenu">
33
  <dir name="Block">
34
- <file name="Navigation.php" hash="87be6224e66862e0562d30977277503c"/>
35
- <file name="Toggle.php" hash="c0e3299c7ce19041edb481ff09ab22c7"/>
36
- <file name="Topmenu.php" hash="7102b3bf0473dc5ecb0d66c12bfc6a95"/>
37
  </dir>
38
  <dir name="Helper">
39
- <file name="Data.php" hash="3fc8215a159463e064f9673e6b9c6a7b"/>
40
  </dir>
41
  <dir name="controllers">
42
- <file name="AjaxmenucontentController.php" hash="7e4b0f04147ede2a9405181e1056fd19"/>
43
- <file name="AjaxmobilemenucontentController.php" hash="7b1690de9885838fb6f483136eed3a06"/>
44
  </dir>
45
  <dir name="etc">
46
- <file name="config.xml" hash="de23ba8f0f2ed3ec5e59fcc8eaaeb5ed"/>
47
- <file name="system.xml" hash="c8df283cdc4662e977c4b7479f09e14d"/>
48
  </dir>
49
  </dir>
50
  </dir>
@@ -62,8 +62,8 @@
62
  <dir name="template">
63
  <dir name="webandpeople">
64
  <dir name="custommenu">
65
- <file name="menucontent.phtml" hash="c6aacc6cd49e638f08e90803183fed7b"/>
66
- <file name="top.phtml" hash="e57f1dc563d8cd5c7bfd39bdf58afd50"/>
67
  </dir>
68
  </dir>
69
  </dir>
@@ -91,7 +91,8 @@
91
  <dir name="js">
92
  <dir name="webandpeople">
93
  <dir name="custommenu">
94
- <file name="custommenu.js" hash="f3a0fc60503e5db502d0e34f7d72c665"/>
 
95
  </dir>
96
  </dir>
97
  </dir>
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <package>
3
  <name>wp_custom_menu</name>
4
+ <version>2.6.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://web-experiment.info/regular_free_license">Web-Experiment.Info Regular Free License</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Magento Extension - Magento Custom Menu (Web-Experiment.Info)</summary>
10
  <description>Magento Extension - Magento Custom Menu (Web-Experiment.Info)</description>
11
+ <notes>Скрыл попап окна от поисковых систем через отложенную инициализацию (по клику или наведению). Убрал параметры Display standard menu in IE6 browser (иначе поисковым ботам, представляющимся как ие6 показывается стандартное меню). Убрал параметр Move content to the bottom (теперь исходный код меню всегда в конце исходного кода страницы, либо его вообще нет, если подгрузка осуществляется аяксом). Если исходный код меню подгружается сразу, а не через аякс, то он кодируется в base64 для однозначного скрытия содержимого меню от любопытных поисковых ботов.</notes>
12
  <authors>
13
  <author>
14
  <name>WebAndPeople</name>
21
  <email>y.gerassimenko@webandpeople.com</email>
22
  </author>
23
  </authors>
24
+ <date>2014-03-24</date>
25
+ <time>22:31:31</time>
26
  <contents>
27
  <target name="mageweb">
28
  <dir name="app">
31
  <dir name="WP">
32
  <dir name="CustomMenu">
33
  <dir name="Block">
34
+ <file name="Navigation.php" hash="f1ec03151889346c5193c3296b556d5b"/>
35
+ <file name="Toggle.php" hash="382ed26b5801f1ca263d3a7b9c21ef40"/>
36
+ <file name="Topmenu.php" hash="baf91d07f38b733b3e09957ccab4db4d"/>
37
  </dir>
38
  <dir name="Helper">
39
+ <file name="Data.php" hash="be43d5f1ef1a48c7d8ff9a20f1eeac5f"/>
40
  </dir>
41
  <dir name="controllers">
42
+ <file name="AjaxmenucontentController.php" hash="8a92f7613cda2a7be6e44adb96da51e3"/>
43
+ <file name="AjaxmobilemenucontentController.php" hash="b2bacb5ba79b3be8d3e2ae1b85472507"/>
44
  </dir>
45
  <dir name="etc">
46
+ <file name="config.xml" hash="289c215691ef34d5f9bac685269af522"/>
47
+ <file name="system.xml" hash="cfd74237b0ab914323f82113923797e8"/>
48
  </dir>
49
  </dir>
50
  </dir>
62
  <dir name="template">
63
  <dir name="webandpeople">
64
  <dir name="custommenu">
65
+ <file name="menucontent.phtml" hash="885ff80797a1b95494f16dc828369c3d"/>
66
+ <file name="top.phtml" hash="eb59b9d6384c118e47c5233ede50c1f2"/>
67
  </dir>
68
  </dir>
69
  </dir>
91
  <dir name="js">
92
  <dir name="webandpeople">
93
  <dir name="custommenu">
94
+ <file name="custommenu.js" hash="35d6faec0ab484f0304a414cc3a1b5bd"/>
95
+ <file name="webtoolkit.base64.js" hash="d464b20d386bdc75f1eb05ff4963f446"/>
96
  </dir>
97
  </dir>
98
  </dir>
skin/frontend/default/default/js/webandpeople/custommenu/custommenu.js CHANGED
@@ -1,5 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  function wpShowMenuPopup(objMenu, event, popupId)
2
  {
 
3
  if (typeof wpCustommenuTimerHide[popupId] != 'undefined') clearTimeout(wpCustommenuTimerHide[popupId]);
4
  objMenu = $(objMenu.id); var popup = $(popupId); if (!popup) return;
5
  if (!!wpActiveMenu) {
@@ -214,14 +234,29 @@ function wpCustomMenuMobileToggle()
214
  y = w.innerHeight|| e.clientHeight|| g.clientHeight;
215
 
216
  if ((x < 800 || wpIsMobile.any()) && wpMobileMenuEnabled) {
 
217
  $('custommenu').hide();
218
  $('custommenu-mobile').show();
219
  // --- ajax load ---
220
  if (wpMoblieMenuAjaxUrl) {
221
- new Ajax.Updater({success: 'menu-content'}, wpMoblieMenuAjaxUrl, {
222
- method: 'get',
223
- asynchronous: true
224
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  wpMoblieMenuAjaxUrl = null;
226
  }
227
  } else {
@@ -230,10 +265,23 @@ function wpCustomMenuMobileToggle()
230
  $('custommenu').show();
231
  // --- ajax load ---
232
  if (wpMenuAjaxUrl) {
233
- new Ajax.Updater({success: 'custommenu'}, wpMenuAjaxUrl, {
234
- method: 'get',
235
- asynchronous: true
236
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  wpMenuAjaxUrl = null;
238
  }
239
  }
1
+ var wpMenuLoaded = false;
2
+ var wpMobileMenuLoaded = false;
3
+
4
+ function wpInitPopupContent()
5
+ {
6
+ if (wpMenuLoaded) return;
7
+ var xMenu = $('custommenu');
8
+ if (typeof wpPopupMenuContent != 'undefined') xMenu.innerHTML = wpPopupMenuContent + xMenu.innerHTML;
9
+ wpMenuLoaded = true;
10
+ }
11
+
12
+ function wpInitMobileMenuContent()
13
+ {
14
+ if (wpMobileMenuLoaded) return;
15
+ var xMenu = $('menu-content');
16
+ if (typeof wpMobileMenuContent != 'undefined') xMenu.innerHTML = wpMobileMenuContent;
17
+ wpMobileMenuLoaded = true;
18
+ }
19
+
20
  function wpShowMenuPopup(objMenu, event, popupId)
21
  {
22
+ wpInitPopupContent();
23
  if (typeof wpCustommenuTimerHide[popupId] != 'undefined') clearTimeout(wpCustommenuTimerHide[popupId]);
24
  objMenu = $(objMenu.id); var popup = $(popupId); if (!popup) return;
25
  if (!!wpActiveMenu) {
234
  y = w.innerHeight|| e.clientHeight|| g.clientHeight;
235
 
236
  if ((x < 800 || wpIsMobile.any()) && wpMobileMenuEnabled) {
237
+ wpInitMobileMenuContent();
238
  $('custommenu').hide();
239
  $('custommenu-mobile').show();
240
  // --- ajax load ---
241
  if (wpMoblieMenuAjaxUrl) {
242
+ new Ajax.Request(
243
+ wpMoblieMenuAjaxUrl, {
244
+ asynchronous: true,
245
+ method: 'post',
246
+ onSuccess: function(transport) {
247
+ if (transport && transport.responseText) {
248
+ try {
249
+ response = eval('(' + transport.responseText + ')');
250
+ } catch (e) {
251
+ response = {};
252
+ }
253
+ }
254
+ wpMobileMenuContent = response;
255
+ wpMobileMenuLoaded = false;
256
+ wpInitMobileMenuContent();
257
+ }
258
+ }
259
+ );
260
  wpMoblieMenuAjaxUrl = null;
261
  }
262
  } else {
265
  $('custommenu').show();
266
  // --- ajax load ---
267
  if (wpMenuAjaxUrl) {
268
+ new Ajax.Request(
269
+ wpMenuAjaxUrl, {
270
+ asynchronous: true,
271
+ method: 'post',
272
+ onSuccess: function(transport) {
273
+ if (transport && transport.responseText) {
274
+ try {
275
+ response = eval('(' + transport.responseText + ')');
276
+ } catch (e) {
277
+ response = {};
278
+ }
279
+ }
280
+ if ($('custommenu')) $('custommenu').update(response.topMenu);
281
+ wpPopupMenuContent = response.popupMenu;
282
+ }
283
+ }
284
+ );
285
  wpMenuAjaxUrl = null;
286
  }
287
  }
skin/frontend/default/default/js/webandpeople/custommenu/webtoolkit.base64.js ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *
3
+ * Base64 encode / decode
4
+ * http://www.webtoolkit.info/javascript-base64.html
5
+ *
6
+ **/
7
+
8
+ var Base64 = {
9
+
10
+ // private property
11
+ _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
12
+
13
+ // public method for encoding
14
+ encode : function (input) {
15
+ var output = "";
16
+ var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
17
+ var i = 0;
18
+
19
+ input = Base64._utf8_encode(input);
20
+
21
+ while (i < input.length) {
22
+
23
+ chr1 = input.charCodeAt(i++);
24
+ chr2 = input.charCodeAt(i++);
25
+ chr3 = input.charCodeAt(i++);
26
+
27
+ enc1 = chr1 >> 2;
28
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
29
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
30
+ enc4 = chr3 & 63;
31
+
32
+ if (isNaN(chr2)) {
33
+ enc3 = enc4 = 64;
34
+ } else if (isNaN(chr3)) {
35
+ enc4 = 64;
36
+ }
37
+
38
+ output = output +
39
+ this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
40
+ this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
41
+
42
+ }
43
+
44
+ return output;
45
+ },
46
+
47
+ // public method for decoding
48
+ decode : function (input) {
49
+ var output = "";
50
+ var chr1, chr2, chr3;
51
+ var enc1, enc2, enc3, enc4;
52
+ var i = 0;
53
+
54
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
55
+
56
+ while (i < input.length) {
57
+
58
+ enc1 = this._keyStr.indexOf(input.charAt(i++));
59
+ enc2 = this._keyStr.indexOf(input.charAt(i++));
60
+ enc3 = this._keyStr.indexOf(input.charAt(i++));
61
+ enc4 = this._keyStr.indexOf(input.charAt(i++));
62
+
63
+ chr1 = (enc1 << 2) | (enc2 >> 4);
64
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
65
+ chr3 = ((enc3 & 3) << 6) | enc4;
66
+
67
+ output = output + String.fromCharCode(chr1);
68
+
69
+ if (enc3 != 64) {
70
+ output = output + String.fromCharCode(chr2);
71
+ }
72
+ if (enc4 != 64) {
73
+ output = output + String.fromCharCode(chr3);
74
+ }
75
+
76
+ }
77
+
78
+ output = Base64._utf8_decode(output);
79
+
80
+ return output;
81
+
82
+ },
83
+
84
+ // private method for UTF-8 encoding
85
+ _utf8_encode : function (string) {
86
+ string = string.replace(/\r\n/g,"\n");
87
+ var utftext = "";
88
+
89
+ for (var n = 0; n < string.length; n++) {
90
+
91
+ var c = string.charCodeAt(n);
92
+
93
+ if (c < 128) {
94
+ utftext += String.fromCharCode(c);
95
+ }
96
+ else if((c > 127) && (c < 2048)) {
97
+ utftext += String.fromCharCode((c >> 6) | 192);
98
+ utftext += String.fromCharCode((c & 63) | 128);
99
+ }
100
+ else {
101
+ utftext += String.fromCharCode((c >> 12) | 224);
102
+ utftext += String.fromCharCode(((c >> 6) & 63) | 128);
103
+ utftext += String.fromCharCode((c & 63) | 128);
104
+ }
105
+
106
+ }
107
+
108
+ return utftext;
109
+ },
110
+
111
+ // private method for UTF-8 decoding
112
+ _utf8_decode : function (utftext) {
113
+ var string = "";
114
+ var i = 0;
115
+ var c = c1 = c2 = 0;
116
+
117
+ while ( i < utftext.length ) {
118
+
119
+ c = utftext.charCodeAt(i);
120
+
121
+ if (c < 128) {
122
+ string += String.fromCharCode(c);
123
+ i++;
124
+ }
125
+ else if((c > 191) && (c < 224)) {
126
+ c2 = utftext.charCodeAt(i+1);
127
+ string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
128
+ i += 2;
129
+ }
130
+ else {
131
+ c2 = utftext.charCodeAt(i+1);
132
+ c3 = utftext.charCodeAt(i+2);
133
+ string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
134
+ i += 3;
135
+ }
136
+
137
+ }
138
+
139
+ return string;
140
+ }
141
+
142
+ }