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; }
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; }
function isBrowserSafari($version = false) { if ($version) { return browserDetect('Safari/') and browserVersion() >= $version; } return browserDetect('Safari/'); }
function tooltipAccessKeyPrefix() { static $tooltipAccessKeyPrefix = null; if ($tooltipAccessKeyPrefix) { return $tooltipAccessKeyPrefix; } $tooltipAccessKeyPrefix = 'alt'; if (isBrowserOpera()) { $tooltipAccessKeyPrefix = 'shift-esc'; } elseif (isBrowserSafari() or browserDetect("Mac") or isBrowserKonqueror()) { $tooltipAccessKeyPrefix = 'ctrl'; } elseif ((browserDetect("firefox/2") or browserDetect("minefield/3") or browserDetect("SeaMonkey/1.1")) and (browserDetect("windows") or browserDetect("x11"))) { $tooltipAccessKeyPrefix = 'alt-shift'; } return $tooltipAccessKeyPrefix; }
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 (isBrowserIE() and browserDetect("Mac")) { $jshide = 0; } if ($notoc or $liststyle == 'ol') { $with_counter = 1; } // Check if user is allowed to get the Page. if (!mayAccessPage('view', $pagename)) { return $this->error(sprintf(_("Illegal access to page %s: no read access"), $pagename)); } $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' => GenerateId("toc"))); if ($notoc) { $html->setAttr('style', 'display:none;'); } if ($position == "left" or $position == "right") { $html->setAttr('style', 'float:' . $position . '; width:' . $width . ';'); } $toclistid = GenerateId("toclist"); $list = HTML::div(array('id' => $toclistid, 'class' => 'toclist')); 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), 5); $levels[] = $level; } } if (TOC_FULL_SYNTAX) { require_once "lib/InlineParser.php"; } if ($headers = $this->extractHeaders($content, $dbi->_markup, $with_toclink, $with_counter, $levels, $firstlevelstyle, $basepage)) { foreach ($headers as $h) { // proper heading indent $level = $h['level']; $indent = $level - 1; $link = new WikiPageName($pagename, $page, $h['anchor']); $li = WikiLink($link, 'known', $h['text']); // Hack to suppress pagename before # // $li->_attr["href"] = strstr($li->_attr["href"], '#'); $list->pushContent(HTML::p(HTML::raw(str_repeat($indentstr, $indent)), $li)); } } $list->setAttr('style', 'display:' . ($jshide ? 'none;' : 'block;')); $open = DATA_PATH . '/' . $WikiTheme->_findFile("images/folderArrowOpen.png"); $close = DATA_PATH . '/' . $WikiTheme->_findFile("images/folderArrowClosed.png"); if ($noheader) { } else { $toctoggleid = GenerateId("toctoggle"); if ($extracollapse) { $toclink = HTML(_("Table of Contents"), " ", HTML::a(array('id' => 'TOC')), HTML::img(array('id' => $toctoggleid, 'class' => 'wikiaction', 'title' => _("Click to display to TOC"), 'onclick' => "toggletoc(this, '" . $open . "', '" . $close . "', '" . $toclistid . "')", 'alt' => 'toctoggle', 'src' => $jshide ? $close : $open))); } else { $toclink = HTML::a(array('id' => 'TOC', 'class' => 'wikiaction', 'title' => _("Click to display"), 'onclick' => "toggletoc(this, '" . $open . "', '" . $close . "', '" . $toclistid . "')"), _("Table of Contents"), HTML::span(array('style' => 'display:none', 'id' => $toctoggleid), " ")); } $html->pushContent(HTML::p(array('class' => 'toctitle'), $toclink)); } $html->pushContent($list); if (count($headers) == 0) { // Do not display an empty TOC $html->setAttr('style', 'display:none;'); } return $html; }
function isBrowserOpera($version = false) { if ($version) { return browserDetect('Opera/') and browserVersion() >= $version; } return browserDetect('Opera/'); }