/** * 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; } }
/** * 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; }
/** * 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; }