Added support for reference building (experimental)

This commit is contained in:
Garvin Hicking 2011-12-16 12:53:13 +01:00
parent 7c19031bda
commit 7c39480944
5 changed files with 286 additions and 7 deletions

View file

@ -1,5 +1,11 @@
# $Id$ # $Id$
0.20:
------------------------------------------------------------------------
* Added support for reference building via <ref (name=XXX)>...reference...</ref>
0.18: 0.18:
* Suppress html_entity_decode() warnings. * Suppress html_entity_decode() warnings.

View file

@ -1,7 +1,7 @@
<?php # $Id: lang_de.inc.php,v 1.2 2007/07/09 11:07:52 brockhaus Exp $ <?php # $Id: lang_de.inc.php,v 1.2 2007/07/09 11:07:52 brockhaus Exp $
@define('PLUGIN_EVENT_WIKILINKS_NAME', 'Freie Wiki-Links für Einträge'); @define('PLUGIN_EVENT_WIKILINKS_NAME', 'Freie Wiki-Links für Einträge');
@define('PLUGIN_EVENT_WIKILINKS_DESC', 'Ermöglicht Links zu blog-internen Einträgen via [[Titel]], Links zu Statischen Seiten via ((Titel)) und einen Link zu beidem via {{Titel}}. Zudem wird ein Button zu internen Einträgen bereitgestellt.'); @define('PLUGIN_EVENT_WIKILINKS_DESC', 'Ermöglicht Links zu blog-internen Einträgen via [[Titel]], Links zu Statischen Seiten via ((Titel)) und einen Link zu beidem via {{Titel}}. Zudem wird ein Button zu internen Einträgen bereitgestellt. Referenzen können am Ende eines Blogeintrags eingehangen werden.');
@define('PLUGIN_EVENT_WIKILINKS_IMGPATH', 'Pfad zu den Bildern'); @define('PLUGIN_EVENT_WIKILINKS_IMGPATH', 'Pfad zu den Bildern');
@define('PLUGIN_EVENT_WIKILINKS_IMGPATH_DESC', 'Bitte Pfad zu den Bildern der Wikilink-Icons eingeben.'); @define('PLUGIN_EVENT_WIKILINKS_IMGPATH_DESC', 'Bitte Pfad zu den Bildern der Wikilink-Icons eingeben.');

View file

@ -1,7 +1,7 @@
<?php # $Id: lang_de.inc.php,v 1.2 2007/07/09 11:07:52 brockhaus Exp $ <?php # $Id: lang_de.inc.php,v 1.2 2007/07/09 11:07:52 brockhaus Exp $
@define('PLUGIN_EVENT_WIKILINKS_NAME', 'Freie Wiki-Links für Einträge'); @define('PLUGIN_EVENT_WIKILINKS_NAME', 'Freie Wiki-Links für Einträge');
@define('PLUGIN_EVENT_WIKILINKS_DESC', 'Ermöglicht Links zu blog-internen Einträgen via [[Titel]], Links zu Statischen Seiten via ((Titel)) und einen Link zu beidem via {{Titel}}. Zudem wird ein Button zu internen Einträgen bereitgestellt.'); @define('PLUGIN_EVENT_WIKILINKS_DESC', 'Ermöglicht Links zu blog-internen Einträgen via [[Titel]], Links zu Statischen Seiten via ((Titel)) und einen Link zu beidem via {{Titel}}. Zudem wird ein Button zu internen Einträgen bereitgestellt. Referenzen können am Ende eines Blogeintrags eingehangen werden.');
@define('PLUGIN_EVENT_WIKILINKS_IMGPATH', 'Pfad zu den Bildern'); @define('PLUGIN_EVENT_WIKILINKS_IMGPATH', 'Pfad zu den Bildern');
@define('PLUGIN_EVENT_WIKILINKS_IMGPATH_DESC', 'Bitte Pfad zu den Bildern der Wikilink-Icons eingeben.'); @define('PLUGIN_EVENT_WIKILINKS_IMGPATH_DESC', 'Bitte Pfad zu den Bildern der Wikilink-Icons eingeben.');

View file

