Skip to content
Permalink
Browse files

Use external library for JSON

  • Loading branch information
flodolo committed Nov 19, 2015
1 parent 1e13de2 commit 268850bef2a95a448a78e5ca958096d82f776e60

This file was deleted.

@@ -1,13 +1,23 @@
<?php
namespace Transvision;

use Json\Json;

// Create a JSON file logging locale/number of requests
$stats = Json::fetch(CACHE_PATH . 'stats_locales.json');
$json_data = new Json;
$local_filename = CACHE_PATH . 'stats_locales.json';
$stats = $json_data
->setURI($local_filename)
->fetchContent();

$stats[$locale] = array_key_exists($locale, $stats) ? $stats[$locale] += 1 : 1;
file_put_contents(CACHE_PATH . 'stats_locales.json', json_encode($stats));
$json_data->saveFile($stats, $local_filename);

// Create a JSON file logging search options to determine if some are unused
$stats = Json::fetch(CACHE_PATH . 'stats_requests.json');
$local_filename = CACHE_PATH . 'stats_requests.json';
$stats = $json_data
->setURI($local_filename)
->fetchContent();

foreach ($check as $k => $v) {
if (in_array($k, $form_checkboxes) && $v == 1) {
@@ -18,6 +28,6 @@
$stats[$v] = array_key_exists($v, $stats) ? $stats[$v] += 1 : 1;
}

file_put_contents(CACHE_PATH . 'stats_requests.json', json_encode($stats));
$json_data->saveFile($stats, $local_filename);
}
unset($stats);
@@ -1,15 +1,18 @@
<?php
namespace Transvision;

use Json\Json;

/*
* This view outputs a json or jsonp representation of search results
* 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
die(Json::output(
// 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
));
@@ -8,6 +8,10 @@
"type": "vcs",
"url": "https://github.com/mozilla-l10n/phpclass-cache"
},
{
"type": "vcs",
"url": "https://github.com/mozilla-l10n/phpclass-json"
},
{
"type": "vcs",
"url": "https://github.com/pascalchevrel/Verif/"
@@ -47,6 +51,7 @@
"monolog/monolog" : "~1.1",
"mozillal10n/bugzilla": "~0.1",
"mozillal10n/cache": "~0.1",
"mozillal10n/json": "~0.1",
"pascalc/tinyl10n" : "~0.1",
"pascalc/vcs": "~0.1",
"robloach/component-installer": "*",

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 268850b

Please sign in to comment.
You can’t perform that action at this time.