noalyss Version-9
tag.class.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
20require_once NOALYSS_INCLUDE.'/database/tag_sql.class.php';
21
22/**
23 * @file
24 * @brief Tag operations or actions to linked them together
25 */
26
27/**
28 * @class Tag
29 * @brief Tag operations or actions to linked them together
30 */
31class Tag
32{
33 private $data; //<! Tag_SQL
34 protected $cn;
35 function __construct($p_cn,$id=-1)
36 {
37 $this->cn=$p_cn;
38 $id = (trim($id)=="")?-1:$id;
39 $this->data=new Tag_SQL($p_cn,$id);
40 }
41 public function get_data()
42 {
43 return $this->data;
44 }
45
46 public function set_data($data)
47 {
48 $this->data=$data;
49 return $this;
50 }
51
52 /**
53 * Show the list of available tag
54 * @return HTML
55 */
56 function show_list()
57 {
58 $ret=$this->data->seek(' order by t_tag');
59 if ( $this->cn->count($ret) == 0) return "";
60 require_once NOALYSS_TEMPLATE.'/tag_list.php';
61 }
62
63 /**
64 * Display a inner window with the detail of a tag
65 */
66 function form_add()
67 {
69 require_once NOALYSS_TEMPLATE.'/tag_detail.php';
70 }
71 /**
72 * Show the tag you can add to a document
73 */
74 function show_form_add()
75 {
76 echo h2(_("Ajout d'un dossier (ou tag)"));
77
78 $this->form_add();
79 }
80 function save($p_array)
81 {
82 if ( trim($p_array['t_tag'])=="" ) return ;
83 $this->data->t_id=$p_array['t_id'];
84 $this->data->t_tag= strip_tags($p_array['t_tag']);
85 $this->data->t_description=strip_tags($p_array['t_description']);
86 $this->data->t_actif=$p_array['t_actif'];
87 $this->data->t_color=$p_array['tagcell_color'];
88 $this->data->save();
89 }
90 function remove($p_array)
91 {
92 $this->data->t_id=$p_array['t_id'];
93 $this->data->delete();
94 }
95 /***
96 * query the active tag and returns the database handler
97 */
99 {
100 $ret=$this->cn->exec_sql(" select t_id,t_tag,t_description,'t' as tag_type ,t_color
101 from tags
102 where t_actif='Y'
103 union all
104 select tg_id,tg_name ,'G','g' ,1 from tag_group order by 2");
105 return $ret;
106 }
107}
108
109?>
h2($p_string, $p_class="", $raw="")
Definition: ac_common.php:68
$input_from cn
Definition: balance.inc.php:66
Manage the table public.tag.
Tag operations or actions to linked them together.
Definition: tag.class.php:32
$data
Definition: tag.class.php:33
show_list()
Show the list of available tag.
Definition: tag.class.php:56
save($p_array)
Definition: tag.class.php:80
set_data($data)
Definition: tag.class.php:46
get_data()
Definition: tag.class.php:41
__construct($p_cn, $id=-1)
Definition: tag.class.php:35
form_add()
Display a inner window with the detail of a tag.
Definition: tag.class.php:66
query_active_tag()
Definition: tag.class.php:98
show_form_add()
Show the tag you can add to a document.
Definition: tag.class.php:74