Magesitemap - Version 1.0

Version Notes

Free Version

Download this release

Release Info

Developer Magento Core Team
Extension Magesitemap
Version 1.0
Comparing to
See all releases


Version 1.0

Files changed (47) hide show
  1. app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap.php +12 -0
  2. app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Edit.php +76 -0
  3. app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Edit/Form.php +19 -0
  4. app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Edit/Tab/Form.php +84 -0
  5. app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Edit/Tabs.php +24 -0
  6. app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Grid.php +115 -0
  7. app/code/local/Magestore/Magesitemap/Block/Magesitemap.php +170 -0
  8. app/code/local/Magestore/Magesitemap/Block/Tree.php +82 -0
  9. app/code/local/Magestore/Magesitemap/Helper/Data.php +6 -0
  10. app/code/local/Magestore/Magesitemap/Model/Direction.php +16 -0
  11. app/code/local/Magestore/Magesitemap/Model/Magesitemap.php +10 -0
  12. app/code/local/Magestore/Magesitemap/Model/Mysql4/Magesitemap.php +10 -0
  13. app/code/local/Magestore/Magesitemap/Model/Mysql4/Magesitemap/Collection.php +10 -0
  14. app/code/local/Magestore/Magesitemap/Model/Status.php +15 -0
  15. app/code/local/Magestore/Magesitemap/controllers/Adminhtml/MagesitemapController.php +237 -0
  16. app/code/local/Magestore/Magesitemap/controllers/IndexController.php +20 -0
  17. app/code/local/Magestore/Magesitemap/etc/config.xml +123 -0
  18. app/code/local/Magestore/Magesitemap/etc/system.xml +42 -0
  19. app/code/local/Magestore/Magesitemap/sql/magesitemap_setup/mysql4-install-0.1.0.php +21 -0
  20. app/code/local/Magestore/Magesitemap/sql/magesitemap_setup/mysql4-upgrade-0.1.0-0.1.1.php +7 -0
  21. app/code/local/Magestore/Magesitemap/sql/magesitemap_setup/mysql4-upgrade-0.1.1-0.1.2.php +22 -0
  22. app/etc/modules/Magestore_Magesitemap.xml +9 -0
  23. js/magestore/api.html +252 -0
  24. js/magestore/example01.html +53 -0
  25. js/magestore/img/base.gif +0 -0
  26. js/magestore/img/cd.gif +0 -0
  27. js/magestore/img/empty.gif +0 -0
  28. js/magestore/img/folder.gif +0 -0
  29. js/magestore/img/folderopen.gif +0 -0
  30. js/magestore/img/globe.gif +0 -0
  31. js/magestore/img/imgfolder.gif +0 -0
  32. js/magestore/img/join.gif +0 -0
  33. js/magestore/img/joinbottom.gif +0 -0
  34. js/magestore/img/line.gif +0 -0
  35. js/magestore/img/minus.gif +0 -0
  36. js/magestore/img/minusbottom.gif +0 -0
  37. js/magestore/img/musicfolder.gif +0 -0
  38. js/magestore/img/nolines_minus.gif +0 -0
  39. js/magestore/img/nolines_plus.gif +0 -0
  40. js/magestore/img/page.gif +0 -0
  41. js/magestore/img/plus.gif +0 -0
  42. js/magestore/img/plusbottom.gif +0 -0
  43. js/magestore/img/question.gif +0 -0
  44. js/magestore/img/trash.gif +0 -0
  45. js/magestore/tree.css +34 -0
  46. js/magestore/tree.js +347 -0
  47. package.xml +18 -0
