Exemple #1
0
 public function get($path, $default = "")
 {
     $data = null;
     if ($this->exists($path)) {
         $data = parent::get($path, $default);
     } else {
         if ($path == 'full_name') {
             return parent::get('givenName') . ' ' . parent::get('familyName');
         } else {
             if ($path == 'first_name') {
                 $data = parent::get('givenName');
             } else {
                 if ($path == 'last_name') {
                     $data = parent::get('familyName');
                 } else {
                     if ($path == "middle_name") {
                         $data = "";
                     } else {
                         if ($path == 'email') {
                             return null;
                         } else {
                             if ($path == 'message') {
                                 $data = parent::get('status.message');
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!is_null($data)) {
         // format or manipulate the data as necessary here
         // format or manipulate the data as necessary here
         return $data;
     } else {
         return $default;
     }
 }
Exemple #2
0
 public function get($path, $default = "")
 {
     $data = null;
     if ($this->exists($path)) {
         $data = parent::get($path, $default);
     } else {
         if ($path == 'full_name') {
             $data = parent::get('name');
         } else {
             if ($path == 'middle_name') {
                 $data = "";
             } else {
                 if ($path == 'birthday') {
                     $birth_day = parent::get('birth_day');
                     $birth_month = parent::get('birth_month');
                     $birth_year = parent::get('birth_year');
                     $data = sprintf("%s-%s-%s", $birth_year, $birth_day, $birth_month);
                 } else {
                     if ($path == 'email') {
                         $emails = parent::get('emails');
                         $data = $emails->preferred;
                     } else {
                         $pos = strpos($path, '.');
                         if ($pos !== false) {
                             $parts = explode('.', $path);
                             if ($parts[0] == 'emails') {
                                 $emails = parent::get($parts[0]);
                                 $data = isset($emails->{$parts}[1]) ? $emails->{$parts}[1] : $default;
                             }
                         }
                     }
                 }
             }
         }
     }
     return $data;
 }
Exemple #3
0
 function get($path, $default = null)
 {
     $data = null;
     if ($this->exists($path)) {
         $data = parent::get($path, $default);
     } else {
         if ($path == 'full_name') {
             $data = parent::get('name');
         } else {
             if ($path == 'first_name') {
                 $data = parent::get('name');
                 $data = substr($data, 0, strpos($data, " "));
             } else {
                 if ($path == 'last_name') {
                     $data = parent::get('name');
                     $data = substr($data, strpos($data, " ") + 1);
                 } else {
                     if ($path == "middle_name") {
                         $data = "";
                     }
                 }
             }
         }
     }
     if (!is_null($data)) {
         // format or manipulate the data as necessary here
         return $data;
     } else {
         return $default;
     }
 }
Exemple #4
0
 function get($path, $default = null)
 {
     if ($this->exists($path)) {
         $data = parent::get($path, $default);
     } else {
         if ($path == 'full_name') {
             $data = parent::get('displayName');
         } else {
             if ($path == 'first_name') {
                 $data = parent::get('name.givenName');
             } else {
                 if ($path == 'middle_name') {
                     $data = parent::get('name.middleName');
                 } else {
                     if ($path == 'last_name') {
                         $data = parent::get('name.familyName');
                     } else {
                         if ($path == 'email') {
                             $emails = parent::get('emails');
                             foreach ($emails as $email) {
                                 if ($email->type == 'account') {
                                     $data = $email->value;
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!empty($data)) {
         // format or manipulate the data as necessary here
         return $data;
     } else {
         return $default;
     }
 }
Exemple #5
0
 public function get($path, $default = "")
 {
     $value = $default;
     if ($path == 'full_name') {
         return parent::get('firstName') . ' ' . parent::get('lastName');
     } else {
         if ($path == 'email') {
             return parent::get('emailAddress');
         } else {
             if ($path == "middle_name") {
                 return "";
             }
         }
     }
     if ($path != 'id') {
         if ($path == "first_name" || $path == "last_name") {
             $path = str_replace('_', '-', $path);
         }
         // Make the path into a JSON key value
         $parts = explode('-', $path);
         $parts = array_map('ucfirst', $parts);
         $path = implode('', $parts);
         $path = lcfirst($path);
     }
     if ($this->exists($path)) {
         $value = parent::get($path, $default);
     }
     $valueParts = explode('.', $path);
     $element = parent::get($valueParts[0]);
     if (array_key_exists(1, $valueParts)) {
         $index = intval($valueParts[1]);
     } else {
         $index = 0;
     }
     switch ($valueParts[0]) {
         case 'positions':
             return $this->getPosition($element, $index);
     }
     return $value;
 }
Exemple #6
0
 function get($path, $default = null)
 {
     $data = null;
     if ($this->exists($path)) {
         $data = parent::get($path, $default);
         if ($path == 'profile_image_url') {
             // return a large image (if possible) instead of a teeny-tiny one
             $data = str_replace("_normal.", ".", $data);
         } else {
             if ($path == 'created_at') {
                 $data = parent::get('created_at');
                 $jdate = new JDate($data);
                 $data = $jdate->format(JText::_('DATE_FORMAT_LC'));
             }
         }
     } else {
         if ($path == 'full_name') {
             $data = parent::get('name');
         } else {
             if ($path == 'first_name') {
                 $data = parent::get('name');
                 $data = substr($data, 0, strpos($data, " "));
             } else {
                 if ($path == 'last_name') {
                     $data = parent::get('name');
                     $data = substr($data, strpos($data, " ") + 1);
                 }
             }
         }
     }
     if (!is_null($data)) {
         // format or manipulate the data as necessary here
         return $data;
     } else {
         return $default;
     }
 }
Exemple #7
0
 function get($path, $default = null)
 {
     $data = $default;
     $pageListTypes = array("music", "books", "movies", "television", "games", "activities", "interests");
     if (in_array($path, $pageListTypes)) {
         $data = $this->formatPageList(parent::get($path, $default));
     } else {
         if ($this->exists($path)) {
             $data = parent::get($path, $default);
         } else {
             if ($path == "full_name") {
                 // standardized provider value for full name
                 $data = parent::get('name', $default);
             } else {
                 // Alternative fields that require extra parsing
                 $parts = explode('.', $path);
                 if ($parts[0] == 'education') {
                     if (isset($this->data->education)) {
                         $edu = $this->data->education;
                         if ($edu) {
                             foreach ($edu as $k => $node) {
                                 if ($node->type == $parts[1]) {
                                     unset($parts[0]);
                                     unset($parts[1]);
                                     $newPath = 'education.' . $k . '.' . implode('.', $parts);
                                     $data = parent::get($newPath, $default);
                                     break;
                                 }
                             }
                         }
                     }
                 } else {
                     return $default;
                 }
             }
         }
     }
     if (!empty($data)) {
         if (is_array($data)) {
             // This is a field with multiple, comma separated values
             // Remove empty values to prevent blah, , blah as output
             unset($data['id']);
             // Remove id key which is useless to import
             $data = SCStringUtilities::r_implode(', ', $data);
         }
         // add custom field handlers here
         switch ($path) {
             case 'website':
                 $websites = explode("\n", $data);
                 if (count($websites) > 0) {
                     $data = trim($websites[0]);
                 }
                 break;
         }
     }
     return $data;
 }
Exemple #8
0
 public function get($path, $default = "")
 {
     $value = $default;
     if ($path == 'full_name') {
         return parent::get('first_name') . ' ' . parent::get('last_name');
     } else {
         if ($path == 'email') {
             return null;
         } else {
             if ($path == "middle_name") {
                 return "";
             }
         }
     }
     // This isn't available from VK
     $pathParts = explode('.', $path);
     if ($this->exists($pathParts[0])) {
         $value = parent::get($pathParts[0], $default);
         if ($path == 'sex') {
             if ($value == 0) {
                 return "Not specified";
             } else {
                 if ($value == 1) {
                     return "Female";
                 } else {
                     if ($value == 2) {
                         return "Male";
                     }
                 }
             }
         } else {
             if ($path == 'relation') {
                 if ($value == 1) {
                     return "Single";
                 } else {
                     if ($value == 2) {
                         return "In a Relationship";
                     } else {
                         if ($value == 3) {
                             return "Engaged";
                         } else {
                             if ($value == 4) {
                                 return "Married";
                             } else {
                                 if ($value == 5) {
                                     return "It's Complicated";
                                 } else {
                                     if ($value == 6) {
                                         return "Actively Searching";
                                     } else {
                                         if ($value == 7) {
                                             return "In Love";
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             } else {
                 if ($path == 'bdate') {
                     // Always returned in DD.MM.YYYY or DD.MM format. We want to return as Y-m-d format
                     if (strpos($value, '.')) {
                         $parts = explode('.', $value);
                         $date = $parts[1] . "-" . $parts[0];
                         if (count($parts) == 3) {
                             $date = $parts[2] . '-' . $date;
                         }
                         return $date;
                     }
                 }
             }
         }
     }
     return $value;
 }
Exemple #9
0
 function get($path, $default = null)
 {
     $data = null;
     if ($this->exists($path)) {
         if ($path == 'created_at') {
             $data = parent::get('created_at');
             $jdate = new JDate($data);
             $data = $jdate->format(JText::_('DATE_FORMAT_LC'));
         } else {
             $data = parent::get($path, $default);
         }
     } else {
         if ($path == 'full_name') {
             $data = parent::get('name');
         } else {
             if ($path == 'first_name') {
                 $data = parent::get('name');
                 $data = substr($data, 0, strpos($data, " "));
             } else {
                 if ($path == 'last_name') {
                     $data = parent::get('name');
                     $data = substr($data, strpos($data, " ") + 1);
                 } else {
                     if ($path == "middle_name") {
                         $data = "";
                     }
                 }
             }
         }
     }
     if (!is_null($data)) {
         // format or manipulate the data as necessary here
         return $data;
     } else {
         return $default;
     }
 }
Exemple #10
0
 public function get($path, $default = "")
 {
     $data = null;
     if ($this->exists($path)) {
         if ($path == 'joined') {
             $data = parent::get('joined');
             $data = intval($data / 1000);
             //convert from milliseconds
             $jdate = new JDate($data);
             $data = $jdate->format(JText::_('DATE_FORMAT_LC'));
         } else {
             if ($path == 'birthday') {
                 $birthday = parent::get('birthday');
                 //Return in Y-m-d format
                 $data = $birthday->year . '-' . $birthday->month . '-' . $birthday->day;
             } else {
                 $parts = explode('.', $path);
                 if ($parts[0] == 'other_services') {
                     $other_services = parent::get($parts[0]);
                     $services = array('facebook', 'twitter', 'linkedin', 'flickr', 'tumblr');
                     if ($parts[1] == 'facebook' && isset($other_services->facebook)) {
                         $data = 'https://www.facebook.com/' . intval($other_services->facebook->identifier);
                     } else {
                         if ($parts[1] == 'twitter' && isset($other_services->twitter)) {
                             $data = strpos($other_services->twitter->identifier, '@') ? 'http://twitter.com/' . str_replace('@', '', $other_services->twitter->identifier) : $other_services->twitter->identifier;
                         } else {
                             $data = $default;
                         }
                     }
                 } else {
                     if ($parts[0] == 'photo') {
                         //photo_link, highres_link, thumb_link
                         $photo = parent::get($parts[0]);
                         $photos = array('photo_link', 'highres_link', 'thumb_link');
                         $data = in_array($parts[1], $photos) && isset($photo->{$parts}[1]) ? $photo->{$parts}[1] : $default;
                     } else {
                         $data = parent::get($path, $default);
                     }
                 }
             }
         }
     } else {
         if ($path == "full_name") {
             $data = parent::get('name', $default);
         } else {
             if ($path == 'first_name') {
                 $data = parent::get('name');
                 $data = substr($data, 0, strpos($data, " "));
             } else {
                 if ($path == 'last_name') {
                     $data = parent::get('name');
                     $data = substr($data, strpos($data, " ") + 1);
                 } else {
                     if ($path == "middle_name") {
                         $data = "";
                     } else {
                         return $default;
                     }
                 }
             }
         }
     }
     return !is_null($data) ? $data : $default;
 }
Exemple #11
0
 public function get($path, $default = "")
 {
     $data = null;
     if ($this->exists($path)) {
         $data = parent::get($path, $default);
     } else {
         if ($path == 'first_name') {
             $data = parent::get('full_name');
             $data = substr($data, 0, strpos($data, " "));
         } else {
             if ($path == 'last_name') {
                 $data = parent::get('full_name');
                 $data = substr($data, strpos($data, " ") + 1);
             } else {
                 if ($path == "middle_name") {
                     $data = "";
                 }
             }
         }
     }
     return $data;
 }