Commit ed085479 authored by Cerdic's avatar Cerdic

offline.api.urlsdownload.json?objet=rubrique&id_objet=2 pour acceder aux urls...

offline.api.urlsdownload.json?objet=rubrique&id_objet=2 pour acceder aux urls a mettre en cache pour l'objet concerne
renvoie le contenu du fichier config/offline/objets/urls-rubrique-2.txt au format json si il existe et sinon un tableau vide, sans provoquer de build
parent 19f91135
......@@ -57,7 +57,10 @@ function action_api_offline_dist($arg = null, $return = false, $cached_or_refres
$c = $GLOBALS['meta']['charset'];
$content_type = 'text/plain';
if (substr($arg,-3) === '.js') {
$content_type = 'text/javascript';
$content_type = 'application/javascript';
}
elseif (substr($arg,-5) === '.json') {
$content_type = 'application/json';
}
header('Content-Type: ' . $content_type . '; charset=' . $c);
......@@ -114,3 +117,17 @@ function action_api_offline_uninstall_js_dist($force_refresh = false) {
)
);
}
function action_api_offline_urlsdownload_json_dist() {
include_spip('inc/offline');
$objet = _request('objet');
$id_objet = _request('id_objet');
$file_urls_load = offline_filename_urls_to_load_objet($objet, $id_objet);
if (!file_exists($file_urls_load) or !$urls = file_get_contents($file_urls_load)) {
return '[]';
}
$urls = explode("\n", $urls);
return json_encode($urls);
}
\ No newline at end of file
......@@ -469,6 +469,10 @@ function offline_filename_urls_to_load_objet($objet, $id_objet) {
$dir_config = sous_repertoire(_DIR_ETC, 'offline');
$dir_config = sous_repertoire($dir_config, 'objets');
// securité
$objet = objet_type($objet);
$id_objet = intval($id_objet);
$file_urls_load = $dir_config . "urls-{$objet}-{$id_objet}.txt";
return $file_urls_load;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment