* @copyright 2001-2006 VIKO team and contributors * @license http://www.gnu.org/licenses/gpl.html GPL 2.0 */ /** * Uses the {@link Configuration} class to access configuration */ require_once 'Configuration.php'; /** * VIKO page * * Possible usage: * *
* $page = new VIKO();
* $page->setTitle("VIKO Hello");
* $page->setContent("Hello, world of VIKO!");
* echo $page->toHTML();
*
*/
class VIKO {
/**#@+
* @access private
* @var string
*/
/**
* Title following the VIKO logo
*/
var $_environment_title="";
/**
* Title of the page
*/
var $_title="--noname--";
/**
* Contents of the page (in HTML format)
*/
var $_content="--empty--";
/**
* The Identifier of active VIKO module
*/
var $_module_id="front-page";
/**
* Stylesheets associated with the page
*/
var $_stylesheets = "";
/**#@-*/
/**
* Navigation menu
*
* @access private
* @var array
*/
var $_nav = array();
/**
* Constructs new VIKO instance
*/
function VIKO()
{
$this->_environment_title = _("learning environment");
$this->addStylesheet("/css/layout.css");
}
/**
* Sets the general VIKO environment, based on user group
*
* For example, if the user group is "STUDENT", the VIKO header will say:
* "VIKO student environment".
*
* @access public
* @param string $user_group the group of the user.
* only 4 values are allowed: STUDENT, TEACHER, SCHOOLADMIN and ADMIN.
* If the parameter is unspecified, no special title will be generated.
*/
function setEnvironment( $user_group="" )
{
switch ($user_group) {
case "": $this->_environment_title = _("learning environment");
break;
case "STUDENT": $this->_environment_title = _("student environment");
break;
case "TEACHER": $this->_environment_title = _("teacher environment");
break;
case "SCHOOLADMIN": $this->_environment_title = _("school administrator environment");
break;
case "ADMIN": $this->_environment_title = _("administrator environment");
break;
default: trigger_error("Unknown user group '$user_group'", E_USER_ERROR);
}
}
/**
* Sets the title of VIKO page
*
* @access public
* @param string $title title of the page.
*/
function setTitle( $title )
{
$this->_title = $title;
}
/**
* Sets the Identifier of current VIKO module
*
* The {@link $module_id} will be used as a value for the 'id' attribute
* of the 'body' element. For example:
*
*
* $viko->setModuleID("about");
* // will also output a body tag like: <body id="about">
* echo $viko->toHTML();
*
*
* @access public
* @param string $module_id ID of module
*/
function setModuleID( $module_id )
{
$this->_module_id = $module_id;
}
/**
* Adds a stylesheet to VIKO page
*
* @access public
* @param string $uri address of the CSS file
* @param string $media CSS media type (or list of types, separated by commas)
* @param string $rel either "stylesheet" or "alternate stylesheet"
*/
function addStylesheet( $uri, $media="all", $rel="stylesheet")
{
$this->_stylesheets .= <<
{$this->_environment_title}{$copyright}