Exemplo n.º 1
0
 public function run()
 {
     if ($this->hasModel()) {
         echo Html::activeTextarea($this->model, $this->attribute, $this->options);
     } else {
         echo Html::textarea($this->name, $this->value, $this->options);
     }
     $this->registerPlugin();
 }
 public function run()
 {
     if ($this->hasModel()) {
         if (!ArrayHelper::getValue($this->options, 'id')) {
             $this->options['id'] = Html::getInputId($this->model, $this->attribute);
         }
         echo Html::activeTextarea($this->model, $this->attribute, $this->options);
     } else {
         if (!ArrayHelper::getValue($this->options, 'id')) {
             $this->options['id'] = Html::getAttributeName($this->name . rand(1, 9999));
         }
         echo Html::textarea($this->name, $this->value, $this->options);
     }
     $this->registerAssets();
 }
Exemplo n.º 3
0
 /**
  * @param $item
  * @return string
  */
 public static function settingField($key, $item, $traslateCategory)
 {
     $return = '';
     switch ($item['type']) {
         case 'checkbox':
             $return = parent::beginTag('div', ['class' => 'form-group']) . parent::beginTag('label', ['class' => 'col-md-3 control-label']) . \Yii::t($traslateCategory, $key) . parent::endTag('label') . parent::beginTag('div', ['class' => 'col-md-9']) . parent::hiddenInput('Settings[' . $key . ']', 0) . \oakcms\bootstrapswitch\Switcher::widget(['id' => 'wid' . uniqid(), 'name' => 'Settings[' . $key . ']', 'checked' => $item['value']]) . parent::endTag('div') . parent::endTag('div');
             break;
         case 'textInput':
             $return = parent::beginTag('div', ['class' => 'form-group']) . parent::beginTag('label', ['class' => 'col-md-3 control-label']) . \Yii::t($traslateCategory, $key) . parent::endTag('label') . parent::beginTag('div', ['class' => 'col-md-9']) . parent::textInput('Settings[' . $key . ']', $item['value'], ['class' => 'form-control']) . parent::endTag('div') . parent::endTag('div');
             break;
         case 'textarea':
             $return = parent::beginTag('div', ['class' => 'form-group']) . parent::beginTag('label', ['class' => 'col-md-3 control-label']) . \Yii::t($traslateCategory, $key) . parent::endTag('label') . parent::beginTag('div', ['class' => 'col-md-9']) . parent::textarea('Settings[' . $key . ']', $item['value'], ['class' => 'form-control']) . parent::endTag('div') . parent::endTag('div');
             break;
         case 'mediaInput':
             $return = parent::beginTag('div', ['class' => 'form-group']) . parent::beginTag('label', ['class' => 'col-md-3 control-label']) . \Yii::t($traslateCategory, $key) . parent::endTag('label') . parent::beginTag('div', ['class' => 'col-md-9']) . InputFile::widget(['id' => 'wid' . uniqid(), 'language' => \Yii::$app->language, 'filter' => 'image', 'name' => 'Settings[' . $key . ']', 'value' => $item['value']]) . parent::endTag('div') . parent::endTag('div');
             break;
         default:
             $return = '';
             break;
     }
     return $return;
 }
Exemplo n.º 4
0
 /**
  * Ham tao giao dien upload anh
  * @return string
  */
 public static function generateInsertFromUrl($image)
 {
     // Image preview
     $template = Html::beginTag('div', ['class' => 'col-sm-12']);
     $template .= Html::img($image, ['id' => 'embed_image_url']);
     $template .= Html::endTag('div');
     // Caption image
     $template .= Html::beginTag('div', ['class' => 'col-sm-12 embed_field']);
     $template .= Html::beginTag('label', ['class' => 'row']);
     $template .= Html::tag('span', 'Caption', ['class' => 'col-sm-12']);
     $template .= Html::textarea('', '', ['class' => 'form-control col-sm-12']);
     $template .= Html::endTag('label');
     $template .= Html::endTag('div');
     // Alt text image
     $template .= Html::beginTag('div', ['class' => 'col-sm-12 embed_field']);
     $template .= Html::beginTag('label', ['class' => 'row']);
     $template .= Html::tag('span', 'Alt text', ['class' => 'col-sm-12']);
     $template .= Html::input('text', '', '', ['class' => 'form-control col-sm-12']);
     $template .= Html::endTag('label');
     $template .= Html::endTag('div');
     return $template;
 }
