modular sidebanners refactoring side-refactoring 4.14.5
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Sat, 16 Aug 2014 11:32:44 +0000 (13:32 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Sat, 16 Aug 2014 11:34:05 +0000 (13:34 +0200)
web/Obj/brisk.conf-templ.pho
web/Obj/brisk.phh
web/Obj/sac-a-push.phh
web/commons.js
web/index.php

index 034dee7..92fe8ee 100644 (file)
@@ -59,21 +59,24 @@ Torneo di briscola<br> chiamata - Milano<br> 17/05/2008</a>
 </div>
 <img class="nobohide" id="topbanner_big" src="img/bcm_tor080517.gif">';
 
-// is the first side banner active ?
-$G_with_sidebanner = TRUE;
-
-$G_sidebanner = '<div class="topbanner" style="background: #ffd780; border: solid 1px #ffae00; width: 60px; margin: auto;" id="sidebanner2">
-<a target="_blank" href="briskmeeting4.php">
-<img style="position: static; border: solid 0px black;" src="img/brisk_meeting_trinacria60b.png"  onMouseOver="show_bigpict($(\'sidebanner2\'), \'over\', 100, -80, \'\');" onMouseOut="show_bigpict($(\'sidebanner2\'), \'out\', 0, 0, \'\');"></div>
-<img class="nobohide" id="sidebanner2_big" src="img/brisk_meeting4big150.png">';
-
-// is the second side banner active ?
-$G_with_sidebanner2 = TRUE;
-
-$G_sidebanner2 = '<div class="topbanner" style="background: #ffd780; border: solid 1px #ffae00; width: 60px; margin: auto;" id="sidebanner2">
-<a target="_blank" href="briskmeeting4.php">
-<img style="position: static; border: solid 0px black;" src="img/brisk_meeting_trinacria60b.png"  onMouseOver="show_bigpict($(\'sidebanner2\'), \'over\', 100, -80, \'\');" onMouseOut="show_bigpict($(\'sidebanner2\'), \'out\', 0, 0, \'\');"></div>
-<img class="nobohide" id="sidebanner2_big" src="img/brisk_meeting4big150.png">';
+$G_sidebanner_idx = array( 0, 1, 0 );
+
+// sidebanners array
+$G_sidebanner = array(
+                      array('link' => 'http://www.alternativeoutput.it/brisk/bm33/',
+                            'title' => '3° BriskMeeting \'Isola delle Femmine\' - Sabato 11 Ottobre 2014 - Palermo (PA)',
+                            'icon_big' => 'bm33/img/bm33_500.jpg'
+                            // 'type' => 'meeting' or 'event'      // (default meeting with the correct icon)
+                            // 'icon' => 'img/brisk_meeting60.gif' // (default is the regulare meeting icon)
+                            // 'dx'
+                            // 'dy'                                // displacement of the big image
+                            ),
+
+                      array('link' => 'https://www.facebook.com/events/525109597594103/',
+                            'title' => 'BriskMeeting Busseto - Terra di Verdi - Sabato 4 Ottobre - Busseto (Parma)',
+                            'icon_big' => 'bm32/img/splash.jpg'
+                            )
+                      );
 
 // is poll active ?
 $G_with_poll = FALSE;
index 3d94f65..391f0a8 100644 (file)
@@ -151,12 +151,12 @@ $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi',
 $G_lng = langtolng($G_lang);
 
 $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "4.14.4";
+$G_brisk_version = "4.14.5";
 
 /* MLANG: ALL THE INFO STRINGS IN brisk.phh */
-$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: nuovo sistema di registrazione degli utenti, aggiunto reinvio dell\' email di verifica, ban con classi di IP, nuovi colori',
+$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: nuovo sistema di registrazione degli utenti, aggiunto reinvio dell\' email di verifica, ban con classi di IP, nuovi colori, nuovo sistema bi banner laterali per gli eventi',
                                        'Se vuoi iscriverti alla <a target="_blank" href="mailto:ml-briscola+subscribe@milug.org">Mailing List</a>, cliccala!' ),
