/** * Load jssor libs * * @global array $context * @param boolean $withCSS option to load defaut CSS for jssor slider */ public static function Load($withCSS = true) { global $context; // note : we assume jquery is loaded if (isset($context['with_debug']) && $context['with_debug'] === 'Y') { Page::defer_script('included/jssor/js/jssor.js'); Page::defer_script('included/jssor/js/jssor.slider.js'); } else { // contains both dev files minified Page::defer_script('included/jssor/js/jssor.slider.mini.js'); } if ($withCSS) { Page::load_style('included/jssor/jssor.css'); } }
if (!$item['latitude'] || !$item['longitude']) { list($item['latitude'], $item['longitude']) = preg_split('/[\\s,;]+/', $item['geo_position']); } // link to anchor page $description = ''; if ($anchor = Anchors::get($item['anchor'])) { $description .= Skin::build_link($anchor->get_url(), $anchor->get_title()); } // item type if (strpos($item['anchor'], 'user:'******'user'; } else { $type = 'other'; } // do the job Page::defer_script('http://maps.google.com/maps/api/js?v=3&sensor=false'); Page::insert_script('var point = new google.maps.LatLng(parseFloat("' . $item['latitude'] . '"), parseFloat("' . $item['longitude'] . '"));' . "\n" . "\n" . 'var mapOptions = {' . "\n" . ' zoom: 10,' . "\n" . ' center: point,' . "\n" . ' mapTypeId: google.maps.MapTypeId.ROADMAP' . "\n" . '};' . "\n" . 'var map = new google.maps.Map($("#map")[0], mapOptions);' . "\n" . ' var marker = new google.maps.Marker({ position: point, map: map });' . "\n" . ' var infoWindow = new google.maps.InfoWindow();' . "\n" . 'google.maps.event.addDomListener(marker, "click", function() {' . "\n" . ' infoWindow.setContent("' . addcslashes($description, '\'\\"' . "\n\r") . '");' . "\n" . ' infoWindow.open(map, marker);' . "\n" . ' });' . "\n" . '$("body").bind("yacs", function(e) {' . "\n" . ' google.maps.event.trigger(map, "resize");' . "\n" . ' map.setZoom( map.getZoom() );' . "\n" . ' map.setCenter(point);' . "\n" . '});' . "\n"); } // geo country if ($item['geo_country']) { $context['text'] .= '<p>' . sprintf(i18n::s('Regional position: %s'), $item['geo_country']) . "</p>\n"; } // display the full text $context['text'] .= Skin::build_block($item['description'], 'description'); // information on uploader $details = array(); if (Surfer::is_member() && $item['edit_name']) { $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])); } // page details if (is_array($details)) {
function layout($result) { global $context; // load skin for ajax request load_skin(); // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // infinite scroll is a option $infinite = $this->has_variant('infinite'); // column grid width may have been setted thru variant if (!($grid_width = $this->has_variant('grid'))) { $grid_width = MC_GRID_DEFAULT; } // wrappers if ($infinite) { $text .= '<div class="mc-infinite">'; } $text .= '<div class="mc-wrap" >' . "\n"; while ($item = SQL::fetch($result)) { // get the object interface, this may load parent and overlay $entity = new $this->listed_type($item); // link $url = $entity->get_permalink(); // title $title = $entity->get_title(); // intro $intro = Codes::beautify_introduction($entity->get_introduction()); if ($intro) { $intro = BR . $intro; } // image $thumb = ''; if (!$this->has_variant('no_thumb')) { if ($thumb = trim($entity->get_thumbnail_url())) { // use parameter of the control panel for this one $options = ''; if (isset($context['classes_for_thumbnail_images'])) { $options = 'class="' . $context['classes_for_thumbnail_images'] . '" '; } // build the complete HTML element $thumb = '<img src="' . $thumb . '" alt="" title="' . encode_field($title) . '" ' . $options . ' />' . "\n"; } else { $thumb = MAP_IMG; } } // use the image as a link to the target page if ($thumb) { $thumb = Skin::build_link($url, $thumb, 'basic', $title); } // use list text of overlay if any $list = ''; if (is_object($entity->overlay)) { $list = $entity->overlay->get_text('list'); } // list articles, if any $childs = $entity->get_childs('articles', 0, 5, 'alistapart'); // content $content = $thumb . $intro . $list; if (isset($childs['article'])) { $content .= $childs['article']; } // add a block, guess the html tag from context if (isset($context['SKIN_HTML5'])) { switch ($this->listed_type) { case 'article': $tag = 'article'; break; case 'section': case 'category': $tag = 'section'; break; case 'user': default: $tag = 'div'; } } else { $tag = 'div'; } $text .= '<' . $tag . ' class="mc-block">' . '<h3>' . $title . '</h3>' . $content . '</' . $tag . '>' . "\n"; } // end wrappers if ($infinite) { $text .= '</div>'; } $text .= '</div>' . "\n"; if (!isset($context['AJAX_REQUEST']) || $context['AJAX_REQUEST'] == false) { // we have bound styles and scripts $this->load_scripts_n_styles(); // initialize js Page::insert_script('Mosaic.init(' . $grid_width . ')'); // infinite scroll js lib if ($infinite) { Page::defer_script('layouts/layout_as_mosaic/jquery.infinitescroll.min.js'); Page::insert_script('Mosaic.infiniteScroll()'); } } else { // insert javascript init at the end of text $text .= '<script>' . 'Mosaic.init(' . $grid_width . ')</script>' . "\n"; if ($infinite) { $text .= '<script>' . 'Mosaic.infiniteScroll()</script>' . "\n"; } } // end of processing SQL::free($result); return $text; }
/** * Load in current page style sheets and javascript * files binded with the overlay. * * Filenames must be same as classname, plus extension. * * Usage : $this->load_scripts_n_styles(); * within parts of your overlay witch need those dependancies. * (render(), get_view_text() ... ) * * Note the function will also call dependancies of parent class. * * @param type $myclass, argument used by the recursive call. */ protected final function load_scripts_n_styles($myclass = '') { // fuse not to search twice for bound files static $fuse_called = false; // function is always called by DEV without specifying the class. // fuse should not block recursive calls from the firt call, // which are always done with a classname argument if (!$myclass && $fuse_called) { return; } $fuse_called = true; if (!$myclass) { $myclass = get_class($this); } $parent = get_parent_class($myclass); // load scripts (if exist) Page::load_style(strtolower('overlays/' . $myclass . '/' . $myclass . '.css')); Page::defer_script(strtolower('overlays/' . $myclass . '/' . $myclass . '.js')); // recursive call to parent class, stop on "Overlay" if ($parent != '' && $parent != 'Overlay') { $parent::load_scripts_n_styles($parent); } }
// display info on current version if (isset($item['id'])) { // the last poster if (isset($item['edit_id']) && $item['edit_id']) { $text = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']) . ' ' . Skin::build_date($item['edit_date']); $fields[] = array(i18n::s('Posted by'), $text); } } // geo place name $label = i18n::s('Place name'); $input = '<input type="text" name="geo_place_name" id="geo_place_name" size="40" value="' . encode_field($item['geo_place_name']) . '" />'; // geocoding based on Google service if (isset($context['google_api_key']) && $context['google_api_key']) { // encode on click $input .= '<button type="button" id="encode" onclick="lookupAddress($(\'#geo_place_name\').val()); return false;">' . encode_field(i18n::s('Encode this address')) . '</button>' . "\n"; Page::defer_script("http://maps.google.com/maps?file=api&v=3&key=" . $context['google_api_key']); Page::insert_script('var geocoder = null;' . "\n" . 'function lookupAddress(address) {' . "\n" . ' if(!geocoder) {' . "\n" . ' geocoder = new google.maps.Geocoder();' . "\n" . ' }' . "\n" . ' if(geocoder) {' . "\n" . ' geocoder.geocode( { "address":container.geo_place_name.value},' . "\n" . ' function(point,status) {' . "\n" . ' if (!point) {' . "\n" . ' alert("' . i18n::s('This address has not been found') . '");' . "\n" . ' } else {' . "\n" . ' $(\'#geo_position\').val( point[0].geometry.location.lat() + ", " + point[0].geometry.location.lng() );' . "\n" . ' alert("' . i18n::s('This address has been encoded as') . '\\n" + point[0].geometry.location.lat() + ", " + point[0].geometry.location.lat());' . "\n" . ' }' . "\n" . ' }' . "\n" . ' )' . "\n" . ' }' . "\n" . '}' . "\n"); } $hint = i18n::s('Street address, city, country'); $fields[] = array($label, $input, $hint); // geo location $label = i18n::s('Coordinates'); $input = '<input type="text" id="geo_position" name="geo_position" size="40" value="' . encode_field($item['geo_position']) . '" />'; $hint = i18n::s('Latitude, Longitude -- west longitudes and south latitudes are negative'); $fields[] = array($label, $input, $hint); // geo country $label = i18n::s('Country'); $input = '<input type="text" name="geo_country" size="40" value="' . encode_field($item['geo_country']) . '" />'; $hint = i18n::s('For regional positioning'); $fields[] = array($label, $input, $hint); // the description