tilda.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. use yii\web\View;
  3. use yii\helpers\ArrayHelper;
  4. use app\modules\ldjson\jsonLD;
  5. use yii\web\UrlManager;
  6. use app\models\Authors;
  7. use app\models\base\Image;
  8. use \app\models\news;
  9. use yii\helpers\Url;
  10. foreach( $obj->css as $item ){
  11. echo '<link href="/'.$obj->dir.'css/'.$item.'" rel="stylesheet">';
  12. }
  13. foreach( $obj->js as $item ){
  14. echo '<script src="/'.$obj->dir.'js/'.$item.'" charset="utf-8" defer></script>';
  15. }
  16. echo '<script src="https://www.amic.ru/project/all/tilda/dvazhdy-ordenonosnyy-'.$id.'/js/tilda-blocks-page'.$id.'.min.js" ></script>';
  17. ?>
  18. <script src="/project/all/tilda/dvazhdy-ordenonosnyy-30604619/js/tilda-slds-1.4.min.js" charset="utf-8" async onerror="this.loaderr='y';"></script>
  19. <script src="/project/all/tilda/dvazhdy-ordenonosnyy-30604619/js/tilda-events-1.0.min.js" charset="utf-8" async onerror="this.loaderr='y';"></script>
  20. <style>
  21. header div{box-sizing: border-box}
  22. .t456.t456__positionabsolute{
  23. top: auto;
  24. left: 0px;
  25. }
  26. .t-title{ line-height: 100%; }
  27. </style>
  28. <script type="text/javascript">
  29. function t_onReady(func) {
  30. if (document.readyState != 'loading') {
  31. func();
  32. } else {
  33. document.addEventListener('DOMContentLoaded', func);
  34. }
  35. }
  36. function t_onFuncLoad(funcName, okFunc, time) {
  37. if (typeof window[funcName] === 'function') {
  38. okFunc();
  39. } else {
  40. setTimeout(function() {
  41. t_onFuncLoad(funcName, okFunc, time);
  42. },(time || 100));
  43. }
  44. }function t_throttle(fn, threshhold, scope) {return function () {fn.apply(scope || this, arguments);};}</script>
  45. <script type="text/javascript">(function () {
  46. if((/bot|google|yandex|baidu|bing|msn|duckduckbot|teoma|slurp|crawler|spider|robot|crawling|facebook/i.test(navigator.userAgent))===false && typeof(sessionStorage)!='undefined' && sessionStorage.getItem('visited')!=='y' && document.visibilityState){
  47. var style=document.createElement('style');
  48. style.type='text/css';
  49. style.innerHTML='@media screen and (min-width: 980px) {.t-records {opacity: 0;}.t-records_animated {-webkit-transition: opacity ease-in-out .2s;-moz-transition: opacity ease-in-out .2s;-o-transition: opacity ease-in-out .2s;transition: opacity ease-in-out .2s;}.t-records.t-records_visible {opacity: 1;}}';
  50. document.getElementsByTagName('head')[0].appendChild(style);
  51. function t_setvisRecs(){
  52. var alr=document.querySelectorAll('.t-records');
  53. Array.prototype.forEach.call(alr, function(el) {
  54. el.classList.add("t-records_animated");
  55. });
  56. setTimeout(function () {
  57. Array.prototype.forEach.call(alr, function(el) {
  58. el.classList.add("t-records_visible");
  59. });
  60. sessionStorage.setItem("visited", "y");
  61. }, 400);
  62. }
  63. document.addEventListener('DOMContentLoaded', t_setvisRecs);
  64. }
  65. })();</script>
  66. <?
  67. $preview = $model->image;
  68. $retina = $preview->getUrl(Image::SIZE_1040x586,"jpg");
  69. $normal = $preview->getUrl(Image::SIZE_841x473,"webp");
  70. $bad = $preview->getUrl(Image::SIZE_680x383,'jpg');
  71. $bad = $bad?$bad:'/images/default.jpg';
  72. if( $retina === false || $normal === false ){
  73. $normal = $bad;
  74. $retina = $bad;
  75. }
  76. $normal .= "?v=".$model->rev;
  77. $retina .= "?v=".$model->rev;
  78. $bad .= "?v=".$model->rev;
  79. /*
  80. После этой даты не выводить фото до подтверждения юриста
  81. if( isset( $model->dt_pub ) && strtotime( $model->dt_pub ) < strtotime('2015-01-01 00:00:00') ){
  82. $bad = '/images/default.jpg';
  83. $normal = $bad;
  84. $retina = $bad;
  85. };
  86. */
  87. $txt_date = date( "[Y-m-d] ", strtotime( $model->dt_pub ) );
  88. $body_text = strip_tags( preg_replace('/<(script|style)\b[^>]*>(.*?)<\/(script|style)>/is', "", $html) );
  89. Yii::$app->og->title =($model->meta_title)?$model->meta_title:$model->title;
  90. Yii::$app->og->description = ($model->lid && trim($model->lid) <> '')?str_replace( '"', "&quot;", strip_tags($model->lid) ):$txt_date.trim(str_replace( '"',"'",substr(strip_tags( $body_text ),0,150)))."...";
  91. if( $model->active == 'N' || $model->dt_pub > date("Y-m-d H:i:s") || $model->noindex == 'Y' ){
  92. Yii::$app->og->noindex = 'Y';
  93. }else{
  94. \Yii::$app->og->canonical = $model->getUrl(true);
  95. \Yii::$app->og->amp = Url::base('https').'/amp/news/'.$model->id;
  96. \Yii::$app->og->og_url = $model->getUrl(true);
  97. \Yii::$app->og->og_image = $model->image->url;
  98. \Yii::$app->og->og_type = "article";
  99. \Yii::$app->og->og_title = htmlspecialchars(($model->meta_title)?strip_tags(str_replace( '"',"&quot;",$model->meta_title)):strip_tags(str_replace( '"',"&quot;",$model->title)));
  100. \Yii::$app->og->og_description = ($model->lid && trim($model->lid) <> '')?str_replace( '"',"&quot;",strip_tags($model->lid)):$txt_date.trim(str_replace( '"',"&quot;",substr(strip_tags( $body_text ),0,150)))."...";
  101. \Yii::$app->og->dtpub = date( "r", strtotime( $model->dt_pub ) );
  102. }
  103. jsonLD::addAmicORG();
  104. jsonLD::news( $model->title, preg_replace('/\s+/', ' ', str_replace( ["\n","\r"],' ',Yii::$app->og->description)), $model->image->url, $model->dt_pub, $model->getUrl(), $model->uid, $body_text, $model->meta_title);
  105. jsonLD::addfaq($body_text, $model->title);
  106. $story = new \app\models\base\Story();
  107. $this->params['breadcrumbs'] = [
  108. [
  109. "text"=>"НОВОСТИ",
  110. "url"=>"/news"
  111. ]
  112. ];
  113. $this->params['context'] = "post-view";
  114. //$topic = ArrayHelper::getValue($model->topics,0);
  115. $topic = Yii::$app->cache->getOrSet('topic-news-'.$model->id, function () use($model){
  116. return $model->getTopics()->andWhere(['show'=>"Y","active"=>1])->orderBy('order asc')->one();
  117. }, News::$keysCache['topic-news-##']);
  118. if($topic instanceof \app\models\base\NewsTopic){
  119. $this->params['breadcrumbs'][] =
  120. [
  121. "text"=>$topic->title,
  122. "url"=>"/news/".mb_strtolower($topic->url)
  123. ];
  124. }
  125. $i = 1;
  126. foreach($this->params['breadcrumbs'] as $el){
  127. jsonLD::addBreadcrumb($i, $el['url'], $el['text']);
  128. $i++;
  129. }
  130. if( $model->show_author == 'Y' )
  131. {
  132. $author = Authors::getAuthor( $model->author );
  133. $authorName = $author->name;
  134. \Yii::$app->og->author =$authorName;
  135. jsonLD::author( $authorName );
  136. }else{
  137. $authorName = 'ИА Амител';
  138. jsonLD::author( $authorName, false );
  139. }
  140. $GLOBALS['type_long'] = ($model->type == 6); //лонгрид
  141. echo $html;