From ce803ca0ae171536185f834355d8be50c5fe0ed4 Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 14 Jun 2013 10:54:04 +0200 Subject: [PATCH] linktrimmer - frontpage option and nativ API use --- serendipity_event_linktrimmer/ChangeLog | 24 ++++++++++------- serendipity_event_linktrimmer/lang_en.inc.php | 2 ++ .../serendipity_event_linktrimmer.php | 27 +++++++++---------- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/serendipity_event_linktrimmer/ChangeLog b/serendipity_event_linktrimmer/ChangeLog index 294412ae..7695f946 100644 --- a/serendipity_event_linktrimmer/ChangeLog +++ b/serendipity_event_linktrimmer/ChangeLog @@ -1,33 +1,37 @@ +1.3: +---- +* Added new option to hide lintrimmer on backend frontpage +* Use nativ API method here - extends S9y version >= 1.3 + 1.1, 1.2: ---- - -static php5 function fixes +* Static php5 function fixes 1.0: ---- -do not show in Dashboard (POC) +* Do not show in Dashboard (POC) 0.9: ---- -added CKEDITOR ready eventData image path +* Added CKEDITOR ready eventData image path 0.8: ---- -latest: Smarty3 forward compatibility +* Latest: Smarty3 forward compatibility 0.7: ---- -Use latin1_general_cs charset due to lower/uppercase lookups, -thanks to danst0 +* Use latin1_general_cs charset due to lower/uppercase lookups, + thanks to danst0 0.6: ---- -Allow to be used in other plugins (danst0) +* Allow to be used in other plugins (danst0) 0.5: ---- -Remove unneeded die() +* Remove unneeded die() 0.1: ---- -Initial Release. See Documentation. \ No newline at end of file +* Initial Release. See Documentation. \ No newline at end of file diff --git a/serendipity_event_linktrimmer/lang_en.inc.php b/serendipity_event_linktrimmer/lang_en.inc.php index bfdfa555..7e72388d 100644 --- a/serendipity_event_linktrimmer/lang_en.inc.php +++ b/serendipity_event_linktrimmer/lang_en.inc.php @@ -9,3 +9,5 @@ define('PLUGIN_LINKTRIMMER_LINKPREFIX', 'Link prefix'); define('PLUGIN_LINKTRIMMER_LINKPREFIX_DESC', 'Enter a unique URL portion that will be used on your domain to identify the base of the linktrimmer. If you enter "l" for example, your URLs will look like http://yourblog/l/feda [with URL-Rewriting enabled] or http://yourblog/index.php?/l/feda [without URL-Rewriting]. Never leave empty, even if you have a separate domain for your short url.'); define('PLUGIN_LINKTRIMMER_DOMAIN', 'Domain'); define('PLUGIN_LINKTRIMMER_DOMAIN_DESC', 'The link that is used for the output. You could use .htaccess redirection of any other domain you own and enter that here. If you have Serendipity on http://mylongdomain.com/serendipity/ but also own http://short.com/ you could enter http://short.com/ here, and inside the .htaccess of short.com redirect everything to your longdomain: RewriteRule ^(.*)$ http://longdomain.com/serendipity/yourprefix/$1 (alternativly: redirectMatch 301 ^(.*)$ http://longdomain.com/serendipity/yourprefix/$1). URLs are then redirected twice: from your short.com to mylongdomain.com to the original URL.'); + +define('PLUGIN_LINKTRIMMER_FRONTPAGE_OPTION', 'Show linktrimmer on backend frontpage?'); diff --git a/serendipity_event_linktrimmer/serendipity_event_linktrimmer.php b/serendipity_event_linktrimmer/serendipity_event_linktrimmer.php index 40ebe26f..c13616a8 100644 --- a/serendipity_event_linktrimmer/serendipity_event_linktrimmer.php +++ b/serendipity_event_linktrimmer/serendipity_event_linktrimmer.php @@ -21,15 +21,15 @@ class serendipity_event_linktrimmer extends serendipity_event { $propbag->add('name', PLUGIN_LINKTRIMMER_NAME); $propbag->add('description', PLUGIN_LINKTRIMMER_DESC); $propbag->add('requirements', array( - 'serendipity' => '0.9', + 'serendipity' => '1.3', 'smarty' => '2.6.7', 'php' => '4.1.0' )); - $propbag->add('version', '1.2'); + $propbag->add('version', '1.3'); $propbag->add('author', 'Garvin Hicking'); $propbag->add('stackable', false); - $propbag->add('configuration', array('prefix', 'domain')); + $propbag->add('configuration', array('prefix', 'frontpage', 'domain')); $propbag->add('event_hooks', array( 'backend_frontpage_display' => true, 'css_backend' => true, @@ -56,6 +56,13 @@ class serendipity_event_linktrimmer extends serendipity_event { $propbag->add('default', 'l'); break; + case 'frontpage': + $propbag->add('type', 'boolean'); + $propbag->add('name', PLUGIN_LINKTRIMMER_FRONTPAGE_OPTION); + $propbag->add('description', ''); + $propbag->add('default', 'true'); + break; + case 'domain': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_LINKTRIMMER_DOMAIN); @@ -202,16 +209,8 @@ class serendipity_event_linktrimmer extends serendipity_event { 'linktrimmer_css' => file_get_contents(dirname(__FILE__) . '/linktrimmer.css') )); - $tfile = serendipity_getTemplateFile('plugin_linktrimmer.tpl', 'serendipityPath'); - if (!$tfile || $tfile == 'plugin_linktrimmer.tpl') { - $tfile = dirname(__FILE__) . '/plugin_linktrimmer.tpl'; - } - - $inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY]; - $serendipity['smarty']->security_settings[INCLUDE_ANY] = true; - $content = $serendipity['smarty']->fetch('file:'. $tfile); - $serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion; - echo $content; + // use nativ API here - extends S9y version >= 1.3 + echo $this->parseTemplate('plugin_linktrimmer.tpl'); } function generate_button ($txtarea) { @@ -299,7 +298,7 @@ class serendipity_event_linktrimmer extends serendipity_event { break; case 'backend_frontpage_display': - if (!isset($serendipity['plugin_dashboard_version'])) $this->show(); + if (!isset($serendipity['plugin_dashboard_version']) && serendipity_db_bool($this->get_config('frontpage', true)) ) $this->show(); break; case 'external_plugin':