trait DatexArgHandlerTrait in Datex 8
Hierarchy
- trait \Drupal\datex\Plugin\views\argument\DatexArgHandlerTrait
2 files declare their use of DatexArgHandlerTrait
- DatexViewsDate.php in src/
Plugin/ views/ filter/ DatexViewsDate.php - DatexViewsDateTime.php in src/
Plugin/ views/ filter/ DatexViewsDateTime.php
File
- src/
Plugin/ views/ argument/ DatexArgHandlerTrait.php, line 5
Namespace
Drupal\datex\Plugin\views\argumentView source
trait DatexArgHandlerTrait {
/**
* {@inheritdoc}
*/
public function query($group_by = FALSE) {
$cal = datex_factory();
if ($cal && $cal
->getCalendarName() !== 'gregorian') {
if ($cal
->parse(self::translate($this->argument), $this->argFormat)) {
$this->argument = $cal
->xFormat($this->argFormat);
}
}
parent::query($group_by);
}
public static function translate($v) {
$pass_0 = [
'ﻯ' => 'ی',
'ﻱ' => 'ی',
'٠' => '0',
'۱' => '1',
'۲' => '2',
'۳' => '3',
'۴' => '4',
'۵' => '5',
'۶' => '6',
'۷' => '7',
'۸' => '8',
'۹' => '9',
'١' => '1',
'٢' => '2',
'٣' => '3',
'٤' => '4',
'٥' => '5',
'٦' => '6',
'٧' => '7',
'٨' => '8',
'٩' => '9',
];
$pass_1 = [
'امروز' => 'today',
'دیروز' => '-1 day',
'فردا' => '+1 day',
'پیش' => 'ago',
'قبل' => 'last',
'بعد' => 'later',
'بعدی' => 'next',
'ثانیه' => 'second',
'دقیقه' => 'minute',
'ساعت' => 'hour',
'روز' => 'day',
'ماه' => 'month',
'سال' => 'year',
'هفته' => 'week',
];
$v = trim($v);
$v = strtr($v, $pass_0);
$v = strtr($v, $pass_1);
return $v;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DatexArgHandlerTrait:: |
public | function | ||
DatexArgHandlerTrait:: |
public static | function |