Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
datenumbergenerator.php
1<?
3
6
7Loc::loadMessages(__FILE__);
8
14{
15 const TEMPLATE_WORD_YEAR = 'YEAR';
16 const TEMPLATE_WORD_MONTH = 'MONTH';
17 const TEMPLATE_WORD_DAY = 'DAY';
18
20 public static function getTemplateWordsForParse()
21 {
22 return [
23 static::getPatternFor(static::TEMPLATE_WORD_DAY),
24 static::getPatternFor(static::TEMPLATE_WORD_MONTH),
25 static::getPatternFor(static::TEMPLATE_WORD_YEAR),
26 ];
27 }
28
30 public static function getTemplateWordsSettings()
31 {
32 return [
33 static::getPatternFor(static::TEMPLATE_WORD_DAY) =>
34 Loc::getMessage('BITRIX_MAIN_NUMERATOR_GENERATOR_DATENUMBERGENERATOR_WORD_DAY'),
35 static::getPatternFor(static::TEMPLATE_WORD_MONTH) =>
36 Loc::getMessage('BITRIX_MAIN_NUMERATOR_GENERATOR_DATENUMBERGENERATOR_WORD_MONTH'),
37 static::getPatternFor(static::TEMPLATE_WORD_YEAR) =>
38 Loc::getMessage('BITRIX_MAIN_NUMERATOR_GENERATOR_DATENUMBERGENERATOR_WORD_YEAR'),
39 ];
40 }
41
43 public function parseTemplate($template)
44 {
45 $wordDay = date(Date::convertFormatToPhp(str_replace(["MM", "YYYY"], "",\CSite::GetDateFormat("SHORT"))), mktime(0, 0, 0, date("m"), date("d"), date("Y")));
46 $wordDay = preg_replace("/[^0-9]/", "", $wordDay);
47 $wordMonth = date(Date::convertFormatToPhp(str_replace(["DD", "YYYY"], "", \CSite::GetDateFormat("SHORT"))), mktime(0, 0, 0, date("m"), date("d"), date("Y")));
48 $wordMonth = preg_replace("/[^0-9]/", "", $wordMonth);
49 $template = str_replace(static::getPatternFor(static::TEMPLATE_WORD_DAY), $wordDay, $template);
50 $template = str_replace(static::getPatternFor(static::TEMPLATE_WORD_MONTH), $wordMonth, $template);
51 $template = str_replace(static::getPatternFor(static::TEMPLATE_WORD_YEAR), date('Y'), $template);
52
53 return $template;
54 }
55
59 public static function getAvailableForType()
60 {
61 return 'DEFAULT';
62 }
63}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29