upstream patch by ian
This commit is contained in:
parent
97cb741907
commit
679e261fdc
|
@ -1,13 +1,17 @@
|
||||||
|
1.14:
|
||||||
|
-----
|
||||||
|
* Fix "Illegal string offset 'from'" error
|
||||||
|
* Use lang API - extends required Serendipity version to 1.6
|
||||||
|
|
||||||
1.13:
|
1.13:
|
||||||
-----
|
-----
|
||||||
Add lang <de>
|
* Add lang <de>
|
||||||
Add new option for case bottom, closing a div class with certain templates
|
* Add new option for case bottom, closing a div class with certain templates
|
||||||
|
|
||||||
1.12:
|
1.12:
|
||||||
-----
|
-----
|
||||||
Add ability for "plaintext" markup
|
* Add ability for "plaintext" markup
|
||||||
|
|
||||||
1.11:
|
1.11:
|
||||||
-----
|
-----
|
||||||
|
* Add support for putting nuggets in RSS feeds
|
||||||
Add support for putting nuggets in RSS feeds
|
|
||||||
|
|
|
@ -4,14 +4,8 @@ if (IN_serendipity !== true) {
|
||||||
die ("Don't hack!");
|
die ("Don't hack!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load possible language files.
|
||||||
// Probe for a language include with constants. Still include defines later on, if some constants were missing
|
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
||||||
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
|
|
||||||
if (file_exists($probelang)) {
|
|
||||||
include $probelang;
|
|
||||||
}
|
|
||||||
|
|
||||||
include dirname(__FILE__) . '/lang_en.inc.php';
|
|
||||||
|
|
||||||
class serendipity_event_page_nugget extends serendipity_event
|
class serendipity_event_page_nugget extends serendipity_event
|
||||||
{
|
{
|
||||||
|
@ -23,19 +17,21 @@ class serendipity_event_page_nugget extends serendipity_event
|
||||||
$propbag->add('description', PLUGIN_PAGE_NUGGET_DESC);
|
$propbag->add('description', PLUGIN_PAGE_NUGGET_DESC);
|
||||||
$propbag->add('stackable', true);
|
$propbag->add('stackable', true);
|
||||||
$propbag->add('author', 'Wesley Hwang-Chung');
|
$propbag->add('author', 'Wesley Hwang-Chung');
|
||||||
$propbag->add('version', '1.13');
|
$propbag->add('version', '1.14');
|
||||||
$propbag->add('requirements', array(
|
$propbag->add('requirements', array(
|
||||||
'serendipity' => '0.8',
|
'serendipity' => '1.6',
|
||||||
'smarty' => '2.6.7',
|
'smarty' => '2.6.7',
|
||||||
'php' => '4.1.0'
|
'php' => '4.1.0'
|
||||||
));
|
));
|
||||||
$propbag->add('groups', array('FRONTEND_ENTRY_RELATED'));
|
$propbag->add('groups', array('FRONTEND_ENTRY_RELATED'));
|
||||||
$propbag->add('event_hooks', array('frontend_header' => true,
|
$propbag->add('event_hooks', array(
|
||||||
'entries_header' => true,
|
'frontend_header' => true,
|
||||||
'entry_display' => true,
|
'entries_header' => true,
|
||||||
'entries_footer' => true,
|
'entry_display' => true,
|
||||||
'frontend_footer' => true,
|
'entries_footer' => true,
|
||||||
'frontend_display' => true));
|
'frontend_footer' => true,
|
||||||
|
'frontend_display' => true)
|
||||||
|
);
|
||||||
$propbag->add('configuration', array('title', 'placement', 'language', 'content', 'content_plain', 'footer_close', 'markup', 'show_where'));
|
$propbag->add('configuration', array('title', 'placement', 'language', 'content', 'content_plain', 'footer_close', 'markup', 'show_where'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,52 +46,52 @@ class serendipity_event_page_nugget extends serendipity_event
|
||||||
$propbag->add('default', '');
|
$propbag->add('default', '');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'placement':
|
case 'placement':
|
||||||
$select = array('head' => PLUGIN_PAGE_NUGGET_HEAD,
|
$select = array('head' => PLUGIN_PAGE_NUGGET_HEAD,
|
||||||
'top' => PLUGIN_PAGE_NUGGET_TOP,
|
'top' => PLUGIN_PAGE_NUGGET_TOP,
|
||||||
'art_foot' => PLUGIN_PAGE_NUGGET_ART_FOOT,
|
'art_foot' => PLUGIN_PAGE_NUGGET_ART_FOOT,
|
||||||
'bottom' => PLUGIN_PAGE_NUGGET_BOTTOM,
|
'bottom' => PLUGIN_PAGE_NUGGET_BOTTOM,
|
||||||
'foot' => PLUGIN_PAGE_NUGGET_FOOT,
|
'foot' => PLUGIN_PAGE_NUGGET_FOOT,
|
||||||
'rss' => PLUGIN_PAGE_NUGGET_RSS);
|
'rss' => PLUGIN_PAGE_NUGGET_RSS);
|
||||||
$propbag->add('type', 'select');
|
$propbag->add('type', 'select');
|
||||||
$propbag->add('select_values', $select);
|
$propbag->add('select_values', $select);
|
||||||
$propbag->add('name', PLUGIN_PAGE_NUGGET_PLACE);
|
$propbag->add('name', PLUGIN_PAGE_NUGGET_PLACE);
|
||||||
$propbag->add('default', 'top');
|
$propbag->add('default', 'top');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'language':
|
case 'language':
|
||||||
$select = array('all' => PLUGIN_PAGE_NUGGET_ALL,
|
$select = array('all' => PLUGIN_PAGE_NUGGET_ALL,
|
||||||
'en' => 'English',
|
'en' => 'English',
|
||||||
'de' => 'German',
|
'de' => 'German',
|
||||||
'da' => 'Danish',
|
'da' => 'Danish',
|
||||||
'es' => 'Spanish',
|
'es' => 'Spanish',
|
||||||
'fr' => 'French',
|
'fr' => 'French',
|
||||||
'fi' => 'Finnish',
|
'fi' => 'Finnish',
|
||||||
'cs' => 'Czech (Win-1250)',
|
'cs' => 'Czech (Win-1250)',
|
||||||
'cz' => 'Czech (ISO-8859-2)',
|
'cz' => 'Czech (ISO-8859-2)',
|
||||||
'nl' => 'Dutch',
|
'nl' => 'Dutch',
|
||||||
'is' => 'Icelandic',
|
'is' => 'Icelandic',
|
||||||
'se' => 'Swedish',
|
'se' => 'Swedish',
|
||||||
'pt' => 'Portuguese Brazilian',
|
'pt' => 'Portuguese Brazilian',
|
||||||
'pt_PT' => 'Portuguese European',
|
'pt_PT' => 'Portuguese European',
|
||||||
'bg' => 'Bulgarian',
|
'bg' => 'Bulgarian',
|
||||||
'hu' => 'Hungarian',
|
'hu' => 'Hungarian',
|
||||||
'no' => 'Norwegian',
|
'no' => 'Norwegian',
|
||||||
'ro' => 'Romanian',
|
'ro' => 'Romanian',
|
||||||
'it' => 'Italian',
|
'it' => 'Italian',
|
||||||
'ru' => 'Russian',
|
'ru' => 'Russian',
|
||||||
'fa' => 'Persian',
|
'fa' => 'Persian',
|
||||||
'tw' => 'Traditional Chinese (Big5)',
|
'tw' => 'Traditional Chinese (Big5)',
|
||||||
'tn' => 'Traditional Chinese (UTF-8)',
|
'tn' => 'Traditional Chinese (UTF-8)',
|
||||||
'zh' => 'Simplified Chinese (GB2312)',
|
'zh' => 'Simplified Chinese (GB2312)',
|
||||||
'cn' => 'Simplified Chinese (UTF-8)',
|
'cn' => 'Simplified Chinese (UTF-8)',
|
||||||
'ja' => 'Japanese',
|
'ja' => 'Japanese',
|
||||||
'ko' => 'Korean');
|
'ko' => 'Korean');
|
||||||
$propbag->add('type', 'select');
|
$propbag->add('type', 'select');
|
||||||
$propbag->add('select_values', $select);
|
$propbag->add('select_values', $select);
|
||||||
$propbag->add('name', PLUGIN_PAGE_NUGGET_LANG);
|
$propbag->add('name', PLUGIN_PAGE_NUGGET_LANG);
|
||||||
$propbag->add('default', 'all');
|
$propbag->add('default', 'all');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'content':
|
case 'content':
|
||||||
$propbag->add('type', 'html');
|
$propbag->add('type', 'html');
|
||||||
|
@ -144,7 +140,8 @@ class serendipity_event_page_nugget extends serendipity_event
|
||||||
$title = $this->get_config('title');
|
$title = $this->get_config('title');
|
||||||
}
|
}
|
||||||
|
|
||||||
function event_hook($event, &$bag, &$eventData, $addData = null) {
|
function event_hook($event, &$bag, &$eventData, $addData = null)
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
$hooks = &$bag->get('event_hooks');
|
$hooks = &$bag->get('event_hooks');
|
||||||
|
@ -152,11 +149,13 @@ class serendipity_event_page_nugget extends serendipity_event
|
||||||
$language = $this->get_config('language', 'all');
|
$language = $this->get_config('language', 'all');
|
||||||
$show_where = $this->get_config('show_where', 'both');
|
$show_where = $this->get_config('show_where', 'both');
|
||||||
|
|
||||||
// if the language doesn't match, do not display
|
// if the language doesn't match, do not display
|
||||||
if ($language != 'all' && $serendipity['lang'] != $language) return false;
|
if ($language != 'all' && $serendipity['lang'] != $language) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// RSS-Feed special case
|
// RSS-Feed special case
|
||||||
if ($event == 'frontend_display' && $addData['from'] == 'functions_entries:printEntries_rss') {
|
if ($event == 'frontend_display' && (isset($addData['from']) && $addData['from'] == 'functions_entries:printEntries_rss')) {
|
||||||
if ($placement == 'rss') {
|
if ($placement == 'rss') {
|
||||||
if (serendipity_db_bool($this->get_config('markup', 'true')) && $event != 'frontend_header') {
|
if (serendipity_db_bool($this->get_config('markup', 'true')) && $event != 'frontend_header') {
|
||||||
$entry = array('html_nugget' => $this->get_config('content'));
|
$entry = array('html_nugget' => $this->get_config('content'));
|
||||||
|
@ -166,50 +165,50 @@ class serendipity_event_page_nugget extends serendipity_event
|
||||||
$eventData['body'] .= $this->get_config('content') . $this->get_config('content_plain');
|
$eventData['body'] .= $this->get_config('content') . $this->get_config('content_plain');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// where to show
|
// where to show
|
||||||
if ($show_where == 'extended' && (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id']))) {
|
if ($show_where == 'extended' && (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id']))) {
|
||||||
return false;
|
return false;
|
||||||
} else if ($show_where == 'overview' && isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) {
|
} else if ($show_where == 'overview' && isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($placement == 'head' && $event == 'frontend_header') ||
|
if (($placement == 'head' && $event == 'frontend_header') ||
|
||||||
($placement == 'top' && $event == 'entries_header') ||
|
($placement == 'top' && $event == 'entries_header') ||
|
||||||
($placement == 'bottom' && $event == 'entries_footer') ||
|
($placement == 'bottom' && $event == 'entries_footer') ||
|
||||||
($placement == 'foot' && $event == 'frontend_footer')) {
|
($placement == 'foot' && $event == 'frontend_footer')) {
|
||||||
// entries_footer hook location workaround: get out of the 'serendipity_entryFooter' class
|
// entries_footer hook location workaround: get out of the 'serendipity_entryFooter' class
|
||||||
if (serendipity_db_bool($this->get_config('footer_close', 'true')) && $event == 'entries_footer') {
|
if (serendipity_db_bool($this->get_config('footer_close', 'true')) && $event == 'entries_footer') {
|
||||||
echo "\n</div>\n<div>\n";
|
echo "\n</div>\n<div>\n";
|
||||||
}
|
}
|
||||||
// if not for HEAD, apply markup?
|
// if not for HEAD, apply markup?
|
||||||
if (serendipity_db_bool($this->get_config('markup', 'true')) && $event != 'frontend_header') {
|
if (serendipity_db_bool($this->get_config('markup', 'true')) && $event != 'frontend_header') {
|
||||||
$entry = array('html_nugget' => $this->get_config('content'));
|
$entry = array('html_nugget' => $this->get_config('content'));
|
||||||
serendipity_plugin_api::hook_event('frontend_display', $entry);
|
serendipity_plugin_api::hook_event('frontend_display', $entry);
|
||||||
echo $entry['html_nugget'] . $this->get_config('content_plain');
|
echo $entry['html_nugget'] . $this->get_config('content_plain');
|
||||||
} else {
|
} else {
|
||||||
echo $this->get_config('content') . $this->get_config('content_plain');
|
echo $this->get_config('content') . $this->get_config('content_plain');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} elseif ($placement == 'art_foot' && $event == 'entry_display') {
|
} elseif ($placement == 'art_foot' && $event == 'entry_display') {
|
||||||
if (!is_array($eventData)) return false;
|
if (!is_array($eventData)) return false;
|
||||||
$elements = count($eventData);
|
$elements = count($eventData);
|
||||||
for ($i = 0; $i < $elements; $i++) {
|
for ($i = 0; $i < $elements; $i++) {
|
||||||
if (serendipity_db_bool($this->get_config('markup', 'true'))) {
|
if (serendipity_db_bool($this->get_config('markup', 'true'))) {
|
||||||
$entry = array('html_nugget' => $this->get_config('content'));
|
$entry = array('html_nugget' => $this->get_config('content'));
|
||||||
serendipity_plugin_api::hook_event('frontend_display', $entry);
|
serendipity_plugin_api::hook_event('frontend_display', $entry);
|
||||||
$eventData[$i]['add_footer'] .= sprintf("\n</div>\n" . $entry['html_nugget'] . $this->get_config('content_plain') . "\n<div>\n");
|
$eventData[$i]['add_footer'] .= sprintf("\n</div>\n" . $entry['html_nugget'] . $this->get_config('content_plain') . "\n<div>\n");
|
||||||
} else {
|
} else {
|
||||||
$eventData[$i]['add_footer'] .= sprintf("\n</div>\n" . $this->get_config('content') . $this->get_config('content_plain') . "\n<div>\n");
|
$eventData[$i]['add_footer'] .= sprintf("\n</div>\n" . $this->get_config('content') . $this->get_config('content_plain') . "\n<div>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in a new issue