X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=showmore_dyn%2Fshowmore_dyn.php;h=bf8f5608dc1d80004c35509cdd97660568937f4b;hb=2dbcc42384b85e5253b939f528236f41909b1596;hp=b38231fac1ecd0f85f0f4bac47e43561ae422b22;hpb=ed45145415b2789f06632a9b75b53aa87c5e377e;p=friendica-addons.git
diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php
index b38231fa..bf8f5608 100644
--- a/showmore_dyn/showmore_dyn.php
+++ b/showmore_dyn/showmore_dyn.php
@@ -15,21 +15,13 @@ use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
-function showmore_dyn_install() {
- Hook::register('page_end', 'addon/showmore_dyn.php/showmore_dyn.php', 'showmore_dyn_script');
- Hook::register('head' , __FILE__, 'showmore_dyn_head');
- Hook::register('footer', __FILE__, 'showmore_dyn_footer');
- Hook::register('addon_settings', 'addon/showmore_dyn/showmore_dyn.php', 'showmore_dyn_settings');
- Hook::register('addon_settings_post', 'addon/showmore_dyn/showmore_dyn.php', 'showmore_dyn_settings_post');
-}
-
-function showmore_dyn_uninstall()
+function showmore_dyn_install()
{
- Hook::unregister('page_end', 'addon/jappixmini/jappixmini.php', 'jappixmini_script');
- Hook::unregister('head' , __FILE__, 'showmore_dyn_head');
- Hook::unregister('footer', __FILE__, 'showmore_dyn_footer');
- Hook::unregister('addon_settings', 'addon/showmore_dyn/showmore_dyn.php', 'showmore_dyn_settings');
- Hook::unregister('addon_settings_post', 'addon/showmore_dyn/showmore_dyn.php', 'showmore_dyn_settings_post');
+ Hook::register('page_end', __FILE__, 'showmore_dyn_script');
+ Hook::register('head', __FILE__, 'showmore_dyn_head');
+ Hook::register('footer', __FILE__, 'showmore_dyn_footer');
+ Hook::register('addon_settings', __FILE__, 'showmore_dyn_settings');
+ Hook::register('addon_settings_post', __FILE__, 'showmore_dyn_settings_post');
}
function showmore_dyn_head(App $a, &$b)
@@ -42,43 +34,43 @@ function showmore_dyn_footer(App $a, &$b)
DI::page()->registerFooterScript(__DIR__ . '/showmore_dyn.js');
}
-function showmore_dyn_settings_post(){
- if(! local_user())
- return;
- if (isset($_POST['showmore_dyn-submit'])){
- $limitHeight = $_POST['showmore_dyn_height'];
- DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight);
-
-/*
- $str=file_get_contents('addon/showmore_dyn/showmore_dyn.css');
- $str=preg_replace("/(max-height: )\d+(px;)/i", "max-height: " . $limitHeight . "px;" ,$str);
- file_put_contents('addon/showmore_dyn/showmore_dyn.css', $str);
+function showmore_dyn_settings_post()
+{
+ if(!local_user()) {
+ return;
+ }
- $str=file_get_contents('addon/showmore_dyn/showmore_dyn.js');
- $str=preg_replace('/if \(\$item.height\(\) \< \d+\) \{/i', 'if ($item.height() < ' . $limitHeight . ') {' ,$str);
- file_put_contents('addon/showmore_dyn/showmore_dyn2.js', $str);*/
- }
+ if (isset($_POST['showmore_dyn-submit'])) {
+ DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $_POST['limitHeight'] ?? 0);
+ }
}
-function showmore_dyn_settings(&$a,&$o) {
- if(! local_user())
- return;
-
+function showmore_dyn_settings(App &$a, &$o)
+{
+ if(!local_user()) {
+ return;
+ }
- $limitHeight = DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight' );
- if ($limitHeight=='') { $limitHeight = 250; DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight); }
+ $limitHeight = DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight', 250);
+ DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight);
- $t = Renderer::getMarkupTemplate("settings.tpl", "addon/showmore_dyn/");
- $o .= Renderer::replaceMacros($t, [
- '$submit' => DI::l10n()->t('Save Settings'),
- '$title' => "Showmore Dynamic",
- '$label' => DI::l10n()->t('Limit Height'),
- '$limitHeight' => $limitHeight,
- ]);
+ $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/showmore_dyn/');
+ $o .= Renderer::replaceMacros($t, [
+ '$submit' => DI::l10n()->t('Save Settings'),
+ '$header' => DI::l10n()->t('Show More Dynamic'),
+ '$limitHeight' => ['limitHeight', DI::l10n()->t('Limit Height'), $limitHeight, DI::l10n()->t('The maximal pixel height of posts before the Show More link is added, 0 to disable'), '', '', 'number'],
+ ]);
}
-function showmore_dyn_script() {
- $limitHeight = DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight' );
- DI::page()['htmlhead'] .= '';
+function showmore_dyn_script()
+{
+ $limitHeight = intval(DI::pConfig()->get(local_user(), 'showmore_dyn', 'limitHeight', 250));
+ $showmore_dyn_showmore_linktext = DI::l10n()->t('Show more...');
+ DI::page()['htmlhead'] .= <<
+ var postLimitHeight = $limitHeight;
+ var showmore_dyn_showmore_linktext = "$showmore_dyn_showmore_linktext";
+
+EOT;
}