Exemple #1
0
 function listings()
 {
     JPluginHelper::importPlugin('easyblog');
     $dispatcher = JDispatcher::getInstance();
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $config = EasyBlogHelper::getConfig();
     $my = JFactory::getUser();
     $acl = EasyBlogACLHelper::getRuleSet();
     $sort = JRequest::getCmd('sort', $config->get('layout_postorder'));
     $bId = JRequest::getCmd('id', '0');
     $blogger = EasyBlogHelper::getTable('Profile', 'Table');
     $blogger->load($bId);
     if (!$config->get('main_nonblogger_profile')) {
         if (!EasyBlogHelper::isBlogger($blogger->id)) {
             $redirect = EasyBlogRouter::_('index.php?option=com_easyblog&view=latest', false);
             $mainframe->redirect($redirect);
             $mainframe->close();
         }
     }
     // If blogger does not exist, redirect
     if (!$blogger->id) {
         $redirect = EasyBlogRouter::_('index.php?option=com_easyblog&view=latest', false);
         $mainframe->redirect($redirect);
         $mainframe->close();
     }
     if ($acl->rules->allow_seo) {
         EasyBlogHelper::setMeta($blogger->id, META_TYPE_BLOGGER, true);
     }
     if (!EasyBlogRouter::isCurrentActiveMenu('blogger', $blogger->id)) {
         if (!EasyBlogRouter::isCurrentActiveMenu('blogger')) {
             $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger'));
         }
         $this->setPathway($blogger->getName());
     }
     $model = $this->getModel('Blog');
     $data = $model->getBlogsBy('blogger', $blogger->id, $sort);
     $pagination = $model->getPagination();
     $data = EasyBlogHelper::formatBlog($data, false, true, true, true);
     $rssURL = EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger&task=rss');
     // @task: Add canonical URLs.
     if ($config->get('main_canonical_entry')) {
         $canonicalUrl = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $blogger->id, false, true, true);
         $document->addCustomTag('<link rel="canonical" href="' . $canonicalUrl . '"/>');
     }
     if ($config->get('layout_showcomment', false)) {
         for ($i = 0; $i < count($data); $i++) {
             $row =& $data[$i];
             $maxComment = $config->get('layout_showcommentcount', 3);
             $comments = EasyBlogHelper::getHelper('Comment')->getBlogComment($row->id, $maxComment, 'desc');
             $comments = EasyBlogHelper::formatBlogCommentsLite($comments);
             $row->comments = $comments;
         }
     }
     if ($config->get('main_rss')) {
         if ($config->get('main_feedburner') && $config->get('main_feedburnerblogger')) {
             $document->addHeadLink(EasyBlogHelper::getHelper('String')->escape($blogger->getRSS()), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
         } else {
             // Add rss feed link
             $document->addHeadLink($blogger->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
             $document->addHeadLink($blogger->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
         }
     }
     $title = EasyBlogHelper::getPageTitle($blogger->getName());
     // @task: Set the page title
     parent::setPageTitle($title, $pagination, $config->get('main_pagetitle_autoappend'));
     $theme = new CodeThemes();
     $theme->set('twitterLink', $blogger->getTwitterLink());
     $theme->set('blogger', $blogger);
     $theme->set('sort', $sort);
     $theme->set('blogs', $data);
     $theme->set('pagination', $pagination->getPagesLinks());
     $theme->set('my', $my);
     $theme->set('acl', $acl);
     $theme->set('currentURL', $blogger->getProfileLink());
     $theme->set('showAvatar', false);
     echo $theme->fetch('blog.blogger.php');
     echo EasyBlogHelper::getFBInitScript();
 }
Exemple #2
0
 public function getProfileLink($defaultItemId = '')
 {
     static $instance = array();
     static $phpbbDB = null;
     static $phpbbpath = null;
     static $isBlogger = array();
     // since it's for avatar, we'll follow the avatar's integration
     $config = EasyBlogHelper::getConfig();
     $source = $config->get('layout_avatarIntegration');
     if (!$config->get('main_nonblogger_profile')) {
         // 1st check if this user a blogger or not.
         $showLink = false;
         if (isset($isBlogger[$this->id])) {
             $showLink = $isBlogger[$this->id];
         } else {
             $showLink = EasyBlogHelper::isBlogger($this->id);
             $isBlogger[$this->id] = $showLink;
         }
         if (!$showLink) {
             return 'javascript: void(0);';
         }
     }
     // phpbb case
     if ($source == 'phpbb' && $phpbbDB === null) {
         $phpbbpath = $config->get('layout_phpbb_path');
         $file = JPATH_ROOT . DIRECTORY_SEPARATOR . $phpbbpath . DIRECTORY_SEPARATOR . 'config.php';
         if (JFile::exists($file)) {
             require $file;
             $host = $dbhost;
             $user = $dbuser;
             $password = $dbpasswd;
             $database = $dbname;
             $prefix = $table_prefix;
             $driver = $dbms;
             $debug = 0;
             $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix);
             $phpbbDB = JDatabase::getInstance($options);
         } else {
             $phpbbDB = false;
         }
     }
     if ($phpbbDB === false) {
         // can't get phpbb's config file, fallback to default profile link
         $source = 'default';
     }
     // Always use the core linking if user does not wants this.
     if (!$config->get('layout_avatar_link_name')) {
         $source = 'default';
     }
     // to ensure the passed in value is only a number
     $defaultItemId = str_replace('&Itemid=', '', $defaultItemId);
     // to ensure the uniqueness of the key
     $key = $source . '-' . $defaultItemId;
     // this is where the magic starts
     if (!isset($instance[$this->id][$key])) {
         $defaultItemId = !empty($defaultItemId) ? '&Itemid=' . $defaultItemId : '';
         $defaultLink = EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $this->id . $defaultItemId);
         switch ($source) {
             case 'k2':
                 $file1 = JPATH_ROOT . '/components/com_k2/helpers/route.php';
                 $file2 = JPATH_ROOT . '/components/com_k2/helpers/utilities.php';
                 jimport('joomla.filesystem.file');
                 if (JFile::exists($file1) && JFile::exists($file2)) {
                     require_once $file1;
                     require_once $file2;
                     $ret = K2HelperRoute::getUserRoute($this->id);
                 } else {
                     $ret = $defaultLink;
                 }
                 break;
             case 'mightyregistration':
                 $ret = JRoute::_('index.php?option=com_community&view=profile&user_id=' . $this->id, false);
                 break;
             case 'communitybuilder':
                 $ret = JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='******'easysocial':
                 $easysocial = EasyBlogHelper::getHelper('EasySocial');
                 $ret = '';
                 if ($easysocial->exists()) {
                     $easysocial->init();
                     $user = Foundry::user($this->id);
                     $ret = $user->getPermalink();
                 }
                 break;
             case 'jomsocial':
                 $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php';
                 $ret = JFile::exists($file) && (require_once $file) ? CRoute::_('index.php?option=com_community&view=profile&userid=' . $this->id) : '';
                 break;
             case 'kunena':
                 $ret = JRoute::_('index.php?option=com_kunena&func=fbprofile&userid=' . $this->id, false);
                 break;
             case 'phpbb':
                 $juser = JFactory::getUser($this->id);
                 $query = 'SELECT ' . $phpbbDB->nameQuote('user_id') . ' ' . 'FROM ' . $phpbbDB->nameQuote('#__users') . ' WHERE LOWER(' . $phpbbDB->nameQuote('username') . ') = LOWER(' . $phpbbDB->quote($juser->username) . ') ';
                 $phpbbDB->setQuery($query, 0, 1);
                 $phpbbuserid = $phpbbDB->loadResult();
                 $ret = $phpbbuserid ? JURI::root() . rtrim($phpbbpath, '/') . '/memberlist.php?mode=viewprofile&u=' . $phpbbuserid : '';
                 break;
             case 'anahita':
                 $person = KFactory::get('lib.anahita.se.person.helper')->getPerson($this->id);
                 $ret = $person->getURL();
                 break;
             case 'easydiscuss':
                 $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easydiscuss' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'router.php';
                 $ret = JFile::exists($file) && (require_once $file) ? DiscussRouter::_('index.php?option=com_easydiscuss&view=profile&id=' . $this->id, false) : '';
                 break;
             case 'gravatar':
             case 'default':
             default:
                 $ret = '';
                 break;
         }
         $instance[$this->id][$key] = $ret ? $ret : $defaultLink;
     }
     return $instance[$this->id][$key];
 }