noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_tag.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00020 require_once 'class_tag_sql.php';
00021 
00022 class Tag
00023 {
00024     function __construct($p_cn,$id=-1)
00025     {
00026         $this->cn=$p_cn;
00027         $this->data=new Tag_SQL($p_cn,$id);
00028     }
00029     /**
00030      * Show the list of available tag
00031      * @return HTML
00032      */
00033     function show_list()
00034     {
00035         $ret=$this->data->seek(' order by t_tag');
00036         if ( $this->cn->count($ret) == 0) return "";
00037         require_once 'template/tag_list.php';
00038     }
00039     /**
00040      * let select a tag to add
00041      */
00042     function select()
00043     {
00044         $ret=$this->data->seek(' order by t_tag');
00045         require_once 'template/tag_select.php';
00046     }
00047     /**
00048      * Display a inner window with the detail of a tag
00049      */
00050     function form_add()
00051     {
00052         $data=$this->data;
00053         require_once 'template/tag_detail.php';
00054     }
00055     /**
00056      * Show the tag you can add to a document
00057      */
00058     function show_form_add()
00059     {
00060         echo '<h2>'.' Ajout d\'un dossier (ou  tag)'.'</h2>';
00061        
00062         $this->form_add();
00063     }
00064     function save($p_array)
00065     {
00066         if ( trim($p_array['t_tag'])=="" ) return ;
00067         $this->data->t_id=$p_array['t_id'];
00068         $this->data->t_tag=  strip_tags($p_array['t_tag']);
00069         $this->data->t_description=strip_tags($p_array['t_description']);
00070         $this->data->save();
00071     }
00072     function remove($p_array)
00073     {
00074         $this->data->t_id=$p_array['t_id'];
00075         $this->data->delete();
00076     }
00077     /**
00078      * Show a button to select tag for Search
00079      * @return HTML
00080      */
00081     static  function button_search($p_prefix)
00082     {
00083         $r="";
00084         $r.=HtmlInput::button("choose_tag", "Etiquette", 'onclick="search_display_tag('.Dossier::id().',\''.$p_prefix.'\')"', "smallbutton");
00085         return $r;
00086     }
00087     /**
00088      * let select a tag to add to the search
00089      */
00090     function select_search($p_prefix)
00091     {
00092         $ret=$this->data->seek(' order by t_tag');
00093         require_once 'template/tag_search_select.php';
00094     }
00095     /**
00096      * In the screen search add this data to the cell
00097      */
00098     function update_search_cell($p_prefix) {
00099         echo '<span id="sp_'.$p_prefix.$this->data->t_id.'" style="border:1px solid black;margin-right:5px;">';
00100         echo h($this->data->t_tag);
00101         echo HtmlInput::hidden($p_prefix.'tag[]', $this->data->t_id);
00102         $js=sprintf("$('sp_".$p_prefix.$this->data->t_id."').remove();");
00103         echo '<span style="background-color:red;text-align:center;border-top:1px solid black; border-right:1px solid black;border-bottom:1px solid black;">';
00104         echo HtmlInput::anchor('X', "javascript:void(0)", "onclick=\"$js\"");
00105         echo '</span>';
00106         echo '</span>';
00107     }
00108     /**
00109      * clear the search cell
00110      */
00111     static function add_clear_button($p_prefix) {
00112         $clear=HtmlInput::button('clear', 'X', 'onclick="search_clear_tag('.Dossier::id().',\''.$p_prefix.'\');"', 'smallbutton');
00113         return $clear;
00114     }
00115 }
00116 
00117 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations