if ($result->lang == 'en') { $cell = $encell; $none = $langcell; } else { $cell = $langcell; $none = $encell; } $date = html_writer::tag('div', local_amos_renderer::commit_datetime($result->timemodified), array('class' => 'timemodified')); $userinfo = html_writer::tag('span', s($result->userinfo), array('class' => 'userinfo')); $commitmsg = html_writer::tag('span', s($result->commitmsg), array('class' => 'commitmsg')); if ($result->deleted) { $text = html_writer::tag('del', s($result->text)); } else { $text = s($result->text); } $text = local_amos_renderer::add_breaks($text); if ($result->commithash) { if ($result->lang == 'en') { $url = 'https://github.com/moodle/moodle/commit/' . $result->commithash; } else { $url = 'https://github.com/mudrd8mz/moodle-lang/commit/' . $result->commithash; } $hashlink = html_writer::link($url, $result->commithash); $commithash = html_writer::tag('div', $hashlink, array('class' => 'commithash')); } else { $commithash = ''; } $text = html_writer::tag('div', $text, array('class' => 'text preformatted')); $cell->text = $date . html_writer::tag('div', $userinfo . ' ' . $commitmsg . $commithash, array('class' => 'usermessage')) . $text; $none->text = ' '; $row = new html_table_row(array($encell, $langcell));
die; } if (!confirm_sesskey()) { header('HTTP/1.1 403 Forbidden'); die; } $stringid = optional_param('stringid', null, PARAM_ALPHANUMEXT); $text = optional_param('text', null, PARAM_RAW); if (is_null($stringid) or is_null($text)) { header('HTTP/1.1 400 Bad Request'); die; } list($lang, $originalid, $translationid) = local_amos_translator::decode_identifier($stringid); $record = $DB->get_record('amos_repository', array('id' => $originalid), 'id,stringid,component,branch', MUST_EXIST); $version = mlang_version::by_code($record->branch); $component = new mlang_component($record->component, $lang, $version); if ($version->code < mlang_version::MOODLE_20) { header('HTTP/1.1 400 Bad Request'); die; } $string = new mlang_string($record->stringid, $text); $string->clean_text(); $component->add_string($string); $stage = mlang_persistent_stage::instance_for_user($USER->id, sesskey()); $stage->add($component, true); $stage->store(); mlang_stash::autosave($stage); header('Content-Type: application/json; charset: utf-8'); $response = new stdclass(); $response->text = local_amos_renderer::add_breaks(s($string->text)); echo json_encode($response);