Dotclear

Ticket #1288 (closed enhancement: duplicate)

Opened 14 years ago

Last modified 12 years ago

Suppression en masse de tags dans les billets-images de Gallery

Reported by: jojojr Owned by: team
Priority: normal Milestone:
Component: module:plugins Version: 2.3
Severity: normal Keywords: Gallery,tags
Cc:

Description

Gallery 0.4.2 sous DC 2.3.1. La suppression en masse de tags n'est pas implémentée.

Fix:

1.- Dans le fichier gallery/items.php vers la ligne 210 remplacer

$combo_action[__('Tags')] = array(
	__('add tags') => 'tags'
);

par

$combo_action[__('Tags')] = array(
	   __('Add tags') => 'tags',
        __('Remove tags') => 'tags_remove'
	);

ce qui au passage corrige la petite erreur d'oubli de majuscule à la chaîne 'add tags'

2.- Dans le fichier gallery/item_actions

  1. vers la ligne 178, après elseif ($action == 'tags' && !empty($_POSTnew_tags?)) (juste avant DISPLAY) rajouter:
elseif ($action == 'tags_remove' && !empty($_POST['meta_id']) 
        && $core->auth->check('delete,contentadmin',$core->blog->id)) {
        try {
            $meta =& $GLOBALS['core']->meta;
            while ($posts->fetch()) {
                foreach ($_POST['meta_id'] as $v) {
                    $meta->delPostMeta($posts->post_id,'tag',$v);
                }
            }   
            http::redirect($redir);
        }
        catch (Exception $e) {
            $core->error->add($e->getMessage());
        }
    }
  1. vers la ligne 306 juste après elseif ($action == 'tags'), rajouter:
elseif ($action == 'tags_remove') {
    $meta =& $GLOBALS['core']->meta;
    $tags = array();
    foreach ($_POST['entries'] as $id) {
        $post_tags = $meta->getMetadata(array(
            'meta_type' => 'tag',
            'post_id' => (integer) $id))->toStatic()->rows();
        foreach ($post_tags as $v) {
            if (isset($tags[$v['meta_id']])) {
                $tags[$v['meta_id']]++;
            } else {
                $tags[$v['meta_id']] = 1;
            }
        }
    }
    echo '<h2>'.__('Remove selected tags from entries').'</h2>';            
    if (empty($tags)) {
        echo '<p>'.__('No tags for selected entries').'</p>';
        return;
    }
    $posts_count = count($_POST['entries']); 
    echo 
        '<form action="plugin.php?p=gallery&amp;m=itemsactions" method="post">'.
        '<fieldset><legend>'.__('Following tags have been found in selected entries:').'</legend>';
    
    foreach ($tags as $k => $n) {
        $label = '<label class="classic">%s %s</label>';
        if ($posts_count == $n) {
            $label = sprintf($label,'%s','<strong>%s</strong>');
        }
        echo '<p>'.sprintf($label,
            form::checkbox(array('meta_id[]'),html::escapeHTML($k)),
            html::escapeHTML($k)).
            '</p>';
    }
    echo
        '<p><input type="submit" value="'.__('ok').'" /></p>'.
        $hidden_fields.
        $core->formNonce().
        form::hidden(array('action'),'tags_remove').
        '</fieldset></form>';
    }

J'attache le fichier gallery/item_actions ainsi modifié.

Attachments

items_actions.php Download (11.3 KB) - added by jojojr 14 years ago.
fichier gallery/items_actions modifié

Change History

Changed 14 years ago by jojojr

fichier gallery/items_actions modifié

comment:1 Changed 14 years ago by noe

  • Status changed from new to closed
  • Resolution set to duplicate

Duplicate #1287 lequel a été résolu comme invalid et reporté  ici

comment:2 Changed 12 years ago by franck

  • Milestone A definir deleted
Note: See TracTickets for help on using tickets.

Sites map