/** @brief Constructs new instance with appropriate sort mode/order.
  *
  * @param $mode [in] Sort mode (see AfsFacetValuesSortMode for details).
  * @param $order [in] Sort order (see AfsSortOrder for details).
  */
 public function __construct($mode, $order)
 {
     AfsFacetValuesSortMode::check_value($mode, 'Invalid facet values sort mode: ');
     AfsSortOrder::check_value($order, 'Invalid facet values sort order: ');
     $this->mode = $mode;
     $this->order = $order;
 }
Beispiel #2
0
 public static function check_value($value, $msg = null)
 {
     if (is_null(self::$instance)) {
         self::$instance = new self();
     }
     BasicEnum::check_val(self::$instance, $value, $msg);
 }
Beispiel #3
0
 /** @brief Adds new sort parameter or substitutes existing one.
  *
  * @param $current_value [in] current sort order value.
  * @param $sort_param [in] new sort parameter
  * @param $order [in] sort order
  *
  * @return copy of current query.
  */
 private function internal_add_sort($current_value, $sort_param, $order, $feed = null)
 {
     if ($sort_param == '') {
         $sort_param = null;
     }
     if (!is_null($sort_param)) {
         if (strncmp('afs:', $sort_param, 4) == 0) {
             AfsSortBuiltins::check_value($sort_param, 'Invalid sort parameter: ');
         } elseif (1 != preg_match('/^[a-zA-Z][a-zA-Z0-9_-]*$/', $sort_param)) {
             throw new Exception('Invalid sort parameter provided: ' . $sort_param);
         }
         AfsSortOrder::check_value($order, 'Invalid sort order provided: ');
         $new_value = $current_value;
         if (is_null($new_value)) {
             $new_value = array();
         }
         $new_value[] = new AfsSortParameter($sort_param, $order, $feed);
     } else {
         $new_value = array();
     }
     $this->sort = $new_value;
 }