Пример #1
0
 /**
  * Invoke the crawling.
  *
  * @since	1.0
  * @access	public
  * @author	Mark Lee <*****@*****.**>
  */
 public function crawl($url)
 {
     $tmp = str_ireplace(array('http://', 'https://'), '', $url);
     if (!EB::string()->isValidDomain($tmp)) {
         return false;
     }
     // Ensure that urls always contains a protocol
     if (stristr($url, 'http://') === false && stristr($url, 'https://') === false) {
         $url = 'http://' . $url;
     }
     // Load up the connector first.
     $connector = EB::connector();
     $connector->addUrl($url);
     $connector->execute();
     // Get the result and parse them.
     $info = parse_url($url);
     $this->contents = $connector->getResult($url);
     // Replace any href="// with href="scheme://"
     $this->contents = str_ireplace('src="//', 'src="' . $info['scheme'] . '://', $this->contents);
     // Get the final url, if there's any redirection.
     $originalUrl = $url;
     $url = $connector->getFinalUrl($url);
     $this->parse($originalUrl, $url);
     return $this;
 }
Пример #2
0
 /**
  * Given a specific URL, try to crawl the site
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function crawl()
 {
     // Get a list of urls to crawl
     $urls = $this->input->get('url', array(), 'array');
     if (!is_array($urls)) {
         $urls = array($urls);
     }
     // Result placeholder
     $result = array();
     if (!$urls || empty($urls)) {
         return $this->ajax->reject();
     }
     // Get the crawler library
     $crawler = EB::crawler();
     foreach ($urls as $url) {
         // Ensures that the domain is valid
         if (!EB::string()->isValidDomain($url)) {
             return $this->ajax->reject(JText::_('COM_EASYBLOG_COMPOSER_BLOCKS_LINKS_EMPTY'));
         }
         // Crawl the url
         $state = $crawler->crawl($url);
         // Get the data from the crawled site
         $data = $crawler->getData();
         $result[$url] = $data;
     }
     return $this->ajax->resolve($result);
 }
Пример #3
0
 public function __construct()
 {
     // EasyBlog's configuration
     $this->config = EB::config();
     $this->jconfig = EB::jconfig();
     // Joomla's document object
     $this->doc = JFactory::getDocument();
     // Joomla's application object
     $this->app = JFactory::getApplication();
     // Request input object
     $this->input = EB::request();
     // Current logged in user.
     $this->my = JFactory::getUser();
     // String library
     $this->string = EB::string();
     $this->lang = JFactory::getLanguage();
 }
Пример #4
0
 /**
  * Sends a ping to pingomatic servers
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function ping(EasyBlogPost &$post)
 {
     // If this is disabled, don't do anything
     if (!$this->config->get('main_pingomatic')) {
         return false;
     }
     // Get the title of the blog post
     $title = EB::string()->escape($post->title);
     // Get the permalink to the post
     $link = $post->getExternalPermalink();
     $link = urlencode($link);
     // Construct the xml content to send to pingomatic
     $content = '<?xml version="1.0"?>' . '<methodCall>' . ' <methodName>weblogUpdates.ping</methodName>' . '  <params>' . '   <param>' . '    <value>' . $title . '</value>' . '   </param>' . '   <param>' . '    <value>' . $url . '</value>' . '   </param>' . '  </params>' . '</methodCall>';
     $headers = "POST / HTTP/1.0\r\n" . "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729)\r\n" . "Host: rpc.pingomatic.com\r\n" . "Content-Type: text/xml\r\n" . "Content-length: " . strlen($content);
     $request = $headers . "\r\n\r\n" . $content;
     $response = "";
     $fs = fsockopen('rpc.pingomatic.com', 80, $errno, $errstr);
     if ($fs) {
         fwrite($fs, $request);
         while (!feof($fs)) {
             $response .= fgets($fs);
         }
         if ($debug) {
             echo "<xmp>" . $response . "</xmp>";
         }
         fclose($fs);
         preg_match_all("/<(name|value|boolean|string)>(.*)<\\/(name|value|boolean|string)>/U", $response, $ar, PREG_PATTERN_ORDER);
         for ($i = 0; $i < count($ar[2]); $i++) {
             $ar[2][$i] = strip_tags($ar[2][$i]);
         }
         return array('status' => $ar[2][1] == 1 ? 'ko' : 'ok', 'msg' => $ar[2][3]);
     } else {
         if ($debug) {
             echo "<xmp>" . $errstr . " (" . $errno . ")</xmp>";
         }
         return array('status' => 'ko', 'msg' => $errstr . " (" . $errno . ")");
     }
 }
Пример #5
0
if ($teams) {
    ?>
        <?php 
    foreach ($teams as $team) {
        ?>
            <div class="mod-item mod-table cell-top">
                <div class="mod-cell cell-tight pr-10">
                    <a class="mod-avatar" href="<?php 
        echo $team->getPermalink();
        ?>
">
                        <img src="<?php 
        echo $team->getAvatar();
        ?>
" alt="<?php 
        echo EB::string()->escape($team->title);
        ?>
" />
                    </a>
                </div>
                <div class="mod-cell">
                    <h3 class="mod-title">
                        <a href="<?php 
        echo $team->getPermalink();
        ?>
"><?php 
        echo $team->title;
        ?>
</a>
                    </h3>
                    <div>
Пример #6
0
 public static function escape($string)
 {
     return EB::string()->escape($string);
 }
Пример #7
0
    ?>
        </div>
    <?php 
}
?>

    <?php 
if ($params->get('showcommentcount', 0)) {
    ?>
        <div class="mod-cell pr-10">
            <a href="<?php 
    echo $post->getPermalink();
    ?>
">
                <?php 
    echo EB::string()->getNoun('MOD_TOPBLOGS_COMMENTS', EB::comment()->getCommentCount($post), true);
    ?>
            </a>
        </div>
    <?php 
}
?>

    <?php 
if ($params->get('showreadmore', true)) {
    ?>
        <div class="mod-cell">
            <a href="<?php 
    echo $post->getPermalink();
    ?>
"><?php 
Пример #8
0
 /**
  * Attaches the open graph tags in the header
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function addOpenGraphTags(EasyBlogPost &$post)
 {
     if (!$this->config->get('main_facebook_opengraph')) {
         return;
     }
     // Get the absolute permalink for this blog item.
     $url = $post->getExternalPermalink();
     // Get the image of the blog post.
     $image = self::getImage($post);
     // Add the blog image.
     $this->doc->addCustomTag('<meta property="og:image" content="' . $image . '"/> ');
     // If app id is provided, attach it on the head
     $appId = $this->config->get('main_facebook_like_appid');
     $adminId = $this->config->get('main_facebook_like_admin');
     if ($appId) {
         $this->doc->addCustomTag('<meta property="fb:app_id" content="' . $appId . '"/> ');
     }
     if ($adminId) {
         $this->doc->addCustomTag('<meta property="fb:admins" content="' . $adminId . '"/>');
     }
     // Add the title tag
     $this->doc->addCustomTag('<meta property="og:title" content="' . $post->title . '" />');
     // Load any necessary meta data for the blog
     $meta = $post->loadMeta();
     // If there's a meta set for the blog, use the stored meta version
     $description = !empty($meta->description) ? $meta->description : $post->getIntro();
     // Remove unwanted tags
     $description = EB::stripEmbedTags($description);
     // Add any slashes
     $description = addslashes($description);
     // Remove any html tags
     $description = strip_tags($description);
     // Ensure that newlines wouldn't affect the header
     $description = trim($description);
     // Replace htmlentities with the counterpert
     // Perhaps we need to explicitly replace &nbsp; with a space?
     $description = html_entity_decode($description);
     // Remove any quotes (") from the content
     $description = str_ireplace('"', '', $description);
     // If there's a maximum length specified, we should respect it.
     $max = $this->config->get('integrations_facebook_blogs_length');
     if ($max) {
         if (JString::strlen($description) > $max) {
             $description = JString::substr($description, 0, $max) . JText::_('COM_EASYBLOG_ELLIPSES');
         }
     }
     // Escape it again
     $description = EB::string()->escape($description);
     $this->doc->addCustomTag('<meta property="og:description" content="' . $description . '" />');
     $this->doc->addCustomTag('<meta property="og:type" content="article" />');
     $this->doc->addCustomTag('<meta property="og:url" content="' . $url . '" />');
     return true;
 }
Пример #9
0
 /**
  * Allows caller to subscribe to the blog
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function subscribe()
 {
     // Ensure that guests are allowed to subscribe
     if (!$this->acl->get('allow_subscription') && !$this->my->id && !$this->config->get('main_allowguestsubscribe')) {
         return $this->ajax->reject(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_SUBSCRIBE_BLOG'));
     }
     // Validate the email address
     $email = $this->input->get('email', '', 'default');
     if (!$email) {
         return $this->ajax->reject(JText::_('COM_EASYBLOG_SUBSCRIPTION_EMAIL_EMPTY_ERROR'));
     }
     // Test if email is valid
     $valid = EB::string()->isValidEmail($email);
     if (!$valid) {
         return $this->ajax->reject(JText::_('COM_EASYBLOG_SUBSCRIPTION_EMAIL_INVALID_ERROR'));
     }
     // Determines if the user wants to register
     $registered = $this->input->get('register', '', 'bool');
     $name = $this->input->get('name', '', 'default');
     $username = $this->input->get('username', '', 'default');
     $id = $this->input->get('id', '', 'int');
     $type = $this->input->get('type', '', 'string');
     $userId = $this->input->get('userId', 0, 'int');
     if (!$name) {
         return $this->ajax->reject(JText::_('COM_EASYBLOG_SUBSCRIPTION_NAME_EMPTY_ERROR'));
     }
     if ($registered && !$this->my->id && !$username) {
         return $this->ajax->reject(JText::_('COM_EASYBLOG_SUBSCRIPTION_USERNAME_EMPTY_ERROR'));
     }
     // Load up the registration library
     $lib = EB::registration();
     // Try to validate the username and email
     $options = array('username' => $username, 'email' => $email);
     $validated = $lib->validate();
     if ($validated !== true) {
         return $this->ajax->reject(JText::_($validated));
     }
     // Add the user's name
     $options['name'] = $name;
     // if the user is guest
     if ($userId == 0 && $registered) {
         // Add the user to the system
         $userId = $lib->addUser($options);
     }
     // Process mailchimp subscriptions here.
     $mailchimp = EB::mailchimp()->subscribe($email, $name);
     // Process mailchimp subscriptions here.
     $sendy = EB::sendy()->subscribe($email, $name);
     // Only use our built in subscription if mailchimp and sendy didn't send anything
     if (!$mailchimp && !$sendy) {
         // Since we have already merged all these tables into one, we don't need to use separate methods
         // to insert new subscriptions
         $subscription = EB::table('Subscriptions');
         $options = array('email' => $email, 'uid' => $id, 'utype' => $type);
         if (!$userId) {
             $options['user_id'] = 0;
         } else {
             $options['user_id'] = $userId;
         }
         if ($name) {
             $options['fullname'] = $name;
         }
         // If this is a valid user, perhaps he's trying to change his email
         if ($userId) {
             $subscription->load(array('user_id' => $userId, 'utype' => $type, 'uid' => $id));
         } else {
             $subscription->load($options);
         }
         // Bind the data
         $subscription->bind($options);
         // Try to save the record now
         $state = $subscription->store();
         // We don't really need to do anythin
         // If the subscribed method returns false, we could assume that they are already subscribed previously
         if (!$state) {
             return $this->ajax->reject(JText::_('COM_EASYBLOG_SUBSCRIPTION_ALREADY_SUBSCRIBED_ERROR'));
         }
     }
     $theme = EB::template();
     $theme->set('email', $email);
     $theme->set('registered', $registered);
     $output = $theme->output('site/subscription/dialog.subscribed');
     return $this->ajax->resolve($output);
 }
Пример #10
0
    ?>
        </div>
    <?php 
}
?>

    <?php 
if ($params->get('showcommentcount', 0)) {
    ?>
        <div class="mod-cell pr-10">
            <a href="<?php 
    echo $post->getPermalink();
    ?>
">
                <?php 
    echo EB::string()->getNoun('MOD_EASYBLOGMOSTCOMMENTEDPOST_COMMENTS', $post->commentCount, true);
    ?>
            </a>
        </div>
    <?php 
}
?>

    <?php 
if ($params->get('showreadmore', true)) {
    ?>
        <div class="mod-cell">
            <a href="<?php 
    echo $post->getPermalink();
    ?>
"><?php 
Пример #11
0
					<a href="<?php 
    echo $post->getPermalink();
    ?>
"><?php 
    echo nl2br($post->title);
    ?>
</a>
				</h2>

				<div class="eb-post-headline-source">
					<a href="<?php 
    echo $post->getAsset('link');
    ?>
" target="_blank">
						<?php 
    echo EB::string()->htmlAnchorLink($link, $link);
    ?>
					</a>
				</div>
			</div>
			<?php 
}
?>

			<!-- Twitter type -->
			<?php 
if ($post->posttype == 'twitter') {
    ?>
			<?php 
    $screen_name = $post->getAsset('screen_name')->getValue();
    $created_at = EB::date($post->getAsset('created_at')->getValue(), true)->format(JText::_('DATE_FORMAT_LC'));
Пример #12
0
 /**
  * Allows caller to set the meta
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public static function setMeta($id, $type, $defaultViewDesc = '')
 {
     $doc = JFactory::getDocument();
     $config = EB::config();
     // Try to load the meta for the content
     $meta = EB::table('Meta');
     $meta->load(array('type' => $type, 'content_id' => $id));
     // If the category was created without any meta, we need to automatically fill in the description
     if ($type == META_TYPE_CATEGORY && !$meta->id) {
         $category = '';
         if (EB::cache()->exists($id, 'category')) {
             $category = EB::cache()->get($id, 'category');
         } else {
             $category = EB::table('Category');
             $category->load($id);
         }
         $doc->setMetadata('description', strip_tags($category->description));
     }
     // If the blogger was created, try to get meta from blogger biography/title
     if ($type == META_TYPE_BLOGGER) {
         $author = '';
         if (EB::cache()->exists($id, 'author')) {
             $author = EB::cache()->get($id, 'author');
         } else {
             $author = EB::table('Profile');
             $author->load($id);
         }
         $doc->setMetadata('description', strip_tags($author->biography));
         if (!empty($author->biography) || !empty($author->title)) {
             $meta = new stdClass();
             $meta->keywords = $author->title;
             $meta->description = EB::string()->escape($author->biography);
         }
     }
     // Automatically fill meta keywords
     if ($type == META_TYPE_POST && ($config->get('main_meta_autofillkeywords') && empty($meta->keywords) || $config->get('main_meta_autofilldescription'))) {
         // Retrieve data from cache
         $post = EB::post();
         $post->load($id);
         $category = $post->getPrimaryCategory();
         $keywords = array($category->getTitle());
         if ($config->get('main_meta_autofillkeywords') && empty($meta->keywords)) {
             $tags = $post->getTags();
             foreach ($tags as $tag) {
                 $keywords[] = $tag->getTitle();
             }
             $meta->keywords = implode(',', $keywords);
         }
         // Automatically fill meta description
         if ($config->get('main_meta_autofilldescription') && empty($meta->description)) {
             $content = $post->getIntro(EASYBLOG_STRIP_TAGS);
             $content = trim($content);
             // Set description into meta headers
             $meta->description = JString::substr($content, 0, $config->get('main_meta_autofilldescription_length'));
             $meta->description = EB::string()->escape($meta->description);
             // $content	= !empty( $post->intro ) ? strip_tags( $post->intro ) : strip_tags( $post->content );
             // $content	= str_ireplace( "\r\n" , "" , $content );
             // $content	= str_ireplace( "&nbsp;" , " " , $content );
             // $content	= trim($content);
         }
         // Remove JFBConnect codes.
         if ($meta->description) {
             $pattern = '/\\{JFBCLike(.*)\\}/i';
             $meta->description = preg_replace($pattern, '', $meta->description);
         }
     }
     // Check if the descriptin or keysword still empty or not. if yes, try to get from joomla menu.
     if (empty($meta->description) && empty($meta->keywords)) {
         $active = JFactory::getApplication()->getMenu()->getActive();
         if ($active) {
             $params = $active->params;
             $description = $params->get('menu-meta_description', '');
             $keywords = $params->get('menu-meta_keywords', '');
             if (!empty($description) || !empty($keywords)) {
                 $meta = new stdClass();
                 $meta->description = EB::string()->escape($description);
                 $meta->keywords = $keywords;
             }
         }
     }
     if (!$meta) {
         return;
     }
     // If there's no meta description, try to get it from Joomla's settings
     if (!$meta->description && $defaultViewDesc) {
         $meta->description = $defaultViewDesc . ' - ' . EB::jconfig()->get('MetaDesc');
     }
     if ($meta->keywords) {
         $doc->setMetadata('keywords', $meta->keywords);
     }
     if ($meta->description) {
         $doc->setMetadata('description', $meta->description);
     }
     // Admin probably disabled indexing
     if (isset($meta->indexing) && !$meta->indexing) {
         $doc->setMetadata('robots', 'noindex,follow');
     }
 }
Пример #13
0
 /**
  * Retrieves the blogger's name
  *
  * @since	4.0
  * @access	public
  * @return	string
  */
 public function getName()
 {
     if ($this->id == 0) {
         return JText::_('COM_EASYBLOG_GUEST');
     }
     if (!$this->user) {
         $this->user = JFactory::getUser($this->id);
     }
     $config = EB::config();
     $type = $config->get('layout_nameformat');
     // Default to the person's name
     $name = $this->user->name;
     if ($type == 'username') {
         $name = $this->user->username;
     }
     if ($type == 'nickname' && !empty($this->nickname)) {
         $name = $this->nickname;
     }
     // Ensure that the name cannot be exploited.
     $name = EB::string()->escape($name);
     return $name;
 }
