From: Arne Heizmann Date: Sat, 14 Aug 2004 22:38:46 +0000 (+0000) Subject: New PHPtal-based skin 'Chick'. Designed for PDAs and other low-resolution devices. X-Git-Tag: 1.5.0alpha1~2346 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=af38689651a1251d0780281c94639593527cb35d;p=lhc%2Fweb%2Fwiklou.git New PHPtal-based skin 'Chick'. Designed for PDAs and other low-resolution devices. See non-whitespace-changing patch at http://bugzilla.wikipedia.org/show_bug.cgi?id=49 --- diff --git a/includes/Parser.php b/includes/Parser.php index 09fd92b7b5..49cda15e13 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -59,8 +59,8 @@ define( 'INVERSE_EXT_LINK_URL_CLASS', '[\]\\x00-\\x20\\x7F]' ); define( 'EXT_LINK_TEXT_CLASS', '[^\]\\x00-\\x1F\\x7F]' ); define( 'EXT_IMAGE_FNAME_CLASS', '[A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]' ); define( 'EXT_IMAGE_EXTENSIONS', 'gif|png|jpg|jpeg' ); -define( 'EXT_LINK_BRACKETED', '/\[(('.URL_PROTOCOLS.'):'.EXT_LINK_URL_CLASS.'+) *('.EXT_LINK_TEXT_CLASS.'*?)\]/S' ); -define( 'EXT_IMAGE_REGEX', +define( 'EXT_LINK_BRACKETED', '/\[(('.URL_PROTOCOLS.'):'.EXT_LINK_URL_CLASS.'+) *('.EXT_LINK_TEXT_CLASS.'*?)\]/S' ); +define( 'EXT_IMAGE_REGEX', '/^('.HTTP_PROTOCOLS.':)'. # Protocol '('.EXT_LINK_URL_CLASS.'+)\\/'. # Hostname and path '('.EXT_IMAGE_FNAME_CLASS.'+)\\.((?i)'.EXT_IMAGE_EXTENSIONS.')$/S' # Filename @@ -514,7 +514,7 @@ class Parser { # Showing subcategories $r .= '

' . wfMsg( 'subcategories' ) . "

\n"; - + $numchild = count( $children ); if($numchild == 1) { $r .= wfMsg( 'subcategorycount1', 1 ); @@ -522,7 +522,7 @@ class Parser $r .= wfMsg( 'subcategorycount' , $numchild ); } unset($numchild); - + if ( count ( $children ) > 6 ) { // divide list into three equal chunks @@ -577,7 +577,7 @@ class Parser $r .= ''; } } # END of if ( count($children) > 0 ) - + $r .= '

' . wfMsg( 'category_header', $ti ) . "

\n"; $numart = count( $articles ); @@ -869,7 +869,7 @@ class Parser $text = $this->doMagicLinks( $text ); $text = $this->replaceInternalLinks ( $text ); $text = $this->replaceInternalLinks ( $text ); - + $text = $this->unstrip( $text, $this->mStripState ); $text = $this->unstripNoWiki( $text, $this->mStripState ); @@ -882,7 +882,7 @@ class Parser $text .= $this->categoryMagic () ; $this->categoryMagicDone = true ; } - + wfProfileOut( $fname ); return $text; } @@ -1111,7 +1111,7 @@ class Parser $protocol = $bits[$i++]; $text = $bits[$i++]; $trail = $bits[$i++]; - + # If the link text is an image URL, replace it with an tag # This happened by accident in the original parser, but some people used it extensively $img = $this->maybeMakeImageLink( $text ); @@ -1124,11 +1124,11 @@ class Parser # No link text, e.g. [http://domain.tld/some.link] if ( $text == '' ) { # Autonumber if allowed - if ( strpos( HTTP_PROTOCOLS, $protocol ) !== false ) { + if ( strpos( HTTP_PROTOCOLS, $protocol ) !== false ) { $text = "[" . ++$this->mAutonumber . "]"; - } else { + } else { # Otherwise just use the URL - $text = htmlspecialchars( $url ); + $text = htmlspecialchars( $url ); } } else { # Have link text, e.g. [http://domain.tld/some.link text]s @@ -1138,14 +1138,18 @@ class Parser $trail = $m2[2]; } } - + $encUrl = htmlspecialchars( $url ); # Bit in parentheses showing the URL for the printable version if( $url == $text || preg_match( "!$protocol://" . preg_quote( $text, "/" ) . "/?$!", $url ) ) { $paren = ''; } else { # Expand the URL for printable version - $paren = " (" . htmlspecialchars ( $encUrl ) . ")"; + if ( ! $sk->suppressUrlExpansion() ) { + $paren = " (" . htmlspecialchars ( $encUrl ) . ")"; + } else { + $paren = ''; + } } # Process the trail (i.e. everything after this link up until start of the next link), @@ -1153,7 +1157,7 @@ class Parser $trail = $this->replaceFreeExternalLinks( $trail ); $la = $sk->getExternalLinkAttributes( $url, $text ); - + # Use the encoded URL # This means that users can paste URLs directly into the text # Funny characters like ö aren't valid in URLs anyway @@ -1181,7 +1185,7 @@ class Parser # Found some characters after the protocol that look promising $url = $protocol . $m[1]; $trail = $m[2]; - + # Move trailing punctuation to $trail $sep = ',;\.:!?'; # If there is no left bracket, then consider right brackets fair game too @@ -1211,7 +1215,7 @@ class Parser } return $s; } - + function maybeMakeImageLink( $url ) { $sk =& $this->mOptions->getSkin(); $text = false; diff --git a/includes/Skin.php b/includes/Skin.php index febacbcc19..bfda48b175 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -13,17 +13,18 @@ require_once( 'Image.php' ); # Language class has internationalized names # /* private */ $wgValidSkinNames = array( - 'standard' => 'Standard', - 'nostalgia' => 'Nostalgia', - 'cologneblue' => 'CologneBlue' + 'standard' => 'Standard', + 'nostalgia' => 'Nostalgia', + 'cologneblue' => 'CologneBlue' ); if( $wgUsePHPTal ) { - #$wgValidSkinNames[] = 'PHPTal'; - #$wgValidSkinNames['davinci'] = 'DaVinci'; - #$wgValidSkinNames['mono'] = 'Mono'; - $wgValidSkinNames['monobook'] = 'MonoBook'; - $wgValidSkinNames['myskin'] = 'MySkin'; - #$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal'; + #$wgValidSkinNames[] = 'PHPTal'; + #$wgValidSkinNames['davinci'] = 'DaVinci'; + #$wgValidSkinNames['mono'] = 'Mono'; + $wgValidSkinNames['monobook'] = 'MonoBook'; + $wgValidSkinNames['myskin'] = 'MySkin'; + #$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal'; + $wgValidSkinNames['chick'] = 'Chick'; } require_once( 'RecentChange.php' ); @@ -2790,6 +2791,9 @@ class Skin { return $toolbar; } + /* public */ function suppressUrlExpansion() { + return false; + } } } diff --git a/includes/SkinPHPTal.php b/includes/SkinPHPTal.php index 2c324a431e..4fe28c4210 100644 --- a/includes/SkinPHPTal.php +++ b/includes/SkinPHPTal.php @@ -634,5 +634,15 @@ if( defined( "MEDIAWIKI" ) ) { $this->skinname = "myskin"; } } + + class SkinChick extends SkinPHPTal { + function initPage( &$out ) { + SkinPHPTal::initPage( $out ); + $this->skinname = "chick"; + $this->template = "xhtml_minimal"; + } + function suppressUrlExpansion() { return true; } + function printSource() { return ""; } + } } ?>