-                       'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: new users subscription system.',
+                       'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: new users subscription system, refactored sidebanner system.',
                                        'If you want to subscribe our <a target="_blank" href="ml-briscola+subscribe@milug.org">Mailing List</a>, click it!' ) );
 
 $G_room_help = array( 'it' => '
index 44ef8ad..3f4f6c8 100644 (file)
@@ -35,11 +35,11 @@ function global_dump()
     GLOBAL $G_alarm_passwd, $G_ban_list, $G_black_list, $G_btrace_pref_sub, $G_dbauth;
     GLOBAL $G_dbpfx, $G_donors_all, $G_donors_cur, $G_is_local, $G_lang;
     GLOBAL $G_poll_entries, $G_poll_name, $G_poll_title, $G_proxy_white_list;
-    GLOBAL $G_room_roadmap, $G_shutdown, $G_sidebanner, $G_sidebanner2;
+    GLOBAL $G_room_roadmap, $G_shutdown;
     GLOBAL $G_splash_content, $G_splash_contents, $G_splash_cont_idx;
     GLOBAL $G_splash_h, $G_splash_idx, $G_splash_interval, $G_splash_timeout;
     GLOBAL $G_splash_w, $G_topbanner, $G_with_donors, $G_with_poll;
-    GLOBAL $G_with_sidebanner, $G_with_sidebanner2, $G_with_splash;
+    GLOBAL $G_with_splash, $G_sidebanner, $G_sidebanner_idx;
     GLOBAL $G_with_topbanner;
 
     fprintf(STDERR, "G_alarm_passwd = [%s]\n", print_r($G_alarm_passwd, TRUE));
@@ -58,8 +58,6 @@ function global_dump()
     fprintf(STDERR, "G_proxy_white_list = [%s]\n", print_r($G_proxy_white_list, TRUE));
     fprintf(STDERR, "G_room_roadmap = [%s]\n", print_r($G_room_roadmap, TRUE));
     fprintf(STDERR, "G_shutdown = [%s]\n", print_r($G_shutdown, TRUE));
-    fprintf(STDERR, "G_sidebanner = [%s]\n", print_r($G_sidebanner, TRUE));
-    fprintf(STDERR, "G_sidebanner2 = [%s]\n", print_r($G_sidebanner2, TRUE));
     fprintf(STDERR, "G_splash_content = [%s]\n", print_r($G_splash_content, TRUE));
     fprintf(STDERR, "G_splash_contents = [%s]\n", print_r($G_splash_contents, TRUE));
     fprintf(STDERR, "G_splash_cont_idx = [%s]\n", print_r($G_splash_cont_idx, TRUE));
@@ -71,8 +69,8 @@ function global_dump()
     fprintf(STDERR, "G_topbanner = [%s]\n", print_r($G_topbanner, TRUE));
     fprintf(STDERR, "G_with_donors = [%s]\n", print_r($G_with_donors, TRUE));
     fprintf(STDERR, "G_with_poll = [%s]\n", print_r($G_with_poll, TRUE));
-    fprintf(STDERR, "G_with_sidebanner = [%s]\n", print_r($G_with_sidebanner, TRUE));
-    fprintf(STDERR, "G_with_sidebanner2 = [%s]\n", print_r($G_with_sidebanner2, TRUE));
+    fprintf(STDERR, "G_sidebanner = [%s]\n", print_r($G_sidebanner, TRUE));
+    fprintf(STDERR, "G_sidebanner_idx = [%s]\n", print_r($G_sidebanner_idx, TRUE));
     fprintf(STDERR, "G_with_splash = [%s]\n", print_r($G_with_splash, TRUE));
     fprintf(STDERR, "G_with_topbanner = [%s]\n", print_r($G_with_topbanner, TRUE));
 }
