]> git.nbdom.net Git - nb.git/commitdiff
config dir
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 6 Jul 2015 13:55:57 +0000 (14:55 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 6 Jul 2015 13:55:57 +0000 (14:55 +0100)
lib/php/db.php
lib/php/functions.php
lib/php/page.php

index a6b2b3a5158b810e03ac477a1bd11a9732e8b77a..ed912d180824ec38bf7a80a242571dee52755860 100644 (file)
@@ -238,7 +238,11 @@ EOF;
   }
 
   function pset($name,$value) {
-    return $_REQUEST[$name] = $value;
+    if ($value === null) {
+      unset ($_REQUEST[$name]);
+      return null;
+    }
+    return ($_REQUEST[$name] = $value);
   }
 
   /*
@@ -290,55 +294,6 @@ class table {
     return $this->fields();
   }
 
-  /*
-   * Function db.page
-   *
-   * print any pages according to params
-   *
-   * @param (array)
-   */
-  function page($Page,$param=null) {
-    if ($param === null) $param = $this->p();
-    elseif (!is_array($param)) $param = array('name' => $param);
-
-    foreach (array(
-      'action' => 'list',
-    ) as $k => $v) {
-    }
-
-    $Page->title = prettyText($this->name);
-
-    #if ($Page->is('html')) $this->form_criterias();
-
-    if ($this->p('format')) $this->print_header($this->p('format'));
-    if ($this->p('format')) {
-      $this->rows(array('format' => $this->p('format')));
-      return 0;
-    }
-
-    #die($Page->content_type);
-    $Page->begin();
-    echo '<div id="msg"></div>'.PHP_EOL;
-    echo '<div id="db">'.PHP_EOL;
-    #$Page->debug($this->tables());
-
-
-    echo $this->html_menu();
-
-    /*
-      Rows
-    */
-    if (@$this) $this->rows(array(
-      'format' => $this->p('format'),
-    ));
-
-    // END
-    echo '</div>'.PHP_EOL;
-    #$Page->out($Db->query2v("SELECT 1"));
-    $Page->end();
-    return 0;
-  }
-
   /*
    * Function db.fields
    *
@@ -795,7 +750,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
     $st = $this->db->conn->prepare($sql);
     $st->execute();
 
-    $format = ''.(isset($opt['format']) ? $opt['format'] : 'table');
+    $format = (!empty($opt['format']) ? $opt['format'] : 'table');
 
     if (!@$opt['is_html']) $opt['is_html'] = preg_match('/^(table)$/',$format) ? true : false;
     if ($opt['is_html']) echo '<div align="center" class="nav" id="nav_top"></div>'.PHP_EOL;
index 9dea64b382547889ba9804faf71c7e80af9c8d5e..3b8d287ebd3527995677acd41bc20408cb779ad5 100644 (file)
@@ -62,6 +62,8 @@ function ls_dir($path,$recurse=false,$exp='') {
 
 }
 
+function ar_first($ar) { return $ar[0]; }
+
 function ar_map($return,$array,$as_hash=false) {
   $map = array_map(create_function('$a',"return($return);"),$array);
 
index 995bbd6eea05cfeb2f41d8dc971e8bfe3082df10..85b9b571368614ea67a9b07e1f79762bd4281bd1 100644 (file)
@@ -83,8 +83,9 @@ class Page {
   }
 
   function filename2title() {
-    $str = preg_replace(',^.*?([^/]+)(\/?.*)?$,','\1',$_SERVER['REQUEST_URI']);
-    if ($str == '/') $str = preg_replace('@^.*?([^/\.]+)(/index)?(\..*?)$@','\1',$_SERVER['SCRIPT_NAME']);
+    $str = '';
+    if (isset($_SERVER['REQUEST_URI'])) $str = preg_replace(',^.*?([^/]+)(\/?.*)?$,','\1',$_SERVER['REQUEST_URI']);
+    if ($str == '' or $str == '/') $str = preg_replace('@^.*?([^/\.]+)(/index)?(\..*?)$@','\1',$_SERVER['SCRIPT_NAME']);
     $str = preg_replace('@[\'_-]+$@',' ',$str);
     return mb_strtoupper(mb_substr($str,0,1)).mb_strtolower(mb_substr($str,1,mb_strlen($str)));
   }