See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Performs checkout of the strings into the translation table 19 * 20 * @package tool 21 * @subpackage customlang 22 * @copyright 2010 David Mudrak <david@moodle.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 define('NO_OUTPUT_BUFFERING', true); // progress bar is used here 27 28 require(__DIR__ . '/../../../config.php'); 29 require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/locallib.php'); 30 require_once($CFG->libdir.'/adminlib.php'); 31 32 require_login(null, false); 33 require_capability('tool/customlang:view', context_system::instance()); 34 35 $action = optional_param('action', '', PARAM_ALPHA); 36 $confirm = optional_param('confirm', false, PARAM_BOOL); 37 $lng = optional_param('lng', '', PARAM_LANG); 38 $next = optional_param('next', 'edit', PARAM_ALPHA); 39 40 admin_externalpage_setup('toolcustomlang'); 41 $langs = get_string_manager()->get_list_of_translations(); 42 43 $PAGE->set_primary_active_tab('siteadminnode'); 44 45 // pre-output actions 46 if ($action === 'checkout') { 47 require_sesskey(); 48 require_capability('tool/customlang:edit', context_system::instance()); 49 if (empty($lng)) { 50 throw new \moodle_exception('missingparameter'); 51 } 52 53 $PAGE->set_cacheable(false); // progress bar is used here 54 $output = $PAGE->get_renderer('tool_customlang'); 55 echo $output->header(); 56 echo $output->heading(get_string('pluginname', 'tool_customlang')); 57 $progressbar = new progress_bar(); 58 $progressbar->create(); // prints the HTML code of the progress bar 59 60 // we may need a bit of extra execution time and memory here 61 core_php_time_limit::raise(HOURSECS); 62 raise_memory_limit(MEMORY_EXTRA); 63 tool_customlang_utils::checkout($lng, $progressbar); 64 65 echo $output->continue_button(new moodle_url("/admin/tool/customlang/{$next}.php", array('lng' => $lng)), 'get'); 66 echo $output->footer(); 67 exit; 68 } 69 if ($action === 'checkin') { 70 require_sesskey(); 71 require_capability('tool/customlang:edit', context_system::instance()); 72 if (empty($lng)) { 73 throw new \moodle_exception('missingparameter'); 74 } 75 76 if (!$confirm) { 77 $output = $PAGE->get_renderer('tool_customlang'); 78 echo $output->header(); 79 echo $output->heading(get_string('pluginname', 'tool_customlang')); 80 echo $output->heading($langs[$lng], 3); 81 $numofmodified = tool_customlang_utils::get_count_of_modified($lng); 82 if ($numofmodified != 0) { 83 echo $output->heading(get_string('modifiednum', 'tool_customlang', $numofmodified), 3); 84 echo $output->confirm(get_string('confirmcheckin', 'tool_customlang'), 85 new moodle_url($PAGE->url, array('action'=>'checkin', 'lng'=>$lng, 'confirm'=>1)), 86 new moodle_url($PAGE->url, array('lng'=>$lng))); 87 } else { 88 echo $output->heading(get_string('modifiedno', 'tool_customlang', $numofmodified), 3); 89 echo $output->continue_button(new moodle_url($PAGE->url, array('lng' => $lng))); 90 } 91 echo $output->footer(); 92 die(); 93 94 } else { 95 tool_customlang_utils::checkin($lng); 96 redirect($PAGE->url); 97 } 98 } 99 100 $output = $PAGE->get_renderer('tool_customlang'); 101 102 // output starts here 103 echo $output->header(); 104 echo $output->heading(get_string('pluginname', 'tool_customlang')); 105 106 if (empty($lng)) { 107 $s = new single_select($PAGE->url, 'lng', $langs); 108 $s->label = get_accesshide(get_string('language')); 109 $s->class = 'langselector'; 110 echo $output->box($OUTPUT->render($s), 'langselectorbox'); 111 echo $OUTPUT->footer(); 112 exit; 113 } 114 115 echo $output->heading($langs[$lng], 3); 116 117 $numofmodified = tool_customlang_utils::get_count_of_modified($lng); 118 119 if ($numofmodified != 0) { 120 echo $output->heading(get_string('modifiednum', 'tool_customlang', $numofmodified), 3); 121 } 122 123 $menu = array(); 124 if (has_capability('tool/customlang:edit', context_system::instance())) { 125 $menu['checkout'] = array( 126 'title' => get_string('checkout', 'tool_customlang'), 127 'url' => new moodle_url($PAGE->url, array('action' => 'checkout', 'lng' => $lng)), 128 'method' => 'post', 129 ); 130 if ($numofmodified != 0) { 131 $menu['checkin'] = array( 132 'title' => get_string('checkin', 'tool_customlang'), 133 'url' => new moodle_url($PAGE->url, array('action' => 'checkin', 'lng' => $lng)), 134 'method' => 'post', 135 ); 136 } 137 $menu['import'] = array( 138 'title' => get_string('import', 'tool_customlang'), 139 'url' => new moodle_url($PAGE->url, ['action' => 'checkout', 'lng' => $lng, 'next' => 'import']), 140 'method' => 'post', 141 ); 142 } 143 if (has_capability('tool/customlang:export', context_system::instance())) { 144 $langdir = tool_customlang_utils::get_localpack_location($lng); 145 if (check_dir_exists(dirname($langdir)) && count(glob("$langdir/*"))) { 146 $menu['export'] = [ 147 'title' => get_string('export', 'tool_customlang'), 148 'url' => new moodle_url("/admin/tool/customlang/export.php", ['lng' => $lng]), 149 'method' => 'post', 150 ]; 151 } 152 } 153 echo $output->render(new tool_customlang_menu($menu)); 154 155 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body