diff --git a/controllers/ContainerImageSetController.php b/controllers/ContainerImageSetController.php new file mode 100644 index 0000000..b8cdab6 --- /dev/null +++ b/controllers/ContainerImageSetController.php @@ -0,0 +1,21 @@ +load(Yii::$app->request->post())) { + return $this->renderAjax('../widgets/image_set/result', ['model' => $model]); + } + + return ModalClose::widget(['error', 'Could not load form data!']); + } +} \ No newline at end of file diff --git a/models/ContainerImageSetModel.php b/models/ContainerImageSetModel.php new file mode 100644 index 0000000..5e3c1a9 --- /dev/null +++ b/models/ContainerImageSetModel.php @@ -0,0 +1,111 @@ + ['user', 'space']], + [['max', 'width', 'height', 'acronymCount', 'hiddenImageWidth', 'hiddenImageHeight'], 'integer'], + [['link', 'tooltip'], 'boolean'], + [['htmlOptions', 'linkOptions', 'imageOptions', 'instance'], 'string'] + ]; + } + + public function attributeHints() + { + return [ + 'instance' => 'Select instance of items.', + 'max' => 'Maximal amount of visible items to render.', + 'width' => 'The width of the visible image in pixels. Default 50px.', + 'height' => 'The height of the visible image in pixels. Equals to width if empty.', + 'htmlOptions' => 'Html options for the generated tag.', + 'link' => 'Create link to the space or user profile.', + 'linkOptions' => 'Html Options of the link.', + 'tooltip' => 'Show tooltip with further information about the space or the user (Only available when link is true).', + 'imageOptions' => 'Optional html options for the image tag.', + 'acronymCount' => 'Number of characters used in the acronym (for spaces only).', + 'hiddenImageWidth' => 'The width of the hidden image in pixels. Default 24px.', + 'hiddenImageHeight' => 'The height of the hidden image in pixels. Equals to width if empty.', + ]; + } + + public function prepareOptions($prop) + { + $options = []; + $string = str_replace(['[', ']', '\'', '"'], '', $this->$prop); + foreach (explode(',', $string) as $item) { + $temp = explode('=>', $item); + $key = trim($temp[0]); + $value = trim($temp[1]); + $options[$key] = $value; + } + + return $options; + } +} \ No newline at end of file diff --git a/views/index/index.php b/views/index/index.php index c075a29..e67088b 100644 --- a/views/index/index.php +++ b/views/index/index.php @@ -61,7 +61,7 @@ PanelRow::widget([ 'items' => [ ['title' => Yii::t('DevtoolsModule.views_index_index', 'Forms'), 'url' => Url::to(['/devtools/showcase/view', 'id' => 'forms']), 'text' => Yii::t('DevtoolsModule.views_index_index', 'Learn how to submit form data.')], - ['disabled' => true, 'title' => Yii::t('DevtoolsModule.views_index_index', 'Widgets'), 'url' => Url::to(['/devtools/showcase/view', 'id' => 'widgets']), 'text' => Yii::t('DevtoolsModule.views_index_index', 'Learn how implement ui widgets.')], + ['disabled' => version_compare(Yii::$app->version, '1.4.dev', '<') ? true : false, 'title' => Yii::t('DevtoolsModule.views_index_index', 'Widgets'), 'url' => Url::to(['/devtools/showcase/view', 'id' => 'widgets']), 'text' => Yii::t('DevtoolsModule.views_index_index', 'Learn how implement ui widgets.')], ['disabled' => version_compare(Yii::$app->version, '1.3', '<') ? true : false, 'title' => Yii::t('DevtoolsModule.views_index_index', 'Richtext'), 'url' => Url::to(['/devtools/showcase/view', 'id' => 'richtext']), 'text' => Yii::t('DevtoolsModule.views_index_index', 'Learn how to use the Richtext widget and plugin system.')], ] ]); diff --git a/views/showcase/tabs/widgets_image_set/try.php b/views/showcase/tabs/widgets_image_set/try.php new file mode 100644 index 0000000..deec28f --- /dev/null +++ b/views/showcase/tabs/widgets_image_set/try.php @@ -0,0 +1,32 @@ + + + + field($model, 'instance')->radioList(['user' => 'Users', 'space' => 'Spaces'], ['value' => 'user']);?> + field($model, 'max')->textInput(['value' => 5])?> + field($model, 'width')->textInput(['value' => 50])?> + field($model, 'height')->textInput()?> + field($model, 'htmlOptions')->textInput()?> + field($model, 'link')->checkboxList(['Yes'])?> + field($model, 'linkOptions')->textInput()?> + field($model, 'tooltip')->checkboxList(['Yes'])?> + field($model, 'imageOptions')->textInput()?> + field($model, 'acronymCount')->textInput()?> + field($model, 'hiddenImageWidth')->textInput()?> + field($model, 'hiddenImageHeight')->textInput()?> + + + \ No newline at end of file diff --git a/views/showcase/tabs/widgets_image_set/view.php b/views/showcase/tabs/widgets_image_set/view.php new file mode 100644 index 0000000..32b1ad6 --- /dev/null +++ b/views/showcase/tabs/widgets_image_set/view.php @@ -0,0 +1,26 @@ + 'php']); ?> + + + +use \humhub\modules\ui\widgets\ContainerImageSet; + +/** @var $items \humhub\modules\user\models\User || \humhub\modules\user\models\Space */ + +?> + + ContainerImageSet::widget([ + 'items' => $items, + 'max' => 2, //Default 5 + 'width' => 50, // Default 50 + 'height' => null, // Default null + 'htmlOptions' => [], + 'link' => true, // Default false + 'linkOptions' => ['class' => 'pull-left'], //Default [] + 'showTooltip' => true, // Default false + 'imageOptions' => ['class' => 'img-rounded tt img_margin'], //Default [] + 'hiddenImageWidth' => 24, // Default 24 + 'hiddenImageWidth' => null // Default null + ]); + ?> + + 'widgets_image_set', + 'title' => Yii::t('DevtoolsModule.views_showcase_widgets', 'Container image set'), + 'description' => Yii::t('DevtoolsModule.views_showcase_widgets', 'Learn how to include container image set into your page.'), + 'tabs' => [ + ['id' => 'try', 'active' => true, 'title' => Yii::t('DevtoolsModule.base', 'Try')], + ['id' => 'view', 'title' => Yii::t('DevtoolsModule.base', 'View')], + ] + ], +]; +?> + + $showcases])?> \ No newline at end of file diff --git a/views/widgets/image_set/result.php b/views/widgets/image_set/result.php new file mode 100644 index 0000000..7bc2cb5 --- /dev/null +++ b/views/widgets/image_set/result.php @@ -0,0 +1,39 @@ + + + Yii::t('DevtoolsModule.views_client_result', 'Result')]); ?> + + + \ No newline at end of file