本文整理汇总了PHP中Horde::initMap方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde::initMap方法的具体用法?PHP Horde::initMap怎么用?PHP Horde::initMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde
的用法示例。
在下文中一共展示了Horde::initMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _content
/**
*/
protected function _content()
{
global $page_output, $registry, $injector, $prefs;
Horde::initMap();
$page_output->addScriptFile('map.js');
$page_output->addScriptFile('blocks/geotag.js');
try {
$images = $injector->getInstance('Ansel_Storage')->getRecentImagesGeodata(null, 0, min($this->_params['limit'], 100));
} catch (Ansel_Exception $e) {
return $e->getMessage();
}
$images = array_reverse($images);
foreach ($images as $key => $image) {
$id = $image['image_id'];
$gallery = $injector->getInstance('Ansel_Storage')->getGallery($image['gallery_id']);
// Don't show locked galleries in the block.
if (!$gallery->isOldEnough() || $gallery->hasPasswd()) {
continue;
}
$style = $gallery->getStyle();
// Generate the image view url
$url = Ansel::getUrlFor('view', array('view' => 'Image', 'slug' => $gallery->get('slug'), 'gallery' => $gallery->id, 'image' => $id, 'gallery_view' => $style->gallery_view), true);
$images[$key]['icon'] = strval(Ansel::getImageUrl($images[$key]['image_id'], 'mini', true));
$images[$key]['link'] = strval($url);
$images[$key]['markerOnly'] = false;
}
// URL for updating selected layer
$layerUrl = $registry->getServiceLink('ajax', 'ansel')->setRaw(true);
$layerUrl->url .= 'setPrefValue';
// And the current defaultLayer, if any.
$defaultLayer = $prefs->getValue('current_maplayer');
$opts = array('layerUpdateEndpoint' => strval($layerUrl), 'layerUpdatePref' => 'current_maplayer', 'defaultBaseLayer' => $defaultLayer);
$json = Horde_Serialize::serialize(array_values($images), Horde_Serialize::JSON);
$js = array('var opts = ' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON), 'new AnselBlockGeoTag(' . $json . ', opts);');
$page_output->addInlineScript($js, true);
return '<div id="ansel_map" style="height:' . $this->_params['height'] . 'px;"></div>';
}
示例2: substr
$taskAlarmParams .= '</ul>';
break;
}
$eventAlarmParams .= '<br />';
$taskAlarmParams .= '<br />';
}
$eventAlarmParams = substr($eventAlarmParams, 0, -6) . '</div>';
$taskAlarmParams = substr($taskAlarmParams, 0, -6) . '</div>';
}
$injector->getInstance('Horde_Core_Factory_Imple')->create('Kronolith_Ajax_Imple_TagAutoCompleter', array('box' => 'kronolithEventACBox', 'id' => 'kronolithEventTags', 'pretty' => true));
$injector->getInstance('Horde_Core_Factory_Imple')->create('Kronolith_Ajax_Imple_TagAutoCompleter', array('box' => 'kronolithCalendarinternalACBox', 'id' => 'kronolithCalendarinternalTags', 'pretty' => true, 'triggerContainer' => 'kronolithACCalendarTriggerContainer'));
$injector->getInstance('Horde_Core_Factory_Imple')->create('Kronolith_Ajax_Imple_TagAutoCompleter', array('box' => 'kronolithTaskACBox', 'id' => 'kronolithTaskTags', 'pretty' => true));
$injector->getInstance('Horde_Core_Factory_Imple')->create('Kronolith_Ajax_Imple_ContactAutoCompleter', array('box' => 'kronolithAttendeesACBox', 'id' => 'kronolithEventAttendees', 'onAdd' => 'function(a) { KronolithCore.addAttendee(a); KronolithCore.checkOrganizerAsAttendee(); }', 'onRemove' => 'KronolithCore.removeAttendee.bind(KronolithCore)', 'pretty' => true, 'triggerContainer' => 'kronolithAttendeesACTriggerContainer', 'beforeUpdate' => 'function(a) { return KronolithCore.normalizeAttendee(a); }'));
$injector->getInstance('Horde_Core_Factory_Imple')->create('Kronolith_Ajax_Imple_ResourceAutoCompleter', array('box' => 'kronolithResourceACBox', 'id' => 'kronolithEventResources', 'onAdd' => 'KronolithCore.addResource.bind(KronolithCore)', 'onRemove' => 'KronolithCore.removeResource.bind(KronolithCore)', 'pretty' => true, 'triggerContainer' => 'kronolithResourceACTriggerContainer'));
if ($conf['maps']['driver']) {
Horde::initMap();
}
$time_jobs = $time_clients = false;
if ($registry->hasMethod('time/listJobTypes')) {
try {
$time_jobs = $registry->time->listJobTypes(array('enabled' => true));
$time_clients = $registry->time->listClients();
} catch (Horde_Exception_PushApp $e) {
}
}
$topbar = $injector->getInstance('Horde_View_Topbar');
$topbar->search = true;
$injector->getInstance('Kronolith_Ajax')->init();
require KRONOLITH_TEMPLATES . '/dynamic/index.inc';
echo $injector->getInstance('Kronolith_View_Sidebar');
$page_output->footer();
示例3: 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');
}