UPGRADED: Cut-and-paste linking codes (HTML, bbCode, bookmark/tag) UPGRADED: Cut-and-paste linking codes (HTML, bbCode, bookmark/tag)
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

UPGRADED: Cut-and-paste linking codes (HTML, bbCode, bookmark/tag)

Started by thejake420, April 03, 2006, 08:30:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

thejake420

Note: See updates further down in this thread, as the scope of this project has changed somewhat, and now incorporates CPMFetch.
---------------

I would like to add a "Add this to your MySpace" (or website, or blog, etc.) I can handle the coding of this part itself, but I'm absolutely lost when it comes to the templating system used in CPG. I dunno if this is in line with the "one question per thread" idea, but it is all associated with one concept... I jst can't find the right places to grab teh appropriate variables, etc. Mods, feel free to break this into a couple of threads if you prefer, though I think that this ought to stay as is due to the fact that so many users would like this functionality. (Which I'll be glad to share once I figure out how to generate the assorted URLs and so forth that I need to finish the code.) It definitely falls under skinning, etc, but it might be big enough of a project to put in a "mods wanted" thread. Either way, I need a little help, and then I can take it from there and work out the rest of the mod.

Here's a pretty relevant (non-CPG) of what I'm trying to do: http://www.bofunk.com/video/991/sexy_runner.html#myspacecode

Note: I'm going to be thinking out loud here so that anybody who wants to assist (or use this) can stay on the same train of thought as me.

Here's what I'm thinking so far... (My site has lots of pics, videos, and flash (and more, but nobody would really want to feature a font on their MySpace/Blog... LOL), so it needs to work across the board, regardless of media type. I mention this only because Pics generate thumbs automatically, whereas videos require a custom thumb, and I'm not sure whether this makes a difference. Most of my vids have custom thumbs, but I need to be able to default to the generic media thumb if the video has no custom thumb associated with it.)

I will need the following URLs in variable form:
1. The Static URL for the page (displayimage.php?pos=-2724)
2. The URL for the associated thumbnail, or if no thumb then the associated generic thumb
3. The direct URL to the video/picture (There's a variation of it mentioned here: http://forum.coppermine-gallery.net/index.php?topic=3082.0)

From there, it seems that I can just write code along the lines of:

1. (code to determine filetype and generate appropriate embed code)
2. If it is a picture, simply use the pic's URL
3. If it is a video, use the same embed code as is on the displayimage.php page already (should be easy enough since the page has already generated it)
4. Since the video, etc. will be in a table on the user's site, the next table row will have a "This came from" nice link pointing to example.com/gallery/displayimage.php?pos=-$MISSINGVARIABLE, and another "View more funny pictures and videos at" link pointing to the main gallery. (The second part can be hardcoded to whatever URLs you desire for your site unless somebody turns it into a "legitimate" mod, in which case you can use variables.)
5. Side thought: It'll need to be in an iframe so that I can use a custom PHP page (which I'll need to write from scratch) to call and show the video. That way, the video is being called from MY site, and I can still block hotlinking via .htaccess.

Any of this make sense? Here's a screenshot of the envisioned finished product, as it would appear on the user's website.blog.MySpace, etc.

http://www.jakesjokes.com/img/examplevideo.jpg

Edit:
To clarify, I specifically need to know how to find (or call) the variables that represent the static URL, the thumbnail URL, and the absolute URL for the image/video.

Edit:
The only reference to a variable that seems like it would work is in line 170 of displayimage.php.

    $info[$lang_picinfo['URL']] = '<a href="' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') .basename($_SERVER['PHP_SELF']) . "?pos=-$CURRENT_PIC_DATA[pid]" . '" >' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') . basename($_SERVER['PHP_SELF']) . "?pos=-$CURRENT_PIC_DATA[pid]" . '</a>';


With the relevant portion being the part below...

?pos=-$CURRENT_PIC_DATA[pid]


Am I at least getting into the right neighborhood? Anybody? Gurus? Non-gurus? Santa Claus? I'll accept feedback/help from anybody... ;)

PS - A little off-topic, but I've noticed a distinct lack of activity in this thread from anyond other than me. Is there anybody out there interested in this sort of thing, or doesn't anybody else enjoy getting lots of traffic? ;) Yes, allowing yoru pics and videos to show on other sites uses your bandwidth, but bandwidth is cheap nowadays. I won't promote my host right now (because I wouldn't be able to stop myself from using my affiliate link to do so), but I have thousands and thousands of visitors daily (enough to make a full time living from the site), and don't even come close to using my allotted bandwidth... and I pay less than $50 a month for the whole package (bear in mind that that includes a lot of extras that most people wouldn't need... prices are as low as $7.95 for packages that are actually good and not "barebones" hosting. Of course there are also those who charge less (though I can't vouch for their reliability, so do your research...) Besides, if it is on a small site with little traffic, you won't use much bandwidth. If it's on a large site, it'll use a decent amount of bandwidth, but it will result in more visitors to your site, hence making you back the money to pay for the bandwidth (assuming you have ads, etc.)


Jake

Joachim Müller

Quote from: thejake420 on April 03, 2006, 08:30:49 AM
A little off-topic, but I've noticed a distinct lack of activity in this thread from anyond other than me. Is there anybody out there interested in this sort of thing, or doesn't anybody else enjoy getting lots of traffic? ;)
You're about to create yet-another-port, which is something we (the coppermine devs) are not particulalry fond of: we've seen them come and go (cpgnuke, cpf for e107, cpg for xoops, pnCPG, cpg for PragmaMx etc.), and the only benefit we had are additional questions of users who used the ports and turned up on this board, asking questions on code we didn't know, asking for updates we didn't have and blaming us for broken stuff that we didn't break. You're free to come up with your port, it's perfectly legal. But please make sure that your users will understand that they can not get support from the coppermine dev team. The author of pnCPG provides support for his modifications in a sub-board of this forum, which is fine. The PragmaMx and Dragonfly people provide support on their own pages and provide their own documentation, that's fine as well.
That's why so far none of the devs posted imo - they probably see little benefit for the coppermine project nor for coppermine users (this is at least the case for me). We're fond of code contributers (givers), but we won't fly to the rescue if someone needs coding help for a port.


