?? pagebase.front.php
字號:
<?php
//error_reporting(E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE);
error_reporting(0);
//set_error_handler("my_handle_error");
require_once 'config.php';
require_once 'authentication.front.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('front'=>'mastertemplates/front_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 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->authLogin = '';
$this->form =& new HTML_QuickForm('frm','post');
$this->renderer =& new HTML_QuickForm_Renderer_Object();
$this->output =& new HTML_Template_Flexy($this->flexyOptions);
//if(isset($_REQUEST['msg']))
//$this->addMessage('Your Password has been Sent to You');
$this->auth = new Authentication($curFile,$this,$security,$userType);
if(!$this->auth->validUser())
{
if($this->auth->msg != '')
{
$this->addError($this->auth->msg);
}
$this->login();
}
$this->topNavArray['Home'] = 'home.php?cmd=List';
if($_SESSION['clientid'] !='1')
$this->topNavArray['Account Information'] = 'accountinfo.php?cmd=detailPage';
else
$this->topNavArray['Users'] = 'user.php?cmd=showList';
$row =& $this->db->getRow('user','id = '.$_SESSION['clientid']);
if($row['isappointments'])
$this->topNavArray['Appointments'] = 'appointment.php?cmd=showList';
if($row['iscontacts'])
$this->topNavArray['Contacts'] = 'contact.php?cmd=showList';
if($row['istasks'])
$this->topNavArray['Tasks'] = 'tasks.php?cmd=showList';
if($row['isnotes'])
$this->topNavArray['Notes'] = 'notes.php?cmd=showList';
if($row['iscustomers'])
$this->topNavArray['Customer Details'] = 'customer.php?cmd=showList';
if($row['isemail_mkt'])
$this->topNavArray['Email Marketing'] = 'email_mkt.php?cmd=showList';
$this->topNavArray['Logout'] = 'home.php?cmd=logout';
$this->authLogin = true;
$this->loginid = $this->auth->getLoginId();
$this->login_UserName = $this->auth->getLoginUserName();
if($this->loginid == '1')
$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');
case '8':
$this->addMessage('Email is Sent Successfully');
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 :');
$sql = 'SELECT * FROM type order by id desc';
$rs = $this->db->query($sql);
$tCount = $rs->numRows();
$logintype[''] = 'Please Select Type';
while($rs->fetchInto($row))
$logintype[$row['id']] = ucfirst($row['name']);
$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->addElement('link', 'st', '',APP_WEB_ROOT.'/forgotpassword.php','Forgot Password');
$this->form->addRule('logintype', 'Please Select Login Type', 'required','','client');
$this->form->setDefaults(array('cmd'=>'login'));
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';
/* //$msg = '';
$sql = 'SELECT * FROM messages WHERE status="1"';
$rs = $this->db->query($sql);
while($rs->fetchInto($row))
$this->globalMessages[] = $row;
//$this->globalMessages = $msg;
*/ $this->output->compile('mastertemplates/simpletemplate.html');
$this->output->outputObject($this);
die();
}
//--------------------------------------------------------
function addAction($name,$url,$class,$target='_self',$idName = '')
{
$this->listActions->add($name,$url,$class,$target,$idName);
$this->actionListFlag = $this->listActions->actionList;
}
function addError($err)
{
$this->errorList[$this->errCount] = $err;
$this->errCount++;
}
function addMessage($msg)
{
$this->messageList[$this->msgCount] = $msg;
$this->msgCount++;
// debug_var($this->messageList);
}
function debug_var($var)
{
print '<hr><pre>';
print_r($var);
print '</pre><hr>';
}
function displayPage($key='front')
{
$MasterContent = $this->master_tmp[$key];
//echo $MasterContent;die();
//$content='mastertemplates/front_master_tmp.html';
$this->output->compile($MasterContent);
$this->output->outputObject($this);
}
function showErrors()
{
foreach($this->errorList as $key=>$val)
{
print '<div class="error">'.$val.'</div>';
}
}
function showMessages()
{
foreach($this->messageList as $key=>$val)
{
print '<div class="message">'.$val.'</div>';
}
}
//----------------------------------------------------------------------
function removeAllElements()
{
if(isset($this->form->_elements))
foreach($this->form->_elements as $key=>$ele)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -