Exemplo n.º 1
0
function node_pick_step1($request)
{
    global $config;
    // Cacti config object
    $host_id = -1;
    $overlib = false;
    $aggregate = false;
    $SQL_picklist = "SELECT graph_templates_graph.id, graph_local.host_id, graph_templates_graph.local_graph_id, graph_templates_graph.height, graph_templates_graph.width, graph_templates_graph.title_cache as description, graph_templates.name, graph_local.host_id\tFROM (graph_local,graph_templates_graph) LEFT JOIN graph_templates ON (graph_local.graph_template_id=graph_templates.id) WHERE graph_local.id=graph_templates_graph.local_graph_id ";
    if (isset($request['host_id'])) {
        $host_id = intval($request['host_id']);
        if ($host_id >= 0) {
            $SQL_picklist .= " and graph_local.host_id={$host_id} ";
        }
    }
    $SQL_picklist .= " order by title_cache";
    cactiDatabaseConnect();
    $sources = db_fetch_assoc($SQL_picklist);
    uasort($sources, "usortNaturalDescriptions");
    $hosts = cactiHostList();
    $tpl = new SimpleTemplate();
    $tpl->set("title", "Pick a graph");
    $tpl->set("hosts", $hosts);
    $tpl->set("sources", $sources);
    $tpl->set("overlib", $overlib ? 1 : 0);
    $tpl->set("selected_host", $host_id);
    $tpl->set("aggregate", $aggregate ? 1 : 0);
    $tpl->set("base_url", isset($config['base_url']) ? $config['base_url'] : '');
    $tpl->set("rra_path", jsEscape($config['rra_path']));
    echo $tpl->fetch("editor-resources/templates/picker-graph.php");
}
 function showMainPage($editor)
 {
     global $WEATHERMAP_VERSION;
     /* add a random bit onto the URL so that the next request won't get the same URL/ETag combo
        even if the config file contents don't change, but the two requests for the same editor page WILL */
     $map_url = "?action=draw&mapname=" . $this->mapname . "&rand=" . rand(0, 100000);
     $tpl = new SimpleTemplate();
     $tpl->set("WEATHERMAP_VERSION", $WEATHERMAP_VERSION);
     $tpl->set("fromplug", $this->isEmbedded() ? 1 : 0);
     $tpl->set("imageurl", htmlspecialchars($map_url));
     if ($this->selected != "") {
         $tpl->set("imageurl", htmlspecialchars($map_url . "&selected=" . urlencode($this->selected)));
     }
     $tpl->set("mapname", htmlspecialchars($this->mapname));
     $tpl->set("newaction", htmlspecialchars($this->next_action));
     $tpl->set("param2", htmlspecialchars($this->param2));
     // draw a map to throw away, just to get the imagemap updated
     $editor->map->drawMapImage('null');
     $editor->map->htmlstyle = 'editor';
     $editor->map->calculateImageMap();
     $tpl->set("imagemap", $editor->map->generateSortedImagemap("weathermap_imap"));
     $tpl->set("map_json", $editor->map->asJS());
     $tpl->set("images_json", "");
     $tpl->set("map_width", $editor->map->width);
     $tpl->set("map_height", $editor->map->height);
     $tpl->set("log", $this->log_message);
     echo $tpl->fetch("editor-resources/templates/main.php");
 }