This is obviously a BIG commit.
It involves how widgets work. Now widgets must always be *registered* to work, even blockparser's. Blockparser has got then a nice GUI to select which pages should be available as widgets; once the page has been enabled it is then available in the main widget panels This solves the non-editable input things with non-firefox browsers: this way you just won't have the editbox anymore :P I hope you'll like the changes. There are many additions in lang files, so be careful to update (otherwise you'll get blank lines)!
This commit is contained in:
parent
461d02ad78
commit
7414932235
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
$widget_list[$wpos][$idx] = array();
|
$widget_list[$wpos][$idx] = array();
|
||||||
|
|
||||||
@list($newid, $params) = explode(":", $wdg);
|
$newid = $wdg; # @list($newid, $params) = explode(":", $wdg);
|
||||||
|
|
||||||
$widget_list[$wpos][$idx]['id'] = $newid;
|
$widget_list[$wpos][$idx]['id'] = $newid;
|
||||||
|
|
||||||
@ -46,8 +46,13 @@
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
global $lang;
|
||||||
|
|
||||||
$widget_list[$wpos][$idx]['name'] = $newid;
|
$widget_list[$wpos][$idx]['name'] = $newid;
|
||||||
$widget_list[$wpos][$idx]['class'] = 'warnings';
|
$widget_list[$wpos][$idx]['class'] = 'errors';
|
||||||
|
|
||||||
|
$errs = sprintf($lang['admin']['widgets']['errors']['generic'], $newid);
|
||||||
|
$this->smarty->append('warnings', $errs);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,7 +68,7 @@
|
|||||||
|
|
||||||
|
|
||||||
lang_load('admin.widgets');
|
lang_load('admin.widgets');
|
||||||
$this->smarty->assign('warnings', admin_widgets_checkall());
|
# $this->smarty->assign('warnings', admin_widgets_checkall());
|
||||||
global $fp_widgets;
|
global $fp_widgets;
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
<ul id="widgetsetid-{$widgetset}">
|
<ul id="widgetsetid-{$widgetset}">
|
||||||
{foreach from=$widgetarr item=widget}
|
{foreach from=$widgetarr item=widget}
|
||||||
<li class="widget-instance widget-id-{$widget.id}">
|
<li class="widget-instance widget-id-{$widget.id} {$widget.class}">
|
||||||
<input class="widget-id" type="hidden" name="widgets[{$widgetset}][]"
|
<input class="widget-id" type="hidden" name="widgets[{$widgetset}][]"
|
||||||
value="{$widget.id}{if $widget.params}:{$widget.params}{/if}" />
|
value="{$widget.id}{if $widget.params}:{$widget.params}{/if}" />
|
||||||
{if $widget.params}
|
{if $widget.params}
|
||||||
|
@ -24,7 +24,15 @@ $fp_config = array (
|
|||||||
'dateformat' => '%A, %B %e, %Y',
|
'dateformat' => '%A, %B %e, %Y',
|
||||||
'charset' => 'utf-8',
|
'charset' => 'utf-8',
|
||||||
'lang' => 'en-us',
|
'lang' => 'en-us',
|
||||||
)
|
),
|
||||||
|
'plugins' =>
|
||||||
|
array (
|
||||||
|
'blockparser' =>
|
||||||
|
array (
|
||||||
|
'menu',
|
||||||
|
'about',
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -42,13 +42,13 @@
|
|||||||
|
|
||||||
global $fp_registered_widgets;
|
global $fp_registered_widgets;
|
||||||
|
|
||||||
|
do {
|
||||||
$content = array();
|
$content = array();
|
||||||
|
|
||||||
do {
|
|
||||||
list(,$id) = each($this->_list[$hor]);
|
list(,$id) = each($this->_list[$hor]);
|
||||||
|
|
||||||
@list($newid, $params) = explode(":", $id);
|
$newid=$id;# @list($newid, $params) = explode(":", $id);
|
||||||
if ($params) $params = explode(',', $params); else $params = array();
|
if (@$params) $params = explode(',', $params); else $params = array();
|
||||||
// $var = 'plugin_' . $newid . '_widget';
|
// $var = 'plugin_' . $newid . '_widget';
|
||||||
$var = $fp_registered_widgets[ $newid ]['func'];
|
$var = $fp_registered_widgets[ $newid ]['func'];
|
||||||
if (function_exists($var)) {
|
if (function_exists($var)) {
|
||||||
@ -65,7 +65,7 @@
|
|||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
} while(!$content);
|
} while(!$content && $id);
|
||||||
|
|
||||||
return array_change_key_case($content, CASE_LOWER);
|
return array_change_key_case($content, CASE_LOWER);
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@
|
|||||||
/* system errors */
|
/* system errors */
|
||||||
|
|
||||||
$lang['admin']['widgets']['errors'] = array(
|
$lang['admin']['widgets']['errors'] = array(
|
||||||
'generic' => 'Could not find widget in plugin <strong>%s</strong>. '.
|
'generic' => 'The widget called <strong>%s</strong> is not registered, and it might not work. '.
|
||||||
'Check if it is enabled in the <a href="admin.php?p=plugin">plugin panel</a>'
|
'Is the plugin enabled in the <a href="admin.php?p=plugin">plugin panel</a>?'
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4,19 +4,23 @@
|
|||||||
|
|
||||||
$lang['admin']['widgets']['blockparser'] = array(
|
$lang['admin']['widgets']['blockparser'] = array(
|
||||||
'head' => 'BlockParser Widgets',
|
'head' => 'BlockParser Widgets',
|
||||||
'description'=>'BlockParser plugin allows you to create a widget '.
|
'description' => 'BlockParser plugin allows you to create a widget from a static page. </p><p>
|
||||||
'from a static page. '.
|
Select one or more static pages from the list to make a corresponding widget available.</p><p>
|
||||||
'Select one or more static pages from the list to make a '.
|
Each <a href="?p=static&action=write">new static page</a> you create will be listed here.',
|
||||||
' corresponding widget available.',
|
|
||||||
|
|
||||||
|
'id' => 'Static page',
|
||||||
'title' => 'Title',
|
'title' => 'Title',
|
||||||
|
'action' => 'Action',
|
||||||
'enable' => 'Enable',
|
'enable' => 'Enable',
|
||||||
'disable' => 'Disable',
|
'disable' => 'Disable',
|
||||||
|
'edit' => 'Edit',
|
||||||
|
|
||||||
);
|
);
|
||||||
$lang['admin']['plugin']['blockparser']['msgs'] = array(
|
$lang['admin']['widgets']['blockparser']['msgs'] = array(
|
||||||
1 => 'The new widget is available. Activate it from the main panel!',
|
1 => 'Your new widget is available. Add it to your blog from the <a href="?p=widgets">main panel!</a>',
|
||||||
-1 => 'Can\'t create the requested widget'
|
-1 => 'Can\'t create the requested widget',
|
||||||
|
2 => 'You have disabled a widget: don\'t forget to remove any references from the <a href="?p=widgets">main panel</a>!',
|
||||||
|
-2 => 'Can\'t disable the widget'
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -27,7 +27,7 @@ function plugin_blockparser_parse($blockid) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
register_widget('blockparser', 'BlockParser', 'plugin_blockparser_widget', 1);
|
# register_widget('blockparser', 'BlockParser', 'plugin_blockparser_widget', 1);
|
||||||
|
|
||||||
function plugin_blockparser_widget($blockid) {
|
function plugin_blockparser_widget($blockid) {
|
||||||
|
|
||||||
@ -44,8 +44,6 @@ function plugin_blockparser_widget($blockid) {
|
|||||||
|
|
||||||
|
|
||||||
function plugin_blockparser_init() {
|
function plugin_blockparser_init() {
|
||||||
global $fp_config;
|
|
||||||
|
|
||||||
|
|
||||||
// for instance:
|
// for instance:
|
||||||
// $fp_config['plugins']['blockparser']['pages'] = array('menu');
|
// $fp_config['plugins']['blockparser']['pages'] = array('menu');
|
||||||
@ -57,58 +55,75 @@ function plugin_blockparser_init() {
|
|||||||
// this would suggest to use an object, though :B
|
// this would suggest to use an object, though :B
|
||||||
// anyway the result is the same...
|
// anyway the result is the same...
|
||||||
|
|
||||||
/*
|
$pgs = plugin_getoptions('blockparser', 'pages');
|
||||||
if (isset($fp_config['plugins']['blockparser'])) {
|
if (is_array($pgs)) {
|
||||||
$pgs = $fp_config['plugins']['blockparser']['pages'];
|
|
||||||
foreach ($pgs as $page) {
|
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');
|
add_action('init', 'plugin_blockparser_init');
|
||||||
|
|
||||||
if (false and class_exists('AdminPanelAction')){
|
if (class_exists('AdminPanelAction')){
|
||||||
|
|
||||||
class admin_widgets_blockparser extends AdminPanelAction {
|
class admin_widgets_blockparser extends AdminPanelAction {
|
||||||
|
|
||||||
var $langres = 'plugin:blockparser';
|
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() {
|
function setup() {
|
||||||
$this->smarty->assign('admin_resource', "plugin:blockparser/admin.plugin.blockparser");
|
$this->smarty->assign('admin_resource', "plugin:blockparser/admin.plugin.blockparser");
|
||||||
|
$this->smarty->assign('enabledlist', $this->bp_enabled = plugin_getoptions('blockparser', 'pages'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
global $fp_config;
|
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());
|
$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);
|
admin_addpanelaction('widgets', 'blockparser', true);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
{*assign var="ps" value=`$panelstrings.blockparser`*}
|
<h2>{$plang.head}</h2>
|
||||||
{*assign var="panelstrings" value=`$panelstrings.blockparser`*}
|
<p>{$plang.description}</p>
|
||||||
<h2>{$ps.head}</h2>
|
|
||||||
<p>{$ps.description}</p>
|
|
||||||
|
|
||||||
{include file=shared:errorlist.tpl}
|
{include file=shared:errorlist.tpl}
|
||||||
{static_block}
|
{static_block}
|
||||||
@ -12,11 +10,40 @@
|
|||||||
|
|
||||||
<table class="entrylist">
|
<table class="entrylist">
|
||||||
<thead>
|
<thead>
|
||||||
<tr><th>{$panelstrings.title}</th>
|
<tr>
|
||||||
<th>{$panelstrings.enable}</th></tr></thead>
|
<th>{$plang.id}</th>
|
||||||
|
<th>{$panelstrings.title}</th>
|
||||||
|
<th>{$panelstrings.action}</th></tr></thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{static}
|
{static}
|
||||||
<tr>
|
|
||||||
|
{assign var=inarr value=$id|in_array:$enabledlist}
|
||||||
|
<tr{if $inarr} class="enabled" {/if}>
|
||||||
|
<td> {$id} </td>
|
||||||
|
<td class="main-cell"> {$subject} </td>
|
||||||
|
<td>
|
||||||
|
<a
|
||||||
|
class="link-general"
|
||||||
|
href="{"?p=static"|action_link:write}&page={$id}">
|
||||||
|
{$panelstrings.edit}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{if $inarr}
|
||||||
|
|
||||||
|
<a class="link-disable"
|
||||||
|
href="{$action_url|cmd_link:disable:$id}">
|
||||||
|
{$panelstrings.disable}
|
||||||
|
</a>
|
||||||
|
{else}
|
||||||
|
<a class="link-enable"
|
||||||
|
href="{$action_url|cmd_link:enable:$id}">
|
||||||
|
{$panelstrings.enable}
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{*** <tr>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<a href="admin.php?p=static&page={$id}&action=write">{$subject|truncate:70}</a>
|
<a href="admin.php?p=static&page={$id}&action=write">{$subject|truncate:70}</a>
|
||||||
@ -24,7 +51,7 @@
|
|||||||
<td>enable/disable</td>
|
<td>enable/disable</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
***}
|
||||||
{/static}
|
{/static}
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user