Exemplo n.º 5
0
 /**
  * @param null $options
  * @param null $pluginOptions
  *
  * @return string
  * @throws \Exception
  */
 public function getItem($options = null, $pluginOptions = null)
 {
     switch ($this->type) {
         case self::TYPE_TEXT:
             return Html::input('text', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
         case self::TYPE_EMAIL:
             return Html::input('email', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
         case self::TYPE_NUMBER:
             return Html::input('number', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
         case self::TYPE_TEXTAREA:
             return Html::textarea('Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
         case self::TYPE_COLOR:
             return ColorInput::widget(['value' => $this->value, 'name' => 'Setting[' . $this->code . ']', 'options' => $options != null ? $options : ['class' => 'form-control']]);
         case self::TYPE_DATE:
             return DatePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['format' => 'yyyy-mm-dd', 'todayHighlight' => true]]);
         case self::TYPE_TIME:
             return TimePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['minuteStep' => 1, 'showSeconds' => true, 'showMeridian' => false]]);
         case self::TYPE_DATETIME:
             return DateTimePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => ['format' => 'yyyy-mm-dd H:i:s', 'todayHighlight' => true]]);
         case self::TYPE_PASSWORD:
             return PasswordInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['showMeter' => true, 'toggleMask' => false]]);
         case self::TYPE_ROXYMCE:
             return RoxyMceWidget::widget(['id' => 'Setting_' . $this->code, 'name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'action' => Url::to(['roxymce/default']), 'options' => $options != null ? $options : ['title' => $this->getName()], 'clientOptions' => $pluginOptions != null ? $pluginOptions : []]);
         case self::TYPE_SELECT:
             return Select2::widget(['value' => $this->value, 'name' => 'Setting[' . $this->code . ']', 'data' => $this->getStoreRange(), 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => ['allowClear' => true]]);
         case self::TYPE_MULTI_SELECT:
             $options['multiple'] = true;
             if (!isset($options['class'])) {
                 $options['class'] = 'form-control';
             }
             return Select2::widget(['name' => 'Setting[' . $this->code . ']', 'value' => explode(",", $this->value), 'data' => $this->getStoreRange(), 'options' => $options, 'pluginOptions' => ['allowClear' => true]]);
         case self::TYPE_FILE_PATH:
             $value = Yii::getAlias($this->store_dir) . DIRECTORY_SEPARATOR . $this->value;
             return FileInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $value, 'options' => $options != null ? $options : ['class' => 'form-control', 'multiple' => false], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['previewFileType' => 'any', 'showRemove' => false, 'showUpload' => false, 'initialPreview' => !$this->isNewRecord ? [$this->value] : []]]);
         case self::TYPE_FILE_URL:
             $value = $this->store_url . '/' . $this->value;
             return FileInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['previewFileType' => 'any', 'showRemove' => false, 'showUpload' => false, 'initialPreviewAsData' => true, 'initialPreviewFileType' => self::fileType(pathinfo($this->value, PATHINFO_EXTENSION)), 'initialPreview' => !$this->isNewRecord ? $value : [], 'initialCaption' => $this->value]]);
         case self::TYPE_PERCENT:
             return RangeInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'html5Options' => ['min' => 0, 'max' => 100, 'step' => 1], 'options' => $options != null ? $options : ['class' => 'form-control'], 'addon' => ['append' => ['content' => '%']]]);
         case self::TYPE_SWITCH:
             $selector = explode(',', $this->store_range);
             if (count($selector) != 2) {
                 throw new ErrorException(Yii::t('setting', 'Switch Field should have store with 2 value, and negative is first. Example: no,yes'), 500);
             }
             return Html::hiddenInput('Setting[' . $this->code . ']', $selector[0]) . SwitchInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $selector[1], 'containerOptions' => ['class' => 'nv-switch-container'], 'options' => $options != null ? $options : [], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['state' => $this->value == $selector[1], 'size' => 'small', 'offText' => ucfirst($selector[0]), 'onText' => ucfirst($selector[1])]]);
         case self::TYPE_CHECKBOX:
             $random = rand(1000, 9999);
             return Html::checkboxList('Setting[' . $this->code . ']', explode(",", $this->value), $this->getStoreRange(), $options != null ? $options : ['class' => 'nv-checkbox-list checkbox', 'item' => function ($index, $label, $name, $checked, $value) use($random) {
                 $html = Html::beginTag('div');
                 $html .= Html::checkbox($name, $checked, ['id' => 'Setting_checkbox_' . $label . '_' . $index . '_' . $random, 'value' => $value]);
                 $html .= Html::label($label, 'Setting_checkbox_' . $label . '_' . $index . '_' . $random);
                 $html .= Html::endTag('div');
                 return $html;
             }]);
         case self::TYPE_RADIO:
             $random = rand(1000, 9999);
             return Html::radioList('Setting[' . $this->code . ']', $this->value, $this->getStoreRange(), $options != null ? $options : ['class' => 'nv-checkbox-list radio', 'item' => function ($index, $label, $name, $checked, $value) use($random) {
                 $html = Html::beginTag('div');
                 $html .= Html::radio($name, $checked, ['id' => 'Setting_radio_' . $label . '_' . $index . '_' . $random, 'value' => $value]);
                 $html .= Html::label($label, 'Setting_radio_' . $label . '_' . $index . '_' . $random);
                 $html .= Html::endTag('div');
                 return $html;
             }]);
         case self::TYPE_SEPARATOR:
             return '<hr>';
         default:
             return Html::input('text', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
     }
 }
