Example #1
0
         }
     }
 }
 foreach (Project::getWebsitesByDataType($sites, 'raw') as $current_website) {
     $website_with_errors = false;
     if (Project::isSupportedLocale($current_website, $current_locale)) {
         $repo = Project::getPublicRepoPath($current_website, $current_locale);
         $current_website_name = Project::getWebsiteName($current_website);
         $opening_div = "      <div class='website_container'>\n" . "        <h2>{$current_website_name}</h2>\n";
         foreach (Project::getWebsiteFiles($current_website) as $current_filename) {
             if (!Project::isSupportedLocale($current_website, $current_locale, $current_filename, $langfiles_subsets)) {
                 // File is not managed for this website+locale, ignore it
                 continue;
             }
             $locale_filename = Project::getLocalFilePath($current_website, $current_locale, $current_filename);
             if (!in_array('optional', Project::getFileFlags($current_website, $current_filename, $current_locale)) && !file_exists($locale_filename)) {
                 if (!$website_with_errors) {
                     $website_with_errors = true;
                     $locale_htmloutput .= $opening_div;
                 }
                 $locale_htmloutput .= "        <p>File missing: {$locale_filename}</p>\n";
                 continue;
             }
         }
     }
     if ($website_with_errors) {
         $locale_htmloutput .= "      </div>\n\n";
         if (!$locale_with_errors) {
             $locale_with_errors = true;
         }
     }
Example #2
0
<?php

namespace Langchecker;

$html_output = '<p id="back"><a href="http://l10n.mozilla-community.org/webdashboard/">Back to Web Dashboard</a></p>';
// This view works only for mozilla.org (website ID 0)
$current_website = $sites[0];
$current_locale = $locale;
if (!Project::isSupportedLocale($current_website, $current_locale)) {
    exit($html_output . '<p>This locale is not supported on mozilla.org</p>');
}
// Create a list of opt-in pages
$optin_pages = [];
foreach (Project::getWebsiteFiles($current_website) as $current_filename) {
    if (in_array('opt-in', Project::getFileFlags($current_website, $current_filename, $current_locale))) {
        $optin_pages[$current_filename] = Project::getSupportedLocales($current_website, $current_filename, $langfiles_subsets);
    }
}
if (count($optin_pages) == 0) {
    exit($html_output . '<p>There are no optional pages available at the moment.</p>');
}
$html_output .= "<h1>List of optional pages for <span>{$current_locale}</span></h1>\n  <table class='optinpages'>\n    <thead>\n      <tr>\n        <th>Filename</th>\n        <th>URL</th>\n        <th>Strings</th>\n        <th>Words</th>\n        <th>Opted-in</th>\n        <th>Actions</th>\n      </tr>\n    </thead>\n    <tbody>\n";
$bugzilla_locale = urlencode(Bugzilla::getBugzillaLocaleField($current_locale, 'www'));
$available_optins = [];
foreach ($optin_pages as $current_filename => $supported_locales) {
    $reference_locale = Project::getReferenceLocale($current_website);
    $reference_data = LangManager::loadSource($current_website, $reference_locale, $current_filename);
    $get_words = function ($item) {
        return str_word_count(strip_tags($item));
    };
    $nb_words = array_sum(array_map($get_words, $reference_data['strings']));
 $html_output .= "  <p>Repository: <a href='{$repo}'>{$repo}</a></p>\n";
 $html_rows = '';
 $done_files = '';
 foreach (Project::getWebsiteFiles($current_website) as $current_filename) {
     if (!Project::isSupportedLocale($current_website, $current_locale, $current_filename, $langfiles_subsets)) {
         // File is not managed for this website+locale, ignore it
         continue;
     }
     $file_analysis = RawManager::compareRawFiles($current_website, $current_locale, $current_filename);
     $cmp_result = $file_analysis['cmp_result'];
     if ($cmp_result == 'ok') {
         // File is translated, store it for later and move on to the next file
         $done_files .= "<a class='file_done activated'>" . basename($current_filename) . "</a>\n";
         continue;
     }
     if (in_array('optional', Project::getFileFlags($current_website, $current_filename, $current_locale)) && $cmp_result != 'untranslated' && $cmp_result != 'outdated') {
         // If a file is optional, it can be deleted from locale repository without generating errors
         // But if it's outdated or untranslated, we display it
         continue;
     }
     if ($file_analysis['reference_exists']) {
         $reference_link = "<a href='{$file_analysis['reference_url']}'>Reference file</a> " . "<span class='last_update' title='last update'>(" . date("Y-m-d H:i", $file_analysis['reference_lastupdate']) . ")</span>";
     } else {
         $reference_link = "-";
     }
     if ($file_analysis['locale_exists']) {
         $locale_link = "<a href='{$file_analysis['locale_url']}'>Locale file</a> " . "<span class='last_update' title='last update'>(" . date("Y-m-d H:i", $file_analysis['locale_lastupdate']) . ")</span>";
     } else {
         $locale_link = "-";
     }
     $html_rows .= "  <tr>\n" . "    <td class='maincolumn'>" . basename($current_filename) . "</td>\n" . "    <td><span class='rawstatus {$cmp_result}'>" . str_replace('_', ' ', $cmp_result) . "</span></td>\n" . "    <td>{$reference_link}</td>\n" . "    <td>{$locale_link}</td>\n" . "  </tr>\n";