source: extensions/Histogram/hgram_ajax.php @ 17335

Last change on this file since 17335 was 16013, checked in by grum, 12 years ago

feature:2640- compatibility with Piwigo 2.4

  • Property svn:executable set to *
File size: 3.2 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : Histogram
4  Author     : Grum
5    email    : grum@piwigo.org
6    website  : http://photos.grum.fr
7
8    << May the Little SpaceFrog be with you ! >>
9  ------------------------------------------------------------------------------
10  See main.inc.php for release information
11
12  --------------------------------------------------------------------------- */
13
14
15  define('PHPWG_ROOT_PATH',dirname(dirname(dirname(__FILE__))).'/');
16
17  /*
18   * set ajax module in admin mode if request is used for admin interface
19   */
20  if(!isset($_REQUEST['ajaxfct'])) $_REQUEST['ajaxfct']='';
21  if(preg_match('/^admin\./i', $_REQUEST['ajaxfct'])) define('IN_ADMIN', true);
22  if(!defined('AJAX_CALL')) define('AJAX_CALL', true);
23
24  // the common.inc.php file loads all the main.inc.php plugins files
25  include_once(PHPWG_ROOT_PATH.'include/common.inc.php' );
26  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
27  include_once('hgram_root.class.inc.php');
28
29  load_language('plugin.lang', HGRAM_PATH);
30
31
32  class HGram_ajax extends HGram_root
33  {
34
35
36    /**
37     * constructor
38     */
39    public function __construct($prefixeTable, $filelocation)
40    {
41      parent::__construct($prefixeTable, $filelocation);
42      $this->loadConfig();
43      $this->checkRequest();
44      $this->returnAjaxContent();
45    }
46
47    /**
48     * check the $_REQUEST values and set default values
49     *
50     */
51    protected function checkRequest()
52    {
53      global $user;
54
55      // check if asked function is valid
56      if(!(
57           $_REQUEST[GPC_AJAX]=='public.histo.build'
58          )
59        ) $_REQUEST[GPC_AJAX]='';
60
61
62      if(preg_match('/^admin\./i', $_REQUEST[GPC_AJAX]) and !is_admin()) $_REQUEST[GPC_AJAX]='';
63
64      // check token validity - don't use GPCAjax::checkToken() because using an homemade token..
65      if(!isset($_REQUEST['token'])) $_REQUEST['token']='';
66
67
68
69      if($_REQUEST[GPC_AJAX]!='')
70      {
71        /*
72         * check public.histo.build
73         */
74        if($_REQUEST[GPC_AJAX]=="public.histo.build")
75        {
76          if(!isset($_REQUEST['id'])) $_REQUEST[GPC_AJAX]='';
77          if($_REQUEST['token']!=self::getToken($_REQUEST['id'])) $_REQUEST[GPC_AJAX]='';
78        }
79      }
80    }
81
82
83    /**
84     * return ajax content
85     */
86    protected function returnAjaxContent()
87    {
88      $result="<p class='errors'>An error has occured</p>";
89      switch($_REQUEST[GPC_AJAX])
90      {
91        case 'public.histo.build':
92          $result=$this->ajax_hgram_public_histoBuild($_REQUEST['id']);
93          break;
94      }
95      GPCAjax::returnResult($result);
96    }
97
98
99    /*------------------------------------------------------------------------*
100     *
101     * PUBLIC FUNCTIONS
102     *
103     *----------------------------------------------------------------------- */
104    private function ajax_hgram_public_histoBuild($imageId)
105    {
106      return(self::getHistogramGraph($imageId, true));
107    }
108
109
110
111    /*------------------------------------------------------------------------*
112     *
113     * ADMIN FUNCTIONS
114     *
115     *----------------------------------------------------------------------- */
116
117
118
119  } //class
120
121
122  $returned=new HGram_ajax($prefixeTable, __FILE__);
123?>
Note: See TracBrowser for help on using the repository browser.