Subversion Repositories portal2

Rev

Rev 668 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
/*  emg - Energy Monitoring & Graphing
*  Copyright (C) 2006-2012 Romain Lievin
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 3 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

?>

<?php
/*
* List available sensors
*
* Called from:
*
* Input args (GET):
* - device_name as string
*
* Inputs args (POST): none
*
* Output args:
* - device_name
* - sensor_name
*
* Call: list_vars.php
*
*/

?>

<?php
include_once('auth_check.php');

if(isset($_SESSION['park']))
{
        $park = $_SESSION['park'];
}
else
{
        $park = null;
}

if(isset($_GET['device_key']))
{
        $device_key = $_GET['device_key'];
        $park       = $_SESSION['park'];
        $device     = $park->getDevice($device_key);
        $device_name= $device->getName();
}
?>

<div id="page_list_sensors">
        <h1>
                <?php echo _("Sensors"); ?>
        </h1>

        <fieldset>
                <?php
                echo '<legend>' . _('List') . ' (' . $device_name . ')' . '</legend>';
                ?>

                <?php
                if(isset($_GET['device_key']))
                {
                        $list = "\n";
                        $list .= "<ul>\n";

                        if($device)
                        {
                                foreach($device as $key => $sensor)
                                {
                                        $sensor_name = $sensor->getName();
                                        $sensor_key  = $key;;

                                        $list .= "  <li>\n";
                                        $id = link_get_id_from_filename("list_vars.php");
                                        $list .= "<a href=\"index.php?id_page=$id&device_key=$device_key&sensor_key=$sensor_key\">" . $sensor_name . '</a>' . "        ";
                                        $list .= "  </li>\n";
                                        $list .= "\n";
                                }
                        }

                        $list .= "</ul>\n";
                        echo $list;
                }
                ?>

        </fieldset>
        </form>
</div>