-
AuthorPosts
-
July 16, 2008 at 6:26 pm #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 FriendSherlock
- Join date:
- September 2014
- Posts:
- 11453
- Downloads:
- 0
- Uploads:
- 88
- Thanks:
- 221
- Thanked:
- 2478 times in 2162 posts
July 17, 2008 at 9:13 am #260466hi spectramaster
Can you say more detail ?July 17, 2008 at 4:18 pm #260549I 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 B2I 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 FriendSherlock
- Join date:
- September 2014
- Posts:
- 11453
- Downloads:
- 0
- Uploads:
- 88
- Thanks:
- 221
- Thanked:
- 2478 times in 2162 posts
July 22, 2008 at 3:36 am #261301Hi 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 FriendSherlock
- Join date:
- September 2014
- Posts:
- 11453
- Downloads:
- 0
- Uploads:
- 88
- Thanks:
- 221
- Thanked:
- 2478 times in 2162 posts
July 22, 2008 at 3:38 am #2613032. 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 FriendSherlock
- Join date:
- September 2014
- Posts:
- 11453
- Downloads:
- 0
- Uploads:
- 88
- Thanks:
- 221
- Thanked:
- 2478 times in 2162 posts
July 22, 2008 at 3:42 am #2613043.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;
}1 user says Thank You to Sherlock for this useful post
Sherlock FriendSherlock
- Join date:
- September 2014
- Posts:
- 11453
- Downloads:
- 0
- Uploads:
- 88
- Thanks:
- 221
- Thanked:
- 2478 times in 2162 posts
July 22, 2008 at 3:42 am #261305hope can help you
July 23, 2008 at 11:25 pm #261847I’m trying your code right now. Thanks a lot for your help!!!
-
AuthorPosts
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