/** * Render view. * * @return string */ public function content() { ob_start(); if ($this->image) { $image = HTML::image(is_string($this->image) ? $this->image : $this->image->get_url(), array('width' => 290)); ?> <div id="slideshow-image"> <?php echo isset($this->link) && $this->link ? HTML::anchor($this->link, $image) : $image; ?> </div> <?php } else { ?> <div class="well"> <?php echo __('No images yet.'); ?> </div> <?php } return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { ob_start(); echo '<figure>', HTML::image($this->image->get_url(Model_Image::SIZE_THUMBNAIL)), '</figure>'; // Tagged people $notes = $this->image->notes(); if (count($notes)) { $names = array(); /** @var Model_Image_Note $note */ foreach ($notes as $note) { $user = $note->user(); $names[] = $user ? HTML::user($user['username']) : HTML::chars($note->name); } echo implode(', ', $names); } // Copyright if ($this->image->author_id) { echo '<br />© ', HTML::user($this->image->author_id); } // Comments if ($this->image->comment_count) { echo '<span class="stats"><i class="icon-comment"></i> ' . $this->image->comment_count . '</span>'; } return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { ob_start(); echo '<figure>', HTML::image($this->image->get_url(Model_Image::SIZE_THUMBNAIL)), '</figure>'; // Comments if ($this->image->comment_count) { echo '<span class="stats"><i class="icon-comment"></i> ' . $this->image->comment_count . '</span>'; } return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { ob_start(); ?> <div class="image"> <figure> <?php echo HTML::image($this->image->get_url()); ?> </figure> </div> <?php return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { ob_start(); echo '<figure>', HTML::image($this->image->get_url(Model_Image::SIZE_THUMBNAIL)), '</figure>'; // Tagged people if ($this->image->description) { $names = array(); foreach (explode(',', $this->image->description) as $name) { $names[] = HTML::user(trim($name)); } echo __('In picture: :users', array(':users' => implode(', ', $names))); } // Copyright if ($this->image->author_id) { echo '<br />© ', HTML::user($this->image->author_id); } // Comments if ($this->image->comment_count) { echo '<span class="stats"><i class="icon-comment"></i> ' . $this->image->comment_count . '</span>'; } return ob_get_clean(); }
/** * Render EXIF info. * * @return array */ public function exif() { // Basic info $info = array('<span>©</span> ' . __('Copyright') => $this->image->author_id ? HTML::user($this->image->author_id) : null, '<i class="fa fa-fw fa-upload"></i> ' . __('Added') => HTML::time(Date::format('DMYYYY_HM', $this->image->created), $this->image->created), '<i class="fa fa-fw fa-comment"></i> ' . __('Comments') => (int) $this->image->comment_count, '<i class="fa fa-fw fa-eye"></i> ' . __('Views') => (int) $this->image->view_count); // EXIF info if ($exif = $this->image->exif()) { if ($exif->make || $exif->model) { $info['<i class="fa fa-fw fa-camera-retro"></i> ' . __('Camera')] = ($exif->make ? HTML::chars($exif->make) : '') . ($exif->model ? ($exif->make ? '<br />' : '') . HTML::chars($exif->model) : ''); } if ($exif->exposure) { $info['<i class="fa fa-fw fa-sun-o"></i> ' . __('Shutter Speed')] = HTML::chars($exif->exposure); } if ($exif->aperture) { $info['<i class="fa fa-fw fa-circle-o"></i> ' . __('Aperture')] = HTML::chars($exif->aperture); } if ($exif->focal) { $info['<i class="fa fa-fw fa-road"></i> ' . __('Focal Length')] = HTML::chars($exif->focal); } if ($exif->iso) { $info['<span class="iso fa fa-fw">iso</span> ' . __('ISO Speed')] = HTML::chars($exif->iso); } if ($exif->lens) { $info['<i class="fa fa-fw fa-cd"></i> ' . __('Lens')] = HTML::chars($exif->lens); } if ($exif->flash) { $info['<i class="fa fa-fw fa-bolt"></i> ' . __('Flash')] = HTML::chars($exif->flash); } if ($exif->program) { $info['<i class="fa fa-fw fa-cloud"></i> ' . __('Program')] = HTML::chars($exif->program); } if ($exif->metering) { $info['<i class="fa fa-fw fa-th"></i> ' . __('Metering')] = HTML::chars($exif->metering); } if ($exif->latitude) { $info['<i class="fa fa-fw fa-arrows-h"></i> ' . __('Latitude')] = HTML::chars($exif->latitude); } if ($exif->longitude) { $info['<i class="fa fa-fw fa-arrows-v"></i> ' . __('Longitude')] = HTML::chars($exif->longitude); } if ($exif->altitude) { $info['<i class="fa fa-fw fa-long-arrow-up"></i> ' . __('Altitude')] = HTML::chars($exif->altitude) . 'm'; } if ($exif->taken) { $info['<i class="fa fa-fw fa-calendar"></i> ' . __('Taken')] = Date::format('DMYYYY_HM', $exif->taken); } } // Original image $info['<i class="fa fa-fw fa-external-link"></i> ' . __('Original')] = HTML::anchor($this->image->get_url(Model_Image::SIZE_ORIGINAL), sprintf('%d×%d <small>(%s)</small>', $this->image->original_width, $this->image->original_height, Text::bytes($this->image->original_size, 'kB')), array('target' => '_blank', 'title' => __('Open in new tab'))); return $info; }
/** * Prepare venue for data array. * * @param Model_Venue $venue * @param array $fields * @return array */ protected function _prepare_venue(Model_Venue $venue, array $fields = null) { $data = array(); if (!$fields) { $fields = self::$_fields; } foreach ($fields as $field) { switch ($field) { // Raw value case 'id': case 'name': case 'description': case 'hours': case 'address': case 'zip': case 'info': case 'latitude': case 'longitude': case 'created': case 'modified': case 'foursquare_id': case 'foursquare_category_id': $data[$field] = $venue->{$field}; break; // Custom value // Custom value case 'city': $data[$field] = $venue->city_name; break; case 'default_image': $image = new Model_Image($venue->default_image_id); $data[$field] = $image->loaded() ? $image->get_url() : ''; break; case 'homepage': $data[$field] = $venue->url; break; case 'url': $data[$field] = URL::site(Route::model($venue), true); break; } } return $data; }
/** * Prepare user for data array * * @param Model_User $user * @param array $fields * @return array */ protected function _prepare_user(Model_User $user, array $fields = null) { $data = array(); empty($fields) and $fields = self::$_fields; foreach ($fields as $field) { switch ($field) { // Raw value case 'id': case 'username': case 'homepage': case 'gender': case 'description': case 'logins': case 'posts': case 'adds': case 'signature': case 'title': case 'dob': case 'latitude': case 'longitude': case 'created': case 'modified': case 'last_login': $data[$field] = $user->{$field}; break; // Custom value // Custom value case 'city': $data[$field] = ($city = $user->city()) ? $city->name : $user->city_name; break; case 'avatar': $data[$field] = $user->avatar ? URL::site($user->avatar, true) : URL::site('avatar/unknown.png'); break; case 'picture': if ($user->default_image_id) { $image = new Model_Image($user->default_image_id); $data[$field] = $image->loaded() ? $image->get_url() : ''; } else { if (Valid::url($user->picture)) { $data[$field] = URL::site($user->picture, true); } else { $data[$field] = null; } } break; case 'url': $data[$field] = URL::site(URL::user($user), true); break; } } return $data; }
/** * Action: import flyers */ public function action_flyers() { $this->history = false; Permission::required(new Model_Flyer(), Model_Flyer::PERMISSION_IMPORT, self::$user); // Action if ($event_ids = (array) Arr::get($_REQUEST, 'event_id')) { foreach ($event_ids as $event_id) { /** @var Model_Event $event */ $event = Model_Event::factory($event_id); if (!$event->loaded()) { throw new Model_Exception($event, $event_id); } if ($import = Arr::get($_REQUEST, 'import')) { // Import flyer switch ($import) { case 'front': $urls = array('front' => $event->flyer_front_url); break; case 'back': $urls = array('back' => $event->flyer_back_url); break; case 'both': $urls = array('back' => $event->flyer_back_url, 'front' => $event->flyer_front_url); break; default: continue; } // Create flyers foreach ($urls as $side => $url) { if (!$url) { continue; } $image = new Model_Image(); $image->remote = $url; $image->created = time(); if ($event->author_id) { $image->author_id = $event->author_id; } try { $image->save(); // Set the image as flyer try { $flyer = new Model_Flyer(); $flyer->set_fields(array('image_id' => $image->id, 'event_id' => $event->id, 'name' => $event->name, 'stamp_begin' => $event->stamp_begin)); $flyer->save(); } catch (Kohana_Exception $e) { //$event->relate('flyers', array($image->id)); } if ($side == 'front') { $event->flyer_front_image_id = $image->id; $event->flyer_front_url = $image->get_url(); } else { if ($side == 'back') { $event->flyer_back_image_id = $image->id; $event->flyer_back_url = $image->get_url(); } } // Save event, skipping validation $event->save(false); Widget::add('main', HTML::anchor(Route::model($event), HTML::image($image->get_url('thumbnail')))); } catch (Validation_Exception $e) { Widget::add('main', Debug::dump($e->array->errors('validation'))); } catch (Kohana_Exception $e) { Widget::add('main', $e->getMessage() . '<br />'); } } } else { if ($clear = Arr::get($_REQUEST, 'clear')) { // Clear flyer if ($clear == 'front' && $event->flyer_front_url) { $event->flyer_front_url = null; $event->save(false); } else { if ($clear == 'back' && $event->flyer_back_url) { $event->flyer_back_url = null; $event->save(false); } else { if ($clear == 'both') { $event->flyer_front_url = null; $event->flyer_back_url = null; $event->save(false); } } } } } } } // Load importable flyers $events = Model_Event::factory()->load(DB::select_array(Model_Event::factory()->fields())->where_open()->where(DB::expr('CHAR_LENGTH(flyer_front_url)'), '>', 4)->and_where(DB::expr('COALESCE(flyer_front_image_id, 0)'), '=', 0)->where_close()->or_where_open()->where(DB::expr('CHAR_LENGTH(flyer_back_url)'), '>', 4)->and_where(DB::expr('COALESCE(flyer_back_image_id, 0)'), '=', 0)->where_close()->order_by('id', 'ASC'), 100); if (count($events)) { Widget::add('main', Form::open(null, array('method' => 'get'))); foreach ($events as $event) { if ($event->flyer_front_url && !$event->flyer_front_image_id) { $front = '<p style="overflow: hidden">'; $front .= HTML::anchor($event->flyer_front_url, HTML::image($event->flyer_front_url, array('width' => '100')), array('target' => '_blank')) . ' '; $front .= HTML::anchor(Route::get('events')->uri(array('action' => 'flyers')) . '?event_id=' . $event->id . '&import=front', __('Import front')) . ': ' . $event->flyer_front_url . '<br />'; $front .= HTML::anchor(Route::get('events')->uri(array('action' => 'flyers')) . '?event_id=' . $event->id . '&clear=front', __('Clear front')); $front .= '</p>'; } else { $front = ''; } if ($event->flyer_back_url && !$event->flyer_back_image_id) { $back = '<p style="overflow: hidden">'; $back .= HTML::anchor($event->flyer_back_url, HTML::image($event->flyer_back_url, array('width' => '100')), array('target' => '_blank')) . ' '; $back .= HTML::anchor(Route::get('events')->uri(array('action' => 'flyers')) . '?event_id=' . $event->id . '&import=back', __('Import back')) . ': ' . $event->flyer_back_url . '<br />'; $back .= HTML::anchor(Route::get('events')->uri(array('action' => 'flyers')) . '?event_id=' . $event->id . '&clear=back', __('Clear back')); $back .= '</p>'; } else { $back = ''; } Widget::add('main', '<h4>' . Form::checkbox('event_id[]', $event->id) . ' ' . $event->id . ': ' . HTML::anchor(Route::model($event), HTML::chars($event->name)) . '</h4>' . $front . $back); } Widget::add('main', Form::checkbox('event_id_all', null, false, array('onchange' => '$("input[type=checkbox]").attr("checked", this.checked);')) . __('Choose all') . ' ' . Form::button('clear', __('Clear'), array('type' => 'submit', 'value' => 'both')) . ' ' . Form::button('import', __('Import'), array('type' => 'submit', 'value' => 'both'))); Widget::add('main', Form::close()); } }
/** * Prepare event for data array * * @param Model_Event $event * @param array $fields * @return array */ protected function _prepare_event(Model_Event $event, array $fields = null) { $data = array(); empty($fields) and $fields = self::$_fields; foreach ($fields as $field) { switch ($field) { // Raw value case 'id': case 'name': case 'homepage': case 'stamp_begin': case 'stamp_end': case 'dj': case 'info': case 'age': case 'price': case 'price2': case 'created': case 'modified': case 'favorite_count': $data[$field] = $event->{$field}; break; // Custom value // Custom value case 'venue': $data[$field] = ($venue = $event->venue()) ? $venue->name : $event->venue_name; break; case 'city': $data[$field] = ($city = $event->city()) ? $city->name : $event->city_name; break; case 'country': $data[$field] = ($country = $event->country()) ? $country->name : ''; break; case 'flyer_front': case 'flyer_back': case 'flyer_front_icon': case 'flyer_back_icon': case 'flyer_front_thumb': case 'flyer_back_thumb': if (strpos($field, 'icon')) { $column = str_replace('_icon', '', $field) . '_image_id'; $size = Model_Image::SIZE_ICON; } else { if (strpos($field, '_thumb')) { $column = str_replace('_thumb', '', $field) . '_image_id'; $size = Model_Image::SIZE_THUMBNAIL; } else { $column = $field . '_image_id'; $size = null; } } $image = new Model_Image($event->{$column}); $data[$field] = $image->loaded() ? $image->get_url($size) : null; break; case 'music': if ($tags = $event->tags()) { $music = implode(', ', $tags); } else { if (!empty($event->music)) { $music = $event->music; } else { $music = null; } } $data[$field] = $music; break; case 'url': $data[$field] = URL::site(Route::model($event), true); break; } } return $data; }
/** * Render view. * * @return string */ public function content() { ob_start(); ?> <div class="image"> <figure> <?php if ($this->url) { echo HTML::anchor($this->url, HTML::image($this->image->get_url(null, $this->gallery->dir)), array('title' => __('Next image'), 'class' => 'image')); } else { echo HTML::anchor(Route::model($this->gallery, $this->show_pending ? 'approve' : ''), HTML::image($this->image->get_url(null, $this->gallery->dir)), array('title' => __('Back to gallery'), 'class' => 'image')); } ?> <?php if ($this->can_note) { ?> <?php echo Form::open(Route::url('gallery_image', array('gallery_id' => Route::model_id($this->gallery), 'id' => $this->image->id, 'action' => 'note')), array('id' => 'form-note')); ?> <fieldset> <?php echo Form::control_group(Form::input('name')); ?> <?php echo Form::submit('save', __('Save'), array('class' => 'btn btn-success')); ?> <a class="cancel" href="#cancel"><?php echo __('Cancel'); ?> </a> <?php echo Form::hidden('x'); ?> <?php echo Form::hidden('y'); ?> <?php echo Form::hidden('width'); ?> <?php echo Form::hidden('height'); ?> <?php echo Form::hidden('user_id'); ?> </fieldset> <?php echo Form::close(); ?> <?php } ?> </figure> <?php echo $this->notes(); ?> </div> <?php return ob_get_clean(); }