Пример #14
0
 /**
  * Displays blog posts created by specific users
  *
  * @since	4.0
  * @access	public
  */
 public function listings()
 {
     // Get sorting options
     $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd');
     $id = $this->input->get('id', 0, 'int');
     // Load the author object
     $author = EB::user($id);
     // Disallow all users from being viewed
     if (!$this->config->get('main_nonblogger_profile') && !EB::isBlogger($author->id) || !$author->id) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_INVALID_AUTHOR_ID_PROVIDED'));
     }
     // Get the authors acl
     $acl = EB::acl($author->id);
     // Set meta tags for the author if allowed to
     if ($acl->get('allow_seo')) {
         EB::setMeta($author->id, META_TYPE_BLOGGER, true);
     }
     // Set the breadcrumbs
     if (!EBR::isCurrentActiveMenu('blogger', $author->id) && !EBR::isCurrentActiveMenu('blogger')) {
         $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), EB::_('index.php?option=com_easyblog&view=blogger'));
         $this->setPathway($author->getName());
     }
     // Get the current active menu
     $active = $this->app->getMenu()->getActive();
     // Excluded categories
     $excludeCats = array();
     if (isset($active->params)) {
         $excludeCats = $active->params->get('exclusion');
         // Ensure that this is an array
         if (!is_array($excludeCats) && $excludeCats) {
             $excludeCats = array($excludeCats);
         }
     }
     // Get the blogs model now to retrieve our blog posts
     $model = EB::model('Blog');
     // Get blog posts
     $posts = $model->getBlogsBy('blogger', $author->id, $sort, 0, '', false, false, '', false, false, false, $excludeCats);
     $pagination = $model->getPagination();
     // Format the blogs with our standard formatter
     $posts = EB::formatter('list', $posts);
     // Add canonical urls
     $this->canonical('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $author->id);
     // Add authors rss links on the header
     if ($this->config->get('main_rss')) {
         if ($this->config->get('main_feedburner') && $this->config->get('main_feedburnerblogger')) {
             $this->doc->addHeadLink(EB::string()->escape($author->getRssLink()), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
         } else {
             // Add rss feed link
             $this->doc->addHeadLink($author->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
             $this->doc->addHeadLink($author->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
         }
     }
     // Set the title of the page
     $title = EB::getPageTitle($author->getName());
     $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend'));
     // Check if subscribed
     $bloggerModel = EB::model('Blogger');
     $isBloggerSubscribed = $bloggerModel->isBloggerSubscribedEmail($author->id, $this->my->email);
     $return = base64_encode($author->getPermalink());
     $this->set('return', $return);
     $this->set('author', $author);
     $this->set('posts', $posts);
     $this->set('sort', $sort);
     $this->set('isBloggerSubscribed', $isBloggerSubscribed);
     parent::display('authors/item');
 }
Пример #15
0
 /**
  * Escapes a string
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function escape($val)
 {
     return EB::string()->escape($val);
 }
Пример #16
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 = '';
     // 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;
 }
Пример #17
0
 /**
  * Sanitizes the text so that it doesn't display any funny characters on the string.
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function sanitizeText($text)
 {
     $text = strip_tags($text);
     $text = str_ireplace("\n", '', $text);
     $text = str_ireplace("\r", '', $text);
     $text = str_ireplace('&nbsp;', ' ', $text);
     $text = EB::string()->escape($text);
     return $text;
 }
Пример #18
0
 /**
  * Validates posted data
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function validatePost($post)
 {
     $config = EB::config();
     $my = JFactory::getUser();
     $comment = isset($post['comment']) ? $post['comment'] : '';
     $title = isset($post['title']) ? $post['title'] : '';
     $register = isset($post['register']) ? $post['register'] : false;
     $username = isset($post['username']) ? $post['username'] : '';
     $subscribe = isset($post['subscribe']) ? $post['subscribe'] : false;
     $name = isset($post['name']) ? $post['name'] : '';
     $email = isset($post['email']) ? $post['email'] : '';
     $website = isset($post['website']) ? $post['website'] : '';
     $terms = isset($post['terms']) ? $post['terms'] : '';
     // If name is empty, it could be that the user is logged in
     if (!$my->guest) {
         $user = EB::user($my->id);
         // Override the name
         $name = $user->getName();
         // Override the email
         $email = $my->email;
         // Override the website
         $website = $user->getWebsite();
     }
     if (!$comment || JString::strlen($comment) == 0) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENTS_PLEASE_ENTER_SOME_COMMENTS'));
         return false;
     }
     if ($config->get('comment_requiretitle') && JString::strlen($title) == 0) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENT_TITLE_IS_EMPTY'));
         return false;
     }
     if ($register && (!$username || JString::strlen($username) == 0)) {
         $this->setError(JText::_('COM_EASYBLOG_SUBSCRIPTION_USERNAME_IS_EMPTY'));
         return false;
     }
     if (!$name || JString::strlen($name) == 0) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENT_NAME_IS_EMPTY'));
         return false;
     }
     if ($config->get('comment_require_email') && (!$email || JString::strlen($email) == 0)) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENT_EMAIL_IS_EMPTY'));
         return false;
     }
     if ($my->guest && ($config->get('comment_require_website') && (!$website || JString::strlen($website) == 0))) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENT_WEBSITE_IS_EMPTY'));
         return false;
     }
     // If user is subscribed to the blog, ensure that email exists
     if ($subscribe && !$email) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENT_EMAIL_IS_EMPTY'));
         return false;
     }
     // Check for valid email
     $validEmail = EB::string()->isValidEmail($email);
     if ($config->get('comment_require_email') && !$validEmail) {
         $this->setError(JText::_('COM_EASYBLOG_COMMENT_EMAIL_INVALID'));
         return false;
     }
     // Ensure that the user checked the terms and condition box.
     if ($config->get('comment_tnc') && !$terms && ($config->get('comment_tnc_users') == 0 && $my->guest || $config->get('comment_tnc_users') == 1 && !$my->guest || $config->get('comment_tnc_users') == 2)) {
         $this->setError(JText::_('COM_EASYBLOG_YOU_MUST_ACCEPT_TNC'));
         return false;
     }
     return true;
 }
Пример #19
0
 /**
  * Tidy up the html contents
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 private function tidyContent($html)
 {
     return EB::string()->tidyHTMLContent($html);
 }
Пример #20
0
 /**
  * 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;
 }
Пример #21
0
 /**
  * Formats the content from the email to a normal blog content
  *
  * @since   4.0
  * @access  public
  * @param   string
  * @return
  */
 public function getMessageContents(EasyBlogMailboxMessage $message, $format = 'html')
 {
     $result = new stdClass();
     $result->html = $message->getHTML();
     $result->plain = nl2br($message->getPlain());
     // If plain text is empty, just fall back to html
     if (empty($result->plain)) {
         $result->body = nl2br(strip_tags($result->html));
     }
     $result->body = $format == 'html' ? $result->html : $result->plain;
     // If we can't get any result, just use the plain text
     $result->body = $result->body ? $result->body : $result->plain;
     // Filter the contents to avoid any unecessary data
     $filter = JFilterInput::getInstance(null, null, 1, 1);
     // JFilterInput doesn't strip css tags
     $result->body = preg_replace("'<style[^>]*>.*?</style>'si", '', $result->body);
     // Clean up the input
     $result->body = $filter->clean($result->body, 'html');
     $result->body = JString::trim($result->body);
     // Tidup content so that does not contain unclosed html codes
     $result->body = EB::string()->tidyHTMLContent($result->body);
     return $result;
 }
Пример #22
0
 public function getContentImage()
 {
     $content = $this->getPlainContent();
     $img = EB::string()->getImage($content);
     return $img;
 }
Пример #23
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;
 }
Пример #24
0
        ?>
		</div>
	<?php 
    }
    ?>

	<?php 
    if ($params->get('showcommentcount', 0)) {
        ?>
		<div class="mod-cell pr-10">
			<a href="<?php 
        echo $post->getPermalink();
        ?>
">
				<?php 
        echo EB::string()->getNoun('MOD_LATESTBLOGS_COMMENT_COUNT', $post->commentCount, true);
        ?>
			</a>
		</div>
	<?php 
    }
    ?>

	<?php 
    if ($params->get('showreadmore', true)) {
        ?>
		<div class="mod-cell">
			<a href="<?php 
        echo $post->getPermalink();
        ?>
"><?php 
Пример #25
0
 /**
  * Indexes a post on the site
  *
  * @since	5.0
  * @access	public
  * @param	FinderIndexerResult		The item to index
  * @param	string	The item's format
  * @return	void
  */
 protected function index(FinderIndexerResult $item, $format = 'html')
 {
     // Check if the extension is enabled
     if (!$this->exists()) {
         return;
     }
     // Build the necessary route and path information.
     $item->url = 'index.php?option=com_easyblog&view=entry&id=' . $item->id;
     $item->route = EBR::getRoutedURL($item->url, false, true);
     // Remove any /administrator/ segments from the url since the indexer could be executed from the back end
     $item->route = $this->removeAdminSegment($item->route);
     // Get the content path
     $item->path = FinderIndexerHelper::getContentPath($item->route);
     // If there is access defined, just set it to 2 which is special privileges.
     if (!$item->access || $item->access == 0) {
         $item->access = 1;
     } else {
         if ($item->access > 0) {
             $item->access = 2;
         }
     }
     // Load up the post item
     $post = EB::post();
     $post->load($item->id);
     // Get the intro text of the content
     $item->summary = $post->getIntro();
     // Get the contents
     $item->body = $post->getContent('entry', false);
     // If the post is password protected, we do not want to display the contents
     if ($post->isPasswordProtected()) {
         $item->summary = JText::_('PLG_FINDER_EASYBLOG_PASSWORD_PROTECTED');
     } else {
         // we want to get custom fields values.
         $fields = $post->getCustomFields();
         $fieldlib = EB::fields();
         $customfields = array();
         if ($fields) {
             foreach ($fields as $field) {
                 if ($field->group->hasValues($post)) {
                     foreach ($field->fields as $customField) {
                         $eachField = $fieldlib->get($customField->type);
                         $customfields[] = $eachField->text($customField, $post);
                     }
                 }
             }
             $customfieldvalues = implode(' ', $customfields);
             $item->body = $item->body . ' ' . $customfieldvalues;
         }
     }
     // Add the author's meta data
     $item->metaauthor = !empty($item->created_by_alias) ? $item->created_by_alias : $item->author;
     $item->author = !empty($item->created_by_alias) ? $item->created_by_alias : $item->author;
     // If the post has an image, use it
     $image = $post->getImage('thumbnail', false, true);
     // If there's no image, try to scan the contents for an image to be used
     if (!$image && $post->isLegacy()) {
         $image = EB::string()->getImage($item->body);
     }
     // If we still can't locate any images, use the placeholder image
     if (!$image) {
         $image = EB::getPlaceholderImage();
     }
     $registry = new JRegistry();
     $registry->set('image', $image);
     $item->params = $registry;
     // Add the meta-data processing instructions.
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
     // Add the type taxonomy data.
     $item->addTaxonomy('Type', 'EasyBlog');
     // Add the author taxonomy data.
     if (!empty($item->author) || !empty($item->created_by_alias)) {
         $item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author);
     }
     // Add the category taxonomy data.
     $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
     // Add the language taxonomy data.
     if (empty($item->language)) {
         $item->language = '*';
     }
     $item->addTaxonomy('Language', $item->language);
     // Get content extras.
     FinderIndexerHelper::getContentExtras($item);
     // For Joomla 3.0, the indexer is assigned to the property
     // Index the item.
     if (EB::isJoomla30()) {
         return $this->indexer->index($item);
     }
     return FinderIndexer::index($item);
 }
Пример #26
0
 /**
  * Normalizes an URI
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function normalizeURI($uri)
 {
     // If the url is already a hyperlink, just skip this
     $url = $uri;
     // If the url is not a hyperlink, MM uri format, we need to get the correct url
     if (!EB::string()->isHyperlink($uri)) {
         $url = EBMM::getUrl($uri);
     }
     return $url;
 }
Пример #27
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;
 }