Dotclear


Ignore:
Timestamp:
10/06/13 14:35:08 (12 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
default
Message:

Add fixes when using %e modifier for windows dates.
Closes #1714, closes #1744

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/dbschema/upgrade.php

    r2274 r2295  
    360360                         files::deltree($root.'/daInstaller'); 
    361361                    } 
     362 
     363                    # add new settings for date and time formats 
     364                    $date_formats = array('%Y-%m-%d','%m/%d/%Y','%d/%m/%Y','%Y/%m/%d','%d.%m.%Y','%b %e %Y','%e %b %Y','%Y %b %e', 
     365                    '%a, %Y-%m-%d','%a, %m/%d/%Y','%a, %d/%m/%Y','%a, %Y/%m/%d','%B %e, %Y','%e %B, %Y','%Y, %B %e','%e. %B %Y', 
     366                    '%A, %B %e, %Y','%A, %e %B, %Y','%A, %Y, %B %e','%A, %Y, %B %e','%A, %e. %B %Y'); 
     367                    $time_formats = array('%H:%M','%I:%M','%l:%M','%Hh%M','%Ih%M','%lh%M'); 
     368                    if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { 
     369                         $date_formats = array_map(create_function('$f', 
     370                                                         'return str_replace(\'%e\',\'%#d\',$f);' 
     371                                                         ),$date_formats); 
     372                    } 
     373 
     374                    $strReqFormat = 'INSERT INTO '.$core->prefix.'setting'; 
     375                    $strReqFormat .= ' (setting_id,setting_ns,setting_value,setting_type,setting_label)'; 
     376                    $strReqFormat .= ' VALUES(\'%s\',\'system\',\'%s\',\'string\',\'%s\')'; 
     377                     
     378                    $strReqSelect = 'SELECT count(1) FROM '.$core->prefix.'setting'; 
     379                    $strReqSelect .= ' WHERE setting_id = \'%s\''; 
     380                    $strReqSelect .= ' AND setting_ns = \'system\''; 
     381                    $strReqSelect .= ' AND blog_id IS NULL'; 
     382 
     383                    $rs = $core->con->select(sprintf($strReqSelect,'date_formats')); 
     384                    if ($rs->f(0)==0) { 
     385                         $strReq = sprintf($strReqFormat,'date_formats',serialize($date_formats),'Date formats examples'); 
     386                         $core->con->execute($strReq);                       
     387                    } 
     388                    $rs = $core->con->select(sprintf($strReqSelect,'time_formats')); 
     389                    if ($rs->f(0)==0) { 
     390                         $strReq = sprintf($strReqFormat,'time_formats',serialize($time_formats),'Time formats examples'); 
     391                         $core->con->execute($strReq); 
     392                    } 
    362393               } 
    363394                
Note: See TracChangeset for help on using the changeset viewer.

Sites map