From 7414932235bb08606e36aca98497a89ea24763b7 Mon Sep 17 00:00:00 2001
From: real_nowhereman
{foreach from=$widgetarr item=widget}
-
+ Select one or more static pages from the list to make a corresponding widget available.
+ Each new static page you create will be listed here.', + + 'id' => 'Static page', 'title' => 'Title', + 'action' => 'Action', 'enable' => 'Enable', 'disable' => 'Disable', + 'edit' => 'Edit', ); - $lang['admin']['plugin']['blockparser']['msgs'] = array( - 1 => 'The new widget is available. Activate it from the main panel!', - -1 => 'Can\'t create the requested widget' + $lang['admin']['widgets']['blockparser']['msgs'] = array( + 1 => 'Your new widget is available. Add it to your blog from the main panel!', + -1 => 'Can\'t create the requested widget', + 2 => 'You have disabled a widget: don\'t forget to remove any references from the main panel!', + -2 => 'Can\'t disable the widget' ); ?> diff --git a/fp-plugins/blockparser/plugin.blockparser.php b/fp-plugins/blockparser/plugin.blockparser.php index c0d5910..7134cfe 100644 --- a/fp-plugins/blockparser/plugin.blockparser.php +++ b/fp-plugins/blockparser/plugin.blockparser.php @@ -27,7 +27,7 @@ function plugin_blockparser_parse($blockid) { return false; } -register_widget('blockparser', 'BlockParser', 'plugin_blockparser_widget', 1); +# register_widget('blockparser', 'BlockParser', 'plugin_blockparser_widget', 1); function plugin_blockparser_widget($blockid) { @@ -44,8 +44,6 @@ function plugin_blockparser_widget($blockid) { function plugin_blockparser_init() { - global $fp_config; - // for instance: // $fp_config['plugins']['blockparser']['pages'] = array('menu'); @@ -57,58 +55,75 @@ function plugin_blockparser_init() { // this would suggest to use an object, though :B // anyway the result is the same... - /* - if (isset($fp_config['plugins']['blockparser'])) { - $pgs = $fp_config['plugins']['blockparser']['pages']; + $pgs = plugin_getoptions('blockparser', 'pages'); + if (is_array($pgs)) { foreach ($pgs as $page) { - register_widget($page, create_function('', "return plugin_blockparser_widget('$page');")); + register_widget( + 'blockparser:'.$page, // widget id + 'BlockParser: ' .$page, // widget name + create_function('', "return plugin_blockparser_widget('$page');") // lambda func + ); } } - */ + } add_action('init', 'plugin_blockparser_init'); -if (false and class_exists('AdminPanelAction')){ +if (class_exists('AdminPanelAction')){ class admin_widgets_blockparser extends AdminPanelAction { var $langres = 'plugin:blockparser'; + var $commands = array('enable', 'disable'); + + function doenable($id) { + $success = -1; + $enabled =& $this->bp_enabled; + if (static_exists($id)) { + if (!$enabled) { + $enabled = array(); + } + if (!in_array($id, $enabled)) { + $enabled[] = $id; + sort($enabled); + plugin_addoption('blockparser', 'pages', $enabled); + plugin_saveoptions(); + $success = 1; + } + } + $this->smarty->assign('success', $success); + return PANEL_REDIRECT_CURRENT; + } + + function dodisable($id) { + $success = -2; + $enabled =& $this->bp_enabled; + if ($enabled && is_numeric( $v = array_search($id, $enabled ) ) ) { + unset($enabled[$v]); + @sort($enabled); + @plugin_addoption('blockparser', 'pages', $enabled); + plugin_saveoptions(); + $success = 2; + } + $this->smarty->assign('success', $success); + return PANEL_REDIRECT_CURRENT; + } function setup() { $this->smarty->assign('admin_resource', "plugin:blockparser/admin.plugin.blockparser"); + $this->smarty->assign('enabledlist', $this->bp_enabled = plugin_getoptions('blockparser', 'pages')); } + function main() { global $fp_config; - $this->smarty->assign_by_ref('enabledpages', $fp_config['plugins']['blockparser']); + // $this->smarty->assign_by_ref('enabledpages', plugin_getoptions('blockparser')); $this->smarty->assign('statics', $assign = static_getlist()); } - - function onsubmit() { - global $fp_config; - - if ($_POST['wp-apikey']){ - - $fp_config['plugins']['akismet']['apikey'] = $_POST['wp-apikey']; - - config_save(); - - $this->smarty->assign('success', 1); - } else { - $this->smarty->assign('success', -1); - } - - - // redirect to this panel (clears POSTDATA; - // 1 would redirect to the default 'action' for widget panel) - - return 2; - } - } admin_addpanelaction('widgets', 'blockparser', true); diff --git a/fp-plugins/blockparser/tpls/admin.plugin.blockparser.tpl b/fp-plugins/blockparser/tpls/admin.plugin.blockparser.tpl index 3a28259..8f9fe41 100644 --- a/fp-plugins/blockparser/tpls/admin.plugin.blockparser.tpl +++ b/fp-plugins/blockparser/tpls/admin.plugin.blockparser.tpl @@ -1,7 +1,5 @@ -{*assign var="ps" value=`$panelstrings.blockparser`*} -{*assign var="panelstrings" value=`$panelstrings.blockparser`*} -
{$ps.description}
+{$plang.description}
{include file=shared:errorlist.tpl} {static_block} @@ -12,11 +10,40 @@{$panelstrings.title} | -{$panelstrings.enable} | |
---|---|---|
{$plang.id} | +{$panelstrings.title} | +{$panelstrings.action} |
{$id} | +{$subject} | ++ + {$panelstrings.edit} + + + {if $inarr} + + + {$panelstrings.disable} + + {else} + + {$panelstrings.enable} + + {/if} + | +
{$subject|truncate:70} @@ -24,7 +51,7 @@ | enable/disable |