Quote from: thejake420 on April 03, 2006, 08:30:49 AMI will need the following URLs in variable form:
1. The Static URL for the page (displayimage.php?pos=-2724)
2. The URL for the associated thumbnail, or if no thumb then the associated generic thumb
3. The direct URL to the video/picture
I'm not sure what you're asking though, as you're surely aware that vars are available in special places only. Some vars need to be made global within your custom functions. Search the code for pid, check the following arrays: $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER

Other stuff you might be interessted in: take a look at cpmFetch - this is the most recommended method to get coppermine data from non-coppermine pages.

thejake420

GauGau: Feel free to move this, if you feel that it is more appropriate in another forum.

However, I'm not making a port. This will be used ONLY for producing cut and paste code so that a user (any user on any site) can simply show my material on any standard HTML page, but without violating my no hotlinking rule in .htaccess. (Since my own php file would call the video.) It is basically the same thing as cut and paste linking code for banners, except that the content in the cut and paste box will change based on whatever item happens to be showing on that page. (Hence the need for the static URLs.) My "offsite.php" page will handle putting everything in a nice iframe, putting the content and linkback in a nice table, etc. Since it is being included, I should be able to use variables used in displayimage.php in offsite.php (I'll do my own research on the PHP part of things re: sharing variables with included pages, etc.)

