Example #1
0
 /**
  * Action: gallery
  */
 public function action_gallery()
 {
     /** @var  Model_Gallery  $gallery */
     $gallery_id = (int) $this->request->param('id');
     $gallery = Model_Gallery::factory($gallery_id);
     if (!$gallery->loaded()) {
         throw new Model_Exception($gallery, $gallery_id);
     }
     // Are we approving pending images?
     if ($this->request->action() == 'pending') {
         // Can we see galleries with un-approved images?
         Permission::required($gallery, Model_Gallery::PERMISSION_APPROVE_WAITING, self::$user);
         // Can we see all of them and approve?
         $approve = Permission::has($gallery, Model_Gallery::PERMISSION_APPROVE, self::$user);
         // Handle images?
         if ($_POST && Security::csrf_valid()) {
             $pending = $gallery->find_images_pending($approve ? null : self::$user);
             $images = (array) Arr::get($_POST, 'image_id');
             $authors = array();
             if (count($pending) && count($images)) {
                 foreach ($pending as $image) {
                     $action = Arr::Get($images, $image->id, 'wait');
                     switch ($action) {
                         case 'approve':
                             if ($approve) {
                                 $author = $image->author();
                                 //$gallery->image_count++;
                                 $authors[$author['id']] = $author['username'];
                                 $image->state(AutoModeler::STATE_LOADED);
                                 $image->status = Model_Image::VISIBLE;
                                 $image->save();
                             }
                             break;
                         case 'deny':
                             $gallery->remove('image', $image->id);
                             $gallery->image_count--;
                             $image->delete();
                             break;
                     }
                 }
                 // Admin actions
                 if ($approve) {
                     // Set default image if none set
                     if (!$gallery->default_image_id) {
                         $gallery->default_image_id = $gallery->images()->current()->id;
                     }
                     $gallery->update_copyright();
                     $gallery->updated = time();
                 }
                 $gallery->save();
                 // Redirect to normal gallery if all images approved/denied
                 if (!count($gallery->find_images_pending($approve ? null : self::$user))) {
                     $this->request->redirect(Route::model($gallery));
                 } else {
                     $this->request->redirect(Route::model($gallery, 'pending'));
                 }
             }
         }
     } else {
         Permission::required($gallery, Model_Gallery::PERMISSION_READ, self::$user);
     }
     // Build page
     $this->view = View_Page::factory(__('Gallery'));
     $this->_set_page_actions(Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_CREATE, self::$user));
     $this->_set_gallery($gallery);
     if (Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_UPDATE, self::$user)) {
         $this->view->actions[] = array('link' => Route::model($gallery, 'update'), 'text' => '<i class="icon-refresh icon-white"></i> ' . __('Update gallery'));
     }
     // Share
     if ($this->request->action() !== 'pending' && Kohana::$config->load('site.facebook')) {
         Anqh::open_graph('title', __('Gallery') . ': ' . $gallery->name);
         Anqh::open_graph('url', URL::site(Route::get('gallery')->uri(array('id' => $gallery->id, 'action' => '')), true));
         Anqh::open_graph('description', __($gallery->image_count == 1 ? ':images image' : ':images images', array(':images' => $gallery->image_count)) . ' - ' . date('l ', $gallery->date) . Date::format(Date::DMY_SHORT, $gallery->date) . ($event ? ' @ ' . $event->venue_name : ''));
         if ($event && ($image = $event->flyer_front())) {
             Anqh::open_graph('image', URL::site($image->get_url('thumbnail'), true));
         } else {
             if ($image = $gallery->default_image()) {
                 Anqh::open_graph('image', URL::site($image->get_url('thumbnail'), true));
             }
         }
     }
     Anqh::share(true);
     $this->view->add(View_Page::COLUMN_SIDE, $this->section_share());
     // Event info
     if ($event = $gallery->event()) {
         // Event flyer
         $this->view->add(View_Page::COLUMN_SIDE, $this->section_event_image($event));
         // Event info
         $this->view->add(View_Page::COLUMN_SIDE, $this->section_event_info($event));
     }
     // Pictures
     $this->view->add(View_Page::COLUMN_MAIN, $this->section_gallery_thumbs($gallery, $this->request->action() == 'pending', isset($approve) ? $approve : null));
 }
