1<?php
2	// DEFAULT TEMPLATE FOR THE USERSUBSCRIPTIONS PLUGIN
3	// You can copy it to your current template directory to customize it
4
5	/* Useful variables and methods available in the template :
6	 * $deletelink (bool) : tells wether delete subscription link must be active
7	 * $nss (string) : contains the name of the base namespace specified in plugin parameters
8	 * $status (string) : contains nothing if no action was triggered, "success" or "failure" otherwise, usable for CSS class selection for example
9	 * $this->getLang(FLAG) : returns localized string from lang files
10	 * $usersubscriptions (array) : contains the list of subscriptions to display, with ns path as id and fields :
11	 * 		usersubscribed (bool) : tells wether the user subscribed to the namespace (directly or inherited)
12	 * 		selfsubscribed (bool) : tells wether the user subscribed directly to the namespace
13	 * 		subscribedfromparent (bool) : tells wether the user subscribed to a parent namespace of the namespace
14	 * 		inheritedsubscription (bool) : tells wether the user only subscribed to a parent namespace of the namespace and not directly to it
15	 * 		itemdelete (bool) : tells wether the delete subscription link can be displayed
16	 * 		isnamespace (bool) : tells wether id refers to a page or a namespace
17	 *
18	 * $quicksubscribe (bool) : tells wether the quicksubscribe panel must be displayed
19	 */
20?>
21<a name="usersubscriptions_anchor"></a>
22<table class="usersubscriptions">
23	<tr>
24		<th colspan="<?php echo $deletelink ? '2' : '1'; ?>" class="usersubscriptions_namespace"><?php echo $renderer->_xmlEntities($nss); ?></th>
25	</tr>
26<?php if($status != '') { ?>
27	<tr>
28		<td colspan="<?php echo $deletelink ? '2' : '1'; ?>" class="usersubscriptions_nothing usersubscription_<?php echo $status; ?>"><?php echo $this->getLang('usersubscription_'.$status); ?></td>
29	</tr>
30<?php }
31foreach($usersubscriptions as $id => $info) {
32	if(!$info['display']) continue; // skips not displayable items
33?>
34	<tr>
35		<td>
36			<p class="usersubscriptions_description">
37				<a href="<?php echo wl($id); ?>">
38					<img src="<?php echo DOKU_BASE; ?>lib/plugins/usersubscriptions/images/<?php echo $info['isnamespace'] ? 'namespace' : 'page'; ?>.png" alt="<?php echo $this->getLang($info['isnamespace'] ? 'it_is_a_namespace' : 'it_is_a_page'); ?>" title="<?php echo $this->getLang($info['isnamespace'] ? 'it_is_a_namespace' : 'it_is_a_page'); ?>" />
39				</a>
40				<span class="usersubscriptions_id">
41					<a href="<?php echo wl($id).($info['isnamespace'] ? ':' : ''); ?>"><?php echo ($id != '') ? $id : $this->getLang('quick_subscription_root'); ?></a>
42				</span>
43				<br />
44				<?php echo $info['inheritedsubscription'] ? $this->getLang('because_parent_ns_subscribed') : '&nbsp;'; ?>
45			</p>
46		</td>
47		<td class="usersubscriptions_delete">
48			<?php if($info['deleteoption']) { ?><a href="<?php echo wl($ID); ?>&amp;pluginusersubscriptions_unsubscribe=<?php echo ($info['isnamespace'] ? 'ns' : 'pg').'-'.$id.($info['isnamespace'] ? ':' : ''); ?>#usersubscriptions_anchor">
49				<img src="<?php echo DOKU_BASE; ?>lib/plugins/usersubscriptions/images/delete.png" alt="<?php echo $this->getLang('delete'); ?>" title="<?php echo $this->getLang('delete'); ?>" />
50			</a><?php } ?>
51		</td>
52	</tr>
53<?php
54}
55if(!count($usersubscriptions)) {
56?>
57	<tr>
58		<td colspan="<?php echo $deletelink ? '2' : '1'; ?>" class="usersubscriptions_nothing"><?php echo $this->getLang('no_subscriptions'); ?></td>
59	</tr>
60<?php
61}
62
63if($quicksubscribe) {
64?>
65	<tr>
66		<td colspan="<?php echo $deletelink ? '2' : '1'; ?>" class="usersubscriptions_nothing">
67			<?php echo $this->getLang('quick_subscription'); ?> : <form method="get" action="<?php echo wl($ID); ?>#usersubscriptions_anchor">
68				<input type="hidden" name="id" value="<?php echo $ID; ?>">
69				<select name="pluginusersubscriptions_subscribe" onchange="this.form.submit();">
70					<option value=""><?php echo $this->getLang('quick_subscription_select'); ?></option>
71<?php
72	foreach($usersubscriptions as $id => $info) {
73		if($info['selfsubscribed']) continue; // don't display already subscribed items
74?>
75					<option value="<?php echo ($info['isnamespace'] ? 'ns' : 'pg').'-'.$id.($info['isnamespace'] ? ':' : '').'" class="'.($info['isnamespace'] ? 'usersubscriptions_nsopt' : '').' '.($info['selfsubscribed'] ? 'usersubscriptions_selopt' : ''); ?>">
76						<!--<?php echo str_repeat('&nbsp;&nbsp;&nbsp;', max(0, $info['lvl'] - 1)); ?>-->
77						<?php echo ($id != '') ? $id : $this->getLang('quick_subscription_root'); ?>
78					</option>
79<?php
80	}
81?>
82				</select>
83				<noscript><input type="submit" value="<?php echo $this->getLang('quick_subscription_post'); ?>" /></noscript>
84			</form>
85		</td>
86	</tr>
87<?php
88}
89?>
90</table>
91