本文整理汇总了PHP中CTemplate::setRef方法的典型用法代码示例。如果您正苦于以下问题:PHP CTemplate::setRef方法的具体用法?PHP CTemplate::setRef怎么用?PHP CTemplate::setRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTemplate
的用法示例。
在下文中一共展示了CTemplate::setRef方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modGetFriendsHTML
/**
* Return friends html block
* @since 2.2.4
* @return string
*/
public function modGetFriendsHTML($userid = null)
{
$html = '';
$tmpl = new CTemplate();
$friendsModel = CFactory::getModel('friends');
$my = CFactory::getUser($userid);
$user = CFactory::getRequestUser();
$params = $user->getParams();
// site visitor
$relation = 10;
// site members
if ($my->id != 0) {
$relation = 20;
}
// friends
if (CFriendsHelper::isConnected($my->id, $user->id)) {
$relation = 30;
}
// mine
if (COwnerHelper::isMine($my->id, $user->id)) {
$relation = 40;
}
// @todo: respect privacy settings
if ($relation >= $params->get('privacyFriendsView')) {
$friends = $friendsModel->getFriends($user->id, 'latest', false, '', PROFILE_MAX_FRIEND_LIMIT + PROFILE_MAX_FRIEND_LIMIT);
// randomize the friend count
if ($friends) {
shuffle($friends);
}
$html = $tmpl->setRef('friends', $friends)->set('total', $user->getFriendCount())->setRef('user', $user)->fetch('profile.friends');
}
return $html;
}
示例2: ajaxGetNotification
public function ajaxGetNotification()
{
if (!COwnerHelper::isRegisteredUser()) {
return $this->ajaxBlockUnregister();
}
$json = array();
$my = CFactory::getUser();
//$inboxModel = CFactory::getModel( 'inbox' );
$friendModel = CFactory::getModel('friends');
$eventModel = CFactory::getModel('events');
$groupModel = CFactory::getModel('groups');
$notiTotal = 0;
//getting pending event request
$pendingEvent = $eventModel->getPending($my->id);
$eventHtml = '';
$event = JTable::getInstance('Event', 'CTable');
if (!empty($pendingEvent)) {
$notiTotal += count($pendingEvent);
for ($i = 0; $i < count($pendingEvent); $i++) {
$row = $pendingEvent[$i];
$row->invitor = CFactory::getUser($row->invited_by);
$event->load($row->eventid);
// remove the notification if there is no longer seats available
if (!CEventHelper::seatsAvailable($event)) {
unset($pendingEvent[$i]);
continue;
}
$row->eventAvatar = $event->getThumbAvatar();
$row->url = CRoute::_('index.php?option=com_community&view=events&task=viewevent&eventid=' . $row->eventid . false);
$row->isGroupEvent = $event->contentid ? true : false;
if ($row->isGroupEvent) {
$group = JTable::getInstance('Group', 'CTable');
$group->load($event->contentid);
$row->groupname = $group->name;
$row->grouplink = CUrlHelper::groupLink($group->id);
}
}
$tmpl = new CTemplate();
$tmpl->set('rows', $pendingEvent);
$tmpl->setRef('my', $my);
$eventHtml = $tmpl->fetch('notification.event.invitations');
}
//getting pending group request
$pendingGroup = $groupModel->getGroupInvites($my->id);
$groupHtml = '';
$group = JTable::getInstance('Group', 'CTable');
$groupNotiTotal = 0;
if (!empty($pendingGroup)) {
$groupNotiTotal += count($pendingGroup);
for ($i = 0; $i < count($pendingGroup); $i++) {
$gRow = $pendingGroup[$i];
$gRow->invitor = CFactory::getUser($gRow->creator);
$group->load($gRow->groupid);
$gRow->name = $group->name;
$gRow->groupAvatar = $group->getThumbAvatar();
$gRow->url = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $gRow->groupid . false);
}
$tmpl = new CTemplate();
$tmpl->set('gRows', $pendingGroup);
$tmpl->setRef('my', $my);
$groupHtml = $tmpl->fetch('notification.group.invitations');
}
//geting pending private group join request
//Find Users Groups Admin
$allGroups = $groupModel->getAdminGroups($my->id, COMMUNITY_PRIVATE_GROUP);
$groupMemberApproveHTML = '';
//Get unApproved member
if (!empty($allGroups)) {
foreach ($allGroups as $groups) {
$member = $groupModel->getMembers($groups->id, 0, false);
if (!empty($member)) {
for ($i = 0; $i < count($member); $i++) {
$oRow = $member[$i];
$group->load($groups->id);
$oRow->groupId = $groups->id;
$oRow->groupName = $groups->name;
$oRow->groupAvatar = $group->getThumbAvatar();
$oRow->url = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id . false);
$members[] = $member[$i];
}
}
}
}
if (!empty($members)) {
$tmpl = new CTemplate();
$tmpl->set('oRows', $members);
$tmpl->set('my', $my);
$groupMemberApproveHTML = $tmpl->fetch('notification.group.request');
}
//non require action notification
$itemHtml = '';
$notifCount = 10;
$notificationModel = CFactory::getModel('notification');
$myParams = $my->getParams();
$notifications = $notificationModel->getNotification($my->id, '0', $notifCount, $myParams->get('lastnotificationlist', ''));
if (!empty($notifications)) {
for ($i = 0; $i < count($notifications); $i++) {
$iRow = $notifications[$i];
$iRow->actorUser = CFactory::getUser($iRow->actor);
$iRow->actorAvatar = $iRow->actorUser->getThumbAvatar();
//.........这里部分代码省略.........
示例3: getEmbedCode
public function getEmbedCode($videoId, $videoWidth, $videoHeight)
{
$video =& JTable::getInstance('Video', 'CTable');
$video->load($videoId);
$tmpl = new CTemplate();
$tmpl->setRef('video', $video);
$tmpl->set('switch', 'pureObjectTag');
return $tmpl->fetch('videos.flowplayer');
}
示例4: showFeaturedGroups
public function showFeaturedGroups($total = 5)
{
$tmpl = new CTemplate();
$config = CFactory::getConfig();
$showlatestgroups = intval($tmpl->params->get('showlatestgroups'));
$html = '';
$data = array();
if ($showlatestgroups != 0) {
$groupModel = CFactory::getModel('groups');
$tmpGroups = $groupModel->getAllGroups(null, null, null, $total);
$groups = array();
$data = array();
$groupView = CFactory::getView('groups');
$groups = $groupView->getGroupsFeaturedList();
$tmpl = new CTemplate();
$html = $tmpl->setRef('groups', $groups)->fetch('frontpage.latestgroup');
}
$data['HTML'] = $html;
return $data;
}
示例5: profile
//.........这里部分代码省略.........
// Split the apps into different list for different positon
$appsInPositions = array();
foreach ($appData as &$app) {
$appsInPositions[$app->position][] = $app;
}
$tmpl = new CTemplate();
$contenHTML = array();
$contenHTML['content'] = '';
$contenHTML['sidebar-top'] = '';
$contenHTML['sidebar-bottom'] = '';
$jscript = '';
foreach ($appsInPositions as $position => $appData) {
ob_start();
foreach ($appData as $app) {
// If the apps content is empty, we ignore this app from showing
// the header in profile page.
if (JString::trim($app->data) == "") {
continue;
}
$tmpl->set('app', $app);
$tmpl->set('isOwner', COwnerHelper::isMine($my->id, $user->id));
switch ($position) {
case 'sidebar-top':
case 'sidebar-bottom':
echo $tmpl->fetch('application.widget');
break;
default:
echo $tmpl->fetch('application.box');
}
}
$contenHTML[$position] = ob_get_contents();
ob_end_clean();
}
// Get the config
$config = CFactory::getConfig();
// get total group
$groupsModel = CFactory::getModel('groups');
$totalgroups = $groupsModel->getGroupsCount($user->id);
// get total friend
$friendsModel = CFactory::getModel('friends');
$totalfriends = $user->getFriendCount();
// get total photos
$photosModel = CFactory::getModel('photos');
$totalphotos = $photosModel->getPhotosCount($user->id);
// get total activities
$activitiesModel = CFactory::getModel('activities');
$totalactivities = $activitiesModel->getActivityCount($user->id);
$isMine = COwnerHelper::isMine($my->id, $user->id);
$isCommunityAdmin = COwnerHelper::isCommunityAdmin($user->id);
// Get reporting html
CFactory::load('libraries', 'reporting');
$report = new CReportingLibrary();
$reportHTML = $isMine ? '' : $report->getReportingHTML(JText::_('CC REPORT BAD USER'), 'profile,reportProfile', array($user->id));
// Check if user is blocked
$blockUserModel = CFactory::getModel('block');
$isBlocked = $blockUserModel->getBlockStatus($user->id, $my->id);
// Get block user html
CFactory::load('helpers', 'user');
$blockUserHTML = $isMine || $isCommunityAdmin ? '' : CUserHelper::getBlockUserHTML($user->id, $isBlocked);
CFactory::load('libraries', 'bookmarks');
$bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=profile&userid=' . $user->id));
$bookmarksHTML = $bookmarks->getHTML();
// Get like
// cater for buble, blueface template
$likesHTML = '';
if ($user->getParams()->get('profileLikes', true)) {
CFactory::load('libraries', 'like');
$likes = new CLike();
$likesHTML = $my->id == 0 ? $likes->getHtmlPublic('profile', $user->id) : $likes->getHTML('profile', $user->id, $my->id);
}
$tmpl = new CTemplate();
$tmpl->set('blockUserHTML', $blockUserHTML);
$tmpl->set('bookmarksHTML', $bookmarksHTML);
$tmpl->set('profileOwnerName', $user->getDisplayName());
$tmpl->set('totalgroups', $totalgroups);
$tmpl->set('totalfriends', $totalfriends);
$tmpl->set('totalphotos', $totalphotos);
$tmpl->set('totalactivities', $totalactivities);
$tmpl->set('reportsHTML', $reportHTML);
$tmpl->set('mainframe', $mainframe);
$tmpl->set('config', $config);
$tmpl->set('about', $this->_getProfileHTML($data->profile));
$tmpl->set('friends', $this->_getFriendsHTML());
$tmpl->set('groups', $this->_getGroupsHTML());
$tmpl->set('newsfeed', $this->_getNewsfeedHTML());
$tmpl->set('header', $headerHTML);
$tmpl->set('adminControlHTML', $this->_getAdminControlHTML($user->id));
$tmpl->set('content', $contenHTML['content']);
$tmpl->set('sidebarTop', $contenHTML['sidebar-top']);
$tmpl->set('sidebarBottom', $contenHTML['sidebar-bottom']);
$tmpl->set('isMine', $isMine);
$tmpl->set('jscript', '');
// maintain for 1.8.0 template compatibility
$tmpl->setRef('user', $user);
$tmpl->set('my', $my);
$tmpl->set('videoid', $data->videoid);
$tmpl->set('likesHTML', $likesHTML);
$html = $tmpl->fetch('profile.index');
echo $html;
}
示例6: getEmbedCode
public function getEmbedCode($videoId, $videoWidth, $videoHeight)
{
$video = JTable::getInstance('Video', 'CTable');
$video->load($videoId);
$tmpl = new CTemplate();
$tmpl->setRef('video', $video);
$tmpl->set('switch', 'pureObjectTag');
$isMp4 = $this->isMp4($video->getFlv());
if (!$isMp4) {
return $tmpl->fetch('videos.flowplayer');
} else {
return $tmpl->fetch('videos.html5');
}
}
示例7: showLatestPhotos
/**
* Show listing of most recent photos.
* @param $rawData Retrieves the raw data of recent photos
*/
public function showLatestPhotos($rawData = false)
{
$tmpl = new CTemplate();
$config = CFactory::getConfig();
$photoModel = CFactory::getModel('photos');
$showlatestphotos = intval($tmpl->params->get('showlatestphotos'));
$frontpagePhotos = intval($config->get('frontpagephotos'));
$latestPhotos = $photoModel->getAllPhotos(null, PHOTOS_USER_TYPE, $frontpagePhotos, 0, COMMUNITY_ORDER_BY_DESC, COMMUNITY_ORDERING_BY_CREATED);
$data = array();
if ($showlatestphotos != 0) {
if ($latestPhotos) {
shuffle($latestPhotos);
// Make sure it is all photo object
foreach ($latestPhotos as &$row) {
$photo =& JTable::getInstance('Photo', 'CTable');
$photo->bind($row);
$row = $photo;
}
}
if (!empty($latestPhotos)) {
for ($i = 0; $i < count($latestPhotos); $i++) {
$row =& $latestPhotos[$i];
$row->user = CFactory::getUser($row->creator);
}
}
if ($rawData) {
return $latestPhotos;
}
$tmpl = new CTemplate();
$data['HTML'] = $tmpl->setRef('latestPhotos', $latestPhotos)->fetch('frontpage.latestphoto');
} else {
$data['HTML'] = '';
}
return $data;
}
示例8: ajaxGetNotification
public function ajaxGetNotification()
{
if (!COwnerHelper::isRegisteredUser()) {
return $this->ajaxBlockUnregister();
}
$objResponse = new JAXResponse();
$my = CFactory::getUser();
$inboxModel = CFactory::getModel('inbox');
$friendModel = CFactory::getModel('friends');
$eventModel = CFactory::getModel('events');
$inboxHtml = '';
$frenHtml = '';
$rowHeight = 50;
$menuHeight = 35;
$extraMenuHeight = 0;
$notiTotal = 0;
// getting inbox
$unreadInbox = $inboxModel->getUnReadInbox();
if (!empty($unreadInbox)) {
$extraMenuHeight += 25;
$notiTotal += count($unreadInbox);
for ($i = 0; $i < count($unreadInbox); $i++) {
$row =& $unreadInbox[$i];
$user = CFactory::getUser($row->from);
$row->avatar = $user->getThumbAvatar();
$row->isUnread = true;
$row->from_name = $user->getDisplayName();
$row->profileLink = CUrlHelper::userLink($user->id);
}
$tmpl = new CTemplate();
$tmpl->set('messages', $unreadInbox);
$inboxHtml = $tmpl->fetch('notification.unread.inbox');
$inboxHtml .= '<br />';
}
// getting pending fren request
$pendingFren = $friendModel->getPending($my->id);
if (!empty($pendingFren)) {
$extraMenuHeight += 25;
$notiTotal += count($pendingFren);
for ($i = 0; $i < count($pendingFren); $i++) {
$row =& $pendingFren[$i];
$row->user = CFactory::getUser($row->id);
$row->user->friendsCount = $row->user->getFriendCount();
$row->user->profileLink = CUrlHelper::userLink($row->id);
}
$tmplF = new CTemplate();
$tmplF->set('rows', $pendingFren);
$tmplF->setRef('my', $my);
$frenHtml = $tmplF->fetch('notification.friend.request');
$frenHtml .= "<br />";
}
//getting pending event request
$pendingEvent = $eventModel->getPending($my->id);
$eventHtml = '';
$event =& JTable::getInstance('Event', 'CTable');
if (!empty($pendingEvent)) {
$extraMenuHeight += 25;
$notiTotal += count($pendingEvent);
for ($i = 0; $i < count($pendingEvent); $i++) {
$row =& $pendingEvent[$i];
$row->invitor = CFactory::getUser($row->invited_by);
$event->load($row->eventid);
$row->eventAvatar = $event->getThumbAvatar();
$row->url = CRoute::_('index.php?option=com_community&view=events&task=viewevent&eventid=' . $row->eventid . false);
}
$tmpl = new CTemplate();
$tmpl->set('rows', $pendingEvent);
$tmpl->setRef('my', $my);
$eventHtml = $tmpl->fetch('notification.event.invitations');
}
$notiHtml = $inboxHtml . $frenHtml . $eventHtml;
$objResponse->addAssign('cWindowContent', 'innerHTML', $notiHtml);
$totalHeight = $menuHeight + $extraMenuHeight + $notiTotal * $rowHeight;
if ($totalHeight > 450) {
$totalHeight = 450;
}
/* Max height 450 */
$objResponse->addAssign('cwin_logo', 'innerHTML', JText::_('CC NOTIFICATIONS'));
$objResponse->addScriptCall('cWindowResize', $totalHeight);
$objResponse->sendResponse();
}
示例9: ajaxGetNotification
public function ajaxGetNotification()
{
if (!COwnerHelper::isRegisteredUser()) {
return $this->ajaxBlockUnregister();
}
$objResponse = new JAXResponse();
$my = CFactory::getUser();
$inboxModel = CFactory::getModel('inbox');
$friendModel = CFactory::getModel('friends');
$eventModel = CFactory::getModel('events');
$groupModel = CFactory::getModel('groups');
$inboxHtml = '';
$frenHtml = '';
$notiTotal = 0;
//getting pending event request
$pendingEvent = $eventModel->getPending($my->id);
$eventHtml = '';
$event =& JTable::getInstance('Event', 'CTable');
if (!empty($pendingEvent)) {
$notiTotal += count($pendingEvent);
for ($i = 0; $i < count($pendingEvent); $i++) {
$row =& $pendingEvent[$i];
$row->invitor = CFactory::getUser($row->invited_by);
$event->load($row->eventid);
$row->eventAvatar = $event->getThumbAvatar();
$row->url = CRoute::_('index.php?option=com_community&view=events&task=viewevent&eventid=' . $row->eventid . false);
}
$tmpl = new CTemplate();
$tmpl->set('rows', $pendingEvent);
$tmpl->setRef('my', $my);
$eventHtml = $tmpl->fetch('notification.event.invitations');
}
//getting pending group request
$pendingGroup = $groupModel->getGroupInvites($my->id);
$groupHtml = '';
$group =& JTable::getInstance('Group', 'CTable');
$groupNotiTotal = 0;
if (!empty($pendingGroup)) {
$groupNotiTotal += count($pendingGroup);
for ($i = 0; $i < count($pendingGroup); $i++) {
$gRow =& $pendingGroup[$i];
$gRow->invitor = CFactory::getUser($gRow->creator);
$group->load($gRow->groupid);
$gRow->name = $group->name;
$gRow->groupAvatar = $group->getThumbAvatar();
$gRow->url = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $gRow->groupid . false);
}
$tmpl = new CTemplate();
$tmpl->set('gRows', $pendingGroup);
$tmpl->setRef('my', $my);
$groupHtml = $tmpl->fetch('notification.group.invitations');
}
//geting pending private group join request
//Find Users Groups Admin
$allGroups = $groupModel->getAdminGroups($my->id, COMMUNITY_PRIVATE_GROUP);
$groupMemberApproveHTML = '';
//Get unApproved member
if (!empty($allGroups)) {
foreach ($allGroups as $groups) {
$member = $groupModel->getMembers($groups->id, 0, false);
if (!empty($member)) {
for ($i = 0; $i < count($member); $i++) {
$oRow =& $member[$i];
$group->load($groups->id);
$oRow->groupId = $groups->id;
$oRow->groupName = $groups->name;
$oRow->groupAvatar = $group->getThumbAvatar();
$oRow->url = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id . false);
$members[] = $member[$i];
}
}
}
}
if (!empty($members)) {
$tmpl = new CTemplate();
$tmpl->set('oRows', $members);
$tmpl->set('my', $my);
$groupMemberApproveHTML = $tmpl->fetch('notification.group.request');
}
$notiHtml = $inboxHtml . $frenHtml . $eventHtml . $groupHtml . $groupMemberApproveHTML;
if (empty($notiHtml)) {
$notiHtml = '<div class="jsNotificationContent jsNotificationEmpty">';
$notiHtml .= '<div class="jsNotificationActor">';
$notiHtml .= JText::_('COM_COMMUNITY_NO_NOTIFICATION');
$notiHtml .= '</div>';
$notiHtml .= '</div>';
}
$objResponse->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_NOTIFICATIONS'));
$objResponse->addScriptCall('cWindowAddContent', $notiHtml);
$objResponse->sendResponse();
}
示例10: invite
/**
* Show the invite window
*/
function invite()
{
$mainframe =& JFactory::getApplication();
$document =& JFactory::getDocument();
$config = CFactory::getConfig();
$document->setTitle(JText::sprintf('CC INVITE FRIENDS TITLE', $config->get('sitename')));
$my = CFactory::getUser();
$this->showSubmenu();
$post = JRequest::getVar('action', '', 'POST') == 'invite' ? JRequest::get('POST') : array('message' => '', 'emails' => '');
$pathway =& $mainframe->getPathway();
$this->addPathway(JText::_('CC FRIENDS'), CRoute::_('index.php?option=com_community&view=friends'));
$this->addPathway(JText::_('CC INVITE FRIENDS'), '');
// Process the Suggest Friends
// Load required filterbar library that will be used to display the filtering and sorting.
CFactory::load('libraries', 'filterbar');
$id = JRequest::getCmd('userid', $my->id);
$user = CFactory::getUser($id);
$sorted = JRequest::getVar('sort', 'suggestion', 'GET');
$filter = JRequest::getVar('filter', 'suggestion', 'GET');
$friends = CFactory::getModel('friends');
$rows = $friends->getFriends($id, $sorted, true, $filter);
$resultRows = array();
foreach ($rows as $row) {
$user = CFactory::getUser($row->id);
$obj = clone $row;
$obj->friendsCount = $user->getFriendCount();
$obj->profileLink = CUrlHelper::userLink($row->id);
$obj->isFriend = true;
$resultRows[] = $obj;
}
unset($rows);
CFactory::load('libraries', 'apps');
$app =& CAppPlugins::getInstance();
$appFields = $app->triggerEvent('onFormDisplay', array('jsform-friends-invite'));
$beforeFormDisplay = CFormElement::renderElements($appFields, 'before');
$afterFormDisplay = CFormElement::renderElements($appFields, 'after');
$tmpl = new CTemplate();
$tmpl->set('beforeFormDisplay', $beforeFormDisplay);
$tmpl->set('afterFormDisplay', $afterFormDisplay);
$tmpl->set('my', $my);
$tmpl->set('post', $post);
$tmpl->setRef('friends', $resultRows);
$tmpl->set('config', CFactory::getConfig());
echo $tmpl->fetch('friends.invite');
}