add('name', PLUGIN_EVENT_TRACKBACK_NAME);
$propbag->add('description', PLUGIN_EVENT_TRACKBACK_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Serendipity Team');
$propbag->add('version', '1.9');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('cachable_events', array('frontend_display' => true));
$propbag->add('event_hooks', array('frontend_display' => true, 'frontend_display_cache' => true));
$propbag->add('scrambles_true_content', true);
$propbag->add('groups', array('STATISTICS'));
$this->markup_elements = array(
array(
'name' => 'ENTRY_BODY',
'element' => 'body',
),
array(
'name' => 'EXTENDED_BODY',
'element' => 'extended',
),
array(
'name' => 'COMMENT',
'element' => 'comment',
),
array(
'name' => 'HTML_NUGGET',
'element' => 'html_nugget',
)
);
$conf_array = array();
foreach($this->markup_elements as $element) {
$conf_array[] = $element['name'];
}
$conf_array[] = 'commentredirection';
$propbag->add('configuration', $conf_array);
}
function install() {
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
}
function uninstall() {
serendipity_plugin_api::hook_event('backend_cache_purge', $this->title);
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
}
function generate_content(&$title) {
$title = $this->title;
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'commentredirection':
$propbag->add('type', 'select');
$propbag->add('select_values', array('none' => PLUGIN_EVENT_TRACKBACK_COMMENTREDIRECTION_NONE,
's9y' => PLUGIN_EVENT_TRACKBACK_COMMENTREDIRECTION_S9Y,
'google' => PLUGIN_EVENT_TRACKBACK_COMMENTREDIRECTION_GOOGLE));
$propbag->add('name', PLUGIN_EVENT_TRACKBACK_COMMENTREDIRECTION);
$propbag->add('description', PLUGIN_EVENT_TRACKBACK_COMMENTREDIRECTION_BLAHBLA);
$propbag->add('default', 'none');
break;
default:
$propbag->add('type', 'boolean');
$propbag->add('name', constant($name));
$propbag->add('description', sprintf(APPLY_MARKUP_TO, constant($name)));
$propbag->add('default', 'true');
}
return true;
}
function event_hook($event, &$bag, &$eventData, $addData = null) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'frontend_display':
if ($bag->get('scrambles_true_content') && is_array($addData) && isset($addData['no_scramble'])) {
return true;
}
case 'frontend_display_cache':
$serendipity['encodeExitsCallback_entry_id'] = (int)(isset($eventData['entry_id']) ? $eventData['entry_id'] : $eventData['id']);
// Fetch all existing links from the database. They have been inserted there by our trackback-discovery.
if (empty($serendipity['encodeExitsCallback_entry_id'])) {
$this->links = array();
} else {
#echo "SELECT id, link FROM {$serendipity['dbPrefix']}references WHERE entry_id = {$serendipity['encodeExitsCallback_entry_id']} AND type = ''
\n";
$this->links = serendipity_db_query("SELECT id, link FROM {$serendipity['dbPrefix']}references WHERE entry_id = {$serendipity['encodeExitsCallback_entry_id']} AND (type = '' OR type IS NULL)", false, 'both', false, 'link', 'id');
#echo "
" . print_r($this->links, true) . "