Example #1
0
 function definition()
 {
     $mform = $this->_form;
     $current = $this->_customdata['current'];
     $mform->addElement('header', 'filtersettings', get_string('filter', 'tool_customlang'));
     // Component
     $options = array();
     foreach (tool_customlang_utils::list_components() as $component => $normalized) {
         list($type, $plugin) = normalize_component($normalized);
         if ($type == 'core' and is_null($plugin)) {
             $plugin = 'moodle';
         }
         $options[$type][$normalized] = $component . '.php';
     }
     $mform->addElement('selectgroups', 'component', get_string('filtercomponent', 'tool_customlang'), $options, array('multiple' => 'multiple', 'size' => 7));
     // Customized only
     $mform->addElement('advcheckbox', 'customized', get_string('filtercustomized', 'tool_customlang'));
     $mform->setType('customized', PARAM_BOOL);
     $mform->setDefault('customized', 0);
     // Only helps
     $mform->addElement('advcheckbox', 'helps', get_string('filteronlyhelps', 'tool_customlang'));
     $mform->setType('helps', PARAM_BOOL);
     $mform->setDefault('helps', 0);
     // Modified only
     $mform->addElement('advcheckbox', 'modified', get_string('filtermodified', 'tool_customlang'));
     $mform->setType('modified', PARAM_BOOL);
     $mform->setDefault('modified', 0);
     // Substring
     $mform->addElement('text', 'substring', get_string('filtersubstring', 'tool_customlang'));
     $mform->setType('substring', PARAM_RAW);
     // String identifier
     $mform->addElement('text', 'stringid', get_string('filterstringid', 'tool_customlang'));
     $mform->setType('stringid', PARAM_STRINGID);
     // Show strings - submit button
     $mform->addElement('submit', 'submit', get_string('filtershowstrings', 'tool_customlang'));
 }
Example #2
0
 /**
  * Returns the name of the file where the component's local strings should be exported into
  *
  * @param string $component normalized name of the component, eg 'core' or 'mod_workshop'
  * @return string|boolean filename eg 'moodle.php' or 'workshop.php', false if not found
  */
 protected static function get_component_filename($component)
 {
     if (is_null(self::$components)) {
         self::$components = self::list_components();
     }
     $return = false;
     foreach (self::$components as $legacy => $normalized) {
         if ($component === $normalized) {
             $return = $legacy . '.php';
             break;
         }
     }
     return $return;
 }
Example #3
0
$translatorsubmitted = optional_param('translatorsubmitted', 0, PARAM_BOOL);
admin_externalpage_setup('toolcustomlang', '', null, new moodle_url('/admin/tool/customlang/edit.php', array('lng' => $lng)), array('pagelayout' => 'report'));
// Hack: allows for wide page contents.
$PAGE->requires->js_init_call('M.tool_customlang.init_editor', array(), true);
if (empty($lng)) {
    // PARAM_LANG validation failed
    print_error('missingparameter');
}
// pre-output processing
$filter = new tool_customlang_filter_form($PAGE->url, null, 'post', '', array('class' => 'filterform'));
$filterdata = tool_customlang_utils::load_filter($USER);
$filter->set_data($filterdata);
if ($filter->is_cancelled()) {
    redirect($PAGE->url);
} elseif ($submitted = $filter->get_data()) {
    tool_customlang_utils::save_filter($submitted, $USER);
    redirect(new moodle_url($PAGE->url, array('p' => 0)));
}
if ($translatorsubmitted) {
    $strings = optional_param_array('cust', array(), PARAM_RAW);
    $updates = optional_param_array('updates', array(), PARAM_INT);
    $checkin = optional_param('savecheckin', false, PARAM_RAW);
    if ($checkin === false) {
        $nexturl = new moodle_url($PAGE->url, array('p' => $currentpage));
    } else {
        $nexturl = new moodle_url('/admin/tool/customlang/index.php', array('action' => 'checkin', 'lng' => $lng, 'sesskey' => sesskey()));
    }
    if (!is_array($strings)) {
        $strings = array();
    }
    $current = $DB->get_records_list('tool_customlang', 'id', array_keys($strings));
Example #4
0
    } else {
        tool_customlang_utils::checkin($lng);
        redirect($PAGE->url);
    }
}
$output = $PAGE->get_renderer('tool_customlang');
// output starts here
echo $output->header();
echo $output->heading(get_string('pluginname', 'tool_customlang'));
if (empty($lng)) {
    $s = new single_select($PAGE->url, 'lng', $langs);
    $s->label = get_accesshide(get_string('language'));
    $s->class = 'langselector';
    echo $output->box($OUTPUT->render($s), 'langselectorbox');
    echo $OUTPUT->footer();
    exit;
}
echo $output->heading($langs[$lng], 3);
$numofmodified = tool_customlang_utils::get_count_of_modified($lng);
if ($numofmodified != 0) {
    echo $output->heading(get_string('modifiednum', 'tool_customlang', $numofmodified), 3);
}
$menu = array();
if (has_capability('tool/customlang:edit', context_system::instance())) {
    $menu['checkout'] = array('title' => get_string('checkout', 'tool_customlang'), 'url' => new moodle_url($PAGE->url, array('action' => 'checkout', 'lng' => $lng)), 'method' => 'post');
    if ($numofmodified != 0) {
        $menu['checkin'] = array('title' => get_string('checkin', 'tool_customlang'), 'url' => new moodle_url($PAGE->url, array('action' => 'checkin', 'lng' => $lng)), 'method' => 'post');
    }
}
echo $output->render(new tool_customlang_menu($menu));
echo $output->footer();
Example #5
0
            $current = $DB->get_record('tool_customlang', array('lang' => $string[0], 'componentid' => $component->id, 'stringid' => $string[2]));
            if (empty($current)) {
                continue;
                // skip unfound stringids
            }
            if (empty($current->local)) {
                $current->local = $string[3];
                $current->modified = 1;
                $current->outdated = 0;
                $current->timecustomized = time();
                $DB->update_record('tool_customlang', $current);
            }
        }
        fclose($handle);
    }
    tool_customlang_utils::checkin($lng);
    $PAGE->set_url(new moodle_url('import.php'));
    redirect($PAGE->url);
}
?>



<form method="post" enctype="multipart/form-data">
	<div style="margin:5px;">
<input name="uploadcsv" type="file" />
	</div>
	<div style="margin:5px;">
		<input type="hidden" name="submit" value="1" />
		<input type="submit" value="Import" />
		<div  style="margin:5px;">Note: You are requested to use separate CSV files  for each language. The first column should contain the language code. <p>Mixing different language codes in the same CSV may lead to corrupt translations.</div>