');
// This is for creating an area that users can hide and show
// It is logically made of 3 parts:
// (*) area is what gets hidden and shown
// (*) trigger is the area that can be clicked for toggling
// (*) image contains a visual indication of the current status
//
// constructor needs
// (*) id: an 'id', used for naming the three parts
// (*) trigger: the html text for the trigger
// (*) options: a hash that can define
// - trigger-tagname : to be used instead of for wrapping the trigger
// - bubble : might not work if trigger-tagname is redefined
// - init-hidden : start hidden rather than visible
//
// methods are as follows
// (*) trigger_html (): return the html code for the trigger
// (*) image_html (): returns the html code for the image
// (*) area_start (): because we have too many places where php 'prints' code: instead
// (*) area_end(): of returning it, we do not expect the code for the area to be passed
// so these methods can be used to delimit the area in question
class PlekitToggle {
// mandatory
var $id;
var $nifty;
var $info_div = "";
function PlekitToggle ($id,$trigger,$options=NULL) {
$this->id = $id;
$this->trigger=$trigger;
if ( ! $options ) $options = array();
if (array_key_exists ('visible',$options)) {
$options['start-hidden'] = ! $options['visible'];
unset ($options['visible']);
}
if (array_key_exists ('info_div',$options)) {
$this->info_div = $options['info_div'];
}
if (!isset ($options['start-hidden'])) $options['start-hidden']=false;
$this->options = $options;
}
// the simple, usual way to use it :
// a container that contains the switch and the area in sequence
function start () { print $this->start_html(); }
function start_html () {
$html = "";
$html .= $this->container_start();
$html .= $this->trigger_html();
$html .= $this->area_start_html();
return $html;
}
function end () { print $this->end_html(); }
function end_html () {
$html = "";
$html .= $this->area_end_html();
$html .= $this->container_end();
return $html;
}
// create two images that get shown/hidden - could not find a better way to do it
function image_html () {
$html="";
if ( ! $this->options['start-hidden']) { $x1=""; $x2=" style='display:none'"; }
else { $x2=""; $x1=" style='display:none'"; }
$image_id=$this->id_name('image-visible');
$html .= "id_name('image-hidden');
$html .= "trigger_html(); }
function trigger_html () {
$trigger_id=$this->id_name('trigger');
if (array_key_exists ('trigger-tagname',$this->options)) $tagname=$this->options['trigger-tagname'];
if (empty($tagname)) $tagname="span";
$bubble="";
if (array_key_exists ('bubble',$this->options)) $bubble=$this->options['bubble'];
$html="<$tagname";
$html .= " id='$trigger_id'";
$html .= " class='plc-toggle-trigger'";
if ($bubble) $html .= " title='$bubble'";
$html .= " onclick=\"plc_toggle('$this->id')\"";
$html .= ">";
$html .= $this->image_html();
$html .= $this->trigger;
$html .= "$tagname>";
if ($this->info_div != "")
$html .= " (info_div','$this->id')>?)";
return $html;
}
function area_start () { print $this->area_start_html(); }
function area_start_html () {
$area_id=$this->id_name('area');
$html="";
$html .= "