public function display($tpl = null) { $id = JRequest::getInt('id', 0); $badge = DiscussHelper::getTable('Badges'); $badge->load($id); if (!$badge->created) { $date = DiscussHelper::getHelper('Date')->dateWithOffset(DiscussHelper::getDate()->toMySQL()); $badge->created = $date->toMySQL(); } // There could be some errors here. if (JRequest::getMethod() == 'POST') { $badge->bind(JRequest::get('post')); // Description might contain html codes $description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW); $badge->description = $description; } $jConfig = DiscussHelper::getJConfig(); $editor = JFactory::getEditor($jConfig->get('editor')); $model = $this->getModel('Badges'); $rules = $model->getRules(); $badges = $this->getBadges(); $this->assign('editor', $editor); $this->assign('badges', $badges); $this->assign('rules', $rules); $this->assign('badge', $badge); parent::display($tpl); }
public function display($tpl = null) { // @rule: Test for user access if on 1.6 and above if (DiscussHelper::getJoomlaVersion() >= '1.6') { if (!JFactory::getUser()->authorise('discuss.manage.settings', 'com_easydiscuss')) { JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error'); JFactory::getApplication()->close(); } } // Initialise variables $config = DiscussHelper::getConfig(); $jconfig = DiscussHelper::getJConfig(); $defaultSAId = DiscussHelper::getDefaultSAIds(); $joomlaVersion = DiscussHelper::getJoomlaVersion(); $joomlaGroups = DiscussHelper::getJoomlaUserGroups(); $this->assignRef('config', $config); $this->assignRef('jconfig', $jconfig); $this->assignRef('defaultSAId', $defaultSAId); $this->assignRef('defaultLength', $defaultLength); $this->assignRef('joomlaversion', $joomlaVersion); $this->assignRef('joomlaGroups', $joomlaGroups); if ($this->getLayout() == 'default') { $app = JFactory::getApplication(); $app->redirect('index.php?option=com_easydiscuss&view=settings&layout=default_main_workflow&child=general'); } parent::display($tpl); }
public function install() { // Request forgeries check JRequest::checkToken() or die('Invalid Token'); $file = JRequest::getVar('rule', '', 'FILES'); $app = JFactory::getApplication(); $files = array(); // @task: If there's no tmp_name in the $file, we assume that the data sent is corrupted. if (!isset($file['tmp_name'])) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR); $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install'); $app->close(); } // There are various MIME type for compressed file. So let's check the file extension instead. if ($file['name'] && JFile::getExt($file['name']) == 'xml') { $files = array($file['tmp_name']); } else { $jConfig = DiscussHelper::getJConfig(); $path = rtrim($jConfig->get('tmp_path'), '/') . '/' . $file['name']; // @rule: Copy zip file to temporary location if (!JFile::copy($file['tmp_name'], $path)) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR); $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install'); $app->close(); } jimport('joomla.filesystem.archive'); $tmp = md5(DiscussHelper::getDate()->toMysQL()); $dest = rtrim($jConfig->get('tmp_path'), '/') . '/' . $tmp; if (!JArchive::extract($path, $dest)) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR); $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install'); $app->close(); } $files = JFolder::files($dest, '.', true, true); if (empty($files)) { // Try to do a level deeper in case the zip is on the outer. $folder = JFolder::folders($dest); if (!empty($folder)) { $files = JFolder::files($dest . '/' . $folder[0], true); $dest = $dest . '/' . $folder[0]; } } if (empty($files)) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_RULE_FILE'), DISCUSS_QUEUE_ERROR); $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install'); $app->close(); } } if (empty($files)) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_RULE_INSTALL_FAILED'), DISCUSS_QUEUE_ERROR); $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install'); $app->close(); } foreach ($files as $file) { $this->installXML($file); } DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_RULE_INSTALL_SUCCESS'), DISCUSS_QUEUE_SUCCESS); $app->redirect('index.php?option=com_easydiscuss&view=rules&layout=install'); $app->close(); }
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); } }
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); } }
function display($tmpl = null) { $config = DiscussHelper::getConfig(); if (!$config->get('main_rss')) { return; } $userid = JRequest::getInt('id', null); $user = JFactory::getUser($userid); $document = JFactory::getDocument(); $document->link = DiscussRouter::_('index.php?option=com_easydiscuss&view=profile&id=' . $user->id); $profile = DiscussHelper::getTable('Profile'); $profile->load($user->id); $document->setTitle($profile->getName()); $document->setDescription($profile->getDescription()); $jConfig = DiscussHelper::getJConfig(); $model = $this->getModel('Posts'); $posts = $model->getPostsBy('user', $profile->id); $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'); } } $document->addItem($item); } }
public function display($tpl = null) { // Initialise variables $config = DiscussHelper::getConfig(); $catId = JRequest::getVar('catid', ''); $cat = JTable::getInstance('Category', 'Discuss'); $cat->load($catId); $this->cat = $cat; $this->addPathway('Home', 'index.php?option=com_easydiscuss'); $this->addPathway(JText::_('Categories'), 'index.php?option=com_easydiscuss&view=categories'); if ($catId) { $this->addPathway('Edit Category'); } else { $this->addPathway('New Category'); } // Set default values for new entries. if (empty($cat->created)) { $date = DiscussDateHelper::getDate(); $now = DiscussDateHelper::toFormat($date); $cat->created = $now; $cat->published = true; } $catRuleItems = JTable::getInstance('CategoryAclItem', 'Discuss'); $categoryRules = $catRuleItems->getAllRuleItems(); $assignedGroupACL = $cat->getAssignedACL('group'); $assignedUserACL = $cat->getAssignedACL('user'); $assignedGroupMod = $cat->getAssignedModerator('group'); $assignedUserMod = $cat->getAssignedModerator('user'); $joomlaGroups = DiscussHelper::getJoomlaUserGroups(); $parentList = DiscussHelper::populateCategories('', '', 'select', 'parent_id', $cat->parent_id); $jConfig = DiscussHelper::getJConfig(); $editor = JFactory::getEditor($jConfig->get('editor')); $this->assignRef('editor', $editor); $this->assignRef('cat', $cat); $this->assignRef('config', $config); $this->assignRef('acl', $acl); $this->assignRef('parentList', $parentList); $this->assignRef('categoryRules', $categoryRules); $this->assignRef('assignedGroupACL', $assignedGroupACL); $this->assignRef('assignedUserACL', $assignedUserACL); $this->assignRef('assignedGroupMod', $assignedGroupMod); $this->assignRef('assignedUserMod', $assignedUserMod); $this->assignRef('joomlaGroups', $joomlaGroups); parent::display($tpl); }
function display($tpl = null) { //initialise variables $document = JFactory::getDocument(); $user = JFactory::getUser(); $config = DiscussHelper::getConfig(); $mainframe = JFactory::getApplication(); $acl = DiscussHelper::getHelper('ACL'); $filteractive = JRequest::getString('filter', 'allposts'); $query = JRequest::getString('query', ''); $sort = JRequest::getString('sort', 'latest'); $category = JRequest::getInt('category_id', 0); $postModel = $this->getModel('Posts'); $featuredposts = ''; $featuredpostsHTML = ''; $showFeaturedPost = true; $posts = $postModel->getData(true, $sort, null, $filteractive, $category, null, $showFeaturedPost); $pagination = $postModel->getPagination('0', $sort, $filteractive, $category, $showFeaturedPost); $posts = DiscussHelper::formatPost($posts); $concatCode = DiscussHelper::getJConfig()->getValue('sef') ? '?' : '&'; $document->addHeadLink(JRoute::_('index.php?option=com_easydiscuss&view=featured') . $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=featured') . $concatCode . 'format=feed&type=atom', 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0')); $rssLink = DiscussHelper::getHelper('Feeds')->getFeedURL('index.php?option=com_easydiscuss&view=featured'); $tpl = new DiscussThemes(); $tpl->set('rssLink', $rssLink); $filterBar = ''; $tpl->set('acl', $acl); $tpl->set('posts', $posts); $tpl->set('paginationType', DISCUSS_QUESTION_TYPE); $tpl->set('parent_id', 0); $tpl->set('pagination', $pagination); $tpl->set('sort', $sort); $tpl->set('filter', $filteractive); $tpl->set('filterbar', $filterBar); $tpl->set('query', $query); $tpl->set('config', $config); echo $tpl->fetch('featured.php'); }
public static function getOffSet16($numberOnly = false) { jimport('joomla.form.formfield'); $user = JFactory::getUser(); $config = DiscussHelper::getConfig(); $jConfig = DiscussHelper::getJConfig(); // temporary ignore the dst in joomla 1.6 if ($user->id != 0) { $userTZ = $user->getParam('timezone'); } if (empty($userTZ)) { $userTZ = $jConfig->get('offset'); } if ($numberOnly) { $newTZ = new DateTimeZone($userTZ); $dateTime = new DateTime("now", $newTZ); $offset = $newTZ->getOffset($dateTime) / 60 / 60; return $offset; } else { //timezone string return $userTZ; } }
public function display($tpl = null) { // Initialise variables $doc = JFactory::getDocument(); $my = JFactory::getUser(); $config = DiscussHelper::getConfig(); $app = JFactory::getApplication(); $registry = DiscussHelper::getRegistry(); $categoryId = JRequest::getInt('category_id', 0); // Perform redirection if there is a category_id in the index view. if (!empty($categoryId)) { $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=categories&layout=listings&category_id=' . $categoryId, false)); $app->close(); } // Try to detect if there's any category id being set in the menu parameter. $activeMenu = $app->getMenu()->getActive(); if ($activeMenu && !$categoryId) { // Load menu params to the registry. $registry->loadString($activeMenu->params); if ($registry->get('category_id')) { $categoryId = $registry->get('category_id'); } } // Get the current logged in user's access. $acl = DiscussHelper::getHelper('ACL'); // Todo: Perhaps we should fix the confused naming of filter and sort to type and sort $filter = JRequest::getString('filter', $registry->get('filter')); $sort = JRequest::getString('sort', $registry->get('sort')); // Get the pagination limit $limit = $registry->get('limit'); $limit = $limit == '-2' ? DiscussHelper::getListLimit() : $limit; $limit = $limit == '-1' ? DiscussHelper::getJConfig()->get('list_limit') : $limit; // Add view to this page. $this->logView(); // set page title. DiscussHelper::setPageTitle(); // Set the meta of the page. DiscussHelper::setMeta(); // 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; // Get the model. $postModel = DiscussHelper::getModel('Posts'); // Get a list of accessible categories $cats = $this->getAccessibleCategories($categoryId); // Get featured posts from this particular category. $featured = array(); if ($config->get('layout_featuredpost_frontpage')) { $options = array('pagination' => false, 'category' => $cats, 'sort' => $sort, 'filter' => $filter, 'limit' => $config->get('layout_featuredpost_limit', $limit), 'featured' => true); $featured = $postModel->getDiscussions($options); if (is_null($featured)) { $featured = array(); } } // Get normal discussion posts. $options = array('sort' => $sort, 'category' => $cats, 'filter' => $filter, 'limit' => $limit, 'featured' => false); $posts = $postModel->getDiscussions($options); if (is_null($posts)) { $posts = array(); } $authorIds = array(); $topicIds = array(); $tmpPostsArr = array_merge($featured, $posts); if (count($tmpPostsArr) > 0) { foreach ($tmpPostsArr as $tmpArr) { $authorIds[] = $tmpArr->user_id; $topicIds[] = $tmpArr->id; } } $pagination = $postModel->getPagination(0, 'latest', '', $cats, false); $postLoader = EDC::getTable('Posts'); $postLoader->loadBatch($topicIds); $postTagsModel = EDC::getModel('PostsTags'); $postTagsModel->setPostTagsBatch($topicIds); $model = EDC::getModel('Posts'); $lastReplyUser = $model->setLastReplyBatch($topicIds); // Reduce SQL queries by pre-loading all author object. $authorIds = array_merge($lastReplyUser, $authorIds); $authorIds = array_unique($authorIds); // Initialize the list of user's so we run lesser sql queries. $profile = EDC::getTable('Profile'); $profile->init($authorIds); // Format featured entries. $featured = EDC::formatPost($featured, false, true); // Format normal entries $posts = EDC::formatPost($posts, false, true); // Get unread count $unreadCount = $model->getUnreadCount($cats, false); // Get unresolved count // Change the "all" to TRUE or FALSE to include/exclude featured post count $unresolvedCount = $model->getUnresolvedCount('', $cats, '', 'all'); // Get resolved count $resolvedCount = $model->getTotalResolved(); // Get unanswered count $unansweredCount = EDC::getUnansweredCount($cats, true); // Get assigned post count that isn't answered yet. $assignedCount = 0; if (EDC::isSiteAdmin() || EDC::isModerator()) { $assignedModel = EDC::getModel('Assigned'); $assignedCount = $assignedModel->getTotalUnresolved(); } $activeFilter = $config->get('layout_frontpage_sorting'); // Let's render the layout now. $theme = new DiscussThemes(); $theme->set('assignedCount', $assignedCount); $theme->set('activeFilter', $activeFilter); $theme->set('activeSort', $sort); $theme->set('categories', $categoryId); $theme->set('unreadCount', $unreadCount); $theme->set('unansweredCount', $unansweredCount); $theme->set('resolvedCount', $resolvedCount); $theme->set('unresolvedCount', $unresolvedCount); $theme->set('posts', $posts); $theme->set('featured', $featured); $theme->set('pagination', $pagination); echo $theme->fetch('frontpage.index.php'); }
/** * Displays a list of recent discussions from a particular category. * * @since 3.0 * @access public */ public function listings() { // Initialise variables $doc = JFactory::getDocument(); $my = JFactory::getUser(); $config = DiscussHelper::getConfig(); $app = JFactory::getApplication(); $registry = DiscussHelper::getRegistry(); $categoryId = JRequest::getInt('category_id', 0); // Try to detect if there's any category id being set in the menu parameter. $activeMenu = $app->getMenu()->getActive(); if ($activeMenu) { // Load menu params to the registry. $registry->loadString($activeMenu->params); // Set the active category id if exists. $categoryId = $registry->get('category_id') ? $registry->get('category_id') : $categoryId; } // Get the current logged in user's access. $acl = DiscussHelper::getHelper('ACL'); // Todo: Perhaps we should fix the confused naming of filter and sort to type and sort $activeFilter = JRequest::getString('filter', $registry->get('filter')); $sort = JRequest::getString('sort', $registry->get('sort')); // Get the pagination limit $limit = $registry->get('limit'); $limit = $limit == '-2' ? DiscussHelper::getListLimit() : $limit; $limit = $limit == '-1' ? DiscussHelper::getJConfig()->get('list_limit') : $limit; // Get the active category id if there is any $activeCategory = DiscussHelper::getTable('Category'); $activeCategory->load($categoryId); DiscussHelper::setPageTitle($activeCategory->title); // Add breadcrumbs for active category. if ($activeCategory->id != 0) { // Test if user is really allowed to access this category. if (!$activeCategory->canAccess()) { $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false), JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS')); $app->close(); return; } // 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'); }
/** * Filters discussion based on a given filter * * @since 3.2 * @access public * @param string * @return */ public function filter() { $filterType = JRequest::getVar('filter'); $sort = JRequest::getVar('sort', 'latest'); $categoryId = JRequest::getVar('id', '0'); if (!$categoryId) { $categoryId = array(); } else { $categoryId = explode(',', $categoryId); } $view = JRequest::getVar('view', 'index'); $ajax = DiscussHelper::getHelper('ajax'); JRequest::setVar('filter', $filterType); $postModel = DiscussHelper::getModel('Posts'); $registry = DiscussHelper::getRegistry(); // Get the pagination limit $limit = $registry->get('limit'); $limit = $limit == '-2' ? DiscussHelper::getListLimit() : $limit; $limit = $limit == '-1' ? DiscussHelper::getJConfig()->get('list_limit') : $limit; // Get normal discussion posts. $options = array('sort' => $sort, 'category' => $categoryId, 'filter' => $filterType, 'limit' => $limit, 'featured' => false); $posts = $postModel->getDiscussions($options); //$posts = $postModel->getData( false , $sort , null , $filterType , $categoryId, null, ''); $posts = DiscussHelper::formatPost($posts); $pagination = ''; $pagination = $postModel->getPagination(0, $sort, $filterType, $categoryId, false); $filtering = array('category_id' => $categoryId, 'filter' => $filterType, 'sort' => $sort); $pagination = $pagination->getPagesLinks($view, $filtering, true); $html = ''; $empty = ''; if (count($posts) > 0) { $template = new DiscussThemes(); $badgesTable = DiscussHelper::getTable('Profile'); $onlineUsers = Discusshelper::getModel('Users')->getOnlineUsers(); foreach ($posts as $post) { $badgesTable->load($post->user->id); $post->badges = $badgesTable->getBadges(); // Translate post status from integer to string switch ($post->post_status) { case '0': $post->post_status_class = ''; $post->post_status = ''; break; case '1': $post->post_status_class = '-on-hold'; $post->post_status = JText::_('COM_EASYDISCUSS_POST_STATUS_ON_HOLD'); break; case '2': $post->post_status_class = '-accept'; $post->post_status = JText::_('COM_EASYDISCUSS_POST_STATUS_ACCEPTED'); break; case '3': $post->post_status_class = '-working-on'; $post->post_status = JText::_('COM_EASYDISCUSS_POST_STATUS_WORKING_ON'); break; case '4': $post->post_status_class = '-reject'; $post->post_status = JText::_('COM_EASYDISCUSS_POST_STATUS_REJECT'); break; default: $post->post_status_class = ''; $post->post_status = ''; break; } $alias = $post->post_type; $modelPostTypes = DiscussHelper::getModel('Post_types'); // Get each post's post status title $title = $modelPostTypes->getTitle($alias); $post->post_type = $title; // Get each post's post status suffix $suffix = $modelPostTypes->getSuffix($alias); $post->suffix = $suffix; $template->set('post', $post); $html .= $template->fetch('frontpage.post.php'); } } else { $template = new DiscussThemes(); $html .= $template->fetch('frontpage.empty.php'); } // This post is already favourite $ajax->resolve($html, $pagination); $ajax->send(); }
public static function isSefEnabled() { $jConfig = DiscussHelper::getJConfig(); $isSef = false; //check if sh404sef enabled or not. if (defined('sh404SEF_AUTOLOADER_LOADED') && JFile::exists(JPATH_ADMINISTRATOR . '/components/com_sh404sef/sh404sef.class.php')) { require_once JPATH_ADMINISTRATOR . '/components/com_sh404sef/sh404sef.class.php'; if (class_exists('shRouter')) { $sefConfig = shRouter::shGetConfig(); if ($sefConfig->Enabled) { $isSef = true; } } } // if sh404sef not enabled, we check on joomla if (!$isSef) { $isSef = $jConfig->getValue('sef'); } return $isSef; }
function getEmailTemplateContent($template, $data) { $config = DiscussHelper::getConfig(); $output = ''; if (!isset($data['unsubscribeLink'])) { $data['unsubscribeLink'] = ''; } $replyBreakText = ''; if ($replyBreakText = $config->get('mail_reply_breaker')) { $replyBreakText = JText::sprintf('COM_EASYDISCUSS_EMAILTEMPLATE_REPLY_BREAK', $replyBreakText); } // If this uses html, we need to switch the template file if ($config->get('notify_html_format')) { $template = str_ireplace('.php', '.html.php', $template); } $theme = new DiscussThemes(); foreach ($data as $key => $val) { $theme->set($key, $val); } $contents = $theme->fetch($template, array('emails' => true)); unset($theme); $theme = new DiscussThemes(); $jConfig = DiscussHelper::getJConfig(); $theme->set('emailTitle', $config->get('notify_email_title', $jConfig->getValue('sitename'))); $theme->set('contents', $contents); $theme->set('unsubscribeLink', $data['unsubscribeLink']); $theme->set('replyBreakText', $replyBreakText); if ($config->get('notify_html_format')) { $output = $theme->fetch('email.template.html.php', array('emails' => true)); } else { $output = $theme->fetch('email.template.text.php', array('emails' => true)); } return $output; }
public static function setMeta() { $config = DiscussHelper::getConfig(); $db = DiscussHelper::getDBO(); $menu = JFactory::getApplication()->getMenu(); $item = $menu->getActive(); $result = new stdClass(); $result->description = $config->get('main_description'); $result->keywords = ''; $description = ''; if (is_object($item)) { $params = $item->params; if (!$params instanceof JRegistry) { $params = DiscussHelper::getRegistry($item->params); } $description = $params->get('menu-meta_description', ''); $keywords = $params->get('menu-meta_keywords', ''); if (!empty($description)) { $result->description = $description; } if (!empty($keywords)) { $result->keywords = $keywords; } } $document = JFactory::getDocument(); if (empty($result->keywords) && empty($result->description)) { // Get joomla default description. $jConfig = DiscussHelper::getJConfig(); $joomlaDesc = $jConfig->getValue('MetaDesc'); $metaDesc = $description . ' - ' . $joomlaDesc; $document->setMetadata('description', $metaDesc); } else { if (!empty($result->keywords)) { $document->setMetadata('keywords', $result->keywords); } if (!empty($result->description)) { $document->setMetadata('description', $result->description); } } }
public static function getHeadingTitle() { static $title = null; if (!$title) { $config = DiscussHelper::getConfig(); $jConfig = DiscussHelper::getJConfig(); $title = $config->get('notify_email_title') ? $config->get('notify_email_title') : $jConfig->getValue('sitename'); } return $title; }
/** * Get total number of guests that is viewing the site. * * @since 3.0 * @access public */ public function getTotalGuests() { $db = DiscussHelper::getDBO(); $jConfig = DiscussHelper::getJConfig(); $lifespan = $jConfig->getValue('lifetime'); $online = time() - $lifespan * 60; $query = array(); $query[] = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__session'); $query[] = 'WHERE ' . $db->nameQuote('guest') . '=' . $db->Quote(1); $query[] = 'AND ' . $db->nameQuote('time') . '>=' . $db->Quote($online); $query = implode(' ', $query); $db->setQuery($query); $total = $db->loadResult(); return $total; }
/** * Shares a new content on Facebook **/ public function share($post) { $config = DiscussHelper::getConfig(); $content = $post->content; $content = EasyDiscussParser::bbcode($content); JFactory::getLanguage()->load('com_easydiscuss', JPATH_ROOT); $editor = DiscussHelper::getEditorType('question'); if ($editor == 'html') { // @rule: Match images from content $pattern = '/<\\s*img [^\\>]*src\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i'; } else { $pattern = '/\\[img\\](.*?)\\[\\/img\\]/ims'; } preg_match($pattern, $content, $matches); $image = ''; if ($matches) { $image = isset($matches[1]) ? $matches[1] : ''; if (JString::stristr($matches[1], 'https://') === false && JString::stristr($matches[1], 'http://') === false && !empty($image)) { $image = DISCUSS_JURIROOT . '/' . ltrim($image, '/'); } } $text = strip_tags($content); // @TODO: Configurable content length. $maxLength = 200; $text = JString::strlen($text) > $maxLength ? JString::substr($text, 0, $maxLength) . '...' : $text; $url = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $post->id, false, true); $this->_access_token = preg_replace('/&expires=.*/i', '', $this->_access_token); $jConfig = DiscussHelper::getJConfig(); $params = array('link' => $url, 'name' => $post->title, 'actions' => '{"name": "' . JText::_('COM_EASYDISCUSS_AUTOPOST_FB_VIEWON_BUTTON') . '", "link" : "' . $url . '"}', 'description' => $text, 'message' => JString::substr(strip_tags($text), 0, 30) . '...', 'access_token' => $this->_access_token); if (!empty($image)) { // Since Facebook does not allow https images we need to replace them here. $params['picture'] = str_ireplace('https://', 'http://', $image); } else { $params['picture'] = DISCUSS_JURIROOT . '/media/com_easydiscuss/images/default_facebook.png'; $params['source'] = rtrim(JURI::root(), '/') . '/media/com_easydiscuss/images/default_facebook.png'; } // @rule: See if we need to post this to a Facebook page instead. $pageId = $config->get('main_autopost_facebook_page_id'); if (!empty($pageId)) { $pages = JString::trim($pageId); $pages = explode(',', $pages); $total = count($pages); // @rule: Test if there are any pages at all the user can access $accounts = parent::api('/me/accounts', array('access_token' => $this->_access_token)); if (is_array($accounts) && isset($accounts['data'])) { for ($i = 0; $i < $total; $i++) { foreach ($accounts['data'] as $page) { if ($page['id'] == $pages[$i]) { $params['access_token'] = $page['access_token']; $query = parent::api('/' . $page['id'] . '/feed', 'post', $params); } } } } } else { // @rule: If this is just a normal posting, just post it on their page. $query = parent::api('/me/feed', 'post', $params); } $success = isset($query['id']) ? true : false; return $success; }
<th width="10%" class="center"><?php echo JHTML::_('grid.sort', JText::_('COM_EASYDISCUSS_ADMIN_POST_TYPES_ALIAS'), 'a.alias', $this->orderDirection, $this->order); ?> </th> <th width="1%" class="center"><?php echo JHTML::_('grid.sort', JText::_('Id'), 'a.id', $this->orderDirection, $this->order); ?> </th> </tr> </thead> <tbody> <?php if ($this->postTypes) { $k = 0; $x = 0; $config = DiscussHelper::getJConfig(); for ($i = 0, $n = count($this->postTypes); $i < $n; $i++) { $row = $this->postTypes[$i]; $date = DiscussHelper::getDate($row->created, $config->get('offset')); ?> <tr class="<?php echo "row{$k}"; ?> "> <td class="center" style="text-align: center;"> <?php echo JHTML::_('grid.id', $x++, $row->id); ?> </td> <td align="left">
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'); }