it's actually a really simple modification and will not require any editing of core code, with the exception of adding an "include offsite.php" statement somewhere in the webmaster's theme.php (which would include whatever code needs copied from sample theme.php since you've made it clear that editing theme.inc.php is not a good option.)

I guess the basic question is this: Specifically, what code do I need to copy from the sample theme.php so that I can include the offsite.php file in a new table directly under the "Add your comment" section on displayimage.php? (I'm OK on the PHP side of things for this project, but I suck at external templates, such as they exist in CPG, especially since not everything is in every template)

In other words:
I want to add a table just like the "Add your comment" part underneath the current "Add your comment" part. How can I acomplish this? (Everything else should fall into place after that, even if I have to figure out some of the more intricate parts by trial and error...)

CPMFetch - Looked through it because I'm all about RSS lately, but it was giving me more trouble than it was worth. ;)

PS - GauGau, you rock when it comes to sheer volume of activity around here... Thanks from me and the many others who have benefitted from your help. ;)


Jake

Joachim Müller

the page offsite.php needs to reside within the coppermine root of the page (in order to keep the includes from breaking, as they use relative paths).
Did you take a look at the arrays I told you to check? Do a print_r($array_name); to see what values exist in it.

thejake420

#4
(Understood re: location of offsite.php)

Check out the picture (link below) to make sure we're on the same page...

Example of how this would display in CPG:
http://www.jakesjokes.com/img/examplecpgmod.gif

Now I understand that it's entirely up to me to figure out how to make my offsite.php handle the 1234 part.. I'm just trying to figure out how to make the 1234 part appear as the same number as in the Permanent link in the info section. (And yes, I'll be going through the information you supplied.)

I'm doing this for two reasons... One, it just needs done. It would be an excellent addition to my sites (increased traffic), but also to any other site as a mod or if it ever got added to the core code (though it would need an on/off switch in the admin section if it were eventually included in a release, since not everybody would necessarily want it for whatever reason.) Second, I'm not a PHP pro. I'm learning, and doing projects like this (that are challenging, but not too overwhelming) force me to read, read, read, and learn, learn, learn. Six months ago, I couldn't write an if statement without using the PHP site for reference, but I've come a long way. Still not a pro, but definitely learning along the way. I have read a lot in these forums, even in topics that don't really apply to my sites.

Quote from: GauGau on April 04, 2006, 06:23:55 AM
I'm not sure what you're asking though, as you're surely aware that vars are available in special places only. Some vars need to be made global within your custom functions. Search the code for pid, check the following arrays: $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER

I was not aware of that. Thank you. I suppose I'll need to call the desired value somehow, then do a bass-ackwards method for turning it into my own simpler variables that I can pass to my own script.

I try to stay away from noob questions and things that you're not responsible for (my PHP skill level, etc.), but when it comes to stuff like figuring out how to display a specific (albeit dynamic) value, sometimes it's better to just ask than to spend a month digging through code. I'm on the right track, but as you (and the other CPG gurus) are obviously more experienced with the inner workings of CPG than I am, I figured I'd ask about a couple of things... Like, I found the part where it displays an static URL in the info section, but decrypting it is a little complicated, since it's not as basic as I would have expected. (There's ecard references, etc., rather than what I expected to be a simple href with a $thispicture at the end...)

Thanks again!


Jake


thejake420

Perfect. I've actually been through both threads, but as they didn't apply to me (when I saw them), I didn't remember them. (Duh...)

I'll be working on this throughout the week, and I'll let you know when I get it working.


Jake

thejake420

#7
WARNING: To anyone looking at this as a potential modification that they would like for their site, please note that I've made some VERY UNORTHODOX modifications to CPG so that it would what I need it to do. These modifications aren't recommended for most users, as it involves directly editing /include/themes.inc.php (which is a big "no-no" accoring to the CPG developers) and displayimage.php. At some point, either I (or someone) will likely come up with a better method of doing this. Consider this a "proof of concept" only, and follow along at your own risk. You've been warned. ;)

I'm sharing all the code I've come up with to contribute to the CPG project in some way. (Much of it makes use of CPMFetch anyway)

Update: The script is coming along nicely (with the help of CPMFetch). I've got everything working except one little detail.

Known current issue:
1. The table (as laid out in the code below) with the cut and paste code (which in my version is located directly beneath the picture or video) doesn't look very pretty. That is merely cosmetic, and I simply haven't prettied it up since I'm still working on the whole "getting it to work right" part. This very minor issue will be fixed soon.

2. In displayimage.php, I define the variable $absoluteid to match the pid. This variable works as expected when called from displayimage.php (where it is defined), but not from themes.inc.php. (I don't know how to "properly" add the relevant parts to my custom theme, or I would be doing it there. Assistance is welcome on this issue. I'm pretty sure it's a relatively simple matter relating to variable scope, but I can't quite put my finger on the solution.)

As for the rest, I'm actually pretty far along. My script randomoffsite.php works exactly as expected. Every time the page is refreshed, a new one appears. The offsite.php works as expected, and processes a URL-based query string for the pid.

My mod so far (note warning above before attempting):

Paths:
randomoffsite.php - Root
offsite.php - Root
CPMFetch - site.com/cpmfetch/
Coppermine Gallery - site.com/gallery/

randomoffsite.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>JakesJokes.com Random Media Linker</title>
<?php
require_once 
"./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gallery");
?>

