Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * TInlineFrame class file.
4
 *
5
 * @author Jason Ragsdale <jrags@jasrags.net>
6
 * @author Harry Pottash <hpottash@gmail.com>
7
 * @link http://www.pradosoft.com/
8
 * @copyright Copyright &copy; 2005-2008 PradoSoft
9
 * @license http://www.pradosoft.com/license/
10
 * @version $Id: TInlineFrame.php 2541 2008-10-21 15:05:13Z qiang.xue $
11
 * @package System.Web.UI.WebControls
12
 */
13
 
14
/**
15
 * TInlineFrame class
16
 *
17
 * TInlineFrame displays an inline frame (iframe) on a Web page.
18
 * The location of the frame content is specified by {@link setFrameUrl FrameUrl}.
19
 * The frame's alignment is specified by {@link setAlign Align}.
20
 * The {@link setMarginWidth MarginWidth} and {@link setMarginHeight MarginHeight}
21
 * properties define the number of pixels to use as the left/right margins and
22
 * top/bottom margins, respectively, within the inline frame.
23
 * The {@link setScrollBars ScrollBars} property specifies whether scrollbars are
24
 * provided for the inline frame. And {@link setDescriptionUrl DescriptionUrl}
25
 * gives the URI of a long description of the frame's contents.
26
 *
27
 * Original Prado v2 IFrame Author Information
28
 * @author Jason Ragsdale <jrags@jasrags.net>
29
 * @author Harry Pottash <hpottash@gmail.com>
30
 * @version $Id: TInlineFrame.php 2541 2008-10-21 15:05:13Z qiang.xue $
31
 * @package System.Web.UI.WebControls
32
 * @since 3.0
33
 */
34
class TInlineFrame extends TWebControl implements IDataRenderer
35
{
36
	/**
37
	 * @return string tag name of the iframe.
38
	 */
39
	protected function getTagName()
40
	{
41
		return 'iframe';
42
	}
43
 
44
	/**
45
	 * @return TInlineFrameAlign alignment of the iframe. Defaults to TInlineFrameAlign::NotSet.
46
	 */
47
	public function getAlign()
48
	{
49
		return $this->getViewState('Align',TInlineFrameAlign::NotSet);
50
	}
51
 
52
	/**
53
	 * @param TInlineFrameAlign alignment of the iframe.
54
	 */
55
	public function setAlign($value)
56
	{
57
		$this->setViewState('Align',TPropertyValue::ensureEnum($value,'TInlineFrameAlign'),TInlineFrameAlign::NotSet);
58
	}
59
 
60
	/**
61
	 * @return string the URL to long description
62
	 */
63
	public function getDescriptionUrl()
64
	{
65
		return $this->getViewState('DescriptionUrl','');
66
	}
67
 
68
	/**
69
	 * @param string the URL to the long description of the image.
70
	 */
71
	public function setDescriptionUrl($value)
72
	{
73
		$this->setViewState('DescriptionUrl',$value,'');
74
	}
75
 
76
	/**
77
	 * @return boolean whether there should be a visual separator between the frames. Defaults to true.
78
	 */
79
	public function getShowBorder()
80
	{
81
		return $this->getViewState('ShowBorder',true);
82
	}
83
 
84
	/**
85
	 * @param boolean whether there should be a visual separator between the frames.
86
	 */
87
	public function setShowBorder($value)
88
	{
89
		$this->setViewState('ShowBorder',TPropertyValue::ensureBoolean($value),true);
90
	}
91
 
92
	/**
93
	 * @return string URL that this iframe will load content from. Defaults to ''.
94
	 */
95
	public function getFrameUrl()
96
	{
97
		return $this->getViewState('FrameUrl','');
98
	}
99
 
100
	/**
101
	 * @param string URL that this iframe will load content from.
102
	 */
103
	public function setFrameUrl($value)
104
	{
105
		$this->setViewState('FrameUrl',$value,'');
106
	}
107
 
108
	/**
109
	 * Returns the URL that this iframe will load content from
110
	 * This method is required by {@link IDataRenderer}.
111
	 * It is the same as {@link getFrameUrl()}.
112
	 * @return string the URL that this iframe will load content from
113
	 * @see getFrameUrl
114
	 * @since 3.1.0
115
	 */
116
	public function getData()
117
	{
118
		return $this->getFrameUrl();
119
	}
120
 
121
	/**
122
	 * Sets the URL that this iframe will load content from.
123
	 * This method is required by {@link IDataRenderer}.
124
	 * It is the same as {@link setFrameUrl()}.
125
	 * @param string the URL that this iframe will load content from
126
	 * @see setFrameUrl
127
	 * @since 3.1.0
128
	 */
129
	public function setData($value)
130
	{
131
		$this->setFrameUrl($value);
132
	}
133
 
134
	/**
135
	 * @return TInlineFrameScrollBars the visibility and position of scroll bars in an iframe. Defaults to TInlineFrameScrollBars::Auto.
136
	 */
137
	public function getScrollBars()
138
	{
139
		return $this->getViewState('ScrollBars',TInlineFrameScrollBars::Auto);
140
	}
141
 
142
	/**
143
	 * @param TInlineFrameScrollBars the visibility and position of scroll bars in an iframe.
144
	 */
145
	public function setScrollBars($value)
146
	{
147
		$this->setViewState('ScrollBars',TPropertyValue::ensureEnum($value,'TInlineFrameScrollBars'),TInlineFrameScrollBars::Auto);
148
	}
149
 
150
	/**
151
	 * @return integer the amount of space, in pixels, that should be left between
152
	 * the frame's contents and the left and right margins. Defaults to -1, meaning not set.
153
	 */
154
	public function getMarginWidth()
155
	{
156
		return $this->getViewState('MarginWidth',-1);
157
	}
158
 
159
	/**
160
	 * @param integer the amount of space, in pixels, that should be left between
161
	 * the frame's contents and the left and right margins.
162
	 */
163
	public function setMarginWidth($value)
164
	{
165
		if(($value=TPropertyValue::ensureInteger($value))<0)
166
			$value=-1;
167
		$this->setViewState('MarginWidth',$value,-1);
168
	}
169
 
170
	/**
171
	 * @return integer the amount of space, in pixels, that should be left between
172
	 * the frame's contents and the top and bottom margins. Defaults to -1, meaning not set.
173
	 */
174
	public function getMarginHeight()
175
	{
176
		return $this->getViewState('MarginHeight',-1);
177
	}
178
 
179
	/**
180
	 * @param integer the amount of space, in pixels, that should be left between
181
	 * the frame's contents and the top and bottom margins.
182
	 */
183
	public function setMarginHeight($value)
184
	{
185
		if(($value=TPropertyValue::ensureInteger($value))<0)
186
			$value=-1;
187
		$this->setViewState('MarginHeight',$value,-1);
188
	}
189
 
190
	/**
191
	 * Adds attribute name-value pairs to renderer.
192
	 * This overrides the parent implementation with additional button specific attributes.
193
	 * @param THtmlWriter the writer used for the rendering purpose
194
	 */
195
	protected function addAttributesToRender($writer)
196
	{
197
		if($this->getID()!=='')
198
			$writer->addAttribute('name',$this->getUniqueID());
199
 
200
		if(($src=$this->getFrameUrl())!=='')
201
			$writer->addAttribute('src',$src);
202
 
203
		if(($align=strtolower($this->getAlign()))!=='notset')
204
			$writer->addAttribute('align',$align);
205
 
206
		$scrollBars=$this->getScrollBars();
207
		if($scrollBars===TInlineFrameScrollBars::None)
208
			$writer->addAttribute('scrolling','no');
209
		else if($scrollBars===TInlineFrameScrollBars::Both)
210
			$writer->addAttribute('scrolling','yes');
211
 
212
		if (!$this->getShowBorder())
213
			$writer->addAttribute('frameborder','0');
214
 
215
		if(($longdesc=$this->getDescriptionUrl())!=='')
216
			$writer->addAttribute('longdesc',$longdesc);
217
 
218
		if(($marginheight=$this->getMarginHeight())!==-1)
219
			$writer->addAttribute('marginheight',$marginheight);
220
 
221
		if(($marginwidth=$this->getMarginWidth())!==-1)
222
			$writer->addAttribute('marginwidth',$marginwidth);
223
 
224
		parent::addAttributesToRender($writer);
225
	}
226
}
227
 
