From ebbaccb189f7f62f3ac0df65f708cda99c0d4e3b Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Mon, 14 Aug 2006 08:53:19 +0000 Subject: [PATCH] rename image button to "media" --- .../serendipity_event_entryproperties.php | 148 ++++++++++++++++-- 1 file changed, 133 insertions(+), 15 deletions(-) diff --git a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php index 83687c1..bea7493 100644 --- a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php +++ b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php @@ -10,7 +10,7 @@ include dirname(__FILE__) . '/lang_en.inc.php'; class serendipity_event_entryproperties extends serendipity_event { - var $services; + var $services, $showPasswordForm; var $title = PLUGIN_EVENT_ENTRYPROPERTIES_TITLE; function introspect(&$propbag) @@ -21,7 +21,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.8'); + $propbag->add('version', '1.12'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', @@ -35,6 +35,7 @@ class serendipity_event_entryproperties extends serendipity_event 'backend_display' => true, 'backend_import_entry' => true, 'entry_display' => true, + 'entries_header' => true, 'frontend_entryproperties' => true, 'backend_sidebar_entries_event_display_buildcache' => true, 'backend_sidebar_entries' => true, @@ -42,7 +43,9 @@ class serendipity_event_entryproperties extends serendipity_event 'backend_cache_purge' => true, 'backend_plugins_new_instance' => true, 'frontend_entryproperties_query' => true, - 'frontend_entries_rss' => true + 'frontend_entries_rss' => true, + 'backend_entry_presave' => true, + 'frontend_configure' => true )); $propbag->add('groups', array('BACKEND_EDITOR')); $propbag->add('configuration', array('cache', 'use_groups', 'use_users', 'default_read', 'customfields')); @@ -135,7 +138,7 @@ class serendipity_event_entryproperties extends serendipity_event 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'); + $supported_properties = array('is_sticky', 'access', 'access_groups', 'access_users', 'cache_body', 'cache_extended', 'no_frontpage', 'hiderss', 'entrypassword'); $fields = explode(',', trim($this->get_config('customfields'))); if (is_array($fields) && count($fields) > 0) { @@ -160,12 +163,36 @@ class serendipity_event_entryproperties extends serendipity_event return $and; } + /* + * This function converts specific property fields so that they are + * available natively to other plugins/templates. + */ + function applyProperties(&$properties) { + global $serendipity; + + if (is_array($properties['disable_markups'])) { + foreach($properties['disable_markups'] AS $idx => $instance) { + $properties['disable_markup_' . $instance] = $instance; + } + } + } + function addProperties(&$properties, &$eventData) { global $serendipity; // Get existing data $property = serendipity_fetchEntryProperties($eventData['id']); $supported_properties = serendipity_event_entryproperties::getSupportedProperties(); + // Special case for disable markups. + if (is_array($properties['disable_markups'])) { + $q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$eventData['id'] . " AND property LIKE 'ep_disable_markup_%'"; + serendipity_db_query($q); + + foreach($properties['disable_markups'] AS $idx => $instance) { + $supported_properties[] = 'disable_markup_' . $instance; + } + } + foreach($supported_properties AS $prop_key) { $prop_val = (isset($properties[$prop_key]) ? $properties[$prop_key] : null); $prop_key = 'ep_' . $prop_key; @@ -184,6 +211,21 @@ class serendipity_event_entryproperties extends serendipity_event } } + function showPasswordform() { + global $serendipity; + $url = serendipity_currentURL(); + + $out = ' +
+
+ + +
+
'; + return $out; + + } + function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; @@ -204,10 +246,6 @@ class serendipity_event_entryproperties extends serendipity_event || (isset($serendipity['POST']['properties']['is_sticky']) && serendipity_db_bool($serendipity['POST']['properties']['is_sticky'])) ? 'checked="checked"' : ''; - $nl2br = (isset($eventData['properties']['ep_no_nl2br']) && serendipity_db_bool($eventData['properties']['ep_no_nl2br'])) - || (isset($serendipity['POST']['properties']['no_nl2br']) && serendipity_db_bool($serendipity['POST']['properties']['no_nl2br'])) - ? 'checked="checked"' - : ''; $no_frontpage = (isset($eventData['properties']['ep_no_frontpage']) && serendipity_db_bool($eventData['properties']['ep_no_frontpage'])) || (isset($serendipity['POST']['properties']['no_frontpage']) && serendipity_db_bool($serendipity['POST']['properties']['no_frontpage'])) @@ -248,6 +286,15 @@ class serendipity_event_entryproperties extends serendipity_event } else { $access_users = array(); } + + if (isset($eventData['properties']['ep_entrypassword'])) { + $password = $eventData['properties']['ep_entrypassword']; + } elseif (isset($serendipity['POST']['properties']['entrypassword'])) { + $password = $serendipity['POST']['properties']['entrypassword']; + } else { + $password = ''; + } + ?>
@@ -255,11 +302,6 @@ class serendipity_event_entryproperties extends serendipity_event
/>
- - /> -
- - />
@@ -273,6 +315,12 @@ class serendipity_event_entryproperties extends serendipity_event +
:
+
+ +
+ +
+
+
+
+ +
+
+ get_config('customfields')); if (!empty($fields)) { @@ -349,7 +429,7 @@ class serendipity_event_entryproperties extends serendipity_event - + addProperties($props, $eventData); } break; + case 'backend_sidebar_entries_event_display_buildcache': if ($is_cache) { $per_fetch = 25; @@ -458,6 +540,12 @@ class serendipity_event_entryproperties extends serendipity_event serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE property LIKE 'ep_cache_%'"); break; + case 'backend_entry_presave': + if (is_array($serendipity['POST']['properties'])) { + $this->applyProperties($serendipity['POST']['properties']); + } + break; + case 'backend_publish': case 'backend_save': if (!isset($serendipity['POST']['properties']) || !is_array($serendipity['POST']['properties']) || !isset($eventData['id'])) { @@ -497,6 +585,13 @@ class serendipity_event_entryproperties extends serendipity_event return true; break; + case 'frontend_configure': + if (isset($serendipity['POST']['id']) && empty($serendipity['GET']['id'])) { + $serendipity['GET']['id'] = &$serendipity['POST']['id']; + $serendipity['GET']['subpage'] = &$serendipity['POST']['subpage']; + } + break; + case 'frontend_entryproperties': $and = $this->returnQueryCondition($is_cache); $q = "SELECT entryid, property, value FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid IN (" . implode(', ', array_keys($addData)) . ") $and"; @@ -516,6 +611,7 @@ class serendipity_event_entryproperties extends serendipity_event // PH: This is done after Garvins suggestion to patchup $eventData in case an entry // is in the process of being created. This must be done for the extended properties // to be applied in the preview. + if (is_array($serendipity['POST']['properties']) && count($serendipity['POST']['properties']) > 0){ $parr = array(); $supported_properties = serendipity_event_entryproperties::getSupportedProperties(); @@ -524,6 +620,28 @@ class serendipity_event_entryproperties extends serendipity_event $eventData[0]['properties']['ep_' . $prop_key] = $serendipity['POST']['properties'][$prop_key]; } } + + if (isset($serendipity['GET']['id']) && isset($eventData[0]['properties']['ep_entrypassword'])) { + + if (isset($_SESSION['entrypassword_unlocked'][$serendipity['GET']['id']]) || $eventData[0]['properties']['ep_entrypassword'] == $serendipity['POST']['entrypassword']) { + // Do not show login form again, once we have first enabled it. + $_SESSION['entrypassword_unlocked'][$serendipity['GET']['id']] = true; + } else { + if (is_array($eventData)) { + $eventData['clean_page'] = true; + } else { + $eventData = array('clean_page' => true); + } + $this->showPasswordForm = true; + } + } + + break; + + case 'entries_header': + if ($this->showPasswordForm) { + echo $this->showPasswordform(); + } break; case 'frontend_fetchentries': @@ -551,7 +669,7 @@ class serendipity_event_entryproperties extends serendipity_event $conds[] = " (ep_access.property IS NULL OR ep_access.value = 'public')"; } - if (!isset($serendipity['GET']['category']) && !isset($serendipity['GET']['adminModule']) && $event == 'frontend_fetchentries') { + if (!isset($serendipity['GET']['category']) && !isset($serendipity['GET']['adminModule']) && $event == 'frontend_fetchentries' && $addData['source'] != 'search') { $conds[] = " (ep_no_frontpage.property IS NULL OR ep_no_frontpage.value != 'true') "; $joins[] = " LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties ep_no_frontpage ON (e.id = ep_no_frontpage.entryid AND ep_no_frontpage.property = 'ep_no_frontpage')"; -- 2.39.5