Esempio n. 1
0
 public function init()
 {
     parent::init();
     $this->_items = Data::cache(CarouselModel::CACHE_KEY, 3600, function () {
         $items = [];
         foreach (CarouselModel::find()->status(CarouselModel::STATUS_ON)->sort()->all() as $item) {
             $items[] = new CarouselObject($item);
         }
         return $items;
     });
 }
Esempio n. 2
0


    <?php 
$a = array(15, 17, 18, 19, 20, 21, 22, 23, 24);
if (in_array($item->item_id, $a, true)) {
    ?>

    <div class="container-fluid useDry">
	   <div class="container">
    	<div class="title"><?php 
    echo yii::t('easyii', 'Uses for dry go');
    ?>
</div>
    			<?php 
    $listData = \app\modules\drygomoduleupdated\models\Carousel::find()->all();
    foreach ($listData as $data) {
        $itemdataUrl = Url::to(['products/view'], true) . '/?slug=' . $item->slug . '&drygo=' . $data->carousel_id . '&review=null&lang=' . \Yii::$app->language;
        ?>

                    <div class="col-md-4 bounceIn wow">
                        <!-- BEGIN TEAM -->
                        <div class="team-image-sec">
                            <div class="img-overlay"></div>
                            <figure>
                                <img title="Image"  src="<?php 
        echo \Yii::$app->language == "en" ? $data->image : $data->image_ar;
        ?>
" alt="<?php 
        echo $data->link;
        ?>
 public function actionView($slug = null, $drygo = null, $review = null, $lang = null)
 {
     $oReview = new \app\modules\reviews\models\News();
     $oReview->time = time();
     $item = Catalog::get($slug);
     if (!$item) {
         throw new NotFoundHttpException('Item not found.');
     }
     if (\Yii::$app->language == 'en') {
         $product_image = $item->image;
     } else {
         $product_image = $item->image_ar;
     }
     //og tags
     $this->view->params['metatitle'] = $item->og_title;
     $this->view->params['metaimage'] = "http://" . $_SERVER['SERVER_NAME'] . $product_image;
     $this->view->params['metadesc'] = strip_tags($item->og_desc);
     //meta tags
     $this->view->params['meta_title'] = $item->meta_title;
     $this->view->params['meta_keyword'] = strip_tags($item->meta_keyword);
     $this->view->params['meta_description'] = strip_tags($item->meta_desc);
     //if for drygo item share
     if ($drygo != '') {
         $dryGoData = \app\modules\drygomoduleupdated\models\Carousel::find()->where('carousel_id=' . $drygo)->one();
         if ($lang != 'en') {
             \Yii::$app->language = "ar";
             $image = $dryGoData->image_ar;
         } else {
             \Yii::$app->language = "en";
             $image = $dryGoData->image;
         }
         if ($dryGoData) {
             $this->view->params['metatitle'] = $dryGoData->title;
             $this->view->params['metaimage'] = "http://" . $_SERVER['SERVER_NAME'] . $image;
             $this->view->params['metadesc'] = $dryGoData->text;
         }
     }
     if ($review != null) {
         if ($lang != 'en') {
             \Yii::$app->language = "ar";
             $image = $item->image_ar;
         } else {
             \Yii::$app->language = "en";
             $image = $item->image;
         }
         $Creview = \app\modules\reviews\models\News::find()->where('news_id=' . $review)->one();
         if ($Creview) {
             $this->view->params['metatitle'] = $Creview->title;
             $this->view->params['metaimage'] = "http://" . $_SERVER['SERVER_NAME'] . $image;
             $this->view->params['metadesc'] = $Creview->short;
         }
     }
     if ($oReview->load(Yii::$app->request->post())) {
         $oReview->product_id = $item->id;
         $oReview->status = 0;
         if (Yii::$app->language == 'en') {
             $oReview->flag_en = 1;
         } else {
             $oReview->flag_en = 0;
         }
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($oReview);
         } else {
             if ($oReview->save()) {
                 \Yii::$app->getSession()->setFlash('success', Yii::t('easyii', 'Your Review has been added successfully'));
             } else {
                 // var_dump($oReview->formatErrors());
                 return $this->refresh();
             }
         }
     }
     //        $reviews= News::find()
     //            ->where("product_id = ".$item->id." and status=1")
     //            ->all();
     $reviews = News::items(['tags' => '', 'pagination' => ['pageSize' => 5]], $item->id);
     $count = 0;
     foreach ($reviews as $review) {
         $count += $review->no_of_review;
     }
     if ($count > 0) {
         $avg_rate = count($reviews) / $count;
     } else {
         $avg_rate = 0;
     }
     $avg_rate = round($avg_rate);
     //var_dump($reviews);die;
     return $this->render('view', ['item' => $item, 'addToCartForm' => new \app\models\AddToCartForm(), 'reviews' => $reviews, 'oReview' => $oReview]);
 }
Esempio n. 4
0
 public function actionDelete($id)
 {
     if ($model = Carousel::findOne($id)) {
         $model->delete();
     } else {
         $this->error = Yii::t('easyii', 'Not found');
     }
     return $this->formatResponse(Yii::t('easyii/drygomoduleupdated', 'Carousel item deleted'));
 }