/** * Initialize component */ public static function initialize() { self::$initialized = true; if (isset(Yii::app()->settings) && Yii::app()->settings instanceof SSystemSettings) { self::$db_settings = Yii::app()->settings->get(self::$settings_key); } else { self::$db_settings = self::$defaults; } }
/** * @return string * */ public function getFilePath() { return Yii::getPathOfAlias(PlayerFilesConfig::get('path')) . '/' . $this->file; }
public function getImageUrl($size = false, $resizeMethod = false, $random = false) { if ($size !== false) { $thumbPath = Yii::getPathOfAlias(PlayerFilesConfig::get('thumbPath')) . '/' . $size; if (!file_exists($thumbPath)) { mkdir($thumbPath, 0777, true); } // Path to source image $fullPath = Yii::getPathOfAlias('webroot') . $this->image; $imageName = explode('/', $this->image); $imageName = array_pop($imageName); // Path to thumb $thumbPath = $thumbPath . '/' . $imageName; if (!file_exists($thumbPath)) { // Resize if needed Yii::import('ext.phpthumb.PhpThumbFactory'); $sizes = explode('x', $size); $thumb = PhpThumbFactory::create($fullPath); if ($resizeMethod === false) { $resizeMethod = PlayerFilesConfig::get('resizeThumbMethod'); } $thumb->{$resizeMethod}($sizes[0], $sizes[1])->save($thumbPath); } return PlayerFilesConfig::get('thumbUrl') . $size . '/' . $imageName; } if ($random === true) { return PlayerFilesConfig::get('url') . $this->image . '?' . rand(1, 10000); } return PlayerFilesConfig::get('url') . $this->image; }
/** * @return string Path to save product image */ public static function getSavePath() { return Yii::getPathOfAlias(PlayerFilesConfig::get('path')); }