/** * Создает уменьшенную копию изображения * * @param string $sourceFilePath * @param string $thumbImagePath * @return bool */ public function createThumb($sourceFilePath, $thumbImagePath) { // Если значение 'max_pixel_side' не равно 'width' или 'height', прерываем процесс if (!in_array($this->max_pixel_side, ['width', 'height'])) { $this->_result[] = 'Невозможно создать уменьшенную копию изображения. Не определена сторона для уменьшения'; return false; } $img = Image::getImagine()->open($sourceFilePath); $size = $img->getSize(); // Если размер выбранной стороны изображения больше заданного, создаем уменьшенную копию $side = 'get' . GlobalHelper::ucfirst($this->max_pixel_side); if ($size->{$side}() > $this->max_pixel) { $ratio = $size->getWidth() / $size->getHeight(); if ($this->max_pixel_side == 'width') { $width = $this->max_pixel; $height = round($width / $ratio); } elseif ($this->max_pixel_side == 'height') { $height = $this->max_pixel; $width = round($height * $ratio); } if ($img->resize(new Box($width, $height))->save($thumbImagePath)) { // Если отмечена галочка "Добавлять водяной знак" if ($this->watermark) { $watermarkImagePath = Yii::getAlias($this->_baseUploadPathAlias) . $this->_watermarkFileName; if ($this->putWatermark($thumbImagePath, $watermarkImagePath)) { $this->_result[] = 'Водяной знак наложен'; } } return true; } } }
<?php /* @var $this yii\web\View */ use yii\helpers\Html; use common\components\helpers\GlobalHelper; $controls = ''; if (!$noControls) { $controls = Html::tag('div', '<i class="fa fa-angle-double-left fa-lg"></i>', ['class' => 'calendar_control', 'id' => 'calendar-prev']); $controls .= Html::tag('div', '<i class="fa fa-angle-double-right fa-lg"></i>', ['class' => 'calendar_control', 'id' => 'calendar-next']); } list($year, $month) = explode('-', $date); $daysInMonth = date('t', strtotime($date)); $dateOut = GlobalHelper::ucfirst(GlobalHelper::rusMonth($month)) . ' ' . $year; if (!empty($posts)) { $dateOut = Html::a($dateOut, '/' . $year . '/' . $month . '/'); } $calendar = '<div class="calendar_nowmonth">' . $dateOut . '</div> <table class="calendar_table"> <tr> <th class="weekday">Пн</th> <th class="weekday">Вт</th> <th class="weekday">Ср</th> <th class="weekday">Чт</th> <th class="weekday">Пт</th> <th class="weekday">Сб</th> <th class="weekday">Вс</th> </tr><tr>'; for ($i = 1; $i <= $daysInMonth; $i++) { $day = sprintf('%02d', $i); $dayOfWeek = date('w', strtotime("{$year}-{$month}-{$day}")); if (!$dayOfWeek) {