123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- <?php
- use yii\helpers\Html;
- use yii\widgets\ActiveForm;
- use kartik\datetime\DateTimePicker;
- use \app\models\base\Story;
- use \app\models\base\NewsTopic;
- $request = Yii::$app->request;
- $id = $request->get('id');
- if( $id ){
- $this->title="Редактирование статьи";
- $news = \app\models\News::find()->andWhere(['id'=>$id])->one();
- // print_a( $news );
- }else{
- $this->title="Новая статья";
- $anews = [
- 'title' => ''
- ];
- $news = new \app\models\News();;
- $news->title = '';
- }
- ?>
- <?
- $form = ActiveForm::begin([
- 'id' => 'news-form',
- 'options' => ['class' => 'form-horizontal','enctype' => 'multipart/form-data'],]);
- //иничиализация
- DateTimePicker::widget([
- 'name' => 'dt_pub',
- 'options' => [],
- 'convertFormat' => true,
- 'pluginOptions' => [
- 'format' => 'd-M-Y g:i A',
- 'startDate' => '01-Mar-2014 12:00 AM',
- 'todayHighlight' => true
- ]
- ]);
- ?>
- <div class="row"><div class="col">
- <div class="input-group mb-3">
- <div class="input-group-prepend">
- <span class="input-group-text" id="basic-addon1" onclick="jQuery('#dt_pub').datetimepicker('show')"><i class="fa fa-calendar"></i></span>
- </div>
- <input type="text" id="dt_pub" class="col-auto" placeholder="Дата публикации" aria-label="Дата публикации" aria-describedby="basic-addon1" value="<?=$news->dt_pub?>" name="news['dt_pub']">
- </div>
- <?
- /*
- echo $form->field($news, 'title')->textInput([
- 'maxlength' => true,
- 'class' => 'form-control js-word-count-input',
- 'placeholder' => 'Заголовок новости'
- ])->label('Заголовок');
- */
- ?>
- <div class="form-group field-news-title required">
- <label class="control-label col-form-label" for="news-title">Заголовок</label>
- <div class="row">
- <input type="text" id="news-title" class="form-control js-word-count-input col-sm-6" name="News[title]" value="Преподаватель МГУ вспомнил, как Горбачёва избила букетом роз старушка в Сибири" placeholder="Заголовок новости" aria-required="true" value="<?=$news->meta_title?>">
- <div class="help-block px-lg-2"><div class="news__input-word-count"><span class="count">0</span> из 80</div></div>
- <a class="btn btn-primary px-lg-2" data-toggle="collapse" href="#collapseSEOTitle" role="button" aria-expanded="false" aria-controls="collapseSEOTitle">SEO title</a>
- </div>
- </div>
- <div class="collapse" id="collapseSEOTitle">
- <div class="card card-body">
- <input type="text" name="news[meta_title]" value="<?=$news->meta_title?>">
- </div>
- </div>
- <div class="form-group field-news-lid required">
- <label class="control-label" for="news-lid">Новость кратко</label>
- <textarea id="news-lid" class="form-control js-word-count-input" name="News[lid]" placeholder="Лид" aria-required="true"><?=$news->lid?></textarea>
- <div class="help-block">Краткое содержание статьи</div>
- </div>
- <div class="form-group">
- <label class="control-label" for="news-link">Прямой переход на URL</label>
- <div class="row">
- <input type="text" class="form-control" name="news[link]" id="news-link" value="<?=$news->link?>">
- </div>
- </div>
- <div class="form-group">
- <label class="control-label" for="news-embed">вставка медиа URL</label>
- <div class="row">
- <input type="text" class="form-control" name="news[embed_url]" id="news-embed" value="<?=$news->embed_url?>">
- </div>
- </div>
- <div class="form-group field-js-news-content required">
- <label class="control-label" for="js-news-content">Контент</label>
- <textarea id="js-news-content" class="form-control" name="News[text]" rows="12" aria-required="true"><?=$news->text?></textarea>
- </div>
- <blockquote class="quote-info mt-0">
- <h5 id="tip">Новость подготовили</h5>
- <p><?=$news->editors?></p>
- </blockquote>
- <div class="input-group">
- <label class="control-label col-form-label mr-3" >Автор</label>
- <select class="custom-select custom-select-sm" name="news[author]" id="news-author">
- <option selected>Откройте это меню выбора</option>
- <option value="1">Вася</option>
- <option value="2">Гоша</option>
- <option value="3">Саша</option>
- </select>
- <label class="input-group-append btn btn-primary" title="показывать автора" for="news-author">
- <input type="checkbox" autocomplete="off" name="News[show_author]"><i class="fa fa-eye ml-2"></i>
- </label>
- </div>
- <div class="card card-outline card-primary">
- <div class="card-body">
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" id="customRadioInline1" name="customRadioInline" class="custom-control-input">
- <label class="custom-control-label" for="customRadioInline1"><i class="fas fa-spell-check"></i>Корректор</label>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" id="customRadioInline2" name="customRadioInline" class="custom-control-input">
- <label class="custom-control-label" for="customRadioInline2"><s><i class="fas fa-search"></i></s>Не отдавать в поиск</label>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" id="customRadioInline4" name="customRadioInline" class="custom-control-input">
- <label class="custom-control-label" for="customRadioInline4"><i class="fas fa-yin-yang"></i>Не отдавать в <strong class="text-indigo">DZEN</strong> новости</label>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" id="customRadioInline3" name="customRadioInline" class="custom-control-input">
- <label class="custom-control-label" for="customRadioInline3"><i class="fas fa-comment-slash"></i>Без коментариев</label>
- </div>
- </div>
- </div>
- <div class="card card-outline card-teal">
- <div class="card-body">
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" name="iphoto_status" value="ON" id="fcont1" class="custom-control-input">
- <label class="custom-control-label" for="fcont1"><i class="fa fa-camera"></i> C фото материалом</label>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" name="ivideo_status" value="ON" id="fcont2" class="custom-control-input">
- <label class="custom-control-label" for="fcont2"><i class="fa fa-video"></i> C видео материалом</label>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" name="iaudio_status" value="ON" id="fcont3" class="custom-control-input">
- <label class="custom-control-label" for="fcont3"><i class="fa fa-headphones"></i> C аудио материалом</label>
- </div>
- </div>
- </div>
- <div class="card card-outline card-olive">
- <div class="card-body">
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" name="iphoto_status" value="ON" id="fcont4" class="custom-control-input">
- <label class="custom-control-label" for="fcont4"><i class="fas fa-comment-dollar"></i> Простая коммерческая</label>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" name="ivideo_status" value="ON" id="fcont5" class="custom-control-input">
- <label class="custom-control-label" for="fcont5"><i class="fas fa-comment-dollar"></i> Медицинская коммерческая</label>
- </div>
- </div>
- </div>
- <div class="card card-outline card-maroon">
- <div class="card-body">
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" name="top" value="ON" id="fcont6" class="custom-control-input">
- <label class="custom-control-label" for="fcont6"><i class="fas fa-comment-dollar"></i> В топ</label>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" name="NH" value="ON" id="fcont7" class="custom-control-input">
- <label class="custom-control-label" for="fcont7"><i class="fas fa-comment-dollar"></i> В НЧ</label>
- </div>
- </div>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" name="active" value="ON" id="active" class="custom-control-input">
- <label class="custom-control-label" for="active"><i class="far fa-play-circle"></i> Опубликовать</label>
- </div>
- <script>
- window.datetimepicker_conf = {"bootcssVer":4,"icontype":"glyphicon","fontAwesome":true,"icons":{"leftArrow":"glyphicon-arrow-left","rightArrow":"glyphicon-arrow-right"},"format":"dd-mm-yyyy hh:ii","type":3,"startDate":"11-Oct-2022 04:35","todayHighlight":true,"language":"ru","autoclose":true,"timezone":"UTC"};
- jQuery(function ($) {
- if (jQuery('#dt_pub').data('datetimepicker')) { jQuery('#dt_pub').datetimepicker('destroy'); }
- $('#dt_pub').datetimepicker(datetimepicker_conf);
- });
- </script>
- <a href="#preview" class="btn btn-info" target="_blank"><i class="fas fa-cat"></i> Предпросмотр</a>
- <?
- echo Html::submitButton('Send', ['class' => 'btn btn-success']);
- echo Html::submitButton('Save', ['class' => 'btn btn-success']);
- ?>
- </div>
- <!-- правая колонка --->
- <div class="col-3">
- <div class="card card-primary">
- <div class="card-header">
- <h3 class="card-title">Фото</h3>
- </div>
- <div class="card-body">
- <?
- if($news->id){
- $imageSrc = "/images/news/news/".$news->id."_size4.jpg";
- }
- echo @app\components\admin\uploadcrop\UploadCrop::widget(
- [
- 'form' => $form,
- 'model' => $news,
- 'attribute' => 'photo',
- 'maxSize' => 3000,
- 'imageSrc' => (isset($imageSrc)) ? $imageSrc : '',
- 'title' => 'Фото',
- 'changePhotoTitle' => 'Фото',
- 'jcropOptions' => [
- 'center' => true,
- 'rotatable' => true,
- 'autoCrop' => true,
- 'autoCropArea' => false,
- 'checkOrientation' => true,
- 'aspectRatio' => 16 / 9,
- 'dragMode' => 'move',
- 'viewMode' => 1,
- 'autoCropArea' => '0.1',
- 'restore' => true,
- 'guides' => true,
- 'center' => true,
- 'movable' => false,
- 'highlight' => true,
- 'cropBoxMovable' => true,
- 'cropBoxResizable' => true,
- 'background' => false,
- 'minContainerHeight' => 500,
- 'minCanvasHeight' => 400,
- 'minCropBoxWidth' => 600,
- 'minCropBoxHeight' => 200,
- 'responsive' => true,
- 'toggleDragModeOnDblclick' => false,
- 'crop' => 'crq'
- ]
- ]
- );
- ?>
- <label class="control-label" for="status-photo">Статусы для фото</label>
- <div class="btn-group" data-toggle="buttons" id="status-photo">
- <label class="btn btn-primary active btn-sm px-3" title="показывать фото">
- <input type="checkbox" autocomplete="off" name="News[photo_include]"><i class="fa fa-eye ml-2"></i>
- </label>
- <label class="btn btn-info active btn-sm px-3" title="фото в пр. ленте">
- <input type="checkbox" autocomplete="off" name="News[photo_rcol]"><i class="fa fa-list-alt ml-2"></i>
- </label>
- <label class="btn btn-dark active btn-sm px-3" title="удалить фото">
- <input type="checkbox" autocomplete="off" name="News[del_photo]"><i class="fa fa-trash ml-2"></i>
- </label>
- </div>
- <div class="form-group field-title-photo required">
- <label class="control-label" for="title-photo">Подпись фото</label>
- <textarea id="title-photo" class="form-control" name="News[photo_title]" rows="1" aria-required="true"><?=$news->photo_title?></textarea>
- </div>
- </div>
- </div>
- <div class="card card-primary">
- <div class="ribbon-wrapper">
- <div class="ribbon bg-primary">
- Рубрики
- </div>
- </div>
- <div class="card-body">
- <?
- $model = new NewsTopic();
- $Titems = $model->getForNews($news->id);
- $atopic = array();
- foreach( $Titems as $item ){
- $atopic[$item->id] = $item->id;
- }
- foreach( NewsTopic::findActive()->getModels() as $item ){
- ?>
- <div class="custom-control <?=($item->show == 'Y')?'custom-checkbox':'custom-switch bg-purple'?>">
- <input class="custom-control-input" type="checkbox" value="" id="flexCheck<?=$item->id?>" name="Topics[<?=$item->id?>]"<?=(in_array($item->id, $atopic, true))?' checked':''?>>
- <label class="custom-control-label" for="flexCheck<?=$item->id?>">
- <?=$item->title?>
- </label>
- </div>
- <?
- }
- ?>
- </div>
- </div>
- <div class="card card-primary">
- <div class="ribbon-wrapper">
- <div class="ribbon bg-primary">
- сюжеты
- </div>
- </div>
- <div class="card-body">
- <div class="input-group">
- <div class="input-group-prepend">
- <span class="btn btn-primary" id="validatedInputGroupPrepend"><i class="fas fa-search"></i></span>
- </div>
- <input type="text" class="form-control" aria-describedby="validatedInputGroupPrepend" id="story">
- </div>
- <?
- $model = new Story();
- $Sitems = $model->getForNews($news->id);
- ?>
- <div class="custom-control custom-checkbox">
- <?
- foreach($Sitems as $item){
- ?>
- <div class="custom-control custom-checkbox">
- <input class="custom-control-input" type="checkbox" value="" id="Story<?=$item->id?>" name="Story[<?=$item->id?>]" checked>
- <label class="custom-control-label" for="Story<?=$item->id?>">
- <?=$item->title?>
- </label>
- </div>
- <?
- }
- ?>
- <div id="story_items"></div>
- </div>
- </div>
- </div>
- <!-- end col r-->
- </div></div>
- <?
- ActiveForm::end();
- ?>
- <script>
- $(function() {
- var cache = {};
- $( "#story" ).autocomplete({
- source: function( request, response ) {
- var term = request.term;
- if ( term in cache ) {
- response( cache[ term ] );
- return;
- }
- $.getJSON( "ajaxstory", {'q':request.term}, function( data, status, xhr ) {
- if( data.status == 'ok' ){
- cache[ term ] = data.item;
- response( data.item );
- }
- });
- },
- minLength: 3,
- select: function( event, ui ) {
- if( $( "#story_items :input[value='"+ui.item.id+"']" ).val() != ui.item.id ){
- $( "#story_items" ).append('<div class="custom-control custom-checkbox"><input class="custom-control-input" type="checkbox" name="Story[]" value="'+ui.item.id+'" checked ><label class="custom-control-label" >'+ ui.item.label +"</label></div>");
- }
- },
- open: function() {
- $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
- },
- close: function() {
- $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
- }
- });
- });
- </script>
|