<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
}
-->
</style>
</head>

<body>

<table width="125" height="150" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
  <tr>
    <td width="125" height="125"><div align="center">
        <?
$styleguide = array(
"imagestyle" => "test1", "linkstyle" => "test1","imagewidth" => "100","imageheight" => "100",
"alttag" => "File: %t - Album: %a - Courtesy of JakesJokes.com ",
"subtitle" => "%t<br>Popularity: %h");

$objCpm->cpm_viewRandomMediaFrom(1,1,"cat=3",$styleguide);
//$objCpm->cpm_viewLastAddedMediaFrom (1,1, "$source");
//cpm_viewLastAddedMedia (1, 5, [array $options = ""])
?>
    </div></td>
  </tr>
  <tr>
    <td height="25"><?
if ( $type == "video" ) {
    ?>
        <div align="center"><a href="http://www.jakesjokes.com/gallery/" class="style1">More funny videos</a></div>
        <?
} elseif($type == "picture"){
    ?>
        <div align="center"><a href="http://www.jakesjokes.com/gallery/" class="style1">More funny pictures</a></div>
        <?
} else {
    ?>
        <div align="center"><a href="http://www.jakesjokes.com/gallery/" class="style1">More free fun stuff</a></div>
        <?
}
?>
    </td>
  </tr>
</table>
</body>
</html>


offsite.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>JakesJokes.com Specific Media Linker</title>
<?php
require_once 
"./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gallery");
?>

<style type="text/css">
<!--
.style1 { font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
}
-->
</style>
</head>

<body>

<table width="125" height="150" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
  <tr>
    <td width="125" height="125"><div align="center">
        <?
$styleguide = array(
"imagestyle" => "test1", "linkstyle" => "test1","imagewidth" => "100","imageheight" => "100",
"alttag" => "File: %t - Album: %a - Courtesy of JakesJokes.com ",
"subtitle" => "%t<br>Popularity: %h");

$objCpm->cpm_viewMediaByPid($absoluteid,$styleguide);
//$objCpm->cpm_viewRandomMediaFrom(1,1,"cat=3",$styleguide);
//$objCpm->cpm_viewLastAddedMediaFrom (1,1, "$source");
//cpm_viewLastAddedMedia (1, 5, [array $options = ""])
?>
    </div></td>
  </tr>
  <tr>
    <td height="25"><?
if ( $type == "video" ) {
    ?>
        <div align="center"><a href="http://www.jakesjokes.com/gallery/" class="style1">More funny videos</a></div>
        <?
} elseif($type == "picture"){
    ?>
        <div align="center"><a href="http://www.jakesjokes.com/gallery/" class="style1">More funny pictures</a></div>
        <?
} else {
    ?>
        <div align="center"><a href="http://www.jakesjokes.com/gallery/" class="style1">Free videos<br>and pictures</a></div>
        <?
}
?>
    </td>
  </tr>
</table>
</body>
</html>


Mod to /include/themes.inc.php: (Near line 668)
// HTML template for intermediate image display

if (!isset($template_display_media))  //{THEMES}
$absoluteid = "$CURRENT_PIC_DATA[pid]";
$template_display_media = <<<EOT
        <tr>
                <td align="center" class="display_media" nowrap="nowrap">
                        <table cellspacing="2" cellpadding="0" class="imageborder">
                                <tr>
                                        <td align="center">
                                                {IMAGE}
<!-- BEGIN My table with linking will goes here -->
<table width="100%"  border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td colspan="2"><div align="center"><strong>Link to this on your website or blog!</strong><br>
    </div></td>
  </tr>
  <tr>
    <td colspan="2"><div align="center"></div></td>
  </tr>
  <tr>
    <td width="20%"><strong>Type of site: </strong></td>
    <td><strong>Code</strong></td>
  </tr>
  <tr>
    <td width="20%">Websites:</td>
    <td><textarea name="textarea" cols="50" rows="5">
