TinyPortal

Development => Block Codes => Topic started by: Jpg on March 18, 2007, 06:08:35 PM

Title: Quick Upload Block for SmfHacks Gallery Lite
Post by: Jpg on March 18, 2007, 06:08:35 PM
Made a code as a request for someone at Smfhacks.com
I felt like it was a good idea so I did it for them...I might as well share it here as well.. :P


global $scripturl, $modSettings, $db_prefix, $txt, $context, $settings, $boarddir;
// gallery.index.php is not loaded yet, so load it here
require_once($boarddir.'/Themes/default/languages/Gallery.english.php');

// text area tag var
$ta_tag = "TEXTAREA";

//Get the category
@$cat = (int) $_REQUEST['cat'];

// display the block info
echo '
<div class="tborder">
<form method="POST" enctype="multipart/form-data" name="picform" id="picform" action="' . $scripturl . '?action=gallery&sa=add2">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr class="catbg">
<td class="smalltext" width="50%" colspan="1" height="19" align="left"><b>Quick Gallery Upload</b></td>
</tr>
<tr class="windowbg2">
<td class="smalltext"><b>Title:</b><br /><input type="text" name="title" size="15" /></td>
</tr>
<tr class="windowbg2">
<td class="smalltext" align="left"><b>Category</b> </td>
</tr>
<tr class="windowbg2">
<td class="smalltext"><select name="cat">';


// get our query results to create select box
$dbresult = db_query("SELECT ID_CAT, title FROM {$db_prefix}gallery_cat ORDER BY roworder ASC", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($dbresult)){
echo '
<option value="' . $row['ID_CAT']  . '" ' . (($cat == $row['ID_CAT']) ? ' selected="selected"' : '') .'>' . $row['title'] . '</option>';
}


echo '
</select>
</td>
</tr>
<tr class="windowbg2">
<td class="smalltext" align="left"><b>Description:</b> </td>
</tr>
<tr class="windowbg2">
<td class="smalltext"><'.$ta_tag.' name="description" rows="6" cols="16"></'.$ta_tag.'></td>
</tr>
<tr class="windowbg2">
<td class="smalltext" align="left"><b>Keywords:</b> </td>
</tr>
<tr class="windowbg2">
<td class="smalltext"><input type="text" name="keywords" maxlength="100" size="15" /></td>
</tr>
<tr class="windowbg2">
<td class="smalltext" align="left"><b>' . $txt['gallery_form_uploadpic'] . '</b> </td>
</tr>
<tr class="windowbg2">
<td class="smalltext"><input type="file" size="12" name="picture" /></td>
</tr>';

if(!empty($modSettings['gallery_commentchoice'])){
echo '
<tr class="windowbg2">
<td class="smalltext" align="left"><b>' . $txt['gallery_form_additionaloptions'] . '</b> </td>
</tr>
<tr class="windowbg2">
<td class="smalltext"><input type="checkbox" name="allowcomments" checked="checked" /><b>Allow Comments</b></td>
</tr>';
}

echo '
<tr class="windowbg2">
<td class="smalltext" width="28%" colspan="2" height="26" align="left" class="windowbg2"><input type="submit" value="Add Picture" name="submit" /></td>
</tr>';

if(!allowedTo('smfgallery_autoapprove')){
echo '
<tr class="windowbg2">
<td class="smalltext">'.$txt['gallery_form_notapproved'].'</td>
</tr>';
}

echo '
</table></form></div>
';


Put this is a Php box.
Updated Thanks to Thurnok :P
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: pvisser on March 19, 2007, 08:14:34 AM
is this going in an PHP box, because when i do then after enable the box and then edit the box again the coding is runnen past the coding box is the box settings. Its to wide. Whel its a supper idear.
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: edwardsiow on March 19, 2007, 04:04:30 PM
"is this going in an PHP box, because when i do then after enable the box and then edit the box again the coding is runnen past the coding box"

