Esempio n. 1
0
    function get_mapo_resume()
    {
        global $mapobgs;
        $showall = $_REQUEST['view'] == "todos";
        $rows = MySQLAdmin::get_last_report(7);
        $_SESSION['url_back'] = "";
        if ($rows == false) {
            echo "Sin datos por el momento.";
            return false;
        }
        $sortedgroups = array();
        foreach ($rows as $parts) {
            $item = explode(",", $parts);
            $i = (int) $item[4];
            if (!in_array($i, array(1, 2, 3, 4))) {
                continue;
            }
            if ($i && !is_array($sortedgroups[$i])) {
                $sortedgroups[$i] = array();
            }
            $sortedgroups[$i][] = $parts;
        }
        ksort($sortedgroups);
        $secondary = array();
        $j = 0;
        if ($showall) {
            echo '
			<h3>Texto</h3>';
        }
        $cols = 4;
        $rowsize = (int) isset($_REQUEST['size']) ? $_REQUEST['size'] : $cols;
        echo '<div class="resume">';
        foreach ($sortedgroups as $parts) {
            echo '
				<div class="col-md-3">';
            if ($showall) {
                echo '
				<ul>';
            }
            $n = 0;
            $sourcecntl = array();
            foreach ($parts as $rowdata) {
                $item = explode(",", $rowdata);
                $name = $item[0];
                $timelapse = MySQLAdmin::get_timelapse($name);
                //if($timelapse['status']!=1) continue;
                if (!$showall && $n > $rowsize - 2) {
                    continue;
                }
                if (!$showall && in_array($timelapse['source'], $sourcecntl) && $timelapse['group_id'] != 2 && $timelapse['group_id'] != 3) {
                    continue;
                }
                if ($n > $rowsize * $cols - 1) {
                    continue;
                }
                $timelast = $item[3];
                $mins = (time() - $timelast) / 60;
                $total = $item[1];
                $timefirst = $item[2];
                $mins2 = (time() - $timefirst) / 60;
                $ratio = $total > 2 ? $mins2 / ($total - 1) : 0;
                $aac = round($ratio);
                switch ($_REQUEST['view']) {
                    // IMAGENES
                    case 'grid':
                    case '':
                        $dot = Utils::file_extension($timelapse['targeturl']);
                        $thumbname = 'latest.' . $dot;
                        $icons = "";
                        if (file_exists(dirname(__FILE__) . '/../data/' . $name . '/latest2.jpg')) {
                            $thumbname = 'latest2.jpg';
                        }
                        if ($timelapse['wustation']) {
                            $icons .= '<div class="wustation" title="' . __('Estación meteorológica en vivo') . '"><!-- --></div>';
                        }
                        $cookiecrop = $_COOKIE['setcrop-' . $timelapse['name']];
                        if (isset($cookiecrop)) {
                            $parts = explode(',', $cookiecrop);
                            $cropx = $parts[0];
                            $cropy = $parts[1];
                            $icons .= '<div class="target" title="' . __('Área personalizada') . '"><!-- --></div>';
                        } else {
                            $cropx = $timelapse['cropx1'];
                            $cropy = $timelapse['cropy1'];
                        }
                        echo '
					<div class="alert alert-' . $mapobgs[$timelapse['group_id'] - 1] . '">
					
					<h4>' . __($timelapse['title']) . '</h4>
					<div class="row">
					<a href="#/tl/' . $name . '" class="col-md-6" title="Ver últimas imágenes de : ' . __($timelapse['title']) . ' ' . __($timelapse['subtitle']) . '"><img src="/static/crop/?
					t=' . $name . '/' . $thumbname . '&
					ttl=' . urlencode($timelapse['source']) . '&
					sx=' . $cropx . '&
					sy=' . $cropy . '" width="120" height="120"/></a>
					';
                        $ul = array();
                        //$ul[] = '<td><a href="/show?e='. $name . '&s=' . $GLOBALS['DEFAULT_DISPLAY_SETTINGS'] .  '" title="Ver últimas imágenes de : ' . __($timelapse['title']) . ' ' . __($timelapse['subtitle']) . '">' . __($timelapse['title']) . '</td>' ;
                        if (!empty($timelapse['subtitle'])) {
                            $ul[] = __($timelapse['subtitle']);
                        }
                        $ul[] = '<a href="' . $timelapse['sourceurl'] . '" title="Fuente : ' . __($timelapse['source']) . '" target="_blank">' . __($timelapse['source']) . '</a>';
                        $ul[] = '<span class="value' . get_gradient_value($mins) . '"> hace <span class="updateable">' . timespan($mins) . '</span></span>';
                        $ul[] = '<span class="value' . get_aac_value($aac) . '">cada ' . timespan($aac) . '&nbsp;</span>';
                        //$ul[3] = '<span class="value">&nbsp;<a href="/ver/' . $name . '/files" target="_blank">' . $total . '</a>&nbsp;</span>';
                        if ($icons != '') {
                            $ul[5] = $icons;
                        }
                        echo ' <div class="col-md-6">
					<ul><li>' . implode("</li><li>", $ul) . '</li></ul></div><div class="clearfix"></div></div></div>
					';
                        break;
                        // TEXTO TODAS
                    // TEXTO TODAS
                    case 'todos':
                        $_SESSION['url_back'] = "?ver=todos";
                        $icon = $mapobgs[$item[4] - 1];
                        if ($timelapse['wustation']) {
                            $icon .= 'ws';
                        }
                        echo '<li><div class="icon' . $icon . '">
					<span class="value" style="margin:0 !important;">&nbsp;<a href="./ver/' . $name . $GLOBALS['DEFAULT_DISPLAY_SETTINGS'] . '">' . __($timelapse['title']) . '&nbsp;' . __($timelapse['subtitle']) . '</a></span>
					<span class="value">&nbsp;<a href="/ver/' . $name . '/files" target="_blank">' . $total . '</a>&nbsp;</span>
					<span class="value">&nbsp;<a href="' . $timelapse['sourceurl'] . '" target="_blank">' . __($timelapse['source']) . '</a>&nbsp;</span>
					<br><span class="value' . get_gradient_value($mins) . '">&nbsp;hace <span class="updateable">' . timespan($mins) . '</span>&nbsp;</span><span class="value' . get_aac_value($aac) . '" style="margin:0 !important;">&nbsp;cada ' . timespan($aac) . '&nbsp;</span>
					</div></li>';
                        break;
                }
                $sourcecntl[] = $timelapse['source'];
                $n++;
            }
            $j++;
            if ($showall) {
                echo '</ul>';
            }
            echo '
				</div>';
        }
        echo '</div>';
    }