]> git.nbdom.net Git - nb.git/commitdiff
buttons in functiopn
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 7 Apr 2016 11:34:54 +0000 (12:34 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 7 Apr 2016 11:34:54 +0000 (12:34 +0100)
lib/php/db/table.php

index 920452c3c023dc68a5ef74b3ba625212eb93fdc4..d4950d4cb81490760dc053a2db049f8aa2b59006 100644 (file)
@@ -223,7 +223,7 @@ Class Table extends nb {
     }
 
     foreach (self::$params as $p) if ($v=self::p($p)) $url[] = $p.'='.urlencode($v);
-    return $url ? '?'.$sep.join($sep,$url) : '';
+    return $url ? '?'.join($sep,$url) : '';
   }
 
   public function fields_keys(&$others=array()) {
@@ -887,22 +887,18 @@ Class Table extends nb {
 
   public function rows_rec_table(&$row) {
 
+    $buttons = $this->html_row_buttons($row);
+
     $html = '<tr class="row">'.NB_EOL;
 
-    if ($this->p('buttons')!=='0') $html .=
-      '<td class="action"><a class="edit button" href="'
-        .$this->url_keys($row,'action=edit')
-      .'">'.DB_HTML_EDIT.'</a></td>'.NB_EOL;
+    if ($this->p('buttons')!=='0') $html .= '<td class="action">'.$buttons[0].'</a></td>'.NB_EOL;
 
     foreach ($row as $k => $v) {
       if (isset($this->extras[$k])) $k .= " extra";
       $html .= '<td class="'.$k.'">'.$v.'</td>'.NB_EOL;
     }
 
-    if ($this->p('buttons')!=='0') $html .=
-      '<td class="action"><a class="delete button" href="'
-        .$this->url_keys($row,'action=delete')
-      .'">'.DB_HTML_DELETE.'</a></td>'.NB_EOL;
+    if ($this->p('buttons')!=='0') $html .= '<td class="action">'.$buttons[1].'</a></td>'.NB_EOL;
 
     $html .= '</tr>'.NB_EOL;
 
@@ -931,8 +927,7 @@ Class Table extends nb {
 
     if ($this->p('buttons')!=='0') {
       $html .= '<li class="buttons">'.NB_EOL;
-      $html .= '<a class="edit button" href="'.$this->url_keys($row,'action=edit').'">'.DB_HTML_EDIT.'</a>'.NB_EOL;
-      $html .= '<a class="delete button" href="'.$this->url_keys($row,'action=delete').'">'.DB_HTML_DELETE.'</a>'.NB_EOL;
+      $html .= join('',$this->html_row_buttons($row));
       $html .= '</li>'.NB_EOL;
     }
 
@@ -1203,6 +1198,13 @@ Class Table extends nb {
     return false;
   }
 
+  public function html_row_buttons(&$row) {
+    return array(
+      '<a class="edit button" href="'.$this->url_keys($row,'action=edit').'">'.DB_HTML_EDIT.'</a>'.NB_EOL,
+      '<a class="delete button" href="'.$this->url_keys($row,'action=delete').'">'.DB_HTML_DELETE.'</a>'.NB_EOL,
+    );
+  }
+
   public function html_rows_top() {
     if (self::p('replace') === '0') return '';
     $html = '';
@@ -1220,7 +1222,7 @@ Class Table extends nb {
   }
 
   public function count() {
-    
+
     if (isset($this->count)) return $this->count;
 
     $sql_count = $this->name;