1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078 |
- <?php
- use app\assets\GalleryManagerAsset;
- use manager\models\News;
- use yii\helpers\Html;
- use yii\helpers\ArrayHelper;
- use yii\widgets\ActiveForm;
- use kartik\datetime\DateTimePicker;
- use \app\models\base\Tags;
- use \app\models\base\Story;
- use \app\models\base\Image;
- use \app\models\base\NewsTopic;
- use app\models\Authors;
- use app\widgets\CropperjsWidget;
- use zxbodya\yii2\galleryManager\GalleryManager;
- use \app\models\Tagsfilter;
- /**
- * @var $news News
- */
- GalleryManagerAsset::register($this);
- $cache = Yii::$app->cache;
- $tmodel = new Tags();
- $session = Yii::$app->session;
- $session->open();
- $tagsmenu = Yii::$app->cache->getOrSet("tagsmenu",function () use($tmodel){
- return $tmodel->find()->rightJoin(['m'=>Tagsfilter::find()], 'm.id = tags.id')->orderBy('sort')->All();
- });
- $key = 'AI_time_midnv#aiprogress0';
- $AI_time_mid = $cache->get($key);
- if( !$AI_time_mid ) $AI_time_mid = 50;
- ?>
- <ul class="nav nav-tabs">
- <li class="nav-item">
- <a class="nav-link active" data-toggle="tab" href="#edit">Статья</a>
- </li>
- <li class="nav-item">
- <a class="nav-link" data-toggle="tab" href="#comments">Комментарии</a>
- </li>
- </ul>
- <div class="tab-content">
- <div class="tab-pane fade show active" id="edit">
- <?
- // редактор
- $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 H:i ',
- 'startDate' => '01-Mar-2000 12:00',
- 'todayHighlight' => true
- ]
- ]);
- $tcount = 90;
- if( mb_strlen( $news->title ) > $tcount ){
- $tcount = mb_strlen( $news->title );
- }
- $model = new Authors();
- $authors = $model->findAll(['active' => 'Y']);
- //$author = $model->findOne(['id' => $news->author]);
- $author = $model->getAuthor($news->author);
- $ids = ArrayHelper::getColumn($authors, 'id');
- if( !in_array($author->id, $ids) ){
- $authors = array_merge($authors, [$author]);
- };
- $news->commerc = ($news->inscription == 2)?'Y':'N';
- $news->mcommerc = ($news->inscription == 1)?'Y':'N';
- $news->pcommerc = ($news->inscription == 3)?'Y':'N';
- $news->fdzen = ($news['export_rss'] & 1)?'Y':'N';
- $news->fmail = ($news['export_rss'] & 2)?'Y':'N';
- $nofirst = ($news->flags & 1);
- $photoamic = ($news->flags & 2);
- if( isset($uuid) )
- {
- $news->uid = $uuid;
- }else{
- $uuid = $news->uid;
- }
- if($news->isNewRecord)
- {
- ?>
- <div class="info-box">
- <span class="info-box-icon bg-info"><i class="far fa-bookmark"></i></span>
- <div class="info-box-content">
- <span class="info-box-text">Сгенерировал. UUID</span>
- <span class="info-box-number"><?=$uuid?></span>
- <div class="progress">
- <div class="progress-bar bg-info" style="width: 70%"></div>
- </div>
- <span class="progress-description">
- Информация для отладки
- </span>
- </div>
- </div>
- <input type="hidden" name="News[photo_name]" id="photo_name" value="">
- <?
- }else{
- ?>
- <div class="info-box">
- <span class="info-box-icon bg-info"><i class="far fa-bookmark"></i></span>
- <div class="info-box-content">
- <span class="info-box-text">ID Новости</span>
- <span class="info-box-number"><?=$news->id?></span>
- <span class="info-box-text">uid Новости</span>
- <span class="info-box-number"><?=$uuid?></span>
- <div class="progress">
- <div class="progress-bar bg-info" style="width: 70%"></div>
- </div>
- <span class="progress-description">
- Информация для отладки
- </span>
- </div>
- </div>
- <input type="hidden" name="News[id]" value="<?=$news->id?>">
- <input type="hidden" name="News[alias]" value="<?=$news->alias?>">
- <input type="hidden" name="News[photo_name]" id="photo_name" value="<?=$news->photo_name?>">
- <?
- if( $res = $cache->get("editNews_".$news->id) ){
- if( isset( unserialize($res)['author'] ) && unserialize($res)['author'] != Yii::$app->user->identity->profile->name){
- //Yii::$app->user->identity->profile->name //self
- /*
- * Предупреждение о пути истинного
- */
- ?>
- <div class="modal" tabindex="-1" data-show="true" id="editing">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">Заблокированная новость</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body">
- <p>Новость уже открыта в другом окне автором: <?=unserialize($res)['author']?></p>
- </div>
- <div class="modal-footer">
- <a href="/manager/news/list"><button type="button" class="btn btn-secondary">Покинуть новость</button></a>
- <button type="button" class="btn btn-primary" data-dismiss="modal">Всё равно войти в новость</button>
- </div>
- </div>
- </div>
- </div>
- <script>$(function () {$('#editing').modal('show')});</script>
- <?
- }
- }else{
- ?>
- <script>
- $(function () {
- $.get( "newsping", { id: <?=$news->id?> }, function(data){} );
- });
- </script>
- <?
- }
- }
- if( $news->errors ){
- ?>
- <div class="card card-danger">
- <div class="card-header">
- <h3 class="card-title">Обнаружены ошибки</h3>
- <div class="card-tools">
- <span class="badge badge-dark">Error</span>
- </div>
- <!-- /.card-tools -->
- </div>
- <!-- /.card-header -->
- <div class="card-body">
- <?=$form->errorSummary($news)?>
- </div>
- <!-- /.card-body -->
- </div>
- <!-- /.card -->
- <?
- }
- $_SESSION['ckfinder_url'] = '/images/upload/'.(string)$news->uid;
- $_SESSION['KCFINDER']['admin_news'] = true;
- ?>
- <input type="hidden" name="News[editors]" value="<?=$news->editors?>">
- <input type="hidden" name="News[uid]" value="<?=$news->uid?>">
- <div class="row"><div class="col">
- <div class="row justify-content-between">
- <div class="input-group mb-3 col-4">
- <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="<?=date("d-m-Y H:i", strtotime( $news->dt_pub ) )?>" name="News[dt_pub]">
- </div>
- <?
- if( $news->dt_cr ){
- ?>
- <div class="col-auto mr-md-auto">
- <small class="badge badge-secondary">Создан: <i class="far fa-clock"></i> <?=date("d-m-Y H:i", strtotime( $news->dt_cr ) )?></small> <small class="badge badge-secondary">Обновлён: <i class="far fa-clock"></i> <?=date("d-m-Y H:i", strtotime( $news->dt_upd ) )?></small>
- </div>
- <?
- }
- ?>
- <div class="col-4">
- <?/*
- 0 => 'НОВОСТЬ',
- 1 => 'ВОПРОС ДНЯ',
- 2 => 'СТАТЬЯ',
- 3 => 'ИНТЕРВЬЮ',
- 4 => 'ССЫЛКА',
- 5 => 'ПОДКАСТ',
- 6 => 'ЛОНГРИД',
- 7 => 'ВИДЕО',
- */?>
- <select class="form-control" name="News[type]">
- <option value="0" <?=($news->type == 0)?'selected':''?>>НОВОСТЬ</option>
- <option value="5" <?=($news->type == 5)?'selected':''?>>Подкаст</option>
- <option value="7" <?=($news->type == 7)?'selected':''?>>Видео</option>
- <option value="6" <?=($news->type == 6)?'selected':''?>>Лонгрид</option>
- <option value="2" <?=($news->type == 2)?'selected':''?>>Разворот</option>
- <option value="4" <?=($news->type == 4)?'selected':''?>>Ссылка</option>
- <option value="8" <?=($news->type == 8)?'selected':''?>>Проект из Tilda</option>
- </select>
- </div>
- </div>
- <?
- /*
- echo $form->field($news, 'title')->textInput([
- 'maxlength' => true,
- 'class' => 'form-control js-word-count-input',
- 'placeholder' => 'Заголовок новости'
- ])->label('Заголовок');
- _errors:yii\base\Model:private
- print_a($model->errors);
- */
- ?>
- <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" maxlength="<?=$tcount?>" id="news-title" class="form-control js-word-count-input col-sm-10 ml-2" name="News[title]" placeholder="Заголовок новости" aria-required="true" value='<?=str_replace("'", ''', $news->title)?>'>
- <span class="input-group-append">
- <span type="button" class="btn btn-outline-primary btn-block btn-sm aiget" style="width: fit-content;" id="aititle" data-pb="aiprogress0" data-preprompt="Подскажи привлекательный заголовок для статьи" title="Сгенерировать нейросетью, время гениратции примерно <?=round($AI_time_mid)?>сек."><i class="fa fa-robot"></i> Гена</span>
- </span>
- <div class="help-block px-lg-2"><div class="news__input-word-count"><span class="badge badge-info" id="title_count"></span></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 class="help-block">
- </div>
- </div>
- <div class="progress progress-sm active mt-1 mr-2 hidden">
- <div class="progress-bar bg-success progress-bar-striped" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%" id="aiprogress0"><span class="sr-only">40</span></div>
- </div>
- </div>
- <div class="collapse show" id="collapseSEOTitle">
- <div class="card card-body py-1">
- <span class="input-group-append">
- <input type="text" name="News[meta_title]" maxlength="<?=$tcount+50?>" value="<?=htmlentities($news->meta_title)?>" placeholder="SEO Title" class="form-control js-word-count-input col-sm-10 ml-1 py-0">
- <span type="button" class="btn btn-outline-primary btn-block btn-sm aiget" style="width: fit-content;" id="aistitle" data-pb="saiprogressx" data-preprompt="Подскажи SEO заголовок для статьи" title="Сгенерировать нейросетью, время гениратции примерно <?=round($AI_time_mid)?>сек."><i class="fa fa-robot"></i> Гена</span>
- </span>
- <div class="help-block">Поле для альтернативного SEO Title заголовка, если не заполнять совпадёт с основным заголовком</div>
- <div class="progress progress-sm active hidden" id="saiprogress">
- <div class="progress-bar bg-success progress-bar-striped" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%" id="saiprogressx"><span class="sr-only">40</span></div>
- </div>
- </div>
- </div>
- <div class="form-group field-news-lid required">
- <label class="control-label" for="news-lid">Новость кратко</label> <span class="badge badge-info" id="lid_count"></span>
- <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>
- <span type="button" class="btn btn-outline-primary btn-block btn-sm aiget" style="width: fit-content;" id="ailid" data-pb="saiprogressx1" data-max_tokens="1000" data-preprompt="Напиши очень коротко discription для статьи менбше 200 символов несколько вариантов" title="Сгенерировать нейросетью, время гениратции примерно <?=round($AI_time_mid)?>сек."><i class="fa fa-robot"></i> Гена</span>
- <div class="progress progress-sm active hidden" id="saiprogress">
- <div class="progress-bar bg-success progress-bar-striped" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%" id="saiprogressx1"><span class="sr-only">40</span></div>
- </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 class="help-block"></div>
- </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 class="help-block"></div>
- </div>
- </div>
- <div class="form-group">
- <div class="card-primary" id="galleriesContainer" style="border: 1px solid gray;">
- <div class="card-header">
- <h3 class="card-title">Галлереи</h3>
- </div>
- <div class="card-body">
- <?php if($news->isNewRecord):?>
- Чтобы добавить галлерею сохраните набросок новости
- <?php else:?>
- <div class="galleries-list">
- <?php foreach ($news->galleries as $gallery){ echo $this->render('@manager/views/news/form/galleryItem',["model"=>$gallery]);} ?>
- </div>
- <div class="form-group">
- <button type="button" class="btn btn-success" data-toggle="modal" data-target="#addGalleryModal"><i class="fas fa-plus"></i> Добавить галлерею</button>
- </div>
- <?php endif;?>
- </div>
- </div>
- </div>
- <div class="form-group field-js_news_content required">
- <label class="control-label" for="js_news_content">Контент <span type="button" class="btn btn-outline-primary btn-block btn-sm aiget ml-4" style="width: fit-content;float: right;" id="acont" data-pb="aiprogressb" data-preprompt="Улучши статью, добавь факты, мнения экспертов, цитаты и источники, написать литературным языком" title="Сгенерировать нейросетью, время гениратции примерно <?=round($AI_time_mid)?>сек."><i class="fa fa-robot"></i> Гена</span></label>
- <div class="progress progress-sm active hidden">
- <div class="progress-bar bg-success progress-bar-striped" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%" id="aiprogressb"><span class="sr-only">40</span></div>
- </div>
- <textarea id="js_news_content" class="form-control" name="News[text]" rows="12" aria-required="true"><?=htmlentities($news->text)?></textarea>
- </div>
- <blockquote class="quote-info mt-0">
- <h5 id="tip">Новость подготовили</h5>
- <p><?=str_replace(',', ', ', $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 value="0" disabled selected hidden>Выберете основного автора</option>
- <?
- foreach( $authors as $item ){
- ?>
- <option value="<?=$item->id?>" <?=($item->id == $author->id)?'selected':''?>><?=$item->name?></option>
- <?
- }
- ?>
- </select>
- <label class="input-group-append btn btn-primary" title="показывать автора" for="news-author">
- <input type="checkbox" autocomplete="off" name="News[show_author]"<?=($news->show_author == 'Y')?' checked':''?> value="Y"><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="News[verifed]" class="custom-control-input"<?=($news->verifed == 'Y')?' checked':''?> value="Y">
- <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="News[noindex]" class="custom-control-input"<?=($news->noindex == 'Y')?' checked':''?> value="Y">
- <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="News[fdzen]" class="custom-control-input"<?=($news->fdzen == 'Y')?' checked':''?> value="Y">
- <label class="custom-control-label" for="customRadioInline4"><i class="fas fa-yin-yang"></i>Не отдавать в <strong class="text-indigo">DZEN</strong> <span class="text-danger">новости</span></label>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" id="customRadioInline4m" name="News[fmail]" class="custom-control-input"<?=($news->fmail == 'Y')?' checked':''?> value="Y">
- <label class="custom-control-label" for="customRadioInline4m"><i class="fas fa-yin-yang"></i>В <strong class="text-indigo">DZEN</strong> <span class="text-danger">канал</span> как черновик</label>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" id="customRadioInline3" name="News[comments]" class="custom-control-input"<?=($news->comments == 'N')?' checked':''?> value="N">
- <label class="custom-control-label" for="customRadioInline3"><i class="fas fa-comment-slash"></i>Без коментариев</label>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" id="nofirst" name="News[nofirst]" class="custom-control-input"<?=($nofirst)?' checked':''?> value="Y">
- <label class="custom-control-label" for="nofirst"><svg xmlns="http://www.w3.org/2000/svg" width="14px" height="14px" viewBox="0 0 512 512"><path d="M245.8 220.9c-14.5-17.6-21.8-39.2-21.8-60.8C224 80 320 0 416 0c53 0 96 43 96 96c0 96-80 192-160.2 192c-21.6 0-43.2-7.3-60.8-21.8L54.6 502.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L245.8 220.9z"/></svg>Спрятать на главной</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="News[photo]" id="fcont1" class="custom-control-input"<?=($news->photo == 'Y')?' checked':''?> value="Y">
- <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="News[video]" id="fcont2" class="custom-control-input"<?=($news->video == 'Y')?' checked':''?> value="Y">
- <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="News[audio]" id="fcont3" class="custom-control-input"<?=($news->audio == 'Y')?' checked':''?> value="Y">
- <label class="custom-control-label" for="fcont3"><i class="fa fa-headphones"></i> C аудио материалом</label>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" id="photoamic" name="News[photoamic]" class="custom-control-input"<?=($photoamic)?' checked':''?> value="Y">
- <label class="custom-control-label" for="photoamic"><i class="fa fa-hand-peace"></i> Проверенные фото</label>
- </div>
- </div>
- </div>
- <div class="card card-outline card-olive">
- <div class="card-body">
- <div class="custom-control custom-radio custom-control-inline">
- <input type="radio" name="News[commerc]" id="fcont44" class="custom-control-input"<?=($news->commerc == 'N' && $news->mcommerc == 'N')?' checked':''?> value="0">
- <label class="custom-control-label" for="fcont44"><i class="fas fa-comment-dollar"></i> Не коммерческая</label>
- </div>
- <div class="custom-control custom-radio custom-control-inline">
- <input type="radio" name="News[commerc]" id="fcont4" class="custom-control-input"<?=($news->commerc == 'Y')?' checked':''?> value="2">
- <label class="custom-control-label" for="fcont4"><i class="fas fa-comment-dollar"></i> Простая коммерческая</label>
- </div>
- <div class="custom-control custom-radio custom-control-inline">
- <input type="radio" name="News[commerc]" id="fcont5" class="custom-control-input"<?=($news->mcommerc == 'Y')?' checked':''?> value="1">
- <label class="custom-control-label" for="fcont5"><i class="fas fa-comment-dollar"></i> Медицинская коммерческая</label>
- </div>
- <div class="custom-control custom-radio custom-control-inline">
- <input type="radio" name="News[commerc]" id="fcont15" class="custom-control-input"<?=($news->pcommerc == 'Y')?' checked':''?> value="3">
- <label class="custom-control-label" for="fcont15"><i class="fas fa-comment-dollar"></i> Партнёр</label>
- </div>
- <div class="custom-control custom-control-inline p-0">
- <button type="button" class="btn btn-secondary btn-sm" onClick="javascript:$('#modalcsl').modal('show');" title="rocket boost"><i class="fas fa-space-shuttle"></i></button>
- </div>
- <div class="custom-control custom-control-inline pl-1">
- <label class="control-label my-0 mr-2" for="news-mark">Метка <small class="form-text text-muted my-0">(токен)</small></label>
- <input type="text" class="form-control" name="News[mark]" id="news-mark" value="<?=$news->mark?>">
- </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="News[top]" id="fcont6" class="custom-control-input"<?=($news->top == 'Y')?' checked':''?> value="Y">
- <label class="custom-control-label" for="fcont6"><i class="fas fa-bomb"></i> В КД</label>
- </div>
- <div id="grpnh" class="custom-control-inline">
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" name="News[NH]" id="fcont7" class="custom-control-input"<?=($news->NH == 'Y')?' checked':''?> value="Y">
- <label class="custom-control-label" for="fcont7"><i class="fas fa-rocket"></i> В НЧ</label>
- </div>
- <div class="custom-control custom-checkbox custom-control-inline">
- <input type="checkbox" name="News[NH]" id="fcont77" class="custom-control-input"<?=($news->NH == 'F')?' checked':''?> value="F">
- <label class="custom-control-label" for="fcont77"><i class="fas fa-thumbtack"></i> В НЧ (закрепить)</label>
- </div>
- </div>
- </div>
- </div>
- <?
- if(!$news->isNewRecord)
- {
- $Tagitems = $tmodel->getForNews($news->id);
- }else{
- $Tagitems = [];
- }
- ?>
- <div class="card card-outline card-warning">
- <div class="card-body">
- <label for="tags"><i class="fas fa-tags"></i>Тэги </label>
- <div class="tags-input" id="myTags">
- <span class="data">
- <?
- foreach($Tagitems as $item){
- ?>
- <span class="btn btn-sm btn-primary tag"><span class="text" _value="<?=$item->id?>"><?=$item->title?></span><span class="close">×</span></span>
- <?
- }
- ?>
- </span>
- <span class="autocomplete">
- <input type="text">
- <div class="autocomplete-items">
- </div>
- </span>
- </div>
- </div>
- </div>
- <div class="btn-group">
- <label class="btn btn-primary active">
- <input type="checkbox" name="News[active]" id="active" style="width:3vw;height:3vh;top: 3px;position: relative;" class="active"<?=($news->active == 'Y')?' checked':''?> value="Y"><i class="far fa-play-circle"></i> Опубликовать</label>
- </label>
- </div>
- <div class="custom-control"><br>
- <button type="submit" class="btn btn-success mx-1" name="send" onClick="window.onbeforeunload = null;">Сохранить и выйти</button>
- <button type="submit" class="btn btn-success mx-1" name="save" onClick="window.onbeforeunload = null;">Сохранить</button>
- <?
- if(!$news->isNewRecord){
- ?>
- <a href="/news/preview/<?=$uuid?>" class="btn btn-info" target="_blank"><i class="fas fa-cat"></i> Предпросмотр</a>
- <?
- }
- ?>
- <div class="card card-info my-3">
- <div class="card-header">
- <h3 class="card-title">Локальные копии автосохранение</h3>
- </div>
- <div class="card-body text-right">
- <button class="btn btn-primary" type="button" onClick="SaveLocal()">Сохранить</button>
- <button class="btn btn-primary" type="button" onClick="LoadLocal()">Востановить</button>
- </div>
- <div class="card-footer">
- Копии сохраняются каждые 60сек. Для лучшего эффекта заполните заголовок
- </div>
- </div>
- <?
- if($news->isNewRecord){
- ?>
- <div class="alert alert-success m-4 bg-olive" role="alert">
- <h4 class="alert-heading">Для не сохранённых статей!</h4>
- <p>Вы ещё ни разу не сохранили документ, по этому нет возможности сделать его предпросмотр.</p>
- <hr>
- <p class="mb-0">Когда вы сохраните документ, станут доступны дополнительные функсии, в том числе авто сохранение локальной копии.</p>
- </div>
- <?
- }
- ?>
- </div>
- </div>
- <!-- правая колонка --->
- <div class="col-3">
- <div class="card card-primary">
- <div class="card-header">
- <h3 class="card-title">Фото</h3>
- </div>
- <div class="card-body">
- <style>
- #image {
- width: 100%;
- height: 56%;
- background: URL(/img/image.svg) no-repeat 50% 50%;
- background-size: contain;
- background-color: #fff;
- cursor: pointer;
- padding: 0px 0px 8px 0px;
- }
- #myTags {
- box-shadow: 0 0 5px rgba(81, 203, 238, 1);
- padding: 3px 0px 3px 3px;
- margin: 5px 1px 3px 0px;
- border: 1px solid rgba(81, 203, 238, 1);
- }
- </style>
- <?
- if($news->id){
- $imageSrc = $news->getImage()->geturl(Image::SIZE_1040x586);
- /*
- $imageSrc = "/images/news/news/".$news->id."_sizehd.jpg";
- if( file_exists( \Yii::getAlias('@webroot').$imageSrc ) === false ){
- if( $news->photo_name != '' ){
- $imageSrc = $news->photo_name;
- }else{
- $imageSrc = '/img/e.gif';
- }
- }
- */
- $imageSrc .= "?r=".rand();
- }else{
- $imageSrc = '/img/e.gif';
- }
- ?>
- <img id="image" src="<?=$imageSrc?>" onClick="$('#modal').modal('show');document.getElementById('inputImage').click();" >
- <?
- echo CropperjsWidget::widget(['image' => 'image', 'file' => 'News[photo]', 'post' => 'cropping', 'aspectRatio' => '16/9']);
- ?><script>
- $('#container_image').attr('src', '<?=$imageSrc?>');
- </script>
- <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]"<?=($news->photo_include == 'Y')?' checked':''?> value="Y"><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]"<?=($news->photo_rcol == 'Y')?' checked':''?> value="Y"><i class="fa fa-list-alt ml-2"></i>
- </label>
- <label class="btn btn-info active btn-sm px-3" title="фото фильтр" onClick="javascript:$('#fphoto').modal('show');">
- <i class="fa fa-adjust"></i>
- </label>
- <label class="btn btn-dark active btn-sm px-3" title="удалить фото">
- <input type="checkbox" autocomplete="off" name="News[del_photo]" value="Y"><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">Подпись фото (автор и описание) от 33 знаков</label>
- <div class="help-block px-lg-2 d-inline"><span class="badge badge-info" id="phototitle_count"></span></div>
- <textarea id="title-photo" class="form-control" name="News[photo_title]" rows="2" aria-required="true" <?=($imageSrc == '/img/e.gif')?'':'minlength="33"'?>><?=$news->photo_title?></textarea>
- </div>
- <button type="button" class="btn btn-primary btn-block" onClick="javascript:$('#sphoto').modal('show');">Поискать</button>
- </div>
- </div>
- <!-- test -->
- <div class="card card-primary">
- <div class="ribbon-wrapper">
- <div class="ribbon bg-lightblue">
- SuperTag
- </div>
- </div>
- <div class="card-body bg-gradient-olive">
- <?
- $tagscheck = [];
- foreach( $Tagitems as $setmenuitem ){
- $tagscheck[$setmenuitem->id] = true;
- }
- foreach( $tagsmenu as $menuitem ){
- ?>
- <div class="custom-control custom-switch">
- <input class="custom-control-input" type="checkbox" value="<?=$menuitem->id?>" id="tflexCheck<?=$menuitem->id?>" name="ExtTag[<?=$menuitem->id?>]"<?=isset($tagscheck[$menuitem->id])?' checked':''?>>
- <label class="custom-control-label" for="tflexCheck<?=$menuitem->id?>"><?=$menuitem->title?></label>
- </div>
- <?
- }
- ?>
- </div>
- </div>
- <!-- /test -->
- <div class="card card-primary">
- <div class="ribbon-wrapper">
- <div class="ribbon bg-primary">
- Рубрики
- </div>
- </div>
- <div class="card-body">
- <?
- $atopic = array();
- if(!$news->isNewRecord)
- {
- $model = new NewsTopic();
- $Titems = $model->getForNews($news->id);
- foreach( $Titems as $item ){
- $atopic[$item->id] = $item->id;
- }
- }
- ?>
- <div class="accordion" id="TopicsSel">
- <div class="card">
- <div class="card-header" id="headingOne">
- <h2 class="mb-0">
- <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapse1" aria-expanded="true" aria-controls="collapse1">
- Общий рубрикатор
- </button>
- </h2>
- </div>
- <div id="collapse1" class="collapse show" aria-labelledby="heading1" data-parent="#TopicsSel">
- <div class="card-body">
- <?
- foreach( NewsTopic::findActive()->getModels() as $item ){
- if( in_array( $item->id, [127,128]) ) continue; // пропустить разделы видео/подкасты
- if( $item->url == '----' ){
- ?>
- <div class="checkbox_title_hr">
- <span><?=$item->title?></span>
- </div>
- <?
- }else{
- ?>
- <div class="custom-control <?=($item->show == 'Y')?'custom-checkbox':'custom-switch bg-purple'?>">
- <input class="custom-control-input" type="checkbox" value="<?=$item->id?>" 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>
- <div class="card">
- <div class="card-header" id="heading2">
- <h2 class="mb-0">
- <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapse2" aria-expanded="true" aria-controls="collapse2">
- Слушать
- </button>
- </h2>
- </div>
- <div id="collapse2" class="collapse" aria-labelledby="heading2" data-parent="#TopicsSel">
- <div class="card-body">
- <?
- foreach( NewsTopic::findActive(127)->getModels() as $item ){
- ?>
- <div class="custom-control <?=($item->show == 'Y')?'custom-checkbox':'custom-switch bg-purple'?>">
- <input class="custom-control-input" type="checkbox" value="<?=$item->id?>" 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>
- <div class="card">
- <div class="card-header" id="heading3">
- <h2 class="mb-0">
- <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapse3" aria-expanded="true" aria-controls="collapse3">
- Смотреть
- </button>
- </h2>
- </div>
- <div id="collapse3" class="collapse" aria-labelledby="heading3" data-parent="#TopicsSel">
- <div class="card-body">
- <?
- foreach( NewsTopic::findActive(128)->getModels() as $item ){
- ?>
- <div class="custom-control <?=($item->show == 'Y')?'custom-checkbox':'custom-switch bg-purple'?>">
- <input class="custom-control-input" type="checkbox" value="<?=$item->id?>" 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>
- </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();
- if(!$news->isNewRecord)
- {
- $Sitems = $model->getForNews($news->id);
- }else{
- $Sitems = [];
- }
- ?>
- <div class="custom-control custom-checkbox">
- <?
- foreach($Sitems as $item){
- ?>
- <div class="custom-control custom-checkbox">
- <input class="custom-control-input" type="checkbox" value="<?=$item->id?>" 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>
- <?
- echo $this->render('modalPhotoFilter', ['imageSrc'=>$imageSrc, 'news'=>$news]);
- ActiveForm::end();
- if(!$news->isNewRecord){
- ?>
- <!-- Modal -->
- <div class="modal fade" id="addGalleryModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <form action="" class="gallery-form" id="galleryForm">
- <div class="modal-header">
- <h5 class="modal-title" id="exampleModalLabel">Добавление галлереи</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body">
- <input type="hidden" value="<?=$news->id?>" name="post_id">
- <div class="form-group">
- <label for="name">Название</label>
- <input type="text" class="form-control" name="name">
- </div>
- <div class="form-group">
- <label for="description">Описание</label>
- <input type="text" class="form-control" name="description">
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Отмена</button>
- <button type="submit" class="btn btn-primary save">Сохранить</button>
- </div>
- </form>
- </div>
- </div>
- </div>
- <script>
- $(document).ready(function () {
- $("#galleryForm").submit(function (e) {
- e.preventDefault()
- $.get(
- '<?=\yii\helpers\Url::to(["/manager/news/add-gallery"])?>',
- $(this).serialize(),
- function (data){
- $("#addGalleryModal").modal('hide')
- $("#galleryForm")[0].reset()
- $("#galleriesContainer .card-body .galleries-list").append(data)
- }
- )
- })
- })
- let galleryRemove = function (id)
- {
- $.get(
- '<?=\yii\helpers\Url::to(["/manager/news/remove-gallery"])?>',
- {id:id},
- function (data){
- $("#gallery-" + id).remove();
- }
- )
- }
- </script>
- <?
- }
- ?>
- <script src="/components/admin/js/ls.js"></script>
- <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 id="storyi'+ui.item.id+'"><label class="custom-control-label" for="storyi'+ui.item.id+'">'+ 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" );
- }*/
- });
- });
- 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-2000 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);
- });
- $(function() {
- window.varsubmit = false;
- window.robotr = false;
- AItime=<?=$AI_time_mid?>;
- $("input[id='news-title']").keyup(function count(){
- number = $("input[id='news-title']").val().length;
- $("#title_count").html(number);
- });
- //phototitle_count
- $("textarea[id='title-photo']").keyup(function count(){
- number = $("textarea[id='title-photo']").val().length;
- $("#phototitle_count").html(number);
- });
- number = $("textarea[id='title-photo']").val().length;
- $("#phototitle_count").html(number);
- $("input[name='News[photo]']").on('change', function() {
- $("textarea[id='title-photo']").attr( "minlength", 33 );
- });
- $('#news-lid').keyup(function(){
- number = $(this).val().length;
- $("#lid_count").html(number);
- });
- $('#grpnh input:checkbox').click(function(){
- if ($(this).is(':checked')) {
- $('#grpnh input:checkbox').not(this).prop('checked', false);
- }
- });
- setInterval( function (){ sendping( '<?=$news->id?>' ) }, 10000 );
- function sendping( newsid ){
- $.get( "newsping", { id: newsid }, function(data){
- data = JSON.parse(data);
- if( data.status == 'warn' ) alert( 'В новости появился '+data['author'] );
- } );
- }
- $('#news-form').submit(function( event ) {
- console.log(window.varsubmit);
- val = $(document.activeElement).attr('name')
- if( (val == 'save' || val == 'send') && $('#news-lid').val().length < 1 ){
- if( !window.varsubmit ){
- alert("Не заполнен lid");
- window.varsubmit = true;
- }else{
- window.varsubmit = false;
- }
- return false;
- }
- if( (val == 'save' || val == 'send') && !window.varsubmit ){
- window.varsubmit = true; //запрет повторного вызова
- // отправка тэгов
- tags = $('#myTags').tagsValues();
- nform = $('#news-form');
- $.each(tags,function (key,value) {
- tpl = $('<input type="hidden" value="'+value+'" name="Tags[]">');
- nform.append(tpl);
- });
- }
- if( (val == 'save' || val == 'send') ) return true;
- });
- $("input[type=text]").keydown(function(event){
- if(event.keyCode == 13){
- event.preventDefault();
- return false;
- }
- });
- $(".aiget").click(function(){
- if( window.robotr ){
- alert('Может быть только один запрос к роботу, подождите окончания предыдущего запроса.');
- return;
- }
- window.robotr = true;
- let text = CKEDITOR.instances.js_news_content.getData();
- let preprompt = $(this).data('preprompt');
- let max_tokens = $(this).data('max_tokens');
- if( !max_tokens ) max_tokens = 0;
- text = preprompt+': '+text;
- let pbar = '#'+$(this).data('pb');
- $(pbar).parent().removeClass('hidden');
- $(pbar).attr('aria-valuenow', 100);
- $(pbar).css('width','100%');
- let data = { timer : null };
- $.post("/manager/ai/ajax-time", {AI:'nv', progress: pbar}, function( data ) {
- if( data.status == 'ok' ){
- AItime = data.time;
- if( !AItime ) AItime = <?=$AI_time_mid?>;
- console.log(AItime);
- }
- }, "json");
- data.timer = setInterval(countprogress, 1000, pbar, data);
- $.post("/manager/ai/ajax-get-title", {AI:'nv',text:text, progress: pbar, tokens: max_tokens}, function( data ) {
- if( data.status == 'ok' ){
- var data_all = data.data;
- $("#AItext").html(data_all);
- $('#AI').modal('show');
- $(data.progress).css('width','0%');
- $(data.progress).attr('aria-valuenow', 0);
- }else{
- console.log(data.msg);
- $("#AItext").html(data.msg);
- $('#AI').modal('show');
- }
- window.robotr = false;
- }, "json");
- });
- });
- function countprogress(pbar, data){
- val = $(pbar).attr('aria-valuenow');
- d = 100/(AItime);
- console.log(d);
- val = val - d;
- if( val <=0 ) clearTimeout(data.timer);
- $(pbar).attr('aria-valuenow', val);
- $(pbar).css('width',val+'%');
- }
- function runSuggestions(element,query) {
- let sug_area=$(element).parents().eq(2).find('.autocomplete .autocomplete-items');
- if( query.length > 1 ){
- $.getJSON("/manager/tags/search", {'q':query}, function( data ) {
- _tag_input_suggestions_data = data;
- $.each(data,function (key,value) {
- let template = $("<div>"+value.name+"</div>").hide()
- sug_area.append(template)
- template.show()
- })
- });
- }
- }
- // CKEditor
- $(function () {
- if($('#js_news_content').length != 0){
- CKEDITOR.replace('js_news_content', {
- 'filebrowserBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=files&uid=<?=$uuid?>',
- 'filebrowserImageBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=images&uid=<?=$uuid?>',
- 'filebrowserFlashBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=flash&uid=<?=$uuid?>',
- 'filebrowserUploadUrl': '/components/admin/ckeditor/kcfinder/upload.php?type=files&uid=<?=$uuid?>',
- 'filebrowserImageUploadUrl': '/components/admin/ckeditor/kcfinder/upload.php?type=images&uid=<?=$uuid?>',
- 'filebrowserFlashUploadUrl': '/components/admin/ckeditor/kcfinder/upload.php?type=flash&uid=<?=$uuid?>',
- 'filebrowserAudioBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=files&uid=<?=$uuid?>',
- 'filebrowserlightboxUploadUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=files&uid=<?=$uuid?>',
- 'height': 400
- });
- CKEDITOR.on('instanceReady', function(ev) {
- ev.editor.on('paste', function(evt) {
- evt.data.dataValue = evt.data.dataValue.replace(/[«»]/g,'"');
- console.log(evt.data.dataValue);
- }, null, null, 9);
- });
- }
- });
- window.onbeforeunload = function(e) {
- return "Вы уверены, что покидаете страницу?";
- };
- </script>
- <?
- // редактор end
- ?>
- </div>
- <div class="tab-pane fade" id="comments">
- <?
- // коменты
- echo $this->render('../comments/newsindex', [
- 'model' => $news,
- ]);
- ?>
- </div>
- </div>
- <?
- echo $this->render('formSP', [
- 'model' => $news,
- ]);
- echo $this->render('../top-slider/modalform', ['news'=>$news]);
- ?>
- <div class="modal" tabindex="-1" data-show="true" id="AI">
- <div class="modal-dialog modal-dialog-scrollable modal-lg">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">Генератор текстов от Гены</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body">
- <p id="AItext"></p>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-primary" data-dismiss="modal">Закрыть</button>
- </div>
- </div>
- </div>
- </div>
|