__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core\output;
use core_text;
use core\check\result as check_result;
/**
* A renderer that generates output for command-line scripts.
*
* The implementation of this renderer is probably incomplete.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
* @package core
* @category output
*/
class core_renderer_cli extends core_renderer {
/**
* @var array $progressmaximums stores the largest percentage for a progress bar.
*/
private $progressmaximums = [];
/**
* Returns the page header.
*
* @return string HTML fragment
*/
public function header() {
return $this->page->heading . "\n";
}
/**
* Renders a Check API result
*
* To aid in CLI consistency this status is NOT translated and the visual
* width is always exactly 10 chars.
*
* @param check_result $result
* @return string HTML fragment
*/
protected function render_check_result(check_result $result) {
$status = $result->get_status();
$labels = [
check_result::NA => ' ' . cli_ansi_format('<colour:darkGray>') . ' NA ',
check_result::OK => ' ' . cli_ansi_format('<colour:green>') . ' OK ',
check_result::INFO => ' ' . cli_ansi_format('<colour:blue>') . ' INFO ',
check_result::UNKNOWN => ' ' . cli_ansi_format('<colour:darkGray>') . ' UNKNOWN ',
check_result::WARNING => ' ' . cli_ansi_format('<colour:black><bgcolour:yellow>') . ' WARNING ',
check_result::ERROR => ' ' . cli_ansi_format('<bgcolour:red>') . ' ERROR ',
check_result::CRITICAL => '' . cli_ansi_format('<bgcolour:red>') . ' CRITICAL ',
];
$string = $labels[$status] . cli_ansi_format('<colour:normal>');
return $string;
}
/**
* Renders a Check API result
*
* @param check_result $result
* @return string fragment
*/
public function check_result(check_result $result) {
return $this->render_check_result($result);
}
/**
* Renders a progress bar.
*
* Do not use $OUTPUT->render($bar), instead use progress_bar::create().
*
* @param progress_bar $bar The bar.
* @return string ascii fragment
*/
public function render_progress_bar(progress_bar $bar) {
global $CFG;
$size = 55; // The width of the progress bar in chars.
$ascii = "\n";
if (stream_isatty(STDOUT)) {
require_once($CFG->libdir . '/clilib.php');
$ascii .= "[" . str_repeat(' ', $size) . "] 0% \n";
return cli_ansi_format($ascii);
}
$this->progressmaximums[$bar->get_id()] = 0;
$ascii .= '[';
return $ascii;
}
/**
* Renders an update to a progress bar.
*
* Note: This does not cleanly map to a renderable class and should
* never be used directly.
*
* @param string $id
* @param float $percent
* @param string $msg Message
* @param string $estimate time remaining message
* @param bool $error (Unused in cli)
* @return string ascii fragment
*/
public function render_progress_bar_update(string $id, float $percent, string $msg, string $estimate,
bool $error = false): string {
$size = 55; // The width of the progress bar in chars.
$ascii = '';
// If we are rendering to a terminal then we can safely use ansii codes
// to move the cursor and redraw the complete progress bar each time
// it is updated.
if (stream_isatty(STDOUT)) {
$colour = $percent == 100 ? 'green' : 'blue';
$done = $percent * $size * 0.01;
$whole = floor($done);
$bar = "<colour:$colour>";
$bar .= str_repeat('█', $whole);
if ($whole < $size) {
// By using unicode chars for partial blocks we can have higher
// precision progress bar.
$fraction = floor(($done - $whole) * 8);
$bar .= core_text::substr(' ▏▎▍▌▋▊▉', $fraction, 1);
// Fill the rest of the empty bar.
$bar .= str_repeat(' ', $size - $whole - 1);
}
$bar .= '<colour:normal>';
if ($estimate) {
$estimate = "- $estimate";
}
$ascii .= '<cursor:up>';
$ascii .= '<cursor:up>';
$ascii .= sprintf("[$bar] %3.1f%% %-22s\n", $percent, $estimate);
$ascii .= sprintf("%-80s\n", $msg);
return cli_ansi_format($ascii);
}
// If we are not rendering to a tty, ie when piped to another command
// or on windows we need to progressively render the progress bar
// which can only ever go forwards.
$done = round($percent * $size * 0.01);
$delta = max(0, $done - $this->progressmaximums[$id]);
$ascii .= str_repeat('#', $delta);
if ($percent >= 100 && $delta > 0) {
$ascii .= sprintf("] %3.1f%%", $percent) . "\n$msg\n";
}
$this->progressmaximums[$id] += $delta;
return $ascii;
}
/**
* Returns a template fragment representing a Heading.
*
* @param string $text The text of the heading
* @param int $level The level of importance of the heading
* @param string $classes A space-separated list of CSS classes
* @param string $id An optional ID
* @return string A template fragment for a heading
*/
public function heading($text, $level = 2, $classes = 'main', $id = null) {
$text .= "\n";
switch ($level) {
case 1:
return '=>' . $text;
case 2:
return '-->' . $text;
default:
return $text;
}
}
/**
* Returns a template fragment representing a fatal error.
*
* @param string $message The message to output
* @param string $moreinfourl URL where more info can be found about the error
* @param string $link Link for the Continue button
* @param array $backtrace The execution backtrace
* @param null|string $debuginfo Debugging information
* @param string $errorcode
* @return string A template fragment for a fatal error
*/
public function fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = "") {
global $CFG;
$output = "!!! $message !!!\n";
if ($CFG->debugdeveloper) {
if (!empty($debuginfo)) {
$output .= $this->notification($debuginfo, 'notifytiny');
}
if (!empty($backtrace)) {
$output .= $this->notification('Stack trace: ' . format_backtrace($backtrace, true), 'notifytiny');
}
}
return $output;
}
/**
* Returns a template fragment representing a notification.
*
* @param string $message The message to print out.
* @param string $type The type of notification. See constants on \core\output\notification.
* @param bool $closebutton Whether to show a close icon to remove the notification (default true).
* @param string|null $title The title of the notification.
* @param ?string $titleicon if the title should have an icon you can give the icon name with the component
* (e.g. 'i/circleinfo, core' or 'i/circleinfo' if the icon is from core)
* @return string A template fragment for a notification
*/
public function notification($message, $type = null, $closebutton = true, ?string $title = null, ?string $titleicon = null) {
$message = clean_text($message);
if ($type === 'notifysuccess' || $type === 'success') {
return "++ $message ++\n";
}
return "!! $message !!\n";
}
/**
* There is no footer for a cli request, however we must override the
* footer method to prevent the default footer.
*/
public function footer() {
}
/**
* Render a notification (that is, a status message about something that has
* just happened).
*
* @param notification $notification the notification to print out
* @return string plain text output
*/
public function render_notification(notification $notification) {
return $this->notification($notification->get_message(), $notification->get_message_type());
}
}
// Alias this class to the old name.
// This file will be autoloaded by the legacyclasses autoload system.
// In future all uses of this class will be corrected and the legacy references will be removed.
class_alias(core_renderer_cli::class, \core_renderer_cli::class);
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| action_menu | Folder | 0777 |
|
|
| actions | Folder | 0777 |
|
|
| dynamic_tabs | Folder | 0777 |
|
|
| local | Folder | 0777 |
|
|
| progress_trace | Folder | 0777 |
|
|
| renderer_factory | Folder | 0777 |
|
|
| requirements | Folder | 0777 |
|
|
| action_link.php | File | 4.86 KB | 0777 |
|
| action_menu.php | File | 23.57 KB | 0777 |
|
| activity_header.php | File | 8.63 KB | 0777 |
|
| bootstrap_renderer.php | File | 12.05 KB | 0777 |
|
| checkbox_toggleall.php | File | 4.93 KB | 0777 |
|
| choicelist.php | File | 9.42 KB | 0777 |
|
| chooser.php | File | 3.78 KB | 0777 |
|
| chooser_item.php | File | 3.12 KB | 0777 |
|
| chooser_section.php | File | 2.25 KB | 0777 |
|
| comboboxsearch.php | File | 6.74 KB | 0777 |
|
| context_header.php | File | 6.01 KB | 0777 |
|
| core_renderer.php | File | 194.2 KB | 0777 |
|
| core_renderer_ajax.php | File | 5.7 KB | 0777 |
|
| core_renderer_cli.php | File | 9.34 KB | 0777 |
|
| core_renderer_maintenance.php | File | 7.86 KB | 0777 |
|
| custom_menu.php | File | 7.03 KB | 0777 |
|
| custom_menu_item.php | File | 7.88 KB | 0777 |
|
| datafilter.php | File | 3.45 KB | 0777 |
|
| dynamic_tabs.php | File | 2.26 KB | 0777 |
|
| external.php | File | 8.11 KB | 0777 |
|
| file_picker.php | File | 3.65 KB | 0777 |
|
| help_icon.php | File | 4.37 KB | 0777 |
|
| html_writer.php | File | 34.28 KB | 0777 |
|
| icon_system.php | File | 5.25 KB | 0777 |
|
| icon_system_font.php | File | 1.53 KB | 0777 |
|
| icon_system_fontawesome.php | File | 26.92 KB | 0777 |
|
| icon_system_standard.php | File | 1.28 KB | 0777 |
|
| image_icon.php | File | 1.27 KB | 0777 |
|
| initials_bar.php | File | 4.94 KB | 0777 |
|
| inplace_editable.php | File | 9.84 KB | 0777 |
|
| js_writer.php | File | 5.42 KB | 0777 |
|
| language_menu.php | File | 5.67 KB | 0777 |
|
| mustache_clean_string_helper.php | File | 2.17 KB | 0777 |
|
| mustache_engine.php | File | 2.62 KB | 0777 |
|
| mustache_filesystem_loader.php | File | 2.35 KB | 0777 |
|
| mustache_helper_collection.php | File | 6.96 KB | 0777 |
|
| mustache_javascript_helper.php | File | 1.9 KB | 0777 |
|
| mustache_pix_helper.php | File | 2.45 KB | 0777 |
|
| mustache_quote_helper.php | File | 1.87 KB | 0777 |
|
| mustache_shorten_text_helper.php | File | 1.76 KB | 0777 |
|
| mustache_string_helper.php | File | 2.31 KB | 0777 |
|
| mustache_template_finder.php | File | 4.12 KB | 0777 |
|
| mustache_template_source_loader.php | File | 14.9 KB | 0777 |
|
| mustache_uniqid_helper.php | File | 1.56 KB | 0777 |
|
| mustache_user_date_helper.php | File | 1.83 KB | 0777 |
|
| named_templatable.php | File | 1.23 KB | 0777 |
|
| notification.php | File | 6.41 KB | 0777 |
|
| paging_bar.php | File | 8.97 KB | 0777 |
|
| participants_action_bar.php | File | 8.83 KB | 0777 |
|
| pix_emoticon.php | File | 1.71 KB | 0777 |
|
| pix_icon.php | File | 4.89 KB | 0777 |
|
| pix_icon_font.php | File | 2.9 KB | 0777 |
|
| pix_icon_fontawesome.php | File | 1.21 KB | 0777 |
|
| plugin_renderer_base.php | File | 5.86 KB | 0777 |
|
| preferences_group.php | File | 1.62 KB | 0777 |
|
| preferences_groups.php | File | 1.47 KB | 0777 |
|
| progress_bar.php | File | 8.54 KB | 0777 |
|
| progress_trace.php | File | 1.68 KB | 0777 |
|
| renderable.php | File | 1.24 KB | 0777 |
|
| renderer_base.php | File | 16.75 KB | 0777 |
|
| routed_error_handler.php | File | 1.69 KB | 0777 |
|
| select_menu.php | File | 6.68 KB | 0777 |
|
| single_button.php | File | 7.88 KB | 0777 |
|
| single_select.php | File | 9.43 KB | 0777 |
|
| sticky_footer.php | File | 4.5 KB | 0777 |
|
| stored_progress_bar.php | File | 10.39 KB | 0777 |
|
| tabobject.php | File | 5.11 KB | 0777 |
|
| tabtree.php | File | 3.37 KB | 0777 |
|
| templatable.php | File | 1.75 KB | 0777 |
|
| theme_config.php | File | 84.2 KB | 0777 |
|
| theme_usage.php | File | 4.32 KB | 0777 |
|
| url_rewriter.php | File | 1.6 KB | 0777 |
|
| url_select.php | File | 9.63 KB | 0777 |
|
| user_picture.php | File | 13.98 KB | 0777 |
|
| xhtml_container_stack.php | File | 5.79 KB | 0777 |
|