•  » Plugins
  •  » [1.7] Plugin Statistics

#46 2008-01-10 19:28:35

sakkhho
Membre
Paris
2007-04-02
1836

Re: [1.7] Plugin Statistics

désolé pas le tps de m'y mettre...


Piwigo 2.3.5

Hors ligne

#47 2008-01-10 21:14:57

DalP
Membre
2008-01-09
2

Re: [1.7] Plugin Statistics

sakkhho a écrit:

désolé pas le tps de m'y mettre...

Bin en fait, si je peux proposer ça :

main.inc.php

Code:

<?php
/*
Plugin Name: Statistics
Version: 1.7.?
Description: Add source code like Google Analytics on each page.
Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=174
Author: Ruben & Sakkhho
Author URI: http://www.phpwebgallery.net
*/


if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');

define('STAT_DIR' , basename(dirname(__FILE__)));
define('STAT_PATH' , PHPWG_PLUGINS_PATH . STAT_DIR . '/');


function statistics_admin_menu($menu)
{
    array_push($menu, array('NAME' => 'Statistics',
      'URL' => get_admin_plugin_menu_link(STAT_PATH . 'admin/stat_admin.php')));
    return $menu;
}

function stat_candoit()
{
  global $conf, $user;

  $conf_statistics = explode("," , $conf['statistics']);

  $is_guest = (function_exists('is_a_guest') ? is_a_guest() : $user['is_the_guest']);

  if
  (
    (($conf_statistics[0] == 'on') or ($conf_statistics[1] == 'on')) and 
    (($conf_statistics[3] == 'on' and !is_admin()) or (empty($conf_statistics[3]))) and
    (($conf_statistics[4] == 'on' and !$is_guest) or (empty($conf_statistics[4])))
  )
  {
    return '
<!-- Plugin Statitics -->
'.$conf_statistics[2].'
<!-- Plugin Statitics -->';
  }
  else
  {
    return false;
  }
}

function stat_tail()
{
  global $template, $conf;

  $conf_statistics = explode("," , $conf['statistics']);

  if (($conf_statistics[1] == 'on') and ($code_stat = stat_candoit()))
  {
    $template->loadfile('tail');
    $template->uncompiled_code['tail'] = str_replace('</div> <!-- the_page -->', $code_stat.'
      </div> <!-- the_page -->', $template->uncompiled_code['tail']);
  }
}


function stat_header()
{
  global $template, $conf;

  $conf_statistics = explode("," , $conf['statistics']);

  if (($conf_statistics[0] == 'on') and ($code_stat = stat_candoit()))
  {
    $template->assign_block_vars('head_element', array('CONTENT' => $code_stat));
  }
}


add_event_handler('get_admin_plugin_menu_links', 'statistics_admin_menu');
add_event_handler('loc_end_page_tail', 'stat_tail');
add_event_handler('loc_end_page_header', 'stat_header');

?>

Je sais qu'il faut encore amélioré ce code, mais ça marche.
Ce qui m'embête, c'est qu'il y a trois fois le même appel à la base de données, mais mes connaissances en PHP ne me permettent pas de faire mieux.

Hors ligne

#48 2008-01-13 10:12:00

sakkhho
Membre
Paris
2007-04-02
1836

Re: [1.7] Plugin Statistics

merci je l'integrerai et le posterai qd meme pour que ca fontionne et dès que j'ai un moment je regarderai pour rendre le code "+ propre" si je sais faire :-)

bon dimanche


Piwigo 2.3.5

Hors ligne

#49 2008-01-13 15:32:51

rub
Former Piwigo Team
Lille
2005-08-26
5239

Re: [1.7] Plugin Statistics

DalP a écrit:

Ce qui m'embête, c'est qu'il y a trois fois le même appel à la base de données, mais mes connaissances en PHP ne me permettent pas de faire mieux.

C'est quoi les 3 appels à la base de données?

Sinon, j'aurais plus mis le test du header et tail dans le candoit plutot que refaire des explode, etc...


Ca donnerai un truc du style:

Code:

<?php
/*
Plugin Name: Statistics
Version: 1.7.?
Description: Add source code like Google Analytics on each page.
Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=174
Author: Ruben & Sakkhho
Author URI: http://www.phpwebgallery.net
*/


if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');

define('STAT_DIR' , basename(dirname(__FILE__)));
define('STAT_PATH' , PHPWG_PLUGINS_PATH . STAT_DIR . '/');


