From 25d1637ec4b980d6ac8daf2f028f0ff579d5c977 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Tue, 14 Jun 2011 11:54:14 +0200 Subject: [PATCH] simple plugin details and log view in admin --- mod/admin.php | 58 ++++++++++++++++++++++++++++++++-- view/admin_logs.tpl | 17 ++++++++++ view/admin_plugins_details.tpl | 7 ++++ 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 view/admin_logs.tpl create mode 100644 view/admin_plugins_details.tpl diff --git a/mod/admin.php b/mod/admin.php index 054b49a21..e40c50396 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -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), + )); +} + diff --git a/view/admin_logs.tpl b/view/admin_logs.tpl new file mode 100644 index 000000000..f2939a7ac --- /dev/null +++ b/view/admin_logs.tpl @@ -0,0 +1,17 @@ +
+

$title - $page

+ +
+ + {{ inc field_checkbox.tpl with $field=$debugging }}{{ endinc }} + {{ inc field_input.tpl with $field=$logfile }}{{ endinc }} + {{ inc field_select.tpl with $field=$loglevel }}{{ endinc }} + +
+ +
+ +

$logname

+ + +
diff --git a/view/admin_plugins_details.tpl b/view/admin_plugins_details.tpl new file mode 100644 index 000000000..7e2e95521 --- /dev/null +++ b/view/admin_plugins_details.tpl @@ -0,0 +1,7 @@ +
+

$title - $page

+ +

$plugin

+ +

$action

+