Ejemplo n.º 1
0
<?php

namespace Transvision;

use Json\Json;
/*
 * This view outputs a JSON or JSONP representation of search results
 */
// Log script performance in PHP integrated developement server console
Utils::logScriptPerformances();
// We die here because we never want to send anything more after the JSON file
$json_data = new Json();
die($json_data->outputContent($json, isset($_GET['callback']) ? $_GET['callback'] : false));
Ejemplo n.º 2
0
 /**
  * @dataProvider redirectToAPIDP
  */
 public function testRedirectToAPI($a, $b)
 {
     $obj = new _Utils();
     $_SERVER["REQUEST_URI"] = $a;
     $_SERVER['QUERY_STRING'] = isset(parse_url($a)['query']) ? parse_url($a)['query'] : null;
     $this->string($obj->redirectToAPI())->isEqualTo($b);
 }
Ejemplo n.º 3
0
<?php

namespace Transvision;

use Cache\Cache;
$cache_id = $repo . $entity . 'alllocales';
if (!($translations = Cache::getKey($cache_id))) {
    $translations = [];
    foreach (Project::getRepositoryLocales($repo) as $locale_code) {
        $strings = Utils::getRepoStrings($locale_code, $repo);
        if (isset($strings[$entity])) {
            $strings[$entity] = trim($strings[$entity]);
            if (Strings::endsWith(strtolower($strings[$entity]), '{ok}')) {
                $strings[$entity] = trim(substr($strings[$entity], 0, -4));
            }
            $translations[$locale_code] = $strings[$entity];
        }
        // Releasing memory in the loop saves 15% memory on the script
        unset($strings);
    }
    Cache::setKey($cache_id, $translations);
}
return $json = $translations;
Ejemplo n.º 4
0
}
// Closing content div for each tab, concatenate all the html
$content = '';
foreach (array_keys($html) as $project) {
    if (!empty($html[$project]['repos'])) {
        $content .= $html[$project]['repos'] . '</table>' . Health::getStatsPane($projects[$project]) . '</div>';
    }
}
// Get stats
$stats = Health::getStats($projects);
$translated = $stats['translated'];
$reference = $stats['total'];
$completion = round($translated / $reference * 100, 2);
$completion = $completion > 100 ? 100 : $completion;
// Get color from completion value
$color = Utils::redYellowGreen($completion);
// Get active projects
$active_projects = '<h4>Active projects:</h4><ul>';
if (isset($projects['release']['repos'])) {
    $active_projects .= '<li><b>Desktop:</b> ';
    foreach (array_keys($projects['release']['repos']) as $repo) {
        if (in_array($repo, array_keys(Project::$components_names))) {
            $active_projects .= Project::$components_names[$repo] . ', ';
        }
    }
    $active_projects .= '</li>';
}
if (isset($projects['gaia'])) {
    $active_projects .= '<li><b>Gaia:</b> ';
    foreach (array_keys($projects['gaia']) as $repo) {
        $active_projects .= Project::getRepositoriesNames()[$repo] . ', ';
Ejemplo n.º 5
0
<p class="api_link">
    <span>API</span>These results are also available as an <a href="<?php 
echo \Transvision\Utils::redirectToAPI();
?>
">API request</a>.<br>
    <a href="https://github.com/mozfr/transvision/wiki/JSON-API">Learn more about Transvision API</a>.
</p>