function statistics_admin_menu($menu)
{
    array_push($menu, array('NAME' => 'Statistics',
      'URL' => get_admin_plugin_menu_link(STAT_PATH . 'admin/stat_admin.php')));
    return $menu;
}

function stat_candoit($type)
{
  global $conf, $user;

  $conf_statistics = explode("," , $conf['statistics']);

  $is_guest = (function_exists('is_a_guest') ? is_a_guest() : $user['is_the_guest']);

  if
  (
    (($conf_statistics[0] == 'on') and ($type == 'header')) and 
    (($conf_statistics[1] == 'on') and ($type == 'tail')) and 
    (($conf_statistics[3] == 'on' and !is_admin()) or (empty($conf_statistics[3]))) and
    (($conf_statistics[4] == 'on' and !$is_guest) or (empty($conf_statistics[4])))
  )
  {
    return '
<!-- Plugin Statitics -->
'.$conf_statistics[2].'
<!-- Plugin Statitics -->';
  }
  else
  {
    return false;
  }
}

function stat_tail()
{
  global $template;

  if ($code_stat = stat_candoit('tail'))
  {
    $template->loadfile('tail');
    $template->uncompiled_code['tail'] = str_replace('</div> <!-- the_page -->', $code_stat.'
      </div> <!-- the_page -->', $template->uncompiled_code['tail']);
  }
}


function stat_header()
{
  global $template;

  if ($code_stat = stat_candoit('header'))
  {
    $template->assign_block_vars('head_element', array('CONTENT' => $code_stat));
  }
}


add_event_handler('get_admin_plugin_menu_links', 'statistics_admin_menu');
add_event_handler('loc_end_page_tail', 'stat_tail');
add_event_handler('loc_end_page_header', 'stat_header');

?>

Attention, je ne l'ai pas testé!

Hors ligne

#50 2008-01-20 11:38:01

sakkhho
Membre
Paris
2007-04-02
1836

Re: [1.7] Plugin Statistics

sans vraiment testé non plus je l'ai integré dans la version 1.7.e
si vous pouvez me faire un petit retour si ca marche pas.


Piwigo 2.3.5

Hors ligne

#51 2008-01-20 12:30:53

sakkhho
Membre
Paris
2007-04-02
1836

Re: [1.7] Plugin Statistics

ben j'ai mis la version de DalP en ligne elle marche
la tienne rub ne semble pas fonctionner. elle n'insert rien.

a+


Piwigo 2.3.5

Hors ligne

#52 2008-01-20 12:47:47

rub
Former Piwigo Team
Lille
2005-08-26
5239

Re: [1.7] Plugin Statistics

sakkhho a écrit:

ben j'ai mis la version de DalP en ligne elle marche
la tienne rub ne semble pas fonctionner. elle n'insert rien.

a+

sakkhho a écrit:

attention j'ai l'impression que la derniere version n'insert aucun code...
comprend pas.

C'est simple, j'avais écrit que je n'avais pas testé!

un or à la place du and et ca va mieux:

Code:

<?php
/*
Plugin Name: Statistics
Version: 1.7.f
Description: Add source code like Google Analytics on each page.
Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=174
Author: Ruben & Sakkhho
Author URI: http://www.phpwebgallery.net
*/


if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');

define('STAT_DIR' , basename(dirname(__FILE__)));
define('STAT_PATH' , PHPWG_PLUGINS_PATH . STAT_DIR . '/');


function statistics_admin_menu($menu)
{
    array_push($menu, array('NAME' => 'Statistics',
      'URL' => get_admin_plugin_menu_link(STAT_PATH . 'admin/stat_admin.php')));
    return $menu;
}

function stat_candoit($type)
{
  global $conf, $user;

  $conf_statistics = explode("," , $conf['statistics']);

  $is_guest = (function_exists('is_a_guest') ? is_a_guest() : $user['is_the_guest']);

  if
  (
    (
      (($conf_statistics[0] == 'on') and ($type == 'header')) or 
      (($conf_statistics[1] == 'on') and ($type == 'tail'))
    ) and 
    (($conf_statistics[3] == 'on' and !is_admin()) or (empty($conf_statistics[3]))) and
    (($conf_statistics[4] == 'on' and !$is_guest) or (empty($conf_statistics[4])))
  )
  {
    return '
<!-- Plugin Statitics -->
'.$conf_statistics[2].'
<!-- Plugin Statitics -->';
  }
  else
  {
    return false;
  }
}

function stat_tail()
{
  global $template;

  if ($code_stat = stat_candoit('tail'))
  {
    $template->loadfile('tail');
    $template->uncompiled_code['tail'] = str_replace('</div> <!-- the_page -->', $code_stat.'
      </div> <!-- the_page -->', $template->uncompiled_code['tail']);
  }
}


function stat_header()
{
  global $template;

  if ($code_stat = stat_candoit('header'))
  {
    $template->assign_block_vars('head_element', array('CONTENT' => $code_stat));
  }
}


add_event_handler('get_admin_plugin_menu_links', 'statistics_admin_menu');
add_event_handler('loc_end_page_tail', 'stat_tail');
add_event_handler('loc_end_page_header', 'stat_header');

?>

Hors ligne

#53 2008-01-20 13:03:26

sakkhho
Membre
Paris
2007-04-02
1836

Re: [1.7] Plugin Statistics

merci rub. 1.7.f dispo.


Piwigo 2.3.5

Hors ligne

#54 2008-02-27 07:38:49

rub
Former Piwigo Team
Lille
2005-08-26
5239

Re: [1.7] Plugin Statistics

sakkhho, si tu as le temps, peux-tu:

1) changer le code de la fonction stat_tail par

Code:

function stat_tail()
{
  global $template;

  if ($code_stat = stat_candoit('tail'))
  {
    $template->assign_block_vars('footer_element', array('CONTENT' => $code_stat));
  }
}

C'est compatible que 1.7.1 mais c'est surtout compatible Butterfly!

2)
Et as-vu les modifs ici:
http://forum.phpwebgallery.net/viewtopi … 674#p81674

