coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: claude258 on May 06, 2006, 05:28:20 AM

Title: Hit counter for full size popup windows
Post by: claude258 on May 06, 2006, 05:28:20 AM
I would like to know if people are using the full size popup windows often on my site. I already installed a counter in template.html but it does not count or track the full size popup clicks. Is it possible to add a counter for full size popup?

Thanks.   
Title: Re: Hit counter for full size popup windows
Post by: Paver on May 06, 2006, 05:49:37 AM
You could customize your theme to do so. 

Look at the function theme_html_picture() in your theme.php, particularly this block of code:
if ($mime_content['content']=='image') {
    if (isset($image_size['reduced'])) {
        $winsizeX = $CURRENT_PIC_DATA['pwidth']+5;  //the +'s are the mysterious FF and IE paddings
        $winsizeY = $CURRENT_PIC_DATA['pheight']+3; //the +'s are the mysterious FF and IE paddings
        $pic_html = "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid=$pid&amp;fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=yes,status=yes,resizable=yes,width=$winsizeX,height=$winsizeY')\">";
        $pic_title = $lang_display_image_php['view_fs'] . "\n==============\n" . $pic_title;
        $pic_html .= "<img src=\"" . $picture_url . "\" class=\"image\" border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />";
        $pic_html .= "</a>\n";
    } else {
        $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />\n";
    }
...

The first part of the second if statement produces the full-size link on the intermediate page, the "else" part of this if statement produces the full-size image tag.

(If you don't have this function in your theme, copy it - the whole function - from sample/theme.php and modify as desired.)
Title: Re: Hit counter for full size popup windows
Post by: claude258 on May 06, 2006, 11:21:50 PM
Thanks Paver.

I am not realy sure of what I should do with your answer. Unfortunatly, I need to learn more about coding. Usualy, if I install a counter I copy a code to the bottom of a html page. This is what I have done with my counter in template.html. But here, I dont know what to do ???. Can you give my a hint on how to do this?

Thanks again.

Title: Re: Hit counter for full size popup windows
Post by: Paver on May 07, 2006, 01:48:58 AM
You could try inserting your code in the else statement shown above:
} else {
    $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />\n";
}

like so:
} else {
    $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />\n";
    $pic_html .= "MY COUNTER CODE HERE";
}


This added line concatenates your code at the end of the previous line because of the ".=" operator.  (Make sure you put that period before the equal sign.)

If your code has any double-quotes in it, you need to escape them by putting a back-slash in front, like so:
$pic_html .= "My code is \"awesome\" and you know it.";
Single quotes are fine and don't need to be escaped. 

If your code is long, use "heredoc syntax" as shown:
$pic_html .= <<<EOT
My code has many lines.
Here's another so-called "line".
And now my code is done.
EOT;

You don't need to escape anything when using heredoc syntax.
Title: Re: Hit counter for full size popup windows
Post by: claude258 on May 09, 2006, 04:06:50 AM
I tried to install the counter. I am using Eyeball theme so had to copy the whole function from sample/theme.php and modify it as the following.

