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

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

[cl_conflit] template compatibility with piwigo 2.2

File size: 6.0 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                $my_path =  basename(dirname(__FILE__)).'/' ;
47            $my_path = dirname(__FILE__).'/';
48                $template->set_filenames(array('cl_conflit_init'=>$my_path. "template/conflit.tpl" ) ); 
49                $DEBUG =  isset($conf['cl_debug']) ? $conf['cl_debug'] : "false"  ; 
50                $cl_conflit_parametres =         cl_conflit_Get_Options() ;
51                $theme=$user['theme'];
52                $url = get_root_url(); 
53   
54                $template->assign(
55                                                array( 
56                                                'cl_conflit_parametres' => $cl_conflit_parametres ,
57                                                'cl_plugins' => $cl_plugin ,
58                                                'cl_version' => $cl_plugin['version'] ,
59                                                'name' => $cl_plugin['name'] ,
60                                                'MY_ROOT' => $url,                                               
61                                                'theme' => $theme  ,
62                                                'DEBUG' => $DEBUG   ,
63                        'CONFLIT_PATH' => CONFLIT_PATH,
64                                                'CONFLIT_PATH_ABS' => CONFLIT_PATH_ABS 
65                        ) );
66       
67                return $template->parse( 'cl_conflit_init', false);
68        }// function cl_conflit_script_1
69//=================================================================================
70/*
71 * cl_conflit_script_2
72*/
73 static public function cl_conflit_script_2()
74 {
75                global  $template,$user,$conf,$picture ,$page,$cl_plugin;
76                        $my_path = dirname(__FILE__).'/';
77                        $DEBUG =  isset($conf['cl_debug']) ? $conf['cl_debug'] : "false"  ; 
78                        $ma_page=isset($page['body_id'])?$page['body_id']:"" ;                   
79                        $theme=$user['theme'];                         
80                        if ($ma_page=='thePiwiShackControllerPage') return ;
81
82                        $template->assign(
83                                        array(                                         
84                                            'cl_version' => $cl_plugin['version'] ,
85                                                'name' => $cl_plugin['name'] ,
86                                                'ma_page' =>    $ma_page,
87                                                 
88                                                'theme' => $theme  ,
89                                                'DEBUG' => $DEBUG   ,
90                                                'CONFLIT_PATH' => CONFLIT_PATH,
91                        'CONFLIT_PATH_ABS' => CONFLIT_PATH_ABS 
92                        )
93                                                );
94                                                 
95                                $autoscript="<script type='text/javascript'>
96                                /* cl_conflit_script_2 */       
97                                if (typeof (save_framework) == 'function')
98                                        save_framework('".$page['body_id']."');
99                                </script>";
100                        $template->append('footer_elements',$autoscript); 
101                        return ;
102 }// function cl_conflit_script_2
103
104    //================================================
105        /*
106        * cl_conflit_admin
107        */
108        static public function cl_conflit_admin($menu)
109                {
110                global  $lang ;
111                array_push($menu, array('NAME' => 'cl_conflit',
112                'URL' => get_admin_plugin_menu_link(CONFLIT_PATH . 'admin/cl_conflit_admin.php')));
113                return $menu;
114        } //function cl_conflit_admin
115
116} // class
117        /*
118        *
119        */
120 function cl_conflit_Get_Options()
121  {
122                global $conf,$cl_conflit_parametres; 
123                $cl_conflit_parametres =  unserialize($conf['cl_conflit']);
124                $cl_conflit_parametres =  cl_conflit_Set_Options();
125                return $cl_conflit_parametres;
126  }
127        /*
128        *
129        */
130function cl_conflit_Set_Options()
131  {
132
133  global $cl_conflit_parametres;
134//=============================================================================
135$cl_conflit_parametres->query =(isset($_POST['query'])) ? $_POST['query'] : ((isset($cl_conflit_parametres->query )) ? $cl_conflit_parametres->query : 'Qt' ) ;
136$cl_conflit_parametres->type=(isset($_POST['type']))? $_POST['type']: ((isset($cl_conflit_parametres->type)) ? $cl_conflit_parametres->type:  'Ty') ;
137
138 
139return $cl_conflit_parametres;
140}
141        /*
142        *
143        */
144function cl_conflit_sauve_options_inf()
145{
146global $options,$infos_message,$conf,$cl_conflit_parametres  ;
147$infos_message .=l10n("cl_conflit_save_config")."<br>";
148 $cl_conflit_parametres=cl_conflit_Set_Options();
149
150 if ( isset($cl_conflit_parametres) )
151        {
152 
153                $query = '
154                UPDATE '.CONFIG_TABLE.'
155                SET value="'.addslashes(serialize($cl_conflit_parametres)).'"
156                WHERE param = "cl_conflit"
157                LIMIT 1';
158                        pwg_query($query);
159          }
160         
161 }
162
163  function conflit_memo_var($variables)
164{
165  ob_start();
166  echo '<pre>';
167  print_r($variables);
168  echo '</pre>';
169  $m= ob_get_contents();
170  ob_end_clean();
171  return $m;           
172}
173   
174?>
Note: See TracBrowser for help on using the repository browser.