&lt;iframe SRC=&quot;http://www.jakesjokes.com/offsite.php?item=$absoluteid&quot; TITLE=&quot;JakesJokes.com Media Linking Utility&quot; WIDTH=&quot;135&quot; HEIGHT=&quot;160&quot; FRAMEBORDER=&quot;0&quot; SCROLLING=&quot;no&quot;&gt; </textarea></td>
  </tr>
</table>
<!-- END My table with linking codes goes here -->
                                        </td>
                                </tr>
                        </table>
                </td></tr>
                <tr><td>
                                                <table width="100%" cellspacing="2" cellpadding="0" class="tableb">
                                <tr>
                                        <td align="center">

                                                {ADMIN_MENU}
                                        </td>
                                </tr>
                        </table>


Mod to displayimage.php: (Near line 169)
    // Create the absolute URL for display in info
    $info[$lang_picinfo['URL']] = '<a href="' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') .basename($_SERVER['PHP_SELF']) . "?pos=-$CURRENT_PIC_DATA[pid]" . '" >' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') . basename($_SERVER['PHP_SELF']) . "?pos=-$CURRENT_PIC_DATA[pid]" . '</a>';
    // with subdomains the variable is $_SERVER["SERVER_NAME"] does not return the right value instead of using a new config variable I reused $CONFIG["ecards_more_pic_target"] no trailing slash in the configure
// Jake Mod - Begin add new variable for easy reference to static URL
$itempermalink = "http://www.jakesjokes.com/gallery/displayimage.php?pos=-$CURRENT_PIC_DATA[pid]";
$absoluteid = "$CURRENT_PIC_DATA[pid]";
// Jake Mod - End add new variable for easy reference to static URL


Devs: All personal matters aside, this is a potentially useful addition to most sites. I'll eventually make it work, but I'm not a good enough coder to necessarily do it "right". But please feel free to take some of this code, de-amateur-ify it, and turn it into something a little more stable... If you get rid of my duct-tape solution and do it right, it would make a lot of users very happy.


Jake

Stramm

I somehow was to lazy to read the entire thread.. please forgive ;)
But as far as I understood from having a look at some parts you just want to have a link 'click to do something' above the pic in displayimage.php. When clicked it should display copy/past ready bbcode that links to exactly that pic?

If so, then it's pretty easy to do as a plugin

edit to give an example:
http://stramm.st.funpic.org/displayimage.php?album=4&pos=0&theme=classic
instead of the 'add to shopping basket' stuff it'll be a 'show copy/ past bbcode' link. When clicking the site refreshes and shows that stuff above the pic (instead of adding the item to the basket)

thejake420

Almost...

I will put ready HTML and BB code on the page, except I cannot get the absolute pid to appear when I call it from another file (ie - themes.inc.php)

I want to be able to reflect "displayimage.php?pos=-8774" not "displayimage.php?album=12&pos=45", anywhere on the page. I tried making pid a new variable, and it works, except I can't use it in themes.inc.php or any other file except displayimage.php (variable scope?)

There is an old BB code mod, but it is for 1.3

Any help is MUCH appreciated. :)


Jake

Stramm

There are a lot of possibilities. Everything depends on where on displayimage you want that link to show up.

eg. http://forum.coppermine-gallery.net/index.php?topic=28446.msg131612#msg131612
explains the basic way of passing data to the template (in that example $template_img_navbar -> above the pic, works similar for the other parts).


example for thumbnail view
http://forum.coppermine-gallery.net/index.php?topic=27654.msg127823#msg127823

Stramm

