* replace variables in single field or dimension * used in StorageService when data is loaded or entered manually * * @param $field * @return array */
($field)
| 94 | * @return array |
| 95 | */ |
| 96 | public function replaceTextVariablesSingle($field) { |
| 97 | if ($field !== null) { |
| 98 | preg_match_all("/%.*?%/", $field, $matches); |
| 99 | if (count($matches[0]) > 0) { |
| 100 | foreach ($matches[0] as $match) { |
| 101 | $replace = null; |
| 102 | if ($match === '%currentDate%') { |
| 103 | $replace = date("Y-m-d"); |
| 104 | } elseif ($match === '%currentTime%') { |
| 105 | $replace = $this->IDateTimeFormatter->formatTime(time(), 'short'); |
| 106 | } elseif ($match === '%now%') { |
| 107 | $replace = time(); |
| 108 | } |
| 109 | if ($replace !== null) { |
| 110 | $field = preg_replace('/' . $match . '/', $replace, $field); |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | return $field; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * replace variables in single field |