示例#1
0
 /**
  * render a location
  *
  * @param string the id, with possible options or variant
  * @return string the rendered text
  **/
 public static function render_location($id)
 {
     global $context;
     // the required library
     include_once $context['path_to_root'] . 'locations/locations.php';
     // check all args
     $attributes = preg_split("/\\s*,\\s*/", $id, 3);
     // [location=latitude, longitude, label]
     if (count($attributes) === 3) {
         $item = array();
         $item['latitude'] = $attributes[0];
         $item['longitude'] = $attributes[1];
         $item['description'] = $attributes[2];
         // [location=id, label] or [location=id]
     } else {
         $id = $attributes[0];
         // a record is mandatory
         if (!($item = Locations::get($id))) {
             if (Surfer::is_member()) {
                 $output = '[location=' . $id . ']';
                 return $output;
             } else {
                 $output = '';
                 return $output;
             }
         }
         // build a small dynamic image if we cannot use Google maps
         if (!isset($context['google_api_key']) || !$context['google_api_key']) {
             $output = BR . '<img src="' . $context['url_to_root'] . 'locations/map_on_earth.php?id=' . $item['id'] . '" width="310" height="155" alt="' . $item['geo_position'] . '" />' . BR;
             return $output;
         }
         // use provided text, if any
         if (isset($attributes[1])) {
             $item['description'] = $attributes[1] . BR . $item['description'];
         }
     }
     // map on Google
     $output = Locations::map_on_google(array($item));
     return $output;
 }
示例#2
0
文件: view.php 项目: rair/yacs
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
include_once 'locations.php';
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
    $id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
    $id = $context['arguments'][0];
}
$id = strip_tags($id);
// get the item from the database
$item = Locations::get($id);
// get the related anchor, if any
$anchor = NULL;
if (isset($item['anchor']) && $item['anchor']) {
    $anchor = Anchors::get($item['anchor']);
}
// the anchor has to be viewable by this surfer
if (!is_object($anchor) || $anchor->is_viewable()) {
    $permitted = TRUE;
} else {
    $permitted = FALSE;
}
// load the skin, maybe with a variant
load_skin('locations', $anchor);
// current item
if (isset($item['id'])) {