@ -7,7 +7,7 @@
*/ */
@define('PLUGIN_EVENT_WIKILINKS_NAME', 'Free Wiki links for your entries'); @define('PLUGIN_EVENT_WIKILINKS_NAME', 'Free Wiki links for your entries');
@define('PLUGIN_EVENT_WIKILINKS_DESC', 'You can specify new/existing links to your blog entries via [[title]], link to staticpages via ((title)) and link to both via {{title}}.'); @define('PLUGIN_EVENT_WIKILINKS_DESC', 'You can specify new/existing links to your blog entries via [[title]], link to staticpages via ((title)) and link to both via {{title}}. References can be automatically appended to the blog entry.');
@define('PLUGIN_EVENT_WIKILINKS_IMGPATH', 'Path to images'); @define('PLUGIN_EVENT_WIKILINKS_IMGPATH', 'Path to images');
@define('PLUGIN_EVENT_WIKILINKS_IMGPATH_DESC', 'Enter the path to where the wikilink edit icons are located.'); @define('PLUGIN_EVENT_WIKILINKS_IMGPATH_DESC', 'Enter the path to where the wikilink edit icons are located.');
@ -23,3 +23,36 @@
@define('PLUGIN_EVENT_WIKILINKS_SHOWDRAFTLINKS_DESC', 'Should links to entries be created, even if they are still at draft state?'); @define('PLUGIN_EVENT_WIKILINKS_SHOWDRAFTLINKS_DESC', 'Should links to entries be created, even if they are still at draft state?');
@define('PLUGIN_EVENT_WIKILINKS_SHOWFUTURELINKS_NAME', 'Create links to future entries?'); @define('PLUGIN_EVENT_WIKILINKS_SHOWFUTURELINKS_NAME', 'Create links to future entries?');
@define('PLUGIN_EVENT_WIKILINKS_SHOWFUTURELINKS_DESK', 'Should links to entries be created, even if they are still dated in the future?'); @define('PLUGIN_EVENT_WIKILINKS_SHOWFUTURELINKS_DESK', 'Should links to entries be created, even if they are still dated in the future?');
@define('PLUGIN_EVENT_WIKILINKS_REFMATCH_NAME', 'Pattern for reference capturing');
@define('PLUGIN_EVENT_WIKILINKS_REFMATCH_DESC', 'Here you can specify the pattern that will be used to go through your text, and that will capture all references written in this way. It will collect those references, store them in a database and format them below the blogentry. Also you can use {$entry.properties.references} to place it anywhere you like in your smarty template file. The pattern is specified as a regular expression, be sure to escape special characters. The default looks complex because it uses named subpatterns, but it can be easily used like this: <ref name="xxx">yyy</ref> - where xxx is an optional name of a reference (see below) and yyy the actual text, where yyy can be any HTML or markup you like.');
@define('PLUGIN_EVENT_WIKILINKS_REFDOC', '<strong>Re-Using references</strong><br /><br />If you want to use references on multiple occasions, it\'s helpful to only specify them once and reuse them later. If you have this text for example:<br />
<div style="border: 1px solid black; padding: 4px">
Serendipity&lt;ref&gt;&lt;a href="http://www.s9y.org"&gt;Serendipity Weblog&lt;/a&gt; - also, Serendipity stands for several other interpretations like a movie, or a dancer in a movie, or a movie of a dancer in a movie.</ref> can be found in many places.
</div>
<br/><br />
Since you surely will mention Serendipity a lot of times in your blog, you should make a referenced mention, which works by adding a <em>name</em> attribute to the &lt;ref&gt; tag, and make it look like this:
<div style="border: 1px solid black; padding: 4px">
Serendipity&lt;ref name="Serendipity"&gt;&lt;a href="http://www.s9y.org"&gt;Serendipity Weblog&lt;/a&gt; - also, Serendipity stands for several other interpretations like a movie, or a dancer in a movie, or a movie of a dancer in a movie.</ref> can be found in many places.</pre>
</div>
<br/><br />
Now you only need to do this for the first occurence of your reference. Whenever you want to use the same reference in future blog entries you simply write this:
<div style="border: 1px solid black; padding: 4px">
Serendipity&lt;ref name="Serendipity"&gt;&lt;/ref&gt;
</div>
<br /><br />
This will take care of fetching the existing, named reference text from the database. Please note that you must use the &lt;ref&gt;...&lt;/ref&gt; notation, &lt;ref.../&gt; is not supported due to the regular expression syntax not properly supporting this.
');
@define('PLUGIN_EVENT_WIKILINKS_REFMATCHTARGET_NAME', 'Format for replaced reference output');
@define('PLUGIN_EVENT_WIKILINKS_REFMATCHTARGET_DESC', 'Here you can enter how the captured reference will be replaced, usually a number linking to the list of references. {count} and {text} are placeholders for the replaced reference number and its original text. {refname} corresponds to an optional name of the reference.');
@define('PLUGIN_EVENT_WIKILINKS_REFMATCHTARGET2_NAME', 'Format for reference list output');
@define('PLUGIN_EVENT_WIKILINKS_REFMATCHTARGET2_DESC', 'Here you can enter how the captured reference will be displayed in the list. If set to "-", then no output will take place (useful if you want to style the output via smarty yourself!)');
@define('PLUGIN_EVENT_WIKILINKS_MAINT', 'Maintain reference index');
@define('PLUGIN_EVENT_WIKILINKS_MAINT_DESC', 'Here you can edit stored references. Be sure to note that if you edit the original entry where the reference occured in, that the text of a reference there always takes precedence over anything you edit here. If you frequently re-edit old entries, you should better maintain the texts of references inside the entries, and not here.');
@define('PLUGIN_EVENT_WIKILINKS_DB_REFNAME', 'Reference name');
@define('PLUGIN_EVENT_WIKILINKS_DB_REF', 'Reference content');
@define('PLUGIN_EVENT_WIKILINKS_DB_ENTRYDID', 'Defined in:');

View file

@ -1,5 +1,8 @@
<?php # $Id: serendipity_event_wikilinks.php,v 1.19 2009/08/07 10:13:48 garvinhicking Exp $ <?php # $Id: serendipity_event_wikilinks.php,v 1.19 2009/08/07 10:13:48 garvinhicking Exp $
// TODO:
// Show existing references for insertion in 'Extended options' panel for 'edit entry' screen
// Test smarty output
if (IN_serendipity !== true) { if (IN_serendipity !== true) {
die ("Don't hack!"); die ("Don't hack!");
@ -16,6 +19,7 @@ include dirname(__FILE__) . '/lang_en.inc.php';
class serendipity_event_wikilinks extends serendipity_event class serendipity_event_wikilinks extends serendipity_event
{ {
var $title = PLUGIN_EVENT_WIKILINKS_NAME; var $title = PLUGIN_EVENT_WIKILINKS_NAME;
var $references = array();
function introspect(&$propbag) function introspect(&$propbag)
{ {
@ -25,7 +29,7 @@ class serendipity_event_wikilinks extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_WIKILINKS_DESC); $propbag->add('description', PLUGIN_EVENT_WIKILINKS_DESC);
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking, Grischa Brockhaus'); $propbag->add('author', 'Garvin Hicking, Grischa Brockhaus');
$propbag->add('version', '0.18'); $propbag->add('version', '0.20');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '1.0', 'serendipity' => '1.0',
'smarty' => '2.6.7', 'smarty' => '2.6.7',
@ -36,7 +40,11 @@ class serendipity_event_wikilinks extends serendipity_event
'frontend_display' => true, 'frontend_display' => true,
'backend_entry_toolbar_extended' => true, 'backend_entry_toolbar_extended' => true,
'backend_entry_toolbar_body' => true, 'backend_entry_toolbar_body' => true,
'external_plugin' => true 'external_plugin' => true,
'backend_publish' => true,
'backend_save' => true,
'backend_sidebar_entries_event_display_wikireferences' => true,
'backend_sidebar_entries' => true,
)); ));
$this->markup_elements = array( $this->markup_elements = array(
@ -65,6 +73,10 @@ class serendipity_event_wikilinks extends serendipity_event
$conf_array[] = 'imgpath'; $conf_array[] = 'imgpath';
$conf_array[] = 'generate_draft_links'; $conf_array[] = 'generate_draft_links';
$conf_array[] = 'generate_future_links'; $conf_array[] = 'generate_future_links';
$conf_array[] = 'reference_match';
$conf_array[] = 'reference_info';
$conf_array[] = 'target_match';
$conf_array[] = 'target_match2';
$propbag->add('configuration', $conf_array); $propbag->add('configuration', $conf_array);
} }
@ -82,12 +94,14 @@ class serendipity_event_wikilinks extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_WIKILINKS_IMGPATH_DESC); $propbag->add('description', PLUGIN_EVENT_WIKILINKS_IMGPATH_DESC);
$propbag->add('default', $serendipity['serendipityHTTPPath'] . 'plugins/serendipity_event_wikilinks/'); $propbag->add('default', $serendipity['serendipityHTTPPath'] . 'plugins/serendipity_event_wikilinks/');
break; break;
case 'generate_draft_links': case 'generate_draft_links':
$propbag->add('name', PLUGIN_EVENT_WIKILINKS_SHOWDRAFTLINKS_NAME); $propbag->add('name', PLUGIN_EVENT_WIKILINKS_SHOWDRAFTLINKS_NAME);
$propbag->add('description', PLUGIN_EVENT_WIKILINKS_SHOWDRAFTLINKS_DESC); $propbag->add('description', PLUGIN_EVENT_WIKILINKS_SHOWDRAFTLINKS_DESC);
$propbag->add('type', 'boolean'); $propbag->add('type', 'boolean');
$propbag->add('default', 'true'); $propbag->add('default', 'true');
break; break;
case 'generate_future_links': case 'generate_future_links':
$propbag->add('name', PLUGIN_EVENT_WIKILINKS_SHOWFUTURELINKS_NAME); $propbag->add('name', PLUGIN_EVENT_WIKILINKS_SHOWFUTURELINKS_NAME);
$propbag->add('description', PLUGIN_EVENT_WIKILINKS_SHOWFUTURELINKS_DESK); $propbag->add('description', PLUGIN_EVENT_WIKILINKS_SHOWFUTURELINKS_DESK);
@ -95,9 +109,40 @@ class serendipity_event_wikilinks extends serendipity_event
$propbag->add('default', 'true'); $propbag->add('default', 'true');
break; break;
case 'reference_match':
$propbag->add('name', PLUGIN_EVENT_WIKILINKS_REFMATCH_NAME);
$propbag->add('description', PLUGIN_EVENT_WIKILINKS_REFMATCH_DESC);
$propbag->add('type', 'string');
$propbag->add('default', '<ref(?:\s*name=["\'](?P<refname>.+)["\'])?>(?P<ref>.*)</ref>');
break;
case 'target_match':
$propbag->add('name', PLUGIN_EVENT_WIKILINKS_REFMATCHTARGET_NAME);
$propbag->add('description', PLUGIN_EVENT_WIKILINKS_REFMATCHTARGET_DESC);
$propbag->add('type', 'string');
$propbag->add('default', '<sup class="wikiref"><a href="#reference{count}" title="{text}">{count}</a></sup>');
break;
case 'target_match2':
$propbag->add('name', PLUGIN_EVENT_WIKILINKS_REFMATCHTARGET2_NAME);
$propbag->add('description', PLUGIN_EVENT_WIKILINKS_REFMATCHTARGET2_DESC);
$propbag->add('type', 'string');
$propbag->add('default', '<li id="reference{count}" title="{refname}">{text}</li>');
break;
case 'reference_info':
$propbag->add('name', PLUGIN_EVENT_WIKILINKS_REFMATCHTARGET2_NAME);
$propbag->add('description', PLUGIN_EVENT_WIKILINKS_REFMATCHTARGET2_DESC);
$propbag->add('type', 'content');
$propbag->add('default', PLUGIN_EVENT_WIKILINKS_REFDOC);
break;
case 'db_built':
return false;
default: default:
$propbag->add('type', 'boolean'); $propbag->add('type', 'boolean');
$propbag->add('name', constant($name)); $propbag->add('name', @constant($name));
$propbag->add('description', sprintf(APPLY_MARKUP_TO, constant($name))); $propbag->add('description', sprintf(APPLY_MARKUP_TO, constant($name)));
$propbag->add('default', 'true'); $propbag->add('default', 'true');
} }
@ -111,6 +156,68 @@ class serendipity_event_wikilinks extends serendipity_event
if (isset($hooks[$event])) { if (isset($hooks[$event])) {
switch($event) { switch($event) {
case 'backend_publish':
case 'backend_save':
// Purge, so that the data within the entry takes precedence over other changes
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}wikireferences WHERE entryid = " . (int)$eventData['id']);
break;
case 'backend_sidebar_entries':
$this->setupDB();
echo '<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=wikireferences">' . PLUGIN_EVENT_WIKILINKS_MAINT . '</a></li>';
break;
case 'backend_sidebar_entries_event_display_wikireferences':
$entries = serendipity_db_query("SELECT id, refname FROM {$serendipity['dbPrefix']}wikireferences ORDER BY refname ASC");
echo '<p>' . PLUGIN_EVENT_WIKILINKS_MAINT_DESC . '</p>';
echo '<form action="serendipity_admin.php" method="post" name="serendipityEntry">';
echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />';
echo '<input type="hidden" name="serendipity[adminAction]" value="wikireferences" />';
echo '<select name="serendipity[wikireference]">';
echo '<option value="">...</option>';
foreach((array)$entries AS $idx => $row) {
echo '<option value="' . $row['id'] . '" ' . ($row['id'] == $serendipity['POST']['wikireference'] ? 'selected="selected"' : '') . '>' . $row['refname'] . '</option>' . "\n";
}
echo '</select>';
echo '<input type="submit" class="serendipityPrettyButton input_button" name="serendipity[typeSubmit]" value="' . GO . '" />';
echo '<br /><br />';
if ($serendipity['POST']['wikireference'] > 0) {
if ($serendipity['POST']['saveSubmit']) {
serendipity_db_update('wikireferences', array('id' => $serendipity['POST']['wikireference']), array('refname' => $serendipity['POST']['wikireference_refname'], 'ref' => $serendipity['POST']['wikireference_ref']));
echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE .': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>';
}
$ref = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}wikireferences WHERE id = " . (int)$serendipity['POST']['wikireference'], 'assoc', true);
$entry = serendipity_fetchEntry('id', $ref['entryid']);
echo '<div>';
echo '<label>' . PLUGIN_EVENT_WIKILINKS_DB_REFNAME . '</label><br />';
echo '<input type="text" name="serendipity[wikireference_refname]" value="' . htmlspecialchars($ref['refname']) . '" />';
echo '<input type="submit" class="serendipityPrettyButton input_button" name="serendipity[saveSubmit]" value="' . SAVE . '" />';
echo '</div>';
echo '<div>';
echo '<label>' . PLUGIN_EVENT_WIKILINKS_DB_REF . '</label><br />';
echo '<textarea cols="80" rows="20" name="serendipity[wikireference_ref]">' . htmlspecialchars($ref['ref']) . '</textarea>';
echo '</div>';
echo '<div>';
echo '<label>' . PLUGIN_EVENT_WIKILINKS_DB_ENTRYDID . '</label>';
echo '<a href="' . serendipity_archiveUrl($ref['entryid'], $entry['title']) . '">' . $entry['title'] . '</a>';
echo '<p><a class="serendipityPrettyButton" href="?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=' . $entry['id'] . '">' . EDIT_ENTRY . '</a></p>';
echo '</div>';
}
echo '</form>';
break;
case 'frontend_display': case 'frontend_display':
foreach ($this->markup_elements as $temp) { foreach ($this->markup_elements as $temp) {
if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) && if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) &&
@ -118,21 +225,36 @@ class serendipity_event_wikilinks extends serendipity_event
!isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) { !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) {
$element = $temp['element']; $element = $temp['element'];
$is_body = false;
if ($element == 'body' || $element == 'extended') { if ($element == 'body' || $element == 'extended') {
$source =& $this->getFieldReference($element, $eventData); $source =& $this->getFieldReference($element, $eventData);
if ($source === '') { if ($source === '') {
// Prevent bug from serendipity 0.9 // Prevent bug from serendipity 0.9
$source =& $eventData[$element]; $source =& $eventData[$element];
} }
$is_body = true;
} else { } else {
$source =& $eventData[$element]; $source =& $eventData[$element];
} }
$this->references = $this->refcount = array();
$this->ref_entry = $eventData['id'];
$source = preg_replace_callback(
'^' . $this->get_config('reference_match') . '^imsU',
array($this, '_reference'),
$source
);
$source = preg_replace_callback( $source = preg_replace_callback(
"#(\[\[|\(\(|\{\{)(.+)(\]\]|\)\)|\}\})#isUm", "#(\[\[|\(\(|\{\{)(.+)(\]\]|\)\)|\}\})#isUm",
array($this, '_wikify'), array($this, '_wikify'),
$source $source
); );
$source .= $this->reference_parse();
if ($is_body) {
$eventData['properties']['references'] = $this->references;
}
} }
} }
@ -299,6 +421,124 @@ function use_link_<?php echo $func; ?>(txt) {
} }
} }
function install() {
$this->setupDB();
}
function setupDB() {
global $serendipity;
$built = $this->get_config('db_built', null);
if (empty($built)) {
serendipity_db_schema_import("CREATE TABLE {$serendipity['dbPrefix']}wikireferences (
id {AUTOINCREMENT} {PRIMARY},
entryid int(11) default '0',
refname text,
ref text)");
serendipity_db_schema_import("CREATE INDEX wikiref_refname ON {$serendipity['dbPrefix']}wikireferences (refname(200));");
serendipity_db_schema_import("CREATE INDEX wikiref_comb ON {$serendipity['dbPrefix']}wikireferences (entryid,refname(200));");
serendipity_db_schema_import("CREATE INDEX wikiref_entry ON {$serendipity['dbPrefix']}wikireferences (entryid);");
$this->set_config('db_built', 1);
}
}
function _reference($buffer) {
global $serendipity;
static $count = 0;
$count++;
if (!empty($buffer['ref']) && !empty($buffer['refname']) && !empty($this->ref_entry)) {
// New refname, needs to be stored in the database IF NOT CURRENTLY EXISTING
$exists = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}wikireferences WHERE refname = '" . serendipity_db_escape_string($buffer['refname']) . "'", 'assoc', true);
if ($exists['entryid'] == $this->ref_entry) {
#serendipity_db_update('wikireferences', array('entryid' => $this->ref_entry, 'refname' => $buffer['refname']), array('ref' => $buffer['ref']));
} elseif (empty($exists['entryid'])) {
serendipity_db_insert('wikireferences', array('entryid' => $this->ref_entry, 'refname' => $buffer['refname'], 'ref' => $buffer['ref']));
}
}
if (empty($buffer['ref']) && !empty($buffer['refname'])) {
// We found a referenced pattern like <ref name="XXX" />, so let's fetch that from the database!
$exists = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}wikireferences WHERE refname = '" . serendipity_db_escape_string($buffer['refname']) . "'", 'assoc', true);
$buffer['ref'] = $exists['ref'];
}
if (empty($buffer['refname'])) {
$buffer['refname'] = $count;
}
$refix = $count;
if (isset($this->references[$buffer['refname']])) {
if ($this->references[$buffer['refname']] == $buffer['ref']) {
$refix = $this->refcount[$buffer['refname']];
} else {
$this->references[$buffer['refname'] . $count] = $buffer['ref'];
$this->refcount[$buffer['refname'] . $count] = $count;
}
} else {
$this->references[$buffer['refname']] = $buffer['ref'];
$this->refcount[$buffer['refname']] = $count;
}
$result = $this->get_config('target_match');
$result = str_replace(
array(
'{count}',
'{text}',
'{refname}'
),
array(
$refix,
htmlspecialchars($buffer['ref']),
htmlspecialchars($buffer['refname']),
),
$result
);
return $result;
}
function reference_parse() {
global $serendipity;
static $count = 0;
static $count2 = 0;
$count++;
$format = $this->get_config('target_match2');
if ($format == '-') return;
$block = "\n\n" . '<ol class="serendipity_referencelist" id="serendipity_referencelist' . $count . '">' . "\n";
foreach($this->references AS $key => $buffer) {
$count2++;
$result = str_replace(
array(
'{count}',
'{text}',
'{refname}'
),
array(
$count2,
htmlspecialchars($buffer),
$key
),
$format
);
$block .= $result . "\n";
}
$block .= '</ol>' . "\n";
return $block;
}
/** /**
* Wikifies: * Wikifies:
@ -309,7 +549,7 @@ function use_link_<?php echo $func; ?>(txt) {
global $serendipity; global $serendipity;
$debug = true; $debug = true;
$$admin_url = false; $admin_url = false;
$cidx = 2; $cidx = 2;