本文整理汇总了PHP中DiscussionModel::AllowedSortFields方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussionModel::AllowedSortFields方法的具体用法?PHP DiscussionModel::AllowedSortFields怎么用?PHP DiscussionModel::AllowedSortFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussionModel
的用法示例。
在下文中一共展示了DiscussionModel::AllowedSortFields方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Sort
/**
* Set user preference for sorting discussions.
*/
public function Sort($Target = '')
{
if (!Gdn::Session()->IsValid()) {
throw PermissionException();
}
if (!$this->Request->IsAuthenticatedPostBack()) {
throw ForbiddenException('GET');
}
// Get param
$SortField = Gdn::Request()->Post('DiscussionSort');
$SortField = 'd.' . StringBeginsWith($SortField, 'd.', TRUE, TRUE);
// Use whitelist here too to keep database clean
if (!in_array($SortField, DiscussionModel::AllowedSortFields())) {
throw new Gdn_UserException("Unknown sort {$SortField}.");
}
// Set user pref
Gdn::UserModel()->SavePreference(Gdn::Session()->UserID, 'Discussions.SortField', $SortField);
if ($Target) {
Redirect($Target);
}
// Send sorted discussions.
$this->DeliveryMethod(DELIVERY_METHOD_JSON);
$this->Render();
}
示例2: allowedSortFields
/**
* Getter/setter for protected $AllowedSortFields array.
*/
public static function allowedSortFields($Allowed = null)
{
if (is_array($Allowed)) {
self::$AllowedSortFields = $Allowed;
}
return self::$AllowedSortFields;
}
示例3: array
<?php
$Options = array('10' => '10', '15' => '15', '20' => '20', '25' => '25', '30' => '30', '40' => '40', '50' => '50', '100' => '100');
$Fields = array('TextField' => 'Code', 'ValueField' => 'Code');
echo $this->Form->Label('Discussions per Page', 'Vanilla.Discussions.PerPage');
echo $this->Form->DropDown('Vanilla.Discussions.PerPage', $Options, $Fields);
?>
</li>
<li>
<?php
echo $this->Form->Label('Comments per Page', 'Vanilla.Comments.PerPage');
echo $this->Form->DropDown('Vanilla.Comments.PerPage', $Options, $Fields);
?>
</li>
<li>
<?php
$AllowedSortFields = DiscussionModel::AllowedSortFields();
$SortFields = array();
foreach ($AllowedSortFields as $Field) {
$SortFields[$Field] = DiscussionSortText($Field);
}
echo $this->Form->Label('Sort discussions by', 'Vanilla.Discussions.SortField');
echo $this->Form->DropDown('Vanilla.Discussions.SortField', $SortFields, $Fields);
?>
</li>
<li>
<?php
$Options = array('0' => T('Authors may never edit'), '350' => sprintf(T('Authors may edit for %s'), T('5 minutes')), '900' => sprintf(T('Authors may edit for %s'), T('15 minutes')), '3600' => sprintf(T('Authors may edit for %s'), T('1 hour')), '14400' => sprintf(T('Authors may edit for %s'), T('4 hours')), '86400' => sprintf(T('Authors may edit for %s'), T('1 day')), '604800' => sprintf(T('Authors may edit for %s'), T('1 week')), '2592000' => sprintf(T('Authors may edit for %s'), T('1 month')), '-1' => T('Authors may always edit'));
$Fields = array('TextField' => 'Text', 'ValueField' => 'Code');
echo $this->Form->Label('Discussion & Comment Editing', 'Garden.EditContentTimeout');
echo $this->Form->DropDown('Garden.EditContentTimeout', $Options, $Fields);
echo Wrap(T('EditContentTimeout.Notes', 'If a user is in a role that has permission to edit content, those permissions will override this.'), 'div', array('class' => 'Info'));