]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 2 Jan 2018 22:23:44 +0000 (22:23 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 2 Jan 2018 22:23:44 +0000 (22:23 +0000)
www/dbq/dbq.php

index c28a828151d42e0c5379f657236be6738081e6ed..39a9bcb40484c57c1388e520fe0bad67e593e8b3 100644 (file)
@@ -554,13 +554,14 @@ class DbQ extends nb {
                return [array_values($title),$nav];
        }
 
-       public function method_post_accept_decode() {
+       public function method_post_accept_decode($type=null) {
                if ( empty($_SERVER['REQUEST_METHOD']) or $_SERVER['REQUEST_METHOD'] != 'POST' ) return;
+               if (empty($type)) $type = self::client_content_type();
                $raw = null;
 
                foreach (['json','yaml'] as $type) {
 
-                       if (!strpos(self::client_content_type(),'/'.$type)) continue;
+                       if (!strpos($type,'/'.$type)) continue;
                        if ($raw) $_POST = [ $type => $raw ];
                        if (empty($_POST[$type])) continue;
                        #bye($_POST);
@@ -578,7 +579,6 @@ class DbQ extends nb {
        }
 
        private function uri_init() {
-               $this->method_post_accept_decode();
 
                #
                # Parse path, respect params order
@@ -801,8 +801,8 @@ EOF;
                if ($this->params['format']) {
                        $format = $this->params['format'];
 
-               } else if ($content_type = self::client_content_type() and ( $format=Mime::toExt($content_type) )) {
-                       #$format = $format;
+               } else if ($content_type = self::client_content_type() and ( $format = Mime::toExt($content_type) )) {
+                       # Not empty !
 
                } else {
                        $format = 
@@ -828,6 +828,7 @@ EOF;
                // Affect values to objects
                if ($format == 'html') $format = $this->format_html;
                $this->format($format);
+               $this->method_post_accept_decode();
                $this->is_html = strpos($content_type,'html') ? true : false;
                $this->db->is_html = $this->is_html;