From: Florent Bruneau Date: Tue, 27 May 2008 21:26:48 +0000 (+0200) Subject: Structures the classes: X-Git-Url: http://git.polytechnique.org/?p=dotclear.git;a=commitdiff_plain;h=b519995bcd7c566065ef0e8537bdf53d5d06de6c Structures the classes: * widget.(...).php => widget * page.(...).php => page (url catcher) * class.(...).php => tool classes Signed-off-by: Florent Bruneau --- diff --git a/_admin.php b/_admin.php index 1a99bbb..f175526 100644 --- a/_admin.php +++ b/_admin.php @@ -1,10 +1,5 @@ addBehavior('initWidgets', array('xorgAuthWidgetBehavior', 'initWidget')); - -class xorgAuthWidgetBehavior { - public static function initWidget(&$w) { - $w->create('XorgAuth', __('Auth. X.org'), array('xorgAuthWidget','widget')); - } -} +require_once dirname(__FILE__) . '/widget.auth.php'; +$core->addBehavior('initWidgets', array('xorgAuthWidget', 'behavior_initWidgets')); ?> diff --git a/_public.php b/_public.php index 44f9d43..fa9bece 100644 --- a/_public.php +++ b/_public.php @@ -1,137 +1,11 @@ url->register('xorgAuth', 'Xorg', '^auth/(.*)$', array('xorgAuthentifier', 'doAuth')); $core->url->register('xorgLogin', 'XorgLogin', '^admin/(xorg\.php)$', array('xorgLoginPage', 'page')); -class xorgAuthWidget { - static public function widget(&$w) { - global $core; - $name = $core->auth->userID(); - if ($name) { - return '

Tu es ' . $core->auth->getInfo('user_displayname') . '
' - . 'déconnexion

'; - } else { - return '

M\'authentifier via Polytechnique.org

'; - } - } -} - -class xorgLoginPage extends dcUrlHandlers { - static public function page($args) { - switch ($args) { - case 'xorg.php': - self::dispatchForm(); - default: - self::p404(); - } - } - - static protected function dispatchForm() { - # If we have a session cookie, go to index.php - if (isset($_SESSION['sess_user_id'])) - { - header('Location: http://murphy.m4x.org/~x2003bruneau/dotclear/admin/index.php'); - } - - # Loading locales for detected language - $dlang = http::getAcceptLanguage(); - if ($dlang) { - l10n::set(dirname(__FILE__).'/../locales/'.$dlang.'/main'); - } - - global $core; - $msg = $err = null; - header('Content-Type: text/html; charset=UTF-8'); - ?> - - - - - - - - - - - <?php echo html::escapeHTML(DC_VENDOR_NAME); ?> - - - - - callBehavior('loginPageHTMLHead'); - ?> - - - - -
-

- - '.$err.''; - } - if ($msg) { - echo '

'.$msg.'

'; - } - - { - echo - '
'. - '

Via Polytechnique.org

' . - '

Via le formulaire

' . - '
'. - - '

'.__('You must accept cookies in order to use the private area.').'

'; - - if ($core->auth->allowPassChange()) { - echo '

'.__('I forgot my password').'

'; - } - } - ?> -
- - - - - -auth->killSession(); - break; - case 'Xorg': - if ($core->auth->callXorg($_GET['path'])) { - header('Location: http://murphy.m4x.org' . $_GET['path']); - exit; - } - break; - case 'XorgReturn': - $core->auth->returnXorg(); - break; - default: - self::p404(); - } - return; - } -} ?> diff --git a/page.auth.admin.php b/page.auth.admin.php new file mode 100644 index 0000000..fc07a97 --- /dev/null +++ b/page.auth.admin.php @@ -0,0 +1,99 @@ + + + + + + + + + + + + <?php echo html::escapeHTML(DC_VENDOR_NAME); ?> + + + + + callBehavior('loginPageHTMLHead'); + ?> + + + + +
+

+ + '.$err.''; + } + if ($msg) { + echo '

'.$msg.'

'; + } + + { + echo + '
'. + '

Via Polytechnique.org

' . + '

Via le formulaire

' . + '
'. + + '

'.__('You must accept cookies in order to use the private area.').'

'; + + if ($core->auth->allowPassChange()) { + echo '

'.__('I forgot my password').'

'; + } + } + ?> +
+ + + + + + diff --git a/page.auth.php b/page.auth.php new file mode 100644 index 0000000..6a197f0 --- /dev/null +++ b/page.auth.php @@ -0,0 +1,26 @@ +auth->killSession(); + break; + case 'Xorg': + if ($core->auth->callXorg($_GET['path'])) { + header('Location: http://murphy.m4x.org' . $_GET['path']); + exit; + } + break; + case 'XorgReturn': + $core->auth->returnXorg(); + break; + default: + self::p404(); + } + return; + } +} + +?> diff --git a/widget.auth.php b/widget.auth.php new file mode 100644 index 0000000..fd6bd83 --- /dev/null +++ b/widget.auth.php @@ -0,0 +1,19 @@ +create('XorgAuth', __('Auth. X.org'), array('xorgAuthWidget', 'widget')); + } + + static public function widget(&$w) { + global $core; + $name = $core->auth->userID(); + if ($name) { + return '

Tu es ' . $core->auth->getInfo('user_displayname') . '
' + . 'déconnexion

'; + } else { + return '

M\'authentifier via Polytechnique.org

'; + } + } +} + +?>