コード例 #1
0
ファイル: client.php プロジェクト: BetterBetterBetter/B3App
 /**
  * Retrieve the extracted content of a blog post that can be formatted to Facebook
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function extractPostData(EasyBlogPost &$post)
 {
     // Prepare the result data
     $data = new stdClass();
     // Get the content's source
     $source = $this->config->get('integrations_facebook_source');
     // Get the blog content
     $data->content = $post->getIntro(true);
     // Get the blog's image to be pushed to Facebook
     $data->image = $post->getImage('thumbnail', true, true);
     // var_dump($data->image);exit;
     // If there's no blog image, try to get the image from the content
     if (!$data->image) {
         // lets get full content.
         $fullcontent = $post->getContent('entry');
         $data->image = EB::string()->getImage($fullcontent);
     }
     // If there's still no image, use author's avatar
     if (!$data->image) {
         $author = $post->getAuthor();
         $data->image = $author->getAvatar();
     }
     // if still no image. lets try to get from placeholder.
     if (!$data->image) {
         $data->image = EB::getPlaceholderImage();
     }
     // Format the content so that it respects the length
     $max = $this->config->get('integrations_facebook_blogs_length');
     // Remove adsense codes
     $data->content = EB::adsense()->strip($data->content);
     if ($max && JString::strlen($data->content) > $max) {
         $data->content = JString::substr($data->content, 0, $max) . JText::_('COM_EASYBLOG_ELLIPSES');
     }
     // Get the url to the blog
     $data->url = EBR::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $post->id, false, true);
     // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls.
     $sh404exists = EBR::isSh404Enabled();
     if ($this->app->isAdmin() && $sh404exists) {
         $data->url = EB::getExternalLink('index.php?option=com_easyblog&view=entry&id=' . $post->id);
     }
     return $data;
 }
コード例 #2
0
ファイル: jomsocial.php プロジェクト: knigherrant/decopatio
 /**
  * Prepares a blog content before submitting to JomSocial's stream
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 private function prepareBlogContent(EasyBlogPost $post, $permalink)
 {
     $content = '';
     // If the stream is configured to not display any contents at all, skip this
     if (!$this->config->get('integrations_jomsocial_submit_content')) {
         return $content;
     }
     // Check if the post requires verification
     if ($this->config->get('main_password_protect', true) && !empty($blog->blogpassword)) {
         $template = EB::template();
         $template->set('id', $blog->id);
         $template->set('return', base64_encode($blogLink));
         $content = $template->output('site/blogs/protected');
         return $content;
     }
     // Get the content
     $content = $post->getContent();
     $image = '';
     // If there's no post image, search for the first image
     if (!$post->hasImage()) {
         // This will return a string of img tag if exist.
         $image = EB::string()->searchImage($content);
         if (!is_array($image)) {
             // We need to extract the src attribute
             preg_match('/src="([^"]*)"/i', $image, $matches);
             if ($matches) {
                 $image = $matches[1];
             }
         }
     } else {
         $image = $post->getImage();
     }
     // Normalize the content of the post
     $content = $this->normalizeContent($content);
     $template = EB::template();
     $template->set('permalink', $permalink);
     $template->set('image', $image);
     $template->set('content', $content);
     $output = $template->output('site/jomsocial/stream');
     return $output;
 }
コード例 #3
0
ファイル: easysocial.php プロジェクト: knigherrant/decopatio
 /**
  * Creates a new stream for new blog post
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function createFeaturedBlogStream(EasyBlogPost $post)
 {
     // Check if integrations is enabled
     if (!$this->config->get('integrations_easysocial_stream_featurepost')) {
         return false;
     }
     // Check if easysocial exists on the site
     if (!$this->exists()) {
         return false;
     }
     $stream = FD::stream();
     $template = $stream->getTemplate();
     // Get the stream template
     $template->setActor($post->getAuthor()->id, SOCIAL_TYPE_USER);
     $template->setContext($post->id, 'blog');
     $template->setContent($post->getContent());
     $template->setTarget($post->getAuthor()->id);
     $template->setSiteWide();
     $template->setVerb('featured');
     // Determines if the blog post should be visible publicly
     $privacyVal = $post->access ? '10' : 0;
     $template->setAccess('easyblog.blog.view', $privacyVal);
     return $stream->add($template);
 }
コード例 #4
0
ファイル: client.php プロジェクト: knigherrant/decopatio
 /**
  * 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;
 }
コード例 #5
0
 /**
  * Prepares a blog content before submitting to JomSocial's stream
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 private function prepareBlogContent(EasyBlogPost $post, $permalink)
 {
     $content = '';
     // If the stream is configured to not display any contents at all, skip this
     if (!$this->config->get('integrations_jomsocial_submit_content')) {
         return $content;
     }
     // Check if the post requires verification
     if ($this->config->get('main_password_protect', true) && !empty($blog->blogpassword)) {
         $template = EB::template();
         $template->set('id', $blog->id);
         $template->set('return', base64_encode($blogLink));
         $content = $template->output('site/blogs/protected');
         return $content;
     }
     // Get the content
     $content = $post->getContent();
     $image = $post->getImage();
     // If there's no post image, search for the first image
     if (!$image) {
         $image = EB::string()->searchImage($content);
     }
     // Normalize the content of the post
     $content = $this->normalizeContent($content);
     $template = EB::template();
     $template->set('permalink', $permalink);
     $template->set('image', $image);
     $template->set('content', $content);
     $output = $template->output('site/jomsocial/stream');
     return $output;
 }