summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <gohr@cosmocode.de>2009-11-30 14:03:11 +0100
committerAdrian Lang <lang@cosmocode.de>2010-01-20 10:53:25 +0100
commit056c20495937fe45fe0f7204b112dbfe6931a855 (patch)
treea994bc7c4850e1c9a54efb55fd8d7913b12cd265 /inc
parentcb3f9dbab0cf12b2a7486cca0de17c47399633f3 (diff)
downloadrpg-056c20495937fe45fe0f7204b112dbfe6931a855.tar.gz
rpg-056c20495937fe45fe0f7204b112dbfe6931a855.tar.bz2
nicer subscription styles
Ignore-this: e1b3b815b5ebb0da320bff997c4fed4b darcs-hash:20091130130311-6e07b-03ccfc52abb3dcc0764eed5784d81f8416841328.gz
Diffstat (limited to 'inc')
-rw-r--r--inc/actions.php20
-rw-r--r--inc/lang/en/lang.php2
-rw-r--r--inc/template.php34
3 files changed, 27 insertions, 29 deletions
diff --git a/inc/actions.php b/inc/actions.php
index 900409a90..1fda0584e 100644
--- a/inc/actions.php
+++ b/inc/actions.php
@@ -558,19 +558,21 @@ function act_export($act){
* @author Adrian Lang <lang@cosmocode.de>
*/
function act_subscription($act){
- if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
- // No post to handle, let tpl_subscribe manage the request.
- return $act;
- }
+ global $lang;
+ global $INFO;
+ global $ID;
- // Get and preprocess data.
+ // get and preprocess data.
$params = array();
foreach(array('target', 'style', 'action') as $param) {
- if (isset($_POST["subscribe_$param"])) {
- $params[$param] = $_POST["subscribe_$param"];
+ if (isset($_REQUEST["sub_$param"])) {
+ $params[$param] = $_REQUEST["sub_$param"];
}
}
+ // any action given? if not just return and show the subscription page
+ if(!$params['action']) return $act;
+
// Handle POST data, may throw exception.
trigger_event('ACTION_HANDLE_SUBSCRIBE', $params, 'subscription_handle_post');
@@ -579,9 +581,6 @@ function act_subscription($act){
$data = $params['data'];
$action = $params['action'];
- global $lang;
- global $INFO;
-
// Perform action.
require_once DOKU_INC . 'inc/subscription.php';
if (!subscription_set($_SERVER['REMOTE_USER'], $target, $style, $data)) {
@@ -591,7 +590,6 @@ function act_subscription($act){
}
msg(sprintf($lang["subscr_{$action}_success"], hsc($INFO['userinfo']['name']),
prettyprint_id($target)), 1);
- global $ID;
act_redirect($ID, $act);
// Assure that we have valid data if act_redirect somehow fails.
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php
index b97713a75..98ded12ca 100644
--- a/inc/lang/en/lang.php
+++ b/inc/lang/en/lang.php
@@ -223,7 +223,7 @@ $lang['subscr_m_new_header'] = 'Add subscription';
$lang['subscr_m_current_header'] = 'Current subscriptions';
$lang['subscr_m_unsubscribe'] = 'Unsubscribe';
$lang['subscr_m_subscribe'] = 'Subscribe';
-
+$lang['subscr_m_receive'] = 'Receive';
$lang['subscr_style_every'] = 'email on every change';
$lang['subscr_style_digest'] = 'digest email of changes for each page';
$lang['subscr_style_list'] = 'list of changed pages since last email';
diff --git a/inc/template.php b/inc/template.php
index 6b0314b84..84fbda051 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1366,24 +1366,21 @@ function tpl_subscribe() {
echo '<p>' . $lang['subscr_m_not_subscribed'] . '</p>';
} else {
echo '<ul>';
-
foreach($INFO['subscribed'] as $sub) {
- $form = new Doku_Form(array('class' => 'unsubscribe'));
+ echo '<li><div class="li">';
if ($sub['target'] !== $ID) {
- $stgt = '<code class="ns">'.hsc(prettyprint_id($sub['target'])).'</code>';
+ echo '<code class="ns">'.hsc(prettyprint_id($sub['target'])).'</code>';
} else {
- $stgt = '<code class="page">'.hsc(prettyprint_id($sub['target'])).'</code>';
+ echo '<code class="page">'.hsc(prettyprint_id($sub['target'])).'</code>';
}
$sstl = $lang['subscr_style_'.$sub['style']];
if(!$sstl) $sstl = hsc($sub['style']);
+ echo ' ('.$sstl.') ';
+
+ echo '<a href="'.wl($ID,array('do'=>'subscribe','sub_target'=>$sub['target'],'sub_style'=>$sub['style'],'sub_action'=>'unsubscribe')).'" class="unsubscribe">'.$lang['subscr_m_unsubscribe'].'</a>';
+
- $form->addElement('<li><div class="li">'.$stgt.' ('.$sstl.') ');
- $form->addElement(form_makeButton('submit', 'subscribe', $lang['subscr_m_unsubscribe']));
- $form->addHidden('subscribe_target', $sub['target']);
- $form->addHidden('subscribe_style', $sub['style']);
- $form->addHidden('subscribe_action', 'unsubscribe');
- $form->addElement('</div></li>');
- html_form('UNSUBSCRIBE', $form);
+ echo '</div></li>';
}
echo '</ul>';
}
@@ -1403,12 +1400,15 @@ function tpl_subscribe() {
'list' => $lang['subscr_style_list'],
);
- $form = new Doku_Form(array('id' => 'subscribe'));
- $form->addElement('<p>' . 'Subscribe to' . '</p>');
- $form->addRadioSet('subscribe_target', $targets);
- $form->addElement('<p>' . 'Receive' . '</p>');
- $form->addRadioSet('subscribe_style', $styles);
- $form->addHidden('subscribe_action', 'subscribe');
+ $form = new Doku_Form(array('id' => 'subscribe__form'));
+ $form->startFieldset($lang['subscr_m_subscribe']);
+ $form->addRadioSet('sub_target', $targets);
+ $form->startFieldset($lang['subscr_m_receive']);
+ $form->addRadioSet('sub_style', $styles);
+ $form->addHidden('sub_action', 'subscribe');
+ $form->addHidden('do', 'subscribe');
+ $form->addHidden('id', $ID);
+ $form->endFieldset();
$form->addElement(form_makeButton('submit', 'subscribe', $lang['subscr_m_subscribe']));
html_form('SUBSCRIBE', $form);
echo '</div>';