Ejemplo n.º 1
0
 public function render_inputs($details = array())
 {
     if (!class_exists('PerchGallery_Albums')) {
         require_once PerchUtil::file_path(PERCH_PATH . '/addons/apps/perch_gallery/PerchGallery_Albums.class.php');
         require_once PerchUtil::file_path(PERCH_PATH . '/addons/apps/perch_gallery/PerchGallery_Album.class.php');
     }
     $id = $this->Tag->input_id();
     $val = '';
     if (isset($details[$id]) && $details[$id] != '') {
         $json = $details[$id];
         $val = $json['albumSlug'];
     }
     $API = new PerchAPI(1, 'perch_gallery');
     $Albums = new PerchGallery_Albums($API);
     $albums = $Albums->return_all();
     $opts = array();
     $opts[] = array('label' => '', 'value' => '');
     if (PerchUtil::count($albums)) {
         foreach ($albums as $Album) {
             $opts[] = array('label' => $Album->albumTitle(), 'value' => $Album->albumSlug());
         }
     }
     if (PerchUtil::count($opts)) {
         $s = $this->Form->select($id, $opts, $val);
     } else {
         $s = '-';
     }
     return $s;
 }
Ejemplo n.º 2
0
<?php

include 'PerchGallery_Albums.class.php';
include 'PerchGallery_Album.class.php';
include 'PerchGallery_Images.class.php';
include 'PerchGallery_Image.class.php';
include 'PerchGallery_ImageVersions.class.php';
include 'PerchGallery_ImageVersion.class.php';
$API = new PerchAPI(1.0, 'perch_gallery');
$Lang = $API->get('Lang');
$Albums = new PerchGallery_Albums($API);
$albums = $Albums->return_all();
$Images = new PerchGallery_Images($API);
$images = $Images->get_recent_for_dashboard(5);
?>
<div class="widget">
	<h2>
		<?php 
echo $Lang->get('Gallery');
?>
		<a href="<?php 
echo PerchUtil::html(PERCH_LOGINPATH . '/addons/apps/perch_gallery/edit/');
?>
" class="add button"><?php 
echo $Lang->get('Add Album');
?>
</a>
	</h2>
	<div class="bd">
		<?php 
