*** wp-mixipublisher.php.orig 2006-09-03 17:03:00.000000000 +0900
--- wp-mixipublisher.php 2008-04-17 03:59:02.000000000 +0900
***************
*** 32,37 ****
--- 32,38 ----
class WpMixiPublisherController extends WpBabelController_01a_wpmp {
var $_publishedId = array();
+ var $files = array();
/**
* WpMixiPublisherController のインスタンスを取得する。(シングルトン)
***************
*** 53,69 ****
$plugin_panel_name = 'Wp-MixiPublisher';
$access_level = 8;
- $this->initialize(
- $plugin_name,
- $plugin_panel_name,
- $access_level);
-
$commonVO = new WPBabelSettingVO_01a_wpmp();
$commonVO->setParam('name', $plugin_name);
$commonVO->setParam('version', get_bloginfo('version'));
$this->wpbview = & new WpMixiPublisherView($commonVO);
$this->wpbmodel = & new WpMixiPublisherModelFacard();
}
/**
--- 54,70 ----
$plugin_panel_name = 'Wp-MixiPublisher';
$access_level = 8;
$commonVO = new WPBabelSettingVO_01a_wpmp();
$commonVO->setParam('name', $plugin_name);
$commonVO->setParam('version', get_bloginfo('version'));
$this->wpbview = & new WpMixiPublisherView($commonVO);
$this->wpbmodel = & new WpMixiPublisherModelFacard();
+
+ $this->initialize(
+ $plugin_name,
+ $plugin_panel_name,
+ $access_level);
}
/**
***************
*** 100,106 ****
$this->updateWpSetting($settingVO);
}
}
!
function publishToMixi($postId) {
global $wpdb, $user_ID;
--- 101,140 ----
$this->updateWpSetting($settingVO);
}
}
!
! function replace_anchor_image($m) {
! list($all, $a_attrs, $img_attrs) = $m;
! if (preg_match('/\bhref\s*=\s*"([^"]*)"/', $a_attrs, $m1)
! && preg_match('/\bsrc\s*=\s*"([^"]*)"/', $img_attrs, $m2)
! ) {
! list(, $href) = $m1;
! list(, $src) = $m2;
! if (dirname($src) == dirname($href)
! && preg_match('/^(.*)\.(?:jpe?g|gif|png)$/i', basename($href), $m1)
! && preg_match('/^(.*)\.(?:jpe?g|gif|png)$/i', basename($src), $m2)
! ) {
! list(, $href_basename) = $m1;
! list(, $src_basename) = $m2;
! if (strpos($src_basename, $href_basename) !== FALSE) {
! $path = str_replace(get_option('siteurl').'/', ABSPATH, $href);
! if (file_exists($path)) {
! $this->files[] = $path;
! return '';
! }
! }
! }
! }
! return $all;
! }
!
! function replace_anchor($m) {
! list(, $attrs, $inner) = $m;
! $href = '';
! if (preg_match('/\bhref\s*=\s*(?:"([^"]*)"|(\S*))/si', $attrs, $m))
! $href = $m[1] == ''? $m[2]: $m[1];
! return $href == trim($inner)? $inner: (trim($inner) == ''? $href: "$inner($href)");
! }
!
function publishToMixi($postId) {
global $wpdb, $user_ID;
***************
*** 127,142 ****
$content = apply_filters('the_content', $content[0]);
}
! $quote_tags = preg_split('/[\s,]+/', $settingVO->getParam('quotes'), 0, PREG_SPLIT_NO_EMPTY);
$content = strip_tags($content, ''.($quote_tags ? '<'.join('><', $quote_tags).'>' : ''));
- $content = preg_replace_callback('/]*>((?:(?!<\/a>).)+)<\/a>/', create_function(
- '$matches',
- '$matches[1] = strpos($matches[1], "/") === 0 ? get_settings("siteurl").$matches[1] : $matches[1];'.
- 'return $matches[1] == trim($matches[2]) ? $matches[2] : $matches[2]."(".$matches[1].")";'
- ), $content);
-
foreach($quote_tags as $tag) {
$content = preg_replace_callback('/<'.$tag.'[^<>]*>\s*((?:(?!<\/'.$tag.'>).)+)<\/'.$tag.'>/s', create_function(
'$matches',
--- 161,173 ----
$content = apply_filters('the_content', $content[0]);
}
! $this->files = array();
! $content = preg_replace_callback('#]*)>\s*
]*)>\s*#si', array($this, 'replace_anchor_image'), $content);
! $content = preg_replace_callback('#]*)>((?:[^<]|<(?!/?a>))+)#si', array($this, 'replace_anchor'), $content);
+ $quote_tags = preg_split('/[\s,]+/', $settingVO->getParam('quotes'), 0, PREG_SPLIT_NO_EMPTY);
$content = strip_tags($content, ''.($quote_tags ? '<'.join('><', $quote_tags).'>' : ''));
foreach($quote_tags as $tag) {
$content = preg_replace_callback('/<'.$tag.'[^<>]*>\s*((?:(?!<\/'.$tag.'>).)+)<\/'.$tag.'>/s', create_function(
'$matches',
***************
*** 152,158 ****
if($post->mixi_diary_id && $mixi->existsDiary($post->mixi_diary_id)) {
$mixi->modifyDiary($post->mixi_diary_id, $title, $content);
}else{
! $mixi_diary_id = $mixi->addDiary($title, $content);
if($mixi_diary_id) {
$wpdb->query("UPDATE $wpdb->posts SET mixi_diary_id = $mixi_diary_id WHERE ID = $postId");
}
--- 183,189 ----
if($post->mixi_diary_id && $mixi->existsDiary($post->mixi_diary_id)) {
$mixi->modifyDiary($post->mixi_diary_id, $title, $content);
}else{
! $mixi_diary_id = $mixi->addDiary($title, $content, $this->files);
if($mixi_diary_id) {
$wpdb->query("UPDATE $wpdb->posts SET mixi_diary_id = $mixi_diary_id WHERE ID = $postId");
}
***************
*** 206,238 ****
function executePublishToMixi($postId, $isModify=false) {
if(in_array($postId, $this->_publishedId)) {
! return $postId;
}
$settingVO = $this->getWpSetting();
if(!$settingVO->getParam('user_id')) {
! return $postId;
}
$post = get_post($postId);
// 公開しない場合は終了
if($post->post_status != 'publish') {
! return $postId;
}
// 1.0.0 RC2: XML-RPCリクエストの場合ディフォルト設定を優先する
if(defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) {
// ディフォルト設定が有効でなければ終了
if($settingVO->getParam('default') != 1) {
! return $postId;
}
// すでにある投稿で、Mixiに投稿していなければ終了
if(!$postObj->mixi_diary_id && $isModify) {
! return $postId;
}
}else{
if($_POST['publish_mixi'] != 1) {
! return $postId;
}
}
--- 237,269 ----
function executePublishToMixi($postId, $isModify=false) {
if(in_array($postId, $this->_publishedId)) {
! return false;
}
$settingVO = $this->getWpSetting();
if(!$settingVO->getParam('user_id')) {
! return false;
}
$post = get_post($postId);
// 公開しない場合は終了
if($post->post_status != 'publish') {
! return false;
}
// 1.0.0 RC2: XML-RPCリクエストの場合ディフォルト設定を優先する
if(defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) {
// ディフォルト設定が有効でなければ終了
if($settingVO->getParam('default') != 1) {
! return false;
}
// すでにある投稿で、Mixiに投稿していなければ終了
if(!$postObj->mixi_diary_id && $isModify) {
! return false;
}
}else{
if($_POST['publish_mixi'] != 1) {
! return false;
}
}
***************
*** 262,272 ****
}
function saveHandler($postId) {
! return $this->executePublishToMixi($postId, true);
}
function publishHandler($postId) {
! return $this->executePublishToMixi($postId);
}
}
--- 293,305 ----
}
function saveHandler($postId) {
! if ($postId == $this->executePublishToMixi($postId, true))
! $this->publishToMixi($postId);
}
function publishHandler($postId) {
! if ($postId == $this->executePublishToMixi($postId))
! $this->publishToMixi($postId);
}
}
***************
*** 427,444 ****
return $this->loggedin;
}
! function submit($action, $param) {
$action = (strpos($action, 'http://') !== false) ? $action : $this->base_url . $action;
! $this->snoopy->submit($action, $param);
return $this->snoopy->results;
}
! function addDiary($diary_title, $diary_body) {
if(!$this->loggedin) {
return false;
}
$latestDiaryId = $this->getLatestDiaryId();
! $param = $this->previewDiary($diary_title, $diary_body);
$param['submit'] = 'confirm';
$result = $this->submit('add_diary.pl', $param);
$diaryId = $this->getLatestDiaryId();
--- 460,477 ----
return $this->loggedin;
}
! function submit($action, $param, $file = '') {
$action = (strpos($action, 'http://') !== false) ? $action : $this->base_url . $action;
! $this->snoopy->submit($action, $param, $file);
return $this->snoopy->results;
}
! function addDiary($diary_title, $diary_body, $diary_files) {
if(!$this->loggedin) {
return false;
}
$latestDiaryId = $this->getLatestDiaryId();
! $param = $this->previewDiary($diary_title, $diary_body, $diary_files);
$param['submit'] = 'confirm';
$result = $this->submit('add_diary.pl', $param);
$diaryId = $this->getLatestDiaryId();
***************
*** 448,454 ****
return false;
}
! function previewDiary($diary_title, $diary_body) {
if(!$this->loggedin) {
return false;
}
--- 481,487 ----
return false;
}
! function previewDiary($diary_title, $diary_body, $diary_files) {
if(!$this->loggedin) {
return false;
}
***************
*** 458,467 ****
$post['diary_title'] = $diary_title;
$post['diary_body'] = $diary_body;
$post['submit'] = 'main';
$this->snoopy->set_submit_multipart();
! $result = $this->submit('add_diary.pl', $post);
! preg_match_all('/\s]*?)["\']? name=["\']?([^<>\s]*?)["\']? value=["\']?(.*?)["\']?>/is', $result, $match, PREG_SET_ORDER);
$part = array();
foreach($match as $part) {
if (!in_array($part[2], $this->mixi_diary_formval)) {
--- 491,507 ----
$post['diary_title'] = $diary_title;
$post['diary_body'] = $diary_body;
$post['submit'] = 'main';
+
+ $files = array();
+ for ($i = 1; $i <= 3 && $diary_files; $i++)
+ $files[sprintf('photo%d', $i)] = array_shift($diary_files);
+ $post['orig_size'] = '';
+ set_time_limit(0);
+
$this->snoopy->set_submit_multipart();
! $result = $this->submit('add_diary.pl', $post, $files);
! preg_match_all('/\s]*?)["\']? name=["\']?([^<>\s]*?)["\']? value=["\']?(.*?)["\']? \/>/is', $result, $match, PREG_SET_ORDER);
$part = array();
foreach($match as $part) {
if (!in_array($part[2], $this->mixi_diary_formval)) {
***************
*** 519,525 ****
$post['form_date'] = 'date';
$this->snoopy->set_submit_multipart();
! return $this->submit('edit_diary.pl?id=' . $id, $post, $file);
}
function isEnabledMixiDiary() {
--- 559,565 ----
$post['form_date'] = 'date';
$this->snoopy->set_submit_multipart();
! return $this->submit('edit_diary.pl?id=' . $id, $post);
}
function isEnabledMixiDiary() {
***************
*** 527,533 ****
return false;
}
$content = $this->fetch('edit_account.pl');
! if(strpos($content, '