3
* This file implements the UI view for the blog URL properties
5
* @author {@link http://wonderwinds.com/ Ed Bennett}
6
* @author {@link http://daniel.hahler.de/ Daniel HAHLER}
7
* @author {@link http://fplanque.net/ Francois PLANQUE}
8
* @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project}
9
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3
12
if(!defined('QP_MAIN_INIT')) die('fail');
17
// Script to update the Blog URL preview
19
<script type="text/javascript">
20
var blog_baseurl = '<?php echo str_replace( "'", "\'", $edited_Blog->gen_baseurl() ); ?>';
21
function update_urlpreview( baseurl )
23
if( typeof baseurl == 'string' )
25
blog_baseurl = baseurl;
27
if( document.getElementById( 'urlpreview' ).hasChildNodes() )
29
document.getElementById( 'urlpreview' ).firstChild.data = blog_baseurl;
33
document.getElementById( 'urlpreview' ).appendChild( document.createTextNode( blog_baseurl ) );
36
function show_hide_cat_prefix(ob)
38
var fldset = document.getElementById( 'category_prefix_container' );
39
if( ob.value == 'param_num' )
41
fldset.style.display = 'none';
45
fldset.style.display = '';
52
$Form->begin_form( 'fform' );
54
$Form->hidden( 'action', 'update' );
55
$Form->hidden( 'tab', 'urls' );
56
$Form->hidden( 'blog', $edited_Blog->ID );
61
// determine siteurl type (if not set from update-action)
62
if( preg_match( '#https?://#', $edited_Blog->get( 'siteurl' ) ) )
65
$blog_siteurl_relative = '';
66
$blog_siteurl_absolute = $edited_Blog->get( 'siteurl' );
71
$blog_siteurl_relative = $edited_Blog->get( 'siteurl' );
72
$blog_siteurl_absolute = 'http://';
75
$Form->begin_fieldset( T_('Blog URL').' ['.T_('Admin').']' );
76
if( $current_User->check_perm( 'blog_admin', 'edit', false, $edited_Blog->ID ) )
78
// Permission to edit advanced admin settings
79
$Form->text( 'blog_urlname', $edited_Blog->get( 'urlname' ), 20, T_('Blog URL name'), T_('Used to uniquely identify this blog. Appears in URLs and gets used as default for the media location (see the advanced tab).'), 255 );
80
if( $default_blog_ID = $Settings->get( 'default_blog_ID' ) )
82
$BlogCache = & get_Cache( 'BlogCache' );
83
if( $default_Blog = & $BlogCache->get_by_ID( $default_blog_ID, false ) )
85
// Default blog exists
86
$defblog = $default_Blog->dget( 'shortname' );
89
$siteurl_relative_warning = '';
90
if( ! preg_match( '~(^|/|\.php.?)$~i', $blog_siteurl_relative ) )
92
$siteurl_relative_warning = ' <span class="note red">'.T_('WARNING: it is highly recommended that this ends in with a / or .php !').'</span>';
94
$siteurl_absolute_warning = '';
95
if( ! preg_match( '~(^|/|\.php.?)$~i', $blog_siteurl_absolute ) )
97
$siteurl_absolute_warning = ' <span class="note red">'.T_('WARNING: it is highly recommended that this ends in with a / or .php !').'</span>';
99
$Form->radio( 'blog_access_type', $edited_Blog->get( 'access_type' ), array(
100
array( 'default', T_('Default blog in index.php'),
101
$app_baseurl.'index.php ('.( ! isset( $defblog )
102
? /* TRANS: NO current default blog */ T_('No default blog is currently set')
103
: /* TRANS: current default blog */ T_('Current default :').' '.$defblog ).
106
'onclick="update_urlpreview( \''.$app_baseurl.'index.php\' );"'
108
array( 'index.php', T_('Explicit param on index.php'),
109
$app_baseurl.'index.php?blog='.$edited_Blog->ID,
111
'onclick="update_urlpreview( \''.$app_baseurl.'index.php?blog='.$edited_Blog->ID.'\' )"',
113
array( 'extrapath', T_('Extra path on index.php'),
114
$app_baseurl.'index.php/'.$edited_Blog->get( 'urlname' ),
116
'onclick="update_urlpreview( \''.$app_baseurl.'index.php/\'+document.getElementById( \'blog_urlname\' ).value )"'
118
array( 'relative', T_('Relative to baseurl').':',
120
'<span class="nobr"><code>'.$app_baseurl.'</code>'
121
.'<input type="text" id="blog_siteurl_relative" class="form_text_input" name="blog_siteurl_relative" size="35" maxlength="120" value="'
122
.format_to_output( $blog_siteurl_relative, 'formvalue' )
123
.'" onkeyup="update_urlpreview( \''.$app_baseurl.'\'+this.value );"
124
onfocus="document.getElementsByName(\'blog_access_type\')[3].checked=true;
125
update_urlpreview( \''.$app_baseurl.'\'+this.value );" /></span>'.$siteurl_relative_warning,
126
'onclick="document.getElementById( \'blog_siteurl_relative\' ).focus();"'
128
array( 'subdom', T_('Subdomain of basedomain'),
129
'http://url_name.'.$basedomain.'/',
131
'onclick="update_urlpreview( \'http://\'+document.getElementById( \'blog_urlname\' ).value+\'.'.$basedomain.'/\' )"'
133
array( 'absolute', T_('Absolute URL').':',
135
'<input type="text" id="blog_siteurl_absolute" class="form_text_input" name="blog_siteurl_absolute" size="50" maxlength="120" value="'
136
.format_to_output( $blog_siteurl_absolute, 'formvalue' )
137
.'" onkeyup="update_urlpreview( this.value );"
138
onfocus="document.getElementsByName(\'blog_access_type\')[5].checked=true;
139
update_urlpreview( this.value );" />'.$siteurl_absolute_warning,
140
'onclick="document.getElementById( \'blog_siteurl_absolute\' ).focus();"'
142
), T_('Blog base URL'), true );
144
// URL Preview (always displayed)
145
$blogurl = $edited_Blog->gen_blogurl();
146
$Form->info( T_('URL preview'), '<span id="urlpreview">'.$blogurl.'</span>' );
147
$Form->end_fieldset();
149
$Form->begin_fieldset( T_('Main page / post list') );
150
$Form->checkbox( 'default_noindex', $edited_Blog->get_setting( 'default_noindex' ), T_('Default blog page'), T_('META NOINDEX') );
151
$Form->checklist( array(
152
array( 'canonical_homepage', 1, T_('301 redirect to canonical URL when possible'), $edited_Blog->get_setting( 'canonical_homepage' ) ),
153
array( 'relcanonical_homepage', 1, T_('Use rel="canonical" if not 301 redirected'), $edited_Blog->get_setting( 'relcanonical_homepage' ) ),
154
), 'canonical_homepage_options', T_('Make canonical') );
155
$Form->checkbox( 'paged_noindex', $edited_Blog->get_setting( 'paged_noindex' ), T_('"Next" blog pages'), T_('META NOINDEX').' - '.T_('Page 2,3,4...') );
156
$Form->checkbox( 'paged_nofollowto', $edited_Blog->get_setting( 'paged_nofollowto' ), '', T_('NOFOLLOW on links to').' '.T_('Page 2,3,4...') );
157
$Form->radio( 'title_link_type', $edited_Blog->get_setting( 'title_link_type' ), array(
158
array( 'permalink', T_('Link to the permanent url of the post') ),
159
array( 'linkto_url', T_('Link to the "link to URL" specified in the post (if any)') ),
160
array( 'auto', T_('Link to the "link to URL" if specified, otherwise fall back to permanent url') ),
161
array( 'none', T_('No links on titles') ),
162
), T_('Post titles'), true );
163
$Form->radio( 'main_content', $edited_Blog->get_setting( 'main_content' ), array(
164
array( 'excerpt', T_('Post excerpts') ),
165
array( 'normal', T_('Standard post contents (stopping at "<!-- more -->")') ),
166
array( 'full', T_('Full post contents (including after "<!-- more -->")') ),
167
), T_('Post contents'), true );
168
$Form->radio( 'permalinks', $edited_Blog->get_setting( 'permalinks' ), array(
169
array( 'single', T_('Link to single post') ),
170
array( 'archive', T_('Link to post in archive') ),
171
array( 'subcat', T_('Link to post in sub-category') ),
172
), T_('Permalinks'), true );
173
$Form->end_fieldset();
175
$Form->begin_fieldset( T_('Single post pages / "Permalink" pages') );
176
$Form->radio( 'single_links', $edited_Blog->get_setting( 'single_links' ), array(
177
array( 'param_num', T_('Use param: post ID'), T_('E-g: ')
178
.url_add_param( $blogurl, '<strong>p=123&more=1</strong>' ) ),
179
array( 'param_title', T_('Use param: post title'), T_('E-g: ')
180
.url_add_param( $blogurl, '<strong>title=post-title&more=1</strong>' ) ),
181
array( 'short', T_('Use extra-path: post title'), T_('E-g: ')
182
.url_add_tail( $blogurl, '<strong>/post-title</strong>' ) ),
183
array( 'y', T_('Use extra-path: year'), T_('E-g: ')
184
.url_add_tail( $blogurl, '<strong>/2006/post-title</strong>' ) ),
185
array( 'ym', T_('Use extra-path: year & month'), T_('E-g: ')
186
.url_add_tail( $blogurl, '<strong>/2006/12/post-title</strong>' ) ),
187
array( 'ymd', T_('Use extra-path: year, month & day'), T_('E-g: ')
188
.url_add_tail( $blogurl, '<strong>/2006/12/31/post-title</strong>' ) ),
189
array( 'subcat', T_('Use extra-path: sub-category'), T_('E-g: ')
190
.url_add_tail( $blogurl, '<strong>/subcat/post-title</strong>' ) ),
191
array( 'chapters', T_('Use extra-path: category path'), T_('E-g: ')
192
.url_add_tail( $blogurl, '<strong>/cat/subcat/post-title</strong>' ) ),
193
), T_('Single post URLs'), true );
194
$Form->checklist( array(
195
array( 'canonical_item_urls', 1, T_('301 redirect to canonical URL when possible'), $edited_Blog->get_setting( 'canonical_item_urls' ) ),
196
array( 'relcanonical_item_urls', 1, T_('Use rel="canonical" if not 301 redirected'), $edited_Blog->get_setting( 'relcanonical_item_urls' ) ),
197
), 'canonical_item_urls_options', T_('Make canonical') );
198
$Form->checkbox( 'excerpts_meta_description', $edited_Blog->get_setting( 'excerpts_meta_description' ), T_('Meta description'), T_('Use excerpt as meta description for posts and pages') );
199
$Form->end_fieldset();
201
$Form->begin_fieldset( T_('Category pages') );
202
$Form->radio( 'category_links', $edited_Blog->get_setting( 'category_links' ), array(
203
array( 'param_num', T_('Use param: cat ID'), T_('E-g: ')
204
.url_add_param( $blogurl, '<strong>cat=123</strong>' ),'', 'onclick="show_hide_cat_prefix(this);"'),
205
array( 'subcat', T_('Use extra-path: sub-category'), T_('E-g: ')
206
.url_add_tail( $blogurl, '<strong>/subcat/</strong>' ), '', 'onclick="show_hide_cat_prefix(this);"' ),
207
array( 'cats', T_('Use extra-path: category path'), T_('E-g: ')
208
.url_add_tail( $blogurl, '<strong>/cat/subcat/</strong>' ), '', 'onclick="show_hide_cat_prefix(this);"' ),
209
), T_('Category URLs'), true );
210
echo '<div id="category_prefix_container">';
211
$Form->text_input( 'category_prefix', $edited_Blog->get_setting( 'category_prefix' ), 30, T_('Prefix'),
212
T_('An optional prefix to be added to the URLs of the categories'), array( 'maxlength' => 120 ) );
214
if( $edited_Blog->get_setting( 'category_links' ) == 'param_num' )
216
<script type="text/javascript">
218
var fldset = document.getElementById( 'category_prefix_container' );
219
fldset.style.display = 'none';
224
$Form->checklist( array(
225
array( 'canonical_cat_urls', 1, T_('301 redirect to canonical URL when possible'), $edited_Blog->get_setting( 'canonical_cat_urls' ) ),
226
array( 'relcanonical_cat_urls', 1, T_('Use rel="canonical" if not 301 redirected'), $edited_Blog->get_setting( 'relcanonical_cat_urls' ) ),
227
), 'canonical_cat_urls_options', T_('Make canonical') );
228
$Form->checkbox( 'category_noindex', $edited_Blog->get_setting( 'category_noindex' ), T_('Indexing'), T_('META NOINDEX') );
229
$Form->radio( 'category_content', $edited_Blog->get_setting( 'category_content' ), array(
230
array( 'excerpt', T_('Post excerpts') ),
231
array( 'normal', T_('Standard post contents (stopping at "<!-- more -->")') ),
232
array( 'full', T_('Full post contents (including after "<!-- more -->")') ),
233
), T_('Post contents'), true );
234
$Form->text( 'category_posts_per_page', $edited_Blog->get_setting( 'category_posts_per_page' ), 4, T_('Posts per page'),
235
T_('Leave empty to use blog default').' ('.$edited_Blog->get_setting( 'posts_per_page' ).')', 4 );
236
$Form->checkbox( 'catdir_noindex', $edited_Blog->get_setting( 'catdir_noindex' ), T_('Category directory'), T_('META NOINDEX') );
237
$Form->checkbox( 'categories_meta_description', $edited_Blog->get_setting( 'categories_meta_description' ),
238
T_('Meta description'), T_('Use category description as meta description for category pages') );
239
$Form->end_fieldset();
241
$Form->begin_fieldset( T_('Tag pages'), array('id' => 'tag_links_fieldset') );
242
$Form->radio( 'tag_links', $edited_Blog->get_setting( 'tag_links' ), array(
243
array( 'param', T_('Use param'), T_('E-g: ')
244
.url_add_param( $blogurl, '<strong>tag=mytag</strong>' ) ),
245
array( 'prefix-only', T_('Use extra-path').': '.'Use URL path prefix only (recommended)', T_('E-g: ')
246
.url_add_tail( $blogurl, '<strong>/<span class="tag_links_tag_prefix"></span>mytag</strong>' ) ),
247
array( 'dash', T_('Use extra-path').': '.'trailing dash', T_('E-g: ')
248
.url_add_tail( $blogurl, '<strong>/<span class="tag_links_tag_prefix"></span>mytag-</strong>' ) ),
249
array( 'colon', T_('Use extra-path').': '.'trailing colon', T_('E-g: ')
250
.url_add_tail( $blogurl, '<strong>/<span class="tag_links_tag_prefix"></span>mytag:</strong>' ) ),
251
array( 'semicolon', T_('Use extra-path').': '.'trailing semi-colon (NOT recommended)', T_('E-g: ')
252
.url_add_tail( $blogurl, '<strong>/<span class="tag_links_tag_prefix"></span>mytag;</strong>' ) ),
253
), T_('Tag page URLs'), true );
254
$Form->text_input( 'tag_prefix', $edited_Blog->get_setting( 'tag_prefix' ), 30, T_('Prefix'),
255
T_('An optional prefix to be added to the URLs of the tag pages'),
256
array( 'maxlength' => 120 ) );
257
$Form->checkbox( 'tag_rel_attrib', $edited_Blog->get_setting( 'tag_rel_attrib' ), T_('Rel attribute'),
258
sprintf( T_('Add <a %s>rel="tag" attribute</a> to tag links.'), 'href="http://microformats.org/wiki/rel-tag"' ) );
259
$Form->checklist( array(
260
array( 'canonical_tag_urls', 1, T_('301 redirect to canonical URL when possible'), $edited_Blog->get_setting( 'canonical_tag_urls' ) ),
261
array( 'relcanonical_tag_urls', 1, T_('Use rel="canonical" if not 301 redirected'), $edited_Blog->get_setting( 'relcanonical_tag_urls' ) ),
262
), 'canonical_tag_urls_options', T_('Make canonical') );
263
$Form->checkbox( 'tag_noindex', $edited_Blog->get_setting( 'tag_noindex' ), T_('Indexing'), T_('META NOINDEX') );
264
$Form->radio( 'tag_content', $edited_Blog->get_setting( 'tag_content' ), array(
265
array( 'excerpt', T_('Post excerpts') ),
266
array( 'normal', T_('Standard post contents (stopping at "<!-- more -->")') ),
267
array( 'full', T_('Full post contents (including after "<!-- more -->")') ),
268
), T_('Post contents'), true );
269
$Form->text( 'tag_posts_per_page', $edited_Blog->get_setting( 'tag_posts_per_page' ), 4, T_('Posts per page'),
270
T_('Leave empty to use blog default').' ('.$edited_Blog->get_setting( 'posts_per_page' ).')', 4 );
271
$Form->end_fieldset();
273
// Javascript juice for the tag fields
275
<script type="text/javascript">
276
jQuery("#tag_links_fieldset input[type=radio]").click( function()
278
// Disable tag_prefix, if "param" is used.
279
jQuery('#tag_prefix').attr("disabled", this.value == 'param' ? "disabled" : "");
280
// Disable tag_rel_attrib, if "prefix-only" is not used.
281
jQuery('#tag_rel_attrib').attr("disabled", this.value == 'prefix-only' ? "" : "disabled");
282
// NOTE: dh> ".closest('fieldset').andSelf()" is required for the add-field_required-class-to-fieldset-hack. Remove as appropriate.
283
if( this.value == 'prefix-only' )
284
jQuery('#tag_prefix').closest('fieldset').andSelf().addClass('field_required');
286
jQuery('#tag_prefix').closest('fieldset').andSelf().removeClass('field_required');
287
} ).filter(":checked").click();
288
// Set text of span.tag_links_tag_prefix according to this field, defaulting to "tag" for "prefix-only".
289
jQuery("#tag_prefix").keyup( function() {
290
jQuery("span.tag_links_tag_prefix").each(
292
var newval = ((jQuery("#tag_prefix").val().length || jQuery(this).closest("div").find("input[type=radio]").attr("value") != "prefix-only") ? jQuery("#tag_prefix").val() : "tag");
293
if( newval.length ) newval += "/";
294
jQuery(this).text( newval );
300
$Form->begin_fieldset( T_('"By date" archives') );
301
$Form->radio( 'archive_links', $edited_Blog->get_setting( 'archive_links' ), array(
302
array( 'param', T_('Use param'), T_('E-g: ').url_add_param( $blogurl, '<strong>m=20071231</strong>' ) ),
303
array( 'extrapath', T_('Use extra-path'), T_('E-g: ').url_add_tail( $blogurl, '<strong>/2007/12/31/</strong>' ) ),
304
), T_('Date archive URLs'), true );
305
$Form->checklist( array(
306
array( 'canonical_archive_urls', 1, T_('301 redirect to canonical URL when possible'), $edited_Blog->get_setting( 'canonical_archive_urls' ) ),
307
array( 'relcanonical_archive_urls', 1, T_('Use rel="canonical" if not 301 redirected'), $edited_Blog->get_setting( 'relcanonical_archive_urls' ) ),
308
), 'canonical_archive_urls_options', T_('Make canonical') );
309
$Form->checkbox( 'archive_noindex', $edited_Blog->get_setting( 'archive_noindex' ), T_('Indexing'), T_('META NOINDEX') );
310
$Form->checkbox( 'archive_nofollowto', $edited_Blog->get_setting( 'archive_nofollowto' ), T_('Follow TO'), T_('NOFOLLOW on links to').' '.T_('date archives') );
311
$Form->radio( 'archive_content', $edited_Blog->get_setting( 'archive_content' ), array(
312
array( 'excerpt', T_('Post excerpts') ),
313
array( 'normal', T_('Standard post contents (stopping at "<!-- more -->")') ),
314
array( 'full', T_('Full post contents (including after "<!-- more -->")') ),
315
), T_('Post contents'), true );
316
$Form->text( 'archive_posts_per_page', $edited_Blog->get_setting( 'archive_posts_per_page' ), 4, T_('Posts per page'),
317
T_('Leave empty to use blog default').' ('.$edited_Blog->get_setting( 'posts_per_page' ).')', 4 );
318
$Form->checkbox( 'arcdir_noindex', $edited_Blog->get_setting( 'arcdir_noindex' ), T_('Archive directory'), T_('META NOINDEX') );
319
$Form->end_fieldset();
321
$Form->begin_fieldset( T_('Other filtered pages') );
322
$Form->checkbox( 'filtered_noindex', $edited_Blog->get_setting( 'filtered_noindex' ), T_('Other filtered posts pages'), T_('META NOINDEX').' - '.T_('Filtered by keyword search, by author, etc.') );
323
$Form->radio( 'filtered_content', $edited_Blog->get_setting( 'filtered_content' ), array(
324
array( 'excerpt', T_('Post excerpts') ),
325
array( 'normal', T_('Standard post contents (stopping at "<!-- more -->")') ),
326
array( 'full', T_('Full post contents (including after "<!-- more -->")') ),
327
), T_('Post contents'), true );
328
$Form->end_fieldset();
330
$Form->begin_fieldset( T_('Other pages') );
331
$Form->checkbox( 'feedback-popup_noindex', $edited_Blog->get_setting( 'feedback-popup_noindex' ), T_('Comment popups'),
332
T_('META NOINDEX').' - '.T_('For templates with comment popups only.') );
333
$Form->checkbox( 'msgform_noindex', $edited_Blog->get_setting( 'msgform_noindex' ), T_('Contact forms'),
334
T_('META NOINDEX').' - '.T_('WARNING: Letting search engines index contact forms will attract spam.') );
335
$Form->checkbox( 'special_noindex', $edited_Blog->get_setting( 'special_noindex' ), T_('Other special pages'),
336
T_('META NOINDEX').' - '.T_('Pages with no index setting of their own... yet.') );
337
$Form->radio( '404_response', $edited_Blog->get_setting( '404_response' ), array(
338
array( '200', T_('200 "OK" response') ),
339
array( '301', T_('301 redirect to main page') ),
340
array( '302', T_('302 redirect to main page') ),
341
array( '303', T_('303 redirect to main page') ),
342
array( '404', T_('404 "Not found" response') ),
343
array( '410', T_('410 "Gone" response') ),
344
), T_('404 "Not Found" response'), true );
345
$Form->end_fieldset();
347
$Form->buttons( array(
348
array( 'submit', 'submit', T_('Update'), 'SaveButton' ),
349
array( 'reset', '', T_('Reset'), 'ResetButton' ),