From: Nicolas Boisselier Date: Tue, 14 Jun 2016 23:37:14 +0000 (+0100) Subject: dbq2 X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=26217729d0501c549e442f18489cef60166f39c8;p=nb.git dbq2 --- diff --git a/etc/dbs/rent.php b/etc/dbs/rent.php index 1cdf044a..ae576fb2 100644 --- a/etc/dbs/rent.php +++ b/etc/dbs/rent.php @@ -1,4 +1,8 @@ '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('%s ',"$url/$p",preg_replace('@^.*?([^/\.]+).*?$@','\1',$p)); + } + } + }, + ); +} + $CONF['rent'] = array ( 'order' => 5, 'pdo' => 'sqlite:/opt/rent/rent.db', diff --git a/lib/js/nb.js b/lib/js/nb.js index 3e175ce0..e7241f57 100644 --- a/lib/js/nb.js +++ b/lib/js/nb.js @@ -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