-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsettings.php
More file actions
executable file
·201 lines (184 loc) · 11.7 KB
/
settings.php
File metadata and controls
executable file
·201 lines (184 loc) · 11.7 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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
function leisref_page_admin() {
$config = get_option('leisref_config');
$filter_labels = array(
'subject' => __('Subject', 'leisref'),
'act-type' => __('Act type', 'leisref'),
'scope' => __('Act scope', 'leisref'),
'country-region' => __('Country', 'leisref'),
'state' => __('State', 'leisref'),
'language' => __('Language', 'leisref'),
'collection' => __('Collection', 'leisref'),
'year' => __('Year', 'leisref'),
'database' => __('Database', 'leisref'),
);
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"></div>
<h2><?php _e('Legislation settings', 'leisref'); ?></h2>
<form method="post" action="options.php">
<?php settings_fields('leisref-settings-group'); ?>
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row"><?php _e('Plugin page', 'leisref'); ?>:</th>
<td><input type="text" name="leisref_config[plugin_slug]" value="<?php echo ($config['plugin_slug'] != '' ? $config['plugin_slug'] : 'leisref'); ?>" class="regular-text code"></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Filter query', 'leisref'); ?>:</th>
<td><input type="text" name="leisref_config[initial_filter]" value='<?php echo $config['initial_filter'] ?>' class="regular-text code"></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('AddThis profile ID', 'leisref'); ?>:</th>
<td><input type="text" name="leisref_config[addthis_profile_id]" value="<?php echo $config['addthis_profile_id'] ?>" class="regular-text code"></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Google Analytics code', 'leisref'); ?>:</th>
<td><input type="text" name="leisref_config[google_analytics_code]" value="<?php echo $config['google_analytics_code'] ?>" class="regular-text code"></td>
</tr>
<?php
if ( function_exists( 'pll_the_languages' ) ) {
$available_languages = pll_languages_list();
$available_languages_name = pll_languages_list(array('fields' => 'name'));
$count = 0;
foreach ($available_languages as $lang) {
$key_name = 'plugin_title_' . $lang;
$home_url = 'home_url_' . $lang;
echo '<tr valign="top">';
echo ' <th scope="row"> ' . __("Home URL", "leisref") . ' (' . $available_languages_name[$count] . '):</th>';
echo ' <td><input type="text" name="leisref_config[' . $home_url . ']" value="' . $config[$home_url] . '" class="regular-text code"></td>';
echo '</tr>';
echo '<tr valign="top">';
echo ' <th scope="row"> ' . __("Page title", "leisref") . ' (' . $available_languages_name[$count] . '):</th>';
echo ' <td><input type="text" name="leisref_config[' . $key_name . ']" value="' . $config[$key_name] . '" class="regular-text code"></td>';
echo '</tr>';
$count++;
}
}else{
echo '<tr valign="top">';
echo ' <th scope="row">' . __("Page title", "leisref") . ':</th>';
echo ' <td><input type="text" name="leisref_config[plugin_title]" value="' . $config["plugin_title"] . '" class="regular-text code"></td>';
echo '</tr>';
}
?>
<tr valign="top">
<th scope="row"><?php _e('Similar documents', 'leisref'); ?>:</th>
<td>
<input type="checkbox" id="similar-docs" name="leisref_config[show_similar_docs]" value="1" <?php if ( $config['show_similar_docs'] == '1' ): echo 'checked="checked"'; endif; ?>>
<?php _e('Show similar documents', 'leisref'); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Sources for similar documents', 'leisref'); ?>:</th>
<td>
<input type="text" id="default-filter-db" name="leisref_config[default_filter_db]" value='<?php echo $config['default_filter_db']; ?>' class="regular-text code" <?php if ( $config['show_similar_docs'] != '1' ): echo 'disabled'; endif; ?>>
<small style="display: block;">* <?php _e('The database names must be separated by commas.', 'leisref'); ?></small>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Related documents', 'leisref'); ?>:</th>
<td>
<input type="checkbox" id="related-docs" name="leisref_config[show_related_docs]" value="1" <?php if ( $config['show_related_docs'] == '1' ): echo 'checked="checked"'; endif; ?>>
<?php _e('Show related documents', 'leisref'); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Sources for related documents', 'leisref'); ?>:</th>
<td>
<input type="text" id="extra-filter-db" name="leisref_config[extra_filter_db]" value='<?php echo $config['extra_filter_db']; ?>' class="regular-text code" <?php if ( $config['show_related_docs'] != '1' ): echo 'disabled'; endif; ?>>
<small style="display: block;">* <?php _e('The database names must be separated by commas.', 'leisref'); ?></small>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('Page layout', 'leisref'); ?>:
</th>
<td>
<label for="whole_page">
<input type="radio" id="whole_page" value="whole_page" name="leisref_config[page_layout]" <?php if($config['page_layout'] == 'whole_page' ){ echo 'checked'; }?>>
<?php _e('Show filters as whole page', 'leisref'); ?>
</label>
<br>
<br>
<label for="normal_page">
<input type="radio" id="normal_page" value="normal_page" name="leisref_config[page_layout]" <?php if(!isset($config['page_layout']) || $config['page_layout'] == 'normal_page' ){ echo 'checked'; }?> >
<?php _e('Show normal page', 'leisref'); ?>
</label>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Search filters', 'leisref');?>:</th>
<?php
$available_filters = 'Subject;Act type;Scope;Country/region;State;Collection;Language;Year;Database';
$available_filter_list = explode(';', $available_filters);
if(!isset($config['available_filter'])){
$order = $available_filter_list;
} else {
$order = array_filter(explode(';', $config['available_filter']));
}
?>
<td>
<table border=0>
<tr>
<td>
<p align="left"><?php _e('Available', 'leisref');?><br />
<ul id="sortable1" class="droptrue">
<?php foreach ($available_filter_list as $key => $value) : ?>
<?php if ( !in_array($value, $order) ) : $slug = sanitize_title($value); ?>
<?php echo '<li class="ui-state-default" id="'.$value.'">'.$filter_labels[$slug].'</li>'; ?>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</p>
</td>
<td>
<p align="left"><?php _e('Selected', 'leisref');?><br />
<ul id="sortable2" class="sortable-list">
<?php
foreach ($order as $index => $item) {
$slug = sanitize_title($item);
$item = trim($item); // Important
echo '<li class="ui-state-default" id="'.$item.'">'.$filter_labels[$slug].'</li>';
}
?>
</ul>
<input type="hidden" id="order_aux" name="leisref_config[available_filter]" value="<?php echo trim($config['available_filter']); ?> " >
</p>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Save changes') ?>" />
</p>
</form>
</div>
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(function(){
$j('#similar-docs').on('change', function() {
$j('#default-filter-db').prop('disabled', !this.checked);
});
$j('#related-docs').on('change', function() {
$j('#extra-filter-db').prop('disabled', !this.checked);
});
$j( "ul.droptrue" ).sortable({
connectWith: "ul"
});
$j('.sortable-list').sortable({
connectWith: 'ul',
update: function(event, ui) {
var changedList = this.id;
var order = $j(this).sortable('toArray');
var positions = order.join(';');
$j('#order_aux').val(positions);
}
});
});
</script>
<?php
}
?>