Archived
1
0

consistent plugin usage - recententries

this and followup commits touches:
    class method parenthesis "\n{\n    <code>\n}\n",
    case break switches,
    consistent boolean usage,
    append css to eventData
    and other cleanups
This commit is contained in:
Ian
2016-01-26 13:58:54 +01:00
parent d4bfdd3039
commit d53c4c1ce9
@@ -3,6 +3,10 @@
// Contributed by Christian Machmeier <cm@redsplash.de>
// Randomizing contributed by Christian Brabandt <cb@256bit.org>
if (IN_serendipity !== true) {
die ("Don't hack!");
}
@serendipity_plugin_api::load_language(dirname(__FILE__));
class serendipity_plugin_recententries extends serendipity_plugin {
@@ -15,9 +19,9 @@ class serendipity_plugin_recententries extends serendipity_plugin {
$propbag->add('description', PLUGIN_RECENTENTRIES_BLAHBLAH);
$propbag->add('stackable', true);
$propbag->add('author', 'Christian Machmeier, Christian Brabandt, Judebert, Don Chambers');
$propbag->add('version', '2.5');
$propbag->add('version', '2.6');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'serendipity' => '1.6',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
@@ -25,63 +29,66 @@ class serendipity_plugin_recententries extends serendipity_plugin {
$propbag->add('groups', array('FRONTEND_VIEWS'));
}
function introspect_config_item($name, &$propbag) {
function introspect_config_item($name, &$propbag)
{
global $serendipity;
switch($name) {
case 'title':
$propbag->add('type', 'string');
$propbag->add('name', TITLE);
$propbag->add('description', TITLE_FOR_NUGGET);
$propbag->add('default', PLUGIN_RECENTENTRIES_TITLE);
$propbag->add('type', 'string');
$propbag->add('name', TITLE);
$propbag->add('description', TITLE_FOR_NUGGET);
$propbag->add('default', PLUGIN_RECENTENTRIES_TITLE);
break;
case 'number':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_RECENTENTRIES_NUMBER);
$propbag->add('description', PLUGIN_RECENTENTRIES_NUMBER_BLAHBLAH);
$propbag->add('default', 10);
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_RECENTENTRIES_NUMBER);
$propbag->add('description', PLUGIN_RECENTENTRIES_NUMBER_BLAHBLAH);
$propbag->add('default', 10);
break;
case 'number_from':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_RECENTENTRIES_NUMBER_FROM);
$propbag->add('description', PLUGIN_RECENTENTRIES_NUMBER_FROM_DESC);
$propbag->add('radio', array(
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_RECENTENTRIES_NUMBER_FROM);
$propbag->add('description', PLUGIN_RECENTENTRIES_NUMBER_FROM_DESC);
$propbag->add('radio', array(
'value' => array('all', 'skip'),
'desc' => array(PLUGIN_RECENTENTRIES_NUMBER_FROM_RADIO_ALL, PLUGIN_RECENTENTRIES_NUMBER_FROM_RADIO_RECENT)
));
$propbag->add('default', 'all');
break;
$propbag->add('default', 'all');
break;
case 'randomize':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_RECENTENTRIES_RANDOMIZE);
$propbag->add('description', PLUGIN_RECENTENTRIES_RANDOMIZE_DESC);
$propbag->add('radio', array(
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_RECENTENTRIES_RANDOMIZE);
$propbag->add('description', PLUGIN_RECENTENTRIES_RANDOMIZE_DESC);
$propbag->add('radio', array(
'value' => array('yes', 'no'),
'desc' => array(YES, NO)
));
$propbag->add('default', 'no');
break;
$propbag->add('default', 'no');
break;
case 'dateformat':
$propbag->add('type', 'string');
$propbag->add('name', GENERAL_PLUGIN_DATEFORMAT);
$propbag->add('description', sprintf(GENERAL_PLUGIN_DATEFORMAT_BLAHBLAH, '%A, %B %e %Y') . '. ' . PLUGIN_RECENTENTRIES_DATEFORMAT_WIN);
$propbag->add('default', '%A, %B %e %Y');
$propbag->add('type', 'string');
$propbag->add('name', GENERAL_PLUGIN_DATEFORMAT);
$propbag->add('description', sprintf(GENERAL_PLUGIN_DATEFORMAT_BLAHBLAH, '%A, %B %e %Y') . '. ' . PLUGIN_RECENTENTRIES_DATEFORMAT_WIN);
$propbag->add('default', '%A, %B %e %Y');
break;
case 'category':
$cats = serendipity_fetchCategories($serendipity['authorid']);
if (!is_array($cats)) {
return false;
break;
}
$catlist = serendipity_generateCategoryList($cats, array(0), 4, 0, 0, '', ' . ');
$tmp_select_cats = explode('@@@', $catlist);
if (!is_array($tmp_select_cats)) {
return false;
break;
}
$select_cats = array();
@@ -94,30 +101,31 @@ class serendipity_plugin_recententries extends serendipity_plugin {
}
}
$propbag->add('type', 'multiselect');
$propbag->add('select_values', $select_cats);
$propbag->add('select_size', 5);
$propbag->add('name', CATEGORY);
$propbag->add('description', CATEGORIES_TO_FETCH);
$propbag->add('default', 'none');
$propbag->add('type', 'multiselect');
$propbag->add('select_values', $select_cats);
$propbag->add('select_size', 5);
$propbag->add('name', CATEGORY);
$propbag->add('description', CATEGORIES_TO_FETCH);
$propbag->add('default', 'none');
break;
case 'show_where':
$select = array('extended' => PLUGIN_ITEM_DISPLAY_EXTENDED, 'overview' => PLUGIN_ITEM_DISPLAY_OVERVIEW, 'both' => PLUGIN_ITEM_DISPLAY_BOTH);
$propbag->add('type', 'select');
$propbag->add('select_values', $select);
$propbag->add('name', PLUGIN_ITEM_DISPLAY);
$propbag->add('description', '');
$propbag->add('default', 'both');
break;
$propbag->add('type', 'select');
$propbag->add('select_values', $select);
$propbag->add('name', PLUGIN_ITEM_DISPLAY);
$propbag->add('description', '');
$propbag->add('default', 'both');
break;
default:
return false;
}
return true;
}
function generate_content(&$title) {
function generate_content(&$title)
{
global $serendipity;
$number = $this->get_config('number');
@@ -147,14 +155,14 @@ class serendipity_plugin_recententries extends serendipity_plugin {
$sql_condition['and'] = '';
if ($category != 'none' && !empty($category)) {
$sql_categories = array();
if (is_numeric($category)) {
$sql_categories[] = $category;
} else {
$sql_categories = explode('^', $category);
}
$category_parts = array();
foreach($sql_categories AS $sql_category) {
$category_parts[] = "\n" . implode(' AND ', serendipity_fetchCategoryRange($sql_category));
@@ -215,9 +223,9 @@ class serendipity_plugin_recententries extends serendipity_plugin {
WHERE isdraft = 'false' {$sql_condition['and']}
$sql_order
$sql_number";
$entries = serendipity_db_query($entries_query);
if (is_string($entries)) {
echo $entries . "<br />\n";
echo $entries_query . "<br />\n";
@@ -249,6 +257,8 @@ class serendipity_plugin_recententries extends serendipity_plugin {
echo '</dl>' . "\n\n";
}
}
}
/* vim: set sts=4 ts=4 smartindent autoindent : */
?>