viewVideo.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <?php
  2. /**
  3. * @var $this \yii\web\View
  4. * @var $model \app\models\News
  5. */
  6. use yii\helpers\ArrayHelper;
  7. use app\modules\ldjson\jsonLD;
  8. use yii\web\UrlManager;
  9. use app\models\Authors;
  10. jsonLD::addAmicORG();
  11. jsonLD::news( $model->title, $model->lid, $model->image->url, $model->dt_pub, $model->getUrl());
  12. $this->title = $model->title;
  13. $this->params['breadcrumbs'] = [
  14. [
  15. "text"=>"НОВОСТИ",
  16. "url"=>"/news"
  17. ]
  18. ];
  19. $this->params['context'] = "post-view";
  20. $topic = ArrayHelper::getValue($model->topics,0);
  21. if($topic instanceof \app\models\base\NewsTopic){
  22. $this->params['breadcrumbs'][] =
  23. [
  24. "text"=>$topic->title,
  25. "url"=>mb_strtoupper($topic->url)
  26. ];
  27. }
  28. $i = 1;
  29. foreach($this->params['breadcrumbs'] as $el){
  30. jsonLD::addBreadcrumb($i, $el['url'], $el['text']);
  31. $i++;
  32. }
  33. if( $model->show_author == 'Y' )
  34. {
  35. $author = Authors::getAuthor( $model->author );
  36. $authorName = $author->name;
  37. jsonLD::author( $authorName );
  38. }else{
  39. $authorName = 'ИА Амител';
  40. jsonLD::author( $authorName, false );
  41. }
  42. $GLOBALS['type_long'] = ($model->type == 6);
  43. ?>
  44. <div class="row">
  45. <div class="<?=($model->type == 2 || $model->type == 6)?'col-md-12':'col-md-8'?>">
  46. <div id="post" class="post">
  47. <?
  48. if( Yii::$app->user->can('admin') ){
  49. ?>
  50. <span style="position: absolute;background-color: #a9a9a924;right: 30px;top: 10px; box-shadow: 2px 5px 5px 3px #888;"><img onclick="location='/manager/news/update?id=<?=$model['id']?>'" src="/img/edit.svg" width="25px" height="25px" style="padding:3px;cursor:pointer;"><img onclick="navigator.clipboard.writeText('https://www.amic.ru/news/<?=$model['id']?>')" src="/img/share-boxed.svg" width="25px" height="25px" style="padding:3px;margin-top: 2px;cursor:pointer;"></span>
  51. <?
  52. }
  53. ?>
  54. <?=$this->render("/layouts/breadcrumbs")?>
  55. <h1><?=$model->title?></h1>
  56. <p class="lead"><?=$model->lid?></p>
  57. <p class="published_at"><?=$model->publishedAt?> <?=date("Y, H:m")?>, <?=$authorName?></p>
  58. <p class="share_and_comment">
  59. <a href="#comments" class="comments_btn">Комментировать</a>
  60. <a onclick="Share.vkontakte('URL','TITLE','IMG_PATH','DESC')">
  61. <svg class="icon icon-vk"><use xlink:href="/svg/symbol/sprite-clear.svg#vk"></use></svg>
  62. </a>
  63. <a onclick="Share.odnoklassniki('URL','DESC')">
  64. <svg class="icon icon-ok"><use xlink:href="/svg/symbol/sprite-clear.svg#ok"></use></svg>
  65. </a>
  66. <a onclick="Share.twitter('URL','TITLE')">
  67. <svg class="icon icon-tw"><use xlink:href="/svg/symbol/sprite-clear.svg#tw"></use></svg>
  68. </a>
  69. </p>
  70. <p>
  71. <?php if($model->photo_include == 'Y' && $model->image instanceof \app\models\base\Image):?>
  72. <div class="picture-cont-16x9">
  73. <picture class="w-100">
  74. <source srcset="<?=$model->image->url?>" media="(min-width: 600px)">
  75. <img src="<?=$model->image->url?>" alt="<?=$model->photo_title?>" class="w-100">
  76. </picture>
  77. </div>
  78. <div class="image-title"><?=$model->photo_title?></div>
  79. <?php endif;?>
  80. </p>
  81. <section class="text">
  82. <?=$model->renderBody()?>
  83. <?=($model->inscription == 1)?'<span class="advertisement">На правах рекламы</span>':''?>
  84. <?=($model->inscription == 2)?'<span class="med_advertisement">Имеются противопоказания, необходима консультация специалиста</span>':''?>
  85. </section>
  86. <section class="comments" id="comments">
  87. <?=$this->render("view/comments/list",["model"=>$model])?>
  88. </section>
  89. </div>
  90. </div>
  91. <script>
  92. (function (){
  93. let main_view_cont = document.getElementById('post');
  94. let height = main_view_cont.offsetHeight;
  95. console.log(height)
  96. let style = document.createElement("style");
  97. style.innerHTML = "#lenta-container{ max-height:"+height+"px;}";
  98. main_view_cont.parentNode.append(style);
  99. })()
  100. </script>
  101. <div class="<?=($model->type == 2 || $model->type == 6)?'hidden':'col-md-4'?>" id="lenta-container">
  102. <?=$this->render("/layouts/lenta/lenta")?>
  103. </div>
  104. <div class="col-md-12" id="infinity_newsfeed">
  105. <?=$this->render("view/infinity_newsfeed",['model'=>$model])?>
  106. </div>
  107. <div id="main-carousel" class="splide"></div>
  108. </div>
  109. <?php
  110. $this->registerJsFile("/js/splide/dist/js/splide.min.js");
  111. $this->registerCssFile("/js/splide/dist/css/splide.min.css")
  112. ?>
  113. <script>
  114. (function (){
  115. var gallery = document.getElementById("gallery-0");
  116. if(gallery===null) return true;
  117. var wrapper = document.createElement("div");
  118. wrapper.classList.add('gallery-wrapper')
  119. gallery.parentNode.insertBefore(wrapper,gallery)
  120. wrapper.append(gallery)
  121. var gallery_items = gallery.getElementsByTagName("img");
  122. var track = document.createElement("div");
  123. var list = document.createElement('ul');
  124. gallery.classList.add("splide")
  125. list.classList.add("splide__list")
  126. track.classList.add("splide__track")
  127. gallery.prepend(track)
  128. track.prepend(list)
  129. for(var i =0; i<gallery_items.length;i++){
  130. var img = gallery_items[i];
  131. var img_cont = document.createElement('li')
  132. img_cont.classList.add("splide__slide")
  133. img_cont.append(img)
  134. list.append(img_cont)
  135. }
  136. var main_view = document.createElement("div")
  137. main_view.classList.add("splide","gallery-view");
  138. main_view.innerHTML=gallery.innerHTML;
  139. gallery.style.paddingBottom = "18px";
  140. gallery.style.marginBottom = 0;
  141. wrapper.prepend(main_view)
  142. document.addEventListener( 'DOMContentLoaded', function () {
  143. var main = new Splide( '.gallery-view', {
  144. type : 'fade',
  145. rewind : true,
  146. pagination: false,
  147. arrows : true,
  148. speed: 1000
  149. } );
  150. var thumbnails =new Splide( '.gallery', {
  151. fixedWidth: 100,
  152. fixedHeight: 60,
  153. gap : 10,
  154. rewind : true,
  155. pagination: false,
  156. isNavigation: true,
  157. arrows : false,
  158. } );
  159. main.sync( thumbnails );
  160. main.mount();
  161. thumbnails.mount();
  162. } );
  163. })()
  164. </script>
  165. <script>
  166. Share = {
  167. vkontakte: function(purl, ptitle, pimg, text) {
  168. url = 'https://vkontakte.ru/share.php?';
  169. url += 'url=' + encodeURIComponent(purl);
  170. url += '&title=' + encodeURIComponent(ptitle);
  171. url += '&description=' + encodeURIComponent(text);
  172. url += '&image=' + encodeURIComponent(pimg);
  173. url += '&noparse=true';
  174. Share.popup(url);
  175. },
  176. odnoklassniki: function(purl, text) {
  177. url = 'https://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1';
  178. url += '&st.comments=' + encodeURIComponent(text);
  179. url += '&st._surl=' + encodeURIComponent(purl);
  180. Share.popup(url);
  181. },
  182. facebook: function(purl, ptitle, pimg, text) {
  183. url = 'http://www.facebook.com/sharer.php?s=100';
  184. url += '&p[title]=' + encodeURIComponent(ptitle);
  185. url += '&p[summary]=' + encodeURIComponent(text);
  186. url += '&p[url]=' + encodeURIComponent(purl);
  187. url += '&p[images][0]=' + encodeURIComponent(pimg);
  188. Share.popup(url);
  189. },
  190. twitter: function(purl, ptitle) {
  191. url = 'https://twitter.com/share?';
  192. url += 'text=' + encodeURIComponent(ptitle);
  193. url += '&url=' + encodeURIComponent(purl);
  194. url += '&counturl=' + encodeURIComponent(purl);
  195. Share.popup(url);
  196. },
  197. mailru: function(purl, ptitle, pimg, text) {
  198. url = 'http://connect.mail.ru/share?';
  199. url += 'url=' + encodeURIComponent(purl);
  200. url += '&title=' + encodeURIComponent(ptitle);
  201. url += '&description=' + encodeURIComponent(text);
  202. url += '&imageurl=' + encodeURIComponent(pimg);
  203. Share.popup(url)
  204. },
  205. popup: function(url) {
  206. window.open(url,'','toolbar=0,status=0,width=626,height=436');
  207. }
  208. };
  209. </script>