Preparing to remove the bundled PHPTAL and let the PHPTAL skins (if enabled) work...
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 20 Nov 2004 04:23:52 +0000 (04:23 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 20 Nov 2004 04:23:52 +0000 (04:23 +0000)
$wgUsePHPTal setting no longer exists; if a PHPTAL-based skin is used it will attempt to load PEAR+PHPTAL and gracefully disable itself if it can't.
Todo: get the list of skins in preferences to reflect this kind of disabling, so unselectable skins don't need to be moved into disabled subdir to be hidden.

includes/DefaultSettings.php
includes/SkinPHPTal.php
includes/SkinTemplate.php
maintenance/commandLine.inc
maintenance/liveCmdLine.inc
skins/SkinPHPTal.sample
skins/disabled/Amethyst.php
skins/disabled/Chick.php
skins/disabled/MonoBookTal.php
skins/disabled/WikimediaWiki.php

index 11c9cea..1d5c0fb 100644 (file)
@@ -608,17 +608,6 @@ $wgSVGConverters = array(
 $wgSVGConverter = 'ImageMagick'; # Pick one of the above
 $wgSVGConverterPath = ''; # If not in the executable PATH, specify
 
-# PHPTAL is a library for page templates. This is optional;
-# MediaWiki's internal skins no longer use it but you might
-# create your own custom skin using it.
-#
-# Use PHPTAL 0.7.0 for PHP 4.x or PHPTAL 1.0.0 for PHP 5.0.
-# http://phptal.sourceforge.net/
-#
-# Leave it off to avoid trying to load the template library
-# if you're not going to be using any such skins.
-$wgUsePHPTal = false;
-
 if( !isset( $wgCommandLineMode ) ) {
        $wgCommandLineMode = false;
 }
index 082e52f..a053203 100644 (file)
  * Based on Brion's smarty skin
  * Copyright (C) Gabriel Wicke -- http://www.aulinx.de/
  *
- * Todo: Needs some serious refactoring into functions that correspond
- * to the computations individual esi snippets need. Most importantly no body
- * parsing for most of those of course.
- * 
- * Set this in LocalSettings to enable phptal:
- * set_include_path(get_include_path() . ":" . $IP.'/PHPTAL-NP-0.7.0/libs');
- * $wgUsePHPTal = true;
+ * The guts of this have moved to SkinTemplate.php
+ *
+ * Make sure the appropriate version of PHPTAL is installed (0.7.0 for PHP4,
+ * or 1.0.0 for PHP5) and available in the include_path. The system PEAR
+ * directory is good.
+ *
+ * If PEAR or PHPTAL can't be loaded, it will try to gracefully fall back.
+ * Turn on MediaWiki's debug log to see it complain.
  *
  * @package MediaWiki
  * @subpackage Skins
@@ -42,15 +43,28 @@ require_once 'SkinTemplate.php';
 
 if( version_compare( phpversion(), "5.0", "lt" ) ) {
        define( 'OLD_PHPTAL', true );
-       global $IP;
-       require_once $IP.'/PHPTAL-NP-0.7.0/libs/PHPTAL.php';
+       # PEAR and PHPTAL 0.7.x must be installed and in include_path
 } else {
        define( 'NEW_PHPTAL', true );
-       # For now, PHPTAL 1.0.x must be installed via PEAR in system dir.
-       require_once 'PEAR.php';
-       require_once 'PHPTAL.php';
+       # PEAR and PHPTAL 1.0.x must be installed and in include_path
+}
+
+@include_once 'PEAR.php';
+if( !class_exists( 'PEAR' ) ) {
+       wfDebug( 'PHPTAL-based skin couldn\'t include PEAR.php' );
+} else {
+
+// PHPTAL may be in the libs dir direct, or under HTML/Template.
+// Try them both to be safe.
+@include_once 'HTML/Template/PHPTAL.php';
+if( !class_exists( 'PHPTAL' ) ) {
+       @include_once 'PHPTAL.php';
 }
 
+if( !class_exists( 'PHPTAL' ) ) {
+       wfDebug( 'PHPTAL-based skin couldn\'t include PHPTAL.php' );
+} else {
+
 /**
  *
  * @package MediaWiki
@@ -130,5 +144,7 @@ class PHPTAL_version_bridge {
        }
 }
 
+} // end of if( class_exists( 'PHPTAL' ) )
+} // end of if( class_exists( 'PEAR' ) )
 } // end of if( defined( 'MEDIAWIKI' ) ) 
 ?>
index 780ed17..8706e29 100644 (file)
  * to the computations individual esi snippets need. Most importantly no body
  * parsing for most of those of course.
  * 
- * PHPTAL support has been moved to a subclass in SkinPHPTal.php
- * Set this in LocalSettings to enable phptal:
- * set_include_path(get_include_path() . ":" . $IP.'/PHPTAL-NP-0.7.0/libs');
- * $wgUsePHPTal = true;
+ * PHPTAL support has been moved to a subclass in SkinPHPTal.php,
+ * and is optional. You'll need to install PHPTAL manually to use
+ * skins that depend on it.
  *
  * @package MediaWiki
  * @subpackage Skins
index 463366e..ce22a41 100644 (file)
@@ -140,7 +140,6 @@ $wgDBuser = $wgDBadminuser;
 $wgDBpassword = $wgDBadminpassword;
 
 
-$wgUsePHPTal = false;
 require_once( "Setup.php" );
 require_once( "install-utils.inc" );
 $wgTitle = Title::newFromText( "Command line script" );
index a3a28ca..529bf6f 100644 (file)
@@ -48,8 +48,6 @@ ini_set( "include_path", "/home/wikipedia/common/php-new:/home/wikipedia/common/
 
 require_once( "/home/wikipedia/common/php-new/CommonSettings.php" );
 
-$wgUsePHPTal = false;
-
 define("MEDIAWIKI",true);
 require_once( "Setup.php" );
 require_once( "../install-utils.inc" );
index a85702b..683c208 100644 (file)
@@ -1,27 +1,28 @@
 <?php
-# Test if PHPTal is enabled. If not MediaWiki will load the 'standard' skin
-# which doesnt use PHPTal
-if ($wgUsePHPTal) {
 require_once('includes/SkinPHPTal.php');
 
-# Your class extension is defined there.
-#
-# The class name MUST begin with 'Skin' and the rest is the name of the file
-# excluding '.php'
-# This file is named SkinPHPTal.sample (but it should end with php). So the
-# class name will be 'Skin' . 'SkinPHPTal'
-
-class SkinSkinPHPTal extends SkinPHPTal {
-       function initPage( &$out ) {
-               SkinPHPTal::initPage( $out );
-               $this->skinname = 'name of your skin all lower case';
-               $this->template = 'phptal template used do not put the .pt';
+# Test if PHPTal is enabled. If not MediaWiki will load the 'standard' skin
+# which doesnt use PHPTal
+if( class_exists( 'SkinPHPTal' ) ) {
+       
+       # Your class extension is defined there.
+       #
+       # The class name MUST begin with 'Skin' and the rest is the name of the file
+       # excluding '.php'
+       # This file is named SkinPHPTal.sample (but it should end with php). So the
+       # class name will be 'Skin' . 'SkinPHPTal'
+       
+       class SkinSkinPHPTal extends SkinPHPTal {
+               function initPage( &$out ) {
+                       SkinPHPTal::initPage( $out );
+                       $this->skinname = 'name of your skin all lower case';
+                       $this->template = 'phptal template used do not put the .pt';
+               }
+       
+       # Override method below
+       #
+       
        }
 
-# Override method below
-#
-
-}
-
 }
 ?>
index d5e6397..3bfaa18 100644 (file)
@@ -13,8 +13,8 @@
  */
 
 /** */
-if ($wgUsePHPTal) {
 require_once('includes/SkinPHPTal.php');
+if( class_exists( 'SkinPHPTal' ) ) {
 
 /**
  * See skin.doc
index f3e06f3..ee28850 100644 (file)
@@ -8,8 +8,8 @@
  */
 
 /** */
-if ($wgUsePHPTal) {
 require_once('includes/SkinPHPTal.php');
+if( class_exists( 'SkinPHPTal' ) ) {
 
 /**
  * See skin.doc
index d565122..bc0f121 100644 (file)
  */
 
 /** */
-if( defined( 'MEDIAWIKI' ) ) {
-
-global $wgUsePHPTal;
-if ($wgUsePHPTal) {
 require_once('includes/SkinPHPTal.php');
 
-/**
- * Inherit everything from SkinPHPTal
- * This is a dummy skin as MonoBook is the default PHPTal skin.
- * @todo document
- * @package MediaWiki
- * @subpackage Skins
- */
-class SkinMonoBookTal extends SkinPHPTal {
-       /** Using monobook. */
-       function initPage( &$out ) {
-               SkinPHPTal::initPage( $out );
-               $this->skinname  = 'monobooktal';
-               $this->stylename = 'monobook';
-               $this->template  = 'MonoBook';
+# Test if PHPTal is enabled. If not MediaWiki will load the 'standard' skin
+# which doesnt use PHPTal
+if( class_exists( 'SkinPHPTal' ) ) {
+       /**
+        * Inherit everything from SkinPHPTal
+        * This is a dummy skin as MonoBook is the default PHPTal skin.
+        * @todo document
+        * @package MediaWiki
+        * @subpackage Skins
+        */
+       class SkinMonoBookTal extends SkinPHPTal {
+               /** Using monobook. */
+               function initPage( &$out ) {
+                       SkinPHPTal::initPage( $out );
+                       $this->skinname  = 'monobooktal';
+                       $this->stylename = 'monobook';
+                       $this->template  = 'MonoBook';
+               }
        }
-}
-
-}
 
 }
 ?>
index 3e125b3..26ce0cc 100644 (file)
@@ -9,8 +9,8 @@
 
 /** */
 
-if($wgUsePHPTal) {
 require_once('includes/SkinPHPTal.php');
+if( class_exists( 'SkinPHPTal' ) ) {
 
 $wgExtraSkins['wikimediawiki'] = 'Wikimediawiki';