DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:autostartpage

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:autostartpage [2014-01-21 09:22] – How to trigger io_wikipage_write StefanLplugin:autostartpage [2020-04-14 14:51] (current) – fix for php7 error flexjoly
Line 1: Line 1:
-====== autostartpage Plugin ======+====== AutoStartPage Plugin ======
  
 ---- plugin ---- ---- plugin ----
Line 6: Line 6:
 email      : charles@rabidaudio.com email      : charles@rabidaudio.com
 type       : action type       : action
-lastupdate : 2013-07-19 +lastupdate : 2015-01-02 
-compatible : weatherwax+compatible : hrun, weatherwax, elenor of tsort, detritus, frusterick manners
 depends    :  depends    : 
 conflicts  conflicts 
Line 24: Line 24:
 ===== Installation ===== ===== Installation =====
  
-Install the plugin using the [[plugin:plugin|Plugin Manager]] and the download URL above, which points to latest version of the plugin. Refer to [[:Plugins]] on how to install plugins manually.+Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
  
 ===== Usage ===== ===== Usage =====
Line 31: Line 31:
  
 This functions a little differently from [[:namespace_templates|page templates]], as it actually creates the page instead of autofilling the edit window when you go to create the page. Thus, the two features should be compatible.  This functions a little differently from [[:namespace_templates|page templates]], as it actually creates the page instead of autofilling the edit window when you go to create the page. Thus, the two features should be compatible. 
 +
 +Note that creating top-level pages doesn't call ''IO_NAMESPACE_CREATED'', even if no other pages exist. You'll have to make the top-level one by hand.
  
 ==== A note about permissions ==== ==== A note about permissions ====
  
-These pages are created by the server, //not// the current user, so they will show up in revision history without a creator. This also means start pages will be created even if the initiator doesn't have permissions. For example: ''usera'' has read permissions on the namespace ''parent'' but full permissions on ''parent:child'', however, neither of those namespaces exist yet (maybe permissions were set in advance or all the pages in those spaces had been deleted)When ''usera'' adds the first page into parent:child, both the ''parent:child:start'' page and the ''parent:start'' page will be created (even though ''usera'' doesn't have permission to create ''parent:start''). This is seen as a featurenot bug. For one, permissions generally won't be set on namespaces that don't yet exist, so rarely this will be an issue. Furthermore, if your start pages are going to be navigational, it means they will be created, so someone with higher permissions won't have to come back later and add them+As of the most recent update, these pages are created by the user who created the first page in the namespace. **If the user does not have permissions to create the start page, it will not be created.** This can be overridden in the settingsbut introduces security risk.
  
 ===== Syntax ===== ===== Syntax =====
Line 54: Line 56:
 ^ @DATE@   | date and time when edit session started                                                | ^ @DATE@   | date and time when edit session started                                                |
  
