[pLog-svn] r4300 - in misc/mediawiki: . extensions
reto at devel.lifetype.net
reto at devel.lifetype.net
Mon Nov 13 19:28:35 GMT 2006
Author: reto
Date: 2006-11-13 19:28:35 +0000 (Mon, 13 Nov 2006)
New Revision: 4300
Added:
misc/mediawiki/extensions/
misc/mediawiki/extensions/kwBreadCrumbs.php
Removed:
misc/mediawiki/LifeType.php
Log:
adding the only extension we use (AFAIK). we didn't change this one, I'm only adding it so we don't forget it on a future upgrade of mediawiki.
Deleted: misc/mediawiki/LifeType.php
===================================================================
--- misc/mediawiki/LifeType.php 2006-11-13 19:24:58 UTC (rev 4299)
+++ misc/mediawiki/LifeType.php 2006-11-13 19:28:35 UTC (rev 4300)
@@ -1,219 +0,0 @@
-<?php
-/**
- * LifeType Template for LifeType OpenSource Blogging Platform Project
- *
- * Build by Mark Wu (mark.wu at markplace.net)
- *
- * @todo document
- * @package MediaWiki
- * @subpackage Skins
- */
-
-if( !defined( 'MEDIAWIKI' ) )
- die();
-
-/** */
-require_once('includes/SkinTemplate.php');
-
-/**
- * Inherit main code from SkinTemplate, set the CSS and template filter.
- * @todo document
- * @package MediaWiki
- * @subpackage Skins
- */
-class SkinLifeType extends SkinTemplate {
- /** Using monobook. */
- function initPage( &$out ) {
- SkinTemplate::initPage( $out );
- $this->skinname = 'lifetype';
- $this->stylename = 'lifetype';
- $this->template = 'LifeTypeTemplate';
- }
-}
-
-/**
- * @todo document
- * @package MediaWiki
- * @subpackage Skins
- */
-class LifeTypeTemplate extends QuickTemplate {
- /**
- * Template filter callback for LifeType skin.
- * Takes an associative array of data set from a SkinTemplate-based
- * class, and a wrapper for MediaWiki's localization database, and
- * outputs a formatted page.
- *
- * @access private
- */
- function execute() {
- // Suppress warnings to prevent notices about missing indexes in $this->data
- wfSuppressWarnings();
-
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>">
- <head>
- <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
- <?php $this->html('headlinks') ?>
- <title><?php $this->text('pagetitle') ?></title>
-
- <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/main.css"; /*]]>*/</style>
- <link rel="stylesheet" type="text/css" <?php if(empty($this->data['printable']) ) { ?>media="print"<?php } ?> href="<?php $this->text('stylepath') ?>/common/commonPrint.css" />
- <!--[if lt IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE50Fixes.css";</style><![endif]-->
- <!--[if IE 5.5000]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE55Fixes.css";</style><![endif]-->
- <!--[if gte IE 6]><style type="text/css">@import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/IE60Fixes.css";</style><![endif]-->
- <!--[if IE]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js"></script>
- <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
-
- <?php if($this->data['jsvarurl' ]) { ?><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('jsvarurl') ?>"></script><?php } ?>
- <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js"></script>
- <?php if($this->data['usercss' ]) { ?><style type="text/css"><?php $this->html('usercss') ?></style><?php } ?>
- <?php if($this->data['userjs' ]) { ?><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('userjs') ?>"></script><?php } ?>
- <?php if($this->data['userjsprev']) { ?><script type="<?php $this->text('jsmimetype') ?>"><?php $this->html('userjsprev') ?></script><?php } ?>
- <?php if($this->data['trackbackhtml']) print $this->data['trackbackhtml']; ?>
-
- <link rel="stylesheet" href="<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/style.css" type="text/css" />
- </head>
- <body>
- <div id="page">
- <div id="header">
- <div id="headerimg">
- <a href="http://www.lifetype.org.tw/1"></a>
- </div>
- </div>
- <table>
- <tr>
- <td style="border:0px;width:750px;padding:0px;"><a href="http://www.lifetype.org.tw/static/1/blog"><img src="<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/<?php $this->text('lang') ?>/news.jpg" width="118" height="35" border="0" alt="News" /></a><a href="http://www.lifetype.org.tw/static/1/features"><img src="<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/<?php $this->text('lang') ?>/features.jpg" width="126" height="35" border="0" alt="Features" /></a><a href="http://www.lifetype.org.tw/static/1/downloads"><img src="<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/<?php $this->text('lang') ?>/downloads.jpg" alt="Downloads" width="118" height="35" border="0" /></a><a href="http://www.lifetype.org.tw/static/1/development"><img src="<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/<?php $this->text('lang') ?>/development.jpg" alt="Development" width="148" height="35" border="0" /></a><a href="http://www.lifetype.org.tw/static/1/support"><img src="<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/<?php $this->text('lang') ?>/support.jpg" alt="Support" width="121" height="35" border="0" /></a><a href="http://www.lifetype.org.tw/static/1/aboutus"><img src="<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/<?php $this->text('lang') ?>/aboutus.jpg" alt="About Us" width="119" height="35" border="0" /></a></td>
- </tr>
- </table>
-
- <div id="content" class="narrowcolumn">
- <div><?php echo kwBreadCrumbsTAL() ?></div>
- <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
- <div class="post">
- <h2><?php $this->text('title') ?></h2>
- </div>
- <div id="bodyContent" class="entry">
- <h3 id="siteSub"><?php $this->msg('tagline') ?></h3>
- <div id="contentSub"><?php $this->html('subtitle') ?></div>
- <?php if($this->data['undelete']) { ?><div id="contentSub"><?php $this->html('undelete') ?></div><?php } ?>
- <?php if($this->data['newtalk'] ) { ?><div class="usermessage"><?php $this->html('newtalk') ?></div><?php } ?>
- <!-- start content -->
- <?php $this->html('bodytext') ?>
- <?php if($this->data['catlinks']) { ?><div id="catlinks"><?php $this->html('catlinks') ?></div><?php } ?>
- <!-- end content -->
- </div>
- </div>
-
- <div id="sidebar" style="padding-left: 15px">
- <ul>
- <li><h2><label for="searchInput"><?php $this->msg('search') ?></label></h2>
- <form name="searchform" action="<?php $this->text('searchaction') ?>">
- <input id="searchInput" name="search" type="text" <?php if($this->haveMsg('accesskey-search')) { ?>accesskey="<?php $this->msg('accesskey-search') ?>"<?php } if( isset( $this->data['search'] ) ) { ?> value="<?php $this->text('search') ?>"<?php } ?> />
- <br/>
- <br/>
- <input type='submit' name="go" value="<?php $this->msg('go') ?>"/>
- <input type='submit' name="fulltext" value="<?php $this->msg('search') ?>" />
- </form>
- </li>
-
- <li><h2><?php $this->msg('views') ?></h2>
- <ul>
- <?php foreach($this->data['content_actions'] as $key => $action) { ?>
- <li><a href="<?php echo htmlspecialchars($action['href']) ?>"><?php echo htmlspecialchars($action['text']) ?></a></li>
- <?php } ?>
- </ul>
- </li>
-
- <li><h2><?php $this->msg('personaltools') ?></h2>
- <ul>
- <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
- <li id="pt-<?php echo htmlspecialchars($key) ?>" style="padding-left: 20px;"><a href="<?php echo htmlspecialchars($item['href']) ?>"><a href="<?php echo htmlspecialchars($item['href']) ?>"<?php if(!empty($item['class'])) { ?> class="<?php echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php echo htmlspecialchars($item['text']) ?></a></li>
- <?php } ?>
- </ul>
- </li>
-
- <?php foreach ($this->data['sidebar'] as $bar => $cont) { ?>
- <li><h2><?php $out = wfMsg( $bar ); if (wfNoMsg($bar, $out)) echo $bar; else echo $out; ?></h2>
- <ul>
- <?php foreach($cont as $key => $val) { ?>
- <li><a href="<?php echo htmlspecialchars($val['href']) ?>"><?php echo htmlspecialchars($val['text'])?></a></li>
- <?php } ?>
- </ul>
- </li>
- <?php } ?>
-
- <li><h2><?php $this->msg('toolbox') ?></h2>
- <ul>
- <?php if($this->data['notspecialpage']) { foreach( array( 'whatlinkshere', 'recentchangeslinked' ) as $special ) { ?>
- <li><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href']) ?>"><?php echo $this->msg($special) ?></a></li>
- <?php } } ?>
- <?php if(isset($this->data['nav_urls']['trackbacklink'])) { ?>
- <li><a href="<?php echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href']) ?>"><?php echo $this->msg('trackbacklink') ?></a></li>
- <?php } ?>
- <?php if($this->data['feeds']) { ?>
- <li><?php foreach($this->data['feeds'] as $key => $feed) { ?><span><a href="<?php echo htmlspecialchars($feed['href']) ?>"><?php echo htmlspecialchars($feed['text'])?></a> </span><?php } ?></li>
- <?php } ?>
- <?php foreach( array('contributions', 'emailuser', 'upload', 'specialpages') as $special ) { ?>
- <?php if($this->data['nav_urls'][$special]) {?>
- <li><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href']) ?>"><?php $this->msg($special) ?></a></li>
- <?php } ?>
- <?php } ?>
- <?php if(!empty($this->data['nav_urls']['print']['href'])) { ?>
- <li><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href']) ?>"><?php echo $this->msg('printableversion') ?></a></li>
- <?php } ?>
- </ul>
- </li>
-
- <?php if( $this->data['language_urls'] ) { ?>
- <li><h2><?php $this->msg('otherlanguages') ?></h2>
- <ul>
- <?php foreach($this->data['language_urls'] as $langlink) { ?>
- <li><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
- <?php } ?>
- </ul>
- </li>
- <?php } ?>
- </ul>
-
- <?php if($this->data['poweredbyico']) { ?><div id="f-poweredbyico"><?php $this->html('poweredbyico') ?></div><?php } ?>
- <br/><br/><br/><br/>
- <?php if($this->data['copyrightico']) { ?><div id="f-copyrightico"><?php $this->html('copyrightico') ?></div><?php } ?>
- </div>
-
- <div id="footer">
- <ul>
- <?php if($this->data['lastmod' ]) { ?><li><?php $this->html('lastmod') ?></li><?php } ?>
- <?php if($this->data['viewcount' ]) { ?><li><?php $this->html('viewcount') ?></li><?php } ?>
- <?php if($this->data['numberofwatchingusers' ]) { ?><li><?php $this->html('numberofwatchingusers') ?></li><?php } ?>
- <?php if($this->data['credits' ]) { ?><li><?php $this->html('credits') ?></li><?php } ?>
- <?php if($this->data['copyright' ]) { ?><li><?php $this->html('copyright') ?></li><?php } ?>
- <?php if($this->data['about' ]) { ?><li><?php $this->html('about') ?></li><?php } ?>
- <?php if($this->data['disclaimer']) { ?><li><?php $this->html('disclaimer') ?></li><?php } ?>
- <?php if($this->data['tagline']) { ?><li><?php echo $this->data['tagline'] ?></li><?php } ?>
- </ul>
-
- <table style="border-top: 1px solid #efefef">
- <tr>
- <td style="width:238px;text-align:left">© 2005 <a href="http://www.lifetype.net" class="black">LifeType</a>. All rights reserved.</td>
- <td style="width:272;text-align:center">
- <a href="http://www.lifetype.net/" class="black">International</a> |
- <a href="http://www.lifetype.de/" class="black">Germany</a> |
- <a href="http://www.lifetype.org.tw/" class="black">Taiwan</a>
- </td>
- <td style="width:240px;text-align:right">
- <a href="http://www.lifetype.org.tw/static/1/sitemap">Sitemap</a> |
- <a href="http://www.lifetype.org.tw/static/1/aboutus#contact" class="black">Contact</a>
- </td>
- </tr>
- </table>
- </div>
- </div>
- <?php $this->html('reporttime') ?>
- </body>
-</html>
-<?php
- wfRestoreWarnings();
- }
-}
-?>
Added: misc/mediawiki/extensions/kwBreadCrumbs.php
===================================================================
--- misc/mediawiki/extensions/kwBreadCrumbs.php 2006-11-13 19:24:58 UTC (rev 4299)
+++ misc/mediawiki/extensions/kwBreadCrumbs.php 2006-11-13 19:28:35 UTC (rev 4300)
@@ -0,0 +1,455 @@
+<?php
+/*
+===Description===
+
+This extension allows you to dynamically create a "trace" of the pages you
+have visited so far. This trace is displayed as a small list of links that
+can typically be positionned at the top of a page. Additional parameters
+can be specified to control the layout of the list and specify how many pages
+should be "remembered".
+
+===Parameters===
+
+ <kw_bread_crumbs>max_nb_crumbs=value|max_title_len=value|prefix=string|trim_prefix=string|separator=string|bgcolor=string|small=boolean|on_top_hack=boolean|session_key=string</kw_bread_crumbs>
+
+* max_nb_crumbs=value: max number of page titles this extension should remember
+* max_title_len=value: max length for each page title (will crop otherwise)
+* prefix=string: string to use in front of the list of titles.
+* trim_prefix=string: if this prefix is found, remove it from each page title.
+* separator=string: string to use between each page title.
+* bgcolor=string: in hex format (ex: FF22AA), color of the table background.
+* small=[0|1]: if true, use a smaller font. True by default.
+* on_top_hack=[0|1]: if true, try to put titles on top of page.
+* session_key=string: explicitly specify the key the trace should be saved in
+
+Note that trim_prefix can be specified multiple times so that different
+prefixes can be trimmed.
+
+You may have to use HTML entities for the prefix and separator parameters to
+work properly.
+
+The session_key parameter specificies the name of the key that is used to
+save and retrieve the trace in the user session. It defaults to the site name
+of the Wiki ($wgSitename) and the version of the MediaWiki running the site.
+If you share multiple wikis with the same name (say, for testing purposes),
+you may need to explicitly define a different session_key for each one.
+
+The on_top_hack option is a hack. I mean, really. It will try to put the
+trace on top of the page, before the page title. This is achieved by
+piggy-backing on top of the wgSiteNotice variable, and will work only
+for the monobook skin. See 'Positioning' below for more options.
+
+===Download===
+
+http://public.kitware.com/cgi-bin/viewcvs.cgi/%2Acheckout%2A/scripts/media-wiki-extensions/kwBreadCrumbs.php?content-type=text%2Fplain&root=kwGridWeb
+
+===Installation===
+
+To activate the extension, copy the file to the Wiki/extensions directory
+and include its contents from your Wiki/LocalSettings.php with:
+ include("extensions/kwBreadCrumbs.php");
+
+===Positioning===
+
+There are 3 ways to position the trace:
+
+1) inline: insert the tag in your page at the specific location you want the
+trace to be rendered. I recommend you test your trace in this mode first.
+
+2) on top: insert the tag anywhere in the page and use on_top_hack=1; the
+extension will attempt to place the trace on top of the page, before the
+page title. This is hack, and it works only for MediaWiki 1.3.
+
+3) anywhere in the layout: you can use this extension as a template element.
+* MediaWiki 1.3: modify the templates/xhtml_slim.tp file to insert the
+kwBreadCrumbs TAL element in the layout, then modify the outputPage() function
+in includes/SkinPHPTal.php to create the contents of this element by calling
+kwBreadCrumbsTAL(). Note that you can not pass any parameters to that
+function though. In order to work around this problem, assign any option to
+a wgKwBreadCrumbs variable in LocalSettings.php:
+ xhtml_slim.tp:
+ <div class="kwBreadCrumbs" tal:content="structure kwBreadCrumbs">Bread Crumbs</div>
+ SkinPHPTal.php:
+ $tpl->set("kwBreadCrumbs", kwBreadCrumbsTAL());
+ LocalSettings.php:
+ $wgKwBreadCrumbs = "prefix=Trace: |small=1|bgcolor=F9F9F9";
+* MediaWiki 1.4: PHPTAL is not included by default anymore. Including the
+trace is there just a matter of editing one of the PHP file in the skins/
+directory and invoke the kwBreadCrumbs() function with options. You may also
+call the parameter-less kwBreadCrumbsTAL() function and assign any option to
+a wgKwBreadCrumbs variable in LocalSettings.php:
+ Monobook.php:
+ <div><?php echo kwBreadCrumbs("prefix=Trace: |bgcolor=F9F9F9") ?></div>
+ or
+ Monobook.php:
+ <div><?php echo kwBreadCrumbsTAL() ?></div>
+ LocalSettings.php:
+ $wgKwBreadCrumbs = "prefix=Trace: |small=1|bgcolor=F9F9F9";
+
+===Issues===
+
+The Wiki engine caches pages to achieve better performance. Sadly, this
+makes extensions relying on dynamic or external contents pretty much useless.
+To prevent pages using this extension from being cached, the 'cur_touched'
+field in the 'cur' table is set slightly ahead in the future, so that the
+page cache is automatically invalidated. The side-effects should be minimal :)
+
+===Author===
+
+Sebastien Barre (Kitware, Inc.)
+
+===Thanks===
+
+I noticed this feature in the DokuWiki project, so kudos
+to them (http://wiki.splitbrain.org/wiki:dokuwiki).
+*/
+
+$wgExtensionFunctions[] = "kwBreadCrumbsExtension";
+
+// ------------------------------------------------------------------------
+function kwBreadCrumbsExtension()
+{
+ global $wgParser;
+ $wgParser->setHook( "kw_bread_crumbs", "kwBreadCrumbs");
+}
+
+// ------------------------------------------------------------------------
+function kwBreadCrumbs($input)
+{
+ global $wgUser, $wgTitle, $wgOut;
+
+ kwBreadCrumbsNoCache();
+
+ // Initialize parameters
+
+ $max_nb_crumbs = 5;
+ $max_title_len = 30;
+ $separator = ' » ';
+ $trim_prefixes = array();
+ $prefix = NULL;
+ $small = 1;
+ $bgcolor = NULL;
+ $on_top_hack = 0;
+ $class = 'kwBreadCrumbs';
+ $session_key = NULL;
+
+ // Parse each parameter
+
+ $params = explode('|', $input);
+ foreach ($params as $param)
+ {
+ $param_components = explode("=", $param, 2);
+ $param_name = strtolower(trim($param_components[0]));
+ $param_value = isset($param_components[1]) ? $param_components[1] : NULL;
+
+ // max_nb_crumbs
+
+ if ($param_name == 'max_nb_crumbs')
+ {
+ if (!strlen($param_value))
+ {
+ return kwBreadCrumbsError("missing value for parameter '$param_name'");
+ }
+ $value = (int)$param_value;
+ if ($value >= 1 && $value <= 50)
+ {
+ $max_nb_crumbs = $value;
+ }
+ }
+
+ // max_title_len
+
+ else if ($param_name == 'max_title_len')
+ {
+ if (!strlen($param_value))
+ {
+ return kwBreadCrumbsError("missing value for parameter '$param_name'");
+ }
+ $value = (int)$param_value;
+ if ($value >= 0 && $value <= 150)
+ {
+ $max_title_len = $value;
+ }
+ }
+
+ // trim_prefix
+
+ else if ($param_name == 'trim_prefix')
+ {
+ if (!strlen($param_value))
+ {
+ return kwSiteMapError("missing value for parameter '$param_name'");
+ }
+ $trim_prefixes[] = $param_value;
+ }
+
+ // prefix
+
+ else if ($param_name == 'prefix')
+ {
+ if (!strlen($param_value))
+ {
+ return kwSiteMapError("missing value for parameter '$param_name'");
+ }
+ $prefix = $param_value;
+ }
+
+ // separator
+
+ else if ($param_name == 'separator')
+ {
+ if (!strlen($param_value))
+ {
+ return kwBreadCrumbsError("missing value for parameter '$param_name'");
+ }
+ $separator = $param_value;
+ }
+
+ // bgcolor
+
+ else if ($param_name == 'bgcolor')
+ {
+ if (!strlen($param_value))
+ {
+ return kwSiteMapError("missing value for parameter '$param_name'");
+ }
+ $bgcolor = $param_value;
+ }
+
+ // small
+
+ else if ($param_name == 'small')
+ {
+ if (!strlen($param_value))
+ {
+ return kwBreadCrumbsError("missing value for parameter '$param_name'");
+ }
+ $small = $param_value ? 1 : 0;;
+ }
+
+ // on_top_hack
+
+ else if ($param_name == 'on_top_hack')
+ {
+ if (!strlen($param_value))
+ {
+ return kwBreadCrumbsError("missing value for parameter '$param_name'");
+ }
+ $on_top_hack = $param_value ? 1 : 0;;
+ }
+
+ // session_key
+
+ else if ($param_name == 'session_key')
+ {
+ if (!strlen($param_value))
+ {
+ return kwSiteMapError("missing value for parameter '$param_name'");
+ }
+ $session_key = $param_value;
+ }
+
+ // unknown parameter
+
+ else if ($param_name)
+ {
+ return kwBreadCrumbsError("unknown parameter '$param_name'");
+ }
+ }
+
+ // Make sure we started a session
+
+ @session_start();
+
+ global $wgSitename, $wgVersion;
+ if (is_null($session_key))
+ {
+ $session_key = "kw_bread_crumbs: $wgSitename ($wgVersion)";
+ }
+ if (!isset($_SESSION[$session_key]))
+ {
+ $_SESSION[$session_key] = array();
+ }
+
+ // Remove duplicates
+
+ $current_title = $wgTitle->getPrefixedText();
+
+ $titles = array();
+ foreach ($_SESSION[$session_key] as $title)
+ {
+ if ($title != $current_title)
+ {
+ $titles[] = $title;
+ }
+ }
+ $_SESSION[$session_key] = $titles;
+ $_SESSION[$session_key][] = $current_title;
+
+ // Shrink the list
+
+ $nb_titles = count($_SESSION[$session_key]);
+ while ($nb_titles > $max_nb_crumbs)
+ {
+ array_shift($_SESSION[$session_key]);
+ $nb_titles--;
+ }
+
+ // Create the trace
+
+ $skin =& $wgUser->getSkin();
+
+ $urls = array();
+ foreach ($_SESSION[$session_key] as $title)
+ {
+ $text = $title;
+ if (count($trim_prefixes))
+ {
+ foreach ($trim_prefixes as $trim_prefix)
+ {
+ if (strpos($text, $trim_prefix) === 0)
+ {
+ $text = substr($text, strlen($trim_prefix));
+ }
+ }
+ }
+ if ($max_title_len > 0)
+ {
+ $text_len = strlen($text);
+ if ($text_len > $max_title_len)
+ {
+ $half = (int)($max_title_len / 2);
+ $text = substr($text, 0, $max_title_len - $half - 1) . '…' .
+ substr($text, -$half);
+ }
+ }
+ $urls[] =
+ ($title == $current_title ? $text : $skin->makeLink($title, $text));
+ }
+
+ $output = '<div class="' . $class . '"';
+ if ($small)
+ {
+ $output .= ' style="font-size:80%"';
+ }
+ $output .= '>';
+
+ if (!is_null($bgcolor))
+ {
+ $output .= '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#' . htmlspecialchars($bgcolor) . '">';
+ }
+
+ $output .=
+ htmlentities(html_entity_decode($prefix)) .
+ implode(htmlentities(html_entity_decode($separator)), $urls);
+
+ if (!is_null($bgcolor))
+ {
+ $output .= '</td></tr></table>';
+ }
+ $output .= '</div>';
+
+ // Hack to display the titles on top:
+ // - only for version 1.3
+ // - only if monobook
+ // - piggy-back after the site notice (wgSiteNotice)
+ // - remove border if <= 1.3.0 beta, alpha, etc.
+
+ if ($on_top_hack)
+ {
+ if (preg_match("/^(\d+)\.(\d+)\.(\d+)(\w*)$/", $wgVersion, $ver))
+ {
+ if ($ver[1] == 1 && $ver[2] == 3)
+ {
+ $user_skin_name = $wgUser->getOption('skin');
+ if ($user_skin_name == "monobook")
+ {
+ global $wgSiteNotice;
+ if (!$wgSiteNotice || !strpos($wgSiteNotice, $class))
+ {
+ $new_notice = NULL;
+ if ($ver[3] == 0 && isset($ver[4]))
+ {
+ $new_notice .= '<div style="margin: -1px -1px -1px -1px; border: 1px solid #FFFFFF; font-weight: bold;"></div>';
+ }
+ $new_notice .= '</div>' . $output;
+ if ($wgSiteNotice)
+ {
+ $new_notice .= '<div id="siteNotice">' . $wgSiteNotice;
+ }
+ else
+ {
+ $new_notice .= '<div>';
+ }
+ $wgSiteNotice = $new_notice;
+ }
+ }
+ }
+ }
+ return '';
+ }
+
+ return $output;
+}
+
+// ------------------------------------------------------------------------
+function kwBreadCrumbsError($msg)
+{
+ return "[kw_bread_crumbs] <b>Error</b>: " . htmlspecialchars($msg);
+}
+
+// ------------------------------------------------------------------------
+function kwBreadCrumbsNoCache()
+{
+ global $wgTitle, $wgOut;
+ if (!isset($wgTitle) || !isset($wgOut))
+ {
+ return;
+ }
+
+ /*
+ Let's 'touch' the page to invalidate its cache.
+ The code below is slightly identical to Title::invalidateCache().
+ Even though invalidateCache() sets cur_touched to 'now', we are still
+ in the process of creating and rendering the page itself and the
+ page will be cached only once it is done. At the end of the day the
+ cache would always end up newer than cur_touched, defeating the whole
+ purpose of calling invalidateCache().
+ The trick here is to set cur_touched in the future, something not too
+ intrusive, say 'now' + 120 seconds, provided that we expect the cached
+ page to be created within 120 secs after this extension code has been
+ executed. That way, cur_touched remains 'fresher' than the cache, and
+ the page is always re-created dynamically.
+ */
+
+ $ts = mktime();
+ $now = gmdate("YmdHis", $ts + 120);
+ $ns = $wgTitle->getNamespace();
+ $ti = wfStrencode($wgTitle->getDBkey());
+ $sql = "UPDATE page SET page_touched='$now' WHERE page_namespace=$ns AND page_title='$ti'";
+ wfQuery($sql, DB_WRITE, "kwBreadCrumbsNoCache");
+
+ // This does not seem to do anything. I assume once it's called here
+ // in the extension, it's already too late.
+
+ $wgOut->enableClientCache(false);
+
+ // The followings should prevent browsers to cache too long
+
+ /*
+ $wgOut->addMeta("http:Pragma", "no-cache");
+ $wgOut->addMeta("http:no-cache", NULL);
+ $wgOut->addMeta("http:EXPIRES", "TUES, 31 DEC 1996 12:00:00 GMT");
+ */
+
+ // HTTP_IF_MODIFIED_SINCE ? // see OutputPage: checkLastModified
+}
+
+// ------------------------------------------------------------------------
+function kwBreadCrumbsTAL()
+{
+ global $wgKwBreadCrumbs;
+ return kwBreadCrumbs(is_null($wgKwBreadCrumbs) ? '' : $wgKwBreadCrumbs);
+}
+
+?>
More information about the pLog-svn
mailing list