mirror of
https://github.com/cosmocode/dokuwiki-plugin-struct.git
synced 2025-08-06 10:24:17 +00:00
Merge remote-tracking branch 'saggi-dw/date-filter'
This commit is contained in:
@ -30,7 +30,7 @@ class SearchConfigTest extends StructTest
|
|||||||
|
|
||||||
$this->assertEquals('user baz', $searchConfig->applyFilterVars('$USER$ $PAGE$'));
|
$this->assertEquals('user baz', $searchConfig->applyFilterVars('$USER$ $PAGE$'));
|
||||||
$this->assertEquals('$user', $searchConfig->applyFilterVars('$user'));
|
$this->assertEquals('$user', $searchConfig->applyFilterVars('$user'));
|
||||||
|
$this->assertEquals(date('Y-m-d'), $searchConfig->applyFilterVars('$DATE(now)$'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_filtervars_struct()
|
public function test_filtervars_struct()
|
||||||
|
@ -80,6 +80,7 @@ $lang['Exception nolookupmix'] = 'Sie können nicht mehr als eine Suche aggregie
|
|||||||
$lang['Exception No data saved'] = 'Keine Daten gespeichert';
|
$lang['Exception No data saved'] = 'Keine Daten gespeichert';
|
||||||
$lang['Exception no sqlite'] = 'Das \'Struct Plugin\' benötigt das \'Sqlite Plugin\'. Bitte installieren und aktivieren.';
|
$lang['Exception no sqlite'] = 'Das \'Struct Plugin\' benötigt das \'Sqlite Plugin\'. Bitte installieren und aktivieren.';
|
||||||
$lang['Exception column not in table'] = 'Die Spalte %s existiert im Schema %s nicht.';
|
$lang['Exception column not in table'] = 'Die Spalte %s existiert im Schema %s nicht.';
|
||||||
|
$lang['Exception datefilter'] = 'Der Filter: \'<code>$Date(%s)$</code>\' enthält einen ungültigen Wert';
|
||||||
$lang['Warning: no filters for cloud'] = 'Filter werden in \'Struct Clouds\' nicht unterstützt';
|
$lang['Warning: no filters for cloud'] = 'Filter werden in \'Struct Clouds\' nicht unterstützt';
|
||||||
$lang['sort'] = 'Nach dieser Spalte sortieren';
|
$lang['sort'] = 'Nach dieser Spalte sortieren';
|
||||||
$lang['next'] = 'Nächste Seite';
|
$lang['next'] = 'Nächste Seite';
|
||||||
|
@ -89,6 +89,7 @@ $lang['Exception nolookupmix'] = 'You can not aggregate more than one Lookup or
|
|||||||
$lang['Exception No data saved'] = 'No data saved';
|
$lang['Exception No data saved'] = 'No data saved';
|
||||||
$lang['Exception no sqlite'] = 'The struct plugin requires the sqlite plugin. Please install and enable it.';
|
$lang['Exception no sqlite'] = 'The struct plugin requires the sqlite plugin. Please install and enable it.';
|
||||||
$lang['Exception column not in table'] = 'There is no column %s in schema %s.';
|
$lang['Exception column not in table'] = 'There is no column %s in schema %s.';
|
||||||
|
$lang['Exception datefilter'] = 'The filter: \'<code>$Date(%s)$</code>\' contains an unsupported value.';
|
||||||
|
|
||||||
$lang['Warning: no filters for cloud'] = 'Filters are not supported for struct clouds.';
|
$lang['Warning: no filters for cloud'] = 'Filters are not supported for struct clouds.';
|
||||||
|
|
||||||
|
@ -137,10 +137,22 @@ class SearchConfig extends Search
|
|||||||
);
|
);
|
||||||
|
|
||||||
// apply struct column placeholder (we support only one!)
|
// apply struct column placeholder (we support only one!)
|
||||||
|
// or apply date formula, given as strtotime
|
||||||
if (preg_match('/^(.*?)(?:\$STRUCT\.(.*?)\$)(.*?)$/', $filter, $match)) {
|
if (preg_match('/^(.*?)(?:\$STRUCT\.(.*?)\$)(.*?)$/', $filter, $match)) {
|
||||||
$filter = $this->applyFilterVarsStruct($match);
|
$filter = $this->applyFilterVarsStruct($match);
|
||||||
} elseif (preg_match('/^(.*?)(?:\$USER\.(.*?)\$)(.*?)$/', $filter, $match)) {
|
} elseif (preg_match('/^(.*?)(?:\$USER\.(.*?)\$)(.*?)$/', $filter, $match)) {
|
||||||
$filter = $this->applyFilterVarsUser($match);
|
$filter = $this->applyFilterVarsUser($match);
|
||||||
|
} elseif (preg_match('/^(.*?)(?:\$DATE\((.*?)\)\$?)(.*?)$/', $filter, $match)) {
|
||||||
|
$toparse = $match[2];
|
||||||
|
if ($toparse == '') {
|
||||||
|
$toparse = 'now';
|
||||||
|
}
|
||||||
|
$timestamp = strtotime($toparse);
|
||||||
|
if ($timestamp === false) {
|
||||||
|
throw new StructException('datefilter', hsc($toparse));
|
||||||
|
} else {
|
||||||
|
$filter = str_replace($filter, date('Y-m-d', $timestamp), $filter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $filter;
|
return $filter;
|
||||||
|
Reference in New Issue
Block a user