497a3564 by vanisha

table generation

1 parent dc218ee6
......@@ -19,13 +19,12 @@
<div class="container">
<table id="view_logs_entries_table" class="compact table table-bordered table-striped table-hover">
<thead><tr><th class="center-class">Sno</th><th class="center-class">Cron file</th><th class="center-class">Cron timing</th><th class="center-class">Cron log</th></tr></thead>
<thead><tr><th class="center-class">Sno</th><th class="center-class">Cron file</th><th class="center-class">Cron log</th></tr></thead>
<tbody>
{{#tablecontents}}
<tr>
<td class="center-class">{{sno}}</td>
<td class="center-class">{{{name}}}</td>
<td>{{{time}}}</td>
<td class="center-class">{{log}}</td>
</tr>
{{/tablecontents}}
......
......@@ -42,6 +42,7 @@ $PAGE->set_heading($pluginname);
echo $OUTPUT->header();
$date = date('d-m-y');
$templatecontext = array();
......@@ -53,7 +54,24 @@ $configpaths = get_config('block_log', 'block_log_path_info');
$isadmin = has_capability('block/log:manageall', context_system::instance());
if($isadmin) {
$templatecontext['tablecontents'] = '';
$table_content_array = array(); $i =1;
$split_paths = explode(",",$configpaths);
foreach($split_paths as $split_path) {
$files = scandir($split_path);
foreach($files as $file) {
if($file === '.' || $file === '..') {continue;}
if( (str_contains($file, $date)) && (str_contains($file, '.log'))) {
$array = array();
$array['sno'] = $i;
$array['name'] = $file;
$array['log'] = file_get_contents($split_path.'/'.$file);
$table_content_array[] = $array;
}
}
}
$templatecontext['tablecontents'] = $table_content_array;
echo $OUTPUT->render_from_template('block_log/cron_logs_view', $templatecontext);
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!