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
- app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap.php +12 -0
- app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Edit.php +76 -0
- app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Edit/Form.php +19 -0
- app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Edit/Tab/Form.php +84 -0
- app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Edit/Tabs.php +24 -0
- app/code/local/Magestore/Magesitemap/Block/Adminhtml/Magesitemap/Grid.php +115 -0
- app/code/local/Magestore/Magesitemap/Block/Magesitemap.php +170 -0
- app/code/local/Magestore/Magesitemap/Block/Tree.php +82 -0
- app/code/local/Magestore/Magesitemap/Helper/Data.php +6 -0
- app/code/local/Magestore/Magesitemap/Model/Direction.php +16 -0
- app/code/local/Magestore/Magesitemap/Model/Magesitemap.php +10 -0
- app/code/local/Magestore/Magesitemap/Model/Mysql4/Magesitemap.php +10 -0
- app/code/local/Magestore/Magesitemap/Model/Mysql4/Magesitemap/Collection.php +10 -0
- app/code/local/Magestore/Magesitemap/Model/Status.php +15 -0
- app/code/local/Magestore/Magesitemap/controllers/Adminhtml/MagesitemapController.php +237 -0
- app/code/local/Magestore/Magesitemap/controllers/IndexController.php +20 -0
- app/code/local/Magestore/Magesitemap/etc/config.xml +123 -0
- app/code/local/Magestore/Magesitemap/etc/system.xml +42 -0
- app/code/local/Magestore/Magesitemap/sql/magesitemap_setup/mysql4-install-0.1.0.php +21 -0
- app/code/local/Magestore/Magesitemap/sql/magesitemap_setup/mysql4-upgrade-0.1.0-0.1.1.php +7 -0
- app/code/local/Magestore/Magesitemap/sql/magesitemap_setup/mysql4-upgrade-0.1.1-0.1.2.php +22 -0
- app/etc/modules/Magestore_Magesitemap.xml +9 -0
- js/magestore/api.html +252 -0
- js/magestore/example01.html +53 -0
- js/magestore/img/base.gif +0 -0
- js/magestore/img/cd.gif +0 -0
- js/magestore/img/empty.gif +0 -0
- js/magestore/img/folder.gif +0 -0
- js/magestore/img/folderopen.gif +0 -0
- js/magestore/img/globe.gif +0 -0
- js/magestore/img/imgfolder.gif +0 -0
- js/magestore/img/join.gif +0 -0
- js/magestore/img/joinbottom.gif +0 -0
- js/magestore/img/line.gif +0 -0
- js/magestore/img/minus.gif +0 -0
- js/magestore/img/minusbottom.gif +0 -0
- js/magestore/img/musicfolder.gif +0 -0
- js/magestore/img/nolines_minus.gif +0 -0
- js/magestore/img/nolines_plus.gif +0 -0
- js/magestore/img/page.gif +0 -0
- js/magestore/img/plus.gif +0 -0
- js/magestore/img/plusbottom.gif +0 -0
- js/magestore/img/question.gif +0 -0
- js/magestore/img/trash.gif +0 -0
- js/magestore/tree.css +34 -0
- js/magestore/tree.js +347 -0
- 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 » Javascripts » Tree » 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> » <a href="/javascripts/">Javascripts</a> » <a href="/javascripts/tree/">Tree</a> » <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 |