📄 pagebase.php
字号:
<?php
//error_reporting(E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE);
error_reporting(E_ALL);
//set_error_handler("my_handle_error");
require_once 'config.php';
require_once 'authentication.php';
require_once 'DB.php';
require_once 'HTML/QuickForm.php';
require_once('HTML/QuickForm/Renderer/Object.php');
require_once 'HTML/Template/Flexy.php';
require_once 'Pager/Sliding.php';
require_once 'listing.php';
require_once APP_DIR_ROOT.'/includes/mydb.php';
function debug_var($var)
{
print '<hr><pre>';
print_r($var);
print '</pre><hr>';
}
//###################################################################################################
function my_handle_error($r)
{
debug_var($r);
die(__FILE__.'<br />database error');
exit;
}
class PageBase
{
var $form;
var $db;
var $template = "";
var $template_form = "";
var $title= APP_TITLE;
var $subTitle='';
var $pageData = array();
var $controllerFile;
var $redirectUrl='';
var $contentTemplate;
var $renderer;
var $flexyOptions;
var $dirp;
var $output;
var $pageListTitles = array();
var $errorList = array();
var $messageList= array();
var $msgCount=0;
var $errCount=1;
var $message = 0;
var $APP_DIR_ROOT = APP_DIR_ROOT;
var $APP_WEB_ROOT = APP_WEB_ROOT;
var $APP_MODE = APP_MODE;
var $UPLOAD_WEB_ROOT = UPLOAD_WEB_ROOT;
var $listActions;
var $curCssCounter=1;
var $pagerLinks='';
var $master_tmp = array('admin'=>'mastertemplates/admin_master_tmp.html');
/* var $master_tmp = array('admin'=>'mastertemplates/admin_master_tmp.html',
'blank'=>'mastertemplates/blank.html',
'front'=>'mastertemplates/front_master_tmp.html');
*/
//-----------------------------------------------------------------------
function setTitle($str)
{
$this->subTitle = $str;
}
function getOrignalFile($path)
{
$ar = split('/',$path);
foreach($ar as $key=>$val)
{
$str = strstr($val,'.php');
if(!empty($str))
{
$val = str_replace('?','/',$val);
$cmdFind = strstr($val,'/');
if(!empty($cmdFind))
{
$arSub = split('/',$val);
return $arSub[0];
}
else
{
return $val;
}
}
}
}
function getActiveLink()
{
$curURL = $this->getOrignalFile($_SERVER['PHP_SELF']);
foreach($this->topNavArray as $text => $link)
{
if($curURL == $this->getOrignalFile($link))
{
return $text;
}
if(isset($this->linksChildArray[$text]))
{
foreach($this->linksChildArray[$text] as $textChild => $linkChild)
{
if($curURL == $this->getOrignalFile($linkChild))
{
return $textChild;
}
}
}
}
}
//-----------------------------------------------------------------------
function getAllignment($key)
{
if($key == 'Active')
return 'right';
return 'left';
}
function getBgColorMenu($menu)
{
// echo $this->activeLink.'<br />';
if($menu == $this->activeLink )
echo 'activeMenu';
else
echo 'InActiveMenu';
}
//-------------------------------------------------------------------------
function getChildMenuOf($child)
{
$this->childMenuArray = $this->linksChildArray[$child];
}
//-------------------------------------------------------------------------
function PageBase($curFile='',$security=true,$userType='dbuser')
{
$this->master_tmp = array('admin'=>'mastertemplates/admin_master_tmp.html',
'blank'=>'mastertemplates/blank.html',
'front'=>'mastertemplates/front_master_tmp.html');
$dsn = 'mysql://'.APP_DB_USER.':'.APP_DB_PASSWORD.'@'.APP_DB_HOST.'/'.APP_DB_DB;
$dbOptions = array('debug' => 2,'portability' => DB_PORTABILITY_ALL);
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK,'my_handle_error');
$this->db = new MyDb($this);
$this->flexyOptions = &PEAR::getStaticProperty('HTML_Template_Flexy','options');
$this->flexyOptions = array(
'templateDir' => $this->APP_DIR_ROOT.'/templates',
'compileDir' => $this->APP_DIR_ROOT.'/compiled_templates',
'forceCompile' => 0,
'debug' => 0,
'locale' => 'en',
'compiler' => 'Standard'
);
/*
$this->topNavArray['Home'] = 'home.php?cmd=List';
$this->topNavArray['Lead'] = 'lead.php?cmd=showList';
$this->topNavArray['Company'] = 'company.php?cmd=showList';
$this->topNavArray['Contacts'] = 'company_contacts.php?cmd=showHirList';
$this->topNavArray['V-Team'] = 'vteam.php?cmd=showHirList';
$this->topNavArray['Placement Opportunity'] = 'plop.php?cmd=showList';
$this->topNavArray['Employee'] = 'employee.php?cmd=showList&action=ListByDesignation';
$curEmpid = isset($_SESSION['employeeid']) ? $_SESSION['employeeid'] : '';
if($curEmpid != 'superadmin')
$this->topNavArray['My Account'] = 'my.account.php?cmd=updatePage';
$this->topNavArray['Employee Log'] = 'vteamemployees_log.php?cmd=showList';
$this->topNavArray['Roles'] = 'role.php?cmd=showList';
$this->topNavArray['Constants'] = 'admin/system_constants.php?cmd=showList';
$this->topNavArray['Logins'] = 'employee.login.php?cmd=showList';
// $this->topNavArray['Interviews Detail'] = 'interview.hir.list.php?cmd=showList';
// $this->topNavArray['Skills'] = 'skill.php?cmd=showList';
$this->topNavArray['Logout'] = 'lead.php?cmd=logout';
*/
$this->topNavArray['Home'] = 'admin/home.php?cmd=List';
// $this->topNavArray['Company'] = 'admin/company.php?cmd=showList';
$this->topNavArray['User'] = 'admin/user.php?cmd=showList';
//$this->topNavArray['Domain'] = 'admin/domain.php?cmd=showList';
//$this->topNavArray['Hosting'] = 'admin/hosting.php?cmd=showList';
//$this->topNavArray['Support Contract'] = 'admin/contract.php?cmd=showList';
//$this->topNavArray['Other Services'] = 'admin/otherservices.php?cmd=showList';
//$this->topNavArray['Support Tickets'] = 'admin/queries.php?cmd=showList';
//$this->topNavArray['Web Design'] = 'admin/webdesign.php?cmd=showList';
//$this->topNavArray['Global Messages'] = 'admin/globalmessages.php?cmd=showList';
$this->topNavArray['Logout'] = 'admin/home.php?cmd=logout';
$this->authLogin = '';
$this->form =& new HTML_QuickForm('frm','post');
$this->renderer =& new HTML_QuickForm_Renderer_Object();
$this->output =& new HTML_Template_Flexy($this->flexyOptions);
$this->auth = new Authentication($curFile,$this,$security,$userType);
if(!$this->auth->validUser())
{
if($this->auth->msg != '')
{
$this->addError($this->auth->msg);
}
$this->login();
}
$this->authLogin = true;
$this->loginid = $this->auth->getLoginId();
$this->login_UserName = $this->auth->getLoginUserName();
if($this->loginid == 'superadmin')
$this->superadmin=true;
$this->m_employeeRoles = $this->auth->getUserRoles();
$this->errCount = 0;
if(isset($_REQUEST['msg']))
{
$msg= intval($_REQUEST['msg']);
switch($msg)
{
case '1':
$this->addMessage('Record is Added Successfully');
break;
case 2:
$this->addMessage('Record is Updated Successfully');
break;
case '3':
$this->addMessage('Record is Deleted Successfully');
break;
case '4':
$this->addMessage('Record is Saved Successfully');
break;
case '5':
$this->addMessage('Image is Deleted Successfully');
break;
case '6':
$this->addMessage('File is Uploaded Successfully');
break;
case '7':
$this->addMessage('Password is Successfully Changed');
break;
default:
$this->message = 0;
}
}
$this->actionListFlag = array();
$this->listActions = new ActionArrayList();
}
//--------------------------------------------------------
function login()
{
$this->removeAllElements();
$this->subTitle='Please Login To Proceed';
$this->form =& new HTML_QuickForm('frmTest1', 'post');
$this->form->addElement('header','login','Login');
$this->form->addElement('text','username','User :');
$this->form->addElement('password','pwd','Password :');
$logintype = array (
'Admin' => 'admin',
'User' => 'user');
$this->form->addElement('select', 'logintype', array('Login Type:',''),$logintype);
$this->form->addElement('submit','action','Login',array('class'=>'button'));
$this->form->addElement('hidden','cmd','cmd');
$this->form->setDefaults(
array('cmd'=>'login',
'username' => '',
'pwd' => ''
));
echo '<script>
function setFocus()
{
var frm = document.getElementById(\'frmTest1\').username.focus();//frm is the form name present in PageBase
}
window.onload = setFocus;
</script>';
$this->contentTemplate = 'login.html';
$this->output->compile('mastertemplates/admin_simpletemplate.html');
$this->output->outputObject($this);
die();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -