DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:actionlink

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:actionlink [2010-12-22 13:07] – [subscribe-unsubscribe link] 82.140.120.164plugin:actionlink [2023-10-31 00:30] (current) Klap-in
Line 1: Line 1:
-====== Actionlink plugin ======+====== Actionlink Plugin ======
  
 ---- plugin ---- ---- plugin ----
Line 6: Line 6:
 email      : nowotnypl@gmail.com email      : nowotnypl@gmail.com
 type       : syntax type       : syntax
-lastupdate : 2006-05-26 +lastupdate : 2018-02-04 
-compatible :+compatible : Anteater, Rincewind, Angua, Adora Belle, Weatherwax, Binky, Ponder Stibbons, Hrun, Detritus, Elenor of Tsort, Frusterick Manners
 depends    : depends    :
 conflicts  : conflicts  :
 similar    : similar    :
-tags       : links+tags       : links, actions
  
-downloadurl: http://mbot.ovh.org/plugin-actionlink-2005-05-26.zip +downloadurl: https://github.com/chang-zhao/actionlink/archive/master.zip 
-bugtracker :  +bugtracker : https://github.com/chang-zhao/actionlink/issues 
-sourcerepo : +sourcerepo : https://github.com/chang-zhao/actionlink
 donationurl:  donationurl: 
 ---- ----
  
 +----
  
 +| **Not compatible with PHP 8.1** \\ Error message: \\ 2023-03-24 06:34:37dokuwiki\Exception\FatalException: Array and string offset access syntax with curly braces is no longer supported \\ /.../lib/plugins/actionlink/syntax.php(179) \\ **Workaround:** Use [[:tips:links-to-dokuwiki-commands|Links to DokuWiki commands]] instead.   |
 +
 +
 +----
 +
 +:!: When building actionlinks for 'admin', 'login' etc. don't forget %%~~NOCACHE~~%%
  
 ===== Syntax ===== ===== Syntax =====
Line 28: Line 35:
   * history - old revisions   * history - old revisions
   * recent  - recent changes   * recent  - recent changes
 +  * :recent, /recent - recent changes from the root namespace
   * login   - login/logout - if ACL enabled   * login   - login/logout - if ACL enabled
   * index   - the index   * index   - the index
Line 34: Line 42:
   * back    - a 'back to parent' link - if available   * back    - a 'back to parent' link - if available
   * backlink - list of backlinks   * backlink - list of backlinks
-\\+  * search  - focus on the search field 
 +  * purge 
 +  * subscribe 
 +  * addtobook 
 +  * cite 
 +  * infomail 
 +  * export_odt 
 +  * export_pdf 
 + 
 +(Of course, for these last commands to work, those plugins should be installed.) 
 The **title** element is optional. It lets you specify a custom string to be used instead of the default 'Edit this page', 'Old revisions', 'Recent changes', etc.  The **title** element is optional. It lets you specify a custom string to be used instead of the default 'Edit this page', 'Old revisions', 'Recent changes', etc. 
  
Line 50: Line 68:
  
 ===== Installation ===== ===== Installation =====
