/** * Render view. * * @return string */ public function content() { ob_start(); // Get shown images if ($this->show_pending) { // Show pending images $images = $this->gallery->find_images_pending($this->can_approve ? null : self::$_user); $radios = array(); if ($this->can_approve) { $radios['approve'] = __('Approve'); } $radios['deny'] = $this->can_approve ? __('Deny') : __('Delete'); $radios['wait'] = __('Wait'); ?> <header class="well sticky"> <?php if ($this->can_approve) { echo __('Approve'), ': <var class="approve"">0</var>, '; echo __('Deny'), ': <var class="deny"">0</var>, '; } else { echo __('Delete'), ': <var class="deny"">0</var>, '; } echo __('Wait'), ': <var class="wait">', count($images), '</var><br />'; ?> </header> <?php } else { // Show approved images $images = $this->gallery->images(); } // Add pending images form? if ($this->show_pending) { echo Form::open(null, array('id' => 'form-image-approval', 'class' => 'form-horizontal')); } $copyright = $multiple = null; foreach ($images as $image) { // Add copyright if ($image->author_id != $copyright) { $copyright = $image->author_id; if ($multiple) { // Not first copyright ?> </ul> <?php } else { // First copyright $multiple = true; } ?> <header>© <?php echo HTML::user($copyright); ?> </header> <ul class="thumbnails"> <?php } // Copyright ?> <li class="span2"> <?php echo HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($this->gallery), 'id' => $image->id, 'action' => $this->show_pending ? 'approve' : '')), HTML::image($image->get_url('thumbnail', $this->gallery->dir)), $image->description ? array('class' => 'thumbnail', 'title' => HTML::chars($image->description)) : array('class' => 'thumbnail')); if (!$this->show_pending) { // Info echo '<i class="icon-comment icon-white"></i> ' . (int) $image->comment_count; echo '<i class="icon-eye-open icon-white"></i> ' . (int) $image->view_count; } else { // Pending image form echo Form::radios_wrap('image_id[' . $image->id . ']', $radios, 'wait'); } ?> </li> <?php } // Images ?> </ul> <?php // Form controls if ($this->show_pending) { ?> <fieldset class="form-actions"> <?php echo Form::radios_wrap('all', $radios, null, null, __('For all images'), null, null, 'inline'); echo Form::csrf(); echo Form::button('approve', __('Save'), array('type' => 'submit', 'class' => 'btn btn-success btn-large')), ' '; echo HTML::anchor(Route::url('galleries', array('action' => 'approval')), __('Cancel'), array('class' => 'cancel')); ?> </fieldset> <?php echo Form::close(); ?> <script> head.ready('jquery', function() { // Calculate totals function totals() { $.each([ 'approve', 'deny', 'wait' ], function totals() { $('var.' + this).text($('input[name!=all][value=' + this + ']:checked').length); }); } // Actions for all images $('form input[name=all]').change(function onChangeAll() { $('form input[value=' + $(this).val() + ']').attr('checked', 'checked'); totals(); }); // Single image actions $('form input[name^=image_id]').change(function onChangeOne() { $('input[name=all]').removeAttr('checked'); totals(); }); }); </script> <?php } return ob_get_clean(); }
/** * Set gallery specific title and actions. * * @param Model_Gallery $gallery */ protected function _set_gallery(Model_Gallery $gallery) { // Set title $images = count($gallery->images()); $this->view->tab = 'gallery'; $this->view->title = $gallery->name; $this->view->subtitle = __($images == 1 ? ':images image' : ':images images', array(':images' => $images)) . ' - ' . HTML::time(Date::format('DMYYYY', $gallery->date), $gallery->date, true); // Set actions $this->view->tabs['galleries']['link'] = Route::url('galleries', array('action' => 'browse', 'year' => date('Y', $gallery->date), 'month' => date('m', $gallery->date))); if ($this->view->actions['upload'] && Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_UPLOAD, self::$user)) { $this->view->actions['upload']['link'] = Route::model($gallery, 'upload'); } $this->view->tabs['gallery'] = array('link' => Route::model($gallery), 'text' => '<i class="icon-camera icon-white"></i> ' . __('Gallery')); if ($event = $gallery->event()) { $this->view->tabs[] = array('link' => Route::model($event), 'text' => '<i class="icon-calendar icon-white"></i> ' . __('Event') . ' »'); } }
/** * Render view. * * @return string */ public function content() { ob_start(); $images = $this->gallery->images(); $copyright = $multiple = null; foreach ($images as $image) { // Add copyright if ($image->author_id != $copyright) { $copyright = $image->author_id; if ($multiple) { // Not first copyright ?> </div> <?php } else { // First copyright $multiple = true; } ?> <header><h3>© <?php echo HTML::user($copyright); ?> </h3></header> <div class="row"> <?php } // Copyright ?> <article class="col-xs-6 col-md-4 col-lg-3"> <div class="thumbnail"> <?php echo HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($this->gallery), 'id' => $image->id, 'action' => '')), HTML::image($image->get_url('thumbnail', $this->gallery->dir))); ?> <small class="stats label label-default"> <?php echo (int) $image->view_count; ?> <i class="fa fa-eye"></i> <?php if ($image->comment_count) { ?> <?php echo (int) $image->comment_count; ?> <i class="fa fa-comment"></i> <?php } ?> </small> </div> </article> <?php } ?> </div> <?php return ob_get_clean(); }