function plugin_backup_get_list($page) { global $layout_pages; //レイアウト部品の場合、スタイルを変更する $is_layout = FALSE; if (isset($layout_pages) && isset($layout_pages[$page])) { $is_layout = TRUE; } $qm = get_qm(); $script = get_script_uri(); $r_page = rawurlencode($page); $s_page = htmlspecialchars($page); //バックアップ一覧へのリンクは、 //レイアウト部品の場合、編集リンクを表示する $backuplist_link = $is_layout ? '<a href="' . h($script) . '?cmd=edit&page=' . $r_page . '">' . h($layout_pages[$page]) . 'を編集する</a>' : '<a href="' . h($script) . '?cmd=backup">' . $qm->m['plg_backup']['backuplist'] . '</a>'; $retval = array(); $retval[0] = ' <ul> <li> ' . $backuplist_link . ' <ul> '; $retval[1] = "\n"; $retval[2] = <<<EOD </ul> </li> </ul> EOD; $backups = _backup_file_exists($page) ? get_backup($page) : array(); if (empty($backups)) { $pagelink = $is_layout ? h($layout_pages[$page]) : make_pagelink($page); $msg = str_replace('$1', $pagelink, $qm->m['plg_backup']['nobackup']); $retval[1] .= ' <li>' . $msg . '</li>' . "\n"; return join('', $retval); } if (!PKWK_READONLY) { $retval[1] .= ' <li><a href="' . $script . '?cmd=backup&action=delete&page=' . $r_page . '">'; $retval[1] .= str_replace('$1', $is_layout ? h($layout_pages[$page]) : $s_page, $qm->m['plg_backup']['title_backup_delete']); $retval[1] .= '</a></li>' . "\n"; } $href = $script . '?cmd=backup&page=' . $r_page . '&age='; $_anchor_from = $_anchor_to = ''; foreach ($backups as $age => $data) { if (!PLUGIN_BACKUP_DISABLE_BACKUP_RENDERING) { $_anchor_from = '<a href="' . $href . $age . '">'; $_anchor_to = '</a>'; } $date = format_date($data['time'], TRUE); $retval[1] .= <<<EOD <li>{$_anchor_from}{$age} {$date}{$_anchor_to} [ <a href="{$href}{$age}&action=diff">{$qm->m['plg_backup']['diff']}</a> | <a href="{$href}{$age}&action=nowdiff">{$qm->m['plg_backup']['nowdiff']}</a> | <a href="{$href}{$age}&action=source">{$qm->m['plg_backup']['source']}</a> ] </li> EOD; } return join('', $retval); }
/** * Get page created time * * PukiWiki API Extension * * @access public * @static * @param string $page pagename * @return int timestamp * @see get_filetime($page) * @version $Id: v 1.0 2008-06-05 11:14:46 sonots $ */ function get_filecreatetime($page) { if (_backup_file_exists($page)) { // PukiWiki Trick // This is not a created time exactly, but the closest time $backup = get_backup($page, 1); // 1st age return $backup['time']; } else { return get_filetime($page); } }
/** * _backup_file * バックアップファイルの内容を取得する * * @access private * @param String $page ページ名 * * @return Array ファイルの内容 */ function _backup_file($page) { return _backup_file_exists($page) ? file(_backup_get_filename($page)) : array(); }
function plugin_backup_convert() { global $vars, $script; // global $_msg_backuplist, $_msg_diff, $_msg_nowdiff, $_msg_source, $_msg_nobackup; // global $_title_backup_delete; $page = isset($vars['page']) ? $vars['page'] : ''; check_readable($page, false); $_msg_backuplist = _('List of Backups'); $_msg_diff = _('diff'); $_msg_nowdiff = _('diff current'); $_msg_source = _('source'); $_msg_nobackup = _('There are no backup(s) of $1.'); $_title_backup_delete = _('Deleting backup of $1'); // Get arguments $with_label = TRUE; $args = func_get_args(); while (isset($args[0])) { switch (array_shift($args)) { case 'default': $diff_mode = 0; break; case 'nowdiff': $diff_mode = 1; break; case 'visualdiff': $diff_mode = 2; break; case 'label': $with_label = TRUE; break; case 'nolabel': $with_label = FALSE; break; } } $r_page = rawurlencode($page); $s_page = htmlspecialchars($page); $retval = array(); $date = get_date("m/d", get_filetime($page)); if ($with_label) { $retval[0] = <<<EOD <form class="center_form" action=""><div><label>Versions: <select onchange="javascript:location.href=this[this.selectedIndex].value"> EOD; $retval[1] = "\n"; $retval[2] = <<<EOD </select></label></div> </form> EOD; } else { $retval[0] = <<<EOD <form class="center_form" action=""><div> <select onchange="javascript:location.href=this[this.selectedIndex].value"> EOD; $retval[1] = "\n"; $retval[2] = <<<EOD </select> </div></form> EOD; } $backups = _backup_file_exists($page) ? get_backup($page) : array(); if (count($backups) == 0) { $retval[1] .= '<option value="' . get_page_uri($page) . '" selected="selected">' . _('->') . " {$date}(No.1)</option>\n"; return join('', $retval); } $maxcnt = count($backups) + 1; $retval[1] .= '<option value="' . get_page_uri($page) . '" selected="selected">' . _('->') . " {$date}(No.{$maxcnt})</option>\n"; $backups = array_reverse($backups, True); foreach ($backups as $age => $data) { $time = isset($data['real']) ? $data['real'] : $data['time']; $date = get_date('m/d', $time); $href = $script . '?cmd=backup&page=' . $r_page . '&age=' . $age; $retval[1] .= '<option value="' . $href; switch ($diff_mode) { case 2: $retval[1] .= '&action=visualdiff'; break; case 1: $retval[1] .= '&action=nowdiff'; break; } $retval[1] .= '">' . $date . ' (No.' . $age . ')</option>' . "\n"; } return join('', $retval); }
function doc_ini_file_exist($page) { $backup = _backup_file_exists($page); $filename = DIFF_DIR . encode($page) . '.txt'; $diff = file_exists($filename); return $backup || $diff; }
function is_newpage($page) { // pukiwiki trick return !_backup_file_exists($page); }
function plugin_backup_get_list($page) { global $_msg_backuplist, $_msg_diff, $_msg_nowdiff, $_msg_source, $_msg_nobackup; global $_title_backup_delete; $script = get_script_uri(); $r_page = rawurlencode($page); $s_page = htmlsc($page); $retval = array(); $retval[0] = <<<EOD <ul> <li><a href="{$script}?cmd=backup">{$_msg_backuplist}</a> <ul> EOD; $retval[1] = "\n"; $retval[2] = <<<EOD </ul> </li> </ul> EOD; $backups = _backup_file_exists($page) ? get_backup($page) : array(); if (empty($backups)) { $msg = str_replace('$1', make_pagelink($page), $_msg_nobackup); $retval[1] .= ' <li>' . $msg . '</li>' . "\n"; return join('', $retval); } if (!PKWK_READONLY) { $retval[1] .= ' <li><a href="' . $script . '?cmd=backup&action=delete&page=' . $r_page . '">'; $retval[1] .= str_replace('$1', $s_page, $_title_backup_delete); $retval[1] .= '</a></li>' . "\n"; } $href = $script . '?cmd=backup&page=' . $r_page . '&age='; $_anchor_from = $_anchor_to = ''; foreach ($backups as $age => $data) { if (!PLUGIN_BACKUP_DISABLE_BACKUP_RENDERING) { $_anchor_from = '<a href="' . $href . $age . '">'; $_anchor_to = '</a>'; } $date = format_date($data['time'], true); $retval[1] .= <<<EOD <li>{$_anchor_from}{$age} {$date}{$_anchor_to} [ <a href="{$href}{$age}&action=diff">{$_msg_diff}</a> | <a href="{$href}{$age}&action=nowdiff">{$_msg_nowdiff}</a> | <a href="{$href}{$age}&action=source">{$_msg_source}</a> ] </li> EOD; } return join('', $retval); }