コード例 #1
0
 public function getField($widgetId, $rowGroupName = '', $rowIndex, $model, $attribute, $name, $value = '', $fieldClassName = '', $htmlOptions = array(), $hasError = false, $data = '', $params = '')
 {
     $template = isset($params['template']) ? $params['template'] : '';
     $content = $template !== '' ? str_replace('{num}', $rowIndex, $template) : $rowIndex;
     if (isset($htmlOptions['id'])) {
         unset($htmlOptions['id']);
     }
     $htmlOptions = ClonnableFields::addClass($htmlOptions, $fieldClassName);
     return CHtml::tag('div', $htmlOptions, $content);
 }
コード例 #2
0
 /**
  * @param string $widgetId
  * @param string $rowGroupName
  * @param int $rowIndex
  * @param CModel|null $model
  * @param string $attribute
  * @param $name
  * @param string $value
  * @param string $fieldClassName
  * @param array $htmlOptions
  * @param bool $hasError
  * @param string $data
  * @param string $params
  *
  * @return mixed|string
  */
 public function getField($widgetId, $rowGroupName = '', $rowIndex, $model, $attribute, $name, $value = '', $fieldClassName = '', $htmlOptions = array(), $hasError = false, $data = '', $params = '')
 {
     $emptyImage = Yii::app()->params['imagesUrl'] . '/no_photo_small.png';
     $imageUrl = $emptyImage;
     $imageObject = ImageObject::getImageObjectFromObject($model, true);
     if ($imageObject) {
         if (isset($imageObject->temp_small_image_url) && $imageObject->temp_small_image_url != '') {
             $imageUrl = $imageObject->temp_small_image_url;
         } else {
             $imageUrl = $imageObject->smallImageFile->getUrl();
         }
     }
     if ($hasError) {
         $fieldClassName = $fieldClassName . ' ' . CHtml::$errorCss;
     }
     $htmlOptions = ClonnableFields::addClass($htmlOptions, $fieldClassName);
     $htmlOptions = ClonnableFields::addClass($htmlOptions, 'clonnable-file-id');
     if (isset($htmlOptions['name'])) {
         $name = $htmlOptions['name'];
     }
     $fileUrlHtmlOptions = array();
     $hiddenFieldFileUrlName = ClonnableFields::generateFieldName(!$rowIndex > 0, $rowGroupName, $rowIndex, 'file_url');
     $fileUrlHtmlOptions['name'] = $hiddenFieldFileUrlName;
     $fileUrlHtmlOptions['id'] = ClonnableFields::generateFieldId($widgetId, $rowGroupName, $rowIndex, 'file_url');
     $fileUrlHtmlOptions['data-groupname'] = $rowGroupName;
     $fileUrlHtmlOptions['data-attribute'] = 'file_url';
     $fileUrlHtmlOptions['data-widgetname'] = $widgetId;
     $fileUrlHtmlOptions = ClonnableFields::addClass($fileUrlHtmlOptions, 'clonnable-file-url');
     $assetPath = Yii::app()->assetManager->getPublishedUrl(dirname(dirname(__FILE__)) . '/assets/');
     $loading = $assetPath . '/templateFineUploaderField/loading.gif';
     $imageStyle = isset($params['imageStyle']) ? ' style="' . $params['imageStyle'] . '"' : '';
     $template = '<div>
                        <div class="messages">
                             <div class="thumbnail">
                                 <img class="uploaded-preview" src="' . $imageUrl . '"' . $imageStyle . '>
                             </div>
                             <div class="progress" style="height:3px; margin-bottom:0px;">
                                <div class="bar" style="display:none; width: 0%;"></div>
                             </div>
                             <div class="buttons-row">
                                 <div class="' . $fieldClassName . ' btn btn-mini upload-button" style="width:100px; ' . ((int) $value > 0 ? 'display:none' : '') . '">
                                     <div class="button-title"><i class="icon-upload"></i> ' . Yii::t("ClonnableFields.templateFineUploaderField", "Upload") . '</div>
                                 </div>
                                 <div class="pull-right">
                                     <a href="#" class="delete-image-link" data-toggle="tooltip" title="' . Yii::t("ClonnableFields.templateFineUploaderField", "Delete File") . '" style="' . ((int) $value > 0 ? '' : 'display:none') . '" ><i class="icon-trash"></i></a>
                                     <a href="#" class="delete-image-wait" data-toggle="tooltip" title="' . Yii::t("ClonnableFields.templateFineUploaderField", "Deleting. Please hold.") . '" style="display:none" ><img src="' . $loading . '" alt="' . Yii::t("ClonnableFields.templateFineUploaderField", "Deleting. Please hold.") . '"></a>
                                 </div>
                             </div>
                             <div style="display:none">' . CHtml::hiddenField($name, $value, $htmlOptions) . '</div>
                             <div style="display:none">' . CHtml::hiddenField($hiddenFieldFileUrlName, $imageUrl, $fileUrlHtmlOptions) . '</div>
                        </div>
                     </div>';
     return $template;
 }
