/[drupal]/contributions/modules/ziki/ziki.inc
ViewVC logotype

Contents of /contributions/modules/ziki/ziki.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Wed Jan 9 03:32:31 2008 UTC (22 months, 2 weeks ago) by narno
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
Changes since 1.1: +26 -2 lines
File MIME type: text/x-php
Cache fixed and optimised
Ziki API function created
1 <?php
2 // $Id: ziki.inc,v 1.1 2007/10/31 00:50:19 narno Exp $
3
4 /**
5 * return an array who contain information about a person
6 * @param string username
7 * @return array
8 */
9 function ziki_get_people($username) {
10 $people = array();
11 $xml = @simplexml_load_file(sprintf(variable_get('ziki_api_xml', ZIKI_API_XML), $username));
12 if ($xml) {
13 $people = array(
14 'url' => (string)$xml->ziki->url,
15 //'photo' => (string)$xml->ziki->photos->thumb, // thumb, small, medium
16 'firstname' => trim($xml->ziki->first_name),
17 'lastname' => trim($xml->ziki->last_name),
18 'nickname' => trim($xml->ziki->nickname),
19 'baseline' => trim($xml->ziki->baseline),
20 'gender' => ($xml->ziki->gender == 'male') ? t('Male') : t('Female'),
21 'age' => t('@age years old', array('@age' => ziki_age($xml->ziki->birthday))),
22 'city' => (string)$xml->ziki->city,
23 'country' => (string)$xml->ziki->country,
24 'website' => (string)$xml->ziki->website
25 );
26 }
27 return $people;
28 }
29
30 /**
31 * return age from a birthday date
32 * @param string birthday date as YYYY-MM-DD
33 * @return integer age
34 */
35 function ziki_age($naiss) {
36 list($annee, $mois, $jour) = split('[-.]', $naiss);
37 $today['mois'] = date('n');
38 $today['jour'] = date('j');
39 $today['annee'] = date('Y');
40 $annees = $today['annee'] - $annee;
41 if ($today['mois'] <= $mois) {
42 if ($mois == $today['mois']) {
43 if ($jour > $today['jour'])
44 $annees--;
45 }
46 else
47 $annees--;
48 }
49 return $annees;
50 }
51 ?>

  ViewVC Help
Powered by ViewVC 1.1.2