Skip to content

Commit

Permalink
refs #1431
Browse files Browse the repository at this point in the history
  * 관련 문서 정리
  • Loading branch information
inureyes committed Feb 11, 2010
1 parent bb6672e commit 1c0cde2
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 27 deletions.
3 changes: 2 additions & 1 deletion framework/model/Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static function getInstance() {
}

public function reset($param = null) {
parent::reset('Lines');
$this->id = null;
$this->blogid = getBlogId();
$this->category = 'public';
Expand All @@ -39,7 +40,7 @@ public function add() {
$this->setAttribute('root',$this->root,true);
$this->setAttribute('author',$this->author,true);
$this->setAttribute('content',$this->content,true);
$this->setAttribute('permalink',$this->content,true);
$this->setAttribute('permalink',$this->permalink,true);
$this->setAttribute('created',$this->created);
return $this->insert();
}
Expand Down
4 changes: 3 additions & 1 deletion interface/owner/entry/line/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@
$conditions['linesforpage'] = 15;

$d = _t('삭제');

$conditions['template'] = <<<EOS
<dl id="line_[##_id_##]" class="line">
<dt class="date">[##_date_##]</dt>
<dd class="content">[##_content_##]</dd>
<dd class="permalink"><a href="[##_permalink_##]" class="permalink">by [##_root_##]</a></dd>
<dd class="delete input-button" onclick="deleteLine('[##_id_##]');return false;"><span class="text">{$d}</span></dd>
</dl>
EOS;
$conditions['dress'] = array('id'=>'id','date'=>'created','content'=>'content');
$conditions['dress'] = array('id'=>'id','date'=>'created','content'=>'content','permalink'=>'permalink','root'=>'root');
$line = Model_Line::getInstance();
$view = $line->getFormattedList($conditions);
$m = _t('더 보기');
Expand Down
1 change: 1 addition & 0 deletions library/model/blog.cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function dumbCronScheduler($checkOnly=true)
$schedules = array(
'1m' => 60,
'5m' => 60*5,
'10m' => 60*10,
'30m' => 60*30,
'1h' => 60*60,
'2h' => 60*60*2,
Expand Down
1 change: 0 additions & 1 deletion library/model/common.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function activatePlugin($name) {
return false;
if (!file_exists(ROOT . "/plugins/$name/index.xml") || !file_exists(ROOT . "/plugins/$name/index.php"))
return false;

$xmls = new XMLStruct();
$manifest = @file_get_contents(ROOT . "/plugins/$name/index.xml");
if ($xmls->open($manifest)) {
Expand Down
95 changes: 73 additions & 22 deletions plugins/JP_TC_PluginForTwitter/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function getCovertDate($reqTime, $published) {
// Twitter Recipients List
function getTwitterRecipientsList($target) {
global $service, $pluginURL, $blogURL, $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);
$tw = new Twitter($data['username'], $data['password']);
$recipientsList = $tw->getRecipientsList(array('twttr'=>'true'));
Expand All @@ -114,7 +114,7 @@ function getTwitterRecipientsList($target) {
// Twitter Create Favorites
function getCreateFavorites($target) {
global $service, $pluginURL, $blogURL, $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);
$id = (isset($_POST['id']) && !empty($_POST['id'])) ? $_POST['id'] : '';
$tw = new Twitter($data['username'], $data['password']);
Expand All @@ -129,7 +129,7 @@ function getCreateFavorites($target) {
// Twitter Destroy Favorites
function getDestroyFavorites($target) {
global $service, $pluginURL, $blogURL, $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);
$id = (isset($_POST['id']) && !empty($_POST['id'])) ? $_POST['id'] : '';
$tw = new Twitter($data['username'], $data['password']);
Expand Down Expand Up @@ -163,7 +163,7 @@ function getSavedSearchesOpenClose($target) {
// Twitter Create Saved Searches
function getCreateSavedSearches($target) {
global $service, $pluginURL, $blogURL, $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);

$q = (isset($_POST['qdata']) && !empty($_POST['qdata'])) ? $_POST['qdata'] : '';
Expand Down Expand Up @@ -194,7 +194,7 @@ function getCreateSavedSearches($target) {
// Twitter Destroy Saved Searches
function getDestroySavedSearches($target) {
global $service, $pluginURL, $blogURL, $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);

$id = (isset($_POST['qdata']) && !empty($_POST['qdata'])) ? $_POST['qdata'] : '';
Expand Down Expand Up @@ -225,7 +225,7 @@ function getDestroySavedSearches($target) {
// Twitter management (Admin->center->Twitter management)
function PN_Twitter_Management() {
global $service, $pluginURL, $blogURL, $pluginMenuURL, $pluginName, $handler, $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);

$savedSearchesView = !is_null(Setting::getBlogSetting("saved_searches")) ? Setting::getBlogSetting("saved_searches") : "open";
Expand Down Expand Up @@ -445,7 +445,7 @@ function PN_Twitter_Management() {
<?php
}
?>
<ul id="timeline" class="statuses <?php echo ($menu == "direct" ? "directMessage" : "");?>">
<ul id="Times-Mirror" class="statuses <?php echo ($menu == "direct" ? "directMessage" : "");?>">
<?php
//friends Timeline
$user_photo = "";
Expand Down Expand Up @@ -701,7 +701,7 @@ function PN_Twitter_Management() {
// Twitter more paging
function getTwitterUpateMorePaging($target) {
global $service, $pluginURL, $blogURL, $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);

$page = (isset($_GET['page']) && !empty($_GET['page'])) ? $_GET['page'] : '1';
Expand Down Expand Up @@ -942,7 +942,7 @@ function getTwitterUpateMorePaging($target) {

function getTwitterPostUpdate($target) {
global $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);
$menu = (isset($_POST['menu']) && !empty($_POST['menu'])) ? $_POST['menu'] : "";
$update_body = (isset($_POST['body']) && !empty($_POST['body'])) ? $_POST['body'] : "";
Expand Down Expand Up @@ -1030,7 +1030,7 @@ function getTwitterPostUpdate($target) {

function getTwitterDestroyStatus($target) {
global $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);
$id = (isset($_POST['id']) && !empty($_POST['id'])) ? $_POST['id'] : "";

Expand Down Expand Up @@ -1058,7 +1058,7 @@ function getTwitterDestroyStatus($target) {

function getTwitterNewMessage($target) {
global $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);
$menu = (isset($_POST['menu']) && !empty($_POST['menu'])) ? $_POST['menu'] : "";
$text = (isset($_POST['text']) && !empty($_POST['text'])) ? $_POST['text'] : "";
Expand Down Expand Up @@ -1138,7 +1138,7 @@ function getTwitterNewMessage($target) {

function getTwitterDestroyMessage($target) {
global $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);
$id = (isset($_POST['id']) && !empty($_POST['id'])) ? $_POST['id'] : "";

Expand Down Expand Up @@ -1168,7 +1168,7 @@ function getTwitterDestroyMessage($target) {

function getTwitterCreateFriendship($target) {
global $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);
$menu = (isset($_POST['menu']) && !empty($_POST['menu'])) ? $_POST['menu'] : "";
$user_id = (isset($_POST['user_id']) && !empty($_POST['user_id'])) ? $_POST['user_id'] : "";
Expand Down Expand Up @@ -1201,7 +1201,7 @@ function getTwitterCreateFriendship($target) {

function getTwitterDestroyFriendship($target) {
global $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);
$menu = (isset($_POST['menu']) && !empty($_POST['menu'])) ? $_POST['menu'] : "";
$user_id = (isset($_POST['user_id']) && !empty($_POST['user_id'])) ? $_POST['user_id'] : "";
Expand Down Expand Up @@ -1237,7 +1237,7 @@ function getTwitterDestroyFriendship($target) {
// Twitter update (Admin->center->dashboard->Twitter update widget)
function CT_Twitter_updating($target){
global $service, $pluginURL, $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);

$twFlagCHK = "";
Expand Down Expand Up @@ -1283,7 +1283,7 @@ function getBitlyShortenURLCreate($target) {

function getUpdatingNewPostToTwitter($target, $mother) {
global $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);

$blogid = getBlogId();
Expand All @@ -1303,7 +1303,7 @@ function getUpdatingNewPostToTwitter($target, $mother) {

function getUpdatingNewLineToTwitter($target, $mother) {
global $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);

if (!empty($data['username']) && !empty($data['password'])) {
Expand All @@ -1316,7 +1316,7 @@ function getUpdatingNewLineToTwitter($target, $mother) {

function getUpdatingNewPostToTwitterSynd($target, $mother) {
global $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);

$blogid = getBlogId();
Expand All @@ -1336,7 +1336,7 @@ function getUpdatingNewPostToTwitterSynd($target, $mother) {

function getTwitterContent($blogid, $entryId, $updateText='title') {
global $blog, $service, $defaultURL, $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);

$content = array();
Expand All @@ -1361,7 +1361,7 @@ function getTwitterContent($blogid, $entryId, $updateText='title') {

function getTwitterBitlyShortenURL($longURL) {
global $configVal;
$data = Misc::fetchConfigVal($configVal);
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);

$result = array();
Expand Down Expand Up @@ -1404,16 +1404,67 @@ function getTwitterInitConfigVal(&$data) {
$data['twitterUpdate'] = isset($data['twitterUpdate']) && !empty($data['twitterUpdate']) ? $data['twitterUpdate'] : "none";
$data['updateText'] = isset($data['updateText']) && !empty($data['updateText']) ? $data['updateText'] : "title";
$data['listLength'] = isset($data['listLength']) && !empty($data['listLength']) ? $data['listLength'] : "10";
$data['synchronizeLine'] = isset($data['synchronizeLine']) && !empty($data['synchronizeLine']) ? $data['synchronizeLine'] : false;
}

function getTwitterDataSet($DATA) {
$cfg = Misc::fetchConfigVal($DATA);
$cfg = Setting::fetchConfigVal($DATA);
$tw = new Twitter($cfg['username'], $cfg['password']);
$res = $tw->getUserTimeline();
if (!empty($res->error)) {
return "::Authentication error::\n\n Username && Password requires authentication. \n (" . $res->error . ")";
}

return true;
}

/************************/
// Synchronizing twitter
function synchronizeTwitterWithLine() {
global $configVal;
$data = Setting::fetchConfigVal($configVal);
getTwitterInitConfigVal($data);
if(empty($data['synchronizeLine'])) return false;

$page = 1;
$tw = new Twitter($data['username'], $data['password']);
$limit = 0;

$option = array('page'=>$page, 'count'=>40);

$timeline = $tw->getUserTimeline($option);
$timelineResults = $timeline;

$line = Model_Line::getInstance();

foreach ($timelineResults as $status) {
$status_id = $status->id;
$user_id = $status->user->id;
$user_name = $status->user->name;
$user_screen_name = $status->user->screen_name;
$user_link = "https://twitter.com/{$user_screen_name}";
$text = $status->text;
$text_convert = getTextBodyConvert($text);
$source = getTextLinkConvert($status->source);
$published = getTwitterDateConvert($status->created_at);
$published_link = "https://twitter.com/{$user_screen_name}/status/{$status_id}";

$line->reset();
$line->setFilter(array('root','equals','Twitter',true));
$line->setFilter(array('content','equals',$text_convert,true));
$line->setFilter(array('created','>',Timestamp::getUNIXtime() - 3600));
$line->setLimit(1);
if(!$line->get('id')) {
$line->reset();
$line->created = strtotime($status->created_at);
$line->content = $text_convert;
$line->author = $user_name;
$line->permalink = $published_link;
$line->root = 'Twitter';
$line->category = 'public';
$line->add();
}
}
flush();
}
?>
?>
12 changes: 10 additions & 2 deletions plugins/JP_TC_PluginForTwitter/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
<listener event="AddLine">getUpdatingNewLineToTwitter</listener>
<listener event="AddPostByBlogAPI">getUpdatingNewPostToTwitter</listener>
<listener event="CreatePostSyndicate">getUpdatingNewPostToTwitterSynd</listener>
<listener event="ShowAdminHeader">getJQueryCheckLoad</listener>
<adminMenu>
<listener event="ShowAdminHeader" handler="getJQueryCheckLoad" />

<listener event="Cron10m" handler="synchronizeTwitterWithLine" />

<adminMenu>
<viewMethods>
<method>
<topMenu>center</topMenu>
Expand Down Expand Up @@ -96,6 +99,11 @@
<caption><![CDATA[* 기본 목록 10개 보여줌. <br/> * 단, 'following', 'followers' 목록 제외]]></caption>
</field>
</fieldset>
<fieldset legend="트위터-라인 동기화">
<field title=" " type="checkbox" name="synchronizeLine" checked="checked">
<op value="true" name="synchronizeLine"><![CDATA[&nbsp;트위터와 라인을 동기화합니다. 트위터에 적은 글이 자동으로 라인의 새 글로 등록됩니다.]]></op>
</field>
</fieldset>
</config>
</binding>
</plugin>

0 comments on commit 1c0cde2

Please sign in to comment.