@@ -625,11 +623,11 @@ class Sac_a_push {
         GLOBAL $G_alarm_passwd, $G_ban_list, $G_black_list, $G_btrace_pref_sub, $G_dbauth;
         GLOBAL $G_dbpfx, $G_donors_all, $G_donors_cur, $G_is_local, $G_lang;
         GLOBAL $G_poll_entries, $G_poll_name, $G_poll_title, $G_proxy_white_list;
-        GLOBAL $G_room_roadmap, $G_shutdown, $G_sidebanner, $G_sidebanner2;
+        GLOBAL $G_room_roadmap, $G_shutdown;
         GLOBAL $G_splash_content, $G_splash_contents, $G_splash_cont_idx;
         GLOBAL $G_splash_h, $G_splash_idx, $G_splash_interval, $G_splash_timeout;
         GLOBAL $G_splash_w, $G_topbanner, $G_with_donors, $G_with_poll;
-        GLOBAL $G_with_sidebanner, $G_with_sidebanner2, $G_with_splash;
+        GLOBAL $G_with_splash, $G_sidebanner, $G_sidebanner_idx;
         GLOBAL $G_with_topbanner;
         GLOBAL $G_tos_vers, $G_tos_fname, $G_tos_dtsoft, $G_tos_dthard, $G_tos_idx, $G_doc_path;
 
index 09129c3..1563ec8 100644 (file)
@@ -1228,38 +1228,20 @@ function topbanner_cb()
     // console.log("A: "+a+"  B: "+b);
 }
 
-function sidebanner_init()
+function sidebanner_init(idx)
 {
-    setInterval(sidebanner_cb, 666);
+    setInterval(function () { sidebanner_cb(idx); }, 666);
 }
 
-function sidebanner2_init()
-{
-    setInterval(sidebanner2_cb, 666);
-}
-
-function sidebanner_cb()
-{
-    var a, b;
-
-    a = $('sidebanner').style.backgroundColor;
-    b = $('sidebanner').style.borderLeftColor;
-
-    $('sidebanner').style.backgroundColor = b;
-    $('sidebanner').style.borderColor = a+" "+a+" "+a+" "+a;
-
-    // console.log("A: "+a+"  B: "+b);
-}
-
-function sidebanner2_cb()
+function sidebanner_cb(idx)
 {
     var a, b;
 
-    a = $('sidebanner2').style.backgroundColor;
-    b = $('sidebanner2').style.borderLeftColor;
+    a = $('sidebanner'+idx).style.backgroundColor;
+    b = $('sidebanner'+idx).style.borderLeftColor;
 
-    $('sidebanner2').style.backgroundColor = b;
-    $('sidebanner2').style.borderColor = a+" "+a+" "+a+" "+a;
+    $('sidebanner'+idx).style.backgroundColor = b;
+    $('sidebanner'+idx).style.borderColor = a+" "+a+" "+a+" "+a;
 
     // console.log("A: "+a+"  B: "+b);
 }
index 6e45cb0..c53bc95 100644 (file)
@@ -237,12 +237,71 @@ function poll_dom() {
     return '';
 }
 
