]> git.mxchange.org Git - friendica-addons.git/commitdiff
[mathjax] Move settings template to separate file
authorHypolite Petovan <mrpetovan@gmail.com>
Fri, 21 Sep 2018 01:48:46 +0000 (21:48 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Fri, 21 Sep 2018 01:48:46 +0000 (21:48 -0400)
mathjax/mathjax.php
mathjax/templates/settings.tpl [new file with mode: 0644]

index a4e8fe05e707146a0730d866376ab027a6073e14..9aa0702724a52cc08ddf97431f10387b4c28e021 100644 (file)
@@ -34,11 +34,7 @@ function mathjax_uninstall()
 
 function mathjax_settings_post($a)
 {
-       if (!local_user()) {
-               return;
-       }
-
-       if (empty($_POST['mathjax-submit'])) {
+       if (!local_user() || empty($_POST['mathjax-submit'])) {
                return;
        }
 
@@ -52,21 +48,14 @@ function mathjax_settings(App $a, &$s)
        }
 
        $use = PConfig::get(local_user(), 'mathjax', 'use', false);
-       $usetext = $use ? ' checked="checked" ' : '';
-       $s .= '<span id="settings_mathjax_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_mathjax_expanded\'); openClose(\'settings_mathjax_inflated\');">';
-       $s .= '<h3>MathJax ' . L10n::t('Settings') . '</h3>';
-       $s .= '</span>';
-       $s .= '<div id="settings_mathjax_expanded" class="settings-block" style="display: none;">';
-       $s .= '<span class="fakelink" onclick="openClose(\'settings_mathjax_expanded\'); openClose(\'settings_mathjax_inflated\');">';
-       $s .= '<h3>MathJax ' . L10n::t('Settings') . '</h3>';
-       $s .= '</span>';
-       $s .= '<p>' . L10n::t('The MathJax addon renders mathematical formulae written using the LaTeX syntax surrounded by the usual $$ or an eqnarray block in the postings of your wall,network tab and private mail.') . '</p>';
-       $s .= '<label id="mathjax_label" for="mathjax_use">' . L10n::t('Use the MathJax renderer') . '</label>';
-       $s .= '<input id="mathjax_use" type="checkbox" name="mathjax_use" value="1"' . $usetext . ' />';
-       $s .= '<div class="clear"></div>';
 
-       $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="mathjax-submit" name="mathjax-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div>';
-       $s .= '</div>';
+       $tpl = get_markup_template('settings.tpl', __DIR__);
+       $s .= replace_macros($tpl, [
+               '$title'        => 'MathJax',
+               '$description'  => L10n::t('The MathJax addon renders mathematical formulae written using the LaTeX syntax surrounded by the usual $$ or an eqnarray block in the postings of your wall,network tab and private mail.'),
+               '$mathjax_use'  => ['mathjax_use', L10n::t('Use the MathJax renderer'), $use, ''],
+               '$savesettings' => L10n::t('Save Settings'),
+       ]);
 }
 
 function mathjax_footer(App $a, &$b)
diff --git a/mathjax/templates/settings.tpl b/mathjax/templates/settings.tpl
new file mode 100644 (file)
index 0000000..98bdb85
--- /dev/null
@@ -0,0 +1,16 @@
+
+<span id="settings_mathjax_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_mathjax_expanded'); openClose('settings_mathjax_inflated');">
+       <h3>{{$title}}</h3>
+</span>
+<div id="settings_mathjax_expanded" class="settings-block" style="display: none;">
+       <span class="fakelink" onclick="openClose('settings_mathjax_expanded'); openClose('settings_mathjax_inflated');">
+               <h3>{{$title}}</h3>
+       </span>
+       <p>{{$description}}</p>
+       {{include file="field_checkbox.tpl" field=$mathjax_use}}
+       <div class="clear"></div>
+
+       <div class="settings-submit-wrapper">
+               <button type="submit" id="mathjax-submit" name="mathjax-submit" class="settings-submit" value="1">{{$savesettings}}</button>
+       </div>
+</div>
\ No newline at end of file