*
h4. mem_if_reblog_post
p. This is a conditional tag that displays the text enclosed by the tag only if the specified entry is a ReBlog entry.
p. Attributes:
* *id* -- (optional) If specified, this is the id of the entry. If not specified, it will use the id of the current article (for use in article templates).
p. Examples:
* This is a reblog post
* This is a reblog post with in an article
# --- END PLUGIN HELP ---
'Draft',
2 => 'Hidden',
3 => 'Pending',
4 => 'Published'
);
function mem_article_status($item, $var) {
global $mem_status_list;
return selectInput($item, $mem_status_list, $var);
}
function mem_reblog_install() {
global $mem_reblog;
if (!safe_field('val','txp_prefs',"name='mem_reblog_author'")) {
set_pref('mem_reblog_author','ReBlog','mem_reblog',1);
}
if (!safe_field('val','txp_prefs',"name='mem_reblog_post_status'")) {
set_pref('mem_reblog_post_status','
safe_insert('txp_prefs',"prefs_id=1,name='mem_reblog_post_status',val='4',type='1',event='mem_reblog',html='mem_article_status'");
}
if (!safe_field('val','txp_prefs',"name='mem_reblog_post_section'")) {
safe_insert('txp_prefs',"prefs_id=1,name='mem_reblog_post_section',val='article',type='1',event='self_reg',html='priv_levels'");
$mem_self['new_user_priv'] = '0';
}
}
function mem_reblog_init() {
global $mem_reblog;
$mem_reblog['post_status'] = safe_field('val','txp_prefs'
}
// what will be the status of the imported entries?
// 1 == draft
// 2 == hidden
// 3 == pending
// 4 == published
define('REBLOG_POST_STATUS', 4);
// what will be the section for the imported entries?
// make sure this section exists, otherwise it will cause display problems
define('REBLOG_POST_SECTION', 'article');
// what categories will be assigned to the imported entries?
// these should exist (but it is not as critical)
define('REBLOG_POST_CATEGORY1', 'ReBlog');
define('REBLOG_POST_CATEGORY2', '');
// Complete URL to RSS 2.0 output from reBlog, typically ends with "rss.php?v=2".
define('REBLOG_URL', 'http://some.domain.com/refeed/out/rss.php?v=2');
// set value to 1 to enable debugging. e
// extra information will be displayed when fetching entries.
define('REBLOG_DEBUG', 1);
// this specifies the directory where magpie is located.
// default is './textpattern/lib/magpierss/'
define('MAGPIE_DIR', dirname( __FILE__ ). '/magpierss/');
// set value to 1
// magpie will cache the fetched rss data for a period of time
// set value to 0
// magpie will not cache the fetched rss data
define('MAGPIE_CACHE_ON', 1);
// How long to store cached RSS objects? In seconds.
define('MAGPIE_CACHE_AGE', 60*60);
// where can magpie use for cache files. this must be writeable.
// default is './textpattern/cache/'
define('MAGPIE_CACHE_DIR', dirname( __FILE__ ).'/../cache/' );
// what name should be used for the table that keeps track of what entries have
// already been imported?
$GLOBALS['tablereblog'] = "txp_reblog";
// what is the table name that holds the textpattern entries?
$GLOBALS['tableposts'] = "textpattern";
//////////////////////////////////////////////////////////////////////////////////////////
// DO NOT MODIFY BELOW THIS LINE
//////////////////////////////////////////////////////////////////////////////////////////
/** mem_reblog_guid
* This is a client side tag. Originally %s from %s
', $item['rb']['via_url'], (isset($item['rb']['source_author']) ? "posted by " . $item['rb']['source_author'] : ""), $item['rb']['source_url'], $item['rb']['source'] ); // determine whether the item's GUID has been encountered before $post = getRow(sprintf("SELECT p.id AS id FROM `{$GLOBALS['tablereblog']}` AS r LEFT JOIN `{$GLOBALS['tableposts']}` AS p ON r.reblog_post_id = p.id WHERE r.reblog_guid = '%s'", mysql_real_escape_string($item['rb']['guid']))); // update existing post if the GUID was found, otherwise insert a new one. if($post !== false) { extract($post); $q = sprintf("UPDATE `{$GLOBALS['tableposts']}` SET Body = '%s', Body_html = '%s', Title = '%s', Excerpt = '%s', LastMod = '%s' WHERE ID = '%s'", mysql_real_escape_string((($content))), mysql_real_escape_string((($content))), mysql_real_escape_string($item['title']), mysql_real_escape_string((($item['summary']))), date('Y-m-d H:i:s'), mysql_real_escape_string($id) ); print("{$q}\n"); $updated++; } else { $q = sprintf("INSERT INTO `{$GLOBALS['tableposts']}` (AuthorID, Posted, LastMod, LastModID, Body, Body_html, Title, Excerpt, Status, Section, Category1, Category2) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", REBLOG_AUTHOR_ID, date('Y-m-d H:i:s', parse_w3cdtf($item['dc']['date'])), date('Y-m-d H:i:s', parse_w3cdtf($item['dc']['date'])), REBLOG_AUTHOR_ID, mysql_real_escape_string((($content))), mysql_real_escape_string((($content))), mysql_real_escape_string($item['title']), mysql_real_escape_string((($item['summary']))), REBLOG_POST_STATUS, REBLOG_POST_SECTION, REBLOG_POST_CATEGORY1, REBLOG_POST_CATEGORY2 ); safe_query($q); print("{$q}\n"); $post = getRow("SELECT LAST_INSERT_ID() AS id FROM `{$GLOBALS['tableposts']}`"); if ($post !== false) { extract($post); $added++; // make sure that we're not about to conflict with an existing GUID in the reblog table $q = sprintf("DELETE FROM `{$GLOBALS['tablereblog']}` WHERE reblog_guid = '%s'", mysql_real_escape_string($item['rb']['guid'])); safe_query($q); print("{$q}\n"); $q = sprintf("INSERT INTO `{$GLOBALS['tablereblog']}` (reblog_post_id, reblog_guid) VALUES ('%s', '%s')", mysql_real_escape_string($id), mysql_real_escape_string($item['rb']['guid'])); safe_query($q); print("{$q}\n"); // pick a category, any category $q = sprintf("INSERT INTO `{$GLOBALS['tablepost2cat']}` (post_id, category_id) VALUES ('%s', '1')", mysql_real_escape_string($id)); safe_query($q); print("{$q}\n"); } } unset($item['description']); unset($item['summary']); print_r($item); } } $effluvia = ob_get_contents(); ob_end_clean(); } return array($added, $updated, $effluvia); } /** mem_reblog * This is called from the Admin Side Plugin when the "reblog" event is encountered. * This is what makes the plugin work. * * @param string event This is the event name passed from the callback function. * It should always be 'reblog'. * * @param string step This is the current step passed from the callback function. */ function mem_reblog($event,$step) { // standard security check check_privs(1,2,3); $message = ''; ob_start(); { echo ''; } $content = ob_get_contents(); ob_end_clean(); // output the top of the admin section (tabs and such) pagetop("ReBlog", $message); echo '