diff options
| author | Patrick Seeger <pseeger@ccwn.org> | 2012-05-15 21:30:11 +0200 |
|---|---|---|
| committer | Patrick Seeger <pseeger@ccwn.org> | 2012-05-15 21:30:11 +0200 |
| commit | 5759435f4da8ec800ba9af0fbbf7d6691e9ed56c (patch) | |
| tree | a3e6f6c676743e89b11804a03bd4f1e837983be9 /protected/components/Html.php | |
| parent | 94bdb31c204cdae3ca820828d4731f11f6ffeeae (diff) | |
diverse Layoutings
Diffstat (limited to 'protected/components/Html.php')
| -rw-r--r-- | protected/components/Html.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/protected/components/Html.php b/protected/components/Html.php new file mode 100644 index 0000000..6c7df3c --- /dev/null +++ b/protected/components/Html.php @@ -0,0 +1,38 @@ +<?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($url) { + return Yii::app()->baseUrl.'/js/'.$url; + } + + 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); + } +} +?>
\ No newline at end of file |
