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