Beispiel #1
0
 public function testFetchContent()
 {
     $obj = new _Json();
     $json_content = $obj->setURI(TEST_FILES . 'test_input.json')->fetchContent();
     $this->integer(count($json_content))->isEqualTo(2);
     $this->boolean(isset($json_content['www.mozilla.org']))->isTrue();
 }
use Cache\Cache;
$json = isset($_GET['json']);
$locale = $_GET['locale'];
// Include all data about our locales
include __DIR__ . '/../data/locales.php';
// Check that this is a valid locale code called via GET
if (!isset($_GET['locale']) || !in_array($_GET['locale'], $locales)) {
    $content = '<h2>Wrong locale code</h2>';
    include __DIR__ . '/../views/error.php';
    return;
} else {
    $locale = $_GET['locale'];
}
// Get lang files status from langchecker
$json_data = new Json();
$lang_files = $json_data->setURI(LANG_CHECKER . "?locale={$locale}&json")->fetchContent();
// Check if the locale is working on locamotion
$cache_id = 'locamotion_locales';
if (!($locamotion = Cache::getKey($cache_id))) {
    $locamotion = $json_data->setURI(LANG_CHECKER . '?action=listlocales&project=locamotion&json')->fetchContent();
    Cache::setKey($cache_id, $locamotion);
}
$locamotion = in_array($locale, $locamotion);
// All open bugs for a locale in the mozilla.org/l10n component
$bugzilla_query_mozillaorg = 'https://bugzilla.mozilla.org/buglist.cgi?' . 'f1=cf_locale' . '&o1=equals' . '&query_format=advanced' . '&v1=' . urlencode(Bugzilla::getBugzillaLocaleField($locale)) . '&o2=equals' . '&f2=component' . '&v2=L10N' . '&bug_status=UNCONFIRMED' . '&bug_status=NEW' . '&bug_status=ASSIGNED' . '&bug_status=REOPENED' . '&classification=Other' . '&product=www.mozilla.org';
// All open bugs for a locale in the Mozilla Localization/locale component, with "webdashboard" in the whiteboard
$bugzilla_query_l10ncomponent = 'https://bugzilla.mozilla.org/buglist.cgi?' . '&query_format=advanced' . '&status_whiteboard_type=allwordssubstr' . '&status_whiteboard=webdashboard' . '&bug_status=UNCONFIRMED' . '&bug_status=NEW' . '&bug_status=ASSIGNED' . '&bug_status=REOPENED' . '&component=' . urlencode(Bugzilla::getBugzillaLocaleField($locale, 'l10n')) . '&classification=Client%20Software' . '&product=Mozilla%20Localizations';
/* Use cached requests if available, cache expires after 1 hour
 * Note: result can be empty, so I need to check strictly for false
 */
$cache_id = "bugs_mozillaorg_{$locale}";
Beispiel #3
0
<?php

namespace Webdashboard;

use Cache\Cache;
// Check if the locale is working on locamotion
$json_data = new Json();
$cache_id = 'locamotion_locales';
if (!($locamotion = Cache::getKey($cache_id))) {
    $locamotion = $json_data->setURI(LANG_CHECKER . '?action=listlocales&project=locamotion&json')->fetchContent();
    Cache::setKey($cache_id, $locamotion);
}
// Base for the query to get external data
$langchecker_query = LANG_CHECKER . '?locale=all&json';
$locale_done = [];
// Include all data about project pages
include __DIR__ . '/../data/project.php';
// Fall back to default if the project is not available
$requested_project = array_key_exists($project, $projects) ? $project : 'default';
$project_data = $projects[$requested_project];
$pages = $project_data['pages'];
$sum_pages = count($pages);
// Get all locales from project pages list
$locales = [];
foreach ($pages as $page) {
    $filename = $page['file'];
    $json_string = $langchecker_query . '&file=' . $filename . '&website=' . $page['site'];
    $cache_id = 'page_' . $filename . '_' . $page['site'];
    if (!($data_page = Cache::getKey($cache_id))) {
        $data_page = $json_data->setURI($json_string)->fetchContent()[$filename];
        Cache::setKey($cache_id, $data_page);