Esempio n. 1
0
 function Head($name = 'edit[content]')
 {
     global $LANG, $WikiTheme;
     $WikiTheme->addMoreHeaders(Javascript('', array('src' => $this->BasePath . 'tiny_mce.js', 'language' => 'JavaScript')));
     return Javascript("\ntinyMCE.init({\n\tmode    : 'exact',\n\telements: '{$name}',\n        theme   : 'advanced',\n        language: \"{$LANG}\",\n        ask     : false,\n\ttheme_advanced_toolbar_location : \"top\",\n\ttheme_advanced_toolbar_align : \"left\",\n\ttheme_advanced_path_location : \"bottom\",\n\ttheme_advanced_buttons1 : \"bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,link,unlink\",\n\ttheme_advanced_buttons2 : \"\",\n\ttheme_advanced_buttons3 : \"\",\n});");
     /*
     plugins : \"table,contextmenu,paste,searchreplace,iespell,insertdatetime\",
     	extended_valid_elements : \"a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]\"
     });
     */
 }
Esempio n. 2
0
 function Head($name = 'edit[content]')
 {
     global $WikiTheme;
     foreach (array("Wikiwyg.js", "Wikiwyg/Toolbar.js", "Wikiwyg/Preview.js", "Wikiwyg/Wikitext.js", "Wikiwyg/Wysiwyg.js", "Wikiwyg/Phpwiki.js", "Wikiwyg/HTML.js", "Wikiwyg/Toolbar.js") as $js) {
         $WikiTheme->addMoreHeaders(Javascript('', array('src' => $this->BasePath . '/' . $js, 'language' => 'JavaScript')));
     }
     $doubleClickToEdit = ($GLOBALS['request']->getPref('doubleClickEdit') or ENABLE_DOUBLECLICKEDIT) ? 'true' : 'false';
     if ($GLOBALS['request']->getArg('mode') && $GLOBALS['request']->getArg('mode') == 'wysiwyg') {
         return JavaScript($this->_jsdefault . "\n            window.onload = function() {\n            var wikiwyg = new Wikiwyg.Phpwiki();\n            var config = {\n            doubleClickToEdit:  {$doubleClickToEdit},\n            javascriptLocation: data_path+'/themes/default/Wikiwyg/',\n            toolbar: {\n\t        imagesLocation: data_path+'/themes/default/Wikiwyg/images/',\n\t\tcontrolLayout: [\n\t\t       'save','preview','save_button','|',\n\t\t       'p','|',\n\t\t       'h2', 'h3', 'h4','|',\n\t\t       'bold', 'italic', '|',\n                       'sup', 'sub', '|',\n                       'toc',\n                       'wikitext','|',\n\t\t       'pre','|',\n\t\t       'ordered', 'unordered','hr','|',\n\t\t       'link','|',\n                       'table'\n\t\t       ],\n\t\tstyleSelector: [\n\t\t       'label', 'p', 'h2', 'h3', 'h4', 'pre'\n\t\t\t\t], \n\t\tcontrolLabels: {\n\t               save:     '" . _("Apply changes") . "',\n\t\t       cancel:   '" . _("Exit toolbar") . "',\n\t\t       h2:       '" . _("Title 1") . "',\n\t\t       h3:       '" . _("Title 2") . "',\n\t\t       h4:       '" . _("Title 3") . "',\n\t\t       verbatim: '" . _("Verbatim") . "',\n                       toc:   '" . _("Table of content") . "', \n                       wikitext:   '" . _("Insert Wikitext section") . "', \n                       sup:      '" . _("Sup") . "', \n                       sub:      '" . _("Sub") . "',\n                       preview:  '" . _("Preview") . "',   \n                       save_button:'" . _("Save") . "'   \n\t              }\n            },\n            wysiwyg: {\n                iframeId: 'iframe0'\n            },\n\t    wikitext: {\n\t      supportCamelCaseLinks: true\n\t    }\n            };\n            var div = document.getElementById(\"" . $this->_htmltextid . "\");\n            wikiwyg.createWikiwygArea(div, config);\n            wikiwyg_divs.push(wikiwyg);\n            wikiwyg.editMode();}");
     }
 }
