Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial checkin

  • Loading branch information...
commit d18285dff996143570fe270a3e4fc55d643ca77a 0 parents
@splitbrain splitbrain authored
55 action.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author Andreas Gohr <gohr@cosmocode.de>
+ */
+if(!defined('DOKU_INC')) die();
+
+if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
+require_once(DOKU_PLUGIN.'action.php');
+
+/**
+ * All DokuWiki plugins to extend the parser/rendering mechanism
+ * need to inherit from this class
+ */
+class action_plugin_oiddelegate extends DokuWiki_Action_Plugin {
+
+ /**
+ * return some info
+ */
+ function getInfo() {
+ return confToHash(dirname(__FILE__).'/info.txt');
+ }
+
+ function register(&$controller) {
+ $controller->register_hook('TPL_METAHEADER_OUTPUT','BEFORE', $this, 'handle_metaheader');
+ }
+
+ function handle_metaheader(&$event, $param) {
+ global $ACT;
+ global $ID;
+ if($ACT != 'show') return true;
+
+ // read delegate setups from config
+ $delegates = confToHash(DOKU_CONF.'openid-delegates.conf');
+ $delegate = $delegates[$ID]; // check delegate for current page
+ if(!$delegate) $delegate = $delegates['*']; // fall back to default if any
+ if(!$delegate) return true;
+
+ list($oid,$server) = preg_split('/\s+/',$delegate,2);
+ $oid = trim($oid);
+ $server = trim($server);
+ if(!$server) $server = $oid;
+
+ $event->data['link'][] = array(
+ 'rel' => 'openid.server',
+ 'href' => $server,
+ );
+ $event->data['link'][] = array(
+ 'rel' => 'openid.delegate',
+ 'href' => $oid,
+ );
+
+ return true;
+ }
+}
109 admin.php
@@ -0,0 +1,109 @@
+<?php
+// must be run within Dokuwiki
+if(!defined('DOKU_INC')) die();
+
+if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
+require_once(DOKU_PLUGIN.'admin.php');
+require_once(DOKU_INC.'inc/changelog.php');
+
+/**
+ * All DokuWiki plugins to extend the admin function
+ * need to inherit from this class
+ */
+class admin_plugin_oiddelegate extends DokuWiki_Admin_Plugin {
+
+ /**
+ * return some info
+ */
+ function getInfo(){
+ return confToHash(dirname(__FILE__).'/info.txt');
+ }
+
+
+ /**
+ * return sort order for position in admin menu
+ */
+ function getMenuSort() {
+ return 80;
+ }
+
+ /**
+ * handle user request
+ */
+ function handle() {
+ if(!is_array($_REQUEST['oiddel'])) return;
+
+ // prepare new config file
+ $data = "# OpenID Delegation Setup\n\n";
+ foreach($_REQUEST['oiddel'] as $line){
+ $line = array_map('trim',$line);
+ // make sure OpenIDs and servers are given as full qualified URLs
+ if($line[1] && !preg_match('#^https?://#',$line[1])){
+ $line[1] = 'http://'.$line[1];
+ }
+ if($line[2] && !preg_match('#^https?://#',$line[2])){
+ $line[2] = 'http://'.$line[2];
+ }
+
+ $data .= join("\t",$line)."\n";
+ }
+
+ //save it
+ if(io_saveFile(DOKU_CONF.'openid-delegates.conf',$data)){
+ msg($this->getLang('saved'),1);
+ }
+ }
+
+ /**
+ * output appropriate html
+ */
+ function html() {
+ global $lang;
+
+ echo $this->plugin_locale_xhtml('intro');
+
+
+ echo '<form action="" method="post">';
+ echo '<table class="inline" id="openid__delegates">';
+
+ echo '<tr>';
+ echo '<th width="20%">'.$this->getLang('page').'</th>';
+ echo '<th width="40%">'.$this->getLang('oid').'</th>';
+ echo '<th width="40%">'.$this->getLang('server').'</th>';
+ echo '</tr>';
+
+ $delegates = confToHash(DOKU_CONF.'openid-delegates.conf');
+ ksort($delegates);
+ $row = 0;
+ foreach($delegates as $page => $delegate){
+ list($oid,$server) = preg_split('/\s+/',$delegate,2);
+ $oid = trim($oid);
+ $server = trim($server);
+
+ echo '<tr>';
+ echo '<td><input type="text" class="edit" name="oiddel['.$row.'][0]" value="'.hsc($page).'" /></td>';
+ echo '<td><input type="text" class="edit" name="oiddel['.$row.'][1]" value="'.hsc($oid).'" /></td>';
+ echo '<td><input type="text" class="edit" name="oiddel['.$row.'][2]" value="'.hsc($server).'" /></td>';
+ echo '</tr>';
+
+ $row++;
+ }
+ echo '<tr>';
+ echo '<td><input type="text" class="edit" name="oiddel['.$row.'][0]" value="" /></td>';
+ echo '<td><input type="text" class="edit" name="oiddel['.$row.'][1]" value="" /></td>';
+ echo '<td><input type="text" class="edit" name="oiddel['.$row.'][2]" value="" /></td>';
+ echo '</tr>';
+
+ echo '<tr>';
+ echo '<th colspan="3" align="center">';
+ echo '<input type="submit" value="'.$this->getLang('submit').'" class="button" />';
+ echo '</th>';
+ echo '</tr>';
+
+ echo '</table>';
+ echo '</form>';
+ }
+
+
+}
+//Setup VIM: ex: et ts=4 enc=utf-8 :
8 info.txt
@@ -0,0 +1,8 @@
+# General Plugin Info do not edit
+
+author Andreas Gohr
+email gohr@cosmocode.de
+date 2009-10-06
+name OpenID Delegation Plugin
+desc Add OpenID delegation headers to all or specific pages in your wiki.
+url http://www.dokuwiki.org/plugin:oiddelegate
5 lang/en/intro.txt
@@ -0,0 +1,5 @@
+====== OpenID Delegation Setup ======
+
+Here you can setup OpenID [[http://openid.net/specs/openid-authentication-1_1.html#delegating_authentication|delegation headers]] for certain wiki pages. You may use the ''*'' character as page name to setup a wiki wide default delegate.
+
+Your configuration is written to ''conf/openid-delegates.conf'', so make sure this file is writable.
9 lang/en/lang.php
@@ -0,0 +1,9 @@
+<?php
+
+$lang['menu'] = 'OpenID Delegation Setup';
+
+$lang['submit'] = 'Save Setup';
+$lang['saved'] = 'Delegation setup saved successfully.';
+$lang['page'] = 'Page';
+$lang['oid'] = 'The OpenID aka. the Delegate';
+$lang['server'] = 'The OpenID Server (empty for same as OpenID)';
3  style.css
@@ -0,0 +1,3 @@
+table#openid__delegates input.edit {
+ width: 95%;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.