Changeset 28500


Ignore:
Timestamp:
May 18, 2014, 12:58:53 PM (6 years ago)
Author:
mistic100
Message:

feature 2679 : allow to change creation time

Location:
trunk
Files:
42 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager_global.php

    r28497 r28500  
    293293    else
    294294    {
    295       $date_creation = $_POST['date_creation'].' 00:00:00';
     295      $date_creation = $_POST['date_creation'];
    296296    }
    297297
     
    566566// creation date
    567567$template->assign('DATE_CREATION',
    568   empty($_POST['date_creation']) ? date('y-n-j') : $_POST['date_creation']
     568  empty($_POST['date_creation']) ? date('Y-m-d').' 00:00:00' : $_POST['date_creation']
    569569  );
    570570
  • trunk/admin/batch_manager_unit.php

    r28497 r28500  
    7979    if (!empty($_POST['date_creation-'.$row['id']]))
    8080    {
    81       if (!empty($row['date_creation']))
    82       {
    83         list(, $time) = explode(' ', $row['date_creation']);
    84       }
    85       else
    86       {
    87         $time = '00:00:00';
    88       }
    89       $data['date_creation'] = $_POST['date_creation-'.$row['id']].' '.$time;
     81      $data['date_creation'] = $_POST['date_creation-'.$row['id']];
    9082    }
    9183    else
     
    222214
    223215    $src_image = new SrcImage($row);
    224 
    225     // creation date
    226     if (!empty($row['date_creation']))
    227     {
    228       list($date) = explode(' ', $row['date_creation']);
    229     }
    230     else
    231     {
    232       $date = '';
    233     }
    234216
    235217    $query = '
     
    261243        'LEVEL' => !empty($row['level'])?$row['level']:'0',
    262244        'DESCRIPTION' => htmlspecialchars(@$row['comment']),
    263         'DATE_CREATION' => $date,
     245        'DATE_CREATION' => $row['date_creation'],
    264246        'TAGS' => $tag_selection,
    265247        )
  • trunk/admin/history.php

    r28497 r28500  
    571571  // by default, at page load, we want the selected date to be the current
    572572  // date
    573   $form['start'] = $form['end'] = date('Y-n-j');
     573  $form['start'] = $form['end'] = date('Y-m-d');
    574574  $form['types'] = $types;
    575575  // Hoverbox by default
  • trunk/admin/picture_modify.php

    r28497 r28500  
    128128  if (!empty($_POST['date_creation']))
    129129  {
    130     $data['date_creation'] = $_POST['date_creation'].' '.$_POST['date_creation_time'];
     130    $data['date_creation'] = $_POST['date_creation'];
    131131  }
    132132  else
     
    255255        : @$row['author']
    256256      ),
     257
     258    'DATE_CREATION' => $row['date_creation'],
    257259
    258260    'DESCRIPTION' =>
     
    317319  );
    318320
    319 // creation date
    320 unset($day, $month, $year);
    321 
    322 if (!empty($row['date_creation']))
    323 {
    324   list($date, $time) = explode(' ', $row['date_creation']);
    325 }
    326 else
    327 {
    328   $date = '';
    329   $time = '00:00:00';
    330 }
    331 
    332 $template->assign(
    333     array(
    334       'DATE_CREATION' => $date,
    335       'DATE_CREATION_TIME' => $time,
    336       )
    337     );
    338 
     321// categories
    339322$query = '
    340323SELECT category_id, uppercats
  • trunk/admin/themes/default/js/datepicker.js

    r28497 r28500  
     1jQuery.timepicker.log = jQuery.noop; // that's ugly, but the timepicker is acting weird and throws parsing errors
     2
    13jQuery.fn.pwgDatepicker = function(options) {
    24  options = options || {};
     
    57    var $this = jQuery(this),
    68        $target = jQuery('[name="'+ jQuery(this).data('datepicker') +'"]'),
    7         value = $target.val().split('-');
     9        linked = !!$target.length;
    810   
    9     function set(date) {
    10       $this.datepicker('setDate', date);
     11    if (linked) { // get value before init
     12      var value = $target.val().split(' ');
     13    }
     14
     15    // custom setter
     16    function set(date, init) {
     17      $this.datetimepicker('setDate', date);
    1118     
    1219      if ($this.data('datepicker-start')) {
    13         $start.datepicker('option', 'maxDate', date);
     20        $start.datetimepicker('option', 'maxDate', date);
    1421      }
    1522      else if ($this.data('datepicker-end')) {
    16         $end.datepicker('option', 'minDate', date);
     23        if (!init) { // on init, "end" is not initialized yet (assuming "start" is before "end" in the DOM)
     24          $end.datetimepicker('option', 'minDate', date);
     25        }
     26      }
     27     
     28      if (!date && linked) {
     29        $target.val('');
    1730      }
    1831    }
    1932
    2033    // init picker
    21     $this.datepicker(jQuery.extend({
    22       dateFormat: 'DD d MM yy',
    23       altField: $target,
     34    $this.datetimepicker(jQuery.extend({
     35      dateFormat: linked ? 'DD d MM yy' : 'yy-mm-dd',
     36      timeFormat: 'HH:mm',
     37     
     38      altField: linked ? $target : null,
    2439      altFormat: 'yy-mm-dd',
     40      altTimeFormat: options.showTimepicker ? 'HH:mm:ss' : '',
     41     
    2542      autoSize: true,
    2643      changeMonth : true,
    27       changeYear: true
     44      changeYear: true,
     45      showTimepicker: false,
     46      altFieldTimeOnly: false,
     47      showSecond: false,
     48      alwaysSetTime: false,
     49      stepMinute: 5
    2850    }, options));
    2951   
    30     // attach linked picker (for ranges)
     52    // attach range pickers
    3153    if ($this.data('datepicker-start')) {
    3254      var $start = jQuery('[data-datepicker="'+ jQuery(this).data('datepicker-start') +'"]');
    3355     
    34       $this.datepicker('option', 'onClose', function(date) {
    35         $start.datepicker('option', 'maxDate', date);
     56      $this.datetimepicker('option', 'onClose', function(date) {
     57        $start.datetimepicker('option', 'maxDate', date);
    3658      });
     59     
     60      $this.datetimepicker('option', 'minDate', $start.datetimepicker('getDate'));
    3761    }
    3862    else if ($this.data('datepicker-end')) {
    3963      var $end = jQuery('[data-datepicker="'+ jQuery(this).data('datepicker-end') +'"]');
    4064     
    41       $this.datepicker('option', 'onClose', function(date) {
    42         $end.datepicker('option', 'minDate', date);
     65      $this.datetimepicker('option', 'onClose', function(date) {
     66        $end.datetimepicker('option', 'minDate', date);
    4367      });
    4468    }
     
    4872      jQuery('#'+ $this.data('datepicker-unset')).on('click', function(e) {
    4973        e.preventDefault();
    50        
    51         $target.val('');
    52         set(null);
     74        set(null, false);
    5375      });
    5476    }
    5577   
    5678    // set value from linked input
    57     if (value.length == 3) {
    58       set(new Date(value[0], value[1]-1, value[2]));
     79    if (linked) {
     80      if (value[0].length == 10 && !options.showTimepicker) {
     81        set(jQuery.datepicker.parseDate('yy-mm-dd', value[0]), true);
     82      }
     83      else if (value.length == 2 && options.showTimepicker) {
     84        set(jQuery.datepicker.parseDateTime('yy-mm-dd', 'HH:mm:ss', value.join(' ')), true);
     85      }
     86      else {
     87        set(null, true);
     88      }
     89    }
     90   
     91    // autoSize not handled by timepicker
     92    if (options.showTimepicker) {
     93      $this.attr('size', parseInt($this.attr('size'))+6);
    5994    }
    6095  });
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r28497 r28500  
    6161{footer_script require='jquery.tokeninput'}
    6262jQuery(document).ready(function() {ldelim}
    63   jQuery('[data-datepicker]').pwgDatepicker();
     63  jQuery('[data-datepicker]').pwgDatepicker({ showTimepicker: true });
    6464
    6565  jQuery("a.preview-box").colorbox();
  • trunk/admin/themes/default/template/batch_manager_unit.tpl

    r28497 r28500  
    5252{* <!-- DATEPICKER --> *}
    5353jQuery(function(){ {* <!-- onLoad needed to wait localization loads --> *}
    54   jQuery('[data-datepicker]').pwgDatepicker();
     54  jQuery('[data-datepicker]').pwgDatepicker({ showTimepicker: true });
    5555});
    5656
  • trunk/admin/themes/default/template/include/datepicker.inc.tpl

    r28497 r28500  
    1 {combine_script id='datepicker.js' load='footer' require='jquery.ui.datepicker' path='admin/themes/default/js/datepicker.js'}
     1{combine_script id='jquery.ui.timepicker-addon' load='footer' require='jquery.ui.datepicker,jquery.ui.slider' path="themes/default/js/ui/jquery.ui.timepicker-addon.js"}
     2{combine_script id='datepicker.js' load='footer' require='jquery.ui.timepicker-addon' path='admin/themes/default/js/datepicker.js'}
    23
    34{assign var="datepicker_language" value="themes/default/js/ui/i18n/jquery.ui.datepicker-`$lang_info.code`.js"}
    4 
    55{if "PHPWG_ROOT_PATH"|@constant|@cat:$datepicker_language|@file_exists}
    6 {combine_script id="jquery.ui.datepicker-$lang_info.code" load='footer' path=$datepicker_language}
     6{combine_script id="jquery.ui.datepicker-$lang_info.code" load='footer' require='jquery.ui.datepicker' path=$datepicker_language}
    77{/if}
    88
     9{assign var="timepicker_language" value="themes/default/js/ui/i18n/jquery.ui.timepicker-`$lang_info.code`.js"}
     10{if "PHPWG_ROOT_PATH"|@constant|@cat:$datepicker_language|@file_exists}
     11{combine_script id="jquery.ui.timepicker-$lang_info.code" load='footer' require='jquery.ui.timepicker-addon' path=$timepicker_language}
     12{/if}
     13
     14{combine_css path="themes/default/js/ui/theme/jquery.ui.slider.css"}
    915{combine_css path="themes/default/js/ui/theme/jquery.ui.datepicker.css"}
     16{combine_css path="themes/default/js/ui/theme/jquery.ui.timepicker-addon.css"}
  • trunk/admin/themes/default/template/picture_modify.tpl

    r28497 r28500  
    7878{* <!-- DATEPICKER --> *}
    7979jQuery(function(){ {* <!-- onLoad needed to wait localization loads --> *}
    80   jQuery('[data-datepicker]').pwgDatepicker();
     80  jQuery('[data-datepicker]').pwgDatepicker({ showTimepicker: true });
    8181});
    8282}());
     
    141141      <strong>{'Creation date'|@translate}</strong>
    142142      <br>
    143       <input type="hidden" name="date_creation_time" value="{$DATE_CREATION_TIME}">
    144143      <input type="hidden" name="date_creation" value="{$DATE_CREATION}">
    145144      <label>
Note: See TracChangeset for help on using the changeset viewer.