Skip to content

Commit 0899386

Browse files
committed
[plugin:tracker] fix "IS NULL" cell style with default value
tracker プラグインの config 設定で、[条件]が "IS NULL" の場合に設定した、 [セルの書式] が、[ページに記入する書式] に値が入っていると効かない問題を修正。
1 parent 5b3fc6c commit 0899386

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

xoops_trust_path/modules/xpwiki/plugin/tracker.inc.php

+28-1
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ class XpWikiTracker_field
398398
var $data;
399399
var $sort_type = SORT_REGULAR;
400400
var $id = 0;
401+
var $field_remover = '';
401402

402403
function XpWikiTracker_field(& $xpwiki, $field, $base, $refer, & $config)
403404
{
@@ -445,6 +446,15 @@ function get_value($value)
445446
{
446447
return $value; // Default: $value itself
447448
}
449+
450+
function set_field_remover()
451+
{
452+
$fields = array();
453+
foreach ($this->config->get('fields') as $field) {
454+
$fields[] = preg_quote($field[0], '/');
455+
}
456+
$this->config->put('field_remover', array('/\[(?:'.join('|', $fields).')\]/'));
457+
}
448458
}
449459

450460
class XpWikiTracker_field_text extends XpWikiTracker_field
@@ -569,9 +579,26 @@ function format_value($str)
569579

570580
function get_style($str)
571581
{
572-
$key = $this->get_key($str);
582+
$key = $this->get_key(! $this->is_null_style($str));
573583
return isset($this->styles[$key]) ? $this->styles[$key] : '%s';
574584
}
585+
586+
function is_null_style($str)
587+
{
588+
if (! $this->config->get('field_remover')) {
589+
$this->set_field_remover();
590+
}
591+
$arr = $this->config->get('field_remover');
592+
$this->field_remover = $arr[0];
593+
if (isset($this->formats['IS NULL'])) {
594+
$null = $this->formats['IS NULL'];
595+
$this->func->cleanup_template_source($null);
596+
$null = preg_replace($this->field_remover, '', $null);
597+
} else {
598+
$null = '';
599+
}
600+
return ($str === $null);
601+
}
575602
}
576603

577604
class XpWikiTracker_field_file extends XpWikiTracker_field_format

0 commit comments

Comments
 (0)