當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。