Ejemplo n.º 1
0
 public function actionUpdate($id)
 {
     if (Yii::app()->user->checkAccess('updatePage') == false) {
         throw new CHttpException(403);
     }
     $viewId = Yii::app()->request->getQuery('view_id');
     $page = Page::model()->multilingual()->findByPk($id);
     if (is_null($page)) {
         throw new CHttpException(404);
     }
     if (isset($_POST['Page'])) {
         $page->attributes = Yii::app()->request->getPost('Page');
         $page->internal_link_keywords = Helper::arrangeKeywords($page->internal_link_keywords);
         $page->search_keywords = Helper::arrangeKeywords($page->search_keywords);
         $page->bannerFile = CUploadedFile::getInstance($page, 'bannerFile');
         foreach (I18nHelper::getFrontendLanguageKeys() as $lang) {
             $page->i18nFormData['bannerFile_' . $lang] = CUploadedFile::getInstance($page, 'i18nFormData[bannerFile_' . $lang . ']');
         }
         $page->bgImageFile = CUploadedFile::getInstance($page, 'bgImageFile');
         if ($page->save()) {
             $this->setFlashMessage(strtr('<strong>{link}</strong> 目录修改成功', array('{link}' => CHtml::link($page->title, array('view', 'id' => $page->primaryKey)))));
             $this->redirect($this->getReturnUrl());
         }
     }
     $pageOptions = Page::model()->getOptions();
     $moduleOptions = Page::model()->getModuleOptions();
     $targetWindowOptions = Page::model()->getTargetWindowOptions();
     $this->breadcrumbs = array('页面' => array('page'), '修改');
     $this->render('create', array('page' => $page, 'viewId' => $viewId, 'pageOptions' => $pageOptions, 'moduleOptions' => $moduleOptions, 'targetWindowOptions' => $targetWindowOptions, 'returnUrl' => $this->getReturnUrl()));
 }
Ejemplo n.º 2
0
 public function i18nLanguages()
 {
     return I18nHelper::getFrontendLanguageKeys();
 }
Ejemplo n.º 3
0
 public function beforeSave()
 {
     foreach (I18nHelper::getFrontendLanguageKeys(false) as $lang) {
         $this->i18nFormData['moduleName_' . $lang] = $this->module_name;
     }
     // 保存 Banner
     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);
         $htmlOptions = array('width' => $width, 'height' => $height);
         $file->saveAs(Helper::mediaPath(self::UPLOAD_BANNER_PATH . $fileName, FRONTEND));
         if ($this->module_name == 'product') {
             $htmlOptions['class'] = 'banner';
         }
         // 生成 HTML 代码
         if (strtolower($file->extensionName) == 'swf') {
             $this->banner_section = Helper::renderFlashHtml(Helper::mediaUrl(self::UPLOAD_BANNER_PATH . $fileName, FRONTEND), $htmlOptions);
         } else {
             $this->banner_section = CHtml::image(Helper::mediaUrl(self::UPLOAD_BANNER_PATH . $fileName, FRONTEND), '', $htmlOptions);
         }
     }
     return parent::beforeSave();
 }