/** * 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'), ' ', 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'), ' ', 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, '€'); ?> </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(); }
/** * Render content. * * @return string */ public function content() { ob_start(); /* // Stamp if ($this->event->stamp_begin != $this->event->stamp_end): echo ($this->event->stamp_end ? '<i class="icon-time icon-white"></i> ' . __('From :from to :to', array( ':from' => HTML::time(Date::format('HHMM', $this->event->stamp_begin), $this->event->stamp_begin), ':to' => HTML::time(Date::format('HHMM', $this->event->stamp_end), $this->event->stamp_end) )) : '<i class="icon-time icon-white"></i> ' . __('From :from onwards', array( ':from' => HTML::time(Date::format('HHMM', $this->event->stamp_begin), $this->event->stamp_begin), ))) . '<br />'; endif; */ // Price if ($this->event->price == 0) { echo '<i class="icon-shopping-cart icon-white"></i> ' . __('Free entry') . '<br />'; } elseif ($this->event->price > 0) { echo '<i class="icon-shopping-cart icon-white"></i> ' . __('Tickets :price', array(':price' => '<var>' . Num::currency($this->event->price, $this->event->stamp_begin) . '</var>')); echo ($this->event->price2 !== null ? ', ' . __('presale :price', array(':price' => '<var>' . Num::currency($this->event->price2, $this->event->stamp_begin) . '</var>')) : '') . '<br />'; } // Age limit if ($this->event->age > 0) { echo '<i class="icon-user icon-white"></i> ' . __('Age limit') . ': ' . __(':years years', array(':years' => '<var>' . $this->event->age . '</var>')) . '<br />'; } // Homepage if (!empty($this->event->homepage)) { echo '<i class="icon-home icon-white"></i> ' . HTML::anchor($this->event->homepage, Text::limit_url($this->event->homepage, 25)) . '<br />'; } // Tags if ($tags = $this->event->tags()) { echo '<i class="icon-music icon-white"></i> ' . implode(', ', $tags) . '<br />'; } elseif (!empty($this->event->music)) { echo '<i class="icon-music icon-white"></i> ' . $this->event->music . '<br />'; } /* // Venue if ($_venue = $this->event->venue()): // Venue found from db $venue = HTML::anchor(Route::model($_venue), HTML::chars($_venue->name)); $address = $_venue->address ? HTML::chars($_venue->address) . ', ' . HTML::chars($_venue->city_name) : HTML::chars($_venue->city_name); if ($_venue->latitude): $map = array( 'marker' => HTML::chars($_venue->name), 'infowindow' => HTML::chars($_venue->address) . '<br />' . HTML::chars($_venue->city_name), 'lat' => $_venue->latitude, 'long' => $_venue->longitude ); Widget::add('foot', HTML::script_source(' head.ready("anqh", function() { $("#event-info a[href=#map]").on("click", function toggleMap(event) { $("#map").toggle("fast", function openMap() { $("#map").googleMap(' . json_encode($map) . '); }); return false; }); }); ')); endif; elseif ($this->event->venue_name): // No venue in db $venue = $this->event->venue_url ? HTML::anchor($this->event->venue_url, HTML::chars($this->event->venue_name)) : HTML::chars($this->event->venue_name); $address = HTML::chars($this->event->city_name); else: // Venue not set $venue = $this->event->venue_hidden ? __('Underground') : __('(Unknown)'); $address = HTML::chars($this->event->city_name); endif; echo '<address><strong><i class="icon-map-marker icon-white"></i> ', $venue, '</strong>' . ($address ? ', ' . $address : '') . '<br />'; if (isset($map)): echo HTML::anchor('#map', __('Toggle map')) . '<br />'; echo '<div id="map" style="display: none">', __('Map loading') . '</div>'; endif; echo '</address>'; */ // Meta echo '<br /><footer class="meta">'; echo __('Added') . ' ' . HTML::time(Date::format(Date::DMY_SHORT, $this->event->created), $this->event->created); if ($this->event->modified) { echo ', ' . __('last modified') . ' ' . HTML::time(Date::short_span($this->event->modified, false), $this->event->modified); } echo '</footer>'; return ob_get_clean(); }
/** * Render content. * * @return string */ public function content() { ob_start(); echo Form::open(null, array('id' => 'form-event', 'class' => 'row')); ?> <!-- <?php if ($this->event_errors) { ?> <ul class="errors"> <?php foreach ($this->event_errors as $error) { ?> <li><?php echo $error; ?> </li> <?php } ?> </ul> <?php } ?> <?php if ($this->venue_errors) { ?> <ul class="errors"> <?php foreach ($this->venue_errors as $error) { ?> <li><?php echo $error; ?> </li> <?php } ?> </ul> <?php } ?> --> <div class="span8"> <fieldset id="fields-primary"> <?php echo Form::control_group(Form::input('name', $this->event->name, array('class' => 'input-block-level')), array('name' => __('Event')), Arr::get($this->event_errors, 'name')); ?> <?php echo Form::control_group(Form::textarea('dj', $this->event->dj, array('class' => 'input-block-level'), true), array('dj' => __('Line-up')), Arr::get($this->event_errors, 'dj')); ?> <?php echo Form::control_group(Form::textarea_editor('info', $this->event->info, array('class' => 'input-block-level'), true), array('info' => __('Other information')), Arr::get($this->event_errors, 'info')); ?> </fieldset> <fieldset class="form-actions"> <?php echo Form::button('save', __('Save event'), array('type' => 'submit', 'class' => 'btn btn-success btn-large')); ?> <?php echo $this->cancel ? HTML::anchor($this->cancel, __('Cancel'), array('class' => 'cancel')) : ''; ?> <?php echo Form::csrf(); ?> <?php echo Form::hidden('latitude', $this->venue->latitude); ?> <?php echo Form::hidden('longitude', $this->venue->longitude); ?> <?php echo Form::hidden('venue_id', $this->venue->id); ?> </fieldset> </div> <div class="span4"> <fieldset id="fields-when" class="row"> <?php echo Form::control_group(Form::input('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, 'placeholder' => 'd.m.yyyy')), array('stamp_begin[date]' => __('Date')), Arr::get($this->event_errors, 'stamp_begin'), null, array('class' => 'span1')); ?> <?php echo Form::control_group(Form::select('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')), array('stamp_begin[time]' => __('From')), Arr::get($this->event_errors, 'stamp_begin'), null, array('class' => 'span1')); ?> <?php echo Form::control_group(Form::select('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')), array('stamp_end[time]' => __('To')), Arr::get($this->event_errors, 'stamp_end'), null, array('class' => 'span1')); ?> </fieldset> <?php echo Form::control_group(Form::input('homepage', $this->event->homepage, array('class' => 'input-block-level', 'placeholder' => 'http://')), array('homepage' => __('Homepage')), Arr::get($this->event_errors, 'homepage')); ?> <fieldset id="fields-venue"> <legend> <?php echo Form::control_group('<label class="checkbox">' . Form::checkbox('venue_hidden', 'true', (bool) $this->event->venue_hidden, array('id' => 'field-ug')) . ' ' . __('Underground') . '</label>', null, null, null, array('class' => 'span2')); ?> <?php echo __('Venue'); ?> </legend> <?php echo Form::control_group(Form::input('venue_name', $this->event->venue_name, (bool) $this->event->venue_hidden ? array('class' => 'input-block-level', 'disabled' => 'disabled') : array('class' => 'input-block-level')), array('venue_name' => __('Venue')), Arr::get($this->event_errors, 'venue_name'), null, array('id' => 'group-venue')); ?> <?php echo Form::control_group(Form::input('city_name', $this->event->city_name, array('class' => 'input-block-level')), array('city_name' => __('City')), Arr::get($this->event_errors, 'city_name')); ?> </fieldset> <fieldset id="fields-tickets"> <legend> <?php echo Form::control_group('<label class="checkbox">' . Form::checkbox('free', 'true', $this->event->price === '0.00', array('id' => 'field-free')) . ' ' . __('Free entry') . '</label>', null, null, null, array('class' => 'span2')); ?> <?php echo __('Tickets'); ?> </legend> <?php echo Form::control_group('<div class="input-append">' . Form::input('price', $this->event->price, $this->event->price === '0.00' ? array('class' => 'input-mini', 'disabled' => 'disabled') : array('class' => 'input-mini')) . '<span class="add-on">€</span>' . '</div>', array('price' => __('Tickets')), Arr::get($this->event_errors, 'price'), null, array('id' => 'group-price')); ?> <?php echo Form::control_group('<div class="input-append">' . Form::input('age', $this->event->age, array('class' => 'input-mini')) . '<span class="add-on">years</span>' . '</div>', array('age' => __('Age limit')), Arr::get($this->event_errors, 'age')); ?> </fieldset> <fieldset id="fields-music"> <legend><?php echo __('Music'); ?> </legend> <?php echo Form::checkboxes_wrap('tag', $this->tags(), $this->event->tags(), null, $this->event_errors, null, 'block-grid three-up'); ?> </fieldset> </div> <?php echo Form::close(); echo $this->javascript(); return ob_get_clean(); }
/** * 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 'age': case 'created': case 'favorite_count': case 'flyer_id': case 'dj': case 'id': case 'info': case 'modified': case 'name': case 'price': case 'price2': case 'stamp_begin': case 'stamp_end': case 'venue_id': $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] = ($venue = $event->venue()) ? $venue->city_name : $event->city_name; break; case 'flyer': case 'flyer_icon': case 'flyer_thumb': if ($field === 'flyer_icon') { $size = Model_Image::SIZE_ICON; } else { if ($field === 'flyer__thumb') { $size = Model_Image::SIZE_THUMBNAIL; } else { $size = null; } } $data[$field] = ($flyer = $event->flyer()) ? $flyer->image_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; }
/** * 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; }
/** * Add event subtitle. * * @param Model_Event $event * @return string */ public static function _event_subtitle(Model_Event $event) { $subtitle = array(); // Date if ($event->stamp_end - $event->stamp_begin > Date::DAY) { // Multi day event $subtitle[] = '<i class="fa fa-calendar"></i> ' . HTML::time(Date('l', $event->stamp_begin) . ', <strong>' . Date::format(Date::DM_LONG, $event->stamp_begin) . ' – ' . Date::format(Date::DMY_LONG, $event->stamp_end) . '</strong>', $event->stamp_begin, true); } else { // Single day event $subtitle[] = '<i class="fa fa-calendar"></i> ' . HTML::time(Date('l', $event->stamp_begin) . ', <strong>' . Date::format(Date::DMY_LONG, $event->stamp_begin) . '</strong>', $event->stamp_begin, true); } // Time if ($event->stamp_begin != $event->stamp_end) { $subtitle[] = $event->stamp_end ? '<i class="fa fa-clock-o"></i> ' . __('From :from until :to', array(':from' => '<strong>' . HTML::time(Date::format('HHMM', $event->stamp_begin), $event->stamp_begin) . '</strong>', ':to' => '<strong>' . HTML::time(Date::format('HHMM', $event->stamp_end), $event->stamp_end) . '</strong>')) : '<i class="fa fa-clock-o"></i> ' . __('From :from onwards', array(':from' => HTML::time(Date::format('HHMM', $event->stamp_begin), $event->stamp_begin))); } // Tickets $tickets = ''; if ($event->price === 0 || $event->price > 0 || $event->ticket_url) { $tickets = '<i class="fa fa-ticket"></i> '; } if ($event->price === 0) { $tickets .= '<strong>' . __('Free entry') . '</strong> '; } else { if ($event->price > 0) { $tickets .= __('Tickets :price', array(':price' => '<strong>' . Num::currency($event->price, $event->stamp_begin) . '</strong>')) . ' '; } } if ($event->ticket_url) { $tickets .= HTML::anchor($event->ticket_url, __('Buy tickets'), array('target' => '_blank')); } if ($tickets) { $subtitle[] = $tickets; } // Age limit if ($event->age > 0) { $subtitle[] = '<i class="fa fa-user"></i> ' . __('Age limit') . ': <strong>' . $event->age . '</strong>'; } // Homepage if (!empty($event->url)) { $subtitle[] = '<i class="fa fa-link"></i> ' . HTML::anchor($event->url, Text::limit_url($event->url, 25)); } // Venue if ($_venue = $event->venue()) { // Venue found from db $venue = HTML::anchor(Route::model($_venue), HTML::chars($_venue->name)); $address = HTML::chars($_venue->city_name); if ($_venue->latitude) { $map = array('marker' => HTML::chars($_venue->name), 'infowindow' => HTML::chars($_venue->address) . '<br />' . HTML::chars($_venue->city_name), 'lat' => $_venue->latitude, 'long' => $_venue->longitude); Widget::add('foot', HTML::script_source(' head.ready("anqh", function() { $("a[href=#map]").on("click", function toggleMap(event) { $("#map").toggle("fast", function openMap() { $("#map").googleMap(' . json_encode($map) . '); }); return false; }); }); ')); } } else { if ($event->venue_name) { // No venue in db $venue = $event->venue_url ? HTML::anchor($event->venue_url, HTML::chars($event->venue_name)) : HTML::chars($event->venue_name); $address = HTML::chars($event->city_name); } else { // Venue not set $venue = $event->venue_hidden ? __('Underground') : __('(Unknown)'); $address = HTML::chars($event->city_name); } } $subtitle[] = '<br /><i class="fa fa-map-marker"></i> <strong>' . $venue . '</strong>' . ($address ? ', ' . $address : ''); if (isset($map)) { $subtitle[] = HTML::anchor('#map', __('Show map')); } // Tags if ($tags = $event->tags()) { $subtitle[] = '<br /><i class="fa fa-music"></i> <em>' . implode(', ', $tags) . '</em>'; } else { if (!empty($event->music)) { $subtitle[] = '<br /><i class="fa fa-music"></i> <em>' . $event->music . '</em>'; } } return implode(' ', $subtitle) . (isset($map) ? '<div id="map" style="display: none">' . __('Map loading') . '</div>' : ''); }