예제 #1
0
파일: helper.php 프로젝트: Tommar/vino2
 /**
  * Shares a new content on LinkedIn
  **/
 public function share($blog, $message = '', $oauth, $useSystem = false)
 {
     $message = $this->processMessage($message, $blog);
     $content = $blog->intro . $blog->content;
     $content = EasyBlogHelper::getHelper('Videos')->strip($content);
     if ($blog->getImage()) {
         $image = $blog->getImage()->getSource('frontpage');
     }
     if (empty($image)) {
         $pattern = '/<\\s*img [^\\>]*src\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i';
         preg_match($pattern, $content, $matches);
         $image = '';
         if (isset($matches[1])) {
             $image = $matches[1];
             if (JString::stristr($matches[1], 'http://') === false && !empty($image)) {
                 $image = rtrim(JURI::root(), '/') . '/' . ltrim($image, '/');
             }
         }
     }
     $text = strip_tags($content);
     // Linkedin now restricts the message and text size.
     $message = JString::substr($message, 0, 700);
     $text = JString::substr($text, 0, 256);
     $content = array('title' => $blog->title, 'comment' => $message, 'submitted-url' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true), 'submitted-image-url' => $image, 'description' => $text, 'visibility' => 'anyone');
     // Share to the person's account
     $status = parent::sharePost('new', $content, true, false);
     // Let's determine if we should auto post to company pages.
     $config = EasyBlogHelper::getConfig();
     $companies = trim($config->get('integrations_linkedin_company'));
     if (!empty($companies) && $useSystem) {
         $companies = explode(',', $companies);
         // Share to company pages.
         foreach ($companies as $company) {
             $status = parent::sharePost('new', $content, true, false, array($company));
         }
     }
     return true;
 }
예제 #2
0
 /**
  * Posts a message on linkedin
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function share(EasyBlogPost &$post, EasyBlogTableOAuth &$oauth)
 {
     // Get the content
     $content = $post->getIntro(EASYBLOG_STRIP_TAGS);
     // Get the blog image
     $image = $post->getImage('thumbnail', true, true);
     // If there's no blog image, try to get the image from the content
     if (!$image) {
         $fullcontent = $post->getContent('entry');
         $image = EB::string()->getImage($fullcontent);
     }
     // If there's still no image, just use the author's avatar
     if (!$image) {
         $image = $post->getAuthor()->getAvatar();
     }
     $options = array('title' => $post->title, 'comment' => $oauth->message, 'submitted-url' => $post->getExternalPermalink(), 'submitted-image-url' => $image, 'description' => $content, 'visibility' => 'anyone');
     // Satisfy linkedin's criteria
     $options['description'] = trim(htmlspecialchars(strip_tags(stripslashes($options['description']))));
     $options['comment'] = htmlspecialchars(trim(strip_tags(stripslashes($options['comment']))));
     // Linkedin now restricts the message and text size.
     // To be safe, we'll use 380 characters instead of 400.
     $options['description'] = trim(JString::substr($options['description'], 0, 395));
     $options['comment'] = JString::substr($options['comment'], 0, 256);
     // Share to their account now
     $status = parent::sharePost('new', $options, true, false);
     // Determines if we should auto post to the company pages.
     if ($oauth->system && $this->config->get('integrations_linkedin_company')) {
         $companies = trim($this->config->get('integrations_linkedin_company'));
         if (!empty($companies)) {
             $companies = explode(',', $companies);
             foreach ($companies as $company) {
                 $status = parent::sharePost('new', $options, true, false, array($company));
             }
         }
     }
     return true;
 }