* Bundled PHPTAL 0.7.0 from http://phptal.sourceforge.net/
(with some patches)
* Most image-related code moved to Image.php
+* More fixes for PHP 4.1.2 (thanks to Asheesh Laroia)
+* URL encoding fix for anchors
=== Caveats ===
}
}
+if( !function_exists('is_a') ) {
+ # Exists in PHP 4.2.0+
+ function is_a( $object, $class_name ) {
+ return
+ (strcasecmp( get_class( $object, $class_name ) == 0) ||
+ is_subclass_of( $object, $class_name ) );
+ }
+}
+
+# html_entity_decode exists in PHP 4.3.0+ but is FATALLY BROKEN even then,
+# with no UTF-8 support.
+function do_html_entity_decode( $string, $quote_style=ENT_COMPAT, $charset="ISO-8859-1" ) {
+ static $trans;
+ if( !isset( $trans ) ) {
+ $trans = array_flip( get_html_translation_table( HTML_ENTITIES, $quote_style ) );
+ # Assumes $charset will always be the same through a run, and only understands
+ # utf-8 or default. Note - mixing latin1 named entities and unicode numbered
+ # ones will result in a bad link.
+ if( strcasecmp( "utf-8", $charset ) == 0 ) {
+ $trans = array_map( "utf8_encode", $trans );
+ }
+ }
+ return strtr( $string, $trans );
+}
+
$wgRandomSeeded = false;
function wfSeedRandom()
/* private */ function formatHeadings( $text )
{
+ global $wgInputEncoding;
+
$doNumberHeadings = $this->mOptions->getNumberHeadings();
$doShowToc = $this->mOptions->getShowToc();
if( !$this->mTitle->userCanEdit() ) {
# strip out HTML
$canonized_headline = preg_replace( "/<.*?" . ">/","",$canonized_headline );
$tocline = trim( $canonized_headline );
- $canonized_headline = preg_replace("/[ \\?&\\/<>\\(\\)\\[\\]=,+']+/", '_', html_entity_decode( $tocline));
+ $canonized_headline = preg_replace("/[ \\?&\\/<>\\(\\)\\[\\]=,+']+/", '_', urlencode( do_html_entity_decode( $tocline, ENT_COMPAT, $wgInputEncoding ) ) );
$refer[$headlineCount] = $canonized_headline;
# count how many in assoc. array so we can track dupes in anchors
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# http://www.gnu.org/copyleft/gpl.html
+ require_once "GlobalFunctions.php";
require_once "PHPTAL.php";
class MediaWiki_I18N extends PHPTAL_I18N
# From text, such as what you would find in a link
/* static */ function newFromText( $text, $defaultNamespace = 0 )
{
- static $trans;
$fname = "Title::newFromText";
wfProfileIn( $fname );
- # Note - mixing latin1 named entities and unicode numbered
- # ones will result in a bad link.
- if( !isset( $trans ) ) {
- global $wgInputEncoding;
- $trans = array_flip( get_html_translation_table( HTML_ENTITIES ) );
- if( strcasecmp( "utf-8", $wgInputEncoding ) == 0 ) {
- $trans = array_map( "utf8_encode", $trans );
- }
- }
-
if( is_object( $text ) ) {
wfDebugDieBacktrace( "Called with object instead of string." );
}
- $text = strtr( $text, $trans );
+ global $wgInputEncoding;
+ $text = do_html_entity_decode( $text, ENT_COMPAT, $wgInputEncoding );
$text = wfMungeToUtf8( $text );