1<?php 2// must be run within Dokuwiki 3if (!defined('DOKU_INC')) die(); 4 5class action_plugin_authfacebook extends DokuWiki_Action_Plugin { 6 /** 7 * Registers the event handlers. 8 */ 9 function register(Doku_Event_Handler $controller) 10 { 11 $controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'hook_html_loginform_output', array()); 12 $controller->register_hook('HTML_UPDATEPROFILEFORM_OUTPUT', 'BEFORE', $this, 'hook_updateprofileform_output', array()); 13 } 14 15 function hook_updateprofileform_output(&$event, $param) { 16 global $USERINFO; 17 if (array_key_exists('is_facebook', $USERINFO) && $USERINFO['is_facebook']) { 18 //print_r($event->data); 19 //$event->data->replaceElement(0, form_makeTextField('fullname', $USERINFO['name'], $lang['fullname'], '', 'block', array('size'=>'50'))); 20 $elem = $event->data->getElementAt(2); 21 $elem['disabled'] = 'disabled'; 22 $event->data->replaceElement(2, $elem); 23 24 $elem = $event->data->getElementAt(3); 25 $elem['disabled'] = 'disabled'; 26 $event->data->replaceElement(3, $elem); 27 28 $event->data->replaceElement(10, null); 29 $event->data->replaceElement(9, null); 30 $event->data->replaceElement(8, null); 31 $event->data->replaceElement(7, null); 32 $event->data->replaceElement(6, null); 33 $event->data->replaceElement(5, null); 34 $event->data->replaceElement(4, null); 35 36 //print_r($event->data); 37 } 38 } 39 40 /** 41 * Handles the login form rendering. 42 */ 43 function hook_html_loginform_output(&$event, $param) { 44 45 //$event->data = null; 46 //echo print_r($event,true); 47 //echo "111"; 48 49 if (isset($_SESSION[DOKU_COOKIE]['authfacebook']['auth_url'])) { 50 $auth_url = $_SESSION[DOKU_COOKIE]['authfacebook']['auth_url']; 51 52 $a_style = "width: 200px;margin:0 auto;color: #666666;cursor: pointer;text-decoration: none !important;display: block;padding-bottom:1.4em;";//-moz-linear-gradient(center top , #F8F8F8, #ECECEC) 53 $div_style = "float:left;line-height: 30px;background-color: #F8F8F8;border: 1px solid #C6C6C6;border-radius: 2px 2px 2px 2px;padding: 0px 5px 0px 5px;position: relative;"; 54 $img_style = "width:42px;height:39px;margin:5px 5px 5px 0;background: url('lib/plugins/authfacebook/images/facebook.png') no-repeat;float:left;"; 55 echo "<p>".$this->getLang('why_facebook')."</p><a href='$auth_url' style='$a_style' title='".$this->getLang('enter_facebook')."'><div style=\"$div_style\"><div style=\"$img_style\"></div>".$this->getLang('enter_facebook')."</div>"; 56 echo "<div style='clear: both;'></div></a>"; 57 } 58 } 59} 60?> 61