]> git.mxchange.org Git - friendica.git/commitdiff
simple plugin details and log view in admin
authorFabio Comuni <fabrix.xm@gmail.com>
Tue, 14 Jun 2011 09:54:14 +0000 (11:54 +0200)
committerFabio Comuni <fabrix.xm@gmail.com>
Tue, 14 Jun 2011 09:54:14 +0000 (11:54 +0200)
mod/admin.php
view/admin_logs.tpl [new file with mode: 0644]
view/admin_plugins_details.tpl [new file with mode: 0644]

index 054b49a2117da46665c9cfdc52b3c0aaf1aaaa2b..e40c5039624b44702adcdadc1fd5a11b6ea048f0 100644 (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),
+       ));
+}
+
diff --git a/view/admin_logs.tpl b/view/admin_logs.tpl
new file mode 100644 (file)
index 0000000..f2939a7
--- /dev/null
@@ -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>
diff --git a/view/admin_plugins_details.tpl b/view/admin_plugins_details.tpl
new file mode 100644 (file)
index 0000000..7e2e955
--- /dev/null
@@ -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>