Changeset 3725:b47f38c701ee for plugins/tags
- Timestamp:
- 03/02/18 15:55:06 (8 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/tags/tag_posts.php
r3606 r3725 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 13 14 14 $tag = isset($_REQUEST['tag']) ? $_REQUEST['tag'] : ''; 15 15 16 $this_url = $p_url .'&m=tag_posts&tag='.rawurlencode($tag);16 $this_url = $p_url . '&m=tag_posts&tag=' . rawurlencode($tag); 17 17 18 19 $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; 20 $nb_per_page = 30; 18 $page = !empty($_GET['page']) ? max(1, (integer) $_GET['page']) : 1; 19 $nb_per_page = 30; 21 20 22 21 # Rename a tag 23 if (isset($_POST['new_tag_id'])) 24 { 25 $new_id = dcMeta::sanitizeMetaID($_POST['new_tag_id']); 26 try { 27 if ($core->meta->updateMeta($tag,$new_id,'tag')) { 28 dcPage::addSuccessNotice(__('Tag has been successfully renamed')); 29 http::redirect($p_url.'&m=tag_posts&tag='.$new_id); 30 } 31 } catch (Exception $e) { 32 $core->error->add($e->getMessage()); 33 } 22 if (isset($_POST['new_tag_id'])) { 23 $new_id = dcMeta::sanitizeMetaID($_POST['new_tag_id']); 24 try { 25 if ($core->meta->updateMeta($tag, $new_id, 'tag')) { 26 dcPage::addSuccessNotice(__('Tag has been successfully renamed')); 27 http::redirect($p_url . '&m=tag_posts&tag=' . $new_id); 28 } 29 } catch (Exception $e) { 30 $core->error->add($e->getMessage()); 31 } 34 32 } 35 33 36 34 # Delete a tag 37 if (!empty($_POST['delete']) && $core->auth->check('publish,contentadmin',$core->blog->id)) 38 { 39 try { 40 $core->meta->delMeta($tag,'tag'); 41 dcPage::addSuccessNotice(__('Tag has been successfully removed')); 42 http::redirect($p_url.'&m=tags'); 43 } catch (Exception $e) { 44 $core->error->add($e->getMessage()); 45 } 35 if (!empty($_POST['delete']) && $core->auth->check('publish,contentadmin', $core->blog->id)) { 36 try { 37 $core->meta->delMeta($tag, 'tag'); 38 dcPage::addSuccessNotice(__('Tag has been successfully removed')); 39 http::redirect($p_url . '&m=tags'); 40 } catch (Exception $e) { 41 $core->error->add($e->getMessage()); 42 } 46 43 } 47 44 48 $params = array();49 $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);45 $params = array(); 46 $params['limit'] = array((($page - 1) * $nb_per_page), $nb_per_page); 50 47 $params['no_content'] = true; 51 48 52 $params['meta_id'] = $tag;49 $params['meta_id'] = $tag; 53 50 $params['meta_type'] = 'tag'; 54 51 $params['post_type'] = ''; … … 56 53 # Get posts 57 54 try { 58 $posts= $core->meta->getPostsByMeta($params);59 $counter = $core->meta->getPostsByMeta($params,true);60 $post_list = new adminPostList($core,$posts,$counter->f(0));55 $posts = $core->meta->getPostsByMeta($params); 56 $counter = $core->meta->getPostsByMeta($params, true); 57 $post_list = new adminPostList($core, $posts, $counter->f(0)); 61 58 } catch (Exception $e) { 62 59 $core->error->add($e->getMessage()); 63 60 } 64 61 65 $posts_actions_page = new dcPostsActionsPage($core, 'plugin.php',array('p'=>'tags', 'm'=>'tag_posts', 'tag'=> $tag));62 $posts_actions_page = new dcPostsActionsPage($core, 'plugin.php', array('p' => 'tags', 'm' => 'tag_posts', 'tag' => $tag)); 66 63 67 64 if ($posts_actions_page->process()) { 68 65 return; 69 66 } 70 67 … … 72 69 <html> 73 70 <head> 74 75 <?php echo dcPage::cssLoad(dcPage::getPF('tags/style.css'));?>76 <?php echo dcPage::jsLoad('js/_posts_list.js');?>77 78 dotclear.msg.confirm_tag_delete = '<?php echo html::escapeJS(sprintf(__('Are you sure you want to remove tag: “%s”?'),html::escapeHTML($tag))) ?>';79 80 81 82 83 84 85 71 <title><?php echo __('Tags'); ?></title> 72 <?php echo dcPage::cssLoad(dcPage::getPF('tags/style.css')); ?> 73 <?php echo dcPage::jsLoad('js/_posts_list.js'); ?> 74 <script type="text/javascript"> 75 dotclear.msg.confirm_tag_delete = '<?php echo html::escapeJS(sprintf(__('Are you sure you want to remove tag: “%s”?'), html::escapeHTML($tag))) ?>'; 76 $(function() { 77 $('#tag_delete').submit(function() { 78 return window.confirm(dotclear.msg.confirm_tag_delete); 79 }); 80 }); 81 </script> 82 <?php echo dcPage::jsConfirmClose('tag_rename'); ?> 86 83 </head> 87 84 <body> … … 89 86 <?php 90 87 echo dcPage::breadcrumb( 91 92 html::escapeHTML($core->blog->name)=> '',93 __('Tags') => $p_url.'&m=tags',94 __('Tag').' “'.html::escapeHTML($tag).'”' => ''95 )).96 88 array( 89 html::escapeHTML($core->blog->name) => '', 90 __('Tags') => $p_url . '&m=tags', 91 __('Tag') . ' “' . html::escapeHTML($tag) . '”' => '' 92 )) . 93 dcPage::notices(); 97 94 ?> 98 95 99 96 <?php 100 echo '<p><a class="back" href="' .$p_url.'&m=tags">'.__('Back to tags list').'</a></p>';97 echo '<p><a class="back" href="' . $p_url . '&m=tags">' . __('Back to tags list') . '</a></p>'; 101 98 102 if (!$core->error->flag()) 103 { 104 if (!$posts->isEmpty()) 105 { 106 echo 107 '<div class="tag-actions vertical-separator">'. 108 '<h3>'.html::escapeHTML($tag).'</h3>'. 109 '<form action="'.$this_url.'" method="post" id="tag_rename">'. 110 '<p><label for="new_tag_id" class="classic">'.__('Rename').'</label> '. 111 form::field('new_tag_id',20,255,html::escapeHTML($tag)). 112 '<input type="submit" value="'.__('OK').'" />'. 113 $core->formNonce(). 114 '</p></form>'; 115 # Remove tag 116 if (!$posts->isEmpty() && $core->auth->check('contentadmin',$core->blog->id)) { 117 echo 118 '<form id="tag_delete" action="'.$this_url.'" method="post">'. 119 '<p><input type="submit" class="delete" name="delete" value="'.__('Delete this tag').'" />'. 120 $core->formNonce(). 121 '</p></form>'; 122 } 123 echo '</div>'; 124 } 99 if (!$core->error->flag()) { 100 if (!$posts->isEmpty()) { 101 echo 102 '<div class="tag-actions vertical-separator">' . 103 '<h3>' . html::escapeHTML($tag) . '</h3>' . 104 '<form action="' . $this_url . '" method="post" id="tag_rename">' . 105 '<p><label for="new_tag_id" class="classic">' . __('Rename') . '</label> ' . 106 form::field('new_tag_id', 20, 255, html::escapeHTML($tag)) . 107 '<input type="submit" value="' . __('OK') . '" />' . 108 $core->formNonce() . 109 '</p></form>'; 110 # Remove tag 111 if (!$posts->isEmpty() && $core->auth->check('contentadmin', $core->blog->id)) { 112 echo 113 '<form id="tag_delete" action="' . $this_url . '" method="post">' . 114 '<p><input type="submit" class="delete" name="delete" value="' . __('Delete this tag') . '" />' . 115 $core->formNonce() . 116 '</p></form>'; 117 } 118 echo '</div>'; 119 } 125 120 126 127 echo '<h4 class="vertical-separator pretty-title">'.sprintf(__('List of entries with the tag “%s”'),html::escapeHTML($tag)).'</h4>';128 $post_list->display($page,$nb_per_page,129 '<form action="'.$core->adminurl->get('admin.plugin').'" method="post" id="form-entries">'.121 # Show posts 122 echo '<h4 class="vertical-separator pretty-title">' . sprintf(__('List of entries with the tag “%s”'), html::escapeHTML($tag)) . '</h4>'; 123 $post_list->display($page, $nb_per_page, 124 '<form action="' . $core->adminurl->get('admin.plugin') . '" method="post" id="form-entries">' . 130 125 131 '%s'.126 '%s' . 132 127 133 '<div class="two-cols">'.134 '<p class="col checkboxes-helpers"></p>'.128 '<div class="two-cols">' . 129 '<p class="col checkboxes-helpers"></p>' . 135 130 136 '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '.137 form::combo('action',$posts_actions_page->getCombo()).138 '<input id="do-action" type="submit" value="'.__('OK').'" /></p>'.139 form::hidden('post_type','').140 form::hidden('p','tags').141 form::hidden('m','tag_posts').142 form::hidden('tag',$tag).143 $core->formNonce().144 '</div>'.145 131 '<p class="col right"><label for="action" class="classic">' . __('Selected entries action:') . '</label> ' . 132 form::combo('action', $posts_actions_page->getCombo()) . 133 '<input id="do-action" type="submit" value="' . __('OK') . '" /></p>' . 134 form::hidden('post_type', '') . 135 form::hidden('p', 'tags') . 136 form::hidden('m', 'tag_posts') . 137 form::hidden('tag', $tag) . 138 $core->formNonce() . 139 '</div>' . 140 '</form>'); 146 141 } 147 142 dcPage::helpBlock('tag_posts');
Note: See TracChangeset
for help on using the changeset viewer.