From e647c353ee4db55c4c3b82185cf7aea386729c52 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Thu, 21 Oct 2010 11:20:36 +0000 Subject: [PATCH] translation.php: Add support for pushing translations. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2583 44740490-163a-0410-bde0-09ae8108e29a --- bin/translation.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/translation.php b/bin/translation.php index 75c7a7c29..088924461 100755 --- a/bin/translation.php +++ b/bin/translation.php @@ -19,9 +19,14 @@ $translationconfig = SimpleSAML_Configuration::getConfig('translation.php'); $application = $translationconfig->getString('application', 'simplesamlphp'); $base = $translationconfig->getString('baseurl') . '/module.php/translationportal/'; -if (!preg_match('/^(.*?)(\.definition|\.translation)?\.(json|php)/', $file, $match)) +if (!preg_match('/^(.*?)(?:\.(definition|translation))?\.(json|php)/', $file, $match)) throw new Exception('Illlegal file name. Must end on (definition|translation).json'); $fileWithoutExt = $match[1]; +if (!empty($match[2])) { + $type = $match[2]; +} else { + $type = 'definition'; +} $basefile = basename($fileWithoutExt); @@ -49,7 +54,7 @@ switch($action) { #$content = file_get_contents($base . 'export.php?aid=' . $application . '&type=translation&file=' . $basefile); #file_put_contents($fileWithoutExt . '.translation.json' , $content); - push($file, $basefile, $application); + push($file, $basefile, $application, $type); break; @@ -87,7 +92,7 @@ function convert_translation($data) { return $data; } -function push($file, $fileWithoutExt, $aid) { +function push($file, $fileWithoutExt, $aid, $type) { if (!file_exists($file)) throw new Exception('Could not find file: ' . $file); @@ -141,7 +146,7 @@ function push($file, $fileWithoutExt, $aid) { } $pushURL = $baseurl . '/module.php/translationportal/push.php'; - $request = array('data' => base64_encode($fileContent), 'file' => $fileWithoutExt, 'aid' => $aid); + $request = array('data' => base64_encode($fileContent), 'file' => $fileWithoutExt, 'aid' => $aid, 'type' => $type); $result = $consumer->postRequest($pushURL, $accessToken, $request); -- GitLab