diff --git a/common/models/Events.php b/common/models/Events.php index d53f5da..59f6def 100755 --- a/common/models/Events.php +++ b/common/models/Events.php @@ -15,7 +15,7 @@ use common\models; * @property string $description */ -class Events extends MyActiveRecord +class Events extends GalleryRecord { public $file; diff --git a/common/models/Gallery.php b/common/models/Gallery.php index 2a4f1a6..47a88ba 100644 --- a/common/models/Gallery.php +++ b/common/models/Gallery.php @@ -16,7 +16,7 @@ use common\models; * @property string $gallery */ -class Gallery extends MyActiveRecord +class Gallery extends GalleryRecord { /** * @inheritdoc diff --git a/common/models/GalleryRecord.php b/common/models/GalleryRecord.php new file mode 100644 index 0000000..1451f4f --- /dev/null +++ b/common/models/GalleryRecord.php @@ -0,0 +1,56 @@ + $length ) + { + $str = wordwrap( $str, $length, '||BR||', false ); + $str = mb_substr( $str, 0, mb_strpos( $str, '||BR||', 0, 'UTF-8' ), 'UTF-8' ); + $str .= '...'; + } + + return $str; + } + + function minImg( $dir, $width, $height=null ){ + if($width == 'original'){ + $preg = '/\/(.[^\/]*)$/'; + preg_match('/\.(.[^.]*)$/', $dir, $type); + $row = preg_replace($preg, '/original.'.$type[1], $dir); + } else { + $preg = '/\/(.[^\/]*)$/'; + preg_match('/\.(.[^.]*)$/', $dir, $type); + $row = preg_replace( $preg, '/'.$width.'X'.$height.'.'.$type[1], $dir); + } + + return $row; +// if(file_exists($_SERVER['DOCUMENT_ROOT'].$row)){ +// return $row; +// } else { +// return "/storage/no-image.png"; +// } + + } + + public function getGallery() + { + if($this->gallery){ + $array = explode(",", $this->gallery); + array_pop($array); + return $array; + } else { + return array(); + } + } +} +?> \ No newline at end of file diff --git a/common/models/MyActiveRecord.php b/common/models/MyActiveRecord.php deleted file mode 100644 index 9814cc4..0000000 --- a/common/models/MyActiveRecord.php +++ /dev/null @@ -1,56 +0,0 @@ - $length ) - { - $str = wordwrap( $str, $length, '||BR||', false ); - $str = mb_substr( $str, 0, mb_strpos( $str, '||BR||', 0, 'UTF-8' ), 'UTF-8' ); - $str .= '...'; - } - - return $str; - } - - function minImg( $dir, $width, $height=null ){ - if($width == 'original'){ - $preg = '/\/(.[^\/]*)$/'; - preg_match('/\.(.[^.]*)$/', $dir, $type); - $row = preg_replace($preg, '/original.'.$type[1], $dir); - } else { - $preg = '/\/(.[^\/]*)$/'; - preg_match('/\.(.[^.]*)$/', $dir, $type); - $row = preg_replace( $preg, '/'.$width.'X'.$height.'.'.$type[1], $dir); - } - - return $row; -// if(file_exists($_SERVER['DOCUMENT_ROOT'].$row)){ -// return $row; -// } else { -// return "/storage/no-image.png"; -// } - - } - - public function getGallery() - { - if($this->gallery){ - $array = explode(",", $this->gallery); - array_pop($array); - return $array; - } else { - return array(); - } - } -} -?> \ No newline at end of file diff --git a/common/models/Schools.php b/common/models/Schools.php index af99271..d2562e5 100644 --- a/common/models/Schools.php +++ b/common/models/Schools.php @@ -18,7 +18,7 @@ use common\models; * @property string $name * @property string $spots_id */ -class Schools extends MyActiveRecord +class Schools extends GalleryRecord { public $file; diff --git a/common/models/Spots.php b/common/models/Spots.php index 98271ac..c4abf81 100644 --- a/common/models/Spots.php +++ b/common/models/Spots.php @@ -22,7 +22,7 @@ use common\models; * @property string $forecast_id * @property string $forecast_code */ -class Spots extends MyActiveRecord +class Spots extends GalleryRecord { public $file_three; /** -- libgit2 0.21.4