+/**
+ * Returns all the fields used in the template
+ *
+ * Returned fields are already decoded to LDAP internals
+ */
+function get_fields_from_template($tpl){
+ global $smarty;
+ global $FIELDS;
+ $tpl = $smarty->template_dir.'/'.$tpl;
+ $data = @file_get_contents($tpl);
+ $matches = array();
+ preg_match_all('/\$entry\.(\w+)/',$data,$matches);
+ $matches = array_unique((array) $matches[1]);
+ $return = array();
+ foreach($matches as $f){
+ if($FIELDS[$f]){
+ $return[] = $FIELDS[$f];
+ }elseif($FIELDS["_$f"]){
+ $return[] = $FIELDS["_$f"];
+ }elseif($f = 'markers'){
+ $return[] = 'marker';
+ }
+ }
+ return $return;
+}
+
+function addCoords(&$coords, $entry, $geocoder)
+{
+ $priv = $geocoder->getPrivateCoords($entry);
+ if ($priv !== null) {
+ $priv->address = '<b>'
+ . $entry['givenname'] . ' ' . $entry['name'] . '</b><br/>'
+ . str_replace("\n", '<br/>', $entry['homestreet']);
+ $coords[] = $priv;
+ }
+
+ $busi = $geocoder->getBusinessCoords($entry);
+ if ($busi !== null) {
+ $busi->address = '<b>' . $entry['organization'] . '<br/>'
+ . $entry['givenname'] . ' ' . $entry['name'] . '</b><br/>'
+ . $entry['street'] . '<br/>'
+ . $entry['zip'] . ' ' . $entry['location'];
+ $coords[] = $busi;
+ }
+}