Esempio n. 3
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     if (!$args['pagename']) {
         return $this->error(_("No pagename specified"));
     }
     // Get our form args.
     $comment = $request->getArg("comment");
     $request->setArg('comment', false);
     if ($request->isPost() and !empty($comment['addcomment'])) {
         $this->add($request, $comment, 'comment');
         // noreturn
     }
     if ($args['jshide'] and isBrowserIE() and browserDetect("Mac")) {
         //trigger_error(_("jshide set to 0 on Mac IE"), E_USER_NOTICE);
         $args['jshide'] = 0;
     }
     // Now we display previous comments and/or provide entry box
     // for new comments
     $html = HTML();
     if ($args['jshide']) {
         $div = HTML::div(array('id' => 'comments', 'style' => 'display:none;'));
         //$list->setAttr('style','display:none;');
         $div->pushContent(Javascript("\nfunction togglecomments(a) {\n  comments=document.getElementById('comments');\n  if (comments.style.display=='none') {\n    comments.style.display='block';\n    a.title='" . _("Click to hide the comments") . "';\n  } else {\n    comments.style.display='none';\n    a.title='" . _("Click to display all comments") . "';\n  }\n}"));
         $html->pushContent(HTML::h4(HTML::a(array('name' => 'comment-header', 'class' => 'wikiaction', 'title' => _("Click to display"), 'onclick' => "togglecomments(this)"), _("Comments"))));
     } else {
         $div = HTML::div(array('id' => 'comments'));
     }
     foreach (explode(',', $args['mode']) as $show) {
         if (!empty($seen[$show])) {
             continue;
         }
         $seen[$show] = 1;
         switch ($show) {
             case 'show':
                 $show = $this->showAll($request, $args, 'comment');
                 //if ($args['jshide']) $show->setAttr('style','display:none;');
                 $div->pushContent($show);
                 break;
             case 'add':
                 global $WikiTheme;
                 if (!$WikiTheme->DUMP_MODE) {
                     $add = $this->showForm($request, $args, 'addcomment');
                     //if ($args['jshide']) $add->setAttr('style','display:none;');
                     $div->pushContent($add);
                 }
                 break;
             default:
                 return $this->error(sprintf("Bad mode ('%s')", $show));
         }
     }
     $html->pushContent($div);
     return $html;
 }
Esempio n. 4
0
 function Head($name = 'edit[content]')
 {
     global $WikiTheme;
     $WikiTheme->addMoreHeaders(Javascript('', array('src' => $this->BasePath . 'fckeditor.js', 'language' => 'JavaScript')));
     return JavaScript("\nwindow.onload = function()\n{\nvar oFCKeditor = new FCKeditor( '{$this->_htmltextid}' ) ;" . $this->_jsdefault . "\n// force textarea in favor of iFrame?\n// oFCKeditor._IsCompatibleBrowser = function() { return false; }\noFCKeditor.ReplaceTextarea();\n}");
 }
Esempio n. 5
0
 public function goback($count = -1)
 {
     Javascript("window.history.go({$count})");
     die;
 }