Here is a part of what I copied with the counter code in it (the project no is masked):
if ($mime_content['content']=='image') {
        if (isset($image_size['reduced'])) {
            $winsizeX = $CURRENT_PIC_DATA['pwidth']+5;  //the +'s are the mysterious FF and IE paddings
            $winsizeY = $CURRENT_PIC_DATA['pheight']+3; //the +'s are the mysterious FF and IE paddings
            $pic_html = "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid=$pid&amp;fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=yes,status=yes,resizable=yes,width=$winsizeX,height=$winsizeY')\">";
            $pic_title = $lang_display_image_php['view_fs'] . "\n==============\n" . $pic_title;
            $pic_html .= "<img src=\"" . $picture_url . "\" class=\"image\" border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />";
            $pic_html .= "</a>\n";
        } else {
            $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />\n";
        $pic_html .= <<<EOT
<!-- Start of StatCounter Code -->
<script type="text/javascript" language="javascript">
var sc_project=xxxxxxxx;
var sc_invisible=1;
var sc_partition=1;
var sc_security="";
var sc_remove_link=1;
</script>

<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><img  src="http://c2.statcounter.com/counter.php?sc_project=xxxxxxx&amp;java=0&amp;security=&amp;invisible=1" alt="website tracking" border="0"> </noscript>
<!-- End of StatCounter Code -->EOT;


The counter does not count or track the visitors when they clic on the image to get the original image displayed.

Have I install the counter the right way?

Thanks

Title: Re: Hit counter for full size popup windows
Post by: Paver on May 09, 2006, 04:25:31 AM
EOT; must be on a line by itself and have no spaces (or other characters) in front of it.
Title: Re: Hit counter for full size popup windows
Post by: claude258 on May 09, 2006, 04:44:05 AM
Sorry. It was on a line by itself on my theme.php.
I dont know why it got move when I copied the code here  ???

  } else {
            $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />\n";
        $pic_html .= <<<EOT
<!-- Start of StatCounter Code -->
<script type="text/javascript" language="javascript">
var sc_project=xxxxxx;
var sc_invisible=1;
var sc_partition=1;
var sc_security="";
var sc_remove_link=1;
</script>

<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><img  src="http://c2.statcounter.com/counter.php?sc_project=xxxxxx&amp;java=0&amp;security=&amp;invisible=1" alt="website tracking" border="0"> </noscript>
<!-- End of StatCounter Code -->
EOT;
     


Title: Re: Hit counter for full size popup windows
Post by: Paver on May 09, 2006, 05:00:10 AM
Off the top of my head, I'm not sure why it wouldn't work.  Would you provide a link to your site so I can look at the code?

I guess I'll try something similar on my site to see if I can see anything that would inhibit such a counter.
Title: Re: Hit counter for full size popup windows
Post by: claude258 on May 09, 2006, 05:12:54 AM
My site is: http://claudebriere.net/coppermine/ (http://claudebriere.net/coppermine/)

Thanks!
Title: Re: Hit counter for full size popup windows
Post by: Paver on May 09, 2006, 05:29:06 AM
Well, that's embarassing.  After looking at your site, I realized that the code you put into theme_html_picture was not showing up on the full-size photo window.  Then I realized that theme_html_picture() is only used for the intermediate display.  If you have intermediate turned off or the full-size photo is smaller than the intermediate size, the full-size photo is shown on the "intermediate" display with the Coppermine stuff wrapped around it.  (This full-size code sent me astray thinking it was the code for the full-size popup.)

The full-size photo popup window (with only the photo on it) is actually output with theme_display_fullsize_pic().  You can copy it from sample/theme.php or copy it from below:
// Display the full size image
function theme_display_fullsize_pic()
{
    global $CONFIG, $THEME_DIR, $ALBUM_SET;
    global $lang_errors, $lang_fullsize_popup, $lang_charset;

    if (isset($_GET['picfile']))
    {
        if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);

    $picfile = $_GET['picfile'];
    $picname = $CONFIG['fullpath'] . $picfile;
    $imagesize = @getimagesize($picname);
    $imagedata = array('name' => $picfile, 'path' => path2url($picname), 'geometry' => $imagesize[3]);
    }
    elseif (isset($_GET['pid']))
    {
    $pid = (int)$_GET['pid'];
    $sql = "SELECT * " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='$pid' $ALBUM_SET";
    $result = cpg_db_query($sql);

    if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);

    $row = mysql_fetch_array($result);
    $pic_url = get_pic_url($row, 'fullsize');
    $geom = 'width="' . $row['pwidth'] . '" height="' . $row['pheight'] . '"';
    $imagedata = array('name' => $row['filename'], 'path' => $pic_url, 'geometry' => $geom);
    }

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
  <title><?php echo $CONFIG['gallery_name'?>: <?php echo $lang_fullsize_popup['click_to_close'];
      
?>
</title>
  <meta http-equiv="content-type" content="text/html; charset=<?php echo $CONFIG['charset'] == 'language file' $lang_charset $CONFIG['charset'?>" />
  <script type="text/javascript" src="scripts.js"></script>
  <style type="text/css">
  body { margin: 0; padding: 0; background-color: gray; }
  img { margin:0; padding:0; border:0; }
  #content { margin:0 auto; padding:0; border:0; }
  table { border:0; height:100%; width:100%; border-collapse:collapse}
  td {         vertical-align: middle; text-align:center; }
  </style>
  </head>
  <body>
    <script language="JavaScript" type="text/JavaScript">
      adjust_popup();
    </script>
    <table>
      <tr>
            <td>
          <div id="content">
              <?php     echo  '<a href="javascript: window.close()"><img src="'
                
htmlspecialchars($imagedata['path']) . '" '
                
$imagedata['geometry']
                . 
'alt="'
                
htmlspecialchars($imagedata['name'])
                . 
'" title="'
                
htmlspecialchars($imagedata['name'])
                . 
"\n" $lang_fullsize_popup['click_to_close']
                . 
'" /></a><br />' ."\n";
               
?>

          </div>
        </td>
      </tr>
    </table>
  </body>
</html>
<?php
}


As you see, the second half of this code is straight HTML.  There's a closing PHP tag - ?> - at the beginning of this straight HTML and an opening one - <?php - at the end to close out the function.  There are a few PHP commands peppered throughout so just avoid them, looking for the opening & closing PHP tags and staying outside them.  So you merely have to insert your counter code in the HTML part wherever you like.  The whole document is output here.
Title: Re: Hit counter for full size popup windows
Post by: claude258 on May 10, 2006, 01:26:21 AM
Thanks Paver!
It is working fine.  ;D
Title: Re: Hit counter for full size popup windows
Post by: Paver on May 10, 2006, 01:50:29 AM
You're welcome.  "Solved" it is. 

I'm not sure if this should be moved to the themes board or not (since the solution was a theme-based solution).  If GauGau happens to stop by this thread, maybe he can give a quick say so.  For now, I won't move it.
Title: Re: Hit counter for full size popup windows
Post by: Joachim Müller on May 10, 2006, 08:01:34 AM
hehe, your choice ;). I guess it should be theming. Moving accordingly from "misc" to "themes"