Advanced search  

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

Pages: [1]   Go Down

Author Topic: Include onlinestats  (Read 8687 times)

0 Members and 1 Guest are viewing this topic.

Senator

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 59
Include onlinestats
« on: October 01, 2006, 11:07:21 pm »

I use the plugin "onlinestats".

It works fine, but i've one problem with it.

After install the plugin i configure it in the config. Now its only vissable on the index.php

I want it make visable on displayimage.php with an php include.

Can someone tell me how to do that.
« Last Edit: October 03, 2006, 10:04:00 am by Sami »
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Include onlinestats
« Reply #1 on: October 02, 2006, 06:36:50 am »

You can't ,it's coded to show only on index !
Logged
‍I don't answer to PM with support question
Please post your issue to related board

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Include onlinestats
« Reply #2 on: October 02, 2006, 06:43:43 am »

Here's one way you can do so. 

In themes/yourtheme/theme.php, add a customization for the pagefooter function as shown:
Code: [Select]
// Function for writing a pagefooter
function pagefooter()
{
    //global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    global $USER, $USER_DATA, $ALBUM_SET, $CONFIG, $time_start, $query_stats, $queries;;
    global $template_footer;

    $custom_footer = cpg_get_custom_include($CONFIG['custom_footer_path']);

    if ($CONFIG['debug_mode']==1 || ($CONFIG['debug_mode']==2 && GALLERY_ADMIN_MODE)) {
    cpg_debug_output();
    }

    // MOD - begin
    CPGPluginAPI::filter('plugin_block', array('','onlinestats'));
    // MOD - end

    $template_vars = array(
        '{CUSTOM_FOOTER}' => $custom_footer,
        '{VANITY}' => (defined('THEME_IS_XHTML10_TRANSITIONAL') && $CONFIG['vanity_block']) ? theme_vanity() : '',
    );

    echo template_eval($template_footer, $template_vars);
}

This is just the default pagefooter function (from themes/sample/theme.php) with one line added in (plus // MOD - begin and // MOD - end before & after it).

This will add 'onlinestats' to every page, including the index page, so you need to remove 'onlinestats' from 'the content of the main page' on the config panel, otherwise you'll see two blocks.

If you want the onlinestats block somewhere else, add the mod line shown above to another theme customization function.  You cannot do a PHP include anywhere and you cannot put it into an HTML file like template.html.  You must find a function in theme.php that will output where you want the block.
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Include onlinestats
« Reply #3 on: October 02, 2006, 06:54:31 am »

Thank you paver for tip :)
Logged
‍I don't answer to PM with support question
Please post your issue to related board

Senator

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 59
Re: Include onlinestats
« Reply #4 on: October 02, 2006, 08:07:49 am »

iám ussing the classic theme, and i've edit this theme.php

but there's nothing changing, and te onlinestats block is'nt vissable down of the page.

What do i wrong.

here is my theme.php

Code: [Select]
<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2006 Coppermine Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.4.4
  $Source: /cvsroot/coppermine/stable/themes/classic/theme.php,v $
  $Revision: 1.15 $
  $Author: gaugau $
  $Date: 2006/02/24 13:32:45 $
**********************************************/

// ------------------------------------------------------------------------- //
// This theme has all CORE items removed                                     //
// ------------------------------------------------------------------------- //
define('THEME_IS_XHTML10_TRANSITIONAL',1);

// Added to display flim_strip
function theme_display_film_strip(&$thumb_list$nbThumb$album_name$aid$cat$pos$sort_options$mode 'thumb')
{
    global 
$CONFIG$THEME_DIR;
    global 
$template_film_strip$lang_film_strip;

    static 
$template '';
    static 
$thumb_cell '';
    static 
$empty_cell '';
    static 
$spacer '';

    if ((!
$template)) {
        
$template $template_film_strip;
        
$thumb_cell template_extract_block($template'thumb_cell');
        
$empty_cell template_extract_block($template'empty_cell');
    }

    
$cat_link is_numeric($aid) ? '' '&amp;cat=' $cat;

    
$thumbcols $CONFIG['thumbcols'];
    
$cell_width ceil(100 $CONFIG['max_film_strip_items']) . '%';

    
$i 0;
    
$thumb_strip '';
    foreach(
$thumb_list as $thumb) {
        
//modify $new_size for max dimension of thumbnails in filmstrip
        
$new_size 65;
        
preg_match('/(?<=width=")[0-9]*/',$thumb['image'],$matches,PREG_OFFSET_CAPTURE);
        
$srcWidth=$matches[0][0];
        
preg_match('/(?<=height=")[0-9]*/',$thumb['image'],$matches,PREG_OFFSET_CAPTURE);
        
$srcHeight=$matches[0][0];
        
$ratio max($srcWidth$srcHeight) / $new_size;
        
$ratio max($ratio1.0);
        
$destWidth = (int)($srcWidth $ratio);
        
$destHeight = (int)($srcHeight $ratio);
        
$thumb['image']=preg_replace('/width="[^"]*"/','width="'.$destWidth.'"',$thumb['image']);
        
$thumb['image']=preg_replace('/height="[^"]*"/','height="'.$destHeight.'"',$thumb['image']);
        
$i++;
        if (
$mode == 'thumb') {
            
$params = array('{CELL_WIDTH}' => $cell_width,
                
'{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&amp;pos={$thumb['pos']}",
                
'{THUMB}' => $thumb['image'],
                
'{CAPTION}' => $thumb['caption'],
                
'{ADMIN_MENU}' => ''
                
);
        } else {
            
$params = array('{CELL_WIDTH}' => $cell_width,
                
'{LINK_TGT}' => "index.php?cat={$thumb['cat']}",
                
'{THUMB}' => $thumb['image'],
                
'{CAPTION}' => '',
                
'{ADMIN_MENU}' => ''
                
);
        }
        
$thumb_strip .= template_eval($thumb_cell$params);
    }

    if (
defined('THEME_HAS_FILM_STRIP_GRAPHICS')) {
        
$tile1 $THEME_DIR 'images/tile1.gif';
        
$tile2 $THEME_DIR 'images/tile2.gif';
    } elseif (
defined('THEME_HAS_FILM_STRIP_GRAPHIC')) {
        
$tile1=$tile2=$THEME_DIR 'images/tile.gif';
    } else {
        
$tile1=$tile2'images/tile.gif';
    }

    
$params = array('{THUMB_STRIP}' => $thumb_strip,
        
'{COLS}' => $i,
        
'{TILE1}' => $tile1,
        
'{TILE2}' => $tile2,
        );

    
ob_start();
    
starttable($CONFIG['picture_table_width']);
    echo 
template_eval($template$params);
    
endtable();
    
$film_strip ob_get_contents();
    
ob_end_clean();

    return 
$film_strip;
}
// Function for writing a pagefooter
function pagefooter()
{
    
//global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    
global $USER$USER_DATA$ALBUM_SET$CONFIG$time_start$query_stats$queries;;
    global 
$template_footer;

    
$custom_footer cpg_get_custom_include($CONFIG['custom_footer_path']);

    if (
$CONFIG['debug_mode']==|| ($CONFIG['debug_mode']==&& GALLERY_ADMIN_MODE)) {
    
cpg_debug_output();
    }

    
// MOD - begin
    
CPGPluginAPI::filter('plugin_block', array('','onlinestats'));
    
// MOD - end

    
$template_vars = array(
        
'{CUSTOM_FOOTER}' => $custom_footer,
        
'{VANITY}' => (defined('THEME_IS_XHTML10_TRANSITIONAL') && $CONFIG['vanity_block']) ? theme_vanity() : '',
    );

    echo 
template_eval($template_footer$template_vars);
}

