[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/inc/locales/ -> _locale_settings.form.php (source)

   1  <?php
   2  /**

   3   * This file implements the UI view for the regional 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-2007 by Francois PLANQUE - {@link http://fplanque.net/}

   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: _locale_settings.form.php,v 1.1 2007/06/25 11:00:38 fplanque Exp $

  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, $locales_path, $locales, $action, $edit_locale, $loc_transinfo, $template, $allow_po_extraction, $servertimenow, $allow_po_extraction;
  47  global $localtimenow;
  48  
  49  
  50  if( $action == 'edit' )
  51  { // Edit a locale:
  52      param( 'template', 'string', ($edit_locale == '_new_') ? T_('Create new locale') : T_('Edit locale'), 'createnew' );
  53  
  54      $Form = & new Form( $pagenow, 'loc_checkchanges' );
  55  
  56      $Form->begin_form( 'fform', T_('Regional Settings') );
  57  
  58      $Form->hidden( 'ctrl', 'locales' );
  59      $Form->hidden( 'loc_transinfo', $loc_transinfo );
  60      $Form->hidden( 'action', ($edit_locale == '_new_') ? 'createlocale' : 'updatelocale' );
  61  
  62      // read template

  63  
  64      if( isset($locales[$template]) )
  65      {
  66          $ltemplate = $locales[ $template ];
  67          $newlocale = $template;
  68      }
  69      elseif( $edit_locale != '_new_' && isset($locales[ $edit_locale ]) )
  70      {
  71          $ltemplate = $locales[ $edit_locale ];
  72          $newlocale = $edit_locale;
  73      }
  74      else
  75      {
  76          $newlocale = '';
  77      }
  78  
  79      if( $edit_locale != '_new_' )
  80      { // we need to remember this for updating locale
  81          $Form->hidden( 'oldloc_locale', $newlocale );
  82      }
  83  
  84      $Form->begin_fieldset();
  85      $Form->text( 'newloc_locale', $newlocale, 20, T_('Locale'), sprintf(T_('The first two letters should be a <a %s>ISO 639 language code</a>. The last two letters should be a <a %s>ISO 3166 country code</a>.'), 'href="http://www.gnu.org/software/gettext/manual/html_chapter/gettext_15.html#SEC221"', 'href="http://www.gnu.org/software/gettext/manual/html_chapter/gettext_16.html#SEC222"'), 20 );
  86      $Form->checkbox( 'newloc_enabled', (isset($ltemplate['enabled']) && $ltemplate['enabled']), T_('Enabled'),    T_('Should this locale be available to users?') );
  87      $Form->text( 'newloc_name', (isset($ltemplate['name']) ? $ltemplate['name'] : ''), 40, T_('Name'),
  88          T_('name of the locale'), 40 );
  89      $Form->text( 'newloc_charset', (isset($ltemplate['charset']) ? $ltemplate['charset'] : ''), 20, T_('Charset'), T_('Must match the lang file charset.'), 15 );
  90      $Form->text( 'newloc_datefmt', (isset($ltemplate['datefmt']) ? $ltemplate['datefmt'] : ''), 20, T_('Date format'), T_('See below.'), 20 );
  91      $Form->text( 'newloc_timefmt', (isset($ltemplate['timefmt']) ? $ltemplate['timefmt'] : ''), 20, T_('Time format'), T_('See below.'), 20 );
  92      $Form->dayOfWeek( 'newloc_startofweek', (isset($ltemplate['startofweek']) ? $ltemplate['startofweek'] : 0), T_('Start of week'), T_('Day at the start of the week.') );
  93      $Form->text( 'newloc_messages', (isset($ltemplate['messages']) ? $ltemplate['messages'] : ''), 20, T_('Lang file'),
  94          T_('the lang file to use, from the <code>locales</code> subdirectory'), 20 );
  95      $Form->text( 'newloc_priority', (isset($ltemplate['priority']) ? $ltemplate['priority'] : ''), 3, T_('Priority'),
  96          T_('1 is highest. Priority is important when selecting a locale from a language code and several locales match the same language; this can happen when detecting browser language. Priority also affects the order in which locales are displayed in dropdown boxes, etc.'), 5 );
  97  
  98      // TODO: Update this field onchange of datefmt/timefmt through AJAX:

  99      // fp> It would actually make more sense to have the preview at the exact place that says "see below"

 100      locale_temp_switch($newlocale);
 101      $Form->info_field( T_('Date preview:'), date_i18n( locale_datefmt().' '.locale_timefmt(), $localtimenow ) );
 102      locale_restore_previous();
 103  
 104      // generate Javascript array of locales to warn in case of overwriting

 105      $l_warnfor = "'".implode("', '", array_keys($locales))."'";
 106      if( $edit_locale != '_new_' )
 107      { // remove the locale we want to edit from the generated array
 108          $l_warnfor = str_replace("'$newlocale'", "'thiswillneverevermatch'", $l_warnfor);
 109      }
 110      $Form->end_fieldset();
 111  
 112      $Form->end_form( array( array( 'submit', 'submit', ($edit_locale == '_new_') ? T_('Create') : T_('Update'), 'SaveButton' ),
 113                                                      array( 'reset', '', T_('Reset'), 'ResetButton' ) ) );
 114  
 115      ?>
 116      <div class="panelinfo">
 117          <h3><?php echo T_('Flags') ?></h3>
 118          <p><?php printf(T_('The flags are stored in subdirectories of <code>%s</code>. Their filename is equal to the country part of the locale (characters 4-5); file extension is .gif .'), '/'.$rsc_subdir.'flags/'); ?></p>
 119          <h3><?php echo T_('Date/Time Formats') ?></h3>
 120          <p><?php echo T_('The following characters are recognized in the format strings:') ?></p>
 121          <p>
 122          <?php echo T_('a - "am" or "pm"') ?><br />
 123          <?php echo T_('A - "AM" or "PM"') ?><br />
 124          <?php echo T_('B - Swatch Internet time') ?><br />
 125          <?php echo T_('c - ISO 8601 date (Requires PHP 5); i.e. "2004-02-12T15:19:21+00:00"') ?><br />
 126          <?php echo T_('d - day of the month, 2 digits with leading zeros; i.e. "01" to "31"') ?><br />
 127          <?php echo T_('D - day of the week, textual, 3 letters; i.e. "Fri"') ?><br />
 128          <?php echo T_('e - day of the week, 1 letter; i.e. "F"') ?><br />
 129          <?php echo T_('F - month, textual, long; i.e. "January"') ?><br />
 130          <?php echo T_('g - hour, 12-hour format without leading zeros; i.e. "1" to "12"') ?><br />
 131          <?php echo T_('G - hour, 24-hour format without leading zeros; i.e. "0" to "23"') ?><br />
 132          <?php echo T_('h - hour, 12-hour format; i.e. "01" to "12"') ?><br />
 133          <?php echo T_('H - hour, 24-hour format; i.e. "00" to "23"') ?><br />
 134          <?php echo T_('i - minutes; i.e. "00" to "59"') ?><br />
 135          <?php echo T_('I (capital i) - "1" if Daylight Savings Time, "0" otherwise.') ?><br />
 136          <?php echo T_('j - day of the month without leading zeros; i.e. "1" to "31"') ?><br />
 137          <?php echo T_('l (lowercase "L") - day of the week, textual, long; i.e. "Friday"') ?><br />
 138          <?php echo T_('L - boolean for whether it is a leap year; i.e. "0" or "1"') ?><br />
 139          <?php echo T_('m - month; i.e. "01" to "12"') ?><br />
 140          <?php echo T_('M - month, textual, 3 letters; i.e. "Jan"') ?><br />
 141          <?php echo T_('n - month without leading zeros; i.e. "1" to "12"') ?><br />
 142          <?php echo T_('O - Difference to Greenwich time (GMT) in hours; i.e. "+0200"') ?><br />
 143          <?php echo T_('r - RFC 822 formatted date; i.e. "Thu, 21 Dec 2000 16:01:07 +0200"') ?><br />
 144          <?php echo T_('s - seconds; i.e. "00" to "59"') ?><br />
 145          <?php echo T_('S - English ordinal suffix, textual, 2 characters; i.e. "th", "nd"') ?><br />
 146          <?php echo T_('t - number of days in the given month; i.e. "28" to "31"') ?><br />
 147          <?php echo T_('T - Timezone setting of this machine; i.e. "MDT"') ?><br />
 148          <?php echo T_('U - seconds since the epoch') ?><br />
 149          <?php echo T_('w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday)') ?><br />
 150          <?php echo T_('W - ISO-8601 week number of year, weeks starting on Monday; i.e. "42"') ?><br />
 151          <?php echo T_('Y - year, 4 digits; i.e. "1999"') ?><br />
 152          <?php echo T_('y - year, 2 digits; i.e. "99"') ?><br />
 153          <?php echo T_('z - day of the year; i.e. "0" to "365"') ?><br />
 154          <?php echo T_('Z - timezone offset in seconds (i.e. "-43200" to "43200"). The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.') ?>
 155          </p>
 156          <?php echo T_('isoZ - full ISO 8601 format, equivalent to Y-m-d\TH:i:s\Z') ?><br />
 157          <p><?php echo T_('Unrecognized characters in the format string will be printed as-is.<br />
 158          You can escape characters by preceding them with a \ to print them as-is.') ?></p>
 159      </div>
 160  <?php
 161  }
 162  else
 163  { // show main form
 164      if( ! isset($locales[$Settings->get('default_locale')])
 165          || ! $locales[$Settings->get('default_locale')]['enabled'] )
 166      { // default locale is not enabled
 167          echo '<div class="error">' . T_('Note: default locale is not enabled.') . '</div>';
 168      }
 169  
 170      // JavaScript function to calculate time difference: {{{

 171      ?>
 172      <script type="text/javascript">
 173  
 174      var server_Date = new Date();
 175      server_Date.setTime( <?php echo $servertimenow.'000' ?> ); // milliseconds

 176      var user_Date = new Date();
 177  
 178  	function calc_TimeDifference(min_dif) {
 179          var ntd = user_Date.getTime() - server_Date.getTime();
 180          ntd = ntd / 1000; // to seconds

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

 183  
 184          var neg = ( ntd < 0 );
 185          ntd = Math.abs(ntd);
 186  
 187          var hours = Math.floor(ntd/3600);
 188          var mins = Math.floor( (ntd%3600)/60 );
 189          //var secs = Math.round( (ntd%3600)%60 );

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

 192  
 193          if( mins == 0 )
 194          {
 195              ntd = hours;
 196          }
 197          else
 198          {
 199              ntd = hours+':'+mins;
 200          }
 201  
 202          if( neg && ntd != '0' ) ntd = '-'+ntd;
 203  
 204          // Apply the calculated time difference

 205          document.getElementById('newtime_difference').value = ntd;
 206      }
 207      </script>
 208  
 209      <?php // }}}
 210  
 211      $Form = & new Form( $pagenow, 'loc_checkchanges' );
 212  
 213      $Form->begin_form( 'fform', T_('Regional Settings') );
 214  
 215      $Form->hidden( 'ctrl', 'locales' );
 216      $Form->hidden( 'action', 'update' );
 217      $Form->hidden( 'loc_transinfo', $loc_transinfo );
 218  
 219      $Form->begin_fieldset( T_('Regional settings') );
 220  
 221      // Time difference:

 222      $td_value = $Settings->get('time_difference');
 223      $neg = ( $td_value < 0 );
 224      $td_value = abs($td_value);
 225      if( $td_value % 3600 != 0 )
 226      { // we have minutes
 227          if( $td_value % 60 != 0 )
 228          { // we have seconds (hh:mm:ss)
 229              $td_value = floor($td_value/3600).':'.sprintf( '%02d', ($td_value % 3600)/60 ).':'.sprintf( '%02d', ($td_value%60) );
 230          }
 231          else
 232          { // hh:mm
 233              $td_value = floor($td_value/3600).':'.sprintf( '%02d', ($td_value % 3600)/60 );
 234          }
 235      }
 236      else
 237      { // just full hours:
 238          $td_value = $td_value/3600;
 239      }
 240      if($neg) { $td_value = '-'.$td_value; }
 241  
 242      $Form->text_input( 'newtime_difference', $td_value, 8 /* hh:mm:ss */, T_('Time difference'), sprintf( '['. T_('in hours, e.g. "1", "1:30" or "1.5"'). '] '. T_('If you\'re not on the timezone of your server. Current server time is: %s.'), '<span id="cur_servertime">'.date_i18n( locale_timefmt(), $servertimenow ).'</span>' )
 243                      .' <a href="#" onclick="calc_TimeDifference(); return false;">'.T_('Calculate time difference').'</a>',
 244                      array( 'maxlength'=> 8, 'required'=>true ) );
 245  
 246      $Form->select( 'newdefault_locale', $Settings->get('default_locale'), 'locale_options_return', T_('Default locale'), T_('Overridden by browser config, user locale or blog locale (in this order).'));
 247      $Form->end_fieldset();
 248  
 249  
 250      $Form->begin_fieldset( T_('Available locales') );
 251  
 252      echo '<p class="center">';
 253      if( $loc_transinfo )
 254      {
 255          echo '<a href="'.$pagenow.'?ctrl=locales">' . T_('Hide translation info'), '</a>';
 256      }
 257      else
 258      {
 259          echo '<a href="'.$pagenow.'?ctrl=locales&amp;loc_transinfo=1">' . T_('Show translation info'), '</a>';
 260      }
 261      echo '</p>';
 262  
 263      echo '<table class="grouped" cellspacing="0">';
 264  
 265      ?>
 266      <tr>
 267          <th class="firstcol"><?php echo T_('Locale') ?></th>
 268          <th><?php echo T_('Enabled') ?></th>
 269          <th><?php echo T_('Name') ?></th>
 270          <th><?php echo T_('Date fmt') ?></th>
 271          <th><?php echo T_('Time fmt') ?></th>
 272          <th title="<?php echo T_('Day at the start of the week: 0 for Sunday, 1 for Monday, 2 for Tuesday, etc');
 273              ?>"><?php echo T_('Start of week') ?></th>
 274          <?php if( $current_User->check_perm( 'options', 'edit' ) )
 275          { ?>
 276              <th><?php echo T_('Edit') ?></th>
 277              <?php
 278          }
 279          if( $loc_transinfo )
 280          {
 281              ?>
 282              <th><?php echo T_('Strings') ?></th>
 283              <th><?php echo T_('Translated') ?></th>
 284              <?php
 285              if( $current_User->check_perm( 'options', 'edit' ) && $allow_po_extraction )
 286              {
 287                  echo '<th class="lastcol">'.T_('Extract').'</th>';
 288              }
 289          } ?>
 290      </tr>
 291  
 292  
 293      <?php
 294      $i = 0; // counter to distinguish POSTed locales later

 295      foreach( $locales as $lkey => $lval )
 296      {
 297          $i++;
 298  
 299          // Generate preview of date/time-format:

 300          locale_temp_switch($lkey);
 301          $datefmt_preview = date_i18n( $locales[$lkey]['datefmt'], $localtimenow );
 302          $timefmt_preview = date_i18n( $locales[$lkey]['timefmt'], $localtimenow );
 303          locale_restore_previous();
 304  
 305          ?>
 306          <tr class="<?php echo (($i%2 == 1) ? 'odd' : 'even') ?>">
 307          <td class="firstcol left" title="<?php echo T_('Priority').': '.$locales[$lkey]['priority'].', '.T_('Charset').': '.$locales[$lkey]['charset'].', '.T_('Lang file').': '.$locales[$lkey]['messages'] ?>">
 308              <?php
 309              echo '<input type="hidden" name="loc_'.$i.'_locale" value="'.$lkey.'" />';
 310              locale_flag( $lkey );
 311              echo'
 312              <strong>';
 313              if( $current_User->check_perm( 'options', 'edit' ) )
 314              {
 315                  echo '<a href="'.$pagenow.'?ctrl=locales&amp;action=edit&amp;edit_locale='.$lkey.($loc_transinfo ? '&amp;loc_transinfo=1' : '').'" title="'.T_('Edit locale').'">';
 316              }
 317              echo $lkey;
 318              if( $current_User->check_perm( 'options', 'edit' ) )
 319              {
 320                  echo '</a>';
 321              }
 322  
 323              // TODO: Update title attribs for datefmt/timefmt onchange through AJAX  -- fp> all that complexity for an invisible tooltip... :/ Users should update the format on the detailed screen and get a dynamic preview there. Maybe the date and time should be editable on the list at all. There is no help here either. Users should be encouraged to go to the detailed screen )

 324              echo '</strong></td>
 325                  <td class="center">
 326                      <input type="checkbox" name="loc_'.$i.'_enabled" value="1"'. ( $locales[$lkey]['enabled'] ? 'checked="checked"' : '' ).' />
 327                  </td>
 328                  <td>
 329                      <input type="text" name="loc_'.$i.'_name" value="'.format_to_output( $locales[$lkey]['name'], 'formvalue' ).'" maxlength="40" size="17" />
 330                  </td>
 331                  <td>
 332                      <input type="text" name="loc_'.$i.'_datefmt" value="'.format_to_output( $locales[$lkey]['datefmt'], 'formvalue' ).'" maxlength="20" size="6" title="'.format_to_output( sprintf( T_('Preview: %s'), $datefmt_preview ), 'formvalue' ).'" />
 333                  </td>
 334                  <td>
 335                      <input type="text" name="loc_'.$i.'_timefmt" value="'.format_to_output( $locales[$lkey]['timefmt'], 'formvalue' ).'" maxlength="20" size="6" title="'.format_to_output( sprintf( T_('Preview: %s'), $timefmt_preview ), 'formvalue' ).'" />
 336                  </td>
 337                  <td>';
 338              $Form->switch_layout( 'none' );
 339              $Form->dayOfWeek( 'loc_'.$i.'_startofweek', $locales[$lkey]['startofweek'], '', '' );
 340              $Form->switch_layout( NULL ); // Restore layout

 341              echo '</td>';
 342  
 343          if( $current_User->check_perm( 'options', 'edit' ) )
 344          {
 345              if( $loc_transinfo )
 346              {
 347                  echo '<td class="shrinkwrap">';
 348              }
 349              else
 350              {
 351                  echo '<td class="lastcol shrinkwrap">';
 352              }
 353              if( $i > 1 )
 354              { // show "move prio up"
 355                  echo action_icon( T_('Move priority up'), 'move_up', $pagenow.'?ctrl=locales&amp;action=prioup&amp;edit_locale='.$lkey.($loc_transinfo ? '&amp;loc_transinfo=1' : '') );
 356              }
 357              else
 358              {
 359                  echo get_icon( 'nomove' ).' ';
 360              }
 361  
 362              if( $i < count($locales) )
 363              { // show "move prio down"
 364                  echo action_icon( T_('Move priority down'), 'move_down', $pagenow.'?ctrl=locales&amp;action=priodown&amp;edit_locale='.$lkey.($loc_transinfo ? '&amp;loc_transinfo=1' : '') );
 365              }
 366              else
 367              {
 368                  echo get_icon( 'nomove' ).' ';
 369              }
 370  
 371              echo action_icon( T_('Copy locale'), 'copy', $pagenow.'?ctrl=locales&amp;action=edit&amp;edit_locale=_new_&amp;template='.$lkey.($loc_transinfo ? '&amp;loc_transinfo=1' : '' ) );
 372  
 373              echo action_icon( T_('Edit locale'), 'edit', $pagenow.'?ctrl=locales&amp;action=edit&amp;edit_locale=_new_&amp;template='.$lkey.($loc_transinfo ? '&amp;loc_transinfo=1' : '' ) );
 374  
 375              if( isset($lval[ 'fromdb' ]) )
 376              { // allow to delete locales loaded from db
 377                  $l_atleastonefromdb = 1;
 378                  echo action_icon( T_('Reset custom settings'), 'delete', $pagenow.'?ctrl=locales&amp;action=deletelocale&amp;edit_locale='.$lkey.($loc_transinfo ? '&amp;loc_transinfo=1' : '' ) );
 379              }
 380              echo '</td>';
 381          }
 382  
 383          if( $loc_transinfo )
 384          {    // Show translation info:
 385              // Get PO file for that locale:

 386              $po_file = $locales_path.$locales[$lkey]['messages'].'/LC_MESSAGES/messages.po';
 387              if( ! is_file( $po_file ) )
 388              {
 389                  echo '<td class="lastcol center" colspan="'.(2 + (int)($current_User->check_perm( 'options', 'edit' ) && $allow_po_extraction)).'">'.T_('No language file...').'</td>';
 390              }
 391              else
 392              {    // File exists:
 393                  $lines = file( $po_file );
 394  
 395                  $lines[] = '';    // Adds a blank line at the end in order to ensure complete handling of the file

 396                  $all = 0;
 397                  $fuzzy = 0;
 398                  $this_fuzzy = false;
 399                  $untranslated=0;
 400                  $translated=0;
 401                  $status='-';
 402                  $matches = array();
 403                  foreach ($lines as $line)
 404                  {
 405                      // echo 'LINE:', $line, '<br />';

 406                      if(trim($line) == '' )
 407                      {    // Blank line, go back to base status:
 408                          if( $status == 't' )
 409                          {    // ** End of a translation ** :
 410                              if( $msgstr == '' )
 411                              {
 412                                  $untranslated++;
 413                                  // echo 'untranslated: ', $msgid, '<br />';

 414                              }
 415                              else
 416                              {
 417                                  $translated++;
 418                              }
 419                              if( $msgid == '' && $this_fuzzy )
 420                              {    // It's OK if first line is fuzzy
 421                                  $fuzzy--;
 422                              }
 423                              $msgid = '';
 424                              $msgstr = '';
 425                              $this_fuzzy = false;
 426                          }
 427                          $status = '-';
 428                      }
 429                      elseif( ($status=='-') && preg_match( '#^msgid "(.*)"#', $line, $matches))
 430                      {    // Encountered an original text
 431                          $status = 'o';
 432                          $msgid = $matches[1];
 433                          // echo 'original: "', $msgid, '"<br />';

 434                          $all++;
 435                      }
 436                      elseif( ($status=='o') && preg_match( '#^msgstr "(.*)"#', $line, $matches))
 437                      {    // Encountered a translated text
 438                          $status = 't';
 439                          $msgstr = $matches[1];
 440                          // echo 'translated: "', $msgstr, '"<br />';

 441                      }
 442                      elseif( preg_match( '#^"(.*)"#', $line, $matches))
 443                      {    // Encountered a followup line
 444                          if ($status=='o')
 445                              $msgid .= $matches[1];
 446                          elseif ($status=='t')
 447                              $msgstr .= $matches[1];
 448                      }
 449                      elseif(strpos($line,'#, fuzzy') === 0)
 450                      {
 451                          $this_fuzzy = true;
 452                          $fuzzy++;
 453                      }
 454                  }
 455  
 456                  // $all=$translated+$fuzzy+$untranslated;

 457                  echo "\n\t".'<td class="center">'.$all.'</td>';
 458  
 459                  $percent_done = ($all > 0) ? round(($translated-$fuzzy/2)/$all*100) : 0;
 460                  $color = sprintf( '%02x%02x00', 255 - round($percent_done * 2.55), round($percent_done * 2.55) );
 461                  echo "\n\t<td class=\"center\" style=\"background-color:#". $color . "\">". $percent_done ." %</td>";
 462  
 463              }
 464  
 465              if( $current_User->check_perm( 'options', 'edit' ) && $allow_po_extraction  )
 466              { // Translator options:
 467                  if( is_file( $po_file ) )
 468                  {
 469                      echo "\n\t".'<td class="lastcol">[<a href="'.$pagenow.'?ctrl=locales&amp;action=extract&amp;edit_locale='.$lkey.($loc_transinfo ? '&amp;loc_transinfo=1' : '').'" title="'.T_('Extract .po file into b2evo-format').'">'.T_('Extract').'</a>]</td>';
 470                  }
 471              }
 472          } // show message file percentage/extraction

 473  
 474          echo '</tr>';
 475      }
 476  
 477      echo '</table>';
 478  
 479      if( $current_User->check_perm( 'options', 'edit' ) )
 480      {
 481          echo '<p class="center"><a href="'.$pagenow.'?ctrl=locales&amp;action=edit'.( $loc_transinfo ? '&amp;loc_transinfo=1' : '' ).'&amp;edit_locale=_new_">'.get_icon( 'new' ).' '.T_('Create new locale').'</a></p>';
 482  
 483          if( isset($l_atleastonefromdb) )
 484          {
 485              echo '<p class="center"><a href="'.$pagenow.'?ctrl=locales&amp;action=reset'.( $loc_transinfo ? '&amp;loc_transinfo=1' : '' ).'" onclick="return confirm(\''.TS_('Are you sure you want to reset?').'\')">'.get_icon( 'delete' ).' '.T_('Reset to defaults (delete database table)').'</a></p>';
 486          }
 487      }
 488  
 489      $Form->end_fieldset();
 490  
 491      if( $current_User->check_perm( 'options', 'edit' ) )
 492      {
 493          $Form->end_form( array( array( 'submit', '', T_('Save !'), 'SaveButton' ),
 494                                                          array( 'reset', '', T_('Reset'), 'ResetButton' ) ) ) ;
 495      }
 496  }
 497  
 498  /*

 499   * $Log: _locale_settings.form.php,v $

 500   * Revision 1.1  2007/06/25 11:00:38  fplanque

 501   * MODULES (refactored MVC)

 502   *

 503   * Revision 1.16  2007/04/26 00:11:12  fplanque

 504   * (c) 2007

 505   *

 506   * Revision 1.15  2006/12/09 01:55:36  fplanque

 507   * feel free to fill in some missing notes

 508   * hint: "login" does not need a note! :P

 509   *

 510   * Revision 1.14  2006/11/24 18:27:26  blueyed

 511   * Fixed link to b2evo CVS browsing interface in file docblocks

 512   *

 513   * Revision 1.13  2006/11/15 00:35:14  blueyed

 514   * Fix

 515   *

 516   * Revision 1.12  2006/11/15 00:12:51  fplanque

 517   * doc

 518   */
 519  ?>


Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics