b2evolution PHP Cross Reference Blogging Systems

Source: /inc/regional/views/_time.form.php - 138 lines - 4322 bytes - Summary - Text - Print

Description: This file implements the UI view for the time settings. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**

   3   * This file implements the UI view for the time settings.

   4   *

   5   * This file is part of the evoCore framework - {@link http://evocore.net/}

   6   * See also {@link http://sourceforge.net/projects/evocms/}.

   7   *

   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}

   9   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.

  10   *

  11   * {@internal License choice

  12   * - If you have received this file as part of a package, please find the license.txt file in

  13   *   the same folder or the closest folder above for complete license terms.

  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)

  15   *   then you must choose one of the following licenses before using the file:

  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php

  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php

  18   * }}

  19   *

  20   * {@internal Open Source relicensing agreement:

  21   * Daniel HAHLER grants Francois PLANQUE the right to license

  22   * Daniel HAHLER's contributions to this file and the b2evolution project

  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  24   * }}

  25   *

  26   * @package admin

  27   *

  28   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}

  29   * @author fplanque: Francois PLANQUE.

  30   * @author blueyed: Daniel HAHLER.

  31   *

  32   * @version $Id: _time.form.php 17 2011-10-25 04:22:09Z sam2kb $

  33   */
  34  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  35  
  36  
  37  /**

  38   * @var User

  39   */
  40  global $current_User;
  41  /**

  42   * @var GeneralSettings

  43   */
  44  global $Settings;
  45  
  46  global $rsc_subdir, $pagenow, $servertimenow;
  47  
  48  
  49  // JavaScript function to calculate time difference: {{{

  50  ?>
  51  <script type="text/javascript">
  52  
  53  var server_Date = new Date();
  54  server_Date.setTime( <?php echo $servertimenow.'000' ?> ); // milliseconds

  55  var user_Date = new Date();
  56  
  57  function calc_TimeDifference(min_dif) {
  58      var ntd = user_Date.getTime() - server_Date.getTime();
  59      ntd = ntd / 1000; // to seconds

  60  
  61      ntd = ntd - 2; // assume that it takes 2 seconds from writing server_Date time into the source until the browser sets user_Date

  62  
  63      var neg = ( ntd < 0 );
  64      ntd = Math.abs(ntd);
  65  
  66      var hours = Math.floor(ntd/3600);
  67      var mins = Math.floor( (ntd%3600)/60 );
  68      //var secs = Math.round( (ntd%3600)%60 );

  69  
  70      //alert( server_Date+"\n"+user_Date+"\n"+ntd+"\nhours: "+hours+"\nmins: "+mins );

  71  
  72      if( mins == 0 )
  73      {
  74          ntd = hours;
  75      }
  76      else
  77      {
  78          ntd = hours+':'+mins;
  79      }
  80  
  81      if( neg && ntd != '0' ) ntd = '-'+ntd;
  82  
  83      // Apply the calculated time difference

  84      document.getElementById('newtime_difference').value = ntd;
  85  }
  86  </script>
  87  
  88  <?php // }}}
  89  
  90  $Form = new Form( $pagenow, 'loc_checkchanges' );
  91  
  92  $Form->begin_form( 'fform' );
  93  
  94  $Form->add_crumb( 'time' );
  95  $Form->hidden( 'ctrl', 'time' );
  96  $Form->hidden( 'action', 'update' );
  97  
  98  $Form->begin_fieldset( T_('Time settings') );
  99  
 100  // Time difference:

 101  $td_value = $Settings->get('time_difference');
 102  $neg = ( $td_value < 0 );
 103  $td_value = abs($td_value);
 104  if( $td_value % 3600 != 0 )
 105  { // we have minutes
 106      if( $td_value % 60 != 0 )
 107      { // we have seconds (hh:mm:ss)
 108          $td_value = floor($td_value/3600).':'.sprintf( '%02d', ($td_value % 3600)/60 ).':'.sprintf( '%02d', ($td_value%60) );
 109      }
 110      else
 111      { // hh:mm
 112          $td_value = floor($td_value/3600).':'.sprintf( '%02d', ($td_value % 3600)/60 );
 113      }
 114  }
 115  else
 116  { // just full hours:
 117      $td_value = $td_value/3600;
 118  }
 119  
 120  if($neg)
 121  {
 122      $td_value = '-'.$td_value;
 123  }
 124  
 125  $Form->text_input( 'newtime_difference', $td_value, 8 /* hh:mm:ss */, T_('Time difference'), '['. T_('in hours, e.g. "1", "1:30" or "-1.5"'). '] '.T_('If you\'re not on the timezone of your server.'), array( 'maxlength'=> 8, 'required'=>true ) );
 126  $Form->info( T_('Current server time'), date_i18n( locale_timefmt(), $servertimenow ) );
 127  $Form->info( '', '<a href="#" onclick="calc_TimeDifference(); return false;">'.T_('Calculate time difference').'</a>' );
 128  
 129  $Form->end_fieldset();
 130  
 131  
 132  if( $current_User->check_perm( 'options', 'edit' ) )
 133  {
 134      $Form->end_form( array( array( 'submit', '', T_('Save !'), 'SaveButton' ),
 135                                                      array( 'reset', '', T_('Reset'), 'ResetButton' ) ) ) ;
 136  }
 137  
 138  ?>

title

Description

title

Description

title

Description

title

title

Body