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

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

[cl_conflit] template compatibility with piwigo 2.2

File size: 5.8 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);
[8929]27if (!defined('CONFLIT_PATH_ABS')) 
28define(
29  'CONFLIT_PATH_ABS',dirname(__FILE__).'/');
[7880]30class conflit_controler {
31//============================================================
32 /*
[8629]33  *  cl_conflit_script_1
[7880]34 */
[8629]35 static public function cl_conflit_script_1()
[7880]36        {
[8629]37                global  $template,$user,$conf,$picture ,$page,$cl_plugin;
38                if (isset( $page['body_id']) && $page['body_id']=='theAdminPage'  ) return ;
39                $ma_page=isset($page['body_id'])?$page['body_id']:"" ;
40                if ($ma_page=='thePiwiShackControllerPage') return ;
[7880]41                $my_path =  basename(dirname(__FILE__)).'/' ;
42            $my_path = dirname(__FILE__).'/';
43                $template->set_filenames(array('cl_conflit_init'=>$my_path. "template/conflit.tpl" ) ); 
[8629]44                $DEBUG =  isset($conf['cl_debug']) ? $conf['cl_debug'] : "false"  ; 
45                $cl_conflit_parametres =         cl_conflit_Get_Options() ;
[7880]46                $theme=$user['theme'];
[8929]47                $url = get_root_url(); 
48   
[7880]49                $template->assign(
[7895]50                                                array( 
[7944]51                                                'cl_conflit_parametres' => $cl_conflit_parametres ,
52                                                'cl_plugins' => $cl_plugin ,
[7905]53                                                'cl_version' => $cl_plugin['version'] ,
[7909]54                                                'name' => $cl_plugin['name'] ,
[8629]55                                                'MY_ROOT' => $url,                                               
[7880]56                                                'theme' => $theme  ,
[8629]57                                                'DEBUG' => $DEBUG   ,
[8929]58                        'CONFLIT_PATH' => CONFLIT_PATH,
59                                                'CONFLIT_PATH_ABS' => CONFLIT_PATH_ABS 
60                        ) );
[8629]61       
[7880]62                return $template->parse( 'cl_conflit_init', false);
[8629]63        }// function cl_conflit_script_1
[7880]64//=================================================================================
65/*
[8629]66 * cl_conflit_script_2
[7880]67*/
68 static public function cl_conflit_script_2()
69 {
[7895]70                global  $template,$user,$conf,$picture ,$page,$cl_plugin;
[7880]71                        $my_path = dirname(__FILE__).'/';
[8629]72                        $DEBUG =  isset($conf['cl_debug']) ? $conf['cl_debug'] : "false"  ; 
73                        $ma_page=isset($page['body_id'])?$page['body_id']:"" ;                   
74                        $theme=$user['theme'];                         
75                        if ($ma_page=='thePiwiShackControllerPage') return ;
[7880]76
77                        $template->assign(
[7895]78                                        array(                                         
[7905]79                                            'cl_version' => $cl_plugin['version'] ,
[7909]80                                                'name' => $cl_plugin['name'] ,
[8629]81                                                'ma_page' =>    $ma_page,
[7944]82                                                 
[7880]83                                                'theme' => $theme  ,
[8629]84                                                'DEBUG' => $DEBUG   ,
[8929]85                                                'CONFLIT_PATH' => CONFLIT_PATH,
86                        'CONFLIT_PATH_ABS' => CONFLIT_PATH_ABS 
87                        )
[7880]88                                                );
89                                                 
[8629]90                                $autoscript="<script type='text/javascript'>
91                                /* cl_conflit_script_2 */       
92                                if (typeof (save_framework) == 'function')
93                                        save_framework('".$page['body_id']."');
94                                </script>";
95                        $template->append('footer_elements',$autoscript); 
96                        return ;
[7905]97 }// function cl_conflit_script_2
[7880]98
[8629]99    //================================================
[7905]100        /*
[8629]101        * cl_conflit_admin
[7905]102        */
103        static public function cl_conflit_admin($menu)
104                {
105                global  $lang ;
106                array_push($menu, array('NAME' => 'cl_conflit',
107                'URL' => get_admin_plugin_menu_link(CONFLIT_PATH . 'admin/cl_conflit_admin.php')));
108                return $menu;
109        } //function cl_conflit_admin
[7880]110
111} // class
[7905]112        /*
113        *
114        */
115 function cl_conflit_Get_Options()
116  {
117                global $conf,$cl_conflit_parametres; 
118                $cl_conflit_parametres =  unserialize($conf['cl_conflit']);
119                $cl_conflit_parametres =  cl_conflit_Set_Options();
120                return $cl_conflit_parametres;
121  }
122        /*
123        *
124        */
125function cl_conflit_Set_Options()
126  {
[7880]127
[7905]128  global $cl_conflit_parametres;
129//=============================================================================
[8187]130$cl_conflit_parametres->query =(isset($_POST['query'])) ? $_POST['query'] : ((isset($cl_conflit_parametres->query )) ? $cl_conflit_parametres->query : 'Qt' ) ;
131$cl_conflit_parametres->type=(isset($_POST['type']))? $_POST['type']: ((isset($cl_conflit_parametres->type)) ? $cl_conflit_parametres->type:  'Ty') ;
[7880]132
[7905]133 
[8187]134return $cl_conflit_parametres;
[7905]135}
136        /*
137        *
138        */
139function cl_conflit_sauve_options_inf()
140{
141global $options,$infos_message,$conf,$cl_conflit_parametres  ;
142$infos_message .=l10n("cl_conflit_save_config")."<br>";
143 $cl_conflit_parametres=cl_conflit_Set_Options();
[7880]144
[7905]145 if ( isset($cl_conflit_parametres) )
146        {
147 
148                $query = '
149                UPDATE '.CONFIG_TABLE.'
150                SET value="'.addslashes(serialize($cl_conflit_parametres)).'"
151                WHERE param = "cl_conflit"
152                LIMIT 1';
153                        pwg_query($query);
154          }
155         
156 }
[7880]157?>
Note: See TracBrowser for help on using the repository browser.