formNews.php 44 KB

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