noalyss  Version-6.9.1.8
 All Data Structures Namespaces Files Functions Variables Pages
class_tag.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is part of NOALYSS.
4  *
5  * NOALYSS is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * NOALYSS is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with NOALYSS; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 // Copyright Author Dany De Bontridder danydb@aevalys.eu
20 require_once NOALYSS_INCLUDE.'/database/class_tag_sql.php';
21 
22 class Tag
23 {
24  function __construct($p_cn,$id=-1)
25  {
26  $this->cn=$p_cn;
27  $this->data=new Tag_SQL($p_cn,$id);
28  }
29  /**
30  * Show the list of available tag
31  * @return HTML
32  */
33  function show_list()
34  {
35  $ret=$this->data->seek(' order by t_tag');
36  if ( $this->cn->count($ret) == 0) return "";
37  require_once NOALYSS_TEMPLATE.'/tag_list.php';
38  }
39  /**
40  * let select a tag to add
41  */
42  function select()
43  {
44  $ret=$this->data->seek(' order by t_tag');
45  require_once NOALYSS_TEMPLATE.'/tag_select.php';
46  }
47  /**
48  * Display a inner window with the detail of a tag
49  */
50  function form_add()
51  {
53  require_once NOALYSS_TEMPLATE.'/tag_detail.php';
54  }
55  /**
56  * Show the tag you can add to a document
57  */
58  function show_form_add()
59  {
60  echo '<h2>'.' Ajout d\'un dossier (ou tag)'.'</h2>';
61 
62  $this->form_add();
63  }
64  function save($p_array)
65  {
66  if ( trim($p_array['t_tag'])=="" ) return ;
67  $this->data->t_id=$p_array['t_id'];
68  $this->data->t_tag= strip_tags($p_array['t_tag']);
69  $this->data->t_description=strip_tags($p_array['t_description']);
70  $this->data->save();
71  }
72  function remove($p_array)
73  {
74  $this->data->t_id=$p_array['t_id'];
75  $this->data->delete();
76  }
77  /**
78  * Show a button to select tag for Search
79  * @return HTML
80  */
81  static function button_search($p_prefix)
82  {
83  $r="";
84  $r.=HtmlInput::button("choose_tag", "Etiquette", 'onclick="search_display_tag('.Dossier::id().',\''.$p_prefix.'\')"', "smallbutton");
85  return $r;
86  }
87  /**
88  * let select a tag to add to the search
89  */
90  function select_search($p_prefix)
91  {
92  $ret=$this->data->seek(' order by t_tag');
93  require_once NOALYSS_TEMPLATE.'/tag_search_select.php';
94  }
95  /**
96  * In the screen search add this data to the cell
97  */
98  function update_search_cell($p_prefix) {
99  echo '<span id="sp_'.$p_prefix.$this->data->t_id.'" style="border:1px solid black;margin-right:5px;">';
100  echo h($this->data->t_tag);
101  echo HtmlInput::hidden($p_prefix.'tag[]', $this->data->t_id);
102  $js=sprintf("$('sp_".$p_prefix.$this->data->t_id."').remove();");
103  echo HtmlInput::anchor( SMALLX, "javascript:void(0)", "onclick=\"$js\"", ' class="smallbutton " style="padding:0px;display:inline" ');
104  echo '</span>';
105  }
106  /**
107  * clear the search cell
108  */
109  static function add_clear_button($p_prefix) {
110  $clear=HtmlInput::button('clear', 'X', 'onclick="search_clear_tag('.Dossier::id().',\''.$p_prefix.'\');"', 'smallbutton');
111  return $clear;
112  }
113 }
114 
115 ?>
show_form_add()
Show the tag you can add to a document.
Definition: class_tag.php:58
static button_search($p_prefix)
Show a button to select tag for Search.
Definition: class_tag.php:81
static add_clear_button($p_prefix)
clear the search cell
Definition: class_tag.php:109
$ret javascript
__construct($p_cn, $id=-1)
Definition: class_tag.php:24
static button($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
save($p_array)
Definition: class_tag.php:64
if($show_row!=0) margin right
function trim(s)
remove trailing and heading space
Definition: scripts.js:95
$input_from cn
Definition: balance.inc.php:71
static id()
return the $_REQUEST['gDossier'] after a check
show_list()
Show the list of available tag.
Definition: class_tag.php:33
select()
let select a tag to add
Definition: class_tag.php:42
form_add()
Display a inner window with the detail of a tag.
Definition: class_tag.php:50
Manage the table public.tag.