Blockparser plugin: Replaced deprecated create_function() call with anonymous function;
FootNotes plugin: Renamed class-named constructor to "__construct"
This commit is contained in:
parent
6bae0cde9d
commit
a6188978d8
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Plugin Name: BlockParser
|
||||
Plugin URI: http://www.nowhereland.it/
|
||||
Type: Block
|
||||
Description: BlockParser plugin. Part of the standard distribution ;) This allow you to use simple non-plugin custom blocks :)
|
||||
Author: NoWhereMan real_nowhereman at user dot sf dot net
|
||||
Version: 1.0
|
||||
Author URI: http://www.nowhereland.it/
|
||||
* Plugin Name: BlockParser
|
||||
* Plugin URI: http://www.nowhereland.it/
|
||||
* Type: Block
|
||||
* Description: BlockParser plugin. Part of the standard distribution ;) This allow you to use simple non-plugin custom blocks :)
|
||||
* Author: NoWhereMan real_nowhereman at user dot sf dot net
|
||||
* Version: 1.0
|
||||
* Author URI: http://www.nowhereland.it/
|
||||
*/
|
||||
|
||||
// define('BLOCKS_DIR', CONTENT_DIR . 'blocks/');
|
||||
@ -16,9 +16,7 @@ Author URI: http://www.nowhereland.it/
|
||||
// so you can edit blocks using the static editor!!
|
||||
define('BLOCKS_DIR', STATIC_DIR);
|
||||
|
||||
|
||||
function plugin_blockparser_parse($blockid) {
|
||||
|
||||
if ($f_contents = io_load_file(BLOCKS_DIR . $blockid . EXT)) {
|
||||
$contents = utils_kexplode($f_contents);
|
||||
return array_change_key_case($contents, CASE_LOWER);
|
||||
@ -27,10 +25,8 @@ 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) {
|
||||
|
||||
if ($contents = plugin_blockparser_parse($blockid)) {
|
||||
$contents ['subject'] = apply_filters('the_title', $contents ['subject']);
|
||||
$contents ['content'] = apply_filters('the_content', $contents ['content']);
|
||||
@ -38,11 +34,12 @@ function plugin_blockparser_widget($blockid) {
|
||||
return $contents;
|
||||
}
|
||||
|
||||
return array( 'subject' => 'BlockParser::Error',
|
||||
'content' => "<ul><li>Error parsing block $blockid; file may not exist</li></ul>" );
|
||||
return array(
|
||||
'subject' => 'BlockParser::Error',
|
||||
'content' => "<ul><li>Error parsing block $blockid; file may not exist</li></ul>"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function plugin_blockparser_init() {
|
||||
|
||||
// for instance:
|
||||
@ -54,19 +51,17 @@ function plugin_blockparser_init() {
|
||||
|
||||
// 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
|
||||
register_widget('blockparser:' . $page, // widget id
|
||||
'BlockParser: ' . $page, // widget name
|
||||
create_function('', "return plugin_blockparser_widget('$page');") // lambda func
|
||||
function () use ($page) {
|
||||
return plugin_blockparser_widget($page);
|
||||
} // lambda func
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
add_action('init', 'plugin_blockparser_init');
|
||||
@ -76,7 +71,11 @@ if (class_exists('AdminPanelAction')){
|
||||
class admin_widgets_blockparser extends AdminPanelAction {
|
||||
|
||||
var $langres = 'plugin:blockparser';
|
||||
var $commands = array('enable', 'disable');
|
||||
|
||||
var $commands = array(
|
||||
'enable',
|
||||
'disable'
|
||||
);
|
||||
|
||||
function doenable($id) {
|
||||
$success = -1;
|
||||
@ -116,19 +115,15 @@ if (class_exists('AdminPanelAction')){
|
||||
$this->smarty->assign('enabledlist', $this->bp_enabled = plugin_getoptions('blockparser', 'pages'));
|
||||
}
|
||||
|
||||
|
||||
function main() {
|
||||
global $fp_config;
|
||||
// $this->smarty->assign_by_ref('enabledpages', plugin_getoptions('blockparser'));
|
||||
$this->smarty->assign('statics', $assign = static_getlist());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
admin_addpanelaction('widgets', 'blockparser', true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
@ -1,21 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: FootNotes
|
||||
Version: 0.1
|
||||
Plugin URI: http://flatpress.nowhereland.it
|
||||
Description: footnotes in your entry
|
||||
Author: NoWhereMan
|
||||
Author URI: http://flatpress.nowhereland.it
|
||||
* Plugin Name: FootNotes
|
||||
* Version: 0.1
|
||||
* Plugin URI: http://flatpress.nowhereland.it
|
||||
* Description: footnotes in your entry
|
||||
* Author: NoWhereMan
|
||||
* Author URI: http://flatpress.nowhereland.it
|
||||
*/
|
||||
|
||||
define('FOOTNOTES_START', '[footnotes]');
|
||||
|
||||
class footnotes_class {
|
||||
|
||||
var $refs = false;
|
||||
|
||||
var $id = 'noid';
|
||||
|
||||
function footnotes_class($id) {
|
||||
function __construct($id) {
|
||||
if ($id)
|
||||
$this->id = $id;
|
||||
}
|
||||
@ -24,18 +24,12 @@ class footnotes_class {
|
||||
$id = $this->id;
|
||||
$this->refs = true;
|
||||
|
||||
return
|
||||
'<li>'.trim($s).
|
||||
" <a id=\"$id-fn-{$n}\" href=\"#$id-rel-{$n}\" ".
|
||||
"title=\"Back {$n}\">^top</a>".
|
||||
'</li>';
|
||||
return '<li>' . trim($s) . " <a id=\"$id-fn-{$n}\" href=\"#$id-rel-{$n}\" " . "title=\"Back {$n}\">^top</a>" . '</li>';
|
||||
}
|
||||
|
||||
function footnotes($matches) {
|
||||
|
||||
$str = '<div class="footnotes"><h4>Footnotes</h4><ol>';
|
||||
|
||||
|
||||
$lines = preg_split('|\[([0-9]+)\]|', $matches [1], -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
// first array element is always empty - remove
|
||||
@ -49,11 +43,9 @@ class footnotes_class {
|
||||
|
||||
$str .= '</ol></div>';
|
||||
return $str;
|
||||
|
||||
}
|
||||
|
||||
function references($matches) {
|
||||
|
||||
$n = $matches [1];
|
||||
|
||||
$id = $this->id;
|
||||
@ -67,16 +59,11 @@ class footnotes_class {
|
||||
function headings($matches) {
|
||||
$i = 7 - strlen($matches [1]);
|
||||
return "<h$i>{$matches[2]}</h$i>";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function plugin_footnotes_filter($text) {
|
||||
|
||||
|
||||
global $smarty;
|
||||
|
||||
$footnotes_obj = new footnotes_class($id = $smarty->get_template_vars('id'));
|
||||
@ -88,36 +75,30 @@ function plugin_footnotes_filter($text) {
|
||||
|
||||
// heading
|
||||
/*
|
||||
$text = preg_replace_callback(
|
||||
'(?<!\w)=(?=\S) (?! =) (.+?) (?<=\S) =(?!>\w)|xs'
|
||||
//'/\n(#{1,6})([^#]+)# * /',
|
||||
array(&$footnotes_obj, 'headings'),
|
||||
$text);
|
||||
|
||||
* $text = preg_replace_callback(
|
||||
* '(?<!\w)=(?=\S) (?! =) (.+?) (?<=\S) =(?!>\w)|xs'
|
||||
* //'/\n(#{1,6})([^#]+)# * /',
|
||||
* array(&$footnotes_obj, 'headings'),
|
||||
* $text);
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
$text = preg_replace_callback('|\n'. preg_quote(FOOTNOTES_START) .'\s*(.*)|sm',
|
||||
array(&$footnotes_obj, 'footnotes'),
|
||||
$text);
|
||||
$text = preg_replace_callback('|\n' . preg_quote(FOOTNOTES_START) . '\s*(.*)|sm', array(
|
||||
&$footnotes_obj,
|
||||
'footnotes'
|
||||
), $text);
|
||||
|
||||
// no [footnotes] references at the bottom of the page: stops
|
||||
if (!$footnotes_obj->refs)
|
||||
return $text;
|
||||
|
||||
$text = preg_replace_callback('|\[([0-9]+)\]|',
|
||||
array(&$footnotes_obj, 'references'),
|
||||
$text);
|
||||
|
||||
$text = preg_replace_callback('|\[([0-9]+)\]|', array(
|
||||
&$footnotes_obj,
|
||||
'references'
|
||||
), $text);
|
||||
|
||||
return $text;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
add_filter('the_content', 'plugin_footnotes_filter', 0);
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user