Exemple #1
0
 public function testGet()
 {
     $list = new Gallery();
     $list->fromJson(self::$outputDir . self::$jsonName);
     $item = new GalleryItem("desc", "year", "pathToFull", "pathToThumb");
     $this->assertEquals($list->get($item->getName()), $item);
 }
Exemple #2
0
 public function deleteAll()
 {
     $config = (require ROOT . '/config/main.php');
     $gallery = new Gallery();
     $gallery->fromJson(ROOT . $config['images']['json']);
     $gallery->deleteAll();
     F3::reroute('upload');
 }
Exemple #3
0
 public static function build(array $cfg)
 {
     $loader = new GalleryLoader();
     $itemList = new Gallery();
     $itemList->fromJson(ROOT . $cfg['json']);
     $loader->setItemList($itemList);
     $itemHandler = new GalleryItemCreator();
     $itemHandler->setFullImageProps($cfg['full']);
     $itemHandler->setLowImageProps($cfg['low']);
     $loader->setItemHandler($itemHandler);
     return $loader;
 }
 public function actionIndex()
 {
     $mainSlider = Slider::find()->all();
     $gallery = Gallery::find()->all();
     $blog = Blog::find()->limit(2)->all();
     return $this->render('index', ['mainSlider' => $mainSlider, 'gallery' => $gallery, 'blog' => $blog]);
 }
 public function GetSingleGallery($id)
 {
     $images = Gallery::GetGalleryImages($id);
     $data["images"] = $images;
     $galleryDetails = Gallery::GetSingleGalleryInfo($id);
     $data["gallery_info"] = $galleryDetails;
     return view("single_portfolio", ["data" => $data]);
 }
Exemple #6
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $images = Gallery::slide();
     $news = News::latest(4);
     $pubs = Publication::latest();
     $trainings = Training::latest();
     $bio = Biography::orderBy('created_at', 'DESC')->first();
     return view('index', compact('images', 'news', 'pubs', 'bio', 'trainings'));
 }
Exemple #7
0
 public static function slide($n = 5)
 {
     $gal = Gallery::where('title_en', '=', 'slider')->where('slug', '=', 'slider')->first();
     // dd($gal);
     if (!$gal) {
         return [];
     }
     return $gal->media()->orderBy('created_at', 'DESC')->limit($n)->get();
 }
