From db8c035f00a266b5cd0f77754c37ecdff560896f Mon Sep 17 00:00:00 2001 From: mudrd8mz Date: Sun, 17 Jun 2007 02:05:18 +0000 Subject: [PATCH] * To choose a file to edit, popup_form() is used now. It saves some space on the screen. * Started to work on GUI improvements. Menu tabs introduced. Heading to fix MDL-8012 * "Number of missing strings" or "No missing strings" displayed in the missing mode. Fixes MDL-7029 This commit covers changes from 1.88.2.5 to 1.88.2.8 which were accidentally done on MOODLE_18_STABLE instead of HEAD. --- admin/lang.php | 203 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 134 insertions(+), 69 deletions(-) diff --git a/admin/lang.php b/admin/lang.php index 7bb9bf97a5..78c4595249 100644 --- a/admin/lang.php +++ b/admin/lang.php @@ -5,8 +5,8 @@ require_once('../config.php'); require_once($CFG->libdir.'/adminlib.php'); - - admin_externalpage_setup('langedit'); + $adminroot = admin_get_root(); + admin_externalpage_setup('langedit', $adminroot); define('LANG_SUBMIT_REPEAT', 1); // repeat displaying submit button? define('LANG_SUBMIT_REPEAT_EVERY', 20); // if so, after how many lines? @@ -46,8 +46,12 @@ $strfilecreated = get_string('filecreated', 'admin'); $strprev = get_string('previous'); $strnext = get_string('next'); - - + $strlocalstringcustomization = 'Local string customization'; // TODO / FIXME + $strlangpackmaintaining = 'Language pack maintaining'; // TODO / FIXME + $strnomissingstrings = 'No missing strings'; // TODO / FIXME + // TODO/FIXME add into en_utf8/admin.php: + // $string['numberofmissingstrings'] = 'Number of missing strings: $a'; + $currentlang = current_language(); switch ($mode) { @@ -77,18 +81,43 @@ } - admin_externalpage_print_header(); + admin_externalpage_print_header($adminroot); + + // Prepare and render menu tabs + $firstrow = array(); + $secondrow = array(); + $inactive = NULL; + $activated = NULL; + $currenttab = $mode; + if ($uselocal) { + $inactive = array('uselocal'); + $activated = array('uselocal'); + } else { + $inactive = array('usemaster'); + $activated = array('usemaster'); + } + $firstrow[] = new tabobject('uselocal', + $CFG->wwwroot."/admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=1", + $strlocalstringcustomization ); + $firstrow[] = new tabobject('usemaster', + $CFG->wwwroot."/admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=0", + $strlangpackmaintaining ); + $secondrow[] = new tabobject('missing', $CFG->wwwroot.'/admin/lang.php?mode=missing', $strmissingstrings ); + $secondrow[] = new tabobject('compare', $CFG->wwwroot.'/admin/lang.php?mode=compare', $streditstrings ); + // TODO + // langdoc.php functionality is planned to be merged into lang.php + $secondrow[] = new tabobject('langdoc', $CFG->wwwroot.'/admin/langdoc.php', $stredithelpdocs ); + $tabs = array($firstrow, $secondrow); + print_tabs($tabs, $currenttab, $inactive, $activated); + if (!$mode) { print_box_start(); $currlang = current_language(); $langs = get_list_of_languages(false, true); popup_form ("$CFG->wwwroot/$CFG->admin/lang.php?lang=", $langs, "chooselang", $currlang, "", "", "", false, 'self', $strcurrentlanguage.':'); - print_heading("$strmissingstrings"); - print_heading("$streditstrings"); - print_heading("$stredithelpdocs"); print_box_end(); - admin_externalpage_print_footer(); + admin_externalpage_print_footer($adminroot); exit; } @@ -191,7 +220,7 @@ foreach ($files as $filekey => $file) { // check all the help files. if (!file_exists("$langdir/help/$file")) { - echo "wwwroot/$CFG->admin/langdoc.php?sesskey=$USER->sesskey&currentfile=help/$file\">" .get_string("filemissing", "", "$currentlang/help/$file") . "" . "
\n"; + echo "

".get_string("filemissing", "", "$langdir/help/$file")."

"; $somethingfound = true; continue; } @@ -202,7 +231,7 @@ } foreach ($files as $filekey => $file) { // check all the docs files. if (!file_exists("$langdir/docs/$file")) { - echo "wwwroot/$CFG->admin/langdoc.php?sesskey=$USER->sesskey&currentfile=docs/$file\">" .get_string("filemissing", "", "$currentlang/docs/$file") . "" . "
\n"; + echo "

".get_string("filemissing", "", "$langdir/docs/$file")."

