/** * Create link/button to user page * * @author Anika Henke <*****@*****.**> */ function _tpl_userpage($userPage, $title, $link = 0, $wrapper = 0, $return = 0) { if (empty($_SERVER['REMOTE_USER'])) { return; } global $conf; $output = ''; $userPage = str_replace('@USER@', $_SERVER['REMOTE_USER'], $userPage); if ($wrapper) { $output .= "<{$wrapper}>"; } if ($link) { ob_start(); tpl_pagelink($userPage, $title); $output .= ob_get_contents(); ob_end_clean(); } else { $output .= html_btn('userpage', $userPage, '', array(), 'get', 0, $title); } if ($wrapper) { $output .= "</{$wrapper}>"; } if ($return) { return $output; } echo $output; }
function parEditButton($parId) { global $ID; global $INFO; $ret = ''; $params = array('do' => 'edit', 'rev' => $INFO['lastmod'], 'parid' => $parId); $ret .= '<div class="secedit editbutton_par' . strval($parId) . '">'; $ret .= html_btn('secedit', $ID, '', $params, 'post'); $ret .= '</div>'; return $ret; }
/** * Create link/button to register page * DW versions > 2011-02-20 can use the core function tpl_action('register') * * @author Anika Henke <*****@*****.**> */ function _tpl_register($link=0,$wrapper=0) { global $conf; global $lang; global $ID; $lang_register = !empty($lang['btn_register']) ? $lang['btn_register'] : $lang['register']; if ($_SERVER['REMOTE_USER'] || !$conf['useacl'] || !actionOK('register')) return; if ($wrapper) echo "<$wrapper>"; if ($link) tpl_link(wl($ID,'do=register'),$lang_register,'class="action register" rel="nofollow"'); else echo html_btn('register',$ID,'',array('do'=>'register'),'get',0,$lang_register); if ($wrapper) echo "</$wrapper>"; }
/** * Create link/button to user page * * @author Anika Henke <*****@*****.**> */ function _tpl_userpage($userPage, $title, $link = 0, $wrapper = 0) { if (empty($_SERVER['REMOTE_USER'])) { return; } global $conf; $userPage = str_replace('@USER@', $_SERVER['REMOTE_USER'], $userPage); if ($wrapper) { echo "<{$wrapper}>"; } if ($link) { tpl_pagelink($userPage, $title); } else { echo html_btn('userpage', $userPage, '', array(), 'get', 0, $title); } if ($wrapper) { echo "</{$wrapper}>"; } }
/** * Create link/button to user page * * @author Anika Henke <*****@*****.**> */ function _tpl_userpage($userNS = 'user', $link = 0, $wrapper = false) { if (!$_SERVER['REMOTE_USER']) { return; } global $conf; $userPage = $userNS . ':' . $_SERVER['REMOTE_USER'] . ':' . $conf['start']; if ($wrapper) { echo "<{$wrapper}>"; } if ($link) { tpl_pagelink($userPage, tpl_getLang('userpage')); } else { echo html_btn('userpage', $userPage, '', array(), 0, 0, tpl_getLang('userpage')); } if ($wrapper) { echo "</{$wrapper}>"; } }
/** * Removes the TOC of the sidebar pages and * shows a edit button if the user has enough rights * * TODO sidebar caching * * @author Michael Klier <*****@*****.**> */ function p_sidebar_xhtml($sb, $pos, $subst = array()) { $data = p_wiki_xhtml($sb, '', false); if (!empty($subst)) { $data = preg_replace($subst['pattern'], $subst['replace'], $data); } if (auth_quickaclcheck($sb) >= AUTH_EDIT) { $data .= '<div class="secedit">' . html_btn('secedit', $sb, '', array('do' => 'edit', 'rev' => '', 'post')) . '</div>'; } // strip TOC $data = preg_replace('/<div class="toc">.*?(<\\/div>\\n<\\/div>)/s', '', $data); // replace headline ids for XHTML compliance $data = preg_replace('/(<h.*?><a.*?name=")(.*?)(".*?id=")(.*?)(">.*?<\\/a><\\/h.*?>)/', '\\1sb_' . $pos . '_\\2\\3sb_' . $pos . '_\\4\\5', $data); return $data; }
/** * Removes the TOC of the sidebar pages and * shows a edit button if the user has enough rights * */ function p_sidebar_xhtml($sb) { global $conf; $tpl = $conf['template']; $data = p_wiki_xhtml($sb, '', false); if (auth_quickaclcheck($sb) >= AUTH_EDIT and tpl_getConf('sidebaredit')) { $data .= '<div class="secedit">' . html_btn('secedit', $sb, '', array('do' => 'edit', 'rev' => '', 'post')) . '</div>'; } // strip TOC $data = preg_replace('/<div class="toc">.*?(<\\/div>\\n<\\/div>)/s', '', $data); // replace headline ids for XHTML compliance $data = preg_replace('/(<h.*?><a.*?id=")(.*?)(">.*?<\\/a><\\/h.*?>)/', '\\1sb_left_\\2\\3', $data); return $data; }
/** * list old revisions * * @author Andreas Gohr <*****@*****.**> * @author Ben Coburn <*****@*****.**> */ function html_revisions($first = 0) { global $ID; global $INFO; global $conf; global $lang; /* we need to get one additionally log entry to be able to * decide if this is the last page or is there another one. * see html_recent() */ $revisions = getRevisions($ID, $first, $conf['recent'] + 1); if (count($revisions) == 0 && $first != 0) { $first = 0; $revisions = getRevisions($ID, $first, $conf['recent'] + 1); } $hasNext = false; if (count($revisions) > $conf['recent']) { $hasNext = true; array_pop($revisions); // remove extra log entry } $date = @strftime($conf['dformat'], $INFO['lastmod']); print p_locale_xhtml('revisions'); $form = new Doku_Form('page__revisions', wl($ID)); $form->addElement(form_makeOpenTag('ul')); if ($INFO['exists'] && $first == 0) { if (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); } else { $form->addElement(form_makeOpenTag('li')); } $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); $form->addElement(form_makeTag('input', array('type' => 'checkbox', 'name' => 'rev2[]', 'value' => 'current'))); $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); $form->addElement($date); $form->addElement(form_makeCloseTag('span')); $form->addElement(form_makeTag('img', array('src' => DOKU_BASE . 'lib/images/blank.gif', 'width' => '15', 'height' => '11', 'alt' => ''))); $form->addElement(form_makeOpenTag('a', array('class' => 'wikilink1', 'href' => wl($ID)))); $form->addElement($ID); $form->addElement(form_makeCloseTag('a')); $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); $form->addElement(' – '); $form->addElement(htmlspecialchars($INFO['sum'])); $form->addElement(form_makeCloseTag('span')); $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); $form->addElement(empty($INFO['editor']) ? '(' . $lang['external_edit'] . ')' : editorinfo($INFO['editor'])); $form->addElement(form_makeCloseTag('span')); $form->addElement('(' . $lang['current'] . ')'); $form->addElement(form_makeCloseTag('div')); $form->addElement(form_makeCloseTag('li')); } foreach ($revisions as $rev) { $date = strftime($conf['dformat'], $rev); $info = getRevisionInfo($ID, $rev, true); $exists = page_exists($ID, $rev); if ($info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); } else { $form->addElement(form_makeOpenTag('li')); } $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); if ($exists) { $form->addElement(form_makeTag('input', array('type' => 'checkbox', 'name' => 'rev2[]', 'value' => $rev))); } else { $form->addElement(form_makeTag('img', array('src' => DOKU_BASE . 'lib/images/blank.gif', 'width' => 14, 'height' => 11, 'alt' => ''))); } $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); $form->addElement($date); $form->addElement(form_makeCloseTag('span')); if ($exists) { $form->addElement(form_makeOpenTag('a', array('href' => wl($ID, "rev={$rev},do=diff", false, '&'), 'class' => 'diff_link'))); $form->addElement(form_makeTag('img', array('src' => DOKU_BASE . 'lib/images/diff.png', 'width' => 15, 'height' => 11, 'title' => $lang['diff'], 'alt' => $lang['diff']))); $form->addElement(form_makeCloseTag('a')); $form->addElement(form_makeOpenTag('a', array('href' => wl($ID, "rev={$rev}", false, '&'), 'class' => 'wikilink1'))); $form->addElement($ID); $form->addElement(form_makeCloseTag('a')); } else { $form->addElement(form_makeTag('img', array('src' => DOKU_BASE . 'lib/images/blank.gif', 'width' => '15', 'height' => '11', 'alt' => ''))); $form->addElement($ID); } $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); $form->addElement(' – '); $form->addElement(htmlspecialchars($info['sum'])); $form->addElement(form_makeCloseTag('span')); $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); if ($info['user']) { $form->addElement(editorinfo($info['user'])); if (auth_ismanager()) { $form->addElement(' (' . $info['ip'] . ')'); } } else { $form->addElement($info['ip']); } $form->addElement(form_makeCloseTag('span')); $form->addElement(form_makeCloseTag('div')); $form->addElement(form_makeCloseTag('li')); } $form->addElement(form_makeCloseTag('ul')); $form->addElement(form_makeButton('submit', 'diff', $lang['diff2'])); html_form('revisions', $form); print '<div class="pagenav">'; $last = $first + $conf['recent']; if ($first > 0) { $first -= $conf['recent']; if ($first < 0) { $first = 0; } print '<div class="pagenav-prev">'; print html_btn('newer', $ID, "p", array('do' => 'revisions', 'first' => $first)); print '</div>'; } if ($hasNext) { print '<div class="pagenav-next">'; print html_btn('older', $ID, "n", array('do' => 'revisions', 'first' => $last)); print '</div>'; } print '</div>'; }
/** * Handle special section edit buttons for the include plugin to get the current page * and replace normal section edit buttons when the current page is different from the * global $ID. */ function handle_secedit_button(&$event, $params) { // stack of included pages in the form ('id' => page, 'rev' => modification time, 'writable' => bool) static $page_stack = array(); global $ID; $data = $event->data; if ($data['target'] == 'plugin_include_start' || $data['target'] == 'plugin_include_start_noredirect') { // handle the "section edits" added by the include plugin $fn = wikiFN($data['name']); array_unshift($page_stack, array('id' => $data['name'], 'rev' => @filemtime($fn), 'writable' => is_writable($fn) && auth_quickaclcheck($data['name']) >= AUTH_EDIT, 'redirect' => $data['target'] == 'plugin_include_start')); } elseif ($data['target'] == 'plugin_include_end') { array_shift($page_stack); } elseif (!empty($page_stack)) { if ($page_stack[0]['writable']) { $name = $data['name']; unset($data['name']); $secid = $data['secid']; unset($data['secid']); if ($page_stack[0]['redirect']) { $data['redirect_id'] = $ID; } $event->result = "<div class='secedit editbutton_" . $data['target'] . " editbutton_" . $secid . "'>" . html_btn('secedit', $page_stack[0]['id'], '', array_merge(array('do' => 'edit', 'rev' => $page_stack[0]['rev'], 'summary' => '[' . $name . '] '), $data), 'post', $name) . '</div>'; } else { $event->result = ''; } } else { return; // return so the event won't be stopped } $event->preventDefault(); $event->stopPropagation(); }
/** * Print one of the buttons * * Available Buttons are * * edit - edit/create/show/draft button * history - old revisions * recent - recent changes * login - login/logout button - if ACL enabled * profile - user profile button (if logged in) * index - The index * admin - admin page - if enough rights * top - a back to top button * back - a back to parent button - if available * backlink - links to the list of backlinks * subscription- subscribe/unsubscribe button * * @author Andreas Gohr <*****@*****.**> * @author Matthias Grimm <*****@*****.**> */ function tpl_button($type) { global $ACT; global $ID; global $REV; global $NS; global $INFO; global $conf; global $auth; // check disabled actions and fix the badly named ones $ctype = $type; if ($type == 'history') { $ctype = 'revisions'; } if (!actionOK($ctype)) { return false; } switch ($type) { case 'edit': #most complicated type - we need to decide on current action if ($ACT == 'show' || $ACT == 'search') { if ($INFO['writable']) { if (!empty($INFO['draft'])) { echo html_btn('draft', $ID, 'e', array('do' => 'draft'), 'post'); } else { if ($INFO['exists']) { echo html_btn('edit', $ID, 'e', array('do' => 'edit', 'rev' => $REV), 'post'); } else { echo html_btn('create', $ID, 'e', array('do' => 'edit', 'rev' => $REV), 'post'); } } } else { if (!actionOK('source')) { return false; } //pseudo action echo html_btn('source', $ID, 'v', array('do' => 'edit', 'rev' => $REV), 'post'); } } else { echo html_btn('show', $ID, 'v', array('do' => 'show')); } return true; case 'history': if (!actionOK('revisions')) { return false; } print html_btn('revs', $ID, 'o', array('do' => 'revisions')); return true; case 'recent': if (!actionOK('recent')) { return false; } print html_btn('recent', $ID, 'r', array('do' => 'recent')); return true; case 'index': if (!actionOK('index')) { return false; } print html_btn('index', $ID, 'x', array('do' => 'index')); return true; case 'back': if ($parent = tpl_getparent($ID)) { print html_btn('back', $parent, 'b', array('do' => 'show')); return true; } return false; case 'top': print html_topbtn(); return true; case 'login': if ($conf['useacl'] && $auth) { if ($_SERVER['REMOTE_USER']) { print html_btn('logout', $ID, '', array('do' => 'logout', 'sectok' => getSecurityToken())); } else { print html_btn('login', $ID, '', array('do' => 'login', 'sectok' => getSecurityToken())); } return true; } return false; case 'admin': if ($INFO['ismanager']) { print html_btn('admin', $ID, '', array('do' => 'admin')); return true; } return false; case 'subscribe': case 'subscription': if ($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1) { if ($_SERVER['REMOTE_USER']) { if ($INFO['subscribed']) { if (!actionOK('unsubscribe')) { return false; } print html_btn('unsubscribe', $ID, '', array('do' => 'unsubscribe')); } else { if (!actionOK('subscribe')) { return false; } print html_btn('subscribe', $ID, '', array('do' => 'subscribe')); } if ($type == 'subscribe') { return true; } } } if ($type == 'subscribe') { return false; } // fall through for backward compatibility // fall through for backward compatibility case 'subscribens': if ($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1) { if ($_SERVER['REMOTE_USER']) { if ($INFO['subscribedns']) { if (!actionOK('unsubscribens')) { return false; } print html_btn('unsubscribens', $ID, '', array('do' => 'unsubscribens')); } else { if (!actionOK('subscribens')) { return false; } print html_btn('subscribens', $ID, '', array('do' => 'subscribens')); } return true; } } return false; case 'backlink': if (!actionOK('backlink')) { return false; } print html_btn('backlink', $ID, '', array('do' => 'backlink')); return true; case 'profile': if ($conf['useacl'] && $_SERVER['REMOTE_USER'] && $auth && $auth->canDo('Profile') && $ACT != 'profile') { print html_btn('profile', $ID, '', array('do' => 'profile')); return true; } return false; default: print '[unknown button type]'; return true; } }
/** * display recent changes * * @author Andreas Gohr <*****@*****.**> * @author Matthias Grimm <*****@*****.**> * @author Ben Coburn <*****@*****.**> */ function html_recent($first = 0) { global $conf; global $lang; global $ID; /* we need to get one additionally log entry to be able to * decide if this is the last page or is there another one. * This is the cheapest solution to get this information. */ $recents = getRecents($first, $conf['recent'] + 1, getNS($ID)); if (count($recents) == 0 && $first != 0) { $first = 0; $recents = getRecents($first, $conf['recent'] + 1, getNS($ID)); } $hasNext = false; if (count($recents) > $conf['recent']) { $hasNext = true; array_pop($recents); // remove extra log entry } print p_locale_xhtml('recent'); print '<ul>'; foreach ($recents as $recent) { $date = date($conf['dformat'], $recent['date']); print $recent['type'] === 'e' ? '<li class="minor">' : '<li>'; print '<div class="li">'; print $date . ' '; print '<a href="' . wl($recent['id'], "do=diff") . '">'; $p = array(); $p['src'] = DOKU_BASE . 'lib/images/diff.png'; $p['width'] = 15; $p['height'] = 11; $p['title'] = $lang['diff']; $p['alt'] = $lang['diff']; $att = buildAttributes($p); print "<img {$att} />"; print '</a> '; print '<a href="' . wl($recent['id'], "do=revisions") . '">'; $p = array(); $p['src'] = DOKU_BASE . 'lib/images/history.png'; $p['width'] = 12; $p['height'] = 14; $p['title'] = $lang['btn_revs']; $p['alt'] = $lang['btn_revs']; $att = buildAttributes($p); print "<img {$att} />"; print '</a> '; print html_wikilink(':' . $recent['id'], $conf['useheading'] ? NULL : $recent['id']); print ' – ' . htmlspecialchars($recent['sum']); print ' <span class="user">'; if ($recent['user']) { print $recent['user']; } else { print $recent['ip']; } print '</span>'; print '</div>'; print '</li>'; } print '</ul>'; print '<div class="pagenav">'; $last = $first + $conf['recent']; if ($first > 0) { $first -= $conf['recent']; if ($first < 0) { $first = 0; } print '<div class="pagenav-prev">'; print html_btn('newer', '', "p", array('do' => 'recent', 'first' => $first)); print '</div>'; } if ($hasNext) { print '<div class="pagenav-next">'; print html_btn('older', '', "n", array('do' => 'recent', 'first' => $last)); print '</div>'; } print '</div>'; }
/** * Print one of the buttons * * Available Buttons are * * edit - edit/create/show/draft button * history - old revisions * recent - recent changes * login - login/logout button - if ACL enabled * profile - user profile button (if logged in) * index - The index * admin - admin page - if enough rights * top - a back to top button * back - a back to parent button - if available * backlink - links to the list of backlinks * subscription- subscribe/unsubscribe button * * @author Andreas Gohr <*****@*****.**> * @author Matthias Grimm <*****@*****.**> */ function tpl_button($type, $return = false) { global $ACT; global $ID; global $REV; global $NS; global $INFO; global $conf; global $auth; // check disabled actions and fix the badly named ones $ctype = $type; if ($type == 'history') { $ctype = 'revisions'; } if (!actionOK($ctype)) { return false; } $out = ''; switch ($type) { case 'edit': // most complicated type - we need to decide on current action if ($ACT == 'show' || $ACT == 'search') { if ($INFO['writable']) { if (!empty($INFO['draft'])) { $out .= html_btn('draft', $ID, 'e', array('do' => 'draft'), 'post'); } else { if ($INFO['exists']) { $out .= html_btn('edit', $ID, 'e', array('do' => 'edit', 'rev' => $REV), 'post'); } else { $out .= html_btn('create', $ID, 'e', array('do' => 'edit', 'rev' => $REV), 'post'); } } } else { if (!actionOK('source')) { return false; } //pseudo action $out .= html_btn('source', $ID, 'v', array('do' => 'edit', 'rev' => $REV), 'post'); } } else { $out .= html_btn('show', $ID, 'v', array('do' => 'show')); } break; case 'history': if (actionOK('revisions')) { $out .= html_btn('revs', $ID, 'o', array('do' => 'revisions')); } break; case 'recent': if (actionOK('recent')) { $out .= html_btn('recent', $ID, 'r', array('do' => 'recent')); } break; case 'index': if (actionOK('index')) { $out .= html_btn('index', $ID, 'x', array('do' => 'index')); } break; case 'back': if ($parent = tpl_getparent($ID)) { $out .= html_btn('back', $parent, 'b', array('do' => 'show')); } break; case 'top': $out .= html_topbtn(); break; case 'login': if ($conf['useacl'] && $auth) { if (isset($_SERVER['REMOTE_USER'])) { $out .= html_btn('logout', $ID, '', array('do' => 'logout', 'sectok' => getSecurityToken())); } else { $out .= html_btn('login', $ID, '', array('do' => 'login', 'sectok' => getSecurityToken())); } } break; case 'admin': if ($INFO['ismanager']) { $out .= html_btn('admin', $ID, '', array('do' => 'admin')); } break; case 'revert': if ($INFO['ismanager'] && $REV && $INFO['writable'] && actionOK('revert')) { $out .= html_btn('revert', $ID, '', array('do' => 'revert', 'rev' => $REV, 'sectok' => getSecurityToken())); } break; case 'subscribe': if ($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] && isset($_SERVER['REMOTE_USER']) && actionOK('subscribe')) { $out .= html_btn('subscribe', $ID, '', array('do' => 'subscribe')); } break; case 'backlink': if (actionOK('backlink')) { $out .= html_btn('backlink', $ID, '', array('do' => 'backlink')); } break; case 'profile': if ($conf['useacl'] && isset($_SERVER['REMOTE_USER']) && $auth && $auth->canDo('Profile') && $ACT != 'profile') { $out .= html_btn('profile', $ID, '', array('do' => 'profile')); } break; default: $out .= '[unknown button type]'; break; } if ($return) { return $out; } print $out; return $out ? true : false; }
/** * Display an edit button for the included page */ function _edit_button() { global $ID; $id = $this->entry['page']; $perm = auth_quickaclcheck($id); if (page_exists($id)) { if ($perm >= AUTH_EDIT && is_writable(wikiFN($id))) { $action = 'edit'; } else { return ''; } } elseif ($perm >= AUTH_CREATE) { $action = 'create'; } $params = array('do' => 'edit'); $params['redirect_id'] = $ID; return '<div class="secedit">' . DOKU_LF . DOKU_TAB . html_btn($action, $id, '', $params, 'post') . DOKU_LF . '</div>' . DOKU_LF; }
/** * output appropriate html */ function html() { global $conf; global $lang; $go = (int) $_REQUEST['time']; if (!$go) { $go = time() + 60 * 60; } //one hour in the future to trick pagination $min = $go - 7 * 24 * 60 * 60; $max = $go; echo $this->locale_xhtml('intro'); echo '<p>' . $this->getLang('range') . ' ' . strftime($conf['dformat'], $min) . ' - ' . strftime($conf['dformat'], $max) . '</p>'; echo '<table class="inline loglog">'; echo '<tr>'; echo '<th>' . $this->getLang('date') . '</th>'; echo '<th>' . $this->getLang('ip') . '</th>'; echo '<th>' . $lang['user'] . '</th>'; echo '<th>' . $this->getLang('action') . '</th>'; echo '</tr>'; $lines = $this->_readlines($min, $max); $lines = array_reverse($lines); foreach ($lines as $line) { list($dt, $junk, $ip, $user, $msg) = explode("\t", $line, 5); if ($dt < $min) { continue; } if ($dt > $max) { continue; } if (!$user) { continue; } if ($msg == 'logged off') { $msg = $this->getLang('off'); $class = 'off'; } elseif ($msg == 'logged in permanently') { $msg = $this->getLang('in'); $class = 'perm'; } elseif ($msg == 'logged in temporarily') { $msg = $this->getLang('tin'); $class = 'temp'; } elseif ($msg == 'failed login attempt') { $msg = $this->getLang('fail'); $class = 'fail'; } else { $msg = '****' . hsc($msg) . '****'; $class = 'error'; } echo '<tr>'; echo '<td>' . strftime($conf['dformat'], $dt) . '</td>'; echo '<td>' . hsc($ip) . '</td>'; echo '<td>' . hsc($user) . '</td>'; echo '<td><span class="loglog_' . $class . '">' . $msg . '</span></td>'; echo '</tr>'; } echo '</table>'; echo '<div class="pagenav">'; if ($max < time() - 7 * 24 * 60 * 60) { echo '<div class="pagenav-prev">'; echo html_btn('newer', $ID, "p", array('do' => 'admin', 'page' => 'loglog', 'time' => $max + 7 * 24 * 60 * 60)); echo '</div>'; } echo '<div class="pagenav-next">'; echo html_btn('older', $ID, "n", array('do' => 'admin', 'page' => 'loglog', 'time' => $min)); echo '</div>'; echo '</div>'; }
/** * Handle special section edit buttons for the include plugin to get the current page * and replace normal section edit buttons when the current page is different from the * global $ID. */ function handle_secedit_button(Doku_Event &$event, $params) { // stack of included pages in the form ('id' => page, 'rev' => modification time, 'writable' => bool) static $page_stack = array(); global $ID, $lang; $data = $event->data; if ($data['target'] == 'plugin_include_start' || $data['target'] == 'plugin_include_start_noredirect') { // handle the "section edits" added by the include plugin $fn = wikiFN($data['name']); $perm = auth_quickaclcheck($data['name']); array_unshift($page_stack, array( 'id' => $data['name'], 'rev' => @filemtime($fn), 'writable' => (page_exists($data['name']) ? (is_writable($fn) && $perm >= AUTH_EDIT) : $perm >= AUTH_CREATE), 'redirect' => ($data['target'] == 'plugin_include_start'), )); } elseif ($data['target'] == 'plugin_include_end') { array_shift($page_stack); } elseif ($data['target'] == 'plugin_include_editbtn') { if ($page_stack[0]['writable']) { $params = array('do' => 'edit', 'id' => $page_stack[0]['id']); if ($page_stack[0]['redirect']) $params['redirect_id'] = $ID; $event->result = '<div class="secedit">' . DOKU_LF . html_btn('incledit', $page_stack[0]['id'], '', $params, 'post', $data['name'], $lang['btn_secedit'].' ('.$page_stack[0]['id'].')') . '</div>' . DOKU_LF; } } elseif (!empty($page_stack)) { // Special handling for the edittable plugin if ($data['target'] == 'table' && !plugin_isdisabled('edittable')) { /* @var action_plugin_edittable $edittable */ $edittable =& plugin_load('action', 'edittable'); $data['name'] = $edittable->getLang('secedit_name'); } if ($page_stack[0]['writable'] && isset($data['name']) && $data['name'] !== '') { $name = $data['name']; unset($data['name']); $secid = $data['secid']; unset($data['secid']); if ($page_stack[0]['redirect']) $data['redirect_id'] = $ID; $event->result = "<div class='secedit editbutton_" . $data['target'] . " editbutton_" . $secid . "'>" . html_btn('secedit', $page_stack[0]['id'], '', array_merge(array('do' => 'edit', 'rev' => $page_stack[0]['rev'], 'summary' => '['.$name.'] '), $data), 'post', $name) . '</div>'; } else { $event->result = ''; } } else { return; // return so the event won't be stopped } $event->preventDefault(); $event->stopPropagation(); }
/** * Print one of the buttons * * @author Adrian Lang <*****@*****.**> * @see tpl_get_action */ function tpl_button($type, $return = false) { $data = tpl_get_action($type); if ($data === false) { return false; } elseif (!is_array($data)) { $out = sprintf($data, 'button'); } else { /** * @var string $accesskey * @var string $id * @var string $method * @var array $params */ extract($data); if ($id === '#dokuwiki__top') { $out = html_topbtn(); } else { $out = html_btn($type, $id, $accesskey, $params, $method); } } if ($return) { return $out; } echo $out; return true; }
/** * list old revisions * * @author Andreas Gohr <*****@*****.**> * @author Ben Coburn <*****@*****.**> * @author Kate Arzamastseva <*****@*****.**> */ function html_revisions($first = 0, $media_id = false) { global $ID; global $INFO; global $conf; global $lang; $id = $ID; /* we need to get one additionally log entry to be able to * decide if this is the last page or is there another one. * see html_recent() */ if (!$media_id) { $revisions = getRevisions($ID, $first, $conf['recent'] + 1); } else { $revisions = getRevisions($media_id, $first, $conf['recent'] + 1, 8192, true); $id = $media_id; } if (count($revisions) == 0 && $first != 0) { $first = 0; if (!$media_id) { $revisions = getRevisions($ID, $first, $conf['recent'] + 1); } else { $revisions = getRevisions($media_id, $first, $conf['recent'] + 1, 8192, true); } } $hasNext = false; if (count($revisions) > $conf['recent']) { $hasNext = true; array_pop($revisions); // remove extra log entry } if (!$media_id) { $date = dformat($INFO['lastmod']); } else { $date = dformat(@filemtime(mediaFN($id))); } if (!$media_id) { print p_locale_xhtml('revisions'); } $params = array('id' => 'page__revisions'); if ($media_id) { $params['action'] = media_managerURL(array('image' => $media_id), '&'); } $form = new Doku_Form($params); $form->addElement(form_makeOpenTag('ul')); if (!$media_id) { $exists = $INFO['exists']; } else { $exists = @file_exists(mediaFN($id)); } if ($exists && $first == 0) { if (!$media_id && isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); } else { $form->addElement(form_makeOpenTag('li')); } $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); $form->addElement(form_makeTag('input', array('type' => 'checkbox', 'name' => 'rev2[]', 'value' => 'current'))); $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); $form->addElement($date); $form->addElement(form_makeCloseTag('span')); $form->addElement('<img src="' . DOKU_BASE . 'lib/images/blank.gif" width="15" height="11" alt="" />'); if (!$media_id) { $href = wl($id); } else { $href = media_managerURL(array('image' => $id, 'tab_details' => 'view'), '&'); } $form->addElement(form_makeOpenTag('a', array('class' => 'wikilink1', 'href' => $href))); $form->addElement($id); $form->addElement(form_makeCloseTag('a')); if ($media_id) { $form->addElement(form_makeOpenTag('div')); } if (!$media_id) { $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); $form->addElement(' – '); $form->addElement(htmlspecialchars($INFO['sum'])); $form->addElement(form_makeCloseTag('span')); } $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); if (!$media_id) { $editor = $INFO['editor']; } else { $revinfo = getRevisionInfo($id, @filemtime(fullpath(mediaFN($id))), 1024, true); if ($revinfo['user']) { $editor = $revinfo['user']; } else { $editor = $revinfo['ip']; } } $form->addElement(empty($editor) ? '(' . $lang['external_edit'] . ')' : editorinfo($editor)); $form->addElement(form_makeCloseTag('span')); $form->addElement('(' . $lang['current'] . ')'); if ($media_id) { $form->addElement(form_makeCloseTag('div')); } $form->addElement(form_makeCloseTag('div')); $form->addElement(form_makeCloseTag('li')); } foreach ($revisions as $rev) { $date = dformat($rev); if (!$media_id) { $info = getRevisionInfo($id, $rev, true); $exists = page_exists($id, $rev); } else { $info = getRevisionInfo($id, $rev, true, true); $exists = @file_exists(mediaFN($id, $rev)); } if ($info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); } else { $form->addElement(form_makeOpenTag('li')); } $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); if ($exists) { $form->addElement(form_makeTag('input', array('type' => 'checkbox', 'name' => 'rev2[]', 'value' => $rev))); } else { $form->addElement('<img src="' . DOKU_BASE . 'lib/images/blank.gif" width="15" height="11" alt="" />'); } $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); $form->addElement($date); $form->addElement(form_makeCloseTag('span')); if ($exists) { if (!$media_id) { $href = wl($id, "rev={$rev},do=diff", false, '&'); } else { $href = media_managerURL(array('image' => $id, 'rev' => $rev, 'mediado' => 'diff'), '&'); } $form->addElement(form_makeOpenTag('a', array('href' => $href, 'class' => 'diff_link'))); $form->addElement(form_makeTag('img', array('src' => DOKU_BASE . 'lib/images/diff.png', 'width' => 15, 'height' => 11, 'title' => $lang['diff'], 'alt' => $lang['diff']))); $form->addElement(form_makeCloseTag('a')); if (!$media_id) { $href = wl($id, "rev={$rev}", false, '&'); } else { $href = media_managerURL(array('image' => $id, 'tab_details' => 'view', 'rev' => $rev), '&'); } $form->addElement(form_makeOpenTag('a', array('href' => $href, 'class' => 'wikilink1'))); $form->addElement($id); $form->addElement(form_makeCloseTag('a')); } else { $form->addElement('<img src="' . DOKU_BASE . 'lib/images/blank.gif" width="15" height="11" alt="" />'); $form->addElement($id); } if ($media_id) { $form->addElement(form_makeOpenTag('div')); } if ($info['sum']) { $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); if (!$media_id) { $form->addElement(' – '); } $form->addElement(htmlspecialchars($info['sum'])); $form->addElement(form_makeCloseTag('span')); } $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); if ($info['user']) { $form->addElement(editorinfo($info['user'])); if (auth_ismanager()) { $form->addElement(' (' . $info['ip'] . ')'); } } else { $form->addElement($info['ip']); } $form->addElement(form_makeCloseTag('span')); if ($media_id) { $form->addElement(form_makeCloseTag('div')); } $form->addElement(form_makeCloseTag('div')); $form->addElement(form_makeCloseTag('li')); } $form->addElement(form_makeCloseTag('ul')); if (!$media_id) { $form->addElement(form_makeButton('submit', 'diff', $lang['diff2'])); } else { $form->addHidden('mediado', 'diff'); $form->addElement(form_makeButton('submit', '', $lang['diff2'])); } html_form('revisions', $form); print '<div class="pagenav">'; $last = $first + $conf['recent']; if ($first > 0) { $first -= $conf['recent']; if ($first < 0) { $first = 0; } print '<div class="pagenav-prev">'; if ($media_id) { print html_btn('newer', $media_id, "p", media_managerURL(array('first' => $first), '&', false, true)); } else { print html_btn('newer', $id, "p", array('do' => 'revisions', 'first' => $first)); } print '</div>'; } if ($hasNext) { print '<div class="pagenav-next">'; if ($media_id) { print html_btn('older', $media_id, "n", media_managerURL(array('first' => $last), '&', false, true)); } else { print html_btn('older', $id, "n", array('do' => 'revisions', 'first' => $last)); } print '</div>'; } print '</div>'; }
/** * Display an edit button for the included page */ function _editButton($data) { $ret = ''; if (!isset($data['perm'])) { $data['perm'] = auth_quickaclcheck($data['id']); } if ($data['exists']) { if ($data['perm'] >= AUTH_EDIT && is_writable($data['filepath'])) { $ret = '<div class="secedit">' . html_btn('edit', $data['id'], '', array('do' => 'edit'), 'post') . '</div>'; } } elseif ($data['perm'] >= AUTH_CREATE) { $ret = '<div class="secedit">' . html_btn('create', $data['id'], '', array('do' => 'edit'), 'post') . '</div>'; } return $ret; }