$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']); $total_strings += $nb_strings; $total_words += $nb_words; $total_files++; $html_output .= "<tr>\n"; // Check if the file is obsolete for all locales if (Project::isObsoleteFile($current_website, $current_filename, 'all')) { $html_output .= " <td class='obsolete' title='Obsolete file'>{$current_filename}</td>\n"; } else { $html_output .= " <td>{$current_filename}</td>\n"; } $html_output .= ' <td>' . Project::getLocalizedURL($reference_data, '', 'html') . "</td>\n" . " <td><a class='table_small_link' href='?locale=all&website={$site_index}&file={$current_filename}'>Status</a></td>\n" . " <td><a class='table_small_link' href='?website={$site_index}&file={$current_filename}&action=translate&show'>Show</a></td>\n" . " <td>{$nb_strings}</td>\n" . " <td>{$nb_words}</td>\n" . "</tr>\n"; } else { $html_output .= "<tr>\n" . " <td>" . basename($current_filename) . "</td>\n" . " <td><a class='table_small_link' href='?locale=all&website={$site_index}&file={$current_filename}'>Status</a></td>\n" . "</tr>\n"; } } $total_files .= $total_files != 1 ? ' files' : ' file'; if ($website_data_source == 'lang') { $html_output .= "<tr class=\"tabletotals\">\n" . " <th colspan=\"3\">Total</th>\n" . " <td>{$total_files}</td>\n" . " <td>{$total_strings}</td>\n" . " <td>{$total_words}</td>\n" . "</tr>\n"; } $html_output .= " </tbody>\n</table>\n\n"; } if ($html_output == '') { echo "<p>No files available.</p>"; } else { echo $html_output; }
} } 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;