test
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • spectramaster Friend
    #130942

    Hi, I have searching the forums over and over again and there seems to be any answer regarding whether it’s possible or not to select multiple galleries for a user-uploaded image.

    At the very least, how could I change the dropdown box to a selection box? I don’t care if I have to hard-code the parent and child galleries.

    Thanks in advance for your help!!!

    Sherlock Friend
    #260466

    hi spectramaster
    Can you say more detail ?

    spectramaster Friend
    #260549

    I have the following gallery structure:

    1 gallery A
    1.1 subgallery A1
    1.2 subgallery A2
    2 gallery B
    2.1 subgallery B1
    2.2 subgallery B2

    I would like my users to select one or more subgalleries to upload one photo. I thought a checkbox would be the preferred input method. Is this possible to implement in the frontend upload function and/or does rsgallery2 support the same image in multiple galleries?

    If it’s not possible to have the same image in multiple galleries, can I at least convert the dropdown box into a checkbox? Thanks for any help you can provide me.

    Sherlock Friend
    #261301

    Hi spectramaster
    After try to code some days, I have some results, you can follow to add as you want
    1.Edit images.php(administratorcomponentscom_rsgallery2options folder):
    Change from:

    function uploadImage( $option ) {
    global $database;
    //Check if there are galleries created
    $database->setQuery( "SELECT id FROM #__rsgallery2_galleries" );
    $database->query();
    if( $database->getNumRows()==0 ){
    HTML_RSGALLERY::requestCatCreation( );
    return;
    }

    //Create gallery selectlist
    $lists['gallery_id'] = galleryUtils::galleriesSelectList( NULL, 'gallery_id', false );
    html_rsg2_images::uploadImage( $lists, $option );
    }

    To

    function uploadImage( $option ) {
    global $database;
    //Check if there are galleries created
    $database->setQuery( "SELECT id FROM #__rsgallery2_galleries" );
    $database->query();
    if( $database->getNumRows()==0 ){
    HTML_RSGALLERY::requestCatCreation( );
    return;
    }

    //Create gallery selectlist
    $lists['gallery_id'] = galleryUtils::galleriesSelectList_1( NULL, 'gallery_id[]', true );
    html_rsg2_images::uploadImage( $lists, $option );
    }

    Sherlock Friend
    #261303

    2. Edit images.php(administratorcomponentscom_rsgallery2 options folder):
    Change from :

    function saveUploadedImage( $option ) {
    global $id, $rsgOption;
    $title = rsgInstance::getVar('title' , '');
    $descr = rsgInstance::getVar('descr' , '');
    $gallery_id = rsgInstance::getInt('gallery_id' , '');
    $files = rsgInstance::getVar('images','', 'FILES');

    //For each error that is found, store error message in array
    $errors = array();
    foreach ($files["error"] as $key => $error) {
    if( $error != UPLOAD_ERR_OK ) {
    if ($error == 4) {//If no file selected, ignore
    continue;
    } else {
    //Create meaningfull error messages and add to error array
    $error = fileHandler::returnUploadError( $error );
    $errors[] = new imageUploadError($files["name"][$key], $error);
    continue;
    }
    }

    //Special error check to make sure the file was not introduced another way.
    if( !is_uploaded_file( $files["tmp_name"][$key] )) {
    $errors[] = new imageUploadError( $files["tmp_name"][$key], "not an uploaded file, potential malice detected!" );
    continue;
    }
    //Actually importing the image
    $e = fileUtils::importImage($files["tmp_name"][$key], $files["name"][$key], $gallery_id, $title[$key], $descr);
    if ( $e !== true )
    $errors[] = $e;

    }
    //Error handling if necessary
    if ( count( $errors ) == 0){
    mosRedirect( "index2.php?option=$option&rsgOption=$rsgOption", _RSGALLERY_ALERT_UPLOADOK );
    } else {
    //Show error message for each error encountered
    foreach( $errors as $e ) {
    echo $e->toString();
    }
    //If there were more files than errors, assure the user the rest went well
    if ( count( $errors ) < count( $files["error"] ) ) {
    echo "<br>"._RSGALLEY_ALERT_REST_UPLOADOK;
    }
    }
    }

    To

    function saveUploadedImage( $option ) {
    global $id, $rsgOption;
    $title = rsgInstance::getVar('title' , '');
    $descr = rsgInstance::getVar('descr' , '');
    $gallery_id= array();
    //$gallery_id = rsgInstance::getInt('gallery_id[]',null);
    $gallery_id=mosGetParam($_POST,'gallery_id',null);

    $files = rsgInstance::getVar('images','', 'FILES');

    //For each error that is found, store error message in array
    $errors = array();
    foreach ($files["error"] as $key => $error) {
    if( $error != UPLOAD_ERR_OK ) {
    if ($error == 4) {//If no file selected, ignore
    continue;
    } else {
    //Create meaningfull error messages and add to error array
    $error = fileHandler::returnUploadError( $error );
    $errors[] = new imageUploadError($files["name"][$key], $error);
    continue;
    }
    }

    //Special error check to make sure the file was not introduced another way.
    if( !is_uploaded_file( $files["tmp_name"][$key] )) {
    $errors[] = new imageUploadError( $files["tmp_name"][$key], "not an uploaded file, potential malice detected!" );
    continue;
    }
    //Actually importing the image
    for ($y=0;$y<count($gallery_id);$y++){
    $e = fileUtils::importImage($files["tmp_name"][$key], $files["name"][$key], $gallery_id[$y], $title[$key], $descr);
    if ( $e !== true )
    $errors[] = $e;
    }
    }
    //Error handling if necessary
    if ( count( $errors ) == 0){
    mosRedirect( "index2.php?option=$option&rsgOption=$rsgOption", _RSGALLERY_ALERT_UPLOADOK);
    } else {
    //Show error message for each error encountered
    foreach( $errors as $e ) {
    echo $e->toString();
    }
    //If there were more files than errors, assure the user the rest went well
    if ( count( $errors ) < count( $files["error"] ) ) {
    echo "<br>"._RSGALLEY_ALERT_REST_UPLOADOK;
    }
    }
    }

    Sherlock Friend
    #261304

    3.Edit config.rsgallery2.php(administratorcomponentscom_rsgallery2 folder):
    Search this function

    function galleriesSelectList( $galleryid=null, $listName='gallery_id', $style = true, $javascript = NULL )
    At the end of this funstion, add those lines:

    function galleriesSelectList_1( $galleryid=null, $listName='gallery_id[]', $style = true, $javascript = NULL ) {
    global $database;
    if ($style == true)
    $size = ' size="10"';
    else
    $size = ' size="1"';
    // get a list of the menu items
    // excluding the current menu item and its child elements
    $query = "SELECT *"
    . " FROM #__rsgallery2_galleries"
    . " WHERE published != -2"
    . " ORDER BY parent, ordering";

    $database->setQuery( $query );

    $mitems = $database->loadObjectList();

    // establish the hierarchy of the menu
    $children = array();

    if ( $mitems ) {
    // first pass - collect children
    foreach ( $mitems as $v ) {
    $pt = $v->parent;
    $list = @$children[$pt] ? $children[$pt] : array();
    array_push( $list, $v );
    $children[$pt] = $list;
    }
    }

    // second pass - get an indent list of the items
    $list = mosTreeRecurse( 0, '', array(), $children, 9999, 0, 0 );

    // assemble menu items to the array
    $mitems = array();
    //tungps change here
    $mitems[] = mosHTML::makeOption( '0', _RSGALLERY_SELECT_GAL );
    //$mitems[] = mosHTML::makeOption( '-1', _RSGALLERY_ALL_GAL );

    foreach ( $list as $item ) {
    $mitems[] = mosHTML::makeOption( $item->id, '   '.stripcslashes($item->treename) );
    }

    $output = mosHTML::selectList( $mitems, $listName, 'multiple="1" class="inputbox"'.$size.' '.$javascript, 'value', 'text', $galleryid );

    return $output;
    }

    Sherlock Friend
    #261305

    hope can help you

    spectramaster Friend
    #261847

    I’m trying your code right now. Thanks a lot for your help!!!

Viewing 8 posts - 1 through 8 (of 8 total)

This topic contains 8 replies, has 2 voices, and was last updated by  spectramaster 16 years, 5 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum