PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/published/wbsadmin/html/scripts/localization.php

https://github.com/foxluck/otdelstroy
PHP | 202 lines | 122 code | 45 blank | 35 comment | 19 complexity | f2e8279383ae4c57df611acd35e43731 MD5 | raw file
  1. <?php
  2. /*
  3. $init_required = false;
  4. require_once( "../../../common/html/includes/httpinit.php" );
  5. require_once( WBS_DIR."/published/wbsadmin/wbsadmin.php" );
  6. $templateName = "classic";
  7. // $language = LANG_ENG;
  8. */
  9. if ( !isset( $lang_id ) )
  10. $lang_id = $language;
  11. define( "ALLTYPES", "ALLTYPES" );
  12. // Load application strings
  13. //
  14. /* $kernelStrings = $loc_str[$language];
  15. $LocalizationStrings = $db_loc_str[$language];
  16. $fatalError = false;
  17. $errorStr = null;*/
  18. $updated = false;
  19. $btnIndex = getButtonIndex( array("cancelbtn", "languagesbtn", "applybtn", "undobtn"), $_POST );
  20. switch ( $btnIndex ) {
  21. case 0 :
  22. redirectBrowser( PAGE_DB_LANGUAGES, array( 'lang_id'=>$lang_id, 'app_id'=>$app_id ) );
  23. case 1 :
  24. redirectBrowser( PAGE_DB_LANGUAGES, array( 'lang_id'=>$lang_id, 'app_id'=>$app_id, ) );
  25. case 2 :
  26. $updated = true;
  27. $res = wbs_saveFullLocalizationStrings( $lang_id, $app_id, $userIds, $userGroups, $userStrings, $userDescr, $kernelStrings, $LocalizationStrings, true );
  28. if ( PEAR::isError($res) ) {
  29. $errorStr = $res->getMessage();
  30. break;
  31. }
  32. $messageStr .= $LocalizationStrings['wbs_settings_update_success'];
  33. break;
  34. case 3 :
  35. redirectBrowser( PAGE_DB_LOCALIZATION, array( 'lang_id'=>$lang_id, 'app_id'=>$app_id ) );
  36. }
  37. switch ( true ) {
  38. case true :
  39. // Load languages
  40. //
  41. $sys_languages = wbs_listSysLanguages();
  42. if ( PEAR::isError($sys_languages) )
  43. {
  44. $errorStr = $sys_languages->getMessage();
  45. $fatalError = true;
  46. break;
  47. }
  48. $lang_ids = array();
  49. $lang_names = array();
  50. $lang_vals = array();
  51. foreach ( $sys_languages as $key=>$value )
  52. {
  53. $lang_ids[] = $key;
  54. $lang_names[] = $value[WBS_LANGUAGE_NAME];
  55. $lang_vals[] = $value;
  56. if ( $key == $lang_id )
  57. $cur_lang = $value;
  58. }
  59. $show_import = 1;
  60. if ( $cur_lang[WBS_LANGUAGE_ID] == LANG_ENG )
  61. $show_import = 0;
  62. // Load applications
  63. //
  64. $appList = listPublishedApplications( $language, true );
  65. if ( !is_array( $appList ) ) {
  66. $fatalError = true;
  67. $errorStr = $LocalizationStrings[1];
  68. break;
  69. }
  70. $appList = sortPublishedApplications( $appList );
  71. if ( !is_array( $appList ) )
  72. return PEAR::raiseError( $LocalizationStrings[1] );
  73. $app_ids = array( AA_APP_ID,MW_APP_ID,WBSADMIN_APP_ID );
  74. $app_names = array( $LocalizationStrings[25], $LocalizationStrings[64], $LocalizationStrings[6] );
  75. //HACK for DD/2.0
  76. if(isset($appList['DD'])){
  77. $app_dd = 'DD';
  78. $appList_ = array();
  79. $extra_dds = array('%s 2.0'=>'%s ','%s 2.0 backend'=>'%s_backend_folders','%s 2.0 public'=>'%s_public','%s 2.0 template'=>'%s_template_backend');
  80. foreach($extra_dds as $alter_name=>$alter_path){
  81. $alter_app_id = sprintf($alter_path, $app_dd);
  82. $appList_[$alter_app_id] = $appList[$app_dd];
  83. $appList_[$alter_app_id][APP_REG_APPLICATION][APP_REG_LOCAL_NAME] = sprintf($alter_name,$appList_[$alter_app_id][APP_REG_APPLICATION][APP_REG_LOCAL_NAME]);
  84. }
  85. $appList = array_merge($appList,$appList_);
  86. }
  87. foreach( $appList as $key=>$value ) {
  88. $app_ids[] = $key;
  89. $app_names[] = $value[APP_REG_APPLICATION][APP_REG_LOCAL_NAME];
  90. }
  91. // Load string groups
  92. //
  93. $groups = wbs_listApplicationStringGroups( $app_id, $lang_id );
  94. foreach( $groups as $key=>$value )
  95. {
  96. $type_ids[] = base64_encode($value);
  97. $type_names[] = $value;
  98. }
  99. $appList = listPublishedApplications( LANG_ENG, true );
  100. if ( !is_array( $appList ) )
  101. return PEAR::raiseError( $LocalizationStrings[1] );
  102. $appList = array_merge( array(
  103. AA_APP_ID => array(APP_REG_APPLICATION => array(APP_REG_LOCAL_NAME=>$LocalizationStrings[25]) ),
  104. MW_APP_ID => array(APP_REG_APPLICATION => array(APP_REG_LOCAL_NAME=>$LocalizationStrings[64]) ),
  105. WBSADMIN_APP_ID => array(APP_REG_APPLICATION => array(APP_REG_LOCAL_NAME=>$LocalizationStrings[6]) ),
  106. ), $appList );
  107. // Page encoding
  108. //
  109. $langData = $sys_languages[$lang_id];
  110. $html_encoding = $langData[WBS_ENCODING];
  111. if ( !isset($lang_id) /* || !in_array($lang_id, $lang_ids) */ )
  112. $lang_id = $lang_ids[0];
  113. if ( !isset($app_id) )
  114. $app_id = $app_ids[0];
  115. $appList = array($app_id=>$appList[$app_id]);
  116. $curLocalization = wbs_loadCheckedLocalizationStrings( $lang_id, $appList );
  117. }
  118. /*extract(wbs_getSystemStatistics());
  119. $preproc = new php_preprocessor( $templateName, $kernelStrings, $language, "wbsadmin" );
  120. $preproc->assign( 'systemConfiguration', $systemConfiguration );
  121. $preproc->assign( 'companyInfo', $companyInfo );
  122. $preproc->assign( 'systemInfo', $systemInfo );
  123. $preproc->assign( ERROR_STR, $errorStr );
  124. $preproc->assign( FATAL_ERROR, $fatalError );*/
  125. $preproc->assign( FORM_LINK, PAGE_DB_LOCALIZATION );
  126. if ( !$fatalError ) {
  127. $preproc->assign( "cur_lang", $cur_lang );
  128. $preproc->assign( "show_import", $show_import );
  129. $preproc->assign( "errorStr", $errorStr );
  130. $preproc->assign( "lang_ids", $lang_ids );
  131. $preproc->assign( "lang_names", $lang_names );
  132. $preproc->assign( "lang_id", $lang_id );
  133. $preproc->assign( "app_ids", $app_ids );
  134. $preproc->assign( "app_names", $app_names );
  135. $preproc->assign( "app_id", $app_id );
  136. if ( isset($type_ids) )
  137. $preproc->assign( "type_ids", $type_ids );
  138. if ( isset($type_names) )
  139. $preproc->assign( "type_names", $type_names );
  140. if ( isset($type_id) )
  141. $preproc->assign( "type_id", $type_id );
  142. $preproc->assign( "curLocalization", $curLocalization );
  143. $preproc->assign( "updated", $updated );
  144. }
  145. $preproc->assign( PAGE_TITLE, sprintf('%s &mdash; %s',translate('lll_page_title'),isset($cur_lang['NAME'])?$cur_lang['NAME']:translate('lll_page_name')));
  146. $preproc->assign( 'pdfGuideSize', sprintf( "%02.0fK", filesize( GUIDE_FILE )/1024 ) );
  147. $preproc->assign( 'pdfAdminFile', GUIDE_FILE );
  148. $preproc->assign( 'returnLink', PAGE_DB_WBSADMIN );
  149. $preproc->assign ( 'waStrings', $LocalizationStrings);
  150. //$preproc->display( "localization.htm" );
  151. $preproc->assign( "mainTemplate","localization.htm" );
  152. ?>