b2evolution PHP Cross Reference Blogging Systems

Source: /inc/collections/views/_coll_urls.form.php - 351 lines - 13624 bytes - Summary - Text - Print

Description: This file implements the UI view for the collection URL properties. b2evolution - {@link http://b2evolution.net/} Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}

   1  <?php
   2  /**
   3   * This file implements the UI view for the collection URL properties.
   4   *
   5   * b2evolution - {@link http://b2evolution.net/}
   6   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
   7   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   8   * Parts of this file are copyright (c)2004-2005 by Daniel HAHLER - {@link http://thequod.de/contact}.
   9   *
  10   * {@internal Open Source relicensing agreement:
  11   * Daniel HAHLER grants Francois PLANQUE the right to license
  12   * Daniel HAHLER's contributions to this file and the b2evolution project
  13   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  14   * }}
  15   *
  16   * @package admin
  17   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  18   * @author blueyed: Daniel HAHLER
  19   * @author fplanque: Francois PLANQUE.
  20   *
  21   * @version $Id: _coll_urls.form.php 6136 2014-03-08 07:59:48Z manuel $
  22   */
  23  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  24  
  25  /**
  26   * @var Blog
  27   */
  28  global $edited_Blog;
  29  /**
  30   * @var GeneralSettings
  31   */
  32  global $Settings;
  33  /**
  34   * @var Log
  35   */
  36  global $Debuglog;
  37  
  38  ?>
  39  <script type="text/javascript">
  40      // Script to update the Blog URL preview:
  41      var blog_baseurl = '<?php echo str_replace( "'", "\'", $edited_Blog->gen_baseurl() ); ?>';
  42  
  43  	function update_urlpreview( baseurl )
  44      {
  45          if( typeof baseurl == 'string' )
  46          {
  47              blog_baseurl = baseurl;
  48          }
  49  
  50          if( document.getElementById( 'urlpreview' ).hasChildNodes() )
  51          {
  52              document.getElementById( 'urlpreview' ).firstChild.data = blog_baseurl;
  53          }
  54          else
  55          {
  56              document.getElementById( 'urlpreview' ).appendChild( document.createTextNode( blog_baseurl ) );
  57          }
  58      }
  59  
  60  	function show_hide_chapter_prefix(ob)
  61      {
  62          var fldset = document.getElementById( 'category_prefix_container' );
  63          if( ob.value == 'param_num' )
  64          {
  65              fldset.style.display = 'none';
  66          }
  67          else
  68          {
  69              fldset.style.display = '';
  70          }
  71      }
  72  </script>
  73  
  74  
  75  <?php
  76  
  77  global $blog, $tab;
  78  
  79  global $preset;
  80  
  81  $Form = new Form();
  82  
  83  $Form->begin_form( 'fform' );
  84  
  85  $Form->add_crumb( 'collection' );
  86  $Form->hidden_ctrl();
  87  $Form->hidden( 'action', 'update' );
  88  $Form->hidden( 'tab', $tab );
  89  $Form->hidden( 'blog', $blog );
  90  
  91  
  92  global $baseurl, $basedomain;
  93  
  94  // determine siteurl type (if not set from update-action)
  95  if( preg_match('#https?://#', $edited_Blog->get( 'siteurl' ) ) )
  96  { // absolute
  97      $blog_siteurl_relative = '';
  98      $blog_siteurl_absolute = $edited_Blog->get( 'siteurl' );
  99  }
 100  else
 101  { // relative
 102      $blog_siteurl_relative = $edited_Blog->get( 'siteurl' );
 103      $blog_siteurl_absolute = 'http://';
 104  }
 105  
 106  $Form->begin_fieldset( T_('Blog URL').' ['.T_('Admin').']'.get_manual_link('blog_url_settings') );
 107  
 108      if( $current_User->check_perm( 'blog_admin', 'edit', false, $edited_Blog->ID ) )
 109      {    // Permission to edit advanced admin settings
 110  
 111          $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 );
 112  
 113          if( $default_blog_ID = $Settings->get('default_blog_ID') )
 114          {
 115              $Debuglog->add('Default blog is set to: '.$default_blog_ID);
 116              $BlogCache = & get_BlogCache();
 117              if( $default_Blog = & $BlogCache->get_by_ID($default_blog_ID, false) )
 118              { // Default blog exists
 119                  $defblog = $default_Blog->dget('shortname');
 120              }
 121          }
 122  
 123          $siteurl_relative_warning = '';
 124          if( ! preg_match( '~(^|/|\.php.?)$~i', $blog_siteurl_relative ) )
 125          {
 126              $siteurl_relative_warning = ' <span class="note red">'.T_('WARNING: it is highly recommended that this ends in with a / or .php !').'</span>';
 127          }
 128  
 129          $siteurl_absolute_warning = '';
 130          if( ! preg_match( '~(^|/|\.php.?)$~i', $blog_siteurl_absolute ) )
 131          {
 132              $siteurl_absolute_warning = ' <span class="note red">'.T_('WARNING: it is highly recommended that this ends in with a / or .php !').'</span>';
 133          }
 134  
 135  
 136          $Form->radio( 'blog_access_type', $edited_Blog->get( 'access_type' ), array(
 137              /* TODO: Tblue> This option only should be available if the
 138               *              current blog is set as the default blog, otherwise
 139               *              this setting is confusing. Another possible
 140               *              solution would be to change the default blog
 141               *              setting if this blog-specific setting is changed,
 142               *              but then we would be have the same setting in
 143               *              two places... I would be in favor of the first
 144               *              solution.
 145               * fp> I think it should actually change the default blog setting because
 146               * people have a hard time finding the settings. I personally couldn't care
 147               * less that there are 2 ways to do the same thing.
 148               */
 149              array( 'default', T_('Default blog in index.php'),
 150                                              $baseurl.'index.php ('.( !isset($defblog)
 151                                                  ?    /* TRANS: NO current default blog */ T_('No default blog is currently set')
 152                                                  : /* TRANS: current default blog */ T_('Current default :').' '.$defblog ).
 153                                              ')',
 154                                          '',
 155                                          'onclick="update_urlpreview( \''.$baseurl.'index.php\' );"'
 156              ),
 157              array( 'index.php', T_('Explicit param on index.php'),
 158                                          $baseurl.'index.php?blog='.$edited_Blog->ID,
 159                                          '',
 160                                          'onclick="update_urlpreview( \''.$baseurl.'index.php?blog='.$edited_Blog->ID.'\' )"',
 161              ),
 162              array( 'extrapath', T_('Extra path on index.php'),
 163                                          $baseurl.'index.php/'.$edited_Blog->get( 'urlname' ),
 164                                          '',
 165                                          'onclick="update_urlpreview( \''.$baseurl.'index.php/\'+document.getElementById( \'blog_urlname\' ).value )"'
 166              ),
 167              array( 'relative', T_('Relative to baseurl').':',
 168                                          '',
 169                                          '<span class="nobr"><code>'.$baseurl.'</code>'
 170                                          .'<input type="text" id="blog_siteurl_relative" class="form_text_input" name="blog_siteurl_relative" size="35" maxlength="120" value="'
 171                                          .format_to_output( $blog_siteurl_relative, 'formvalue' )
 172                                          .'" onkeyup="update_urlpreview( \''.$baseurl.'\'+this.value );"
 173                                          onfocus="document.getElementsByName(\'blog_access_type\')[3].checked=true;
 174                                          update_urlpreview( \''.$baseurl.'\'+this.value );" /></span>'.$siteurl_relative_warning,
 175                                          'onclick="document.getElementById( \'blog_siteurl_relative\' ).focus();"'
 176              ),
 177              array( 'subdom', T_('Subdomain of basedomain'),
 178                                          preg_replace( '#(https?://)#i', '$1'.$edited_Blog->urlname.'.', $baseurl ),
 179                                          '',
 180                                          'onclick="update_urlpreview( \'http://\'+document.getElementById( \'blog_urlname\' ).value+\'.'.preg_replace( '#(https?://)#i', '', $baseurl ).'\' )"'
 181              ),
 182              array( 'absolute', T_('Absolute URL').':',
 183                                          '',
 184                                          '<input type="text" id="blog_siteurl_absolute" class="form_text_input" name="blog_siteurl_absolute" size="50" maxlength="120" value="'
 185                                              .format_to_output( $blog_siteurl_absolute, 'formvalue' )
 186                                              .'" onkeyup="update_urlpreview( this.value );"
 187                                              onfocus="document.getElementsByName(\'blog_access_type\')[5].checked=true;
 188                                              update_urlpreview( this.value );" />'.$siteurl_absolute_warning,
 189                                          'onclick="document.getElementById( \'blog_siteurl_absolute\' ).focus();"'
 190              ),
 191          ), T_('Blog base URL'), true );
 192  
 193      }
 194  
 195      // URL Preview (always displayed)
 196      $blogurl = $edited_Blog->gen_blogurl();
 197      $Form->info( T_('URL preview'), '<span id="urlpreview">'.$blogurl.'</span>' );
 198  
 199  $Form->end_fieldset();
 200  
 201  
 202  $Form->begin_fieldset( T_('Date archive URLs') );
 203  
 204      $Form->radio( 'archive_links', $edited_Blog->get_setting('archive_links'),
 205          array(
 206                  array( 'param', T_('Use param'), T_('E-g: ')
 207                                  .url_add_param( $blogurl, '<strong>m=20071231</strong>' ) ),
 208                  array( 'extrapath', T_('Use extra-path'), T_('E-g: ')
 209                                  .url_add_tail( $blogurl, '<strong>/2007/12/31/</strong>' ) ),
 210              ), T_('Date archive URLs'), true );
 211  
 212  $Form->end_fieldset();
 213  
 214  
 215  $Form->begin_fieldset( T_('Category URLs') );
 216  
 217      $Form->radio( 'chapter_links', $edited_Blog->get_setting('chapter_links'),
 218          array(
 219                  array( 'param_num', T_('Use param: cat ID'), T_('E-g: ')
 220                                  .url_add_param( $blogurl, '<strong>cat=123</strong>' ),'', 'onclick="show_hide_chapter_prefix(this);"'),
 221                  array( 'subchap', T_('Use extra-path: sub-category'), T_('E-g: ')
 222                                  .url_add_tail( $blogurl, '<strong>/subcat/</strong>' ), '', 'onclick="show_hide_chapter_prefix(this);"' ),
 223                  array( 'chapters', T_('Use extra-path: category path'), T_('E-g: ')
 224                                  .url_add_tail( $blogurl, '<strong>/cat/subcat/</strong>' ), '', 'onclick="show_hide_chapter_prefix(this);"' ),
 225              ), T_('Category URLs'), true );
 226  
 227  
 228          echo '<div id="category_prefix_container">';
 229              $Form->text_input( 'category_prefix', $edited_Blog->get_setting( 'category_prefix' ), 30, T_('Prefix'),
 230                                                          T_('An optional prefix to be added to the URLs of the categories'),
 231                                                          array('maxlength' => 120) );
 232          echo '</div>';
 233  
 234          if( $edited_Blog->get_setting( 'chapter_links' ) == 'param_num' )
 235          { ?>
 236          <script type="text/javascript">
 237              <!--
 238              var fldset = document.getElementById( 'category_prefix_container' );
 239              fldset.style.display = 'none';
 240              //-->
 241          </script>
 242          <?php
 243          }
 244  
 245  $Form->end_fieldset();
 246  
 247  
 248  $Form->begin_fieldset( T_('Tag page URLs'), array('id'=>'tag_links_fieldset') );
 249  
 250      $Form->radio( 'tag_links', $edited_Blog->get_setting('tag_links'),
 251          array(
 252              array( 'param', T_('Use param'), T_('E-g: ')
 253                  .url_add_param( $blogurl, '<strong>tag=mytag</strong>' ) ),
 254              array( 'prefix-only', T_('Use extra-path').': '.'Use URL path prefix only (recommended)', T_('E-g: ')
 255                  .url_add_tail( $blogurl, '<strong>/<span class="tag_links_tag_prefix"></span>mytag</strong>' ) ),
 256              array( 'dash', T_('Use extra-path').': '.'trailing dash', T_('E-g: ')
 257                  .url_add_tail( $blogurl, '<strong>/<span class="tag_links_tag_prefix"></span>mytag-</strong>' ) ),
 258              array( 'colon', T_('Use extra-path').': '.'trailing colon', T_('E-g: ')
 259                  .url_add_tail( $blogurl, '<strong>/<span class="tag_links_tag_prefix"></span>mytag:</strong>' ) ),
 260              array( 'semicolon', T_('Use extra-path').': '.'trailing semi-colon (NOT recommended)', T_('E-g: ')
 261                  .url_add_tail( $blogurl, '<strong>/<span class="tag_links_tag_prefix"></span>mytag;</strong>' ) ),
 262          ), T_('Tag page URLs'), true );
 263  
 264  
 265      $Form->text_input( 'tag_prefix', $edited_Blog->get_setting( 'tag_prefix' ), 30, T_('Prefix'),
 266          T_('An optional prefix to be added to the URLs of the tag pages'),
 267          array('maxlength' => 120) );
 268  
 269      $Form->checkbox( 'tag_rel_attrib', $edited_Blog->get_setting( 'tag_rel_attrib' ), T_('Rel attribute'),
 270          sprintf( T_('Add <a %s>rel="tag" attribute</a> to tag links.'), 'href="http://microformats.org/wiki/rel-tag"' ) );
 271  
 272  $Form->end_fieldset();
 273  
 274  // Javascript juice for the tag fields.
 275  ?>
 276  <script type="text/javascript">
 277  jQuery( '#tag_links_fieldset input[type=radio]' ).click( function()
 278  {
 279      if( jQuery( this ).val() == 'param' )
 280      { // Disable tag_prefix, if "param" is used.
 281          jQuery( '#tag_prefix' ).attr( 'disabled', 'disabled' );
 282      }
 283      else
 284      {
 285          jQuery( '#tag_prefix' ).removeAttr( 'disabled' );
 286      }
 287  
 288      if( jQuery( this ).val() == 'prefix-only' )
 289      { // Enable tag_rel_attrib, if "prefix-only" is used.
 290          jQuery( '#tag_rel_attrib' ).removeAttr( 'disabled' );
 291      }
 292      else
 293      {
 294          jQuery( '#tag_rel_attrib' ).attr( 'disabled', 'disabled' );
 295      }
 296  
 297      // NOTE: dh> ".closest('fieldset').andSelf()" is required for the add-field_required-class-to-fieldset-hack. Remove as appropriate.
 298      if( jQuery( this ).val() == 'prefix-only' )
 299      {
 300          jQuery( '#tag_prefix' ).closest( 'fieldset' ).andSelf().addClass( 'field_required' );
 301      }
 302      else
 303      {
 304          jQuery( '#tag_prefix' ).closest( 'fieldset' ).andSelf().removeClass( 'field_required' );
 305      }
 306  } ).filter( ':checked' ).click();
 307  
 308  // Set text of span.tag_links_tag_prefix according to this field, defaulting to "tag" for "prefix-only".
 309  jQuery("#tag_prefix").keyup( function() {
 310      jQuery("span.tag_links_tag_prefix").each(
 311          function() {
 312              var newval = ((jQuery("#tag_prefix").val().length || jQuery(this).closest("div").find("input[type=radio]").attr("value") != "prefix-only") ? jQuery("#tag_prefix").val() : "tag");
 313              if( newval.length ) newval += "/";
 314              jQuery(this).text( newval );
 315          }
 316      ) } ).keyup();
 317  </script>
 318  
 319  
 320  <?php
 321  $Form->begin_fieldset( T_('Single post URLs') );
 322  
 323      $Form->radio( 'single_links', $edited_Blog->get_setting('single_links'),
 324          array(
 325                array( 'param_num', T_('Use param: post ID'), T_('E-g: ')
 326                                .url_add_param( $blogurl, '<strong>p=123&amp;more=1</strong>' ) ),
 327                array( 'param_title', T_('Use param: post title'), T_('E-g: ')
 328                                .url_add_param( $blogurl, '<strong>title=post-title&amp;more=1</strong>' ) ),
 329                  array( 'short', T_('Use extra-path: post title'), T_('E-g: ')
 330                                  .url_add_tail( $blogurl, '<strong>/post-title</strong>' ) ),
 331                  array( 'y', T_('Use extra-path: year'), T_('E-g: ')
 332                                  .url_add_tail( $blogurl, '<strong>/2006/post-title</strong>' ) ),
 333                  array( 'ym', T_('Use extra-path: year & month'), T_('E-g: ')
 334                                  .url_add_tail( $blogurl, '<strong>/2006/12/post-title</strong>' ) ),
 335                  array( 'ymd', T_('Use extra-path: year, month & day'), T_('E-g: ')
 336                                  .url_add_tail( $blogurl, '<strong>/2006/12/31/post-title</strong>' ) ),
 337                  array( 'subchap', T_('Use extra-path: sub-category'), T_('E-g: ')
 338                                  .url_add_tail( $blogurl, '<strong>/subcat/post-title</strong>' ) ),
 339                  array( 'chapters', T_('Use extra-path: category path'), T_('E-g: ')
 340                                  .url_add_tail( $blogurl, '<strong>/cat/subcat/post-title</strong>' ) ),
 341              ), T_('Single post URLs'), true );
 342  
 343  $Form->end_fieldset();
 344  
 345  
 346  $Form->buttons( array( array( 'submit', 'submit', T_('Save !'), 'SaveButton' ),
 347                                                      array( 'reset', '', T_('Reset'), 'ResetButton' ) ) );
 348  
 349  $Form->end_form();
 350  
 351  ?>

title

Description

title

Description

title

Description

title

title

Body