11
11
*
12
12
*/
13
13
function easy_xmlsitemap_settings_form () {
14
-
15
- $ config = config ('easy_xmlsitemap.settings ' );
14
+ $ config = config ('easy_xmlsitemap.settings ' );
16
15
$ last_build_date = $ config ->get ('last_build_date ' );
17
16
18
17
$ info = $ last_build_date != 0
19
- ? t ('Sitemap file last build time: ' ) . format_date ($ last_build_date , 'short ' )
20
- : t ('Sitemap file has not built yet. ' );
18
+ ? t ('Sitemap last build time: ' ) . format_date ($ last_build_date , 'short ' )
19
+ : t ('Sitemap has not built yet. ' );
21
20
21
+ $ site_langs = language_list (TRUE , TRUE );
22
+
22
23
$ form = array ();
23
24
24
25
$ form ['build_info ' ] = array (
25
26
'#type ' => 'fieldset ' ,
26
27
'#title ' => t ('Sitemap build ' ),
27
28
'#collapsible ' => TRUE ,
28
29
'#collapsed ' => FALSE ,
29
- );
30
+ );
30
31
31
32
$ form ['build_info ' ]['info ' ] = array (
32
33
'#markup ' => '<p> ' . $ info . '</p> ' ,
33
34
);
34
- $ form ['build_info ' ]['actions ' ] = array ('#type ' => 'actions ' );
35
- $ form ['build_info ' ]['actions ' ]['build ' ] = array (
35
+ $ form ['build_info ' ]['build ' ] = array (
36
36
'#type ' => 'submit ' ,
37
37
'#value ' => t ('Build sitemap now ' ),
38
+ '#attributes ' => array (
39
+ 'class ' => array ('button-primary ' ),
40
+ ),
38
41
);
39
42
$ form ['build_info ' ]['actions ' ]['info ' ] = array (
40
- '#markup ' => '<div class="description"> ' . t ('This will rebuild XML sitemap. ' ) . '</div> ' ,
43
+ '#markup ' => '<div class="description"> ' . t ('This will rebuild sitemap immediately . ' ) . '</div> ' ,
41
44
);
42
45
43
46
$ form ['settings ' ] = array (
44
47
'#type ' => 'fieldset ' ,
45
- '#title ' => t ('Settings ' ),
48
+ '#title ' => t ('Advanced settings ' ),
46
49
'#collapsible ' => TRUE ,
47
50
'#collapsed ' => TRUE ,
48
51
);
49
52
50
53
$ form ['settings ' ]['base_url ' ] = array (
51
54
'#type ' => 'textfield ' ,
52
- '#title ' => t ('Default base URL ' ),
55
+ '#title ' => t ('Default base URL (optional) ' ),
53
56
'#default_value ' => $ config ->get ('base_url ' ),
54
- '#description ' => t ('Optional default base URL used for sitemaps and sitemap links, for example: http://example.com, can be left empty. ' ),
57
+ '#description ' => t ('Optional replacement for base URL, should be used instead of actual domain for sitemap links, for example: http://example.com. In most cases can be left empty. ' ),
55
58
);
56
59
$ form ['settings ' ]['rebuild_frequency ' ] = array (
57
60
'#type ' => 'select ' ,
@@ -68,37 +71,45 @@ function easy_xmlsitemap_settings_form() {
68
71
'#type ' => 'textarea ' ,
69
72
'#title ' => t ('Excluded URLs list (optional) ' ),
70
73
'#default_value ' => $ config ->get ('excluded_urls ' ),
71
- '#description ' => t ('If some URLs should be excluded from sitemap, place these URLs here, one URL per line without domain, for example: ' )
74
+ '#description ' => t ('If some URLs should be excluded from sitemap, place these URLs here, one URL per line without domain, see an example below : ' )
72
75
. '<br />403.html '
73
76
. '<br />404.html '
74
77
. '<br />node/123 '
75
78
. '<br />some-test-page.html '
76
79
);
77
-
78
- $ form ['settings ' ]['actions ' ] = array ('#type ' => 'actions ' );
79
- $ form ['settings ' ]['actions ' ]['submit ' ] = array (
80
+ if (count ($ site_langs ) > 1 ) {
81
+ $ form ['settings ' ]['excluded_langs ' ] = array (
82
+ '#type ' => 'checkboxes ' ,
83
+ '#title ' => t ('Exclude from sitemap all pages for selected language (optional): ' ),
84
+ '#options ' => $ site_langs ,
85
+ '#default_value ' => $ config ->get ('excluded_langs ' ),
86
+ '#description ' => t ('In some cases you might want do not include to sitemap links to pages for specific language. ' ),
87
+ );
88
+ }
89
+ $ form ['settings ' ]['submit ' ] = array (
80
90
'#type ' => 'submit ' ,
81
91
'#value ' => t ('Save settings ' ),
92
+ '#attributes ' => array (
93
+ 'class ' => array ('button-primary ' ),
94
+ ),
82
95
);
83
96
84
97
return $ form ;
85
-
86
98
}
87
99
88
100
/**
89
101
* Submit actions for form
90
102
*
91
103
*/
92
104
function easy_xmlsitemap_settings_form_submit ($ form , &$ form_state ) {
93
-
94
105
global $ user ;
95
106
$ config = config ('easy_xmlsitemap.settings ' );
96
107
97
108
if ($ form_state ['clicked_button ' ]['#id ' ] == 'edit-submit ' ) {
98
-
99
109
$ config ->set ('base_url ' , trim ($ form_state ['values ' ]['base_url ' ]));
100
110
$ config ->set ('rebuild_frequency ' , $ form_state ['values ' ]['rebuild_frequency ' ]);
101
111
$ config ->set ('excluded_urls ' , trim ($ form_state ['values ' ]['excluded_urls ' ]));
112
+ $ config ->set ('excluded_langs ' , $ form_state ['values ' ]['excluded_langs ' ]);
102
113
103
114
$ config ->save ();
104
115
watchdog ('easy_xmlsitemap ' , t ('Settings changed by @user. ' , array ('@user ' => $ user ->name )));
@@ -108,4 +119,3 @@ function easy_xmlsitemap_settings_form_submit($form, &$form_state) {
108
119
easy_xmlsitemap_build ();
109
120
}
110
121
}
111
-
0 commit comments