A php program called text-resizer is in the public domain and I've been using it on my desktop perfectly well. Also uploaded to my web site where it performs as expected whether accessed through the pc or the laptop.
Have installed wampserver 2 (freshly downloaded) onto the laptop and it comes up with an error when using exactly the same code as that on the pc.
Reported error:-
Undefined index: set_text in C:\Wamp\www\text-resizer.class.php on line 39
I can see nothing wrong with it and, as I say, it works perfectly well with the same version of wampserver on the pc.
Here's the code:
<?php
/*
*
* author:
kumar@chicagomodular.com* css help from Collin Olan <collin@staartje.com>
*
* Release: 2003-08-22
* License: Gnu Public License [
www.gnu.org]
*
*
Short Description: Resizes text on a page using styles and sessions.
Full Description: Thanks to the cascading nature of CSS, a simple font-size percentage can be included in the head of any page to facilite this text resizer. It will not disrupt any other attribute of your styles except the body's font size.
Directions: Instantiate this object on any page where you want to use the resizer, call ProcessTextReset(), and
reset the text size by passing query string variables: set_text=smaller, set_text=larger, or set_text=normal (the
class uses sessions to remember values). The font size is reset to a percentage of the default size of your user's
browser. It should be compatible with all of PHP 4; let me know if you find problems.
*
*/
class TextResizer
{
var $PercentageIncrement = 10;
var $TextPercentage;
function TextResizer()
{
session_start();
} // END function TextResizer()
function GetGetVar($VarName)
{
if(!empty($GLOBALS['HTTP_GET_VARS'][$VarName]))
$_GET[$VarName] = $GLOBALS['HTTP_GET_VARS'][$VarName];
return $_GET[$VarName];
} // END function GetGetVar($VarName)
function GetSessionVar($VarName)
{
if(!empty($GLOBALS['HTPP_SESSION_VARS'][$VarName]))
$_SESSION[$VarName] = $GLOBALS['HTPP_SESSION_VARS'][$VarName];
return $_SESSION[$VarName];
} // END function GetSessionVar($VarName)
function GetTextPercentage()
{
if(!empty($this->TextPercentage))
return $this->TextPercentage;
$this->TextPercentage = $this->GetSessionVar('TextPercentage');
if(!empty($this->TextPercentage))
return $this->TextPercentage;
$this->TextPercentage = 100;
return $this->TextPercentage;
} // END function GetTextPercentage()
# function PrintStyle()
#
# this style must be printed after any other styles are defined.
# It should not disrupt any other part of your style except the body's
# font size
function PrintStyle()
{
$TextPercentage = $this->GetTextPercentage();
$Style = <<<Style
<style type="text/css"> body { font-size: $TextPercentage%; } </style>
Style;
echo $Style;
} // END function PrintStyle()
function ProcessTextReset()
{
$SetText = $this->GetGetVar('set_text');
$TextPercentage = $this->GetTextPercentage();
if(empty($TextPercentage)) $TextPercentage = 100;
switch($SetText) {
case 'smaller':
$TextPercentage -= $this->PercentageIncrement; if(empty($TextPercentage)) $TextPercentage = 100;
if($TextPercentage <= 90) $TextPercentage = 90;
break;
case 'larger':
$TextPercentage += $this->PercentageIncrement;
if($TextPercentage >= 110) $TextPercentage = 110;
break;
case 'normal':
$TextPercentage = 100;
break;
} // END switch($SetText) {
$this->SetTextPercentage($TextPercentage);
} // END function ProcessTextReset()
function SetPercentageIncrement($PercentageIncrement)
{
$this->PercentageIncrement = $PercentageIncrement;
} // END function SetPercentageIncrement($PercentageIncrement)
function SetSessionVar($VarName,$Value)
{
if(isset($_SESSION))
$_SESSION[$VarName] = $Value;
else
$GLOBALS['HTTP_SESSION_VARS'][$VarName] = $Value;
} // END function SetSessionVar($VarName,$Value)
# function SetTextPercentage($TextPercentage)
#
# this method sets the percentage for the text, i.e. 100%
# If you want to give your users a static number of text percentage options
# you should create a new processing function like ProcessTextReset() to wrap
# around this function
function SetTextPercentage($TextPercentage)
{
$this->SetSessionVar('TextPercentage',$TextPercentage);
$this->TextPercentage = $TextPercentage;
} // END function SetTextPercentage($TextPercentage)
} // END class TextResizer
?>
Any advice much appreciated,
Ken