1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<?php
class Html extends CHtml {
/**
* Makes the given URL relative to the /image directory
*/
public static function imageUrl($url) {
return Yii::app()->baseUrl.'/images/'.$url;
}
/**
* Makes the given URL relative to the /css directory
*/
public static function cssUrl($url) {
return Yii::app()->baseUrl.'/css/'.$url;
}
/**
* Makes the given URL relative to the /js directory
*/
public static function jsUrl($filename) {
return Yii::app()->baseUrl.'/js/'.$filename;
}
public static function registerJavascript($filename) {
Yii::app()->getClientScript()->registerScriptFile(self::jsUrl($filename));
}
public static function enumItem($model, $attribute) {
$attr = $attribute;
self::resolveName($model, $attr);
preg_match('/\((.*)\)/', $model->tableSchema->columns[$attr]->dbType, $matches);
foreach (explode(',', $matches[1]) as $value) {
$value = str_replace("'", null, $value);
$values[$value] = Yii::t('enumItem', $value);
}
return $values;
}
public static function enumDropDownList($model, $attribute, $htmlOptions = array()) {
return CHtml::activeDropDownList($model, $attribute, Html::enumItem($model, $attribute), $htmlOptions);
}
public static function einheitenDropDownList($model, $attribute, $values, $htmlOptions = array()) {
$tmpEinheiten = preg_split('/,/', $values);
$einheiten = array();
foreach ($tmpEinheiten as $einheit) {
$einheit = trim($einheit);
$einheiten[$einheit] = $einheit;
}
self::resolveNameID($model, $attribute, $htmlOptions);
$selectedValue = self::resolveValue($model, $attribute);
return CHtml::dropDownList($htmlOptions['name'], $selectedValue, $einheiten);
}
}
?>
|