-You can install this plugin using the [[plugin:plugin|plugin manager]].\\ +Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually. 
-\\ + 
-Sources: [[http://mbot.ovh.org/plugin-actionlink-2005-05-26.tar.gz|plugin-actionlink-2005-05-26.tar.gz(2kb)]] | [[http://mbot.ovh.org/plugin-actionlink-2005-05-26.zip|plugin-actionlink-2005-05-26.zip(2kb)]]+ 
 +Sources: <del>[[http://mbot.ovh.org/plugin-actionlink-2005-05-26.tar.gz|plugin-actionlink-2005-05-26.tar.gz(2kb)]] | [[http://mbot.ovh.org/plugin-actionlink-2005-05-26.zip|plugin-actionlink-2005-05-26.zip(2kb)]]</del> https://github.com/chang-zhao/actionlink
  
-To install manually: create a folder ''actionlink'' in ''lib/plugins'' and put the code below in ''syntax.php''.+To install manually: create a folder ''actionlink'' in ''lib/plugins'' and put the code <del>below</del> in ''syntax.php''The last version see here: https://github.com/chang-zhao/actionlink/blob/master/syntax.php
 <code php><?php <code php><?php
 /** /**
Line 192: Line 211:
  $renderer->doc .=$this->tpll_link(wl($ID,'do=backlink'),$title, 'class="action backlink"');  $renderer->doc .=$this->tpll_link(wl($ID,'do=backlink'),$title, 'class="action backlink"');
  return true;   return true;
 + default:
 + if(!isset($title)) $title='';
 + $renderer->doc .= $title;
 + return true;
 + }
 +        }
 +        return false;
 +    }
 + function tpll_link($url,$name,$more=''){
 + $link='<a href="'.$url.'" ';
 + if ($more) $link.=' '.$more;
 + $link.=">$name</a>";
 + return $link;
 +}
 +}
 + 
 +//Setup VIM: ex: et ts=4 enc=utf-8 :
 +</code>
 +
 +extended version with some plugins:
 +
 +<code php>
 +<?php
 +/**
 + * Action link plugin. Lets you use action links in your wiki syntax.
 + * Based on the core function - tpl_actionlink().
 + *
 + * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 + * @author Andreas Gohr <andi@splitbrain.org>
 + * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
 + * @author nowotny <nowotnypl@gmail.com>
 + */
 + 
 +if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
 +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
 +require_once(DOKU_PLUGIN.'syntax.php');
 +require_once(DOKU_INC.'inc/template.php'); //mod
 + 
 +class syntax_plugin_actionlink extends DokuWiki_Syntax_Plugin {
 + 
 +    function getInfo(){
 +        return array(
 +            'author' => 'nowotny',
 +            'email'  => 'nowotnypl@gmail.com',
 +            'date'   => '2006-05-26',
 +            'name'   => 'Actionlink plugin',
 +            'desc'   => 'Actionlink plugin lets you use action links in your wiki syntax.
 +            Basic syntax: {{actionlink>action|title}}',
 +            'url'    => 'http://wiki.splitbrain.org/plugin:actionlink',
 +        );
 +    }
 + 
 +    function getType(){
 +        return 'substition';
 +    }
 + 
 +    function getSort(){
 +        return 306;
 +    }
 + 
 +    function connectTo($mode) {
 +      $this->Lexer->addSpecialPattern('\{\{actionlink>.+?\}\}',$mode,'plugin_actionlink');
 +    }
 +
 +    function handle($match, $state, $pos, &$handler){
 + $match = substr($match,13, -2);
 + $matches=explode('|', $match, 2);
 + return array('action'=>hsc($matches[0]),'title'=>hsc($matches[1]));
 +    }
 + 
 +    function render($mode, &$renderer, $data){
 + if($mode == 'xhtml'){
 +
 + if(!empty($data['action'])) $action=$data['action'];
 + else $action='';
 + if(!empty($data['title'])) $title=$data['title'];
 +
 + global $ID;
 + global $INFO;
 + global $REV;
 + global $ACT;
 + global $conf;
 + global $lang;
 + global $auth;
 +
 + switch($action){
 + case 'edit':
 + #most complicated type - we need to decide on current action
 + if($ACT == 'show' || $ACT == 'search'){
 + if($INFO['writable']){
 + if($INFO['exists']){
 + if(!isset($title)) $title=$lang['btn_edit'];
 + $renderer->doc .=$this->tpll_link(wl($ID,'do=edit&amp;rev='.$REV),
 + $title,
 + 'class="action edit" accesskey="e" rel="nofollow"');
 + }else{
 + if(!isset($title)) $title=$lang['btn_create'];
 + $renderer->doc .=$this->tpll_link(wl($ID,'do=edit&amp;rev='.$REV),
 + $title,
 + 'class="action create" accesskey="e" rel="nofollow"');
 + }
 + }else{
 + if(!isset($title)) $title=$lang['btn_source'];
 + $renderer->doc .=$this->tpll_link(wl($ID,'do=edit&amp;rev='.$REV),
 + $title,
 + 'class="action source" accesskey="v" rel="nofollow"');
 + }
 + }else{
 + if(!isset($title)) $title=$lang['btn_show'];
 + $renderer->doc .=$this->tpll_link(wl($ID,'do=show'),
 + $title,
 + 'class="action show" accesskey="v" rel="nofollow"');
 + }
 + return true;
 + case 'history':
 + if(!isset($title)) $title=$lang['btn_revs'];
 + $renderer->doc .=$this->tpll_link(wl($ID,'do=revisions'),$title,'class="action revisions" accesskey="o"');
 + return true;
 + case 'recent':
 + if(!isset($title)) $title=$lang['btn_recent'];
 + $renderer->doc .=$this->tpll_link(wl($ID,'do=recent'),$title,'class="action recent" accesskey="r"');
 + return true;
 + case 'index':
 + if(!isset($title)) $title=$lang['btn_index'];
 + $renderer->doc .=$this->tpll_link(wl($ID,'do=index'),$title,'class="action index" accesskey="x"');
 + return true;
 + case 'top':
 + if(!isset($title)) $title=$lang['btn_top'];
 + $renderer->doc .= '<a href="#dokuwiki__top" class="action top" accesskey="x">'.$title.'</a>';
 + return true;
 + case 'back':
 + if ($ID = tpl_getparent($ID)) {
 + if(!isset($title)) $title=$lang['btn_back'];
 + $renderer->doc .=$this->tpll_link(wl($ID,'do=show'),$title,'class="action back" accesskey="b"');
 + return true;
 + }
 + return false;
 + case 'login':
 + if($conf['useacl']){
 + if($_SERVER['REMOTE_USER']){
 + if(!isset($title)) $title=$lang['btn_logout'];
 + $renderer->doc .=$this->tpll_link(wl($ID,'do=logout'),$title,'class="action logout"');
 + }else{
 + if(!isset($title)) $title=$lang['btn_login'];
 + $renderer->doc .=$this->tpll_link(wl($ID,'do=login'),$title,'class="action logout"');
 + }
 + return true;
 + }
 + return false;
 + case 'admin':
 + if($INFO['perm'] == AUTH_ADMIN){
 + if(!isset($title)) $title=$lang['btn_admin'];
 + $renderer->doc .=$this->tpll_link(wl($ID,'do=admin'),$title,'class="action admin"');
 + return true;
 + }
 + return false;
 + case 'backlink':
 + if(!isset($title)) $title=$lang['btn_backlink'];
 + $renderer->doc .=$this->tpll_link(wl($ID,'do=backlink'),$title, 'class="action backlink"');
 + return true;
 +            case 'purge': // {{actionlink>purge|Purge}}
 +                if(!isset($title)) $title=$lang['btn_purge'];
 +                $renderer->doc .=$this->tpll_link(wl($ID,'purge=true'),$title, 'class="action purge"');
 +                return true;
 + case 'subscribe': //mod
 + if(!isset($title)) $title=$lang['btn_subscribe'];
 + $renderer->doc .=$this->tpll_link(wl($ID, array("do"=>"subscribe"), false, "&"),$title,'class="action subscribe"');
 + return true;
 + case 'addtobook': //mod
 + if(!isset($title)) $title=$lang['btn_addtobook'];
 + $renderer->doc .=$this->tpll_link(wl($ID, array("do"=>"addtobook"), false, "&"),$title,'class="action addtobook"');
 + return true;
 + case 'cite': //mod
 + if(!isset($title)) $title=$lang['btn_cite'];
 + $renderer->doc .=$this->tpll_link(wl($ID, array("do"=>"cite"), false, "&"),$title,'class="action cite"');
 + return true;
 + case 'infomail': //mod
 + if(!isset($title)) $title=$lang['btn_infomail'];
 + $renderer->doc .=$this->tpll_link(wl($ID, array("do"=>"infomail"), false, "&"),$title,'class="action infomail"');
 + return true;
 + case 'export_odt': //mod
 + if(!isset($title)) $title=$lang['btn_export_odt'];
 + $renderer->doc .=$this->tpll_link(wl($ID, array("do"=>"export_odt"), false, "&"),$title,'class="action export_odt"');
 + return true;
 + case 'export_pdf': //mod
 + if(!isset($title)) $title=$lang['btn_export_pdf'];
 + $renderer->doc .=$this->tpll_link(wl($ID, array("do"=>"export_pdf"), false, "&"),$title,'class="action export_pdf"');
 + return true;
  default:  default:
  if(!isset($title)) $title='';  if(!isset($title)) $title='';
Line 299: Line 506:
  
 ===== use NOCACHE ===== ===== use NOCACHE =====
-When builing actionlinks for 'admin', 'login' etc. dont forget\\+When building actionlinks for 'admin', 'login' etc. dont forget\\
 \\ \\
 %%~~NOCACHE~~%%\\ %%~~NOCACHE~~%%\\
plugin/actionlink.1293019621.txt.gz · Last modified: 2010-12-22 13:07 by 82.140.120.164

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