noalyss Version-9
menu.inc.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// Copyright Author Dany De Bontridder danydb@aevalys.eu
22
23/**
24 * \file
25 *
26 *
27 * \brief Show the table menu and let you add your own
28 *
29 */
30if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
31
32
33echo '<div class="content">';
34/**
35 * if post save then we save a new one
36 */
37if ( isset($_POST['save_plugin']))
38{
39 extract($_POST, EXTR_SKIP);
40 $plugin=new Extension($cn);
41 $plugin->me_code=$me_code;
42 $plugin->me_menu=$me_menu;
43 $plugin->me_file=$me_file;
44 $plugin->me_description=$me_description;
45 $plugin->me_parameter='plugin_code='.$me_code;
46 $plugin->insert_plugin();
47}
48/**
49 * if post update then we update
50 */
51if (isset($_POST['mod_plugin']))
52{
53 extract ($_POST, EXTR_SKIP);
54 $plugin=new Extension($cn);
55 $plugin->me_code=strtoupper($me_code);
56 $plugin->me_menu=$me_menu;
57 $plugin->me_file=$me_file;
58 $plugin->me_description=$me_description;
59 $plugin->me_parameter='plugin_code='.strtoupper($me_code);
60 if ( !isset ($delete_pl))
61 {
62 $plugin->update_plugin();
63 }
64 else
65 {
66 $plugin->remove_plugin();
67 }
68}
69/**
70 * if post save then we save a new one
71 */
72if ( isset($_POST['create_menu'])|| isset($_POST['modify_menu']))
73{
74 extract($_POST, EXTR_SKIP);
75 $menu_ref=new Menu_Ref($cn);
76 $menu_ref->me_code=strtoupper($me_code);
77 $menu_ref->me_menu=$me_menu;
78 $menu_ref->me_file=$me_file;
79 $menu_ref->me_description=$me_description;
80 $menu_ref->me_parameter=$me_parameter;
81 $menu_ref->me_url=$me_url;
82 $menu_ref->me_javascript=$me_javascript;
83 $menu_ref->me_type='ME';
84 $check=$menu_ref->verify();
85 if ($check == 0)
86 {
87 if (isset($_POST['create_menu']))
88 {
89 $menu_ref->insert();
90 }
91 elseif (isset($_POST['modify_menu']))
92 {
93 if ($menu_ref->verify() == 0)
94 $menu_ref->update();
95 }
96 }
97}
98//////////////////////////////////////////////////////////////////////////////
99// Show the list of menu
100//////////////////////////////////////////////////////////////////////////////
101global $cn;
102
104$url=$_SERVER['REQUEST_URI'];
105
106$table->add(_('Code'),$url,"order by me_code asc","order by me_code desc","codea","coded");
107$table->add(_('Menu'),$url,"order by me_menu asc","order by me_menu desc","menua","menud");
108$table->add(_('Description'),$url,"order by me_description asc","order by me_description desc","desa","desd");
109$table->add(_('Type'),$url,"order by me_type asc","order by me_type desc","ta","td");
110$table->add(_('Fichier'),$url,"order by me_file asc","order by me_file desc","fa","fd");
111$table->add(_('URL'),$url,"order by me_url asc","order by me_url desc","urla","urld");
112$table->add(_('Paramètre'),$url,"order by me_parametere asc","order by me_parameter desc","paa","pad");
113$table->add(_('Javascript'),$url,"order by me_javascript asc","order by me_javascript desc","jsa","jsd");
114
115$ord=(isset($_REQUEST['ord']))?$_REQUEST['ord']:'codea';
116
117$order=$table->get_sql_order($ord);
118
119
120
121$iselect=new ISelect('p_type');
122$iselect->value=array(
123 array("value"=>'',"label"=>_("Tout")),
124 array("value"=>'ME',"label"=>_("Menu")),
125 array("value"=>'PR',"label"=>_("Impression")),
126 array("value"=>'PL',"label"=>_("Extension / Plugin")),
127 array("value"=>'SP',"label"=>_("Valeurs spéciales"))
128 );
129$iselect->selected=(isset($_REQUEST['p_type']))?$_REQUEST['p_type']:'';
131if ( $iselect->selected != '')
132{
133 $sql="where me_type='".sql_string($_REQUEST['p_type'])."' ";
134}
136$ret=$menu->seek($sql.$order);
137?>
138<fieldset><legend><?php echo _('Recherche')?></legend>
139<form method="GET">
140 <?php echo $iselect->input()?>
141 <?php echo HtmlInput::submit("search", _("Recherche"))?>
142 <?php echo HtmlInput::request_to_hidden(array('ac','gDossier','ord'))?>
143</form>
144 <?php echo _('Filtre'),HtmlInput::filter_table('menu_tb', '0,1,2,4', '1'); ?>
145</fieldset>
146<?php
148echo HtmlInput::button("Add_plugin", _("Ajout d'un plugin"), "onclick=add_plugin($gDossier)");
149echo HtmlInput::button("Add_menu", _("Ajout d'un menu"), "onclick=create_menu($gDossier)");
150
151echo '<table class="result" id="menu_tb">';
152echo '<tr>';
153echo '<th>'.$table->get_header(0).'</th>';
154echo '<th>'.$table->get_header(1).'</th>';
155echo '<th>'.$table->get_header(2).'</th>';
156echo '<th>'.$table->get_header(3).Icon_Action::infobulle(33).'</th>';
157echo '<th>'.$table->get_header(4).'</th>';
158echo '<th>'.$table->get_header(5).'</th>';
159echo '<th>'.$table->get_header(6).'</th>';
160echo '<th>'.$table->get_header(7).'</th>';
161echo '</tr>';
162
163for ($i = 0; $i < Database::num_row($ret); $i++)
164{
165 $row = $menu->get_object($ret, $i);
166 $js = $row->me_code;
167 switch ($row->me_type)
168 {
169 case 'PL':
170 $js = sprintf('<A class="line" href="javascript:void(0)" onclick="mod_plugin(\'%s\',\'%s\')">%s</A>', $gDossier, $row->me_code, $row->me_code);
171 break;
172 case 'ME':
173 $js = sprintf('<A class="line" href="javascript:void(0)" onclick="modify_menu(\'%s\',\'%s\')">%s</A>', $gDossier, $row->me_code, $row->me_code);
174 break;
175 }
176 $class = ( $i % 2 == 0) ? $class = ' class="odd"' : $class = ' class="even"';
177 // compatibility 8.1 , null is not an empty string
178 $me_description=($row->me_description===null)?"":_($row->me_description);
179 $me_menu=($row->me_menu===null)?"":_($row->me_menu);
180 echo "<tr $class>";
181 echo td($js);
182 echo td($me_menu);
183 echo td(h($me_description));
184 echo td(h($row->me_type));
185 echo td(h($row->me_file));
186 echo td(h($row->me_url));
187 echo td(h($row->me_parameter));
188 echo td(h($row->me_javascript));
189 echo '</tr>';
190}
191echo '</table>';
192
193?>
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
h( $row[ 'oa_description'])
$_REQUEST['ac']
$class
static num_row($ret)
wrapper for the function pg_num_rows
static id()
return the 'gDossier' value after a check
manage the extension, it involves the table extension
static request_to_hidden(array $array)
transform $_REQUEST data to hidden
static filter_table($p_table_id, $p_col, $start_row)
filter the rows in a table and keep the colored row in alternance
static button($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
ORM Manage the table public.menu_ref.
Menu_Ref let you manage the available menu.
Description of class_syn_sort_table.
$_POST['ac']
Definition: do.php:310
if( $delta< 0) elseif( $delta==0)
$check
$sql
Definition: menu.inc.php:130
$gDossier
Definition: menu.inc.php:147
$order
Definition: menu.inc.php:117
$iselect
Definition: menu.inc.php:121
$ord
Definition: menu.inc.php:115
if( $iselect->selected !='') $menu
Definition: menu.inc.php:135
$url
Definition: menu.inc.php:104
if(isset($_POST['save_plugin'])) if(isset( $_POST[ 'mod_plugin'])) if(isset($_POST['create_menu'])||isset($_POST['modify_menu'])) global $cn
if post save then we save a new one
Definition: menu.inc.php:72
$table
Definition: menu.inc.php:103
$ret
Definition: menu.inc.php:136