本文整理汇总了PHP中CTemplate::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP CTemplate::fetch方法的具体用法?PHP CTemplate::fetch怎么用?PHP CTemplate::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTemplate
的用法示例。
在下文中一共展示了CTemplate::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showGroupMiniHeader
public function showGroupMiniHeader($groupId)
{
CMiniHeader::load();
$option = JRequest::getVar('option', '', 'REQUEST');
JFactory::getLanguage()->load('com_community');
CFactory::load('models', 'groups');
$group =& JTable::getInstance('Group', 'CTable');
$group->load($groupId);
$my = CFactory::getUser();
// @rule: Test if the group is unpublished, don't display it at all.
if (!$group->published) {
return '';
}
if (!empty($group->id) && $group->id != 0) {
$isMember = $group->isMember($my->id);
$config = CFactory::getConfig();
$tmpl = new CTemplate();
$tmpl->set('my', $my);
$tmpl->set('group', $group);
$tmpl->set('isMember', $isMember);
$tmpl->set('config', $config);
$showMiniHeader = $option == 'com_community' ? $tmpl->fetch('groups.miniheader') : '<div id="community-wrap" style="min-height:50px;">' . $tmpl->fetch('groups.miniheader') . '</div>';
return $showMiniHeader;
}
}
示例2: getHTML
public static function getHTML($url, $sortItems = array(), $defaultSort = '', $filterItems = array(), $defaultFilter = '')
{
$mainframe = JFactory::getApplication();
$jinput = $mainframe->input;
$cleanURL = $url;
$uri = JFactory::getURI();
$queries = $_REQUEST;
$allow = array('option', 'view', 'browse', 'task');
foreach ($queries as $key => $value) {
if (!in_array($key, $allow)) {
unset($queries[$key]);
}
}
$selectedSort = $jinput->get->get('sort', $defaultSort, 'STRING');
$selectedFilter = $jinput->get->get('filter', $defaultFilter, 'STRING');
$tmpl = new CTemplate();
$tmpl->set('queries', $queries);
$tmpl->set('selectedSort', $selectedSort);
$tmpl->set('selectedFilter', $selectedFilter);
$tmpl->set('sortItems', $sortItems);
$tmpl->set('uri', $uri);
$tmpl->set('filterItems', $filterItems);
$tmpl->set('jinput', $jinput);
return $tmpl->fetch('filterbar.html');
}
示例3: getHTML
public function getHTML($url, $sortItems = array(), $defaultSort = '', $filterItems = array(), $defaultFilter = '')
{
$cleanURL = $url;
$uri =& JFactory::getURI();
$queries = JRequest::get('GET');
// If there is Itemid in the querystring, we need to unset it so that CRoute
// will generate it's correct Itemid
if (isset($queries['Itemid'])) {
unset($queries['Itemid']);
}
// Force link to start with first page
if (isset($queries['limitstart'])) {
unset($queries['limitstart']);
}
if (isset($queries['start'])) {
unset($queries['start']);
}
$selectedSort = JRequest::getVar('sort', $defaultSort, 'GET');
$selectedFilter = JRequest::getVar('filter', $defaultFilter, 'GET');
$tmpl = new CTemplate();
$tmpl->set('queries', $queries);
$tmpl->set('selectedSort', $selectedSort);
$tmpl->set('selectedFilter', $selectedFilter);
$tmpl->set('sortItems', $sortItems);
$tmpl->set('uri', $uri);
$tmpl->set('filterItems', $filterItems);
return $tmpl->fetch('filterbar.html');
}
示例4: export
function export($event)
{
CFactory::load('helpers', 'event');
$handler = CEventHelper::getHandler($event);
if (!$handler->showExport()) {
echo JText::_('CC ACCESS FORBIDDEN');
return;
}
header('Content-type: text/Calendar');
header('Content-Disposition: attachment; filename="calendar.ics"');
$creator = CFactory::getUser($event->creator);
$offset = $creator->getUtcOffset();
$date = new JDate($event->startdate);
$dtstart = $date->toFormat('%Y%m%dT%H%M%S');
$date = new JDate($event->enddate);
$dtend = $date->toFormat('%Y%m%dT%H%M%S');
$url = $handler->getFormattedLink('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false, true);
$tmpl = new CTemplate();
$tmpl->set('dtstart', $dtstart);
$tmpl->set('dtend', $dtend);
$tmpl->set('url', $url);
$tmpl->set('event', $event);
$raw = $tmpl->fetch('events.ical');
unset($tmpl);
echo $raw;
exit;
}
示例5: send
/**
* Do a batch send
*/
function send($total = 100)
{
$mailqModel = CFactory::getModel('mailq');
$userModel = CFactory::getModel('user');
$mails = $mailqModel->get($total);
$jconfig = JFactory::getConfig();
$mailer = JFactory::getMailer();
$config = CFactory::getConfig();
$senderEmail = $jconfig->getValue('mailfrom');
$senderName = $jconfig->getValue('fromname');
if (empty($mails)) {
return;
}
CFactory::load('helpers', 'string');
foreach ($mails as $row) {
// @rule: only send emails that is valid.
// @rule: make sure recipient is not blocked!
$userid = $userModel->getUserFromEmail($row->recipient);
$user = CFactory::getUser($userid);
if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar')) {
$mailer->setSender(array($senderEmail, $senderName));
$mailer->addRecipient($row->recipient);
$mailer->setSubject($row->subject);
$tmpl = new CTemplate();
$raw = isset($row->params) ? $row->params : '';
$params = new JParameter($row->params);
$base = $config->get('htmlemail') ? 'email.html' : 'email.text';
if ($config->get('htmlemail')) {
$row->body = JString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body);
$mailer->IsHTML(true);
} else {
//@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags.
$row->body = CStringHelper::escape(strip_tags($row->body));
}
$tmpl->set('content', $row->body);
$tmpl->set('template', rtrim(JURI::root(), '/') . '/components/com_community/templates/' . $config->get('template'));
$tmpl->set('sitename', $config->get('sitename'));
$row->body = $tmpl->fetch($base);
// Replace any occurences of custom variables within the braces scoe { }
if (!empty($row->body)) {
preg_match_all("/{(.*?)}/", $row->body, $matches, PREG_SET_ORDER);
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::getExternalURL($replaceWith);
}
if (!is_null($replaceWith)) {
$row->body = JString::str_ireplace($val[0], $replaceWith, $row->body);
}
}
}
unset($tmpl);
$mailer->setBody($row->body);
$mailer->send();
}
$mailqModel->markSent($row->id);
$mailer->ClearAllRecipients();
}
}
示例6: _addSubmenu
public function _addSubmenu()
{
$mySQLVer = 0;
if (JFile::exists(JPATH_COMPONENT . DS . 'libraries' . DS . 'advancesearch.php')) {
require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'advancesearch.php';
$mySQLVer = CAdvanceSearch::getMySQLVersion();
}
// Only display related links for guests
$my = CFactory::getUser();
$config = CFactory::getConfig();
if ($my->id == 0) {
$tmpl = new CTemplate();
$tmpl->set('url', CRoute::_('index.php?option=com_community&view=search'));
$html = $tmpl->fetch('search.submenu');
$this->addSubmenuItem('index.php?option=com_community&view=search', JText::_('COM_COMMUNITY_SEARCH_FRIENDS'), 'joms.videos.toggleSearchSubmenu(this)', SUBMENU_LEFT, $html);
if ($mySQLVer >= 4.1 && $config->get('guestsearch')) {
$this->addSubmenuItem('index.php?option=com_community&view=search&task=advancesearch', JText::_('COM_COMMUNITY_CUSTOM_SEARCH'));
}
} else {
$this->addSubmenuItem('index.php?option=com_community&view=friends', JText::_('COM_COMMUNITY_FRIENDS_VIEW_ALL'));
$tmpl = new CTemplate();
$tmpl->set('url', CRoute::_('index.php?option=com_community&view=search'));
$html = $tmpl->fetch('search.submenu');
$this->addSubmenuItem('index.php?option=com_community&view=search', JText::_('COM_COMMUNITY_SEARCH_FRIENDS'), 'joms.videos.toggleSearchSubmenu(this)', SUBMENU_LEFT, $html);
if ($mySQLVer >= 4.1) {
$this->addSubmenuItem('index.php?option=com_community&view=search&task=advancesearch', JText::_('COM_COMMUNITY_CUSTOM_SEARCH'));
}
$this->addSubmenuItem('index.php?option=com_community&view=friends&task=invite', JText::_('COM_COMMUNITY_INVITE_FRIENDS'));
$this->addSubmenuItem('index.php?option=com_community&view=friends&task=sent', JText::_('COM_COMMUNITY_FRIENDS_REQUEST_SENT'));
$this->addSubmenuItem('index.php?option=com_community&view=friends&task=pending', JText::_('COM_COMMUNITY_FRIENDS_PENDING_APPROVAL'));
}
}
示例7: onActivityContentDisplay
function onActivityContentDisplay($args)
{
$model =& CFactory::getModel('Wall');
$wall =& JTable::getInstance('Wall', 'CTable');
$my = CFactory::getUser();
if (empty($args->content)) {
return '';
}
$wall->load($args->cid);
CFactory::load('libraries', 'privacy');
CFactory::load('libraries', 'comment');
$comment = CComment::stripCommentData($wall->comment);
$config = CFactory::getConfig();
$commentcut = false;
if (strlen($comment) > $config->getInt('streamcontentlength')) {
$origcomment = $comment;
$comment = JString::substr($comment, 0, $config->getInt('streamcontentlength')) . ' ...';
$commentcut = true;
}
if (CPrivacy::isAccessAllowed($my->id, $args->target, 'user', 'privacyProfileView')) {
CFactory::load('helpers', 'videos');
CFactory::load('libraries', 'videos');
CFactory::load('libraries', 'wall');
$videoContent = '';
$params = new CParameter($args->params);
$videoLink = $params->get('videolink');
$image = $params->get('url');
// For older activities that does not have videoLink , we need to process it the old way.
if (!$videoLink) {
$html = CWallLibrary::_processWallContent($comment);
$tmpl = new CTemplate();
$html = CStringHelper::escape($html);
if ($commentcut) {
//add read more/less link for content
$html .= '<br /><br /><a href="javascript:void(0)" onclick="jQuery(\'#shortcomment_' . $args->cid . '\').hide(); jQuery(\'#origcomment_' . $args->cid . '\').show();" >' . JText::_('COM_COMMUNITY_READ_MORE') . '</a>';
$html = '<div id="shortcomment_' . $args->cid . '">' . $html . '</div>';
$html .= '<div id="origcomment_' . $args->cid . '" style="display:none;">' . $origcomment . '<br /><br /><a href="javascript:void(0);" onclick="jQuery(\'#shortcomment_' . $args->cid . '\').show(); jQuery(\'#origcomment_' . $args->cid . '\').hide();" >' . JText::_('COM_COMMUNITY_READ_LESS') . '</a></div>';
}
$tmpl->set('comment', $html);
$html = $tmpl->fetch('activity.wall.post');
} else {
$html = '<ul class ="cDetailList clrfix">';
$html .= '<li>';
$image = !$image ? rtrim(JURI::root(), '/') . '/components/com_community/assets/playvideo.gif' : $image;
$videoLib = new CVideoLibrary();
$provider = $videoLib->getProvider($videoLink);
$html .= '<!-- avatar --><div class="avatarWrap"><a href="javascript:void(0);" onclick="joms.activities.showVideo(\'' . $args->id . '\');"><img width="64" src="' . $image . '" class="cAvatar"/></a></div><!-- avatar -->';
$videoPlayer = $provider->getViewHTML($provider->getId(), '300', '300');
$comment = CString::str_ireplace($videoLink, '', $comment);
$html .= '<!-- details --><div class="detailWrap alpha">' . $comment . '</div><!-- details -->';
if (!empty($videoPlayer)) {
$html .= '<div style="display: none;clear: both;padding-top: 5px;" class="video-object">' . $videoPlayer . '</div>';
}
$html .= '</li>';
$html .= '</ul>';
}
return $html;
}
}
示例8: renderElements
/**
* Renders the provided elements into their respective HTML formats.
*
* @param Array formElements An array of CFormElement objects.
* @param string position The position of the field 'before' will be loaded before the rest of the form and 'after' will be loaded after the rest of the form loaded.
*
* returns string html Contents of generated CFormElements.
**/
public static function renderElements($formElements, $position)
{
$tmpl = new CTemplate();
$tmpl->set('formElements', $formElements);
$tmpl->set('position', $position);
$html = $tmpl->fetch('form.elements');
return trim($html);
}
示例9: getItemsHTML
/**
*
* @param string $tag the tag to seach for
* @return string HTML code of item listing
*/
public function getItemsHTML($tag)
{
$items = $this->getItems($tag);
$tmpl = new CTemplate();
$tmpl->set('items', $items);
$html = $tmpl->fetch('tag.list');
return $html;
}
示例10: getActivityContentHTML
static function getActivityContentHTML($act)
{
// Ok, the activity could be an upload OR a wall comment. In the future, the content should
// indicate which is which
$html = '';
$param = new JParameter($act->params);
$action = $param->get('action', false);
$photoid = $param->get('photoid', 0);
CFactory::load('models', 'photos');
$url = $param->get('url', false);
CFactory::load('helpers', 'albums');
if ($action == 'wall') {
// unfortunately, wall post can also have 'photo' as its $act->apps. If the photo id is availble
// for (newer activity stream, inside the param), we will show the photo snippet as well. Otherwise
// just print out the wall content
// Version 1.6 onwards, $params will contain photoid information
// older version would have #photoid in the $title, since we link it to the photo
$photoid = $param->get('photoid', false);
if ($photoid) {
$photo = JTable::getInstance('Photo', 'CTable');
$photo->load($act->cid);
$helper = new CAlbumsHelper($photo->albumid);
if ($helper->showActivity()) {
$tmpl = new CTemplate();
$tmpl->set('url', $url);
$tmpl->set('photo', $photo);
$tmpl->set('param', $param);
$tmpl->set('act', $act);
return $tmpl->fetch('activity.photos.wall');
}
}
return '';
} elseif ($action == 'upload' && $photoid > 0) {
$albumsHelper = new CAlbumsHelper($act->cid);
if ($albumsHelper->isPublic()) {
// If content has link to image, we could assume it is "upload photo" action
// since old content add this automatically.
// The $act->cid will be the album id, Retrive the recent photos uploaded
// If $act->activities has data, that means this is an aggregated content
// display some of them
$photoModel = CFactory::getModel('photos');
$album = JTable::getInstance('Album', 'CTable');
$album->load($act->cid);
if (empty($act->activities)) {
$acts[] = $act;
} else {
$acts = $act->activities;
}
$tmpl = new CTemplate();
$tmpl->set('album', $album);
$tmpl->set('acts', $acts);
return $tmpl->fetch('activity.photos.upload');
}
}
return $html;
}
示例11: getEventSummary
static function getEventSummary($eventid, $param)
{
$model = CFactory::getModel('events');
$event =& JTable::getInstance('Event', 'CTable');
$event->load($eventid);
$tmpl = new CTemplate();
$tmpl->set('event', $event);
$tmpl->set('param', $param);
return $tmpl->fetch('activity.events.update');
}
示例12: invite
function invite()
{
CFactory::load('libraries', 'facebook');
$facebook = new CFacebook();
$config = CFactory::getConfig();
$tmpl = new CTemplate();
$tmpl->set('facebook', $facebook);
$tmpl->set('config', $config);
echo $tmpl->fetch('facebook.invite');
}
示例13: getHTML
function getHTML()
{
$config = CFactory::getConfig();
if ($config->get('enablesharethis')) {
$tmpl = new CTemplate();
$tmpl->set('uri', $this->currentURI);
return $tmpl->fetch('bookmarks');
} else {
return '';
}
}
示例14: showSwitcher
public function showSwitcher()
{
$uri = JFactory::getURI();
// Will see if there's a nicer solution to this
$query = $uri->getQuery(true);
unset($query['screen']);
$query = $uri->buildQuery($query);
$uri->setQuery($query);
$uri = $uri->toString();
// Build links
$link = array('mobile' => $uri . '&screen=mobile', 'desktop' => $uri . '&screen=desktop');
$tmpl = new CTemplate();
$tmpl->set('link', $link);
$tmpl->set('viewtype', JRequest::setVar('screen'));
echo $tmpl->fetch('mobile.switcher');
}
示例15: ajaxIphoneFriends
public function ajaxIphoneFriends()
{
$objResponse = new JAXResponse();
$document = JFactory::getDocument();
$viewType = $document->getType();
$view =& $this->getView('friends', '', $viewType);
$html = '';
ob_start();
$this->display();
$content = ob_get_contents();
ob_end_clean();
$tmpl = new CTemplate();
$tmpl->set('toolbar_active', 'friends');
$simpleToolbar = $tmpl->fetch('toolbar.simple');
$objResponse->addAssign('social-content', 'innerHTML', $simpleToolbar . $content);
return $objResponse->sendResponse();
}