public function __construct($esxman, $database, $username = '', $error = null) { $this->esxman = $esxman; $this->database = $database; $this->username = $username; $this->html = array('footer' => ' ', 'menu' => ' ', 'tree' => ' ', 'user' => ' ', 'content' => ' '); $this->commands = array(); $this->title = _('Login'); if (request('form_name') == 'login') { if ($this->database->authenticate_user(request('username'), request('password'))) { session_destroy(); session_start(); $_SESSION['username'] = request('username'); $_SESSION['key'] = md5($_SESSION['username'] . getenv('REMOTE_ADDR') . getenv('X-FORWARDED-FOR')); debug('User ' . request('username') . ' logging in!'); $this->commands[] = "\$('#dialog').html('" . _('Populating inventory...') . "');"; $this->commands[] = js_command('get', 'action=populate_inventory'); return; } $error = _('Authentication failed'); } $tpl = new Template('dialog_login.html'); if ($error) { $tpl->setVar('error', $error); $tpl->parse('error_message'); } $this->commands[] = js_command('display_dialog', _('Login'), $tpl->get(), _('Login')); }
public function test($path) { $tmpl = new Template(); $tmpl->loadTmpl($path); $subTmpl = $tmpl->getSubTmpl('EVENT_VERSION1'); $subTmpl->setVar('TITLE', 'Das ist ein Test'); $list = $subTmpl->render(); $tmpl->setVar('EVENTLIST', $list); echo $tmpl->render(); }
public function __construct($username, $database) { $this->username = $username; $this->database = $database; $this->html = ''; $this->commands = array(); $menu = array('hosts' => array('label' => _('Hosts'), 'link' => 'page=hosts'), 'vms' => array('label' => _('Virtual Machines'), 'link' => 'page=vms')); $tpl = new Template('block_menu.html'); foreach ($menu as $data) { $tpl->setVars(array('label' => htmlentities($data['label']), 'link' => $data['link'])); $tpl->parse('menuitem'); } $tpl->setVar('label_logout', _('Logout')); $this->html = $tpl->get(); }
<?php if (!defined('AXE')) { exit; } //common include $box_simple_wide = new Template("styles/" . $style . "/box_simple_wide.php"); $box_wide = new Template("styles/" . $style . "/box_wide.php"); $box_wide->setVar("imagepath", 'styles/' . $style . '/images/'); $box_simple_wide->setVar("imagepath", 'styles/' . $style . '/images/'); //end common include include "dataVariables.php"; $cont2 .= "<div id='armory'><form action='' method='get'><input type='hidden' name='name' value='armory'><input type='text' name='char' value='" . $_GET['char'] . "' placeholder='Look for character...'><div id='log-b'><input type='submit' value='Search'></div></form><br><br>"; if ($_GET['char']) { $char = mysql_real_escape_string($_GET['char']); function wowhead_did($item) { mysql_select_db('world'); $sql = mysql_query("SELECT displayid FROM item_template WHERE entry = '{$item}'"); $displayid = mysql_result($sql, 0); return $displayid; } $db->select_db($realm[1]['db']); $charData = $db->query("SELECT * FROM characters WHERE name='{$char}'"); while ($row = mysql_fetch_array($charData)) { $status = array('offline', 'online'); $guid = $row['guid']; $gender = $row['gender']; $status = $status[$row['online']]; $cont2 .= "<li><div class='avatar'><img class='ava' src='./images/portraits/wow-default/" . $row['gender'] . "-" . $row['race'] . "-" . $row['class'] . ".gif' border='0'></div>"; $cont2 .= "<h2>" . $row['name'] . " <span class='charStatus' data-status='" . $status . "'>(" . $status . ")</span></h2>";
/** * Method to prepare a new Horizontal Plain Menu. * * This method processes items of a menu to prepare and return * the corresponding Horizontal Plain Menu code. * * @access public * @param string $menu_name the name of the menu whose items have to be processed * @return string */ function newHorizontalPlainMenu($menu_name = "") { $horizontal_plain_menu_blck = ""; $t = new Template(); $t->setFile("tplfile", $this->horizontalPlainMenuTpl); $t->setBlock("tplfile", "template", "template_blck"); $t->setBlock("template", "horizontal_plain_menu_cell", "horizontal_plain_menu_cell_blck"); $t->setVar("horizontal_plain_menu_cell_blck", ""); $t->setBlock("horizontal_plain_menu_cell", "plain_menu_cell", "plain_menu_cell_blck"); $t->setVar("plain_menu_cell_blck", ""); for ($cnt = $this->_firstItem[$menu_name]; $cnt <= $this->_lastItem[$menu_name]; $cnt++) { if ($this->tree[$cnt]["level"] == 1 && $cnt > $this->_firstItem[$menu_name]) { $t->parse("horizontal_plain_menu_cell_blck", "horizontal_plain_menu_cell", true); $t->setVar("plain_menu_cell_blck", ""); } $nbsp = ""; for ($i = 1; $i < $this->tree[$cnt]["level"]; $i++) { $nbsp .= " "; } $t->setVar(array("nbsp" => $nbsp, "link" => $this->tree[$cnt]["parsed_link"], "title" => $this->tree[$cnt]["parsed_title"], "target" => $this->tree[$cnt]["parsed_target"], "text" => $this->tree[$cnt]["parsed_text"])); $t->parse("plain_menu_cell_blck", "plain_menu_cell", true); } $t->parse("horizontal_plain_menu_cell_blck", "horizontal_plain_menu_cell", true); $this->_horizontalPlainMenu[$menu_name] = $t->parse("template_blck", "template"); return $this->_horizontalPlainMenu[$menu_name]; }
} //HTML Template for the user-specific part on the website $userTemplate = new Template("www/templates/loggedin_template.html"); //Give the template the possibility to use the UserAuthentification class. $userTemplate->setVar("UserAuthentification", $userAuth); //Array mapping a champion name to its icon. Array ( ["ChampionName"] => "Icon", ["ChampionName2"] => "Icon2" ) $champJson = cURL("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/champion?champData=image&api_key=" . $apiKey); $championData = parseChampJSON($champJson, array("Champion" => new ArrayObject(array("img" => "www/any.png", "name" => "Any Champion", "key" => "Champion"), ArrayObject::ARRAY_AS_PROPS))); //$spellData = parseSpellJSON(cURL("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/summoner-spell?spellData=image,key&api_key=" . $apiKey)); //Get all those items... $itemdata = recursiveArrayObject(collapseResultArray2($database->query("SELECT i.ID AS ItemID, i.Gold, i.Name AS ItemName, i.Description, ibi.BuildsIntoID, ibf.BuildsFromID, it.Tag FROM `Items` i LEFT JOIN `ItemBuildsFrom` ibf ON i.ID = ibf.ItemID LEFT JOIN `ItemBuildsInto` ibi ON i.ID = ibi.ItemID LEFT JOIN `ItemTags` it ON i.ID = it.ItemID"), true, true, true), ArrayObject::ARRAY_AS_PROPS); $headerTemplate = new Template("www/templates/header_template.html"); $headerTemplate->setVar("UserTemplate", $userTemplate); $headerTemplate->setVar("buttons", array(new ArrayObject(array("name" => "Home", "href" => "index.php"), ArrayObject::ARRAY_AS_PROPS), new ArrayObject(array("name" => "My Sets", "href" => "mysets.php"), ArrayObject::ARRAY_AS_PROPS))); //And then, printerino! $csTemplate = new Template("www/templates/createset_template.html"); $csTemplate->setVar("ChampionData", $championData); $csTemplate->setVar("ItemSet", $itemset); //$csTemplate->setVar("SpellData", $spellData); $csTemplate->setVar("Items", $itemdata); $csTemplate->setVar("i", 1); $csTemplate->setVar("TypusMaximusWaddafakius", $type); $csTemplate->setVar("ChampionData", $championData); $footerTemplate = new Template("www/templates/footer_template.html"); $userTemplate->prepare(); $headerTemplate->prepare(); $csTemplate->prepare(); $footerTemplate->prepare(); echo $headerTemplate->printTemplate(); echo $csTemplate->printTemplate(); echo $footerTemplate->printTemplate();
/** * @param $use * * @return string */ protected function renderNoneMethods(&$use) { $reflector = new \ReflectionClass($this->className['fullClassName']); $methodTemplate = new Template(sprintf('%s%sTemplates%sNoneMethod.tpl', __DIR__, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)); if ($reflector->isAbstract()) { $methodTemplate->setVar(array('asserter' => "testedClass\n\t\t\t\t->isAbstract()", 'className' => $this->className['className'])); } else { $interfaces = $reflector->getInterfaceNames(); if (empty($interfaces)) { if ($reflector->getParentClass()) { $use .= 'use ' . $reflector->getParentClass()->getName() . ";\n"; $components = explode('\\', $reflector->getParentClass()->getName()); $methodTemplate->setVar(array('asserter' => "testedClass\n\t\t\t\t->extends(" . array_pop($components) . "::class)", 'className' => $this->className['className'])); } else { $methodTemplate = new Template(sprintf('%s%sTemplates%sEmptyMethod.tpl', __DIR__, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)); $methodTemplate->setVar(array('className' => $this->className['className'])); } } else { $use .= 'use ' . $interfaces[0] . ";\n"; $components = explode('\\', $interfaces[0]); $methodTemplate->setVar(array('asserter' => "testedClass\n\t\t\t\t->implements(" . array_pop($components) . "::class)", 'className' => $this->className['className'])); } } return $methodTemplate->render(); }
$twentyItemSets = array(); foreach ($rawItemSets as $val) { array_push($twentyItemSets, newItemSet($database, $userAuth, $val)); } $setListTemplate = new Template("www/templates/home_setList_template.html"); $setListTemplate->setVar("ChampionData", $championData); //$setListTemplate->setVar("SpellData", $spellData); $setListTemplate->setVar("CurrentChampion", $_GET["itemsetChampion"]); $setListTemplate->setVar("ItemSets", $twentyItemSets); //Itemset-Ajax for example when updating search parameters. if (isset($_POST['itemsetAjax'])) { $setListTemplate->prepare(); echo $setListTemplate->printTemplate(); exit; } //Print all that stuff $headerTemplate = new Template("www/templates/header_template.html"); $headerTemplate->setVar("UserTemplate", $userTemplate); $headerTemplate->setVar("buttons", array(new ArrayObject(array("name" => "My Sets", "href" => "mysets.php"), ArrayObject::ARRAY_AS_PROPS), new ArrayObject(array("name" => "Create Set", "href" => "createset.php"), ArrayObject::ARRAY_AS_PROPS))); $homeTemplate = new Template("www/templates/homepage_template.html"); $homeTemplate->setVar("ChampionData", $championData); $homeTemplate->setVar("ItemSetTemplate", $setListTemplate); $footerTemplate = new Template("www/templates/footer_template.html"); $userTemplate->prepare(); $headerTemplate->prepare(); $setListTemplate->prepare(); $homeTemplate->prepare(); $footerTemplate->prepare(); echo $headerTemplate->printTemplate(); echo $homeTemplate->printTemplate(); echo $footerTemplate->printTemplate();
$champJson = cURL("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/champion?champData=image&api_key=" . $apiKey); $championData = parseChampJSON($champJson, array("Champion" => new ArrayObject(array("img" => "www/any.png", "name" => "Any Champion", "key" => "Champion"), ArrayObject::ARRAY_AS_PROPS))); //$spellData = parseSpellJSON(cURL("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/summoner-spell?spellData=image,key&api_key=" . $apiKey)); $res = $database->query("SELECT m.ItemSetID, m.ItemID, m.ItemCount, s.OwnerID, s.Title, s.Type, s.Map, s.Mode, s.Sortrank, s.Champion, IFNULL(v.Rating, 0) AS Rating, s.Date, b.Name, b.recMath, b.minSumLvl, b.maxSumLvl, b.showIfSumSpell, b.hideIfSumSpell, i.Gold, i.Name AS ItemName, i.Description, ibi.BuildsIntoID, ibf.BuildsFromID FROM `ItemSetMap` m JOIN `ItemSets` s ON m.ItemSetID = s.ID JOIN `ItemBlocks` b ON m.BlockID = b.ID JOIN `Items` i ON m.ItemID = i.ID LEFT JOIN `ItemBuildsFrom` ibf ON m.ItemID = ibf.ItemID LEFT JOIN `ItemBuildsInto` ibi ON m.ItemID = ibi.ItemID LEFT JOIN (SELECT ItemsetID, SUM(Rating) AS Rating FROM `Votes` GROUP BY ItemsetID) v ON v.ItemsetID = m.ItemSetID WHERE `OwnerID` = " . $userAuth->id . " ORDER BY `Sortrank` DESC;", false); $rawSets = collapseResultArray($res); $sets = array(); foreach ($rawSets as $rawSet) { $set = ItemSet::newSet($rawSet); $set->setEditable(true); $set->canRate(false); $set->canCopy(true); array_push($sets, $set); } $setListTemplate = new Template("www/templates/home_setList_template.html"); $setListTemplate->setVar("ChampionData", $championData); //$setListTemplate->setVar("SpellData", $spellData); $setListTemplate->setVar("ItemSets", $sets); $headerTemplate = new Template("www/templates/header_template.html"); $headerTemplate->setVar("UserTemplate", $userTemplate); $headerTemplate->setVar("buttons", array(new ArrayObject(array("name" => "Home", "href" => "index.php"), ArrayObject::ARRAY_AS_PROPS), new ArrayObject(array("name" => "Create Set", "href" => "createset.php"), ArrayObject::ARRAY_AS_PROPS))); $mysets_template = new Template("www/templates/mysets_template.html"); $mysets_template->setVar("ItemSetTemplate", $setListTemplate); $footerTemplate = new Template("www/templates/footer_template.html"); $userTemplate->prepare(); $headerTemplate->prepare(); $setListTemplate->prepare(); $mysets_template->prepare(); $footerTemplate->prepare(); echo $headerTemplate->printTemplate(); echo $mysets_template->printTemplate(); echo $footerTemplate->printTemplate();
/** * Method to prepare a new Tree Menu. * * This method processes items of a menu to prepare and return * the corresponding Tree Menu code. * * @access public * @param string $menu_name the name of the menu whose items have to be processed * @return string */ function newTreeMenu($menu_name = "") { if (!isset($this->_firstItem[$menu_name]) || !isset($this->_lastItem[$menu_name])) { $this->error("newTreeMenu: the first/last item of the menu '{$menu_name}' is not defined; please check if you have parsed its menu data."); return 0; } $this->_treeMenu[$menu_name] = ""; $img_space = $this->imgwww . "tree_space." . $this->treeMenuImagesType; $alt_space = " "; $img_vertline = $this->imgwww . "tree_vertline." . $this->treeMenuImagesType; $alt_vertline = "| "; $img_expand = $this->imgwww . "tree_expand." . $this->treeMenuImagesType; $alt_expand = "+-"; $img_expand_first = $this->imgwww . "tree_expand_first." . $this->treeMenuImagesType; $alt_expand_first = "+-"; $img_expand_corner = $this->imgwww . "tree_expand_corner." . $this->treeMenuImagesType; $alt_expand_corner = "+-"; $img_collapse = $this->imgwww . "tree_collapse." . $this->treeMenuImagesType; $alt_collapse = "--"; $img_collapse_first = $this->imgwww . "tree_collapse_first." . $this->treeMenuImagesType; $alt_collapse_first = "--"; $img_collapse_corner = $this->imgwww . "tree_collapse_corner." . $this->treeMenuImagesType; $alt_collapse_corner = "--"; $img_split = $this->imgwww . "tree_split." . $this->treeMenuImagesType; $alt_split = "|-"; $img_split_first = $this->imgwww . "tree_split_first." . $this->treeMenuImagesType; $alt_split_first = "|-"; $img_corner = $this->imgwww . "tree_corner." . $this->treeMenuImagesType; $alt_corner = "`-"; $img_folder_closed = $this->imgwww . "tree_folder_closed." . $this->treeMenuImagesType; $alt_folder_closed = "->"; $img_folder_open = $this->imgwww . "tree_folder_open." . $this->treeMenuImagesType; $alt_folder_open = "->"; $img_leaf = $this->imgwww . "tree_leaf." . $this->treeMenuImagesType; $alt_leaf = "->"; for ($i = 0; $i <= $this->_maxLevel[$menu_name]; $i++) { $levels[$i] = 0; } // Find last nodes of subtrees $last_level = $this->_maxLevel[$menu_name]; for ($i = $this->_lastItem[$menu_name]; $i >= $this->_firstItem[$menu_name]; $i--) { if ($this->tree[$i]["level"] < $last_level) { for ($j = $this->tree[$i]["level"] + 1; $j <= $this->_maxLevel[$menu_name]; $j++) { $levels[$j] = 0; } } if ($levels[$this->tree[$i]["level"]] == 0) { $levels[$this->tree[$i]["level"]] = 1; $this->tree[$i]["last_item"] = 1; } else { $this->tree[$i]["last_item"] = 0; } $last_level = $this->tree[$i]["level"]; } $toggle = ""; $toggle_function_name = "toggle" . $menu_name; for ($cnt = $this->_firstItem[$menu_name]; $cnt <= $this->_lastItem[$menu_name]; $cnt++) { $this->_treeMenu[$menu_name] .= "<div id=\"jt" . $cnt . "\" class=\"{$menu_name}_treemenudiv\">\n"; // vertical lines from higher levels for ($i = 0; $i < $this->tree[$cnt]["level"] - 1; $i++) { if ($levels[$i] == 1) { $img = $img_vertline; $alt = $alt_vertline; } else { $img = $img_space; $alt = $alt_space; } $this->_treeMenu[$menu_name] .= "<img align=\"top\" border=\"0\" class=\"imgs\" src=\"" . $img . "\" alt=\"" . $alt . "\" />"; } $not_a_leaf = $cnt < $this->_lastItem[$menu_name] && $this->tree[$cnt + 1]["level"] > $this->tree[$cnt]["level"]; if ($this->tree[$cnt]["last_item"] == 1) { // corner at end of subtree or t-split if ($not_a_leaf) { $this->_treeMenu[$menu_name] .= "<a onmousedown=\"" . $toggle_function_name . "('" . $cnt . "')\"><img align=\"top\" border=\"0\" class=\"imgs\" id=\"jt" . $cnt . "node\" src=\"" . $img_collapse_corner . "\" alt=\"" . $alt_collapse_corner . "\" /></a>"; } else { $this->_treeMenu[$menu_name] .= "<img align=\"top\" border=\"0\" class=\"imgs\" src=\"" . $img_corner . "\" alt=\"" . $alt_corner . "\" />"; } $levels[$this->tree[$cnt]["level"] - 1] = 0; } else { if ($not_a_leaf) { if ($cnt == $this->_firstItem[$menu_name]) { $img = $img_collapse_first; $alt = $alt_collapse_first; } else { $img = $img_collapse; $alt = $alt_collapse; } $this->_treeMenu[$menu_name] .= "<a onmousedown=\"" . $toggle_function_name . "('" . $cnt . "');\"><img align=\"top\" border=\"0\" class=\"imgs\" id=\"jt" . $cnt . "node\" src=\"" . $img . "\" alt=\"" . $alt . "\" /></a>"; } else { if ($cnt == $this->_firstItem[$menu_name]) { $img = $img_split_first; $alt = $alt_split_first; } else { $img = $img_split; $alt = $alt_split; } $this->_treeMenu[$menu_name] .= "<a onmousedown=\"" . $toggle_function_name . "('" . $cnt . "');\"><img align=\"top\" border=\"0\" class=\"imgs\" id=\"jt" . $cnt . "node\" src=\"" . $img . "\" alt=\"" . $alt . "\" /></a>"; } $levels[$this->tree[$cnt]["level"] - 1] = 1; } if ($this->tree[$cnt]["parsed_link"] == "" || $this->tree[$cnt]["parsed_link"] == "#") { $a_href_open_img = ""; $a_href_close_img = ""; $a_href_open = "<a class=\"{$menu_name}_phplmnormal\">"; $a_href_close = "</a>"; } else { $a_href_open_img = "<a href=\"" . $this->tree[$cnt]["parsed_link"] . "\"" . $this->tree[$cnt]["parsed_title"] . $this->tree[$cnt]["parsed_target"] . ">"; $a_href_close_img = "</a>"; $a_href_open = "<a href=\"" . $this->tree[$cnt]["parsed_link"] . "\"" . $this->tree[$cnt]["parsed_title"] . $this->tree[$cnt]["parsed_target"] . " class=\"{$menu_name}_phplm\">"; $a_href_close = "</a>"; } if ($not_a_leaf) { $this->_treeMenu[$menu_name] .= $a_href_open_img . "<img align=\"top\" border=\"0\" class=\"imgs\" id=\"jt" . $cnt . "folder\" src=\"" . $img_folder_open . "\" alt=\"" . $alt_folder_open . "\" />" . $a_href_close_img; } else { if ($this->tree[$cnt]["parsed_icon"] != "") { $this->_treeMenu[$menu_name] .= $a_href_open_img . "<img align=\"top\" border=\"0\" src=\"" . $this->imgwww . $this->tree[$cnt]["parsed_icon"] . "\" width=\"" . $this->tree[$cnt]["iconwidth"] . "\" height=\"" . $this->tree[$cnt]["iconheight"] . "\" alt=\"" . $alt_leaf . "\" />" . $a_href_close_img; } else { $this->_treeMenu[$menu_name] .= $a_href_open_img . "<img align=\"top\" border=\"0\" class=\"imgs\" src=\"" . $img_leaf . "\" alt=\"" . $alt_leaf . "\" />" . $a_href_close_img; } } $this->_treeMenu[$menu_name] .= " " . $a_href_open . $this->tree[$cnt]["text"] . $a_href_close . "\n"; $this->_treeMenu[$menu_name] .= "</div>\n"; if ($cnt < $this->_lastItem[$menu_name] && $this->tree[$cnt]["level"] < $this->tree[$cnt + 1]["level"]) { $this->_treeMenu[$menu_name] .= "<div id=\"jt" . $cnt . "son\" class=\"{$menu_name}_treemenudiv\">\n"; if ($this->tree[$cnt]["expanded"] != 1) { $toggle .= "if (expand[" . $cnt . "] != 1) " . $toggle_function_name . "('" . $cnt . "');\n"; } else { $toggle .= "if (collapse[" . $cnt . "] == 1) " . $toggle_function_name . "('" . $cnt . "');\n"; } } if ($cnt > $this->_firstItem[$menu_name] && $this->tree[$cnt]["level"] > $this->tree[$cnt + 1]["level"]) { for ($i = max(1, $this->tree[$cnt + 1]["level"]); $i < $this->tree[$cnt]["level"]; $i++) { $this->_treeMenu[$menu_name] .= "</div>\n"; } } } /* // Some (old) browsers do not support the "white-space: nowrap;" CSS property... $this->_treeMenu[$menu_name] = "<table>\n" . "<tr>\n" . "<td class=\"phplmnormal\" nowrap=\"nowrap\">\n" . $this->_treeMenu[$menu_name] . "</td>\n" . "</tr>\n" . "</table>\n"; */ $t = new Template(); $t->setFile("tplfile", $this->libjsdir . "layerstreemenu.ijs"); $t->setVar(array("menu_name" => $menu_name, "toggle_function_name" => $toggle_function_name, "img_expand" => $img_expand, "img_expand_first" => $img_expand_first, "img_collapse" => $img_collapse, "img_collapse_first" => $img_collapse_first, "img_collapse_corner" => $img_collapse_corner, "img_folder_open" => $img_folder_open, "img_expand_corner" => $img_expand_corner, "img_folder_closed" => $img_folder_closed)); $toggle_function = $t->parse("out", "tplfile"); $toggle_function = "<script language=\"JavaScript\" type=\"text/javascript\">\n" . "<!--\n" . $toggle_function . "// -->\n" . "</script>\n"; $toggle = "<script language=\"JavaScript\" type=\"text/javascript\">\n" . "<!--\n" . "if ((DOM && !Opera56 && !Konqueror2) || IE4) {\n" . $toggle . "}\n" . "if (NS4) alert('Only the accessibility is provided to Netscape 4 on the JavaScript Tree Menu.\\nWe *strongly* suggest you to upgrade your browser.');\n" . "// -->\n" . "</script>\n"; $this->_treeMenu[$menu_name] = $toggle_function . "\n" . $this->_treeMenu[$menu_name] . "\n" . $toggle; return $this->_treeMenu[$menu_name]; }
private function singlehost($host) { $this->title = sprintf(_('Host %s'), $host['hostname']); $tpl = new Template('page_hosts_singlehost.html'); if ($_SESSION['hosts'][$host['hostname']]['connected']) { $nics = 0; foreach ($_SESSION['hosts'][$host['hostname']]['hardware']->pciDevice as $device) { if ($device->classId == 512) { $nics++; } } $tpl->setVars(array('manufacturer' => $_SESSION['hosts'][$host['hostname']]['hardware']->systemInfo->vendor, 'model' => $_SESSION['hosts'][$host['hostname']]['hardware']->systemInfo->model, 'cpucores' => $_SESSION['hosts'][$host['hostname']]['hardware']->cpuInfo->numCpuCores, 'processortype' => $_SESSION['hosts'][$host['hostname']]['hardware']->cpuPkg[0]->description, 'processorsockets' => count($_SESSION['hosts'][$host['hostname']]['hardware']->cpuPkg), 'numbernics' => $nics, 'virtualmachines' => count($_SESSION['hosts'][$host['hostname']]['vm']))); $tpl->parse('connected'); $tpl->hideBlock('notconnected'); } else { $tpl->setVar('text_notconnected', _('This host is currently not connected')); $tpl->parse('notconnected'); $tpl->hideBlock('connected'); } $tpl->setVars(array('label_host' => sprintf(_('Host %s'), $host['hostname']), 'label_manufacturer' => _('Manufacturer'), 'label_model' => _('Model'), 'label_cpucores' => _('CPU cores'), 'label_processortype' => _('Processor type'), 'label_processorsockets' => _('Processor sockets'), 'label_numbernics' => _('Number of NICs'), 'label_virtualmachines' => _('Virtual machines'), 'label_editsettings' => _('Edit settings'), 'label_deletehost' => _('Delete host'), 'hostname' => $host['hostname'])); $this->html['content'] = $tpl->get(); }
private function novms($hosts) { $tpl = new Template('page_vms_novms.html'); $tpl->setVar('label_vms', _('Virtual machines')); if ($hosts) { $tpl->setVar('label_addvm', _('Add vm')); $tpl->setVar('text_novms', _('You do not have any virtual machines defined. Please use the button below to add an virtual machine.')); $tpl->parse('hashosts'); } else { $tpl->setVar('text_novms', _('You do not have any hosts defined.')); $tpl->hideBlock('hashosts'); } $this->html['content'] = $tpl->get(); }
private function send_page($page) { if (is_ajax()) { /* AJAX request: We only need to send html parts and commands generated for this page. */ require_once dirname(__FILE__) . '/pages/' . $page . '.php'; $args = func_get_args(); /* Call page object with arguments ($esxman, $database, [, $arg[, ...]]). */ $args[0] = $this->database; array_unshift($args, $this); $reflector = new ReflectionClass('page_' . $page); $object = $reflector->newInstanceArgs($args); $result = $object->html; $result['commands'] = $object->commands; /* Set inactivity timer and inventory change timer. */ if (!preg_match('/^(login|console)$/', $page)) { if (request('reason') != 'inventory') { $result['commands'][] = 'start_inactivity_timer(' . $this->config['timeout'] . ');'; } $result['commands'][] = 'get_inventory_changes();'; } echo json_encode($result); } else { /* Non-AJAX request: We need to initialize objects and timers and stuff. */ $tpl = new Template($page == 'console' ? 'console.html' : 'main.html'); $commands = array(); /* Fetch content for div elements, except main content. */ $vars = $tpl->getVars(); foreach ($vars as $var) { if (preg_match('/div$/', $var) && $var != 'contentdiv' && !isset($object->html[preg_replace('/div$/', '', $var)])) { require_once dirname(__FILE__) . '/blocks/' . preg_replace('/div$/', '', $var) . '.php'; $blockobjectname = 'block_' . preg_replace('/div$/', '', $var); $blockobject = new $blockobjectname($this->username, $this->database); $tpl->setVar($var, $blockobject->html, true); $commands = array_merge($commands, $blockobject->commands); } } /* Add javascript commands. */ $commands[] = "\$('#wrapper').css('display', 'block');"; $commands[] = "var label_bummer = '" . _('Bummer') . "';"; $commands[] = "var label_waitdotdotdot = '" . _('Wait...') . "';"; $commands[] = "var label_pleasewait = '" . _('Please wait...') . "';"; $commands[] = "var inactivity_timer = null;"; $commands[] = "var inventory_timer = null;"; $commands[] = "get(document.URL.replace(/.*(#\\/|\\?)/, ''));"; $tpl->setVar('commands', implode("\n", $commands)); echo $tpl->get(); } exit; }