languages
[ class tree: languages ] [ index: languages ] [ all elements ]

Source for file master_strings.php

Documentation is available at master_strings.php

  1. <?php
  2. /**
  3.  * @package languages
  4.  * @subpackage functions
  5.  * @version $Header$
  6.  */
  7.  
  8. // Copyright (c) 2005, bitweaver.org
  9. // All Rights Reserved. See below for details and a complete list of authors.
  10. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
  11. /**
  12.  * Initialization
  13.  */
  14. require_once'../kernel/setup_inc.php' );
  15.  
  16. $gBitSystem->verifyPermission'p_languages_edit_master' );
  17.  
  18. $languages $gBitLanguage->listLanguages();
  19. $gBitSmarty->assign_by_ref'languages'$languages );
  20. $feedback $masterMsg array();
  21.  
  22. if!empty$_REQUEST['source_hash'&& !is_array$_REQUEST['source_hash') ) {
  23.     $_REQUEST['source_hash'array$_REQUEST['source_hash');
  24. }
  25.  
  26. if!empty$_REQUEST['delete_master'&& !empty$_REQUEST['source_hash') ) {
  27.     ifempty$_REQUEST['confirm') ) {
  28.         $gBitSystem->setBrowserTitletra'Confirm Delete' ) );
  29.         $formHash['delete_master'TRUE;
  30.         $msgHash array(
  31.             'label' => tra'Delete Master Strings' ),
  32.             'warning' => tra'This will remove the language master string. If you are tracking translations and the string is still used, it will be inserted again, however, any translations associated with it will be lost.' ),
  33.             'confirm_item' => tra"The following Master Strings will be removed" ).":",
  34.         );
  35.         foreach$_REQUEST['source_hash'as $source_hash {
  36.             $gBitLanguage->loadMasterStrings$source_hash );
  37.             $formHash['input']['<input type="hidden" name="source_hash[]" value="'.$source_hash.'"/>'.htmlentities$gBitLanguage->mStrings['master'][$source_hash]['source');
  38.         }
  39.         $gBitSystem->confirmDialog$formHash$msgHash );
  40.     else {
  41.         foreach$_REQUEST['source_hash'as $source_hash {
  42.             if$gBitLanguage->expungeMasterString$source_hash ) ) {
  43.                 $success TRUE;
  44.             else {
  45.                 $error TRUE;
  46.             }
  47.         }
  48.  
  49.         if!empty$error ) ) {
  50.             $feedback['error''At least one of the master strings could not be deleted.';
  51.         elseif!empty$success ) ) {
  52.             $feedback['success''The requested master strings were successfully deleted.';
  53.         }
  54.     }
  55. elseif!empty$_REQUEST['save_translations') ) {
  56.     foreach$_REQUEST['edit_trans'as $sourceHash => $sources {
  57.         foreach$sources as $langCode => $string {
  58.             $tranStrings[$sourceHash$gBitLanguage->getTranslatedStrings$sourceHash );
  59.             // store if (We had a string and it is now empty) or ( we have a new string and it is different from before)
  60.             if( (empty$string && !empty$tranStrings[$sourceHash][$langCode))
  61.                 || (!empty$string && (empty$tranStrings[$sourceHash][$langCode|| $string != $tranStrings[$sourceHash][$langCode]['trans']) ) ) {
  62.                 $gBitLanguage->storeTranslationString$langCode$string$sourceHash );
  63.             }
  64.         }
  65.         $gBitLanguage->loadMasterStrings$sourceHash );
  66.         if!empty$_REQUEST['edit_master'][$sourceHash) ) {
  67.             $newSourceHash $gBitLanguage->getSourceHash$_REQUEST['edit_master'][$sourceHash);
  68.             $gBitLanguage->loadMasterStrings();
  69.             if$newSourceHash != $sourceHash {
  70.                 if$gBitLanguage->storeMasterStringarray'source_hash' => $sourceHash'new_source' => $_REQUEST['edit_master'][$sourceHash) ) ) {
  71.                     unset$_REQUEST['source_hash');
  72.                     $_REQUEST['source_hash'][$newSourceHash;
  73.                     $tranStrings[$newSourceHash$gBitLanguage->getTranslatedStrings$newSourceHash );
  74.                     $masterMsg['success']['Master translation string has been updated';
  75.                 else {
  76.                     $masterMsg['error'][$gBitLanguage->mErrors['master'];
  77.                 }
  78.             }
  79.         }
  80.     }
  81.     $masterMsg['success']['Translation strings have been updated';
  82. elseif!empty$_REQUEST['find'&& !empty$_REQUEST['search') ) {
  83.     $gBitSmarty->assign_by_ref'masterStrings'$gBitLanguage->searchMasterStrings$_REQUEST['find') );
  84. else {
  85.     $gBitLanguage->loadMasterStrings(
  86.         NULL,
  87.         !empty$_REQUEST['filter'$_REQUEST['filter'NULL ),
  88.         !empty$_REQUEST['filter_lang'$_REQUEST['filter_lang'NULL )
  89.     );
  90.  
  91.     // work out what strings to display
  92.     ifempty$_REQUEST['char')) {
  93.         $pattern "/^a/i";
  94.     elseif $_REQUEST['char'== '0-9' {
  95.         $pattern "/^\d/";
  96.     elseif $_REQUEST['char'== '+' {
  97.         $pattern "/^[^a-zA-Z0-9]/";
  98.     elseif $_REQUEST['char'== 'all' {
  99.         $pattern "//";
  100.     else {
  101.         $pattern "/^".$_REQUEST['char']."/i";
  102.     }
  103.     $masterStr $gBitLanguage->mStrings['master'];
  104.     foreach$masterStr as $key => $master {
  105.         ifpreg_match$pattern$master['source') ) {
  106.             $masterStrings[$key$master;
  107.         }
  108.     }
  109.     $gBitSmarty->assign'char'empty$_REQUEST['char''' $_REQUEST['char');
  110.     $gBitSmarty->assign_by_ref'masterStrings'$masterStrings );
  111. }
  112.  
  113.  
  114. if!empty$_REQUEST['source_hash'&& empty$_REQUEST['cancel') ) {
  115.     foreach$_REQUEST['source_hash'as $reqSourceHash {
  116.         $gBitLanguage->loadMasterStrings$reqSourceHash );
  117.         ifstrlen$gBitLanguage->mStrings['master'][$reqSourceHash]['source'100 {
  118.             $gBitLanguage->mStrings['master'][$reqSourceHash]['textarea'TRUE;
  119.         }
  120.         $translate[$reqSourceHash$gBitLanguage->getTranslatedStrings$_REQUEST['source_hash');
  121.     }
  122.     $gBitSmarty->assign_by_ref'masterStrings'$gBitLanguage->mStrings['master');
  123.     $gBitSmarty->assign_by_ref'tranStrings'$translate );
  124.     $gBitSmarty->assign'sources'$_REQUEST['source_hash');
  125. }
  126.  
  127. // Display the template
  128. $gBitSmarty->assign'masterMsg'$masterMsg );
  129. $gBitSmarty->assign'feedback'$feedback );
  130. $gBitSystem->display'bitpackage:languages/language_master_strings.tpl''Edit Master Strings' array'display_mode' => 'display' ));
  131. ?>

Documentation generated on Wed, 29 Jul 2015 13:57:04 +0000 by phpDocumentor 1.5.0-lsces