Hors ligne

#55 2008-02-27 08:11:35

sakkhho
Membre
Paris
2007-04-02
1836

Re: [1.7] Plugin Statistics

j'integrerai les 2 modifs des que possible !
a+


Piwigo 2.3.5

Hors ligne

#56 2008-02-27 09:28:18

rub
Former Piwigo Team
Lille
2005-08-26
5239

Re: [1.7] Plugin Statistics

sakkhho a écrit:

j'integrerai les 2 modifs des que possible !
a+

cool & merci!

Hors ligne

#57 2008-02-28 19:02:04

tramway61
Membre
2006-10-05
207

Re: [1.7] Plugin Statistics

Bonsoir,

J'ai installé l'excellentissime PluginManager et j'ai commencé à installer quelques plugins qui me manquaient. Et "statistics" me pose problème. Je me suis inscrit sur Google Analytics, récupéré le code, je l'ai mis dans le plugin et validé. Or 48 h après: rien.
J'ai cherché où j'avais pu commettre une bourde mais je ne trouve pas.
2 pistes: le lien fournit sur Google n'est pas bon ( que faut-il mettre ?) ou le code ne se colle pas (où devrait-il être pour être visible?)
Ah! 3eme piste: je suis chez Free :)

Version de PhpWebGallery
PhpWebGallery 1.7.1

Environnement
System d'exploitation: Linux
PHP: 5.1.3RC4-dev
MySQL: 5.0.45

http://argentanwebferro.free.fr/galerie/index.php

Merci

@+


@+
Thierry

Hors ligne

#58 2008-02-28 19:54:44

P@t
Ex Equipe Piwigo
Nice
2007-06-13
5695

Re: [1.7] Plugin Statistics

Je vois un code phpmyvisite sur ton site, mais rien pour google analytic...
Je me suis inscrit sur ton site...
Passe moi en admin/adviser, j'y jetterai un oeil.


P@t

Hors ligne

#59 2008-02-28 20:03:21

tramway61
Membre
2006-10-05
207

Re: [1.7] Plugin Statistics

P@t a écrit:

Je vois un code phpmyvisite sur ton site, mais rien pour google analytic...

Exact, j'ai omis de le préciser.

Merci Pat


@+
Thierry

Hors ligne

#60 2008-02-28 20:15:49

sakkhho
Membre
Paris
2007-04-02
1836

Re: [1.7] Plugin Statistics

j'ai pas fait la modif
promis ça sera fait ce week end
en tout cas ça fonctionne qd meme

Dernière modification par sakkhho (2008-02-28 20:16:35)


Piwigo 2.3.5

Hors ligne

  •  » Plugins
  •  » [1.7] Plugin Statistics

Pied de page des forums

Propulsé par FluxBB

github twitter newsletter Faire un don Piwigo.org © 2002-2025 · Contact