+function sidebanners_init($sidebanner_idx)
+{
+    for ($i = 0 ; $i < count($sidebanner_idx) ; $i++) {
+        printf("     sidebanner_init(%d);\n", $i);
+    }
+}
+
+function sidebanners_render($sidebanner, $sidebanner_idx)
+{
+    $sb_n = count($sidebanner_idx);
+    if ($sb_n == 0) {
+        return;
+    }
+
+    if ($sb_n == 1) {
+        printf("<br><br>");
+    }
+
+    for ($i = 0 ; $i < $sb_n ; $i++) {
+        $idx = $sidebanner_idx[$i];
+        $sb  = $sidebanner[$idx];
+        if (!array_key_exists('link', $sb)
+            || !array_key_exists('title', $sb)
+            || !array_key_exists('icon_big', $sb)) {
+            continue;
+        }
+        $sb_type = (array_key_exists('type', $sb) ? $sb['type'] : 'meeting');
+        if (array_key_exists('icon', $sb)) {
+            $sb_icon = $sb['icon'];
+        }
+        else {
+            if ($sb_type == 'meeting') {
+                if ($sb_n < 3) {
+                    $sb_icon = 'img/brisk_meeting60.gif';
+                }
+                else {
+                    $sb_icon = 'img/brisk_meeting35.gif';
+                }
+            }
+            else {
+                // no standard icon for other type of events please add them
+                continue;
+            }
+        }
+        $sb_dx =  (array_key_exists('dx', $sb) ? $sb['dx'] : 100);
+        $sb_dy =  (array_key_exists('dy', $sb) ? $sb['dy'] : -230);
+
+        printf('<div class="sidebanner" style="background: #ffd780; border: solid 1px #ffae00; width: 60px;" id="sidebanner%d">', $i);
+        printf('<a target="_blank" href="%s">', $sb['link']);
+        printf('<img style="position: static; border: solid 0px black;" src="%s"', $sb_icon);
+        printf('  onMouseOver="show_bigpict($(\'sidebanner%d\'), \'over\', %d, %d, \'\');"', $i, $sb_dx, $sb_dy);
+        printf('  onMouseOut="show_bigpict($(\'sidebanner%d\'), \'out\', 0, 0, \'\');"', $i);
+        $tit = eschtml($sb['title']);
+        printf('  alt="%s" title="%s"></a></div>', $tit, $tit);
+        printf("\n");
+        printf('<img class="nobohide" style="z-index: 255; border: 1px solid gray;" id="sidebanner%d_big" src="%s">', $i, $sb['icon_big']);
+        printf("\n");
+    }
+}
+
 function index_main(&$brisk, $transp_type, &$header_out, $remote_addr_full, $get, $post, $cookie)
 {
     GLOBAL $G_with_donors, $G_donors_cur, $G_donors_all;
     GLOBAL $G_with_topbanner, $G_topbanner, $G_is_local;
-    GLOBAL $G_with_sidebanner, $G_sidebanner;
-    GLOBAL $G_with_sidebanner2, $G_sidebanner2;
+    GLOBAL $G_sidebanner, $G_sidebanner_idx;
     GLOBAL $G_with_poll;
     GLOBAL $G_lang, $G_lng, $mlang_room;
     GLOBAL $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER;
@@ -923,13 +982,8 @@ supported by:<br>
 <?php
      if ($G_with_topbanner) {
        printf("     topbanner_init();\n");
-    }
-     if ($G_with_sidebanner) {
-       printf("     sidebanner_init();\n");
-    }
-     if ($G_with_sidebanner2) {
-       printf("     sidebanner2_init();\n");
-    }
+     }
+     sidebanners_init($G_sidebanner_idx);
 ?>
 
      g_withflash = DetectFlashVer(6,0,0);
@@ -969,18 +1023,7 @@ supported by:<br>
     printf("<table class=\"floaty\"><tr><td class=\"floatyleft\">\n");
     printf($brisk_vertical_menu, '', '');
 
-   if ($G_with_sidebanner xor $G_with_sidebanner2) {
-     printf("<br><br>");
-   }
-
-   if ($G_with_sidebanner) {
-     printf("%s", $G_sidebanner);
-   }
-
-
-   if ($G_with_sidebanner2) {
-     printf("%s", $G_sidebanner2);
-   }
+    sidebanners_render($G_sidebanner, $G_sidebanner_idx);
    printf("</td><td>");
 ?> 
 
@@ -1095,13 +1138,7 @@ else {
      if ($G_with_topbanner) {
        printf("     topbanner_init();\n");
      }
-     if ($G_with_sidebanner) {
-       printf("     sidebanner_init();\n");
-    }
-     if ($G_with_sidebanner2) {
-       printf("     sidebanner2_init();\n");
-    }
-
+     sidebanners_init($G_sidebanner_idx);
 ?>
      sess = "<?php echo "$sess"; ?>";
 xstm = new xynt_streaming(window, "<?php echo "$transp_type"; ?>", 80, 2, null /* console */, gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);});
@@ -1161,19 +1198,7 @@ if ($is_login) {
    printf("<table class=\"floaty\"><tr><td class=\"floatyleft\">\n");
    printf($brisk_vertical_menu, '', $brisk_donate);
 
-
-   if ($G_with_sidebanner xor $G_with_sidebanner2) {
-     printf("<br><br>");
-   }
-
-   if ($G_with_sidebanner) {
-     printf("%s", $G_sidebanner);
-   }
-
-
-   if ($G_with_sidebanner2) {
-     printf("%s", $G_sidebanner2);
-   }
+   sidebanners_render($G_sidebanner, $G_sidebanner_idx);
 
    printf("</td><td>");
 ?>