49 lines
895 B
PHP
49 lines
895 B
PHP
<?php
|
|
|
|
class ImagesController extends Controller
|
|
{
|
|
|
|
static function actionGet()
|
|
{
|
|
$pointId = (int) App::getParam('id');
|
|
$width = (int) App::getParam('width');
|
|
$height = (int) App::getParam('height');
|
|
|
|
if ($width <= 0 || $width > 200) {
|
|
$width = 200;
|
|
}
|
|
|
|
if ($height <= 0 || $height > 200) {
|
|
$height = 200;
|
|
}
|
|
|
|
if (!$pointId) {
|
|
App::error404();
|
|
}
|
|
|
|
$point = Point::model()->getByPK($pointId);
|
|
|
|
if (!$point) {
|
|
App::error404();
|
|
}
|
|
|
|
$photos = $point->photos;
|
|
$img = array_shift($photos);
|
|
|
|
|
|
if ($img) {
|
|
$photo = $photo = App::getBasedir() . '../public/' . 'photos/' . $img->name;
|
|
} else {
|
|
$photo = $photo = App::getBasedir() . '../public/' . 'img/noPhoto.png';
|
|
}
|
|
|
|
if (!file_exists($photo)) {
|
|
$photo = $photo = App::getBasedir() . '../public/' . 'img/noPhoto.png';
|
|
}
|
|
|
|
Image::createCustomSize($photo, $width, $height);
|
|
// print $photo;
|
|
}
|
|
|
|
}
|