本文整理汇总了PHP中DiscussHelper::getAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper::getAlias方法的具体用法?PHP DiscussHelper::getAlias怎么用?PHP DiscussHelper::getAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussHelper
的用法示例。
在下文中一共展示了DiscussHelper::getAlias方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit
/**
* update posts
*/
public function submit()
{
if (JRequest::getMethod() == 'POST') {
JRequest::checkToken('request') or jexit('Invalid Token');
$user = JFactory::getUser();
// get all forms value
$post = JRequest::get('post');
// get id if available
$id = JRequest::getInt('id', 0);
// get post parent id
$parent = JRequest::getInt('parent_id', 0);
// the source where page come from
$source = JRequest::getVar('source', 'posts');
// Get raw content from request as we may need to respect the html codes.
$content = JRequest::getVar('dc_reply_content', '', 'post', 'none', JREQUEST_ALLOWRAW);
// Ensure that the posted content is respecting the correct values.
$post['dc_reply_content'] = $content;
// get config
$config = DiscussHelper::getConfig();
$post['alias'] = empty($post['alias']) ? DiscussHelper::getAlias($post['title'], 'post', $id) : DiscussHelper::getAlias($post['alias'], 'post', $id);
//clear tags if editing a post.
$previousTags = array();
if (!empty($id)) {
$postsTagsModel = $this->getModel('PostsTags');
$tmppreviousTags = $postsTagsModel->getPostTags($id);
if (!empty($tmppreviousTags)) {
foreach ($tmppreviousTags as $previoustag) {
$previousTags[] = $previoustag->id;
}
}
$postsTagsModel->deletePostTag($id);
}
// bind the table
$postTable = JTable::getInstance('posts', 'Discuss');
$postTable->load($id);
//get previous post status before binding.
$prevPostStatus = $postTable->published;
$postTable->bind($post, true);
// hold last inserted ID in DB
$lastId = null;
// @rule: Bind parameters
$postTable->bindParams($post);
if ($config->get('main_private_post') && isset($post['private'])) {
$postTable->private = $post['private'];
}
// @trigger: onBeforeSave
$isNew = (bool) $postTable->id;
DiscussEventsHelper::importPlugin('content');
DiscussEventsHelper::onContentBeforeSave('post', $post, $isNew);
if (!$postTable->store()) {
JError::raiseError(500, $postTable->getError());
}
//Clear off previous records before storing
$ruleModel = DiscussHelper::getModel('CustomFields');
$ruleModel->deleteCustomFieldsValue($postTable->id, 'update');
// Process custom fields.
$fieldIds = JRequest::getVar('customFields');
if (!empty($fieldIds)) {
foreach ($fieldIds as $fieldId) {
$fields = JRequest::getVar('customFieldValue_' . $fieldId);
if (!empty($fields)) {
// Cater for custom fields select list
// To detect if there is no value selected for the select list custom fields
if (in_array('defaultList', $fields)) {
$tempKey = array_search('defaultList', $fields);
$fields[$tempKey] = '';
}
}
$postTable->bindCustomFields($fields, $fieldId);
}
}
// @trigger: onAfterSave
DiscussEventsHelper::onContentAfterSave('post', $post, $isNew);
// The category_id for the replies should change too
$postTable->moveChilds($postTable->id, $postTable->category_id);
$lastId = $postTable->id;
// Bind file attachments
$postTable->bindAttachments();
$message = JText::_('COM_EASYDISCUSS_POST_SAVED');
$date = DiscussHelper::getDate();
//@task: Save tags
$tags = JRequest::getVar('tags', '', 'POST');
if (!empty($tags)) {
$tagModel = $this->getModel('Tags');
foreach ($tags as $tag) {
if (!empty($tag)) {
$tagTable = JTable::getInstance('Tags', 'Discuss');
//@task: Only add tags if it doesn't exist.
if (!$tagTable->exists($tag)) {
$tagInfo['title'] = JString::trim($tag);
$tagInfo['alias'] = DiscussHelper::getAlias($tag, 'tag');
$tagInfo['created'] = $date->toMySQL();
$tagInfo['published'] = 1;
$tagInfo['user_id'] = $user->id;
$tagTable->bind($tagInfo);
$tagTable->store();
} else {
//.........这里部分代码省略.........
示例2: submit
/**
* Handles POST request for new discussions
*
* @since 3.0
* @access public
*/
public function submit()
{
JRequest::checkToken('request') or jexit('Invalid Token');
$config = DiscussHelper::getConfig();
$my = JFactory::getUser();
$app = JFactory::getApplication();
$acl = DiscussHelper::getHelper('ACL');
// If guest posting is disallowed in the settings, they shouldn't be able to create a discussion at all.
if (!$my->id && !$acl->allowed('add_question', '0')) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_POST_PLEASE_LOGIN'), DISCUSS_QUEUE_ERROR);
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
return $app->close();
}
// If user is disallowed in the acl, they shouldn't be able to create a discussion at all.
if ($my->id && !$acl->allowed('add_question', '0')) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'), DISCUSS_QUEUE_ERROR);
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
return $app->close();
}
// Get values from the posted form.
$data = JRequest::get('post');
if (isset($data['mod_post_topic_category_id'])) {
$data['category_id'] = $data['mod_post_topic_category_id'];
unset($data['mod_post_topic_category_id']);
}
// Run validation on the posted data.
if (!$this->_fieldValidate($data)) {
$files = JRequest::getVar('filedata', array(), 'FILES');
$data['attachments'] = $files;
DiscussHelper::storeSession($data, 'NEW_POST_TOKEN');
$app->redirect(DiscussRouter::getAskRoute(null, false));
}
// get id if available
$id = JRequest::getInt('id', 0);
// bind the table
$post = DiscussHelper::getTable('Post');
$post->load($id);
// set is new value
$isNew = !$post->id ? true : false;
// If the post is edited and it doesn't have private the user might be switching from private -> non private
if (!$isNew && !isset($data['private'])) {
$post->private = false;
}
// Perform captcha validation
$state = EDC::validateCaptcha($data);
if (!$state) {
// Store the data into the session
EDC::storeSession($data, 'NEW_POST_TOKEN');
// Set error message
EDC::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_CAPTCHA'), DISCUSS_QUEUE_ERROR);
if ($isNew) {
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=ask', false));
} else {
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=ask&id=' . $post->id, false));
}
}
$previousTags = array();
if (!$isNew) {
//check if admin or is owner before allowing edit.
$isMine = DiscussHelper::isMine($post->user_id);
$isAdmin = DiscussHelper::isSiteAdmin();
$isEditor = $acl->allowed('edit_question');
if (!$my->id && !$isMine && !$isAdmin && !$isEditor) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_NO_PERMISSION_TO_PERFORM_THE_REQUESTED_ACTION'), DISCUSS_QUEUE_ERROR);
$this->setRedirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $id, false));
return;
}
// If this is an edited post, we need to remove existing tags and add them back again.
$postsTagsModel = $this->getModel('PostsTags');
$tmppreviousTags = $postsTagsModel->getPostTags($id);
if (!empty($tmppreviousTags)) {
foreach ($tmppreviousTags as $previoustag) {
$previousTags[] = $previoustag->id;
}
}
if ($acl->allowed('add_tag', '0')) {
$postsTagsModel->deletePostTag($id);
}
}
// Get raw content from request as we may need to respect the html codes.
$content = JRequest::getVar('dc_reply_content', '', 'post', 'none', JREQUEST_ALLOWRAW);
if (empty($content)) {
// if there is no content from component, get from module quick question
$content = JRequest::getVar('quick_question_reply_content', '', 'post', 'none', JREQUEST_ALLOWRAW);
}
// some joomla editor htmlentity the content before it send to server. so we need
// to do the god job to fix the content.
$content = DiscussHelper::getHelper('String ')->unhtmlentities($content);
// Ensure that the posted content is respecting the correct values.
$data['dc_reply_content'] = $content;
// Cleanup alias.
$alias = DiscussHelper::wordFilter($data['title']);
$data['alias'] = DiscussHelper::getAlias($alias, 'post', $post->id);
// Detect the poster type.
//.........这里部分代码省略.........
示例3: ajaxSubmitReply
//.........这里部分代码省略.........
return false;
}
if (empty($my->id)) {
if (empty($post['user_type'])) {
// Append result
$output = array();
$output['message'] = JText::_('COM_EASYDISCUSS_INVALID_USER_TYPE');
$output['type'] = 'error';
echo $this->_outputJson($output);
return false;
}
if (!DiscussUserHelper::validateUserType($post['user_type'])) {
$output = array();
$output['message'] = JText::sprintf('COM_EASYDISCUSS_THIS_USERTYPE_HAD_BEEN_DISABLED', $post['user_type']);
$output['type'] = 'error';
echo $this->_outputJson($output);
return false;
}
if (empty($post['poster_name']) || empty($post['poster_email'])) {
$output = array();
$output['message'] = JText::sprintf('COM_EASYDISCUSS_GUEST_SIGN_IN_DESC');
$output['type'] = 'error';
echo $this->_outputJson($output);
return false;
}
} else {
$post['user_type'] = 'member';
$post['poster_name'] = '';
$post['poster_email'] = '';
}
// get id if available
$id = 0;
// set alias
$post['alias'] = DiscussHelper::getAlias($post['title'], 'post');
// set post owner
$post['user_id'] = $my->id;
$content = JRequest::getVar('dc_reply_content', '', 'post', 'none', JREQUEST_ALLOWRAW);
$content = DiscussHelper::getHelper('String ')->unhtmlentities($content);
// Rebind the post data
$post['dc_reply_content'] = $content;
$post['content_type'] = DiscussHelper::getEditorType('reply');
// Set the ip address
$post['ip'] = JRequest::getVar('REMOTE_ADDR', '', 'SERVER');
// bind the table
$table = DiscussHelper::getTable('Post');
$table->bind($post, true);
// Set the category id for the reply since we might need to use this for acl checks.
$table->category_id = $question->category_id;
if ($config->get('main_moderatepost', 0) && !DiscussHelper::isModerateThreshold($my->id) && !DiscussHelper::isSiteAdmin($post->user_id)) {
$table->published = DISCUSS_ID_PENDING;
} else {
$table->published = DISCUSS_ID_PUBLISHED;
}
require_once DISCUSS_CLASSES . '/recaptcha.php';
if (DiscussRecaptcha::isRequired()) {
$obj = DiscussRecaptcha::recaptcha_check_answer($config->get('antispam_recaptcha_private'), $_SERVER['REMOTE_ADDR'], $post['recaptcha_challenge_field'], $post['recaptcha_response_field']);
if (!$obj->is_valid) {
$output = array();
$output['message'] = JText::_('COM_EASYDISCUSS_POST_INVALID_RECAPTCHA_RESPONSE');
$output['type'] = 'error.captcha';
echo $this->_outputJson($output);
return false;
}
} else {
if ($config->get('antispam_easydiscuss_captcha')) {
$runCaptcha = DiscussHelper::getHelper('Captcha')->showCaptcha();
示例4: save
/**
* Method to save a badge
*
* @since 3.0
* @access public
*/
public function save()
{
JRequest::checkToken('request') or jexit('Invalid Token');
$app = JFactory::getApplication();
$badge = DiscussHelper::getTable('Badges');
$id = JRequest::getInt('id');
$doc = JFactory::getDocument();
// Load the badge.
$badge->load($id);
$oldTitle = $badge->title;
$post = JRequest::get('POST');
$badge->bind($post);
// Description might contain html codes
$description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
$badge->description = $description;
if (!$badge->created) {
$badge->created = DiscussHelper::getDate()->toMySQL();
}
// Set the badge alias if necessary.
if ($badge->title != $oldTitle || $oldTitle == '') {
$badge->alias = DiscussHelper::getAlias($badge->title);
}
// Get the current task
$task = $this->getTask();
// Test for rules here.
if (!$badge->title || !$badge->description || !$badge->description) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_BADGE_SAVE_FAILED'), DISCUSS_QUEUE_ERROR);
JRequest::setVar('view', 'badge');
return parent::display();
}
$badge->store();
if ($task == 'savePublishNew') {
$redirect = 'index.php?option=com_easydiscuss&controller=badges&task=edit';
} else {
$redirect = 'index.php?option=com_easydiscuss&view=badges';
}
$message = !empty($id) ? JText::_('COM_EASYDISCUSS_BADGE_UPDATED') : JText::_('COM_EASYDISCUSS_BADGE_CREATED');
DiscussHelper::setMessageQueue($message, DISCUSS_QUEUE_SUCCESS);
$app->redirect($redirect);
}