Преглед на файлове

Merge remote-tracking branch 'origin/dev' into dev

vadeg_ne@mail.ru преди 1 година
родител
ревизия
62325dc815

+ 1 - 1
models/base/TagsRelation.php

@@ -62,7 +62,7 @@ class TagsRelation extends BaseFrontendClass
 					'type' => 'news'
 				])->execute();
 			}else{
-				if( mb_strlen( $item ) > 2 ){	//совсем мусор
+				if( mb_strlen( $item ) > 2 && 0 ){	//совсем мусор #отключено простое добавление, стали заводить мусор
 					$tags = new Tags();
 					$r = $tags->simpleAdd($item);
 					if( $r !== false && $r*1 > 0 ){

+ 9 - 5
modules/manager/controllers/CommentsController.php

@@ -17,6 +17,7 @@ class CommentsController extends BaseController
     /**
      * @inheritDoc
      */
+
     public function behaviors()
     {
         return array_merge(
@@ -103,12 +104,15 @@ class CommentsController extends BaseController
     public function actionUpdate($id)
     {
         $model = $this->findModel($id);
+		if (isset($_POST['Comments'])) {
+			$model->message = $_POST['Comments']['message'];
+			$model->visible = $_POST['Comments']['visible'];
+			if ($model->save()) {
+					return $this->redirect(['view', 'id' => $model->id]);
+			}
+		}
 
-        if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
-            return $this->redirect(['view', 'id' => $model->id]);
-        }
-
-        return $this->render('update', [
+		return $this->render('update', [
             'model' => $model,
         ]);
     }

+ 1 - 1
modules/manager/views/comments/_form.php

@@ -10,7 +10,7 @@ use yii\widgets\ActiveForm;
 
 <div class="comments-form">
 
-    <?php $form = ActiveForm::begin(); ?>
+    <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
 
     <?= $form->field($model, 'id')->textInput() ?>
 

+ 51 - 0
views/layouts/lenta/_item_right.php

@@ -0,0 +1,51 @@
+<?php
+/**
+ * @var $model \app\models\News
+ * @var $index integer
+ */
+use app\models\base\Image;
+
+$preview = $model->image;
+
+$retina = $preview->getUrl(Image::SIZE_680x383,"webp");
+$normal = $preview->getUrl(Image::SIZE_320x180,"webp");
+$bad = $preview->getUrl(Image::SIZE_320x180,'jpg');
+
+$bad = $bad?$bad:'/images/default.jpg';
+
+if( $retina === false || $normal == false ){
+	$normal = $bad;
+	$retina = $bad;
+}
+$normal .= "?v=".$model->rev;
+$retina .= "?v=".$model->rev;
+$bad .= "?v=".$model->rev;
+
+if(  $model->photo_rcol == 'Y' ){
+?>
+        <div class="card-body mb-2">
+            <?php if($preview instanceof \app\models\base\Image):?>
+                <div class="picture-cont-16x9">
+                    <a href="<?=$model->url?>">
+                        <picture class="w-100">
+                            <source srcset="<?=$normal?>, <?=$retina?> 2x" media="(min-width: 600px)">
+                            <img src="<?=$bad?>" alt="<?=htmlentities($model->photo_title,ENT_QUOTES)?>" srcset="<?=$normal?>, <?=$retina?> 2x" class="w-100" <?=($index > 2)?'loading="lazy"':''?>>
+                        </picture>
+                    </a>
+                </div>
+            <?php endif;?>
+        </div>
+<?}?>
+<h3>
+    <?=\yii\helpers\Html::a($model->title,$model->url);?>
+    <div class="published_at">
+        <?=($model->dt_pub<date("Y-m-d H:i:s",strtotime("-1 day")))?date("d.m.Y H:i",strtotime($model->dt_pub)):$model->publishedAt?>
+        <?php
+        $count=$model->getCommentsAll()->count();
+        ?>
+        <?php if($count>0):?>
+            <span class="commnets">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></span>
+        <?php endif;?>
+    </div>
+</h3>
+

+ 43 - 0
views/layouts/lenta/lenta_right.php

@@ -0,0 +1,43 @@
+<?php
+
+use app\models\front\News;
+
+$keyadd = News::keyFilter();
+?>
+<a class="news-link" href="/news">Лента новостей</a>
+<?php if( Yii::$app->controller->action->id!="index") echo $this->render("@app/views/_etc/banners/desktopLentBannerVideo"); ?>
+<div class="lenta">
+    <?= Yii::$app->cache->getOrSet("main_page_lenta_".(Yii::$app->deviceDetect->isMobile() ?"desktop":"mobile").Yii::$app->controller->action->id.$keyadd,function () {
+        $lenta = "<div id='list-wrapper' class='list-wrapper'>";
+/*
+// Фиксированные новости или банера в верху ленты
+## пример "День поля"
+*/
+
+/*		$lenta .= '<style>.lenta .list-wrapper .lenta_fix:hover{background:#60b740;}</style>
+<div class="lenta_fix"><h3>
+    <a href="/story/den_sibirskogo_polya_2023" title="День Сибирского поля-2023"><img src="/img/day_pole.svg" width="275px" height="80px" alt="День Сибирского поля"></a><div class="published_at">28-29 июня</div>
+</h3>
+</div>
+';
+*/
+        $index = 0;
+        foreach (News::findFilter()->andWhere(["(flags & 1)"=>0])->limit(70)->all() as $model){
+            $index++;
+            $lenta.= \yii\helpers\Html::tag('div',$this->render('_item_right',["model"=>$model, "index"=>$index])) ;
+
+            if($index==3)  $lenta.=$this->render("@app/views/_etc/banners/mobileMainPageLentBanner");
+            if($index==10 && Yii::$app->controller->action->id!="index") $lenta.=$this->render("@app/views/_etc/banners/desktopLentBanner");
+            if($index==20 && Yii::$app->controller->action->id!="index") $lenta.=$this->render("@app/views/_etc/banners/desktopLent20Banner");
+            if($index>20 && ($index % 10)==0 && Yii::$app->controller->action->id!="index" ) $lenta.=$this->render("@app/views/_etc/banners/desktopLent20Banner",["index"=>$index]);
+
+        }
+        $lenta.="</div>";
+        return $lenta;
+    },News::$keysCache['main_page_lenta']);
+
+    ?>
+    <div class="all-news">
+        <a href="/news">Все новости</a>
+    </div>
+</div>

+ 36 - 1
views/news/view.php

@@ -166,12 +166,45 @@ $GLOBALS['type_long'] = ($model->type == 6); //лонгрид
             <?php
 			echo $this->render("@app/views/news/view/tags",["model"=>$model]);
 ?>
+<?
+/*
+
 			<section class="share-this">
                 <!-- ShareThis BEGIN -->
                 <div class="sharethis-inline-reaction-buttons"></div>
                 <!-- ShareThis END -->
                 <div style="clear: both;"></div>
             </section>
+
+
+*/
+// Временно ок для конкурса
+?>
+			<section class="share-this">
+				<center><div id="ok_shareWidget"></div></center>
+                <div style="clear: both;"></div>
+            </section>
+<script>
+!function (d, id, did, st, title, description, image) {
+  function init(){
+    OK.CONNECT.insertShareWidget(id,did,st, title, description, image);
+  }
+  if (!window.OK || !OK.CONNECT || !OK.CONNECT.insertShareWidget) {
+    var js = d.createElement("script");
+    js.src = "https://connect.ok.ru/connect.js";
+    js.onload = js.onreadystatechange = function () {
+    if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") {
+      if (!this.executed) {
+        this.executed = true;
+        setTimeout(init, 0);
+      }
+    }};
+    d.documentElement.appendChild(js);
+  } else {
+    init();
+  }
+}(document,"ok_shareWidget",document.URL,'{"sz":30,"st":"oval","ck":1,"bgclr":"ED8207","txclr":"FFFFFF"}',"","","");
+</script>
 <?
             $stn = $story->getForNews($model->id);
             if( count($stn) > 0 ){
@@ -470,7 +503,8 @@ if( strpos( $model->text, 'class="InviewElement' ) !== false ){
     })()
 </script>
 <?
-if(	Yii::$app->deviceDetect->isMobile() ){
+/*
+if(	Yii::$app->deviceDetect->isMobile()  ){
 	$this->registerJs(
 <<<JS
 $(function () {
@@ -493,3 +527,4 @@ JS
     'sharethis'
 	);
 }
+*/