function wfCreatePageSpecial($par)
{
    global $wgOut, $wgUser, $wgRequest, $wgServer, $wgScriptPath, $wgEnableAjaxLogin, $wgContLang;
    require_once $IP . 'extensions/wikiwyg/share/MediaWiki/extensions/TagCloud/TagCloudClass.php';
    if (!isset($wgWikiwygPath)) {
        $wgWikiwygPath = "{$wgServer}/{$wgScriptPath}/extensions/wikiwyg";
    }
    if (!isset($wgWikiwygJsPath)) {
        $wgWikiwygJsPath = "{$wgWikiwygPath}/share/MediaWiki";
    }
    if (!isset($wgWikiwygCssPath)) {
        $wgWikiwygCssPath = "{$wgWikiwygPath}/share/MediaWiki/css";
    }
    if (!isset($wgWikiwygImagePath)) {
        $wgWikiwygImagePath = "{$wgWikiwygPath}/share/MediaWiki/images";
    }
    $wgOut->addScript("<style type=\"text/css\" media=\"screen,projection\">/*<![CDATA[*/ @import \"{$wgWikiwygCssPath}/MediaWikiwyg.css\"; /*]]>*/</style>\n");
    /* load main js file when not loaded yet */
    if (wfGetDependingOnSkin() == 0) {
        if (isset($wgWysiwygEnabled) && $wgWysiwygEnabled == true) {
            $useWysiwygTrue = 1;
        } else {
            $useWysiwygTrue = 0;
        }
        if (!isset($wgEnableAjaxLogin) || $wgEnableAjaxLogin == false) {
            $wgEnableAjaxLogin = 0;
        }
        $wgOut->addScript("\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\tif (typeof(Wikiwyg) == 'undefined') Wikiwyg = function() {};\n\t\t\t\tWikiwyg.mediawiki_source_path = \"{$wgWikiwygPath}\";\n\t\t\t\tvar wgEditCaption = \"" . mb_strtolower(wfMsg('qbedit')) . "\";\n\t\t\t\tvar wgSaveCaption = \"" . mb_strtolower(wfMsg('save')) . "\";\n\t\t\t\tvar wgCancelCaption = \"" . mb_strtolower(wfMsg('cancel')) . "\";\n\t\t\t\tvar wgSummaryCaption = \"" . wfMsg('edit-summary') . "\";\n\t\t\t\tvar wgPreviewCaption = \"" . wfMsg('preview') . "\";\n\t\t\t\tvar wgHelpCaption = \"" . wfMsg('help') . "\" ;\n\t\t\t\tvar wgBoldTip = \"" . wfMsg('bold_tip') . "\";\n\t\t\t\tvar wgItalicTip = \"" . wfMsg('italic_tip') . "\";\n\t\t\t\tvar wgIntlinkTip = \"" . wfMsg('link_tip') . "\";\n\t\t\t\tvar wgExtlinkTip = \"" . wfMsg('extlink_tip') . "\";\n\t\t\t\tvar wgNowikiTip = \"" . wfMsg('nowiki_tip') . "\";\n\t\t\t\tvar wgHrTip = \"" . wfMsg('hr_tip') . "\";\n\t\t\t\tvar wgTimestampTip =  \"" . wfMsg('sig_tip') . "\";\n\t\t\t\tvar wgUseWysiwyg = " . $useWysiwygTrue . " ;\n\t\t\t\tvar wgUseInPage = " . wfGetDependingOnSkin() . ";\n\t\t\t\tvar wgFullPageEditing = false ;\n\t\t\t\tvar wgWysiwygCaption = \"" . wfMsg('wysiwygcaption') . "\" ;\n\t\t\t\tvar wgInsertImageCaption = \"" . wfMsg('insertimage') . "\" ;\n\t\t\t\tvar wgDefaultMode = \"" . $wgUser->getOption('visualeditormode', 'wysiwyg') . "\" ;\n\t\t\t\tvar wgCategoryPrefix = \"" . urlencode($wgContLang->getNsText(NS_CATEGORY)) . "\" ;\n\t\t\t\tvar wgSpecialPrefix = \"" . urlencode($wgContLang->getNsText(NS_SPECIAL)) . "\" ;\n\t\t\t\tvar wgEnableAjaxLogin = "******" ;\n\t\t\t\t</script>\n\t\t\t");
        $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgWikiwygJsPath}/MediaWikiWyg.js?" . $GLOBALS['wgStyleVersion'] . "\"></script>\n");
    }
    $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgWikiwygJsPath}/extensions/CreatePage/js/createpage.js\"></script>\n");
    if (!isset($wgEnableAjaxLogin) || $wgEnableAjaxLogin == false) {
        $wgEnableAjaxLogin = 0;
    }
    $wgOut->addHTML("\n\t\t<script type=\"text/javascript\">\n\t\t\tvar wgEnableAjaxLogin = {$wgEnableAjaxLogin} ;\n\t\t</script>");
    $wgOut->setPageTitle(wfMsg('createpage_title'));
    $cSF = new CreatePageForm($par);
    $action = $wgRequest->getVal('action');
    if ('success' == $action) {
        /* do something */
    } else {
        if ($wgRequest->wasPosted() && 'submit' == $action && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
            $cSF->doSubmit();
        } else {
            if ('failure' == $action) {
                $cSF->showForm('Please specify title');
            } else {
                if ('check' == $action) {
                    $cSF->checkArticleExists($wgRequest->getVal('to_check'));
                } else {
                    $cSF->showForm('');
                }
            }
        }
    }
}
function registerWikiwygExtension()
{
    global $wgOut, $wgSkin, $jsdir, $cssdir, $wgScriptPath;
    global $wgWikiwygPath, $wgUser, $wgTitle;
    global $wgServer, $wgWikiwygJsPath, $wgWikiwygCssPath, $wgWikiwygImagePath;
    global $wgRequest, $wgWysiwygEnabled, $wgMessageCache;
    global $wgLang, $wgContLang, $wgEnableAjaxLogin;
    if (wfGetDependingOnSkin() == 0) {
        return;
    }
    wfLoadExtensionMessages('Wikiwyg');
    if (!isset($wgWikiwygPath)) {
        $wgWikiwygPath = $wgScriptPath . "/extensions/wikiwyg";
    }
    if (!isset($wgWikiwygJsPath)) {
        $wgWikiwygJsPath = "{$wgWikiwygPath}/share/MediaWiki";
    }
    if (!isset($wgWikiwygCssPath)) {
        $wgWikiwygCssPath = "{$wgWikiwygPath}/share/MediaWiki/css";
    }
    if (!isset($wgWikiwygImagePath)) {
        $wgWikiwygImagePath = "{$wgWikiwygPath}/share/MediaWiki/images";
    }
    $wgOut->addScript("<style type=\"text/css\" media=\"screen,projection\">/*<![CDATA[*/ @import \"{$wgWikiwygCssPath}/MediaWikiwyg.css\"; /*]]>*/</style>\n");
    if (isset($wgWysiwygEnabled) && $wgWysiwygEnabled == true) {
        $useWysiwygTrue = 1;
    } else {
        $useWysiwygTrue = 0;
    }
    if (!isset($wgEnableAjaxLogin) || $wgEnableAjaxLogin == false) {
        $wgEnableAjaxLogin = 0;
    }
    $wgOut->addScript("\n<script type=\"text/javascript\">\n    if (typeof(Wikiwyg) == 'undefined') Wikiwyg = function() {};\n    Wikiwyg.mediawiki_source_path = \"{$wgWikiwygPath}\";\n    var wgEditCaption = \"" . mb_strtolower(wfMsg('qbedit')) . "\";\n    var wgSaveCaption = \"" . mb_strtolower(wfMsg('save')) . "\";\n    var wgCancelCaption = \"" . mb_strtolower(wfMsg('cancel')) . "\";\n    var wgSummaryCaption = \"" . wfMsg('edit-summary') . "\";\n    var wgPreviewCaption = \"" . wfMsg('preview') . "\";\n    var wgHelpCaption = \"" . wfMsg('help') . "\" ;\n    var wgBoldTip = \"" . wfMsg('bold_tip') . "\";\n    var wgItalicTip = \"" . wfMsg('italic_tip') . "\";\n    var wgIntlinkTip = \"" . wfMsg('mwlink_tip') . "\";\n    var wgExtlinkTip = \"" . wfMsg('extlink_tip') . "\";\n    var wgNowikiTip = \"" . wfMsg('nowiki_tip') . "\";\n    var wgHrTip = \"" . wfMsg('hr_tip') . "\";\n    var wgTimestampTip =  \"" . wfMsg('sig_tip') . "\";\n    var wgUseWysiwyg = " . $useWysiwygTrue . " ;\n    var wgUseInPage = " . wfGetDependingOnSkin() . ";\n    var wgFullPageEditing = false ;\n    var wgWysiwygCaption = \"" . wfMsg('wysiwygcaption') . "\" ;\n    var wgInsertImageCaption = \"" . wfMsg('insertimage') . "\" ;\n    var wgMinoreditCaption = \"" . wfMsg('minoredit') . "\" ;\n    var wgWatchthisCaption = \"" . wfMsg('watchthis') . "\" ;\n    var wgDefaultMode = \"" . $wgUser->getOption('visualeditormode', 'wysiwyg') . "\" ;\n    var wgCategoryPrefix = \"" . urlencode($wgContLang->getNsText(NS_CATEGORY)) . "\" ;\n    var wgSpecialPrefix = \"" . urlencode($wgContLang->getNsText(NS_SPECIAL)) . "\" ;\n</script>\n");
    $wgOut->addScript("\n\t\t<script type=\"text/javascript\">\n\t\tfunction insertTags (tagOpen, tagClose, sampleText) {\n\t\t                currentWikiwyg.current_mode.markup_line_alone (['line_alone', tagOpen + sampleText + tagClose]) ;\n\t\t\t\t}\n\t\t\t\tdocument.insertTags = insertTags ;\n\t\t </script>\n    ");
    $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgWikiwygJsPath}/MediaWikiWyg.js?" . $GLOBALS['wgStyleVersion'] . "\"></script>\n");
}
function WikiwygEditTagCloud($epage)
{
    global $wgOut, $wgRequest;
    if (wfGetDependingOnSkin() == 1) {
        /* only for NS_MAIN, except on override */
        if (!wfIsCategoryCloudAllowed($epage)) {
            return true;
        }
        require_once $IP . 'extensions/wikiwyg/share/MediaWiki/extensions/TagCloud/TagCloudClass.php';
        $MyCloud = new TagCloud();
        $num = 0;
        $cloud_html = '';
        if (is_array($MyCloud->tags)) {
            foreach ($MyCloud->tags as $name => $tag) {
                /* take care of the sorting parameter */
                $core_name = str_replace('/|.*/', '', $name);
                $cloud_html .= "<span id=\"tag-{$num}\" style=\"font-size:" . $tag["size"] . "pt\">\n                                            <a href=\"#\" id=\"cloud_{$num}\" onclick=\"EditPageAddCategory ('{$name}', {$num}) ; return false ;\">{$core_name}</a>\n                                            </span>";
                $num++;
            }
        }
        $wgOut->addHTML("\n\t    \t<br/>\n                <div id=\"wikiwyg_lower_wrapper\">\n\t\t<table id=\"editpage_table\">\n\t\t<tr>\n\t\t\t<td class=\"editpage_header\">" . wfMsg('edit-summary') . ":</td>\n\t\t\t<td id=\"editpage_summary_td\"></td>\n\t\t</tr>\n\t\t<tr style=\"padding: 6px 0px 6px 0px\">\n\t\t\t<td class=\"editpage_header\">&nbsp;</td>\n\t\t\t<td>" . wfMsg('createpage_categories_help') . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=\"editpage_header\">" . wfMsg('createpage_categories') . "</td>\n\t\t\t<td>\n\t\t\t\t<span id=\"category_textarea_placeholder\"></span>\n\t\t\t\t<div id=\"category_cloud_wrapper\" style=\"display: none\" class=ditpage_inside\">\n\t\t\t\t\t<div id=\"editpage_cloud_section\" style=\"line-height: 22pt; border: 1px solid gray; padding: 15px 15px 15px 15px\">\n\t\t\t\t\t" . $cloud_html . "\n\t\t\t\t</div>\n\t\t\t</td>\n\t\t</tr>\n                </table>\n\t\t</div>\n\t\t<input type=\"hidden\" name=\"wpCategoryTagCount\", id=\"category_tag_count\" value=\"{$num}\" />\n\t    ");
    }
    return true;
}