Example #1
0
    }
}
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']));
    $nb_strings = count($reference_data['strings']);
    if (in_array($current_locale, $supported_locales)) {
        $status = '<span class=\'yes\'>yes</span>';
        $actions = '-';
    } else {
        $available_optins[] = $current_filename;
        $status = '<span class=\'no\'>no</span> ';
        $actions = '<a href="' . Bugzilla::getNewBugLink($current_locale, $bugzilla_locale, 'opt-in', [$current_filename]) . '"' . ' class="table_small_link" title="File a bug to request this page">Opt-in</a>';
    }
    $html_output .= "<tr>\n" . "  <td class='optin_filename'>{$current_filename}</td>\n" . '  <td>' . Project::getLocalizedURL($reference_data, $current_locale, 'html') . "</td>\n" . "  <td>{$nb_strings}</td>\n" . "  <td>{$nb_words}</td>\n" . "  <td class='optin_status'>{$status}</td>\n" . "  <td class='optin_actions'>{$actions}</td>\n" . "</tr>\n";
}
$html_output .= "</tbody>\n  </table>\n";
if (count($available_optins) > 0) {
    $html_output .= '<p>You can also <a href="' . Bugzilla::getNewBugLink($current_locale, $bugzilla_locale, 'opt-in', $available_optins) . '">file a bug to opt-in for all pages</a> currently unsupported (' . count($available_optins) . ').</p>';
}
echo $html_output;
 $todo_files = '';
 foreach (Project::getWebsiteFiles($current_website) as $current_filename) {
     // File not supported
     if (!Project::isSupportedLocale($current_website, $current_locale, $current_filename, $langfiles_subsets)) {
         continue;
     }
     // File marked as obsolete
     if (Project::isObsoleteFile($current_website, $current_filename, $current_locale)) {
         continue;
     }
     // File doesn't exist
     if (!file_exists(Project::getLocalFilePath($current_website, $current_locale, $current_filename))) {
         continue;
     }
     $supported_locale = true;
     $bugzilla_link = Bugzilla::getNewBugLink($current_locale, $bugzilla_locale, 'upload', [$current_filename]);
     // Load reference strings
     $reference_filename = Project::getLocalFilePath($current_website, $reference_locale, $current_filename);
     $reference_url = Project::getPublicFilePath($current_website, $reference_locale, $current_filename);
     $reference_data = LangManager::loadSource($current_website, $reference_locale, $current_filename);
     // Extract data from locale
     $locale_filename = Project::getLocalFilePath($current_website, $current_locale, $current_filename);
     $locale_url = Project::getPublicFilePath($current_website, $current_locale, $current_filename);
     $locale_analysis = LangManager::analyzeLangFile($current_website, $current_locale, $current_filename, $reference_data);
     if (!in_array($current_filename, $no_active_tag) && $website_name == 'www.mozilla.org') {
         $status = $locale_analysis['activated'] ? ' file_activated' : ' file_notactivated';
     } else {
         $status = ' file_activated';
     }
     // check if the lang file is in utf8
     if (Utils::isUTF8($locale_filename) == false) {