-I've added a few more for namespaces: +I've added a few more custom ones:
- +
-^ @!NS@    | namespace of the page (with spaces) but with the first character uppercased            | +
-^ @!!NS@   | same as above but with the first character of all words uppercased                     | +
-^ @!!NS!@  | same as above but with all characters uppercased                                       |+
  
 +^ @!NS@            | namespace of the page (with spaces) but with the first character uppercased            |
 +^ @!!NS@           | same as above but with the first character of all words uppercased                     |
 +^ @!!NS!@          | same as above but with all characters uppercased                                       |
 +^ @PARENT@         | the name of the parent namespace. Blank if parent is top                               |
 +^ @DATE=STRFTIME@  | Where ''STRFTIME'' is a ''[[http://php.net/manual/en/function.strftime.php|strftime()]]'' configure string of page creation time, e.g. ''%a %d-%m-%y'' => ''Thu 06-12-12''       |
  
 ===== Configuration ===== ===== Configuration =====
Line 73: Line 76:
   * **2013-07-19**   * **2013-07-19**
     * Initial release     * Initial release
 +  * **2015-01-02**
 +    * New shortcut: ''@DATE=STRFTIME@''
 +    * New shortcut: ''@PARENT@''
 +    * Pages now are created as user
 +    * Added force create option
 +    * Fixed constantly outdated issue
 +    * Other minor fixes
  
 === ToDo/Wish List === === ToDo/Wish List ===
  
-  * I plan to add support for strftime dates like [[:namespace_templates#replacement_patterns|namespace templates]]+  * <del>I plan to add support for strftime dates like [[:namespace_templates#replacement_patterns|namespace templates]]</del> done
   * I also want to be able to have different templates for different namespaces   * I also want to be able to have different templates for different namespaces
-  * Could you also add support for the parent namespace? That way you could make a navigation page that automatically links to the previous namespace.+  * <del>Could you also add support for the parent namespace? That way you could make a navigation page that automatically links to the previous namespace.</del> done
  
 ===== Discussion ===== ===== Discussion =====
 +
 +**Update for php7** \\
 +Hi, (I hope I do this right) \\
 +The plugin has a minor error with php7 and a pull-request is open for some year now. So I made a fork and committed the  [[https://github.com/rabidaudio/dokuwiki-plugin-autostartpage/pull/2#issue-57976936|proposed change by splitbrain]]. It worked for me. Here you can find [[https://github.com/flexjoly/dokuwiki-plugin-autostartpage|the new fork]]. Greetz,  --- [[user>flexjoly|flexjoly]] //2020-04-14 14:48//
 +
  
 Registers as [[:devel:event:io_namespace_created|IO_NAMESPACE_CREATED]]. Registers as [[:devel:event:io_namespace_created|IO_NAMESPACE_CREATED]].
Line 91: Line 106:
 > which triggers that event... > which triggers that event...
 > Greetings  --- [[user>StefanL|StefanL]] //2014/01/21 09:16// > Greetings  --- [[user>StefanL|StefanL]] //2014/01/21 09:16//
 +>> Hi Stefan, thanks for the suggestion. I'm not sure why I didn't do that in the first place.
 +>> It's been fixed now, and the docs have been updated. Cheers, [[user>charlesjuliank|charlesjuliank]] //2015/01/02 11:27//
 +
 +On "frusterick manners", you have to create 2 new namespaces for this plugin to work. But after that, it's fine
 + --- [[user>redge76|redge76]] //2018-01-15 09:53//
 +
 +
 +**excellent - very useful plugin**
 +I notice you comment that one of the todo's is the ability to have different start page templates for different places.
 +
 +well - I wanted that too - so made a few minor amendments - code is hopefully self explanatory - happy if you want to include these changes or if others want to do a similar mod - I am just using a local edit of the plugin on my system - works nice! (also removed a couple of &s so that it would work on php 7.1)
  
 +  .
 +  .
 +  .
 +  .
 +    public function autostartpage_handle(Doku_Event $event, $param) {
 +        global $conf;
 +        global $INFO;
 +        $ns=$event->data[0];       //namespace that has just been created
 +        
 +        $passed_template = $this->getConf('templatefile');   // the template that is set in the configuration
 +        $templatefile = wikiFN($this->getConf('templatefile'), '', false);   //get the filename for the template
 +        
 +        if (substr_count($passed_template, ":") === 0) {        //no namespace specified in configuration so climb the hierarchy        
 +  /*
 +  This if statement checks to see whether the start page template set in the configuration manager includes a ":"
 +  If it does then this is an absolute startpage template to be used for all new namespaces and the logic progresses as per original plugin
 +  If there is no ":" then the stored value is taken to be the startpage template and is sought within the current namespace structure
 +  first the newly created namespace's parent is checked for a template - if found that is used and we break to the next block of code
 +  if the parent doesnt contain a template then the grandparent is checked by moving the current parent to the temp namespace name
 +  and we go round the loop again. Processing continues till we hit the top level folder.
 +  */
 +    $instance = substr_count($ns, ":") ;                 // how many levels of namespace?
 +     $ns_sepchar = ":";
 + $ns_temp = $ns;
 +            
 +            do {
 +             $parent=implode($ns_sepchar, array_splice(preg_split("/".preg_quote($ns_sepchar, "/")."/", $ns_temp), 0, -1));
 +            $parent_template = $parent .":"  .$passed_template;        
 +            $parent_templatefile = wikiFN($parent_template, '', false);   //get the filename for the parent template       
 +            if(@file_exists($parent_templatefile)){
 +            $wikitext=io_readFile($parent_templatefile);
 +            break;
 +        }  else {
 +        $ns_temp = $parent ;
 +        --$instance;
 +        }
 +        }
 +        while ($instance > 0);
 +       
 +        } else { 
 +        if(@file_exists($templatefile)){
 +            $wikitext=io_readFile($templatefile);
 +        }
 + }
 +  /*
 +      NO FURTHER CHANGES AFTER HERE
 +  */
 +        $ns_type=$event->data[1];
 +        if($ns_type === "pages" && $wikitext){
plugin/autostartpage.1390292543.txt.gz · Last modified: 2014-01-21 09:22 by StefanL

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki