-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathextension.driver.php
More file actions
executable file
·109 lines (89 loc) · 3.66 KB
/
extension.driver.php
File metadata and controls
executable file
·109 lines (89 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
Class extension_sitemap_xml extends Extension{
public function fetchNavigation() {
return array(
array(
'location' => __('System'),
'name' => __('Sitemap XML'),
'link' => '/xml/',
),
);
}
public function getSubscribedDelegates() {
return array(
array(
'page' => '/system/preferences/',
'delegate' => 'AddCustomPreferenceFieldsets',
'callback' => 'appendPreferences'
),
array(
'page' => '/backend/',
'delegate' => 'InitaliseAdminPageHead',
'callback' => 'appendPageHead'
)
);
}
public function install() {
// Add defaults to config.php
if (!Symphony::Configuration()->get('index_type', 'sitemap_xml')) {
Symphony::Configuration()->set('index_type', 'index', 'sitemap_xml');
Symphony::Configuration()->set('global', 'sitemap', 'sitemap_xml');
Symphony::Configuration()->set('changefreq', 'monthly', 'sitemap_xml');
Symphony::Configuration()->write();
}
// Add table to database
Symphony::Database()->query('
CREATE TABLE IF NOT EXISTS tbl_sitemap_xml (
`id` INT(11) unsigned NOT NULL auto_increment,
`page_id` INT(4) unsigned DEFAULT NULL,
`datasource_handle` varchar(255) DEFAULT NULL,
`relative_url` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY datasource_handle_page_id_relative_url (`datasource_handle`(75), `page_id`, `relative_url`(75))
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
');
// Autogenerate a blank sitemap.xml
General::writeFile(getcwd() . '/sitemap.xml', '');
return true;
}
public function uninstall() {
Symphony::Configuration()->remove('sitemap_xml');
Symphony::Database()->query('DROP TABLE IF EXISTS tbl_sitemap_xml');
return Symphony::Configuration()->write();
}
public function appendPageHead($context) {
$callback = Administration::instance()->getPageCallback();
if($callback['driver'] == 'xml') {
Administration::instance()->Page->addScriptToHead(URL . '/extensions/sitemap_xml/assets/sitemap_xml.publish.js', 10001);
Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/sitemap_xml/assets/sitemap_xml.publish.css', 'screen');
}
}
public function appendPreferences($context) {
$sitemap_entries = Symphony::Database()->fetch("SELECT * FROM `tbl_sitemap_xml`");
/*@group Fieldset containing config settings*/
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', __('Sitemap XML')));
$context['wrapper']->appendChild($fieldset);
/* column 1*/
$column = new XMLElement('div');
$column->setAttribute('class', 'two columns');
$label = Widget::Label(__('Home page type'));
$label->setAttribute('class', 'column');
$label->appendChild(Widget::Input('settings[sitemap_xml][index_type]', General::Sanitize(Symphony::Configuration()->get('index_type', 'sitemap_xml'))));
$column->appendChild($label);
$label = Widget::Label(__('Global page type'));
$label->setAttribute('class', 'column');
$label->appendChild(Widget::Input('settings[sitemap_xml][global]',General::Sanitize(Symphony::Configuration()->get('global', 'sitemap_xml'))));
$column->appendChild($label);
$fieldset->appendChild($column);
/* column 2*/
$column = new XMLElement('div');
$label = Widget::Label(__('Change frequency of XML'));
$label->appendChild(Widget::Input('settings[sitemap_xml][changefreq]',General::Sanitize(Symphony::Configuration()->get('changefreq', 'sitemap_xml'))));
$column->appendChild($label);
$fieldset->appendChild($column);
/*@column end*/
}
}
?>