WeakWiki


lib\gui.library.php

WeakWiki (WeakWiki GUI support library: gui.library.php) Copyright (C) 2010 Alexander Lang This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . Project Home: http://weakwiki.robnet.wmweb.at/ Contact: robbiblubber@robnet.wmweb.at



/********************************************************************************
WeakWiki (WeakWiki GUI support library: gui.library.php)
Copyright (C) 2010 Alexander Lang

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this
program; if not, see .

Project Home: http://weakwiki.robnet.wmweb.at/
Contact:      robbiblubber@robnet.wmweb.at
********************************************************************************/



define('MSG_ERROR',   'error');
define('MSG_SUCCESS', 'success');



/** Helps to create a page menu.												*/
class PageMenu
{
	//////////////////////////////////////////////////////////////////////////////
	// protected members														//
	//////////////////////////////////////////////////////////////////////////////
	
	/** Page menu text.															*/
	protected $text;
	
	/** Padding value.															*/
	protected $pad;
	
	/** Determines, if modules should be integrated.							*/
	protected $mod;
	
	/** Determines, if menue should be right-aligned.							*/
	protected $right;
	
	
	//////////////////////////////////////////////////////////////////////////////
	// constructor																//
	//////////////////////////////////////////////////////////////////////////////
	
	/** Creates a new instance of the class.
		@param $pad			Padding value.
		@param $mod			Determines, if modules should be integrated.
		@param $right		Determines, if menue should be right-aligned.		*/
	public function __construct($pad = 110, $mod = true, $right = true)
	{
		$this->text  = "";
		$this->pad   = $pad;
		$this->mod   = $mod;
		$this->right = $right;
	}
	
	
	//////////////////////////////////////////////////////////////////////////////
	// public methods															//
	//////////////////////////////////////////////////////////////////////////////
	
	/** Adds a link to the menu.
		@param $link		Link.												*/
	public function add($link)
	{
		if($this->text == "") 
		{
			$this->text = $link;
		}
		else
		{
			$this->text .= ("  " . $link);
		}
	}
	
	
	/** Returns the HTML representation of the menu.
		@return				HTML code.											*/
	public function getHTML()
	{
		$rval = "";
		
		if($this->right)
		{
			$rval .= "

"; } else if($this->pad > 0) { $rval .= "pad . "px\"> "; } if($this->mod) { foreach($GLOBALS['mod_load'] as $mod) { $rval .= $mod->addToPageMenu(); } } $rval .= $this->text; if($this->right) { $rval .= "pad . "px\"> 

\n"; } return $rval; } /** Writes the page menu. */ public function write() { echo($this->getHTML()); } } /** This class generates a message box */ class MessageBox { ////////////////////////////////////////////////////////////////////////////// // protected members // ////////////////////////////////////////////////////////////////////////////// /** Title string. */ protected $title; /** Text string. */ protected $text; /** Type. */ protected $type; ////////////////////////////////////////////////////////////////////////////// // constructor // ////////////////////////////////////////////////////////////////////////////// /** Creates a new instance of the class. @param $title Message box title. @param $text Message box text. @param $txpe Message box type. */ public function __construct($title = "", $text = "", $type = MSG_SUCCESS) { $this->title = $title; $this->text = $text; $this->type = $type; } ////////////////////////////////////////////////////////////////////////////// // public methods // ////////////////////////////////////////////////////////////////////////////// /** Returns the message box title. @return Message box title. */ public function getTitle() { return $this->title; } /** Sets the message box title. @param $value Message box title. */ public function setTitle($value) { $this->title = $value; } /** Returns the message box text. @return Message box text. */ public function getText() { return $this->text; } /** Sets the message box text. @param $value Message box text. */ public function setText($value) { $this->text = $value; } /** Returns the message box type. @return Message box type. */ public function getType() { return $this->type; } /** Sets the message box type. @param $value Message box type. */ public function setType($value) { $this->type = $value; } /** Returns the HTML-representation of the message box. @return HTML code. */ public function getHTML() { return "

type . "\">
" . "
  " . $this->title . "
\n  " . $this->text . "

\n

\n"; } /** Writes the message box. */ public function write() { echo($this->getHTML()); } } ?>

WeakWiki