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));
$mem = memory_get_usage(); $memdiff = $memprev < $mem ? '+' : '-'; $memdiff = $memdiff . abs($mem - $memprev); fputs(STDOUT, "FOUND {$commithash} {$changetype} {$file} [{$mem} {$memdiff}]\n"); // get some additional information of the commit $format = implode('%n', array('%an', '%ae', '%at', '%s', '%b')); // name, email, timestamp, subject, body $commitinfo = array(); $gitcmd = AMOS_PATH_GIT . " log --format={$format} {$commithash} ^{$commithash}~"; exec($gitcmd, $commitinfo); $committer = $commitinfo[0]; $committeremail = $commitinfo[1]; $realmodified = $commitinfo[2]; // the real timestamp of the commit - should be the same as $committime $commitmsg = iconv('UTF-8', 'UTF-8//IGNORE', $commitinfo[3]); $commitmsg .= "\n\nCommitted into Git: " . local_amos_renderer::commit_datetime($realmodified); $fullcommitmsg = implode("\n", array_slice($commitinfo, 3)); // AMOS script is looked up here later if ($changetype == 'D') { // whole file removal - do not do anything, fix-drift job will clear the repository continue; } // get the list of strings affected by the commit $gitcmd = AMOS_PATH_GIT . " log -1 -p --format=format: " . $commithash . ' -- ' . $file; $diff = array(); exec($gitcmd, $diff); foreach (mlang_tools::get_affected_strings($diff) as $stringid) { $affected[$componentname][$stringid] = true; } // dump the given revision of the file to a temporary area $checkout = $commithash . '_' . str_replace('/', '_', $file);
} $other = mlang_component::from_snapshot($componentname, $otherlang, $version, null, true, false, array($string->id)); if ($other->has_string($string->id)) { $current = $other->get_string($string->id); if (!$current->deleted) { $current->deleted = true; $current->timemodified = time(); $stage->add($other); } } $other->clear(); unset($other); } $stage->rebase(); if ($stage->has_component()) { $string->timemodified = local_amos_renderer::commit_datetime($string->timemodified); $msg = <<<EOF Propagating removal of the string The string '{$string->id}' was removed from the English language pack by {$string->extra->userinfo} at {$string->timemodified}. Their commit message was: {$string->extra->commitmsg} {$string->extra->commithash} EOF; fputs(STDOUT, "COMMIT removal of '{$string->id}' from '{$english->name}'\n"); $stage->commit($msg, array('source' => 'revclean', 'userinfo' => 'AMOS-bot <*****@*****.**>'), true); } $stage->clear(); unset($stage); } }
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);