Esempio n. 6
0
 function _generate()
 {
     global $WikiTheme, $request;
     $toolbar = "document.writeln(\"<div class=\\\"edit-toolbar\\\" id=\\\"toolbar\\\">\");\n";
     if (ENABLE_EDIT_TOOLBAR) {
         $username = $request->_user->UserName();
         if (FUSIONFORGE or DISABLE_MARKUP_WIKIWORD or !isWikiWord($username)) {
             $username = '******' . $username . ']]';
         }
         $signature = " ––" . $username . " " . CTime();
         $toolarray = array(array("image" => "ed_format_bold.png", "open" => "**", "close" => "**", "sample" => _("Bold text"), "title" => _("Bold text [alt-b]")), array("image" => "ed_format_italic.png", "open" => "//", "close" => "//", "sample" => _("Italic text"), "title" => _("Italic text [alt-i]")), array("image" => "ed_format_strike.png", "open" => "<s>", "close" => "</s>", "sample" => _("Strike-through text"), "title" => _("Strike")), array("image" => "ed_format_color.png", "open" => "%color=green% ", "close" => " %%", "sample" => _("Color text"), "title" => _("Color")), array("image" => "ed_pagelink.png", "open" => "[[", "close" => "]]", "sample" => _("PageName|optional label"), "title" => _("Link to page")), array("image" => "ed_link.png", "open" => "[[", "close" => "]]", "sample" => _("http://www.example.com|optional label"), "title" => _("External link (remember http:// prefix)")), array("image" => "ed_headline.png", "open" => "\\n== ", "close" => " ==\\n", "sample" => _("Headline text"), "title" => _("Level 1 headline")), array("image" => "ed_nowiki.png", "open" => "\\<verbatim\\>\\n", "close" => "\\n\\</verbatim\\>", "sample" => _("Insert non-formatted text here"), "title" => _("Ignore wiki formatting")), array("image" => "ed_sig.png", "open" => $signature, "close" => "", "sample" => "", "title" => _("Your signature")), array("image" => "ed_hr.png", "open" => "\\n----\\n", "close" => "", "sample" => "", "title" => _("Horizontal line")), array("image" => "ed_table.png", "open" => "\\n{| class=\"bordered\"\\n|+ This is the table caption\\n|= This is the table summary\\n|-\\n! Header A !! Header B !! Header C\\n|-\\n| Cell A1 || Cell B1 || Cell C1\\n|-\\n| Cell A2 || Cell B2 || Cell C2\\n|-\\n| Cell A3 || Cell B3 || Cell C3\\n|}\\n", "close" => "", "sample" => "", "title" => _("Sample table")), array("image" => "ed_enumlist.png", "open" => "\\n# Item 1\\n# Item 2\\n# Item 3\\n", "close" => "", "sample" => "", "title" => _("Enumeration")), array("image" => "ed_list.png", "open" => "\\n* Item 1\\n* Item 2\\n* Item 3\\n", "close" => "", "sample" => "", "title" => _("List")), array("image" => "ed_toc.png", "open" => "<<CreateToc with_toclink||=1>>\\n", "close" => "", "sample" => "", "title" => _("Table of Contents")), array("image" => "ed_redirect.png", "open" => "<<RedirectTo page=\"", "close" => "\">>", "sample" => _("Page Name"), "title" => _("Redirect")), array("image" => "ed_templateplugin.png", "open" => "{{", "close" => "}}", "sample" => _("Template Name"), "title" => _("Template")));
         $btn = new SubmitImageButton(_("Save"), "edit[save]", 'toolbar', $WikiTheme->getImageURL("ed_save.png"));
         $btn->addTooltip(_("Save"));
         $btn->setAccesskey("s");
         $toolbar .= 'document.writeln("' . addslashes($btn->asXml()) . '");' . "\n";
         // preview not supported yet on Wikiblog
         if (empty($WikiTheme->_headers_printed)) {
             $btn = new SubmitImageButton(_("Preview"), "edit[preview]", 'toolbar', $WikiTheme->getImageURL("ed_preview.png"));
             $btn->addTooltip(_("Preview"));
             $btn->setAccesskey("p");
             $toolbar .= 'document.writeln("' . addslashes($btn->asXml()) . '");' . "\n";
         }
         foreach ($toolarray as $tool) {
             global $WikiTheme;
             $image = $WikiTheme->getImageURL($tool["image"]);
             $open = $tool["open"];
             $close = $tool["close"];
             $sample = addslashes($tool["sample"]);
             // Note that we use the title both for the ALT tag and the TITLE tag of the image.
             // Older browsers show a "speedtip" type message only for ALT.
             // Ideally these should be different, realistically they
             // probably don't need to be.
             $tool = $WikiTheme->fixAccesskey($tool);
             $title = addslashes($tool["title"]);
             $toolbar .= "addTagButton('{$image}','{$title}','{$open}','{$close}','{$sample}');\n";
         }
         /* Fails with Chrome */
         if (!isBrowserSafari()) {
             $toolbar .= "addInfobox('" . addslashes(_("Click a button to get an example text")) . "');\n";
         }
     }
     if (JS_SEARCHREPLACE) {
         $undo_d_btn = $WikiTheme->getImageURL("ed_undo_d.png");
         //$redo_btn = $WikiTheme->getImageURL("ed_redo.png");
         $sr_btn = $WikiTheme->getImageURL("ed_replace.png");
         //TODO: generalize the UNDO button and fix it for Search & Replace
         $sr_html = HTML(HTML::img(array('class' => "toolbar", 'id' => "sr_undo", 'src' => $undo_d_btn, 'title' => _("Undo Search & Replace"), 'alt' => _("Undo Search & Replace"), 'onclick' => "do_undo()")), HTML::img(array('class' => "toolbar", 'src' => $sr_btn, 'alt' => _("Search & Replace"), 'title' => _("Search & Replace"), 'onclick' => "replace()")));
     } else {
         $sr_html = '';
     }
     //TODO: Delegate this to run-time with showing an hidden input at the right, and do
     // a seperate moacdropdown and xmlrpc:titleSearch.
     // Button to generate categories, display in extra window as popup and insert
     $sr_html = HTML($sr_html, $this->categoriesPulldown());
     // Button to generate plugins, display in extra window as popup and insert
     $sr_html = HTML($sr_html, $this->pluginPulldown());
     // Button to generate pagenames, display in extra window as popup and insert
     if (TOOLBAR_PAGELINK_PULLDOWN) {
         $sr_html = HTML($sr_html, $this->pagesPulldown(TOOLBAR_PAGELINK_PULLDOWN));
     }
     // Button to insert from an template, display pagename in extra window as popup and insert
     if (TOOLBAR_TEMPLATE_PULLDOWN) {
         $sr_html = HTML($sr_html, $this->templatePulldown(TOOLBAR_TEMPLATE_PULLDOWN));
     }
     // Button to add images, display in extra window as popup and insert
     if (TOOLBAR_IMAGE_PULLDOWN) {
         $sr_html = HTML($sr_html, $this->imagePulldown(TOOLBAR_IMAGE_PULLDOWN));
     }
     // don't use document.write for replace, otherwise self.opener is not defined.
     $toolbar_end = "document.writeln(\"</div>\");";
     if ($sr_html) {
         return HTML(Javascript($toolbar), "\n", $sr_html, "\n", Javascript($toolbar_end));
     } else {
         return HTML(Javascript($toolbar . $toolbar_end));
     }
 }
