| 1 |
<?php |
<?php |
| 2 |
// $Id: foaf.module,v 1.11 2005/11/29 18:23:01 walkah Exp $ |
// $Id: foaf.module,v 1.13 2006/07/12 17:13:51 walkah Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implements hook_help |
* Implements hook_help |
| 11 |
$output .= '<p>'. t('The FOAF module allows users to export FOAF documents based on their profile information. It also allows users to import profile information from external FOAF files, and even includes an option to let profiles auto sync when using distributed authentication. The FOAF module can export your buddy list if the buddy list module is enabled. You can download FOAF files in the view tab of a user profile if FOAF is enabled.') .'</p>'; |
$output .= '<p>'. t('The FOAF module allows users to export FOAF documents based on their profile information. It also allows users to import profile information from external FOAF files, and even includes an option to let profiles auto sync when using distributed authentication. The FOAF module can export your buddy list if the buddy list module is enabled. You can download FOAF files in the view tab of a user profile if FOAF is enabled.') .'</p>'; |
| 12 |
$output .= t('<p>You can</p> |
$output .= t('<p>You can</p> |
| 13 |
<ul> |
<ul> |
| 14 |
<li>read the <a href="%external-http-en-wikipedia-org-wiki-FOAF" title = "explanation of FOAF from wikipedia the free encyclopedia">FOAF wikipedia explanation</a>.</li> |
<li>read the <a href="%external-http-en-wikipedia-org-wiki-FOAF" title="Explanation of FOAF from Wikipedia the free encyclopedia">FOAF Wikipedia explanation</a>.</li> |
| 15 |
<li>read the <a href="http://www.socialtext.net/foafnet/index.cgi?basic_specs" title = "a programmers level description of this social networking standard">FOAFNet specificiation</a>.</li> |
<li>read the <a href="%external-http-www-socialtext-net-foafnet-index-cgi" title="A programmer\'s level description of this social networking standard">FOAFNet specificiation</a>.</li> |
| 16 |
<li>view <a href="%profile"> user profiles</a> and select a user to see their FOAF file.</li> |
<li>view <a href="%profile">user profiles</a> and select a user to see their FOAF file.</li> |
| 17 |
<li>enable the buddy list module at <a href="%admin-modules" > administrator >> modules</a>.</li> |
<li>enable the buddy list module at <a href="%admin-modules">administrator >> modules</a>.</li> |
| 18 |
', array('%external-http-en-wikipedia-org-wiki-FOAF' => 'http://en.wikipedia.org/wiki/FOAF', '%external-http-www-socialtext-net-foafnet-index-cgi' => 'http://www.socialtext.net/foafnet/index.cgi?basic_specs', '%profile' => url('profile'), '%admin-modules' => url('admin/modules'))) .'</ul>'; |
', array('%external-http-en-wikipedia-org-wiki-FOAF' => 'http://en.wikipedia.org/wiki/FOAF', '%external-http-www-socialtext-net-foafnet-index-cgi' => 'http://www.socialtext.net/foafnet/index.cgi?basic_specs', '%profile' => url('profile'), '%admin-modules' => url('admin/modules'))) .'</ul>'; |
| 19 |
$output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="%foaf">FOAF page</a>.', array('%foaf' => 'http://www.drupal.org/handbook/modules/foaf/')) .'</p>'; |
$output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="%foaf">FOAF page</a>.', array('%foaf' => 'http://drupal.org/handbook/modules/foaf/')) .'</p>'; |
| 20 |
return $output; |
return $output; |
| 21 |
case 'admin/modules#description': |
case 'admin/modules#description': |
| 22 |
return t('Allows <acronym title="Friend of a Friend">FOAF</acronym> import / export'); |
return t('Allows <acronym title="Friend of a Friend">FOAF</acronym> import / export'); |
| 32 |
$items = array(); |
$items = array(); |
| 33 |
|
|
| 34 |
if ($may_cache) { |
if ($may_cache) { |
| 35 |
$items[] = array('path' => 'foaf', 'title' => t('foaf'), |
$items[] = array( |
| 36 |
'access' => user_access('access content'), |
'path' => 'foaf', |
| 37 |
'callback' => 'foaf_export', |
'title' => t('FOAF'), |
| 38 |
'type' => MENU_CALLBACK); |
'access' => user_access('access content'), |
| 39 |
|
'callback' => 'foaf_export', |
| 40 |
|
'type' => MENU_CALLBACK, |
| 41 |
|
); |
| 42 |
|
} |
| 43 |
|
else { |
| 44 |
|
$items[] = array( |
| 45 |
|
'path' => 'admin/settings/foaf', |
| 46 |
|
'title' => t('FOAF'), |
| 47 |
|
'callback' => 'drupal_get_form', |
| 48 |
|
'callback arguments' => array('foaf_settings'), |
| 49 |
|
'access' => user_access('administer foaf'), |
| 50 |
|
'type' => MENU_NORMAL_ITEM, |
| 51 |
|
); |
| 52 |
} |
} |
| 53 |
return $items; |
return $items; |
| 54 |
} |
} |
| 67 |
} |
} |
| 68 |
break; |
break; |
| 69 |
case 'view': |
case 'view': |
| 70 |
drupal_set_html_head("\n".'<link rel="meta" type="application/rdf+xml" title="FOAF" href="'.url('foaf/'.$user->uid, NULL, NULL, TRUE).'" />'); |
drupal_set_html_head('<link rel="meta" type="application/rdf+xml" title="FOAF" href="'. url('foaf/'. $user->uid, NULL, NULL, TRUE) .'" />'); |
| 71 |
$output = ''; |
$output = ''; |
| 72 |
if (_foaf_allow_export($user)) { |
if (_foaf_allow_export($user)) { |
| 73 |
return array(t('Personal Information') => l(t('Download <acronym title="Friend of a Friend">FOAF</acronym>'), 'foaf/'.$user->uid, NULL, NULL, NULL, FALSE, TRUE)); |
return array(t('Personal Information') => array(0 => array(/*'title' => 'FOAF',*/ 'value' => l(t('Download <acronym title="Friend of a Friend">FOAF</acronym>'), 'foaf/'. $user->uid, NULL, NULL, NULL, FALSE, TRUE)))); |
| 74 |
} |
} |
| 75 |
break; |
break; |
| 76 |
case 'form': |
case 'form': |
| 82 |
} |
} |
| 83 |
|
|
| 84 |
function foaf_settings() { |
function foaf_settings() { |
|
$output = ''; |
|
| 85 |
|
|
| 86 |
$output.= form_radios(t('Export <acronym title="Friend of a Friend">FOAF</acronym> for users by default'), 'foaf_export_default', variable_get('foaf_export_default', 0), array(0 => t('no'), 1=> t('yes')), t('This can be overridden by individual users')); |
$form['foaf_export_default'] = array( |
| 87 |
|
'#type' => 'radios', |
| 88 |
$mapping.= form_select(t('Field for foaf:name'), 'foaf_name', variable_get('foaf_name', ''), _foaf_profile_fields()); |
'#title' => t('Export <acronym title="Friend of a Friend">FOAF</acronym> for users by default'), |
| 89 |
$mapping.= form_select(t('Field for foaf:title'), 'foaf_title', variable_get('foaf_title', ''), _foaf_profile_fields()); |
'#default_value' => variable_get('foaf_export_default', 0), |
| 90 |
$mapping.= form_select(t('Field for foaf:firstName'), 'foaf_firstName', variable_get('foaf_firstName', ''), _foaf_profile_fields()); |
'#options' => array(0 => t('no'), 1 => t('yes')), |
| 91 |
$mapping.= form_select(t('Field for foaf:surname'), 'foaf_surname', variable_get('foaf_surname', ''), _foaf_profile_fields()); |
'#description' => t('This can be overridden by individual users'), |
| 92 |
$mapping.= form_select(t('Field for foaf:Organization'), 'foaf_Organization', variable_get('foaf_Organization', ''), _foaf_profile_fields()); |
); |
| 93 |
$mapping.= form_select(t('Field for foaf:phone'), 'foaf_phone', variable_get('foaf_phone', ''), _foaf_profile_fields()); |
|
| 94 |
$mapping.= form_select(t('Field for foaf:aimChatID'), 'foaf_aimChatID', variable_get('foaf_aimChatID', ''), _foaf_profile_fields()); |
$mapping = variable_get('mapping', NULL); |
| 95 |
$mapping.= form_select(t('Field for foaf:icqChatID'), 'foaf_icqChatID', variable_get('foaf_icqChatID', ''), _foaf_profile_fields()); |
|
| 96 |
$mapping.= form_select(t('Field for foaf:msnChatID'), 'foaf_msnChatID', variable_get('foaf_msnChatID', ''), _foaf_profile_fields()); |
$form['mapping'] = array( |
| 97 |
$mapping.= form_select(t('Field for foaf:yahooChatID'), 'foaf_yahooChatID', variable_get('foaf_yahooChatID', ''), _foaf_profile_fields()); |
'#type' => 'fieldset', |
| 98 |
$mapping.= form_select(t('Field for foaf:jabberID'), 'foaf_jabberID', variable_get('foaf_jabberID', ''), _foaf_profile_fields()); |
'#title' => t('Field Mappings'), |
| 99 |
$mapping.= form_select(t('Field for foaf:workplaceHomepage'), 'foaf_workplaceHomepage', variable_get('foaf_workplaceHomepage', ''), _foaf_profile_fields()); |
); |
| 100 |
$mapping.= form_select(t('Field for vCard:Street'), 'foaf_street', variable_get('foaf_street', ''), _foaf_profile_fields()); |
|
| 101 |
$mapping.= form_select(t('Field for vCard:Locality'), 'foaf_locality', variable_get('foaf_locality', ''), _foaf_profile_fields()); |
$form['mapping']['foaf_name'] = array( |
| 102 |
$mapping.= form_select(t('Field for vCard:Region'), 'foaf_region', variable_get('foaf_region', ''), _foaf_profile_fields()); |
'#type' => 'select', |
| 103 |
$mapping.= form_select(t('Field for vCard:Pcode'), 'foaf_pcode', variable_get('foaf_pcode', ''), _foaf_profile_fields()); |
'#title' => t('Field for foaf:name'), |
| 104 |
$mapping.= form_select(t('Field for vCard:Country'), 'foaf_country', variable_get('foaf_country', ''), _foaf_profile_fields()); |
'#default_value' => variable_get('foaf_name', ''), |
| 105 |
$mapping.= form_select(t('Field for bio:keywords'), 'foaf_keywords', variable_get('foaf_keywords', ''), _foaf_profile_fields()); |
'#options' => _foaf_profile_fields(), |
| 106 |
|
); |
| 107 |
|
|
| 108 |
|
$form['mapping']['foaf_title'] = array( |
| 109 |
|
'#type' => 'select', |
| 110 |
|
'#title' => t('Field for foaf:title'), |
| 111 |
|
'#default_value' => variable_get('foaf_title', ''), |
| 112 |
|
'#options' => _foaf_profile_fields(), |
| 113 |
|
); |
| 114 |
|
|
| 115 |
|
$form['mapping']['foaf_firstName'] = array( |
| 116 |
|
'#type' => 'select', |
| 117 |
|
'#title' => t('Field for foaf:firstName'), |
| 118 |
|
'#default_value' => variable_get('foaf_firstName', ''), |
| 119 |
|
'#options' => _foaf_profile_fields(), |
| 120 |
|
); |
| 121 |
|
|
| 122 |
|
$form['mapping']['foaf_surname'] = array( |
| 123 |
|
'#type' => 'select', |
| 124 |
|
'#title' => t('Field for foaf:surname'), |
| 125 |
|
'#default_value' => variable_get('foaf_surname', ''), |
| 126 |
|
'#options' => _foaf_profile_fields(), |
| 127 |
|
); |
| 128 |
|
|
| 129 |
|
$form['mapping']['foaf_Organization'] = array( |
| 130 |
|
'#type' => 'select', |
| 131 |
|
'#title' => t('Field for foaf:Organization'), |
| 132 |
|
'#default_value' => variable_get('foaf_Organization', ''), |
| 133 |
|
'#options' => _foaf_profile_fields(), |
| 134 |
|
); |
| 135 |
|
|
| 136 |
|
$form['mapping']['foaf_phone'] = array( |
| 137 |
|
'#type' => 'select', |
| 138 |
|
'#title' => t('Field for foaf:phone'), |
| 139 |
|
'#default_value' => variable_get('foaf_phone', ''), |
| 140 |
|
'#options' => _foaf_profile_fields(), |
| 141 |
|
); |
| 142 |
|
|
| 143 |
|
$form['mapping']['foaf_aimChatID'] = array( |
| 144 |
|
'#type' => 'select', |
| 145 |
|
'#title' => t('Field for foaf:aimChatID'), |
| 146 |
|
'#default_value' => variable_get('foaf_aimChatID', ''), |
| 147 |
|
'#options' => _foaf_profile_fields(), |
| 148 |
|
); |
| 149 |
|
|
| 150 |
|
$form['mapping']['foaf_icqChatID'] = array( |
| 151 |
|
'#type' => 'select', |
| 152 |
|
'#title' => t('Field for foaf:icqChatID'), |
| 153 |
|
'#default_value' => variable_get('foaf_icqChatID', ''), |
| 154 |
|
'#options' => _foaf_profile_fields(), |
| 155 |
|
); |
| 156 |
|
|
| 157 |
|
$form['mapping']['foaf_msnChatID'] = array( |
| 158 |
|
'#type' => 'select', |
| 159 |
|
'#title' => t('Field for foaf:msnChatID'), |
| 160 |
|
'#default_value' => variable_get('foaf_msnChatID', ''), |
| 161 |
|
'#options' => _foaf_profile_fields(), |
| 162 |
|
); |
| 163 |
|
|
| 164 |
|
$form['mapping']['foaf_yahooChatID'] = array( |
| 165 |
|
'#type' => 'select', |
| 166 |
|
'#title' => t('Field for foaf:yahooChatID'), |
| 167 |
|
'#default_value' => variable_get('foaf_yahooChatID', ''), |
| 168 |
|
'#options' => _foaf_profile_fields(), |
| 169 |
|
); |
| 170 |
|
|
| 171 |
|
$form['mapping']['foaf_jabberID'] = array( |
| 172 |
|
'#type' => 'select', |
| 173 |
|
'#title' => t('Field for foaf:jabberID'), |
| 174 |
|
'#default_value' => variable_get('foaf_jabberID', ''), |
| 175 |
|
'#options' => _foaf_profile_fields(), |
| 176 |
|
); |
| 177 |
|
|
| 178 |
|
$form['mapping']['foaf_workplaceHomepage'] = array( |
| 179 |
|
'#type' => 'select', |
| 180 |
|
'#title' => t('Field for foaf:workplaceHomepage'), |
| 181 |
|
'#default_value' => variable_get('foaf_workplaceHomepage', ''), |
| 182 |
|
'#options' => _foaf_profile_fields(), |
| 183 |
|
); |
| 184 |
|
|
| 185 |
|
$form['mapping']['foaf_street'] = array( |
| 186 |
|
'#type' => 'select', |
| 187 |
|
'#title' => t('Field for vCard:Street'), |
| 188 |
|
'#default_value' => variable_get('foaf_street', ''), |
| 189 |
|
'#options' => _foaf_profile_fields(), |
| 190 |
|
); |
| 191 |
|
|
| 192 |
|
$form['mapping']['foaf_locality'] = array( |
| 193 |
|
'#type' => 'select', |
| 194 |
|
'#title' => t('Field for vCard:Locality'), |
| 195 |
|
'#default_value' => variable_get('foaf_locality', ''), |
| 196 |
|
'#options' => _foaf_profile_fields(), |
| 197 |
|
); |
| 198 |
|
|
| 199 |
|
$form['mapping']['foaf_region'] = array( |
| 200 |
|
'#type' => 'select', |
| 201 |
|
'#title' => t('Field for vCard:Region'), |
| 202 |
|
'#default_value' => variable_get('foaf_region', ''), |
| 203 |
|
'#options' => _foaf_profile_fields(), |
| 204 |
|
); |
| 205 |
|
|
| 206 |
|
$form['mapping']['foaf_pcode'] = array( |
| 207 |
|
'#type' => 'select', |
| 208 |
|
'#title' => t('Field for vCard:Pcode'), |
| 209 |
|
'#default_value' => variable_get('foaf_pcode', ''), |
| 210 |
|
'#options' => _foaf_profile_fields(), |
| 211 |
|
); |
| 212 |
|
|
| 213 |
|
$form['mapping']['foaf_country'] = array( |
| 214 |
|
'#type' => 'select', |
| 215 |
|
'#title' => t('Field for vCard:Country'), |
| 216 |
|
'#default_value' => variable_get('foaf_country', ''), |
| 217 |
|
'#options' => _foaf_profile_fields(), |
| 218 |
|
); |
| 219 |
|
|
| 220 |
|
$form['mapping']['foaf_keywords'] = array( |
| 221 |
|
'#type' => 'select', |
| 222 |
|
'#title' => t('Field for bio:keywords'), |
| 223 |
|
'#default_value' => variable_get('foaf_keywords', ''), |
| 224 |
|
'#options' => _foaf_profile_fields(), |
| 225 |
|
); |
| 226 |
|
|
| 227 |
$output.= form_group(t('Field Mappings'), $mapping); |
return system_settings_form($form); |
|
return $output; |
|
| 228 |
} |
} |
| 229 |
|
|
| 230 |
function foaf_xmlrpc() { |
function foaf_xmlrpc() { |
| 241 |
return; |
return; |
| 242 |
} |
} |
| 243 |
|
|
| 244 |
if ( !_foaf_allow_export($account)) { |
if (!_foaf_allow_export($account)) { |
| 245 |
drupal_access_denied(); |
drupal_access_denied(); |
| 246 |
return; |
return; |
| 247 |
} |
} |
| 248 |
|
|
| 249 |
$output .= '<?xml version="1.0" encoding="iso-8859-1" ?>'."\n"; |
// Define variables in the output. |
| 250 |
$output .= '<!-- generator="Drupal FOAF.Module" -->'."\n"; |
$dc['title'] = t('FOAF for @name at @site', array('@name' => $account->name, '@site' => variable_get('site_name', 'drupal'))); |
| 251 |
$output .= '<rdf:RDF xmlns="http://xmlns.com/foaf/0.1"'."\n"; |
$dc['description'] = t('Friend of a Friend description for @name', array('@name' => $account->name)); |
| 252 |
$output .= ' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n"; |
|
| 253 |
$output .= ' xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"'."\n"; |
$foaf['names'] = ''; |
| 254 |
$output .= ' xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n"; |
if ($firstName = _foaf_profile_get($uid, variable_get('foaf_firstName', ''))) { |
| 255 |
$output .= ' xmlns:admin="http://webns.net/mvcb/"'. "\n"; |
$foaf['names'] .= ' <foaf:firstName>'. $firstName ."</foaf:firstName>\n"; |
|
$output .= ' xmlns:bio="http://purl.org/vocab/bio/0.1/"'."\n"; |
|
|
$output .= ' xmlns:foaf="http://xmlns.com/foaf/0.1/"'."\n"; |
|
|
$output .= ' xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#">'."\n"; |
|
|
|
|
|
// foaf:PersonalProfileDocument |
|
|
$output .= '<foaf:PersonalProfileDocument rdf:about="">' ."\n"; |
|
|
$output .= ' <foaf:maker rdf:nodeID="_'.$uid.'" />'."\n"; |
|
|
$output .= ' <foaf:primaryTopic rdf:nodeID="_'.$uid.'" />'."\n"; |
|
|
$output .= ' <dc:title>'. t('FOAF for %name at %site', array('%name' => $account->name, '%site' => variable_get('site_name', 'drupal'))) ."</dc:title>\n"; |
|
|
$output .= ' <dc:description>' . t('Friend of a Friend description for %name', array('%name' => $account->name)) . "</dc:description>\n"; |
|
|
$output .= ' <admin:generatorAgent rdf:resource="http://www.drupal.org/" />'."\n"; |
|
|
$output .= "</foaf:PersonalProfileDocument>\n"; |
|
|
|
|
|
//$name = ($val = _foaf_profile_get($uid, variable_get('foaf_name',''))) ? $val : $account->name; |
|
|
$picture = ($account->picture) ? file_create_url($account->picture) : ''; |
|
|
|
|
|
// foaf:Person |
|
|
$output.= '<foaf:Person rdf:nodeID="_'.$uid.'">'."\n"; |
|
|
if ($firstName = _foaf_profile_get($uid, variable_get('foaf_firstName',''))) { |
|
|
$output.= ' <foaf:firstName>'.$firstName."</foaf:firstName>\n"; |
|
| 256 |
} |
} |
| 257 |
if ($surname = _foaf_profile_get($uid, variable_get('foaf_surname',''))) { |
if ($surname = _foaf_profile_get($uid, variable_get('foaf_surname', ''))) { |
| 258 |
$output.= ' <foaf:surname>'.$surname."</foaf:surname>\n"; |
$foaf['names'] .= ' <foaf:surname>'. $surname ."</foaf:surname>\n"; |
| 259 |
} |
} |
|
|
|
| 260 |
// Guess foaf:name (if not present) |
// Guess foaf:name (if not present) |
| 261 |
if (!$name = _foaf_profile_get($uid, variable_get('foaf_name',''))) { |
if (!$name = _foaf_profile_get($uid, variable_get('foaf_name', ''))) { |
| 262 |
if ($firstName && $surname) { |
if ($firstName && $surname) { |
| 263 |
$name = $firstName . ' ' . $surname; |
$name = $firstName .' '. $surname; |
| 264 |
} |
} |
| 265 |
else { |
else { |
| 266 |
$name = $account->name; |
$name = $account->name; |
| 267 |
} |
} |
| 268 |
} |
} |
| 269 |
$output.= ' <foaf:name>'.$name."</foaf:name>\n"; |
$foaf['names'] .= ' <foaf:name>'. $name ."</foaf:name>\n"; |
| 270 |
|
|
| 271 |
if ($account->mail) { |
if ($account->mail) { |
| 272 |
$output.= ' <foaf:mbox_sha1sum>'.sha1('mailto:' . $account->mail)."</foaf:mbox_sha1sum>\n"; |
$foaf['mail'] = ' <foaf:mbox_sha1sum>'. sha1('mailto:'. $account->mail) ."</foaf:mbox_sha1sum>\n"; |
| 273 |
} |
} |
| 274 |
|
|
| 275 |
|
$foaf['img'] = ''; |
| 276 |
|
$picture = ($account->picture) ? file_create_url($account->picture) : ''; |
| 277 |
if ($picture) { |
if ($picture) { |
| 278 |
$output.= ' <foaf:img rdf:resource="'.$picture.'" />' . "\n"; |
$foaf['img'] .= ' <foaf:img rdf:resource="'. $picture ."\" />\n"; |
| 279 |
$output.= ' <foaf:depiction rdf:resource="'.$picture.'" />' . "\n"; |
$foaf['img'] .= ' <foaf:depiction rdf:resource="'. $picture ."\" />\n"; |
| 280 |
} |
} |
|
$output.= ' <foaf:nick>'.$account->name ."</foaf:nick>\n"; |
|
| 281 |
|
|
| 282 |
// weblog |
// weblog |
| 283 |
if (module_exist('blog')) { |
if (module_exists('blog')) { |
| 284 |
$output.= ' <foaf:weblog rdf:resource="'.url('blog/'.$uid, null, null, true) . '" />' . "\n"; |
$foaf['weblog'] = ' <foaf:weblog rdf:resource="'. url('blog/'. $uid, null, null, true) .'" />'."\n"; |
| 285 |
} |
} |
| 286 |
|
if ($title = _foaf_profile_get($uid, variable_get('foaf_title', ''))) { |
| 287 |
if ($title = _foaf_profile_get($uid, variable_get('foaf_title',''))) { |
$foaf['title'] = ' <foaf:title>'. $title ."</foaf:title>\n"; |
|
$output.= ' <foaf:title>'.$title."</foaf:title>\n"; |
|
| 288 |
} |
} |
| 289 |
if ($Organization = _foaf_profile_get($uid, variable_get('foaf_Organization',''))) { |
if ($Organization = _foaf_profile_get($uid, variable_get('foaf_Organization', ''))) { |
| 290 |
$output.= ' <foaf:Organization>'.$Organization."</foaf:Organization>\n"; |
$foaf['Organization'] = ' <foaf:Organization>'. $Organization ."</foaf:Organization>\n"; |
| 291 |
} |
} |
| 292 |
if ($phone = _foaf_profile_get($uid, variable_get('foaf_phone',''))) { |
if ($phone = _foaf_profile_get($uid, variable_get('foaf_phone', ''))) { |
| 293 |
$output.= ' <foaf:phone rdf:resource="'.$phone.'"/>'."\n"; |
$foaf['phone'] = ' <foaf:phone rdf:resource="'. $phone .'"/>'."\n"; |
| 294 |
} |
} |
| 295 |
if ($aimChatID = _foaf_profile_get($uid, variable_get('foaf_aimChatID',''))) { |
if ($aimChatID = _foaf_profile_get($uid, variable_get('foaf_aimChatID', ''))) { |
| 296 |
$output.= ' <foaf:aimChatID>'.$aimChatID."</foaf:aimChatID>\n"; |
$foaf['aimChatID'] = ' <foaf:aimChatID>'. $aimChatID ."</foaf:aimChatID>\n"; |
| 297 |
} |
} |
| 298 |
if ($icqChatID = _foaf_profile_get($uid, variable_get('foaf_icqChatID',''))) { |
if ($icqChatID = _foaf_profile_get($uid, variable_get('foaf_icqChatID', ''))) { |
| 299 |
$output.= ' <foaf:icqChatID>'.$icqChatID."</foaf:icqChatID>\n"; |
$foaf['icqChatID'] = ' <foaf:icqChatID>'. $icqChatID ."</foaf:icqChatID>\n"; |
| 300 |
} |
} |
| 301 |
if ($msnChatID = _foaf_profile_get($uid, variable_get('foaf_msnChatID',''))) { |
if ($msnChatID = _foaf_profile_get($uid, variable_get('foaf_msnChatID', ''))) { |
| 302 |
$output.= ' <foaf:msnChatID>'.$msnChatID."</foaf:msnChatID>\n"; |
$foaf['msnChatID'] = ' <foaf:msnChatID>'. $msnChatID ."</foaf:msnChatID>\n"; |
| 303 |
} |
} |
| 304 |
if ($yahooChatID = _foaf_profile_get($uid, variable_get('foaf_yahooChatID',''))) { |
if ($yahooChatID = _foaf_profile_get($uid, variable_get('foaf_yahooChatID', ''))) { |
| 305 |
$output.= ' <foaf:yahooChatID>'.$yahooChatID."</foaf:yahooChatID>\n"; |
$foaf['yahooChatID'] = ' <foaf:yahooChatID>'. $yahooChatID ."</foaf:yahooChatID>\n"; |
| 306 |
} |
} |
| 307 |
if ($jabberID = _foaf_profile_get($uid, variable_get('foaf_jabberID',''))) { |
if ($jabberID = _foaf_profile_get($uid, variable_get('foaf_jabberID', ''))) { |
| 308 |
$output.= ' <foaf:jabberID>'.$jabberID."</foaf:jabberID>\n"; |
$foaf['jabberID'] = ' <foaf:jabberID>'. $jabberID ."</foaf:jabberID>\n"; |
| 309 |
} |
} |
| 310 |
if ($workplaceHomepage = _foaf_profile_get($uid, variable_get('foaf_workplaceHomepage',''))) { |
if ($workplaceHomepage = _foaf_profile_get($uid, variable_get('foaf_workplaceHomepage', ''))) { |
| 311 |
$output.= ' <foaf:workplaceHomepage rdf:resource="'.htmlentities($workplaceHomepage).'" />'."\n"; |
$foaf['workplaceHomepage'] = ' <foaf:workplaceHomepage rdf:resource="'. htmlentities($workplaceHomepage) .'" />'."\n"; |
| 312 |
} |
} |
| 313 |
|
|
| 314 |
$address = ''; |
$address = ''; |
| 315 |
if ($street = _foaf_profile_get($uid, variable_get('foaf_street',''))) { |
if ($street = _foaf_profile_get($uid, variable_get('foaf_street', ''))) { |
| 316 |
$address.= ' <vCard:Street>'.$street."</vCard:Street>\n"; |
$address .= ' <vCard:Street>'. $street ."</vCard:Street>\n"; |
| 317 |
} |
} |
| 318 |
if ($locality = _foaf_profile_get($uid, variable_get('foaf_locality',''))) { |
if ($locality = _foaf_profile_get($uid, variable_get('foaf_locality', ''))) { |
| 319 |
$address.= ' <vCard:Locality>'.$locality."</vCard:Locality>\n"; |
$address .= ' <vCard:Locality>'. $locality ."</vCard:Locality>\n"; |
| 320 |
} |
} |
| 321 |
if ($region = _foaf_profile_get($uid, variable_get('foaf_region',''))) { |
if ($region = _foaf_profile_get($uid, variable_get('foaf_region', ''))) { |
| 322 |
$address.= ' <vCard:Region>'.$region."</vCard:Region>\n"; |
$address .= ' <vCard:Region>'. $region ."</vCard:Region>\n"; |
| 323 |
} |
} |
| 324 |
if ($pcode = _foaf_profile_get($uid, variable_get('foaf_pcode',''))) { |
if ($pcode = _foaf_profile_get($uid, variable_get('foaf_pcode', ''))) { |
| 325 |
$address.= ' <vCard:Pcode>'.$pcode."</vCard:Pcode>\n"; |
$address .= ' <vCard:Pcode>'. $pcode ."</vCard:Pcode>\n"; |
| 326 |
} |
} |
| 327 |
if ($country = _foaf_profile_get($uid, variable_get('foaf_country',''))) { |
if ($country = _foaf_profile_get($uid, variable_get('foaf_country', ''))) { |
| 328 |
$address.= ' <vCard:Country>'.$country."</vCard:Country>\n"; |
$address .= ' <vCard:Country>'. $country ."</vCard:Country>\n"; |
| 329 |
} |
} |
| 330 |
|
|
| 331 |
if ($address) { |
if ($address) { |
| 332 |
$output.= ' <vCard:ADR rdf:parseType="Resource">'."\n"; |
$vCard['ADR'] = ' <vCard:ADR rdf:parseType="Resource">'."\n$address </vCard:ADR>\n"; |
|
$output.= $address; |
|
|
$output.= " </vCard:ADR>\n"; |
|
| 333 |
} |
} |
| 334 |
|
|
| 335 |
if ($keywords = _foaf_profile_get($uid, variable_get('foaf_keywords', ''))) { |
if ($keywords = _foaf_profile_get($uid, variable_get('foaf_keywords', ''))) { |
| 336 |
$output .= ' <bio:keywords>'.$keywords."</bio:keywords>\n"; |
$bio['keywords'] = ' <bio:keywords>'. $keywords ."</bio:keywords>\n"; |
| 337 |
} |
} |
| 338 |
|
|
| 339 |
if (function_exists('buddylist_get_buddies')) { |
if (function_exists('buddylist_get_buddies')) { |
| 340 |
$buddies = buddylist_get_buddies($uid); |
$buddies = buddylist_get_buddies($uid); |
| 341 |
|
$foaf_buddylist = ''; |
| 342 |
foreach ($buddies as $buddy) { |
foreach ($buddies as $buddy) { |
| 343 |
$output .= " <foaf:knows>\n"; |
$buddy = user_load(array('uid' => $buddy['uid'])); |
| 344 |
$output .= " <foaf:Person>\n"; |
if (_foaf_allow_export($buddy)) { |
| 345 |
$output .= " <foaf:name>".$buddy->name."</foaf:name>\n"; |
$foaf_buddylist .= " <foaf:knows>\n"; |
| 346 |
if ($buddy->mail) { |
$foaf_buddylist .= " <foaf:Person>\n"; |
| 347 |
$output .= ' <foaf:mbox_sha1sum>'.sha1('mailto:' . $buddy->mail)."</foaf:mbox_sha1sum>\n"; |
$foaf_buddylist .= " <foaf:name>". $buddy->name ."</foaf:name>\n"; |
| 348 |
} |
if ($buddy->mail) { |
| 349 |
if ($buddy->uid) { |
$foaf_buddylist .= ' <foaf:mbox_sha1sum>'. sha1('mailto:'. $buddy->mail) ."</foaf:mbox_sha1sum>\n"; |
| 350 |
$output .= ' <rdfs:seeAlso rdf:resource="'. url('foaf/'.$buddy->uid) . '" />' ."\n"; |
} |
| 351 |
|
if ($buddy->uid) { |
| 352 |
|
$foaf_buddylist .= ' <rdfs:seeAlso rdf:resource="'. url('foaf/'. $buddy->uid, NULL, NULL, TRUE) .'" />'."\n"; |
| 353 |
|
} |
| 354 |
|
$foaf_buddylist .= " </foaf:Person>\n"; |
| 355 |
|
$foaf_buddylist .= " </foaf:knows>\n"; |
| 356 |
} |
} |
|
$output .= " </foaf:Person>\n"; |
|
|
$output .= " </foaf:knows>\n"; |
|
| 357 |
} |
} |
| 358 |
} |
} |
|
|
|
|
$output .= "</foaf:Person>\n"; |
|
|
$output .= "</rdf:RDF>\n"; |
|
| 359 |
|
|
| 360 |
header ('Content-Type: application/rdf+xml'); |
// Output |
| 361 |
header ('Content-Disposition: attachment; filename="'.$account->name.'.rdf"'); |
$output .= <<<OUTPUT |
| 362 |
|
<?xml version="1.0" encoding="utf-8" ?> |
| 363 |
|
<!-- generator="Drupal FOAF.Module" --> |
| 364 |
|
<rdf:RDF xmlns="http://xmlns.com/foaf/0.1" |
| 365 |
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
| 366 |
|
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" |
| 367 |
|
xmlns:dc="http://purl.org/dc/elements/1.1/" |
| 368 |
|
xmlns:admin="http://webns.net/mvcb/" |
| 369 |
|
xmlns:bio="http://purl.org/vocab/bio/0.1/" |
| 370 |
|
xmlns:foaf="http://xmlns.com/foaf/0.1/" |
| 371 |
|
xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#"> |
| 372 |
|
|
| 373 |
|
<foaf:PersonalProfileDocument rdf:about=""> |
| 374 |
|
<foaf:maker rdf:nodeID="_{$uid}" /> |
| 375 |
|
<foaf:primaryTopic rdf:nodeID="_{$uid}" /> |
| 376 |
|
<dc:title>{$dc['title']}</dc:title> |
| 377 |
|
<dc:description>{$dc['description']}</dc:description> |
| 378 |
|
<admin:generatorAgent rdf:resource="http://drupal.org/" /> |
| 379 |
|
</foaf:PersonalProfileDocument> |
| 380 |
|
|
| 381 |
|
<foaf:Person rdf:nodeID="_{$uid}"> |
| 382 |
|
{$foaf['names']}{$foaf['mail']}{$foaf['img']} |
| 383 |
|
<foaf:nick>{$account->name}</foaf:nick> |
| 384 |
|
{$foaf['weblog']}{$foaf['title']}{$foaf['Organization']}{$foaf['phone']}{$foaf['aimChatID']}{$foaf['icqChatID']}{$foaf['msnChatID']}{$foaf['yahooChatID']}{$foaf['jabberID']}{$foaf['workplaceHomepage']}{$vCard['ADR']}{$bio['keywords']}{$foaf_buddylist} |
| 385 |
|
</foaf:Person> |
| 386 |
|
</rdf:RDF> |
| 387 |
|
OUTPUT; |
| 388 |
|
|
| 389 |
|
drupal_set_header('Content-Type: application/rdf+xml; charset=utf-8'); |
| 390 |
|
drupal_set_header('Content-Disposition: attachment; filename="'. $account->name .'.rdf"'); |
| 391 |
print $output; |
print $output; |
| 392 |
} |
} |
| 393 |
|
|
| 396 |
return; |
return; |
| 397 |
} |
} |
| 398 |
|
|
| 399 |
$fp = fopen($account->foaf_url,'r'); |
$fp = fopen($account->foaf_url, 'r'); |
| 400 |
if (!$fp) { |
if (!$fp) { |
| 401 |
// failed to open file (set allow_url_fopen = On) |
// failed to open file (set allow_url_fopen = On) |
| 402 |
return; |
return; |
| 403 |
} |
} |
| 404 |
while (!feof($fp)) { |
while (!feof($fp)) { |
| 405 |
$data .= fread($fp, 4192); |
$data .= fread($fp, 4192); |
| 416 |
_foaf_import_image($depiction, $account); |
_foaf_import_image($depiction, $account); |
| 417 |
} |
} |
| 418 |
|
|
| 419 |
_foaf_profile_set($account->uid, variable_get('foaf_name',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:NAME'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_name', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:NAME'][0]['VALUE']); |
| 420 |
_foaf_profile_set($account->uid, variable_get('foaf_title',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:TITLE'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_title', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:TITLE'][0]['VALUE']); |
| 421 |
_foaf_profile_set($account->uid, variable_get('foaf_firstName',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:FIRSTNAME'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_firstName', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:FIRSTNAME'][0]['VALUE']); |
| 422 |
_foaf_profile_set($account->uid, variable_get('foaf_surname',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:SURNAME'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_surname', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:SURNAME'][0]['VALUE']); |
| 423 |
_foaf_profile_set($account->uid, variable_get('foaf_Organization',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:ORGANIZATION'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_Organization', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:ORGANIZATION'][0]['VALUE']); |
| 424 |
_foaf_profile_set($account->uid, variable_get('foaf_phone',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:PHONE'][0]['ATTRIBUTES']['RDF:RESOURCE']); |
_foaf_profile_set($account->uid, variable_get('foaf_phone', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:PHONE'][0]['ATTRIBUTES']['RDF:RESOURCE']); |
| 425 |
_foaf_profile_set($account->uid, variable_get('foaf_aimChatID',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:AIMCHATID'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_aimChatID', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:AIMCHATID'][0]['VALUE']); |
| 426 |
_foaf_profile_set($account->uid, variable_get('foaf_icqChatID',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:ICQCHATID'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_icqChatID', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:ICQCHATID'][0]['VALUE']); |
| 427 |
_foaf_profile_set($account->uid, variable_get('foaf_msnChatID',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:MSNCHATID'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_msnChatID', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:MSNCHATID'][0]['VALUE']); |
| 428 |
_foaf_profile_set($account->uid, variable_get('foaf_yahooChatID',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:YAHOOCHATID'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_yahooChatID', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:YAHOOCHATID'][0]['VALUE']); |
| 429 |
_foaf_profile_set($account->uid, variable_get('foaf_jabberID',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:JABBERID'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_jabberID', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:JABBERID'][0]['VALUE']); |
| 430 |
_foaf_profile_set($account->uid, variable_get('foaf_workplaceHomepage',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:WORKPLACEHOMEPAGE'][0]['ATTRIBUTES']['RDF:RESOURCE']); |
_foaf_profile_set($account->uid, variable_get('foaf_workplaceHomepage', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['FOAF:WORKPLACEHOMEPAGE'][0]['ATTRIBUTES']['RDF:RESOURCE']); |
| 431 |
_foaf_profile_set($account->uid, variable_get('foaf_street',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['VCARD:ADR'][0]['VCARD:STREET'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_street', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['VCARD:ADR'][0]['VCARD:STREET'][0]['VALUE']); |
| 432 |
_foaf_profile_set($account->uid, variable_get('foaf_locality',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['VCARD:ADR'][0]['VCARD:LOCALITY'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_locality', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['VCARD:ADR'][0]['VCARD:LOCALITY'][0]['VALUE']); |
| 433 |
_foaf_profile_set($account->uid, variable_get('foaf_region',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['VCARD:ADR'][0]['VCARD:REGION'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_region', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['VCARD:ADR'][0]['VCARD:REGION'][0]['VALUE']); |
| 434 |
_foaf_profile_set($account->uid, variable_get('foaf_pcode',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['VCARD:ADR'][0]['VCARD:PCODE'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_pcode', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['VCARD:ADR'][0]['VCARD:PCODE'][0]['VALUE']); |
| 435 |
_foaf_profile_set($account->uid, variable_get('foaf_country',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['VCARD:ADR'][0]['VCARD:COUNTRY'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_country', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['VCARD:ADR'][0]['VCARD:COUNTRY'][0]['VALUE']); |
| 436 |
_foaf_profile_set($account->uid, variable_get('foaf_keywords',0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['BIO:KEYWORDS'][0]['VALUE']); |
_foaf_profile_set($account->uid, variable_get('foaf_keywords', 0), $foaf['RDF:RDF'][0]['FOAF:PERSON'][0]['BIO:KEYWORDS'][0]['VALUE']); |
| 437 |
|
|
| 438 |
watchdog('user', t('FOAF: imported data from %url', array('%url' => $account->foaf_url))); |
watchdog('user', t('FOAF: imported data from %url', array('%url' => $account->foaf_url))); |
| 439 |
} |
} |
| 441 |
function foaf_login($user) { |
function foaf_login($user) { |
| 442 |
if (!$user->foaf_url) { |
if (!$user->foaf_url) { |
| 443 |
if ($server = strrchr($user->name, '@')) { |
if ($server = strrchr($user->name, '@')) { |
| 444 |
$name = substr($user->name, 0, strlen($user->name) - strlen($server)); |
$name = drupal_substr($user->name, 0, drupal_strlen($user->name) - drupal_strlen($server)); |
| 445 |
$server = substr($server, 1); |
$server = drupal_substr($server, 1); |
| 446 |
} |
} |
| 447 |
else { |
else { |
| 448 |
return; |
return; |
| 463 |
*/ |
*/ |
| 464 |
function foaf_get_url($username) { |
function foaf_get_url($username) { |
| 465 |
if ($user = user_load(array('name' => $username, 'status' => 1))) { |
if ($user = user_load(array('name' => $username, 'status' => 1))) { |
| 466 |
return url('foaf/'.$user->uid, null,null, true); |
return url('foaf/'. $user->uid, null, null, true); |
| 467 |
} |
} |
| 468 |
} |
} |
| 469 |
|
|
| 470 |
function foaf_user_form($user) { |
function foaf_user_form($user) { |
|
$data = form_textfield(t('URL for your FOAF file'), 'foaf_url', $user->foaf_url, 64, 255); |
|
|
$data.= form_checkbox(t('Allow FOAF export'), 'foaf_export', 1, _foaf_allow_export($user)); |
|
|
|
|
|
$items = array(); |
|
|
$items[] = array('title' => t("FOAF Settings"), |
|
|
'data' => $data, |
|
|
'weight' => 0); |
|
| 471 |
|
|
| 472 |
return $items; |
$foafuser = variable_get('foafuser', NULL); |
| 473 |
|
|
| 474 |
|
$form['foafuser'] = array( |
| 475 |
|
'#type' => 'fieldset', |
| 476 |
|
'#title' => t('FOAF Settings'), |
| 477 |
|
'#weight' => 0, |
| 478 |
|
); |
| 479 |
|
|
| 480 |
|
$form['foafuser']['foaf_url'] = array( |
| 481 |
|
'#type' => 'textfield', |
| 482 |
|
'#title' => t('URL for your FOAF file'), |
| 483 |
|
'#default_value' => $user->foaf_url, |
| 484 |
|
'#size' => 64, |
| 485 |
|
'#maxlength' => 255, |
| 486 |
|
); |
| 487 |
|
|
| 488 |
|
$form['foafuser']['foaf_export'] = array( |
| 489 |
|
'#type' => 'checkbox', |
| 490 |
|
'#title' => t('Allow FOAF export'), |
| 491 |
|
'#return_value' => 1, |
| 492 |
|
'#default_value' => _foaf_allow_export($user), |
| 493 |
|
); |
| 494 |
|
|
| 495 |
|
return $form; |
| 496 |
} |
} |
| 497 |
|
|
| 498 |
/** |
/** |
| 527 |
* TODO - refactor user_validate_picture |
* TODO - refactor user_validate_picture |
| 528 |
*/ |
*/ |
| 529 |
function _foaf_import_image($url, $account) { |
function _foaf_import_image($url, $account) { |
| 530 |
$fp = fopen($url,'r'); |
$fp = fopen($url, 'r'); |
| 531 |
if (!$fp) { |
if (!$fp) { |
| 532 |
// failed to open file (set allow_url_fopen = On) |
// failed to open file (set allow_url_fopen = On) |
| 533 |
return; |
return; |
| 534 |
} |
} |
| 535 |
while (!feof($fp)) { |
while (!feof($fp)) { |
| 536 |
$data .= fread($fp, 4192); |
$data .= fread($fp, 4192); |
| 554 |
file_delete($tempfile); |
file_delete($tempfile); |
| 555 |
} |
} |
| 556 |
else { |
else { |
| 557 |
switch($size[2]) { |
switch ($size[2]) { |
| 558 |
case 1: |
case 1: |
| 559 |
$ext = '.gif'; |
$ext = '.gif'; |
| 560 |
break; |
break; |
| 591 |
|
|
| 592 |
// internal function: build a node of the tree |
// internal function: build a node of the tree |
| 593 |
function _foaf_buildtag($thisvals, $vals, &$i, $type) { |
function _foaf_buildtag($thisvals, $vals, &$i, $type) { |
| 594 |
|
$tag = array(); |
| 595 |
|
|
| 596 |
if (isset($thisvals['attributes'])) |
if (isset($thisvals['attributes'])) |
| 597 |
$tag['ATTRIBUTES'] = $thisvals['attributes']; |
$tag['ATTRIBUTES'] = $thisvals['attributes']; |
| 632 |
if ($index_numeric) { |
if ($index_numeric) { |
| 633 |
$tag['TAG'] = $vals[$i]['tag']; |
$tag['TAG'] = $vals[$i]['tag']; |
| 634 |
$children[] = $tag; |
$children[] = $tag; |
| 635 |
} else |
} |
| 636 |
|
else { |
| 637 |
$children[$vals[$i]['tag']][] = $tag; |
$children[$vals[$i]['tag']][] = $tag; |
| 638 |
} |
} |
| 639 |
|
} |
| 640 |
|
|
| 641 |
// 'close: End of node, return collected data |
// 'close: End of node, return collected data |
| 642 |
// Do not increment $i or nodes disappear! |
// Do not increment $i or nodes disappear! |
| 644 |
break; |
break; |
| 645 |
} |
} |
| 646 |
if ($collapse_dups) |
if ($collapse_dups) |
| 647 |
foreach($children as $key => $value) |
foreach ($children as $key => $value) |
| 648 |
if (is_array($value) && (count($value) == 1)) |
if (is_array($value) && (count($value) == 1)) |
| 649 |
$children[$key] = $value[0]; |
$children[$key] = $value[0]; |
| 650 |
return $children; |
return $children; |
| 658 |
return variable_get('foaf_export_default', 0); |
return variable_get('foaf_export_default', 0); |
| 659 |
} |
} |
| 660 |
} |
} |
|
?> |
|