From: Raphaël Barrois Date: Sun, 26 Jun 2011 22:22:54 +0000 (+0200) Subject: Fix handling of 'display' field for PlTableEditor. X-Git-Tag: core/1.1.5~2 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=b2eec295f4a018ae416566007ff9bda64a5f5734;p=platal.git Fix handling of 'display' field for PlTableEditor. Now split into two subfields: * display_list controls the display in list mode * display_item controls the display in 'item' mode Signed-off-by: Raphaël Barrois --- diff --git a/classes/pltableeditor.php b/classes/pltableeditor.php index 208a92d..89c0b14 100644 --- a/classes/pltableeditor.php +++ b/classes/pltableeditor.php @@ -95,7 +95,10 @@ class PLTableEditor while ($a = $r->next()) { // desc will be the title of the column $a['desc'] = $a['Field']; - $a['display'] = true; + // display_list decides whether to display the field in 'list' mode + $a['display_list'] = true; + // display_item decides whether a field is displayed in 'item edition' mode + $a['display_item'] = true; if (substr($a['Type'],0,8) == 'varchar(') { // limit editing box size @@ -181,10 +184,11 @@ class PLTableEditor } // change display of a field - public function describe($name, $desc, $display) + public function describe($name, $desc, $display_list, $display_item=true) { $this->vars[$name]['desc'] = $desc; - $this->vars[$name]['display'] = $display; + $this->vars[$name]['display_list'] = $display_list; + $this->vars[$name]['display_item'] = $display_item; } // add a join table, when deleting a row corresponding entries will be deleted in these tables @@ -361,7 +365,7 @@ class PLTableEditor } elseif ($descr['Type'] == 'ip_address') { $val = ip2long($val); } - } elseif ($descr['display']) { + } elseif ($descr['display_item']) { $cancel = true; $page->trigError("Il manque le champ ".$field); } @@ -458,7 +462,7 @@ class PLTableEditor $it = XDB::iterator("SELECT t.* {$optional_fields} FROM {$this->table} AS t {$optional_joints} WHERE " . $this->get_where_clause() . " $sort"); $this->nbfields = 0; foreach ($this->vars as $field => $descr) - if ($descr['display']) $this->nbfields++; + if ($descr['display_list']) $this->nbfields++; $page->assign('list', $it); } $page->assign('t', $this); diff --git a/templates/table-editor.tpl b/templates/table-editor.tpl index f89e021..80b6caa 100644 --- a/templates/table-editor.tpl +++ b/templates/table-editor.tpl @@ -33,7 +33,7 @@ - {foreach from=$t->vars item=myval key=myvar}{if $myval.display} + {foreach from=$t->vars item=myval key=myvar}{if $myval.display_list} {/if}{/foreach} {if !$hideactions} @@ -54,7 +54,7 @@ {/if} {iterate from=$list item=myrow} -{foreach from=$t->vars item=myval}{if $myval.display} +{foreach from=$t->vars item=myval}{if $myval.display_list} - {foreach from=$t->vars item=myval}{assign var="myfield" value=$myval.Field}{if (($myfield neq $t->idfield) or ($t->idfield_editable)) and $myval.display} + {foreach from=$t->vars item=myval}{assign var="myfield" value=$myval.Field}{if (($myfield neq $t->idfield) or ($t->idfield_editable)) and $myval.display_item}
{$myval.desc}{if $t->sortfield eq $myvar}{if $t->sortdesc}{icon name="bullet_arrow_down"}{else}{icon name="bullet_arrow_up"}{/if}{/if}
{assign var="myfield" value=$myval.Field} {if $myfield eq $t->idfield} @@ -116,7 +116,7 @@ {/if}
{$myval.desc}