1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
13 | |
---|
14 | $tag = (!empty($_REQUEST['tag']) || $_REQUEST['tag'] == '0') ? $_REQUEST['tag'] : ''; |
---|
15 | |
---|
16 | $this_url = $p_url.'&m=tag_posts&tag='.rawurlencode($tag); |
---|
17 | |
---|
18 | |
---|
19 | $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; |
---|
20 | $nb_per_page = 30; |
---|
21 | |
---|
22 | # Rename a tag |
---|
23 | if (!empty($_POST['new_tag_id']) || $_POST['new_tag_id'] == '0') |
---|
24 | { |
---|
25 | $new_id = dcMeta::sanitizeMetaID($_POST['new_tag_id']); |
---|
26 | try { |
---|
27 | if ($core->meta->updateMeta($tag,$new_id,'tag')) { |
---|
28 | http::redirect($p_url.'&m=tag_posts&tag='.$new_id.'&renamed=1'); |
---|
29 | } |
---|
30 | } catch (Exception $e) { |
---|
31 | $core->error->add($e->getMessage()); |
---|
32 | } |
---|
33 | } |
---|
34 | |
---|
35 | # Delete a tag |
---|
36 | if (!empty($_POST['delete']) && $core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
37 | { |
---|
38 | try { |
---|
39 | $core->meta->delMeta($tag,'tag'); |
---|
40 | http::redirect($p_url.'&m=tags&del=1'); |
---|
41 | } catch (Exception $e) { |
---|
42 | $core->error->add($e->getMessage()); |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | $params = array(); |
---|
47 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
48 | $params['no_content'] = true; |
---|
49 | |
---|
50 | $params['meta_id'] = $tag; |
---|
51 | $params['meta_type'] = 'tag'; |
---|
52 | $params['post_type'] = ''; |
---|
53 | |
---|
54 | # Get posts |
---|
55 | try { |
---|
56 | $posts = $core->meta->getPostsByMeta($params); |
---|
57 | $counter = $core->meta->getPostsByMeta($params,true); |
---|
58 | $post_list = new adminPostList($core,$posts,$counter->f(0)); |
---|
59 | } catch (Exception $e) { |
---|
60 | $core->error->add($e->getMessage()); |
---|
61 | } |
---|
62 | |
---|
63 | # Actions combo box |
---|
64 | $combo_action = array(); |
---|
65 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
66 | { |
---|
67 | $combo_action[__('Status')] = array( |
---|
68 | __('Publish') => 'publish', |
---|
69 | __('Unpublish') => 'unpublish', |
---|
70 | __('Schedule') => 'schedule', |
---|
71 | __('Mark as pending') => 'pending' |
---|
72 | ); |
---|
73 | } |
---|
74 | $combo_action[__('Mark')] = array( |
---|
75 | __('Mark as selected') => 'selected', |
---|
76 | __('Mark as unselected') => 'unselected' |
---|
77 | ); |
---|
78 | $combo_action[__('Change')] = array(__('Change category') => 'category'); |
---|
79 | if ($core->auth->check('admin',$core->blog->id)) |
---|
80 | { |
---|
81 | $combo_action[__('Change')] = array_merge($combo_action[__('Change')], |
---|
82 | array(__('Change author') => 'author')); |
---|
83 | } |
---|
84 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
85 | { |
---|
86 | $combo_action[__('Delete')] = array(__('Delete') => 'delete'); |
---|
87 | } |
---|
88 | |
---|
89 | # --BEHAVIOR-- adminPostsActionsCombo |
---|
90 | $core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); |
---|
91 | |
---|
92 | ?> |
---|
93 | <html> |
---|
94 | <head> |
---|
95 | <title><?php echo __('Tags'); ?></title> |
---|
96 | <link rel="stylesheet" type="text/css" href="index.php?pf=tags/style.css" /> |
---|
97 | <script type="text/javascript" src="js/_posts_list.js"></script> |
---|
98 | <script type="text/javascript"> |
---|
99 | //<![CDATA[ |
---|
100 | dotclear.msg.confirm_tag_delete = '<?php echo html::escapeJS(sprintf(__('Are you sure you want to remove this %s?'),'tag')) ?>'; |
---|
101 | $(function() { |
---|
102 | $('#tag_delete').submit(function() { |
---|
103 | return window.confirm(dotclear.msg.confirm_tag_delete); |
---|
104 | }); |
---|
105 | }); |
---|
106 | //]]> |
---|
107 | </script> |
---|
108 | </head> |
---|
109 | <body> |
---|
110 | |
---|
111 | <?php |
---|
112 | dcPage::breadcrumb( |
---|
113 | array( |
---|
114 | html::escapeHTML($core->blog->name) => '', |
---|
115 | __('Tags') => $p_url.'&m=tags', |
---|
116 | '<span class="page-title">'.__('Tag').' “'.html::escapeHTML($tag).'”'.'</span>' => '' |
---|
117 | )); |
---|
118 | ?> |
---|
119 | |
---|
120 | <?php |
---|
121 | if (!empty($_GET['renamed'])) { |
---|
122 | dcPage::message(__('Tag has been successfully renamed')); |
---|
123 | } |
---|
124 | |
---|
125 | echo '<p><a href="'.$p_url.'&m=tags">'.__('Back to tags list').'</a></p>'; |
---|
126 | |
---|
127 | if (!$core->error->flag()) |
---|
128 | { |
---|
129 | if (!$posts->isEmpty()) |
---|
130 | { |
---|
131 | echo |
---|
132 | '<form action="'.$this_url.'" method="post">'. |
---|
133 | '<div class="fieldset"><h3>'.__('Actions for this tag').'</h3>'. |
---|
134 | '<p><label for="new_tag_id">'.__('Edit tag name:').'</label>'. |
---|
135 | form::field('new_tag_id',20,255,html::escapeHTML($tag)). |
---|
136 | '<input type="submit" value="'.__('Rename').'" />'. |
---|
137 | $core->formNonce(). |
---|
138 | '</p></form>'; |
---|
139 | # Remove tag |
---|
140 | if (!$posts->isEmpty() && $core->auth->check('contentadmin',$core->blog->id)) { |
---|
141 | echo |
---|
142 | '<form id="tag_delete" action="'.$this_url.'" method="post">'. |
---|
143 | '<p class="no-margin">'.__('Delete this tag:'). |
---|
144 | '</p><p><input type="submit" class="delete" name="delete" value="'.__('Delete').'" />'. |
---|
145 | $core->formNonce(). |
---|
146 | '</p></form>'; |
---|
147 | } |
---|
148 | echo '</div>'; |
---|
149 | } |
---|
150 | |
---|
151 | # Show posts |
---|
152 | echo '<h3>'.__('List of entries with this tag').'</h3>'; |
---|
153 | $post_list->display($page,$nb_per_page, |
---|
154 | '<form action="posts_actions.php" method="post" id="form-entries">'. |
---|
155 | |
---|
156 | '%s'. |
---|
157 | |
---|
158 | '<div class="two-cols">'. |
---|
159 | '<p class="col checkboxes-helpers"></p>'. |
---|
160 | |
---|
161 | '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '. |
---|
162 | form::combo('action',$combo_action). |
---|
163 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
164 | form::hidden('post_type',''). |
---|
165 | form::hidden('redir',$p_url.'&m=tag_posts&tag='. |
---|
166 | str_replace('%','%%',rawurlencode($tag)).'&page='.$page). |
---|
167 | $core->formNonce(). |
---|
168 | '</div>'. |
---|
169 | '</form>'); |
---|
170 | } |
---|
171 | ?> |
---|
172 | </body> |
---|
173 | </html> |
---|