Batch Add "Put files of ..." menu indistinguishable in Google Chrome Batch Add "Put files of ..." menu indistinguishable in Google Chrome
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Batch Add "Put files of ..." menu indistinguishable in Google Chrome

Started by pols1337, July 10, 2012, 01:47:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pols1337

Hi Andre,

I'm not sure if this is a problem or maybe a suggestion that you can improve for the future, but I primarily use Google Chrome browser.  When I want to Batch Add files, the "put files of folder/album into [Select Album]" shows a dropdown list of all possible albums.  In Google Chrome, the categories and albums look exactly the same with similar font style so they are indistinguishable.  This makes it very hard to find the appropriate album to batch add the files.

I've attached a screenshot from both Google Chrome and Mozilla Firefox.  It looks normal in Firefox. 

URL: http://adonismale.com/tg/

Joel / pols1337

Αndré

Please open include/functions.inc.php and replace the whole function album_selection_options with the following one:
function album_selection_options($selected = 0)
{
    global $CONFIG, $lang_common, $cpg_udb, $LINEBREAK;
    // html string of options to be returned   
    $options = '';
    $albums = array();
    // load all albums
   
    if (GALLERY_ADMIN_MODE) {
        $result = cpg_db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} ORDER BY pos");
    } elseif (USER_ID) {
        $result = cpg_db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (FIRST_USER_CAT + USER_ID) . " OR owner = " . USER_ID . " ORDER BY pos");
    }
   
    while ( ($row = mysql_fetch_assoc($result)) ) {
        $albums[$row['category']][$row['aid']] = $row['title'];
    }
    if (!empty($albums[0])) {
        // Albums in no category
        $options .= '<optgroup label="' . $lang_common['albums_no_category'] . '">';
        foreach ($albums[0] as $aid => $title) {
            $options .= sprintf('<option value="%d"%s>%s</option>'.$LINEBREAK, $aid, $aid == $selected ? ' selected="selected"' : '', $title);
        }
        $options .= '</optgroup>';
    }
    // Load all categories
    if (GALLERY_ADMIN_MODE) {
        $result = cpg_db_query("SELECT cid, rgt, name FROM {$CONFIG['TABLE_CATEGORIES']} ORDER BY lft");
    } else {
        $result = cpg_db_query("SELECT c.cid, c.rgt, c.name FROM {$CONFIG['TABLE_ALBUMS']} AS a RIGHT JOIN {$CONFIG['TABLE_CATEGORIES']} AS c ON a.category = c.cid WHERE c.cid = " . USER_GAL_CAT . " OR a.owner = ". USER_ID . " ORDER BY lft");
    }
   
    $cats = array();
    // Loop through all categories
    while ( ($row = mysql_fetch_assoc($result))) {
        // Determine category hierarchy
        if (count($cats)) {
            while ($cats && $cats[count($cats)-1]['rgt'] < $row['rgt']) {
                array_pop($cats);
            }
        }
        $cats[] = $row;
        // Add this category to the hierarchy
        if ($row['cid'] == USER_GAL_CAT) {
            // User galleries
            $options .= '<optgroup label="' . $lang_common['personal_albums'] . '">' . $LINEBREAK;

            if (GALLERY_ADMIN_MODE) {
                $result2 = cpg_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name "
                    . "FROM {$cpg_udb->usertable} ORDER BY {$cpg_udb->field['username']}", $cpg_udb->link_id);
                $users = cpg_db_fetch_rowset($result2);
                mysql_free_result($result2);
            } else {
                $users = array(array('user_id' => USER_ID, 'user_name' => USER_NAME));
            }
           
            foreach ($users as $user) {
                if (!empty($albums[$user['user_id'] + FIRST_USER_CAT])) {
                    $options .= '<optgroup label="&nbsp;&nbsp;&nbsp;&nbsp;' . $user['user_name'] . '">' . $LINEBREAK;
                    foreach ($albums[$user['user_id'] + FIRST_USER_CAT] as $aid => $title) {
                        $options .= sprintf('<option value="%d"%s>%s</option>' . $LINEBREAK, $aid, $aid == $selected ? ' selected="selected"' : '', '&nbsp;&nbsp;&nbsp;&nbsp;'.$title);
                    }
                    $options .= '</optgroup>';
                }
            }
            $options .= '</optgroup>';
            unset($users);
            continue;
        }
        // construct a category hierarchy string breadcrumb style
        $elements = array();
        foreach ($cats as $cat) {
            $elements[] = $cat['name'];
        }
        $hierarchy = implode(' - ', $elements);
        // calculate indent for this level
        $indent = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', (count($elements) - 1));
        // albums in the category
        if (!empty($albums[$row['cid']])) {
            // category header
            $options .= '<optgroup label="' . $indent . $hierarchy . '">' . $LINEBREAK;
           
            foreach ($albums[$row['cid']] as $aid => $title) {
                $options .= sprintf('<option value="%d"%s>%s</option>' . $LINEBREAK, $aid, $aid == $selected ? ' selected="selected"' : '', $indent . $title);
            }
           
            $options .= '</optgroup>';
        }
    }
    return $options;
}


Please report if it works as expected in as many browsers as possible. I just checked it in Firefox and Chrome.

pols1337

Hi Andre,

Did as you requested.  I tested and it works in in:

Internet Explorer (64-bit) 9
Mozilla Firefox 13.0.1
Google Chrome

Resolved

Αndré

Change committed in SVN revision 8468. Will be included in cpg1.5.22.

pols1337

Hi Andre,

I have a follow-up suggestion regarding the Batch Add "Put files of ..." that maybe you can think about:

Instead of showing ALL the albums immediately, maybe show a collapsible (like the Config menu) or navigable folder structure.  For people with only a few albums, this may not make a difference.  But for people with hundreds of folders, this would help a lot.  Just a thought. 

Joel

P.S.  By the way, good job on all of the support!  I haven't visited the forums in a couple of weeks, but you and the other developers and support staff do an amazing job of answering questions.   

Αndré

That's a feature that won't be included to cpg1.5.x. Please post your suggestion in the feature requests board so we maybe can add it to a later release of Coppermine.