if (PerchUtil::count($images)) {
<?php

$GalleryAlbums = new PerchGallery_Albums($API);
$Albums = $GalleryAlbums;
$Images = new PerchGallery_Images($API);
$PerchGallery_ImageVersions = new PerchGallery_ImageVersions($API);
$message = false;
$new_image = false;
$HTML = $API->get('HTML');
if (isset($_GET['album_id']) && $_GET['album_id'] != '') {
    $albumID = (int) $_GET['album_id'];
    $Album = $Albums->find($albumID);
}
if (isset($_GET['id']) && $_GET['id'] != '') {
    $imageID = (int) $_GET['id'];
    $Image = $Images->find($imageID);
    $details = $Image->to_array();
    $heading1 = 'Editing an Image';
    $heading2 = 'Edit Image';
} else {
    $Image = false;
    $imageID = false;
    $details = array();
    $details['albumID'] = $albumID;
    $heading1 = 'Adding a New Image';
    $heading2 = 'Add image';
}
$Template = $API->get('Template');
$Template->set('gallery/image.html', 'gallery');
$result = false;
$Form = $API->get('Form');
<?php

$Albums = new PerchGallery_Albums($API);
$Images = new PerchGallery_Images($API);
$Versions = new PerchGallery_ImageVersions($API);
$HTML = $API->get('HTML');
$Template = $API->get('Template');
$Template->set('gallery/image.html', 'gallery');
if (!$CurrentUser->has_priv('perch_gallery.image.upload')) {
    die('Your role does not have permission to upload images.');
}
$message = false;
if (isset($_GET['album_id']) && $_GET['album_id'] != '') {
    $albumID = (int) $_GET['album_id'];
}
$apps_php = file_get_contents(PerchUtil::file_path(PERCH_PATH . '/config/apps.php'));
if (!strpos($apps_php, 'perch_gallery')) {
    $message = $HTML->warning_message('You need to add the Gallery app to your %sconfig/apps.php%s file.', '<code>', '</code>');
}
$Form = $API->get('Form');
if ($Form->submitted()) {
    $bucket_name = 'default';
    $Settings = PerchSettings::fetch();
    $bucket_mode = $Settings->get('perch_gallery_bucket_mode')->val();
    if ($bucket_mode == '') {
        $bucket_mode = 'single';
    }
    switch ($bucket_mode) {
        case 'dynamic':
            $Album = $Albums->find($albumID);
            if (is_object($Album)) {
Ejemplo n.º 5
0
function perch_gallery_album_field($slug, $field, $return = false)
{
    $slug = rtrim($slug, '/');
    $API = new PerchAPI(1.0, 'perch_gallery');
    $Albums = new PerchGallery_Albums($API);
    $Album = $Albums->find_by_slug($slug);
    $r = false;
    $encode = true;
    if (is_object($Album)) {
        $field = $Album->{$field}();
        if (is_array($field)) {
            if (isset($field['processed'])) {
                $r = $field['processed'];
                $encode = false;
            } elseif (isset($field['_default'])) {
                $r = $field['_default'];
            } else {
                $r = $field;
            }
        } else {
            $r = $field;
        }
    }
    if ($return) {
        return $r;
    }
    if ($encode) {
        $HTML = $API->get('HTML');
        echo $HTML->encode($r);
    } else {
        echo $r;
    }
}
<?php

$GalleryAlbums = new PerchGallery_Albums($API);
$HTML = $API->get('HTML');
$Form = $API->get('Form');
$Form->require_field('albumID', 'Required');
$message = false;
if (isset($_GET['id']) && $_GET['id'] != '') {
    $Album = $GalleryAlbums->find($_GET['id']);
} else {
    PerchUtil::redirect($API->app_path());
}
if ($Form->submitted()) {
    $postvars = array('albumID');
    $data = $Form->receive($postvars);
    $Album = $GalleryAlbums->find($data['albumID']);
    if (is_object($Album)) {
        $Album->delete();
        PerchUtil::redirect($API->app_path());
    } else {
        $message = $HTML->failure_message('Sorry, that album could not be deleted.');
    }
}
$details = $Album->to_array();
<?php

$HTML = $API->get('HTML');
$GalleryAlbums = new PerchGallery_Albums($API);
$Form = $API->get('Form');
if ($Form->submitted()) {
    $items = $Form->find_items('a-');
    if (PerchUtil::count($items)) {
        foreach ($items as $albumID => $albumOrder) {
            $Album = $GalleryAlbums->find($albumID);
            if (is_object($Album)) {
                $data = array('albumOrder' => $albumOrder);
                $Album->update($data);
            }
        }
        $Alert->set('success', $Lang->get('Album orders successfully updated.'));
    }
}
$albums = $GalleryAlbums->return_all();
Ejemplo n.º 8
0
<?php

$HTML = $API->get('HTML');
$GalleryAlbums = new PerchGallery_Albums($API);
$albums = $GalleryAlbums->return_all();
// Install
if ($albums == false) {
    $GalleryAlbums->attempt_install();
}
<?php

$GalleryAlbums = new PerchGallery_Albums($API);
$message = false;
$HTML = $API->get('HTML');
if (isset($_GET['id']) && $_GET['id'] != '') {
    $albumID = (int) $_GET['id'];
    $Album = $GalleryAlbums->find($albumID);
    $details = $Album->to_array();
    $heading1 = 'Editing Album Options';
    $heading2 = 'Edit Album';
} else {
    $Album = false;
    $albumID = false;
    $details = array();
    $heading1 = 'Creating a New Album';
    $heading2 = 'Add Album';
    if (!$CurrentUser->has_priv('perch_gallery.album.create')) {
        die('Your role does not have permission to create new albums.');
    }
}
$Template = $API->get('Template');
$Template->set('gallery/album.html', 'gallery');
$result = false;
$Form = $API->get('Form');
$Form->handle_empty_block_generation($Template);
$Form->require_field('albumTitle', 'Required');
$Form->set_required_fields_from_template($Template, $details);
if ($Form->submitted()) {
    $postvars = array('albumID', 'albumTitle', 'albumOrder');
    $data = $Form->receive($postvars);
Ejemplo n.º 10
0
<?php

$GalleryAlbums = new PerchGallery_Albums($API);
$message = false;
$HTML = $API->get('HTML');
if (isset($_GET['id']) && $_GET['id'] != '') {
    $albumID = (int) $_GET['id'];
    $Album = $GalleryAlbums->find($albumID);
    $details = $Album->to_array();
    $heading1 = 'Editing Album Options';
    $heading2 = 'Edit Album';
} else {
    $Album = false;
    $albumID = false;
    $details = array();
    $heading1 = 'Creating a New Album';
    $heading2 = 'Add Album';
    if (!$CurrentUser->has_priv('perch_gallery.album.create')) {
        die('Your role does not have permission to create new albums.');
    }
}
$Template = $API->get('Template');
$Template->set('gallery/album.html', 'gallery');
$result = false;
$Form = $API->get('Form');
$Form->require_field('albumTitle', 'Required');
$Form->set_required_fields_from_template($Template);
if ($Form->submitted()) {
    $postvars = array('albumID', 'albumTitle', 'albumOrder');
    $data = $Form->receive($postvars);
    $dynamic_fields = $Form->receive_from_template_fields($Template, $details);
Ejemplo n.º 11
0
function perch_gallery_album_details($slug, $opts = array(), $return = false)
{
    $default_opts = array('template' => 'album.html', 'skip-template' => false);
    $opts = array_merge($default_opts, $opts);
    if ($opts['skip-template']) {
        $return = true;
    }
    $API = new PerchAPI(1.0, 'perch_gallery');
    $Albums = new PerchGallery_Albums($API);
    $Album = $Albums->find_by_slug($slug);
    if (is_object($Album)) {
        if ($opts['skip-template']) {
            return $Album->to_array();
        }
        $Template = $API->get('Template');
        $Template->set('gallery/' . $opts['template'], 'gallery');
        $r = $Template->render($Album);
        if ($return) {
            return $r;
        }
        echo $r;
        return;
    }
    return false;
}