#1070 - Правка верстки в ПУ Контент

parent b588085e
......@@ -18,7 +18,8 @@ $(function() {
FormSliderSwitcher.init();
tinymce.init({
selector: "textarea",theme: "modern",
selector: "textarea",
theme: "modern",
language: "ru",
custom_elements: "emstart,emend,header,main,span",
extended_valid_elements: "span[id|name|class|style],i[id|name|class|style],ul[id|name|class|style],li[id|name|class|style]",
......@@ -27,7 +28,7 @@ $(function() {
plugins: [
"advlist autolink link image code lists charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
"table contextmenu directionality emoticons paste textcolor responsivefilemanager codesample"
"table contextmenu directionality emoticons paste textcolor responsivefilemanager codesample infowidgets"
],
toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | codesample | styleselect",
toolbar2: "| responsivefilemanager | link unlink anchor | image media | forecolor backcolor | print preview code ",
......
tinymce.PluginManager.add('infowidgets', function(editor, url) {
editor.addMenuItem('infowidget_button', {
text: 'Инфо-блок',
context: 'insert',
menu: [],
onPostRender: function() {
var ctrl = this, menu = [];
$.getJSON( '/content/block-admin/get' , function(response)
{
if(response.success)
{
tinymce.each(response.items, function(blocks, category) {
var subMenu = [];
tinymce.each(blocks, function(name, code) {
subMenu.push({
text: name,
onclick: function() {
editor.insertContent('{'+code+'}');
}
});
});
if(category == '')
{
category = '(Не определено)';
}
menu.push({
text: category,
menu: subMenu
});
});
ctrl.state.data.menu = ctrl.settings.menu = menu;
}
});
}
});
});
\ No newline at end of file
......@@ -5,6 +5,8 @@ namespace common\modules\content\controllers;
use Yii;
use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\web\Response;
use yii\helpers\ArrayHelper;
use yii\filters\VerbFilter;
use common\modules\content\models\CoBlocks;
......@@ -25,6 +27,7 @@ class BlockAdminController extends AdminController
'Copy' => 'Копирование блока',
'Delete' => 'Удаление блока',
'View' => 'Просмотр блока',
'Get' => 'Вывод списка блоков'
];
}
......@@ -198,6 +201,20 @@ class BlockAdminController extends AdminController
]);
}
/**
* Lists all CoBlocks models.
* @return mixed
*/
public function actionGet()
{
Yii::$app->response->format = Response::FORMAT_JSON;
return [
'success' => true,
'items' => ArrayHelper::map(CoBlocks::find()->all(), 'name', 'title', 'category.name')
];
}
/**
* Deletes an existing CoBlocks model.
* If deletion is successful, the browser will be redirected to the 'index' page.
......
......@@ -6,6 +6,7 @@ use Yii;
use common\modules\languages\models\Languages;
use common\modules\content\models\CoBlocksLang;
use common\modules\content\models\CoCategory;
/**
* This is the model class for table "co_blocks".
......@@ -78,6 +79,11 @@ class CoBlocks extends \common\components\ActiveRecordModel
];
}
public function getCategory()
{
return $this->hasOne(CoCategory::className(), ['id' => 'category_id']);
}
public function getLang($lang_id = null)
{
$lang_id = ($lang_id === null)? Languages::getCurrent()->id: $lang_id;
......
......@@ -35,7 +35,7 @@ use common\modules\content\models\CoBlocks;
<?php endforeach; ?>
</ul>
<div class="tab-content">
<div class="tab-content" style="padding: 15px 0;">
<?php $c = 0; foreach ($model->getLangsHelper() as $block) : $c++;
$lang_id = $block->lang->id; ?>
<div class="tab-pane fade <?=($c==1?'active in':'')?>" id="lang-<?=$block->lang->url;?>">
......
......@@ -73,7 +73,7 @@ $blocks = \common\modules\content\models\CoBlocks::find()->all();
}
?>
<div class="tab-content">
<div class="tab-content" style="padding: 15px 0;">
<?php $c = 0; foreach ($model->getLangsHelper() as $content) : $c++;
$lang_id = $content->lang->id; ?>
<div class="tab-pane fade <?=($c==1?'active in':'')?>" id="lang-<?=$content->lang->url;?>">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment