eGroupWare PHP Cross Reference Groupware Applications

Source: /etemplate/inc/class.uilangfile.inc.php - 649 lines - 22575 bytes - Summary - Text - Print

   1  <?php
   2  /**
   3   * EGroupware - TranslationTools
   4   *
   5   * @link http://www.egroupware.org
   6   * @author Miles Lott <milos(at)groupwhere.org>
   7   * @author Ralf Becker <RalfBecker(at)outdoor-training.de>
   8   * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
   9   * @package etemplate
  10   * @subpackage translationtools
  11   * @version $Id$
  12   */
  13  
  14  class uilangfile
  15  {
  16      var $helpme;
  17      var $public_functions = array(
  18          'index'     => True,
  19          'edit'      => True,
  20          'create'    => True,
  21          'addphrase' => True,
  22          'missingphrase'=> True,
  23          'missingphrase2'=> True,
  24          'download'  => True
  25      );
  26      /**
  27       * business object
  28       *
  29       * @var bolangfile
  30       */
  31      var $bo;
  32      /**
  33       * Reference to global Template object
  34       *
  35       * @var Template
  36       */
  37      var $template;
  38      /**
  39       * nextmatchs object
  40       *
  41       * @var nextmatches
  42       */
  43      var $nextmatchs;
  44  
  45      var $use_app = 'developer_tools';
  46  
  47  	function __construct()
  48      {
  49          $this->template = new Template(EGW_SERVER_ROOT.'/etemplate/templates/default');
  50          $this->template->egroupware_hack = False;    // else the phrases got translated
  51          $this->bo = new bolangfile();
  52          $this->nextmatchs = new nextmatchs();
  53          translation::add_app('developer_tools');
  54          translation::add_app('common');
  55          egw_framework::csp_script_src_attrs('unsafe-inline');
  56  
  57          if (empty($GLOBALS['egw_info']['user']['apps']['developer_tools']))
  58          {
  59              $this->use_app = 'etemplate';
  60          }
  61      }
  62  
  63  	function addphrase()
  64      {
  65          $app_name   = get_var('app_name',array('POST','GET'));
  66          $sourcelang = get_var('sourcelang',array('POST','GET'));
  67          $targetlang = get_var('targetlang',array('POST','GET'));
  68          $entry      = $_POST['entry'];
  69  
  70          $this->bo->read_sessiondata();
  71          if($_POST['add'] || $_POST['cancel'] || $_POST['more'])
  72          {
  73              if($_POST['add'] || $_POST['more'])
  74              {
  75                  if (get_magic_quotes_gpc())
  76                  {
  77                      foreach(array('message_id','content','target') as $name)
  78                      {
  79                          $entry[$name] = stripslashes($entry[$name]);
  80                      }
  81                  }
  82                  $this->bo->addphrase($entry);
  83                  if ($sourcelang == $targetlang)
  84                  {
  85                      $this->bo->target_langarray = $this->bo->source_langarray;
  86                  }
  87                  $this->bo->save_sessiondata();
  88              }
  89              if (!$_POST['more'])
  90              {
  91                  $GLOBALS['egw']->redirect_link('/index.php',array(
  92                      'menuaction' => $this->use_app.'.uilangfile.edit',
  93                      'app_name'   => $app_name,
  94                      'sourcelang' => $sourcelang,
  95                      'targetlang' => $targetlang
  96                  ));
  97              }
  98          }
  99          $GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps'][$GLOBALS['egw_info']['flags']['currentapp']]['title'].
 100              ' - '.lang('Add new phrase');
 101  
 102          common::egw_header();
 103          echo parse_navbar();
 104  
 105          $this->template->set_var('form_action',$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.addphrase"));
 106          $this->template->set_var('sourcelang',$sourcelang);
 107          $this->template->set_var('targetlang',$targetlang);
 108          $this->template->set_var('app_name',$app_name);
 109  
 110          $this->template->set_file(array('form' => 'addphrase.tpl'));
 111          $this->template->set_var('message_id_field','<textarea rows="5" style="width: 100%;" name="entry[message_id]"></textarea>');
 112          if ($app_name == 'api') $app_name = 'common';
 113          $this->template->set_var('app_field',$this->lang_option($app_name,isset($entry)?$entry['app_name']:$app_name,'entry[app_name]'));
 114          $this->template->set_var('translation_field','<textarea rows="5" style="width: 100%;"  name="entry[content]"></textarea>');
 115          $this->template->set_var('target_field','<textarea rows="5" style="width: 100%;" name="entry[target]"></textarea>');
 116  
 117          $this->template->set_var('lang_message_id',lang('message_id in English'));
 118          $this->template->set_var('lang_app',lang('Application'));
 119          $this->template->set_var('lang_translation',lang('Phrase in English (or empty if identical)'));
 120          $this->template->set_var('lang_target',lang('Translation of phrase'));
 121          $this->template->set_var('lang_add',lang('Add'));
 122          $this->template->set_var('lang_more',lang('Add more'));
 123          $this->template->set_var('lang_cancel',lang('Cancel'));
 124  
 125          $this->template->pfp('phpgw_body','form');
 126      }
 127  
 128  	function missingphrase()
 129      {
 130          $app_name    = get_var('app_name',array('POST','GET'));
 131          $sourcelang  = get_var('sourcelang',array('POST','GET'));
 132          $targetlang  = get_var('targetlang',array('POST','GET'));
 133  
 134          $this->bo->read_sessiondata();
 135          $this->bo->missing_app($app_name,$sourcelang);
 136          $this->bo->save_sessiondata();
 137  
 138          // we have to redirect here, as solangfile defines function sidebox_menu, which clashes with the iDots func.
 139          //
 140          $GLOBALS['egw']->redirect_link('/index.php',array(
 141              'menuaction' => $this->use_app.'.uilangfile.missingphrase2',
 142              'app_name'   => $app_name,
 143              'sourcelang' => $sourcelang,
 144              'targetlang' => $targetlang
 145          ));
 146      }
 147  
 148  	function missingphrase2()
 149      {
 150          $app_name    = get_var('app_name',array('POST','GET'));
 151          $sourcelang  = get_var('sourcelang',array('POST','GET'));
 152          $targetlang  = get_var('targetlang',array('POST','GET'));
 153          $newlang     = $_POST['newlang'];
 154          $dlsource    = $_POST['dlsource'];
 155          $writesource = $_POST['writesource'];
 156          $dltarget    = $_POST['dltarget'];
 157          $writetarget = $_POST['writetarget'];
 158          $update      = $_POST['update'];
 159          $entry       = $_POST['entry'];
 160          $submit      = $_POST['submit'];
 161          $this->bo->read_sessiondata();
 162  
 163          $this->template->set_file(array('langfile' => 'langmissing.tpl'));
 164          $this->template->set_block('langfile','header','header');
 165          $this->template->set_block('langfile','postheader','postheader');
 166          $this->template->set_block('langfile','detail','detail');
 167          $this->template->set_block('langfile','prefooter','prefooter');
 168          $this->template->set_block('langfile','footer','footer');
 169          if(!$sourcelang)
 170          {
 171              $sourcelang = 'en';
 172          }
 173          if(!$targetlang)
 174          {
 175              $targetlang = 'en';
 176          }
 177          $missingarray = $this->bo->missing_langarray;
 178          //echo "missingarray=<pre>"; print_r($this->bo->missing_langarray); echo "</pre>\n";
 179          if ($update)
 180          {
 181              $deleteme     = $_POST['delete'];
 182              //echo "deleteme=<pre>"; print_r($deleteme); echo "</pre>\n";
 183  
 184              while (list($_mess,$_checked) = @each($deleteme))
 185              {
 186                  if($_checked == 'on')
 187                  {
 188                      $_mess = $this->recode_id($_mess);
 189                      $this->bo->movephrase($_mess);
 190                      /* _debug_array($missingarray[$_mess]); */
 191                      unset($missingarray[$_mess]);
 192                      /* _debug_array($missingarray[$_mess]); */
 193                  }
 194              }
 195              unset($deleteme);
 196  
 197              $this->bo->save_sessiondata();
 198              $GLOBALS['egw']->redirect_link('/index.php',array(
 199                  'menuaction' => $this->use_app.'.uilangfile.edit',
 200                  'app_name'   => $app_name,
 201                  'sourcelang' => $sourcelang,
 202                  'targetlang' => $targetlang
 203              ));
 204          }
 205          common::egw_header();
 206          echo parse_navbar();
 207  
 208          $this->template->set_var('lang_remove',lang('Add phrase'));
 209          $this->template->set_var('lang_application',lang('Application'));
 210          $this->template->set_var('lang_update',lang('Add'));
 211          $this->template->set_var('lang_view',lang('Cancel'));
 212  
 213          $this->template->set_var('action_url',$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.missingphrase2"));
 214          $this->template->set_var('sourcelang',$sourcelang);
 215          $this->template->set_var('targetlang',$targetlang);
 216          $this->template->set_var('app_name',$app_name);
 217          $this->template->set_var('app_title',$GLOBALS['egw_info']['apps'][$app_name]['title']);
 218          $this->template->pfp('out','header');
 219          if($sourcelang && $targetlang)
 220          {
 221              $this->template->set_var('lang_appname',lang('Application'));
 222              $this->template->set_var('lang_message',lang('Message'));
 223              $this->template->set_var('lang_original',lang('Original'));
 224              $this->template->set_var('view_link',
 225                  $GLOBALS['egw']->link(
 226                      '/index.php',
 227                      "menuaction=$this->use_app.uilangfile.edit&app_name=".$app_name.'&sourcelang=' . $sourcelang . '&targetlang=' . $targetlang
 228                  )
 229              );
 230              $this->template->pfp('out','postheader');
 231              while(list($key,$data) = @each($missingarray))
 232              {
 233                  $mess_id  = $this->encode_id($key);
 234                  $this->template->set_var('mess_id',$mess_id);
 235                  $this->template->set_var('source_content',html::htmlspecialchars($data['content']));
 236                  $this->template->set_var('transapp',$this->lang_option($app_name,$data['app_name'],"transapp[$mess_id]"));
 237                  $this->template->set_var('tr_class',$this->nextmatchs->alternate_row_color('',true));
 238                  $this->template->pfp('out','detail');
 239              }
 240              $this->template->pfp('out','prefooter');
 241              $this->template->pfp('out','footer');
 242          }
 243          /* _debug_array($this->bo->loaded_apps); */
 244          $this->bo->save_sessiondata();
 245      }
 246  
 247  	function edit()
 248      {
 249          if ($_POST['cancel'])
 250          {
 251              $GLOBALS['egw']->redirect_link('/index.php', "menuaction=$this->use_app.uilangfile.index");
 252          }
 253          $app_name   = get_var('app_name',array('POST','GET'));
 254          $sourcelang = get_var('sourcelang',array('POST','GET'));
 255          $targetlang = get_var('targetlang',array('POST','GET'));
 256          $entry       = $_POST['entry'];
 257  
 258          if($_POST['addphrase'] || $_POST['missingphrase'])
 259          {
 260              $GLOBALS['egw']->redirect_link('/index.php',array(
 261                  'menuaction' => $this->use_app.'.uilangfile.'.($_POST['addphrase']?'addphrase':'missingphrase'),
 262                  'app_name'   => $app_name,
 263                  'sourcelang' => $sourcelang,
 264                  'targetlang' => $targetlang
 265              ));
 266          }
 267          if ($_POST['revert'])
 268          {
 269              $this->bo->clear_sessiondata();
 270          }
 271          $this->bo->read_sessiondata();
 272  
 273          if($_POST['dlsource'])
 274          {
 275              $this->download('source',$sourcelang);
 276          }
 277          if($_POST['dltarget'])
 278          {
 279              $this->download('target',$targetlang);
 280          }
 281          $GLOBALS['egw_info']['flags']['css'] .= ".untranslated { background-color: #dab0b0; }\n";
 282          common::egw_header();
 283          echo parse_navbar();
 284  
 285          $this->template->set_file(array('langfile' => 'langfile.tpl'));
 286          $this->template->set_block('langfile','header','header');
 287          $this->template->set_block('langfile','postheader','postheader');
 288          $this->template->set_block('langfile','detail','detail');
 289          $this->template->set_block('langfile','detail_long','detail_long');
 290          $this->template->set_block('langfile','footer','footer');
 291  
 292          $this->template->set_var('action_url',$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.edit"));
 293          $this->template->set_var('lang_remove',lang('Remove'));
 294          $this->template->set_var('lang_application',lang('Application'));
 295          $this->template->set_var('lang_source',lang('Source Language'));
 296          $this->template->set_var('lang_target',lang('Target Language'));
 297          $this->template->set_var('lang_submit',lang('Load'));
 298          $this->template->set_var('lang_update',lang('Save'));
 299          $this->template->set_var('lang_revert',lang('Revert'));
 300          $this->template->set_var('lang_cancel',lang('Cancel'));
 301          $this->template->set_var('lang_step',lang('Step'));
 302          $help = 'onMouseOver="self.status=\'%s\'; return true;" onMouseOut="self.status=\'\'; return true;"';
 303          $this->template->set_var('cancel_help',sprintf($help,str_replace("'","\\'",lang('Returns to the application list, not saved changes get lost !!!'))));
 304          $this->template->set_var('load_help',sprintf($help,str_replace("'","\\'",lang('Loads the selected lang-files, to be modified in the next steps'))));
 305          $this->template->set_var('update_help',sprintf($help,str_replace("'","\\'",lang('Saves the added/changed translations to an internal buffer, to be used in further steps'))));
 306          $this->template->set_var('search_help',sprintf($help,str_replace("'","\\'",lang('Searches the source-code for phrases not in the actual source-lang-file'))));
 307          $this->template->set_var('add_help',sprintf($help,str_replace("'","\\'",lang('Allows you to add a single phrase'))));
 308          $this->template->set_var('revert_help',sprintf($help,str_replace("'","\\'",lang('Clears the internal buffer, all changes made sofar are lost'))));
 309          $this->template->set_var('download_help',sprintf($help,str_replace("'","\\'",lang('Download the lang-file to be saved in the apps setup-dir'))));
 310          $this->template->set_var('write_help',sprintf($help,str_replace("'","\\'",lang('Write the lang-file to the apps setup-dir'))));
 311  
 312          if(!$sourcelang)
 313          {
 314              $sourcelang = 'en';
 315          }
 316          if(!$targetlang)
 317          {
 318              $targetlang = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
 319          }
 320  
 321          foreach(translation::list_langs() as $lang_id => $lang_name)
 322          {
 323              $sourcelangs .= '      <option value="' . $lang_id . '"';
 324              if ($lang_id == $sourcelang || !$sourcelang && $lang_id == 'en')
 325              {
 326                  $sourcelangs .= ' selected="selected"';
 327              }
 328              $sourcelangs .= '>' . $lang_name . '</option>' . "\n";
 329  
 330              $targetlangs .= '      <option value="' . $lang_id . '"';
 331              if ($lang_id == $targetlang || !$targetlang && $lang_id == 'en')
 332              {
 333                  $targetlangs .= ' selected="selected"';
 334              }
 335              $targetlangs .= '>' . $lang_name . '</option>' . "\n";
 336          }
 337          $this->template->set_var('sourcelangs',$sourcelangs);
 338          $this->template->set_var('targetlangs',$targetlangs);
 339          $this->template->set_var('app_name',$app_name);
 340          $this->template->set_var('app_title',$GLOBALS['egw_info']['apps'][$app_name]['title']);
 341          $this->template->pfp('out','header');
 342  
 343          foreach($GLOBALS['egw_info']['apps']+array('setup' => array('title' => lang('Setup'))) as $app => $data)
 344          {
 345              $userapps .= '<option value="' . $userapp . '"';
 346              if ($application_name == $userapp)
 347              {
 348                  $userapps .= ' selected="selected"';
 349              }
 350              $userapps .= '>' . $data['title'] . '</option>' . "\n";
 351          }
 352          $this->template->set_var('userapps',$userapps);
 353  
 354          if ($_POST['update'] || $_POST['update_too'])
 355          {
 356              $transapp     = $_POST['transapp'];
 357              $translations = $_POST['translations'];
 358              $deleteme     = $_POST['delete'];
 359              foreach($transapp as $_mess => $_app)
 360              {
 361                  if($_mess)
 362                  {
 363                      $_mess = strtolower(trim($this->recode_id($_mess)));
 364                      $this->bo->source_langarray[$_mess]['app_name'] = $_app;
 365                      $this->bo->target_langarray[$_mess]['app_name'] = $_app;
 366                  }
 367              }
 368              if (!is_array($this->bo->target_langarray))
 369              {
 370                  $this->bo->target_langarray = array();
 371              }
 372              foreach($translations as $_mess => $_cont)
 373              {
 374                  if($_mess && $_cont)
 375                  {
 376                      $_mess = strtolower(trim($this->recode_id($_mess)));
 377                      $this->bo->target_langarray[$_mess]['message_id'] = $_mess;
 378                      //POST method adds slashes if magic_quotes_gpc is set !!!
 379                      if (get_magic_quotes_gpc())
 380                      {
 381                          $_cont = stripslashes($_cont);
 382                      }
 383                      $this->bo->target_langarray[$_mess]['content'] = $_cont;
 384                      if($sourcelang == $targetlang)
 385                      {
 386                          $this->bo->source_langarray[$_mess]['content'] = $_cont;
 387                      }
 388                  }
 389              }
 390              if ($deleteme)
 391              foreach($deleteme as $_mess => $_checked)
 392              {
 393                  if($_checked == 'on')
 394                  {
 395                      $_mess = strtolower(trim($this->recode_id($_mess)));
 396                      unset($this->bo->source_langarray[$_mess]);
 397                      unset($this->bo->target_langarray[$_mess]);
 398                  }
 399              }
 400              @ksort($this->bo->source_langarray);
 401              @ksort($this->bo->target_langarray);
 402              /* $this->bo->save_sessiondata($this->bo->source_langarray,$this->bo->target_langarray); */
 403              unset($transapp);
 404              unset($translations);
 405              if($deleteme)
 406              {
 407                  $this->bo->save_sessiondata();
 408              }
 409              unset($deleteme);
 410          }
 411          if($_POST['writesource'] || $_POST['writesource_too'])
 412          {
 413              echo '<br>'.lang("Writing langfile for '%1' ...",$sourcelang);
 414              $this->bo->write_file('source',$app_name,$sourcelang);
 415          }
 416          if($_POST['writetarget'] || $_POST['writetarget_too'])
 417          {
 418              echo '<br>'.lang("Writing langfile for '%1' ...",$targetlang);
 419              $this->bo->write_file('target',$app_name,$targetlang);
 420          }
 421  
 422          if($sourcelang && $targetlang)
 423          {
 424              $this->template->set_var('lang_appname',lang('Application'));
 425              $this->template->set_var('lang_message',lang('Message'));
 426              $this->template->set_var('lang_original',lang('Original'));
 427              $this->template->set_var('lang_translation',lang('Translation'));
 428              $this->template->set_var('lang_missingphrase',lang('Search new phrases'));
 429              $this->template->set_var('lang_addphrase',lang('Add new phrase'));
 430              $this->template->set_var('sourcelang',$sourcelang);
 431              $this->template->set_var('targetlang',$targetlang);
 432              $this->template->pfp('out','postheader');
 433  
 434              $langarray = $this->bo->add_app($app_name,$sourcelang);
 435              $translation = $this->bo->load_app($app_name,$targetlang);
 436  
 437              while(list($key,$data) = @each($langarray))
 438              {
 439                  $mess_id  = $this->encode_id($key);
 440                  $content  = html::htmlspecialchars($mess_id == 'charset' ? $mess_id : $data['content']);
 441                  $transy   = html::htmlspecialchars($translation[$key]['content']);
 442                  $this->template->set_var('mess_id',$mess_id);
 443                  $this->template->set_var('source_content',$content);
 444                  $this->template->set_var('content',$transy);
 445                  $this->template->set_var('transapp',$this->lang_option($app_name,$data['app_name'],"transapp[$mess_id]"));
 446                  $this->template->set_var('tr_class',empty($transy) ? 'untranslated' : $this->nextmatchs->alternate_row_color('',true));
 447                  if (($len = max(strlen($key),strlen($content))) > 50)
 448                  {
 449                      $this->template->set_var('rows',min(intval($len/80+0.5),10));
 450                      $this->template->pfp('out','detail_long');
 451                  }
 452                  else
 453                  {
 454                      $this->template->pfp('out','detail');
 455                  }
 456              }
 457              $this->template->set_var('sourcelang',$sourcelang);
 458              $this->template->set_var('targetlang',$targetlang);
 459              $this->template->set_var('lang_write',lang('Write'));
 460              $this->template->set_var('lang_download',lang('Download'));
 461              $this->template->set_var('src_file',$this->bo->src_file);
 462              if(!$this->bo->loaded_apps[$sourcelang]['writeable'])
 463              {
 464                  $this->template->set_block('footer','srcwrite','srcwrite');
 465                  $this->template->set_var('srcwrite','');
 466              }
 467              $this->template->set_var('tgt_file',$this->bo->tgt_file);
 468              $this->template->set_var('targetlang',$targetlang);
 469              if(!$this->bo->loaded_apps[$targetlang]['writeable'])
 470              {
 471                  $this->template->set_block('footer','tgtwrite','tgtwrite');
 472                  $this->template->set_var('tgtwrite','');
 473              }
 474  
 475              $this->template->set_var('helpmsg',lang('you have to [Save] every manual change in the above fields, before you can go to the next step !!!'));
 476              $this->template->pfp('out','footer');
 477          }
 478          /* _debug_array($this->bo->loaded_apps); */
 479          $this->bo->save_sessiondata();
 480      }
 481  
 482  	function encode_id($id)
 483      {
 484          return str_replace(array('[',']','&','"'),array('%5B','%5D','&amp;','&quot;'),$id);
 485      }
 486  
 487  	function recode_id($id)
 488      {
 489          if (get_magic_quotes_gpc())
 490          {
 491              $id = stripslashes($id);
 492          }
 493          return str_replace(array('%5B','%5D'),array('[',']'),$id);    // &amp; + &quot; are recode by php
 494      }
 495  
 496  	function download($which,$userlang)
 497      {
 498          switch ($which)
 499          {
 500              case 'source':
 501                  $langarray = $this->bo->source_langarray;
 502                  break;
 503              case 'target':
 504                  // removing phrases not in the source language
 505                  $langarray = $this->bo->target_langarray = array_intersect_assoc($this->bo->target_langarray,$this->bo->source_langarray);
 506                  break;
 507              default:
 508                  break;
 509          }
 510          html::content_header(translation::LANGFILE_PREFIX . $userlang . '.lang');
 511          $to = translation::charset($userlang);
 512          $from = translation::charset();
 513          while(list($mess_id,$data) = @each($langarray))
 514          {
 515              $content = translation::convert(trim($data['content']),$from,$to);
 516              if (!empty($content))
 517              {
 518                  echo $mess_id . "\t" . $data['app_name'] . "\t" . $userlang . "\t" . $content . "\n";
 519              }
 520          }
 521          common::egw_exit();
 522      }
 523  
 524  	function index()
 525      {
 526          $start = $_POST['start'];
 527          $sort  = $_POST['sort'];
 528          $order = $_POST['order'];
 529          $query = $_POST['query'];
 530  
 531          $this->bo->save_sessiondata('','');
 532          $GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps'][$GLOBALS['egw_info']['flags']['currentapp']]['title'].
 533              ' - '.lang('Installed applications');
 534          common::egw_header();
 535          echo parse_navbar();
 536  
 537          $this->template->set_file(array('applications' => 'applications.tpl'));
 538          $this->template->set_block('applications','list','list');
 539          $this->template->set_block('applications','row','row');
 540  
 541          $offset = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
 542  
 543          $apps = array(
 544              strtolower(lang('Setup')) => array(
 545                  'name'  => 'setup',
 546                  'title' => lang('Setup')
 547              )
 548          );
 549          foreach($GLOBALS['egw_info']['apps'] as $app => $data)
 550          {
 551              $apps[strtolower($data['title'])] = $data;
 552          }
 553          $total = count($apps);
 554  
 555          if(!$sort)
 556          {
 557              $sort = 'ASC';
 558          }
 559  
 560          if($sort == 'ASC')
 561          {
 562              ksort($apps);
 563          }
 564          else
 565          {
 566              krsort($apps);
 567          }
 568  
 569          if ($start && $offset)
 570          {
 571              $limit = $start + $offset;
 572          }
 573          elseif ($start && !$offset)
 574          {
 575              $limit = $start;
 576          }
 577          elseif(!$start && !$offset)
 578          {
 579              $limit = $total;
 580          }
 581          else
 582          {
 583              $start = 0;
 584              $limit = $offset;
 585          }
 586  
 587          if ($limit > $total)
 588          {
 589              $limit = $total;
 590          }
 591  
 592          $this->template->set_var('sort_title',$this->nextmatchs->show_sort_order($sort,'title','title','/index.php',lang('Title'),"&menuaction=$this->use_app.uilangfile.index"));
 593          $this->template->set_var('lang_showing',$this->nextmatchs->show_hits($total,$start));
 594          $this->template->set_var('left',$this->nextmatchs->left('/index.php',$start,$total,"&menuaction=$this->use_app.uilangfile.index"));
 595          $this->template->set_var('right',$this->nextmatchs->right('/index.php',$start,$total,"&menuaction=$this->use_app.uilangfile.index"));
 596  
 597          $this->template->set_var('lang_edit',lang('Edit'));
 598          //$this->template->set_var('lang_translate',lang('Translate'));
 599          $this->template->set_var('new_action',$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.create"));
 600          $this->template->set_var('create_new',lang('Create New Language File'));
 601  
 602          $i = 0;
 603          foreach($apps as $data)
 604          {
 605              if($start <= $i && $i < $limit)
 606              {
 607                  $this->template->set_var('tr_class',$this->nextmatchs->alternate_row_color('',true));
 608  
 609                  $this->template->set_var('name',$data['title']);
 610  
 611                  $this->template->set_var('edit','<a href="' . $GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.edit&app_name=" . urlencode($data['name'])) . '"> ' . lang('Edit') . ' </a>');
 612              //    $this->template->set_var('translate','<a href="' . $GLOBALS['egw']->link('/index.php',"menuaction=$this->use_app.uilangfile.translate&app_name=" . urlencode($app['name'])) . '"> ' . lang('Translate') . ' </a>');
 613  
 614                  $this->template->set_var('status',$status);
 615  
 616                  $this->template->parse('rows','row',True);
 617              }
 618              ++$i;
 619          }
 620  
 621          $this->template->pparse('phpgw_body','list');
 622      }
 623  
 624  	function lang_option($app_name,$current,$name)
 625      {
 626          $list = (is_array($this->bo->src_apps) ? $this->bo->src_apps : array()) + array(
 627              $app_name     => $app_name,
 628              'common'      => 'common',
 629              'login'       => 'login',
 630              'admin'       => 'admin',
 631              'preferences' => 'preferences'
 632          );
 633  
 634          $select  = "\n" .'<select name="' . $name . '">' . "\n";
 635          foreach($list as $key => $val)
 636          {
 637              $select .= '<option value="' . $key . '"';
 638              if ($key == $current && $current != '')
 639              {
 640                  $select .= ' selected="selected"';
 641              }
 642              $select .= '>' . $val . '</option>'."\n";
 643          }
 644  
 645          $select .= '</select>'."\n";
 646  
 647          return $select;
 648      }
 649  }

title

Description

title

Description

title

Description

title

title

Body