Changeset 1934587
- Timestamp:
- 09/02/2018 02:03:27 PM (8 years ago)
- Location:
- tistorywriter/trunk
- Files:
-
- 7 added
- 9 edited
-
assets/pages/metabox_main.php (modified) (5 diffs)
-
assets/pages/panel_changelog.php (modified) (1 diff)
-
assets/scripts/common (added)
-
assets/scripts/common/tw_request.js (added)
-
assets/scripts/modules (added)
-
assets/scripts/modules/tw_metabox.js (added)
-
assets/scripts/modules/tw_setting.js (added)
-
assets/scripts/request_type.js (added)
-
assets/scripts/tw_jquery.js (modified) (3 diffs)
-
assets/scripts/tw_metabox_jquery.js (modified) (3 diffs)
-
def/requests.php (added)
-
features/api_manager.php (modified) (2 diffs)
-
features/handler_manager.php (modified) (2 diffs)
-
features/tistory_writer.php (modified) (6 diffs)
-
readme.txt (modified) (2 diffs)
-
tistorywriter.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tistorywriter/trunk/assets/pages/metabox_main.php
r1934352 r1934587 7 7 use const tistory_writer\FEATURE_KEY\OPTION; 8 8 use const tistory_writer\FEATURE_KEY\TISTORY_API; 9 use const tistory_writer\OPTION_KEY\ACCESS_TOKEN; 10 use const tistory_writer\OPTION_KEY\CLIENT_ID; 9 11 use const tistory_writer\OPTION_KEY\REDIRECT_URI; 10 12 use const tistory_writer\OPTION_KEY\SELECTED_BLOG; … … 13 15 14 16 $api_mgr = TistoryWriter::getManager(TISTORY_API); 15 $option_mgr = TistoryWriter::getManager(OPTION);16 17 echo "<div class=\"service-container\" data-redirecturi=\"" . $option_mgr->getOption(REDIRECT_URI) . "\"></div>";18 17 19 18 // 액세스 토큰 유효성 검사 … … 23 22 24 23 if (!$isAccessTokenAvailable) { 25 echo "<div id=\"div_require_token\" style='padding: 10px; vertical-align:center;'>";26 echo "<span style='padding: 5px; vertical-align: center; height: 50px;'>액세스 토큰이 설정되지 않았습니다. 계정 설정을 먼저 해주세요.</span></div>";27 }28 else {29 24 ?> 30 25 <div id="div_require_token" style="padding: 10px; vertical-align:center;"> 26 <span style="padding: 5px; vertical-align: center; height: 50px;"> 27 액세스 토큰이 설정되지 않았습니다. 계정 설정을 먼저 해주세요.</span> 28 <div style="padding: 5px; margin-top: 5px;"> 29 <input type="button" value="액세스 토큰 갱신" id="refresh_access_code" class="button" /> 30 </div> 31 </div> 32 33 <?php 34 } else { 35 ?> 31 36 <div id="tw_metabox"> 32 37 <style> … … 41 46 </style> 42 47 <div id="tw-table"> 43 44 48 <div class="tw-row"> 45 49 <div class="tw-cell tw-entryname"> 46 50 <span class="cell-content" style="margin-left: 3px;">연동 계정</span></div> 47 51 <div class="tw-cell"> 48 <span id=" span_access_code">52 <span id="blogAccount" class="blogAccount"> 49 53 <?php 50 54 if ($isAccessTokenAvailable) { … … 214 218 215 219 </div> 216 217 220 <?php 218 221 } -
tistorywriter/trunk/assets/pages/panel_changelog.php
r1934352 r1934587 5 5 <h4>업데이트 내역</h4> 6 6 <div class="mdl-cell mdl-cell--8-col mdl-card__supporting-text no-padding"> 7 <h6>1.0.5</h6> 8 <ul> 9 <li>글 작성 시 Access Code 만료된 경우 코드 갱신할 수 있도록 버튼 추가</li> 10 <li>Access Code 만료 시 포스팅 창 내 오류 메시지 출력 제거</li> 11 </ul> 12 7 13 <h6>1.0.4</h6> 8 14 <ul> -
tistorywriter/trunk/assets/scripts/tw_jquery.js
r1934309 r1934587 1 1 jQuery(document).ready(function($) { 2 3 2 document.getElementById('footer-thankyou').style.display = 'none'; 4 3 document.getElementById('footer-upgrade').style.display = 'none'; … … 58 57 if (opener != null) { 59 58 var access_code_span = opener.document.getElementById('span_access_code'); 60 access_code_span.innerText = access_token;61 59 62 var json_data = JSON.parse(data); 60 if (typeof(access_code_span) != "undefined" && access_code_span != null) { 61 access_code_span.innerText = access_token; 63 62 64 if (json_data != null) { 65 // 블로그 정보 갱신 66 for (var i in json_data) { 67 var blogurl_span = opener.document.getElementById('blog_url_' + json_data[i].name); 68 if (blogurl_span != null) { 69 blogurl_span.innerHTML = "<a href=\"" + json_data[i].url + "\">" + json_data[i].title + "(" + json_data[i].url + ")</a>"; 63 var json_data = JSON.parse(data); 64 65 if (json_data != null) { 66 // 블로그 정보 갱신 67 for (var i in json_data) { 68 var blogurl_span = opener.document.getElementById('blog_url_' + json_data[i].name); 69 if (blogurl_span != null) { 70 blogurl_span.innerHTML = "<a href=\"" + json_data[i].url + "\">" + json_data[i].title + "(" + json_data[i].url + ")</a>"; 71 } 70 72 } 71 73 } … … 79 81 80 82 jQuery(document).ready(function($) { 81 82 /*83 * 설정 저장 이벤트 처리84 */85 83 $(".tw-save-setting").click(function () { //event 86 84 -
tistorywriter/trunk/assets/scripts/tw_metabox_jquery.js
r1934352 r1934587 1 // global variables 2 var timer, subwin; 3 1 4 $(document).ready(function() { 2 5 3 var client_id; 4 var redirect_uri; 6 $("#refresh_access_code").click(function () { 5 7 6 $('.service-container').each(function() {7 var container = $(this);8 9 //client_id = container.data('clientid');10 redirect_uri = container.data('redirecturi');11 });12 13 $('.refresh_access_code').click(function() {14 8 $.post(tw_ajax.ajax_url, { 15 9 _ajax_nonce: tw_ajax.nonce, 16 action: "refreshAccessCode", 17 }, function (data) { 18 19 }); 10 action: "getUrlForAccessToken" 11 }, function(url) { 12 subwin = window.open(url); 13 timer = setInterval(checkChild, 500); 14 }) 20 15 }); 21 16 … … 53 48 }); 54 49 }); 50 51 function checkChild() { 52 if (subwin.closed) { 53 clearInterval(timer); 54 location.reload(); 55 } 56 } 55 57 56 58 function GetMetaboxData() { … … 120 122 } 121 123 else { 122 $("# acceptComment").prop('checked', false);124 $("#checkAllowComment").prop('checked', false); 123 125 } 124 126 } -
tistorywriter/trunk/features/api_manager.php
r1934352 r1934587 130 130 131 131 for ($i = 0; $i < TRY_NUM; $i++ ) { 132 $result = file_get_contents($requestUrl);133 if ( $result != false) {132 $result = @file_get_contents($requestUrl); 133 if (empty($result)) { 134 134 return $result; 135 135 } … … 152 152 153 153 for ($i = 0; $i < TRY_NUM; $i++ ) { 154 $result = file_get_contents( $url, false, $context );154 $result = @file_get_contents( $url, false, $context ); 155 155 if ($result != false) { 156 156 return $result; -
tistorywriter/trunk/features/handler_manager.php
r1846025 r1934587 1 1 <?php 2 2 namespace tistory_writer; 3 4 use const tistory_writer\REQUEST_KEY\REQUEST_SAVE_SETTINGS; 5 use const tistory_writer\REQUEST_KEY\HANDLER_SUFFIX; 3 6 4 7 /** … … 11 14 public function __construct() 12 15 { 13 $this->handlers = array ( 14 REDIRECT_EVENT\SETTINGINFO => array($this, 'handlerSettingInfo'), 15 REDIRECT_EVENT\SETTINGINFO_RESET => array($this, 'handlerSettingInfoReset'), 16 REDIRECT_EVENT\SETTING_ACCESSCODE => array($this, 'handlerAccessCode'), 16 // Initiailize request handlers 17 $this->handlers = array( 18 REQUEST_SAVE_SETTINGS => REQUEST_SAVE_SETTINGS . HANDLER_SUFFIX, 17 19 ); 18 20 } 19 21 20 public function handle ($redirectDef)22 public function handleRequest($requestName) 21 23 { 22 24 // Validate $redirectDef value 23 if (array_key_exists($re directDef, $this->handlers)) {24 $this->handlers[$re directDef]();25 if (array_key_exists($requestName, $this->handlers)) { 26 $this->handlers[$requestName](); 25 27 } 26 28 } 27 29 28 /** 29 * 사용자가 설정창에서 #2 설정단계를 SUbmit했을 경우에 호출되는 핸들러 30 */ 31 public function handlerSettingInfo() 32 { 33 $optionMgr = TistoryWriter::getManager(FEATURE_KEY\OPTION); 30 public static function REQUEST_SAVE_SETTINGS_HANDLER() 31 { 32 check_ajax_referer( 'tistory_writer' ); 34 33 35 $callback_uri_temp = get_admin_url() . 'options-general.php?page=tistory_writer';34 $optionMgr = self::getManager(FEATURE_KEY\OPTION); 36 35 37 /* 옵션 설정 */ 38 $optionMgr->setOption(OPTION_KEY\CLIENT_ID, wp_kses_post($_POST['client_id'])); 39 $optionMgr->setOption(OPTION_KEY\SECRET_KEY, wp_kses_post($_POST['secret_key'])); 40 $optionMgr->setOption(OPTION_KEY\BLOG_NAME, wp_kses_post($_POST['blogname'])); 41 $optionMgr->setOption(OPTION_KEY\CALLBACK_URL, wp_kses_post($callback_uri_temp)); 36 $optionMgr->setOption(CLIENT_ID, $_POST['client_id']); 37 $optionMgr->setOption(SECRET_KEY, $_POST['secret_key']); 38 $optionMgr->setOption(BLOG_NAME, $_POST['blog_name']); 42 39 43 wp_safe_redirect(get_admin_url() . "/options-general.php?page=tistory_writer");44 } 40 $apiMgr = self::getManager(TISTORY_API); 41 $blogInfo = $apiMgr->getBlogInformation(); 45 42 46 /** 47 * 사용자가 Access Token을 얻어왔을 때 처리 핸들러 48 */ 49 public function handlerAccessCode() 50 { 51 $optionMgr = TistoryWriter::getManager(FEATURE_KEY\OPTION); 52 $optionMgr->setOption(OPTION_KEY\ACCESS_TOKEN, wp_kses_post($_POST['access_code'])); 53 54 wp_safe_redirect(get_admin_url() . "/options-general.php?page=tistory_writer"); 55 } 56 57 public function handlerSettingInfoReset() 58 { 59 $optionMgr = TistoryWriter::getManager(FEATURE_KEY\OPTION); 60 $optionMgr->setOption(OPTION_KEY\ACCESS_TOKEN, ''); 61 62 wp_safe_redirect(get_admin_url() . "/options-general.php?page=tistory_writer"); 63 } 43 wp_die(json_encode($blogInfo)); 44 } 64 45 } -
tistorywriter/trunk/features/tistory_writer.php
r1934352 r1934587 3 3 namespace tistory_writer; 4 4 5 use const tistory_writer\FEATURE_KEY\HANDLER; 5 6 use const tistory_writer\FEATURE_KEY\OPTION; 6 7 use const tistory_writer\FEATURE_KEY\TISTORY_API; … … 19 20 * @author Sukbeom Kim <sukbeom.kim@gmail.com> 20 21 * @license GPL v2 21 * @version Release: 1.0. 422 * @version Release: 1.0.5 22 23 * @link https://github.com/seokbeomKim/TistoryWriter 23 24 */ … … 61 62 } 62 63 64 public static function handleRequest() { 65 $handlerMgr = self::getManager(HANDLER); 66 $handlerMgr->handleRequest($_POST['action']); 67 } 68 63 69 public static function checkAuthCode($code) 64 70 { … … 184 190 { 185 191 $apiMgr = self::getManager(FEATURE_KEY\TISTORY_API); 186 $postId = "";187 192 $title = $_POST['title']; 188 193 189 194 $categories = $apiMgr->getCategoryList(); 190 191 $postInfo = $apiMgr->getPostInfoWithTitle($title, $postId); 195 $postInfo = $apiMgr->getPostInfoWithTitle($title); 192 196 193 197 if (!is_null($postInfo)) { … … 293 297 294 298 wp_die(json_encode($blogInfo)); 299 } 300 301 public static function getUrlForAccessToken() 302 { 303 $optionMgr = self::getManager(FEATURE_KEY\OPTION); 304 305 $rvalue = "https://www.tistory.com/oauth/authorize?client_id=" . $optionMgr->getOption(CLIENT_ID) . 306 "&redirect_uri=" . $optionMgr->getOption(REDIRECT_URI) . "&response_type=token"; 307 308 wp_die($rvalue); 295 309 } 296 310 … … 348 362 $flag = isset($_POST['turnIntegratationOff']); 349 363 350 if (!$flag && isset($_POST['postId'])) { 364 $post_info = $apiMgr->getPostInfoWithTitle($post->post_title); 365 366 if (!$flag) { 351 367 if (strpos($post->name, 'autosave') != true) { 352 $ti = (int)wp_kses_post($ _POST['postId']);368 $ti = (int)wp_kses_post($post_info['id']); 353 369 if ($ti <= 0) { 354 370 self::postUpdate(); -
tistorywriter/trunk/readme.txt
r1934352 r1934587 5 5 Requires at least: 1.5 6 6 Tested up to: 4.9.5 7 Stable tag: 1.0. 47 Stable tag: 1.0.5 8 8 License: MIT License 9 9 License URI: https://mit-license.org/ … … 42 42 43 43 == Changelog == 44 = 1.0.5 = 45 * 글 작성 시 Access Code 만료된 경우 코드 갱신할 수 있도록 버튼 추가 46 * Access Code 만료 시 포스팅 창 내 오류 메시지 출력 제거 47 44 48 = 1.0.4 = 45 49 * 버그 수정 -
tistorywriter/trunk/tistorywriter.php
r1934352 r1934587 7 7 * Author URI: https://chaoxifer.tistory.com 8 8 * Contributors:None 9 * Version: 1.0. 49 * Version: 1.0.5 10 10 * Text Domain: TistoryWriter 11 11 … … 38 38 defined('ABSPATH') or die('No script kiddies please!'); 39 39 40 define(__NAMESPACE__ . '\VERSION', '1.0. 4');40 define(__NAMESPACE__ . '\VERSION', '1.0.5'); 41 41 define(__NAMESPACE__ . '\MAIN_URL', $_SERVER['HTTP_HOST'] . '/wp-admin/options-general.php?page=tistory_writer'); 42 42 define(__NAMESPACE__ . '\PLUGIN_DIR', plugin_dir_path(__FILE__)); … … 51 51 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'def' . DIRECTORY_SEPARATOR . 'fs_require.php'); 52 52 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'def' . DIRECTORY_SEPARATOR . 'errors.php'); 53 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'def' . DIRECTORY_SEPARATOR . 'requests.php'); 53 54 54 55 add_action('admin_menu', array('tistory_writer\TistoryWriter', 'addAdminOptionMenu')); … … 63 64 64 65 add_action( 'wp_ajax_saveSettings', array('tistory_writer\TistoryWriter', 'saveSettings') ); 66 //add_action( 'wp_ajax_saveSettings', array('tistory_writer\TistoryWriter', 'handleRequest') ); 65 67 add_action( 'wp_ajax_requestAccessCode', array('tistory_writer\TistoryWriter', 'requestAccessCode') ); 66 68 add_action( 'wp_ajax_requestAccessCodeWithAuth', array('tistory_writer\TistoryWriter', 'requestAccessCodeWithAuth') ); … … 68 70 add_action( 'wp_ajax_getMetaboxData', array('tistory_writer\TistoryWriter', 'getMetaboxData') ); 69 71 add_action( 'wp_ajax_requestBlogUrl', array('tistory_writer\TistoryWriter', 'requestBlogUrl') ); 72 add_action( 'wp_ajax_getUrlForAccessToken', array('tistory_writer\TistoryWriter', 'getUrlForAccessToken') ); 70 73 71 74 register_activation_hook(__FILE__, array('tistory_writer\TistoryWriter', 'activatePlugin'));
Note: See TracChangeset
for help on using the changeset viewer.