Source for file OCSP_AJAX.phpclass
Documentation is available at OCSP_AJAX.phpclass
* Class file OCSP_AJAX.phpclass
* thanx to the SAJAX project
* @project Open CSP-Management
* @author Peter Krebs (pk) <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
define('OCSP_AJAX_RQMODE_GET',"get");
define('OCSP_AJAX_RQMODE_POST',"post");
require_once dirname(__FILE__
).
_OCSP_DIRSEP_.
"OCSP_AJAX_FUNCTION.phpclass";
require_once __OCSP_PHPINCPATH__.
"common".
_OCSP_DIRSEP_.
"pcf_directory.phpinc";
require_once __OCSP_PHPINCPATH__.
"common".
_OCSP_DIRSEP_.
"OCSP_OBJ.phpclass";
require_once dirname(__FILE__
) .
_OCSP_DIRSEP_ .
"jOCSP_functions.phpinc";
* this class is designed to handle ajex requests
* @project Open CSP-Management
* @author Peter Krebs (pk) <p.krebs@amicas.at>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
/*** class constants --------------------------------------------- */
* @constant string CLASS_SRC_FILE
const CLASS_SRC_FILE = __FILE__
;
/*** class variables --------------------------------------------- */
/*** class methods --------------------------------------------- */
return (isset
($_SERVER['HTTP_X_REQUESTED_WITH']) &&
($_SERVER['HTTP_X_REQUESTED_WITH'] ==
'XMLHttpRequest'));
return (isset
($_GET['inToDiv']) &&
!empty($_GET['inToDiv']));
* @var array $functionLst the functions available (registered)
* @var array $done_funcLst the functions available (registered)
* @var string $objId the id of the ajax object
* @var array $valueLst values the functions uses
* @var string $jsAction the action used
* @var string $jsCode aditional code to include in on the page
* @var string $myClassSrcFile
* @var boolean $isCachable
* where to cache the object
* - session (cache the object data to the session)
* @var string $myCacheType
* array of cached objects
* @var array $myCacheObjects
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function OCSP_AJAX($aId=
"",$funcInc=
"",$debug=
FALSE) {
* if $this->objId is empty $_SERVER['UNIQUE
* if you use a special class to handle the ajax requests overwrite this methode
if (empty($this->objId)) {
if ($debug) echoDebug(__FILE__
,"<p style=\"padding-left:20px\">Generating objId: <b>".
$this->objId.
"</b></p>\n");
* sets the action uri (where the request is sent)
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* retuns a registered function or an pointer to an empty function in $this::functionLst
* @param string $func_name
* @returns OCSP_AJAX_FUNCTION
* @param string $func_name name of the php function to call
* @param string $func_include include file containing the $func_name
* @param array $func_args argument array to submit too
* @param string $rq_methode request methode (GET|POST)
* @returns OCSP_AJAX_FUNCTION
function ®isterFunction($func_name,$func_include=
"",$func_args=
NULL,$rq_methode=
OCSP_AJAX_RQMODE_GET,$debug=
FALSE) {
* @param string $func_name name of the php function to call
* @param string $frmName name of the formular (document.forms['$frmName'])
* @param string $func_include include file containing the $func_name
* @param array $func_args argument array to submit too
* @param string $rq_methode request methode (GET|POST)
* @returns OCSP_AJAX_FUNC_FRMSUBMIT
function ®isterFormSubmit($func_name,$frmName,$func_include,$func_args=
NULL,$rq_methode=
OCSP_AJAX_RQMODE_POST,$debug=
FALSE) {
require_once dirname(__FILE__
).
"/OCSP_AJAX_FUNC_FRMSUBMIT.phpclass";
$this->functionLst[$func_name]=
new OCSP_AJAX_FUNC_FRMSUBMIT($this,$func_name,$frmName,$func_include,$func_args,$rq_methode);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* javascript escape a value
* returns the js code for the function List
* @return string (javascript code)
foreach($this->functionLst as $s_funcName =>
&$o_function) {
$s_ret.=
$o_function->js_getFunction();
* returns the javascript for the object
$s_ret.=
"<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\n";
$s_ret.=
"// ajax js_getScript\n";
$s_ret.=
"// -->\n</script>\n";
* returns the javascript code for an ajax function argument
$str_ret=
"new ocspAjax_funcArg('MEN_ID',";
$str_ret.=
"'".
$this->js_esc($value).
"'";
* returns the javascript code for an ajax function argument list
* @param array $argList (array(varName => value))
foreach($argList as $str_name =>
$str_val)
* sets the http header for the ajax return
* @param string $contentType
function setHTTPheader($contentType=
"text/javascript",$charset=
"UTF-8")
header ("Expires: Mon, 26 Feb 2007 00:00:00 GMT"); // Date in the past
header ("Last-Modified: " .
gmdate("D, d M Y H:i:s") .
" GMT");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if (!empty($contentType) &&
!empty($charset))
header ("Content-Type: ".
$contentType.
"; charset=".
$charset);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* enables the object caching
* @param string cacheType
switch($cacheType) // check the type
echo
"<p>Cachetype: $cacheType NOT IMPLEMENTED<br>".__FILE__.
" Line: ".__LINE__.
" (".__CLASS__.
"::".__METHOD__.
")</p>\n";
* @todo OCSP_AJAX::cacheStore() use ocsp session
if (!is_array($_SESSION)) // session not startet -> start it
echo
"<p>Cachetype: $cacheType NOT IMPLEMENTED<br>".__FILE__.
" Line: ".__LINE__.
" (".__CLASS__.
"::".__METHOD__.
")</p>\n";
* @param string $cacheType
* @todo OCSP_AJAX::cacheLoad() use ocsp session
function cacheLoad($cacheType=
'session',$debug=
FALSE)
if (!is_array($_SESSION)) // session not startet -> start it
echo
"<p>Cachetype: $cacheType NOT IMPLEMENTED<br>".__FILE__.
" Line: ".__LINE__.
" (".__CLASS__.
"::".__METHOD__.
")</p>\n";
Documentation generated on Thu, 08 Jan 2009 17:45:06 +0100 by phpDocumentor 1.4.0a2