simple plugin details and log view in admin

This commit is contained in:
Fabio Comuni 2011-06-14 11:54:14 +02:00
parent 5dc8fbccb2
commit 25d1637ec4
3 changed files with 80 additions and 2 deletions

View file

@ -19,10 +19,12 @@ function admin_post(&$a){
// urls
if ($a->argc > 1){
switch ($a->argv[1]){
case 'site': {
case 'site':
admin_page_site_post($a);
break;
}
case 'logs':
admin_page_logs_post($a);
break;
}
}
@ -83,6 +85,9 @@ function admin_content(&$a) {
case 'plugins':
$o = admin_page_plugins($a);
break;
case 'logs':
$o = admin_page_logs($a);
break;
default:
notice( t("Item not found.") );
}
@ -386,3 +391,52 @@ function admin_page_plugins(&$a){
));
}
/**
* Logs admin page
*/
function admin_page_logs_post(&$a) {
if (x($_POST,"page_logs")) {
$logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
$debugging = ((x($_POST,'debugging')) ? true : false);
$loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
set_config('system','logfile', $logfile);
set_config('system','debugging', $debugging);
set_config('system','loglevel', $loglevel);
}
goaway($a->get_baseurl() . '/admin/logs' );
return; // NOTREACHED
}
function admin_page_logs(&$a){
$log_choices = Array(
LOGGER_NORMAL => 'Normal',
LOGGER_TRACE => 'Trace',
LOGGER_DEBUG => 'Debug',
LOGGER_DATA => 'Data',
LOGGER_ALL => 'All'
);
$t = get_markup_template("admin_logs.tpl");
return replace_macros($t, array(
'$title' => t('Administration'),
'$page' => t('Logs'),
'$submit' => t('Submit'),
'$clear' => t('Clear'),
'$baseurl' => $a->get_baseurl(),
'$logname' => get_config('system','logfile'),
// name, label, value, help string, extra data...
'$debugging' => array('debugging', t("Debugging"),get_config('system','debugging'), ""),
'$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), "Must be writable by web server. Relative to your Friendika index.php."),
'$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices),
));
}

17
view/admin_logs.tpl Normal file
View file

@ -0,0 +1,17 @@
<div id='adminpage'>
<h1>$title - $page</h1>
<form action="$baseurl/admin/logs" method="post">
{{ inc field_checkbox.tpl with $field=$debugging }}{{ endinc }}
{{ inc field_input.tpl with $field=$logfile }}{{ endinc }}
{{ inc field_select.tpl with $field=$loglevel }}{{ endinc }}
<div class="submit"><input type="submit" name="page_logs" value="$submit" /></div>
</form>
<h3>$logname</h3>
<iframe src='$baseurl/$logname' style="width:100%; height:400px"></iframe>
<!-- <div class="submit"><input type="submit" name="page_logs_clear_log" value="$clear" /></div> -->
</div>

View file

@ -0,0 +1,7 @@
<div id='adminpage'>
<h1>$title - $page</h1>
<p><span class='icon $status'></span> $plugin</p>
<p><a href="$baseurl/admin/plugins/$plugin/?a=t">$action</a></p>
</div>