/** * This method store a post by user. */ public function storePost() { $app = JFactory::getApplication(); /** @var $app JApplicationSite */ $content = $this->input->getString('content'); $user = JFactory::getUser(); $userId = $user->get('id'); $content = JString::trim(strip_tags($content)); $content = JHtmlString::truncate($content, 140); if (!$userId) { $app->close(); } $userTimeZone = !$user->getParam('timezone') ? null : $user->getParam('timezone'); try { $date = new JDate('now', $userTimeZone); $entity = new Socialcommunity\Wall\User\Post(JFactory::getDbo()); $entity->setUserId($userId); $entity->setContent($content); $entity->setCreated($date->toSql(true)); $entity->store(); } catch (Exception $e) { JLog::add($e->getMessage()); throw new Exception(JText::_('COM_SOCIALCOMMUNITY_ERROR_SYSTEM')); } $params = JComponentHelper::getParams('com_socialcommunity'); $filesystemHelper = new Prism\Filesystem\Helper($params); $mediaFolder = $filesystemHelper->getMediaFolderUri($userId); $profile = new Socialcommunity\Profile\Profile(JFactory::getDbo()); $profile->load(['user_id' => $userId]); $displayData = new stdClass(); $displayData->id = $entity->getId(); $displayData->profileLink = JRoute::_(SocialCommunityHelperRoute::getProfileRoute($profile->getSlug()), false); $displayData->name = htmlentities($profile->getName(), ENT_QUOTES, 'utf-8'); $displayData->alias = htmlentities($profile->getAlias(), ENT_QUOTES, 'utf-8'); $displayData->imageSquare = $mediaFolder . '/' . $profile->getImageSquare(); $displayData->imageAlt = $displayData->name; $displayData->content = $entity->getContent(); $displayData->created = JHtml::_('socialcommunity.created', $entity->getCreated(), $userTimeZone); $layout = new JLayoutFile('wall_post'); echo $layout->render($displayData); $app->close(); }
protected static function findItem($needles = null) { $app = JFactory::getApplication(); $menus = $app->getMenu('site'); // Prepare the reverse lookup array. // Collect all menu items and create an array that contains // the ID from the query string of the menu item as a key, // and the menu item id (Itemid) as a value // Example: // array( "category" => // 1(id) => 100 (Itemid), // 2(id) => 101 (Itemid) // ); if (self::$lookup === null) { self::$lookup = array(); $component = JComponentHelper::getComponent(self::$component); $items = $menus->getItems('component_id', $component->id); if ($items) { foreach ($items as $item) { if (isset($item->query) && isset($item->query['view'])) { $view = $item->query['view']; if (!isset(self::$lookup[$view])) { self::$lookup[$view] = array(); } if (isset($item->query['id'])) { self::$lookup[$view][$item->query['id']] = $item->id; } else { // If it is a root element that have no a request parameter ID ( categories, authors ), we set 0 for an key self::$lookup[$view][0] = $item->id; } } } } } if ($needles) { foreach ($needles as $view => $ids) { if (isset(self::$lookup[$view])) { foreach ($ids as $id) { if (isset(self::$lookup[$view][(int) $id])) { return self::$lookup[$view][(int) $id]; } } } } } else { $active = $menus->getActive(); if ($active) { return $active->id; } } return null; }
/** * Get a link to user profile. * * <code> * $ids = array(1, 2, 3, 4); * $userId = 1; * * $profiles = new ITPrismIntegrateProfilesSocialCommunity(); * $profiles->load($ids); * * $link = $profiles->getLink($userId); * </code> * * @param integer $userId * * @return string */ public function getLink($userId) { if (!isset($this->profiles[$userId])) { $link = ""; } else { $link = SocialCommunityHelperRoute::getProfileRoute($this->profiles[$userId]->slug); } return $link; }
<div class="media"> <?php if (!empty($item->image)) { ?> <div class="media-left"> <img class="media-object" src="<?php echo $item->image; ?> "> </div> <?php } ?> <div class="media-body"> <a href="<?php echo JRoute::_(SocialCommunityHelperRoute::getNotificationRoute($item->id)); ?> "><?php echo $item->content; ?> </a> </div> </div> </div> <div class="col-md-1"> <img src="<?php echo !$item->status ? 'media/com_socialcommunity/images/status_active.png' : 'media/com_socialcommunity/images/status_inactive.png'; ?> "/> </div> </div>
/** * Get a link to user profile. * * <code> * $ids = array(1, 2, 3, 4); * $userId = 1; * * $profiles = new Prism\Integration\Profiles\SocialCommunity(\JFactory::getDbo()); * $profiles->load($ids); * * $link = $profiles->getLink($userId); * </code> * * @param int $userId * @param bool $route Route or not the link. * * @return string */ public function getLink($userId, $route = true) { $link = ''; if (array_key_exists($userId, $this->profiles) and !empty($this->profiles[$userId]->slug)) { $link = \SocialCommunityHelperRoute::getProfileRoute($this->profiles[$userId]->slug); if ($route) { $link = \JRoute::_($link); } } return $link; }
* @copyright Copyright (C) 2016 Todor Iliev <*****@*****.**>. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL */ // no direct access defined('_JEXEC') or die; if (!$this->item->image) { $image = 'media/com_socialcommunity/images/no_profile_200x200.png'; $imageSquare = 'media/com_socialcommunity/images/no_profile_50x50.png'; $imageAlt = ''; } else { $image = $this->mediaFolder . '/' . $this->item->image; $imageSquare = $this->mediaFolder . '/' . $this->item->image_square; $imageAlt = 'alt="' . $this->escape($this->item->name) . '"'; } $layoutData = new stdClass(); $layoutData->profileLink = JRoute::_(SocialCommunityHelperRoute::getProfileRoute($this->item->user_id), false); $layoutData->imageAlt = $imageAlt; $layoutData->imageSquare = $imageSquare; $layoutData->name = $this->escape($this->item->name); $layoutData->alias = $this->escape($this->item->alias); ?> <div class="scprofile-wall<?php echo $this->params->get('pageclass_sfx'); ?> "> <?php if ($this->item->event->beforeDisplayContent) { echo $this->item->event->beforeDisplayContent; } ?>
echo JText::_('JREGISTER'); ?> </button> <a class="btn btn-default" href="<?php echo JRoute::_(''); ?> " title="<?php echo JText::_('JCANCEL'); ?> "> <?php echo JText::_('JCANCEL'); ?> </a> </div> <input type="hidden" name="option" value="com_users" /> <input type="hidden" name="task" value="registration.register" /> <input type="hidden" name="return" value="<?php echo base64_encode(JRoute::_(SocialCommunityHelperRoute::getProfileRoute())); ?> " /> <?php echo JHtml::_('form.token'); ?> </form> <?php echo $this->formRegistration->getLabel('spacer'); ?> </div> </div> </div>
/** * Get a link to user profile. * * <code> * $ids = array(1, 2, 3, 4); * $userId = 1; * * $profiles = new Prism\Integration\Profiles\SocialCommunity(\JFactory::getDbo()); * $profiles->load($ids); * * $link = $profiles->getLink($userId); * </code> * * @param int $userId * @param bool $route Route or not the link. * * @return string */ public function getLink($userId, $route = true) { $link = ""; if (isset($this->profiles[$userId]) and !empty($this->profiles[$userId]->slug)) { $link = \SocialCommunityHelperRoute::getProfileRoute($this->profiles[$userId]->slug); if ($route) { $link = \JRoute::_($link); } } return $link; }
echo $active["contact"] ? 'class="active"' : ''; ?> > <a href="<?php echo JRoute::_(SocialCommunityHelperRoute::getFormRoute("contact")); ?> "> <?php echo JText::_("COM_SOCIALCOMMUNITY_CONTACT"); ?> </a> </li> <li <?php echo $active["social"] ? 'class="active"' : ''; ?> > <a href="<?php echo JRoute::_(SocialCommunityHelperRoute::getFormRoute("social")); ?> "> <?php echo JText::_("COM_SOCIALCOMMUNITY_SOCIAL"); ?> </a> </li> </ul> </div> </div> </div>
/** * Provide a link to social profile. * * <code> * $userId = 1; * * $profile = new Prism\Integration\Profile\SocialCommunity(\JFactory::getDbo()); * $profile->load($userId); * * $link = $profile->getLink(); * </code> * * @param bool $route Route or not the link. * * @return string */ public function getLink($route = true) { $link = ""; if (!empty($this->slug)) { $link = \SocialCommunityHelperRoute::getProfileRoute($this->slug); if ($route) { $link = \JRoute::_($link); } } return $link; }
echo $active['contact'] ? 'class="active"' : ''; ?> > <a href="<?php echo JRoute::_(SocialCommunityHelperRoute::getFormRoute('contact')); ?> "> <?php echo JText::_('COM_SOCIALCOMMUNITY_CONTACT'); ?> </a> </li> <li <?php echo $active['social'] ? 'class="active"' : ''; ?> > <a href="<?php echo JRoute::_(SocialCommunityHelperRoute::getFormRoute('social')); ?> "> <?php echo JText::_('COM_SOCIALCOMMUNITY_SOCIAL_PROFILES'); ?> </a> </li> </ul> </div> </div> </div>
/** * Provide a link to social profile. * * <code> * $userId = 1; * * $profile = new Prism\Integration\Profile\SocialCommunity(\JFactory::getDbo()); * $profile->load($userId); * * $link = $profile->getLink(); * </code> * * @param bool $route Route or not the link. * * @return string */ public function getLink($route = true) { $link = ''; if (\JString::strlen($this->slug) > 0) { $link = \SocialCommunityHelperRoute::getProfileRoute($this->slug); if ($route) { $link = \JRoute::_($link); } } return $link; }