From 19403adde251182671a1869f674f8ecd8adc2193 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Mon, 8 Aug 2016 15:54:29 +0100 Subject: [PATCH] Read plugin LICENSES json and display in Store Config (#359) --- application/controllers/Config.php | 75 ++++++++++++++++++++++++------ license/bootstrap.license | 2 +- license/bootstrap.version | 2 +- license/bootswatch.version | 2 +- license/jquery.license | 44 ------------------ license/jquery.version | 1 - 6 files changed, 65 insertions(+), 61 deletions(-) delete mode 100644 license/jquery.license delete mode 100644 license/jquery.version diff --git a/application/controllers/Config.php b/application/controllers/Config.php index 86c8d84f6..f17a2f0db 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -17,6 +17,7 @@ class Config extends Secure_Controller private function _licenses() { $i = 0; + $various = FALSE; $license = array(); $license[$i]['title'] = 'Open Source Point Of Sale ' . $this->config->item('application_version'); @@ -36,23 +37,71 @@ class Config extends Secure_Controller foreach($dir as $fileinfo) { // license files must be in couples: .version (name & version) & .license (license text) - if($fileinfo->isFile() && $fileinfo->getExtension() == 'version') + if($fileinfo->isFile()) { - ++$i; - - $basename = 'license/' . $fileinfo->getBasename('.version'); - - $license[$i]['title'] = $this->xss_clean(file_get_contents($basename . '.version', NULL, NULL, 0, 100)); - - $license_text_file = $basename . '.license'; - - if(file_exists($license_text_file)) + if($fileinfo->getExtension() == 'version') { - $license[$i]['text'] = $this->xss_clean(file_get_contents($license_text_file , NULL, NULL, 0, 2000)); + ++$i; + + $basename = 'license/' . $fileinfo->getBasename('.version'); + + $license[$i]['title'] = $this->xss_clean(file_get_contents($basename . '.version', NULL, NULL, 0, 100)); + + $license_text_file = $basename . '.license'; + + if(file_exists($license_text_file)) + { + $license[$i]['text'] = $this->xss_clean(file_get_contents($license_text_file , NULL, NULL, 0, 2000)); + } + else + { + $license[$i]['text'] = $license_text_file . ' file is missing'; + } } - else + elseif($fileinfo->getBasename() == 'LICENSES') { - $license[$i]['text'] = $license_text_file . ' file is missing'; + // set a flag to indicate that the LICENSES file is available and needs to be attached at the end + $various = TRUE; + } + } + } + + // attach the licenses from the LICENSES file generated by bower + if($various) + { + ++$i; + $license[$i]['title'] = 'Plugins'; + $license[$i]['text'] = ''; + + $file = file_get_contents('license/LICENSES'); + $array = json_decode($file, true); + + foreach($array as $key => $val) + { + if(is_array($val)) + { + $license[$i]['text'] .= 'component: ' . $key . "\n"; + + foreach($val as $key1 => $val1) + { + if(is_array($val1)) + { + $license[$i]['text'] .= $key1 . ': '; + + foreach($val1 as $key2 => $val2) + { + $license[$i]['text'] .= $val2 . ' '; + } + + $license[$i]['text'] .= "\n"; + } + else + { + $license[$i]['text'] .= $key1 . ': ' . $val1 . "\n"; + } + } + + $license[$i]['text'] .= "\n"; } } } diff --git a/license/bootstrap.license b/license/bootstrap.license index f4c52d6a4..5ac7228f5 100644 --- a/license/bootstrap.license +++ b/license/bootstrap.license @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2011-2015 Twitter, Inc +Copyright (c) 2011-2016 Twitter, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/license/bootstrap.version b/license/bootstrap.version index e531c5b2a..f1eda158e 100644 --- a/license/bootstrap.version +++ b/license/bootstrap.version @@ -1 +1 @@ -Bootstrap 3.3.6 \ No newline at end of file +Bootstrap 3.3.7 \ No newline at end of file diff --git a/license/bootswatch.version b/license/bootswatch.version index 80145e3fa..4c31438e0 100644 --- a/license/bootswatch.version +++ b/license/bootswatch.version @@ -1 +1 @@ -Bootswatch 3.3.6 \ No newline at end of file +Bootswatch 3.3.7 \ No newline at end of file diff --git a/license/jquery.license b/license/jquery.license deleted file mode 100644 index 156f8d5ca..000000000 --- a/license/jquery.license +++ /dev/null @@ -1,44 +0,0 @@ -Copyright 2007, 2014 jQuery Foundation and other contributors, -https://jquery.org/ - -This software consists of voluntary contributions made by many -individuals. For exact contribution history, see the revision history -available at https://github.com/jquery/jquery-ui - -The following license applies to all parts of this software except as -documented below: - -==== - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -==== - -Copyright and related rights for sample code are waived via CC0. Sample -code is defined as all source code contained within the demos directory. - -CC0: http://creativecommons.org/publicdomain/zero/1.0/ - -==== - -All files located in the node_modules and external directories are -externally maintained libraries used by this software which have their -own licenses; we recommend you read them, as their terms may differ from -the terms above. diff --git a/license/jquery.version b/license/jquery.version deleted file mode 100644 index 9410699ed..000000000 --- a/license/jquery.version +++ /dev/null @@ -1 +0,0 @@ -jQuery 1.12.4 jQuery-UI 1.11.4 \ No newline at end of file