Dotclear


Ignore:
Timestamp:
03/02/18 15:55:06 (8 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Use specialized input fields (color, email, url, number, …) where is relevant

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/tags/tag_posts.php

    r3606 r3725  
    1010# 
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    12 if (!defined('DC_CONTEXT_ADMIN')) { return; } 
     12if (!defined('DC_CONTEXT_ADMIN')) {return;} 
    1313 
    1414$tag = isset($_REQUEST['tag']) ? $_REQUEST['tag'] : ''; 
    1515 
    16 $this_url = $p_url.'&amp;m=tag_posts&amp;tag='.rawurlencode($tag); 
     16$this_url = $p_url . '&amp;m=tag_posts&amp;tag=' . rawurlencode($tag); 
    1717 
    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; 
    2120 
    2221# 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      } 
     22if (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    } 
    3432} 
    3533 
    3634# 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      } 
     35if (!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    } 
    4643} 
    4744 
    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); 
    5047$params['no_content'] = true; 
    5148 
    52 $params['meta_id'] = $tag; 
     49$params['meta_id']   = $tag; 
    5350$params['meta_type'] = 'tag'; 
    5451$params['post_type'] = ''; 
     
    5653# Get posts 
    5754try { 
    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)); 
    6158} catch (Exception $e) { 
    62      $core->error->add($e->getMessage()); 
     59    $core->error->add($e->getMessage()); 
    6360} 
    6461 
    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)); 
    6663 
    6764if ($posts_actions_page->process()) { 
    68      return; 
     65    return; 
    6966} 
    7067 
     
    7269<html> 
    7370<head> 
    74      <title><?php echo __('Tags'); ?></title> 
    75      <?php echo dcPage::cssLoad(dcPage::getPF('tags/style.css'));?> 
    76      <?php echo dcPage::jsLoad('js/_posts_list.js');?> 
    77      <script type="text/javascript"> 
    78           dotclear.msg.confirm_tag_delete = '<?php echo html::escapeJS(sprintf(__('Are you sure you want to remove tag: “%s”?'),html::escapeHTML($tag))) ?>'; 
    79           $(function() { 
    80                $('#tag_delete').submit(function() { 
    81                     return window.confirm(dotclear.msg.confirm_tag_delete); 
    82                }); 
    83           }); 
    84      </script> 
    85      <?php echo dcPage::jsConfirmClose('tag_rename'); ?> 
     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'); ?> 
    8683</head> 
    8784<body> 
     
    8986<?php 
    9087echo dcPage::breadcrumb( 
    91      array( 
    92           html::escapeHTML($core->blog->name) => '', 
    93           __('Tags') => $p_url.'&amp;m=tags', 
    94           __('Tag').' &ldquo;'.html::escapeHTML($tag).'&rdquo;' => '' 
    95      )). 
    96      dcPage::notices(); 
     88    array( 
     89        html::escapeHTML($core->blog->name)                        => '', 
     90        __('Tags')                                                  => $p_url . '&amp;m=tags', 
     91        __('Tag') . ' &ldquo;' . html::escapeHTML($tag) . '&rdquo;' => '' 
     92    )) . 
     93dcPage::notices(); 
    9794?> 
    9895 
    9996<?php 
    100 echo '<p><a class="back" href="'.$p_url.'&amp;m=tags">'.__('Back to tags list').'</a></p>'; 
     97echo '<p><a class="back" href="' . $p_url . '&amp;m=tags">' . __('Back to tags list') . '</a></p>'; 
    10198 
    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      } 
     99if (!$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    } 
    125120 
    126      # Show posts 
    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">' . 
    130125 
    131      '%s'. 
     126        '%s' . 
    132127 
    133      '<div class="two-cols">'. 
    134      '<p class="col checkboxes-helpers"></p>'. 
     128        '<div class="two-cols">' . 
     129        '<p class="col checkboxes-helpers"></p>' . 
    135130 
    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      '</form>'); 
     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>'); 
    146141} 
    147142dcPage::helpBlock('tag_posts'); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map