/** * Add event subtitle. * * @param Model_Event $event * @return string */ protected function _event_subtitle(Model_Event $event) { $subtitle = array(); // Date $subtitle[] = '<i class="icon-calendar icon-white"></i> ' . HTML::time(Date('l', $event->stamp_begin) . ', ' . Date::format(Date::DMY_LONG, $event->stamp_begin), $event->stamp_begin, true); // Time if ($event->stamp_begin != $event->stamp_end) { $subtitle[] = $event->stamp_end ? '<i class="icon-time icon-white"></i> ' . __(':from until :to', array(':from' => HTML::time(Date::format('HHMM', $event->stamp_begin), $event->stamp_begin), ':to' => HTML::time(Date::format('HHMM', $event->stamp_end), $event->stamp_end))) : '<i class="icon-time icon-white"></i> ' . __('From :from onwards', array(':from' => HTML::time(Date::format('HHMM', $event->stamp_begin), $event->stamp_begin))); } // 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[] = '<i class="icon-map-marker icon-white"></i> ' . $venue . ($address ? ', ' . $address : ''); if (isset($map)) { $subtitle[] = HTML::anchor('#map', __('Show map')); return implode(' ', $subtitle) . '<div id="map" style="display: none">' . __('Map loading') . '</div>'; } return implode(' ', $subtitle); }
/** * Creates a textarea form input with BBCode editor. * * @param string $name textarea name * @param string $body textarea body * @param array $attributes html attributes * @param boolean $double_encode encode existing HTML characters * @return string * * @uses HTML::attributes * @uses HTML::chars */ public static function textarea_editor($name, $body = '', array $attributes = null, $double_encode = true) { // Get DOM element if ($element = Arr::get($attributes, 'id')) { $element = '#' . $element; } else { $element = 'textarea[name=' . $name . ']'; } return new View_Generic_Smileys($element) . Form::textarea($name, $body, $attributes, $double_encode) . HTML::script_source('head.ready("vendor", function initMarkItUp() { $("' . $element . '").markItUp(bbCodeSettings); });'); }
echo HTML::script_source(' head.ready("anqh", function() { $("a.post-edit").live("click", function(e) { e.preventDefault(); var href = $(this).attr("href"); var post = href.match(/([0-9]*)\\/edit/); $("#post-" + post[1] + " .actions").fadeOut(); $.get(href, function(data) { $("#post-" + post[1] + " .post-content").html(data); }); }); $("a.post-delete").each(function(i) { var action = $(this); action.data("action", function() { var post = action.attr("href").match(/([0-9]*)\\/delete/); if (post) { $("#post-" + post[1]).slideUp(); $.get(action.attr("href")); } }); }); $("a.post-quote").live("click", function(e) { e.preventDefault(); var href = $(this).attr("href"); var post = href.match(/([0-9]*)\\/quote/); var article = $(this).closest("article"); $("#post-" + post[1] + " .actions").fadeOut(); $.get(href, function(data) { article.append(data); var quote = article.find("#quote"); if (quote.offset().top + quote.outerHeight() > $(window).scrollTop() + $(window).height()) { window.scrollTo(0, quote.offset().top + quote.outerHeight() - $(window).height() ); } }); }); $("section.post-content form").live("submit", function(e) { e.preventDefault(); var post = $(this).closest("article"); post.loading(); $.post($(this).attr("action"), $(this).serialize(), function(data) { post.replaceWith(data); }); }); $("section.post-content form a").live("click", function(e) { e.preventDefault(); var post = $(this).closest("article"); $.get($(this).attr("href"), function(data) { post.replaceWith(data); }); }); $("#quote form a").live("click", function(e) { e.preventDefault(); var quote = $("#quote"); var article = quote.closest("article"); quote.slideUp(null, function() { quote.remove(); }); article.find(".actions").fadeIn(); }); }); ');
/** * Destroy controller */ public function after() { if ($this->ajax || $this->internal) { // AJAX and HMVC requests $this->response->body($this->response->body() . ''); } else { if ($this->auto_render) { // Normal requests $session = Session::instance(); // Save current URI /* Moved to Controller if ($this->history && $this->response->status() < 400) { $uri = $this->request->current_uri(); unset($this->breadcrumb[$uri]); $this->breadcrumb = array_slice($this->breadcrumb, -9, 9, true); $this->breadcrumb[$uri] = $this->page_title; $session ->set('history', $uri . ($_GET ? URL::query($_GET) : '')) ->set('breadcrumb', $this->breadcrumb); } */ // Controller name as the default page id if none set empty($this->page_id) and $this->page_id = $this->request->controller(); // Stylesheets $styles = array('ui/boot.css' => null, 'ui/typo.css' => null, 'ui/base.css' => null, 'ui/jquery-ui.css' => null, 'http://fonts.googleapis.com/css?family=Nobile:regular,bold' => null); // Generic views Widget::add('breadcrumb', View::factory('generic/breadcrumb', array('breadcrumb' => $this->breadcrumb, 'last' => !$this->history))); Widget::add('actions', View::factory('generic/actions', array('actions' => $this->page_actions))); Widget::add('navigation', View::factory('generic/navigation', array('items' => Kohana::$config->load('site.menu'), 'selected' => $this->page_id))); if (!empty($this->tabs)) { Widget::add('subnavigation', View::factory('generic/navigation', array('items' => $this->tabs, 'selected' => $this->tab_id))); } /* Widget::add('tabs', View::factory('generic/tabs_top', array( 'tabs' => $this->tabs, 'selected' => $this->tab_id ))); */ // Footer Widget::add('footer', View_Module::factory('events/event_list', array('mod_id' => 'footer-events-new', 'mod_class' => 'article grid4 first cut events', 'mod_title' => __('New events'), 'events' => Model_Event::factory()->find_new(10)))); Widget::add('footer', View_Module::factory('forum/topiclist', array('mod_id' => 'footer-topics-active', 'mod_class' => 'article grid4 cut topics', 'mod_title' => __('New posts'), 'topics' => Model_Forum_Topic::factory()->find_by_latest_post(10)))); Widget::add('footer', View_Module::factory('blog/entry_list', array('mod_id' => 'footer-blog-entries', 'mod_class' => 'article grid4 cut blogentries', 'mod_title' => __('New blogs'), 'entries' => Model_Blog_Entry::factory()->find_new(10)))); // Skin $skins = Kohana::$config->load('site.skins'); $skin = 'dark'; //$session->get('skin', 'dark'); $skin_imports = array('ui/mixin.less', 'ui/grid.less', 'ui/layout.less', 'ui/widget.less', 'ui/custom.less'); // Dock $classes = array(); foreach ($skins as $skin_name => &$skin_config) { $skin_config['path'] = 'ui/' . $skin_name . '/skin.less'; $classes[] = HTML::anchor(Route::get('setting')->uri(array('action' => 'skin', 'value' => $skin_name)), $skin_config['name'], array('class' => 'theme', 'rel' => $skin_name)); } //Widget::add('dock', __('Theme') . ': ' . implode(', ', $classes)); // Language selection $available_languages = Kohana::$config->load('locale.languages'); if (count($available_languages)) { $languages = array(); foreach ($available_languages as $lang => $locale) { $languages[] = HTML::anchor('set/lang/' . $lang, HTML::chars($locale[2])); } // Widget::add('dock', ' | ' . __('Language: ') . implode(', ', $languages)); } // Search /* Widget::add('search', View_Module::factory('generic/search', array( 'mod_id' => 'search' ))); */ // Visitor card Widget::add('visitor', View::factory('generic/visitor', array('user' => self::$user))); // Time & weather Widget::add('dock', ' | ' . View::factory('generic/clock', array('user' => self::$user))); // Pin Widget::add('dock', ' | ' . HTML::anchor('#pin', '▲', array('title' => __('Lock menu'), 'class' => 'icon unlock', 'onclick' => '$("#header").toggleClass("pinned"); return false;'))); // End Widget::add('end', View::factory('generic/end')); // Analytics if ($google_analytics = Kohana::$config->load('site.google_analytics')) { Widget::add('head', HTML::script_source("\nvar tracker;\nhead.js(\n\t{ 'google-analytics': 'http://www.google-analytics.com/ga.js' },\n\tfunction() {\n\t\ttracker = _gat._getTracker('" . $google_analytics . "');\n\t\ttracker._trackPageview();\n\t}\n);\n")); } // Open Graph $og = array(); foreach ((array) Anqh::open_graph() as $key => $value) { $og[] = '<meta property="' . $key . '" content="' . HTML::chars($value) . '" />'; } if (!empty($og)) { Widget::add('head', implode("\n", $og)); } // Share if (Anqh::share()) { if ($share = Kohana::$config->load('site.share')) { // 3rd party share Widget::add('share', View_Module::factory('share/share', array('mod_class' => 'like', 'id' => $share))); Widget::add('foot', View::factory('share/foot', array('id' => $share))); } else { if ($facebook = Kohana::$config->load('site.facebook')) { // Facebook Like Widget::add('share', View_Module::factory('facebook/like')); Widget::add('ad_top', View::factory('facebook/connect', array('id' => $facebook))); } } } // Ads $ads = Kohana::$config->load('site.ads'); if ($ads && $ads['enabled']) { foreach ($ads['slots'] as $ad => $slot) { Widget::add($slot, View::factory('ads/' . $ad), Widget::MIDDLE); } } // And finally the profiler stats if (self::$user && self::$user->has_role('admin')) { //in_array(Kohana::$environment, array(Kohana::DEVELOPMENT, Kohana::TESTING))) { Widget::add('foot', View::factory('generic/debug')); Widget::add('foot', View::factory('profiler/stats')); } // Do some CSS magic to page class $page_class = explode(' ', $this->language . ' ' . $session->get('page_width', 'fixed') . ' ' . $session->get('page_main', 'left') . ' ' . $this->request->action() . ' ' . $this->page_class); // Controller set classes $page_class = implode(' ', array_unique(array_map('trim', $page_class))); // Bind the generic page variables $this->template->set('styles', $styles)->set('skin', $skin)->set('skins', $skins)->set('skin_imports', $skin_imports)->set('language', $this->language)->set('page_id', $this->page_id)->set('page_class', $page_class)->set('page_title', $this->page_title)->set('page_subtitle', $this->page_subtitle); // Add statistics $queries = 0; if (Kohana::$profiling) { foreach (Profiler::groups() as $group => $benchmarks) { if (strpos($group, 'database') === 0) { $queries += count($benchmarks); } } } $total = array('{memory_usage}' => number_format((memory_get_peak_usage() - KOHANA_START_MEMORY) / 1024, 2) . 'KB', '{execution_time}' => number_format(microtime(true) - KOHANA_START_TIME, 5), '{database_queries}' => $queries, '{included_files}' => count(get_included_files())); $this->template = strtr($this->template, $total); // Render page if ($this->auto_render === true) { $this->response->body($this->template); } } } return parent::after(); }
echo HTML::script_source(' // Keyboard navigation head.ready("jquery-ui", function() { $(document).keyup(function(e) { var key = e.keyCode || e.which; if (e.target.type === undefined) { switch (key) { case 37: var link = $(".gallery-image a.prev").first().attr("href"); break; case 39: var link = $(".gallery-image a.next").first().attr("href"); break; } if (link) { window.location = link; } } }); }); // Notes head.ready("anqh", function() { $("a.image").notes(' . json_encode($note_array) . '); $("input[name=name]").autocompleteUser(); $("a.note-add").click(function() { function updateForm(img, area) { $("#form-note") .css({ left: area.x1 + "px", top: area.y1 + area.height + 5 + "px" }) .show(); $("#form-note input[name=x]").val(area.x1); $("#form-note input[name=y]").val(area.y1); $("#form-note input[name=width]").val(area.width); $("#form-note input[name=height]").val(area.height); } $("a.image img").imgAreaSelect({ onInit: updateForm, onSelectChange: updateForm, handles: true, persistent: true, minWidth: 50, minHeight: 50, maxWidth: 150, maxHeight: 150, x1: parseInt($("a.image").width() / 2) - 50, y1: parseInt($("a.image").height() / 2) - 50, x2: parseInt($("a.image").width() / 2) + 50, y2: parseInt($("a.image").height() / 2) + 50 }); return false; }); $("#form-note a.cancel").click(function() { $("a.image img").imgAreaSelect({ hide: true }); $("#form-note").hide(); }); }); ');
<div class="info"></div> </div> </div> </div> <a class="navi prev" title="<?php echo __('Previous'); ?> ">«</a> <a class="navi next" title="<?php echo __('Next'); ?> ">»</a> <a class="action close" title="<?php echo __('Close'); ?> ">✖</a> </div> <?php echo HTML::script_source("\nhead.js(\n\t{ 'jquery': 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' },\n\t{ 'jquery-ui': 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js' },\n\t{ 'jquery-tools': '" . URL::base() . "js/jquery.tools.min.js' },\n\t{ 'jquery-form': '" . URL::base() . "js/jquery.form.js' },\n\t{ 'jquery-overflow': '" . URL::base() . "js/jquery.text-overflow.js' },\n\t{ 'jquery-imgarea': '" . URL::base() . "js/jquery.imgareaselect.js' },\n\t{ 'jquery-scroll': '" . URL::base() . "js/jquery-scrolltofixed-min.js' },\n\t{ 'jquery-markitup': '" . URL::base() . "js/jquery.markitup.pack.js' },\n\t{ 'jquery-bbcode': '" . URL::base() . "js/markitup.bbcode.js' },\n\t{ 'anqh': '" . URL::base() . "js/anqh.js?2' },\n\tfunction() {\n\t\tAnqh.geoNamesURL = '" . Kohana::$config->load('geo.base_url') . "';\n\t\tAnqh.geoNamesUser = '******'geo.username') . "';\n\t}\n);\n"); ?> <?php echo Widget::get('foot'); ?> </body> </html>
echo HTML::script_source(' head.ready("anqh", function() { $("#field-name").autocompleteEvent({ "action": function(event, ui) { window.location = "' . URL::site(Route::get('galleries')->uri(array('action' => 'upload'))) . '?from=" + ui.item.id; }, }); return; $("#field-name") .autocomplete({ minLength: 3, source: function(request, response) { $.ajax({ url: "/api/v1/events/search", dataType: "json", data: { q: request.term, limit: 25, filter: "past", search: "name", field: "id:name:city:stamp_begin", order: "stamp_begin.desc" }, success: function(data) { response($.map(data.events, function(item) { return { label: item.name, stamp: item.stamp_begin, city: item.city, value: item.name, id: item.id } })) } }); }, select: function(event, ui) { window.location = "' . URL::site(Route::get('galleries')->uri(array('action' => 'upload'))) . '?from=" + ui.item.id; }, }) .data("autocomplete")._renderItem = function(ul, item) { return $("<li></li>") .data("item.autocomplete", item) .append("<a>" + $.datepicker.formatDate("dd.mm.yy", new Date(item.stamp * 1000)) + " " + item.label + ", " + item.city + "</a>") .appendTo(ul); }; }); ');
/** * Destroy controller. */ public function after() { if ($this->_request_type !== Controller::REQUEST_INITIAL) { // AJAX and HMVC requests $this->response->body((string) $this->response->body()); } else { if ($this->auto_render) { // Normal requests // Stylesheets $styles = array('ui/jquery-ui.css', 'http://fonts.googleapis.com/css?family=Terminal+Dosis'); // Skins $selected_skin = $this->session->get('skin', 'blue'); // Less files needed to build a skin $less_imports = array('ui/mixin.less', 'ui/anqh.less'); $skins = array(HTML::style('static/css/bootstrap.css'), HTML::style('static/css/bootstrap-responsive.css')); foreach (array('blue') as $skin) { $skinsi[] = Less::style('ui/' . $skin . '.less', array('title' => $skin, 'rel' => $skin == $selected_skin ? 'stylesheet' : 'alternate stylesheet'), false, $less_imports); } // Footer $section = new View_Events_List(); $section->class .= ' span4'; $section->title = __('New events'); $section->events = Model_Event::factory()->find_new(10); Widget::add('footer', $section); $section = new View_Topics_List(); $section->class .= ' span4'; $section->title = __('New posts'); $section->topics = Model_Forum_Topic::factory()->find_by_latest_post(10); Widget::add('footer', $section); $section = new View_Blogs_List(); $section->class .= ' span4'; $section->title = __('New blogs'); $section->blog_entries = Model_Blog_Entry::factory()->find_new(10); Widget::add('footer', $section); // Open Graph $og = array(); foreach ((array) Anqh::open_graph() as $key => $value) { $og[] = '<meta property="' . $key . '" content="' . HTML::chars($value) . '" />'; } if (!empty($og)) { Widget::add('head', implode("\n", $og)); } // Analytics if ($google_analytics = Kohana::$config->load('site.google_analytics')) { Widget::add('head', HTML::script_source("\nvar tracker;\nhead.js(\n\t{ 'google-analytics': 'http://www.google-analytics.com/ga.js' },\n\tfunction() {\n\t\ttracker = _gat._getTracker('" . $google_analytics . "');\n\t\ttracker._trackPageview();\n\t}\n);\n")); } // Ads /* $ads = Kohana::$config->load('site.ads'); if ($ads && $ads['enabled']) { foreach ($ads['slots'] as $ad => $slot) { if ($slot == 'side') { $this->view->add(View_Page::COLUMN_SIDE, View::factory('ads/' . $ad)); } else { Widget::add($slot, View::factory('ads/' . $ad), Widget::MIDDLE); } } }*/ // Do some CSS magic to page class $page_class = array_merge(array($this->language, $this->request->action(), self::$user ? 'authenticated' : 'unauthenticated'), explode(' ', $this->page_class)); $page_class = implode(' ', array_unique($page_class)); // Set the generic page variables $this->view->styles = $styles; $this->view->skins = $skins; $this->view->language = $this->language; $this->view->id = $this->page_id; $this->view->class = $page_class; if ($this->page_actions) { $this->view->tabs = $this->page_actions; } if ($this->page_breadcrumbs) { $this->view->breadcrumbs = $this->page_breadcrumbs; } // And finally the profiler stats if (self::$user && self::$user->has_role('admin')) { //in_array(Kohana::$environment, array(Kohana::DEVELOPMENT, Kohana::TESTING))) { Widget::add('foot', View::factory('generic/debug')); Widget::add('foot', View::factory('profiler/stats')); } } } parent::after(); }
/** * Action: settings */ public function action_settings() { $this->history = false; $user = $this->_get_user(); Permission::required($user, Model_User::PERMISSION_UPDATE, self::$user); // Set generic page parameters $this->_set_page($user); // Handle post $errors = array(); if ($_POST && Security::csrf_valid()) { $user->set(Arr::extract($_POST, Model_User::$editable_fields)); // GeoNames if ($_POST['city_id'] && ($city = Geo::find_city((int) $_POST['city_id']))) { $user->city = $city; } $user->modified = time(); try { $user->save(); $this->request->redirect(URL::user($user)); } catch (Validate_Exception $e) { $errors = $e->array->errors('validation'); } } // Build form $form = array('values' => $user, 'errors' => $errors, 'cancel' => URL::user($user), 'hidden' => array('city_id' => $user->city ? $user->city->id : 0, 'latitude' => $user->latitude, 'longitude' => $user->longitude), 'groups' => array('basic' => array('header' => __('Basic information'), 'fields' => array('name' => array(), 'gender' => array('input' => 'radio'), 'dob' => array('pretty_format' => 'j.n.Y'), 'title' => array(), 'description' => array('attributes' => array('rows' => 5)))), 'contact' => array('header' => __('Contact information'), 'fields' => array('email' => array(), 'homepage' => array(), 'address_street' => array(), 'address_zip' => array(), 'address_city' => array())), 'forum' => array('header' => __('Forum settings'), 'fields' => array('signature' => array('attributes' => array('rows' => 5)))))); Widget::add('main', View_Module::factory('form/anqh', array('form' => $form))); // Autocomplete $this->autocomplete_city('address_city', 'city_id'); // Date picker $options = array('changeMonth' => true, 'changeYear' => true, 'dateFormat' => 'd.m.yy', 'defaultDate' => date('j.n.Y', $user->dob), 'dayNames' => array(__('Sunday'), __('Monday'), __('Tuesday'), __('Wednesday'), __('Thursday'), __('Friday'), __('Saturday')), 'dayNamesMin' => array(__('Su'), __('Mo'), __('Tu'), __('We'), __('Th'), __('Fr'), __('Sa')), 'firstDay' => 1, 'monthNames' => array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), __('September'), __('October'), __('November'), __('December')), 'monthNamesShort' => array(__('Jan'), __('Feb'), __('Mar'), __('Apr'), __('May'), __('Jun'), __('Jul'), __('Aug'), __('Sep'), __('Oct'), __('Nov'), __('Dec')), 'nextText' => __('»'), 'prevText' => __('«'), 'showWeek' => true, 'showOtherMonths' => true, 'weekHeader' => __('Wk'), 'yearRange' => '1900:+0'); Widget::add('foot', HTML::script_source('$("#field-dob").datepicker(' . json_encode($options) . ');')); // Maps Widget::add('foot', HTML::script_source(' $(function() { $("#fields-contact ul").append("<li><div id=\\"map\\">' . __('Loading map..') . '</div></li>"); $("#map").googleMap(' . ($user->latitude ? json_encode(array('marker' => true, 'lat' => $user->latitude, 'long' => $user->longitude)) : '') . '); $("input[name=address_street], input[name=address_city]").blur(function(event) { var address = $("input[name=address_street]").val(); var city = $("input[name=address_city]").val(); if (address != "" && city != "") { var geocode = address + ", " + city; geocoder.geocode({ address: geocode }, function(results, status) { if (status == google.maps.GeocoderStatus.OK && results.length) { map.setCenter(results[0].geometry.location); $("input[name=latitude]").val(results[0].geometry.location.lat()); $("input[name=longitude]").val(results[0].geometry.location.lng()); var marker = new google.maps.Marker({ position: results[0].geometry.location, map: map }); } }); } }); }); ')); }
<section id="<?php echo $id; ?> " class="mod tabs"> <ul> <?php $t = 0; $selected = 0; foreach ($tabs as $tab) { $selected = !empty($tab['selected']) ? $t : $selected; $t++; ?> <li><?php echo HTML::anchor($tab['href'], $tab['title']); ?> </li> <?php } ?> </ul> <?php foreach ($tabs as $tab) { echo $tab['tab']; } ?> </section> <?php // Initialize tabs immediately to aviod ugly jumping echo HTML::script_source('$("#' . $id . '").tabs({ selected: ' . $selected . ', collapsible: true, fx: { height: "toggle", opacity: "toggle", duration: "fast" } });'); //echo html::script_source('$("#' . $id . ' > ul").tabs("#' . $id . ' .tab", { initialIndex: ' . $selected . ', effect: "fade" });');
$t++; ?> <li><?php echo HTML::anchor($tab['href'], $tab['title']); ?> </li> <?php } ?> </ul> <?php foreach ($tabs as $tab) { echo $tab['tab']; } ?> </section> <?php echo HTML::script_source(' head.ready("jquery-ui", function() { $("#' . $id . '") .tabs({ "selected": ' . $selected . ', "collapsible": true, "fx": { "height": "toggle", "opacity": "toggle", "duration": "fast" } }) .show(); });');
/** * 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>' : ''); }
/** * Autocomplete for city * * @param string $name Form input name for city name * @param string $id Form input name for city id */ public function autocomplete_city($name = 'city_name', $id = 'city_id') { Widget::add('foot', HTML::script_source(' $(function() { $("input[name=' . $name . ']") .autocomplete({ source: function(request, response) { $.ajax({ url: "http://ws.geonames.org/searchJSON", dataType: "jsonp", data: { lang: "' . $this->language . '", featureClass: "P", countryBias: "FI", style: "full", maxRows: 10, name_startsWith: request.term }, success: function(data) { response($.map(data.geonames, function(item) { return { id: item.geonameId, label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName, value: item.name, lat: item.lat, long: item.lng } })) } }) }, minLength: 2, select: function(event, ui) { $("input[name=' . $id . ']").val(ui.item.id); if ($("input[name=address]") && $("input[name=address]").val() == "") { $("input[name=latitude]").val(ui.item.lat); $("input[name=longitude]").val(ui.item.long); map && map.setCenter(new google.maps.LatLng(ui.item.lat, ui.item.long)); } }, }); }); ')); }
<?php } ?> </ul> <?php if (!empty($tabs)) { ?> </div> </section> <?php echo HTML::script_source(' head("jquery-ui", function() { $("#newsfeed-tabs").tabs({ selected: ' . (isset($tab) && $tab == 'friends' ? 1 : 0) . ', fx: { height: "toggle", opacity: "toggle", duration: "fast" }, ajaxOptions: { error: function(xhr, status, index, anchor) { $(anchor.hash).html("' . __('Frak, error loading newsfeed :(') . '"); } } }); }); '); }
/** * Creates a textarea form input. * * @param string $name textarea name * @param string $body textarea body * @param array $attributes html attributes * @param boolean $double_encode encode existing HTML characters * * @param string $label * @param string|array $error * @param string|array $tip * @param boolean $bbcode * @return string */ public static function textarea_wrap($name, $body = '', array $attributes = null, $double_encode = true, $label = null, $error = null, $tip = null, $bbcode = null) { if (is_array($body)) { $body = Arr::get($body, $name); } else { if (is_object($body)) { $body = $body->{$name}; } } $attributes = (array) $attributes + array('id' => self::input_id($name)); $label = $label ? array($attributes['id'] => $label) : ''; $input = Form::textarea($name, $body, $attributes, $double_encode); if ($bbcode) { $input .= HTML::script_source(' head.ready("bbcode", function initMarkItUp() { $("#' . $attributes['id'] . '").markItUp(bbCodeSettings); }); '); } return Form::wrap($input, $name, $label, $error, $tip); }
if ($post) { ?> <fieldset id="fields-post"> <ul> <?php echo Form::textarea_wrap('post', $post, array('tabindex' => ++$tabindex), true, __('Post'), $errors); ?> </ul> </fieldset> <?php } ?> <fieldset> <?php echo Form::csrf(); ?> <?php echo Form::submit_wrap('save', __('Save'), array('tabindex' => ++$tabindex), $cancel); ?> </fieldset> <?php echo Form::close(); if ($private) { echo HTML::script_source(' head.ready("anqh", function() { $("textarea[name=recipients]").autocompleteUser({ user: '******', maxUsers: 100 }); }); '); }
<?php echo Form::csrf(); ?> <?php echo Form::submit_wrap('save', __('Save')); ?> </fieldset> </div> <?php echo Form::close(); $options = array('changeMonth' => true, 'changeYear' => true, 'dateFormat' => 'd.m.yy', 'dayNames' => array(__('Sunday'), __('Monday'), __('Tuesday'), __('Wednesday'), __('Thursday'), __('Friday'), __('Saturday')), 'dayNamesMin' => array(__('Su'), __('Mo'), __('Tu'), __('We'), __('Th'), __('Fr'), __('Sa')), 'firstDay' => 1, 'monthNames' => array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), __('September'), __('October'), __('November'), __('December')), 'monthNamesShort' => array(__('Jan'), __('Feb'), __('Mar'), __('Apr'), __('May'), __('Jun'), __('Jul'), __('Aug'), __('Sep'), __('Oct'), __('Nov'), __('Dec')), 'nextText' => __('»'), 'prevText' => __('«'), 'showWeek' => true, 'showOtherMonths' => true, 'weekHeader' => __('Wk')); // Event search date range if ($flyer->stamp_begin) { $year = Arr::get(getdate($flyer->stamp_begin), 'year'); $event_options = array('filter' => 'date:' . mktime(0, 0, 0, 1, 1, $year) . '-' . mktime(0, 0, 0, 1, 1, $year + 1)); } else { $event_options = null; } echo HTML::script_source(' // Date head.ready("jquery-ui", function() { $("#field-stamp-begin-date").datepicker(' . json_encode($options) . '); }); // Event head.ready("anqh", function() { $("input[name=event]").autocompleteEvent(' . json_encode($event_options) . '); }); ');
echo HTML::script_source(' // Date picker head.ready("jquery-ui", function() { $("#field-dob").datepicker(' . json_encode($options) . '); }); // Maps head.ready("jquery", function() { $("#fields-contact ul").append("<li><div id=\\"map\\">' . __('Loading map..') . '</div></li>"); }); head.ready("anqh", function() { $("#map").googleMap(' . ($user->latitude ? json_encode(array('marker' => true, 'lat' => $user->latitude, 'long' => $user->longitude)) : '') . '); $("input[name=address_city]").autocompleteCity(); $("input[name=address_street], input[name=address_city]").blur(function(event) { var address = $("input[name=address_street]").val(); var city = $("input[name=address_city]").val(); if (address != "" && city != "") { var geocode = address + ", " + city; Anqh.geocoder.geocode({ address: geocode }, function(results, status) { if (status == google.maps.GeocoderStatus.OK && results.length) { Anqh.map.setCenter(results[0].geometry.location); $("input[name=latitude]").val(results[0].geometry.location.lat()); $("input[name=longitude]").val(results[0].geometry.location.lng()); var marker = new google.maps.Marker({ position: results[0].geometry.location, map: Anqh.map }); } }); } }); }); ');
if ($approve) { echo HTML::icon_value(array(':images' => 0), __('Approved'), null, 'approve') . ' '; } echo HTML::icon_value(array(':images' => 0), $approve ? __('Denied') : __('Deleted'), null, 'deny') . ' '; echo HTML::icon_value(array(':images' => count($images)), __('Waiting'), null, 'wait') . '<br />'; echo Form::submit_wrap('approve', __('Save'), null, Route::get('galleries')->uri(array('action' => 'approval'))); echo Form::close(); echo HTML::script_source(' head.ready("jquery", function() { $("form input[name=all]").change(function() { $("form input[value=" + $(this).val() + "]").attr("checked", true); $.each([ "approve", "deny", "wait" ], function() { $("var.icon." + this).text($("input[name!=all][value=" + this + "]:checked").length); }); }); $("form input[name^=image_id]").change(function() { $(this).closest("li") .toggleClass("approved", $(this).val() == "approve" && $(this).attr("checked")) .toggleClass("denied", $(this).val() == "deny" && $(this).attr("checked")); $.each([ "approve", "deny", "wait" ], function() { $("var.icon." + this).text($("input[name!=all][value=" + this + "]:checked").length); }); }); }); '); }
echo HTML::script_source(' head.ready("jquery", function() { head.js( { "jquery-upload": "' . URL::base() . 'js/jquery.html5_upload.js?3" }, function upload_loaded() { var $field = $("#' . $field_id . '"); $field .html5_upload({ url: $("#form-multiple-upload").attr("action"), autostart: false, sendBoundary: window.FormData || $.browser.mozilla, fieldName: "' . $field_name . '", onStart: function(event, total) { return true; //return confirm("You are trying to upload " + total + " files. Are you sure?"); }, onStartOne: function(event, name, number, total) { $("#upload-" + number + " .progress").text("Uploading..."); return true; }, onProgress: function(event, progress, name, number, total) { progress = Math.ceil(progress * 100); $("#upload-" + number + " .progress").text(progress == 100 ? "Processing..." : progress + "%"); $("#progress-report .progress-bar var").text(progress + "%"); return true; }, onFinishOne: function(event, response, name, number, total) { try { response = $.parseJSON(response); var message = (response.error) ? "Failed: " + response.error : "Done"; if (response.thumbnail) { $("#progress-thumbnails").append(response.thumbnail); } } catch (e) { var message = "Failed"; } $("#upload-" + number).addClass(response.error ? "error" : "done"); $("#upload-" + number + " .progress").text(message); }, setName: function(text) { $("#progress-report-name").text(text); }, setStatus: function(text) { $("#progress-report-status").text(text); }, setProgress: function(val) { $("#progress-report .progress-bar div").css("width", Math.ceil(val * 100) + "%"); } }) .on("change", function addFiles() { $("#progress-files").show(); var files = this.files; var total = files.length; var $files = $("#progress-files tbody").empty(); var size = 0; $.each(files, function(index, file) { size += file.fileSize; $files.append("<tr id=\\"upload-" + index + "\\"><td>" + file.fileName + "</td><td>" + Math.round(file.fileSize / 1024) + "kB</td><td class=\\"progress\\"></td></tr>"); }); $("#progress-files tfoot").html("<tr><th>" + total + " file(s)</th><th colspan=\\"2\\">" + Math.round(size / 1024) + "kB</th></tr>"); }); $("#form-multiple-upload").on("submit", function uploadFiles(event) { event.preventDefault(); $("#progress-report").show(); $field.trigger("html5_upload.start"); return false; }); } ); }); ');
?> <li><?php echo Form::submit(false, __('Shout')); ?> </li> </ul> <?php echo Form::csrf(); ?> </fieldset> <?php echo Form::close(); ?> <?php // AJAX hooks echo HTML::script_source(' $(function() { $("section.shout form").live("submit", function(e) { e.preventDefault(); var shouts = $(this).closest("section.shout"); $.post($(this).attr("action"), $(this).serialize(), function(data) { shouts.replaceWith(data); }); return false; }); }); '); }
/** * Get Javascripts. * * @return string */ protected function javascript() { // Date picker $options = array('changeMonth' => true, 'changeYear' => true, 'dateFormat' => 'd.m.yy', 'defaultDate' => date('j.n.Y', $this->user->dob), 'dayNames' => array(__('Sunday'), __('Monday'), __('Tuesday'), __('Wednesday'), __('Thursday'), __('Friday'), __('Saturday')), 'dayNamesMin' => array(__('Su'), __('Mo'), __('Tu'), __('We'), __('Th'), __('Fr'), __('Sa')), 'firstDay' => 1, 'monthNames' => array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), __('September'), __('October'), __('November'), __('December')), 'monthNamesShort' => array(__('Jan'), __('Feb'), __('Mar'), __('Apr'), __('May'), __('Jun'), __('Jul'), __('Aug'), __('Sep'), __('Oct'), __('Nov'), __('Dec')), 'nextText' => __('»'), 'prevText' => __('«'), 'showWeek' => true, 'showOtherMonths' => true, 'weekHeader' => __('Wk'), 'yearRange' => '1900:+0'); return HTML::script_source(' // Date picker head.ready("jquery-ui", function() { $("input[name=dob]").datepicker(' . json_encode($options) . '); }); // Maps head.ready("jquery", function() { $("#fields-contact").append("<div id=\\"map\\">' . __('Loading map..') . '</div>"); }); head.ready("anqh", function() { $("#map").googleMap(' . ($this->user->latitude ? json_encode(array('marker' => true, 'lat' => $this->user->latitude, 'long' => $this->user->longitude)) : '') . '); $("input[name=address_city]").autocompleteGeo(); $("input[name=address_street], input[name=address_city]").blur(function(event) { var address = $("input[name=address_street]").val() , city = $("input[name=address_city]").val(); if (address != "" && city != "") { var geocode = address + ", " + city; Anqh.geocoder.geocode({ address: geocode }, function(results, status) { if (status == google.maps.GeocoderStatus.OK && results.length) { Anqh.map.setCenter(results[0].geometry.location); $("input[name=latitude]").val(results[0].geometry.location.lat()); $("input[name=longitude]").val(results[0].geometry.location.lng()); var marker = new google.maps.Marker({ position: results[0].geometry.location, map: Anqh.map }); } }); } }); }); '); }
echo HTML::script_source(' $(function() { $("#' . $field_id . '") .html5_upload({ url: $("#form-multiple-upload").attr("action"), autostart: false, sendBoundary: window.FormData || $.browser.mozilla, fieldName: "' . $field_name . '", onStart: function(event, total) { return true; //return confirm("You are trying to upload " + total + " files. Are you sure?"); }, onStartOne: function(event, name, number, total) { $("#upload-" + number + " .progress").text("Uploading..."); return true; }, onProgress: function(event, progress, name, number, total) { $("#upload-" + number + " .progress").text(Math.ceil(progress * 100) + "%"); return true; }, onFinishOne: function(event, response, name, number, total) { try { response = $.parseJSON(response); var message = (response.error) ? "Failed: " + response.error : "Done"; if (response.thumbnail) { $("#progress-thumbnails").append(response.thumbnail); } } catch (e) { var message = "Failed"; } $("#upload-" + number + " .progress").text(message); }, setName: function(text) { $("#progress-report-name").text(text); }, setStatus: function(text) { $("#progress-report-status").text(text); }, setProgress: function(val) { $("#progress-report-bar").css("width", Math.ceil(val * 100) + "%"); } }) .bind("change", function() { var files = this.files; var total = files.length; var $files = $("#progress-files").empty(); var size = 0; $.each(files, function(index, file) { size += file.fileSize; $files.append("<li id=\\"upload-" + index + "\\">" + file.fileName + ", " + Math.round(file.fileSize / 1024) + "kB <span class=\\"progress\\"></span></li>"); }); $files.append("<li>Total: " + total + " files, " + Math.round(size / 1024) + "kB</li>"); }); $("#form-multiple-upload").bind("submit", function() { $("#' . $field_id . '").trigger("html5_upload.start"); return false; }); }); ');
<?php defined('SYSPATH') or die('No direct access allowed.'); /** * AddThis JavaScripts * * @package Anqh * @author Antti Qvickström * @copyright (c) 2011 Antti Qvickström * @license http://www.opensource.org/licenses/mit-license.php MIT license */ if ($google_analytics = Kohana::$config->load('site.google_analytics')) { // Google Analytics integration echo HTML::script_source("\nvar addthis_config;\nhead.ready('google-analytics',\tfunction() {\n\taddthis_config = {\n\t\tdata_ga_tracker: tracker,\n\t\tdata_track_clickback: true,\n\t\tusername: '******'\n\t};\n\n\tvar at = document.createElement('script'); at.type = 'text/javascript'; at.async = true;\n\tat.src = 'http://s7.addthis.com/js/250/addthis_widget.js';\n\t(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(at);\n});\n"); } else { // Default echo HTML::script('http://s7.addthis.com/js/250/addthis_widget.js#username=' . $id); }
/** * JavaScript source code block * * @param string|array $source * @return string */ public static function script_source($source) { $compiled = ''; if (is_array($source)) { foreach ($source as $script) { $compiled .= HTML::script_source($script); } } else { $compiled = implode("\n", array('<script>', trim($source), '</script>')); } return $compiled; }
<?php defined('SYSPATH') or die('No direct access allowed.'); /** * Facebook Connect * * @package Anqh * @author Antti Qvickström * @copyright (c) 2011 Antti Qvickström * @license http://www.opensource.org/licenses/mit-license.php MIT license */ ?> <div id="fb-root"></div> <?php echo HTML::script_source("\nwindow.fbAsyncInit = function() {\n\tFB.init({\n\t\tappId: " . (!is_string($id) ? 'null' : "'" . $id . "'") . ",\n\t\tstatus: true,\n\t\tcookie: true,\n\t\txfbml: true\n\t});\n};\n\nhead.js({ 'facebook-connect': document.location.protocol + '//connect.facebook.net/en_US/all.js' });\n/*\n(function() {\n\tvar e = document.createElement('script');\n\te.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';\n\te.async = true;\n\tdocument.getElementById('fb-root').appendChild(e);\n}());\n*/\n");