Пример #1
0
 protected function afterSave()
 {
     parent::afterSave();
     require_once 'Image.php';
     // 保存图片
     if ($this->bannerFile instanceof CUploadedFile && $this->hasErrors('bannerFile') == false) {
         // 保存原文件
         $file = $this->bannerFile;
         $fileName = md5($file->tempName . uniqid()) . '.' . $file->extensionName;
         //list($width, $height, $type, $attr) = getimagesize($file->tempName);
         $filePath = Helper::mediaPath(self::UPLOAD_LARGE_IMAGE_PATH . $fileName, FRONTEND);
         $file->saveAs($filePath);
         if (strtolower($file->extensionName) != 'swf') {
             $image = new Image($filePath);
             $image->save(Helper::mediaPath(self::UPLOAD_LARGE_IMAGE_PATH . $fileName, FRONTEND));
         }
         // 更新数据
         $this->updateByPk($this->primaryKey, array('banner_path' => $fileName));
     } else {
         if ($this->deleteBannerFile) {
             // 删除图片
             @unlink(Helper::mediaPath(self::UPLOAD_LARGE_IMAGE_PATH . $this->banner_path, FRONTEND));
             // 更新数据
             $this->updateByPk($this->primaryKey, array('banner_path' => ''));
         }
     }
 }
Пример #2
0
 protected function afterSave()
 {
     parent::afterSave();
     require_once 'Image.php';
     // 保存图片
     if ($this->serverFile instanceof CUploadedFile && $this->hasErrors('serverFile') == false) {
         // 保存原文件
         $file = $this->serverFile;
         $fileName = md5($file->tempName . uniqid()) . '.' . $file->extensionName;
         $filePath = Helper::mediaPath(self::UPLOAD_ORIGINAL_FILE_PATH . $fileName, FRONTEND);
         $file->saveAs($filePath);
         // 如果是图片需要进行裁切
         if (strtolower($file->extensionName) != 'swf') {
             $image = new Image($filePath);
             $image->resize(350, 230)->save(Helper::mediaPath(self::UPLOAD_THUMBNAIL_IMAGE_PATH . $fileName, FRONTEND));
         }
         // 更新数据
         $this->updateByPk($this->primaryKey, array('image_path' => $fileName));
     } else {
         if ($this->deleteServerFile) {
             // 删除图片
             @unlink(Helper::mediaPath(self::UPLOAD_ORIGINAL_FILE_PATH . $this->image_path, FRONTEND));
             // 更新数据
             $this->updateByPk($this->primaryKey, array('image_path' => ''));
         }
     }
 }
Пример #3
0
 protected function afterSave()
 {
     parent::afterSave();
     require_once 'Image.php';
     // 保存背景图片
     if ($this->bgImageFile instanceof CUploadedFile && $this->hasErrors('bgImageFile') == false) {
         // 保存原文件
         $file = $this->bgImageFile;
         $fileName = md5($file->tempName . uniqid()) . '.' . $file->extensionName;
         $filePath = Helper::mediaPath(self::UPLOAD_BG_IMAGE_PATH . $fileName, FRONTEND);
         $file->saveAs($filePath);
         // 更新数据
         $this->updateByPk($this->primaryKey, array('bg_image_path' => $fileName));
     } else {
         if ($this->deleteBgImageFile) {
             // 删除图片
             @unlink(Helper::mediaPath(self::UPLOAD_BG_IMAGE_PATH . $this->bg_image_path, FRONTEND));
             // 更新数据
             $this->updateByPk($this->primaryKey, array('bg_image_path' => ''));
         }
     }
     // 内链关键词
     foreach (I18nHelper::getFrontendLanguages(false) as $lang => $attr) {
         if ($lang == I18nHelper::getFrontendSourceLanguage()) {
             InternalLinkKeyword::model()->insertOrUpdate('page', $this->page_id, $lang, $this->internal_link_keywords);
         } else {
             InternalLinkKeyword::model()->insertOrUpdate('page', $this->page_id, $lang, $this->i18nFormData['internal_link_keywords_' . $lang]);
         }
     }
 }
Пример #4
0
 public function afterSave()
 {
     if ($this->_path != $this->path) {
         $children = $this->children;
         foreach ($children as $page) {
             $page->path = $page->generatePath(true);
             $page->save(false);
         }
     }
     $langs = array_keys(self::getLangs());
     foreach ($langs as $lang) {
         $param = $lang . '_url';
         if ($this->_url[$lang] != $this->{$param}) {
             $this->{$param} = $this->generateUrl(true, $lang . '_alias');
             $children = $this->children;
             foreach ($children as $page) {
                 $page->save(false);
             }
         }
     }
     return parent::afterSave();
 }