Improved helper
Can now provide different types of link to private namespace or public page
This commit is contained in:
parent
55add7eb37
commit
9f825ed647
54
helper.php
54
helper.php
|
@ -11,23 +11,47 @@ if(!defined('DOKU_INC')) die();
|
|||
|
||||
class helper_plugin_userhomepage extends DokuWiki_Plugin {
|
||||
|
||||
function getPrivateNs() {
|
||||
function getPrivateID() {
|
||||
if ($this->getConf('group_by_name')) {
|
||||
// private:s:simon
|
||||
// private:s:simon or private:s:simon_delage
|
||||
$this->private_ns = cleanID($this->getConf('users_namespace').':'.strtolower(substr($this->privateNamespace(), 0, 1)).':'. $this->privateNamespace());
|
||||
} else {
|
||||
// private:simon
|
||||
// private:simon or private:simon_delage
|
||||
$this->private_ns = cleanID($this->getConf('users_namespace').':'. $this->privateNamespace());
|
||||
}
|
||||
// private:simon:start.txt
|
||||
return $this->private_page = cleanID($this->private_ns . ':' . $this->privatePage());
|
||||
// ...:start.txt
|
||||
return $this->private_page = cleanID($this->private_ns.':'.$this->privateStart());
|
||||
|
||||
}
|
||||
|
||||
function getPublicPage() {
|
||||
function getPublicID() {
|
||||
return $this->public_page = cleanID($this->getConf('public_pages_ns').':'. $_SERVER['REMOTE_USER']);
|
||||
}
|
||||
|
||||
function getPrivateLink($param=null) {
|
||||
global $INFO;
|
||||
global $lang;
|
||||
if ($param == "loggedinas") {
|
||||
return '<li>'.$lang['loggedinas'].' : <a href="'.wl($this->getPrivateID()).'" class="uhp_private" rel="nofollow" title="'.$this->getLang('privatenamespace').'">'.$INFO['userinfo']['name'].' ('.$_SERVER['REMOTE_USER'].')</a></li>';
|
||||
} elseif ($param != null) {
|
||||
return '<a href="'.wl($this->getPrivateID()).'" rel="nofollow" title="'.$this->getLang('privatenamespace').'">'.$param.'</a>';
|
||||
} else {
|
||||
return '<a href="'.wl($this->getPrivateID()).'" rel="nofollow" title="'.$this->getLang('privatenamespace').'">'.$this->getLang('privatenamespace').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
function getPublicLink($param=null) {
|
||||
global $INFO;
|
||||
global $lang;
|
||||
if ($param == "loggedinas") {
|
||||
return '<li>'.$lang['loggedinas'].' : <a href="'.wl($this->getPublicID()).'" class="uhp_public" rel="nofollow" title="'.$this->getLang('publicpage').'">'.$INFO['userinfo']['name'].' ('.$_SERVER['REMOTE_USER'].')</a></li>';
|
||||
} elseif ($param != null) {
|
||||
return '<a href="'.wl($this->getPublicID()).'" rel="nofollow" title="'.$this->getLang('publicpage').'">'.$param.'</a>';
|
||||
} else {
|
||||
return '<a href="'.wl($this->getPublicID()).'" rel="nofollow" title="'.$this->getLang('publicpage').'">'.$this->getLang('publicpage').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
function privateNamespace() {
|
||||
if ( $this->getConf('use_name_string')) {
|
||||
global $INFO;
|
||||
|
@ -40,7 +64,7 @@ class helper_plugin_userhomepage extends DokuWiki_Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
function privatePage() {
|
||||
function privateStart() {
|
||||
if ( $this->getConf('use_start_page')) {
|
||||
global $conf;
|
||||
return $conf['start'];
|
||||
|
@ -49,20 +73,4 @@ class helper_plugin_userhomepage extends DokuWiki_Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
// //draws a home button, used by calls from main.php in template folder
|
||||
// function homeButton() {
|
||||
// $this->init();
|
||||
// if ($_SERVER['REMOTE_USER']!=null) {
|
||||
// echo '<form class="button btn_show" method="post" action="doku.php?id='.$this->private_page.'"><input class="button" type="submit" value="Home"/></form>';
|
||||
// }
|
||||
// }
|
||||
// //draws a home link, used by calls from main.php in template folder
|
||||
// function privateLink() {
|
||||
// $this->init();
|
||||
// if ($_SERVER['REMOTE_USER']!=null) {
|
||||
// echo '<li>'.$lang['loggedinas'].' : <a href="'.wl($privatens).'" class="iw_user" rel="nofollow" title="Private NS">'.$INFO['userinfo']['name'].' ('.$_SERVER['REMOTE_USER'].')</a></li>';
|
||||
// echo '<a href="doku.php?id='.$this->private_page.'">Home</a>';
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 792 B |
Binary file not shown.
After Width: | Height: | Size: 742 B |
|
@ -6,3 +6,5 @@
|
|||
*/
|
||||
|
||||
$lang['created'] = 'Created from template by Userhompage plugin';
|
||||
$lang['privatenamespace'] = 'Private Namespace';
|
||||
$lang['publicpage'] = 'Public Page';
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
/********************************************************************
|
||||
Screen Styles for the Userhomepage Plugin (additional to all.css)
|
||||
********************************************************************/
|
||||
|
||||
a.uhp_private,a.uhp_public { padding-left:19px; }
|
||||
a.uhp_private { background:url(images/ns.png) no-repeat left; }
|
||||
a.uhp_public { background:url(images/user.png) no-repeat left; }
|
Loading…
Reference in New Issue