private static function findSortOrder($run, $mode_id, $revision) { $version_control = VersionControl::forMode($mode_id); $j = 0; while (True) { if ($j++ > 30) { throw new Exception("There shouldn't be too many runs in between"); } if (!$run->isBuildInfoComplete()) { throw new Exception("Encountered an incomplete run."); } $build = Build::withRunAndMode($run->id, $mode_id); // We can safely ignore runs that have no results with the requested mode_id if (!$build) { $run = $run->next(); continue; } // We skip to the next run, if revisions are the same. // To make sure that new runs are shown after existing ones. if ($version_control->equal($build->revision(), $revision)) { $run = $run->next(); continue; } // Using version control take a peek if the revision // is later/earlier than this one. if ($version_control->isAfter($build->revision(), $revision)) { return $run->sort_order(); } $run = $run->next(); } }
public static function retriggerable($machine_id, $mode_id) { $retrigger = RetriggerController::fromMachine($machine_id, $mode_id); if (count($retrigger->tasks) == 0) { return false; } try { VersionControl::forMode($mode_id); } catch (Exception $e) { return false; } return true; }
$target_string = str_replace(' ', '<span class="highlight-gray"> </span>', $target_string); $source_string = Utils::secureText($tmx_source[$entity]); // 3locales view if ($url['path'] == '3locales') { $bz_target_string2 = $target_string2 = isset($tmx_target2[$entity]) ? Utils::secureText($tmx_target2[$entity]) : ''; // Highlight non-breaking spaces only after strings have been escaped $target_string2 = str_replace(' ', '<span class="highlight-gray"> </span>', $target_string2); switch ($current_repo) { case 'mozilla_org': $path_locale3 = VersionControl::gitPath($locale2, $current_repo, $entity); break; case 'firefox_ios': $path_locale3 = VersionControl::svnPath($locale2, $current_repo, $entity); break; default: $path_locale3 = VersionControl::hgPath($locale2, $current_repo, $entity); break; } // Link to entity $entity_link = "?sourcelocale={$source_locale}" . "&locale={$locale2}" . "&repo={$current_repo}" . "&search_type=entities&recherche={$entity}"; $file_bug = '<a class="bug_link" target="_blank" href="' . Bugzilla::reportErrorLink($locale2, $entity, $source_string, $bz_target_string2, $current_repo, $entity_link) . '"><report a bug></a>'; $extra_column_rows = "\n <td dir='{$direction3}'>\n <span class='celltitle'>{$locale2}</span>\n <div class='string'>{$target_string2}</div>\n <div dir='ltr' class='result_meta_link'>\n <a class='source_link' href='{$path_locale3}'><em><source></em></a>\n {$file_bug}\n </div>\n </td>"; } else { $extra_column_rows = ''; } // Link to entity $entity_link = "?sourcelocale={$source_locale}" . "&locale={$locale}" . "&repo={$current_repo}" . "&search_type=entities&recherche={$entity}"; $file_bug = '<a class="bug_link" target="_blank" href="' . Bugzilla::reportErrorLink($locale, $entity, $source_string, $bz_target_string, $current_repo, $entity_link) . '"><report a bug></a>'; $anchor_name = str_replace(['/', ':'], '_', $entity); $table .= "\n <tr>\n <td>\n <span class='celltitle'>Entity</span>\n <a class='resultpermalink tag' id='{$anchor_name}' href='#{$anchor_name}' title='Permalink to this result'>link</a>\n <a class='l10n tag' href='/string/?entity={$entity}&repo={$current_repo}' title='List all translations for this entity'>l10n</a>\n <a class='link_to_entity' href='/{$entity_link}'>" . ShowResults::formatEntity($entity, $initial_search) . "</a>\n </td>\n <td dir='{$direction1}'>\n <span class='celltitle'>{$source_locale}</span>\n <div class='string'>{$source_string}</div>\n <div dir='ltr' class='result_meta_link'>\n <a class='source_link' href='{$path_locale1}'><em><source></em></a>\n </div>\n </td>\n <td dir='{$direction2}'>\n <span class='celltitle'>{$locale}</span>\n <div class='string'>{$target_string}</div>\n <div dir='ltr' class='result_meta_link'>\n <a class='source_link' href='{$path_locale2}'><em><source></em></a>\n {$file_bug}\n </div>\n </td>\n {$extra_column_rows}\n </tr>\n"; }
/** * Html table of search results used by the main view (needs a lot of refactoring) * * @param array $search_id Identifier for the current search * @param array $search_results List of rows * @param string $recherche The words searched for * @param string $locale1 Reference locale to search in, usually en-US * @param string $locale2 Target locale to search in * @param array $search_options All the search options from the query * * @return string html table to insert in the view */ public static function resultsTable($search_id, $search_results, $recherche, $locale1, $locale2, $search_options) { $direction1 = RTLSupport::getDirection($locale1); $direction2 = RTLSupport::getDirection($locale2); if (isset($search_options['extra_locale'])) { $locale3 = $search_options['extra_locale']; $direction3 = RTLSupport::getDirection($locale3); $extra_column_header = "<th>{$locale3}</th>"; } else { $extra_column_header = ''; } $table = "<table class='collapsable results_table {$search_id}'>\n <tr class='column_headers'>\n <th>Entity</th>\n <th>{$locale1}</th>\n <th>{$locale2}</th>\n {$extra_column_header}\n </tr>"; if (!$search_options['whole_word'] && !$search_options['perfect_match']) { $recherche = Utils::uniqueWords($recherche); } else { $recherche = [$recherche]; } $current_repo = $search_options['repo']; foreach ($search_results as $key => $strings) { // Don't highlight search matches in entities when searching strings if ($search_options['search_type'] == 'strings') { $result_entity = self::formatEntity($key); } else { $result_entity = self::formatEntity($key, $recherche[0]); } $component = explode('/', $key)[0]; $source_string = trim($strings[0]); $target_string = trim($strings[1]); $entity_link = "?sourcelocale={$locale1}" . "&locale={$locale2}" . "&repo={$current_repo}" . "&search_type=entities&recherche={$key}"; $bz_link = [Bugzilla::reportErrorLink($locale2, $key, $source_string, $target_string, $current_repo, $entity_link)]; if (isset($search_options['extra_locale'])) { $target_string2 = trim($strings[2]); $entity_link = "?sourcelocale={$locale1}" . "&locale={$search_options['extra_locale']}" . "&repo={$current_repo}" . "&search_type=entities&recherche={$key}"; $bz_link[] = Bugzilla::reportErrorLink($search_options['extra_locale'], $key, $source_string, $target_string2, $current_repo, $entity_link); } else { $target_string2 = ''; } foreach ($recherche as $val) { $source_string = Utils::markString($val, $source_string); $target_string = Utils::markString($val, $target_string); if (isset($search_options["extra_locale"])) { $target_string2 = Utils::markString($val, $target_string2); } } // Escape HTML before highlighing search terms $source_string = htmlspecialchars($source_string); $target_string = htmlspecialchars($target_string); $source_string = Utils::highlightString($source_string); $target_string = Utils::highlightString($target_string); if (isset($search_options["extra_locale"])) { $target_string2 = htmlspecialchars($target_string2); $target_string2 = Utils::highlightString($target_string2); } $replacements = [' ' => '<span class="highlight-gray" title="Non breakable space"> </span>', ' ' => '<span class="highlight-red" title="Thin space"> </span>', '…' => '<span class="highlight-gray">…</span>', '…' => '<span class="highlight-gray">…</span>']; $target_string = Strings::multipleStringReplace($replacements, $target_string); $temp = explode('-', $locale1); $locale1_short_code = $temp[0]; $temp = explode('-', $locale2); $locale2_short_code = $temp[0]; switch ($current_repo) { case 'mozilla_org': $locale1_path = VersionControl::gitPath($locale1, $current_repo, $key); $locale2_path = VersionControl::gitPath($locale2, $current_repo, $key); break; case 'firefox_ios': $locale1_path = VersionControl::svnPath($locale1, $current_repo, $key); $locale2_path = VersionControl::svnPath($locale2, $current_repo, $key); break; default: $locale1_path = VersionControl::hgPath($locale1, $current_repo, $key); $locale2_path = VersionControl::hgPath($locale2, $current_repo, $key); break; } // errors $error_message = ''; // check for final dot if (substr(strip_tags($source_string), -1) == '.' && substr(strip_tags($target_string), -1) != '.') { $error_message = '<em class="error"> No final dot?</em>'; } // check abnormal string length $length_diff = Utils::checkAbnormalStringLength($source_string, $target_string); if ($length_diff) { switch ($length_diff) { case 'small': $error_message = $error_message . '<em class="error"> Small string?</em>'; break; case 'large': $error_message = $error_message . '<em class="error"> Large String?</em>'; break; } } // Missing string error if (!$source_string) { $source_string = '<em class="error">warning: missing string</em>'; $error_message = ''; } if (!$target_string) { $target_string = '<em class="error">warning: missing string</em>'; $error_message = ''; } if (!$target_string2) { $target_string2 = '<em class="error">warning: missing string</em>'; $error_message = ''; } // Replace / and : in the key name and use it as an anchor name $anchor_name = str_replace(['/', ':'], '_', $key); $clipboard_target_string = 'clip_' . md5($target_string); // 3locales view if (isset($search_options["extra_locale"])) { switch ($current_repo) { case 'mozilla_org': $locale3_path = VersionControl::gitPath($locale3, $current_repo, $key); break; case 'firefox_ios': $locale3_path = VersionControl::svnPath($locale3, $current_repo, $key); break; default: $locale3_path = VersionControl::hgPath($locale3, $current_repo, $key); break; } $clipboard_target_string2 = 'clip_' . md5($target_string2); $extra_column_rows = "\n <td dir='{$direction3}' lang='{$locale3}'>\n <span class='celltitle'>{$locale3}</span>\n <div class='string' id='{$clipboard_target_string2}'>{$target_string2}</div>\n <div dir='ltr' class='result_meta_link'>\n <a class='source_link' href='{$locale3_path}'>\n <source>\n </a>\n \n <a class='bug_link' target='_blank' href='{$bz_link[1]}'>\n <report a bug>\n </a>\n <span class='clipboard' data-clipboard-target='#{$clipboard_target_string2}' alt='Copy to clipboard'><img src='/img/copy_icon_black_18x18.png'></span>\n </div>\n </td>"; } else { $extra_column_rows = ''; } $table .= "\n <tr class='{$component} {$search_id}'>\n <td>\n <span class='celltitle'>Entity</span>\n <a class='resultpermalink tag' id='{$anchor_name}' href='#{$anchor_name}' title='Permalink to this result'>link</a>\n <a class='l10n tag' href='/string/?entity={$key}&repo={$current_repo}' title='List all translations for this entity'>l10n</a>\n <a class='link_to_entity' href=\"/{$entity_link}\">{$result_entity}</a>\n </td>\n <td dir='{$direction1}' lang='{$locale1}'>\n <span class='celltitle'>{$locale1}</span>\n <div class='string'>\n {$source_string}\n </div>\n <div dir='ltr' class='result_meta_link'>\n <a class='source_link' href='{$locale1_path}'>\n <source>\n </a>\n <span>Translate with:</span>\n <a href='http://translate.google.com/#{$locale1_short_code}/{$locale2_short_code}/" . urlencode(strip_tags(html_entity_decode(html_entity_decode($source_string)))) . "' target='_blank'>Google</a>\n <a href='http://www.bing.com/translator/?from={$locale1_short_code}&to={$locale2_short_code}&text=" . urlencode(strip_tags(html_entity_decode(html_entity_decode($source_string)))) . "' target='_blank'>BING</a>\n </div>\n </td>\n\n <td dir='{$direction2}' lang='{$locale2}'>\n <span class='celltitle'>{$locale2}</span>\n <div class='string' id='{$clipboard_target_string}'>{$target_string}</div>\n <div dir='ltr' class='result_meta_link'>\n <a class='source_link' href='{$locale2_path}'>\n <source>\n </a>\n \n <a class='bug_link' target='_blank' href='{$bz_link[0]}'>\n <report a bug>\n </a>\n <span class='clipboard' data-clipboard-target='#{$clipboard_target_string}' alt='Copy to clipboard'><img src='/img/copy_icon_black_18x18.png'></span>\n {$error_message}\n </div>\n </td>\n {$extra_column_rows}\n </tr>"; } $table .= " </table>"; return $table; }
$path_locale2 = VersionControl::hgPath($locale, $check['repo'], $entity); } // Escape strings for HTML display $bz_target_string = $target_string = isset($tmx_target[$entity]) ? Utils::secureText($tmx_target[$entity]) : ''; // Highlight non-breaking spaces only after strings have been escaped $target_string = str_replace(' ', '<span class="highlight-gray"> </span>', $target_string); $source_string = Utils::secureText($tmx_source[$entity]); // 3locales view if ($url['path'] == '3locales') { $bz_target_string2 = $target_string2 = isset($tmx_target2[$entity]) ? Utils::secureText($tmx_target2[$entity]) : ''; // Highlight non-breaking spaces only after strings have been escaped $target_string2 = str_replace(' ', '<span class="highlight-gray"> </span>', $target_string2); if ($check['repo'] == 'mozilla_org') { $path_locale3 = VersionControl::svnPath($locale2, $check['repo'], $entity); } else { $path_locale3 = VersionControl::hgPath($locale2, $check['repo'], $entity); } // Link to entity $entity_link = "?sourcelocale={$source_locale}" . "&locale={$locale2}" . "&repo={$check['repo']}" . "&search_type=entities&recherche={$entity}"; $file_bug = '<a class="bug_link" target="_blank" href="' . Bugzilla::reportErrorLink($locale2, $entity, $source_string, $bz_target_string2, $check['repo'], $entity_link) . '"><report a bug></a>'; $extra_column_rows = "\n <td dir='{$direction3}'>\n <span class='celltitle'>{$locale2}</span>\n <div class='string'>{$target_string2}</div>\n <div dir='ltr' class='result_meta_link'>\n <a class='source_link' href='{$path_locale3}'><em><source></em></a>\n {$file_bug}\n </div>\n </td>"; } else { $extra_column_rows = ''; } // Link to entity $entity_link = "?sourcelocale={$source_locale}" . "&locale={$locale}" . "&repo={$check['repo']}" . "&search_type=entities&recherche={$entity}"; $file_bug = '<a class="bug_link" target="_blank" href="' . Bugzilla::reportErrorLink($locale, $entity, $source_string, $bz_target_string, $check['repo'], $entity_link) . '"><report a bug></a>'; $anchor_name = str_replace(['/', ':'], '_', $entity); $table .= "\n <tr>\n <td>\n <span class='celltitle'>Entity</span>\n <a class='resultpermalink tag' id='{$anchor_name}' href='#{$anchor_name}' title='Permalink to this result'>link</a>\n <a class='l10n tag' href='/string/?entity={$entity}&repo={$check['repo']}' title='List all translations for this entity'>l10n</a>\n <a class='link_to_entity' href='/{$entity_link}'>" . ShowResults::formatEntity($entity, $my_search) . "</a>\n </td>\n <td dir='{$direction1}'>\n <span class='celltitle'>{$source_locale}</span>\n <div class='string'>{$source_string}</div>\n <div dir='ltr' class='result_meta_link'>\n <a class='source_link' href='{$path_locale1}'><em><source></em></a>\n </div>\n </td>\n <td dir='{$direction2}'>\n <span class='celltitle'>{$locale}</span>\n <div class='string'>{$target_string}</div>\n <div dir='ltr' class='result_meta_link'>\n <a class='source_link' href='{$path_locale2}'><em><source></em></a>\n {$file_bug}\n </div>\n </td>\n {$extra_column_rows}\n </tr>\n"; } $table .= "</table>\n\n";
<?php namespace Transvision; // Include the common simple search form include __DIR__ . '/simplesearchform.php'; if ($error_count > 0) { $search_id = 'check_variable'; $content = "<h2><span class=\"results_count_{$search_id}\">" . Utils::pluralize($error_count, 'result') . "</span> found</h2>\n"; if (isset($filter_block)) { $content .= "<div id='filters'>" . " <h4>Filter by folder:</h4>\n" . " <a href='#showall' id='showall' class='filter'>Show all results</a>\n" . $filter_block . "</div>\n"; } $content .= "<table class='collapsable results_table {$search_id}'>\n" . " <tr>\n" . " <th>Entity</th>\n" . " <th>{$source_locale}</th>\n" . " <th>{$locale}</th>\n" . " </tr>\n"; foreach ($var_errors as $string_id) { // Link to entity $string_id_link = "?sourcelocale={$source_locale}" . "&locale={$locale}" . "&repo={$repo}" . "&search_type=entities&recherche={$string_id}"; $bugzilla_link = Bugzilla::reportErrorLink($locale, $string_id, $source[$string_id], $target[$string_id], $repo, $string_id_link); $path_locale1 = VersionControl::hgPath($source_locale, $repo, $string_id); $path_locale2 = VersionControl::hgPath($locale, $repo, $string_id); $component = explode('/', $string_id)[0]; $content .= "<tr class='{$component} {$search_id}'>\n <td>\n <span class='celltitle'>Entity</span>\n <a class='link_to_entity' href=\"/{$string_id_link}\">" . ShowResults::formatEntity($string_id) . "</a>\n </td>\n <td dir='{$direction1}'>\n <span class='celltitle'>{$source_locale}</span>\n <div class='string'>" . Utils::secureText($source[$string_id]) . "</div>\n <div class='result_meta_link'>\n <a class='source_link' href='{$path_locale1}'><em><source></em></a>\n </div>\n </td>\n <td dir='{$direction2}'>\n <span class='celltitle'>{$locale}</span>\n <div class='string'>" . Utils::secureText($target[$string_id]) . "</div>\n <div class='result_meta_link'>\n <a class='source_link' href='{$path_locale2}'><em><source></em></a>\n <a class='bug_link' target='_blank' href='{$bugzilla_link}'><report a bug></a>\n </div>\n </td>\n </tr>\n"; } $content .= "</table>\n"; } else { $content = "<h2>Congratulations, no errors found.</h2>"; } print $content;
<?php /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ require_once "../internals.php"; require_once "../lib/DB/Regression.php"; require_once "../lib/VersionControl.php"; init_database(); $postdata = file_get_contents("php://input"); $request = json_decode($postdata); $id = (int) $request->id; $regression = Regression::FromId($id); $build = $regression->build() or throw_exception("Couldn't retrieve the build of regression {$id}."); $prev_build = $regression->prev_build() or throw_exception("Couldn't retrieve the prev_build of regression {$id}."); $regression->build()->revision(); $regression->prev_build()->revision(); $versionControl = VersionControl::forMode($build->mode_id()); $revisions = $versionControl->revisions($prev_build->revision(), $build->revision()); $data = array(); foreach ($revisions as $revision) { $data[] = array("author" => $revision->author, "date" => $revision->date, "revision" => $revision->revision, "message" => $revision->message); } echo json_encode($data);