php-tool-box:todo
差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン最新のリビジョン両方とも次のリビジョン | ||
php-tool-box:todo [2010/06/25 04:49] – 0.3.6 a:visitedを青色にした dgbadmin | php-tool-box:todo [2015/09/26 15:55] – [ソースコード] dgbadmin | ||
---|---|---|---|
行 33: | 行 33: | ||
===== ソースコード ===== | ===== ソースコード ===== | ||
- | <code php> | ||
- | <?php | ||
- | /** | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | */ | ||
- | class Todo { | ||
- | /** 文字コード */ | ||
- | const ENCODING = ' | ||
- | |||
- | /** サーバに保存するファイル名の文字コード */ | ||
- | //const FILE_NAME_ENCODING = ' | ||
- | const FILE_NAME_ENCODING = ' | ||
- | //const FILE_NAME_ENCODING = ' | ||
- | |||
- | /** TODOデータを保存するディレクトリ */ | ||
- | const DATA_DIR = ' | ||
- | |||
- | /** カテゴリ名として許可する正規表現 */ | ||
- | const CAT_REGEX = ' | ||
- | |||
- | /** バックアップの保存期限 */ | ||
- | const BACKUP_TIME = '-7 day'; | ||
- | |||
- | /** 優先度の最大値 */ | ||
- | const PRI_MAX = 5; | ||
- | |||
- | public $cat; | ||
- | public $cats; | ||
- | public $list; | ||
- | |||
- | /** | ||
- | | ||
- | | ||
- | */ | ||
- | public function __construct($cat) { | ||
- | mb_internal_encoding(Todo:: | ||
- | mb_regex_encoding(Todo:: | ||
- | ini_set(' | ||
- | ini_set(' | ||
- | mb_substitute_character(0x005f); | ||
- | | ||
- | $this-> | ||
- | } | ||
- | /** | ||
- | | ||
- | */ | ||
- | public function setUp() { | ||
- | if ($this-> | ||
- | if ($_REQUEST[' | ||
- | } else { | ||
- | if ($_POST[' | ||
- | $this-> | ||
- | } | ||
- | $this-> | ||
- | } | ||
- | } | ||
- | $this-> | ||
- | } | ||
- | /** | ||
- | | ||
- | | ||
- | */ | ||
- | public function isValidCat() { | ||
- | return mb_eregi(Todo:: | ||
- | } | ||
- | /** | ||
- | | ||
- | | ||
- | */ | ||
- | public function getPath() { | ||
- | $cat = mb_convert_encoding($this-> | ||
- | return Todo:: | ||
- | } | ||
- | /** | ||
- | | ||
- | | ||
- | | ||
- | */ | ||
- | private function _encode($input) { | ||
- | return mb_convert_encoding($input, | ||
- | } | ||
- | /** | ||
- | | ||
- | | ||
- | */ | ||
- | private function _getCategories() { | ||
- | $h = openDir(Todo:: | ||
- | if (!$h) { | ||
- | exit(' | ||
- | } | ||
- | $cats = array(); | ||
- | $limit = date(' | ||
- | while (false !== ($file = readDir($h))) { | ||
- | if (is_dir($file)) { | ||
- | continue; | ||
- | } | ||
- | $arr = explode(' | ||
- | $path = Todo:: | ||
- | if (count($arr) == 3) { // | ||
- | if ($arr[2] < $limit) { // | ||
- | unlink($path); | ||
- | } | ||
- | } else { // | ||
- | $cat = mb_convert_encoding($arr[0], | ||
- | $cats[$cat] = fileSize($path); | ||
- | } | ||
- | } | ||
- | closeDir($h); | ||
- | ksort($cats); | ||
- | return $cats; | ||
- | } | ||
- | /** | ||
- | | ||
- | */ | ||
- | private function _updateList() { | ||
- | $oldCat = new Todo($_POST[' | ||
- | $newPath = $this-> | ||
- | if (is_file(strToUpper(__FILE__))) { // | ||
- | $change = strCaseCmp($oldCat-> | ||
- | } else { | ||
- | $change = ($oldCat-> | ||
- | } | ||
- | if ($change && is_file($newPath)) { | ||
- | return; | ||
- | } | ||
- | |||
- | $oldPath = $oldCat-> | ||
- | if ($oldCat-> | ||
- | rename($oldPath, | ||
- | } | ||
- | |||
- | foreach ($_POST[' | ||
- | if ($post[1] != '' | ||
- | $data .= implode(" | ||
- | } | ||
- | } | ||
- | file_put_contents($newPath, | ||
- | } | ||
- | /** | ||
- | | ||
- | | ||
- | */ | ||
- | private function _getList() { | ||
- | $path = $this-> | ||
- | if (!is_file($path)) { // | ||
- | return array('' | ||
- | } | ||
- | $list = explode(" | ||
- | rsort($list); | ||
- | return $list; | ||
- | } | ||
- | /** | ||
- | | ||
- | | ||
- | */ | ||
- | private function _deleteCat() { | ||
- | $path = $this-> | ||
- | if (!is_file($path) || fileSize($path)) { // | ||
- | return false; | ||
- | } | ||
- | $this-> | ||
- | return unlink($path); | ||
- | } | ||
- | } | ||
- | |||
- | //----- HTMLレンダリング用のグローバル関数 ----- | ||
- | /** | ||
- | | ||
- | | ||
- | | ||
- | */ | ||
- | function h($val) { | ||
- | return htmlSpecialChars($val, | ||
- | } | ||
- | /** | ||
- | | ||
- | | ||
- | | ||
- | */ | ||
- | function echoOption($val, | ||
- | if ($val == $selectedVal) { | ||
- | $selected = ' | ||
- | } | ||
- | echo "< | ||
- | } | ||
- | // | ||
- | |||
- | |||
- | $todo = new Todo($_REQUEST[' | ||
- | $todo-> | ||
- | ?> | ||
- | < | ||
- | <html lang=" | ||
- | < | ||
- | <meta charset="<? | ||
- | < | ||
- | <link rel=" | ||
- | <link rel=" | ||
- | < | ||
- | header, article, footer { display: block } | ||
- | header { padding-top: | ||
- | #bd, #add { | ||
- | #cat { margin-bottom: | ||
- | h1 { margin: 1em 0 0 } | ||
- | a { | ||
- | a:visited { | ||
- | tr.row: | ||
- | th, td { border: solid #79a 1px } | ||
- | td { padding: 1px 0 1px 1px } | ||
- | select, input { margin: 0 } | ||
- | select, input.date, footer { text-align: center } | ||
- | select, #todo input { border-width: | ||
- | select { width: 4.3em; height: 1.6em } | ||
- | input.todo { padding-left: | ||
- | input.date { width: 6em } | ||
- | #update { | ||
- | #update input { padding: 0 2em; line-height: | ||
- | li { padding-top: | ||
- | li input { width: 5em } | ||
- | </ | ||
- | < | ||
- | // | ||
- | document.createElement(" | ||
- | document.createElement(" | ||
- | </ | ||
- | </ | ||
- | |||
- | < | ||
- | <div id=" | ||
- | |||
- | <header id=" | ||
- | |||
- | <div id=" | ||
- | |||
- | <div id=" | ||
- | |||
- | <article class=" | ||
- | <?php | ||
- | if ($todo-> | ||
- | ?> | ||
- | <form method=" | ||
- | |||
- | <div id=" | ||
- | カテゴリ : <input type=" | ||
- | <input type=" | ||
- | </ | ||
- | |||
- | <!-- TODOリスト --> | ||
- | <table id=" | ||
- | < | ||
- | < | ||
- | </ | ||
- | |||
- | < | ||
- | <?php | ||
- | $styleClasses = array('', | ||
- | $statuses = array('< | ||
- | |||
- | foreach ($todo-> | ||
- | $task = explode(" | ||
- | if ($task[4] == $statuses[2]) { // | ||
- | continue; | ||
- | } | ||
- | ?> | ||
- | <tr class=" | ||
- | |||
- | <!-- 優先度 --> | ||
- | <td> | ||
- | <select name=" | ||
- | <?php | ||
- | for ($j = 1; $j < Todo:: | ||
- | echoOption($j, | ||
- | } | ||
- | ?> | ||
- | </ | ||
- | </td> | ||
- | |||
- | <!-- TODO、開始日、期限 --> | ||
- | <?php | ||
- | for ($j = 1; $j < 4; $j++) { | ||
- | ?> | ||
- | <td> | ||
- | <input type=" | ||
- | | ||
- | </td> | ||
- | <?php | ||
- | } | ||
- | ?> | ||
- | |||
- | <!-- 状態 --> | ||
- | <td> | ||
- | <select name=" | ||
- | <?php | ||
- | foreach ($statuses as $status) { | ||
- | echoOption($status, | ||
- | } | ||
- | ?> | ||
- | </ | ||
- | </td> | ||
- | |||
- | </tr> | ||
- | <?php | ||
- | } | ||
- | ?> | ||
- | </ | ||
- | </ | ||
- | |||
- | <div id=" | ||
- | |||
- | </ | ||
- | <?php | ||
- | } else if ($todo-> | ||
- | ?> | ||
- | <span class=" | ||
- | 残念ですが、このカテゴリ名( <?php echo h($todo-> | ||
- | </ | ||
- | <?php | ||
- | } | ||
- | ?> | ||
- | </ | ||
- | |||
- | </ | ||
- | |||
- | <!-- カテゴリリスト --> | ||
- | <nav class=" | ||
- | <ul> | ||
- | <?php | ||
- | foreach ($todo-> | ||
- | $href = '? | ||
- | ?> | ||
- | <li> | ||
- | <a href="<? | ||
- | <?php | ||
- | if (!$fileSize) { // | ||
- | ?> | ||
- | <a href="<? | ||
- | <?php | ||
- | } | ||
- | ?> | ||
- | </li> | ||
- | <?php | ||
- | } | ||
- | ?> | ||
- | |||
- | <li id=" | ||
- | <form method=" | ||
- | <div> | ||
- | <input type=" | ||
- | <input type=" | ||
- | </ | ||
- | </ | ||
- | </li> | ||
- | |||
- | </ul> | ||
- | </ | ||
- | |||
- | </ | ||
- | |||
- | <footer id=" | ||
- | powered by <a href=" | ||
- | </ | ||
- | |||
- | </ | ||
- | |||
- | <script src="// | ||
- | <script src="// | ||
- | <script src="// | ||
- | < | ||
- | Pryn.addEvent(window, | ||
- | YahhoCal.loadYUI(); | ||
- | YahhoCal.setMondayAs1st(); | ||
- | (function(input) { | ||
- | var acs = new Pryn.ClassAccessor(input); | ||
- | if (acs.hasClass(" | ||
- | Pryn.addEvent(input, | ||
- | YahhoCal.render(YAHOO.util.Dom.generateId(input)); | ||
- | }); | ||
- | acs.addClass(" | ||
- | input.title = " | ||
- | } | ||
- | }).foreach($T(" | ||
- | }); | ||
- | </ | ||
- | |||
- | </ | ||
- | </ | ||
- | </ | ||
+ | [[https:// |
php-tool-box/todo.txt · 最終更新: 2015/10/24 14:34 by dgbadmin