]> git.nbdom.net Git - nb.git/commitdiff
dbq2
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 14 Jun 2016 23:37:14 +0000 (00:37 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 14 Jun 2016 23:37:14 +0000 (00:37 +0100)
etc/dbs/rent.php
lib/js/nb.js

index 1cdf044abe69852200b7c2979890c956c015ac3d..ae576fb2a8375863453408d1fd1125f80a0b54bd 100644 (file)
@@ -1,4 +1,8 @@
 <?php
+#die(print_r(posix_getpwnam('nico'),true));
+#die(print_r(posix_getpwuid(posix_getuid()),true));
+#die(print_r(pathinfo('~/.gitconfig'),true));
+#die(file_exists(realpath('~/.gitconfig')) ? 'yes' : 'no');
 $CONF['_rent'] = array(
   'Title' => 'Rent',
   'notice' => 'Micro foncier 4BE',
@@ -57,6 +61,39 @@ $CONF['_rent'] = array(
   ),
 );
 
+function untilde($path) {
+  if (!function_exists('posix_getuid')) return $path;
+  return preg_replace_callback('/^(~)(\w+)?/',function($m){
+    if (!empty($m[2])) return str_replace($m[2],posix_getpwnam('nico')['dir'],$m[0]);
+    return str_replace($m[1],posix_getpwuid(posix_getuid())['dir'],$m[0]);
+  },$path);
+}
+
+#die(untilde('~/.gitconfig'));
+if (!empty($_SERVER['DOCUMENT_ROOT'])) {
+  $CONF['_rent']['tables']['tenant'] = array(
+    'row_parse_post' => function(&$r) {
+      $url = '/data/tenant';
+
+      if (
+        (
+          (!$doc=$r['doc']) and file_exists( $dir = $_SERVER['DOCUMENT_ROOT'].$url.'/'.$r['id'] )
+        ) or (
+          ( $dir = untilde($r['doc']) ) 
+          and file_exists($dir) and is_dir($dir)
+          and ($url='' or 1)
+        )
+      ) {
+  #debug($_SERVER['DOCUMENT_ROOT'].'/data/tenant/');
+        foreach (ls_dir($dir,true) as $p) {
+          #$r['doc'] .= '/data/tenant/'.$p;
+          $r['doc'] .= sprintf('<a href="%s" class="small">%s</a> ',"$url/$p",preg_replace('@^.*?([^/\.]+).*?$@','\1',$p));
+        }
+      }
+    },
+  );
+}
+
 $CONF['rent'] = array (
   'order' => 5,
   'pdo' => 'sqlite:/opt/rent/rent.db',
index 3e175ce042a9763883f6afe559ee3803f0c45b40..e7241f57e78b8b79b584c5a55d2346a5de6864be 100644 (file)
@@ -283,11 +283,12 @@ function NB(args) {
 
   this.str2a = function(elems,compact,class_exp_file) {
     compact = (typeof compact === 'undefined') ? true : compact;
-    class_exp_file = (typeof class_exp_file === 'undefined') ? 'dir|path' : class_exp_file;
+    class_exp_file = (typeof class_exp_file === 'undefined') ? 'doc|dir|path' : class_exp_file;
     $(elems).each(function(){
 
       var text = $(this).text();
       if (text == '') return;
+      if (text != $(this).html()) return; // contents html
 
       // Search /home
       var url = text