static function drawGraph($obj=NULL,$parent=NULL) { $link = $GLOBALS['GRAPHITE_URL'].'/render/?'; $lines = Line::findAll($obj->getGraphId()); foreach($lines as $line) { $link .= 'target='; $target = 'alias(' . $line->getTarget() . '%2C%22' . $line->getAlias() . '%22)'; if ($line->getColor() != '') { $target = 'color(' . $target . '%2C%22' . $line->getColor() . '%22)'; } $link .= $target .'&'; } if (!is_null($parent)) { $link .= 'width=' . $parent->getGraphWidth() .'&'; $link .= 'height=' . $parent->getGraphHeight() .'&'; if ($obj->getVtitle() != '') { $link .= 'vtitle=' . $obj->getVtitle() .'&'; } if ($obj->getName() != '') { $link .= 'title=' . $obj->getName() .'&'; } if ($obj->getArea() != 'none') { $link .= 'areaMode=' . $obj->getArea() .'&'; } if ($obj->getTime_Value() != '' && $obj->getUnit() != '') { $link .= 'from=-' . $obj->getTime_Value() . $obj->getUnit() . '&'; } if ($obj->getCustom_Opts() != '') { $link .= $obj->getCustom_Opts() . '&'; } } return $link; }
// 3 -> Both are displayed $display_options_links = 0; } include VIEW_PATH . '/view_dashboard.php'; } elseif ('delete' == $action) { $class_name = 'Dashboard'; try { $obj = new Dashboard($dashboard_id); $delete_text = 'Are you sure you want to delete dashboard : <strong>' . $obj->getName() . '</strong>?'; if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $obj->delete(); $graphs = Graph::findAll($dashboard_id); // Do Dashboard Subelement Cleanup foreach ($graphs as $graph) { $lines = Line::findAll($graph->getGraphId()); foreach ($lines as $line) { $line->delete(); } $graph->delete(); } fMessaging::create('success', Dashboard::makeUrl('list'), 'The Dashboard ' . $obj->getName() . ' was successfully deleted'); fURL::redirect(Dashboard::makeUrl('list')); } } catch (fNotFoundException $e) { fMessaging::create('error', Dashboard::makeUrl('list'), 'The Dashboard requested could not be found'); fURL::redirect(Dashboard::makeUrl('list')); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/delete.php';
fURL::redirect(Graph::makeUrl('edit', $graph)); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } } include VIEW_PATH . '/add_edit_graph.php'; } elseif ('delete' == $action) { $class_name = 'Graph'; try { $obj = new Graph($graph_id); $dashboard = new Dashboard($obj->getDashboardId()); $delete_text = 'Are you sure you want to delete the graph : <strong>' . $obj->getName() . '</strong>?'; if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $obj->delete(); $lines = Line::findAll($graph_id); foreach ($lines as $line) { $line->delete(); } fMessaging::create('success', Dashboard::makeUrl('edit', $dashboard), 'The graph for ' . $dashboard->getName() . ' was successfully deleted'); fURL::redirect(Dashboard::makeUrl('edit', $dashboard)); } } catch (fNotFoundException $e) { fMessaging::create('error', Dashboard::makeUrl('edit', $dashboard), 'The line requested could not be found'); fURL::redirect(Dashboard::makeUrl('edit', $dashboard)); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/delete.php'; } elseif ('clone' == $action) { if (fRequest::isPost()) {
fMessaging::create('error', fURL::get(), $e->getMessage()); } } $dashboard = new Dashboard($graph->getDashboardId()); $dashboard_id = $graph->getDashboardId(); $lines = Line::findAll($graph_id); include VIEW_PATH . '/add_edit_graph.php'; } elseif ('reorder' == $action) { $drag_order = fRequest::get('drag_order'); $error = false; if (empty($drag_order)) { // In this case, the user clicks on the arrow $move = fRequest::getValid('move', array('previous', 'next')); $line_to_move = new Line($line_id); $graph_id = $line_to_move->getGraphId(); $lines_in_graph = Line::findAll($graph_id); $number_of_lines = $lines_in_graph->count(TRUE); $skip_next = false; for ($i = 0; $i < $number_of_lines; $i++) { if (!$skip_next) { $current_line = $lines_in_graph[$i]; if ($current_line->getLineId() != $line_id) { // This isn't the concerned line $current_line->setWeight($i); } else { if ('previous' == $move) { if ($i > 0) { $current_line->setWeight($i - 1); $previous_line = $lines_in_graph[$i - 1]; $previous_line->setWeight($i); }
public function export_in_json() { $graph_id = $this->getGraphId(); $json_env = parent::export_in_json(); // Find all the lines of this graph $lines = Line::findAll($graph_id); $json_lines_array = array(); foreach ($lines as $line_in_graph) { // Export them in JSON $json_lines_array[] = $line_in_graph->export_in_json(); } // Implode them $json_lines = "\"lines\":["; if (!empty($json_lines_array)) { $json_lines .= implode(",", $json_lines_array); } $json_lines .= "]"; // Erase the last } of the json $json_env[strlen($json_env) - 1] = ","; // Concat the graph with its lines $json_env .= $json_lines . "}"; return $json_env; }