示例#1
0
 /**
  * Before delete event
  */
 public function beforeDelete()
 {
     // Delete all theme files first
     ThemeFile::model()->deleteAll('theme_id=:id', array(':id' => $this->id));
     // Delete theme folder with all files
     $path = Yii::getPathOfAlias('application.www.themes');
     $themeDir = $path . '/' . $this->dirname;
     if (is_dir($themeDir)) {
         recursiveDirRemove($themeDir);
     }
     return parent::beforeDelete();
 }
 /**
  * set file content
  */
 public function actionAjaxSetThemeFileContent()
 {
     // Init
     $fileId = getPostParam('fileId');
     $content = getPostParam('content');
     // Access check
     if (!checkAccess('op_theme_file_edit')) {
         echoJson(array('error' => at('Sorry, You are not allowed to edit theme files.')));
     }
     // Check to make sure the theme file exists
     $themeFile = ThemeFile::model()->with(array('theme'))->findByPk($fileId);
     if (!$themeFile) {
         echoJson(array('error' => at('Sorry, We could not located that file.')));
     }
     // Update theme content
     $themeFile->content = $content;
     $themeFile->update();
     // Log
     alog(at("Updated Theme '{name}', File {file}", array('{name}' => $themeFile->theme->name, '{file}' => $themeFile->file_location)));
     // Sync theme to save changes
     $themeFile->theme->syncTheme();
     echoJson(array('html' => at('Theme File Saved!')));
 }