Example #2
0
File: edit.php Project: anqh/anqh
    /**
     * Render content.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        ?>

<div id="preview"></div>

<?php 
        echo Form::open(null, array('id' => 'form-event', 'class' => 'row'));
        ?>

<div class="col-md-8">

	<?php 
        if ($this->event_errors || $this->venue_errors) {
            ?>
	<div class="alert alert-danger">
		<strong><?php 
            echo __('Error happens!');
            ?>
</strong>
		<ul class="">
			<?php 
            foreach ((array) $this->event_errors as $error) {
                ?>
			<li><?php 
                echo $error;
                ?>
</li>
			<?php 
            }
            ?>
			<?php 
            foreach ((array) $this->venue_errors as $error) {
                ?>
			<li><?php 
                echo __('Venue');
                ?>
: <?php 
                echo $error;
                ?>
</li>
			<?php 
            }
            ?>
		</ul>
	</div>
	<?php 
        }
        ?>

	<fieldset id="fields-primary">
		<?php 
        echo Form::input_wrap('name', $this->event->name, array('class' => 'input-lg'), __('Name'), Arr::get($this->event_errors, 'name'), __("Please don't use dates in the name, looks nasty everywhere as the date is usually shown automagically."));
        ?>

		<?php 
        echo Form::textarea_wrap('info', $this->event->info, array('class' => 'input-lg', 'rows' => 20), true, __('Information'), Arr::get($this->event_errors, 'info'), __('Remember, only the first few rows are visible in the calendar view.'), true);
        ?>
	</fieldset>

	<fieldset>
		<?php 
        echo Form::button('save', __('Save event'), array('type' => 'submit', 'class' => 'btn btn-success btn-lg'));
        ?>
		<?php 
        echo Form::button('preview', __('Preview'), array('class' => 'btn btn-default btn-lg', 'data-content-class' => '*', 'data-prepend' => '#preview'));
        ?>
		<?php 
        echo $this->cancel ? HTML::anchor($this->cancel, __('Cancel'), array('class' => 'cancel')) : '';
        ?>

		<?php 
        echo Form::csrf();
        ?>
		<?php 
        echo Form::hidden('latitude', $this->venue->latitude, array('data-geo' => 'lat'));
        ?>
		<?php 
        echo Form::hidden('longitude', $this->venue->longitude, array('data-geo' => 'lng'));
        ?>
		<?php 
        echo Form::hidden('city', $this->event->city_name, array('data-geo' => 'locality'));
        ?>
		<?php 
        echo Form::hidden('venue_id', $this->venue->id);
        ?>
		<?php 
        echo Form::hidden('foursquare_id', $this->venue->foursquare_id);
        ?>
	</fieldset>
</div>

<div class="col-md-4">

	<fieldset id="fields-when" class="row form-inline">
		<div class="col-md-3">
			<?php 
        echo Form::input_wrap('stamp_begin[date]', is_numeric($this->event->stamp_begin) ? Date::format('DMYYYY', $this->event->stamp_begin) : $this->event->stamp_begin, array('class' => 'date', 'maxlength' => 10, 'size' => 7, 'placeholder' => 'd.m.yyyy'), __('From'), Arr::Get($this->event_errors, 'stamp_begin'));
        ?>
		</div>

		<div class="col-md-3">
			<?php 
        echo Form::select_wrap('stamp_begin[time]', array_reverse(Date::hours_minutes(30, true)), is_numeric($this->event->stamp_begin) ? Date::format('HHMM', $this->event->stamp_begin) : (empty($this->event->stamp_begin) ? '22:00' : $this->event->stamp_begin), array('class' => 'time'), '&nbsp;', Arr::get($this->event_errors, 'stamp_begin'));
        ?>
		</div>

		<div class="col-md-3">
			<?php 
        echo Form::select_wrap('stamp_end[time]', Date::hours_minutes(30, true), is_numeric($this->event->stamp_end) ? Date::format('HHMM', $this->event->stamp_end) : (empty($this->event->stamp_end) ? '04:00' : $this->event->stamp_end), array('class' => 'time'), __('To'), Arr::get($this->event_errors, 'stamp_end'));
        ?>
		</div>

		<div class="col-md-3">
			<?php 
        echo Form::input_wrap('stamp_end[date]', is_numeric($this->event->stamp_end) ? Date::format('DMYYYY', $this->event->stamp_end) : $this->event->stamp_end, array('class' => 'date', 'maxlength' => 10, 'size' => 7, 'placeholder' => 'd.m.yyyy'), '&nbsp;', Arr::Get($this->event_errors, 'stamp_end'));
        ?>
		</div>
	</fieldset>

	<br>

	<fieldset id="fields-venue" class="row">
		<div class="col-md-12">
			<?php 
        echo Form::input_wrap('city_name', $this->event->city_name, null, __('City'), Arr::get($this->event_errors, 'city_name'));
        ?>
		</div>

		<div class="col-md-7">
			<?php 
        echo Form::input_wrap('venue_name', $this->event->venue_name, (bool) $this->event->venue_hidden ? array('disabled') : null, __('Venue'), Arr::get($this->event_errors, 'venue_name'));
        ?>
		</div>

		<div class="col-md-5">
			<br>
			<?php 
        echo Form::checkbox_wrap('venue_hidden', 'true', (bool) $this->event->venue_hidden, array('id' => 'field-ug'), __('Underground'));
        ?>
		</div>

		<div class="col-md-12 venue-placeholder hidden">
			<label><?php 
        echo __('Venue');
        ?>
</label>
			<p>
				<span class="venue-name"><?php 
        echo $this->event->venue_name;
        ?>
</span>,
				<span class="venue-city"><?php 
        echo $this->event->city_name;
        ?>
</span>
				<a href="#venue"><?php 
        echo __('Change');
        ?>
</a>
			</p>
		</div>
	</fieldset>

	<div id="map" class="well"></div>

	<fieldset>
		<?php 
        if (!$this->event->flyer_id) {
            echo Form::input_wrap('flyer', $this->event->flyer_url, array('type' => 'url', 'placeholder' => 'http://'), __('Flyer'), $this->flyer_error, __('If you have the flyer only locally you can upload it after saving the event.'));
        }
        ?>

		<?php 
        echo Form::input_wrap('url', $this->event->url, array('type' => 'url', 'placeholder' => 'http://'), __('Homepage'), Arr::get($this->event_errors, 'url'));
        ?>
	</fieldset>

	<fieldset id="fields-tickets" class="row">
		<div class="col-md-4">
			<?php 
        echo Form::input_wrap('price', $this->event->price, $this->event->price === '0.00' ? array('disabled', 'type' => 'number', 'min' => 0, 'step' => 0.5) : array('type' => 'number', 'min' => 0, 'step' => 0.5), __('Tickets'), Arr::get($this->event_errors, 'tickets'), null, '&euro;');
        ?>
		</div>

		<div class="col-md-8">
			<br>
			<?php 
        echo Form::checkbox_wrap('free', 'true', $this->event->price === '0.00', array('id' => 'field-free'), __('Free entry'));
        ?>
		</div>

		<div class="col-md-12">
			<?php 
        echo Form::input_wrap('ticket_url', $this->event->ticket_url, array('placeholder' => 'http://'), __('Buy tickets from'), Arr::get($this->event_errors, 'ticket_url'));
        ?>
		</div>

		<div class="col-md-5">
			<?php 
        echo Form::input_wrap('age', $this->event->age, array('type' => 'number', 'min' => 0, 'max' => 50, 'maxlength' => 3), __('Age limit'), Arr::get($this->event_errors, 'age'), null, __('years'));
        ?>
		</div>
	</fieldset>

	<fieldset id="fields-music">
		<?php 
        echo Form::checkboxes_wrap('tag', $this->tags(), $this->event->tags(), array('class' => 'block-grid three-up'), __('Music'), $this->event_errors);
        ?>
	</fieldset>
</div>

		<?php 
        echo Form::close();
        echo $this->javascript();
        return ob_get_clean();
    }