Google Image Mod - Posted (1426 Views)
Advanced Member
Carefree
Posts: 4224
4224
I'm working on a little mod, ran into a snag getting the URL variable in the func common tags to work right. I'm not getting the first strTempString value to appear.
Code:

   CodeTags(1,1,2) = "<a href=""originalurl&q="& strTempString & """>" & strTempString
CodeTags(1,2,2) = "</a>"
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
New Member
kyodai
Posts: 74
74
I'd personally have put a blank in before the ampersand but i can't see any real error here.
Posted
Advanced Member
Carefree
Posts: 4224
4224
Never mind. Fixed it using a different approach.
Posted
Development Team Member
Davio
Posts: 12217
12217
Care to share for the benefit of others?
Posted
Advanced Member
Carefree
Posts: 4224
4224
I'll have to separate my notes and write it up, Davio. Working on too many things at the same time. It still has one bug to work out.

OK, here's what I did for the guy. He wanted a single button added to the editor functions so that he could put in a hotlink to Google images about a particular subject.

Save this to your images folder as "icon_editor_gimage.png": [IMG]http://i53.tinypic.com/2zdotmo.png[/IMG]
Code:

"inc_func_common.asp"

Search for the following line (appx 1555):

Sub WriteFooter() %>

Above it, insert the following:

' ##### GImage Below #####
Function ReplaceGImageTags(fString)
Dim oTag, cTag
Dim roTag, rcTag
Dim oTagPos, cTagPos
Dim nTagPos
Dim counter1, counter2
Dim strCodeText
Dim Tagcount
Dim strTempString, strResultString
TagCount = 2
Dim CodeTags(2,2,2)
Dim strArray, strArray2
CodeTags(1,1,1) = "[GImage]"
CodeTags(1,2,1) = "[/GImage]"
CodeTags(1,1,2) = "<a href=""http://images.google.com/images?hl=en&source=img&q="
CodeTags(1,2,2) = "</a>"
CodeTags(2,1,1) = "[GImage]"
CodeTags(2,2,1) = "[/GImage]"
CodeTags(2,1,2) = CodeTags(1,1,2)
CodeTags(2,2,2) = CodeTags(1,2,2)
strResultString = ""
strTempString = fString
for counter1 = 1 to TagCount
oTag = CodeTags(counter1,1,1)
roTag = CodeTags(counter1,1,2)
cTag = CodeTags(counter1,2,1)
rcTag = CodeTags(counter1,2,2)
oTagPos = InStr(1, strTempString, oTag, 1)
cTagPos = InStr(1, strTempString, cTag, 1)
if (oTagpos > 0) and (cTagPos > 0) then
strArray = Split(strTempString, oTag, -1)
for counter2 = 0 to Ubound(strArray)
if (Instr(1, strArray(counter2), cTag) > 0) then
strArray2 = split(strArray(counter2), cTag, -1)
strCodeText = trim(strArray2(0))
strResultString = strResultString & roTag & strCodeText & """ target=""_blank"">" & strCodeText & rcTag & strArray2(1)
else
strResultString = strResultString & strArray(counter2)
end if
next
strTempString = strResultString
strResultString = ""
end if
next
ReplaceGImageTags = strTempString
End Function
' ##### GImage Above #####

Next, search for the following line (appx 146):

FormatStr = fString

Above it, insert the following:

' ##### GImage Below #####
fString = ReplaceGImageTags(fString)
' ##### GImage Above #####

"inc_iconfiles.asp"
Search for the following line (appx 148):

Const strIconZap = "icon_zap.gif|16|16"

Below it, add the following:

' ##### GImage Below #####
Const strIconGImage = "icon_editor_gimage.png|23|22"
' ##### GImage Above #####

"inc_post_buttons.asp"
Search for the following lines (appx 61-63):

if strIMGInPosts = "1" then
Response.Write "<a href=""Javascript:image();"" tabindex=""-1"">" & getCurrentIcon(strIconEditorImage,"Insert Image","align=""top""") & "</a>" & vbNewLine
end if

Change them to say:

if strIMGInPosts = "1" then
Response.Write "<a href=""Javascript:image();"" tabindex=""-1"">" & getCurrentIcon(strIconEditorImage,"Insert Image","align=""top""") & "</a>" & vbNewLine
' ##### GImage Below #####
Response.Write "<a href=""Javascript:GImage();"" tabindex=""-1"">" & getCurrentIcon(strIconGImage,"Google Images","align=""top""") & "</a>" & vbNewLine
' ##### GImage Above #####
end if

"inc_code.js"
Add the following to the very bottom of the file:

function GImage() {
var text = getText();
if (helpstat) {
alert("GImage tag searches for related images on Google.\n\nUSE: [GImage](words to search for)[/GImage]");
} else if (basic) {
AddTxt="[GImage]" + text + "[/GImage]";
AddText(AddTxt);
} else {
if (text) {
txt=prompt("Image to search for.",text);
} else {
txt=prompt("Image to search for.","Insert words describing image to search for.");
}
if (txt!=null) {
AddTxt="[GImage]"+txt+"[/GImage]";
AddText(AddTxt);
}
}
}
 
You Must enter a message