?>
Logged

Senator

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 59
Re: Include onlinestats
« Reply #5 on: October 02, 2006, 08:13:22 pm »

Can someone help me with this, iám traying it for weeks but can make ik work
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Include onlinestats
« Reply #6 on: October 02, 2006, 08:48:51 pm »

Please provide a link to your site.  And put 'onlinestats' in your 'content of the main page' on the config panel so it shows up on the index page.  I want to see it running on the index page, and we'll try to figure out why it's not showing up on the other pages (and not showing up twice on the index page as I mentioned before).
Logged

Senator

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 59
Re: Include onlinestats
« Reply #7 on: October 02, 2006, 09:22:44 pm »

ok, it's configure in config.

you can see on my site
*** WARNING: not safe for work

Edit (by Paver): added warning above - please make sure to note links that are "not safe for work".
« Last Edit: October 04, 2006, 08:55:41 pm by Senator »
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Include onlinestats
« Reply #8 on: October 02, 2006, 10:58:46 pm »

Ok, I think I figured it out.  There is a bug in version 1.2 of the 'onlinestats' plugin.  I noted it previously for another issue with multiple plugins.  This bug also causes the problem you note here - in other words, my code above does not work with version 1.2 of this plugin.  There is no version 1.3 available yet; I am planning to work on that when I have time.

So, there are two things you can do:
1. Apply the fix to the plugin noted in this post.
2. Adjust the code mod I gave above as shown:
Code: [Select]
    // MOD - begin
    global $matches;
    $matches = array('','onlinestats');
    CPGPluginAPI::filter('plugin_block', array('','onlinestats'));
    // MOD - end

Either solution should fix your problem.  You should apply the #1 solution at some point anyways, so I would suggest that one.  The #2 solution will work for both a fixed plugin and an unfixed plugin, although it might have some issues I haven't thought about. 
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Include onlinestats
« Reply #9 on: October 02, 2006, 11:53:22 pm »

#1 solution works only if you have other block plugin such as CPGoCat
Logged
‍I don't answer to PM with support question
Please post your issue to related board

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Include onlinestats
« Reply #10 on: October 03, 2006, 12:21:40 am »

@Sami: Do you mean that you have to have another plugin installed as well?  In my test gallery, I installed only the 'onlinestats' plugin with the fix I applied (from the #1 solution), and then I can show the 'onlinestats' on every page, so it seems to work fine with only the one plugin installed.

I have also tried it with CPGOCat installed as well, and everything is still fine ('onlinestats' on every page).

What problem do you see?
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Include onlinestats
« Reply #11 on: October 03, 2006, 12:32:35 am »

I've got only header and footer if applied #1 fix and have only onlinestats plugin installed

[Edit]
Sorry it was my mistake,I should add $matches as a parameter for online_mainpage function ...
So it's okey and all was my side ...
Logged
‍I don't answer to PM with support question
Please post your issue to related board

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Include onlinestats
« Reply #12 on: October 03, 2006, 12:39:35 am »

Yes, the #1 solution (from the linked fix) is to add $matches to the function mainpage() parameter list and to remove it from the global variable list.  That's the way the 'plugin_block' filter is supposed to work - pass in the $matches variable and receive it back from the plugin function.
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Include onlinestats
« Reply #13 on: October 03, 2006, 09:49:27 am »

@Senator: can we mark this thread as a "Solved"?
« Last Edit: October 03, 2006, 10:03:30 am by Sami »
Logged
‍I don't answer to PM with support question
Please post your issue to related board

Senator

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 59
Re: Include onlinestats
« Reply #14 on: October 03, 2006, 09:54:20 am »

Yes, sorry for the delay.

Its works perfectly.

Thanks Paver.


Topic= Solved
Logged
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 20 queries.