当前位置: 首页>>代码示例>>PHP>>正文


PHP Ansel::point2Deg方法代码示例

本文整理汇总了PHP中Ansel::point2Deg方法的典型用法代码示例。如果您正苦于以下问题:PHP Ansel::point2Deg方法的具体用法?PHP Ansel::point2Deg怎么用?PHP Ansel::point2Deg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ansel的用法示例。


在下文中一共展示了Ansel::point2Deg方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: html

 /**
  * Build the HTML for the widget
  *
  * @return string
  */
 public function html()
 {
     global $page_output;
     $view = $GLOBALS['injector']->getInstance('Horde_View');
     $view->addTemplatePath(ANSEL_TEMPLATES . '/widgets');
     $view->title = _("Location");
     $view->background = $this->_style->background;
     $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
     $geodata = $ansel_storage->getImagesGeodata($this->_params['images']);
     $viewType = $this->_view->viewType();
     // Exit early?
     if (count($geodata) == 0 && $viewType != 'Image') {
         return '';
     }
     // Setup map and javascript includes
     Horde::initMap();
     $page_output->addScriptFile('map.js');
     $page_output->addScriptFile('popup.js', 'horde');
     $page_output->addScriptFile('widgets/geotag.js');
     // Values needed by map javascript
     $relocate_url = Horde::url('map_edit.php', true);
     $rtext = _("Relocate this image");
     $dtext = _("Delete geotag");
     $thisTitleText = _("This image");
     $otherTitleText = _("Other images in this gallery");
     $geotagUrl = $GLOBALS['registry']->getServiceLink('ajax', 'ansel')->setRaw(true);
     $geotagUrl->url .= 'imageSaveGeotag';
     $permsEdit = (int) $this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
     $view->haveEdit = $permsEdit;
     // URL for updating selected layer
     $layerUrl = $GLOBALS['registry']->getServiceLink('ajax', 'ansel')->setRaw(true);
     $layerUrl->url .= 'setPrefValue';
     // And the current defaultLayer, if any.
     $defaultLayer = $GLOBALS['prefs']->getValue('current_maplayer');
     // Add extra information to the JSON data to be sent:
     foreach ($geodata as $id => $data) {
         $geodata[$id]['icon'] = (string) Ansel::getImageUrl($geodata[$id]['image_id'], 'mini', true);
         $geodata[$id]['markerOnly'] = $viewType == 'Image';
         $geodata[$id]['link'] = (string) Ansel::getUrlFor('view', array('view' => 'Image', 'gallery' => $this->_view->gallery->id, 'image' => $geodata[$id]['image_id']), true);
     }
     // Image view?
     $view->isImageView = $viewType == 'Image';
     // If this is an image view, get the other gallery images
     if ($viewType == 'Image' && !empty($geodata)) {
         $image_id = $this->_view->resource->id;
         $others = $this->_getGalleryImagesWithGeodata();
         foreach ($others as $id => $data) {
             if ($id != $image_id) {
                 $others[$id]['icon'] = (string) Ansel::getImageUrl($others[$id]['image_id'], 'mini', true);
                 $others[$id]['link'] = (string) Ansel::getUrlFor('view', array('view' => 'Image', 'gallery' => $this->_view->gallery->id, 'image' => $others[$id]['image_id']), true);
             } else {
                 unset($others[$id]);
             }
         }
         $geodata = array_values(array_merge($geodata, $others));
         $view->geodata = $geodata;
     }
     if ($permsEdit) {
         // Image view, but no geotags, provide ability to add it.
         $addurl = Horde::url('map_edit.php')->add('image', $this->_params['images'][0]);
         $view->addLink = $addurl->link(array('onclick' => Horde::popupJs(Horde::url('map_edit.php'), array('params' => array('image' => $this->_params['images'][0]), 'urlencode' => true, 'width' => '750', 'height' => '600')) . 'return false;'));
         $view->imgs = $ansel_storage->getRecentImagesGeodata($GLOBALS['registry']->getAuth());
         if (count($view->imgs) > 0) {
             foreach ($view->imgs as $id => &$data) {
                 if (!empty($data['image_location'])) {
                     $data['title'] = $data['image_location'];
                 } else {
                     $data['title'] = sprintf('%s %s', Ansel::point2Deg($data['image_latitude'], true), Ansel::point2Deg($data['image_longitude']));
                 }
                 $data['add_link'] = $addurl->link(array('title' => $title, 'onclick' => "Ansel.widgets.geotag.setLocation(" . $image_id . ",'" . $data['image_latitude'] . "', '" . $data['image_longitude'] . "'); return false"));
             }
         }
     }
     // Build the javascript to handle the map on the gallery/image views.
     $json = Horde_Serialize::serialize(array_values($geodata), Horde_Serialize::JSON);
     $js_params = array('smallMap' => 'ansel_map_small', 'mainMap' => 'ansel_map', 'viewType' => $viewType, 'relocateUrl' => strval($relocate_url), 'relocateText' => $rtext, 'markerLayerTitle' => $thisTitleText, 'imageLayerTitle' => $otherTitleText, 'defaultBaseLayer' => $defaultLayer, 'deleteGeotagText' => $dtext, 'hasEdit' => $permsEdit, 'updateEndpoint' => strval($geotagUrl), 'layerUpdateEndpoint' => strval($layerUrl), 'layerUpdatePref' => 'current_maplayer', 'geocoder' => $GLOBALS['conf']['maps']['geocoder']);
     $js = array('Ansel.widgets = Ansel.widgets || {};', 'Ansel.widgets.geotag = new AnselGeoTagWidget(' . $json . ',' . Horde_Serialize::serialize($js_params, Horde_Serialize::JSON) . ');');
     $page_output->addInlineScript($js, true);
     if (count($geodata)) {
         $page_output->addInlineScript('Ansel.widgets.geotag.doMap();', true);
     }
     return $view->render('geotag');
 }
