本文整理汇总了PHP中DiscussHelper::populateCategories方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper::populateCategories方法的具体用法?PHP DiscussHelper::populateCategories怎么用?PHP DiscussHelper::populateCategories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussHelper
的用法示例。
在下文中一共展示了DiscussHelper::populateCategories方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
public function display($tpl = null)
{
// Initialise variables
$doc = JFactory::getDocument();
$doc->addScript(JURI::root() . 'administrator/components/com_easydiscuss/assets/js/admin.js');
// Load front end language file.
JFactory::getLanguage()->load('com_easydiscuss', JPATH_ROOT);
$postId = JRequest::getInt('id', 0);
$parentId = JRequest::getString('pid', '');
$source = JRequest::getVar('source', 'posts');
$post = JTable::getInstance('Posts', 'Discuss');
$post->load($postId);
$post->content_raw = $post->content;
// Get post's tags
$postModel = $this->getModel('Posts');
$post->tags = $postModel->getPostTags($post->id);
$post->content = EasyDiscussParser::html2bbcode($post->content);
// Select top 20 tags.
$tagmodel = $this->getModel('Tags');
$populartags = $tagmodel->getTagCloud('20', 'post_count', 'DESC');
$repliesCnt = $postModel->getPostRepliesCount($post->id);
$nestedCategories = DiscussHelper::populateCategories('', '', 'select', 'category_id', $post->category_id, true, true);
$config = DiscussHelper::getConfig();
// Get's the creator's name
$creatorName = $post->poster_name;
if ($post->user_id) {
$author = DiscussHelper::getTable('Profile');
$author->load($post->user_id);
$creatorName = $author->getName();
}
require_once DISCUSS_CLASSES . '/composer.php';
$composer = new DiscussComposer("creating", $post);
$this->assignRef('creatorName', $creatorName);
$this->assignRef('config', $config);
$this->assignRef('post', $post);
$this->assignRef('populartags', $populartags);
$this->assignRef('repliesCnt', $repliesCnt);
$this->assignRef('source', $source);
$this->assignRef('parentId', $parentId);
$this->assignRef('nestedCategories', $nestedCategories);
$this->assignRef('composer', $composer);
$this->assign('joomlaversion', DiscussHelper::getJoomlaVersion());
//load require javascript string
DiscussHelper::loadString(JRequest::getVar('view'));
parent::display($tpl);
}
示例2: movePost
/**
* Displays a dialog with a category selection.
*
* @since 3.0
* @access public
*/
public function movePost($id)
{
$ajax = new Disjax();
$my = JFactory::getUser();
$post = DiscussHelper::getTable('Post');
$state = $post->load($id);
if (!$state || !$id || $post->parent_id) {
echo JText::_('COM_EASYDISCUSS_SYSTEM_INVALID_ID');
return $ajax->send();
}
// Load the category of the post.
$category = DiscussHelper::getTable('Category');
$category->load($post->category_id);
// Load the access.
$access = $post->getAccess($category);
if (!$my->id || !$access->canMove()) {
echo JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS');
return $ajax->send();
}
// Get list of categories.
$categories = DiscussHelper::populateCategories('', '', 'select', 'category_id', $post->category_id, true, true, true, true);
$theme = new DiscussThemes();
$theme->set('categories', $categories);
$theme->set('id', $id);
$content = $theme->fetch('ajax.post.move.php', array('dialog' => true));
$options = new stdClass();
$options->content = $content;
$options->title = JText::_('COM_EASYDISCUSS_MOVE_POST_TITLE');
$buttons = array();
$button = new stdClass();
$button->title = JText::_('COM_EASYDISCUSS_BUTTON_CLOSE');
$button->action = 'disjax.closedlg();';
$buttons[] = $button;
$button = new stdClass();
$button->title = JText::_('COM_EASYDISCUSS_BUTTON_MOVE');
$button->form = '#frmMovePost';
$button->className = 'btn-primary';
$buttons[] = $button;
$options->buttons = $buttons;
$ajax->dialog($options);
$ajax->send();
}
示例3: showMoveDialog
public function showMoveDialog()
{
$ajax = new Disjax();
$options = new stdClass();
// Get list of categories.
$categories = DiscussHelper::populateCategories('', '', 'select', 'new_category', '', true, true, true, true);
$options->title = JText::_('COM_EASYDISCUSS_DIALOG_MOVE_TITLE');
$action = DiscussHelper::getJoomlaVersion() >= '1.6' ? 'Joomla.submitbutton(\'movePosts\');' : 'submitbutton(\'movePosts\')';
ob_start();
?>
<div style="display:none;" id="new_category_error" class="alert alert-error"></div>
<p><?php
echo JText::_('COM_EASYDISCUSS_DIALOG_MOVE_CONTENT');
?>
</p>
<p>
<?php
echo $categories;
?>
</p>
<?php
$options->content = ob_get_clean();
$buttons = array();
$button = new stdClass();
$button->title = JText::_('COM_EASYDISCUSS_CANCEL_BUTTON');
$button->action = 'disjax.closedlg();';
$buttons[] = $button;
$button = new stdClass();
$button->title = JText::_('COM_EASYDISCUSS_MOVE_BUTTON');
$button->action = $action;
$button->className = 'btn-primary';
$buttons[] = $button;
$options->buttons = $buttons;
$ajax->dialog($options);
$ajax->send();
}
示例4: defined
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Restricted access');
require_once DISCUSS_HELPERS . '/router.php';
$config = DiscussHelper::getConfig();
$isEditMode = false;
$post = DiscussHelper::getTable('Post');
$category = JRequest::getInt('category', $post->category_id);
$categoryModel = DiscussHelper::getModel('Category');
$defaultCategory = $categoryModel->getDefaultCategory();
$my = JFactory::getUser();
$showPrivateCat = $my->id == 0 ? false : true;
if ($category == 0 && $defaultCategory !== false) {
$category = $defaultCategory->id;
}
$nestedCategories = DiscussHelper::populateCategories('', '', 'select', 'category_id', $category, true, true, $showPrivateCat);
//recaptcha integration
$recaptcha = '';
$enableRecaptcha = $config->get('antispam_recaptcha');
$publicKey = $config->get('antispam_recaptcha_public');
$skipRecaptcha = $config->get('antispam_skip_recaptcha');
$model = DiscussHelper::getModel('Posts');
$postCount = count($model->getPostsBy('user', $my->id));
if ($enableRecaptcha && !empty($publicKey) && $postCount < $skipRecaptcha) {
require_once DISCUSS_CLASSES . '/recaptcha.php';
$recaptcha = getRecaptchaData($publicKey, $config->get('antispam_recaptcha_theme'), $config->get('antispam_recaptcha_lang'), null, $config->get('antispam_recaptcha_ssl'));
}
?>
<script src="http://easydiscuss.dev/media/foundry/js/foundry.js" type="text/javascript"></script>
示例5: edit
public function edit($tpl = null)
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$my = JFactory::getUser();
$acl = DiscussHelper::getHelper('ACL');
$config = DiscussHelper::getConfig();
// Load post item
$id = JRequest::getInt('id', 0);
if (empty($id)) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_POST_ID'));
return;
}
$post = DiscussHelper::getTable('Post');
$post->load($id);
$post->content_raw = $post->content;
$editing = (bool) $post->id;
if (!$editing) {
// try to get from session if there are any.
$this->getSessionData($post);
}
$categoryId = JRequest::getInt('category', $post->category_id);
// Load category item.
$category = DiscussHelper::getTable('Category');
$category->load($categoryId);
// Check if user is allowed to post a discussion, we also need to check against the category acl
if (empty($my->id) && !$acl->allowed('add_question', 0)) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_PLEASE_KINDLY_LOGIN_TO_CREATE_A_POST'));
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false));
$app->close();
return;
}
if ($my->id != 0 && !$acl->allowed('add_question', '0') && !$category->canPost()) {
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false), JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'));
$app->close();
return;
}
// Set the breadcrumbs.
$this->setPathway(JText::_('COM_EASYDISCUSS_BREADCRUMBS_ASK'));
// Set the page title.
$title = JText::_('COM_EASYDISCUSS_TITLE_ASK');
if ($id && $post->id) {
$title = JText::sprintf('COM_EASYDISCUSS_TITLE_EDIT_QUESTION', $post->getTitle());
}
// Set the page title
DiscussHelper::setPageTitle($title);
if ($editing) {
$isModerator = DiscussHelper::getHelper('Moderator')->isModerator($post->category_id);
if (!DiscussHelper::isMine($post->user_id) && !DiscussHelper::isSiteAdmin() && !$acl->allowed('edit_question') && !$isModerator) {
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $postid, false), JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'));
$app->close();
}
$tagsModel = DiscussHelper::getModel('PostsTags');
$post->tags = $tagsModel->getPostTags($post->id);
} else {
if ($categoryId) {
// set the default category
$post->category_id = $categoryId;
}
}
$attachments = $post->getAttachments();
if (isset($post->sessiondata)) {
$attachments = '';
}
$model = DiscussHelper::getModel('Posts');
$postCount = count($model->getPostsBy('user', $my->id));
$onlyPublished = empty($post->id) ? true : false;
// @rule: If there is a category id passed through the query, respect it first.
$showPrivateCat = empty($post->id) && $my->id == 0 ? false : true;
// [model:category]
$categoryModel = $this->getModel('Category');
$defaultCategory = $categoryModel->getDefaultCategory();
if ($categoryId == 0 && $defaultCategory !== false) {
$categoryId = $defaultCategory->id;
}
$nestedCategories = '';
$categories = '';
if ($config->get('layout_category_selection') == 'multitier') {
$categoriesModel = $this->getModel('Categories');
$categories = $categoriesModel->getCategories(array('acl_type' => DISCUSS_CATEGORY_ACL_ACTION_SELECT));
} else {
$nestedCategories = DiscussHelper::populateCategories('', '', 'select', 'category_id', $categoryId, true, $onlyPublished, $showPrivateCat, true);
}
if ($config->get('layout_reply_editor') == 'bbcode') {
// Legacy fix when switching from WYSIWYG editor to bbcode.
$post->content = EasyDiscussParser::html2bbcode($post->content);
}
$editor = '';
if ($config->get('layout_editor') != 'bbcode') {
$editor = JFactory::getEditor($config->get('layout_editor'));
}
// Get list of moderators from the site.
$moderatorList = array();
if ($config->get('main_assign_user')) {
$moderatorList = DiscussHelper::getHelper('Moderator')->getSelectOptions($post->category_id);
}
$composer = new DiscussComposer("editing", $post);
// Set the discussion object.
$access = $post->getAccess($category);
$theme = new DiscussThemes();
//.........这里部分代码省略.........
示例6: defined
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
$user = JFactory::getUser();
if (!empty($user->id)) {
$postId = JRequest::getInt('id', 0);
$postCat = '';
if ($postId) {
$post = DiscussHelper::getTable('Posts');
$post->load($postId);
$postCat = $post->category_id;
}
$nestedCategories = DiscussHelper::populateCategories('', '', 'select', 'mod_post_topic_category_id', $postCat, true, true);
}
?>
<?php
if (!empty($user->id)) {
?>
<div id="discuss-post-topic" class="discuss-mod discuss-post-topic<?php
echo $params->get('moduleclass_sfx');
?>
">
<form id="mod_post_topic" name="mod_post_topic" action="<?php
echo DiscussRouter::_('index.php?option=com_easydiscuss&controller=posts&task=submit');
?>
" method="post" enctype="multipart/form-data" class="form-horizontal">
<div>