noalyss Version-9
itextarea.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
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!\file
23 * \brief Html Input
24 */
25
26/**
27 * @class ITextarea
28 * @brief Manage the TEXTAREA html element
29 */
30class ITextarea extends HtmlInput
31{
32 private $enrichText;
33 function __construct($p_name = "", $p_value = "", $p_id = "")
34 {
35 parent::__construct($p_name, $p_value, $p_id);
36 $this->style=' class="itextarea" ';
37 $this->enrichText="plain";
38 }
39
40 /**
41 * @brief return if enrichText is set to true or false
42 * @return mixed
43 */
44 public function get_enrichText()
45 {
46 return $this->enrichText;
47 }
48
49 /**
50 * @brief set enrichText to plain or enrich , enrich for WYSIWYG function, plain, plain textarea and choose
51 * to display a button to switch to a WYSIWYG
52 * @param mixed $enrich
53 */
54 public function set_enrichText($enrich)
55 {
56 if ( ! in_array($enrich,['plain','enrich'])) {
57 throw new \Exception("IT57.Invalid option");
58 }
59 $this->enrichText = $enrich;
60 return $this;
61 }
62
63 /*!\brief show the html input of the widget
64 * // style example style="height:15em;width: 80vw
65 */
66 public function input($p_name=null,$p_value=null)
67 {
68 $this->name=($p_name==null)?$this->name:$p_name;
69 $this->value=($p_value==null)?$this->value:$p_value;
70 $this->id=($this->id=="")?$this->name:$this->id;
71 if ( $this->readOnly==true) return $this->display();
72
73 if ( $this->enrichText == "plain" ) {
74 $r="";
75 $r.='<TEXTAREA '.$this->style.' name="'.$this->name.'" id="'.$this->id.'"';
76 $r.='>';
78 $r.="</TEXTAREA>";
79 } elseif ($this->enrichText=='enrich') {
80 if ( empty($this->id)) $this->id=$this->name;
81
82 $r=<<<EOF
83 <textarea name="{$this->name}" id="{$this->id}" {$this->style}>{$this->value}</textarea>
84<script type="text/javascript">
85 (function() {
86 new nicEditor({
87 buttonList : ['fontSize','fontFamily','fontFormat','bold','italic','underline',
88 'strikethrough','subscript','superscript','link','unlink','bgcolor','forecolor','indent','outdent','ol',
89 'ul','left','center','right','justify','hr','removeformat'],
90 'iconsPath': 'image/nicEditorIcons.gif'
91 }).panelInstance('{$this->id}');
92 })();
93 </script>
94EOF;
95 }
96 return $r;
97 }
98
99
100 /*!\brief print in html the readonly value of the widget*/
101 public function display()
102 {
103 if ( $this->enrichText=="plain")
104 {
105 $r='<p>';
106 $r.=h($this->value);
107 $r.=sprintf('<input type="hidden" name="%s" value="%s">',
108 $this->name,h($this->value));
109 $r.='</p>';
110 } elseif ($this->enrichText=='enrich' ) {
112 }
113 return $r;
114
115 }
116}
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
$opd_description style
$from_poste name
$input_from type
Definition: balance.inc.php:65
class widget This class is used to create all the HTML INPUT TYPE and some specials which works with ...
Manage the TEXTAREA html element.
get_enrichText()
return if enrichText is set to true or false
set_enrichText($enrich)
set enrichText to plain or enrich , enrich for WYSIWYG function, plain, plain textarea and choose to ...
__construct($p_name="", $p_value="", $p_id="")
display()
print in html the readonly value of the widget
input($p_name=null, $p_value=null)
show the html input of the widget // style example style="height:15em;width: 80vw
$icard readOnly
if( $delta< 0) elseif( $delta==0)