'BlockParser::Error',
'content' => "
- Error parsing block $blockid; file may not exist
"
);
}
function plugin_blockparser_init() {
// for instance:
// $fp_config['plugins']['blockparser']['pages'] = array('menu');
// (these will) be registered from the panel
// in this case functions are just a convenient way
// to create new instances of the plugin_blockparser_widget() function...
// this would suggest to use an object, though :B
// anyway the result is the same...
$pgs = plugin_getoptions('blockparser', 'pages');
if (is_array($pgs)) {
foreach ($pgs as $page) {
register_widget('blockparser:' . $page, // widget id
'BlockParser: ' . $page, // widget name
function () use ($page) {
return plugin_blockparser_widget($page);
} // lambda func
);
}
}
}
add_action('init', 'plugin_blockparser_init');
if (class_exists('AdminPanelAction')) {
class admin_widgets_blockparser extends AdminPanelAction {
var $langres = 'plugin:blockparser';
var $commands = array(
'enable',
'disable'
);
var $bp_enabled;
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->assignByRef('enabledpages', plugin_getoptions('blockparser'));
$this->smarty->assign('statics', $assign = static_getlist());
}
}
admin_addpanelaction('widgets', 'blockparser', true);
}
?>