本文整理汇总了PHP中DiscussHelper::formatPost方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper::formatPost方法的具体用法?PHP DiscussHelper::formatPost怎么用?PHP DiscussHelper::formatPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussHelper
的用法示例。
在下文中一共展示了DiscussHelper::formatPost方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
public function display($tmpl = null)
{
$config = DiscussHelper::getConfig();
$jConfig = DiscussHelper::getJConfig();
if (!$config->get('main_rss')) {
return;
}
$filteractive = JRequest::getString('filter', 'allposts');
$sort = JRequest::getString('sort', 'latest');
if ($filteractive == 'unanswered' && ($sort == 'active' || $sort == 'popular')) {
//reset the active to latest.
$sort = 'latest';
}
$doc = JFactory::getDocument();
$doc->link = JRoute::_('index.php?option=com_easydiscuss&view=index');
// Load up the tag
$tag = JRequest::getInt('id', 0);
$table = DiscussHelper::getTable('Tags');
$table->load($tag);
// Set the title of the document
$doc->setTitle($table->title);
$doc->setDescription(JText::sprintf('COM_EASYDISCUSS_DISCUSSIONS_TAGGED_IN', $table->title));
$postModel = $this->getModel('Posts');
$posts = $postModel->getTaggedPost($tag, $sort, $filteractive);
$pagination = $postModel->getPagination('0', $sort, $filteractive);
$jConfig = DiscussHelper::getJConfig();
$posts = DiscussHelper::formatPost($posts);
foreach ($posts as $row) {
// Assign to feed item
$title = $this->escape($row->title);
$title = html_entity_decode($title);
// load individual item creator class
$item = new JFeedItem();
$item->title = $title;
$item->link = JRoute::_('index.php?option=com_easydiscuss&view=post&id=' . $row->id);
$item->description = $row->content;
$item->date = DiscussHelper::getDate($row->created)->toMySQL();
if (!empty($row->tags)) {
$tagData = array();
foreach ($row->tags as $tag) {
$tagData[] = '<a href="' . JRoute::_('index.php?option=com_easydiscuss&view=tags&id=' . $tag->id) . '">' . $tag->title . '</a>';
}
$row->tags = implode(', ', $tagData);
} else {
$row->tags = '';
}
$item->category = $row->tags;
$item->author = $row->user->getName();
if ($jConfig->get('feed_email') != 'none') {
if ($jConfig->get('feed_email') == 'author') {
$item->authorEmail = $row->user->email;
} else {
$item->authorEmail = $jConfig->get('mailfrom');
}
}
$doc->addItem($item);
}
}
示例2: display
function display($tmpl = null)
{
$config = DiscussHelper::getConfig();
if (!$config->get('main_rss')) {
return;
}
$document = JFactory::getDocument();
$document->link = JRoute::_('index.php?option=com_easydiscuss&view=index');
$document->setTitle($this->escape($document->getTitle()));
$sort = JRequest::getString('sort', 'latest');
$filter = JRequest::getString('filter', 'allposts');
$category = JRequest::getInt('category_id', 0);
$postModel = $this->getModel('Posts');
$posts = $postModel->getData(true, $sort, null, $filter, $category);
$pagination = $postModel->getPagination('0', $sort, $filter, $category);
$jConfig = DiscussHelper::getJConfig();
$posts = DiscussHelper::formatPost($posts);
require_once DISCUSS_HELPERS . '/parser.php';
foreach ($posts as $row) {
// Assign to feed item
$title = $this->escape($row->title);
$title = html_entity_decode($title);
$category = DiscussHelper::getTable('Category');
$category->load($row->category_id);
// load individual item creator class
$item = new JFeedItem();
//Problems with other language
//$item->title = htmlentities( $title );
$item->title = $row->title;
$item->link = JRoute::_('index.php?option=com_easydiscuss&view=post&id=' . $row->id);
//$row->content = DiscussHelper::parseContent( $row->content );
if ($row->content_type == 'bbcode') {
$row->content = DiscussHelper::parseContent($row->content);
$row->content = html_entity_decode($row->content);
}
// Problems with other language
//$item->description = htmlentities( $row->content );
$item->description = $row->content;
$item->date = DiscussHelper::getDate($row->created)->toMySQL();
$item->author = $row->user->getName();
$item->category = $category->getTitle();
if ($jConfig->get('feed_email') != 'none') {
if ($jConfig->get('feed_email') == 'author') {
$item->authorEmail = $row->user->user->email;
} else {
$item->authorEmail = $jConfig->get('mailfrom');
}
}
$document->addItem($item);
}
}
示例3: display
function display($tpl = null)
{
$config = DiscussHelper::getConfig();
$app = JFactory::getApplication();
if (!$config->get('main_favorite')) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_FEATURE_IS_DISABLED'), DISCUSS_QUEUE_ERROR);
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
$app->close();
}
DiscussHelper::setPageTitle(JText::_('COM_EASYDISCUSS_FAVOURITES_TITLE'));
// @task: Add view
$this->logView();
DiscussHelper::setMeta();
$postModel = DiscussHelper::getModel('Posts');
$posts = $postModel->getData(true, 'latest', null, 'favourites');
$posts = DiscussHelper::formatPost($posts);
$theme = new DiscussThemes();
$theme->set('posts', $posts);
echo $theme->fetch('favourites.php');
}
示例4: jimport
jimport('joomla.filesystem.file');
if (!JFile::exists($path)) {
return;
}
require_once $path;
// require_once (dirname(__FILE__) . '/helper.php');
DiscussHelper::loadStylesheet("module", "mod_easydiscuss_your_discussions");
$my = JFactory::getUser();
$config = DiscussHelper::getConfig();
$profile = DiscussHelper::getTable('Profile');
$profile->load($my->id);
$postsModel = DiscussHelper::getModel('Posts');
$count = $params->get('count', 5);
$posts = array();
$posts = $postsModel->getPostsBy('user', $profile->id, 'latest', '0', '', '', $count);
$posts = DiscussHelper::formatPost($posts);
if (!empty($posts)) {
$posts = Discusshelper::getPostStatusAndTypes($posts);
// foreach( $posts as $post )
// {
// // Translate post status from integer to string
// switch( $post->post_status )
// {
// case '0':
// $post->post_status = '';
// break;
// case '1':
// $post->post_status = JText::_( 'COM_EASYDISCUSS_POST_STATUS_ON_HOLD' );
// break;
// case '2':
// $post->post_status = JText::_( 'COM_EASYDISCUSS_POST_STATUS_ACCEPTED' );
示例5: filter
public function filter($viewtype = 'user-post', $profileId = null)
{
$ajax = new Disjax();
$mainframe = JFactory::getApplication();
$config = DiscussHelper::getConfig();
$acl = DiscussHelper::getHelper('ACL');
$sort = 'latest';
$data = null;
$pagination = null;
$model = $this->getModel('Posts');
$tagsModel = $this->getModel('Tags');
switch ($viewtype) {
case 'user-achievements':
$profile = DiscussHelper::getTable('Profile');
$profile->load($profileId);
$data = $profile->getBadges();
break;
case 'user-tags':
$data = $tagsModel->getTagCloud('', '', '', $profileId);
break;
case 'user-replies':
$data = $model->getRepliesFromUser($profileId);
$pagination = $model->getPagination();
DiscussHelper::formatPost($data);
break;
case 'user-unresolved':
$data = $model->getUnresolvedFromUser($profileId);
$pagination = $model->getPagination();
DiscussHelper::formatPost($data);
break;
case 'user-post':
default:
if (is_null($profileId)) {
break;
}
$model = $this->getModel('Posts');
$data = $model->getPostsBy('user', $profileId);
$data = DiscussHelper::formatPost($data);
$pagination = $model->getPagination();
break;
}
// replace the content
$content = '';
$tpl = new DiscussThemes();
$tpl->set('profileId', $profileId);
if ($viewtype == 'user-post' || $viewtype == 'user-replies' || $viewtype == 'user-unresolved') {
$nextLimit = DiscussHelper::getListLimit();
if ($nextLimit >= $pagination->total) {
// $ajax->remove( 'dc_pagination' );
$ajax->assign($viewtype . ' #dc_pagination', '');
}
$tpl->set('posts', $data);
$content = $tpl->fetch('main.item.php');
$ajax->assign($viewtype . ' #dc_list', $content);
//reset the next start limi
$ajax->value('pagination-start', $nextLimit);
if ($nextLimit < $pagination->total) {
$filterArr = array();
$filterArr['viewtype'] = $viewtype;
$filterArr['id'] = $profileId;
$ajax->assign($viewtype . ' #dc_pagination', $pagination->getPagesLinks('profile', $filterArr, true));
}
} else {
if ($viewtype == 'user-tags') {
$tpl->set('tagCloud', $data);
$content = $tpl->fetch('tags.item.php');
$ajax->assign('discuss-tag-list', $content);
} else {
if ($viewtype == 'user-achievements') {
$tpl->set('badges', $data);
$content = $tpl->fetch('users.achievements.list.php');
$ajax->assign('user-achievements', $content);
}
}
}
$ajax->script('discuss.spinner.hide( "profile-loading" );');
//$ajax->assign( 'sort-wrapper' , $sort );
//$ajax->script( 'EasyDiscuss.$("#pagination-filter").val("'.$viewtype.'");');
$ajax->script('EasyDiscuss.$("#' . $viewtype . '").show();');
$ajax->script('EasyDiscuss.$("#' . $viewtype . ' #dc_pagination").show();');
$ajax->send();
}
示例6: listings
//.........这里部分代码省略.........
// Add pathway for category here.
DiscussHelper::getHelper('Pathway')->setCategoryPathway($activeCategory);
}
// Add view to this page.
$this->logView();
// Set the meta of the page.
DiscussHelper::setMeta();
$doc = JFactory::getDocument();
$doc->setMetadata('description', strip_tags($activeCategory->getDescription()));
// Add rss feed into headers
DiscussHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easydiscuss&view=index');
// Get list of categories on the site.
$catModel = $this->getModel('Categories');
// Pagination is by default disabled.
$pagination = false;
if ($categoryId) {
$category = DiscussHelper::getTable('Category');
$category->load($categoryId);
$categories[] = $category;
} else {
$categories = $catModel->getCategories($categoryId);
if (count($categories) > 1) {
$ids = array();
foreach ($categories as $row) {
$ids[] = $row->id;
}
// iniCounts should only called in index page.
$category = DiscussHelper::getTable('Category');
$category->initCounts($ids, true);
}
}
// Get the model.
$postModel = DiscussHelper::getModel('Posts');
$authorIds = array();
$topicIds = array();
for ($i = 0; $i < count($categories); $i++) {
$category =& $categories[$i];
// building category childs lickage.
$category->childs = null;
$nestedLinks = '';
// In category page
if ($config->get('layout_show_all_subcategories', '1')) {
// By default show all the subcategories of the selected category
DiscussHelper::buildNestedCategories($category->id, $category, false, true);
} else {
// Show one level of subcategories of the selected category only
$category->childs = $catModel->getChildCategories($category->id);
}
DiscussHelper::accessNestedCategories($category, $nestedLinks, '0', '', 'listlink', ', ');
$category->nestedLink = $nestedLinks;
// Get featured posts from this particular category.
$featured = $postModel->getDiscussions(array('pagination' => false, 'sort' => $sort, 'filter' => $activeFilter, 'category' => $category->id, 'limit' => $config->get('layout_featuredpost_limit', $limit), 'featured' => true));
// Get normal discussion posts.
$posts = $postModel->getDiscussions(array('sort' => $sort, 'filter' => $activeFilter, 'category' => $category->id, 'limit' => $limit, 'featured' => false));
$tmpPostsArr = array_merge($featured, $posts);
if (count($tmpPostsArr) > 0) {
foreach ($tmpPostsArr as $tmpArr) {
$authorIds[] = $tmpArr->user_id;
$topicIds[] = $tmpArr->id;
}
}
if ($categoryId) {
$pagination = $postModel->getPagination(0, 'latest', '', $categoryId, false);
}
// Set these items into the category object.
$category->featured = $featured;
$category->posts = $posts;
// Set active filter for the category
$category->activeFilter = $activeFilter;
$category->activeSort = $sort;
}
$lastReplyUser = $postModel->setLastReplyBatch($topicIds);
$authorIds = array_merge($lastReplyUser, $authorIds);
// load all author object 1st.
$authorIds = array_unique($authorIds);
$profile = DiscussHelper::getTable('Profile');
$profile->init($authorIds);
$postLoader = DiscussHelper::getTable('Posts');
$postLoader->loadBatch($topicIds);
$postTagsModel = DiscussHelper::getModel('PostsTags');
$postTagsModel->setPostTagsBatch($topicIds);
// perform data formating here.
for ($i = 0; $i < count($categories); $i++) {
$category =& $categories[$i];
// perform data formating here.
if ($category->featured) {
$category->featured = DiscussHelper::formatPost($category->featured, false, true);
}
if ($category->posts) {
$category->posts = DiscussHelper::formatPost($category->posts, false, true);
}
}
// Let's render the layout now.
$theme = new DiscussThemes();
$theme->set('activeFilter', $activeFilter);
$theme->set('activeSort', $sort);
$theme->set('categories', $categories);
$theme->set('pagination', $pagination);
echo $theme->fetch('frontpage.php');
}
示例7: sort
public function sort($sort = null, $filter = null, $categoryId = null)
{
$ajax = new Disjax();
$mainframe = JFactory::getApplication();
$user = JFactory::getUser();
$config = DiscussHelper::getConfig();
$acl = DiscussHelper::getHelper('ACL');
$activeCategory = DiscussHelper::getTable('Category');
$activeCategory->load($categoryId);
//todo: check against the config
$showAllPosts = 'all';
$postModel = $this->getModel('Posts');
$posts = $postModel->getData(true, $sort, null, $filter, $categoryId, null, $showAllPosts);
$pagination = $postModel->getPagination('0', $sort, $filter, $categoryId, $showAllPosts);
$posts = DiscussHelper::formatPost($posts);
$nextLimit = DiscussHelper::getListLimit();
if ($nextLimit >= $pagination->total) {
$ajax->remove('dc_pagination .pagination-wrap');
}
$tpl = new DiscussThemes();
$tpl->set('posts', $posts);
$content = $tpl->fetch('main.item.php');
//reset the next start limi
$ajax->value('pagination-start', $nextLimit);
if ($nextLimit < $pagination->total) {
$filterArr = array();
$filterArr['filter'] = $filter;
$filterArr['category_id'] = $categoryId;
$filterArr['sort'] = $sort;
$ajax->assign('dc_pagination', $pagination->getPagesLinks('index', $filterArr, true));
}
$ajax->script('discuss.spinner.hide( "index-loading" );');
$ajax->script('EasyDiscuss.$("#pagination-sorting").val("' . $sort . '");');
$ajax->assign('dc_list', $content);
$ajax->script('EasyDiscuss.$("#dc_list").show();');
$ajax->script('EasyDiscuss.$("#dc_pagination").show();');
$ajax->send();
}
示例8: display
/**
* Displays the user's profile.
*
* @since 2.0
* @access public
*/
function display($tmpl = null)
{
$doc = JFactory::getDocument();
$app = JFactory::getApplication();
$id = JRequest::getInt('id', null);
$my = JFactory::getUser($id);
$config = DiscussHelper::getConfig();
// Custom parameters.
$sort = JRequest::getString('sort', 'latest');
$filteractive = JRequest::getString('filter', 'allposts');
$viewType = JRequest::getString('viewtype', 'questions');
$profile = DiscussHelper::getTable('Profile');
$profile->load($my->id);
// If profile is invalid, throw an error.
if (!$profile->id) {
// Show login form.
$theme = new DiscussThemes();
$theme->set('redirect', DiscussRouter::_('index.php?option=com_easydiscuss&view=profile', false));
echo $theme->fetch('login.form.php');
return;
}
$params = DiscussHelper::getRegistry($profile->params);
$fields = array('facebook', 'linkedin', 'twitter', 'website');
foreach ($fields as $site) {
if ($params->get($site, '') != '') {
if ($site == 'facebook' || $site == 'linkedin' || $site == 'twitter') {
$name = $params->get($site);
$url = 'www.' . $site . '.com/' . $name;
$params->set($site, DiscussUrlHelper::clean($url));
}
if ($site == 'website') {
$url = $params->get($site);
$params->set($site, DiscussUrlHelper::clean($url));
}
}
}
// Set the title for the page.
DiscussHelper::setPageTitle(JText::sprintf('COM_EASYDISCUSS_PROFILE_PAGE_TITLE', $profile->getName()));
// Set the pathway
$this->setPathway(JText::_($profile->getName()));
$postsModel = DiscussHelper::getModel('Posts');
$tagsModel = DiscussHelper::getModel('Tags');
$posts = array();
$replies = array();
$tagCloud = array();
$badges = array();
$unresolved = array();
$pagination = null;
$filterArr = array();
$filterArr['viewtype'] = $viewType;
$filterArr['id'] = $profile->id;
switch ($viewType) {
case 'replies':
$replies = $postsModel->getRepliesFromUser($profile->id);
$pagination = $postsModel->getPagination();
$pagination = $pagination->getPagesLinks('profile', $filterArr, true);
$replies = DiscussHelper::formatPost($replies);
break;
case 'unresolved':
$unresolved = $postsModel->getUnresolvedFromUser($profile->id);
$pagination = $postsModel->getPagination();
$pagination = $pagination->getPagesLinks('profile', $filterArr, true);
$unresolved = DiscussHelper::formatPost($unresolved);
break;
case 'questions':
default:
$posts = $postsModel->getPostsBy('user', $profile->id);
$pagination = $postsModel->getPagination();
$pagination = $pagination->getPagesLinks('profile', $filterArr, true);
$posts = DiscussHelper::formatPost($posts);
break;
}
// Get user badges
$badges = $profile->getBadges();
// @rule: Clear up any notifications that are visible for the user.
$notifications = DiscussHelper::getModel('Notification');
$notifications->markRead($profile->id, false, array(DISCUSS_NOTIFICATIONS_PROFILE, DISCUSS_NOTIFICATIONS_BADGE));
$tpl = new DiscussThemes();
// EasyBlog integrations
$easyblogExists = $this->easyblogExists();
$blogCount = 0;
if ($easyblogExists && $config->get('integrations_easyblog_profile')) {
$blogModel = EasyBlogHelper::getModel('Blog');
$blogCount = $blogModel->getBlogPostsCount($profile->id, false);
}
$komentoExists = $this->komentoExists();
$commentCount = 0;
if ($komentoExists && $config->get('integrations_komento_profile')) {
$commentsModel = Komento::getModel('comments');
$commentCount = $commentsModel->getTotalComment($profile->id);
}
$posts = Discusshelper::getPostStatusAndTypes($posts);
$favPosts = $postsModel->getData('true', 'latest', 'null', 'favourites');
$favPosts = DiscussHelper::formatPost($favPosts);
//.........这里部分代码省略.........
示例9: tags
function tags($tmpl = null)
{
//initialise variables
$mainframe = JFactory::getApplication();
$document = JFactory::getDocument();
$user = JFactory::getUser();
$config = DiscussHelper::getConfig();
$tags = JRequest::getVar('ids');
if (is_null($tags) || $tags == '') {
$mainframe->enqueueMessage(JText::_('COM_EASYDISCUSS_INVALID_TAG'), 'error');
$mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index'));
}
$tags = explode('+', $tags);
if (count($tags) < 2) {
$tags = explode(' ', $tags[0]);
}
$dirtyTags = $tags;
unset($tags);
$tags = array();
foreach ($dirtyTags as $dirtyTag) {
$dirtyTag = (int) $dirtyTag;
if (!empty($dirtyTag)) {
$tags[] = $dirtyTag;
}
}
if (empty($tags)) {
$mainframe->enqueueMessage(JText::_('COM_EASYDISCUSS_INVALID_TAG'), 'error');
$mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index'));
}
$this->setPathway(JText::_('COM_EASYDISCUSS_TAGS'), DiscussRouter::_('index.php?option=com_easydiscuss&view=tags'));
DiscussHelper::setMeta();
$tagNames = array();
foreach ($tags as $tag) {
$table = DiscussHelper::getTable('Tags');
$table->load($tag);
$tagNames[] = JText::_($table->title);
}
$this->setPathway(implode(' + ', $tagNames));
$tagIDs = implode('+', $tags);
$concatCode = DiscussHelper::getJConfig()->getValue('sef') ? '?' : '&';
$document->addHeadLink(JRoute::_('index.php?option=com_easydiscuss&view=tags&ids=' . $tagIDs) . $concatCode . 'format=feed&type=rss', 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
$document->addHeadLink(JRoute::_('index.php?option=com_easydiscuss&view=tags&ids=' . $tagIDs) . $concatCode . 'format=feed&type=atom', 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
$filteractive = JRequest::getString('filter', 'allposts');
$sort = JRequest::getString('sort', 'latest');
if ($filteractive == 'unanswered' && ($sort == 'active' || $sort == 'popular')) {
//reset the active to latest.
$sort = 'latest';
}
$postModel = $this->getModel('Posts');
$posts = $postModel->getTaggedPost($tags, $sort, $filteractive);
$pagination = $postModel->getPagination($sort, $filteractive);
$posts = DiscussHelper::formatPost($posts);
$tagModel = $this->getModel('Tags');
$currentTag = $tagModel->getTagNames($tags);
$tpl = new DiscussThemes();
$tpl->set('rssLink', JRoute::_('index.php?option=com_easydiscuss&view=tags&id=' . $tag . '&format=feed'));
$tpl->set('posts', $posts);
$tpl->set('paginationType', DISCUSS_TAGS_TYPE);
$tpl->set('pagination', $pagination);
$tpl->set('sort', $sort);
$tpl->set('filter', $filteractive);
$tpl->set('showEmailSubscribe', true);
$tpl->set('currentTag', $currentTag);
$tpl->set('parent_id', 0);
$tpl->set('config', $config);
echo $tpl->fetch('tag.php');
}