source: extensions/cl_conflit/conflit.inc.php @ 15907

Last change on this file since 15907 was 8958, checked in by cljosse, 13 years ago

[cl_conflit] bug on compatibility with piwigo 2.2

File size: 6.3 KB
RevLine 
[7880]1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
[8629]4// | cl_conflit                                                            |
[7880]5// +-----------------------------------------------------------------------+
6// | Copyright(C) 2010      cljosse                                        |
7// +-----------------------------------------------------------------------+
8// | This program is free software; you can redistribute it and/or modify  |
9// | it under the terms of the GNU General Public License as published by  |
10// | the Free Software Foundation                                          |
11// |                                                                       |
12// | This program is distributed in the hope that it will be useful, but   |
13// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
14// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
15// | General Public License for more details.                              |
16// |                                                                       |
17// | You should have received a copy of the GNU General Public License     |
18// | along with this program; if not, write to the Free Software           |
19// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
20// | USA.                                                                  |
21// +-----------------------------------------------------------------------+
22if (!defined('CONFLIT_PATH')) 
23define(
24  'CONFLIT_PATH',
25   PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'
26);
[8941]27
28  $CONFLIT_PATH_ABS=str_replace('\\','/',dirname(__FILE__) );
[8929]29if (!defined('CONFLIT_PATH_ABS')) 
30define(
[8941]31  'CONFLIT_PATH_ABS',   $CONFLIT_PATH_ABS."/"
32);
33
34
[7880]35class conflit_controler {
36//============================================================
37 /*
[8629]38  *  cl_conflit_script_1
[7880]39 */
[8629]40 static public function cl_conflit_script_1()
[7880]41        {
[8629]42                global  $template,$user,$conf,$picture ,$page,$cl_plugin;
43                if (isset( $page['body_id']) && $page['body_id']=='theAdminPage'  ) return ;
44                $ma_page=isset($page['body_id'])?$page['body_id']:"" ;
45                if ($ma_page=='thePiwiShackControllerPage') return ;
[8958]46
47         if (PHPWG_VERSION < 2.2 ) 
48                $file =CONFLIT_PATH_ABS.'template/header_2_1.tpl' ;
49        else 
50                $file =CONFLIT_PATH_ABS.'template/header_2_2.tpl' ;
51 
52        $template->set_filenames(array('cl_conflit_init_header'=> $file ));
53                $template->set_filenames(array('cl_conflit_init'=>CONFLIT_PATH_ABS. "template/conflit.tpl" ) ); 
[8629]54                $DEBUG =  isset($conf['cl_debug']) ? $conf['cl_debug'] : "false"  ; 
55                $cl_conflit_parametres =         cl_conflit_Get_Options() ;
[7880]56                $theme=$user['theme'];
57                $template->assign(
[7895]58                                                array( 
[7944]59                                                'cl_conflit_parametres' => $cl_conflit_parametres ,
60                                                'cl_plugins' => $cl_plugin ,
[7905]61                                                'cl_version' => $cl_plugin['version'] ,
[7909]62                                                'name' => $cl_plugin['name'] ,
[8958]63                                                                         
[7880]64                                                'theme' => $theme  ,
[8629]65                                                'DEBUG' => $DEBUG   ,
[8929]66                        'CONFLIT_PATH' => CONFLIT_PATH,
67                                                'CONFLIT_PATH_ABS' => CONFLIT_PATH_ABS 
68                        ) );
[8958]69                               
70                $template->concat('cl_conflit_init', $template->parse('cl_conflit_init_header', true));
[7880]71                return $template->parse( 'cl_conflit_init', false);
[8629]72        }// function cl_conflit_script_1
[7880]73//=================================================================================
74/*
[8629]75 * cl_conflit_script_2
[7880]76*/
77 static public function cl_conflit_script_2()
78 {
[7895]79                global  $template,$user,$conf,$picture ,$page,$cl_plugin;
[7880]80                        $my_path = dirname(__FILE__).'/';
[8629]81                        $DEBUG =  isset($conf['cl_debug']) ? $conf['cl_debug'] : "false"  ; 
82                        $ma_page=isset($page['body_id'])?$page['body_id']:"" ;                   
83                        $theme=$user['theme'];                         
84                        if ($ma_page=='thePiwiShackControllerPage') return ;
[7880]85
86                        $template->assign(
[7895]87                                        array(                                         
[7905]88                                            'cl_version' => $cl_plugin['version'] ,
[7909]89                                                'name' => $cl_plugin['name'] ,
[8629]90                                                'ma_page' =>    $ma_page,
[7944]91                                                 
[7880]92                                                'theme' => $theme  ,
[8629]93                                                'DEBUG' => $DEBUG   ,
[8929]94                                                'CONFLIT_PATH' => CONFLIT_PATH,
95                        'CONFLIT_PATH_ABS' => CONFLIT_PATH_ABS 
96                        )
[7880]97                                                );
98                                                 
[8629]99                                $autoscript="<script type='text/javascript'>
100                                /* cl_conflit_script_2 */       
101                                if (typeof (save_framework) == 'function')
102                                        save_framework('".$page['body_id']."');
103                                </script>";
104                        $template->append('footer_elements',$autoscript); 
105                        return ;
[7905]106 }// function cl_conflit_script_2
[7880]107
[8629]108    //================================================
[7905]109        /*
[8629]110        * cl_conflit_admin
[7905]111        */
112        static public function cl_conflit_admin($menu)
113                {
114                global  $lang ;
115                array_push($menu, array('NAME' => 'cl_conflit',
116                'URL' => get_admin_plugin_menu_link(CONFLIT_PATH . 'admin/cl_conflit_admin.php')));
117                return $menu;
118        } //function cl_conflit_admin
[7880]119
120} // class
[7905]121        /*
122        *
123        */
124 function cl_conflit_Get_Options()
125  {
126                global $conf,$cl_conflit_parametres; 
127                $cl_conflit_parametres =  unserialize($conf['cl_conflit']);
128                $cl_conflit_parametres =  cl_conflit_Set_Options();
129                return $cl_conflit_parametres;
130  }
131        /*
132        *
133        */
134function cl_conflit_Set_Options()
135  {
[7880]136
[7905]137  global $cl_conflit_parametres;
138//=============================================================================
[8187]139$cl_conflit_parametres->query =(isset($_POST['query'])) ? $_POST['query'] : ((isset($cl_conflit_parametres->query )) ? $cl_conflit_parametres->query : 'Qt' ) ;
140$cl_conflit_parametres->type=(isset($_POST['type']))? $_POST['type']: ((isset($cl_conflit_parametres->type)) ? $cl_conflit_parametres->type:  'Ty') ;
[7880]141
[7905]142 
[8187]143return $cl_conflit_parametres;
[7905]144}
145        /*
146        *
147        */
148function cl_conflit_sauve_options_inf()
149{
150global $options,$infos_message,$conf,$cl_conflit_parametres  ;
151$infos_message .=l10n("cl_conflit_save_config")."<br>";
152 $cl_conflit_parametres=cl_conflit_Set_Options();
[7880]153
[7905]154 if ( isset($cl_conflit_parametres) )
155        {
156 
157                $query = '
158                UPDATE '.CONFIG_TABLE.'
159                SET value="'.addslashes(serialize($cl_conflit_parametres)).'"
160                WHERE param = "cl_conflit"
161                LIMIT 1';
162                        pwg_query($query);
163          }
164         
165 }
[8942]166
167  function conflit_memo_var($variables)
168{
169  ob_start();
170  echo '<pre>';
171  print_r($variables);
172  echo '</pre>';
173  $m= ob_get_contents();
174  ob_end_clean();
175  return $m;           
176}
177   
[7880]178?>
Note: See TracBrowser for help on using the repository browser.