コード例 #3
0
 public function getField($widgetId, $rowGroupName = '', $rowIndex, $model, $attribute, $name, $value = '', $fieldClassName = '', $htmlOptions = array(), $hasError = false, $data = '', $params = '')
 {
     if ($hasError) {
         $fieldClassName = $fieldClassName . ' ' . CHtml::$errorCss;
     }
     $htmlOptions = ClonnableFields::addClass($htmlOptions, $fieldClassName);
     if (ClonnableFields::isModel($model)) {
         return CHtml::activeTextArea($model, $attribute, $htmlOptions);
     } else {
         return CHtml::textArea($name, $value, $htmlOptions);
     }
 }
コード例 #4
0
 public function getField($widgetId, $rowGroupName = '', $rowIndex, $model, $attribute, $name, $value = '', $fieldClassName = '', $htmlOptions = array(), $hasError = false, $data = '', $params = '')
 {
     if ($hasError) {
         $fieldClassName = $fieldClassName . ' ' . CHtml::$errorCss;
     }
     $htmlOptions = ClonnableFields::addClass($htmlOptions, $fieldClassName);
     $asDropDownList = isset($params['asDropDownList']) && $params['asDropDownList'] ? true : false;
     if (ClonnableFields::isModel($model)) {
         return $asDropDownList ? CHtml::activeDropDownList($model, $attribute, $data, $htmlOptions) : CHtml::activeHiddenField($model, $attribute, $htmlOptions);
     } else {
         return $asDropDownList ? CHtml::dropDownList($name, $value, $data, $htmlOptions) : CHtml::hiddenField($name, $value, $htmlOptions);
     }
 }
コード例 #5
0
 public function getField($widgetId, $rowGroupName = '', $rowIndex, $model, $attribute, $name, $value = '', $fieldClassName = '', $htmlOptions = array(), $hasError = false, $data = '', $params = '')
 {
     if ($hasError) {
         $fieldClassName = $fieldClassName . ' ' . CHtml::$errorCss;
     }
     $toggleButtonHtmlOptions = array('class' => 'toggle-button ' . $fieldClassName);
     $result = CHtml::openTag('div', $toggleButtonHtmlOptions);
     if (ClonnableFields::isModel($model)) {
         $result .= CHtml::activeCheckBox($model, $attribute, $htmlOptions);
     } else {
         $result .= CHtml::checkBox($name, $value, $htmlOptions);
     }
     $result .= CHtml::closeTag('div');
     return $result;
 }
コード例 #6
0
 public function getField($widgetId, $rowGroupName = '', $rowIndex, $model, $attribute, $name, $value = '', $fieldClassName = '', $htmlOptions = array(), $hasError = false, $data = '', $params = '')
 {
     if ($hasError) {
         $fieldClassName = $fieldClassName . ' ' . CHtml::$errorCss;
     }
     $htmlOptions = ClonnableFields::addClass($htmlOptions, $fieldClassName);
     $htmlOptions['autocomplete'] = 'off';
     $htmlOptions['aria-autocomplete'] = 'list';
     $htmlOptions['aria-haspopup'] = 'true';
     if (ClonnableFields::isModel($model)) {
         return CHtml::activeTextField($model, $attribute, $htmlOptions);
     } else {
         return CHtml::textField($name, $value, $htmlOptions);
     }
 }
コード例 #7
0
 public function getField($widgetId, $rowGroupName = '', $rowIndex, $model, $attribute, $name, $value = '', $fieldClassName = '', $htmlOptions = array(), $hasError = false, $data = '', $params = '')
 {
     $prepend = isset($params['prepend']) && $params['prepend'];
     $additionClass = $prepend ? 'input-prepend' : 'input-append';
     $prependHtml = isset($params['prependHtml']) ? $params['prependHtml'] : '';
     $prependHtml = CHtml::tag('span', array('class' => 'add-on'), $prependHtml);
     if ($hasError) {
         $fieldClassName = $fieldClassName . ' ' . CHtml::$errorCss;
     }
     $htmlOptions = ClonnableFields::addClass($htmlOptions, $fieldClassName);
     if (ClonnableFields::isModel($model)) {
         $inputHtml = CHtml::activeTextField($model, $attribute, $htmlOptions);
     } else {
         $inputHtml = CHtml::textField($name, $value, $htmlOptions);
     }
     return CHtml::tag('div', array('class' => $additionClass), $prepend ? $prependHtml . $inputHtml : $inputHtml . $prependHtml);
 }
コード例 #8
0
 public function getField($widgetId, $rowGroupName = '', $rowIndex, $model, $attribute, $name, $value = '', $fieldClassName = '', $htmlOptions = array(), $hasError = false, $data = '', $params = '')
 {
     if ($hasError) {
         $fieldClassName = $fieldClassName . ' ' . CHtml::$errorCss;
     }
     $htmlOptions = ClonnableFields::addClass($htmlOptions, $fieldClassName);
     $htmlOptions['type'] = 'number';
     if (!isset($htmlOptions['name'])) {
         $htmlOptions['name'] = $name;
     }
     if (!isset($htmlOptions['value'])) {
         $htmlOptions['value'] = $value;
     }
     $htmlOptions['type'] = 'number';
     if (ClonnableFields::isModel($model)) {
         return CHtml::activeNumberField($model, $attribute, $htmlOptions);
     } else {
         return CHtml::tag('input', $htmlOptions);
     }
 }