Changed template stuff

Patern on [templatepath] option was preventing to change the path. Also
renamed _template.txt to _template_private.txt and changed code
accordingly.
This commit is contained in:
Simon DELAGE 2014-09-01 15:57:34 +02:00
parent 4bfeddd685
commit 75232deb62
5 changed files with 9 additions and 9 deletions

View file

@ -1 +0,0 @@
====== @NAME@ (@USER@) ======

1
_template_private.txt Normal file
View file

@ -0,0 +1 @@
====== @NAME@ (@USER@) - Private Namespace ======

View file

@ -16,7 +16,7 @@ require_once (DOKU_PLUGIN . '/acl/admin.php');
class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
function register(&$controller) {
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'redirect',array());
$controller->register_hook('HTML_PAGE_FROMTEMPLATE', 'BEFORE', $this, 'page_template',array());
// $controller->register_hook('HTML_PAGE_FROMTEMPLATE', 'BEFORE', $this, 'page_template',array());
}
function redirect(&$event, $param) {
global $conf;
@ -44,9 +44,9 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
// Write things back to conf/acl.auth.php
file_put_contents(DOKU_INC.'conf/acl.auth.php', implode($lines));
if (!$this->getConf('edit_before_create')) {
//writes the user info to page
//writes the user info to private page
lock($id);
saveWikiText($id,$this->_template(),$lang['created']);
saveWikiText($id,$this->_template_private(),$lang['created']);
unlock($id);
}
// redirect to edit home page
@ -72,7 +72,7 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
require_once (DOKU_INC.'inc/search.php');
if($_SERVER['REMOTE_USER']!=null) {
$this->doku_page_path = $conf['datadir'];
$this->home_page_template = DOKU_INC . $this->getConf('templatepath');
$this->private_page_template = DOKU_INC . $this->getConf('templatepath');
if ($this->getConf('group_by_name')) {
// private:s:simon
$this->home_wiki_ns = cleanID($this->getConf('users_namespace').':'.strtolower(substr($this->homeNamespace(), 0, 1)).':'. $this->homeNamespace());
@ -103,9 +103,9 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
return $this->homeNamespace();
}
}
function _template() {
function _template_private() {
global $INFO;
$content = io_readFile($this->home_page_template, false);
$content = io_readFile($this->private_page_template, false);
$name = $INFO['userinfo']['name'];
$user = strtolower($_SERVER['REMOTE_USER']);
$content = str_replace('@NAME@',$name,$content);

View file

@ -12,5 +12,5 @@ $conf['users_namespace'] = 'private';
$conf['set_permissions'] = 1;
$conf['set_permissions_others'] = '0';
$conf['group_by_name'] = 1;
$conf['templatepath'] = 'lib/plugins/userhomepage/_template.txt';
$conf['templatepath'] = 'lib/plugins/userhomepage/_template_private.txt';
$conf['edit_before_create'] = 0;

View file

@ -12,5 +12,5 @@ $meta['users_namespace'] = array('string','_pattern' => '/^(|[a-zA-Z\-:]+)$/');
$meta['set_permissions'] = array('onoff');
$meta['set_permissions_others'] = array('multichoice','_choices'=>array('0','1','2','4','8','16'));
$meta['group_by_name'] = array('onoff');
$meta['templatepath'] = array('string','_pattern' => '/^(|[a-zA-Z\-]+)$/');
$meta['templatepath'] = array('string');
$meta['edit_before_create'] = array('onoff');