123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981 |
- <?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();
- });
- //echo $news->text;
- ?>
- <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 = 85;
- if( mb_strlen( $news->title ) > 85 ){
- $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);
- 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>
- <?
- }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)?>'>
- <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>
- <div class="collapse show" id="collapseSEOTitle">
- <div class="card card-body py-1">
- <input type="text" name="News[meta_title]" maxlength="<?=$tcount?>" value="<?=htmlentities($news->meta_title)?>" placeholder="SEO Title" class="form-control js-word-count-input col-sm-10 ml-1 py-0">
- <div class="help-block">Поле для альтернативного SEO Title заголовка, если не заполнять совпадёт с основным заголовком</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>
- </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">Контент</label>
- <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>
- </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="1" 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;
- $("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;
- }
- });
- });
- 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]);
- ?>
|