|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00026 define('NO_OUTPUT_BUFFERING', true); // progress bar is used here 00027 00028 require(dirname(dirname(dirname(dirname(__FILE__)))) . '/config.php'); 00029 require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/locallib.php'); 00030 require_once($CFG->libdir.'/adminlib.php'); 00031 00032 require_login(SITEID, false); 00033 require_capability('tool/customlang:view', get_system_context()); 00034 00035 $action = optional_param('action', '', PARAM_ALPHA); 00036 $confirm = optional_param('confirm', false, PARAM_BOOL); 00037 $lng = optional_param('lng', '', PARAM_LANG); 00038 00039 admin_externalpage_setup('toolcustomlang'); 00040 $langs = get_string_manager()->get_list_of_translations(); 00041 00042 // pre-output actions 00043 if ($action === 'checkout') { 00044 require_sesskey(); 00045 require_capability('tool/customlang:edit', get_system_context()); 00046 if (empty($lng)) { 00047 print_error('missingparameter'); 00048 } 00049 00050 $PAGE->set_cacheable(false); // progress bar is used here 00051 $output = $PAGE->get_renderer('tool_customlang'); 00052 echo $output->header(); 00053 echo $output->heading(get_string('pluginname', 'tool_customlang')); 00054 $progressbar = new progress_bar(); 00055 $progressbar->create(); // prints the HTML code of the progress bar 00056 00057 // we may need a bit of extra execution time and memory here 00058 @set_time_limit(HOURSECS); 00059 raise_memory_limit(MEMORY_EXTRA); 00060 tool_customlang_utils::checkout($lng, $progressbar); 00061 00062 echo $output->continue_button(new moodle_url('/admin/tool/customlang/edit.php', array('lng' => $lng)), 'get'); 00063 echo $output->footer(); 00064 exit; 00065 } 00066 00067 if ($action === 'checkin') { 00068 require_sesskey(); 00069 require_capability('tool/customlang:edit', get_system_context()); 00070 if (empty($lng)) { 00071 print_error('missingparameter'); 00072 } 00073 00074 if (!$confirm) { 00075 $output = $PAGE->get_renderer('tool_customlang'); 00076 echo $output->header(); 00077 echo $output->heading(get_string('pluginname', 'tool_customlang')); 00078 echo $output->heading($langs[$lng], 3); 00079 $numofmodified = tool_customlang_utils::get_count_of_modified($lng); 00080 if ($numofmodified != 0) { 00081 echo $output->heading(get_string('modifiednum', 'tool_customlang', $numofmodified), 3); 00082 echo $output->confirm(get_string('confirmcheckin', 'tool_customlang'), 00083 new moodle_url($PAGE->url, array('action'=>'checkin', 'lng'=>$lng, 'confirm'=>1)), 00084 new moodle_url($PAGE->url, array('lng'=>$lng))); 00085 } else { 00086 echo $output->heading(get_string('modifiedno', 'tool_customlang', $numofmodified), 3); 00087 echo $output->continue_button(new moodle_url($PAGE->url, array('lng' => $lng))); 00088 } 00089 echo $output->footer(); 00090 die(); 00091 00092 } else { 00093 tool_customlang_utils::checkin($lng); 00094 redirect($PAGE->url); 00095 } 00096 } 00097 00098 $output = $PAGE->get_renderer('tool_customlang'); 00099 00100 // output starts here 00101 echo $output->header(); 00102 echo $output->heading(get_string('pluginname', 'tool_customlang')); 00103 00104 if (empty($lng)) { 00105 $s = new single_select($PAGE->url, 'lng', $langs); 00106 $s->label = get_accesshide(get_string('language')); 00107 $s->class = 'langselector'; 00108 echo $output->box($OUTPUT->render($s), 'langselectorbox'); 00109 echo $OUTPUT->footer(); 00110 exit; 00111 } 00112 00113 echo $output->heading($langs[$lng], 3); 00114 00115 $numofmodified = tool_customlang_utils::get_count_of_modified($lng); 00116 00117 if ($numofmodified != 0) { 00118 echo $output->heading(get_string('modifiednum', 'tool_customlang', $numofmodified), 3); 00119 } 00120 00121 $menu = array(); 00122 if (has_capability('tool/customlang:edit', get_system_context())) { 00123 $menu['checkout'] = array( 00124 'title' => get_string('checkout', 'tool_customlang'), 00125 'url' => new moodle_url($PAGE->url, array('action' => 'checkout', 'lng' => $lng)), 00126 'method' => 'post', 00127 ); 00128 if ($numofmodified != 0) { 00129 $menu['checkin'] = array( 00130 'title' => get_string('checkin', 'tool_customlang'), 00131 'url' => new moodle_url($PAGE->url, array('action' => 'checkin', 'lng' => $lng)), 00132 'method' => 'post', 00133 ); 00134 } 00135 } 00136 echo $output->render(new tool_customlang_menu($menu)); 00137 00138 echo $output->footer();