@define('PLUGIN_EVENT_SPARTACUS_FETCH', 'Hier klicken um ein neues %s aus dem Netz zu installieren.');
@define('PLUGIN_EVENT_SPARTACUS_FETCHERROR', 'Die URL %s konnte nicht geöffnet werden. Möglicherweise existieren Server- oder Netzwerkprobleme.');
@define('PLUGIN_EVENT_SPARTACUS_FETCHING', 'Versuche URL %s zu öffnen...');
+ @define('PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_URL', '%s bytes von obiger URL geladen. Speichere Inhalt als %s...');
+ @define('PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE', '%s bytes von bereits bestehender Datei geladen. Speichere Inhalt als %s...');
+ @define('PLUGIN_EVENT_SPARTACUS_FETCHED_DONE', 'Data successfully fetched.');
break;
+
case 'en':
default:
@define('PLUGIN_EVENT_SPARTACUS_NAME', 'Spartacus');
@define('PLUGIN_EVENT_SPARTACUS_FETCH', 'Click here to fetch a new %s from the Serendipity Online Repository');
@define('PLUGIN_EVENT_SPARTACUS_FETCHERROR', 'The URL %s could not be opened. Maybe the Serendipity or SourceForge.net Server is down - we are sorry, you need to try again later.');
@define('PLUGIN_EVENT_SPARTACUS_FETCHING', 'Trying to open URL %s...');
+ @define('PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_URL', 'Fetched %s bytes from the URL above. Saving file as %s...');
+ @define('PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE', 'Fetched %s bytes from already existing file on your server. Saving file as %s...');
+ @define('PLUGIN_EVENT_SPARTACUS_FETCHED_DONE', 'Data successfully fetched.');
break;
}
$propbag->add('description', PLUGIN_EVENT_SPARTACUS_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
- $propbag->add('version', '1.01');
+ $propbag->add('version', '1.1');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
}
function &fetchfile($url, $target, $cacheTimeout = 0) {
- printf(PLUGIN_EVENT_SPARTACUS_FETCHING, '<a href="' . $url . '">' . serendipity_truncateString($url, 68) . '</a>');
+ printf(PLUGIN_EVENT_SPARTACUS_FETCHING, '<a href="' . $url . '">' . basename($url) . '</a>');
echo '<br />';
if (file_exists($target) && filesize($target) > 0 && filemtime($target) >= (time()-$cacheTimeout)) {
$data = file_get_contents($target);
+ printf(PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE, strlen($data), $target);
+ echo '<br />';
} else {
require_once S9Y_INCLUDE_PATH . 'bundled-libs/HTTP/Request.php';
$req = &new HTTP_Request($url);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
printf(PLUGIN_EVENT_SPARTACUS_FETCHERROR, $url);
+ echo '<br />';
if (file_exists($target) && filesize($target) > 0) {
$data = file_get_contents($target);
+ printf(PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE, strlen($data), $target);
+ echo '<br />';
}
} else {
// Fetch file
$data = $req->getResponseBody();
+ printf(PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_URL, strlen($data), $target);
+ echo '<br />';
$tdir = dirname($target);
if (!is_dir($tdir) && !$this->rmkdir($tdir)) {
printf(FILE_WRITE_ERROR, $tdir);
if (!$fp) {
printf(FILE_WRITE_ERROR, $target);
+ echo '<br />';
return false;
}
fwrite($fp, $data);
fclose($fp);
+ echo PLUGIN_EVENT_SPARTACUS_FETCHED_DONE;
+ echo '<br />';
}
}
$pdir = $serendipity['serendipityPath'] . '/plugins/';
if (!is_writable($pdir)) {
printf(DIRECTORY_WRITE_ERROR, $pdir);
+ echo '<br />';
return false;
}
'metaWeblog.newMediaObject' =>
array('function' => 'metaWeblog_newMediaObject'),
'metaWeblog.getRecentPosts' =>
- array('function' => 'mt_getRecentPostTitles'),
+ array('function' => 'metaWeblog_getRecentPosts'),
'mt.getRecentPostTitles' =>
array('function' => 'mt_getRecentPostTitles'),
'mt.getCategoryList' =>
array(
'postid' => new XML_RPC_Value($entry['id'], 'string'),
'title' => new XML_RPC_Value($entry['title'], 'string'),
+ 'content' => new XML_RPC_Value($entry['body'], 'string'),
'userid' => new XML_RPC_Value($entry['authorid'], 'string'),
- 'dateCreated' => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp']), 'dateTime.iso8601'),
- 'postid' => new XML_RPC_Value($entry['id'], 'string')), 'struct');
+ 'dateCreated' => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp']), 'dateTime.iso8601')
+ ), 'struct');
}
$xml_entries = new XML_RPC_Value($xml_entries_vals, 'array');
return new XML_RPC_Response($xml_entries);
return new XML_RPC_Response($xml_entries);
}
+function metaWeblog_getRecentPosts($message) {
+ $val = $message->params[1];
+ $username = $val->getval();
+ $val = $message->params[2];
+ $password = $val->getval();
+ $val = $message->params[3];
+ $numposts = $val->getval();
+ if (!serendipity_authenticate_author($username, $password)) {
+ return new XML_RPC_Response('', 4, 'Authentication Failed');
+ }
+ $entries = serendipity_fetchEntries('', false, $numposts);
+ $xml_entries_vals = array();
+
+ foreach ($entries as $tentry) {
+ $entry = serendipity_fetchEntry('id', $tentry['id']);
+ $xml_entries_vals[] = new XML_RPC_Value(
+ array(
+ 'dateCreated' => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp']), 'dateTime.iso8601'),
+ 'postid' => new XML_RPC_Value($entry['id'], 'string'),
+ 'userid' => new XML_RPC_Value($entry['authorid'], 'string'),
+ 'description' => new XML_RPC_Value($entry['body'], 'string'),
+ 'mt_excerpt' => new XML_RPC_Value('', 'string'),
+ 'mt_allow_comments' => new XML_RPC_Value(1, 'int'),
+ 'mt_text_more' => new XML_RPC_Value($entry['extended'], 'string' ),
+ 'mt_allow_pings' => new XML_RPC_Value(1, 'int'),
+ 'mt_convert_breaks' => new XML_RPC_Value('', 'string'),
+ 'mt_keywords' => new XML_RPC_Value('', 'string'),
+ 'title' => new XML_RPC_Value($entry['title'],'string'),
+ 'permalink' => new XML_RPC_Value(serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])), 'string'),
+ 'link' => new XML_RPC_Value(serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])), 'string')
+ ),
+ 'struct');
+
+ }
+ $xml_entries = new XML_RPC_Value($xml_entries_vals, 'array');
+ return new XML_RPC_Response($xml_entries);
+
+}
function mt_getRecentPostTitles($message) {
$val = $message->params[1];
$username = $val->getval();
'postid' => new XML_RPC_Value($entry['id'], 'string'),
'title' => new XML_RPC_Value($entry['title'], 'string'),
'userid' => new XML_RPC_Value($entry['authorid'], 'string'),
- 'dateCreated' => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp']), 'dateTime.iso8601'),
- 'postid' => new XML_RPC_Value($entry['id'], 'string')
+ 'dateCreated' => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp']), 'dateTime.iso8601')
),
'struct');
}
}
$val = $message->params[4];
$entry['body'] = $val->getval();
+ $val = $message->params[5];
+ $topublish = $val->getval();
+ if ($topublish == 1){
+ $entry['isdraft'] = 'false';
+ } else { $entry['isdraft'] = 'true'; }
+
$entry['allow_comments'] = $serendipity['allowCommentsDefault'];
$entry['moderate_comments'] = $serendipity['moderateCommentsDefault'];
$id = serendipity_updertEntry($entry);
if (!serendipity_authenticate_author($username, $password)) {
return new XML_RPC_Response('', 4, 'Authentication Failed');
}
- $val = $message->params[4];
- $entry['body'] = $val->getval();
- $entry['author'] = $username;
+
$id = serendipity_deleteEntry($entry['id']);
return new XML_RPC_Response(new XML_RPC_Value(1, 'boolean'));
}
$val = $message->params[4];
$publish = $val->getval();
+
$entry['categories'] = universal_fetchCategories($post_array['categories']);
$entry['title'] = $post_array['title'];
$entry['body'] = $post_array['description'];
$entry['extended'] = $post_array['mt_text_more'];
$entry['isdraft'] = ($publish == 0) ? 'true' : 'false';
- $entry['allow_comments'] = $serendipity['allowCommentsDefault'];
+ if (isset($post_array['mt_allow_comments'])) {
+ $entry['allow_comments'] = $post_array['mt_allow_comments'];
+ } else {
+ $entry['allow_comments'] = $serendipity['allowCommentsDefault'];
+ }
+
$entry['moderate_comments'] = $serendipity['moderateCommentsDefault'];
+ $entry['keywords'] = $post_array['mt_keywords'];
$id = serendipity_updertEntry($entry);
$val = $message->params[4];
$publish = $val->getval();
- $entry['categories'] = universal_fetchCategories($post_array['categories']);
+ if (isset($post_array['categories'])) {
+ $entry['categories'] = universal_fetchCategories($post_array['categories']);
+ }
$entry['title'] = $post_array['title'];
$entry['body'] = $post_array['description'];
$entry['extended'] = $post_array['mt_text_more'];
return new XML_RPC_Response(new XML_RPC_Value($id ? true : false, 'boolean'));
}
+
function metaWeblog_getPost($message) {
global $serendipity;
$val = $message->params[0];
}
$entry = serendipity_fetchEntry('id', $postid);
- $entry = new XML_RPC_Value(metaWeblog_setEntry($entry), 'struct');
- return new XML_RPC_Response($entry);
+ $tmp = new XML_RPC_Value(array(
+ 'userid' => new XML_RPC_Value($entry['authorid'], 'string'),
+ 'dateCreated' => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp']), 'dateTime.iso8601'),
+ 'postid' => new XML_RPC_Value($postid, 'string'),
+ 'description' => new XML_RPC_Value($entry['body'], 'string'),
+ 'title' => new XML_RPC_Value($entry['title'],'string'),
+ 'link' => new XML_RPC_Value(serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp'])), 'string'),
+ 'permalink' => new XML_RPC_Value(serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp'])), 'string'),
+ 'mt_excerpt' => new XML_RPC_Value($entry['excerpt'], 'string'),
+ 'mt_text_more' => new XML_RPC_Value($entry['extended'], 'string'),
+ 'mt_allow_comments' => new XML_RPC_Value($entry['allow_comments'], 'int'),
+ 'mt_allow_pings' => new XML_RPC_Value($entry['mt_allow_pings'], 'int'),
+ 'mt_convert_breaks' => new XML_RPC_Value($entry['mt_convert_breaks'], 'string'),
+ 'mt_keywords' => new XML_RPC_Value($entry['mt_keywords'], 'string')), 'struct');
+
+ return new XML_RPC_Response($tmp);
}
function metaWeblog_deletePost($message) {
}
$category_ids = universal_fetchCategories($categories->getval(), true);
- serendipity_updateEntryCategories($postid, $category_ids);
+ $entry = serendipity_fetchEntry ( 'id', $postid );
+ $entry['categories'] = $category_ids;
+ $entry = serendipity_updertEntry ( $entry );
+ //serendipity_updateEntryCategories($postid, $category_ids);
return new XML_RPC_Response(new XML_RPC_Value(1, 'boolean'));
}
}
$fp = fopen($full, 'w');
- fwrite($fp, base64_decode($struct['bits']));
+ fwrite($fp, $struct['bits']);
fclose($fp);
$path = $serendipity['baseURL'] . $serendipity['uploadPath'] . $struct['name'];
return new XML_RPC_Response(new XML_RPC_Value(array('url' => new XML_RPC_Value($path, 'string')), 'struct'));