MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
linkcontrols.class
Ir para a documentação deste ficheiro.
1<?php
2
3class MLink extends MFormControl
4{
5 public $target='_self';
6 public $href;
7 public $onClick;
8
9
10 public function __construct( $name = NULL, $label = NULL, $href = NULL, $text = NULL, $target = '_self' )
11 {
12 parent::__construct( $name, $href, $label );
13
14 $this->caption = $text;
15 $this->href = $href;
16 $this->onClick = '';
17 $this->target = $target;
18 }
19
20
21 public function setOnClick( $onClick )
22 {
23 $this->onClick = $onClick;
24 }
25
26
27 public function setText( $text )
28 {
29 $this->caption = $text;
30 }
31
32
33 public function setHREF( $href )
34 {
35 $this->href = $href;
36 }
37
38
39 public function setAction( $module = '', $action = '', $item = null, $args = null )
40 {
41 $this->setHREF( $this->manager->getActionURL( $module, $action, $item, $args ) );
42 }
43
44
45 public function generateInner()
46 {
47 if ( $this->readOnly )
48 {
49 $this->inner = HtmlPainter::Span( 'm-readonly', $this->name, $this->caption );
50
51 return;
52 }
53
54 if ( $this->getClass() == '' )
55 {
56 $this->setClass( 'm-link' );
57 }
58
59 if ( $this->onClick != '' )
60 {
61 $this->addAttribute( 'onclick', $this->onClick );
62 }
63
64 if ( $this->target != '_self' )
65 {
66 $this->addAttribute( 'target', $this->target );
67 }
68
69 if ( $this->caption == '' )
70 {
71 $this->caption = $this->label;
72 }
73
74 $this->inner = $this->generateLabel() . $this->getRender('anchor');
75 }
76
77 function setTarget( $target )
78 {
79 $this->target = $target;
80 }
81}
82
83
84class MLinkButton extends MLink
85{
86 private $generateLinkButton = true;
87
88 public function __construct( $name = '', $label = '', $action = '' )
89 {
90 parent::__construct( $name, $label, $action );
91 }
92
93 public function getGenerateLinkButton()
94 {
95 return $this->generateLinkButton;
96 }
97
98 public function setGenerateLinkButton($generateLinkButton)
99 {
100 $this->generateLinkButton = $generateLinkButton;
101 }
102
103 public function generateLink()
104 {
106 $form = $this->page->name;
107 $name = str_replace( 'frm_', '', $this->name );
108 $onclick = ( $name != '' ) ? "{$name}:click" : '';
109
110 if ( count($this->eventHandlers) )
111 {
112 $param = $this->eventHandlers['click']['param'];
113 }
114
115 if ( $this->generateLinkButton )
116 {
117 $this->href = "javascript:_MIOLO_LinkButton('{$form}','{$action}','$onclick','$param','$this->target');";
118 }
119 }
120
121
122 public function generateInner()
123 {
124 $this->generateLink();
125
126 parent::generateInner();
127 }
128
129}
130
131
133{
134 public function __construct( $name, $label, $module = '', $action = '', $item = null, $args = null )
135 {
136 parent::__construct( $name, $label );
137
138 $this->setAction( $module, $action, $item, $args );
139 }
140}
141
142
143class MImageLink extends MLink
144{
147
148 public function __construct( $name = '', $label = '', $action = '', $location = '', $attrs = NULL )
149 {
150 parent::__construct( $name, $label, $action );
151
152 $this->location = $location;
153 $this->setAttributes( $attrs );
154
155 $this->image = new MImage( '', $label, $location, array('border' => '0') );
156 }
157
158
159 public function generateLink()
160 {
161 $this->caption = $this->image->generate();
162 }
163
164 public function generateInner()
165 {
166 $this->setClass( 'm-image-link' );
167 $this->generateLink();
168
169 parent::generateInner();
170 }
171}
172
173
175{
176 private $imageType = 'normal';
177
178
179 public function setImageType( $type = 'normal' )
180 {
181 $this->imageType = $type;
182 }
183
184
185 public function generateLink()
186 {
187 if ( $this->imageType == 'normal' )
188 {
189 $this->image->generateInner();
190 $image = new MDiv( '', $this->image->GetInner(), 'm-image-centered' );
191 $text = new MSpan( '', $this->label, 'm-image-link-label m-image-label' );
192 $this->caption = $image->generate() . $text->generate();
193 }
194 elseif ( $this->imageType == 'icon' )
195 {
196 $this->image->setClass( 'm-image-icon' );
197 $this->image->generateInner();
198 // $image = new MSpan('', $this->image->GetInner());
199 $text = new MSpan( '', $this->label, 'm-image-link-label' );
200 $this->caption = $this->image->generate() . $text->generate();
201 }
202 }
203}
204
205
207{
208 public function generateLink()
209 {
210 parent::generateLink();
211
213 $form = $this->page->name;
214 $name = str_replace( 'frm_', '', $this->name );
215 $onclick = ($name != '') ? "{$name}:click" : '';
216
217 $this->href = "javascript:_MIOLO_LinkButton('{$form}','{$action}','$onclick','','$this->target');";
218 $this->target = '';
219 }
220}
221
223{
224 private $imageType = 'normal';
225
226 public function setImageType($type = 'normal')
227 {
228 $this->imageType = $type;
229 }
230
231 public function generateLink()
232 {
233 parent::generateLink();
234
235 if ( $this->imageType == 'normal' )
236 {
237 $this->setClass('m-image-centered');
238 $text = new MSpan('', $this->label, 'm-image-link-label m-image-label');
239 }
240 elseif ( $this->imageType == 'icon' )
241 {
242 $this->image->setClass('m-image-icon');
243 $text = new MSpan('', $this->label, 'm-image-link-label');
244 }
245
246 $this->caption = $this->image->generate() . $text->generate();
247 }
248}
249
250?>
setAttributes($attr)
Definição mcontrol.class:462
setClass( $cssClass, $add=true)
Definição mcontrol.class:398
addAttribute( $name, $value='')
Definição mcontrol.class:443
getRender( $method)
Definição mcontrol.class:833
setImageType($type='normal')
setImageType( $type='normal')
setGenerateLinkButton($generateLinkButton)
__construct( $name='', $label='', $action='')
$action
Definição base.php:4