to show you how it works the plugin way (my fav as said, cause you won't have to change any core code but it still would work for all themes)

It's pretty much finished, have a look. Above the intermediate is the link you wanted to have. If you click it, the page refreshes and shows instead of the link the pid (absolute id). Just pop up the heredoc with whatever additional info you need

Stramm

or without the need to reload displayimage



<?php
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

// Add a filter
$thisplugin->add_filter('file_data','bbcode_add_data');


function 
bbcode_add_data($pic_data){
global $CONFIG;

    
$info '<a href=' $CONFIG["ecards_more_pic_target"] . basename($_SERVER['PHP_SELF']) . "?pos=-{$CURRENT_PIC_DATA[pid]}' >' $CONFIG["ecards_more_pic_target"] . basename($_SERVER['PHP_SELF']) . "?pos=-{$CURRENT_PIC_DATA[pid]}'</a>';

$display_data =  <<<EOT
<table align="center">
<tr>
<td>
<a href="javascript:;" onclick="blocking('bbcode','yes', 'block');return false;" title="show more">Show copy/ paste bbcode</a><br>
<div id="bbcode" style="display: none;">
<br />
<textarea cols="60" rows="1">
{$info}</textarea>
</div>
</td>
</tr>
</table>
EOT;


$pic_data['html'] = $display_data.$pic_data['html'];
return $pic_data;
}
?>

thejake420

Stramm,

You're my HERO!!!! :)

That is exactly what I needed to get me on the right track. I'll edit the codebase as needed per my requirements, but it functions perfectly. Thank you! Everything from here on out is going to be my own, but most of it is already coded and working properly. I'll share whatever I come up with for a future plugin.

PS - In case you were wondering why I'm so worried about this seemingly minor project... Aside from the obvious benefit of getting more inbound links, we also benefit from doing it "in this format" because doing this as a plugin (or mod) versus simply making the picture's actual URL (gallery/albums/.../picture.jpg) available is that we'll be able to still maintain a no-hotlinking policy via .htaccess, since the files will be called from my offsite.php script, which htaccess will allow, seeing as it's on my own server. I want to allow people to link to me, but I'm a little picky about hotlinking, considering I have videos etc. I know I can do it via htaccess per filetype, but this bypasses everything and allows them to link "the way I want them to link".


Jake

thejake420

#14
Ok, I've got it up and running. I'd still like to go further with some advanced functionality, but it's good enough for mainstream use at the moment. (Taking the appropriate disclaimers into consideration, of course... This is NOT an official mod or plugin! It's just an idea I'm working on that I thought I'd share, since it's really useful.)

Working Demo:
http://www.jakesjokes.com/gallery/displayimage.php?pos=-175

Here's what I've got so far, including some modified version of the codebase from the plugin you attached earlier in this thread. (Note that the URLs in my modified codebase are "for my site". I'm sure there's a way to add the server information dynamically, but I don't know it offhand. For the time being, anyone can simply change the jakesjokes.com references to theirsite.com, etc.


Modified codebase:

<?php
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
include (
"http://www.jakesjokes.com/gallery/include/functions.inc.php");
// Create the BBcode with link to thumbnail 
$bbcodethumb_url get_pic_url($CURRENT_PIC_DATA'thumb');
// Add a filter
$thisplugin->add_filter('file_data','bbcode_add_data');


function 
bbcode_add_data($pic_data){

$event = isset($_GET['event']) ? $_GET['event'] : null;
switch ($event) {
    
case 'show_bbcode':
$display_data =  <<<EOT
<table>
<tr>
<td>
<strong>Permanent URL:</strong><br><textarea name="textarea" cols="50" rows="2">http://www.jakesjokes.com/gallery/displayimage.php?pos=-
{$pic_data['pid']}</textarea><br>
<br>
<strong>HTML Linking code:</strong> (With Thumbnail)<br><textarea name="textarea" cols="50" rows="6">
&lt;iframe SRC=&quot;http://www.jakesjokes.com/specificoffsite.php?item=
{$pic_data['pid']}&quot; TITLE=&quot;Free funny jokes, videos, and pictures at JakesJokes.com&quot; WIDTH=&quot;135&quot; HEIGHT=&quot;160&quot; FRAMEBORDER=&quot;0&quot; SCROLLING=&quot;no&quot;&gt;&lt;/iframe&gt;</textarea>
<br>
<strong>HTML Linking code:</strong> (Without Thumbnail)<br><em>Tip</em> - You can edit &quot;Funny video or picture&quot; to say whatever you want)<br><textarea name="textarea" cols="50" rows="5">
&lt;a href=&quot;http://www.jakesjokes.com/gallery/displayimage.php?pos=-
{$pic_data['pid']}&quot; title=&quot;Free funny jokes, videos, and pictures at JakesJokes.com&quot; target=&quot;_blank&quot;&gt;Funny video or picture&lt;/a&gt;</textarea>

<br>

<strong>Forum bbCode:</strong><br><em>Tip</em> - You can edit &quot;Funny video or picture&quot; to say whatever you want)<br><textarea name="textarea" cols="50" rows="2">
[url=http://www.jakesjokes.com/gallery/displayimage.php?pos=-
{$pic_data['pid']}]Funny video or picture[/url]</textarea>
</td>
</tr>
</table>
EOT;
break;

default : 
$referer = ($_SERVER['PHP_SELF'] . (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] ? '?' $_SERVER['QUERY_STRING'] : ''));
$display_data =  <<<EOT
<table>
<tr>
<td>
<a href="
{$referer}&event=show_bbcode"><h2><font color="blue"><u>Link to this!</u></font></h2></a>
</td>
</tr>
</table>
EOT;
break;
}
$pic_data['html'] = $display_data.$pic_data['html'];
return $pic_data;
}
?>