this happen on me too...but everytime i want to edit, i have to delete the phpbox first....then add a new one....is it the TP bugs or?
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Jpg on March 19, 2007, 09:09:02 PM
I said it doesn't work well with Internet explorer. :P
And yeah I think it might be a Tp error.
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Thurnok on March 20, 2007, 03:34:48 AM
This is not a TP bug.

This is simply a peculiarity that one must be aware of when operating from within EVAL() functions which TP uses for blocks.  Since the editor for blocks is a TEXTAREA you cannot embed a </textarea> tag in your block directly since it will close the editor textarea tag.

Instead, you need to break it up or call it as a variable so that it is parsed after the EVAL().

See the modified code in JPGs first post.
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Jpg on March 20, 2007, 03:36:56 AM
Ah I see, it edits onto the code that Tp uses for blocks...I see. :P
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: superQ on March 20, 2007, 08:38:23 PM
This one is nice, but when I looked at it in edit the code did not stay in the box in any theme. It went in right  then when I look at it asfter saving it it is out... Happened 3 times--and currently?

Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: G6Cad on March 20, 2007, 08:50:35 PM
What have you done there ?

You seem to have errors in the templatefiles aswell.
Reupload the TP files to your forum again, Use the Manual install package and just replace the files with the old you have.
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Jpg on March 20, 2007, 08:56:02 PM
Lol, blame Thurnok...*points to Thurnok*  :D

I guess it's a one time edit deal for now...

[Same thing happens to me G6..it's the php block's code..not Tp itself...]
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: superQ on March 20, 2007, 09:10:44 PM
I was wondering why I don't see any errors ... I meant to ask if you had that prob JPG.  :coolsmiley:

I Think I have become pre-programmed to think I did something to screw it up :o My first thought is usually "what did the Q do now" :uglystupid2:
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Thurnok on March 21, 2007, 02:01:34 AM
OMG! LOL!!!

That's what I get for editing php code in the message editor!  LOL.. ok, I fixed it and replaced it in JPGs first post. ... hehe... wooopsie!  :)
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Jpg on March 21, 2007, 02:46:52 AM
Quote from: Thurnok on March 21, 2007, 02:01:34 AM
OMG! LOL!!!

That's what I get for editing php code in the message editor!  LOL.. ok, I fixed it and replaced it in JPGs first post. ... hehe... wooopsie!  :)

Thanks man. :D
I appreciate it.
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: superQ on March 21, 2007, 03:28:09 AM
hmmm-- don't seem to want to fit right in any theme

www.therockpile.org

on the left

check that :uglystupid2: it just don't look right in default and the one's I want to  use ???
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: alhaudhie on March 21, 2007, 05:58:51 PM
my left block not the default size, but smaller than the default. how can i resize this code to make same size with my left side block?
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: superQ on March 21, 2007, 06:05:22 PM
Yea I see that too---do me a favor and check your forum error log and see if it has any since you installed this. I am seeing 2. Maybe permission thing???

8: Undefined index: gallery_form_notapproved
File: /home2/^^^^^/public_html/Themes/default/Search.template.php (eval?)
Line: 73

and:

8: Undefined index: gallery_form_uploadpic
File: /home2/8888888/public_html/Themes/default/TPortal.template.php (eval?)
Line: 49
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Thurnok on March 22, 2007, 03:09:35 AM
I went thru and cleaned it up alot for JPG.  Was missing several </td>'s and other things.  Changed the table size to 95%, and included the Gallery.english.php file which contains the text strings for the gallery since they are not loaded yet at the TP Block parsing.

Don't forget, if you have really long categories, the block will spill over into your centerblocks/articles because the select component will size to the largest category name size.
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Jpg on March 22, 2007, 03:15:47 AM
Quote from: Thurnok on March 22, 2007, 03:09:35 AM
I went thru and cleaned it up alot for JPG.  Was missing several </td>'s and other things.  Changed the table size to 95%, and included the Gallery.english.php file which contains the text strings for the gallery since they are not loaded yet at the TP Block parsing.

