Example #1
0
 /**
  * Generate CKEditor language value.
  * @throws CException if CKEditor lang folder cannot be read.
  * @return string CKEditor language value.
  */
 private function _generateCkLang()
 {
     if ($this->autoLanguage === false) {
         $CKEditorExtPath = $this->_CKEditorExtPath;
         if (empty(self::$_languages)) {
             $languages = glob($CKEditorExtPath . '/lang/*');
             if (empty($languages)) {
                 throw new CException('ext.editMe: Cannot access ' . $CKEditorExtPath . '/lang');
             }
             foreach ($languages as $index => $language) {
                 $language = str_replace($CKEditorExtPath . '/lang/', '', $language);
                 if (strpos($language, '_') === 0) {
                     unset($languages[$index]);
                 } else {
                     $languages[$index] = substr($language, 0, -3);
                 }
             }
             self::$_languages = $languages;
         } else {
             $languages = self::$_languages;
         }
         $appLanguage = str_replace('_', '-', strtolower(Yii::app()->language));
         if (in_array($appLanguage, $languages)) {
             return CJavaScript::encode($appLanguage);
         } else {
             if (in_array(substr($appLanguage, 0, 2), $languages)) {
                 return CJavaScript::encode(substr($appLanguage, 0, 2));
             } else {
                 return CJavaScript::encode('en');
             }
         }
     } else {
         return CJavaScript::encode('');
     }
 }
 /**
  * Initialize the editMe widget.
  */
 public function init()
 {
     $this->_ckeExtensionPath = dirname(dirname(__FILE__)) . '/vendor/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, 'CHANGES.md', 'README.md', '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);
         }
     }
 }
Example #3
0
 /**
  * Initialize the editMe widget.
  */
 public function init()
 {
     $this->_ckeExtensionPath = dirname(dirname(__FILE__)) . '/vendors/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, '_source.7z', 'INSTALL.html', 'CHANGES.html', 'ckeditor_basic_source.js', 'ckeditor_basic.js', 'ckeditor_php4.php', 'ckeditor_php5.php', 'ckeditor_source.js', 'ckeditor.asp', 'ckeditor.pack', 'ckeditor.php', '_samples', '_source');
         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 . '/' . md5(self::$_ckeAssetUrl) . '.js') === false) {
             @file_put_contents($ckeAssetPath . '/' . md5(self::$_ckeAssetUrl) . '.js', 'var CKEDITOR_BASEPATH="' . self::$_ckeAssetUrl . '/";', LOCK_EX);
         }
     }
 }