Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 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 * @package tool 19 * @subpackage customlang 20 * @copyright 2010 David Mudrak <david@moodle.com> 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 */ 23 24 require(__DIR__ . '/../../../config.php'); 25 require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/locallib.php'); 26 require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/filter_form.php'); 27 require_once($CFG->libdir.'/adminlib.php'); 28 29 require_login(SITEID, false); 30 require_capability('tool/customlang:edit', context_system::instance()); 31 32 $lng = required_param('lng', PARAM_LANG); 33 $currentpage = optional_param('p', 0, PARAM_INT); 34 $translatorsubmitted = optional_param('translatorsubmitted', 0, PARAM_BOOL); 35 36 admin_externalpage_setup('toolcustomlang', '', null, 37 new moodle_url('/admin/tool/customlang/edit.php', array('lng' => $lng)), 38 array('pagelayout' => 'report')); // Hack: allows for wide page contents. 39 40 $PAGE->requires->js_init_call('M.tool_customlang.init_editor', array(), true); 41 42 if (empty($lng)) { 43 // PARAM_LANG validation failed 44 print_error('missingparameter'); 45 } 46 47 // pre-output processing 48 $filter = new tool_customlang_filter_form($PAGE->url, null, 'post', '', array('class'=>'filterform')); 49 $filterdata = tool_customlang_utils::load_filter($USER); 50 $filter->set_data($filterdata); 51 52 if ($filter->is_cancelled()) { 53 redirect($PAGE->url); 54 55 } elseif ($submitted = $filter->get_data()) { 56 tool_customlang_utils::save_filter($submitted, $USER); 57 redirect(new moodle_url($PAGE->url, array('p'=>0))); 58 } 59 60 if ($translatorsubmitted) { 61 $strings = optional_param_array('cust', array(), PARAM_RAW); 62 $updates = optional_param_array('updates', array(), PARAM_INT); 63 $checkin = optional_param('savecheckin', false, PARAM_RAW); 64 65 if ($checkin === false) { 66 $nexturl = new moodle_url($PAGE->url, array('p' => $currentpage)); 67 } else { 68 $nexturl = new moodle_url('/admin/tool/customlang/index.php', array('action'=>'checkin', 'lng' => $lng, 'sesskey'=>sesskey())); 69 } 70 71 if (!is_array($strings)) { 72 $strings = array(); 73 } 74 $current = $DB->get_records_list('tool_customlang', 'id', array_keys($strings)); 75 $now = time(); 76 77 foreach ($strings as $recordid => $customization) { 78 $customization = trim($customization); 79 80 if (empty($customization) and !is_null($current[$recordid]->local)) { 81 $current[$recordid]->local = null; 82 $current[$recordid]->modified = 1; 83 $current[$recordid]->outdated = 0; 84 $current[$recordid]->timecustomized = null; 85 $DB->update_record('tool_customlang', $current[$recordid]); 86 continue; 87 } 88 89 if (empty($customization)) { 90 continue; 91 } 92 93 if ($customization !== $current[$recordid]->local) { 94 $current[$recordid]->local = $customization; 95 $current[$recordid]->modified = 1; 96 $current[$recordid]->outdated = 0; 97 $current[$recordid]->timecustomized = $now; 98 $DB->update_record('tool_customlang', $current[$recordid]); 99 continue; 100 } 101 } 102 103 if (!is_array($updates)) { 104 $updates = array(); 105 } 106 if (!empty($updates)) { 107 list($sql, $params) = $DB->get_in_or_equal($updates); 108 $DB->set_field_select('tool_customlang', 'outdated', 0, "local IS NOT NULL AND id $sql", $params); 109 } 110 111 redirect($nexturl); 112 } 113 114 $translator = new tool_customlang_translator($PAGE->url, $lng, $filterdata, $currentpage); 115 116 // output starts here 117 $output = $PAGE->get_renderer('tool_customlang'); 118 $paginator = $output->paging_bar($translator->numofrows, $currentpage, tool_customlang_translator::PERPAGE, $PAGE->url, 'p'); 119 120 echo $output->header(); 121 $filter->display(); 122 echo $paginator; 123 echo $output->render($translator); 124 echo $paginator; 125 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body