Exemplo n.º 6
0
<div>
    <label>Store Name</label>
    <?php 
echo Html::textInput('properties[store_name]', Property::getPropertyValue('store_name', ''), ['class' => 'form-control']);
?>
    <label>Default Title</label>
    <?php 
echo Html::textInput('properties[store_title]', Property::getPropertyValue('store_title', ''), ['class' => 'form-control']);
?>
    <label>META Description</label>
    <?php 
echo Html::textarea('properties[store_description]', Property::getPropertyValue('store_description', ''), ['class' => 'form-control']);
?>
    <label>META Keywords</label>
    <?php 
echo Html::textarea('properties[store_keywords]', Property::getPropertyValue('store_keywords', ''), ['class' => 'form-control']);
?>
    <label>Google Analytics ID</label>
    <?php 
echo Html::textInput('properties[google_analytics_id]', Property::getPropertyValue('google_analytics_id', ''), ['class' => 'form-control']);
?>
</div>

<h3>Authorize.net</h3>
<div>
    <label>Access Key</label>
    <?php 
echo Html::textInput('properties[authorize_key]', Property::getPropertyValue('authorize_key', ''), ['class' => 'form-control']);
?>
    <label>Access Login</label>
    <?php 
Exemplo n.º 7
0
<?php

/**
 * @copyright Copyright (c) 2016 RNP
 * @license http://github.com/ufrgs-hyman/meican#license
 */
