]> git.mjollnir.org Git - s9y.git/commitdiff
Add custom fields to entryproperties plugin
authorgarvinhicking <garvinhicking>
Wed, 19 Oct 2005 14:25:01 +0000 (14:25 +0000)
committergarvinhicking <garvinhicking>
Wed, 19 Oct 2005 14:25:01 +0000 (14:25 +0000)
docs/NEWS
plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php
plugins/serendipity_event_spamblock/serendipity_event_spamblock.php
templates/default/admin/style.css

index a92642c1172a098412efe322ae53d8cf18f0463e..0c69c4a61b05e446a1f4e921507ad0f549523b0d 100644 (file)
--- 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)
      
index 99dfd9cce700b667265740b5aeddc8350a838fd8..954fa50d6b7e39fddb5587aab35904bd2dddf2df 100644 (file)
@@ -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 <a href="%s" target="_blank" title="' . PLUGIN_EVENT_ENTRYPROPERTIES_TITLE . '">plugin configuration</a>.');
+
 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
                                 ?>
                                 </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&amp;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;
index a5bca5a0e658f74c07685087508760849b4c4590..94d5f37cd7d44a146fe07186baa15f8614b676b2 100644 (file)
@@ -677,7 +677,7 @@ var $filter_defaults;
                         $this->set_config('contentfilter_urls', implode(';', $items));
                     }
 
-                    echo ' - ' . WORD_OR . ' - <a class="serendipityPrettyButton" href="serendipity_admin.php?serendipity[adminModule]=plugins&amp;serendipity[plugin_to_conf]=serendipity_event_spamblock%3A' . $this->instance . '">' . PLUGIN_EVENT_SPAMBLOCK_CONFIG . '</a>';
+                    echo ' - ' . WORD_OR . ' - <a class="serendipityPrettyButton" href="serendipity_admin.php?serendipity[adminModule]=plugins&amp;serendipity[plugin_to_conf]=' . $this->instance . '">' . PLUGIN_EVENT_SPAMBLOCK_CONFIG . '</a>';
                     return true;
                     break;
 
index c9d1db85ce76ec38ae3342db288bbf7d4d940d67..017eeda5a6cef12ec0569f480cf16689b75b6d9c 100644 (file)
@@ -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;
+}