Example #1
0
 /**
  * Initialize the editMe widget.
  */
 public function init()
 {
     $this->_ckeExtensionPath = dirname(dirname(__FILE__)) . '/editor/source/ckeditor';
     // Start the publishing process if it has not been executed on the current page already
     if (empty(self::$_ckeAssetUrl)) {
         $excludeFiles = Yii::app()->assetManager->excludeFiles;
         array_push(Yii::app()->assetManager->excludeFiles, 'samples');
         self::$_ckeAssetUrl = Yii::app()->assetManager->publish($this->_ckeExtensionPath);
         Yii::app()->assetManager->excludeFiles = $excludeFiles;
         $ckeAssetPath = str_replace(Yii::app()->assetManager->baseUrl, Yii::app()->assetManager->basePath, self::$_ckeAssetUrl);
         if (@is_file($ckeAssetPath . '/editMe/.' . md5(self::$_ckeAssetUrl) . '.min.js') === false) {
             $scriptContents[] = 'var CKEDITOR_BASEPATH=' . CJavaScript::encode(self::$_ckeAssetUrl . '/') . ';';
             $scriptContents[] = @file_get_contents($ckeAssetPath . '/ckeditor.js');
             $scriptContents[] = @file_get_contents($ckeAssetPath . '/adapters/jquery.js');
             @file_put_contents($ckeAssetPath . '/editMe.' . md5(self::$_ckeAssetUrl) . '.min.js', implode("\n", $scriptContents), LOCK_EX);
         }
     }
 }