public function getFamiliyaInicialy() { $result = ''; if ($this->familiya) { $result = $this->familiya; } if ($this->imya) { if ($result) { $result .= StringHelper::nbsp(); } $result .= mb_substr($this->imya, 0, 1) . '.'; } if ($result && $this->otchestvo) { $result .= StringHelper::nbsp() . mb_substr($this->otchestvo, 0, 1) . '.'; } return $result; }
use app\entities\Tema; use app\helpers\ArrayHelper; use app\helpers\StringHelper; use app\helpers\Val; use yii\web\View; /** * @var $prefixNo integer * @var $temaRecord Tema * @var $this View */ $prefixNo = $prefixNo . '.' . Val::of($temaRecord, 'nomer'); $chasy = Val::of($temaRecord, 'chasy'); $nedelya = Val::of($temaRecord, 'nedelya'); $time = ''; $nbsp = StringHelper::nbsp(); if ($chasy) { $time .= "{$chasy}{$nbsp}ч."; } if ($nedelya) { if ($time) { $time .= ",{$nbsp}"; } $time .= "{$nedelya}{$nbsp}неделя"; } $caption = $prefixNo . ' ' . Val::asText($temaRecord, 'nazvanie'); if ($time) { $caption .= " ({$time})"; } ?> <h4><?php
/** * @param FizLico|array $value * @param int $format * @throws InvalidParamException * @return string */ public function asFizLico($value, $format = null) { if ($value === null) { return $this->nullDisplay; } if ($format === null) { $format = $this->fizLicoFormat; } if (!in_array($format, [self::FIZ_LICO_FORMAT_SHORT, self::FIZ_LICO_FORMAT_FULL])) { throw new InvalidParamException('Unknow $format value'); } $result = []; $familiya = ArrayHelper::getValue($value, 'familiya'); if ($familiya !== null && $familiya !== '') { $result[] = trim($familiya); } $imya = ArrayHelper::getValue($value, 'imya'); $otchestvo = ArrayHelper::getValue($value, 'otchestvo'); foreach ([$imya, $otchestvo] as $item) { $item = trim($item); if (!$item) { break; } switch ($format) { case self::FIZ_LICO_FORMAT_SHORT: $result[] = mb_substr($item, 0, 1) . '.'; break; case self::FIZ_LICO_FORMAT_FULL: default: $result[] = $item; } } switch ($format) { case self::FIZ_LICO_FORMAT_SHORT: return implode(StringHelper::nbsp(), $result); case self::FIZ_LICO_FORMAT_FULL: default: return implode(' ', $result); } }