From cd2687893b7207f28703047b9dbafe007179e92c Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Fri, 19 Jan 2018 04:03:29 +0000 Subject: [PATCH] lib/php/nb.php --- lib/php/mime.php | 4 ++-- lib/php/nb.php | 7 ++++++- www/dbq/dbq.php | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/php/mime.php b/lib/php/mime.php index 10ee5f1c..780da05d 100644 --- a/lib/php/mime.php +++ b/lib/php/mime.php @@ -692,14 +692,14 @@ class Mime { 'text/sh' => 'sh', ]; - public static function fromExt($ext) { + public static function get($ext) { foreach (self::Types as $t => $e) { if ($ext == $e) return $t; } return null; } - public static function toExt($type) { + public static function ext($type) { if (empty(self::Types[$type])) return null; return self::Types[$type]; } diff --git a/lib/php/nb.php b/lib/php/nb.php index e7dfeace..96d25a6b 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -7,7 +7,7 @@ if (!defined('NB_EOL')) define('NB_EOL',(defined('NB_PROD') and NB_PROD) ? '' : if (!defined('NB_P_GET')) define('NB_P_GET',true); require_once(NB_ROOT.'/lib/php/functions.php'); -require_once(NB_ROOT.'/lib/php/http.php'); +require_once(NB_ROOT.'/lib/php/mime.php'); if (class_exists('NB')) return; # protect against double include class NB { @@ -24,6 +24,7 @@ class NB { #<_SHELL_REPLACE ); + # NB 19.01.18: TODEL protected static $content_types = array( 'json' => 'text/json', 'doc' => 'application/msword', @@ -228,11 +229,14 @@ class NB { * Function: prettyText * Does what it says */ + # NB 19.01.18: TODEL public static function prettyText($text) { return prettyText($text); } + # NB 19.01.18: TODEL public static function mime2ext($mime) { + return Mime::ext($mime); static $aliases = null; if ($aliases === null) $aliases = array_combine( @@ -255,6 +259,7 @@ class NB { */ #public static function ext2content_type($ext) { return self::ext2mime($ext); } public static function ext2mime($ext) { + return Mime::get($ext); foreach (self::$content_types as $e => $c) { if ($ext == $e) return $c; diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 68bfb6c2..47a96e12 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -860,7 +860,7 @@ EOF; if ($this->params['format']) { $format = $this->params['format']; - } else if ($content_type = self::client_content_type() and ( $format = Mime::toExt($content_type) )) { + } else if ($content_type = self::client_content_type() and ( $format = Mime::ext($content_type) )) { # Not empty ! } else { @@ -879,7 +879,7 @@ EOF; if (!empty($this->limits)) $this->db->limits = $this->limits; // Then content type - if (empty($content_type)) $content_type = Mime::fromExt($format==$this->format_cli ? 'txt' : $format); + if (empty($content_type)) $content_type = Mime::get($format==$this->format_cli ? 'txt' : $format); if (empty($content_type) and $this->db->out->is_html($format)) $content_type = 'text/html'; if (empty($content_type)) $content_type = 'text/plain'; if ($content_type) $this->page->content_type($content_type); -- 2.47.3