Beispiel #1
0
 public static function renderFormRows($rows, Apartment $model)
 {
     if (!$rows) {
         return '';
     }
     //print_r($rows);
     $isShowTip = true;
     foreach ($rows as $row) {
         if (!$model->canShowInForm($row['field'])) {
             continue;
         }
         // если есть файл отображения для формы
         if ($row['standard_type'] == FormDesigner::STANDARD_TYPE_ORIGINAL_VIEW) {
             Yii::app()->controller->renderPartial('//../views/common/apartments/backend/fields/' . $row['field'], array('model' => $model));
             continue;
         }
         $required = $row->rules == FormDesigner::RULE_REQUIRED || $row->rules == FormDesigner::RULE_REQUIRED_NUMERICAL ? array('required' => true) : array();
         echo '<div class="rowold">';
         if ($row['standard_type'] == FormDesigner::STANDARD_TYPE_NEW) {
             echo CHtml::label($row['label_' . Yii::app()->language], get_class($model) . '_' . $row['field'], $required);
         } else {
             echo $row['is_i18n'] ? '' : CHtml::activeLabel($model, $row['field']);
         }
         if ($row['is_i18n']) {
             $isShowTip = false;
         }
         if ($isShowTip) {
             echo Apartment::getTip($row['field']);
         }
         switch ($row['type']) {
             case FormDesigner::TYPE_TEXT:
                 if ($row['is_i18n']) {
                     Yii::app()->controller->widget('application.modules.lang.components.langFieldWidget', array('model' => $model, 'field' => $row['field'], 'type' => 'string'));
                 } else {
                     echo CHtml::activeTextField($model, $row['field'], array('class' => 'width500', 'maxlength' => 255));
                 }
                 break;
             case FormDesigner::TYPE_INT:
                 echo CHtml::activeTextField($model, $row['field'], array('class' => 'width70', 'maxlength' => 255));
                 if ($row->measure_unit) {
                     echo '&nbsp;' . $row->measure_unit;
                 }
                 break;
             case FormDesigner::TYPE_TEXT_AREA:
                 if ($row['is_i18n']) {
                     Yii::app()->controller->widget('application.modules.lang.components.langFieldWidget', array('model' => $model, 'field' => $row['field'], 'type' => 'text'));
                 } else {
                     echo CHtml::activeTextArea($model, $row['field'], array('class' => 'width500 height200'));
                 }
                 break;
             case FormDesigner::TYPE_TEXT_AREA_WS:
                 if ($row['is_i18n']) {
                     Yii::app()->controller->widget('application.modules.lang.components.langFieldWidget', array('model' => $model, 'field' => $row['field'], 'type' => 'text-editor'));
                 } else {
                     // даем пользователям ограниченый набор форматирования
                     $toolbar = array(array('Source', '-', 'Bold', 'Italic', 'Underline', 'Strike'), array('NumberedList', 'BulletedList', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'));
                     $filebrowserImageUploadUrl = '';
                     if (Yii::app()->user->checkAccess('backend_access')) {
                         // if admin - enable upload image
                         $filebrowserImageUploadUrl = Yii::app()->createAbsoluteUrl('/site/uploadimage', array('type' => 'imageUpload', Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken));
                         $toolbar = array(array('Source', '-', 'Bold', 'Italic', 'Underline', 'Strike'), array('Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'), array('NumberedList', 'BulletedList', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'), array('Styles', 'Format', 'Font', 'FontSize', 'TextColor', 'BGColor'), array('Image', 'Link', 'Unlink', 'SpecialChar'));
                     }
                     Yii::app()->controller->widget('application.extensions.editMe.widgets.ExtEditMe', array('model' => $model, 'attribute' => $row['field'], 'toolbar' => $toolbar, 'filebrowserImageUploadUrl' => $filebrowserImageUploadUrl, 'htmlOptions' => array('id' => $model->id)));
                 }
                 break;
             case FormDesigner::TYPE_REFERENCE:
                 echo CHtml::activeDropDownList($model, $row['field'], CMap::mergeArray(array("" => Yii::t('common', 'Please select')), FormDesigner::getListByCategoryID($row->reference_id)));
                 break;
         }
         echo '</div>';
     }
 }