--------------------

Demo of specificoffsite.php output as it would appear on visitor's site. (Modify table layout as desired.)
http://www.jakesjokes.com/specificoffsite.php?item=3668

specificoffsite.php (Located in site root, not gallery root... modify paths as needed)


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Link to specific funny media - JakesJokes.com</title>
<?php
require_once 
"./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gallery");
?>

<style type="text/css">
<!--
.style1 { font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
}
-->
</style>
</head>

<body>

<table width="125" height="150" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
  <tr>
    <td width="125" height="125"><div align="center">
        <?
$absoluteid = $item;
$styleguide = array(
"imagestyle" => "test1", "linkstyle" => "test1","imagewidth" => "100","imageheight" => "100",
"alttag" => "File: %t - Album: %a - Courtesy of JakesJokes.com ",
"subtitle" => "%t<br>Popularity: %h");

$objCpm->cpm_viewMediaByPid($absoluteid,$styleguide);
//$objCpm->cpm_viewRandomMediaFrom(1,1,"cat=3",$styleguide);
//$objCpm->cpm_viewLastAddedMediaFrom (1,1, "$source");
//cpm_viewLastAddedMedia (1, 5, [array $options = ""])
?>
    </div></td>
  </tr>
  <tr>
    <td height="25"><?
if ( $type == "video" ) {
    ?>
        <div align="center"><a href="http://www.jakesjokes.com/gallery/" class="style1">More funny videos</a></div>
        <?
} elseif($type == "picture"){
    ?>
        <div align="center"><a href="http://www.jakesjokes.com/gallery/" class="style1">More funny pictures</a></div>
        <?
} else {
    ?>
        <div align="center"><a href="http://www.jakesjokes.com/gallery/" class="style1">Free videos<br>and pictures</a></div>
        <?
}
?>
    </td>
  </tr>
</table>
</body>
</html>


Everything else doesn't require a demo.

1. The absolute URL to the media page is simply "listed", for advanced visitors who want to make their own links.
2. The HTML version WITH a thumbnail makes use of CPMFetch, and assumes that CPMFetch is installed at site.com/cpmfetch/, and that the Coppermine gallery is installed at site.com/gallery/ ---- Modify path in the require_once statement (near line 7) of specificoffsite.php and also the line after that as needed for your own configuration.
3. The HTML version WITHOUT a thumbnail is basically just a regular HTML (a href) link. Obviously, some of the text will need modified (if you don't have "Funny pictures", you'll want to change all references to that, etc.)
4. The bbCode is basically just a plain bbCode-formatted text link, nothing fancy, not even a thumbnail.


--------------
Help Needed / To Do List:

1. I need a way to call the actual thumbnail URL directly, but not via CPMFetch since that method won't work for bbCode versions. (ie - I can't make bbCode that will display an iframe, etc.) For example, I'd like to include a version with the appropriate thumbnail as a clickable image, but I don't know how to get the URL for it yet. I know, it's in this forum somewhere. I'll find it eventually, but if anybody knows the answer and wants to provide it, it would be most welcome.

2. I need a way to call the title of the media (ie - "Three funny chickens on the roof") from the database with a variable, so that I can include that information as clickable anchor text in some of the link codes.