Don't forget, if you have really long categories, the block will spill over into your centerblocks/articles because the select component will size to the largest category name size.

Dude...I would kiss you if you weren't a dude. :D
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: superQ on March 22, 2007, 03:33:12 AM
Thanks Thurnok---error free :up: :up: :up:
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Thurnok on March 22, 2007, 03:33:36 AM
oops.. heh.. I left out a class statement for one column.... anyway, it should look fairly good now...  fixed..
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: G6Cad on March 22, 2007, 06:35:50 AM
QuoteDude...I would kiss you if you weren't a dude.

I can kiss him for you  :-*  :-*  :-*
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Thurnok on March 22, 2007, 06:40:03 AM
Quote from: G6â„¢ on March 22, 2007, 06:35:50 AM
I can kiss him for you  :-*  :-*  :-*

Woohoo!  I'll hold you to that at the TP Convention!  :-*
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: G6Cad on March 22, 2007, 06:41:13 AM
Youd better have lifeguard with you  :coolsmiley:
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Thurnok on March 22, 2007, 06:43:43 AM
I think you will be the lifeguard. Of course, I'll be the drowning victim and need mouth-to-mouth resuscitation.  ;)
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: G6Cad on March 22, 2007, 06:51:53 AM
 ;D
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Thurnok on April 01, 2007, 06:43:29 AM
I put a small fix in the code in the first post of this topic.  Should make it look right in various themes.

Don't forget however, that the form elements (input boxes, etc.) are all static, so depending on the theme and your block size, you might need to downsize  some of the elements.
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: fotografo74 on February 24, 2009, 11:26:01 AM
Hi :-)
Thanks for this Mod.
It's possibile convert the query ( get id_cat) for works with SMF2RC1 ?
Thanks
Antonio
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Ken. on February 24, 2009, 12:44:50 PM
You'll need to wait for a while fotografo74, TinyPortal has not yet been released or updated to work with SMF 2.0 and so there are no blocks for it at this time.
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: dimdom on February 24, 2009, 12:53:29 PM
Excellent code...

Is it possible to exclude certain categories from showing up in the dropdown list?
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: fotografo74 on February 24, 2009, 01:20:28 PM
Quote from: Ken. on February 24, 2009, 12:44:50 PM
You'll need to wait for a while fotografo74, TinyPortal has not yet been released or updated to work with SMF 2.0 and so there are no blocks for it at this time.
Ok, i'm waiting :-) ( and i'm waiting for TP2! )
I use SMF Gallery  Random Images by Thurnok with SMF2...and works! :-)
forum test:    www.macroforum.org/smf2rc/index.php

I need your block for works with SMF2 :-)
Thanks!
Antonio
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: Ken. on February 24, 2009, 01:58:57 PM
Quote from: fotografo74 on February 24, 2009, 01:20:28 PM
Quote from: Ken. on February 24, 2009, 12:44:50 PM
You'll need to wait for a while fotografo74, TinyPortal has not yet been released or updated to work with SMF 2.0 and so there are no blocks for it at this time.
Ok, i'm waiting :-) ( and i'm waiting for TP2! )
I use SMF Gallery  Random Images by Thurnok with SMF2...and works! :-)
forum test:    www.macroforum.org/smf2rc/index.php

I need your block for works with SMF2 :-)
Thanks!
Antonio

Your test forum is running SimplePortal 2.1.1, so you should be asking them for a block code... we only do block codes for TinyPortal. :)
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: fotografo74 on February 24, 2009, 03:32:17 PM
Quote from: Ken. on February 24, 2009, 01:58:57 PM
Quote from: fotografo74 on February 24, 2009, 01:20:28 PM
Quote from: Ken. on February 24, 2009, 12:44:50 PM
You'll need to wait for a while fotografo74, TinyPortal has not yet been released or updated to work with SMF 2.0 and so there are no blocks for it at this time.
Ok, i'm waiting :-) ( and i'm waiting for TP2! )
I use SMF Gallery  Random Images by Thurnok with SMF2...and works! :-)
forum test:    www.macroforum.org/smf2rc/index.php