use yii\bootstrap\Html;
$doc = new \DOMDocument('1.0');
$doc->preserveWhiteSpace = false;
$doc->formatOutput = true;
$doc->loadXML($model->message);
echo '<b>' . $model->getTypeLabel() . "</b> by " . $model->getAuthor() . ' at ' . Yii::$app->formatter->asDatetime($model->created_at) . '<br>' . Html::textarea('message', $doc->saveXML(), ['rows' => 20, 'cols' => 140, 'readOnly' => true]);
Exemplo n.º 8
0
 /**
  * Ham get html cho input theo type
  * @param string $type input co the la text, textarea, editor, date, datetime, daterange, dropdown, checkbox, radio
  * @param string $templateSetting giao dien input theo type
  * @param string $keySetting ten cua key setting
  * @param string $value gia tri cua key setting
  * @param array $items Mang cac gia tri cua setting neu setting co type la dropdown, checkbox, radio
  * @return string
  */
 private static function getInputByType($type = 'text', $templateSetting = null, $keySetting = null, $value = null, $items = [])
 {
     switch ($type) {
         case 'textarea':
             $templateSetting = Html::textarea($keySetting, $value, ['class' => 'form-control', 'title' => $keySetting]);
             break;
         case 'date':
             $templateSetting = DateControl::widget(['name' => $keySetting, 'value' => $value, 'type' => DateControl::FORMAT_DATE, 'ajaxConversion' => false, 'options' => ['pluginOptions' => ['autoclose' => true], 'options' => ['title' => $keySetting]], 'displayFormat' => 'dd-MM-yyyy', 'saveFormat' => 'yyyy-MM-dd']);
             break;
         case 'datetime':
             $templateSetting = DateControl::widget(['name' => $keySetting, 'value' => $value, 'type' => DateControl::FORMAT_DATETIME, 'ajaxConversion' => false, 'options' => ['pluginOptions' => ['autoclose' => true], 'options' => ['title' => $keySetting]], 'saveFormat' => 'yyyy-MM-dd']);
             break;
         case 'daterange':
             $templateSetting = DateRangePicker::widget(['name' => $keySetting, 'value' => $value, 'presetDropdown' => true, 'hideInput' => true, 'options' => ['title' => $keySetting]]);
             break;
         case 'dropdown':
             $templateSetting = Html::dropDownList($keySetting, $value, $items, ['class' => 'form-control', 'title' => $keySetting]);
             break;
         case 'checkbox':
             $templateSetting = Html::checkboxList($keySetting, $value, $items, ['class' => 'form-control', 'title' => $keySetting]);
             break;
         case 'radio':
             $templateSetting = Html::radioList($keySetting, $value, $items, ['class' => 'form-control', 'title' => $keySetting]);
             break;
         default:
             $templateSetting = Html::textInput($keySetting, $value, ['class' => 'form-control', 'title' => $keySetting]);
             break;
     }
     return $templateSetting;
 }
