]> git.nbdom.net Git - nb.git/commitdiff
lib/php/nb.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 19 Jan 2018 04:03:29 +0000 (04:03 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 19 Jan 2018 04:03:29 +0000 (04:03 +0000)
lib/php/mime.php
lib/php/nb.php
www/dbq/dbq.php

index 10ee5f1c3884bb8dc75ea4eb57b546a970e4b77f..780da05dd88d61724bd019d6fdf8c25e6dc263ce 100644 (file)
@@ -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];
        }
index e7dfeace822fc7866670af9c62967f86561c97db..96d25a6b07ec40523ba372cb5ea038b068120008 100644 (file)
@@ -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;
index 68bfb6c2466ffe9689d9cecd69dda1732ab085b6..47a96e1206295b926e15ca259c5740d70731e9c9 100644 (file)
@@ -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);