Esempio n. 7
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     extract($this->getArgs($argstr, $request));
     if ($pagename) {
         // Expand relative page names.
         $page = new WikiPageName($pagename, $basepage);
         $pagename = $page->name;
     }
     if (!$pagename) {
         return $this->error(_("no page specified"));
     }
     if ($jshide and isBrowserIE() and browserDetect("Mac")) {
         //trigger_error(_("jshide set to 0 on Mac IE"), E_USER_NOTICE);
         $jshide = 0;
     }
     $page = $dbi->getPage($pagename);
     $current = $page->getCurrentRevision();
     //FIXME: I suspect this only to crash with Apache2
     if (!$current->get('markup') or $current->get('markup') < 2) {
         if (in_array(php_sapi_name(), array('apache2handler', 'apache2filter'))) {
             trigger_error(_("CreateToc disabled for old markup"), E_USER_WARNING);
             return '';
         }
     }
     $content = $current->getContent();
     $html = HTML::div(array('class' => 'toc', 'id' => 'toc'));
     /*if ($liststyle == 'dl')
           $list = HTML::dl(array('id'=>'toclist','class' => 'toc'));
       elseif ($liststyle == 'ul')
           $list = HTML::ul(array('id'=>'toclist','class' => 'toc'));
       elseif ($liststyle == 'ol')
           $list = HTML::ol(array('id'=>'toclist','class' => 'toc'));
           */
     $list = HTML::ul(array('id' => 'toclist', 'class' => 'toc'));
     if (!strstr($headers, ",")) {
         $headers = array($headers);
     } else {
         $headers = explode(",", $headers);
     }
     $levels = array();
     foreach ($headers as $h) {
         //replace !!! with level 1, ...
         if (strstr($h, "!")) {
             $hcount = substr_count($h, '!');
             $level = min(max(1, $hcount), 3);
             $levels[] = $level;
         } else {
             $level = min(max(1, (int) $h), 3);
             $levels[] = $level;
         }
     }
     if (TOC_FULL_SYNTAX) {
         require_once "lib/InlineParser.php";
     }
     if ($headers = $this->extractHeaders($content, $dbi->_markup, $with_toclink, $with_counter, $levels, $basepage)) {
         $container = $list;
         $levelRefs = array();
         $previousLevel = 3;
         foreach ($headers as $k => $h) {
             if ($h['level'] < $previousLevel) {
                 // h2 -> h3 (level 3 -> level 2)
                 // Keep track of previous points
                 $levelRefs[$previousLevel] = $container;
                 // Create new container
                 $ul = HTML::ul();
                 $container->pushContent($ul);
                 $container = $ul;
             } elseif ($h['level'] > $previousLevel) {
                 // h4 -> h3 (level 1 -> level 2)
                 if (isset($levelRefs[$h['level']])) {
                     $container = $levelRefs[$h['level']];
                 }
             }
             $h = $headers[$k];
             $link = new WikiPageName($pagename, $page, $h['anchor']);
             $li = WikiLink($link, 'known', $h['text']);
             $container->pushContent(HTML::li($li));
             $previousLevel = $h['level'];
         }
     }
     $list->setAttr('style', 'display:' . ($jshide ? 'none;' : 'block;'));
     $open = DATA_PATH . '/' . $WikiTheme->_findFile("images/folderArrowOpen.png");
     $close = DATA_PATH . '/' . $WikiTheme->_findFile("images/folderArrowClosed.png");
     $html->pushContent(Javascript("\nfunction toggletoc(a) {\n  var toc=document.getElementById('toclist')\n  //toctoggle=document.getElementById('toctoggle')\n  var open='" . $open . "'\n  var close='" . $close . "'\n  if (toc.style.display=='none') {\n    toc.style.display='block'\n    a.title='" . _("Click to hide the TOC") . "'\n    a.src = open\n  } else {\n    toc.style.display='none';\n    a.title='" . _("Click to display") . "'\n    a.src = close\n  }\n}"));
     if ($extracollapse) {
         $toclink = HTML(_("Table Of Contents"), " ", HTML::a(array('name' => 'TOC')), HTML::img(array('id' => 'toctoggle', 'class' => 'wikiaction', 'title' => _("Click to display to TOC"), 'onClick' => "toggletoc(this)", 'height' => 15, 'width' => 15, 'border' => 0, 'src' => $jshide ? $close : $open)));
     } else {
         $toclink = HTML::a(array('name' => 'TOC', 'class' => 'wikiaction', 'title' => _("Click to display"), 'onclick' => "toggletoc(this)"), _("Table Of Contents"), HTML::span(array('style' => 'display:none', 'id' => 'toctoggle'), " "));
     }
     $html->pushContent(HTML::h4($toclink));
     $html->pushContent($list);
     return $html;
 }
