Esempio n. 1
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. 2
0
 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;
 }
Esempio n. 3
0
/**
 * <object> / <embed> tags instead of <img> for all non-image extensions
 * in INLINE_IMAGES.
 * Called by LinkImage(), not directly.
 * Syntax:  [image.svg size=50% alt=image.gif border=n align= hspace= vspace= width= height=]
 * Samples: [Upload:song.mp3 type=audio/mpeg width=200 height=10]
 *   $alt may be an alternate img
 * TODO: Need to unify with WikiPluginCached::embedObject()
 *
 * Note that Safari 1.0 will crash with <object>, so use only <embed>
 *   http://www.alleged.org.uk/pdc/2002/svg-object.html
 *
 * Allowed object tags:
 *   DATA=URI (object data)
 *   CLASSID=URI (location of implementation)
 *   ARCHIVE=CDATA (archive files)
 *   CODEBASE=URI (base URI for CLASSID, DATA, ARCHIVE)
 *   WIDTH=Length (object width)
 *   HEIGHT=Length (object height)
 *   NAME=CDATA (name for form submission)
 *   USEMAP=URI (client-side image map)
 *   TYPE=ContentType (content-type of object)
 *   CODETYPE=ContentType (content-type of code)
 *   STANDBY=Text (message to show while loading)
 *   TABINDEX=NUMBER (position in tabbing order)
 *   DECLARE (do not instantiate object)
 * The rest is added as <param name="" value="" /> tags
 */
function ImgObject($img, $url)
{
    // get the url args: data="sample.svgz" type="image/svg+xml" width="400" height="300"
    $params = explode(",", "data,classid,archive,codebase,name,usemap,type," . "codetype,standby,tabindex,declare");
    if (is_array($url)) {
        $args = $url;
        $found = array();
        foreach ($args as $attr => $value) {
            foreach ($params as $param) {
                if ($param == $attr) {
                    $img->setAttr($param, $value);
                    if (isset($found[$param])) {
                        $found[$param]++;
                    } else {
                        $found[$param] = 1;
                    }
                    break;
                }
            }
        }
        // now all remaining args are added as <param> to the object
        $params = array();
        foreach ($args as $attr => $value) {
            if (!isset($found[$attr])) {
                $params[] = HTML::param(array('name' => $attr, 'value' => $value));
            }
        }
        $url = $img->getAttr('src');
        $force_img = "png|jpg|gif|jpeg|bmp";
        if (!preg_match("/\\.(" . $force_img . ")/i", $url)) {
            $img->setAttr('src', false);
        }
    } else {
        $args = explode(' ', $url);
        if (count($args) >= 1) {
            $url = array_shift($args);
            $found = array();
            foreach ($args as $attr) {
                foreach ($params as $param) {
                    if (preg_match("/^{$param}=(\\S+)\$/i", $attr, $m)) {
                        $img->setAttr($param, $m[1]);
                        if (isset($found[$param])) {
                            $found[$param]++;
                        } else {
                            $found[$param] = 1;
                        }
                        break;
                    }
                }
            }
            // now all remaining args are added as <param> to the object
            $params = array();
            foreach ($args as $attr) {
                if (!isset($found[$attr]) and preg_match("/^(\\S+)=(\\S+)\$/i", $attr, $m)) {
                    $params[] = HTML::param(array('name' => $m[1], 'value' => $m[2]));
                }
            }
        }
    }
    $type = $img->getAttr('type');
    if (!$type) {
        // TODO: map extension to mime-types if type is not given and php < 4.3
        if (function_exists('mime_content_type')) {
            $type = mime_content_type($url);
        }
    }
    $object = HTML::object(array_merge($img->_attr, array('type' => $type)), $img->_content);
    $object->setAttr('class', 'inlineobject');
    if ($params) {
        foreach ($params as $param) {
            $object->pushContent($param);
        }
    }
    if (isBrowserSafari() and !isBrowserSafari(532)) {
        // recent chrome can do OBJECT
        return HTML::embed($object->_attr, $object->_content);
    }
    $object->pushContent(HTML::embed($object->_attr));
    return $object;
}
Esempio n. 4
0
/**
 * <object> / <embed> tags instead of <img> for all non-image extensions allowed via INLINE_IMAGES
 * Called by LinkImage(), not directly.
 * Syntax: [image.svg size=50% border=n align= hspace= vspace= width= height=]
 * $alt may be an alternate img
 * TODO: Need to unify with WikiPluginCached::embedObject()
 *
 * Note that Safari 1.0 will crash with <object>, so use only <embed>
 *   http://www.alleged.org.uk/pdc/2002/svg-object.html
 */
function ImgObject($img, $url)
{
    // get the url args: data="sample.svgz" type="image/svg+xml" width="400" height="300"
    $args = split(' ', $url);
    if (count($args) >= 1) {
        $url = array_shift($args);
        foreach ($args as $attr) {
            if (preg_match('/^type=(\\S+)$/', $attr, $m)) {
                $img->setAttr('type', $m[1]);
            }
            if (preg_match('/^data=(\\S+)$/', $attr, $m)) {
                $img->setAttr('data', $m[1]);
            }
        }
    }
    $type = $img->getAttr('type');
    if (!$type) {
        // TODO: map extension to mime-types if type is not given and php < 4.3
        if (function_exists('mime_content_type')) {
            $type = mime_content_type($url);
        }
    }
    $link = HTML::object(array_merge($img->_attr, array('src' => $url, 'type' => $type)));
    $link->setAttr('class', 'inlineobject');
    if (isBrowserSafari()) {
        return HTML::embed($link->_attr);
    }
    $link->pushContent(HTML::embed($link->_attr));
    return $link;
}