Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 72 lines (65 sloc) 1.865 kb
840e016 Initial implementation of form feature.
qiang.xue authored
1 <?php
27cc745
qiang.xue authored
2 /**
3 * CFormStringElement class file.
4 *
5 * @author Qiang Xue <qiang.xue@gmail.com>
6 * @link http://www.yiiframework.com/
4be0af6 changed copyright year.
qiang.xue authored
7 * @copyright Copyright &copy; 2008-2011 Yii Software LLC
27cc745
qiang.xue authored
8 * @license http://www.yiiframework.com/license/
9 */
840e016 Initial implementation of form feature.
qiang.xue authored
10
27cc745
qiang.xue authored
11 /**
12 * CFormStringElement represents a string in a form.
13 *
646cbb2 Documented component accessors with @property for significantly bette…
alexander.makarow authored
14 * @property string $on Scenario names separated by commas. Defaults to null.
15 *
27cc745
qiang.xue authored
16 * @author Qiang Xue <qiang.xue@gmail.com>
17 * @version $Id$
18 * @package system.web.form
19 * @since 1.1
20 */
840e016 Initial implementation of form feature.
qiang.xue authored
21 class CFormStringElement extends CFormElement
22 {
27cc745
qiang.xue authored
23 /**
24 * @var string the string content
25 */
840e016 Initial implementation of form feature.
qiang.xue authored
26 public $content;
27
27cc745
qiang.xue authored
28 private $_on;
840e016 Initial implementation of form feature.
qiang.xue authored
29
27cc745
qiang.xue authored
30 /**
31 * Returns a value indicating under which scenarios this string is visible.
32 * If the value is empty, it means the string is visible under all scenarios.
33 * Otherwise, only when the model is in the scenario whose name can be found in
34 * this value, will the string be visible. See {@link CModel::scenario} for more
35 * information about model scenarios.
36 * @return string scenario names separated by commas. Defaults to null.
37 */
840e016 Initial implementation of form feature.
qiang.xue authored
38 public function getOn()
39 {
40 return $this->_on;
41 }
42
27cc745
qiang.xue authored
43 /**
72b9745 Updated PHPDoc @param parameter names
mdomba authored
44 * @param string $value scenario names separated by commas.
27cc745
qiang.xue authored
45 */
840e016 Initial implementation of form feature.
qiang.xue authored
46 public function setOn($value)
47 {
48 $this->_on=preg_split('/[\s,]+/',$value,-1,PREG_SPLIT_NO_EMPTY);
49 }
50
27cc745
qiang.xue authored
51 /**
52 * Renders this element.
53 * The default implementation simply returns {@link content}.
54 * @return string the string content
55 */
840e016 Initial implementation of form feature.
qiang.xue authored
56 public function render()
57 {
58 return $this->content;
59 }
27cc745
qiang.xue authored
60
61 /**
62 * Evaluates the visibility of this element.
63 * This method will check the {@link on} property to see if
64 * the model is in a scenario that should have this string displayed.
65 * @return boolean whether this element is visible.
66 */
67 protected function evaluateVisible()
68 {
0044126 refactoring form feature.
qiang.xue authored
69 return empty($this->_on) || in_array($this->getParent()->getModel()->getScenario(),$this->_on);
27cc745
qiang.xue authored
70 }
840e016 Initial implementation of form feature.
qiang.xue authored
71 }
Something went wrong with that request. Please try again.