You are here

function socialmedia_slideshare_parser in Social media 7

1 string reference to 'socialmedia_slideshare_parser'
socialmedia_slideshare_platform_info in ./socialmedia.platforms.inc

File

./socialmedia.platforms.inc, line 746
Defines social media platforms

Code

function socialmedia_slideshare_parser($values, $scope = 'site') {
  $profile = array(
    'url' => '',
    'username' => '',
  );
  $str = $values['url'];
  $pattern = '/(?:http:\\/\\/)?(www\\.)*(slideshare\\.net\\/)(\\w+)+/i';

  //$pattern = '/^http:\/\/(www\.)?twitter\.com\/(#!\/)?(?<name>[^\/]+)(/\w+)*$/';
  if (!preg_match($pattern, $str, $matches, PREG_OFFSET_CAPTURE)) {
    if (trim($values['url'])) {
      form_set_error('input_slideshare_url', t('SlideShare URL invalid.'));
    }
    return FALSE;
  }
  $a = explode('slideshare.net/', $str);
  $profile['url'] = 'www.slideshare.net/' . $a[1];
  $b = explode('/', $a[1]);
  $profile['userid'] = $profile['username'] = $b[0];
  if (isset($values['username']) && trim($values['username'])) {
    $profile['username'] = $values['username'];
  }
  if (isset($profile['username'])) {
    return $profile;
  }
  return $profile;
  form_set_error('input_slideshare_username', t('Cannot derive username for this type URL. Please provide a username.'));
  return FALSE;
}