formNews.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  1. <?php
  2. use app\assets\GalleryManagerAsset;
  3. use manager\models\News;
  4. use yii\helpers\Html;
  5. use yii\helpers\ArrayHelper;
  6. use yii\widgets\ActiveForm;
  7. use kartik\datetime\DateTimePicker;
  8. use \app\models\base\Tags;
  9. use \app\models\base\Story;
  10. use \app\models\base\Image;
  11. use \app\models\base\NewsTopic;
  12. use app\models\Authors;
  13. use app\widgets\CropperjsWidget;
  14. use zxbodya\yii2\galleryManager\GalleryManager;
  15. use \app\models\Tagsfilter;
  16. /**
  17. * @var $news News
  18. */
  19. GalleryManagerAsset::register($this);
  20. $cache = Yii::$app->cache;
  21. $tmodel = new Tags();
  22. $session = Yii::$app->session;
  23. $session->open();
  24. $tagsmenu = Yii::$app->cache->getOrSet("tagsmenu",function () use($tmodel){
  25. return $tmodel->find()->rightJoin(['m'=>Tagsfilter::find()], 'm.id = tags.id')->orderBy('sort')->All();
  26. });
  27. //echo $news->text;
  28. ?>
  29. <ul class="nav nav-tabs">
  30. <li class="nav-item">
  31. <a class="nav-link active" data-toggle="tab" href="#edit">Статья</a>
  32. </li>
  33. <li class="nav-item">
  34. <a class="nav-link" data-toggle="tab" href="#comments">Комментарии</a>
  35. </li>
  36. </ul>
  37. <div class="tab-content">
  38. <div class="tab-pane fade show active" id="edit">
  39. <?
  40. // редактор
  41. $form = ActiveForm::begin([
  42. 'id' => 'news-form',
  43. 'options' => ['class' => 'form-horizontal','enctype' => 'multipart/form-data'],]);
  44. //иничиализация
  45. DateTimePicker::widget([
  46. 'name' => 'dt_pub',
  47. 'options' => [],
  48. 'convertFormat' => true,
  49. 'pluginOptions' => [
  50. 'format' => 'd-M-Y H:i ',
  51. 'startDate' => '01-Mar-2000 12:00',
  52. 'todayHighlight' => true
  53. ]
  54. ]);
  55. $tcount = 85;
  56. if( mb_strlen( $news->title ) > 85 ){
  57. $tcount = mb_strlen( $news->title );
  58. }
  59. $model = new Authors();
  60. $authors = $model->findAll(['active' => 'Y']);
  61. //$author = $model->findOne(['id' => $news->author]);
  62. $author = $model->getAuthor($news->author);
  63. $ids = ArrayHelper::getColumn($authors, 'id');
  64. if( !in_array($author->id, $ids) ){
  65. $authors = array_merge($authors, [$author]);
  66. };
  67. $news->commerc = ($news->inscription == 2)?'Y':'N';
  68. $news->mcommerc = ($news->inscription == 1)?'Y':'N';
  69. $news->pcommerc = ($news->inscription == 3)?'Y':'N';
  70. $news->fdzen = ($news['export_rss'] & 1)?'Y':'N';
  71. $news->fmail = ($news['export_rss'] & 2)?'Y':'N';
  72. $nofirst = ($news->flags & 1);
  73. if( isset($uuid) )
  74. {
  75. $news->uid = $uuid;
  76. }else{
  77. $uuid = $news->uid;
  78. }
  79. if($news->isNewRecord)
  80. {
  81. ?>
  82. <div class="info-box">
  83. <span class="info-box-icon bg-info"><i class="far fa-bookmark"></i></span>
  84. <div class="info-box-content">
  85. <span class="info-box-text">Сгенерировал. UUID</span>
  86. <span class="info-box-number"><?=$uuid?></span>
  87. <div class="progress">
  88. <div class="progress-bar bg-info" style="width: 70%"></div>
  89. </div>
  90. <span class="progress-description">
  91. Информация для отладки
  92. </span>
  93. </div>
  94. </div>
  95. <?
  96. }else{
  97. ?>
  98. <div class="info-box">
  99. <span class="info-box-icon bg-info"><i class="far fa-bookmark"></i></span>
  100. <div class="info-box-content">
  101. <span class="info-box-text">ID Новости</span>
  102. <span class="info-box-number"><?=$news->id?></span>
  103. <span class="info-box-text">uid Новости</span>
  104. <span class="info-box-number"><?=$uuid?></span>
  105. <div class="progress">
  106. <div class="progress-bar bg-info" style="width: 70%"></div>
  107. </div>
  108. <span class="progress-description">
  109. Информация для отладки
  110. </span>
  111. </div>
  112. </div>
  113. <input type="hidden" name="News[id]" value="<?=$news->id?>">
  114. <input type="hidden" name="News[alias]" value="<?=$news->alias?>">
  115. <input type="hidden" name="News[photo_name]" id="photo_name" value="<?=$news->photo_name?>">
  116. <?
  117. if( $res = $cache->get("editNews_".$news->id) ){
  118. if( isset( unserialize($res)['author'] ) && unserialize($res)['author'] != Yii::$app->user->identity->profile->name){
  119. //Yii::$app->user->identity->profile->name //self
  120. /*
  121. * Предупреждение о пути истинного
  122. */
  123. ?>
  124. <div class="modal" tabindex="-1" data-show="true" id="editing">
  125. <div class="modal-dialog">
  126. <div class="modal-content">
  127. <div class="modal-header">
  128. <h5 class="modal-title">Заблокированная новость</h5>
  129. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  130. <span aria-hidden="true">&times;</span>
  131. </button>
  132. </div>
  133. <div class="modal-body">
  134. <p>Новость уже открыта в другом окне автором: <?=unserialize($res)['author']?></p>
  135. </div>
  136. <div class="modal-footer">
  137. <a href="/manager/news/list"><button type="button" class="btn btn-secondary">Покинуть новость</button></a>
  138. <button type="button" class="btn btn-primary" data-dismiss="modal">Всё равно войти в новость</button>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. <script>$(function () {$('#editing').modal('show')});</script>
  144. <?
  145. }
  146. }else{
  147. ?>
  148. <script>
  149. $(function () {
  150. $.get( "newsping", { id: <?=$news->id?> }, function(data){} );
  151. });
  152. </script>
  153. <?
  154. }
  155. }
  156. if( $news->errors ){
  157. ?>
  158. <div class="card card-danger">
  159. <div class="card-header">
  160. <h3 class="card-title">Обнаружены ошибки</h3>
  161. <div class="card-tools">
  162. <span class="badge badge-dark">Error</span>
  163. </div>
  164. <!-- /.card-tools -->
  165. </div>
  166. <!-- /.card-header -->
  167. <div class="card-body">
  168. <?=$form->errorSummary($news)?>
  169. </div>
  170. <!-- /.card-body -->
  171. </div>
  172. <!-- /.card -->
  173. <?
  174. }
  175. $_SESSION['ckfinder_url'] = '/images/upload/'.(string)$news->uid;
  176. $_SESSION['KCFINDER']['admin_news'] = true;
  177. ?>
  178. <input type="hidden" name="News[editors]" value="<?=$news->editors?>">
  179. <input type="hidden" name="News[uid]" value="<?=$news->uid?>">
  180. <div class="row"><div class="col">
  181. <div class="row justify-content-between">
  182. <div class="input-group mb-3 col-4">
  183. <div class="input-group-prepend">
  184. <span class="input-group-text" id="basic-addon1" onclick="jQuery('#dt_pub').datetimepicker('show')"><i class="fa fa-calendar"></i></span>
  185. </div>
  186. <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]">
  187. </div>
  188. <div class="col-4">
  189. <?/*
  190. 0 => 'НОВОСТЬ',
  191. 1 => 'ВОПРОС ДНЯ',
  192. 2 => 'СТАТЬЯ',
  193. 3 => 'ИНТЕРВЬЮ',
  194. 4 => 'ССЫЛКА',
  195. 5 => 'ПОДКАСТ',
  196. 6 => 'ЛОНГРИД',
  197. 7 => 'ВИДЕО',
  198. */?>
  199. <select class="form-control" name="News[type]">
  200. <option value="0" <?=($news->type == 0)?'selected':''?>>НОВОСТЬ</option>
  201. <option value="5" <?=($news->type == 5)?'selected':''?>>Подкаст</option>
  202. <option value="7" <?=($news->type == 7)?'selected':''?>>Видео</option>
  203. <option value="6" <?=($news->type == 6)?'selected':''?>>Лонгрид</option>
  204. <option value="2" <?=($news->type == 2)?'selected':''?>>Разворот</option>
  205. <option value="4" <?=($news->type == 4)?'selected':''?>>Ссылка</option>
  206. </select>
  207. </div>
  208. </div>
  209. <?
  210. /*
  211. echo $form->field($news, 'title')->textInput([
  212. 'maxlength' => true,
  213. 'class' => 'form-control js-word-count-input',
  214. 'placeholder' => 'Заголовок новости'
  215. ])->label('Заголовок');
  216. _errors:yii\base\Model:private
  217. print_a($model->errors);
  218. */
  219. ?>
  220. <div class="form-group field-news-title required">
  221. <label class="control-label col-form-label" for="news-title">Заголовок</label>
  222. <div class="row">
  223. <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("'", '&apos;', $news->title)?>'>
  224. <div class="help-block px-lg-2"><div class="news__input-word-count"><span class="badge badge-info" id="title_count"></span></div></div>
  225. <a class="btn btn-primary px-lg-2" data-toggle="collapse" href="#collapseSEOTitle" role="button" aria-expanded="false" aria-controls="collapseSEOTitle">SEO title</a>
  226. <div class="help-block"></div>
  227. </div>
  228. </div>
  229. <div class="collapse show" id="collapseSEOTitle">
  230. <div class="card card-body py-1">
  231. <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">
  232. <div class="help-block">Поле для альтернативного SEO Title заголовка, если не заполнять совпадёт с основным заголовком</div>
  233. </div>
  234. </div>
  235. <div class="form-group field-news-lid required">
  236. <label class="control-label" for="news-lid">Новость кратко</label> <span class="badge badge-info" id="lid_count"></span>
  237. <textarea id="news-lid" class="form-control js-word-count-input" name="News[lid]" placeholder="Лид" aria-required="true"><?=$news->lid?></textarea>
  238. <div class="help-block">Краткое содержание статьи</div>
  239. </div>
  240. <div class="form-group">
  241. <label class="control-label" for="news-link">Прямой переход на URL</label>
  242. <div class="row">
  243. <input type="text" class="form-control" name="News[link]" id="news-link" value="<?=$news->link?>">
  244. <div class="help-block"></div>
  245. </div>
  246. </div>
  247. <div class="form-group">
  248. <label class="control-label" for="news-embed">вставка медиа URL</label>
  249. <div class="row">
  250. <input type="text" class="form-control" name="News[embed_url]" id="news-embed" value="<?=$news->embed_url?>">
  251. <div class="help-block"></div>
  252. </div>
  253. </div>
  254. <div class="form-group">
  255. <div class="card-primary" id="galleriesContainer" style="border: 1px solid gray;">
  256. <div class="card-header">
  257. <h3 class="card-title">Галлереи</h3>
  258. </div>
  259. <div class="card-body">
  260. <?php if($news->isNewRecord):?>
  261. Чтобы добавить галлерею сохраните набросок новости
  262. <?php else:?>
  263. <div class="galleries-list">
  264. <?php foreach ($news->galleries as $gallery){ echo $this->render('@manager/views/news/form/galleryItem',["model"=>$gallery]);} ?>
  265. </div>
  266. <div class="form-group">
  267. <button type="button" class="btn btn-success" data-toggle="modal" data-target="#addGalleryModal"><i class="fas fa-plus"></i> Добавить галлерею</button>
  268. </div>
  269. <?php endif;?>
  270. </div>
  271. </div>
  272. </div>
  273. <div class="form-group field-js_news_content required">
  274. <label class="control-label" for="js_news_content">Контент</label>
  275. <textarea id="js_news_content" class="form-control" name="News[text]" rows="12" aria-required="true"><?=htmlentities($news->text)?></textarea>
  276. </div>
  277. <blockquote class="quote-info mt-0">
  278. <h5 id="tip">Новость подготовили</h5>
  279. <p><?=str_replace(',', ', ', $news->editors)?></p>
  280. </blockquote>
  281. <div class="input-group">
  282. <label class="control-label col-form-label mr-3" >Автор</label>
  283. <select class="custom-select custom-select-sm" name="News[author]" id="news-author">
  284. <option value="0" disabled selected hidden>Выберете основного автора</option>
  285. <?
  286. foreach( $authors as $item ){
  287. ?>
  288. <option value="<?=$item->id?>" <?=($item->id == $author->id)?'selected':''?>><?=$item->name?></option>
  289. <?
  290. }
  291. ?>
  292. </select>
  293. <label class="input-group-append btn btn-primary" title="показывать автора" for="news-author">
  294. <input type="checkbox" autocomplete="off" name="News[show_author]"<?=($news->show_author == 'Y')?' checked':''?> value="Y"><i class="fa fa-eye ml-2"></i>
  295. </label>
  296. </div>
  297. <div class="card card-outline card-primary">
  298. <div class="card-body">
  299. <div class="custom-control custom-checkbox custom-control-inline">
  300. <input type="checkbox" id="customRadioInline1" name="News[verifed]" class="custom-control-input"<?=($news->verifed == 'Y')?' checked':''?> value="Y">
  301. <label class="custom-control-label" for="customRadioInline1"><i class="fas fa-spell-check"></i>Корректор</label>
  302. </div>
  303. <div class="custom-control custom-checkbox custom-control-inline">
  304. <input type="checkbox" id="customRadioInline2" name="News[noindex]" class="custom-control-input"<?=($news->noindex == 'Y')?' checked':''?> value="Y">
  305. <label class="custom-control-label" for="customRadioInline2"><s><i class="fas fa-search"></i></s>Не отдавать в поиск</label>
  306. </div>
  307. <div class="custom-control custom-checkbox custom-control-inline">
  308. <input type="checkbox" id="customRadioInline4" name="News[fdzen]" class="custom-control-input"<?=($news->fdzen == 'Y')?' checked':''?> value="Y">
  309. <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>
  310. </div>
  311. <div class="custom-control custom-checkbox custom-control-inline">
  312. <input type="checkbox" id="customRadioInline4m" name="News[fmail]" class="custom-control-input"<?=($news->fmail == 'Y')?' checked':''?> value="Y">
  313. <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>
  314. </div>
  315. <div class="custom-control custom-checkbox custom-control-inline">
  316. <input type="checkbox" id="customRadioInline3" name="News[comments]" class="custom-control-input"<?=($news->comments == 'N')?' checked':''?> value="N">
  317. <label class="custom-control-label" for="customRadioInline3"><i class="fas fa-comment-slash"></i>Без коментариев</label>
  318. </div>
  319. <div class="custom-control custom-checkbox custom-control-inline">
  320. <input type="checkbox" id="nofirst" name="News[nofirst]" class="custom-control-input"<?=($nofirst)?' checked':''?> value="Y">
  321. <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>
  322. </div>
  323. </div>
  324. </div>
  325. <div class="card card-outline card-teal">
  326. <div class="card-body">
  327. <div class="custom-control custom-checkbox custom-control-inline">
  328. <input type="checkbox" name="News[photo]" id="fcont1" class="custom-control-input"<?=($news->photo == 'Y')?' checked':''?> value="Y">
  329. <label class="custom-control-label" for="fcont1"><i class="fa fa-camera"></i> C фото материалом</label>
  330. </div>
  331. <div class="custom-control custom-checkbox custom-control-inline">
  332. <input type="checkbox" name="News[video]" id="fcont2" class="custom-control-input"<?=($news->video == 'Y')?' checked':''?> value="Y">
  333. <label class="custom-control-label" for="fcont2"><i class="fa fa-video"></i> C видео материалом</label>
  334. </div>
  335. <div class="custom-control custom-checkbox custom-control-inline">
  336. <input type="checkbox" name="News[audio]" id="fcont3" class="custom-control-input"<?=($news->audio == 'Y')?' checked':''?> value="Y">
  337. <label class="custom-control-label" for="fcont3"><i class="fa fa-headphones"></i> C аудио материалом</label>
  338. </div>
  339. </div>
  340. </div>
  341. <div class="card card-outline card-olive">
  342. <div class="card-body">
  343. <div class="custom-control custom-radio custom-control-inline">
  344. <input type="radio" name="News[commerc]" id="fcont44" class="custom-control-input"<?=($news->commerc == 'N' && $news->mcommerc == 'N')?' checked':''?> value="0">
  345. <label class="custom-control-label" for="fcont44"><i class="fas fa-comment-dollar"></i> Не коммерческая</label>
  346. </div>
  347. <div class="custom-control custom-radio custom-control-inline">
  348. <input type="radio" name="News[commerc]" id="fcont4" class="custom-control-input"<?=($news->commerc == 'Y')?' checked':''?> value="2">
  349. <label class="custom-control-label" for="fcont4"><i class="fas fa-comment-dollar"></i> Простая коммерческая</label>
  350. </div>
  351. <div class="custom-control custom-radio custom-control-inline">
  352. <input type="radio" name="News[commerc]" id="fcont5" class="custom-control-input"<?=($news->mcommerc == 'Y')?' checked':''?> value="1">
  353. <label class="custom-control-label" for="fcont5"><i class="fas fa-comment-dollar"></i> Медицинская коммерческая</label>
  354. </div>
  355. <div class="custom-control custom-radio custom-control-inline">
  356. <input type="radio" name="News[commerc]" id="fcont15" class="custom-control-input"<?=($news->pcommerc == 'Y')?' checked':''?> value="3">
  357. <label class="custom-control-label" for="fcont15"><i class="fas fa-comment-dollar"></i> Партнёр</label>
  358. </div>
  359. <div class="custom-control custom-control-inline p-0">
  360. <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>
  361. </div>
  362. <div class="custom-control custom-control-inline pl-1">
  363. <label class="control-label my-0 mr-2" for="news-mark">Метка <small class="form-text text-muted my-0">(токен)</small></label>
  364. <input type="text" class="form-control" name="News[mark]" id="news-mark" value="<?=$news->mark?>">
  365. </div>
  366. </div>
  367. </div>
  368. <div class="card card-outline card-maroon">
  369. <div class="card-body">
  370. <div class="custom-control custom-checkbox custom-control-inline">
  371. <input type="checkbox" name="News[top]" id="fcont6" class="custom-control-input"<?=($news->top == 'Y')?' checked':''?> value="Y">
  372. <label class="custom-control-label" for="fcont6"><i class="fas fa-bomb"></i> В КД</label>
  373. </div>
  374. <div id="grpnh" class="custom-control-inline">
  375. <div class="custom-control custom-checkbox custom-control-inline">
  376. <input type="checkbox" name="News[NH]" id="fcont7" class="custom-control-input"<?=($news->NH == 'Y')?' checked':''?> value="Y">
  377. <label class="custom-control-label" for="fcont7"><i class="fas fa-rocket"></i> В НЧ</label>
  378. </div>
  379. <div class="custom-control custom-checkbox custom-control-inline">
  380. <input type="checkbox" name="News[NH]" id="fcont77" class="custom-control-input"<?=($news->NH == 'F')?' checked':''?> value="F">
  381. <label class="custom-control-label" for="fcont77"><i class="fas fa-thumbtack"></i> В НЧ (закрепить)</label>
  382. </div>
  383. </div>
  384. </div>
  385. </div>
  386. <?
  387. if(!$news->isNewRecord)
  388. {
  389. $Tagitems = $tmodel->getForNews($news->id);
  390. }else{
  391. $Tagitems = [];
  392. }
  393. ?>
  394. <div class="card card-outline card-warning">
  395. <div class="card-body">
  396. <label for="tags"><i class="fas fa-tags"></i>Тэги </label>
  397. <div class="tags-input" id="myTags">
  398. <span class="data">
  399. <?
  400. foreach($Tagitems as $item){
  401. ?>
  402. <span class="btn btn-sm btn-primary tag"><span class="text" _value="<?=$item->id?>"><?=$item->title?></span><span class="close">&times;</span></span>
  403. <?
  404. }
  405. ?>
  406. </span>
  407. <span class="autocomplete">
  408. <input type="text">
  409. <div class="autocomplete-items">
  410. </div>
  411. </span>
  412. </div>
  413. </div>
  414. </div>
  415. <div class="btn-group">
  416. <label class="btn btn-primary active">
  417. <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>
  418. </label>
  419. </div>
  420. <div class="custom-control"><br>
  421. <button type="submit" class="btn btn-success mx-1" name="send" onClick="window.onbeforeunload = null;">Сохранить и выйти</button>
  422. <button type="submit" class="btn btn-success mx-1" name="save" onClick="window.onbeforeunload = null;">Сохранить</button>
  423. <?
  424. if(!$news->isNewRecord){
  425. ?>
  426. <a href="/news/preview/<?=$uuid?>" class="btn btn-info" target="_blank"><i class="fas fa-cat"></i> Предпросмотр</a>
  427. <div class="card card-info my-3">
  428. <div class="card-header">
  429. <h3 class="card-title">Локальные копии автосохранение</h3>
  430. </div>
  431. <div class="card-body text-right">
  432. <button class="btn btn-primary" type="button" onClick="SaveLocal()">Сохранить</button>
  433. <button class="btn btn-primary" type="button" onClick="LoadLocal()">Востановить</button>
  434. </div>
  435. <div class="card-footer">
  436. Копии сохраняются каждые 60сек. Для лучшего эффекта заполните заголовок
  437. </div>
  438. </div>
  439. <?
  440. }else{
  441. ?>
  442. <div class="alert alert-success m-4 bg-olive" role="alert">
  443. <h4 class="alert-heading">Для не сохранённых статей!</h4>
  444. <p>Вы ещё ни разу не сохранили документ, по этому нет возможности сделать его предпросмотр.</p>
  445. <hr>
  446. <p class="mb-0">Когда вы сохраните документ, станут доступны дополнительные функсии, в том числе авто сохранение локальной копии.</p>
  447. </div>
  448. <?
  449. }
  450. ?>
  451. </div>
  452. </div>
  453. <!-- правая колонка --->
  454. <div class="col-3">
  455. <div class="card card-primary">
  456. <div class="card-header">
  457. <h3 class="card-title">Фото</h3>
  458. </div>
  459. <div class="card-body">
  460. <style>
  461. #image {
  462. width: 100%;
  463. height: 56%;
  464. background: URL(/img/image.svg) no-repeat 50% 50%;
  465. background-size: contain;
  466. background-color: #fff;
  467. cursor: pointer;
  468. padding: 0px 0px 8px 0px;
  469. }
  470. #myTags {
  471. box-shadow: 0 0 5px rgba(81, 203, 238, 1);
  472. padding: 3px 0px 3px 3px;
  473. margin: 5px 1px 3px 0px;
  474. border: 1px solid rgba(81, 203, 238, 1);
  475. }
  476. </style>
  477. <?
  478. if($news->id){
  479. $imageSrc = $news->getImage()->geturl(Image::SIZE_1040x586);
  480. /*
  481. $imageSrc = "/images/news/news/".$news->id."_sizehd.jpg";
  482. if( file_exists( \Yii::getAlias('@webroot').$imageSrc ) === false ){
  483. if( $news->photo_name != '' ){
  484. $imageSrc = $news->photo_name;
  485. }else{
  486. $imageSrc = '/img/e.gif';
  487. }
  488. }
  489. */
  490. $imageSrc .= "?r=".rand();
  491. }else{
  492. $imageSrc = '/img/e.gif';
  493. }
  494. ?>
  495. <img id="image" src="<?=$imageSrc?>" onClick="$('#modal').modal('show');document.getElementById('inputImage').click();" >
  496. <?
  497. echo CropperjsWidget::widget(['image' => 'image', 'file' => 'News[photo]', 'post' => 'cropping', 'aspectRatio' => '16/9']);
  498. ?><script>
  499. $('#container_image').attr('src', '<?=$imageSrc?>');
  500. </script>
  501. <label class="control-label" for="status-photo">Статусы для фото</label>
  502. <div class="btn-group" data-toggle="buttons" id="status-photo">
  503. <label class="btn btn-primary active btn-sm px-3" title="показывать фото">
  504. <input type="checkbox" autocomplete="off" name="News[photo_include]"<?=($news->photo_include == 'Y')?' checked':''?> value="Y"><i class="fa fa-eye ml-2"></i>
  505. </label>
  506. <label class="btn btn-info active btn-sm px-3" title="фото в пр. ленте">
  507. <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>
  508. </label>
  509. <label class="btn btn-dark active btn-sm px-3" title="удалить фото">
  510. <input type="checkbox" autocomplete="off" name="News[del_photo]" value="Y"><i class="fa fa-trash ml-2"></i>
  511. </label>
  512. </div>
  513. <div class="form-group field-title-photo required">
  514. <label class="control-label" for="title-photo">Подпись фото</label>
  515. <textarea id="title-photo" class="form-control" name="News[photo_title]" rows="1" aria-required="true"><?=$news->photo_title?></textarea>
  516. </div>
  517. <button type="button" class="btn btn-primary btn-block" onClick="javascript:$('#sphoto').modal('show');">Поискать</button>
  518. </div>
  519. </div>
  520. <!-- test -->
  521. <div class="card card-primary">
  522. <div class="ribbon-wrapper">
  523. <div class="ribbon bg-lightblue">
  524. SuperTag
  525. </div>
  526. </div>
  527. <div class="card-body bg-gradient-olive">
  528. <?
  529. $tagscheck = [];
  530. foreach( $Tagitems as $setmenuitem ){
  531. $tagscheck[$setmenuitem->id] = true;
  532. }
  533. foreach( $tagsmenu as $menuitem ){
  534. ?>
  535. <div class="custom-control custom-switch">
  536. <input class="custom-control-input" type="checkbox" value="<?=$menuitem->id?>" id="tflexCheck<?=$menuitem->id?>" name="ExtTag[<?=$menuitem->id?>]"<?=isset($tagscheck[$menuitem->id])?' checked':''?>>
  537. <label class="custom-control-label" for="tflexCheck<?=$menuitem->id?>"><?=$menuitem->title?></label>
  538. </div>
  539. <?
  540. }
  541. ?>
  542. </div>
  543. </div>
  544. <!-- /test -->
  545. <div class="card card-primary">
  546. <div class="ribbon-wrapper">
  547. <div class="ribbon bg-primary">
  548. Рубрики
  549. </div>
  550. </div>
  551. <div class="card-body">
  552. <?
  553. $atopic = array();
  554. if(!$news->isNewRecord)
  555. {
  556. $model = new NewsTopic();
  557. $Titems = $model->getForNews($news->id);
  558. foreach( $Titems as $item ){
  559. $atopic[$item->id] = $item->id;
  560. }
  561. }
  562. ?>
  563. <div class="accordion" id="TopicsSel">
  564. <div class="card">
  565. <div class="card-header" id="headingOne">
  566. <h2 class="mb-0">
  567. <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapse1" aria-expanded="true" aria-controls="collapse1">
  568. Общий рубрикатор
  569. </button>
  570. </h2>
  571. </div>
  572. <div id="collapse1" class="collapse show" aria-labelledby="heading1" data-parent="#TopicsSel">
  573. <div class="card-body">
  574. <?
  575. foreach( NewsTopic::findActive()->getModels() as $item ){
  576. if( in_array( $item->id, [127,128]) ) continue; // пропустить разделы видео/подкасты
  577. if( $item->url == '----' ){
  578. ?>
  579. <div class="checkbox_title_hr">
  580. <span><?=$item->title?></span>
  581. </div>
  582. <?
  583. }else{
  584. ?>
  585. <div class="custom-control <?=($item->show == 'Y')?'custom-checkbox':'custom-switch bg-purple'?>">
  586. <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':''?>>
  587. <label class="custom-control-label" for="flexCheck<?=$item->id?>">
  588. <?=$item->title?>
  589. </label>
  590. </div>
  591. <?
  592. }
  593. }
  594. ?>
  595. </div>
  596. </div>
  597. </div>
  598. <div class="card">
  599. <div class="card-header" id="heading2">
  600. <h2 class="mb-0">
  601. <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapse2" aria-expanded="true" aria-controls="collapse2">
  602. Слушать
  603. </button>
  604. </h2>
  605. </div>
  606. <div id="collapse2" class="collapse" aria-labelledby="heading2" data-parent="#TopicsSel">
  607. <div class="card-body">
  608. <?
  609. foreach( NewsTopic::findActive(127)->getModels() as $item ){
  610. ?>
  611. <div class="custom-control <?=($item->show == 'Y')?'custom-checkbox':'custom-switch bg-purple'?>">
  612. <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':''?>>
  613. <label class="custom-control-label" for="flexCheck<?=$item->id?>">
  614. <?=$item->title?>
  615. </label>
  616. </div>
  617. <?
  618. }
  619. ?>
  620. </div>
  621. </div>
  622. </div>
  623. <div class="card">
  624. <div class="card-header" id="heading3">
  625. <h2 class="mb-0">
  626. <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapse3" aria-expanded="true" aria-controls="collapse3">
  627. Смотреть
  628. </button>
  629. </h2>
  630. </div>
  631. <div id="collapse3" class="collapse" aria-labelledby="heading3" data-parent="#TopicsSel">
  632. <div class="card-body">
  633. <?
  634. foreach( NewsTopic::findActive(128)->getModels() as $item ){
  635. ?>
  636. <div class="custom-control <?=($item->show == 'Y')?'custom-checkbox':'custom-switch bg-purple'?>">
  637. <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':''?>>
  638. <label class="custom-control-label" for="flexCheck<?=$item->id?>">
  639. <?=$item->title?>
  640. </label>
  641. </div>
  642. <?
  643. }
  644. ?>
  645. </div>
  646. </div>
  647. </div>
  648. </div>
  649. </div>
  650. </div>
  651. <div class="card card-primary">
  652. <div class="ribbon-wrapper">
  653. <div class="ribbon bg-primary">
  654. сюжеты
  655. </div>
  656. </div>
  657. <div class="card-body">
  658. <div class="input-group">
  659. <div class="input-group-prepend">
  660. <span class="btn btn-primary" id="validatedInputGroupPrepend"><i class="fas fa-search"></i></span>
  661. </div>
  662. <input type="text" class="form-control" aria-describedby="validatedInputGroupPrepend" id="story">
  663. </div>
  664. <?
  665. $model = new Story();
  666. if(!$news->isNewRecord)
  667. {
  668. $Sitems = $model->getForNews($news->id);
  669. }else{
  670. $Sitems = [];
  671. }
  672. ?>
  673. <div class="custom-control custom-checkbox">
  674. <?
  675. foreach($Sitems as $item){
  676. ?>
  677. <div class="custom-control custom-checkbox">
  678. <input class="custom-control-input" type="checkbox" value="<?=$item->id?>" id="Story<?=$item->id?>" name="Story[<?=$item->id?>]" checked>
  679. <label class="custom-control-label" for="Story<?=$item->id?>">
  680. <?=$item->title?>
  681. </label>
  682. </div>
  683. <?
  684. }
  685. ?>
  686. <div id="story_items"></div>
  687. </div>
  688. </div>
  689. </div>
  690. <!-- end col r-->
  691. </div></div>
  692. <?
  693. ActiveForm::end();
  694. if(!$news->isNewRecord){
  695. ?>
  696. <!-- Modal -->
  697. <div class="modal fade" id="addGalleryModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  698. <div class="modal-dialog" role="document">
  699. <div class="modal-content">
  700. <form action="" class="gallery-form" id="galleryForm">
  701. <div class="modal-header">
  702. <h5 class="modal-title" id="exampleModalLabel">Добавление галлереи</h5>
  703. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  704. <span aria-hidden="true">&times;</span>
  705. </button>
  706. </div>
  707. <div class="modal-body">
  708. <input type="hidden" value="<?=$news->id?>" name="post_id">
  709. <div class="form-group">
  710. <label for="name">Название</label>
  711. <input type="text" class="form-control" name="name">
  712. </div>
  713. <div class="form-group">
  714. <label for="description">Описание</label>
  715. <input type="text" class="form-control" name="description">
  716. </div>
  717. </div>
  718. <div class="modal-footer">
  719. <button type="button" class="btn btn-secondary" data-dismiss="modal">Отмена</button>
  720. <button type="submit" class="btn btn-primary save">Сохранить</button>
  721. </div>
  722. </form>
  723. </div>
  724. </div>
  725. </div>
  726. <script>
  727. $(document).ready(function () {
  728. $("#galleryForm").submit(function (e) {
  729. e.preventDefault()
  730. $.get(
  731. '<?=\yii\helpers\Url::to(["/manager/news/add-gallery"])?>',
  732. $(this).serialize(),
  733. function (data){
  734. $("#addGalleryModal").modal('hide')
  735. $("#galleryForm")[0].reset()
  736. $("#galleriesContainer .card-body .galleries-list").append(data)
  737. }
  738. )
  739. })
  740. })
  741. let galleryRemove = function (id)
  742. {
  743. $.get(
  744. '<?=\yii\helpers\Url::to(["/manager/news/remove-gallery"])?>',
  745. {id:id},
  746. function (data){
  747. $("#gallery-" + id).remove();
  748. }
  749. )
  750. }
  751. </script>
  752. <script src="/components/admin/js/ls.js"></script>
  753. <?
  754. }
  755. ?>
  756. <script>
  757. $(function() {
  758. var cache = {};
  759. $( "#story" ).autocomplete({
  760. source: function( request, response ) {
  761. var term = request.term;
  762. if ( term in cache ) {
  763. response( cache[ term ] );
  764. return;
  765. }
  766. $.getJSON( "ajaxstory", {'q':request.term}, function( data, status, xhr ) {
  767. if( data.status == 'ok' ){
  768. cache[ term ] = data.item;
  769. response( data.item );
  770. }
  771. });
  772. },
  773. minLength: 3,
  774. select: function( event, ui ) {
  775. if( $( "#story_items :input[value='"+ui.item.id+"']" ).val() != ui.item.id ){
  776. $( "#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>");
  777. }
  778. },
  779. /* open: function() {
  780. $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
  781. },
  782. close: function() {
  783. $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
  784. }*/
  785. });
  786. });
  787. 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"};
  788. jQuery(function ($) {
  789. if (jQuery('#dt_pub').data('datetimepicker')) { jQuery('#dt_pub').datetimepicker('destroy'); }
  790. $('#dt_pub').datetimepicker(datetimepicker_conf);
  791. });
  792. $(function() {
  793. window.varsubmit = false;
  794. $("input[id='news-title']").keyup(function count(){
  795. number = $("input[id='news-title']").val().length;
  796. $("#title_count").html(number);
  797. });
  798. $('#news-lid').keyup(function(){
  799. number = $(this).val().length;
  800. $("#lid_count").html(number);
  801. });
  802. $('#grpnh input:checkbox').click(function(){
  803. if ($(this).is(':checked')) {
  804. $('#grpnh input:checkbox').not(this).prop('checked', false);
  805. }
  806. });
  807. setInterval( function (){ sendping( '<?=$news->id?>' ) }, 10000 );
  808. function sendping( newsid ){
  809. $.get( "newsping", { id: newsid }, function(data){
  810. data = JSON.parse(data);
  811. if( data.status == 'warn' ) alert( 'В новости появился '+data['author'] );
  812. } );
  813. }
  814. $('#news-form').submit(function( event ) {
  815. console.log(window.varsubmit);
  816. val = $(document.activeElement).attr('name')
  817. if( (val == 'save' || val == 'send') && !window.varsubmit ){
  818. window.varsubmit = true; //запрет повторного вызова
  819. // отправка тэгов
  820. tags = $('#myTags').tagsValues();
  821. nform = $('#news-form');
  822. $.each(tags,function (key,value) {
  823. tpl = $('<input type="hidden" value="'+value+'" name="Tags[]">');
  824. nform.append(tpl);
  825. });
  826. }
  827. if( (val == 'save' || val == 'send') ) return true;
  828. });
  829. $("input[type=text]").keydown(function(event){
  830. if(event.keyCode == 13){
  831. event.preventDefault();
  832. return false;
  833. }
  834. });
  835. });
  836. function runSuggestions(element,query) {
  837. let sug_area=$(element).parents().eq(2).find('.autocomplete .autocomplete-items');
  838. if( query.length > 1 ){
  839. $.getJSON("/manager/tags/search", {'q':query}, function( data ) {
  840. _tag_input_suggestions_data = data;
  841. $.each(data,function (key,value) {
  842. let template = $("<div>"+value.name+"</div>").hide()
  843. sug_area.append(template)
  844. template.show()
  845. })
  846. });
  847. }
  848. }
  849. // CKEditor
  850. $(function () {
  851. if($('#js_news_content').length != 0){
  852. CKEDITOR.replace('js_news_content', {
  853. 'filebrowserBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=files&uid=<?=$uuid?>',
  854. 'filebrowserImageBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=images&uid=<?=$uuid?>',
  855. 'filebrowserFlashBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=flash&uid=<?=$uuid?>',
  856. 'filebrowserUploadUrl': '/components/admin/ckeditor/kcfinder/upload.php?type=files&uid=<?=$uuid?>',
  857. 'filebrowserImageUploadUrl': '/components/admin/ckeditor/kcfinder/upload.php?type=images&uid=<?=$uuid?>',
  858. 'filebrowserFlashUploadUrl': '/components/admin/ckeditor/kcfinder/upload.php?type=flash&uid=<?=$uuid?>',
  859. 'filebrowserAudioBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=files&uid=<?=$uuid?>',
  860. 'filebrowserlightboxUploadUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=files&uid=<?=$uuid?>',
  861. 'height': 400
  862. });
  863. CKEDITOR.on('instanceReady', function(ev) {
  864. ev.editor.on('paste', function(evt) {
  865. evt.data.dataValue = evt.data.dataValue.replace(/[«»]/g,'"');
  866. console.log(evt.data.dataValue);
  867. }, null, null, 9);
  868. });
  869. }
  870. });
  871. window.onbeforeunload = function(e) {
  872. return "Вы уверены, что покидаете страницу?";
  873. };
  874. </script>
  875. <?
  876. // редактор end
  877. ?>
  878. </div>
  879. <div class="tab-pane fade" id="comments">
  880. <?
  881. // коменты
  882. echo $this->render('../comments/newsindex', [
  883. 'model' => $news,
  884. ]);
  885. ?>
  886. </div>
  887. </div>
  888. <?
  889. echo $this->render('formSP', [
  890. 'model' => $news,
  891. ]);
  892. echo $this->render('../top-slider/modalform', ['news'=>$news]);
  893. ?>