Dotclear

source: plugins/tags/tag_posts.php @ 1179:a43a29427ef3

Revision 1179:a43a29427ef3, 4.8 KB checked in by franck <carnet.franck.paul@…>, 11 years ago (diff)

Update copyright notice

Line 
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 -----------------------------------------
12if (!defined('DC_CONTEXT_ADMIN')) { return; }
13
14$tag = (!empty($_REQUEST['tag']) || $_REQUEST['tag'] == '0') ? $_REQUEST['tag'] : '';
15
16$this_url = $p_url.'&amp;m=tag_posts&amp;tag='.rawurlencode($tag);
17
18
19$page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
20$nb_per_page =  30;
21
22# Rename a tag
23if (!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
36if (!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
55try {
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();
65if ($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');
79if ($core->auth->check('admin',$core->blog->id))
80{
81     $combo_action[__('Change')] = array_merge($combo_action[__('Change')],
82          array(__('Change author') => 'author'));
83}
84if ($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<h2><?php echo html::escapeHTML($core->blog->name); ?> &rsaquo;
112<span class="page-title"><?php echo __('Edit tag').' &ldquo;'.html::escapeHTML($tag).'&rdquo;'; ?></span></h2>
113
114<?php
115if (!empty($_GET['renamed'])) {
116     dcPage::message(__('Tag has been successfully renamed'));
117}
118
119echo '<p><a href="'.$p_url.'&amp;m=tags">'.__('Back to tags list').'</a></p>';
120
121if (!$core->error->flag())
122{
123     if (!$posts->isEmpty())
124     {
125          echo
126          '<form action="'.$this_url.'" method="post">'.
127          '<div class="fieldset"><h3>'.__('Actions for this tag').'</h3>'.
128          '<p><label for="new_tag_id">'.__('Edit tag name:').'</label>'.
129          form::field('new_tag_id',20,255,html::escapeHTML($tag)).
130          '<input type="submit" value="'.__('Rename').'" />'.
131          $core->formNonce().
132          '</form>';
133          # Remove tag
134          if (!$posts->isEmpty() && $core->auth->check('contentadmin',$core->blog->id)) {
135               echo
136               '<form id="tag_delete" action="'.$this_url.'" method="post">'.
137               '<p class="no-margin">'.__('Delete this tag:').'</p>'.
138               '<input type="submit" class="delete" name="delete" value="'.__('Delete').'" />'.
139               $core->formNonce().
140               '</form>';
141          }
142          echo '</p></div>';
143     }
144     
145     # Show posts
146     echo '<h3>'.__('List of entries with this tag').'</h3>';
147     $post_list->display($page,$nb_per_page,
148     '<form action="posts_actions.php" method="post" id="form-entries">'.
149     
150     '%s'.
151     
152     '<div class="two-cols">'.
153     '<p class="col checkboxes-helpers"></p>'.
154     
155     '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '.
156     form::combo('action',$combo_action).
157     '<input type="submit" value="'.__('ok').'" /></p>'.
158     form::hidden('post_type','').
159     form::hidden('redir',$p_url.'&amp;m=tag_posts&amp;tag='.
160          str_replace('%','%%',rawurlencode($tag)).'&amp;page='.$page).
161     $core->formNonce().
162     '</div>'.
163     '</form>');
164}
165?>
166</body>
167</html>
Note: See TracBrowser for help on using the repository browser.

Sites map