public static function render(StorageInterface $storage, $limit, $runs, $start, $page) { ?> <!DOCTYPE HTML><html> <?php HtmlHead::render('List of profiler files - SugarCRM XHProf Viewer', array('xhprof/css/xhprof.css', 'bower_components/bootstrap/dist/css/bootstrap.min.css', 'bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css', 'bower_components/font-awesome/css/font-awesome.min.css'), array('bower_components/jquery/dist/jquery.min.js', 'bower_components/bootstrap/dist/js/bootstrap.min.js', 'bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js', 'xhprof/js/list.js')); ?> <body class="container-fluid"> <form id="list-form" method="get" action=""> <input type="hidden" id="offset_hidden" name="offset" value="<?php echo CurrentPage::getParam('offset'); ?> " /> <input type="hidden" id="f_sort_by" name="f_sort_by" value="<?php echo CurrentPage::getParam('f_sort_by'); ?> " /> <input type="hidden" id="f_sort_dir" name="f_sort_dir" value="<?php echo CurrentPage::getParam('f_sort_dir'); ?> " /> <div class="page-header form-inline" style="margin-top: 20px;"> <a class="btn btn-primary pull-right" href="<?php echo CurrentPage::url(); ?> "><i class="fa fa-refresh"></i> Refresh</a> <h1>SugarCRM XHProf Viewer <small>List of profiler files in <select id="dir" name="dir" class="form-control"> <?php foreach ($storage->listDirectories() as $dir => $dirName) { ?> <option <?php if ($dir == $storage->getCurrentDirectory()) { ?> selected<?php } ?> value="<?php echo htmlspecialchars($dir); ?> "><?php echo htmlspecialchars($dirName); ?> </option> <?php } ?> </select> </small></h1> </div> <div class="navbar-collapse collapse" id="searchbar" style="padding:0;margin-bottom:20px;"> <div class="navbar-form navbar-right"> <label for="f_wt_min" style="padding-left:5px;">Min Wall Time</label> <input style="width:104px" type="text" class="form-control" autocomplete="off" placeholder="0" name="f_wt_min" id="f_wt_min" value="<?php echo htmlspecialchars(CurrentPage::getParam('f_wt_min')); ?> " /> <label for="date_1" style="padding-left:20px;">Date from</label> <input style="width:104px" type="text" class="form-control datepicker-dropdown" data-provide="datepicker" placeholder="Date From" name="f_date_from" id="date_1" value="<?php echo CurrentPage::getParam('f_date_from'); ?> " /> <label for="date_2">to</label> <input style="width:104px" type="text" class="form-control datepicker-dropdown" data-provide="datepicker" placeholder="Date To" name="f_date_to" id="date_2" value="<?php echo CurrentPage::getParam('f_date_to'); ?> " /> <button class="btn btn-default" style="margin-left:20px;" type="submit"><b>APPLY</b></button> </div> <div class="navbar-form" style="padding-left:0;"> <div class="form-group" style="display:inline;"> <div class="input-group" style="display:table;"> <span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-search"></span></span> <input class="form-control" name="f_text" placeholder="Search Here" autocomplete="off" autofocus="autofocus" type="text" value="<?php echo htmlspecialchars(CurrentPage::getParam('f_text')); ?> "> </div> </div> </div> </div> <?php $filterValues = array("f_date_from={CurrentPage::getParam('f_date_from')}", "f_date_to={CurrentPage::getParam('f_date_to')}", "f_text={CurrentPage::getParam('f_text')}"); $url = "?" . implode('&', $filterValues) . "&limit={$limit}"; $sortMarker = CurrentPage::getParam('f_sort_dir') == 'desc' ? '<span class="caret"></span>' : '<span class="dropup"><span class="caret"></span></span>'; $url .= "&offset=0"; ?> <table id="tbl" class="table table-condensed table-bordered"> <thead> <tr class="active"> <th class="align-right">#</th> <th>Profile</th> <th class="align-right sortable" ><a href="<?php echo static::thisPageFilterUrl('wt'); ?> " >Wall Time<?php echo CurrentPage::getParam('f_sort_by') == 'wt' ? $sortMarker : ''; ?> </a> </th> <th class="align-right sortable"> <a href="<?php echo static::thisPageFilterUrl('sql'); ?> " >SQL<?php echo CurrentPage::getParam('f_sort_by') == 'sql' ? $sortMarker : ''; ?> </a> </th> <th class="align-right sortable"> <a href="<?php echo static::thisPageFilterUrl('ts'); ?> " >Timestamp<?php echo CurrentPage::getParam('f_sort_by') == 'ts' ? $sortMarker : ''; ?> </a> </th> <th class="align-right">File Size</th> </tr> </thead> <tbody> <?php $lastTestTime = 0; $microtime = microtime(1); foreach ($runs['runs'] as $index => $run) { if (CurrentPage::getParam('f_sort_by') == 'ts' && (!$lastTestTime || abs($run['timestamp'] - $lastTestTime) > 5)) { ?> <tr> <td colspan="7" class="align-center age-bar"> <?php echo static::toTimePcs($microtime - $run['timestamp']); ?> ago </td> </tr> <?php } $lastTestTime = $run['timestamp']; ?> <tr class="run"> <td class="align-right"><?php echo $index + 1; ?> </td> <td><a title="<?php echo strlen($run['namespace']) > 100 ? $run['namespace'] : ''; ?> " href="<?php echo UrlHelper::url(array('dir' => $storage->getCurrentDirectory(), 'run' => $run['run'], 'source' => 'xhprof', 'list_url' => CurrentPage::url())); ?> "> <?php $name = substr($run['namespace'], 0, 100) . '' . (strlen($run['namespace']) > 100 ? ' ...' : ''); ?> <?php echo $name ? preg_replace("/" . preg_quote(CurrentPage::getParam('f_text')) . "/i", "<b style='color:black;background-color:yellow;'>\$0</b>", $name) : '-no-name-'; ?> </a> </td> <td class="align-right"><?php echo is_null($run['wall_time']) ? '-' : number_format($run['wall_time'], 0, ' ', ' '); ?> </td> <td class="align-right"> <?php echo $run['sql_queries'] === false || is_null($run['sql_queries']) ? '-' : $run['sql_queries']; ?> </td> <td class="align-right"><?php echo date('Y-m-d H:i:s', $run['timestamp']); ?> </td> <td class="align-right"><?php echo static::toBytes($run['size']); ?> </td> </tr> <?php } ?> </tbody> </table> <div class="form-inline align-center"> <?php if ($runs['total'] > $limit) { $pages = ceil($runs['total'] / $limit); $startPage = ceil($start / $limit) + 1; $startPage = $startPage ?: 1; $pagesBefore = $startPage - 1; $pagesAfter = $pages - $startPage; if ($pagesBefore > 4) { $pagesBefore = $pagesAfter < 4 ? 4 + (4 - $pagesAfter) : 4; } if ($pagesAfter + $pagesBefore > 8) { $pagesAfter = 8 - $pagesBefore; } ?> <ul class="pagination pagination-sm"> <?php $liClass = $startPage > 1 ? '' : ' class="disabled"'; ?> <li<?php echo $liClass; ?> ><a href="<?php echo CurrentPage::url(array('offset' => 0)); ?> "><<< </a></li> <li<?php echo $liClass; ?> ><a href="<?php echo CurrentPage::url(array('offset' => $page - 1)); ?> ">< </a></li> <?php for ($i = 1; $i <= $pagesBefore; $i++) { ?> <li><a href="<?php echo CurrentPage::url(array('offset' => $startPage - ($pagesBefore - $i + 1) - 1)); ?> "><?php echo $startPage - ($pagesBefore - $i + 1); ?> </a></li> <?php } ?> <li class="active"><a href="<?php echo CurrentPage::url(array('offset' => $startPage - 1)); ?> "><?php echo $startPage; ?> </a></li> <?php for ($i = 1; $i <= $pagesAfter; $i++) { ?> <li><a href="<?php echo CurrentPage::url(array('offset' => $i + $startPage - 1)); ?> "><?php echo $i + $startPage; ?> </a></li> <?php } ?> <?php $liClass = $pagesAfter > 0 ? '' : ' class="disabled"'; ?> <li<?php echo $liClass; ?> ><a href="<?php echo CurrentPage::url(array('offset' => $page + 1)); ?> "> ></a></li> <li<?php echo $liClass; ?> ><a href="<?php echo CurrentPage::url(array('offset' => $pages - 1)); ?> "> >>></a></li> </ul> <p>Filtered: <?php echo $runs['total']; ?> / Total: <?php echo $runs['grand_total']; ?> / <?php echo $pages; ?> pages</p> <?php } else { ?> <p>Filtered: <?php echo $runs['total']; ?> / Total: <?php echo $runs['grand_total']; ?> </p> <?php } ?> <p> Results per page: <select class="form-control" id="limit" name="limit"> <?php foreach (array(10, 50, 100, 500, 1000, 10000, 100000) as $val) { ?> <option value="<?php echo $val; ?> "<?php echo $val == $limit ? ' selected' : ''; ?> ><?php echo $val; ?> </option> <?php } ?> </select> </p> <?php \Sugarcrm\XHProf\Viewer\Templates\RunsList\VersionTemplate::render(); ?> </div> </form> <script type="application/javascript"> $(function () { $('[data-toggle="tooltip"]').tooltip({html: true}) }); </script> </body> </html> <?php }
public static function render($runData) { ?> <ul class="nav nav-tabs"> <li role="presentation" <?php if (!CurrentPageHelper::getParam('page')) { ?> class="active"<?php } ?> > <a href="<?php echo UrlHelper::url(array('dir' => CurrentPageHelper::getParam('dir'), 'run' => CurrentPageHelper::getParam('run'), 'list_url' => CurrentPageHelper::getParam('list_url'))); ?> ">Function Calls</a> </li> <li role="presentation" <?php if (CurrentPageHelper::getParam('page') == 'sql') { ?> class="active"<?php } ?> > <a href="<?php echo UrlHelper::url(array('dir' => CurrentPageHelper::getParam('dir'), 'run' => CurrentPageHelper::getParam('run'), 'page' => 'sql', 'list_url' => CurrentPageHelper::getParam('list_url'))); ?> ">SQL Queries <?php if (isset($runData['sql_queries'])) { ?> <span class="badge"><?php echo FormatHelper::number($runData['sql_queries']); ?> </span> <?php } ?> </a> </li> <li role="presentation" <?php if (CurrentPageHelper::getParam('page') == 'elastic') { ?> class="active"<?php } ?> > <a href="<?php echo UrlHelper::url(array('dir' => CurrentPageHelper::getParam('dir'), 'run' => CurrentPageHelper::getParam('run'), 'page' => 'elastic', 'list_url' => CurrentPageHelper::getParam('list_url'))); ?> ">Elastic Queries <?php if (isset($runData['elastic_queries'])) { ?> <span class="badge"><?php echo FormatHelper::number($runData['elastic_queries']); ?> </span> <?php } ?> </a> </li> </ul> <?php }
protected static function typeAheadUrl() { return UrlHelper::url(array('dir' => CurrentPageHelper::getParam('dir'), 'run' => CurrentPageHelper::getParam('run'))); }
protected static function callgraphUrl($symbol) { return UrlHelper::url(array('dir' => CurrentPageHelper::getParam('dir'), 'run' => CurrentPageHelper::getParam('run'), 'func' => $symbol)); }
/** * Generates a tabular report for all functions. This is the top-level report. * * @author Kannan */ function full_report($url_params, $symbol_tab) { $callgraph_report_title = '<i class="fa fa-pie-chart"></i> View Full Callgraph'; $callGraphUrl = \Sugarcrm\XHProf\Viewer\Templates\Helpers\UrlHelper::url(array('callgraph' => 1, 'dir' => CurrentPageHelper::getParam('dir'), 'run' => CurrentPageHelper::getParam('run'))); $callGraphButton = '<a class="btn btn-primary btn-sm" target="_blank" href="' . $callGraphUrl . '">' . $callgraph_report_title . '</a>'; $flat_data = array(); foreach ($symbol_tab as $symbol => $info) { $tmp = $info; $tmp["fn"] = $symbol; if (!isset($tmp['bcc'])) { $tmp['bcc'] = ''; } $flat_data[] = $tmp; } usort($flat_data, 'sort_cbk'); if (!empty($url_params['all'])) { $limit = 0; // display all rows } else { $limit = 100; // display only limited number of rows } print_flat_data('Top-Level Report ', $flat_data, $limit, $callGraphButton); }
public static function url($override = array(), $drop = array()) { return UrlHelper::url(static::getParams($override, $drop)); }