This editor is using an <iframe> element-based editing area, provided by the Wysiwygarea plugin.
<iframe>
CKEDITOR.replace( 'textarea_id' )
ユーザ情報入力画面
ユーザー情報入力画面は、Googleカレンダーとtoodledoのユーザー情報入力と同期実行ボタンを持つ画面。
ユーザ情報入力画面のイベント機能を説明する。
「同期」ボタンクリックイベント
「popupwindow」アンカークリックイベント
以下の操作はユーザプログラムからの操作方法が不明であるため機能仕様に含めないことにする。
当該サービスから初めて同期オペレーションを行ったさい、Googleカレンダーに対し以下のカレンダー名のカレンダー追加をGoogleログインアカウントに実行する。
toodledoカレンダーは、toodledoイベントとの同期カレンダーとして利用される。 完了toodledoは、toodledoの完了イベントを登録する。
当該サービスはイベントの削除を行わない。 イベントを削除したい場合、ユーザーはGoogledoカレンダーとtoodledoそれぞれのサービスアプリケーションでイベントを削除すること。
Googleカレンダーないしtoodledoの片方のみからイベントを削除した場合、当該サービスの同期オペレーションによって新規イベントに同期してしまうので注意すること。
Googleカレンダーイベントの変更と、toodledoイベントの変更に競合が発生した場合、いずれか過去の変更を破棄する。
当該サービスアプリケーションが保存する情報を記載する。(全てtoodledoアカウント毎に保存する)
マッピング情報の削除は、toodledoイベント側で完了となったイベントを対象とする。
Googleカレンダーないしtoodledoがエラーを返却した場合の挙動を纏める。
最終同期日時を更新しないことで、次回の同期ですでに同期済みのイベントも同期の対象となるが、同期済みを同期しても特にデータが変わることはないので問題ない。
機能仕様が曖昧なので、以下の通りの検証を行うこととする。
toodledoイベントの追加編集にて開始日(startdate)にUNIXタイムスタンプを指定しても、時刻部分は破棄されてしまう。
2013年11月23日4時9分14秒から15秒の間に更新されたイベントを抽出する。
2011年8月28日5時43分22秒以降(指定時含まず)に更新されたイベントを取得する。
http://www.toodledo.com/info/api_doc_tasks.php
http://api.toodledo.com/api.php?method=addTask;key=YourKey; title=new years;priority=1;repeat=0;length=30;duedate=2010-01-01
$this->_googleCalendar->setTargetEvent($eventId); $this->_googleCalendar->updateEvent( 'タイトル替えちゃったyo', 'メモも買えちゃったyo', '2013-12-28 13:00', '2013-12-28 14:00' );
/** * イベントを変更する * @param unknown $title * @param unknown $memo * @param unknown $startDateTime * @param string $endDateTime */ public function updateEvent( $title, $memo, $startDateTime, $endDateTime = '' ){ $this->_targetEvent->title = $this->_service->newTitle($title); $this->_targetEvent->content = $this->_service->newContent($memo); $when = $this->_createWhen($startDateTime,$endDateTime); $this->_targetEvent->when = array($when); try { $this->_targetEvent->save(); } catch (Zend_Gdata_App_Exception $e) { $this->exceptionErrorMessage = $e->getMessage(); return FALSE; } return TRUE; }
/** * 開始日時($startDateTime)、終了日時($endDateTime) * を、日付と時刻に分離。さらに時刻が無ければ終日フラグを設定 * @param unknown $startDate * @param unknown $startTime * @param unknown $endDate * @param unknown $endTime * @param unknown $allDayFlg * @param unknown $startDateTime * @param string $endDateTime * @return boolean */ protected function _createStartDateTimeEndDateTime( &$startDate, &$startTime, &$endDate, &$endTime, &$allDayFlg, $startDateTime, $endDateTime='' ){ if (!self::validDateTime($startDateTime)) { return FALSE; } if ($endDateTime != '') { if (!self::validDateTime($endDateTime)) { return FALSE; } } $allDayFlg = FALSE; /*** 開始と終了が同じ日時の場合は登録しない */ if ($startDateTime == $endDateTime) { return FALSE; } /*** 終日判定 */ if (strlen($startDateTime) == strlen('YYYY-MM-DD')) { $allDayFlg = TRUE; $startDate = $startDateTime; /*** 翌日作成 */ $baseDate = str_replace('-', '', $startDate).'0000'; $objDateMath = new DateMath($baseDate); $objDateMath->getDateAfterDays(1); $endDate = '' . $objDateMath->iResultYear . '-' . $objDateMath->iResultMonth . '-' . $objDateMath->iResultDay; } /*** 開始終了時刻初期化 */ $startTime = '00:00'; $endTime = '01:00'; /*** 日/時分割 */ if (!$allDayFlg) { $divide = explode(' ', $startDateTime); $startDate = $divide[0]; $startTime = $divide[1]; $divide = explode(' ', $endDateTime); $endDate = $divide[0]; $endTime = $divide[1]; } return TRUE; }
$taskInfo = array( 'id' => '214034545', 'title' => 'たんたいてすとによるを変更', 'note' => 'めもめもも変更', 'startdate' => '2013-12-29', 'starttime' => '12:34 pm', 'duedate' => '2013-12-30', 'duetime' => '10:56 pm' ); $result = $this->_toodledo->request('editTask', $taskInfo, Toodledo::RAW);
Googleカレンダー/toodledo同期サービスの処理方法を記載する。
以上
Googleカレンダー/toodledo同期サービスが独自に保存する情報の記録方式を記載する。
{YYYY-MM-DD}T{HH:mm:ss}
Googleカレンダー用フォーマット:2013-11-23T04:09:14
toodle用フォーマット:2011-08-28 05:43:22
{GoogleカレンダーイベントID},{toodledoイベントID}
ソースコードを公開するので、ToodledoのアプリケーションIDの設定アルゴリズムも白日となる。 アプリケーションIDをファイルに埋め込んだ場合、そのファイルの所在がプログラムを解説することで容易に知ることができる。 サーバーのデフォルトの設定では、場所がわかれば "http://../場所" でブラウザでそこに記載された内容を表示することができる。 もちろん、アクセスコントロールファイルを変更すれば表示できなくなる。しかし、変更が初期化されるリスクは高い。 そこで、サーバの設定を変えることなくアプリケーションIDを隠蔽するため以下の方式をとる。
この方式により、ブラウザで「http://../appid.php」にアクセスしても、白紙が表示されるだけとなる。
0件
Array
( [@attributes] => Array ( [num] => 0 [total] => 0 [start] => 0 [end] => 1000 )
)
Array ( [@attributes] => Array ( [num] => 2 [total] => 2 [start] => 0 [end] => 1000 )
[task] => Array ( [0] => Array ( [id] => 208651389 [parent] => 0 [children] => 0 [title] => ほしい鞄 [tag] => 買い物 [folder] => 1914315 [context] => 出かけたい場所 [goal] => ストレス解消 [added] => 2013-10-26 [modified] => 2013-12-31 03:52:18 [startdate] => 2013-12-31 [duedate] => Array ( [@attributes] => Array ( [modifier] => )
[duetime] => Array ( )
[starttime] => Array ( )
[reminder] => 0 [completed] => Array ( )
[repeat] => 0 [rep_advanced] => Array ( )
[status] => 5 [star] => 0 [priority] => 0 [length] => 0 [timer] => 0 [note] => https://www.evernote.com/shard/s89/sh/fdd29ba0-3d2f-4f8e-a8f6-5cbebe3baff8/c470710aaf619cdbb8aff8fe0e91ea2dsoreda )
[1] => Array ( [id] => 210360366 [parent] => 0 [children] => 0 [title] => 寝床検討 [tag] => 思考 [folder] => 1914315 [context] => 場所を問わずできる [goal] => 健康維持 [added] => 2013-11-14 [modified] => 2013-12-31 03:52:03 [startdate] => 2013-12-31 [duedate] => Array ( [@attributes] => Array ( [modifier] => )
[status] => 3 [star] => 0 [priority] => 2 [length] => 0 [timer] => 0 [note] => koreda )
1件 count($task)とした場合、1を期待するものの実際には24が帰ってくる(連想配列の数)
Array ( [@attributes] => Array ( [num] => 1 [total] => 1 [start] => 0 [end] => 1000 )
[task] => Array ( [id] => 210360366 [parent] => 0 [children] => 0 [title] => 寝床検討 [tag] => 思考 [folder] => 1914315 [context] => 場所を問わずできる [goal] => 健康維持 [added] => 2013-11-14 [modified] => 2013-12-31 03:55:53 [startdate] => 2013-12-31 [duedate] => Array ( [@attributes] => Array ( [modifier] => )
[status] => 3 [star] => 0 [priority] => 2 [length] => 0 [timer] => 0 [note] => koredaよ )
Array ( [num] => 1 [total] => 1 [start] => 0 [end] => 1000 [task] => Array ( [0] => Array ( [id] => 208651389 [parent] => 0 [children] => 0 [title] => ほしい鞄 [tag] => 買い物 [folder] => 1914315 [context] => Array ( [id] => 976351 [_content] => 出かけたい場所 )
[goal] => Array ( [id] => 299346 [_content] => ストレス解消 )
[added] => 2013-10-26 [modified] => 2014-01-01 04:10:51 [startdate] => 2014-01-31 [duedate] => Array ( [modifier] => [_content] => 2014-01-31 )
[duetime] => 1:00 pm [starttime] => 12:30 pm [reminder] => 0 [completed] => [repeat] => 0 [rep_advanced] => [status] => 5 [star] => 0 [priority] => 0 [length] => 30 [timer] => Array ( [onfor] => 0 [_content] => 0 )
[note] => https://www.evernote.com/shard/s89/sh/fdd29ba0-3d2f-4f8e-a8f6-5cbebe3baff8/c470710aaf619cdbb8aff8fe0e91ea2d soreda )
Array ( [0] => Array ( [ID] => Zend_Gdata_App_Extension_Id Object ( [_rootElement:protected] => id [_rootNamespace:protected] => atom [_rootNamespaceURI:protected] => [_extensionElements:protected] => Array ( )
[_extensionAttributes:protected] => Array ( )
[_text:protected] => http://www.google.com/calendar/feeds/0rhh763d7t49tfnn28bgkuj5lg%40group.calendar.google.com/private/full/rjulqtl9f9uuh8nggep0oqpgj8 [_namespaces:protected] => Array ( [atom] => Array ( [1] => Array ( [0] => http://www.w3.org/2005/Atom )
[app] => Array ( [1] => Array ( [0] => http://purl.org/atom/app# )
[2] => Array ( [0] => http://www.w3.org/2007/app )
[NAME] => Zend_Gdata_App_Extension_Title Object ( [_rootElement:protected] => title [_type:protected] => text [_rootNamespace:protected] => atom [_rootNamespaceURI:protected] => [_extensionElements:protected] => Array ( )
[_text:protected] => 散歩&検討inスマホ [_namespaces:protected] => Array ( [atom] => Array ( [1] => Array ( [0] => http://www.w3.org/2005/Atom )
[START_TIME] => 1388552400 [END_TIME] => 1388556000 [ALLDAY] => 1 [UPDATED] => Zend_Gdata_App_Extension_Updated Object ( [_rootElement:protected] => updated [_rootNamespace:protected] => atom [_rootNamespaceURI:protected] => [_extensionElements:protected] => Array ( )
[_text:protected] => 2014-01-01T10:04:46.000Z [_namespaces:protected] => Array ( [atom] => Array ( [1] => Array ( [0] => http://www.w3.org/2005/Atom )
[CONTENT] => Zend_Gdata_App_Extension_Content Object ( [_rootElement:protected] => content [_src:protected] => [_type:protected] => text [_rootNamespace:protected] => atom [_rootNamespaceURI:protected] => [_extensionElements:protected] => Array ( )
[_text:protected] => やったよね [_namespaces:protected] => Array ( [atom] => Array ( [1] => Array ( [0] => http://www.w3.org/2005/Atom )
WEB動作でToodledoがエラーになるので
$method getTasks
$params Array [4] end 2 modafter 1389528065 unix 1
$url http://api.toodledo.com/api.php?method=getTasks;end=2;modafter=1389528065;unix=1;key=26a0c6f7ffa64ee685394e24dd76840f
=====
$url http://api.toodledo.com/api.php?method=getTasks;end=2;modafter=1389529811;unix=1;key=26a0c6f7ffa64ee685394e24dd76840f
$token td52d2550563a29 td52d2550563a29
key 26a0c6f7ffa64ee685394e24dd76840f 26a0c6f7ffa64ee685394e24dd76840f
getの
$params Array [3] end 2 modafter 2013-12-28 05:43:22 unix 1
$params Array [2] modafter 1389528065 unix 1
ToodledoAPIのオープンソースでは、APIから期待しないレスポンスがあるとExceptionを発行している。 これらを全て、エラーメッセージテキストを設定してのエラーリターンに変更する。
public $exeptionMessage = ''; const EXERROR_EMPTY_RESPONCE = ''Empty response''; const EXERROR_INVALID_RESPONCE = 'Invalid response while getting token';
public function request($method, $params=array(), $output=self::DEFAULT_RETURN){ if (!empty($this->key)) $params['key'] = $this->key; $url = self::APIURL . 'method='.$method . (!empty($params) ? ';' . http_build_query($params, '', ';') : '');
$string = file_get_contents($url); if (empty($string)) throw new Exception('Empty response'); if ($output === self::RAW) return $string; // Wrap with <response> so outer-most wrapper is accesible with $xml->foo if (substr($string,0,2) === '<?' && ($pos=strpos($string,'?>')) !== false && $pos < strpos($string, '<', 1)) $string = substr_replace($string, '<response>', $pos+2, 0) . '</response>'; else $string = '<response>' . $string . '</response>'; $xml = new SimpleXMLElement($string); $error = $xml->error; if (!empty($error)) throw new Exception((string)$error); if ($output === self::ARR) return self::simplexml2array($xml); return $xml; }
$this->exceptionMessage=(string)$error; return FALSE;
http://pear.php.net/manual/ja/package.xml.xml-serializer.php https://hariushi-lib.googlecode.com/svn/trunk/DateMath.php https://hariushi-lib.googlecode.com/svn/trunk/Google/Calendar.php https://hariushi-lib.googlecode.com/svn/trunk/Math.php https://hariushi-lib.googlecode.com/svn/trunk/Request/Request.php https://hariushi-lib.googlecode.com/svn/trunk/Session.php https://hariushi-lib.googlecode.com/svn/trunk/Toodledo/api/Toodledo.php https://task-shoot-calendar.googlecode.com/svn/trunk/application/configs/application.ini https://task-shoot-calendar.googlecode.com/svn/trunk/application/controllers/ErrorController.php https://task-shoot-calendar.googlecode.com/svn/trunk/application/controllers/IndexController.php https://task-shoot-calendar.googlecode.com/svn/trunk/application/models/AuthController.php https://task-shoot-calendar.googlecode.com/svn/trunk/application/models/EventmapController.php https://task-shoot-calendar.googlecode.com/svn/trunk/application/views/scripts/index/index.phtml https://task-shoot-calendar.googlecode.com/svn/trunk/application/views/scripts/index/index2.phtml https://task-shoot-calendar.googlecode.com/svn/trunk/application/views/scripts/index/mini.phtml https://task-shoot-calendar.googlecode.com/svn/trunk/application/views/scripts/index/wait.phtml https://task-shoot-calendar.googlecode.com/svn/trunk/public/include_path_env.php https://task-shoot-calendar.googlecode.com/svn/trunk/public/index.php
ソースコード公開に当たり、toodledoのアプリケーションIDを隠蔽するために設置されたマジックワードメソッドについての説明です。
[TOP]|[編集]|[新規] [TASK(PRIVATE)]