BeCastWebEngine/inc/panel.class.php

253 lines
7.2 KiB
PHP
Raw Normal View History

2025-06-20 19:10:23 +02:00
<?php
/**
* Project: BeCast Webengine - simple site engine
2025-06-20 20:13:51 +02:00
* File: /inc/panel.class.php
2025-06-20 19:10:23 +02:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.becast.at
2025-06-20 20:13:51 +02:00
* @copyright 2009-2025 becast.at
2025-06-20 19:10:23 +02:00
* @author Bernhard Jaud <bernhard at becast dot at>
2025-06-20 20:13:51 +02:00
* @package BcWe core
2025-06-20 19:10:23 +02:00
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
2025-06-20 20:13:51 +02:00
* @version $Id$
2025-06-20 19:10:23 +02:00
*/
$module["panel"]["name"]="Panel Class";
2025-06-20 20:13:51 +02:00
$module["panel"]["ver"]="0.3.5";
2025-06-20 19:10:23 +02:00
class panel {
var $sidebar="";
var $page="";
var $bodyext="";
var $title="";
var $content="";
var $meta="";
var $form="";
var $foot="";
var $head="";
var $menu_items ="";
function page($additional_title="",$meta=""){
global $config,$db,$core;
2025-06-20 20:13:51 +02:00
return '<!DOCTYPE html>
2025-06-20 19:10:23 +02:00
<html>
<head>
<title>'.$config['sitetitle'].'</title>
<link rel="stylesheet" type="text/css" href="admin.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
'.$this->meta.'
</head>
<body '.$this->bodyext.'>
<div id="container">
'.$this->menu().'
<div id="content">
'.$this->page.'
</div>
<div id="footer">
&copy; 2016 - 2025 Becast.at | mySQL Queries: '.$db->querys().'
<br/>
Powered by
<a href="http://www.becast.at">BeCast WebEngine</a>
'.$core->ver_major.'.'.$core->ver_minor.".".$core->ver_rev.' - '.$core->ver_codename.'
</div>
</div>
'.$this->foot.'
</body>
</html>';
}
function parse_page(){
$this->page.="<h2>".$this->title."</h2>
<p>".$this->content."</p>";
$this->title="";
$this->content="";
echo $this->page();
exit();
}
function menu_item($panel,$text, $img=""){
global $config, $userdata, $userinfo, $session, $meta;
if($panel=="group_only"){
$this->menu_items.="<li><strong>".$text."</strong></li>";
}elseif($panel=="admin_home"){
$this->menu_items.="<li><a href=\"".$config["path"]."/admin/index.php\"><img src=\"".$config["path"]."/admin/images/icons/".$img.".png\" /> ".$text."</a></li>";
}elseif($panel=="page_home"){
$this->menu_items.="<li><a href=\"".$config["path"]."/index.php\"><img src=\"".$config["path"]."/admin/images/icons/".$img.".png\" /> ".$text."</a></li>";
}else{
if($img!=""){
$this->menu_items.="<li><a href=\"".$config["path"]."/admin/index.php?panel=".$panel."\"><img src=\"".$config["path"]."/admin/images/icons/".$img.".png\" /> ".$text."</a></li>";
}else{
$this->menu_items.="<li><a href=\"".$config["path"]."/admin/index.php?panel=".$panel."\">".$text."</a></li>";
}
}
}
function admin_message($title,$message,$redirect=FALSE,$panel="",$time="4"){
global $config,$session,$lang;
$session->page_begin("Admin Message", True);
if($panel!="" && $redirect){
$this->content=$message."<br /><a href=\"".$config["path"]."/admin/index.php?panel=".$panel."\">".$lang->_('CLICKREDIRECT')."</a>";
}elseif($panel!="" && !$redirect){
$this->content=$message."<br /><a href=\"".$config["path"]."/admin/index.php?panel=".$panel."\">".$lang->_('CLICKCONTINUE')."</a>";
}else{
$this->content=$message;
}
if($redirect && $panel!="")
$this->meta.="<meta http-equiv=\"refresh\" content=\"".$time."; URL=".$config["path"]."/admin/index.php?panel=".$panel."\" />";
$this->title=$title;
$this->parse_page();
}
function menu(){
return '<div id="menu">
<ul>'.$this->menu_items.'</ul></div>';
}
function form ($args = array(),$return=FALSE,$extra=""){
$method = $args["method"] ? $args["method"] : 'post';
$action = $args["action"] ? $args["action"] : $_SERVER['PHP_SELF'];
$form = '<form action="' .$action. '" method="' .$method. '"' .$extra. '>';
if(!$return){
$this->content .= $form;
}else{
return $form;
}
}
function formClose ()
{
$form = '</form>';
if(!$return){
$this->content .= $form;
}else{
return $form;
}
}
function button ($text = '', $name='', $extra='', $return=FALSE)
{
$fld = '<input type="button" name="'.$name.'" value="'.$text.'" ' .$extra. ' />';
if(!$return){
$this->content .= $fld;
}else{
return $fld;
}
}
function radio ($args=array(),$extra="",$return=FALSE)
{
$name = $args["name"] ? $args["name"] : 'radiobutton';
$value = $args["value"];
if($value!=""){
$extra .= ' value="'.$value.'"';
}
$fld=$this->radioOrCheck ("radio",$name,$extra,$return);
if($return){
return $fld;
}
}
function checkbox ($args=array(),$extra="",$return=FALSE)
{
$name = $args["name"] ? $args["name"] : 'checkbox';
$value = $args["value"];
if($value!=""){
$extra .= ' value="'.$value.'"';
}
$fld=$this->radioOrCheck ("checkbox",$name,$extra,$return);
if($return){
return $fld;
}
}
/* private */
function radioOrCheck ($type,$name="",$extra="",$return=FALSE)
{
$fld = '<input type="'.$type.'" name="'.$name.'" ' .$extra. ' />';
if(!$return){
$this->content .= $fld;
}else{
return $fld;
}
}
function field ($args=array(),$extra="",$return=FALSE)
{
$typ = $args["typ"] ? $args["typ"] : 'text';
$name = $args["name"] ? $args["name"] : 'textfield';
$value = $args["value"] ? $args["value"] : '';
$fld = '<input type="' .$typ. '" name="' .$name. '" value="' .$value. '"' .$extra. ' />'; // html: form field
if(!$return){
$this->content .= $fld;
}else{
return $fld;
}
}
function submit ($args=array(),$extra="",$return=FALSE)
{
$name = $args["name"] ? $args["name"] : 'submit';
$fld = '<input type="submit" name="'.$name.'" ' .$extra. ' />'; // html: form submit button
if(!$return){
$this->content .= $fld;
}else{
return $fld;
}
}
/*
$args[value] used for default text (as in "field" function)
*/
function textarea ($args = array(),$extra="",$return=FALSE)
{
$name = $args["name"] ? $args["name"] : 'field';
$rows = $args["rows"] ? $args["rows"] : '3';
$cols = $args["cols"] ? $args["cols"] : '30';
$text = $args["value"] ? $args["value"] : '';
$fld = '<textarea name="' .$name. '" rows="' .$rows. '" cols="' .$cols. '"' .$extra. '>' .$text. '</textarea>';
if(!$return){
$this->content .= $fld;
}else{
return $fld;
}
}
/*
$values = array containing values (key = processing value, data = displaying value)
*/
function select ($values=array(),$selected="",$name="",$extra="",$return=FALSE)
{
$fld='<select name="'.$name.'" '.$extra.'>';
foreach($values as $name=>$val){
if($val==$selected){
$fld.='<option value="'.$val.'" selected="selected">'.$name.'</option>';
}else{
$fld.='<option value="'.$val.'">'.$name.'</option>';
}
}
$fld.="</select>";
if(!$return){
$this->content .= $fld;
}else{
return $fld;
}
}
}
?>