Merge pull request #1219 from annando/rendertime

Rendertime: Admin configuration added
pull/1220/head
Philipp 2021-12-12 23:14:38 +01:00 committed by GitHub
commit d672029da0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 3 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-01 18:15+0100\n" "POT-Creation-Date: 2021-12-12 22:09+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,14 +17,36 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: rendertime.php:36 #: rendertime.php:30
msgid "Save Settings"
msgstr ""
#: rendertime.php:31
msgid "Show callstack"
msgstr ""
#: rendertime.php:31
msgid ""
"Show detailed performance measures in the callstack. When deactivated, only "
"the summary will be displayed."
msgstr ""
#: rendertime.php:32
msgid "Minimal time"
msgstr ""
#: rendertime.php:32
msgid "Minimal time that an activity needs to be listed in the callstack."
msgstr ""
#: rendertime.php:57
#, php-format #, php-format
msgid "" msgid ""
"Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: " "Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: "
"%s, Total: %s" "%s, Total: %s"
msgstr "" msgstr ""
#: rendertime.php:53 #: rendertime.php:74
#, php-format #, php-format
msgid "Class-Init: %s, Boot: %s, Init: %s, Content: %s, Other: %s, Total: %s" msgid "Class-Init: %s, Boot: %s, Init: %s, Content: %s, Other: %s, Total: %s"
msgstr "" msgstr ""

View File

@ -8,15 +8,36 @@
*/ */
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
function rendertime_install() { function rendertime_install() {
Hook::register('page_end', 'addon/rendertime/rendertime.php', 'rendertime_page_end'); Hook::register('page_end', 'addon/rendertime/rendertime.php', 'rendertime_page_end');
DI::config()->set('system', 'profiler', true);
}
function rendertime_uninstall() {
DI::config()->delete('system', 'profiler');
} }
function rendertime_init_1(&$a) { function rendertime_init_1(&$a) {
} }
function rendertime_addon_admin(&$a, &$o) {
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/rendertime/");
$o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'),
'$callstack' => ['callstack', DI::l10n()->t('Show callstack'), DI::config()->get('rendertime', 'callstack'), DI::l10n()->t('Show detailed performance measures in the callstack. When deactivated, only the summary will be displayed.')],
'$minimal_time' => ['minimal_time', DI::l10n()->t('Minimal time'), DI::config()->get('rendertime', 'minimal_time'), DI::l10n()->t('Minimal time that an activity needs to be listed in the callstack.')],
]);
}
function rendertime_addon_admin_post(&$a) {
DI::config()->set('rendertime', 'callstack', $_POST['callstack'] ?? false);
DI::config()->set('rendertime', 'minimal_time', $_POST['minimal_time'] ?? 0);
}
/** /**
* @param Friendica\App $a * @param Friendica\App $a
* @param string $o * @param string $o

View File

@ -0,0 +1,3 @@
{{include file="field_checkbox.tpl" field=$callstack}}
{{include file="field_input.tpl" field=$minimal_time}}
<div class="submit"><button type="submit" class="btn btn-primary" name="page_site" value="{{$submit}}">{{$submit}}</button></div>