本文整理汇总了PHP中CTimeHelper::timeLapse方法的典型用法代码示例。如果您正苦于以下问题:PHP CTimeHelper::timeLapse方法的具体用法?PHP CTimeHelper::timeLapse怎么用?PHP CTimeHelper::timeLapse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTimeHelper
的用法示例。
在下文中一共展示了CTimeHelper::timeLapse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getArticleHTML
public static function _getArticleHTML($userid, $limit, $limitstart, $row, $app, $total, $cat, $params)
{
JPluginHelper::importPlugin('content');
$dispatcher = JDispatcher::getInstance();
$html = "";
if (!empty($row)) {
$html .= '<div class="joms-app--myarticle">';
$html .= '<ul class="joms-list">';
foreach ($row as $data) {
$text_limit = $params->get('limit', 50);
$result = $dispatcher->trigger('onPrepareContent', array(&$data, &$params, 0));
if (empty($cat[$data->catid])) {
$cat[$data->catid] = "";
}
$data->sectionid = empty($data->sectionid) ? 0 : $data->sectionid;
$link = plgCommunityMyArticles::buildLink($data->id, $data->alias, $data->catid, $cat[$data->catid], $data->sectionid);
$created = new JDate($data->created);
$date = CTimeHelper::timeLapse($created);
$html .= ' <li>';
$html .= ' <a href="' . $link . '">' . htmlspecialchars($data->title) . '</a>';
$html .= '<span class="joms-block joms-text--small joms-text--light">' . $date . '</span>';
$html .= ' </li>';
}
$html .= '</ul>';
$showall = CRoute::_('index.php?option=com_community&view=profile&userid=' . $userid . '&task=app&app=myarticles');
$html .= "<div class='joms-gap'></div><div class='list-articles--button'><small><a class='joms-button--link' href='" . $showall . "'>" . JText::_('PLG_MYARTICLES_SHOWALL') . "</a></small></div>";
$html .= '</div>';
} else {
$html .= "<p>" . JText::_("PLG_MYARTICLES_NO_ARTICLES") . "</p>";
}
return $html;
}
示例2: getLastUpdated
public function getLastUpdated($raw = false)
{
$this->_lastupdated = $this->created;
if ($raw) {
return $this->_lastupdated;
}
if ($this->_lastupdated == '0000-00-00 00:00:00' || $this->_lastupdated == '') {
$this->_lastupdated = $this->created;
if ($this->_lastupdated == '' || $this->_lastupdated == '0000-00-00 00:00:00') {
$this->_lastupdated = JText::_('COM_COMMUNITY_NO_LAST_ACTIVITY');
} else {
$lastUpdated = new JDate($this->_lastupdated);
//$this->_lastupdated = CActivityStream::_createdLapse( $lastUpdated, false );
$this->_lastupdated = CTimeHelper::timeLapse($lastUpdated);
}
} else {
$lastUpdated = new JDate($this->_lastupdated);
//$this->_lastupdated = CActivityStream::_createdLapse( $lastUpdated, false );
$this->_lastupdated = CTimeHelper::timeLapse($lastUpdated);
}
return $this->_lastupdated;
}
示例3: viewdiscussion
/**
* View method to display specific discussion from a group
* @since 2.4
* @access public
* @param Object Data object passed from controller
*/
public function viewdiscussion()
{
$mainframe =& JFactory::getApplication();
$document = JFactory::getDocument();
$jconfig = JFactory::getConfig();
$config = CFactory::getConfig();
// Load window library
CFactory::load('libraries', 'window');
// Load necessary window css / javascript headers.
CWindow::load();
// Get necessary variables
CFactory::load('models', 'groups');
CFactory::load('models', 'discussions');
$my = CFactory::getUser();
$groupId = JRequest::getInt('groupid', '', 'GET');
$topicId = JRequest::getInt('topicid', '', 'GET');
// Load necessary library and objects
$groupModel = CFactory::getModel('groups');
$group =& JTable::getInstance('Group', 'CTable');
$discussion =& JTable::getInstance('Discussion', 'CTable');
$group->load($groupId);
$discussion->load($topicId);
$isBanned = $group->isBanned($my->id);
$document->addCustomTag('<link rel="image_src" href="' . $group->getThumbAvatar() . '" />');
// @rule: Test if the group is unpublished, don't display it at all.
if (!$group->published) {
$this->_redirectUnpublishGroup();
return;
}
$feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussion&topicid=' . $topicId . '&format=feed');
$feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_GROUPS_LATEST_FEED') . '" href="' . $feedLink . '"/>';
$document->addCustomTag($feed);
CFactory::load('helpers', 'owner');
if ($group->approvals == 1 && !$group->isMember($my->id) && !COwnerHelper::isCommunityAdmin()) {
$this->noAccess(JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE'));
return;
}
// Execute discussion onDisplay filter
$appsLib =& CAppPlugins::getInstance();
$appsLib->loadApplications();
$args = array();
$args[] =& $discussion;
$appsLib->triggerEvent('onDiscussionDisplay', $args);
// Get the discussion creator info
$creator = CFactory::getUser($discussion->creator);
// Format the date accordingly.
//$discussion->created = CTimeHelper::getDate( $discussion->created );
$dayinterval = ACTIVITY_INTERVAL_DAY;
$timeFormat = $config->get('activitiestimeformat');
$dayFormat = $config->get('activitiesdayformat');
if ($config->get('activitydateformat') == COMMUNITY_DATE_FIXED) {
$discussion->created = CTimeHelper::getDate($discussion->created)->toFormat(JText::_('DATE_FORMAT_LC2'), true);
} else {
$discussion->created = CTimeHelper::timeLapse(CTimeHelper::getDate($discussion->created));
}
// Set page title
$document->setTitle(JText::sprintf('COM_COMMUNITY_GROUPS_DISCUSSION_TITTLE', $discussion->title));
// Add pathways
$this->_addGroupInPathway($group->id);
$this->addPathway(JText::_('COM_COMMUNITY_GROUPS_DISCUSSION'), CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussions&groupid=' . $group->id));
$this->addPathway(JText::sprintf('COM_COMMUNITY_GROUPS_DISCUSSION_TITTLE', $discussion->title));
CFactory::load('helpers', 'owner');
$isGroupAdmin = $groupModel->isAdmin($my->id, $group->id);
if ($my->id == $creator->id || $isGroupAdmin || COwnerHelper::isCommunityAdmin()) {
$title = JText::_('COM_COMMUNITY_DELETE_DISCUSSION');
$titleLock = $discussion->lock ? JText::_('COM_COMMUNITY_UNLOCK_DISCUSSION') : JText::_('COM_COMMUNITY_LOCK_DISCUSSION');
$actionLock = $discussion->lock ? JText::_('COM_COMMUNITY_UNLOCK') : JText::_('COM_COMMUNITY_LOCK');
$this->addSubmenuItem('', $actionLock, "joms.groups.lockTopic('" . $titleLock . "','" . $group->id . "','" . $discussion->id . "');", SUBMENU_RIGHT);
$this->addSubmenuItem('', JText::_('COM_COMMUNITY_DELETE'), "joms.groups.removeTopic('" . $title . "','" . $group->id . "','" . $discussion->id . "');", SUBMENU_RIGHT);
$this->addSubmenuItem('index.php?option=com_community&view=groups&task=editdiscussion&groupid=' . $group->id . '&topicid=' . $discussion->id, JText::_('COM_COMMUNITY_EDIT'), '', SUBMENU_RIGHT);
}
$this->showSubmenu();
CFactory::load('libraries', 'wall');
$wallContent = CWallLibrary::getWallContents('discussions', $discussion->id, $isGroupAdmin, $jconfig->get('list_limit'), 0, 'wall.content', 'groups,discussion');
$wallCount = CWallLibrary::getWallCount('discussions', $discussion->id);
$viewAllLink = CRoute::_('index.php?option=com_community&view=groups&task=discussapp&topicid=' . $discussion->id . '&app=walls');
$wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
// Test if the current browser is a member of the group
$isMember = $group->isMember($my->id);
$waitingApproval = false;
// If I have tried to join this group, but not yet approved, display a notice
if ($groupModel->isWaitingAuthorization($my->id, $group->id)) {
$waitingApproval = true;
}
$wallForm = '';
$config = CFactory::getConfig();
// Only get the wall form if user is really allowed to see it.
if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && $isMember && !$isBanned && !$waitingApproval || COwnerHelper::isCommunityAdmin()) {
$outputLock = '<div class="warning">' . JText::_('COM_COMMUNITY_DISCUSSION_LOCKED_NOTICE') . '</div>';
$outputUnLock = CWallLibrary::getWallInputForm($discussion->id, 'groups,ajaxSaveDiscussionWall', 'groups,ajaxRemoveReply');
$wallForm = '<div class="wall-tittle">' . JText::_('COM_COMMUNITY_REPLIES') . '</div>';
$wallForm .= $discussion->lock ? $outputLock : $outputUnLock;
}
if (empty($wallForm)) {
//.........这里部分代码省略.........
示例4: getLastUpdate
/**
* Method to get the last update
*
* @return type
*/
public function getLastUpdate()
{
// If new albums that has just been created and
// does not contain any images, the lastupdated will always be 0000-00-00 00:00:00:00
// Try to use the albums creation date instead.
if ($this->lastupdated == '0000-00-00 00:00:00' || $this->lastupdated == '') {
$lastupdated = $this->created;
if ($this->lastupdated == '' || $this->lastupdated == '0000-00-00 00:00:00') {
$lastupdated = JText::_('COM_COMMUNITY_PHOTOS_NO_ACTIVITY');
} else {
$lastUpdated = new JDate($this->lastupdated);
$lastupdated = CTimeHelper::timeLapse($lastUpdated, false);
}
} else {
$lastUpdated = new JDate($this->lastupdated);
$lastupdated = CTimeHelper::timeLapse($lastUpdated, false);
}
return $lastupdated;
}
示例5: getGroupAnnouncementUpdate
/**
* @since 2.6
* @param user id
* @return array of the latest group announcement the user is in
*/
public function getGroupAnnouncementUpdate($userid, $limit = 3)
{
$userGroups = $this->getGroupIds($userid);
$albumsDetails = array();
if ($limit > 0) {
$extraSQL = ' LIMIT ' . $limit;
}
if (count($userGroups) > 0) {
$db = $this->getDBO();
$groups_id = implode(',', $userGroups);
$query = 'SELECT b.*, g.name AS group_name FROM ' . $db->quoteName('#__community_groups_bulletins') . ' AS b, ' . $db->quoteName('#__community_groups') . ' AS g WHERE b.groupid IN (' . $groups_id . ' ) AND g.id=b.groupid ORDER BY b.id DESC ' . $extraSQL;
$db->setQuery($query);
$announcements = $db->loadAssocList();
foreach ($announcements as &$announcement) {
//grouplink
$announcement['group_link'] = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $announcement['groupid']);
$announcement['announcement_link'] = CRoute::_('index.php?option=com_community&view=groups&task=viewbulletin&groupid=' . $announcement['groupid'] . '&bulletinid=' . $announcement['id']);
$date = CTimeHelper::getDate($announcement['date']);
$announcement['created_interval'] = CTimeHelper::timeLapse($date);
$announcement['user_avatar'] = CFactory::getUser($announcement['created_by'])->getThumbAvatar();
$announcement['user_name'] = CFactory::getUser($announcement['created_by'])->getName();
}
}
return $announcements;
}
示例6: ajaxGetInbox
/**
* Popup message notification
*/
public function ajaxGetInbox()
{
$objResponse = new JAXResponse();
$inboxModel = CFactory::getModel('inbox');
$messages = $inboxModel->getInbox(false);
// format for template
$data = array();
foreach ($messages as $row) {
$user = CFactory::getUser($row->from);
$obj = new stdClass();
$obj->user = $user;
$obj->title = $row->subject;
$obj->link = CRoute::_('index.php?option=com_community&view=inbox&task=read&msgid=' . $row->parent);
$obj->created = CTimeHelper::timeLapse(CTimeHelper::getDate($row->posted_on));
$obj->action = null;
$data[] = $obj;
}
$tmpl = new CTemplate();
$html = $tmpl->set('notifications', $data)->set('link', CRoute::_('index.php?option=com_community&view=inbox'))->set('link_text', JText::_('COM_COMMUNITY_NOTIFICATIONS_SHOW_ALL_MSG'))->set('empty_notice', JText::_('COM_COMMUNITY_NOTIFICATIONS_NO_MESSAGE'))->fetch('notification.list');
$objResponse->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_MESSAGE'));
$objResponse->addScriptCall('cWindowAddContent', $html);
return $objResponse->sendResponse();
}
示例7: formatComment
/**
* Return formatted comment given the wall item
*/
public static function formatComment($wall)
{
$config = CFactory::getConfig();
$my = CFactory::getUser();
$actModel = CFactory::getModel('activities');
$like = new CLike();
$likeCount = $like->getLikeCount('comment', $wall->id);
$isLiked = $like->userLiked('comment', $wall->id, $my->id);
$user = CFactory::getUser($wall->post_by);
// Censor if the user is banned
if ($user->block) {
$wall->comment = $origComment = JText::_('COM_COMMUNITY_CENSORED');
} else {
// strip out the comment data
$CComment = new CComment();
$wall->comment = $CComment->stripCommentData($wall->comment);
// Need to perform basic formatting here
// 1. support nl to br,
// 2. auto-link text
$CTemplate = new CTemplate();
$wall->comment = $origComment = $CTemplate->escape($wall->comment);
$wall->comment = CStringHelper::autoLink($wall->comment);
}
$commentsHTML = '';
$commentsHTML .= '<div class="cComment wall-coc-item" id="wall-' . $wall->id . '"><a href="' . CUrlHelper::userLink($user->id) . '"><img src="' . $user->getThumbAvatar() . '" alt="" class="wall-coc-avatar" /></a>';
$date = new JDate($wall->date);
$commentsHTML .= '<a class="wall-coc-author" href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a> ';
$commentsHTML .= $wall->comment;
$commentsHTML .= '<span class="wall-coc-time">' . CTimeHelper::timeLapse($date);
$cid = isset($wall->contentid) ? $wall->contentid : null;
$activity = $actModel->getActivity($cid);
$ownPost = $my->id == $wall->post_by;
$allowRemove = $my->authorise('community.delete', 'walls', $wall);
$canEdit = $config->get('wallediting') && $my->id == $wall->post_by || COwnerHelper::isCommunityAdmin();
// only poster can edit
if ($allowRemove) {
$commentsHTML .= ' <span class="wall-coc-remove-link">• <a href="#removeComment">' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</a></span>';
}
$commentsHTML .= '</span>';
$commentsHTML .= '</div>';
$editHTML = '';
if ($config->get('wallediting') && $ownPost || COwnerHelper::isCommunityAdmin()) {
$editHTML .= '<a href="javascript:" class="joms-button--edit">';
$editHTML .= '<svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="' . CRoute::getURI() . '#joms-icon-pencil"></use></svg>';
$editHTML .= '<span>' . JText::_('COM_COMMUNITY_EDIT') . '</span>';
$editHTML .= '</a>';
}
$removeHTML = '';
if ($allowRemove) {
$removeHTML .= '<a href="javascript:" class="joms-button--remove">';
$removeHTML .= '<svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="' . CRoute::getURI() . '#joms-icon-remove"></use></svg>';
$removeHTML .= '<span>' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</span>';
$removeHTML .= '</a>';
}
$removeTagHTML = '';
if (CActivitiesHelper::hasTag($my->id, $wall->comment)) {
$removeTagHTML = '<span><a data-action="remove-tag" data-id="' . $wall->id . '" href="javascript:">' . JText::_('COM_COMMUNITY_WALL_REMOVE_TAG') . '</a></span>';
}
/* user deleted */
if ($user->guest == 1) {
$userLink = '<span class="cStream-Author">' . $user->getDisplayName() . '</span> ';
} else {
$userLink = '<a class="cStream-Avatar cStream-Author cFloat-L" href="' . CUrlHelper::userLink($user->id) . '"> <img class="cAvatar" src="' . $user->getThumbAvatar() . '"> </a> ';
}
$params = $wall->params;
$paramsHTML = '';
$image = (array) $params->get('image');
$photoThumbnail = false;
if ($params->get('attached_photo_id') > 0) {
$photo = JTable::getInstance('Photo', 'CTable');
$photo->load($params->get('attached_photo_id'));
$photoThumbnail = $photo->getThumbURI();
$paramsHTML .= '<div style="padding: 5px 0"><img class="joms-stream-thumb" src="' . $photoThumbnail . '" /></div>';
} else {
if ($params->get('title')) {
$video = self::detectVideo($params->get('url'));
if (is_object($video)) {
$paramsHTML .= '<div class="joms-media--video joms-js--video"';
$paramsHTML .= ' data-type="' . $video->type . '"';
$paramsHTML .= ' data-id="' . $video->id . '"';
$paramsHTML .= ' data-path="' . ($video->type === 'file' ? JURI::root(true) . '/' : '') . $video->path . '"';
$paramsHTML .= ' style="margin-top:10px;">';
$paramsHTML .= '<div class="joms-media__thumbnail">';
$paramsHTML .= '<img src="' . $video->getThumbnail() . '">';
$paramsHTML .= '<a href="javascript:" class="mejs-overlay mejs-layer mejs-overlay-play joms-js--video-play joms-js--video-play-' . $wall->id . '">';
$paramsHTML .= '<div class="mejs-overlay-button"></div>';
$paramsHTML .= '</a>';
$paramsHTML .= '</div>';
$paramsHTML .= '<div class="joms-media__body">';
$paramsHTML .= '<h4 class="joms-media__title">' . JHTML::_('string.truncate', $video->title, 50, true, false) . '</h4>';
$paramsHTML .= '<p class="joms-media__desc">' . JHTML::_('string.truncate', $video->description, $config->getInt('streamcontentlength'), true, false) . '</p>';
$paramsHTML .= '</div>';
$paramsHTML .= '</div>';
} else {
$paramsHTML .= '<div class="joms-gap"></div>';
$paramsHTML .= '<div class="joms-media--album joms-relative joms-js--comment-preview">';
if ($user->id == $my->id || COwnerHelper::isCommunityAdmin()) {
//.........这里部分代码省略.........
示例8:
echo JText::_('COM_COMMUNITY_INBOX_REMOVE');
?>
</span>
</a>
</div>
<div class="joms-list--message__checkbox js-mail-checkbox">
<span>
<input type="checkbox" class="joms-checkbox" name="message[]" value="<?php
echo $message->id;
?>
" onclick="checkSelected();">
</span>
</div>
<small class="joms-list--message__time">
<?php
$postdate = CTimeHelper::timeLapse(CTimeHelper::getDate($message->posted_on));
echo $postdate;
?>
<svg class="joms-icon" viewBox="0 0 16 16">
<use xlink:href="<?php
echo CRoute::getURI();
?>
#joms-icon-clock"/>
</svg>
</small>
</div>
<?php
}
?>
</div>
示例9: getCreateTimeFormatted
/**
* Return create time formatted by follow configured
* @return string
*/
public function getCreateTimeFormatted()
{
$config = CFactory::getConfig();
$date = JFactory::getDate($this->get('created'));
if ($config->get('activitydateformat') == "lapse") {
$createdTime = CTimeHelper::timeLapse($date, false);
} else {
$createdTime = $date->format($config->get('profileDateFormat'));
}
return $createdTime;
}
示例10: foreach
<img src="<?php
echo $user->getThumbAvatar();
?>
" alt="<?php
echo $user->getDisplayName();
?>
" data-author="<?php
echo $user->id;
?>
" />
</a>
</div>
<div class="joms-stream__meta">
<div class="joms-stream__time">
<small><?php
echo CTimeHelper::timeLapse(CTimeHelper::getDate($row->created));
?>
</small>
</div>
</div>
</div>
<div class="joms-stream__body">
<div class="cStream-Headline"><?php
$content = CContentHelper::injectTags($row->content, $row->params, true);
if ($isPhotoModal && $row->cmd_type == 'notif_photos_like') {
preg_match_all('/(albumid|photoid)=(\\d+)/', $content, $matches);
// Get albumid and photoid.
$albumid = false;
$photoid = false;
foreach ($matches[1] as $index => $varname) {
if ($varname == 'albumid') {
示例11: _getKunenaHTML
public static function _getKunenaHTML($usr_info, $userId, $userName, $items, $fbItemid)
{
ob_start();
if ($usr_info) {
if (!empty($items)) {
?>
<div id="applications-kunena">
<?php
foreach ($items as $item) {
$fbURL = JRoute::_("index.php?option=com_kunena&func=view" . $fbItemid . "&catid=" . $item->catid . "&id=" . $item->id . "#" . $item->id);
$fbCatURL = JRoute::_("index.php?option=com_kunena" . $fbItemid . "&func=showcat&catid=" . $item->catid);
$postDate = new JDate($item->time);
?>
<div class="apps-item">
<b>
<a href="<?php
echo $fbURL;
?>
"
class="apps-headline"><?php
echo stripslashes($item->subject);
?>
</a>
</b>
in
<a href="<?php
echo $fbCatURL;
?>
"><?php
echo $item->catname;
?>
</a>
on
<?php
echo CTimeHelper::timeLapse($postDate, false);
?>
</div>
<?php
}
?>
</div>
<?php
} else {
?>
<div class="icon-nopost">
<img src="<?php
echo JURI::base();
?>
plugins/community/kunena/kunena/no-post.gif" alt=""/>
</div>
<div class="content-nopost">
<?php
echo $userName . ' ' . JText::_('PLG_KUNENA_NO_DISCUSSION_JOIN');
?>
</div>
<?php
}
} else {
?>
<div class="icon-nopost">
<img src="<?php
echo JURI::base();
?>
plugins/community/kunena/kunena/no-post.gif" alt=""/>
</div>
<div class="content-nopost">
<?php
echo JText::_('PLG_KUNENA_NO_FORUM_POST');
?>
</div>
<?php
}
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
示例12:
<div class="body">
<div class="name">
<a href="<?php
echo JURI::root() . '/administrator/index.php?option=com_community&view=users&layout=edit&id=' . $member->id;
?>
"><?php
echo $member->getDisplayName();
?>
</a>
</div>
<div class="time">
<i class="js-icon-time"></i>
<span class="green"><?php
echo CTimeHelper::timeLapse(JFactory::getDate($member->registerDate));
?>
</span>
</div>
<div id="member-label-<?php
echo $member->id;
?>
">
<span class="label <?php
echo $this->getLabelCss($member->memberstatus);
?>
"><?php
echo $member->memberstatus;
?>
</span>
示例13:
</a>
</div>
<?php
} else {
if ($paramsHTML) {
?>
<?php
echo $paramsHTML;
?>
<?php
}
}
?>
<span class="joms-comment__time"><small><?php
echo CTimeHelper::timeLapse($date);
?>
</small></span>
<div class="joms-comment__actions joms-js--comment-actions">
<?php
// this is for like button
if ($my->id) {
if ($isLiked != COMMUNITY_LIKE) {
?>
<a class="joms-button--liked" href="javascript:" onclick="joms.api.commentLike('<?php
echo $wall->id;
?>
');"
data-lang-like="<?php
示例14: _getData
//.........这里部分代码省略.........
$oRow->activities[] = $row;
}
}
$app = !empty($oRow->app) ? $this->_appLink($oRow->app, $oRow->actor, $oRow->target) : '';
$oRow->title = JString::str_ireplace('{app}', $app, $oRow->title);
$favicon = '';
// this should not really be empty
if (!empty($oRow->app)) {
// check if the image icon exist in template folder
if (JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'templates' . DS . $config->get('template') . DS . 'images' . DS . 'favicon' . DS . $oRow->app . '.png')) {
$favicon = JURI::root() . 'components/com_community/templates/' . $config->get('template') . '/images/favicon/' . $oRow->app . '.png';
} else {
// check if the image icon exist in asset folder
if (JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'assets' . DS . 'favicon' . DS . $oRow->app . '.png')) {
$favicon = JURI::root() . 'components/com_community/assets/favicon/' . $oRow->app . '.png';
} elseif (JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'plugins' . DS . 'community' . DS . $oRow->app . DS . 'favicon.png')) {
$favicon = JURI::root() . 'plugins/community/' . $oRow->app . '/favicon.png';
} else {
$favicon = JURI::root() . 'components/com_community/assets/favicon/default.png';
}
}
} else {
$favicon = JURI::root() . 'components/com_community/assets/favicon/default.png';
}
$act->favicon = $favicon;
$target = $this->_targetLink($oRow->target, true);
$oRow->title = JString::str_ireplace('{target}', $target, $oRow->title);
if (count($oRow->activities) > 0) {
// multiple
$actorsLink = '';
foreach ($oRow->activities as $actor) {
if (empty($actorsLink)) {
$actorsLink = $this->_actorLink(intval($actor->actor));
} else {
// only add if this actor is NOT already linked
$alink = $this->_actorLink(intval($actor->actor));
$pos = strpos($actorsLink, $alink);
if ($pos === false) {
$actorsLink .= ', ' . $alink;
}
}
}
$actorLink = $this->_actorLink(intval($oRow->actor));
$count = count($oRow->activities);
$oRow->title = preg_replace('/\\{single\\}(.*?)\\{\\/single\\}/i', '', $oRow->title);
$search = array('{multiple}', '{/multiple}');
$oRow->title = JString::str_ireplace($search, '', $oRow->title);
$oRow->title = JString::str_ireplace('{actors}', $actorsLink, $oRow->title);
$oRow->title = JString::str_ireplace('{actor}', $actorLink, $oRow->title);
$oRow->title = JString::str_ireplace('{count}', $count, $oRow->title);
} else {
// single
$actorLink = $this->_actorLink(intval($oRow->actor));
$oRow->title = preg_replace('/\\{multiple\\}(.*)\\{\\/multiple\\}/i', '', $oRow->title);
$search = array('{single}', '{/single}');
$oRow->title = JString::str_ireplace($search, '', $oRow->title);
$oRow->title = JString::str_ireplace('{actor}', $actorLink, $oRow->title);
}
// @rule: If an exclusion is added, we need to fetch activities without these items.
// Compile exclusion lists.
$exclusions[] = $oRow->id;
// If the param contains any data, replace it with the content
preg_match_all("/{(.*?)}/", $oRow->title, $matches, PREG_SET_ORDER);
if (!empty($matches)) {
$params = new JParameter($oRow->params);
foreach ($matches as $val) {
$replaceWith = $params->get($val[1], null);
//if the replacement start with 'index.php', we can CRoute it
if (strpos($replaceWith, 'index.php') === 0) {
$replaceWith = CRoute::_($replaceWith);
}
if (!is_null($replaceWith)) {
$oRow->title = JString::str_ireplace($val[0], $replaceWith, $oRow->title);
}
}
}
$act->id = $oRow->id;
$act->title = $oRow->title;
$act->actor = $oRow->actor;
$act->content = $this->getActivityContent($oRow);
$timeFormat = $config->get('activitiestimeformat');
$dayFormat = $config->get('activitiesdayformat');
$date = CTimeHelper::getDate($oRow->created);
$createdTime = '';
if ($config->get('activitydateformat') == COMMUNITY_DATE_FIXED) {
$createdTime = $date->toFormat($dayinterval == ACTIVITY_INTERVAL_DAY ? $timeFormat : $dayFormat);
} else {
$createdTime = CTimeHelper::timeLapse($date);
}
$act->created = $createdTime;
$act->createdDate = $date->toFormat(JText::_('DATE_FORMAT_LC2'));
$act->app = $oRow->app;
$htmlData[] = $act;
}
}
$objActivity = new stdClass();
$objActivity->data = $htmlData;
$objActivity->exclusions = empty($htmlData) ? false : implode(',', $exclusions);
return $objActivity;
}
示例15: formatComment
/**
* Return formatted comment given the wall item
*/
public static function formatComment($wall)
{
CFactory::load('helpers', 'owner');
$my = CFactory::getUser();
// Save processing time
if (!$wall->comment) {
return '';
}
// strip out the comment data
CFactory::load('libraries', 'comment');
$wall->comment = CComment::stripCommentData($wall->comment);
// Need to perform basic formatting here
// 1. support nl to br,
// 2. auto-link text
CFactory::load('helpers', 'linkgenerator');
$wall->comment = CTemplate::escape($wall->comment);
$wall->comment = CLinkGeneratorHelper::replaceURL($wall->comment);
$wall->comment = nl2br($wall->comment);
CFactory::load('helpers', 'time');
$user = CFactory::getUser($wall->post_by);
$commentsHTML = '';
$commentsHTML .= '<div class="cComment wall-coc-item" id="wall-' . $wall->id . '"><a href="' . CUrlHelper::userLink($user->id) . '"><img src="' . $user->getThumbAvatar() . '" alt="" class="wall-coc-avatar" /></a>';
$date = new JDate($wall->date);
$commentsHTML .= '<a class="wall-coc-author" href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a> ';
$commentsHTML .= $wall->comment;
$commentsHTML .= '<span class="wall-coc-time">' . CTimeHelper::timeLapse($date);
// Only site admin, or wall author can remove it
// @todo: the target stream activity should also be able to delete it
if (COwnerHelper::isCommunityAdmin() || $my->id == $wall->post_by) {
$commentsHTML .= ' <span class="wall-coc-remove-link">• <a onclick="joms.miniwall.remove(' . $wall->id . ');" href="#removeThisComment">' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</a></span>';
}
$commentsHTML .= '</span>';
$commentsHTML .= '</div>';
return $commentsHTML;
}