formNews.php 44 KB

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