228
/**
229
 * TInlineFrameAlign class.
230
 * TInlineFrameAlign defines the enumerable type for the possible alignments
231
 * that the content in a {@link TInlineFrame} could be.
232
 *
233
 * The following enumerable values are defined:
234
 * - NotSet: the alignment is not specified.
235
 * - Left: left aligned
236
 * - Right: right aligned
237
 * - Top: top aligned
238
 * - Middle: middle aligned
239
 * - Bottom: bottom aligned
240
 *
241
 * @author Qiang Xue <qiang.xue@gmail.com>
242
 * @version $Id: TInlineFrame.php 2541 2008-10-21 15:05:13Z qiang.xue $
243
 * @package System.Web.UI.WebControls
244
 * @since 3.0.4
245
 */
246
class TInlineFrameAlign extends TEnumerable
247
{
248
	const NotSet='NotSet';
249
	const Left='Left';
250
	const Right='Right';
251
	const Top='Top';
252
	const Middle='Middle';
253
	const Bottom='Bottom';
254
}
255
 
256
/**
257
 * TInlineFrameScrollBars class.
258
 * TInlineFrameScrollBars defines the enumerable type for the possible scroll bar mode
259
 * that a {@link TInlineFrame} control could use.
260
 *
261
 * The following enumerable values are defined:
262
 * - None: no scroll bars.
263
 * - Auto: scroll bars automatically appeared when needed.
264
 * - Both: show both horizontal and vertical scroll bars all the time.
265
 *
266
 * @author Qiang Xue <qiang.xue@gmail.com>
267
 * @version $Id: TInlineFrame.php 2541 2008-10-21 15:05:13Z qiang.xue $
268
 * @package System.Web.UI.WebControls
269
 * @since 3.0.4
270
 */
271
class TInlineFrameScrollBars extends TEnumerable
272
{
273
	const None='None';
274
	const Auto='Auto';
275
	const Both='Both';
276
}