/** * Return content for history row * */ protected function HistoryRow($time, $size, $username, $which = 'history') { global $langmessage; ob_start(); $date = \gp\tool::date($langmessage['strftime_datetime'], $time); echo '<tr><td title="' . htmlspecialchars($date) . '">'; switch ($which) { case 'current': echo '<b>' . $langmessage['Current Page'] . '</b><br/>'; break; case 'draft': echo '<b>' . $langmessage['Working Draft'] . '</b><br/>'; break; } $elapsed = \gp\admin\Tools::Elapsed(time() - $time); echo sprintf($langmessage['_ago'], $elapsed); echo '</td><td>'; if ($size && is_numeric($size)) { echo \gp\admin\Tools::FormatBytes($size); } echo '</td><td>'; if (!empty($username)) { echo $username; } echo '</td><td>'; switch ($which) { case 'current': echo \gp\tool::Link($this->title, $langmessage['View'], 'cmd=ViewCurrent', array('data-cmd' => 'cnreq')); break; case 'draft': echo \gp\tool::Link($this->title, $langmessage['View']); echo ' ' . \gp\tool::Link($this->title, $langmessage['Publish Draft'], 'cmd=PublishDraft', array('data-cmd' => 'cnreq')); break; case 'history': echo \gp\tool::Link($this->title, $langmessage['View'], 'cmd=ViewRevision&time=' . $time, array('data-cmd' => 'cnreq')); echo ' '; echo \gp\tool::Link($this->title, $langmessage['delete'], 'cmd=DeleteRevision&time=' . $time, array('data-cmd' => 'gpabox', 'class' => 'gpconfirm')); break; } echo '</td></tr>'; return ob_get_clean(); }
/** * Show files in the cache * */ protected function ShowFiles() { global $langmessage; $this->page->head_js[] = '/include/thirdparty/tablesorter/tablesorter.js'; $this->page->jQueryCode .= '$("table.tablesorter").tablesorter({cssHeader:"gp_header",cssAsc:"gp_header_asc",cssDesc:"gp_header_desc"});'; if (!$this->all_files) { return; } echo '<p>'; echo \gp\tool::Link('Admin/Cache', 'Empty Cache', 'cmd=EmptyResourceCache', array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => 'Empty the resource cache?')); echo '</p>'; echo '<table class="bordered tablesorter full_width">'; echo '<thead>'; echo '<tr><th>'; echo $langmessage['file_name']; echo '</th><th>'; echo $langmessage['File Size']; echo '</th><th>'; echo 'Touched'; echo '</th><th>'; echo $langmessage['options']; echo '</th></tr>'; echo '</thead>'; $total_size = 0; echo '<tbody>'; foreach ($this->all_files as $file) { $full = $this->cache_dir . '/' . $file; echo '<tr><td>'; echo '<a href="?cmd=ViewFile&file=' . rawurlencode($file) . '">'; echo $file; echo '</a>'; echo '</td><td>'; $size = filesize($full); echo '<span style="display:none">' . $size . '</span>'; echo \gp\admin\Tools::FormatBytes($size); $total_size += $size; echo '</td><td>'; $elapsed = \gp\admin\Tools::Elapsed(time() - filemtime($full)); echo sprintf($langmessage['_ago'], $elapsed); echo '</td><td>'; echo \gp\tool::Link('Admin/Cache', $langmessage['delete'], 'cmd=DeleteFile&file=' . rawurlencode($file), array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => $langmessage['delete_confirm'])); echo '</tr>'; } echo '</tbody>'; //totals echo '<tfoot>'; echo '<tr><td>'; echo number_format(count($this->all_files)) . ' Files'; echo '</td><td>'; echo \gp\admin\Tools::FormatBytes($total_size); echo '</td><td>'; echo '</tr>'; echo '</table>'; }
/** * Return Performance Stats about the current request * * @return array */ public static function PerformanceStats() { $stats = array(); if (function_exists('memory_get_peak_usage')) { $stats['<span cms-memory-usage>?</span>'] = \gp\admin\Tools::FormatBytes(memory_get_usage()); $stats['<span cms-memory-max>?</span>'] = \gp\admin\Tools::FormatBytes(memory_get_peak_usage()); } if (isset($_SERVER['REQUEST_TIME_FLOAT'])) { $time = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']; } else { $time = microtime(true) - gp_start_time; } $stats['<span cms-seconds>?</span>'] = round($time, 3); $stats['<span cms-ms>?</span>'] = round($time * 1000); return $stats; }
/** * Get the output formatting data for * */ public function GetReplaceData($title, $layout_info, $menu_key, $menu_value = array()) { global $langmessage, $gp_titles; $isSpecialLink = \gp\tool::SpecialOrAdmin($title); //get the data for this title $data = array('key' => $menu_key, 'url' => \gp\tool::GetUrl($title), 'title' => $title, 'special' => $isSpecialLink, 'has_layout' => !empty($gp_titles[$menu_key]['gpLayout']), 'layout_color' => $layout_info['color'], 'layout_label' => $layout_info['label'], 'types' => $gp_titles[$menu_key]['type'], 'opts' => '', 'size' => '', 'mtime' => ''); if (isset($menu_value['level'])) { $data['level'] = $menu_value['level']; } if ($isSpecialLink === false) { $file = \gp\tool\Files::PageFile($title); $stats = @stat($file); if ($stats) { $data['size'] = \gp\admin\Tools::FormatBytes($stats['size']); $data['time'] = \gp\tool::date($langmessage['strftime_datetime'], $stats['mtime']); } } ob_start(); \gp\tool\Plugins::Action('MenuPageOptions', array($title, $menu_key, $menu_value, $layout_info)); $menu_options = ob_get_clean(); if ($menu_options) { $data['opts'] = $menu_options; } return $data; }
public function Exported() { global $langmessage; if (count($this->exported) == 0) { return; } echo '<table class="bordered full_width">'; echo '<tr><th>'; echo $langmessage['Previous Exports']; echo '</th><th> </th><th>'; echo $langmessage['File Size']; echo '</th><th>'; echo $langmessage['options']; echo '</th></tr>'; $total_size = 0; $total_count = 0; foreach ($this->exported as $file) { $info = $this->FileInfo($file); if (!$info) { continue; } $full_path = $this->export_dir . '/' . $file; echo '<tr><td>'; echo str_replace(' ', ' ', $info['time']); echo '</td><td>'; echo implode(', ', $info['exported']); echo '</td><td>'; $size = filesize($full_path); echo \gp\admin\Tools::FormatBytes($size); echo ' '; echo $info['ext']; echo '</td><td>'; echo '<a href="' . \gp\tool::GetDir('/data/_exports/' . $file) . '">' . $langmessage['Download'] . '</a>'; echo ' '; if ($this->CanRevert($info['bits'])) { echo \gp\tool::Link('Admin/Port', $langmessage['Revert'], 'cmd=revert&archive=' . rawurlencode($file), '', $file); } else { echo $langmessage['Revert']; } echo ' '; echo \gp\tool::Link('Admin/Port', $langmessage['delete'], 'cmd=delete&file=' . rawurlencode($file), array('data-cmd' => 'postlink', 'title' => $langmessage['delete_confirm'], 'class' => 'gpconfirm'), $file); echo '</td></tr>'; $total_count++; $total_size += $size; } //totals echo '<tr><th>'; echo $langmessage['Total']; echo ': '; echo $total_count; echo '</th><th> </th><th>'; echo \gp\admin\Tools::FormatBytes($total_size); echo '</th><th> </th></tr>'; echo '</table>'; }