Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_entryproperties
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12510/plugins/serendipity_event_entryproperties
Modified Files:
serendipity_event_entryproperties.php
Log Message:
* Fix fetching entryproperties - when 'cache' is disabled, several are not allowed to be fetched!
* Added ability that entryproperties plugin will always be last in the plugin queue
Index: serendipity_event_entryproperties.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- serendipity_event_entryproperties.php 27 Jan 2005 16:37:11 -0000 1.13
+++ serendipity_event_entryproperties.php 28 Jan 2005 11:16:56 -0000 1.14
@@ -78,7 +78,9 @@
'backend_sidebar_entries_event_display_buildcache' => true,
'backend_sidebar_entries' => true,
'backend_cache_entries' => true,
- 'backend_cache_purge' => true
+ 'backend_cache_purge' => true,
+ 'backend_plugins_new_instance' => true,
+ 'frontend_entryproperties_query' => true
));
$propbag->add('configuration', array('cache', 'default_read'));
@@ -137,6 +139,15 @@
return $supported_properties;
}
+ function returnQueryCondition($is_cache) {
+ $and = '';
+ if (!$is_cache) {
+ $and = " AND property NOT LIKE 'ep_cache_%' ";
+ }
+
+ return $and;
+ }
+
function addProperties(&$properties, &$eventData) {
global $serendipity;
// Get existing data
@@ -165,6 +176,11 @@
$is_cache = serendipity_db_bool($this->get_config('cache', 'true'));
if (isset($hooks[$event])) {
switch($event) {
+ case 'frontend_entryproperties_query':
+ $eventData['and'] = $this->returnQueryCondition($is_cache);
+ return true;
+ break;
+
case 'backend_display':
$is_sticky = (isset($eventData['properties']['ep_is_sticky']) && serendipity_db_bool($eventData['properties']['ep_is_sticky']))
|| (isset($serendipity['POST']['properties']['is_sticky']) && serendipity_db_bool($serendipity['POST']['properties']['is_sticky']))
@@ -323,10 +339,7 @@
break;
case 'frontend_entryproperties':
- $and = '';
- if (!$is_cache) {
- $and = " AND property NOT LIKE 'ep_cache_%' ";
- }
+ $and = $this->returnQueryCondition($is_cache);
$q = "SELECT entryid, property, value FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid IN (" . implode(', ', array_keys($addData)) . ") $and";
$properties = serendipity_db_query($q);
@@ -339,6 +352,7 @@
}
return true;
break;
+
case 'entry_display':
// 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
@@ -423,6 +437,30 @@
return true;
break;
+ case 'backend_plugins_new_instance':
+ // This hook will always push the entryproperties plugin as last in queue.
+ // Happens always when a new plugin is added.
+ // This is important because of its caching mechanism!
+
+ // Fetch maximum sort_order value. This will be the new value of our current plugin.
+ $q = "SELECT MAX(sort_order) as sort_order_max FROM {$serendipity['dbPrefix']}plugins WHERE placement = '" . $addData['default_placement'] . "'";
+ $rs = serendipity_db_query($q, true, 'num');
+
+ // Fetch current sort_order of current plugin.
+ $q = "SELECT sort_order FROM {$serendipity['dbPrefix']}plugins WHERE name = '" . $this->instance . "'";
+ $cur = serendipity_db_query($q, true, 'num');
+
+ // Decrease sort_order of all plugins after current plugin by one.
+ $q = "UPDATE {$serendipity['dbPrefix']}plugins SET sort_order = sort_order - 1 WHERE placement = '" . $addData['default_placement'] . "' AND sort_order > " . intval($cur[0]);
+ serendipity_db_query($q);
+
+ // Set current plugin as last plugin in queue.
+ $q = "UPDATE {$serendipity['dbPrefix']}plugins SET sort_order = " . intval($rs[0]) . " WHERE name = '" . $this->instance . "'";
+ serendipity_db_query($q);
+
+ return true;
+ break;
+
default:
return false;
break;
|