1 <?php rcs_id('$Id: Theme.php,v 1.62 2003-02-21 04:14:52 dairiki Exp $');
3 require_once('lib/HtmlElement.php');
7 * Make a link to a wiki page (in this wiki).
9 * This is a convenience function.
11 * @param mixed $page_or_rev
13 * <dt>A string</dt><dd>The page to link to.</dd>
14 * <dt>A WikiDB_Page object</dt><dd>The page to link to.</dd>
15 * <dt>A WikiDB_PageRevision object</dt><dd>A specific version of the page to link to.</dd>
20 * <dt>'unknown'</dt><dd>Make link appropriate for a non-existant page.</dd>
21 * <dt>'known'</dt><dd>Make link appropriate for an existing page.</dd>
22 * <dt>'auto'</dt><dd>Either 'unknown' or 'known' as appropriate.</dd>
23 * <dt>'button'</dt><dd>Make a button-style link.</dd>
24 * <dt>'if_known'</dt><dd>Only linkify if page exists.</dd>
26 * Unless $type of of the latter form, the link will be of class 'wiki', 'wikiunknown',
27 * 'named-wiki', or 'named-wikiunknown', as appropriate.
29 * @param mixed $label (string or XmlContent object)
30 * Label for the link. If not given, defaults to the page name.
32 * @return XmlContent The link
34 function WikiLink ($page_or_rev, $type = 'known', $label = false) {
35 global $Theme, $request;
37 if ($type == 'button') {
38 return $Theme->makeLinkButton($page_or_rev, $label);
43 if (isa($page_or_rev, 'WikiDB_PageRevision')) {
44 $version = $page_or_rev->getVersion();
45 $page = $page_or_rev->getPage();
46 $pagename = $page->getName();
47 $wikipage = $pagename;
50 elseif (isa($page_or_rev, 'WikiDB_Page')) {
52 $pagename = $page->getName();
53 $wikipage = $pagename;
55 elseif (isa($page_or_rev, 'WikiPageName')) {
56 $wikipage = $page_or_rev;
57 $pagename = $wikipage->name;
60 $wikipage = new WikiPageName($page_or_rev, $request->getPage());
61 $pagename = $wikipage->name;
65 if ($type == 'auto' or $type == 'if_known') {
67 $current = $page->getCurrentRevision();
68 $exists = ! $current->hasDefaultContents();
71 $dbi = $request->getDbh();
72 $exists = $dbi->isWikiPage($wikipage->name);
75 elseif ($type == 'unknown') {
82 // FIXME: this should be somewhere else, if really needed.
83 // WikiLink makes A link, not a string of fancy ones.
84 // (I think that the fancy split links are just confusing.)
85 // Todo: test external ImageLinks http://some/images/next.gif
86 if (isa($wikipage, 'WikiPageName') and !$label
87 and strchr(substr($wikipage->shortName,1), SUBPAGE_SEPARATOR)) {
88 $parts = explode(SUBPAGE_SEPARATOR, $wikipage->shortName);
89 $last_part = array_pop($parts);
92 foreach ($parts as $part) {
94 $parent = join(SUBPAGE_SEPARATOR, $path);
96 $link->pushContent($Theme->linkExistingWikiWord($parent, $sep . $part));
97 $sep = SUBPAGE_SEPARATOR;
100 $link->pushContent($Theme->linkExistingWikiWord($wikipage, $sep . $last_part, $version));
102 $link->pushContent($Theme->linkUnknownWikiWord($wikipage, $last_part));
107 return $Theme->linkExistingWikiWord($wikipage, $label, $version);
109 elseif ($type == 'if_known') {
110 if (!$label && isa($wikipage, 'WikiPageName'))
111 $label = $wikipage->shortName;
112 return HTML($label ? $label : $pagename);
115 return $Theme->linkUnknownWikiWord($pagename, $label);
124 * This is a convenience function.
126 * @param $action string
128 * <dt>[action]</dt><dd>Perform action (e.g. 'edit') on the selected page.</dd>
129 * <dt>[ActionPage]</dt><dd>Run the actionpage (e.g. 'BackLinks') on the selected page.</dd>
130 * <dt>'submit:'[name]</dt><dd>Make a form submission button with the given name.
131 * ([name] can be blank for a nameless submit button.)</dd>
132 * <dt>a hash</dt><dd>Query args for the action. E.g.<pre>
133 * array('action' => 'diff', 'previous' => 'author')
137 * @param $label string
138 * A label for the button. If ommited, a suitable default (based on the valued of $action)
141 * @param $page_or_rev mixed
142 * Which page (& version) to perform the action on.
144 * <dt>A string</dt><dd>The pagename.</dd>
145 * <dt>A WikiDB_Page object</dt><dd>The page.</dd>
146 * <dt>A WikiDB_PageRevision object</dt><dd>A specific version of the page.</dd>
148 * ($Page_or_rev is ignored for submit buttons.)
150 function Button ($action, $label = false, $page_or_rev = false) {
153 if (!is_array($action) && preg_match('/submit:(.*)/A', $action, $m))
154 return $Theme->makeSubmitButton($label, $m[1], $class = $page_or_rev);
156 return $Theme->makeActionButton($action, $label, $page_or_rev);
161 var $HTML_DUMP_SUFFIX = '';
162 function Theme ($theme_name = 'default') {
163 $this->_name = $theme_name;
164 $themes_dir = defined('PHPWIKI_DIR') ? PHPWIKI_DIR . "/themes" : "themes";
166 $this->_path = defined('PHPWIKI_DIR') ? PHPWIKI_DIR . "/" : "";
167 $this->_theme = "themes/$theme_name";
169 if ($theme_name != 'default')
170 $this->_default_theme = new Theme;
173 function file ($file) {
174 return $this->_path . "$this->_theme/$file";
177 function _findFile ($file, $missing_okay = false) {
178 if (file_exists($this->_path . "$this->_theme/$file"))
179 return "$this->_theme/$file";
181 // FIXME: this is a short-term hack. Delete this after all files
182 // get moved into themes/...
183 if (file_exists($this->_path . $file))
187 if (isset($this->_default_theme)) {
188 return $this->_default_theme->_findFile($file, $missing_okay);
190 else if (!$missing_okay) {
191 trigger_error("$file: not found", E_USER_NOTICE);
196 function _findData ($file, $missing_okay = false) {
197 $path = $this->_findFile($file, $missing_okay);
201 if (defined('DATA_PATH'))
202 return DATA_PATH . "/$path";
206 ////////////////////////////////////////////////////////////////
208 // Date and Time formatting
210 ////////////////////////////////////////////////////////////////
212 // Note: Windows' implemetation of strftime does not include certain
213 // format specifiers, such as %e (for date without leading zeros). In
215 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_strftime.2c_.wcsftime.asp
216 // As a result, we have to use %d, and strip out leading zeros ourselves.
218 var $_dateFormat = "%B %d, %Y";
219 var $_timeFormat = "%I:%M %p";
221 var $_showModTime = true;
224 * Set format string used for dates.
226 * @param $fs string Format string for dates.
228 * @param $show_mod_time bool If true (default) then times
229 * are included in the messages generated by getLastModifiedMessage(),
230 * otherwise, only the date of last modification will be shown.
232 function setDateFormat ($fs, $show_mod_time = true) {
233 $this->_dateFormat = $fs;
234 $this->_showModTime = $show_mod_time;
238 * Set format string used for times.
240 * @param $fs string Format string for times.
242 function setTimeFormat ($fs) {
243 $this->_timeFormat = $fs;
249 * Any time zone offset specified in the users preferences is
250 * taken into account by this method.
252 * @param $time_t integer Unix-style time.
254 * @return string The date.
256 function formatDate ($time_t) {
259 $offset_time = $time_t + 3600 * $request->getPref('timeOffset');
260 // strip leading zeros from date elements (ie space followed by zero)
261 return preg_replace('/ 0/', ' ',
262 strftime($this->_dateFormat, $offset_time));
268 * Any time zone offset specified in the users preferences is
269 * taken into account by this method.
271 * @param $time_t integer Unix-style time.
273 * @return string The time.
275 function formatTime ($time_t) {
276 //FIXME: make 24-hour mode configurable?
278 $offset_time = $time_t + 3600 * $request->getPref('timeOffset');
279 return preg_replace('/^0/', ' ',
280 strtolower(strftime($this->_timeFormat, $offset_time)));
284 * Format a date and time.
286 * Any time zone offset specified in the users preferences is
287 * taken into account by this method.
289 * @param $time_t integer Unix-style time.
291 * @return string The date and time.
293 function formatDateTime ($time_t) {
294 return $this->formatDate($time_t) . ' ' . $this->formatTime($time_t);
298 * Format a (possibly relative) date.
300 * If enabled in the users preferences, this method might
301 * return a relative day (e.g. 'Today', 'Yesterday').
303 * Any time zone offset specified in the users preferences is
304 * taken into account by this method.
306 * @param $time_t integer Unix-style time.
308 * @return string The day.
310 function getDay ($time_t) {
313 if ($request->getPref('relativeDates') && ($date = $this->_relativeDay($time_t))) {
314 return ucfirst($date);
316 return $this->formatDate($time_t);
320 * Format the "last modified" message for a page revision.
322 * @param $revision object A WikiDB_PageRevision object.
324 * @param $show_version bool Should the page version number
325 * be included in the message. (If this argument is omitted,
326 * then the version number will be shown only iff the revision
327 * is not the current one.
329 * @return string The "last modified" message.
331 function getLastModifiedMessage ($revision, $show_version = 'auto') {
334 // dates >= this are considered invalid.
335 if (! defined('EPOCH'))
336 define('EPOCH', 0); // seconds since ~ January 1 1970
338 $mtime = $revision->get('mtime');
340 return fmt("Never edited.");
342 if ($show_version == 'auto')
343 $show_version = !$revision->isCurrent();
345 if ($request->getPref('relativeDates') && ($date = $this->_relativeDay($mtime))) {
346 if ($this->_showModTime)
347 $date = sprintf(_("%s at %s"),
348 $date, $this->formatTime($mtime));
351 return fmt("Version %s, saved %s.", $revision->getVersion(), $date);
353 return fmt("Last edited %s.", $date);
356 if ($this->_showModTime)
357 $date = $this->formatDateTime($mtime);
359 $date = $this->formatDate($mtime);
362 return fmt("Version %s, saved on %s.", $revision->getVersion(), $date);
364 return fmt("Last edited on %s.", $date);
367 function _relativeDay ($time_t) {
369 $offset = 3600 * $request->getPref('timeOffset');
371 $now = time() + $offset;
372 $today = localtime($now, true);
373 $time = localtime($time_t + $offset, true);
375 if ($time['tm_yday'] == $today['tm_yday'] && $time['tm_year'] == $today['tm_year'])
378 // Note that due to daylight savings chages (and leap seconds), $now minus
379 // 24 hours is not guaranteed to be yesterday.
380 $yesterday = localtime($now - (12 + $today['tm_hour']) * 3600, true);
381 if ($time['tm_yday'] == $yesterday['tm_yday'] && $time['tm_year'] == $yesterday['tm_year'])
382 return _("yesterday");
387 ////////////////////////////////////////////////////////////////
389 // Hooks for other formatting
391 ////////////////////////////////////////////////////////////////
393 //FIXME: PHP 4.1 Warnings
394 //lib/Theme.php:84: Notice[8]: The call_user_method() function is deprecated,
395 //use the call_user_func variety with the array(&$obj, "method") syntax instead
397 function getFormatter ($type, $format) {
398 $method = strtolower("get${type}Formatter");
399 if (method_exists($this, $method))
400 return $this->{$method}($format);
404 ////////////////////////////////////////////////////////////////
408 ////////////////////////////////////////////////////////////////
410 var $_autosplitWikiWords = false;
412 function setAutosplitWikiWords($autosplit=false) {
413 $this->_autosplitWikiWords = $autosplit ? true : false;
416 function maybeSplitWikiWord ($wikiword) {
417 if ($this->_autosplitWikiWords)
418 return split_pagename($wikiword);
423 function linkExistingWikiWord($wikiword, $linktext = '', $version = false) {
426 if ($version !== false)
427 $url = WikiURL($wikiword, array('version' => $version));
429 $url = WikiURL($wikiword);
431 // Extra steps for dumping page to an html file.
432 // FIXME: shouldn't this be in WikiURL?
433 if ($this->HTML_DUMP_SUFFIX) {
434 // urlencode for pagenames with accented letters
435 $url = rawurlencode($url);
436 $url = preg_replace('/^\./', '%2e', $url);
437 $url .= $this->HTML_DUMP_SUFFIX;
440 $link = HTML::a(array('href' => $url));
442 if (isa($wikiword, 'WikiPageName'))
443 $default_text = $wikiword->shortName;
445 $default_text = $wikiword;
447 if (!empty($linktext)) {
448 $link->pushContent($linktext);
449 $link->setAttr('class', 'named-wiki');
450 $link->setAttr('title', $this->maybeSplitWikiWord($default_text));
453 $link->pushContent($this->maybeSplitWikiWord($default_text));
454 $link->setAttr('class', 'wiki');
456 if ($request->getArg('frame'))
457 $link->setAttr('target', '_top');
461 function linkUnknownWikiWord($wikiword, $linktext = '') {
464 // Get rid of anchors on unknown wikiwords
465 if (isa($wikiword, 'WikiPageName')) {
466 $default_text = $wikiword->shortName;
467 $wikiword = $wikiword->name;
470 $default_text = $wikiword;
473 $url = WikiURL($wikiword, array('action' => 'edit'));
474 //$link = HTML::span(HTML::a(array('href' => $url), '?'));
475 $button = $this->makeButton('?', $url);
476 $button->addTooltip(sprintf(_("Edit: %s"), $wikiword));
477 $link = HTML::span($button);
480 if (!empty($linktext)) {
481 $link->pushContent(HTML::u($linktext));
482 $link->setAttr('class', 'named-wikiunknown');
485 $link->pushContent(HTML::u($this->maybeSplitWikiWord($default_text)));
486 $link->setAttr('class', 'wikiunknown');
488 if ($request->getArg('frame'))
489 $link->setAttr('target', '_top');
494 ////////////////////////////////////////////////////////////////
498 ////////////////////////////////////////////////////////////////
499 var $_imageAliases = array();
500 var $_imageAlt = array();
504 * (To disable an image, alias the image to <code>false</code>.
506 function addImageAlias ($alias, $image_name) {
507 $this->_imageAliases[$alias] = $image_name;
510 function addImageAlt ($alias, $alt_text) {
511 $this->_imageAlt[$alias] = $alt_text;
513 function getImageAlt ($alias) {
514 return $this->_imageAlt[$alias];
517 function getImageURL ($image) {
518 $aliases = &$this->_imageAliases;
520 if (isset($aliases[$image])) {
521 $image = $aliases[$image];
526 // If not extension, default to .png.
527 if (!preg_match('/\.\w+$/', $image))
530 // FIXME: this should probably be made to fall back
531 // automatically to .gif, .jpg.
532 // Also try .gif before .png if browser doesn't like png.
534 $path = $this->_findData("images/$image", 'missing okay');
535 if (!$path) // search explicit images/ or button/ links also
536 return $this->_findData("$image", 'missing okay');
541 function setLinkIcon($proto, $image = false) {
545 $this->_linkIcons[$proto] = $image;
548 function getLinkIconURL ($proto) {
549 $icons = &$this->_linkIcons;
550 if (!empty($icons[$proto]))
551 return $this->getImageURL($icons[$proto]);
552 elseif (!empty($icons['*']))
553 return $this->getImageURL($icons['*']);
557 function addButtonAlias ($text, $alias = false) {
558 $aliases = &$this->_buttonAliases;
561 $aliases = array_merge($aliases, $text);
562 elseif ($alias === false)
563 unset($aliases[$text]);
565 $aliases[$text] = $alias;
568 function getButtonURL ($text) {
569 $aliases = &$this->_buttonAliases;
570 if (isset($aliases[$text]))
571 $text = $aliases[$text];
573 $qtext = urlencode($text);
574 $url = $this->_findButton("$qtext.png");
575 if ($url && strstr($url, '%')) {
576 $url = preg_replace('|([^/]+)$|e', 'urlencode("\\1")', $url);
578 if (!$url) {// Jeff complained about png not supported everywhere. This is not PC
579 $url = $this->_findButton("$qtext.gif");
580 if ($url && strstr($url, '%')) {
581 $url = preg_replace('|([^/]+)$|e', 'urlencode("\\1")', $url);
587 function _findButton ($button_file) {
588 if (!isset($this->_button_path))
589 $this->_button_path = $this->_getButtonPath();
591 foreach ($this->_button_path as $dir) {
592 $path = "$this->_theme/$dir/$button_file";
593 if (file_exists($this->_path . $path))
594 return defined('DATA_PATH') ? DATA_PATH . "/$path" : $path;
599 function _getButtonPath () {
600 $button_dir = $this->file("buttons");
601 if (!file_exists($button_dir) || !is_dir($button_dir))
604 $path = array('buttons');
606 $dir = dir($button_dir);
607 while (($subdir = $dir->read()) !== false) {
608 if ($subdir[0] == '.')
610 if (is_dir("$button_dir/$subdir"))
611 $path[] = "buttons/$subdir";
618 ////////////////////////////////////////////////////////////////
622 ////////////////////////////////////////////////////////////////
624 function makeButton ($text, $url, $class = false) {
625 // FIXME: don't always try for image button?
627 // Special case: URLs like 'submit:preview' generate form
628 // submission buttons.
629 if (preg_match('/^submit:(.*)$/', $url, $m))
630 return $this->makeSubmitButton($text, $m[1], $class);
632 $imgurl = $this->getButtonURL($text);
634 return new ImageButton($text, $url, $class, $imgurl);
636 return new Button($text, $url, $class);
639 function makeSubmitButton ($text, $name, $class = false) {
640 $imgurl = $this->getButtonURL($text);
643 return new SubmitImageButton($text, $name, $class, $imgurl);
645 return new SubmitButton($text, $name, $class);
649 * Make button to perform action.
651 * This constructs a button which performs an action on the
652 * currently selected version of the current page.
653 * (Or anotherpage or version, if you want...)
655 * @param $action string The action to perform (e.g. 'edit', 'lock').
656 * This can also be the name of an "action page" like 'LikePages'.
657 * Alternatively you can give a hash of query args to be applied
660 * @param $label string Textual label for the button. If left empty,
661 * a suitable name will be guessed.
663 * @param $page_or_rev mixed The page to link to. This can be
664 * given as a string (the page name), a WikiDB_Page object, or as
665 * WikiDB_PageRevision object. If given as a WikiDB_PageRevision
666 * object, the button will link to a specific version of the
667 * designated page, otherwise the button links to the most recent
668 * version of the page.
670 * @return object A Button object.
672 function makeActionButton ($action, $label = false, $page_or_rev = false) {
673 extract($this->_get_name_and_rev($page_or_rev));
675 if (is_array($action)) {
677 $action = isset($attr['action']) ? $attr['action'] : 'browse';
680 $attr['action'] = $action;
682 $class = is_safe_action($action) ? 'wikiaction' : 'wikiadmin';
684 $label = $this->_labelForAction($action);
687 $attr['version'] = $version;
689 if ($action == 'browse')
690 unset($attr['action']);
692 return $this->makeButton($label, WikiURL($pagename, $attr), $class);
696 * Make a "button" which links to a wiki-page.
698 * These are really just regular WikiLinks, possibly
699 * disguised (e.g. behind an image button) by the theme.
701 * This method should probably only be used for links
702 * which appear in page navigation bars, or similar places.
704 * Use linkExistingWikiWord, or LinkWikiWord for normal links.
706 * @param $page_or_rev mixed The page to link to. This can be
707 * given as a string (the page name), a WikiDB_Page object, or as
708 * WikiDB_PageRevision object. If given as a WikiDB_PageRevision
709 * object, the button will link to a specific version of the
710 * designated page, otherwise the button links to the most recent
711 * version of the page.
713 * @return object A Button object.
715 function makeLinkButton ($page_or_rev, $label = false) {
716 extract($this->_get_name_and_rev($page_or_rev));
718 $args = $version ? array('version' => $version) : false;
720 return $this->makeButton($label ? $label : $this->maybeSplitWikiWord($pagename),
721 WikiURL($pagename, $args), 'wiki');
724 function _get_name_and_rev ($page_or_rev) {
727 if (empty($page_or_rev)) {
729 $pagename = $request->getArg("pagename");
730 $version = $request->getArg("version");
732 elseif (is_object($page_or_rev)) {
733 if (isa($page_or_rev, 'WikiDB_PageRevision')) {
735 $page = $rev->getPage();
736 $version = $rev->getVersion();
739 $page = $page_or_rev;
741 $pagename = $page->getName();
744 $pagename = (string) $page_or_rev;
746 return compact('pagename', 'version');
749 function _labelForAction ($action) {
751 case 'edit': return _("Edit");
752 case 'diff': return _("Diff");
753 case 'logout': return _("Sign Out");
754 case 'login': return _("Sign In");
755 case 'lock': return _("Lock Page");
756 case 'unlock': return _("Unlock Page");
757 case 'remove': return _("Remove Page");
759 // I don't think the rest of these actually get used.
761 // 'upload' 'dumpserial' 'loadfile' 'zip'
763 return gettext(ucfirst($action));
767 //----------------------------------------------------------------
768 var $_buttonSeparator = "\n | ";
770 function setButtonSeparator($separator) {
771 $this->_buttonSeparator = $separator;
774 function getButtonSeparator() {
775 return $this->_buttonSeparator;
779 ////////////////////////////////////////////////////////////////
783 ////////////////////////////////////////////////////////////////
785 function _CSSlink($title, $css_file, $media, $is_alt = false) {
786 $link = HTML::link(array('rel' => $is_alt ? 'alternate stylesheet' : 'stylesheet',
788 'type' => 'text/css',
789 'charset' => CHARSET,
790 'href' => $this->_findData($css_file)));
792 $link->setAttr('media', $media);
796 function setDefaultCSS ($title, $css_file, $media = false) {
797 if (isset($this->_defaultCSS)) {
798 $oldtitle = $this->_defaultCSS->getAttr('title');
799 $error = sprintf("'%s' -> '%s'", $oldtitle, $title);
800 trigger_error(sprintf(_("Redefinition of %s: %s"), "'default CSS'", $error),
803 if (isset($this->_alternateCSS))
804 unset($this->_alternateCSS[$title]);
805 $this->_defaultCSS = $this->_CSSlink($title, $css_file, $media);
808 function addAlternateCSS ($title, $css_file, $media = false) {
809 $this->_alternateCSS[$title] = $this->_CSSlink($title, $css_file, $media, true);
813 * @return string HTML for CSS.
816 $meta = HTML::meta(array('http-equiv' => 'Default-Style',
817 'content' => $this->_defaultCSS->getAttr('title')));
818 $css = HTML($meta, $this->_defaultCSS);
819 if (!empty($this->_alternateCSS))
820 $css->pushContent($this->_alternateCSS);
824 function findTemplate ($name) {
825 return $this->_path . $this->_findFile("templates/$name.tmpl");
831 * A class representing a clickable "button".
833 * In it's simplest (default) form, a "button" is just a link associated
834 * with some sort of wiki-action.
836 class Button extends HtmlElement {
839 * @param $text string The text for the button.
840 * @param $url string The url (href) for the button.
841 * @param $class string The CSS class for the button.
843 function Button ($text, $url, $class = false) {
845 $this->HtmlElement('a', array('href' => $url));
847 $this->setAttr('class', $class);
848 if ($request->getArg('frame'))
849 $this->setAttr('target', '_top');
850 $this->pushContent($GLOBALS['Theme']->maybeSplitWikiWord($text));
857 * A clickable image button.
859 class ImageButton extends Button {
862 * @param $text string The text for the button.
863 * @param $url string The url (href) for the button.
864 * @param $class string The CSS class for the button.
865 * @param $img_url string URL for button's image.
866 * @param $img_attr array Additional attributes for the <img> tag.
868 function ImageButton ($text, $url, $class, $img_url, $img_attr = false) {
869 $this->HtmlElement('a', array('href' => $url));
871 $this->setAttr('class', $class);
873 if (!is_array($img_attr))
875 $img_attr['src'] = $img_url;
876 $img_attr['alt'] = $text;
877 $img_attr['class'] = 'wiki-button';
878 $img_attr['border'] = 0;
879 $this->pushContent(HTML::img($img_attr));
884 * A class representing a form <samp>submit</samp> button.
886 class SubmitButton extends HtmlElement {
889 * @param $text string The text for the button.
890 * @param $name string The name of the form field.
891 * @param $class string The CSS class for the button.
893 function SubmitButton ($text, $name = false, $class = false) {
894 $this->HtmlElement('input', array('type' => 'submit',
897 $this->setAttr('name', $name);
899 $this->setAttr('class', $class);
906 * A class representing an image form <samp>submit</samp> button.
908 class SubmitImageButton extends SubmitButton {
911 * @param $text string The text for the button.
912 * @param $name string The name of the form field.
913 * @param $class string The CSS class for the button.
914 * @param $img_url string URL for button's image.
915 * @param $img_attr array Additional attributes for the <img> tag.
917 function SubmitImageButton ($text, $name = false, $class = false, $img_url) {
918 $this->HtmlElement('input', array('type' => 'image',
923 $this->setAttr('name', $name);
925 $this->setAttr('class', $class);
930 // $Log: not supported by cvs2svn $
931 // Revision 1.61 2003/02/18 21:52:05 dairiki
932 // Fix so that one can still link to wiki pages with # in their names.
933 // (This was made difficult by the introduction of named tags, since
934 // '[Page #1]' is now a link to anchor '1' in page 'Page'.
936 // Now the ~ escape for page names should work: [Page ~#1].
938 // Revision 1.60 2003/02/15 01:59:47 dairiki
939 // Theme::getCSS(): Add Default-Style HTTP(-eqiv) header in attempt
940 // to fix default stylesheet selection on some browsers.
941 // For details on the Default-Style header, see:
942 // http://home.dairiki.org/docs/html4/present/styles.html#h-14.3.2
944 // Revision 1.59 2003/01/04 22:30:16 carstenklapp
945 // New: display a "Never edited." message instead of an invalid epoch date.
948 // (c-file-style: "gnu")
953 // c-hanging-comment-ender-p: nil
954 // indent-tabs-mode: nil