Пример #1
0
 /**
  * get all items of a user or all uploaded latest
  */
 public function getItems($id = null)
 {
     $total = [];
     $query = Photos::find()->where('FIND_IN_SET(:id,shared_with)', [':id' => Yii::$app->user->id])->orderBy(['id' => SORT_DESC]);
     if ($id != null) {
         $models = Photos::find()->where(['user_id' => $id])->orderBy(['id' => SORT_DESC])->all();
     } else {
         if (Yii::$app->controller->action->id == 'index') {
             $models = $query->orWhere(['user_id' => Yii::$app->user->id])->all();
         } elseif (Yii::$app->controller->action->id == 'dashboard') {
             $models = Photos::find()->where('FIND_IN_SET(:id,shared_with)', [':id' => Yii::$app->user->id])->orderBy(['id' => SORT_DESC])->all();
         }
     }
     foreach ($models as $k => $model) {
         if (Yii::$app->find->isShared(Yii::$app->user->id, $model->shared_with) == false && Yii::$app->user->id != $model->user_id) {
             continue;
         }
         //var_dump(Yii::$app->controller->action->id); die();
         if (Yii::$app->controller->action->id != 'view') {
             if ($k > 30) {
                 break;
             }
         }
         //var_dump($model->shared_with);
         $items = ['url' => $model->src, 'src' => '@web/uploads/albums/thumbs/' . $model->filename, 'options' => array('title' => 'By ' . $model->user->fullname)];
         array_push($total, $items);
     }
     return $total;
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Photos::find()->where(['user_id' => Yii::$app->user->id]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'filename', $this->filename])->andFilterWhere(['like', 'shared_with', $this->shared_with]);
     return $dataProvider;
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Photos::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'event_id' => $this->event_id]);
     $query->andFilterWhere(['like', 'photo_path', $this->photo_path]);
     return $dataProvider;
 }
Пример #4
0
 /**
  * Display user dashboard
  */
 public function actionDashboard()
 {
     //$model = Yii::$app->user->identity;
     $journals = new ActiveDataProvider(['query' => Journal::find()->orderBy(['date' => SORT_DESC])->limit(5), 'pagination' => false]);
     $events = new ActiveDataProvider(['query' => \app\models\Event::find()->orderBy(['date' => SORT_DESC])->limit(5), 'pagination' => false]);
     $photos = \app\models\Photos::find()->orderBy(['id' => SORT_DESC])->limit(5)->all();
     $wishlists = new ActiveDataProvider(['query' => \app\models\Wishlist::find()->where(['status' => 0])->orderBy('id')->limit(5), 'pagination' => false]);
     $DataProvider = new ActiveDataProvider(['query' => User::find()->where('level !=0 AND parent_id=0')->orderBy('id')]);
     $RegisteredMembers = count(User::find()->where('level > :level', [':level' => 3])->orWhere('level > :level', [':level' => 2])->orWhere('level > :level', [':level' => 1])->all());
     $famillies = User::find()->where(['level' => '1'])->count();
     $orders = count(\app\models\Payment::find()->all());
     $payments = Payment::getPaymentsCount();
     $months = Payment::getMonths();
     $epercent = Payment::earningPercentage();
     $earning = Payment::getMonthlyEarning();
     $revenue = Payment::totalRevenue();
     $rpercent = payment::revenuePercentage();
     $mearning = Payment::getPaymentsMonth();
     return $this->render('dashboard', ['dataProvider' => $DataProvider, 'events' => $events, 'journals' => $journals, 'photos' => $photos, 'wishlists' => $wishlists, 'RegisteredMembers' => $RegisteredMembers, 'orders' => $orders, 'payments' => $payments, 'months' => $months, 'epercent' => $epercent, 'earning' => $earning, 'revenue' => $revenue, 'rpercent' => $rpercent, 'mearning' => $mearning, 'famillies' => $famillies]);
 }
Пример #5
0
 /**
  * @return newsfeed generations array- DTR
  */
 public function getNews()
 {
     $user = Yii::$app->user->id;
     $notification = Notification::find()->where(['shared_id' => $user])->orderBy(['date' => SORT_DESC])->all();
     foreach ($notification as $news) {
         if ($news->type == 'event') {
             return Event::find()->where(['id' => $news->type_id]);
         } elseif ($news->type == 'activity') {
             return Activity::find()->where(['id' => $news->type_id]);
         } elseif ($news->type == 'journal') {
             return Journal::find()->where(['id' => $news->type_id]);
         } elseif ($news->type == 'wishlist') {
             return Wishlist::find()->where(['id' => $news->type_id]);
         } else {
             return Photos::find()->where(['id' => $news->type_id]);
         }
     }
 }
