From: garvinhicking Date: Wed, 19 Oct 2005 14:25:01 +0000 (+0000) Subject: Add custom fields to entryproperties plugin X-Git-Tag: 0.9~49 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=28b9c92688561ba008c80dcf5aae6e2d9cfc00a8;p=s9y.git Add custom fields to entryproperties plugin --- diff --git a/docs/NEWS b/docs/NEWS index a92642c..0c69c4a 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 0.9-beta3 () ------------------------------------------------------------------------ + * Enhanced entryproperties plugin to support entering custom field- + names (RFE #1328773) (garvinhicking) + * Also fetch and display entryproperties in the results of a search. Fixes bug #1329379 (garvinhicking) diff --git a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php index 99dfd9c..954fa50 100644 --- a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php +++ b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php @@ -32,6 +32,11 @@ if (file_exists($probelang)) { @define('PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS', 'Hide content in RSS'); @define('PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS_DESC', 'If enabled, the content of this entry will not be shown inside the RSS feed(s).'); +@define('PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS', 'Custom Fields'); +@define('PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC1', 'Additional custom fields can be used in your template at places where you want them to show up. For that, edit your entries.tpl template file and place Smarty tags like {$entry.properties.ep_MyCustomField} in the HTML where you like. Note the prefix ep_ for each field. '); +@define('PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC2', 'Here you can enter a list of commaseparated field names that you can use to enter for every entry - do not use special characters or spaces for those fieldnames. Example: "Customfield1, Customfield2". ' . PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC1); +@define('PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC3', 'The list of available custom fields can be changed in the plugin configuration.'); + class serendipity_event_entryproperties extends serendipity_event { var $services; @@ -45,7 +50,7 @@ class serendipity_event_entryproperties extends serendipity_event $propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Garvin Hicking'); - $propbag->add('version', '1.5'); + $propbag->add('version', '1.6'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', @@ -69,7 +74,7 @@ class serendipity_event_entryproperties extends serendipity_event 'frontend_entries_rss' => true )); $propbag->add('groups', array('BACKEND_EDITOR')); - $propbag->add('configuration', array('cache', 'use_groups', 'use_users', 'default_read')); + $propbag->add('configuration', array('cache', 'use_groups', 'use_users', 'default_read', 'customfields')); } function introspect_config_item($name, &$propbag) @@ -88,6 +93,13 @@ class serendipity_event_entryproperties extends serendipity_event break; + case 'customfields': + $propbag->add('type', 'text'); + $propbag->add('name', PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS); + $propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC2); + $propbag->add('default', 'CustomField1, CustomField2, CustomField3'); + break; + case 'use_groups': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_EVENT_ENTRYPROPERTIES_GROUPS); @@ -149,7 +161,21 @@ class serendipity_event_entryproperties extends serendipity_event } function getSupportedProperties() { - static $supported_properties = array('is_sticky', 'access', 'access_groups', 'access_users', 'cache_body', 'cache_extended', 'no_nl2br', 'no_frontpage', 'hiderss'); + static $supported_properties = null; + + if ($supported_properties === null) { + $supported_properties = array('is_sticky', 'access', 'access_groups', 'access_users', 'cache_body', 'cache_extended', 'no_nl2br', 'no_frontpage', 'hiderss'); + + $fields = explode(',', trim($this->get_config('customfields'))); + if (is_array($fields) && count($fields) > 0) { + foreach($fields AS $field) { + $field = trim($field); + if (!empty($field)) { + $supported_properties[] = $field; + } + } + } + } return $supported_properties; } @@ -325,6 +351,42 @@ class serendipity_event_entryproperties extends serendipity_event ?> + + get_config('customfields')); + if (!empty($fields)) { + $fields = explode(',', $fields); + } + if (is_array($fields) && count($fields) > 0) { ?> +
+ :
+ ' . sprintf(PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC3, 'serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $this->instance); ?>
+
+ + + + + + + +
+
+ set_config('contentfilter_urls', implode(';', $items)); } - echo ' - ' . WORD_OR . ' - ' . PLUGIN_EVENT_SPAMBLOCK_CONFIG . ''; + echo ' - ' . WORD_OR . ' - ' . PLUGIN_EVENT_SPAMBLOCK_CONFIG . ''; return true; break; diff --git a/templates/default/admin/style.css b/templates/default/admin/style.css index c9d1db8..017eeda 100644 --- a/templates/default/admin/style.css +++ b/templates/default/admin/style.css @@ -272,4 +272,24 @@ a.serendipityPrettyButton { color: black; vertical-align: middle; padding: 10px 0px 5px 10px; -} \ No newline at end of file +} + +table#serendipity_customfields { + width: 100%; +} + +table#serendipity_customfields .customfield_name { + background-color: #FAFAFA; + width: 25%; + padding-left: 5px; +} + +table#serendipity_customfields .customfield_value { + background-color: #FFFFFF; + width: 75%; +} + +table#serendipity_customfields .customfield_value textarea { + width: 100%; + height: 100px; +}