*/ // must be run within Dokuwiki if (!defined('DOKU_INC')) die(); class helper_plugin_npd extends DokuWiki_Plugin { function getInfo() { return confToHash(dirname(__FILE__).'/plugin.info.txt'); } function getMethods() { $result = array(); $result[] = array( 'name' => 'html_new_page_button', 'desc' => 'include a html button', 'params' => array(), 'return' => array() ); return $result; } /** * Create the HTML for the new page button * * If $return is set to FALSE, will directly echo the HTML * * @param bool $return * @return string */ public function html_new_page_button($return = false) { $ret = ''; global $conf; global $ID; // Don't show the button if the user doesn't have edit permissions if(auth_quickaclcheck($ID) < AUTH_EDIT) { return ''; } $label = $this->getLang('btn_create_new_page'); if (!$label) { // Translation not found $label = 'Create New Page'; } $tip = htmlspecialchars($label); // Filter id (without urlencoding) $id = idfilter($ID, false); // Make nice URLs even for buttons if($conf['userewrite'] == 2){ $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id . "?"; }elseif($conf['userewrite']){ $script = DOKU_BASE.$id."?"; }else{ $script = DOKU_BASE.DOKU_SCRIPT . "?"; $params['id'] = $id; } $params['idx'] = ":" . getNS($ID); $params['npd'] = 1; $url = $script; if(is_array($params)){ reset($params); while (list($key, $val) = each($params)) { $url .= $key.'='; $url .= htmlspecialchars($val.'&'); } } $link_type = $this->getConf('link_type'); switch ($link_type) { case 'link': $ret .= ''; break; case 'button': default: $ret .= '
'; $ret .= '