FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Date.php
Go to the documentation of this file.
1 <?php
2 
4 
5 class Date extends \Rsi\Fred\Controller\View\Html\Widget{
6 
7  protected function attribs(){
8  $length = strlen(preg_replace('/\\w/','??',str_replace('Y','????',$format = $this->_widget->local->dateFormat)));
9  $attribs = ['maxlength' => $length,'size' => $length];
10  if($words = $this->_view->component('trans')->str($this->_widget->placeholder)) try{
11  $words = \Rsi\Record::explode($words,';','=');
12  $placeholder = '';
13  foreach(str_split($format) as $char) $placeholder .= $words[$char] ?? $char;
14  $attribs['placeholder'] = $placeholder;
15  }
16  catch(\Exception $e){
17  $this->_view->component('log')->warning("Invalid placeholder '$words': " . $e->getMessage());
18  }
19  return array_merge(parent::attribs(),$attribs);
20  }
21 
22 }