Update of /cvsroot/php-blog/serendipity/plugins/serendipity_plugin_entrylinks
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7447/plugins/serendipity_plugin_entrylinks
Added Files:
serendipity_plugin_entrylinks.php
Log Message:
new plugin 'entrylinks'.
--- NEW FILE: serendipity_plugin_entrylinks.php ---
<?php # $Id: serendipity_plugin_entrylinks.php,v 1.1 2004/06/06 19:55:54 garvinhicking Exp $
switch ($serendipity['lang']) {
case 'de':
@define('PLUGIN_ENTRYLINKS_NAME', 'Links des Artikels');
@define('PLUGIN_ENTRYLINKS_BLAHBLAH', 'Zeigt alle referenzierten Links eines Artikels');
@define('PLUGIN_ENTRYLINKS_NEWWIN', 'Links in neuem Fenster öffnen?');
@define('PLUGIN_ENTRYLINKS_NEWWIN_BLAHBLAH', 'Sollen die Links in einem neuen Fenster geöffnet werden? (Standard: Nein)');
break;
case 'en':
default:
@define('PLUGIN_ENTRYLINKS_NAME', 'Entry\'s Links');
@define('PLUGIN_ENTRYLINKS_BLAHBLAH', 'Shows all links referrenced in an article');
@define('PLUGIN_ENTRYLINKS_NEWWIN', 'Open links in new window?');
@define('PLUGIN_ENTRYLINKS_NEWWIN_BLAHBLAH', 'Should the links be opened in a new window? (Default: Current window)');
break;
}
class serendipity_plugin_entrylinks extends serendipity_plugin
{
function introspect(&$propbag)
{
global $serendipity;
$propbag->add('name', PLUGIN_ENTRYLINKS_NAME);
$propbag->add('description', PLUGIN_ENTRYLINKS_BLAHBLAH);
$propbag->add('configuration', array('title', 'newwin', 'markup'));
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'title':
$propbag->add('type', 'string');
$propbag->add('name', TITLE);
$propbag->add('description', TITLE);
break;
case 'newwin':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_ENTRYLINKS_NEWWIN);
$propbag->add('description', PLUGIN_ENTRYLINKS_NEWWIN_BLAHBLAH);
break;
case 'markup':
$propbag->add('type', 'boolean');
$propbag->add('name', DO_MARKUP);
$propbag->add('description', DO_MARKUP_DESCRIPTION);
break;
default:
return false;
}
return true;
}
function generate_content(&$title)
{
global $serendipity;
$title = $this->get_config('title', PLUGIN_ENTRYLINKS_NAME);
if (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id'])) {
return false;
}
$target = '';
$newwin = $this->get_config('newwin', 'false');
if ($newwin == 'true') {
$target = ' target="_blank" ';
}
$references = serendipity_db_query("SELECT link, name FROM {$serendipity['dbPrefix']}references WHERE entry_id = " . serendipity_db_escape_string($serendipity['GET']['id']) . " GROUP BY link");
if (is_array($references)) {
$links = '<ul style="margin: 5px; padding: 2px">';
foreach($references AS $key => $row) {
$links .= '<li><a href="' . $row['link'] . '" ' . $target . '>' . $row['name'] . "</a></li>\n";
}
$links .= '</ul>';
if ($this->get_config('markup', 'true') == 'true') {
$entry = array('html_nugget' => $links);
serendipity_plugin_api::hook_event('frontend_display', $entry);
echo $entry['html_nugget'];
} else {
echo $links;
}
}
}
}
/* vim: set sts=4 ts=4 expandtab : */
?>
|