api.mapscommon.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. <?php
  2. /**
  3. * Checks is some switch id linked with
  4. *
  5. * @param array $alllinks Array of id=>parentid
  6. * @param int $traceid Switch ID wich will be traced
  7. * @param int $checkid Switch ID to check
  8. *
  9. * @return bool
  10. */
  11. function sm_MapIsLinked($alllinks, $traceid, $checkid) {
  12. $road = array();
  13. $road[] = $traceid;
  14. $x = $traceid;
  15. while (!empty($x)) {
  16. foreach ($alllinks as $id => $parentid) {
  17. if ($x == $id) {
  18. $road[] = $parentid;
  19. $x = $parentid;
  20. }
  21. }
  22. }
  23. if (in_array($checkid, $road)) {
  24. $result = true;
  25. } else {
  26. $result = false;
  27. }
  28. return ($result);
  29. }
  30. /**
  31. * Returns array of switch parent switches with himself
  32. *
  33. * @param array $alllinks all switches links
  34. * @param int $traceid switch name to trace
  35. *
  36. * @return array
  37. */
  38. function zb_SwitchGetParents($alllinks, $traceid) {
  39. $road = array();
  40. $road[] = $traceid;
  41. $x = $traceid;
  42. while (!empty($x)) {
  43. foreach ($alllinks as $id => $parentid) {
  44. if ($x == $id) {
  45. $road[] = $parentid;
  46. $x = $parentid;
  47. }
  48. }
  49. }
  50. $result = $road;
  51. return ($result);
  52. }
  53. /**
  54. * Checks is loop possible after setting for switchId something as parent device
  55. *
  56. * @param array $alllinks
  57. * @param int $switchId
  58. * @param int $setParent
  59. *
  60. * @return bool
  61. */
  62. function sm_CheckLoop($alllinks, $switchId, $setParent) {
  63. $result = false;
  64. $tmpArr = array();
  65. if (!empty($switchId)) {
  66. if (sm_MapIsLinked($alllinks, $setParent, $switchId)) {
  67. $result = false;
  68. } else {
  69. $result = true;
  70. }
  71. } else {
  72. $result = true;
  73. }
  74. return ($result);
  75. }
  76. /**
  77. * Returns full map of switch links
  78. *
  79. * @param int $traceid switch ID to trace uplinks
  80. *
  81. * @return string
  82. */
  83. function sm_MapDrawSwitchUplinks($traceid = '') {
  84. global $ubillingConfig;
  85. $ym_conf = $ubillingConfig->getYmaps();
  86. $query = "SELECT * from `switches`";
  87. $tmpSwitches = simple_queryall($query);
  88. $allswitches = array();
  89. $alllinks = array();
  90. $result = '';
  91. //dead switches detection
  92. $dead_raw = zb_StorageGet('SWDEAD');
  93. $deadarr = array();
  94. if ($dead_raw) {
  95. $deadarr = unserialize($dead_raw);
  96. }
  97. if (!empty($tmpSwitches)) {
  98. //transform array to id=>switchdata
  99. foreach ($tmpSwitches as $io => $each) {
  100. $allswitches[$each['id']] = $each;
  101. }
  102. //making id=>parentid array if needed
  103. if (!empty($traceid)) {
  104. foreach ($tmpSwitches as $io => $each) {
  105. $alllinks[$each['id']] = $each['parentid'];
  106. }
  107. }
  108. }
  109. if (!empty($allswitches)) {
  110. foreach ($allswitches as $io => $each) {
  111. if (!empty($each['parentid'])) {
  112. if (isset($allswitches[$each['parentid']])) {
  113. if (($allswitches[$each['parentid']]['geo'] != '') AND ( $each['geo'] != '')) {
  114. $coord1 = $each['geo'];
  115. $coord2 = $allswitches[$each['parentid']]['geo'];
  116. $hint = $each['location'] . ' ' . $each['ip'] . ' → ' . $allswitches[$each['parentid']]['location'] . ' ' . $allswitches[$each['parentid']]['ip'];
  117. if ((!isset($deadarr[$each['ip']])) AND ( !isset($deadarr[$allswitches[$each['parentid']]['ip']]))) {
  118. $color = '#00FF00';
  119. } else {
  120. $color = '#FF0000';
  121. }
  122. //trace mode
  123. if (!empty($traceid)) {
  124. //switch is traced device
  125. if ($each['id'] == $traceid) {
  126. $width = 5;
  127. $result .= sm_MapAddLine($coord1, $coord2, $color, $hint, $width);
  128. } else {
  129. //detecting uplinks
  130. if (sm_MapIsLinked($alllinks, $traceid, $each['id'])) {
  131. $width = 3;
  132. $result .= sm_MapAddLine($coord1, $coord2, $color, $hint, $width);
  133. }
  134. }
  135. } else {
  136. $width = 1;
  137. $result .= sm_MapAddLine($coord1, $coord2, $color, $hint, $width);
  138. }
  139. }
  140. }
  141. }
  142. }
  143. }
  144. return ($result);
  145. }
  146. /**
  147. * Returns indications point to nuclear strikes :)
  148. *
  149. * @return string
  150. */
  151. function sm_MapDrawSwitchesCoverage() {
  152. $ym_conf = rcms_parse_ini_file(CONFIG_PATH . "ymaps.ini");
  153. $query = "SELECT * from `switches` WHERE `geo` != '' ";
  154. $allswitches = simple_queryall($query);
  155. $result = '';
  156. if (!empty($allswitches)) {
  157. foreach ($allswitches as $io => $each) {
  158. $geo = mysql_real_escape_string($each['geo']);
  159. $result .= sm_MapAddCircle($geo, '100');
  160. }
  161. }
  162. return ($result);
  163. }
  164. /**
  165. * Returns full map marks for switches with filled GEO field
  166. *
  167. * @return string
  168. *
  169. */
  170. function sm_MapDrawSwitches() {
  171. $ym_conf = rcms_parse_ini_file(CONFIG_PATH . "ymaps.ini");
  172. $query = "SELECT * from `switches` WHERE `geo` != '' ";
  173. $allswitches = simple_queryall($query);
  174. $uplinkTraceIcon = wf_img('skins/ymaps/uplinks.png', __('Show links'));
  175. $switchEditIcon = wf_img('skins/icon_edit.gif', __('Edit'));
  176. $switchPollerIcon = wf_img('skins/snmp.png', __('SNMP query'));
  177. $switchLocatorIcon = wf_img('skins/icon_search_small.gif', __('Zoom in'));
  178. $footerDelimiter = wf_tag('br');
  179. $result = '';
  180. //dead switches detection
  181. $dead_raw = zb_StorageGet('SWDEAD');
  182. $deadarr = array();
  183. if ($dead_raw) {
  184. $deadarr = unserialize($dead_raw);
  185. }
  186. if (!empty($allswitches)) {
  187. foreach ($allswitches as $io => $each) {
  188. $geo = mysql_real_escape_string($each['geo']);
  189. $title = mysql_real_escape_string($each['ip']);
  190. //switch hint content
  191. $content = mysql_real_escape_string($each['location']);
  192. $iconlabel = '';
  193. if (!isset($deadarr[$each['ip']])) {
  194. $footer = __('Switch alive');
  195. if ($ym_conf['CANVAS_RENDER']) {
  196. if ($ym_conf['CANVAS_RENDER_IGNORE_LABELED']) {
  197. if ($ym_conf['ALIVE_LABEL']) {
  198. $icon = sm_MapGoodIcon();
  199. } else {
  200. $icon = sm_MapGoodIcon(false);
  201. }
  202. } else {
  203. $icon = sm_MapGoodIcon(false);
  204. }
  205. } else {
  206. $icon = sm_MapGoodIcon();
  207. }
  208. //alive mark labels
  209. if ($ym_conf['ALIVE_LABEL']) {
  210. $iconlabel = $each['location'];
  211. } else {
  212. $iconlabel = '';
  213. }
  214. } else {
  215. $footer = __('Switch dead');
  216. if ($ym_conf['CANVAS_RENDER']) {
  217. if ($ym_conf['CANVAS_RENDER_IGNORE_LABELED']) {
  218. if ($ym_conf['DEAD_LABEL']) {
  219. $icon = sm_MapBadIcon();
  220. } else {
  221. $icon = sm_MapBadIcon(false);
  222. }
  223. } else {
  224. $icon = sm_MapBadIcon(false);
  225. }
  226. } else {
  227. $icon = sm_MapBadIcon();
  228. }
  229. //dead mark labels
  230. if ($ym_conf['DEAD_LABEL']) {
  231. if (!empty($each['location'])) {
  232. $iconlabel = $each['location'];
  233. } else {
  234. $iconlabel = __('No location set');
  235. }
  236. } else {
  237. $iconlabel = '';
  238. }
  239. }
  240. //switch footer controls
  241. $footer .= $footerDelimiter;
  242. $footer .= wf_tag('a', false, '', 'href="?module=switches&edit=' . $each['id'] . '"') . $switchEditIcon . wf_tag('a', true) . ' ';
  243. if (!empty($each['snmp'])) {
  244. $footer .= wf_tag('a', false, '', 'href="?module=switchpoller&switchid=' . $each['id'] . '"') . $switchPollerIcon . wf_tag('a', true) . ' ';
  245. }
  246. $footer .= wf_tag('a', false, '', 'href="?module=switchmap&finddevice=' . $each['geo'] . '"') . $switchLocatorIcon . wf_tag('a', true) . ' ';
  247. if (!empty($each['parentid'])) {
  248. $uplinkTraceUrl = '?module=switchmap&finddevice=' . $each['geo'] . '&showuplinks=true&traceid=' . $each['id'];
  249. $uplinkTraceLink = wf_tag('a', false, '', 'href="' . $uplinkTraceUrl . '"') . $uplinkTraceIcon . wf_tag('a', true) . ' ';
  250. $footer .= $uplinkTraceLink;
  251. }
  252. if ($ym_conf['CANVAS_RENDER']) {
  253. $result .= sm_MapAddMark($geo, $title, $content, $footer, $icon, $iconlabel, true);
  254. } else {
  255. $result .= sm_MapAddMark($geo, $title, $content, $footer, $icon, $iconlabel, false);
  256. }
  257. }
  258. }
  259. return ($result);
  260. }
  261. /**
  262. * Returns full map marks for builds with filled GEO field
  263. *
  264. * @param int $buildIdFilter return only one build placemark
  265. *
  266. * @return string
  267. */
  268. function um_MapDrawBuilds($buildIdFilter = '') {
  269. $buildIdFilter = ubRouting::filters($buildIdFilter, 'int');
  270. $ym_conf = rcms_parse_ini_file(CONFIG_PATH . "ymaps.ini");
  271. $query = "SELECT * from `build` WHERE `geo` != '' ";
  272. //optional filter here
  273. if ($buildIdFilter) {
  274. $query .= " AND `id`='" . $buildIdFilter . "'";
  275. }
  276. $allbuilds = simple_queryall($query);
  277. $allstreets = zb_AddressGetStreetAllData();
  278. $streetData = array();
  279. $cache = new UbillingCache();
  280. $cacheTime = 3600;
  281. //reading cached data
  282. $cachedData = $cache->get('INBUILDUSERS', $cacheTime);
  283. if (empty($cachedData)) {
  284. $cachedData = array();
  285. $updateCache = true;
  286. } else {
  287. $updateCache = false;
  288. }
  289. //street id => streetname
  290. if (!empty($allstreets)) {
  291. foreach ($allstreets as $ia => $eachstreet) {
  292. $streetData[$eachstreet['id']] = $eachstreet['streetname'];
  293. }
  294. }
  295. //get apts in all builds aggregated with users logins
  296. $aptData = array();
  297. $allapts_q = "SELECT `buildid`,`apt`,`login` from `apt` JOIN `address` ON `apt`.`id`=`address`.`aptid`";
  298. $allapts = simple_queryall($allapts_q);
  299. if (!empty($allapts)) {
  300. $aptData = $allapts;
  301. }
  302. //get all user ips
  303. $alluserips = zb_UserGetAllIPs();
  304. //form alive ips array
  305. $aliveIps = array();
  306. if (file_exists("exports/nmaphostscan")) {
  307. $nmapData = file_get_contents("exports/nmaphostscan");
  308. $nmapData = explodeRows($nmapData);
  309. if (!empty($nmapData)) {
  310. foreach ($nmapData as $ic => $eachnmaphost) {
  311. $zhost = zb_ExtractIpAddress($eachnmaphost);
  312. if ($zhost) {
  313. $aliveIps[$zhost] = $zhost;
  314. }
  315. }
  316. }
  317. }
  318. $result = '';
  319. if (!empty($allbuilds)) {
  320. foreach ($allbuilds as $io => $each) {
  321. $geo = mysql_real_escape_string($each['geo']);
  322. @$streetname = $streetData[$each['streetid']];
  323. $title = wf_Link("?module=builds&action=editbuild&frommaps=true&streetid=" . $each['streetid'] . "&buildid=" . $each['id'], $streetname . ' ' . $each['buildnum'], false);
  324. $content = '';
  325. $cells = wf_TableCell(__('apt.'));
  326. $cells .= wf_TableCell(__('User'));
  327. $cells .= wf_TableCell(__('Status'));
  328. $rows = wf_tag('tr', false, 'row1', 'bgcolor=#DCDCDC') . $cells . wf_tag('tr', true);
  329. $iconlabel = '';
  330. $footer = '';
  331. $aliveUsers = 0;
  332. $usersCount = 0;
  333. if (!empty($aptData)) {
  334. //is current build in cache
  335. if (isset($cachedData[$each['id']])) {
  336. $updateCache = false;
  337. } else {
  338. $updateCache = true;
  339. }
  340. //cache in actual state
  341. if (!$updateCache) {
  342. //build extracted from cache
  343. $cachePrev = $cachedData[$each['id']];
  344. $rows = $cachePrev['rows'];
  345. $usersCount = $cachePrev['userscount'];
  346. $aliveUsers = $cachePrev['aliveusers'];
  347. } else {
  348. //all cache need to be updated
  349. foreach ($aptData as $ib => $eachapt) {
  350. if ($eachapt['buildid'] == $each['id']) {
  351. if (isset($alluserips[$eachapt['login']])) {
  352. $userIp = $alluserips[$eachapt['login']];
  353. $usersCount++;
  354. if (isset($aliveIps[$userIp])) {
  355. $aliveFlag = web_bool_led(true);
  356. $aliveUsers++;
  357. $aliveKey = 'live';
  358. } else {
  359. $aliveFlag = web_bool_led(false);
  360. $aliveKey = 'dead';
  361. }
  362. $cells = wf_TableCell($eachapt['apt']);
  363. $cells .= wf_TableCell(wf_Link('?module=userprofile&username=' . $eachapt['login'], $userIp, false));
  364. $cells .= wf_TableCell($aliveFlag, '', '', 'sorttable_customkey="' . $aliveKey . '"');
  365. $rows .= wf_TableRow($cells, 'row5');
  366. }
  367. }
  368. }
  369. $cachedData[$each['id']]['rows'] = $rows;
  370. $cachedData[$each['id']]['userscount'] = $usersCount;
  371. $cachedData[$each['id']]['aliveusers'] = $aliveUsers;
  372. }
  373. }
  374. $footer = __('Active') . ' ' . $aliveUsers . '/' . $usersCount;
  375. $icon = um_MapBuildIcon($usersCount);
  376. $content = json_encode(wf_TableBody($rows, '', 0));
  377. $title = json_encode($title);
  378. $content = str_replace('"', '', $content);
  379. $content = str_replace("'", '', $content);
  380. $content = str_replace("\n", '', $content);
  381. $title = str_replace('"', '', $title);
  382. $title = str_replace("'", '', $title);
  383. $title = str_replace("\n", '', $title);
  384. $result .= sm_MapAddMark($geo, $title, $content, $footer, $icon, $iconlabel, true);
  385. }
  386. //update cache data if required
  387. if ($updateCache) {
  388. $cache->set('INBUILDUSERS', $cachedData, $cacheTime);
  389. }
  390. }
  391. return ($result);
  392. }
  393. /**
  394. * Returns build icon class
  395. *
  396. * @param int $usersCount - count of users in building
  397. *
  398. * @return string
  399. */
  400. function um_MapBuildIcon($usersCount) {
  401. if ($usersCount < 3) {
  402. $iconClass = 'twirl#houseIcon';
  403. } else {
  404. $iconClass = 'twirl#buildingsIcon';
  405. }
  406. if ($usersCount == 0) {
  407. $iconClass = 'twirl#campingIcon';
  408. }
  409. return ($iconClass);
  410. }
  411. /**
  412. * Returns bad icon class
  413. *
  414. * @param bool $stretchy - icon resizable by content?
  415. *
  416. * @return string
  417. */
  418. function sm_MapBadIcon($stretchy = true) {
  419. if ($stretchy) {
  420. return ('twirl#redStretchyIcon');
  421. } else {
  422. return ('twirl#redIcon');
  423. }
  424. }
  425. /**
  426. * Returns good icon class
  427. *
  428. * @param bool $stretchy - icon resizable by content?
  429. *
  430. * @return string
  431. */
  432. function sm_MapGoodIcon($stretchy = true) {
  433. if ($stretchy) {
  434. return ('twirl#lightblueStretchyIcon');
  435. } else {
  436. return ('twirl#lightblueIcon');
  437. }
  438. }
  439. /**
  440. * Returns form for placing switch to selected coordinates
  441. *
  442. * @return string
  443. */
  444. function um_MapLocationBuildForm() {
  445. $query = "SELECT * from `build` WHERE `geo` IS NULL OR `geo`='' ORDER by `streetid`";
  446. $allNoGeoBuilds = simple_queryall($query);
  447. $buildData = array();
  448. $streetData = array();
  449. $cityData = array();
  450. $result = '';
  451. $selectedBuild = (wf_CheckGet(array('placebld'))) ? vf($_GET['placebld'], 3) : '';
  452. if (!empty($allNoGeoBuilds)) {
  453. $allCities = zb_AddressGetFullCityNames();
  454. $allStreets = zb_AddressGetStreetAllData();
  455. if (!empty($allStreets)) {
  456. foreach ($allStreets as $ia => $eachstreet) {
  457. $streetData[$eachstreet['id']] = $eachstreet['streetname'];
  458. if (isset($allCities[$eachstreet['cityid']])) {
  459. $cityData[$eachstreet['id']] = $allCities[$eachstreet['cityid']];
  460. }
  461. }
  462. }
  463. foreach ($allNoGeoBuilds as $io => $each) {
  464. @$streetname = $streetData[$each['streetid']];
  465. $streetcity = (isset($cityData[$each['streetid']])) ? $cityData[$each['streetid']] . ' ' : '';
  466. $buildData[$each['id']] = $streetcity . $streetname . ' - ' . $each['buildnum'];
  467. }
  468. //form construct
  469. if (cfr('BUILDS')) {
  470. $inputs = wf_Selector('buildplacing', $buildData, '', $selectedBuild, true);
  471. $inputs .= wf_Submit('Save');
  472. $result .= $inputs;
  473. }
  474. }
  475. return ($result);
  476. }
  477. /**
  478. * Returns form for placing switch to selected coordinates
  479. *
  480. * @return string
  481. */
  482. function sm_MapLocationSwitchForm() {
  483. $query = "SELECT * from `switches` WHERE `geo`='' AND `desc` NOT LIKE '%NP%'";
  484. $allNoGeoSwitches = simple_queryall($query);
  485. $switchData = array();
  486. $result = '';
  487. if (!empty($allNoGeoSwitches)) {
  488. foreach ($allNoGeoSwitches as $io => $each) {
  489. $cleanLocation = str_replace("'", '`', $each['location']);
  490. $switchData[$each['id']] = $each['ip'] . ' - ' . $cleanLocation;
  491. }
  492. //form construct
  493. if (cfr('SWITCHESEDIT')) {
  494. //preselect some switch if required
  495. if (wf_CheckGet(array('placesw'))) {
  496. $selected = $_GET['placesw'];
  497. } else {
  498. $selected = '';
  499. }
  500. $inputs = wf_Selector('switchplacing', $switchData, '', $selected, true);
  501. $inputs .= wf_Submit('Save');
  502. $result .= $inputs;
  503. }
  504. }
  505. return ($result);
  506. }
  507. /**
  508. * Returns map mark
  509. *
  510. * @param $coords - map coordinates
  511. * @param $title - ballon title
  512. * @param $content - ballon content
  513. * @param $footer - ballon footer content
  514. * @param $icon - YM icon class
  515. * @param $iconlabel - icon label string
  516. * @param $canvas - is canvas rendering enabled?
  517. *
  518. * @return string
  519. */
  520. function sm_MapAddMark($coords, $title = '', $content = '', $footer = '', $icon = 'twirl#lightblueIcon', $iconlabel = '', $canvas = false) {
  521. return (generic_MapAddMark($coords, $title, $content, $footer, $icon, $iconlabel, $canvas));
  522. }
  523. /**
  524. * Returns map circle
  525. *
  526. * @param string $coords
  527. * @param int $radius
  528. * @param string $content
  529. * @param string $hint
  530. *
  531. * @return string
  532. */
  533. function sm_MapAddCircle($coords, $radius, $content = '', $hint = '') {
  534. return (generic_MapAddCircle($coords, $radius, $content, $hint));
  535. }
  536. /**
  537. * Returns JS code to draw line within two points
  538. *
  539. * @param string $coord1
  540. * @param string $coord2
  541. * @param string $color
  542. * @param string $hint
  543. *
  544. * @return string
  545. */
  546. function sm_MapAddLine($coord1, $coord2, $color = '', $hint = '', $width = '') {
  547. return (generic_MapAddLine($coord1, $coord2, $color, $hint, $width));
  548. }
  549. /**
  550. * Initialize map container with some settings
  551. *
  552. * @param $center - map center lat,long
  553. * @param $zoom - default map zoom
  554. * @param $type - map type, may be: map, satellite, hybrid
  555. * @param $placemarks - already filled map placemarks
  556. * @param $editor - field for visual editor or geolocator
  557. * @param $lang - map language in format ru-RU
  558. *
  559. * @return void
  560. */
  561. function sm_MapInit($center, $zoom, $type, $placemarks = '', $editor = '', $lang = 'ru-RU') {
  562. show_window('', generic_MapInit($center, $zoom, $type, $placemarks, $editor, $lang));
  563. }
  564. /**
  565. * Return geo coordinates locator for builds
  566. *
  567. * @return string
  568. */
  569. function um_MapLocationFinder() {
  570. $title = wf_tag('b') . __('Place coordinates') . wf_tag('b', true);
  571. $data = um_MapLocationBuildForm();
  572. $result = generic_MapEditor('placecoords', $title, $data);
  573. return ($result);
  574. }
  575. /**
  576. * Returns geo coordinates locator
  577. *
  578. * @return string
  579. */
  580. function sm_MapLocationFinder() {
  581. $title = wf_tag('b') . __('Place coordinates') . wf_tag('b', true);
  582. $data = sm_MapLocationSwitchForm();
  583. $result = generic_MapEditor('placecoords', $title, $data);
  584. return ($result);
  585. }
  586. /**
  587. * Initialize map container with some settings
  588. *
  589. * @param $center - map center lat,long
  590. * @param $zoom - default map zoom
  591. * @param $type - map type, may be: map, satellite, hybrid
  592. * @param $placemarks - already filled map placemarks
  593. * @param $editor - field for visual editor or geolocator
  594. * @param $lang - map language in format ru-RU
  595. *
  596. * @return void
  597. */
  598. function sm_MapInitQuiet($center, $zoom, $type, $placemarks = '', $editor = '', $lang = 'ru-RU') {
  599. return (generic_MapInit($center, $zoom, $type, $placemarks, $editor, $lang));
  600. }
  601. /**
  602. * Initialize map container with some settings
  603. *
  604. * @param $center - map center lat,long
  605. * @param $zoom - default map zoom
  606. * @param $type - map type, may be: map, satellite, hybrid
  607. * @param $placemarks - already filled map placemarks
  608. * @param $editor - field for visual editor or geolocator
  609. * @param $lang - map language in format ru-RU
  610. *
  611. * @return void
  612. */
  613. function sm_MapInitBasic($center, $zoom, $type, $placemarks = '', $editor = '', $lang = 'ru-RU') {
  614. return (generic_MapInit($center, $zoom, $type, $placemarks, $editor, $lang));
  615. }
  616. /**
  617. * Shows map container
  618. *
  619. * @return void
  620. *
  621. */
  622. function sm_ShowMapContainer() {
  623. $container = wf_tag('div', false, '', 'id="ubmap" style="width: 1000; height:800px;"');
  624. $container .= wf_tag('div', true);
  625. $controls = '';
  626. if (cfr('USERSMAP')) {
  627. $controls .= wf_Link("?module=usersmap", wf_img('skins/ymaps/build.png') . ' ' . __('Builds map'), false, 'ubButton');
  628. }
  629. if (cfr('SWITCHMAP')) {
  630. $controls .= wf_Link("?module=switchmap", wf_img('skins/ymaps/network.png') . ' ' . __('Switches map'), false, 'ubButton');
  631. }
  632. if (cfr('SWITCHESEDIT')) {
  633. $controls .= wf_Link("?module=switchmap&locfinder=true", wf_img('skins/ymaps/edit.png') . ' ' . __('Edit map'), false, 'ubButton');
  634. }
  635. $controls .= wf_Link("?module=switchmap&showuplinks=true", wf_img('skins/ymaps/uplinks.png') . ' ' . __('Show links'), false, 'ubButton');
  636. $controls .= wf_Link("?module=switchmap&coverage=true", wf_img('skins/ymaps/coverage.png') . ' ' . __('Coverage area'), false, 'ubButton');
  637. if (cfr('SWITCHES')) {
  638. $controls .= wf_Link("?module=switches", wf_img('skins/ymaps/switchdir.png') . ' ' . __('Available switches'), true, 'ubButton');
  639. }
  640. $controls .= wf_delimiter(1);
  641. show_window(__('Active equipment map'), $controls . $container);
  642. }
  643. /**
  644. * Shows map container for builds
  645. *
  646. * @return void
  647. */
  648. function um_ShowMapContainer() {
  649. $container = wf_tag('div', false, '', 'id="ubmap" style="width: 1000; height:800px;"');
  650. $container .= wf_tag('div', true);
  651. $controls = '';
  652. if (cfr('SWITCHMAP')) {
  653. $controls .= wf_Link("?module=switchmap", wf_img('skins/ymaps/network.png') . ' ' . __('Switches map'), false, 'ubButton');
  654. }
  655. if (cfr('USERSMAP')) {
  656. $controls .= wf_Link("?module=usersmap", wf_img('skins/ymaps/build.png') . ' ' . __('Builds map'), false, 'ubButton');
  657. }
  658. if (cfr('BUILDS')) {
  659. $controls .= wf_Link("?module=usersmap&locfinder=true", wf_img('skins/ymaps/edit.png') . ' ' . __('Edit map'), false, 'ubButton');
  660. }
  661. $controls .= wf_delimiter(1);
  662. show_window(__('Builds and users map'), $controls . $container);
  663. }