本文整理汇总了PHP中DiscussionModel::discussionTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussionModel::discussionTypes方法的具体用法?PHP DiscussionModel::discussionTypes怎么用?PHP DiscussionModel::discussionTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussionModel
的用法示例。
在下文中一共展示了DiscussionModel::discussionTypes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: allowedDiscussionTypes
/**
*
*
* @param $Category
* @return array
*/
public static function allowedDiscussionTypes($Category)
{
$Category = self::permissionCategory($Category);
$Allowed = val('AllowedDiscussionTypes', $Category);
$AllTypes = DiscussionModel::discussionTypes();
if (empty($Allowed) || !is_array($Allowed)) {
return $AllTypes;
} else {
return array_intersect_key($AllTypes, array_flip($Allowed));
}
}
示例2: allowedDiscussionTypes
/**
* Checks the allowed discussion types on a category.
*
* @param array $PermissionCategory The permission category of the category.
* @param array $category The category we're checking the permission on.
* @return array The allowed discussion types on the category.
* @throws Exception
*/
public static function allowedDiscussionTypes($PermissionCategory, $category = [])
{
$PermissionCategory = self::permissionCategory($PermissionCategory);
$Allowed = val('AllowedDiscussionTypes', $PermissionCategory);
$AllTypes = DiscussionModel::discussionTypes();
if (empty($Allowed) || !is_array($Allowed)) {
$allowedTypes = $AllTypes;
} else {
$allowedTypes = array_intersect_key($AllTypes, array_flip($Allowed));
}
Gdn::pluginManager()->EventArguments['AllowedDiscussionTypes'] =& $allowedTypes;
Gdn::pluginManager()->EventArguments['Category'] = $category;
Gdn::pluginManager()->EventArguments['PermissionCategory'] = $PermissionCategory;
Gdn::pluginManager()->fireEvent('AllowedDiscussionTypes');
return $allowedTypes;
}
示例3: discussion
//.........这里部分代码省略.........
}
}
$isTitleValid = true;
$Name = trim($this->Form->getFormValue('Name', ''));
if (!$Draft) {
// Let's be super aggressive and disallow titles with no word characters in them!
$hasWordCharacter = preg_match('/\\w/u', $Name) === 1;
if (!$hasWordCharacter || $Name != '' && Gdn_Format::text($Name) == '') {
$this->Form->addError(t('You have entered an invalid discussion title'), 'Name');
$isTitleValid = false;
}
}
if ($isTitleValid) {
// Trim the name.
$FormValues['Name'] = $Name;
$this->Form->setFormValue('Name', $Name);
}
if ($this->Form->errorCount() == 0) {
if ($Draft) {
$DraftID = $this->DraftModel->save($FormValues);
$this->Form->setValidationResults($this->DraftModel->validationResults());
} else {
$DiscussionID = $this->DiscussionModel->save($FormValues);
$this->Form->setValidationResults($this->DiscussionModel->validationResults());
if ($DiscussionID > 0) {
if ($DraftID > 0) {
$this->DraftModel->delete($DraftID);
}
}
if ($DiscussionID == SPAM || $DiscussionID == UNAPPROVED) {
$this->StatusMessage = t('DiscussionRequiresApprovalStatus', 'Your discussion will appear after it is approved.');
// Clear out the form so that a draft won't save.
$this->Form->formValues(array());
$this->render('Spam');
return;
}
}
}
} else {
// If this was a preview click, create a discussion/comment shell with the values for this comment
$this->Discussion = new stdClass();
$this->Discussion->Name = $this->Form->getValue('Name', '');
$this->Comment = new stdClass();
$this->Comment->InsertUserID = $Session->User->UserID;
$this->Comment->InsertName = $Session->User->Name;
$this->Comment->InsertPhoto = $Session->User->Photo;
$this->Comment->DateInserted = Gdn_Format::date();
$this->Comment->Body = val('Body', $FormValues, '');
$this->Comment->Format = val('Format', $FormValues, c('Garden.InputFormatter'));
$this->EventArguments['Discussion'] =& $this->Discussion;
$this->EventArguments['Comment'] =& $this->Comment;
$this->fireEvent('BeforeDiscussionPreview');
if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
$this->addAsset('Content', $this->fetchView('preview'));
} else {
$this->View = 'preview';
}
}
if ($this->Form->errorCount() > 0) {
// Return the form errors
$this->errorMessage($this->Form->errors());
} elseif ($DiscussionID > 0 || $DraftID > 0) {
// Make sure that the ajax request form knows about the newly created discussion or draft id
$this->setJson('DiscussionID', $DiscussionID);
$this->setJson('DraftID', $DraftID);
if (!$Preview) {
// If the discussion was not a draft
if (!$Draft) {
// Redirect to the new discussion
$Discussion = $this->DiscussionModel->getID($DiscussionID, DATASET_TYPE_OBJECT, array('Slave' => false));
$this->setData('Discussion', $Discussion);
$this->EventArguments['Discussion'] = $Discussion;
$this->fireEvent('AfterDiscussionSave');
if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
redirect(discussionUrl($Discussion, 1)) . '?new=1';
} else {
$this->RedirectUrl = discussionUrl($Discussion, 1, true) . '?new=1';
}
} else {
// If this was a draft save, notify the user about the save
$this->informMessage(sprintf(t('Draft saved at %s'), Gdn_Format::date()));
}
}
}
}
// Add hidden fields for editing
$this->Form->addHidden('DiscussionID', $DiscussionID);
$this->Form->addHidden('DraftID', $DraftID, true);
$this->fireEvent('BeforeDiscussionRender');
if ($this->CategoryID) {
$Breadcrumbs = CategoryModel::getAncestors($this->CategoryID);
} else {
$Breadcrumbs = array();
}
$Breadcrumbs[] = array('Name' => $this->data('Title'), 'Url' => val('AddUrl', val($this->data('Type'), DiscussionModel::discussionTypes()), '/post/discussion'));
$this->setData('Breadcrumbs', $Breadcrumbs);
$this->setData('_AnnounceOptions', $this->announceOptions());
// Render view (posts/discussion.php or post/preview.php)
$this->render();
}
示例4: discussionTypes
/**
* Get the allowed discussion types.
*
* @return array Returns an array of discussion type definitions.
*/
public static function discussionTypes()
{
if (self::$discussionTypes === null) {
$DiscussionTypes = ['Discussion' => ['Singular' => 'Discussion', 'Plural' => 'Discussions', 'AddUrl' => '/post/discussion', 'AddText' => 'New Discussion']];
Gdn::pluginManager()->EventArguments['Types'] =& $DiscussionTypes;
Gdn::pluginManager()->fireAs('DiscussionModel')->fireEvent('DiscussionTypes');
self::$discussionTypes = $DiscussionTypes;
unset(Gdn::pluginManager()->EventArguments['Types']);
}
return self::$discussionTypes;
}