-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmps.admin.inc
174 lines (157 loc) · 6.28 KB
/
mps.admin.inc
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
/**
* @file
* Admin settings pages for MPS
*/
/**
* MPS administrative settings form.
*/
function mps_admin_settings() {
$form['mps_base_url'] = array(
'#type' => 'textfield',
'#title' => t('Base URL'),
'#description' => t('Enter in form of a qualified domain, including a trailing slash. Eg: http://mps.ivillage.com/'),
'#default_value' => variable_get('mps_base_url', MPS_DEFAULT_BASE_URL),
'#required' => TRUE,
);
$form['mps_exclude_paths'] = array(
'#type' => 'textarea',
'#title' => t('Pages to exclude from MPS processing'),
'#description' => t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
'%blog' => 'blog',
'%blog-wildcard' => 'blog/*',
'%front' => '<front>',
)),
'#default_value' => variable_get('mps_exclude_paths', MPS_DEFAULT_EXCLUDE_PATHS),
);
$form['mps_mapping_defaults'] = array(
'#type' => 'fieldset',
'#title' => t('Mappings'),
'#description' => t('Specify token rewrites. Note that a call to hook_mps_request_alter() is made for each request, and this can be utilized for fine control on how these values are sent.'),
'#tree' => TRUE,
);
// The only required fields: site and path.
$form['mps_mapping_defaults']['site'] = array(
'#type' => 'textfield',
'#title' => 'Site ID [site]',
'#description' => 'Example: ' . MPS_DEFAULT_SITE_ID,
'#default_value' => mps_get_mapping_default('site', MPS_DEFAULT_SITE_ID),
'#required' => TRUE,
);
$form['mps_mapping_defaults']['path'] = array(
'#type' => 'textfield',
'#title' => 'Path [path]',
'#description' => t('Full path. Must begin with a slash. Do not include query parameters.'),
'#default_value' => mps_get_mapping_default('path', '/[url:path]'),
'#required' => TRUE,
);
// Taxonomy:
$form['mps_mapping_defaults']['cat'] = array(
'#type' => 'textfield',
'#title' => 'Category [cat]',
'#description' => t("Primary category within which content resides. Example, 'entertainment'. Multiple values are delimited by the '|' character."),
'#default_value' => mps_get_mapping_default('cat'),
);
$form['mps_mapping_defaults']['pkgid'] = array(
'#type' => 'textfield',
'#title' => 'Package ID [pkgid]',
'#description' => t('Deprecated: The CMS defined package id of what this content belongs to. Analogue of [cat].'),
'#default_value' => mps_get_mapping_default('pkgid'),
);
// Content type:
$form['mps_mapping_defaults']['content_id'] = array(
'#type' => 'textfield',
'#title' => 'Content ID [content_id]',
'#description' => t('Numeric identifier. For example, node ID.'),
'#default_value' => mps_get_mapping_default('content_id'),
);
$form['mps_mapping_defaults']['type'] = array(
'#type' => 'textfield',
'#title' => 'Content type [type]',
'#default_value' => mps_get_mapping_default('type'),
);
$form['mps_mapping_defaults']['subtype'] = array(
'#type' => 'textfield',
'#title' => 'Sub-content type [subtype]',
'#description' => t('Can be utilized by Omniture. Generally not needed.'),
'#default_value' => mps_get_mapping_default('subtype'),
);
// Published date.
$form['mps_mapping_defaults']['pubdate'] = array(
'#type' => 'textfield',
'#title' => 'Publish date [pubdate]',
'#description' => t('The date the article was published in UNIX timestamp format.'),
'#default_value' => mps_get_mapping_default('pubdate'),
);
// SEO fields.
$form['mps_mapping_defaults']['title'] = array(
'#type' => 'textfield',
'#title' => 'Title [title]',
'#default_value' => mps_get_mapping_default('title'),
);
$form['mps_mapping_defaults']['stitle'] = array(
'#type' => 'textfield',
'#title' => 'Short title [stitle]',
'#default_value' => mps_get_mapping_default('stitle'),
);
$form['mps_mapping_defaults']['hline'] = array(
'#type' => 'textfield',
'#title' => 'Headline [hline]',
'#default_value' => mps_get_mapping_default('hline'),
);
// Search results.
$form['mps_mapping_defaults']['keywords'] = array(
'#type' => 'textfield',
'#title' => 'Keywords [keywords]',
'#description' => t('If a page is the result of a search query, these are the terms used to reach it.'),
'#default_value' => mps_get_mapping_default('keywords'),
);
// Parent object: used for items such as slideshow galleries.
$form['mps_mapping_defaults']['envelope'] = array(
'#type' => 'textfield',
'#title' => 'Parent Object Title [envelope]',
'#description' => t('The title of a container node or other object entity, for example "Christmas Gift Slideshow".'),
'#default_value' => mps_get_mapping_default('envelope'),
);
$form['mps_mapping_defaults']['envelope_id'] = array(
'#type' => 'textfield',
'#title' => 'Parent Object ID [envelope_id]',
'#description' => t('Numeric ID (node ID) of parent container.'),
'#default_value' => mps_get_mapping_default('envelope_id'),
);
$form['mps_mapping_defaults']['partner'] = array(
'#type' => 'textfield',
'#title' => 'Partner [partner]',
'#description' => t('Example, co-branded sites, referrals, partner information.'),
'#default_value' => mps_get_mapping_default('partner'),
);
// TODO- implement field[field_name]=value
$form['mps_mapping_defaults']['token'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Replacement values'),
);
$form['mps_mapping_defaults']['token']['tokens'] = array(
'#markup' => theme('token_tree', array(
'token_types' => 'all',
'click_insert' => TRUE,
'show_restricted' => TRUE,
)),
);
$form['mps_debug'] = array(
'#type' => 'checkbox',
'#title' => t('Debug mode'),
'#default_value' => variable_get('mps_debug', 0),
);
$form['#validate'][] = 'mps_admin_settings_validate';
return system_settings_form($form);
}
/**
* Setting validation callback.
*/
function mps_admin_settings_validate($form, &$form_state) {
$form_state['values']['mps_mapping_defaults'] = array_filter($form_state['values']['mps_mapping_defaults']);
cache_clear_all('mps_adunit_regions', 'cache');
cache_clear_all('mps_component_regions', 'cache');
}