public function sendCallBack() { if ($this->request->post('name') && $this->request->post('phone')) { $name = $this->request->post('name'); $phone = $this->request->post('phone'); $insert = $this->database->insert("callback", array("idate" => time(), "name_rus" => $name, "phone" => $phone)); if ($insert) { $data = new Dwoo_Data(); $data->assign("date", date("d-m-Y H:s:i", time())); $data->assign("name", $name); $data->assign("phone", $phone); $message = $this->dwoo->get("email/call-me.php", $data); $mail = new PHPMailer(true); $mail->From = "*****@*****.**"; $mail->FromName = "Interline"; $mail->CharSet = "utf-8"; $mail->Subject = "Обратная связь"; $mail->IsHTML(true); $mail->MsgHTML($message); $emails = $this->model->cms_interface()->where("label=", "email-callme")->getOne(); $emails = strip_tags(trim($emails['content'])); $emails = explode(",", $emails); foreach ($emails as $one) { if (!empty($one)) { $mail->AddAddress(trim($one)); $mail->Send(); $mail->ClearAddresses(); } } jsonout(array("ok" => 1)); } } }
/** * {@inheritdoc} */ public function render($viewName, Model $model, NotificationCenter $notificationCenter, $output = true) { Profile::start('Renderer', 'Generate HTML'); $templateName = $viewName . '.' . static::$templateFileExtension; $dwoo = new Dwoo($this->compiledPath, $this->cachePath); $dwoo->getLoader()->addDirectory($this->functionsPath); Profile::start('Renderer', 'Create template file.'); $template = new Dwoo_Template_File($templateName); $template->setIncludePath($this->getTemplatesPath()); Profile::stop(); Profile::start('Renderer', 'Render'); $dwooData = new Dwoo_Data(); $dwooData->setData($model->getData()); $dwooData->assign('errorMessages', $notificationCenter->getErrors()); $dwooData->assign('successMessages', $notificationCenter->getSuccesses()); $this->setHeader('Content-type: text/html', $output); // I do never output directly from dwoo to have the possibility to show an error page if there was a render error. $result = $rendered = $dwoo->get($template, $dwooData, null, false); if ($output) { echo $result; } Profile::stop(); Profile::stop(); return $output ? null : $rendered; }
public function getYmlTemplate($products, $catalog = false) { $data = new Dwoo_Data(); $data->assign("products", $products); $data->assign("catalog", $catalog); $data->assign("course", $this->course); $xml = $this->dwoo->get("xml/yml.php", $data); file_put_contents($this->dir . "yml.xml", $xml); return $xml; }
public function testAppend() { $data = new Dwoo_Data(); $data->assign('var', 'val'); $data->append('var', 'moo'); $this->assertEquals(array('var' => array('val', 'moo')), $data->getData()); $data->assign('var', 'val'); $data->append(array('var' => 'moo', 'var2' => 'bar')); $this->assertEquals(array('var' => array('val', 'moo'), 'var2' => array('bar')), $data->getData()); }
protected function _assign(Dwoo_Data $data) { try { $details = $this->_eventData->getAllDetails(); $arrayDetails = array(); foreach ($details as $detail) { $arrayDetails[] = array('unit' => $detail->getUnit()->toArray(), 'period' => (array) $detail->getPeriod(), 'periodtime' => (array) $detail->getPeriod(true), 'persons' => $detail->getPersons()->getAll(), 'total' => $detail->getTotal()); } $data->assign('details', $arrayDetails); $data->assign('user', $this->_eventData->getUser()->toArray()); $data->assign('reservation_id', $this->_eventData->getReservationID()); } catch (Exception $e) { return false; } return $data; }
protected function _assign(Dwoo_Data $data) { $user = $this->_eventData->getUser(); $user = $user->toArray(); $data->assign('user', $user); return $data; }
/** * Method that parsed invoice template and returns string * * All variable that parsed into invoice.pthml template * $reservation: * $reservation.id * $reservation.user_id * $reservation.confirmed (Yes, No - translated) * $reservation.is_read (Yes, No - translated) * $reservation.creation_datetime (In MySQL format: Y-m-d H:m:s) * $reservation.modified_datetime (In MySQL format: Y-m-d H:m:s) * $reservation.notes * $reservation.tax * $reservation.paid * $reservation.due * * $customer: * $customer.id * $customer.title (Translated) * $customer.first_name * $customer.last_name * $customer.address1 * $customer.address2 * $customer.state * $customer.city * $customer.postcode * $customer.country * $customer.telephone * $customer.mobile * $customer.email * $customer.username * * $details each detail is an $element: * $element.reservation_id * $element.unit_id * $element.start_datetime (In MySQL format: Y-m-d H:m:s) * $element.end_datetime (In MySQL format: Y-m-d H:m:s) * $element.total_price * $element.unit.id * $element.unit.rating (number) * $element.unit.published (Yes, No - translated) * $element.unit.color (hex color) * $element.unit.(all language db field names that are belong to unit type, for example: name, summary, description) * * $text: all text constants in section 'Admin.Invoice' in languages file, for example $text.BookingReference * * @param RM_Reservation_Row $reservation * @return <type> */ public static function getInvoice(RM_Reservation_Row $reservation) { $translate = RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN); $data = new Dwoo_Data(); $data->assign('invoice', array('date' => date('d/m/Y'))); $config = new RM_Config(); $data->assign('currencysymbol', $config->getCurrencySymbol()); //TODO: resmania - we need to add discounts and coupons here $reservationArray = $reservation->toArray(); $billing = new RM_Billing(); $priceCharges = $billing->getPrice($reservation->id); $reservationArray['tax'] = $priceCharges->tax; $reservationArray['paid'] = $billing->getPaymentsTotal($reservation); $reservationArray['due'] = abs($priceCharges->total - $billing->getPaymentsTotal($reservation)); $reservationArray['total'] = $priceCharges->total; $reservationArray['confirmed'] = $reservation->confirmed ? $translate->_('MessageYes') : $translate->_('MessageNo'); $reservationArray['is_read'] = $reservation->is_read ? $translate->_('MessageYes') : $translate->_('MessageNo'); $data->assign('reservation', $reservationArray); $text = $translate->getSectionMessages('Common.Invoice'); $data->assign('text', $text); $userModel = new RM_Users(); $user = $userModel->getByReservation($reservation); if ($user == null) { $userArray = array(); } else { $userArray = $user->toArray(); $userArray['title'] = $user->getTitle(); } $data->assign('customer', $userArray); $reservationDetailsModel = new RM_ReservationDetails(); $summaryModel = new RM_ReservationSummary(); $details = $reservationDetailsModel->getAllByReservation($reservation); $arrayDetails = array(); foreach ($details as $detail) { $arrayDetail = $detail->toArray(); $unit = $detail->findUnit(); $unitArray = $unit->toArray(); $unitArray['id'] = $unit->getId(); $unitArray['published'] = $unitArray->published ? $translate->_('MessageYes') : $translate->_('MessageNo'); // format the start/end dates $arrayDetail['start_datetime'] = $config->convertDates($arrayDetail['start_datetime'], RM_Config::PHP_DATEFORMAT, RM_Config::JS_DATEFORMAT); $arrayDetail['end_datetime'] = $config->convertDates($arrayDetail['end_datetime'], RM_Config::PHP_DATEFORMAT, RM_Config::JS_DATEFORMAT); // extras $reservationDetailsExtra = $summaryModel->fetchByReservationDetail($detail)->toArray(); foreach ($reservationDetailsExtra as $extra) { if ($extra['value'] == 0) { $extra['value'] = ""; } $unitArray['extras'][] = array("name" => $extra['name'], "value" => $extra['value'], "total_amount" => $extra['total_amount']); } $arrayDetail['unit'] = $unitArray; $arrayDetails[] = $arrayDetail; } $data->assign('details', $arrayDetails); $templateFile = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'userdata', 'views', 'admin', 'scripts', 'templates', 'invoice.phtml')); $template = new Dwoo_Template_File($templateFile); $dwoo = new Dwoo(); return $dwoo->get($template, $data); }
function GenerateModLogRSS() { global $tc_db; require_once KU_ROOTDIR . 'lib/dwoo.php'; $dwoo = new Dwoo(); $dwoo_data = new Dwoo_Data(); $entries = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "modlog` ORDER BY `timestamp` DESC LIMIT 15"); $dwoo_data->assign('entries', $entries); $rss = $dwoo->get(KU_TEMPLATEDIR . '/rss_mod.tpl', $dwoo_data); return $rss; }
protected function _assign(Dwoo_Data $data) { $details = $this->_eventData->getAllDetails(); $reservationID = $this->_eventData->getReservationID(); $reservationModel = new RM_Reservations(); $reservation = $reservationModel->find($reservationID)->current(); $arrayDetails = array(); foreach ($details as $detail) { $arrayDetails[] = array('unit' => $detail->getUnit()->toArray(), 'period' => (array) $detail->getPeriod(), 'periodtime' => (array) $detail->getPeriod(true), 'persons' => $detail->getPersons(), 'total' => $detail->getTotal()); } // total paid and total due $billing = new RM_Billing(); $priceCharges = $billing->getPrice($reservationID); $billingArray['tax'] = $priceCharges->tax; $billingArray['paid'] = $billing->getPaymentsTotal($reservation); $billingArray['due'] = $priceCharges->total; $billingArray['confirmed'] = $reservation->confirmed ? $translate->_('MessageYes') : $translate->_('MessageNo'); $data->assign('details', $arrayDetails); $data->assign('reservation_id', $this->_eventData->getReservationID()); return $data; }
protected function _assign(Dwoo_Data $data) { $translate = RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN); $locationsDAO = new RM_Locations(); $reservationID = $this->_eventData->getReservationID(); $reservationModel = new RM_Reservations(); $reservation = $reservationModel->find($reservationID)->current(); // reservation details $details = $this->_eventData->getAllDetails(); $arrayDetails = array(); foreach ($details as $detail) { $unit = $detail->getUnit()->toArray(); $period = $detail->getPeriod()->toArray(); $periodWithTime = $detail->getPeriod()->toArray(true); $location = $locationsDAO->fetchByUnit($unit['id'])->toArray(); $extrasForTemplate = array(); $extras = $detail->getExtras(); foreach ($extras as $extra) { $extrasForTemplate[] = $extra->toArray(); } $arrayDetails[] = array('unit' => $unit, 'locationInfo' => isset($location[0]) ? $location[0] : '', 'period' => $period, 'periodtime' => $periodWithTime, 'persons' => $detail->getPersons()->getAll(), 'total' => $detail->getTotal(), 'extras' => $extrasForTemplate); } // total paid and total due $billing = new RM_Billing(); $priceCharges = $billing->getPrice($reservationID); $billingArray['tax'] = $priceCharges->tax; $billingArray['paid'] = $billing->getPaymentsTotal($reservation); $billingArray['due'] = $priceCharges->total; $billingArray['confirmed'] = $reservation->confirmed ? $translate->_('MessageYes') : $translate->_('MessageNo'); // return the data to the template $data->assign('extras', $extrasForTemplate); $data->assign('details', $arrayDetails); $data->assign('user', $this->_eventData->getUser()->toArray()); $data->assign('reservation_id', $reservationID); $data->assign('billing', $billingArray); return $data; }
public function startFollow() { $filename = APP_DIR . 'cron/block.php'; $new_array = array(); $follow_price = $this->model->follow_price()->joined(true)->order("pos ASC")->getByActive(1); foreach ($follow_price as $key => $item) { $email = strtolower(trim($item['email'])); $new_array[$email][] = $item; } foreach ($new_array as $key => $item) { foreach ($item as $k => $v) { $new_array[$key][$k]['new_price'] = $v['product']['price']; if ($v['old_price'] <= $v['product']['price']) { unset($new_array[$key][$k]); } else { $this->database->update('follow_price', array('old_price' => $v['new_price'], 'procent' => $v['old_price'] - $v['new_price']), array('id' => $v['id'])); } } } foreach ($new_array as $key => $item) { if (isset($item) && is_array($item) && !empty($item)) { $data = new Dwoo_Data(); $data->assign('products', $item); $message = $this->dwoo->get("email/follow-mail.php", $data); $mail = new PHPMailer(true); $mail->From = "*****@*****.**"; $mail->FromName = "Interline"; $mail->CharSet = "utf-8"; $mail->Subject = "Скидка на товары"; $mail->IsHTML(true); $mail->MsgHTML($message); $mail->AddAddress(trim($key)); $mail->Send(); $mail->ClearAddresses(); } } }
$result = $db->Execute('SELECT * FROM ' . DB::$calls . ' ORDER BY ' . DB::$calls_start_time . ' DESC'); $total_call_duration = 0; $total_call_count = $result->RecordCount(); // This data is used by the JS charting library to display a dot chart // showing the calls received each hour. Each slot in the array // corresponds to an hour in the day. $call_volume_chart_data = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); while ($row = $result->FetchRow()) { $from = $row[DB::$calls_from]; $location = $row[DB::$calls_location]; $start_time = new DateTime($row[DB::$calls_start_time], $server_timezone); $duration = ceil($row[DB::$calls_duration] / 60); $total_call_duration += $duration; $call_volume_chart_data[$start_time->format('G')] += 1; $start_time->setTimezone($local_timezone); $call['from'] = format_phone_number($from); $call['location'] = $location; $call['start_time'] = $start_time->format('F j, Y \\a\\t g:i A'); $call['duration'] = $duration; $calls[] = $call; } } catch (ADODB_Exception $e) { $error = 'An error occurred while connecting to the database. Please try again later.'; } $data->assign('total_call_count', $total_call_count); $data->assign('total_call_duration', $total_call_duration); $data->assign('total_spent', money_format('%i', $total_call_duration * CALL_COST)); $data->assign('call_volume_chart_data', implode(', ', $call_volume_chart_data)); $data->assign('calls', $calls); $data->assign('error', $error); $dwoo->output($tpl, $data);
<?php include_once "./global.php"; $tpl = new Dwoo_Template_File(template("compare_hosts.tpl")); $data = new Dwoo_Data(); $data->assign("range", $range); $size = isset($clustergraphsize) ? $clustergraphsize : 'default'; //set to 'default' to preserve old behavior $size = $size == 'medium' ? 'default' : $size; retrieve_metrics_cache(); $matches = array(); if (array_key_exists('hreg', $_GET)) { foreach ($_GET['hreg'] as $key => $query) { if ($query != '') { foreach ($index_array['hosts'] as $key => $host_name) { if (preg_match("/{$query}/i", $host_name)) { // We can have same hostname in multiple clusters foreach ($index_array['cluster'][$host_name] as $clustername) { $matches[] = array("hostname" => $host_name, "clustername" => $clustername); } } } } } } #print "<PRE>";print_r($index_array['metrics']); $host_metrics = array(); $host_cluster = array(); foreach ($matches as $index => $match) { $hostname = $match['hostname']; $host_cluster[] = $match['hostname'] . "|" . $match['clustername'];
<?php /* $Id$ */ $tpl = new Dwoo_Template_File(template("meta_view.tpl")); $data = new Dwoo_Data(); discover_filters(); if (!empty($filter_defs)) { $data->assign("filters", $filter_defs); $data->assign("choose_filter", $choose_filter); } # Find the private clusters. But no one is emabarrassed in the # control room (public only!). if ($context != "control") { $private = embarrassed(); } $source_names = array_keys($grid); # Build a list of cluster names and randomly pick a smaller subset to # display for control room mode. This allows a dedicated host to # eventually cycle through all the graphs w/o scrolling the mouse. A bunch # of these stations could monitor a large grid. # # For the standard meta view still display all the hosts. if ($context == "control") { srand((double) microtime() * 1000000); shuffle($source_names); $subset = array_slice($source_names, 0, abs($controlroom)); $source_names = $subset; } foreach ($source_names as $c) { $cpucount = $metrics[$c]["cpu_num"]['SUM']; if (!$cpucount) {
<?php $tpl = new Dwoo_Template_File(template("compare_hosts.tpl")); $data = new Dwoo_Data(); $data->assign("range", $range); $size = isset($clustergraphsize) ? $clustergraphsize : 'default'; //set to 'default' to preserve old behavior $size = $size == 'medium' ? 'default' : $size; retrieve_metrics_cache(); $matches = array(); if (array_key_exists('hreg', $_GET)) { foreach ($_GET['hreg'] as $key => $query) { if ($query != '') { foreach ($index_array['hosts'] as $key => $host_name) { if (preg_match("/{$query}/i", $host_name)) { // We can have same hostname in multiple clusters $matches[] = array("hostname" => $host_name, "clustername" => $index_array['cluster'][$host_name]); } } } } } #print "<PRE>";print_r($index_array['metrics']); $host_metrics = array(); $host_cluster = array(); foreach ($matches as $index => $match) { $hostname = $match['hostname']; $host_cluster[] = $match['hostname'] . "|" . $match['clustername']; foreach ($index_array['metrics'] as $metric_name => $hosts) { if (array_search($hostname, $hosts) !== FALSE && !isset($host_metrics[$metric_name])) { $host_metrics[$metric_name] = 1;
/** * Replace all placeholders with information from current made reservations * * @param RM_Reservation_Manager $manager * @param string $template * @return */ private function _parseCompleteTemplate(RM_Reservation_Manager $manager, $template) { $data = new Dwoo_Data(); $reservationModel = new RM_Reservations(); $reservation = $reservationModel->find($manager->getReservationID())->current(); $summaryModel = new RM_ReservationSummary(); $unitModel = new RM_Units(); $details = $reservation->getDetails(); $arrayDetails = array(); foreach ($details as $detailRow) { $detail = $detailRow->transform(); $unitArray = $detail->getUnit()->toArray(); $periodArray = $detail->getPeriod()->toArray(); $periodArrayWithTime = $detail->getPeriod()->toArray(true); $personsArray = $detailRow->getPersons(); //$unitID = $detail->getUnit()->getId(); $unitID = $unitArray['id']; $unit = $unitModel->get($unitID); $locationModel = new RM_Locations(); $location = $locationModel->fetchByUnit($unitID)->current(); $arrayDetails[] = array('unit' => $unit->toArray(), 'period' => $periodArray, 'periodtime' => $periodArrayWithTime, 'persons' => $personsArray, 'summary' => $summaryModel->fetchByReservationDetail($detailRow)->toArray(), 'location' => $location !== null ? $location->toArray() : $locationModel->createRow()->toArray()); } $data->assign('details', $arrayDetails); $data->assign('user', $manager->getUser()->toArray()); $reservationArray = $reservation->toArray(); $reservationArray['confirmed'] = $reservation->isPaid() ? $this->_translate->_('MessageYes') : $this->_translate->_('MessageNo'); $reservationArray['total'] = $reservation->getTotalPrice(); $reservationArray['paid'] = $reservation->getTotalPaid(); $reservationArray['due'] = $reservationArray['total'] - $reservationArray['paid']; $data->assign('reservation', $reservationArray); $dwooTemplate = new Dwoo_Template_String($template); $dwoo = new Dwoo(); return $dwoo->get($dwooTemplate, $data); }
protected function _assign(Dwoo_Data $data) { $data->assign('reservation_id', $this->_eventData->getReservationID()); return $data; }
$view_name = $_GET['vn']; } $viewList = new ViewList(); $dwoo = new Dwoo($conf['dwoo_compiled_dir'], $conf['dwoo_cache_dir']); $tpl = new Dwoo_Template_File(template("view_content.tpl")); $data = new Dwoo_Data(); $size = isset($clustergraphsize) ? $clustergraphsize : 'default'; // set to 'default' to preserve old behavior if ($size == 'medium') { $size = 'default'; } $additional_host_img_css_classes = ""; if (isset($conf['zoom_support']) && $conf['zoom_support'] === true) { $additional_host_img_css_classes = "host_{$size}_zoomable"; } $data->assign("additional_host_img_css_classes", $additional_host_img_css_classes); $view_items = NULL; $view = $viewList->getView($view_name); if ($view != NULL) { $range = isset($_GET["r"]) ? escapeshellcmd(rawurldecode($_GET["r"])) : NULL; $cs = isset($_GET["cs"]) ? escapeshellcmd($_GET["cs"]) : NULL; $ce = isset($_GET["ce"]) ? escapeshellcmd($_GET["ce"]) : NULL; if ($cs or $ce) { $range = "custom"; } $view_items = getViewItems($view, $range, $cs, $ce); } if (isset($view_items)) { $data->assign("view_items", $view_items); $data->assign("number_of_view_items", count($view_items)); if ($view['common_y_axis'] != 0) {
<?php $tpl = new Dwoo_Template_File(template("decompose_graph.tpl")); $data = new Dwoo_Data(); $data->assign("range", $range); $graph_type = "line"; $line_width = "2"; $user['view_name'] = isset($_GET["vn"]) ? sanitize($_GET["vn"]) : NULL; $user['item_id'] = isset($_GET["item_id"]) ? sanitize($_GET["item_id"]) : NULL; ################################################################################# # Let's check if we are decomposing a composite graph from a view ################################################################################# if ($user['view_name'] and $user['item_id']) { $available_views = get_available_views(); foreach ($available_views as $id => $view) { # Find view settings if ($user['view_name'] == $view['view_name']) { break; } } unset($available_views); foreach ($view['items'] as $index => $graph_config) { if ($user['item_id'] == $graph_config['item_id']) { break; } } unset($view); $title = ""; } else { if (isset($_GET['aggregate'])) { $graph_config = build_aggregate_graph_config($graph_type, $line_width, $_GET['hreg'], $_GET['mreg']);
function template($name = "", $varname1 = "", $varval1 = "", $varname2 = "", $varval2 = "", $varname3 = "", $varval3 = "") { if (!$name) { $name = $GLOBALS['def_template']; } $php_template = $name . ".php.html"; if (!file_exists($php_template)) { $php_template = "uses/" . $name . ".php.html"; } if (!file_exists($php_template)) { $php_template = "views/" . $name . ".php.html"; } if (file_exists($php_template)) { ob_start(); foreach ($GLOBALS as $key => $value) { ${$key} = $value; } require $php_template; $contents = ob_get_contents(); ob_end_clean(); return $contents; } $dwoo_template = "uses/" . $name . ".dwoo.html"; if (file_exists($dwoo_template)) { require_once "uses/dwoo/dwooAutoload.php"; $dwoo = new Dwoo(); $data = new Dwoo_Data(); foreach ($GLOBALS as $key => $value) { $data->assign($key, $value); } $html = $dwoo->get($dwoo_template, $data); return $html; } $fname = "uses/" . $name . ".tmpl.html"; if (!file_exists($fname)) { $fname = "uses/" . $name . ".html"; } if (file_exists($fname)) { $html = file_get_contents($fname); template_set($html, $varname1, $varval1, $varname2, $varval2, $varname3, $varval3); replace_files($html); replace_my_tags($html); replace_globals($html); return $html; } else { die("template: {$name} not found"); } }
# Although this page repeats some information from # host_view, it had the concept of Constant Metrics before # the SLOPE=zero attribute. It also uses style sheets for clean # looks. In the future, it may display process information for # the node as well. # # Originally by Federico Sacerdoti <*****@*****.**> # # Host is specified in get_context.php. if (empty($hostname)) { print "<h1>Missing a Node Name</h1>"; return; } $tpl = new Dwoo_Template_File(template("show_node.tpl")); $data = new Dwoo_Data(); $data->assign("extra", template("node_extra.tpl")); $up = $hosts_up ? 1 : 0; $class = $up ? "even" : "down"; $data->assign("class", $class); $data->assign("name", $hostname); # $metrics is an array of [Metrics][Hostname][NAME|VAL|TYPE|UNITS|SOURCE]. # Find the host's physical location in the cluster. $hostattrs = $up ? $hosts_up : $hosts_down; list($rack, $rank, $plane) = findlocation($hostattrs); $location = $rack < 0 ? "Unknown" : "Rack {$rack}, Rank {$rank}, Plane {$plane}."; $data->assign("location", $location); if (isset($hostattrs['ip'])) { $data->assign("ip", $hostattrs['ip']); } else { $data->assign("ip", ""); }
<?php /* $Id: cluster_view.php 2588 2011-05-02 21:19:54Z vvuksan $ */ $tpl = new Dwoo_Template_File( template("cluster_view.tpl") ); $data = new Dwoo_Data(); $data->assign("extra", template("cluster_extra.tpl")); $data->assign("images","./templates/${conf['template_name']}/images"); $data->assign("user_may_edit", checkAccess( $clustername, GangliaAcl::EDIT, $conf ) ); $data->assign("graph_engine", $conf['graph_engine']); $cpu_num = !$showhosts ? $metrics["cpu_num"]['SUM'] : cluster_sum("cpu_num", $metrics); $load_one_sum = !$showhosts ? $metrics["load_one"]['SUM'] : cluster_sum("load_one", $metrics); $load_five_sum = !$showhosts ? $metrics["load_five"]['SUM'] : cluster_sum("load_five", $metrics); $load_fifteen_sum = !$showhosts ? $metrics["load_fifteen"]['SUM'] : cluster_sum("load_fifteen", $metrics); # # Correct handling of *_report metrics # if (!$showhosts) { if(array_key_exists($metricname, $metrics)) $units = $metrics[$metricname]['UNITS']; } else { if(array_key_exists($metricname, $metrics[key($metrics)])) if (isset($metrics[key($metrics)][$metricname]['UNITS'])) $units = $metrics[key($metrics)][$metricname]['UNITS']; else $units = ''; } if(isset($cluster['HOSTS_UP'])) {
if (!isset($_COOKIE["gs"]) or $_COOKIE["gs"] != $gridstack_str) { setcookie("gs", $gridstack_str, time() + 86400); } } # Invariant: back pointer is second-to-last element of gridstack. Grid stack # never has duplicate entries. # RFM - The original line caused an error when count($gridstack) = 1. This # should fix that. $parentgrid = $parentlink = NULL; if (count($gridstack) > 1) { list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack) - 2]); } $tpl = new Dwoo_Template_File(template("{$header}.tpl")); $data = new Dwoo_Data(); if (isset($_GET["hide-hf"]) && filter_input(INPUT_GET, "hide-hf", FILTER_VALIDATE_BOOLEAN, array("flags" => FILTER_NULL_ON_FAILURE))) { $data->assign("hide_header", true); } // Server timezone used in generating pretty dates and times when zooming $data->assign("server_timezone", date_default_timezone_get()); $data->assign("page_title", $title); $data->assign("refresh", $conf['default_refresh']); # Templated Logo image $data->assign("images", "./templates/{$conf['template_name']}/images"); $data->assign("date", date("r")); # The page to go to when "Get Fresh Data" is pressed. if (isset($page)) { $data->assign("page", $page); } else { $data->assign("page", "./"); } #
<?php /* $Id$ */ $tpl = new Dwoo_Template_File(template("cluster_view.tpl")); $data = new Dwoo_Data(); $data->assign("extra", template("cluster_extra.tpl")); $data->assign("images", "./templates/{$template_name}/images"); $cpu_num = !$showhosts ? $metrics["cpu_num"]['SUM'] : cluster_sum("cpu_num", $metrics); $load_one_sum = !$showhosts ? $metrics["load_one"]['SUM'] : cluster_sum("load_one", $metrics); $load_five_sum = !$showhosts ? $metrics["load_five"]['SUM'] : cluster_sum("load_five", $metrics); $load_fifteen_sum = !$showhosts ? $metrics["load_fifteen"]['SUM'] : cluster_sum("load_fifteen", $metrics); # # Correct handling of *_report metrics # if (!$showhosts) { if (array_key_exists($metricname, $metrics)) { $units = $metrics[$metricname]['UNITS']; } } else { if (array_key_exists($metricname, $metrics[key($metrics)])) { if (isset($metrics[key($metrics)][$metricname]['UNITS'])) { $units = $metrics[key($metrics)][$metricname]['UNITS']; } else { $units = ''; } } } if (isset($cluster['HOSTS_UP'])) { $data->assign("num_nodes", intval($cluster['HOSTS_UP'])); } else { $data->assign("num_nodes", 0);
if (!isset($_COOKIE["gs"]) or $_COOKIE["gs"] != $gridstack_str) { setcookie("gs", $gridstack_str, time() + 86400); } } # Invariant: back pointer is second-to-last element of gridstack. Grid stack # never has duplicate entries. # RFM - The original line caused an error when count($gridstack) = 1. This # should fix that. $parentgrid = $parentlink = NULL; if (count($gridstack) > 1) { list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack) - 2]); } $tpl = new Dwoo_Template_File(template("{$header}.tpl")); $data = new Dwoo_Data(); // Server offset used in generating pretty dates and times when zooming $data->assign("server_utc_offset", date('Z')); // $data->assign("page_title", $title); $data->assign("refresh", $conf['default_refresh']); # Templated Logo image $data->assign("images", "./templates/{$conf['template_name']}/images"); $data->assign("date", date("r")); # The page to go to when "Get Fresh Data" is pressed. if (isset($page)) { $data->assign("page", $page); } else { $data->assign("page", "./"); } # # Used when making graphs via graph.php. Included in most URLs #
/* $Id$ */ # # Displays the cluster in a physical view. Cluster nodes in # this view are located by Rack, Rank, and Plane in the physical # cluster. # # Originally written by Federico Sacerdoti <*****@*****.**> # Part of the Ganglia Project, All Rights Reserved. # # Called from index.php, so cluster and xml tree vars # ($metrics, $clusters, $hosts) are set, and header.php # already called. $tpl = new Dwoo_Template_File(template("physical_view.tpl")); $data = new Dwoo_Data(); $data->assign("cluster", $clustername); $cluster_url = rawurlencode($clustername); $data->assign("cluster_url", $cluster_url); $verbosity_levels = array('3' => "", '2' => "", '1' => ""); # Assign the verbosity level. Can take the value of the 'p' CGI variable. $verbose = $physical ? $physical : 2; $verbosity_levels[$verbose] = "checked"; $data->assign("verbosity_levels", $verbosity_levels); # # Give the capacities of this cluster: total #CPUs, Memory, Disk, etc. # $CPUs = cluster_sum("cpu_num", $metrics); # Divide by 1024^2 to get Memory in GB. $Memory = sprintf("%.1f GB", cluster_sum("mem_total", $metrics) / (double) 1048576); $Disk = cluster_sum("disk_total", $metrics); $Disk = $Disk ? sprintf("%.1f GB", $Disk) : "Unknown";
} } if ($col_index != 0) { for ($i = 0; $i < $num_cols * $num_cols - $num_hosts; $i++) { $heatmap .= ",{host:\"unused\",load:0}"; } $heatmap .= ']'; } $heatmap .= ']'; $data->assign("heatmap_data", $heatmap); } $fn = "cluster_" . ($refresh ? "refresh" : "view") . ".tpl"; $tpl = new Dwoo_Template_File(template($fn)); $data = new Dwoo_Data(); if (!$refresh) { $data->assign("php_gd", function_exists('imagegif') or function_exists('imagepng')); $data->assign("extra", template("cluster_extra.tpl")); $data->assign("user_may_edit", checkAccess($clustername, GangliaAcl::EDIT, $conf)); $data->assign("graph_engine", $conf['graph_engine']); } $data->assign("cluster", $clustername); $data->assign("localtimestamp", $cluster['LOCALTIME']); $data->assign("localtime", date("Y-m-d H:i", $cluster['LOCALTIME'])); get_cluster_overview($showhosts, $metrics, $cluster, $range, $clustername, $data); $user_metricname = $user['metricname']; if (!$showhosts) { if (array_key_exists($user_metricname, $metrics)) { $units = $metrics[$user_metricname]['UNITS']; } } else { if (array_key_exists($user_metricname, $metrics[key($metrics)])) {
if (!$conf['display_views_using_tree']) { ?> <div id="views_menu"> <?php echo $existing_views; ?> </div> <script type="text/javascript">$(function(){$("#views_menu").buttonsetv();});</script> <?php } else { } exit(0); } $tpl = new Dwoo_Template_File(template("views_view.tpl")); $data = new Dwoo_Data(); $data->assign("range", $range); if (isset($conf['ad-hoc-views']) && $conf['ad-hoc-views'] === true && isset($_GET['ad-hoc-view'])) { $is_ad_hoc = true; } // Pop up a warning message if there are no available views // (Disable temporarily, otherwise we can't create views) if (count($viewList->getViews()) == -1 && !$is_ad_hoc) { $error_msg = ' <div class="ui-widget"> <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"> <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> <strong>Alert:</strong> There are no views defined.</p> </div> </div>'; }
<?php $tpl = new Dwoo_Template_File(template("footer.tpl")); $data = new Dwoo_Data(); $data->assign("webfrontend_version", $version["webfrontend"]); if (isset($_GET["hide-hf"]) && filter_input(INPUT_GET, "hide-hf", FILTER_VALIDATE_BOOLEAN, array("flags" => FILTER_NULL_ON_FAILURE))) { $data->assign("hide_footer", true); } if ($version["rrdtool"]) { $data->assign("rrdtool_version", $version["rrdtool"]); } $backend_components = array("gmetad", "gmetad-python", "gmond"); foreach ($backend_components as $backend) { if (isset($version[$backend])) { $data->assign("webbackend_component", $backend); $data->assign("webbackend_version", $version[$backend]); break; } } $data->assign("parsetime", sprintf("%.4f", $parsetime) . "s"); $dwoo->output($tpl, $data);
<?php /* $Id: grid_tree.php 2372 2010-11-29 19:21:44Z vvuksan $ */ $tpl = new Dwoo_Template_File(template("grid_tree.tpl")); $data = new Dwoo_Data(); $data->assign("self", "{$self}"); # Not as complicated as before. No depth-first-search, and # we only show our immediate children. # Publish past grids in our stack. $ancestors = $gridstack; # Take ourself off the end of the stack. array_pop($ancestors); if (count($ancestors)) { $data->assign("parentgrid", 1); $parentgridtable = ""; $parentgridstack = array(); foreach ($ancestors as $g) { list($name, $link) = explode("@", $g); $parentgridstack[] = $g; $parentgridstack_url = rawurlencode(join(">", $parentgridstack)); $parentgridtable .= "<tr><td align=center class=grid>" . "<a href=\"{$link}?t=yes&gw=back&gs={$parentgridstack_url}\">{$name}</a></td></tr>\n"; } $data->assign("parents", $parentgridtable); } $gridtable = ""; # Publish our children. if ($n = count($grid)) { $data->assign("n", $n); foreach ($grid as $source => $attrs) { if ($source == $self) { continue;