Example #1
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']));
Example #2
0
     }
     if ($website_with_errors) {
         $locale_htmloutput .= "      </div>\n\n";
         if (!$locale_with_errors) {
             $locale_with_errors = true;
         }
     }
 }
 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) {