Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 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 echo $output->continue_button(new moodle_url("/admin/tool/customlang/{$next}.php", array('lng' => $lng)), 'get'); 61 echo $output->footer(); 62 63 \core\session\manager::write_close(); 64 echo $OUTPUT->select_element_for_append(); 65 66 // We may need a bit of extra execution time and memory here. 67 core_php_time_limit::raise(HOURSECS); 68 raise_memory_limit(MEMORY_EXTRA); 69 tool_customlang_utils::checkout($lng, $progressbar); 70 71 exit; 72 } 73 if ($action === 'checkin') { 74 require_sesskey(); 75 require_capability('tool/customlang:edit', context_system::instance()); 76 if (empty($lng)) { 77 throw new \moodle_exception('missingparameter'); 78 } 79 80 if (!$confirm) { 81 $output = $PAGE->get_renderer('tool_customlang'); 82 echo $output->header(); 83 echo $output->heading(get_string('pluginname', 'tool_customlang')); 84 echo $output->heading($langs[$lng], 3); 85 $numofmodified = tool_customlang_utils::get_count_of_modified($lng); 86 if ($numofmodified != 0) { 87 echo $output->heading(get_string('modifiednum', 'tool_customlang', $numofmodified), 3); 88 echo $output->confirm(get_string('confirmcheckin', 'tool_customlang'), 89 new moodle_url($PAGE->url, array('action'=>'checkin', 'lng'=>$lng, 'confirm'=>1)), 90 new moodle_url($PAGE->url, array('lng'=>$lng))); 91 } else { 92 echo $output->heading(get_string('modifiedno', 'tool_customlang', $numofmodified), 3); 93 echo $output->continue_button(new moodle_url($PAGE->url, array('lng' => $lng))); 94 } 95 echo $output->footer(); 96 die(); 97 98 } else { 99 tool_customlang_utils::checkin($lng); 100 redirect($PAGE->url); 101 } 102 } 103 104 $output = $PAGE->get_renderer('tool_customlang'); 105 106 // output starts here 107 echo $output->header(); 108 echo $output->heading(get_string('pluginname', 'tool_customlang')); 109 110 if (empty($lng)) { 111 $s = new single_select($PAGE->url, 'lng', $langs); 112 $s->label = get_accesshide(get_string('language')); 113 $s->class = 'langselector'; 114 echo $output->box($OUTPUT->render($s), 'langselectorbox'); 115 echo $OUTPUT->footer(); 116 exit; 117 } 118 119 echo $output->heading($langs[$lng], 3); 120 121 $numofmodified = tool_customlang_utils::get_count_of_modified($lng); 122 123 if ($numofmodified != 0) { 124 echo $output->heading(get_string('modifiednum', 'tool_customlang', $numofmodified), 3); 125 } 126 127 $menu = array(); 128 if (has_capability('tool/customlang:edit', context_system::instance())) { 129 $menu['checkout'] = array( 130 'title' => get_string('checkout', 'tool_customlang'), 131 'url' => new moodle_url($PAGE->url, array('action' => 'checkout', 'lng' => $lng)), 132 'method' => 'post', 133 ); 134 if ($numofmodified != 0) { 135 $menu['checkin'] = array( 136 'title' => get_string('checkin', 'tool_customlang'), 137 'url' => new moodle_url($PAGE->url, array('action' => 'checkin', 'lng' => $lng)), 138 'method' => 'post', 139 ); 140 } 141 $menu['import'] = array( 142 'title' => get_string('import', 'tool_customlang'), 143 'url' => new moodle_url($PAGE->url, ['action' => 'checkout', 'lng' => $lng, 'next' => 'import']), 144 'method' => 'post', 145 ); 146 } 147 if (has_capability('tool/customlang:export', context_system::instance())) { 148 $langdir = tool_customlang_utils::get_localpack_location($lng); 149 if (check_dir_exists(dirname($langdir)) && count(glob("$langdir/*"))) { 150 $menu['export'] = [ 151 'title' => get_string('export', 'tool_customlang'), 152 'url' => new moodle_url("/admin/tool/customlang/export.php", ['lng' => $lng]), 153 'method' => 'post', 154 ]; 155 } 156 } 157 echo $output->render(new tool_customlang_menu($menu)); 158 159 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body