/** * Display the subscribe form * * @author Adrian Lang <*****@*****.**> */ function tpl_subscribe() { global $INFO; global $ID; global $lang; global $conf; $stime_days = $conf['subscribe_time'] / 60 / 60 / 24; echo p_locale_xhtml('subscr_form'); echo '<h2>' . $lang['subscr_m_current_header'] . '</h2>'; echo '<div class="level2">'; if ($INFO['subscribed'] === false) { echo '<p>' . $lang['subscr_m_not_subscribed'] . '</p>'; } else { echo '<ul>'; foreach ($INFO['subscribed'] as $sub) { echo '<li><div class="li">'; if ($sub['target'] !== $ID) { echo '<code class="ns">' . hsc(prettyprint_id($sub['target'])) . '</code>'; } else { echo '<code class="page">' . hsc(prettyprint_id($sub['target'])) . '</code>'; } $sstl = sprintf($lang['subscr_style_' . $sub['style']], $stime_days); 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', 'sectok' => getSecurityToken())) . '" class="unsubscribe">' . $lang['subscr_m_unsubscribe'] . '</a></div></li>'; } echo '</ul>'; } echo '</div>'; // Add new subscription form echo '<h2>' . $lang['subscr_m_new_header'] . '</h2>'; echo '<div class="level2">'; $ns = getNS($ID) . ':'; $targets = array($ID => '<code class="page">' . prettyprint_id($ID) . '</code>', $ns => '<code class="ns">' . prettyprint_id($ns) . '</code>'); $styles = array('every' => $lang['subscr_style_every'], 'digest' => sprintf($lang['subscr_style_digest'], $stime_days), 'list' => sprintf($lang['subscr_style_list'], $stime_days)); $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>'; }