Exemplo n.º 1
0
    public static function editor_js()
    {
        global $tinymce_version, $concatenate_scripts, $compress_scripts;
        /**
         * Filter "tiny_mce_version" is deprecated
         *
         * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE.
         * These plugins can be refreshed by appending query string to the URL passed to "mce_external_plugins" filter.
         * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code).
         */
        $version = 'ver=' . $tinymce_version;
        $tmce_on = !empty(self::$mce_settings);
        if (!isset($concatenate_scripts)) {
            script_concat_settings();
        }
        $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
        if ($tmce_on && 'en' != self::$mce_locale) {
            include_once ABSPATH . nxtINC . '/js/tinymce/langs/nxt-langs.php';
        }
        $mceInit = $qtInit = '';
        if ($tmce_on) {
            foreach (self::$mce_settings as $editor_id => $init) {
                $options = self::_parse_init($init);
                $mceInit .= "'{$editor_id}':{$options},";
            }
            $mceInit = '{' . trim($mceInit, ',') . '}';
        } else {
            $mceInit = '{}';
        }
        if (!empty(self::$qt_settings)) {
            foreach (self::$qt_settings as $editor_id => $init) {
                $options = self::_parse_init($init);
                $qtInit .= "'{$editor_id}':{$options},";
            }
            $qtInit = '{' . trim($qtInit, ',') . '}';
        } else {
            $qtInit = '{}';
        }
        $ref = array('plugins' => implode(',', self::$plugins), 'theme' => 'advanced', 'language' => self::$mce_locale);
        do_action('before_nxt_tiny_mce', self::$mce_settings);
        ?>

	<script type="text/javascript">
		tinyMCEPreInit = {
			base : "<?php 
        echo self::$baseurl;
        ?>
",
			suffix : "",
			query : "<?php 
        echo $version;
        ?>
",
			mceInit : <?php 
        echo $mceInit;
        ?>
,
			qtInit : <?php 
        echo $qtInit;
        ?>
,
			ref : <?php 
        echo self::_parse_init($ref);
        ?>
,
			load_ext : function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
		};
	</script>
<?php 
        $baseurl = self::$baseurl;
        if ($tmce_on) {
            if ($compressed) {
                echo "<script type='text/javascript' src='{$baseurl}/nxt-tinymce.php?c=1&amp;{$version}'></script>\n";
            } else {
                echo "<script type='text/javascript' src='{$baseurl}/tiny_mce.js?{$version}'></script>\n";
            }
            if ('en' != self::$mce_locale && isset($lang)) {
                echo "<script type='text/javascript'>\n{$lang}\n</script>\n";
            } else {
                echo "<script type='text/javascript' src='{$baseurl}/langs/nxt-langs-en.js?{$version}'></script>\n";
            }
        }
        ?>

	<script type="text/javascript">
		(function(){
			var init, ed, qt, first_init, mce = <?php 
        echo nxt_default_editor() == 'tinymce' ? 'true' : 'false';
        ?>
;

			if ( typeof(tinymce) == 'object' ) {
				// mark nxt_theme/ui.css as loaded
				tinymce.DOM.files[tinymce.baseURI.getURI() + '/themes/advanced/skins/nxt_theme/ui.css'] = true;

				for ( ed in tinyMCEPreInit.mceInit ) {
					if ( first_init ) {
						init = tinyMCEPreInit.mceInit[ed] = tinymce.extend( {}, first_init, tinyMCEPreInit.mceInit[ed] );
					} else {
						init = first_init = tinyMCEPreInit.mceInit[ed];
					}

					if ( mce )
						try { tinymce.init(init); } catch(e){}
				}
			}

			if ( typeof(QTags) == 'function' ) {
				for ( qt in tinyMCEPreInit.qtInit ) {
					try { quicktags( tinyMCEPreInit.qtInit[qt] ); } catch(e){}
				}
			}
		})();

		var nxtActiveEditor;

		jQuery('.nxt-editor-wrap').mousedown(function(e){
			nxtActiveEditor = this.id.slice(3, -5);
		});

<?php 
        if (self::$ext_plugins) {
            echo self::$ext_plugins . "\n";
        }
        if (!$compressed && $tmce_on) {
            ?>
		(function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.ref.language,th=t.ref.theme,pl=t.ref.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');sl.markDone(t.base+'/themes/advanced/skins/nxt_theme/ui.css');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})();
<?php 
        }
        if (!is_admin()) {
            echo 'var ajaxurl = "' . admin_url('admin-ajax.php') . '";';
        }
        ?>
	</script>
<?php 
        if (in_array('nxtlink', self::$plugins, true) || in_array('link', self::$qt_buttons, true)) {
            self::nxt_link_dialog();
        }
        if (in_array('nxtfullscreen', self::$plugins, true) || in_array('fullscreen', self::$qt_buttons, true)) {
            self::nxt_fullscreen_html();
        }
        do_action('after_nxt_tiny_mce', self::$mce_settings);
    }
Exemplo n.º 2
0
 public static function editor($content, $editor_id, $settings = array())
 {
     $set = self::parse_settings($editor_id, $settings);
     $editor_class = ' class="' . trim($set['editor_class'] . ' nxt-editor-area theEditor') . '"';
     $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : '';
     $rows = ' rows="' . (int) $set['textarea_rows'] . '"';
     $switch_class = 'html-active';
     $toolbar = $buttons = '';
     if (!current_user_can('upload_files')) {
         $set['media_buttons'] = false;
     }
     if ($set['quicktags'] && $set['tinymce']) {
         $switch_class = 'html-active';
         if ('html' == nxt_default_editor()) {
             add_filter('the_editor_content', 'nxt_htmledit_pre');
         } else {
             add_filter('the_editor_content', 'nxt_richedit_pre');
             $switch_class = 'tmce-active';
         }
         $buttons .= '<a id="' . $editor_id . '-html" class="hide-if-no-js nxt-switch-editor switch-html" onclick="switchEditors.switchto(this);">' . __('HTML') . "</a>\n";
         $buttons .= '<a id="' . $editor_id . '-tmce" class="hide-if-no-js nxt-switch-editor switch-tmce" onclick="switchEditors.switchto(this);">' . __('Visual') . "</a>\n";
     }
     echo '<div id="nxt-' . $editor_id . '-wrap" class="nxt-editor-wrap ' . $switch_class . '">';
     nxt_print_styles('editor-buttons');
     if (!empty($set['editor_css'])) {
         echo $set['editor_css'] . "\n";
     }
     if (!empty($buttons) || $set['media_buttons']) {
         echo '<div id="nxt-' . $editor_id . '-editor-tools" class="nxt-editor-tools">';
         echo $buttons;
         if ($set['media_buttons']) {
             //self::$has_medialib = true;
             if (!function_exists('media_buttons')) {
                 include ABSPATH . 'nxt-admin/includes/media.php';
             }
             echo '<div id="nxt-' . $editor_id . '-media-buttons" class="hide-if-no-js nxt-media-buttons">';
             do_action('media_buttons', $editor_id);
             echo "</div>\n";
         }
         echo "</div>\n";
     }
     $the_editor = apply_filters('the_editor', '<div id="nxt-' . $editor_id . '-editor-container" class="nxt-editor-container"><textarea' . $editor_class . $rows . $tabindex . ' cols="40" name="' . $set['textarea_name'] . '" id="' . $editor_id . '">%s</textarea></div>');
     $content = apply_filters('the_editor_content', $content);
     printf($the_editor, $content);
     echo "\n</div>\n\n";
     ckeditor_nxtclass::getInstance()->editor_js();
 }