コード例 #1
0
ファイル: SMW_ResultArray.php プロジェクト: Tjorriemorrie/app
 /**
  * Make a request option object based on the given parameters, and
  * return NULL if no such object is required. The parameter defines
  * if the limit should be taken into account, which is not always desired
  * (especially if results are to be cached for future use).
  * 
  * @param boolean $useLimit
  * 
  * @return SMWRequestOptions or null
  */
 protected function getRequestOptions($useLimit = true)
 {
     $limit = $useLimit ? $this->mPrintRequest->getParameter('limit') : false;
     $order = trim($this->mPrintRequest->getParameter('order'));
     // Important: use "!=" for order, since trim() above does never return "false", use "!==" for limit since "0" is meaningful here.
     if ($limit !== false || $order != false) {
         $options = new SMWRequestOptions();
         if ($limit !== false) {
             $options->limit = trim($limit);
         }
         if ($order == 'descending' || $order == 'reverse' || $order == 'desc') {
             $options->sort = true;
             $options->ascending = false;
         } elseif ($order == 'ascending' || $order == 'asc') {
             $options->sort = true;
             $options->ascending = true;
         }
     } else {
         $options = null;
     }
     return $options;
 }