当前位置: 首页>>代码示例>>PHP>>正文


PHP DiscussionModel::AllowedSortFields方法代码示例

本文整理汇总了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();
 }
开发者ID:3marproof,项目名称:vanilla,代码行数:27,代码来源:class.discussionscontroller.php

示例2: allowedSortFields

 /**
  * Getter/setter for protected $AllowedSortFields array.
  */
 public static function allowedSortFields($Allowed = null)
 {
     if (is_array($Allowed)) {
         self::$AllowedSortFields = $Allowed;
     }
     return self::$AllowedSortFields;
 }
开发者ID:RodSloan,项目名称:vanilla,代码行数:10,代码来源:class.discussionmodel.php

示例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'));
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:31,代码来源:advanced.php


注:本文中的DiscussionModel::AllowedSortFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。