Nextrek
@ 9
Nextrek / Web / epg / index_wall_php.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
<?php require_once 'database.php'; $data = array(); if (sql_connect()) { $cursor = sql_cursor_open('SELECT timestamp, canale, programma, tipo, durata FROM `palinsesto` ORDER BY canale, timestamp'); while ($row = sql_fetch_row($cursor)) { $canale = $row['canale']; if (!array_key_exists($canale, $data)) { $data[$canale] = array(); } $data[$canale][] = $row; } sql_cursor_close($cursor); sql_disconnect(); } function date2timestamp($datetime, $INCLUDE_TIME=TRUE) { // 11 // 0123 45 67 89 01 // yyyy mm dd HH MM $y = substr($datetime,0,4); $mo = substr($datetime,4,2); $d = substr($datetime,6,2); $h = substr($datetime,8,2); $mi = substr($datetime,10,2); if (!$INCLUDE_TIME) { $h = 0; $mi = 0; } return mktime($h,$mi,0,$mo,$d,$y)/60; // seconds -> minutes } $min2px = 5; $larghezza_canale = 150; $padding = 5; $altezza_logo = 40; $larghezza_timeline = 150; ?> <html> <head> <script type="text/javascript" src="jquery-1.8.2.min.js"></script> <style> * { margin:0; padding:0; font-size:10px; } .canali { } .canale { text-align: center; position: absolute; } .header { background-color: silver; border-bottom: 2px solid black; height: 35px; left: 0; position: absolute; top: 0; z-index: 1000; } .logo { position: absolute; text-align: center; } .programmi { position: relative; } .programma { position: absolute; border: 1px solid black; width: 100%; overflow: hidden; border-radius: 10px; } .timestamp { display: block; } .titolo { display: block; font-weight: bold; } .tipo { display: block; } .durata { display: block; } .timeline { z-index: 900; position: absolute; left:0; top:0; background-color: blue; border-right: 2px solid black; width: <?php echo $larghezza_timeline; ?>px; } .ora { color: white; position: absolute; text-align: right; width: 90%; font-size: 18px; } .minuti { font-size: 14px; font-weight: normal; } </style> <script> $(function() { $(window).scroll(function(){ $('.header').css('top',$(window).scrollTop()); $('.timeline').css('left',$(window).scrollLeft()); }); }); </script> </head> <body> <?php echo '<div class="header" style="width:'.(count($data)*($larghezza_canale+2*$padding)+$larghezza_timeline).'px">'; $left = $padding+$larghezza_timeline; foreach($data as $channel => &$epg) { echo '<span class="logo" style="left:'.$left.'px; width:'.$larghezza_canale.'px">'; echo '<img style="max-width:'.$larghezza_canale.'px;" src="logo/'.$channel.'.png" />'; echo '</span>'; $left+=$larghezza_canale+2*$padding; } echo '</div>'; $ore_di_timeline = 24*2 + 8; // 2 giorni e 8 ore echo '<div class="timeline" style="height:'.((($ore_di_timeline+1)*60)*$min2px).'px">'; for($h = 0; $h < ($ore_di_timeline); $h++) { $top = $h * 60 * $min2px + $altezza_logo; $ore = $h % 24; $hm = (($ore < 10) ? '0' : '') . $ore; echo '<div class="ora" style="top:'.$top.'px">'.$hm.':00</div>'; $top += 30 * $min2px; echo '<div class="ora minuti" style="top:'.$top.'px">'.$hm.':30</div>'; } echo '</div>'; echo '<div class="canali">'; $left = $padding+$larghezza_timeline; foreach($data as $channel => &$epg) { echo '<div class="canale" style="left:'.$left.'px; width:'.$larghezza_canale.'px">'; echo '<div class="programmi">'; $datereference = date2timestamp($epg[0]['timestamp'], FALSE); foreach($epg as $program) { $top = (date2timestamp($program['timestamp']) - $datereference) * $min2px + $altezza_logo; $height = ($program['durata']-1); if ($height<1) $height=1; $height *= $min2px; echo '<div class="programma" style="top:'.$top.'px; height:'.$height.'px">'; echo '<span class="titolo">'.$program['programma'].'</span>'; //echo '<span class="timestamp">'.$program['timestamp'].'</span>'; echo '<span class="tipo">'.$program['tipo'].'</span>'; echo '<span class="durata">'.$program['durata'].'</span>'; echo '</div>'; } echo '</div>'; echo '</div>'; $left+=$larghezza_canale+2*$padding; } echo '</div>'; ?> </body> </html> |
Commits for Nextrek/Web/epg/index_wall_php.php
Revision | Author | Commited | Message |
---|---|---|---|
9 | DRuega | Mon 06 May, 2013 21:54:02 +0000 | Ripristinato EPG |