source: extensions/cl_conflit/conflit.inc.php

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

[cl_conflit] bug on compatibility with piwigo 2.2

File size: 6.3 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// | cl_conflit                                                            |
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);
27
28  $CONFLIT_PATH_ABS=str_replace('\\','/',dirname(__FILE__) );
29if (!defined('CONFLIT_PATH_ABS')) 
30define(
31  'CONFLIT_PATH_ABS',   $CONFLIT_PATH_ABS."/"
32);
33
34
35class conflit_controler {
36//============================================================
37 /*
38  *  cl_conflit_script_1
39 */
40 static public function cl_conflit_script_1()
41        {
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 ;
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" ) ); 
54                $DEBUG =  isset($conf['cl_debug']) ? $conf['cl_debug'] : "false"  ; 
55                $cl_conflit_parametres =         cl_conflit_Get_Options() ;
56                $theme=$user['theme'];
57                $template->assign(
58                                                array( 
59                                                'cl_conflit_parametres' => $cl_conflit_parametres ,
60                                                'cl_plugins' => $cl_plugin ,
61                                                'cl_version' => $cl_plugin['version'] ,
62                                                'name' => $cl_plugin['name'] ,
63                                                                         
64                                                'theme' => $theme  ,
65                                                'DEBUG' => $DEBUG   ,
66                        'CONFLIT_PATH' => CONFLIT_PATH,
67                                                'CONFLIT_PATH_ABS' => CONFLIT_PATH_ABS 
68                        ) );
69                               
70                $template->concat('cl_conflit_init', $template->parse('cl_conflit_init_header', true));
71                return $template->parse( 'cl_conflit_init', false);
72        }// function cl_conflit_script_1
73//=================================================================================
74/*
75 * cl_conflit_script_2
76*/
77 static public function cl_conflit_script_2()
78 {
79                global  $template,$user,$conf,$picture ,$page,$cl_plugin;
80                        $my_path = dirname(__FILE__).'/';
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 ;
85
86                        $template->assign(
87                                        array(                                         
88                                            'cl_version' => $cl_plugin['version'] ,
89                                                'name' => $cl_plugin['name'] ,
90                                                'ma_page' =>    $ma_page,
91                                                 
92                                                'theme' => $theme  ,
93                                                'DEBUG' => $DEBUG   ,
94                                                'CONFLIT_PATH' => CONFLIT_PATH,
95                        'CONFLIT_PATH_ABS' => CONFLIT_PATH_ABS 
96                        )
97                                                );
98                                                 
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 ;
106 }// function cl_conflit_script_2
107
108    //================================================
109        /*
110        * cl_conflit_admin
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
119
120} // class
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  {
136
137  global $cl_conflit_parametres;
138//=============================================================================
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') ;
141
142 
143return $cl_conflit_parametres;
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();
153
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 }
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   
178?>
Note: See TracBrowser for help on using the repository browser.