Пример #6
0
        <!-- gallery -->


        <div class="c-c gallery">
            <?php 
foreach ($result as $photo) {
    ?>
                <?php 
    if (!empty($photo->photo_preview) && file_exists('../web/uploads/previewphoto/' . $photo->photo_preview)) {
        $src = '/uploads/previewphoto/' . $photo->photo_preview;
    } else {
        $src = isset($photo->photos[0]) ? $photo->photos[0] : "#";
    }
    $photos = \app\models\Photos::find()->where("catalog_id = :catalog_id", [":catalog_id" => $photo['id']])->select("url_thumbnail")->asArray()->column();
    $photosCount = \app\models\Photos::find()->where("catalog_id = :catalog_id", [":catalog_id" => $photo['id']])->count("*");
    ?>
                <div class="c x1d4--d x1d3--t x1d2--m gallery-element">
                    <div class="photo-element new">
                        <a href="/photo/<?php 
    echo $photo['url'];
    ?>
">
                            <div class="preview">
                                <img src="<?php 
    echo $src;
    ?>
" class="r" alt="<?php 
    echo $photo['title'];
    ?>
">
Пример #7
0
<div class="g w1140 main">

    <article class="c-c">

        <!-- intro text -->
        <div class="c text-center inflated-top">
            <p><?php 
echo $model->description;
?>
</p>
        </div>
        <!-- intro text -->
        <?php 
// $ads = "test";
$ads = \app\components\widgets\AdsWidget::widget(['url' => 'photo-slider']);
$photos = \app\models\Photos::find()->where("catalog_id = :catalog_id", [':catalog_id' => $model->id])->orderBy('sort')->all();
?>
        <div class="c-c gallery">
            <?php 
foreach ($photos as $k => $photo) {
    ?>
                <div class="c x1d4--d x1d3--t x1d2--m gallery-element">
                    <div class="photo-element">
                        <div class="preview-photo" >
                            <a title="" href="<?php 
    echo $photo->url;
    ?>
" class="thumbnail">
                                <img src="<?php 
    echo $photo->url_thumbnail;
    ?>
Пример #8
0
 public function beforeDelete()
 {
     $photos = Photos::find()->where(['catalog_id' => $this->id])->all();
     //print_r($photos); die();
     foreach ($photos as $photo) {
         if (file_exists("../web" . $photo->url_thumbnail)) {
             unlink("../web" . $photo->url_thumbnail);
         }
         $config = ArrayHelper::map(Config::find()->all(), 'name', 'value');
         $s3 = new S3Client(['version' => 'latest', 'region' => 'us-west-2', 'credentials' => ['key' => $config['amazon_key'], 'secret' => $config['amazon_secret']]]);
         if ($this->storage == 2) {
             try {
                 $res = $s3->deleteObject(['Bucket' => $config['amazon_bucket'], 'Key' => 'photo/' . urldecode(mb_substr($photo->url, mb_strrpos($photo->url, '/') + 1))]);
             } catch (S3Exception $e) {
                 echo $e->getMessage();
                 Yii::$app->session->setFlash('error', $e->getMessage());
             }
         } else {
             if ($this->storage == 1) {
                 if (file_exists("../web" . $photo->url)) {
                     unlink("../web" . $photo->url);
                 }
             } else {
                 $arr = explode('/', $photo->url);
                 $f = array_pop($arr);
                 //  print_r($f); //die();
                 $this->ftp_delete($f);
             }
         }
     }
     return parent::beforeDelete();
     // TODO: Change the autogenerated stub
 }
Пример #9
0
 /**
  * Deletes an existing Photos model.
  * If deletion is successful, the browser will be redirected to the post page.
  * @param integer $id
  * @return mixed
  */
 public function actionDeletePhoto($id)
 {
     $photo = $this->findModelPhoto($id);
     $id_posts = $photo->id_posts;
     $photo->delete();
     return Yii::t("app/posts", 'Photos ({0})', [Photos::find()->where(['id_posts' => $id_posts])->count()]);
 }