Esempio n. 8
0
 function _generate()
 {
     global $WikiTheme;
     $toolbar = "document.writeln(\"<div class=\\\"edit-toolbar\\\" id=\\\"toolbar\\\">\");\n";
     if (ENABLE_EDIT_TOOLBAR) {
         $toolarray = array(array("image" => "ed_format_bold.png", "open" => "*", "close" => "*", "sample" => _("Bold text"), "tip" => _("Bold text")), array("image" => "ed_format_italic.png", "open" => "_", "close" => "_", "sample" => _("Italic text"), "tip" => _("Italic text")), array("image" => "ed_pagelink.png", "open" => "[", "close" => "]", "sample" => _("optional label | PageName"), "tip" => _("Link to page")), array("image" => "ed_link.png", "open" => "[", "close" => "]", "sample" => _("optional label | http://www.example.com"), "tip" => _("External link (remember http:// prefix)")), array("image" => "ed_headline.png", "open" => "\\n!!! ", "close" => "\\n", "sample" => _("Headline text"), "tip" => _("Level 1 headline")), array("image" => "ed_image.png", "open" => "[ ", "close" => " ]", "sample" => _("Example.jpg"), "tip" => _("Embedded image")), array("image" => "ed_nowiki.png", "open" => "\\n\\<verbatim\\>\\n", "close" => "\\n\\</verbatim\\>\\n", "sample" => _("Insert non-formatted text here"), "tip" => _("Ignore wiki formatting")), array("image" => "ed_sig.png", "open" => " --" . $GLOBALS['request']->_user->UserName(), "close" => "", "sample" => "", "tip" => _("Your signature")), array("image" => "ed_hr.png", "open" => "\\n----\\n", "close" => "", "sample" => "", "tip" => _("Horizontal line")));
         $btn = new SubmitImageButton(_("Save"), "edit[save]", 'toolbar', $WikiTheme->getImageURL("ed_save.png"));
         $btn->addTooltip(_("Save"));
         $toolbar .= 'document.writeln("' . addslashes($btn->asXml()) . '");' . "\n";
         $btn = new SubmitImageButton(_("Preview"), "edit[preview]", 'toolbar', $WikiTheme->getImageURL("ed_preview.png"));
         $btn->addTooltip(_("Preview"));
         $toolbar .= 'document.writeln("' . addslashes($btn->asXml()) . '");' . "\n";
         foreach ($toolarray as $tool) {
             $image = $WikiTheme->getImageURL($tool["image"]);
             $open = $tool["open"];
             $close = $tool["close"];
             $sample = addslashes($tool["sample"]);
             // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
             // Older browsers show a "speedtip" type message only for ALT.
             // Ideally these should be different, realistically they
             // probably don't need to be.
             $tip = addslashes($tool["tip"]);
             $toolbar .= "addTagButton('{$image}','{$tip}','{$open}','{$close}','{$sample}');\n";
         }
         $toolbar .= "addInfobox('" . addslashes(_("Click a button to get an example text")) . "');\n";
     }
     if (JS_SEARCHREPLACE) {
         $undo_d_btn = $WikiTheme->getImageURL("ed_undo_d.png");
         //$redo_btn = $WikiTheme->getImageURL("ed_redo.png");
         $sr_btn = $WikiTheme->getImageURL("ed_replace.png");
         //TODO: generalize the UNDO button and fix it for Search & Replace
         $sr_html = HTML(HTML::img(array('class' => "toolbar", 'id' => "sr_undo", 'src' => $undo_d_btn, 'title' => _("Undo Search & Replace"), 'alt' => _("Undo Search & Replace"), 'onclick' => "do_undo()")), HTML::img(array('class' => "toolbar", 'src' => $sr_btn, 'alt' => _("Search & Replace"), 'title' => _("Search & Replace"), 'onclick' => "replace()")));
     } else {
         $sr_html = '';
     }
     //TODO: delegate these calculations to a seperate popup/pulldown action request
     // using moacdropdown and xmlrpc:titleSearch
     // action=pulldown or xmlrpc/soap (see google: WebServiceProxyFactory.createProxyAsync)
     // Button to generate categories, display in extra window as popup and insert
     $sr_html = HTML($sr_html, $this->categoriesPulldown());
     // Button to generate plugins, display in extra window as popup and insert
     $sr_html = HTML($sr_html, $this->pluginPulldown());
     // Button to generate pagenames, display in extra window as popup and insert
     if (TOOLBAR_PAGELINK_PULLDOWN) {
         $sr_html = HTML($sr_html, $this->pagesPulldown(TOOLBAR_PAGELINK_PULLDOWN));
     }
     // Button to insert from an template, display pagename in extra window as popup and insert
     if (TOOLBAR_TEMPLATE_PULLDOWN) {
         $sr_html = HTML($sr_html, $this->templatePulldown(TOOLBAR_TEMPLATE_PULLDOWN));
     }
     // don't use document.write for replace, otherwise self.opener is not defined.
     $toolbar_end = "document.writeln(\"</div>\");";
     if ($sr_html) {
         return HTML(Javascript($toolbar), "\n", $sr_html, "\n", Javascript($toolbar_end));
     } else {
         return HTML(Javascript($toolbar . $toolbar_end));
     }
 }