3. I need a way to call the intermediate (and full size) image URLs directly. Why? Well, EVENTUALLY... I'd like to build an option to allow "indirect hotlinking" (via a php page on my server, shown on their site in an iframe, similar in concept to specificoffsite.php) where they can actually have a video play "on their site"... But only, of course, if they use my linking code (My .htaccess will then be set up to block "direct" hotlinking). Ths way, I can let them "indirectly" hotlink the video, but I can force a link to my site to appear under it. (Basically trading free bandwidth for the videos, etc. in exchange for a link back to my site. I know - there are some technical issues to deal with on this one, but it's on the wishlist...)

More to come as I get more comfortable editing this stuff...


Jake

Stramm

the URL to the gallery is defined in
$CONFIG['ecards_more_pic_target']

the way how to get the thumb url within that plugin
$thumb_url = get_pic_url($pic_data, 'thumb');
the same for normal and full
$fullsized_url = get_pic_url($pic_data);
$normal_url = get_pic_url($pic_data, 'normal');

within the plugin title and caption are defined in
    $pic_data['title']
    $pic_data['caption']

That's bsically all you need???

And thanks for sharing ;)

thejake420

Awesome. I'll look into that and let you know how things work out.


Jake

thejake420

I added those lines, but when I place a variable, it comes up blank (ie - nothing there)

if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
include ("http://www.jakesjokes.com/gallery/include/functions.inc.php");
// Create the BBcode with link to thumbnail
$bbcodethumb_url = get_pic_url($CURRENT_PIC_DATA, 'thumb');
$thumb_url = get_pic_url($pic_data, 'thumb');
$fullsized_url = get_pic_url($pic_data);
$normal_url = get_pic_url($pic_data, 'normal');
// Add a filter
$thisplugin->add_filter('file_data','bbcode_add_data');


Example: I call $thumb_url anywhere where text appears, but get nothing, as if it doesn't exist. I'm obviously missing something here... Do they get added directly to codebase.php as I've done, or somewhere else?


Jake

Stramm


<?php
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

// Add a filter
$thisplugin->add_filter('file_data','bbcode_add_data');


function 
bbcode_add_data($pic_data){ //$pic_data

$thumb_url get_pic_url($pic_data'thumb');
$fullsized_url get_pic_url($pic_data);
$normal_url get_pic_url($pic_data'normal');

$pic_data['html'] = $thumb_url.'<br>'.$fullsized_url.'<br>'.$normal_url.'<br>'.$pic_data['html']; 
return $pic_data//return $pic_data
}
?>



thejake420

#19
Have I mentioned that you're my hero?  ;D

I had to move things around a little bit because I was getting some errors (identical function name used twice, etc.), but through a little trial and error it came out working perfectly.

Live demo, pulled from my CPG (version 1.4.5) via cut and paste bbCode method
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.jakesjokes.com%2Fgallery%2Falbums%2Fuserpics%2F10001%2Fthumb_computer_addiction.jpg&hash=dd6fd1748d2753111c7c4b3d815efbab22bb5e81)
Computer addict


Given the information I now have, I should be able to come up with everything else needed to make this a more useful mod, including (hopefully) a link code generator. You know, click the radio button for HTML or bbcode, then select with or without a thuimbnail, etc. Click "Create code" and the appropriate code will be generated. Obviously, that is outside of the scope of this original project, but I'll release it once I finish it and get it prettied up a bit.

1. DONE - Just the absolute URL (plain)
2. DONE - Premade HTML link
3. DONE - Premade HTML with thumb (currently uses CPMFetch, this may change to make this a standalone plugin)
4. DONE - bbCode with thumbnail, no text
5. DONE - bbCode with thumbnail and text link (anchor = the title of the image)
6. DONE - bbcode text link (anchor = title of the image)
7. MySpace code (I don't know squat about MySpace, so this one might be a while if they use some oddball proprietary scripting / templating / whatever method)
8. EASY TO DO - Blogger, Xanga, LiveJournal, etc. code (should be basic HTML, but I'll check to see if it's different)
9. Several other minor bells and whistles, as I think of them...
10. Eventually another offsite.php type page that plays a video with the appropriate player. Need to figure out how to determine the file type, and then an overly complex if/elseif/else statement to display the appropriate player with the video embedded.

Jake