Пример #1
0
 public static function create($name, $description)
 {
     $bean = R::dispense('gallery');
     $bean->userId = App::user()->id;
     $bean->created = R::isoDateTime();
     $gallery = new Gallery(null, $bean);
     return $gallery->setName($name)->setDescription($description)->save();
 }
Пример #2
0
<?php

use Enpowi\App;
use Enpowi\Modules\Module;
use Enpowi\Files\Gallery;
use Enpowi\Types;
Module::is();
$galleryId = App::paramInt('g');
$gallery = new Gallery($galleryId);
if ($gallery->exists()) {
    $images = App::paramFiles('files', 'Enpowi\\Files\\Image');
    foreach ($images as $i => $_image) {
        $image = Types::Files_Image($_image);
        if ($image->upload()) {
            $gallery->addImage($image);
        } else {
            echo -1;
            die;
        }
    }
    $gallery->save();
    echo 1;
} else {
    echo -1;
}
Пример #3
0
use Enpowi\Modules\DataOut;
Module::is();
$galleryId = App::paramInt('g');
$gallery = null;
$images = null;
$galleries = null;
$galleriesImages = null;
if ($galleryId > 0) {
    $possibleGallery = new Gallery($galleryId);
    if ($possibleGallery->userId === App::user()->id) {
        $gallery = $possibleGallery;
        $images = $gallery->images(App::paramInt('page'));
    }
} else {
    $galleriesImages = [];
    $galleries = Gallery::galleries(App::get()->user()->id, App::paramInt('page'));
    foreach ($galleries as $_gallery) {
        $images = $_gallery->images(1);
        if (isset($images[0])) {
            $galleriesImages[] = $images[0]->hash;
        }
    }
}
(new DataOut())->add('galleries', $galleries)->add('galleriesImages', $galleriesImages)->add('gallery', $gallery)->add('images', $images)->add('g', $galleryId)->bind();
?>
<title>{{session.siteName}} - Gallery</title>
<div
	v-module
	class="container">
	<!--galleries list-->
	<div
Пример #4
0
<?php

use Enpowi\App;
use Enpowi\Modules\Module;
use Enpowi\Files\Gallery;
Module::is();
$name = App::param('name');
$description = App::param('description');
if (!Gallery::isUnique($name)) {
    Module::paramRespond('name', 'Not unique');
} else {
    $id = Gallery::create($name, $description);
    Module::successRespond('g', $id);
}