"; $somethingfound = true; continue; } @@ -211,7 +240,7 @@ if (!empty($somethingfound)) { print_continue("lang.php"); } else { - notice(get_string("languagegood"), "lang.php"); + notice(get_string("languagegood"), "lang.php", '', $adminroot); } } else if ($mode == "compare") { @@ -279,32 +308,21 @@ unset($packstring); } - print_heading_with_help($streditstrings, "langedit"); - print_box_start('generalbox editstrings'); + $menufiles = array(); foreach ($stringfiles as $file) { - if ($file == $currentfile) { - echo "$file   "; - } else { - echo "$file   "; - } + $menufiles[$file] = $file; } - print_box_end(); + popup_form("$CFG->wwwroot/$CFG->admin/lang.php?mode=compare&currentfile=", $menufiles, "choosefile", + $currentfile, $strchoosefiletoedit); - print_heading("$strmissingstrings", "center", 4); // one-click way back - - print_box_start(); + echo '
'; echo $strfilestoredin; + echo ''; echo $uselocal ? "{$currentlang}_local" : $currentlang; + echo ''; helpbutton('langswitchstorage', $strfilestoredinhelp, 'moodle'); - - echo '
frametarget.' method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'. - '
'. - ''. - ''. - ''. - ''. - '
'; + echo '
'; print_box_end(); if ($currentfile <> '') { @@ -329,11 +347,7 @@ } error_reporting($CFG->debug); - print_heading("$currentfile", "", 4); - if (LANG_DISPLAY_MISSING_LINKS && $editable) { - print_heading(''.$strgotofirst.'', "", 4); - } - + $o = ''; // stores the HTML output to be echo-ed unset($string); include("$enlangdir/$currentfile"); $enstring = $string; @@ -354,36 +368,36 @@ @include("$langdir/$currentfile"); if ($editable) { - echo "
"; - echo '
'; + $o .= ""; + $o .= '
'; } - echo ""; + $o .= "
"; $linescounter = 0; $missingcounter = 0; foreach ($enstring as $key => $envalue) { $linescounter++ ; if (LANG_SUBMIT_REPEAT && $editable && $linescounter % LANG_SUBMIT_REPEAT_EVERY == 0) { - echo ''; + $o .= ''; } $envalue = nl2br(htmlspecialchars($envalue)); $envalue = preg_replace('/(\$a\-\>[a-zA-Z0-9]*|\$a)/', '$0', $envalue); // Make variables bold. $envalue = str_replace("%%","%",$envalue); $envalue = str_replace("\\","",$envalue); // Delete all slashes - echo "\n\n".''; - echo ''."\n"; + $o .= '">'; + $o .= ''."\n"; // Missing array keys are not bugs here but missing strings error_reporting(E_ALL ^ E_NOTICE); @@ -433,7 +447,7 @@ } if ($editable) { - echo ''; + $o .= $missingnext . ''; } else { - echo ''; + $o .= ''; } - echo ''."\n"; + $o .= ''."\n"; } if ($editable) { - echo ''; + $o .= ''; } - echo '
 
'; - echo ' '; - echo '
 
 
'; + $o .= ''; + $o .= '
 
'; - echo ''.$envalue.''; - echo '
'."\n"; - echo ''.$key.''; - echo '
'; + $o .= ''.$envalue.''; + $o .= '
'."\n"; + $o .= ''.$key.''; + $o .= '
'. $missingprev . $missingtarget."\n"; + $o .= ''. $missingprev . $missingtarget."\n"; if (isset($string[$key])) { $valuelen = strlen($value); } else { @@ -442,44 +456,56 @@ $cols=40; if (strstr($value, "\r") or strstr($value, "\n") or $valuelen > $cols) { $rows = ceil($valuelen / $cols); - echo ''."\n"; + $o .= ''."\n"; } else { if ($valuelen) { $cols = $valuelen + 5; } - echo ''; + $o .= ''; } if ($value2 <> '' && $value <> $value2) { - echo '
'.$value2.''; + $o .= '
'.$value2.''; } - echo $missingnext . '
'.$value.''.$value.'
 
'; - echo ''; - echo ' '; - echo ' '; - echo ' '; - echo '
 
'; + $o .= ''; + $o .= ''; + $o .= ''; + $o .= ''; + $o .= '
'; + $o .= ''; if ($editable) { - echo '
'; - echo ''; + $o .= '
'; + $o .= ''; + } + + if (LANG_DISPLAY_MISSING_LINKS) { + if ($missingcounter > 0) { + print_heading(get_string('numberofmissingstrings', 'admin', $missingcounter), '', 4); + if ($editable) { + print_heading(''.$strgotofirst.'', "", 4); + } + } else { + print_heading($strnomissingstrings, '', 4, 'notifysuccess'); + } } + echo $o; } else { // no $currentfile specified - print_heading($strchoosefiletoedit, "", 4); + // no useful information to display - maybe some help? instructions? } } - admin_externalpage_print_footer(); + admin_externalpage_print_footer($adminroot); ////////////////////////////////////////////////////////////////////// @@ -704,5 +730,44 @@ function lang_xhtml_save_substr($str, $start, $length = NULL) { } } +/** +* Find all language location. +* +* Taken from lib/moodlelib.php::get_strig() +* +* @todo This is here just because I started to work on MDL-9361. It is not used yet. And maybe will not. +*/ +function lang_locations($module = '') { + global $CFG; + + // Default language packs locations + $locations = array( $CFG->dataroot.'/lang/', $CFG->dirroot.'/lang/' ); + + // Extra places to look for strings + $rules = places_to_search_for_lang_strings(); + $exceptions = $rules['__exceptions']; + unset($rules['__exceptions']); + + // Add all other possible locations + if (!in_array($module, $exceptions)) { + $dividerpos = strpos($module, '_'); + if ($dividerpos === false) { + $type = ''; + $plugin = $module; + } else { + $type = substr($module, 0, $dividerpos + 1); + $plugin = substr($module, $dividerpos + 1); + } + if (!empty($rules[$type])) { + foreach ($rules[$type] as $location) { + $locations[] = $CFG->dirroot . "/$location/$plugin/lang/"; + } + } + } + + return $locations; + +} + ?> -- 2.39.5