Exemple #8
0
 public function upload($id)
 {
     if ($this->validate()) {
         $it = 0;
         foreach ($this->imageFiles as $file) {
             $path = 'uploads/' . $id . 'n' . $it . '.' . $file->extension;
             $file->saveAs($path);
             $gallery = new Gallery();
             $gallery->id_tour = $id;
             $gallery->path = $path;
             $gallery->save(false);
             ++$it;
         }
         $img = Tour::findOne(['id' => $id]);
         $img->image = 'uploads/' . $id . 'n0' . '.' . $this->imageFiles[0]->extension;
         $img->save(false);
         return true;
     } else {
         return false;
     }
 }
 public function actionIndex()
 {
     $categoryModel = Category::find()->All();
     $projectModel = Project::find()->where(['show_in_index' => '1'])->limit(6)->all();
     $customerModel = Customer::find()->All();
     $applicationConfig = ApplicationConfig::find()->one();
     $newsModel = News::find()->where(['show_in_index' => '1'])->limit(2)->all();
     $galleryModel = Gallery::find()->orderBy(new Expression('rand()'))->limit(6)->all();
     $visitor = ApplicationConfig::findOne(1);
     $visitor->visitors_count = $visitor->visitors_count + 1;
     $visitor->save();
     return $this->render('index', ['categoryModel' => $categoryModel, 'projectModel' => $projectModel, 'customerModel' => $customerModel, 'applicationConfig' => $applicationConfig, 'newsModel' => $newsModel, 'galleryModel' => $galleryModel]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Gallery::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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title_en', $this->title_en])->andFilterWhere(['like', 'title_pt', $this->title_pt])->andFilterWhere(['like', 'summary_en', $this->summary_en])->andFilterWhere(['like', 'summary_pt', $this->summary_pt]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Gallery::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['sort' => SORT_ASC]]]);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'active' => $this->active, 'sort' => $this->sort]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
 public function actionLike($gid)
 {
     if ($id = intval(preg_replace('/\\D/', '', Yii::$app->request->post('id')))) {
         if ($image = Gallery::findOne($gid)->getBehavior('galleryBehavior')->getImage($id)) {
             /* @var GalleryImage $image */
             $result = 0;
             $liked = Yii::$app->request->cookies->getValue('liked', []);
             if (Yii::$app->request->post('liked') !== 'true') {
                 if ($image->liked > 0 && ($result = $image->LikedDown()) && ($key = array_search($id, $liked)) !== false) {
                     unset($liked[$key]);
                 }
             } else {
                 if (($result = $image->LikedUp()) && !in_array($id, $liked)) {
                     $liked[] = $id;
                     sort($liked);
                 }
             }
             if ($result) {
                 Yii::$app->response->cookies->add(new \yii\web\Cookie(['name' => 'liked', 'value' => $liked]));
             }
         }
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Gallery $gallery)
 {
     $gallery->delete();
     \Session::flash('message', 'Галлерея удалена');
     return redirect()->route('admin.gallery.index');
 }
 public function UploadGalleryImages($id)
 {
     if (isset($_POST["editGalleryInfoButton"])) {
         $title = $_POST["galleryTitle"];
         if (Input::hasFile("galleryPicture")) {
             $hasImage = true;
             $file = Input::file("galleryPicture");
             $folder = '/images/';
             $destinationPath = public_path() . $folder;
             $filename = str_random(6) . '_' . $file->getClientOriginalName();
             $uploadSuccess = $file->move($destinationPath, $filename);
             $image = $folder . $filename;
         } else {
             $image = "";
             $hasImage = false;
         }
         Gallery::UpdateGalleryInfo($id, $title, $image, $hasImage);
         return Redirect::to("admin/edit_gallery/" . $id);
     }
     if (isset($_POST["uploadImagesButton"])) {
         echo "uploading";
         $tmp_name_array = $_FILES['imagesToUpload']['tmp_name'];
         //get the temporary file names
         for ($i = 0; $i < count($tmp_name_array); $i++) {
             //traverse through them
             $name = "images/" . str_random(6) . '_' . $_FILES['imagesToUpload']['name'][$i];
             //upload file to server
             move_uploaded_file($tmp_name_array[$i], $name);
             Gallery::InsertImageToDB($id, $name);
         }
         return Redirect::back();
     }
     if (isset($_POST["deletePicsButton"])) {
         foreach ($_POST["imagesCheckboxGroup"] as $id) {
             $pd = Gallery::GetSingleImage($id);
             $img = $pd[0]->image_path;
             if (File::exists(public_path() . $img)) {
                 File::delete(public_path() . $img);
             }
             Gallery::DeleteImage($id);
         }
         return Redirect::back();
     }
 }
Exemple #15
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $media = Media::find($id);
     $galleries = Gallery::all()->lists('title_en', 'id');
     return view('media.edit', compact('media', 'galleries'));
 }
 /**
  * Finds the Gallery model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Gallery the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Gallery::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionIndex()
 {
     $galleryModel = Gallery::find()->joinWith('category', 'category.category_id = gallery.category_id')->all();
     return $this->render('index', ['galleryModel' => $galleryModel, 'categoryModel' => CategoryGallery::find()->all()]);
 }
Exemple #18
0
 public function actionTmp()
 {
     $model = Gallery::find()->where(['id_tour' => '43'])->all();
     return $this->render('tmp', ['model' => $model]);
 }
Exemple #19
0
Route::resource('services', 'ServicesController');
/**
 *
 * Static page
 */
$router->get('/page/{spage}', ['uses' => 'StaticPageController@index', 'as' => 'static-page']);
$router->bind('spage', function ($slug) {
    return \App\Models\StaticPage::where('slug', '=', $slug)->firstOrFail();
});
/**
 *
 * Gallery
 */
$router->get('/gallery/{gslug}', ['uses' => 'GalleryController@index', 'as' => 'gallery.index']);
$router->bind('gslug', function ($slug) {
    return \App\Models\Gallery::where('slug', '=', $slug)->firstOrFail();
});
/** ADMIN */
$router->get('/admin', function () {
    return \Illuminate\Support\Facades\Redirect::route('admin.dashboard.index');
});
$router->bind('banner', function ($id) {
    return App\Models\Banner::find($id);
});
$router->bind('services', function ($id) {
    return App\Models\Services::find($id);
});
Route::get('/ipn', 'ZaLaravel\\LaravelPayeer\\Controllers\\IpnPayeerController@getResult');
$router->group(['namespace' => 'AdminControllers', 'prefix' => 'admin', 'middleware' => 'admin'], function ($router) {
    Route::resource('catshop', 'AdminShopCategoriesController');
    Route::resource('shops', 'AdminShopsController');
 public function actionDeleteGalleryImage()
 {
     $id = (int) $_POST['id'];
     $model = Gallery::findOne($id);
     if ($model != null) {
         FileUploader::delete($model->image, "product");
         $model->delete();
     }
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function publish($slug)
 {
     $gallery = Gallery::findBySlug($slug);
     $gallery->update(['is_published' => $gallery->is_published ? 0 : 1]);
     return Redirect::route('galleries.admin');
 }
Exemple #22
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGalleries()
 {
     return $this->hasMany(Gallery::className(), ['race_id' => 'id']);
 }