function write_links($aliases) { // Here we run through the static pages database and put in cross links // around the keywords in the text global $serendipity; // **TODO** Change this to pull out only entries for the current wiki echo '<br/><p>' . IMPORTER_VOODOO_WRITEINTRALINKS . '</p>'; $pages =& serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}staticpages ORDER BY pagetitle DESC"); foreach ($pages as $thispage) { // Parse the content string foreach ($aliases as $alias => $permalink) { $thispage['content'] = Serendipity_Import_VoodooPad::wikify($alias, $permalink, $thispage['content']); } for ($counter = 0; $counter <= 12; $counter += 1) { unset($thispage[$counter]); } // Write back to the database serendipity_db_update("staticpages", array("id" => $thispage["id"]), $thispage); } echo DONE . '<br />'; }
/** * Inserts a new entry into the database or updates an existing entry * * Another central function, that parses, prepares and commits changes to an entry * * @access public * @param array The new/modified entry data. * @return mixed Integer with new entry ID if successfull, a string or array if error(s). */ function serendipity_updertEntry($entry) { global $serendipity; include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php'; $errors = array(); serendipity_plugin_api::hook_event('backend_entry_updertEntry', $errors, $entry); if (count($errors) > 0) { // Return error message(s) return implode("\n", $errors); } serendipity_plugin_api::hook_event('backend_entry_presave', $entry); $categories = $entry['categories']; unset($entry['categories']); $newEntry = 0; $exflag = 0; if (isset($entry['properties'])) { unset($entry['properties']); } if (!is_numeric($entry['timestamp'])) { $entry['timestamp'] = time(); } /* WYSIWYG-editor inserts empty ' ' for extended body; this is reversed here */ if (isset($entry['extended']) && (trim($entry['extended']) == '' || trim($entry['extended']) == '<br />' || trim($entry['extended']) == '<p></p>' || str_replace(array("\r", "\n", "\t", "", "<br />", "<p>", "</p>", "<br>"), array('', '', '', '', '', '', '', ''), trim($entry['extended'])) == '')) { $entry['extended'] = ''; } if (strlen($entry['extended'])) { $exflag = 1; } $entry['exflag'] = $exflag; if (!is_numeric($entry['id'])) { /* we need to insert */ unset($entry['id']); $entry['comments'] = 0; if (!isset($entry['last_modified']) || !is_numeric($entry['last_modified'])) { $entry['last_modified'] = $entry['timestamp']; } // New entries need an author $entry['author'] = $serendipity['user']; if (!isset($entry['authorid']) || empty($entry['authorid'])) { $entry['authorid'] = $serendipity['authorid']; } if (!$_SESSION['serendipityRightPublish']) { $entry['isdraft'] = 'true'; } if (!isset($entry['allow_comments'])) { $entry['allow_comments'] = 'false'; } if (!isset($entry['moderate_comments'])) { $entry['moderate_comments'] = 'false'; } $res = serendipity_db_insert('entries', $entry); if ($res) { $entry['id'] = $serendipity['lastSavedEntry'] = serendipity_db_insert_id('entries', 'id'); if (is_array($categories)) { foreach ($categories as $cat) { if (is_numeric($cat)) { serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}entrycat (entryid, categoryid) VALUES ({$entry['id']}, {$cat})"); } } } serendipity_insertPermalink($entry); } else { //Some error message here return ENTRIES_NOT_SUCCESSFULLY_INSERTED; } $newEntry = 1; } else { /* we need to update */ // Get settings from entry if already in DB, which should not be alterable with POST methods $_entry = serendipity_fetchEntry('id', $entry['id'], 1, 1); $entry['authorid'] = $_entry['authorid']; if (isset($serendipity['GET']['adminModule']) && $serendipity['GET']['adminModule'] == 'entries' && $entry['authorid'] != $serendipity['authorid'] && !serendipity_checkPermission('adminEntriesMaintainOthers')) { // Only chiefs and admins can change other's entry. Else update fails. return; } if (!$_SESSION['serendipityRightPublish']) { $entry['isdraft'] = 'true'; } if (is_array($categories)) { serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}entrycat WHERE entryid={$entry['id']}"); foreach ($categories as $cat) { serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}entrycat (entryid, categoryid) VALUES ({$entry['id']}, {$cat})"); } } //if (!serendipity_db_bool($entry['isdraft']) && !serendipity_db_bool($_entry['isdraft'])) { $entry['last_modified'] = time(); //} $res = serendipity_db_update('entries', array('id' => $entry['id']), $entry); $newEntry = 0; serendipity_updatePermalink($entry); } if (is_string($res)) { return $res; } // Reset session data, so that a reload to this frame should not happen! $_SESSION['save_entry']['id'] = (int) $entry['id']; if (!serendipity_db_bool($entry['isdraft'])) { serendipity_plugin_api::hook_event('frontend_display', $entry, array('no_scramble' => true, 'from' => 'functions_entries:updertEntry')); $drafted_entry = $entry; } serendipity_purgeEntry($entry['id'], $entry['timestamp']); if (!serendipity_db_bool($entry['isdraft']) && $entry['timestamp'] <= serendipity_serverOffsetHour()) { // When saving an entry, first all references need to be gathered. But trackbacks to them // shall only be send at the end of the execution flow. However, certain plugins depend on // the existance of handled references. Thus we store the current references at this point, // execute the plugins and then reset the found references to the original state. serendipity_handle_references($entry['id'], $serendipity['blogTitle'], $drafted_entry['title'], $drafted_entry['body'] . $drafted_entry['extended'], true); } // Send publish tags if either a new article has been inserted from scratch, or if the entry was previously // stored as draft and is now published $entry['categories'] =& $categories; if (!serendipity_db_bool($entry['isdraft']) && ($newEntry || serendipity_db_bool($_entry['isdraft']))) { serendipity_plugin_api::hook_event('backend_publish', $entry, $newEntry); } else { serendipity_plugin_api::hook_event('backend_save', $entry, $newEntry); } if (!serendipity_db_bool($entry['isdraft']) && $entry['timestamp'] <= serendipity_serverOffsetHour()) { // Now that plugins are executed, we go ahead into the Temple of Doom and send possibly failing trackbacks. // First, original list of references is restored (inside the function call) serendipity_handle_references($entry['id'], $serendipity['blogTitle'], $drafted_entry['title'], $drafted_entry['body'] . $drafted_entry['extended'], false); } return (int) $entry['id']; }
static function updateOpenID($openid_url, $authorID) { global $serendipity; if (!is_array(serendipity_db_query("SELECT username FROM {$serendipity['dbPrefix']}openid_authors LIMIT 1", true, 'both', false, false, false, true))) { serendipity_db_schema_import("CREATE TABLE {$serendipity['dbPrefix']}openid_authors (\r\n openid_url varchar(255) default null,\r\n hash varchar(32) default null,\r\n authorid int(11) default '0'\r\n );"); } $hash = md5($openid_url); if (serendipity_common_openid::getOpenID($authorID, true)) { $retVal = serendipity_db_update('openid_authors', array('authorid' => $authorID), array('openid_url' => $openid_url, 'hash' => $hash)); } else { $retVal = serendipity_db_insert('openid_authors', array('openid_url' => $openid_url, 'hash' => $hash, 'authorid' => $authorID)); } return $retVal === true ? true : false; }
function move_down($id) { // no more & global $serendipity; $dospecial = false; $q = 'SELECT pageorder, parent_id FROM ' . $serendipity['dbPrefix'] . 'staticpages WHERE id=' . $id; $thispage = serendipity_db_query($q, true, 'assoc'); $q = 'SELECT id FROM ' . $serendipity['dbPrefix'] . 'staticpages WHERE parent_id = ' . $thispage['parent_id'] . ' AND pageorder = ' . ($thispage['pageorder'] + 1); $childpage = serendipity_db_query($q, true, 'assoc'); $sisters = $this->getSystersID($id); for ($i = 0, $ii = count($sisters); $i < $ii; $i++) { if ($sisters[$i]['id'] != $id && $sisters[$i]['pageorder'] == $thispage['pageorder']) { $dospecial = true; break; } } if ($dospecial) { for ($i = 0, $ii = count($sisters); $i < $ii; $i++) { serendipity_db_update('staticpages', array('id' => $sisters[$i]['id']), array('pageorder' => $i + 1)); } } else { serendipity_db_update('staticpages', array('id' => $id), array('pageorder' => $thispage['pageorder'] + 1)); serendipity_db_update('staticpages', array('id' => $childpage['id']), array('pageorder' => $thispage['pageorder'])); } @unlink($this->cachefile); }
function faqMove(&$id, &$cid, $moveto) { global $serendipity; $q = 'SELECT faqorder FROM ' . $serendipity['dbPrefix'] . 'faqs WHERE id = ' . $id . ' AND cid = ' . $cid; $old = serendipity_db_query($q, true, 'assoc'); switch ($moveto) { case D_FAQ_MOVEUP: serendipity_db_update('faqs', array('cid' => $cid, 'faqorder' => $old['faqorder'] - 1), array('faqorder' => $old['faqorder'])); serendipity_db_update('faqs', array('id' => $id), array('faqorder' => $old['faqorder'] - 1)); break; case D_FAQ_MOVEDOWN: serendipity_db_update('faqs', array('cid' => $cid, 'faqorder' => $old['faqorder'] + 1), array('faqorder' => $old['faqorder'])); serendipity_db_update('faqs', array('id' => $id), array('faqorder' => $old['faqorder'] + 1)); break; default: return false; } return true; }
/** * Update table for re-ordering * * @access public * @author Falk Doering * @param string Name of the table * @param string The direction ('up' or 'down') * @param array The update array * @param array The array containing the where clause * @return boolean */ function doReorder($table, $moveto, $update_array, $where_array) { global $serendipity; if (is_array($update_array) && is_array($where_array)) { $where = ''; foreach ($where_array as $key => $value) { if (strlen($where)) { $where .= ' AND '; } $where .= $key . ' = ' . $value; } $q = 'SELECT ' . implode(", ", array_keys($update_array)) . ' FROM ' . $serendipity['dbPrefix'] . $table . ' WHERE ' . $where; $old = serendipity_db_query($q, true, 'assoc'); if (is_array($old)) { $where = array(); $update = array(); switch ($moveto) { case 'up': foreach ($update_array as $key => $value) { if ($value) { $where[$key] = $old[$key] - 1; $update[$key] = $old[$key]; $update_1[$key] = $old[$key] - 1; } else { $where[$key] = $old[$key]; } } break; case 'down': foreach ($update_array as $key => $value) { if ($value) { $where[$key] = $old[$key] + 1; $update[$key] = $old[$key]; $update_1[$key] = $old[$key] + 1; } else { $where[$key] = $old[$key]; } } break; default: return false; } serendipity_db_update($table, $where, $update); serendipity_db_update($table, $where_array, $update_1); return true; } } return false; }
function del_category($id) { global $serendipity; $q = 'DELETE FROM ' . $serendipity['dbPrefix'] . 'link_category where categoryid=' . (int) $id; $sql = serendipity_db_query($q); $values['category'] = 0; $key['category'] = $id; serendipity_db_update('links', $key, $values); }
function updateStaticBlock() { global $serendipity; $this->checkBlock(); if (empty($this->staticblock['apply_markup'])) { $this->staticblock['apply_markup'] = '0'; } if (!isset($this->staticblock['id'])) { $result = serendipity_db_insert('staticblocks', $this->staticblock); if (is_string($result)) { if ($serendipity['version'][0] < 2) { echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />ERROR: ' . $result . '</div>' . "\n"; } else { echo '<div class="msg_error"><span class="icon-attention-circled"></span> ERROR: ' . $result . '</div>' . "\n"; } } $serendipity["POST"]["staticblock"] = serendipity_db_insert_id("staticblocks", 'id'); } else { $result = serendipity_db_update("staticblocks", array("id" => $this->staticblock["id"]), $this->staticblock); if (is_string($result)) { if ($serendipity['version'][0] < 2) { echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />ERROR: ' . $result . '</div>' . "\n"; } else { echo '<div class="msg_error"><span class="icon-attention-circled"></span> ERROR: ' . $result . '</div>' . "\n"; } } } }
function del_category($id) { global $serendipity; $q = 'DELETE FROM ' . $serendipity['dbPrefix'] . 'project_category where categoryid=' . $id; $sql = serendipity_db_query($q); $values['category'] = 0; $key['category'] = $id; serendipity_db_update('percentagedone', $key, $values); }
function lj_update($eventData, $delete = '') { global $serendipity; $this->check_lj_entries(); $rec_exists = false; $itemid = 0; $rec = serendipity_db_query("SELECT itemid FROM {$serendipity['dbPrefix']}lj_entries where entry_id=" . (int) $eventData['id'], true); if (is_array($rec)) { $itemid = $rec['itemid']; $rec_exests = true; } if ($delete == 'delete' && $itemid == 0) { return; } echo "Update LiveJournal...<br />\n"; if ($delete == 'delete') { serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}lj_entries where entry_id=" . (int) $eventData['id']); } else { if ($rec_exists) { serendipity_db_update('lj_entries', array('entry_id' => round($eventData['id'])), array('itemid' => $itemid, 'current_mood' => $serendipity['POST']['ljmood'], 'current_music' => $serendipity['POST']['ljmusic'], 'picture_keyword' => $serendipity['POST']['ljuserpic'], 'security' => $serendipity['POST']['ljsecurity'], 'opt_nocomments' => $serendipity['POST']['ljcomment'])); } else { serendipity_db_insert('lj_entries', array('entry_id' => (int) $eventData['id'], 'itemid' => $itemid, 'current_mood' => $serendipity['POST']['ljmood'], 'current_music' => $serendipity['POST']['ljmusic'], 'picture_keyword' => $serendipity['POST']['ljuserpic'], 'security' => $serendipity['POST']['ljsecurity'], 'opt_nocomments' => $serendipity['POST']['ljcomment'])); } } $event = $eventData['body']; if ($eventData['extended']) { $event .= "<br /><br /><lj-cut text='" . $this->get_config('ljcuttext') . "'>\n" . $eventData['extended'] . "</lj-cut>"; } if ($serendipity['POST']['ljcomment'] == 1) { $commentlink = serendipity_archiveURL($eventData['id'], $eventData['title'], 'baseURL', true, array('timestamp' => $eventData['timestamp'])); $event .= "<br /><a style=\"text-align: right\" href=\"{$commentlink}#comments\">" . PLUGIN_LJUPDATE_READCOMMENTS . "</a>"; } else { $serendipity['POST']['ljcomment'] = 0; } if (empty($serendipity['POST']['ljsecurity'])) { $serendipity['POST']['ljsecurity'] = 'public'; } //Make LJ Entries not doublespaced $event = str_replace("\n", "", $event); //Replace relative with absolute URLs $event = preg_replace('@(href|src)=("|\')(' . preg_quote($serendipity['serendipityHTTPPath']) . ')(.*)("|\')(.*)>@imsU', '\\1=\\2' . $serendipity['baseURL'] . '\\4\\2\\6>', $event); $t = serendipity_serverOffsetHour($eventData['timestamp']); $params['username'] = new XML_RPC_Value($this->get_config('ljusername'), 'string'); $params['hpassword'] = new XML_RPC_Value(md5($this->get_config('ljpass')), 'string'); if ($itemid != 0) { $params['itemid'] = new XML_RPC_Value($itemid, 'string'); } if ($delete == 'delete') { $params['event'] = new XML_RPC_Value('', 'string'); $params['subject'] = new XML_RPC_Value('', 'string'); $params['year'] = new XML_RPC_Value('', 'string'); $params['mon'] = new XML_RPC_Value('', 'string'); $params['day'] = new XML_RPC_Value('', 'string'); $params['hour'] = new XML_RPC_Value('', 'string'); $params['min'] = new XML_RPC_Value('', 'string'); } else { $params['event'] = new XML_RPC_Value($event, 'string'); $params['subject'] = new XML_RPC_Value($eventData['title'], 'string'); $params['year'] = new XML_RPC_Value(date('Y', $t), 'string'); $params['mon'] = new XML_RPC_Value(date('m', $t), 'string'); $params['day'] = new XML_RPC_Value(date('d', $t), 'string'); $params['hour'] = new XML_RPC_Value(date('H', $t), 'string'); $params['min'] = new XML_RPC_Value(date('i', $t), 'string'); $params['security'] = new XML_RPC_Value($serendipity['POST']['ljsecurity'], 'string'); if ($serendipity['POST']['ljsecurity'] == 'usemask') { $params['allowmask'] = new XML_RPC_Value(1, 'string'); } $props['current_mood'] = new XML_RPC_Value($serendipity['POST']['ljmood'], 'string'); $props['current_music'] = new XML_RPC_Value($serendipity['POST']['ljmusic'], 'string'); $props['picture_keyword'] = new XML_RPC_Value($serendipity['POST']['ljuserpic'], 'string'); $props['opt_nocomments'] = new XML_RPC_Value($serendipity['POST']['ljcomment'], 'string'); $params['props'] = new XML_RPC_Value($props, 'struct'); } $client = new XML_RPC_Client('/interface/xmlrpc', $this->get_config('ljserver')); $data = new XML_RPC_Value($params, 'struct'); if ($itemid == 0 && $delete != 'delete') { $msg = new XML_RPC_Message('LJ.XMLRPC.postevent', array($data)); } else { $msg = new XML_RPC_Message('LJ.XMLRPC.editevent', array($data)); } $res = $client->send($msg, 10); if ($res->faultCode() == 0) { $v = $res->value()->getval(); $newitemid = (int) $v['itemid']; } else { echo htmlentities($res->faultString(), ENT_COMPAT, LANG_CHARSET) . '<br />'; $newitemid = 0; } if ($itemid != $newitemid && $newitemid != 0) { serendipity_db_update('lj_entries', array('entry_id' => round($eventData['id'])), array('itemid' => $newitemid)); } echo "Updating finished.<br />\n"; }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$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&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'], true, 'assoc'); $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="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($ref['refname']) : htmlspecialchars($ref['refname'], ENT_COMPAT, LANG_CHARSET)) . '" />'; 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]">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($ref['ref']) : htmlspecialchars($ref['ref'], ENT_COMPAT, LANG_CHARSET)) . '</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&serendipity[adminModule]=entries&serendipity[adminAction]=edit&serendipity[id]=' . $entry['id'] . '">' . EDIT_ENTRY . '</a></p>'; echo '</div>'; } echo '</form>'; break; case 'frontend_display': $this->out_references = array(); foreach ($this->markup_elements as $temp) { if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) && !$eventData['properties']['ep_disable_markup_' . $this->instance] && !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) { $element = $temp['element']; $is_body = false; if ($element == 'body' || $element == 'extended') { $source =& $this->getFieldReference($element, $eventData); if ($source === '') { // Prevent bug from serendipity 0.9 $source =& $eventData[$element]; } $is_body = true; } else { $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("#(\\[\\[|\\(\\(|\\{\\{)(.+)(\\]\\]|\\)\\)|\\}\\})#isUm", array($this, '_wikify'), $source); $source .= $this->reference_parse(); if ($is_body) { if (!is_array($eventData['properties']['references'])) { $eventData['properties']['references'] = array(); } $eventData['properties']['references'] += $this->references; } } } return true; break; case 'external_plugin': $what = ''; if ($eventData == 'popup_choose_entry') { $what = 'body'; } elseif ($eventData == 'popup_choose_entrybody') { $what = 'body'; } elseif ($eventData == 'popup_choose_entryextended') { $what = 'extended'; } elseif (preg_match('/^popup_choose_entry(.*)$/i', $eventData, $matches)) { // get the custom thing that is to be selected, for example a nugget $what = $matches[1]; } if (empty($what)) { return false; } ?> <html> <head> <title><?php echo PLUGIN_EVENT_WIKILINKS_LINKENTRY; ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo LANG_CHARSET; ?> " /> <link rel="stylesheet" type="text/css" href="<?php echo 'serendipity.css.php?serendipity[css_mode]=serendipity_admin.css'; ?> " /> <link rel="stylesheet" type="text/css" href="<?php echo serendipity_getTemplateFile('admin/pluginmanager.css'); ?> " /> </head> <body id="serendipity_admin_page"> <div id="serendipityAdminFrame"> <div id="serendipityAdminBanner"> <h1><?php echo SERENDIPITY_ADMIN_SUITE; ?> </h1> <h2><?php echo PLUGIN_EVENT_WIKILINKS_LINKENTRY_DESC; ?> </h2> </div> <div id="serendipityAdminContent"> <ul> <?php $sql = "SELECT *\n FROM {$serendipity['dbPrefix']}entries\n ORDER BY timestamp DESC"; $e = serendipity_db_query($sql); if (is_array($e)) { foreach ($e as $entry) { $link = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])); $jslink = "'<a href=\\'{$link}\\'>" . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . "<' + '/a>'"; echo '<li style="margin-bottom: 10px">' . '<a href="javascript:parent.self.opener.use_link_' . $what . '(' . $jslink . '); self.close();" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '"><strong>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '</strong></a> (<a href="' . $link . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '">#' . $entry['id'] . '</a>)<br />' . POSTED_BY . ' ' . $entry['author'] . ' ' . ON . ' ' . serendipity_formatTime(DATE_FORMAT_SHORT, $entry['timestamp']) . ($entry['isdraft'] != 'false' ? ' (' . DRAFT . ')' : '') . '</a></li>' . "\n"; } } ?> </ul> </div> </div> </body> </html> <?php return true; case 'backend_entry_toolbar_extended': if (!isset($txtarea)) { $txtarea = 'serendipity[extended]'; $func = 'extended'; } case 'backend_entry_toolbar_body': if (!isset($txtarea)) { if (isset($eventData['backend_entry_toolbar_body:textarea'])) { // event caller has given us the name of the textarea converted // into a wysiwg editor(for example, the staticpages plugin) $txtarea = $eventData['backend_entry_toolbar_body:textarea']; } else { // default value $txtarea = 'serendipity[body]'; } if (isset($eventData['backend_entry_toolbar_body:nugget'])) { $func = $eventData['backend_entry_toolbar_body:nugget']; } else { $func = 'body'; } } // CKEDITOR needs this little switch if (preg_match('@^nugget@i', $func)) { $cke_txtarea = $func; } else { $cke_txtarea = $txtarea; } if (!isset($popcl)) { $popcl = ' serendipityPrettyButton'; } if (!isset($style)) { $style = 'text-align: right; margin-top: 5px'; } ?> <script type="text/javascript"> <!-- function use_link_<?php echo $func; ?> (txt) { // use the shared insert function instead of the wikilinks provided function // the shared JS function implements all the wikilinks functionality + NO WYSIWYG insertion serendipity_imageSelector_addToBody(txt, '<?php echo $func; ?> ' ); return; if(typeof(CKEDITOR) != 'undefined') { var oEditor = CKEDITOR.instances['<?php echo $cke_txtarea; ?> ']; oEditor.insertHtml(txt); } else if(typeof(FCKeditorAPI) != 'undefined') { var oEditor = FCKeditorAPI.GetInstance('<?php echo $txtarea; ?> ') ; oEditor.InsertHtml(txt); } else if(typeof(xinha_editors) != 'undefined') { if(typeof(xinha_editors['<?php echo $txtarea; ?> ']) != 'undefined') { // this is good for the two default editors (body & extended) xinha_editors['<?php echo $txtarea; ?> '].insertHTML(txt); } else if(typeof(xinha_editors['<?php echo $func; ?> ']) != 'undefined') { // this should work in any other cases than previous one xinha_editors['<?php echo $func; ?> '].insertHTML(txt); } else { // this is the last chance to retrieve the instance of the editor ! // editor has not been registered by the name of it's textarea // so we must iterate over editors to find the good one for (var editorName in xinha_editors) { if('<?php echo $txtarea; ?> ' == xinha_editors[editorName]._textArea.name) { xinha_editors[editorName].insertHTML(txt); return; } } // not found ?!? } } else if(typeof(HTMLArea) != 'undefined') { if(typeof(editor<?php echo $func; ?> ) != 'undefined') editor<?php echo $func; ?> .insertHTML(txt); else if(typeof(htmlarea_editors) != 'undefined' && typeof(htmlarea_editors['<?php echo $func; ?> ']) != 'undefined') htmlarea_editors['<?php echo $func; ?> '].insertHTML(txt); } else if(typeof(TinyMCE) != 'undefined') { //tinyMCE.execCommand('mceInsertContent', false, txt); tinyMCE.execInstanceCommand('<?php echo $txtarea; ?> ', 'mceInsertContent', false, txt); } else { // default case: no wysiwyg editor txtarea = document.getElementById('<?php echo $txtarea; ?> '); if (txtarea.createTextRange && txtarea.caretPos) { caretPos = txtarea.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + ' ' + txt + ' ' : caretPos.text + ' ' + txt + ' '; } else { txtarea.value += ' ' + txt + ' '; } // alert(obj); txtarea.focus(); } } //--> </script> <?php echo '<input type="button" class="serendipityPrettyButton input_button" onclick="entrypopup = window.open(\'' . $serendipity['baseURL'] . $serendipity['indexFile'] . '?/plugin/popup_choose_entry' . $func . '\', \'js_entrypopup\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\')" value="' . PLUGIN_EVENT_WIKILINKS_LINKENTRY . '" />'; return true; default: return false; } } else { return false; } }