aboutsummaryrefslogtreecommitdiffstats
path: root/mayor-orig/mayor-base/www/skin/ajax
diff options
context:
space:
mode:
authorM.Gergo2019-03-08 21:20:34 +0100
committerM.Gergo2019-03-08 21:20:34 +0100
commitf51c9ed2abe5c68211bb3736be5f70b1fe2c9ec0 (patch)
treee13e60e4b94a3b58f1e2bfbe271102c8f04b67bd /mayor-orig/mayor-base/www/skin/ajax
parentc76a004b0135786f2742283f8d5f917106f58bd8 (diff)
downloadmayor-f51c9ed2abe5c68211bb3736be5f70b1fe2c9ec0.tar.gz
mayor-f51c9ed2abe5c68211bb3736be5f70b1fe2c9ec0.zip
további rendrakás
Diffstat (limited to 'mayor-orig/mayor-base/www/skin/ajax')
-rw-r--r--mayor-orig/mayor-base/www/skin/ajax/base/html/alert.phtml25
-rw-r--r--mayor-orig/mayor-base/www/skin/ajax/base/html/base.phtml101
2 files changed, 126 insertions, 0 deletions
diff --git a/mayor-orig/mayor-base/www/skin/ajax/base/html/alert.phtml b/mayor-orig/mayor-base/www/skin/ajax/base/html/alert.phtml
new file mode 100644
index 00000000..e81b75ed
--- /dev/null
+++ b/mayor-orig/mayor-base/www/skin/ajax/base/html/alert.phtml
@@ -0,0 +1,25 @@
+<?php
+/*
+ Module: base
+
+ js_alert($alert)
+ html_alert($alert)
+
+ AJAX változat: csak akkor írja ki az alert-et, ha van $_GET['showAlert'] be van állítva...
+*/
+
+// ------------------------------------------------------------------- //
+// Az $alert két részből áll: típus:hiba //
+// típus: alert : javaScript alert //
+// message : hibaüzenet után az oldal betöltődik //
+// page : hibaüzenet után az oldal nem töltődik be //
+// info : információs üzenet //
+// ------------------------------------------------------------------- //
+ function html_alert($alert='') {
+
+ $_SESSION['alert'] = array();
+ return true;
+
+ }
+
+?> \ No newline at end of file
diff --git a/mayor-orig/mayor-base/www/skin/ajax/base/html/base.phtml b/mayor-orig/mayor-base/www/skin/ajax/base/html/base.phtml
new file mode 100644
index 00000000..cfa12036
--- /dev/null
+++ b/mayor-orig/mayor-base/www/skin/ajax/base/html/base.phtml
@@ -0,0 +1,101 @@
+<?php
+/*
+ Module: base
+
+ html_base($sessionID,$page,$sub,$f,$lang,$skin,$MENU)
+ html_head($page,$f,$lang,$skin)
+ html_mayor_head($sessionID,$page,$sub,$f,$lang,$MENU,$skin = 'default')
+ html_mayor_foot()
+ //page($page,$sub,$f,$lang,$skin) --> base.php
+ putValidXHTML()
+*/
+
+
+ /* Egy JSON példa
+ echo '{ "action" : [ '
+ .'{ "func" : "alert", "param" : [ "Helló", "World" ] }, '
+ .'{ "func" : "update", "param" : [ { "id" : "updateForm", "content" : "Helló Update" } ]}, '
+ .'{ "func" : "hide", "param" : [ "settings" ] },'
+ .'{ "func" : "show", "param" : [ "updateWindow" ] },'
+ .'{ "func" : "remove", "param" : [ "head" ] },'
+ .'{ "func" : "removeClass", "param" : [ { "id" : "jegy-1", "class" : "jegy1" } ] },'
+ .'{}],'
+ .' "name" : "Violet", "occupation" : "character" }';
+ */
+
+
+// -------------------------------------------------------------------
+// html_base() : a html oldal szerkezete
+// -------------------------------------------------------------------
+
+function html_base($sessionID,$policy,$page,$sub,$f,$lang,$skin,$MENU) {
+
+ global $_JSON;
+
+ if ($_JSON['result'] === false) @header("HTTP/1.1 400 Bad Request");
+ else @header("HTTP/1.1 200 OK");
+
+ @header('Content-type: application/json; charset=utf-8');
+ @header("Etag: ".__SALTVALUE.'-'.__SALTNAME.'-'.$_SESSION['mayorToken']); // ajax request esetén innen tudható a _SALTVALUE
+
+ _httpHeader();
+
+ if ( (!is_array($_JSON)?false:json_encode($_JSON)) === false) {
+ ob_start();
+ define('_UNIQUE', uniqid());
+ //echo '<div id="alertMsg'._UNIQUE.'"></div>';
+ page($page,$sub,$f,$lang,$skin,$policy);
+ $_JSON['html'] = ob_get_contents();
+ ob_end_clean();
+ }
+ if (is_array($_SESSION['alert']) && count($_SESSION['alert'])>0) {
+ for($i=0; $i<count($_SESSION['alert']); $i++) {
+
+ /* állítsuk össze a hibaüzenetet */
+ $_E = explode(':', $_SESSION['alert'][$i]);
+ $_JSON['alert'][] = $_E;
+ }
+ $_JSON['alertHTML'] = _html_base_alert($_SESSION['alert']); // UJ
+ }
+ echo json_encode($_JSON);
+ $_SESSION['alert'] = array();
+
+}
+
+function _html_base_alert($alert) {
+ if (is_array($alert))
+ foreach($alert as $a) {
+ $param = array();
+ $tmp = explode(':', $a);
+ $aType = readVariable($tmp[0], 'enum', 'message', array('message','info','page')); $aCode = $tmp[1];
+ for ($p = 2; $p < count($tmp); $p++) $param[] = htmlspecialchars($tmp[$p]);
+ $pstr = '';
+ // preparing $msg
+ if (!isset($ALERT_MSG[$aCode]) || $ALERT_MSG[$aCode] == '')
+ $msg = $ALERT_MSG['default'].' (<span class="alertParam">'.$aType.':'.$aCode.')</span>';
+ else $msg = $ALERT_MSG[$aCode];
+
+ // paraméter behelyettesítés
+ for($i = 0; $i < count($param); $i++) {
+ $_msg = $msg;
+ $msg = @str_replace("%$i%",'<span class="alertParam">'.($param[$i]).'</span>',$msg);
+ if ($param[$i] != '' and $_msg == $msg) $pstr .= '<span class="alertParam">'.($param[$i]).'</span>,';
+ }
+ if ($pstr != '') $msg .= ' (' . substr($pstr,0,-1) . ')';
+ if (($aType == 'message') or ($aType == 'page')) {
+ $title = _ERROR;
+ $class = 'errorMsg';
+ if ($aType == 'page') $showPage = false;
+ } else {
+ $title = _INFORMATION;
+ $class = 'infoMsg';
+ }
+ $msg = '<span>'.$title.':</span> ' . $msg;
+ $showPage .= '<div class="'.$class.'">'.str_replace('***','<br/>',$msg).'</div>'."\n";
+ }
+
+ return $showPage;
+
+}
+
+?>