Commit e372dd69 authored by mcramer's avatar mcramer

Implemented:

 - javascript hooks prepared (onAfterContentLoad is first available hook)
 - new abstract class for GET and POST requests
 - new js.d directory that is included into main template
parent cab7ea5f
......@@ -61,52 +61,6 @@ class functions {
$app->ispcmail->send($to);
$app->ispcmail->finish();
/* left in here just for the case...
if($filepath != '') {
if(!file_exists($filepath)) $app->error("Mail attachement does not exist ".$filepath);
$content = file_get_contents($filepath);
$content = chunk_split(base64_encode($content));
$uid = strtoupper(md5(uniqid(time())));
$subject = "=?utf-8?B?".base64_encode($subject)."?=";
if($filename == '') {
$path_parts = pathinfo($filepath);
$filename = $path_parts["basename"];
unset($path_parts);
}
$header = "Return-Path: $from\nFrom: $from\nReply-To: $from\n";
if($cc != '') $header .= "Cc: $cc\n";
if($bcc != '') $header .= "Bcc: $bcc\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\n";
$header .= "--$uid\n";
$header .= "Content-Type: text/plain;\n\tcharset=\"UTF-8\"\n";
$header .= "Content-Transfer-Encoding: 8bit\n\n";
$header .= "$text\n";
$header .= "--$uid\n";
$header .= "Content-Type: $filetype; name=\"$filename\"\n";
$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment; filename=\"$filename\"\n\n";
$header .= "$content\n";
$header .= "--$uid--";
mail($to, $subject, "", $header);
} else {
$header = "From: $from\nReply-To: $from\n";
if($cc != '') $header .= "Cc: $cc\n";
if($bcc != '') $header .= "Bcc: $bcc\n";
$header .= "Content-Type: text/plain;\n\tcharset=\"UTF-8\"\n";
$header .= "Content-Transfer-Encoding: 8bit\n\n";
$subject = "=?utf-8?B?".base64_encode($subject)."?=";
mail($to, $subject, $text, $header);
}
*/
return true;
}
......
This diff is collapsed.
......@@ -60,6 +60,22 @@ if(isset($_SESSION['show_error_msg'])) {
unset($_SESSION['show_error_msg']);
}
// read js.d files
$js_d = ISPC_WEB_PATH . '/js/js.d';
$js_d_files = array();
if(@is_dir($js_d)) {
$dir = opendir($js_d);
while($file = readdir($dir)) {
$filename = $js_d . '/' . $file;
if($file === '.' || $file === '..' || !is_file($filename)) continue;
if(substr($file, -3) !== '.js') continue;
$js_d_files[] = array('file' => $file);
}
closedir($dir);
}
$app->tpl->setLoop('js_d_includes', $js_d_files);
unset($js_d_files);
$app->tpl_defaults();
$app->tpl->pparse();
......
......@@ -18,6 +18,7 @@ var requestsRunning = 0;
var indicatorPaddingH = -1;
var indicatorPaddingW = -1;
var indicatorCompleted = false;
var registeredHooks = new Array();
redirect = '';
function reportError(request) {
......@@ -28,6 +29,20 @@ function reportError(request) {
/*alert(request);*/
}
function registerHook(name, callback) {
if(!registeredHooks[name]) registeredHooks[name] = new Array();
var newindex = registeredHooks[name].length;
registeredHooks[name][newindex] = callback;
}
function callHook(name, params) {
if(!registeredHooks[name]) return;
for(var i = 0; i < registeredHooks[name].length; i++) {
var callback = registeredHooks[name][i];
callback(name, params);
}
}
function resetFormChanged() {
pageFormChanged = false;
}
......@@ -73,7 +88,9 @@ function hideLoadIndicator() {
}
}
function onAfterContentLoad() {
function onAfterContentLoad(url, data) {
if(!data) data = '';
else data = '&' + data;
<?php
if($server_config_array['misc']['use_combobox'] == 'y'){
?>
......@@ -81,6 +98,7 @@ if($server_config_array['misc']['use_combobox'] == 'y'){
<?php
}
?>
callHook('onAfterContentLoad', {'url': url, 'data': data });
}
function loadContentRefresh(pagename) {
......@@ -96,7 +114,7 @@ function loadContentRefresh(pagename) {
success: function(data, textStatus, jqXHR) {
hideLoadIndicator();
jQuery('#pageContent').html(jqXHR.responseText);
onAfterContentLoad();
onAfterContentLoad(pagename, "refresh="+document.getElementById('refreshinterval').value);
pageFormChanged = false;
},
error: function() {
......@@ -175,7 +193,7 @@ function submitLoginForm(formname) {
document.location.href = 'index.php';
} else {
jQuery('#pageContent').html(jqXHR.responseText);
onAfterContentLoad();
onAfterContentLoad('content.php', jQuery('#'+formname).serialize());
pageFormChanged = false;
}
loadMenus();
......@@ -213,7 +231,7 @@ function submitForm(formname,target) {
//window.setTimeout('loadContent(redirect)', 1000);
} else {
jQuery('#pageContent').html(jqXHR.responseText);
onAfterContentLoad();
onAfterContentLoad(target, jQuery('#'+formname).serialize());
pageFormChanged = false;
}
hideLoadIndicator();
......@@ -252,7 +270,7 @@ function submitFormConfirm(formname,target,confirmation) {
//window.setTimeout('loadContent(redirect)', 1000);
} else {
jQuery('#pageContent').html(jqXHR.responseText);
onAfterContentLoad();
onAfterContentLoad(target, jQuery('#'+formname).serialize());
pageFormChanged = false;
}
hideLoadIndicator();
......@@ -330,7 +348,7 @@ function loadContent(pagename) {
//jQuery.each(reponseScript, function(idx, val) { eval(val.text); } );
jQuery('#pageContent').html(jqXHR.responseText);
onAfterContentLoad();
onAfterContentLoad(pagename, (params ? params : null));
pageFormChanged = false;
}
hideLoadIndicator();
......@@ -357,7 +375,7 @@ function loadInitContent() {
loadContent(parts[1]);
} else {
jQuery('#pageContent').html(jqXHR.responseText);
onAfterContentLoad();
onAfterContentLoad('content.php', "s_mod=login&s_pg=index");
pageFormChanged = false;
}
hideLoadIndicator();
......
......@@ -18,6 +18,9 @@
<script type="text/javascript" src="js/uni-form/uni-form.jquery.js"></script>
<script type="text/javascript" src="js/jquery.ispconfigsearch.js"></script>
<script type="text/javascript" src="js/jquery.tipsy.js"></script>
<tmpl_loop name="js_d_includes">
<script type="text/javascript" src="js/js.d/<tmpl_var name='file'>"></script>
</tmpl_loop>
<script language="JavaScript" type="text/javascript">
jQuery(document).ready(function() {
loadInitContent();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment