@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 <a href="%s" target="_blank" title="' . PLUGIN_EVENT_ENTRYPROPERTIES_TITLE . '">plugin configuration</a>.');
+
class serendipity_event_entryproperties extends serendipity_event
{
var $services;
$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',
'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)
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);
}
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;
}
?>
</select>
</div>
+
+ <?php
+ $fields = trim($this->get_config('customfields'));
+ if (!empty($fields)) {
+ $fields = explode(',', $fields);
+ }
+ if (is_array($fields) && count($fields) > 0) { ?>
+ <br />
+ <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS; ?>:<br />
+ <em><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC1 . '<br />' . sprintf(PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC3, 'serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $this->instance); ?></em><br />
+ <div style="margin-left: 10px">
+ <table id="serendipity_customfields">
+ <?php
+ foreach($fields AS $fieldname) {
+ $fieldname = trim($fieldname);
+
+ if (isset($serendipity['POST']['properties'][$fieldname])) {
+ $value = $serendipity['POST']['properties'][$fieldname];
+ } elseif (!empty($eventData['properties']['ep_' . $fieldname])) {
+ $value = $eventData['properties']['ep_' . $fieldname];
+ } else {
+ $value = '';
+ }
+ ?>
+ <tr>
+ <td class="customfield_name"><strong><?php echo $fieldname; ?></strong></td>
+ <td class="customfield_value"><textarea name="serendipity[properties][<?php echo htmlspecialchars($fieldname); ?>]"><?php echo htmlspecialchars($value); ?></textarea></td>
+ </tr>
+ <?php
+ }
+ ?>
+ </table>
+ </div>
+ <?php
+ }
+ ?>
</fieldset>
<?php
return true;