getdirections.api.inc 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <?php
  2. /**
  3. * @file
  4. * Get directions API
  5. */
  6. /**
  7. * API Function to generate a url path for use by other modules/themes.
  8. *
  9. * Example Usage:
  10. * $path = getdirections_location_path('to', $nid);
  11. * $url = l(t('Get directions'), $path);
  12. *
  13. * @param string $direction
  14. * Required. The direction the supplied input applies to. Must be either 'to' or 'from'
  15. * @param int $nid
  16. * Required. The nid of the location node
  17. * @return
  18. * Returns a path relative to the drupal root.
  19. */
  20. function getdirections_location_path($direction, $nid) {
  21. if (getdirections_get_current_supported_module() && is_numeric($nid) && ($direction == 'to' || $direction == 'from')) {
  22. return "getdirections/location/$direction/$nid";
  23. }
  24. }
  25. /**
  26. * API Function to generate a url path for use by other modules/themes.
  27. *
  28. * Example Usage:
  29. * $path = getdirections_location_user_path('to', $uid);
  30. * $url = l(t('Get directions'), $path);
  31. *
  32. * @param string $direction
  33. * Required. The direction the supplied input applies to. Must be either 'to' or 'from'
  34. * @param int $uid
  35. * Required. The uid of the location owner
  36. * @return
  37. * Returns a path relative to the drupal root.
  38. */
  39. function getdirections_location_user_path($direction, $uid) {
  40. if (getdirections_get_current_supported_module() && is_numeric($uid) && ($direction == 'to' || $direction == 'from')) {
  41. return "getdirections/location_user/$direction/$uid";
  42. }
  43. }
  44. /**
  45. * API Function to generate a url path for use by other modules/themes.
  46. *
  47. * Example Usage:
  48. * $path = getdirections_locations_path($fromnid, $tonid);
  49. * $url = l(t('Get directions'), $path);
  50. *
  51. * @param int $fromnid
  52. * Required. The nid of the location node of the starting point
  53. * @param int $tonid
  54. * Required. The nid of the location node of the destination
  55. * @return
  56. * Returns a path relative to the drupal root.
  57. */
  58. function getdirections_locations_path($fromnid, $tonid) {
  59. if (getdirections_get_current_supported_module() && is_numeric($fromnid) && is_numeric($tonid)) {
  60. return "getdirections/locations/$fromnid/$tonid";
  61. }
  62. }
  63. /**
  64. * API Function to generate a url path for use by other modules/themes.
  65. *
  66. * Example Usage:
  67. * $path = getdirections_locations_user_path($fromuid, $touid);
  68. * $url = l(t('Get directions'), $path);
  69. *
  70. * @param int $fromuid
  71. * Required. The uid of the location user of the starting point
  72. * @param int $touid
  73. * Required. The uid of the location user of the destination
  74. * @return
  75. * Returns a path relative to the drupal root.
  76. */
  77. function getdirections_locations_user_path($fromuid, $touid) {
  78. if (getdirections_get_current_supported_module() && is_numeric($fromuid) && is_numeric($touid)) {
  79. return "getdirections/locations_user/$fromuid/$touid";
  80. }
  81. }
  82. /**
  83. * API Function to generate a url path for use by other modules/themes.
  84. *
  85. * Example Usage:
  86. * $uids = "1,2,3,4";
  87. * where '1' is the uid of the starting point
  88. * '4' is the uid of the end point
  89. * and the numbers in between are the uids of the waypoints
  90. * $path = getdirections_locations_user_via_path($uids);
  91. * $url = l(t('Get directions'), $path);
  92. *
  93. * @param string $uids
  94. * Required. A comma delimited list of uid numbers
  95. * @return
  96. * Returns a path relative to the drupal root.
  97. */
  98. function getdirections_locations_user_via_path($uids) {
  99. if (getdirections_get_current_supported_module()) {
  100. return "getdirections/locations_user_via/$uids";
  101. }
  102. }
  103. /**
  104. * API Function to generate a url path for use by other modules/themes.
  105. *
  106. * Example Usage:
  107. * $nids = "1,2,3,4";
  108. * where '1' is the nid of the starting point
  109. * '4' is the nid of the end point
  110. * and the numbers in between are the nids of the waypoints
  111. * $path = getdirections_locations_via_path($nids);
  112. * $url = l(t('Get directions'), $path);
  113. *
  114. * @param string $nids
  115. * Required. A comma delimited list of nid numbers
  116. * @return
  117. * Returns a path relative to the drupal root.
  118. */
  119. function getdirections_locations_via_path($nids) {
  120. if (getdirections_get_current_supported_module()) {
  121. return "getdirections/locations_via/$nids";
  122. }
  123. }
  124. /**
  125. * API Function to generate a url path for use by other modules/themes.
  126. *
  127. * Example Usage:
  128. * $path = getdirections_location_u2n_path($fromuid, $tonid);
  129. * $url = l(t('Get directions'), $path);
  130. *
  131. *
  132. *
  133. * @param int $fromuid
  134. * Required. The uid of the location user of the starting point
  135. * @param int $tonid
  136. * Required. The nid of the location node of the destination
  137. * @return
  138. * Returns a path relative to the drupal root.
  139. */
  140. function getdirections_location_u2n_path($fromuid, $tonid) {
  141. if (getdirections_get_current_supported_module() && is_numeric($fromuid) && is_numeric($tonid)) {
  142. return "getdirections/location_u2n/$fromuid/$tonid";
  143. }
  144. }
  145. /**
  146. * API Function to generate a url path for use by other modules/themes.
  147. *
  148. * Example Usage:
  149. * $path = getdirections_location_n2u_path($fromnid, $touid);
  150. * $url = l(t('Get directions'), $path);
  151. *
  152. *
  153. *
  154. * @param int $fromnid
  155. * Required. The vid of the location node of the starting point
  156. * @param int $touid
  157. * Required. The uid of the location user of the destination
  158. * @return
  159. * Returns a path relative to the drupal root.
  160. */
  161. function getdirections_location_n2u_path($fromnid, $touid) {
  162. if (getdirections_get_current_supported_module() && is_numeric($fromnid) && is_numeric($touid)) {
  163. return "getdirections/location_u2n/$fromnid/$touid";
  164. }
  165. }
  166. /**
  167. * API Function to generate a url path for use by other modules/themes.
  168. *
  169. * Example Usage:
  170. * $path = getdirections_location_latlon_path('to', '1.1234,1.234', 'my place');
  171. * $url = l(t('Get directions'), $path);
  172. *
  173. *
  174. * @param string $direction
  175. * Required. The direction the supplied input applies to. Must be either 'to' or 'from'
  176. * @param string $latlon
  177. * Required. The location point to be used. In decimal latitude,longitude
  178. * @param string $locs
  179. * Optional. A description of the point.
  180. * @return
  181. * Returns a path relative to the drupal root.
  182. */
  183. function getdirections_location_latlon_path($direction, $latlon, $locs='') {
  184. if (($direction == 'to' || $direction == 'from') && preg_match("/[0-9.\-],[0-9.\-]/", $latlon)) {
  185. $out = "getdirections/latlon/$direction/$latlon";
  186. if ($locs) {
  187. $out .= "/$locs";
  188. }
  189. return $out;
  190. }
  191. }
  192. /**
  193. * API Function to generate a url path for use by other modules/themes.
  194. *
  195. * Example Usage:
  196. * $path = getdirections_location_id_path('to', $lid);
  197. * $url = l(t('Get directions'), $path);
  198. *
  199. * @param string $direction
  200. * Required. The direction the supplied input applies to. Must be either 'to' or 'from'
  201. * @param int $lid
  202. * Required. The lid (location id) of the location, as found in the location table
  203. * @return
  204. * Returns a path relative to the drupal root.
  205. */
  206. function getdirections_location_id_path($direction, $lid) {
  207. if (getdirections_get_current_supported_module() && is_numeric($lid) && ($direction == 'to' || $direction == 'from')) {
  208. return "getdirections/location_id/$direction/$lid";
  209. }
  210. }
  211. /**
  212. * API Function to setup a map with two points
  213. *
  214. * @param string $fromlocs
  215. * Required. The string to display for From.
  216. * @param string $fromlatlon
  217. * Required. The location point for From. In decimal latitude,longitude
  218. * @param string $tolocs
  219. * Required. The string to display for To.
  220. * @param string $tolatlon
  221. * Required. The location point for To. In decimal latitude,longitude
  222. * @return
  223. * Returns the themed map.
  224. */
  225. function getdirections_locations_bylatlon($fromlocs, $fromlatlon, $tolocs, $tolatlon, $width='', $height='') {
  226. return getdirections_locations($fromlocs, $fromlatlon, $tolocs, $tolatlon, $width, $height);
  227. }