Exemplo n.º 9
0
 /**
  * Function generate preview infomation image
  * @param $image Infomation image
  * @return string
  */
 public static function generatePreviewImage($image)
 {
     $image = Json::decode($image);
     $url = ArrayHelper::getValue($image, 'url');
     $title = ArrayHelper::getValue($image, 'title');
     $caption = ArrayHelper::getValue($image, 'caption');
     $alt_text = ArrayHelper::getValue($image, 'alt_text');
     $imageUrl = Yii::getAlias('@web') . DIRECTORY_SEPARATOR . Yii::$app->getModule('gallery')->syaDirUpload . DIRECTORY_SEPARATOR . $url;
     $imagePath = Yii::getAlias(Yii::$app->getModule('gallery')->syaDirPath) . Yii::$app->getModule('gallery')->syaDirUpload . DIRECTORY_SEPARATOR . $url;
     $info = FileHelper::getInfomation($imagePath);
     $basename = ArrayHelper::getValue($info, 'basename');
     $filesize = ArrayHelper::getValue($info, 'filesize');
     $fileatime = ArrayHelper::getValue($info, 'fileatime');
     $width = ArrayHelper::getValue($info, 'width');
     $height = ArrayHelper::getValue($info, 'height');
     $template = Html::tag('h3', Yii::t('gallery', 'ATTACHMENT DETAILS'), []);
     // Info img
     $template .= Html::beginTag('div', ['class' => 'sya_info_galllery row']);
     $template .= Html::beginTag('div', ['class' => 'col-md-6', 'style' => 'padding: 0;']);
     $template .= Html::img($imageUrl, []);
     $template .= Html::endTag('div');
     $template .= Html::beginTag('div', ['class' => 'col-md-6', 'style' => 'padding: 0; word-break: break-word;']);
     // File Name
     $template .= Html::beginTag('div', ['style' => 'font-weight: bold;']);
     $template .= $basename;
     $template .= Html::endTag('div');
     $template .= Html::beginTag('div', []);
     $template .= date('d/m/Y', $fileatime);
     $template .= Html::endTag('div');
     // File size
     $template .= Html::beginTag('div', []);
     $template .= $filesize;
     $template .= Html::endTag('div');
     $template .= Html::beginTag('div', []);
     $template .= $width . ' x ' . $height;
     $template .= Html::endTag('div');
     $template .= Html::endTag('div');
     $template .= Html::endTag('div');
     // Attribute img
     $template .= Html::beginTag('div', ['class' => 'col-md-12 form-horizontal', 'style' => 'margin-top: 20px;']);
     $template .= Html::beginForm(' ', ' ', ['id' => 'sya_gallery_form_preview']);
     // Url
     $template .= Html::beginTag('div', ['class' => 'form-group field-gallery-url']);
     $template .= Html::tag('label', 'Url', ['class' => 'control-label col-sm-3']);
     $template .= Html::beginTag('div', ['class' => 'col-sm-9']);
     $template .= Html::input('text', 'sya_url', $url, ['class' => 'col-sm-10 form-control', 'readonly' => true]);
     $template .= Html::endTag('div');
     $template .= Html::endTag('div');
     // Title
     $template .= Html::beginTag('div', ['class' => 'form-group field-gallery-title']);
     $template .= Html::tag('label', 'Title', ['class' => 'control-label col-sm-3']);
     $template .= Html::beginTag('div', ['class' => 'col-sm-9']);
     $template .= Html::input('text', 'sya_title', $title, ['class' => 'col-sm-10 form-control', 'id' => 'sya_preview_title']);
     $template .= Html::endTag('div');
     $template .= Html::endTag('div');
     // Caption
     $template .= Html::beginTag('div', ['class' => 'form-group field-gallery-caption']);
     $template .= Html::tag('label', 'Caption', ['class' => 'control-label col-sm-3']);
     $template .= Html::beginTag('div', ['class' => 'col-sm-9']);
     $template .= Html::textarea('sya_caption', $caption, ['class' => 'col-sm-10 form-control', 'id' => 'sya_preview_caption']);
     $template .= Html::endTag('div');
     $template .= Html::endTag('div');
     // Alt text
     $template .= Html::beginTag('div', ['class' => 'form-group field-gallery-alt-text']);
     $template .= Html::tag('label', 'Alt text', ['class' => 'control-label col-sm-3']);
     $template .= Html::beginTag('div', ['class' => 'col-sm-9']);
     $template .= Html::input('text', 'sya_alt_text', $alt_text, ['class' => 'col-sm-10 form-control', 'id' => 'sya_preview_alt_text']);
     $template .= Html::endTag('div');
     $template .= Html::endTag('div');
     $template .= Html::endForm();
     $template .= Html::endTag('div');
     return $template;
 }