app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Magesitemap_Block_Adminhtml_Magesitemap extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_magesitemap';
7
+ $this->_blockGroup = 'magesitemap';
8
+ $this->_headerText = Mage::helper('magesitemap')->__('XmlTag Manager');
9
+ $this->_addButtonLabel = Mage::helper('magesitemap')->__('Add XmlTag');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Edit.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Magesitemap_Block_Adminhtml_Magesitemap_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'magesitemap';
11
+ $this->_controller = 'adminhtml_magesitemap';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('magesitemap')->__('Save Tag'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('magesitemap')->__('Delete Tag'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+ $dataObject = Mage::registry('magesitemap_data');
22
+ $is_static = '0';
23
+ if(is_object($dataObject)){
24
+ if($dataObject->getData('static_value')){
25
+ $is_static ='1';
26
+ }
27
+ }
28
+ $this->_formScripts[] = "
29
+ function toggleEditor() {
30
+ if (tinyMCE.getInstanceById('magesitemap_content') == null) {
31
+ tinyMCE.execCommand('mceAddControl', false, 'magesitemap_content');
32
+ } else {
33
+ tinyMCE.execCommand('mceRemoveControl', false, 'magesitemap_content');
34
+ }
35
+ }
36
+
37
+ function saveAndContinueEdit(){
38
+ editForm.submit($('edit_form').action+'back/edit/');
39
+ }
40
+ function choooseType(){
41
+ if($('type_attribute').value !='attribute_product'){
42
+ $('attribute_code').hide();
43
+ $('attribute_code').removeClassName('required-entry');
44
+ $('static_value').hide();
45
+ $('static_value').removeClassName('required-entry');
46
+ if($('type_attribute').value == 'static_value'){
47
+ $('static_value').show();
48
+ $('static_value').addClassName('required-entry');
49
+ }
50
+ }else{
51
+ $('attribute_code').show();
52
+ $('attribute_code').addClassName('required-entry');
53
+ $('static_value').hide();
54
+ $('static_value').removeClassName('required-entry');
55
+ }
56
+ }
57
+ function checkIsStatic(is_static){
58
+ if(is_static ==1){
59
+ $('type_attribute').value = 'static_value';
60
+ $('attribute_code').hide();
61
+ $('static_value').show();
62
+ }
63
+ }
64
+ window.onload = checkIsStatic('".$is_static."');
65
+ ";
66
+ }
67
+
68
+ public function getHeaderText()
69
+ {
70
+ if( Mage::registry('magesitemap_data') && Mage::registry('magesitemap_data')->getId() ) {
71
+ return Mage::helper('magesitemap')->__("Edit Tag '%s'", $this->htmlEscape(Mage::registry('magesitemap_data')->getData('alias_name')));
72
+ } else {
73
+ return Mage::helper('magesitemap')->__('Add Tag');
74
+ }
75
+ }
76
+ }
app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Magesitemap_Block_Adminhtml_Magesitemap_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Edit/Tab/Form.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Magesitemap_Block_Adminhtml_Magesitemap_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('magesitemap_form', array('legend'=>Mage::helper('magesitemap')->__('Item information')));
10
+
11
+ $fieldset->addField('alias_name', 'text', array(
12
+ 'label' => Mage::helper('magesitemap')->__('Tag Name'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'alias_name',
16
+ ));
17
+
18
+ $fieldset->addField('type_attribute', 'select', array(
19
+ 'label' => Mage::helper('magesitemap')->__('Select Type'),
20
+ 'name' => 'type_attribute',
21
+ 'onchange' => 'choooseType();',
22
+ 'values' => array(
23
+ array(
24
+ 'value' => 'attribute_product',
25
+ 'label' => Mage::helper('magesitemap')->__('Product Attribute'),
26
+ ),
27
+ array(
28
+ 'value' => 'product_link',
29
+ 'label' => Mage::helper('magesitemap')->__('Product Link'),
30
+ ),
31
+ array(
32
+ 'value' => 'shipping_cost',
33
+ 'label' => Mage::helper('magesitemap')->__('Shipping cost'),
34
+ ),
35
+ array(
36
+ 'value' => 'tax_rate',
37
+ 'label' => Mage::helper('magesitemap')->__('Tax'),
38
+ ),
39
+ array(
40
+ 'value' =>'static_value',
41
+ 'label' =>Mage::helper('magesitemap')->__("Static Tag"),
42
+ ),
43
+ ),
44
+ ));
45
+
46
+
47
+ $fieldset->addField('attribute_code', 'text', array(
48
+ 'label' => Mage::helper('magesitemap')->__('Attribute Code'),
49
+ // 'style' =>'display:none;',
50
+ 'required' => true,
51
+ 'name' => 'attribute_code',
52
+ ));
53
+ $fieldset->addField('static_value', 'text', array(
54
+ 'label' => Mage::helper('magesitemap')->__('Static Value'),
55
+ 'required' => false,
56
+ 'style' =>'display:none;',
57
+ 'name' => 'static_value',
58
+ ));
59
+ $fieldset->addField('status', 'select', array(
60
+ 'label' => Mage::helper('magesitemap')->__('Status'),
61
+ 'name' => 'status',
62
+ 'values' => array(
63
+ array(
64
+ 'value' => 1,
65
+ 'label' => Mage::helper('magesitemap')->__('Enabled'),
66
+ ),
67
+
68
+ array(
69
+ 'value' => 2,
70
+ 'label' => Mage::helper('magesitemap')->__('Disabled'),
71
+ ),
72
+ ),
73
+ ));
74
+
75
+ if ( Mage::getSingleton('adminhtml/session')->getMagesitemapData() )
76
+ {
77
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getMagesitemapData());
78
+ Mage::getSingleton('adminhtml/session')->setMagesitemapData(null);
79
+ } elseif ( Mage::registry('magesitemap_data') ) {
80
+ $form->setValues(Mage::registry('magesitemap_data')->getData());
81
+ }
82
+ return parent::_prepareForm();
83
+ }
84
+ }
app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Magesitemap_Block_Adminhtml_Magesitemap_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('magesitemap_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('magesitemap')->__('Tag Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('magesitemap')->__('Tag Information'),
18
+ 'title' => Mage::helper('magesitemap')->__('Tag Information'),
19
+ 'content' => $this->getLayout()->createBlock('magesitemap/adminhtml_magesitemap_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Grid.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Magesitemap_Block_Adminhtml_Magesitemap_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('magesitemapGrid');
9
+ $this->setDefaultSort('magesitemap_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('magesitemap/magesitemap')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('magesitemap_id', array(
24
+ 'header' => Mage::helper('magesitemap')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'magesitemap_id',
28
+ ));
29
+
30
+ $this->addColumn('alias_name', array(
31
+ 'header' => Mage::helper('magesitemap')->__('XmlTag Name'),
32
+ 'align' =>'left',
33
+ 'index' => 'alias_name',
34
+ ));
35
+
36
+ $this->addColumn('attribute_code', array(
37
+ 'header' => Mage::helper('magesitemap')->__('Attribute Code'),
38
+ 'align' =>'left',
39
+ 'index' => 'attribute_code',
40
+ ));
41
+
42
+
43
+ $this->addColumn('status', array(
44
+ 'header' => Mage::helper('magesitemap')->__('Status'),
45
+ 'align' => 'left',
46
+ 'width' => '80px',
47
+ 'index' => 'status',
48
+ 'type' => 'options',
49
+ 'options' => array(
50
+ 1 => 'Enabled',
51
+ 2 => 'Disabled',
52
+ ),
53
+ ));
54
+
55
+ $this->addColumn('action',
56
+ array(
57
+ 'header' => Mage::helper('magesitemap')->__('Action'),
58
+ 'width' => '100',
59
+ 'type' => 'action',
60
+ 'getter' => 'getId',
61
+ 'actions' => array(
62
+ array(
63
+ 'caption' => Mage::helper('magesitemap')->__('Edit'),
64
+ 'url' => array('base'=> '*/*/edit'),
65
+ 'field' => 'id'
66
+ )
67
+ ),
68
+ 'filter' => false,
69
+ 'sortable' => false,
70
+ 'index' => 'stores',
71
+ 'is_system' => true,
72
+ ));
73
+
74
+ $this->addExportType('*/*/exportCsv', Mage::helper('magesitemap')->__('CSV'));
75
+ $this->addExportType('*/*/exportXml', Mage::helper('magesitemap')->__('XML'));
76
+
77
+ return parent::_prepareColumns();
78
+ }
79
+
80
+ protected function _prepareMassaction()
81
+ {
82
+ $this->setMassactionIdField('magesitemap_id');
83
+ $this->getMassactionBlock()->setFormFieldName('magesitemap');
84
+
85
+ $this->getMassactionBlock()->addItem('delete', array(
86
+ 'label' => Mage::helper('magesitemap')->__('Delete'),
87
+ 'url' => $this->getUrl('*/*/massDelete'),
88
+ 'confirm' => Mage::helper('magesitemap')->__('Are you sure?')
89
+ ));
90
+
91
+ $statuses = Mage::getSingleton('magesitemap/status')->getOptionArray();
92
+
93
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
94
+ $this->getMassactionBlock()->addItem('status', array(
95
+ 'label'=> Mage::helper('magesitemap')->__('Change status'),
96
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
97
+ 'additional' => array(
98
+ 'visibility' => array(
99
+ 'name' => 'status',
100
+ 'type' => 'select',
101
+ 'class' => 'required-entry',
102
+ 'label' => Mage::helper('magesitemap')->__('Status'),
103
+ 'values' => $statuses
104
+ )
105
+ )
106
+ ));
107
+ return $this;
108
+ }
109
+
110
+ public function getRowUrl($row)
111
+ {
112
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
113
+ }
114
+
115
+ }
app/code/local/Magestore/Magesitemap/Block/Magesitemap.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Magesitemap_Block_Magesitemap extends Mage_Core_Block_Template
3
+ {
4
+ protected $_categoryId;
5
+
6
+ public function setCategory($categoryId){
7
+ $this->_categoryId = $categoryId;
8
+ }
9
+
10
+ public function getCategory(){
11
+ $categoryModel = Mage::getModel("catalog/category")
12
+ ->load($this->_categoryId);
13
+ if($categoryModel->getId()){
14
+ return $categoryModel;
15
+ }else{
16
+ return NULL;
17
+ }
18
+
19
+ }
20
+
21
+ public function getCurrentStore(){
22
+ $storeCode = $this->getRequest()->getParam('store','');
23
+
24
+ if($storeCode !=''){
25
+ //die($storeCode);
26
+ $store = Mage::app()->getStore()->load($storeCode);
27
+ return $store;
28
+ }
29
+ return Mage::app()->getStore();
30
+
31
+ }
32
+
33
+ public function getProductCollection(){
34
+
35
+ $collection = Mage::getModel("catalog/product")->getCollection()
36
+ ->addAttributeToSelect("*")
37
+ ->setOrder('updated_at','DESC')
38
+ ->addCategoryFilter($this->getCategory())
39
+ ->setStore($this->getCurrentStore())
40
+ ;
41
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
42
+ return $collection;
43
+ }
44
+
45
+ public function addNodeXML($tag_name,$tag_value,$cdata = false){
46
+ $value = $cdata ? '<![CDATA['.trim($tag_value).']]>' : trim($tag_value);
47
+ $name = trim($tag_name);
48
+ return "<{$name}>{$value}</{$name}>";
49
+ }
50
+
51
+ public function setHeader(){
52
+ Header("Cache-Control: no-cache, must-revalidate");
53
+ Header("Pragma: no-cache");
54
+ Header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
55
+ Header("Content-type: text/xml; charset=utf-8");
56
+ }
57
+
58
+ public function encode($htmlInput){
59
+
60
+ if( defined('_ENCODING') && strtolower(_ENCODING) != 'utf-8' ){
61
+ $htmlInput = iconv( _ENCODING, 'utf-8', $htmlInput );
62
+ }
63
+ print $htmlInput;
64
+ }
65
+
66
+ public function getXmlTags(){
67
+ $collection = Mage::getModel("magesitemap/magesitemap")
68
+ ->getCollection()
69
+ ->addFieldToFilter('status',1);
70
+ return $collection;
71
+ }
72
+ public function getTaxPercent($product){
73
+
74
+ $percent = $product->getTaxPercent();
75
+ $taxClassId = $product->getTaxClassId();
76
+ if (is_null($percent)) {
77
+ if ($taxClassId) {
78
+ $request = Mage::getSingleton('tax/calculation')->getRateRequest(null, null, null, null);
79
+ $percent = Mage::getSingleton('tax/calculation')->getRate($request->setProductClassId($taxClassId));
80
+ }
81
+ }
82
+ $product_tax = $percent;
83
+ }
84
+
85
+ public function exportXml(){
86
+
87
+ $storeName = $this->getCurrentStore()->getName();
88
+ $xml_data[] = '<?xml version="1.0" encoding="utf-8" ?>';
89
+ $xml_data[] = '<store name ="'.$storeName.'" date="'.date('d/m/Y').'" time ="'.date('H:i:s').'" >';
90
+ $xml_data[] = '<products>';
91
+ $productCollection = $this->getProductCollection();
92
+
93
+ foreach($productCollection as $_product){
94
+ $xml_data[] = '<product>';
95
+ $xmltags = $this->getXmlTags();
96
+ if($xmltags->getSize()>0){
97
+ foreach($xmltags as $_tag){
98
+ $_tagName = $this->preProcessTagData($_tag->getAliasName());
99
+ $_tagValue = $this->preProcessTagData($_tag->getAttributeCode());
100
+ if($_tagValue == 'image'){
101
+ $_tagValue = Mage::helper('catalog/image')->init($_product, 'image')->resize(400);
102
+ $xml_data[] = $this->addNodeXML($_tagName,$_tagValue,true);
103
+ }elseif($_tagValue =='price'){
104
+ $price = $_product->getFinalPrice();
105
+ $_tagValue = $this->getCurrentStore()->convertPrice($price, false, false);
106
+ $currency_code = $this->getCurrentStore()->getCurrentCurrency()->getCurrencyCode();
107
+ $xml_data[] = $this->addNodeXML('currency_code',$currency_code,true);
108
+ $xml_data[] = $this->addNodeXML($_tagName,$_tagValue,true);
109
+ }elseif($_tagValue =='product_link'){
110
+ $_tagValue = $_product->getProductUrl();
111
+ $xml_data[] = $this->addNodeXML($_tagName,$_tagValue,true);
112
+
113
+ }elseif($_tagValue =='shipping_cost'){
114
+ $default_shipping = Mage::getStoreConfig('carriers/flatrate/price');
115
+ $_tagValue = $default_shipping;
116
+ $xml_data[] = $this->addNodeXML($_tagName,$_tagValue,true);
117
+
118
+ }elseif($_tagValue == 'tax_rate'){
119
+ $_tagValue = $this->getTaxPercent($_product);
120
+ $xml_data[] = $this->addNodeXML($_tagName,$_tagValue,true);
121
+ }elseif($_tagValue == 'static_value'){
122
+ $_tagValue = $_tag->getStaticValue();
123
+ $xml_data[] = $this->addNodeXML($_tagName,$_tagValue,true);
124
+ }else{
125
+ $attrModel = $_product->getResource()->getAttribute($_tagValue);
126
+ if(is_object($attrModel)){
127
+ if($attrModel->getData("frontend_input") =="select" || $attrModel->getData("frontend_input") == "multiselect"){
128
+ $_tagValue = $_product->getAttributeText($_tagValue);
129
+ $xml_data[] = $this->addNodeXML($_tagName,$_tagValue,true);
130
+
131
+ }else{
132
+ $_tagValue = $_product->getData($_tagValue);
133
+ $xml_data[] = $this->addNodeXML($_tagName,$_tagValue,true);
134
+ }
135
+ }
136
+
137
+ }
138
+
139
+
140
+ }
141
+ }
142
+ $xml_data[] = '</product>';
143
+
144
+ }
145
+ $xml_data[] = '</products>';
146
+ $xml_data[] = '</store>';
147
+ $xml_output = join("\n",$xml_data);
148
+ $this->setHeader();
149
+ $this->encode($xml_output);
150
+
151
+ }
152
+
153
+ public function preProcessTagData($data){
154
+ $outputData = str_replace(' ','',strtolower($data));
155
+ return $outputData;
156
+ }
157
+
158
+ public function getPrice($product){
159
+
160
+ $finalPrice = $product->getFinalPrice();
161
+ $price = $this->getCurrentStore()->convertPrice($finalPrice, false, false);
162
+ return $price;
163
+ }
164
+
165
+ public function getCurrencyCode(){
166
+
167
+ $currencyCode = $this->getCurrentStore()->getData("current_currency")->getCurrencyCode();
168
+ return $currencyCode;
169
+ }
170
+ }
app/code/local/Magestore/Magesitemap/Block/Tree.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Magesitemap_Block_Tree extends Mage_Core_Block_Template
3
+ {
4
+ public function buildTree(){
5
+ $urlJsFile = $this->getJsUrl("magestore/tree.js");
6
+ $urlJsCss = $this->getJsUrl("magestore/tree.css");
7
+ $direction = Mage::getStoreConfig('xmlsitemap/general/direction');
8
+ $dir = '';
9
+ if($direction ==2){
10
+ $dir = 'dir ="rtl"';
11
+ }else{
12
+ $dir = 'dir ="ltr"';
13
+ }
14
+ $_html = "<html {$dir} >";
15
+ $_html .= '<head>'.
16
+ '<link rel="stylesheet" href="'.$this->getJsUrl().'magestore/tree.css" type="text/css">'.
17
+ '<script language="javascript" src="'.$this->getJsUrl().'magestore/tree.js"></script>';
18
+ $_html .= '<title>Sitemap</title>';
19
+ $_html .= '</head>';
20
+ $_html .= '<body><div class="dtree">';
21
+ $_html .= '<div class="block_store">';
22
+ $_html .= $this->getStoreHtml();
23
+ $_html .= '</div>';
24
+ $_html .= '<script type="text/javascript"> <!--'."\n";
25
+ $_html .= " var baseUrl = '".$this->getJsUrl('magestore/')."';";
26
+ $_html .= " var d = new dTree('d');d.icon.setUrl('".$this->getJsUrl('magestore/')."');";
27
+ $storeName = $this->getCurrentStore()->getName();
28
+ $rootCategory = Mage::getModel("catalog/category")->load($this->getCurrentStore()->getRootCategoryId());
29
+ $_html .= $this->addNode($rootCategory,true);
30
+ $listCategory = Mage::getModel("catalog/category")->getCollection();
31
+ foreach($listCategory as $item ){
32
+ if($item->getId() == $rootCategory){
33
+ continue;
34
+ }
35
+ $_category = Mage::getModel('catalog/category')->load($item->getId());
36
+ if (!$_category->getId()) {
37
+ continue;
38
+ }
39
+
40
+ if (!$_category->getIsActive()) {
41
+ continue;
42
+ }
43
+ $_html .= $this->addNode($_category);
44
+ }
45
+ $_html .= 'document.write(d); //--> </script>';
46
+ $_html .= '</div></body></html>';
47
+ print($_html);
48
+ }
49
+ public function getCurrentStore(){
50
+ $storeCode = $this->getRequest()->getParam('store','');
51
+ if($storeCode !=''){
52
+ $store = Mage::app()->getStore()->load($storeCode);
53
+ return $store;
54
+ }
55
+ return Mage::app()->getStore();
56
+
57
+ }
58
+ public function addNode($_category,$isRoot = false){
59
+ if($isRoot){
60
+ return "d.add({$_category->getId()},-1,'".addslashes($this->getCurrentStore()->getName())."','".$this->getUrl("*/*/index")."catID/{$_category->getId()}');\n";
61
+ }else{
62
+ return "d.add({$_category->getId()},{$_category->getParentId()},'".addslashes($_category->getName())."','".$this->getUrl("*/*/index")."catID/{$_category->getId()}/store/{$this->getCurrentStore()->getId()}');\n";
63
+ }
64
+ }
65
+ public function getStoreHtml(){
66
+ $stores = Mage::app()->getStore()->getCollection();
67
+ $currentStoreId = $this->getCurrentStore()->getId();
68
+ $selected = '';
69
+ $html = '<form id="store_form" method="get" action =""><select name="store" id="store_view" onchange="document.getElementById(\'store_form\').submit()">';
70
+ foreach($stores as $_store){
71
+ if($_store->getId() == $currentStoreId){
72
+ $html .='<option value="'.$_store->getId().'" selected ="selected" >'.$_store->getName().'</option>';
73
+ }else{
74
+ $html .='<option value="'.$_store->getId().'" >'.$_store->getName().'</option>';
75
+ }
76
+
77
+ }
78
+ $html .='</select></form>';
79
+ return $html;
80
+
81
+ }
82
+ }
app/code/local/Magestore/Magesitemap/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Magesitemap_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Magestore/Magesitemap/Model/Direction.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Magesitemap_Model_Direction extends Mage_Core_Model_Abstract
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function toOptionArray()
9
+ {
10
+ $option = array(
11
+ 1 =>'Left to right',
12
+ 2 =>'Right to left',
13
+ );
14
+ return $option;
15
+ }
16
+ }
app/code/local/Magestore/Magesitemap/Model/Magesitemap.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Magesitemap_Model_Magesitemap extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('magesitemap/magesitemap');
9
+ }
10
+ }
app/code/local/Magestore/Magesitemap/Model/Mysql4/Magesitemap.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Magesitemap_Model_Mysql4_Magesitemap extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the magesitemap_id refers to the key field in your database table.
8
+ $this->_init('magesitemap/magesitemap', 'magesitemap_id');
9
+ }
10
+ }
app/code/local/Magestore/Magesitemap/Model/Mysql4/Magesitemap/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Magesitemap_Model_Mysql4_Magesitemap_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('magesitemap/magesitemap');
9
+ }
10
+ }
app/code/local/Magestore/Magesitemap/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Magesitemap_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('magesitemap')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('magesitemap')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Magestore/Magesitemap/controllers/Adminhtml/MagesitemapController.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Magesitemap_Adminhtml_MagesitemapController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('magesitemap/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Tag Manager'), Mage::helper('adminhtml')->__('Tag Manager'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+
19
+ public function editAction() {
20
+ $id = $this->getRequest()->getParam('id');
21
+ $model = Mage::getModel('magesitemap/magesitemap')->load($id);
22
+
23
+ if ($model->getId() || $id == 0) {
24
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
25
+ if (!empty($data)) {
26
+ $model->setData($data);
27
+ }
28
+
29
+ Mage::register('magesitemap_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('magesitemap/items');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
36
+
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('magesitemap/adminhtml_magesitemap_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('magesitemap/adminhtml_magesitemap_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magesitemap')->__('Item does not exist'));
45
+ $this->_redirect('*/*/');
46
+ }
47
+ }
48
+
49
+ public function newAction() {
50
+ $this->_forward('edit');
51
+ }
52
+
53
+ public function saveAction() {
54
+ if ($data = $this->getRequest()->getPost()) {
55
+
56
+ $model = Mage::getModel('magesitemap/magesitemap');
57
+
58
+ $model->setData($data)
59
+ ->setId($this->getRequest()->getParam('id'));
60
+ if($data['type_attribute'] !='attribute_product'){
61
+ if($data['type_attribute'] == 'static_value'){
62
+ $model->setStaticValue($data['static_value']);
63
+ $model->setAttributeCode($data['type_attribute']);
64
+ }else{
65
+ $model->setAttributeCode($data['type_attribute']);
66
+ }
67
+ }
68
+ try {
69
+
70
+ $model->save();
71
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('magesitemap')->__('Item was successfully saved'));
72
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
73
+
74
+ if ($this->getRequest()->getParam('back')) {
75
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
76
+ return;
77
+ }
78
+ $this->_redirect('*/*/');
79
+ return;
80
+ } catch (Exception $e) {
81
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
82
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
83
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
84
+ return;
85
+ }
86
+ }
87
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magesitemap')->__('Unable to find item to save'));
88
+ $this->_redirect('*/*/');
89
+ }
90
+
91
+ public function deleteAction() {
92
+ if( $this->getRequest()->getParam('id') > 0 ) {
93
+ try {
94
+ $model = Mage::getModel('magesitemap/magesitemap');
95
+
96
+ $model->setId($this->getRequest()->getParam('id'))
97
+ ->delete();
98
+
99
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
100
+ $this->_redirect('*/*/');
101
+ } catch (Exception $e) {
102
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
103
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
104
+ }
105
+ }
106
+ $this->_redirect('*/*/');
107
+ }
108
+
109
+ public function massDeleteAction() {
110
+ $magesitemapIds = $this->getRequest()->getParam('magesitemap');
111
+ if(!is_array($magesitemapIds)) {
112
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
113
+ } else {
114
+ try {
115
+ foreach ($magesitemapIds as $magesitemapId) {
116
+ $magesitemap = Mage::getModel('magesitemap/magesitemap')->load($magesitemapId);
117
+ $magesitemap->delete();
118
+ }
119
+ Mage::getSingleton('adminhtml/session')->addSuccess(
120
+ Mage::helper('adminhtml')->__(
121
+ 'Total of %d record(s) were successfully deleted', count($magesitemapIds)
122
+ )
123
+ );
124
+ } catch (Exception $e) {
125
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
126
+ }
127
+ }
128
+ $this->_redirect('*/*/index');
129
+ }
130
+
131
+ public function massStatusAction()
132
+ {
133
+ $magesitemapIds = $this->getRequest()->getParam('magesitemap');
134
+ if(!is_array($magesitemapIds)) {
135
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
136
+ } else {
137
+ try {
138
+ foreach ($magesitemapIds as $magesitemapId) {
139
+ $magesitemap = Mage::getSingleton('magesitemap/magesitemap')
140
+ ->load($magesitemapId)
141
+ ->setStatus($this->getRequest()->getParam('status'))
142
+ ->setIsMassupdate(true)
143
+ ->save();
144
+ }
145
+ $this->_getSession()->addSuccess(
146
+ $this->__('Total of %d record(s) were successfully updated', count($magesitemapIds))
147
+ );
148
+ } catch (Exception $e) {
149
+ $this->_getSession()->addError($e->getMessage());
150
+ }
151
+ }
152
+ $this->_redirect('*/*/index');
153
+ }
154
+
155
+ public function exportCsvAction()
156
+ {
157
+ $fileName = 'magesitemap.csv';
158
+ $content = $this->getLayout()->createBlock('magesitemap/adminhtml_magesitemap_grid')
159
+ ->getCsv();
160
+
161
+ $this->_sendUploadResponse($fileName, $content);
162
+ }
163
+
164
+ public function exportXmlAction()
165
+ {
166
+ $fileName = 'magesitemap.xml';
167
+ $content = $this->getLayout()->createBlock('magesitemap/adminhtml_magesitemap_grid')
168
+ ->getXml();
169
+
170
+ $this->_sendUploadResponse($fileName, $content);
171
+ }
172
+
173
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
174
+ {
175
+ $response = $this->getResponse();
176
+ $response->setHeader('HTTP/1.1 200 OK','');
177
+ $response->setHeader('Pragma', 'public', true);
178
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
179
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
180
+ $response->setHeader('Last-Modified', date('r'));
181
+ $response->setHeader('Accept-Ranges', 'bytes');
182
+ $response->setHeader('Content-Length', strlen($content));
183
+ $response->setHeader('Content-type', $contentType);
184
+ $response->setBody($content);
185
+ $response->sendResponse();
186
+ die;
187
+ }
188
+ /***************start create Controller Sitemap**********************/
189
+ protected function _initcreateAction() {
190
+ $this->loadLayout()
191
+ ->_setActiveMenu('magesitemap/create')
192
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Create Sitemap'), Mage::helper('adminhtml')->__('Create Sitemap'));
193
+
194
+ return $this;
195
+ }
196
+
197
+ public function createAction(){
198
+ $this->loadLayout();
199
+ $this->_addContent($this->getLayout()->createBlock('magesitemap/adminhtml_createsitemap'));
200
+ $this->renderLayout();
201
+
202
+ }
203
+
204
+ public function editsitemapAction() {
205
+ $id = $this->getRequest()->getParam('id');
206
+ $model = Mage::getModel('magesitemap/createsitemap')->load($id);
207
+
208
+ if ($model->getId() || $id == 0) {
209
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
210
+ if (!empty($data)) {
211
+ $model->setData($data);
212
+ }
213
+
214
+ Mage::register('createsitemap_data', $model);
215
+
216
+ $this->loadLayout();
217
+ $this->_setActiveMenu('magesitemap/create');
218
+
219
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Sitemap Manager'), Mage::helper('adminhtml')->__('Sitemap Manager'));
220
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Sitemap News'), Mage::helper('adminhtml')->__('Sitemap News'));
221
+
222
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
223
+
224
+ $this->_addContent($this->getLayout()->createBlock('magesitemap/adminhtml_createsitemap_edit'))
225
+ ->_addLeft($this->getLayout()->createBlock('magesitemap/adminhtml_createsitemap_edit_tabs'));
226
+
227
+ $this->renderLayout();
228
+ } else {
229
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magesitemap')->__('Item does not exist'));
230
+ $this->_redirect('*/*/');
231
+ }
232
+ }
233
+
234
+ public function newsitemapAction() {
235
+ $this->_forward('editsitemap');
236
+ }
237
+ }
app/code/local/Magestore/Magesitemap/controllers/IndexController.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Magesitemap_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction(){
5
+
6
+ $categoryId = $this->getRequest()->getParam('catID');
7
+
8
+ if($categoryId){
9
+ $sitemap = new Magestore_Magesitemap_Block_Magesitemap();
10
+ $sitemap->setCategory($categoryId);
11
+ $sitemap->exportXml();
12
+
13
+ }else{
14
+ $jsTree = new Magestore_Magesitemap_Block_Tree();
15
+ $jsTree->buildTree();
16
+
17
+ }
18
+
19
+ }
20
+ }
app/code/local/Magestore/Magesitemap/etc/config.xml ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magestore_Magesitemap>
5
+ <version>0.1.2</version>
6
+ </Magestore_Magesitemap>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <magesitemap>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Magestore_Magesitemap</module>
14
+ <frontName>magesitemap</frontName>
15
+ </args>
16
+ </magesitemap>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <magesitemap>
21
+ <file>magesitemap.xml</file>
22
+ </magesitemap>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <magesitemap>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Magestore_Magesitemap</module>
32
+ <frontName>magesitemap</frontName>
33
+ </args>
34
+ </magesitemap>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <menu>
39
+ <magesitemap module="magesitemap">
40
+ <title>Store Sitemap</title>
41
+ <sort_order>71</sort_order>
42
+ <children>
43
+ <items module="magesitemap">
44
+ <title>XML Mapping</title>
45
+ <sort_order>0</sort_order>
46
+ <action>magesitemap/adminhtml_magesitemap</action>
47
+ </items>
48
+ </children>
49
+ </magesitemap>
50
+ </menu>
51
+ <acl>
52
+ <resources>
53
+ <all>
54
+ <title>Allow Everything</title>
55
+ </all>
56
+ <admin>
57
+ <children>
58
+ <Magestore_Magesitemap>
59
+ <title>Magesitemap Module</title>
60
+ <sort_order>10</sort_order>
61
+ </Magestore_Magesitemap>
62
+ </children>
63
+ </admin>
64
+ </resources>
65
+ </acl>
66
+ <layout>
67
+ <updates>
68
+ <magesitemap>
69
+ <file>magesitemap.xml</file>
70
+ </magesitemap>
71
+ </updates>
72
+ </layout>
73
+ </adminhtml>
74
+ <global>
75
+ <models>
76
+ <magesitemap>
77
+ <class>Magestore_Magesitemap_Model</class>
78
+ <resourceModel>magesitemap_mysql4</resourceModel>
79
+ </magesitemap>
80
+ <magesitemap_mysql4>
81
+ <class>Magestore_Magesitemap_Model_Mysql4</class>
82
+ <entities>
83
+ <magesitemap>
84
+ <table>magesitemap</table>
85
+ </magesitemap>
86
+ <createsitemap>
87
+ <table>createsitemap</table>
88
+ </createsitemap>
89
+ </entities>
90
+ </magesitemap_mysql4>
91
+ </models>
92
+ <resources>
93
+ <magesitemap_setup>
94
+ <setup>
95
+ <module>Magestore_Magesitemap</module>
96
+ </setup>
97
+ <connection>
98
+ <use>core_setup</use>
99
+ </connection>
100
+ </magesitemap_setup>
101
+ <magesitemap_write>
102
+ <connection>
103
+ <use>core_write</use>
104
+ </connection>
105
+ </magesitemap_write>
106
+ <magesitemap_read>
107
+ <connection>
108
+ <use>core_read</use>
109
+ </connection>
110
+ </magesitemap_read>
111
+ </resources>
112
+ <blocks>
113
+ <magesitemap>
114
+ <class>Magestore_Magesitemap_Block</class>
115
+ </magesitemap>
116
+ </blocks>
117
+ <helpers>
118
+ <magesitemap>
119
+ <class>Magestore_Magesitemap_Helper</class>
120
+ </magesitemap>
121
+ </helpers>
122
+ </global>
123
+ </config>
app/code/local/Magestore/Magesitemap/etc/system.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <magestore translate="label">
5
+ <label>Magestore Extension</label>
6
+ <sort_order>400</sort_order>
7
+ </magestore>
8
+ </tabs>
9
+ <sections>
10
+ <xmlsitemap>
11
+ <class>separator-top</class>
12
+ <label>XML Sitemap</label>
13
+ <tab>magestore</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>300</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <general translate="label">
21
+ <label>Setting</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <direction translate="label">
29
+ <label>Direction Page</label>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>magesitemap/direction</source_model>
32
+ <sort_order>100</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>0</show_in_website>
35
+ <show_in_store>0</show_in_store>
36
+ </direction>
37
+ </fields>
38
+ </general>
39
+ </groups>
40
+ </xmlsitemap>
41
+ </sections>
42
+ </config>
app/code/local/Magestore/Magesitemap/sql/magesitemap_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('magesitemap')};
10
+ CREATE TABLE {$this->getTable('magesitemap')} (
11
+ `magesitemap_id` int(11) unsigned NOT NULL auto_increment,
12
+ `alias_name` varchar(255) NOT NULL default '',
13
+ `attribute_code` varchar(255) NOT NULL default '',
14
+ `status` smallint(6) NOT NULL default '0',
15
+ `sort_order` smallint(6) NOT NULL default '0',
16
+ PRIMARY KEY (`magesitemap_id`)
17
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
18
+
19
+ ");
20
+
21
+ $installer->endSetup();
app/code/local/Magestore/Magesitemap/sql/magesitemap_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+ $conn = $installer->_conn;
6
+ $conn->addColumn($this->getTable('magesitemap'), 'static_value', 'varchar(255) NOT NULL');
7
+ $installer->endSetup();
app/code/local/Magestore/Magesitemap/sql/magesitemap_setup/mysql4-upgrade-0.1.1-0.1.2.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('createsitemap')};
10
+ CREATE TABLE {$this->getTable('createsitemap')} (
11
+ `createsitemap_id` int(11) unsigned NOT NULL auto_increment,
12
+ `name` varchar(255) NOT NULL default '',
13
+ `description` varchar(255) NOT NULL default '',
14
+ `tag_ids` varchar(255) NOT NULL default '',
15
+ `status` smallint(6) NOT NULL default '0',
16
+ `sort_order` smallint(6) NOT NULL default '0',
17
+ PRIMARY KEY (`createsitemap_id`)
18
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
19
+
20
+ ");
21
+
22
+ $installer->endSetup();
app/etc/modules/Magestore_Magesitemap.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magestore_Magesitemap>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Magestore_Magesitemap>
8
+ </modules>
9
+ </config>
js/magestore/api.html ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+
3
+ <html>
4
+
5
+ <head>
6
+ <title>Destroydrop &raquo; Javascripts &raquo; Tree &raquo; Api</title>
7
+
8
+ <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
9
+ <link rel="stylesheet" href="/dd.css" type="text/css" />
10
+ <link rel="shortcut icon" href="/favicon.ico" />
11
+ </head>
12
+
13
+ <body>
14
+
15
+ <div id="shadow">
16
+
17
+ <div id="content">
18
+
19
+ <div id="location">
20
+ <h1><a href="/">Destroydrop</a> &raquo; <a href="/javascripts/">Javascripts</a> &raquo; <a href="/javascripts/tree/">Tree</a> &raquo; <a href="/javascripts/tree/api/">Api</a></h1>
21
+ </div>
22
+
23
+
24
+ <div class="line"></div>
25
+
26
+ <div id="files">
27
+
28
+
29
+ <h3>Overview</h3>
30
+ <div class="line"></div>
31
+ <div class="item">
32
+
33
+ <ul class="arrow">
34
+ <li><a href="#functions">Functions</a>
35
+ <ul class="arrow">
36
+ <li><a href="#add">add</a></li>
37
+ <li><a href="#openall">openAll</a></li>
38
+ <li><a href="#closeall">closeAll</a></li>
39
+ <li><a href="#opento">openTo</a></li>
40
+ </ul>
41
+ </li>
42
+ <li><a href="#configuration">Configuration</a></li>
43
+ </ul>
44
+
45
+ </div>
46
+
47
+ <a name="functions"></a>
48
+ <h3>Functions</h3>
49
+ <div class="line"></div>
50
+ <div class="item">
51
+
52
+ <a name="add"></a>
53
+ <h4 class="func">add()</h4>
54
+ <p>Adds a node to the tree.<br />Can only be called before the tree is drawn.</p>
55
+ <p>id, pid and name are required.</p>
56
+
57
+ <h4>Parameters</h4>
58
+ <table class="files">
59
+ <tr>
60
+ <th>Name</th>
61
+ <th>Type</th>
62
+ <th>Description</th>
63
+ </tr>
64
+ <tr>
65
+ <td>id</td>
66
+ <td>Number</td>
67
+ <td>Unique identity number.</td>
68
+ </tr>
69
+ <tr>
70
+ <td>pid</td>
71
+ <td>Number</td>
72
+ <td>Number refering to the parent node. The value for the root node has to be -1.</td>
73
+ </tr>
74
+ <tr>
75
+ <td>name</td>
76
+ <td>String</td>
77
+ <td>Text label for the node.</td>
78
+ </tr>
79
+ <tr>
80
+ <td>url</td>
81
+ <td>String</td>
82
+ <td>Url for the node.</td>
83
+ </tr>
84
+ <tr>
85
+ <td>title</td>
86
+ <td>String</td>
87
+ <td>Title for the node.</td>
88
+ </tr>
89
+ <tr>
90
+ <td>target</td>
91
+ <td>String</td>
92
+ <td>Target for the node.</td>
93
+ </tr>
94
+ <tr>
95
+ <td>icon</td>
96
+ <td>String</td>
97
+ <td>Image file to use as the icon. Uses default if not specified.</td>
98
+ </tr>
99
+ <tr>
100
+ <td>iconOpen</td>
101
+ <td>String</td>
102
+ <td>Image file to use as the open icon. Uses default if not specified.</td>
103
+ </tr>
104
+ <tr>
105
+ <td>open</td>
106
+ <td>Boolean</td>
107
+ <td>Is the node open.</td>
108
+ </tr>
109
+ </table>
110
+ <br />
111
+
112
+
113
+ <h4>Example</h4>
114
+ <p><code>mytree.add(1, 0, 'My node', 'node.html', 'node title', 'mainframe', 'img/musicfolder.gif');</code></p>
115
+ <br />
116
+
117
+ <a name="openall"></a>
118
+ <h4 class="func">openAll()</h4>
119
+ <p>Opens all the nodes.<br />Can be called before and after the tree is drawn.</p>
120
+ <h4>Example</h4>
121
+ <p><code>mytree.openAll();</code></p>
122
+ <br />
123
+
124
+
125
+ <a name="closeall"></a>
126
+ <h4 class="func">closeAll()</h4>
127
+ <p>Closes all the nodes.<br />Can be called before and after the tree is drawn.</p>
128
+ <h4>Example</h4>
129
+ <p><code>mytree.closeAll();</code></p>
130
+ <br />
131
+
132
+
133
+ <a name="opento"></a>
134
+ <h4 class="func">openTo()</h4>
135
+ <p>Opens the tree to a certain node and can also select the node.<br />
136
+ Can only be called after the tree is drawn.</p>
137
+
138
+ <h4>Parameters</h4>
139
+ <table class="files">
140
+ <tr>
141
+ <th>Name</th>
142
+ <th>Type</th>
143
+ <th>Description</th>
144
+ </tr>
145
+ <tr>
146
+ <td>id</td>
147
+ <td>Number</td>
148
+ <td>Identity number for the node.</td>
149
+ </tr>
150
+ <tr>
151
+ <td>select</td>
152
+ <td>Boolean</td>
153
+ <td>Should the node be selected.</td>
154
+ </tr>
155
+ </table>
156
+
157
+ <h4>Example</h4>
158
+ <p><code>mytree.openTo(4, true);</code></p>
159
+
160
+ </div>
161
+
162
+ <a name="configuration"></a>
163
+ <h3>Configuration</h3>
164
+ <div class="line"></div>
165
+ <div class="item">
166
+
167
+ <table class="files">
168
+ <tr>
169
+ <th>Variable</th>
170
+ <th>Type</th>
171
+ <th>Default</th>
172
+ <th>Description</th>
173
+ </tr>
174
+ <tr>
175
+ <td>target</td>
176
+ <td>String</td>
177
+ <td>true</td>
178
+ <td>Target for all the nodes.</td>
179
+ </tr>
180
+ <tr>
181
+ <td>folderLinks</td>
182
+ <td>Boolean</td>
183
+ <td>true</td>
184
+ <td>Should folders be links.</td>
185
+ </tr>
186
+ <tr>
187
+ <td>useSelection</td>
188
+ <td>Boolean</td>
189
+ <td>true</td>
190
+ <td>Nodes can be selected(highlighted).</td>
191
+ </tr>
192
+ <tr>
193
+ <td>useCookies</td>
194
+ <td>Boolean</td>
195
+ <td>true</td>
196
+ <td>The tree uses cookies to rember it's state.</td>
197
+ </tr>
198
+ <tr>
199
+ <td>useLines</td>
200
+ <td>Boolean</td>
201
+ <td>true</td>
202
+ <td>Tree is drawn with lines.</td>
203
+ </tr>
204
+ <tr>
205
+ <td>useIcons</td>
206
+ <td>Boolean</td>
207
+ <td>true</td>
208
+ <td>Tree is drawn with icons.</td>
209
+ </tr>
210
+ <tr>
211
+ <td>useStatusText</td>
212
+ <td>Boolean</td>
213
+ <td>false</td>
214
+ <td>Displays node names in the statusbar instead of the url.</td>
215
+ </tr>
216
+ <tr>
217
+ <td>closeSameLevel</td>
218
+ <td>Boolean</td>
219
+ <td>false</td>
220
+ <td>Only one node within a parent can be expanded at the same time. openAll() and closeAll() functions do not work when this is enabled.</td>
221
+ </tr>
222
+ <tr>
223
+ <td>inOrder</td>
224
+ <td>Boolean</td>
225
+ <td>false</td>
226
+ <td>If parent nodes are always added before children, setting this to true speeds up the tree.</td>
227
+ </tr>
228
+ </table>
229
+
230
+ <h4>Example</h4>
231
+ <p><code>mytree.config.target = "mytarget";</code></p>
232
+
233
+ </div>
234
+
235
+ </div>
236
+
237
+ <div class="line"></div>
238
+
239
+
240
+ <div id="copy">
241
+ <p class="right"><a href="http://validator.w3.org/check/referer">XHTML</a>, <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a></p>
242
+ <p><a href="mailto&#58;drop&#64;destroydrop&#46;com">&copy;2002-2003 Geir Landr&ouml;</a></p>
243
+ </div>
244
+
245
+ </div>
246
+
247
+ </div>
248
+
249
+
250
+ </body>
251
+
252
+ </html>
js/magestore/example01.html ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+
3
+ <html>
4
+
5
+ <head>
6
+ <title>Destroydrop &raquo; Javascripts &raquo; Tree</title>
7
+
8
+ <link rel="StyleSheet" href="tree.css" type="text/css" />
9
+ <script type="text/javascript" src="tree.js"></script>
10
+
11
+ </head>
12
+
13
+ <body>
14
+
15
+ <h1><a href="/">Destroydrop</a> &raquo; <a href="/javascripts/">Javascripts</a> &raquo; <a href="/javascripts/tree/">Tree</a></h1>
16
+
17
+ <h2>Example</h2>
18
+
19
+ <div class="dtree">
20
+
21
+ <p><a href="javascript: d.openAll();">open all</a> | <a href="javascript: d.closeAll();">close all</a></p>
22
+
23
+ <script type="text/javascript">
24
+ <!--
25
+
26
+ d = new dTree('d');
27
+
28
+ d.add(0,-1,'My example tree');
29
+ d.add(1,0,'Node 1','example01.html');
30
+ d.add(2,0,'Node 2','example01.html');
31
+ d.add(3,1,'Node 1.1','example01.html');
32
+ d.add(4,0,'Node 3','example01.html');
33
+ d.add(5,3,'Node 1.1.1','example01.html');
34
+ d.add(6,5,'Node 1.1.1.1','example01.html');
35
+ d.add(7,0,'Node 4','example01.html');
36
+ d.add(8,1,'Node 1.2','example01.html');
37
+ d.add(9,0,'My Pictures','example01.html','Pictures I\'ve taken over the years','','','img/imgfolder.gif');
38
+ d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir');
39
+ d.add(11,9,'Mom\'s birthday','example01.html');
40
+ d.add(12,0,'Recycle Bin','example01.html','','','img/trash.gif');
41
+
42
+ document.write(d);
43
+
44
+ //-->
45
+ </script>
46
+
47
+ </div>
48
+
49
+ <p><a href="mailto&#58;drop&#64;destroydrop&#46;com">&copy;2002-2003 Geir Landr&ouml;</a></p>
50
+
51
+ </body>
52
+
53
+ </html>
js/magestore/img/base.gif ADDED
Binary file
js/magestore/img/cd.gif ADDED
Binary file
js/magestore/img/empty.gif ADDED
Binary file
js/magestore/img/folder.gif ADDED
Binary file
js/magestore/img/folderopen.gif ADDED
Binary file
js/magestore/img/globe.gif ADDED
Binary file
js/magestore/img/imgfolder.gif ADDED
Binary file
js/magestore/img/join.gif ADDED
Binary file
js/magestore/img/joinbottom.gif ADDED
Binary file
js/magestore/img/line.gif ADDED
Binary file
js/magestore/img/minus.gif ADDED
Binary file
js/magestore/img/minusbottom.gif ADDED
Binary file
js/magestore/img/musicfolder.gif ADDED
Binary file
js/magestore/img/nolines_minus.gif ADDED
Binary file
js/magestore/img/nolines_plus.gif ADDED
Binary file
js/magestore/img/page.gif ADDED
Binary file
js/magestore/img/plus.gif ADDED
Binary file
js/magestore/img/plusbottom.gif ADDED
Binary file
js/magestore/img/question.gif ADDED
Binary file
js/magestore/img/trash.gif ADDED
Binary file
js/magestore/tree.css ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*--------------------------------------------------|
2
+ | dTree 2.05 | www.destroydrop.com/javascript/tree/ |
3
+ |---------------------------------------------------|
4
+ | Copyright (c) 2002-2003 Geir Landr� |
5
+ |--------------------------------------------------*/
6
+
7
+ .dtree {
8
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
9
+ font-size: 11px;
10
+ color: #666;
11
+ white-space: nowrap;
12
+ }
13
+ .dtree img {
14
+ border: 0px;
15
+ vertical-align: middle;
16
+ }
17
+ .dtree a {
18
+ color: #333;
19
+ text-decoration: none;
20
+ }
21
+ .dtree a.node, .dtree a.nodeSel {
22
+ white-space: nowrap;
23
+ padding: 1px 2px 1px 2px;
24
+ }
25
+ .dtree a.node:hover, .dtree a.nodeSel:hover {
26
+ color: #333;
27
+ text-decoration: underline;
28
+ }
29
+ .dtree a.nodeSel {
30
+ background-color: #c0d2ec;
31
+ }
32
+ .dtree .clip {
33
+ overflow: hidden;
34
+ }
js/magestore/tree.js ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*--------------------------------------------------|
2
+ | dTree 2.05 | www.destroydrop.com/javascript/tree/ |
3
+ |---------------------------------------------------|
4
+ | Copyright (c) 2002-2003 Geir Landr� |
5
+ | |
6
+ | This script can be used freely as long as all |
7
+ | copyright messages are intact. |
8
+ | |
9
+ | Updated: 17.04.2003 |
10
+ |--------------------------------------------------*/
11
+
12
+ // Node object
13
+ function Node(id, pid, name, url, title, target, icon, iconOpen, open) {
14
+ this.id = id;
15
+ this.pid = pid;
16
+ this.name = name;
17
+ this.url = url;
18
+ this.title = title;
19
+ this.target = target;
20
+ this.icon = icon;
21
+ this.iconOpen = iconOpen;
22
+ this._io = open || false;
23
+ this._is = false;
24
+ this._ls = false;
25
+ this._hc = false;
26
+ this._ai = 0;
27
+ this._p;
28
+ };
29
+
30
+ // Tree object
31
+ function dTree(objName) {
32
+ this.config = {
33
+ target : null,
34
+ folderLinks : true,
35
+ useSelection : true,
36
+ useCookies : true,
37
+ useLines : true,
38
+ useIcons : true,
39
+ useStatusText : false,
40
+ closeSameLevel : false,
41
+ inOrder : false
42
+ };
43
+ this.icon = {
44
+ root : baseUrl + 'img/base.gif',
45
+ folder : baseUrl + 'img/folder.gif',
46
+ folderOpen : baseUrl + 'img/folderopen.gif',
47
+ node : baseUrl + 'img/page.gif',
48
+ empty : baseUrl + 'img/empty.gif',
49
+ line : baseUrl + 'img/line.gif',
50
+ join : baseUrl + 'img/join.gif',
51
+ joinBottom : baseUrl + 'img/joinbottom.gif',
52
+ plus : baseUrl + 'img/plus.gif',
53
+ plusBottom : baseUrl + 'img/plusbottom.gif',
54
+ minus : baseUrl + 'img/minus.gif',
55
+ minusBottom : baseUrl + 'img/minusbottom.gif',
56
+ nlPlus : baseUrl + 'img/nolines_plus.gif',
57
+ nlMinus : baseUrl + 'img/nolines_minus.gif'
58
+ };
59
+ this.obj = objName;
60
+ this.aNodes = [];
61
+ this.aIndent = [];
62
+ this.root = new Node(-1);
63
+ this.selectedNode = null;
64
+ this.selectedFound = false;
65
+ this.completed = false;
66
+ };
67
+
68
+ // Adds a new node to the node array
69
+ dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {
70
+ this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);
71
+ };
72
+
73
+ // Open/close all nodes
74
+ dTree.prototype.openAll = function() {
75
+ this.oAll(true);
76
+ };
77
+ dTree.prototype.closeAll = function() {
78
+ this.oAll(false);
79
+ };
80
+
81
+ // Outputs the tree to the page
82
+ dTree.prototype.toString = function() {
83
+ var str = '<div class="dtree">\n';
84
+ if (document.getElementById) {
85
+ if (this.config.useCookies) this.selectedNode = this.getSelected();
86
+ str += this.addNode(this.root);
87
+ } else str += 'Browser not supported.';
88
+ str += '</div>';
89
+ if (!this.selectedFound) this.selectedNode = null;
90
+ this.completed = true;
91
+ return str;
92
+ };
93
+
94
+ // Creates the tree structure
95
+ dTree.prototype.addNode = function(pNode) {
96
+ var str = '';
97
+ var n=0;
98
+ if (this.config.inOrder) n = pNode._ai;
99
+ for (n; n<this.aNodes.length; n++) {
100
+ if (this.aNodes[n].pid == pNode.id) {
101
+ var cn = this.aNodes[n];
102
+ cn._p = pNode;
103
+ cn._ai = n;
104
+ this.setCS(cn);
105
+ if (!cn.target && this.config.target) cn.target = this.config.target;
106
+ if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
107
+ if (!this.config.folderLinks && cn._hc) cn.url = null;
108
+ if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
109
+ cn._is = true;
110
+ this.selectedNode = n;
111
+ this.selectedFound = true;
112
+ }
113
+ str += this.node(cn, n);
114
+ if (cn._ls) break;
115
+ }
116
+ }
117
+ return str;
118
+ };
119
+
120
+ // Creates the node icon, url and text
121
+ dTree.prototype.node = function(node, nodeId) {
122
+ var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
123
+ if (this.config.useIcons) {
124
+ if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
125
+ if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
126
+ if (this.root.id == node.pid) {
127
+ node.icon = this.icon.root;
128
+ node.iconOpen = this.icon.root;
129
+ }
130
+ str += '<img id="i' + this.obj + nodeId + '" src="'+ this.baseUrl + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
131
+ }
132
+ if (node.url) {
133
+ str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
134
+ if (node.title) str += ' title="' + node.title + '"';
135
+ if (node.target) str += ' target="' + node.target + '"';
136
+ if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
137
+ if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
138
+ str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
139
+ str += '>';
140
+ }
141
+ else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
142
+ str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
143
+ str += node.name;
144
+ if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
145
+ str += '</div>';
146
+ if (node._hc) {
147
+ str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
148
+ str += this.addNode(node);
149
+ str += '</div>';
150
+ }
151
+ this.aIndent.pop();
152
+ return str;
153
+ };
154
+
155
+ // Adds the empty and line icons
156
+ dTree.prototype.indent = function(node, nodeId) {
157
+ var str = '';
158
+ if (this.root.id != node.pid) {
159
+ for (var n=0; n<this.aIndent.length; n++)
160
+ str += '<img src="'+this.baseUrl + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';
161
+ (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
162
+ if (node._hc) {
163
+ str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="'+this.baseUrl;
164
+ if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
165
+ else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
166
+ str += '" alt="" /></a>';
167
+ } else str += '<img src="'+this.baseUrl + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';
168
+ }
169
+ return str;
170
+ };
171
+
172
+ // Checks if a node has any children and if it is the last sibling
173
+ dTree.prototype.setCS = function(node) {
174
+ var lastId;
175
+ for (var n=0; n<this.aNodes.length; n++) {
176
+ if (this.aNodes[n].pid == node.id) node._hc = true;
177
+ if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
178
+ }
179
+ if (lastId==node.id) node._ls = true;
180
+ };
181
+
182
+ // Returns the selected node
183
+ dTree.prototype.getSelected = function() {
184
+ var sn = this.getCookie('cs' + this.obj);
185
+ return (sn) ? sn : null;
186
+ };
187
+
188
+ // Highlights the selected node
189
+ dTree.prototype.s = function(id) {
190
+ if (!this.config.useSelection) return;
191
+ var cn = this.aNodes[id];
192
+ if (cn._hc && !this.config.folderLinks) return;
193
+ if (this.selectedNode != id) {
194
+ if (this.selectedNode || this.selectedNode==0) {
195
+ eOld = document.getElementById("s" + this.obj + this.selectedNode);
196
+ eOld.className = "node";
197
+ }
198
+ eNew = document.getElementById("s" + this.obj + id);
199
+ eNew.className = "nodeSel";
200
+ this.selectedNode = id;
201
+ if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
202
+ }
203
+ };
204
+
205
+ // Toggle Open or close
206
+ dTree.prototype.o = function(id) {
207
+ var cn = this.aNodes[id];
208
+ this.nodeStatus(!cn._io, id, cn._ls);
209
+ cn._io = !cn._io;
210
+ if (this.config.closeSameLevel) this.closeLevel(cn);
211
+ if (this.config.useCookies) this.updateCookie();
212
+ };
213
+
214
+ // Open or close all nodes
215
+ dTree.prototype.oAll = function(status) {
216
+ for (var n=0; n<this.aNodes.length; n++) {
217
+ if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
218
+ this.nodeStatus(status, n, this.aNodes[n]._ls)
219
+ this.aNodes[n]._io = status;
220
+ }
221
+ }
222
+ if (this.config.useCookies) this.updateCookie();
223
+ };
224
+
225
+ // Opens the tree to a specific node
226
+ dTree.prototype.openTo = function(nId, bSelect, bFirst) {
227
+ if (!bFirst) {
228
+ for (var n=0; n<this.aNodes.length; n++) {
229
+ if (this.aNodes[n].id == nId) {
230
+ nId=n;
231
+ break;
232
+ }
233
+ }
234
+ }
235
+ var cn=this.aNodes[nId];
236
+ if (cn.pid==this.root.id || !cn._p) return;
237
+ cn._io = true;
238
+ cn._is = bSelect;
239
+ if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
240
+ if (this.completed && bSelect) this.s(cn._ai);
241
+ else if (bSelect) this._sn=cn._ai;
242
+ this.openTo(cn._p._ai, false, true);
243
+ };
244
+
245
+ // Closes all nodes on the same level as certain node
246
+ dTree.prototype.closeLevel = function(node) {
247
+ for (var n=0; n<this.aNodes.length; n++) {
248
+ if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
249
+ this.nodeStatus(false, n, this.aNodes[n]._ls);
250
+ this.aNodes[n]._io = false;
251
+ this.closeAllChildren(this.aNodes[n]);
252
+ }
253
+ }
254
+ }
255
+
256
+ // Closes all children of a node
257
+ dTree.prototype.closeAllChildren = function(node) {
258
+ for (var n=0; n<this.aNodes.length; n++) {
259
+ if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
260
+ if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
261
+ this.aNodes[n]._io = false;
262
+ this.closeAllChildren(this.aNodes[n]);
263
+ }
264
+ }
265
+ }
266
+
267
+ // Change the status of a node(open or closed)
268
+ dTree.prototype.nodeStatus = function(status, id, bottom) {
269
+ eDiv = document.getElementById('d' + this.obj + id);
270
+ eJoin = document.getElementById('j' + this.obj + id);
271
+ if (this.config.useIcons) {
272
+ eIcon = document.getElementById('i' + this.obj + id);
273
+ eIcon.src = this.baseUrl + (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
274
+ }
275
+ eJoin.src = this.baseUrl + (this.config.useLines)?
276
+ ((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
277
+ ((status)?this.icon.nlMinus:this.icon.nlPlus);
278
+ eDiv.style.display = (status) ? 'block': 'none';
279
+ };
280
+
281
+
282
+ // [Cookie] Clears a cookie
283
+ dTree.prototype.clearCookie = function() {
284
+ var now = new Date();
285
+ var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
286
+ this.setCookie('co'+this.obj, 'cookieValue', yesterday);
287
+ this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
288
+ };
289
+
290
+ // [Cookie] Sets value in a cookie
291
+ dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
292
+ document.cookie =
293
+ escape(cookieName) + '=' + escape(cookieValue)
294
+ + (expires ? '; expires=' + expires.toGMTString() : '')
295
+ + (path ? '; path=' + path : '')
296
+ + (domain ? '; domain=' + domain : '')
297
+ + (secure ? '; secure' : '');
298
+ };
299
+
300
+ // [Cookie] Gets a value from a cookie
301
+ dTree.prototype.getCookie = function(cookieName) {
302
+ var cookieValue = '';
303
+ var posName = document.cookie.indexOf(escape(cookieName) + '=');
304
+ if (posName != -1) {
305
+ var posValue = posName + (escape(cookieName) + '=').length;
306
+ var endPos = document.cookie.indexOf(';', posValue);
307
+ if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
308
+ else cookieValue = unescape(document.cookie.substring(posValue));
309
+ }
310
+ return (cookieValue);
311
+ };
312
+
313
+ // [Cookie] Returns ids of open nodes as a string
314
+ dTree.prototype.updateCookie = function() {
315
+ var str = '';
316
+ for (var n=0; n<this.aNodes.length; n++) {
317
+ if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
318
+ if (str) str += '.';
319
+ str += this.aNodes[n].id;
320
+ }
321
+ }
322
+ this.setCookie('co' + this.obj, str);
323
+ };
324
+
325
+ // [Cookie] Checks if a node id is in a cookie
326
+ dTree.prototype.isOpen = function(id) {
327
+ var aOpen = this.getCookie('co' + this.obj).split('.');
328
+ for (var n=0; n<aOpen.length; n++)
329
+ if (aOpen[n] == id) return true;
330
+ return false;
331
+ };
332
+
333
+ // If Push and pop is not implemented by the browser
334
+ if (!Array.prototype.push) {
335
+ Array.prototype.push = function array_push() {
336
+ for(var i=0;i<arguments.length;i++)
337
+ this[this.length]=arguments[i];
338
+ return this.length;
339
+ }
340
+ };
341
+ if (!Array.prototype.pop) {
342
+ Array.prototype.pop = function array_pop() {
343
+ lastElement = this[this.length-1];
344
+ this.length = Math.max(this.length-1,0);
345
+ return lastElement;
346
+ }
347
+ };
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Magesitemap</name>
4
+ <version>1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">Extension license name (OSL v3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Create XML sitemap for magento store</summary>
10
+ <description>The major function of this extension is to export information of the products in the category with XML file format. In the admin module, you can add XMLTag with attributes to display XML file. These attributes are managed in admin module.</description>
11
+ <notes>Free Version</notes>
12
+ <authors><author><name>Magestore</name><user>auto-converted</user><email>magestore@gmail.com</email></author></authors>
13
+ <date>2010-04-13</date>
14
+ <time>10:35:36</time>
15
+ <contents><target name="mageweb"><dir name="js"><dir name="magestore"><file name="api.html" hash="9981598a3df339056814f5997216573b"/><file name="example01.html" hash="fcdb2be6af73dd5237794c189fa649cf"/><file name="tree.css" hash="1e861c5a4d2d49ccfbfc1a5aaa87e0dd"/><file name="tree.js" hash="db1420dd1f2c78d37974dbacde8c06a7"/><dir name="img"><file name="base.gif" hash="1f71b021e061a4948d69adc4ff10ccad"/><file name="cd.gif" hash="f41037663522fab5c5c31530c7fa43d8"/><file name="empty.gif" hash="df22aff6e941ff1cc577333d1712b584"/><file name="folder.gif" hash="ea16980ab437fa6ba4aba3d480e83e9e"/><file name="folderopen.gif" hash="18aa3d75315bf95bf080357733437fcc"/><file name="globe.gif" hash="d6b48614cf8dc9553e077c19197637d2"/><file name="imgfolder.gif" hash="1d488d377762e65ab4e8b691ba01e5a4"/><file name="join.gif" hash="4d5d614e0da056df815a4306d6368692"/><file name="joinbottom.gif" hash="4b3daa7f2cc584f1aac0d142275d7cba"/><file name="line.gif" hash="63ab38a6203262f15ca46c631232ea2c"/><file name="minus.gif" hash="d647fbbd0ec410b8f3bb3357b62eedcf"/><file name="minusbottom.gif" hash="b09d684cca7135ef728141aaf2464baa"/><file name="musicfolder.gif" hash="21ece951734f23adb2f75befe1f31fc1"/><file name="nolines_minus.gif" hash="eb2243a354ffcfac93ba0fe948f7167d"/><file name="nolines_plus.gif" hash="ec92b634b63608fb4b0dbf114e3b89e1"/><file name="page.gif" hash="c25b136c1cb3bb145495c25b35d93754"/><file name="plus.gif" hash="5c55d798909c553deca31d610bd18fac"/><file name="plusbottom.gif" hash="1924ce363c38a992f888a4df48c0b274"/><file name="question.gif" hash="ea0ca196ce0ebfd625cc1210abfdec6c"/><file name="trash.gif" hash="6cbfd3ed29531044aed9b4edb3cca9ad"/></dir></dir></dir></target><target name="magelocal"><dir name="Magestore"><dir name="Magesitemap"><dir name="Block"><file name="Magesitemap.php" hash="fc1289df526d29eabd1bfa6e0da4bd4e"/><file name="Tree.php" hash="ada4bb58517eb49da6bfadfc5747945c"/><dir name="Adminhtml"><file name="Magesitemap.php" hash="9f926857355e9fa3b7160f9dc4b2e4ee"/><dir name="Magesitemap"><file name="Edit.php" hash="d332d1342d686111cbeebba4a3c5b404"/><file name="Grid.php" hash="b30c2113fc230a3d53b3c6bad708aea8"/><dir name="Edit"><file name="Form.php" hash="2391055251983c40b8f28dcda3fe8295"/><file name="Tabs.php" hash="5899ce4f2520408ce880aa5a0fd94db2"/><dir name="Tab"><file name="Form.php" hash="c5c8e7401fcd7f45b7091388d1e35def"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="18c78c35420963a7bc6c951522d65fbe"/><dir name="Adminhtml"><file name="MagesitemapController.php" hash="9e53444d998635b6b500268691986cdb"/></dir></dir><dir name="etc"><file name="config.xml" hash="f2c4d3025d0fa703028717a3e45c1417"/><file name="system.xml" hash="98491d326b9a394fc0299fe338bbe68a"/></dir><dir name="Helper"><file name="Data.php" hash="be1bd6d50f0c20460b496a81a5237f0c"/></dir><dir name="Model"><file name="Direction.php" hash="243925ce6a9fab41bc01d72f83769a7b"/><file name="Magesitemap.php" hash="7c3da5f14b4351a710556f14e7b5490c"/><file name="Status.php" hash="5fc0f529a67b679a18ed4ba21a8d7083"/><dir name="Mysql4"><file name="Magesitemap.php" hash="7a151e361adaf11415a7cd652e7e835c"/><dir name="Magesitemap"><file name="Collection.php" hash="a1a55b8c2645248ae540b0de0086c27a"/></dir></dir></dir><dir name="sql"><dir name="magesitemap_setup"><file name="mysql4-install-0.1.0.php" hash="02bdc0c319d33fd794445b1ab4bfb9a2"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="dee280a0d7c33729f12da2d6042b3983"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="3fe155c1bb1df2d144da9ea4ded7968b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magestore_Magesitemap.xml" hash="c02d72c95a18e605391d5d4000123196"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>