开发者ID:Gomez,项目名称:horde,代码行数:88,代码来源:Geotag.php

示例2: imageSaveGeotag

 /**
  * Save/update image geotag.
  *
  * @return object  Object with 2 parameters:
  *   - message
  *   - response
  */
 public function imageSaveGeotag()
 {
     global $injector, $registry;
     $type = $this->vars->action;
     $location = $this->vars->location;
     $lat = $this->vars->lat;
     $lng = $this->vars->lng;
     $img = $this->vars->img;
     $result = new stdClass();
     $result->response = 0;
     if (empty($img) || $type == 'location' && empty($location) || (empty($type) || $type == 'all') && ($type == 'all' && empty($lat))) {
         return new Horde_Core_Ajax_Response_Prototypejs($result);
     }
     // Get the image and gallery to check perms
     try {
         $ansel_storage = $injector->getInstance('Ansel_Storage');
         $image = $ansel_storage->getImage((int) $img);
         $gallery = $ansel_storage->getGallery($image->gallery);
     } catch (Ansel_Exception $e) {
         return new Horde_Core_Ajax_Response_Prototypejs($result);
     }
     // Bail out if no perms on the image.
     if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
         return new Horde_Core_Ajax_Response_Prototypejs($result);
     }
     switch ($type) {
         case 'geotag':
             $image->geotag($lat, $lng, !empty($location) ? $location : '');
             $result->response = 1;
             break;
         case 'location':
             $image->location = !empty($location) ? urldecode($location) : '';
             $image->save();
             $result->response = 1;
             $result->message = htmlentities($image->location);
             break;
         case 'untag':
             $image->geotag('', '', '');
             // Now get the "add geotag" stuff
             $addurl = Horde::url('map_edit.php')->add('image', $img);
             $addLink = $addurl->link(array('onclick' => Horde::popupJs(Horde::url('map_edit.php'), array('params' => array('image' => $img), 'urlencode' => true, 'width' => '750', 'height' => '600')) . 'return false;'));
             $imgs = $ansel_storage->getRecentImagesGeodata($registry->getAuth());
             if (count($imgs) > 0) {
                 $imgsrc = '<div class="ansel_location_sameas">';
                 foreach ($imgs as $id => $data) {
                     $title = empty($data['image_location']) ? Ansel::point2Deg($data['image_latitude'], true) . ' ' . Ansel::point2Deg($data['image_longitude']) : $data['image_location'];
                     $imgsrc .= $addurl->link(array('title' => $title, 'onclick' => "Ansel.widgets.geotag.setLocation('" . $data['image_latitude'] . "', '" . $data['image_longitude'] . "');return false")) . '<img src="' . Ansel::getImageUrl($id, 'mini', true) . '" alt="[image]" /></a>';
                 }
                 $imgsrc .= '</div>';
                 $result->message = sprintf(_("No location data present. Place using %smap%s or click on image to place at the same location."), $addLink, '</a>') . $imgsrc;
             } else {
                 $result->message = sprintf(_("No location data present. You may add some %s."), $addLink . _("here") . '</a>');
             }
             $result->response = 1;
             break;
     }
     return new Horde_Core_Ajax_Response_Prototypejs($result);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:65,代码来源:Handler.php

示例3: _

?>
" class="button" type="submit" />
  </form>
 </div>
 <div class="ansel_location_sameas"><?php 
echo _("Click on a thumbnail to locate at the same point.");
?>
<br />
 <?php 
foreach ($this->imgs as $id => $data) {
    ?>
   <?php 
    if ($this->image_id != $id) {
        ?>
   <?php 
        $title = !empty($data['image_location']) ? Ansel::point2Deg($data['image_latitude'], true) . ' ' . Ansel::point2Deg($data['image_longitude']) : $data['image_location'];
        $url = new Horde_Url('#');
        echo $url->link(array('title' => $title, 'id' => 'geo_' . $id));
        ?>
        <img src="<?php 
        echo Ansel::getImageUrl($id, 'mini', true);
        ?>
" alt="[thumbnail]" /></a>
   <?php 
    }
    ?>
 <?php 
}
?>
 </div>
 <div class="control" style="vertical-align:bottom;">
开发者ID:jubinpatel,项目名称:horde,代码行数:31,代码来源:map_edit.html.php


注:本文中的Ansel::point2Deg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。