Exemplo n.º 10
0
 public static function renderField($group, $fieldName, $fieldParams)
 {
     $id = $fieldParams['id'];
     $type = $fieldParams['type'];
     $value = $fieldParams['value'];
     $description = $fieldParams['description'];
     $options = $fieldParams['options'];
     $fld = $group . '[' . $fieldName . ']';
     $html = '';
     switch ($type) {
         case 'text':
             $html .= self::labelInput($fieldName, $fld, Html::textInput($fld, $value, ['class' => 'form-control']));
             $html .= self::hint($description);
             break;
         case 'textarea':
             $html .= self::labelInput($fieldName, $fld, Html::textarea($fld, $value, ['rows' => 5, 'class' => 'form-control', 'hint' => $description]));
             $html .= ConfigurationUtils::hint($description);
             break;
         case 'checkbox':
             $html .= self::labelInput($fieldName, $fld, Html::checkbox($fld, $value, ['value' => $value == '1' ? '1' : '0', 'class' => 'form-control autoval']));
             break;
         case 'dropdown':
             $data = explode(",", $options);
             $data = array_reverse($data);
             $data[''] = Yii::t('app', 'Select an option...');
             $data = array_reverse($data);
             $data = array_combine($data, $data);
             $html .= self::labelInput($fieldName, $fld, Html::dropDownList($fld, $value, $data, ['class' => 'form-control']));
             break;
     }
     return $html;
 }
Exemplo n.º 11
0
    /**
     * Executes the widget.
     * @return string the result of widget execution to be outputted.
     * @throws InvalidParamException
     */
    public function run()
    {
        $this->view->registerJs('$(function() {
			tinyMCE.init({' . substr(Json::encode($this->clientOptions), 1, -1) . ',"file_browser_callback": RoxyFileBrowser});
		});', View::POS_HEAD);
        $this->view->registerJs('function RoxyFileBrowser(field_name, url, type, win) {
			var roxyMce = "' . $this->action . '";
			if(roxyMce.indexOf("?") < 0) {
				roxyMce += "?type=" + type;
			}
			else {
				roxyMce += "&type=" + type;
			}
			roxyMce += "&input=" + field_name + "&value=" + win.document.getElementById(field_name).value;
			if(tinyMCE.activeEditor.settings.language) {
				roxyMce += "&langCode=" + tinyMCE.activeEditor.settings.language;
			}
			tinyMCE.activeEditor.windowManager.open({
				file          : roxyMce,
				title         : "' . (array_key_exists('title', $this->clientOptions) ? $this->clientOptions['title'] : 'RoxyMce') . '",
				width         : 850,
				height        : 480,
				resizable     : "yes",
				plugins       : "media",
				inline        : "yes",
				close_previous: "no"
			}, {
				window: win,
				input : field_name
			});
			return false;
		}', View::POS_HEAD);
        if ($this->model !== null) {
            return Html::activeTextarea($this->model, $this->attribute, $this->options);
        } else {
            return Html::textarea($this->name, $this->value, $this->options);
        }
    }
Exemplo n.º 12
-13
 /**
  * @return string
  */
 public function renderField()
 {
     switch ($this->type) {
         case 'textInput':
             return Html::textInput($this->param_name, $this->param_value, ['class' => 'form-control']);
             break;
         case 'textarea':
             return Html::textarea($this->param_name, $this->param_value, ['class' => 'form-control']);
             break;
         case 'checkbox':
             return Html::hiddenInput($this->param_name, 0) . \oakcms\bootstrapswitch\Switcher::widget(['name' => $this->param_name, 'checked' => $this->param_value]);
             break;
         case 'language':
             return Html::dropDownList($this->param_name, $this->param_value, ArrayHelper::map(Language::getLanguages(), 'language_id', 'name'), ['class' => 'form-control']);
             break;
         case 'getTheme':
             $files = scandir(Yii::getAlias('@app') . '/templates/frontend');
             $items = [];
             foreach ($files as $file) {
                 //if(!is_file($file) AND $file != '.' AND $file != '..') {
                 if ($file != '.' and $file != '..') {
                     $items[$file] = $file;
                 }
             }
             return Html::dropDownList($this->param_name, $this->param_value, $items, ['class' => 'form-control']);
             break;
     }
 }