I need your block for works with SMF2 :-)
Thanks!
Antonio

Your test forum is running SimplePortal 2.1.1, so you should be asking them for a block code... we only do block codes for TinyPortal. :)
Sure,but i will install TP2 in future...i'm waiting! in www.macroforum.org,official forum,i have TP.
The php block,and code,works to TP and SimplyPortal.
i will try modify myself the query for get id category. Without the query the block shows ok,but is not the category list.
Thanks!
antonio
Title: Re: Quick Upload Block for SmfHacks Gallery Lite
Post by: fotografo74 on March 01, 2009, 09:53:49 AM
I solved :-)
Now the code works with SMF2 RC1  ( i'm waiting TP2, now i use Simple Portal)

global $smcFunc, $scripturl, $txt, $context, $settings, $modSettings, $boarddir;
// gallery.index.php is not loaded yet, so load it here
require_once($boarddir.'/Themes/default/languages/Gallery.italian.php');

// text area tag var
$ta_tag = "TEXTAREA";

//Get the category
@$cat = (int) $_REQUEST['cat'];



// display the block info
echo '
<div class="tborder">
<form method="POST" enctype="multipart/form-data" name="picform" id="picform" action="' . $scripturl . '?action=gallery&sa=add2">
<table border="0" cellpadding="0" cellspacing="0" width="95%" align="center" height="129">
</tr>

<tr class="windowbg2">
<td class="smalltext"><b>Titolo:</b><br /><input type="text" name="title" size="15" /></td>
</tr>
<tr class="windowbg2">
<td class="smalltext" align="left"><b>Categoria</b> </td>
</tr>
<tr class="windowbg2">
<td class="smalltext"><select name="cat">';


// get our query results to create select box
$dbresult = $smcFunc['db_query'] ('', "
SELECT
id_cat, title, orderby
FROM {db_prefix}gallery_cat
ORDER BY roworder DESC");
while($row = $smcFunc ['db_fetch_assoc'] ($dbresult)) 


if (($row['id_cat'] != 1) && ($row['id_cat'] != 15) && ($row['id_cat'] != 16)) 
{    echo '             <option value="' . $row['id_cat']  . '" ' . (($cat == $row['id_cat']) ? ' selected="selected"' : '') .'>' . $row['title'] . '</option>'; }


echo '
</select>
</td>
</tr>
<tr class="windowbg2">
<td class="smalltext" align="left"><b>Descrizione:</b> </td>
</tr>
<tr class="windowbg2">
<td class="smalltext"><'.$ta_tag.' name="description" rows="6" cols="16"></'.$ta_tag.'></td>
</tr>
<tr class="windowbg2">
<td class="smalltext" align="left"><b>Parole chiave:</b> </td>
</tr>
<tr class="windowbg2">
<td class="smalltext"><input type="text" name="keywords" maxlength="100" size="15" /></td>
</tr>
<tr class="windowbg2">
<td class="smalltext" align="left"><b>' . $txt['gallery_form_uploadpic'] . '</b> </td>
</tr>
<tr class="windowbg2">
<td class="smalltext"><input type="file" size="12" name="picture" /></td>
</tr>';

if(!empty($modSettings['gallery_commentchoice'])){
echo '
<tr class="windowbg2">
<td class="smalltext" align="left"><b>' . $txt['gallery_form_additionaloptions'] . '</b> </td>
</tr>
<tr class="windowbg2">
<td class="smalltext"><input type="checkbox" name="allowcomments" checked="checked" /><b>Permetti commenti</b></td>
</tr>';
}

echo '
<tr class="windowbg2">
<td class="smalltext" width="28%" colspan="2" height="26" align="left" class="windowbg2"><input type="submit" value="Carica foto" name="submit" /></td>
</tr>

</table><br />
';



echo '
</form>
</div>';


I se that category number 1-15-16 in my Smf Gaeery Pro not display.
Antonio