00001 <?php
00002
00010 class SnapSearchRequest extends SObject {
00011 const TYPE_DIRECTORY = 0;
00012 const TYPE_RESOURCE = 1;
00013 const TYPE_VERSION = 2;
00014
00015 const OP_MATCHES = 0;
00016 const OP_NOMATCH = 1;
00017 const OP_CONTAINS = 2;
00018 const OP_NOCONTAIN = 3;
00019
00020 const CONJ_OR = 0;
00021 const CONJ_AND = 1;
00022
00023 const ORDER_ASCENDING = 0;
00024 const ORDER_DESCENDING = 1;
00025
00026 private $domain = '';
00027 private $types = array(self::TYPE_DIRECTORY => false, self::TYPE_RESOURCE => false, self::TYPE_VERSION => false);
00028 private $conj = self::CONJ_OR;
00029
00030 private $dirConstraints = array();
00031 private $resConstraints = array();
00032 private $versConstraints = array();
00033 private $fileConstraints = array();
00034
00035 private $offset = 0;
00036 private $limit = 25;
00037 private $ordering = array();
00038
00047 public function setDomain($path) {
00048 $this->domain = $path;
00049 }
00050
00059 public function addType($type) {
00060 $this->types[$type] = true;
00061 }
00062
00071 public function removeType($type) {
00072 $this->types[$type] = false;
00073 }
00074
00083 public function setConjunction($conj) {
00084 $this->conj = $conj;
00085 }
00086
00095 public function setOffset($off) {
00096 $this->offset = $off;
00097 }
00098
00107 public function setLimit($limit) {
00108 $this->limit = $limit;
00109 }
00110
00120 public function addOrdering($field, $dir = self::ORDER_ASCENDING) {
00121 $this->ordering[$field] = $dir;
00122 }
00123
00134 public function addDirectoryConstraint($field, $op, $value) {
00135 $this->dirConstraints[] = array($op, $field, $value);
00136 }
00137
00148 public function addResourceConstraint($field, $op, $value) {
00149 $this->resConstraints[] = array($op, $field, $value);
00150 }
00151
00162 public function addFileConstraint($field, $op, $value) {
00163 $this->fileConstraints[] = array($op, $field, $value);
00164 }
00165
00176 public function addVersionConstraint($field, $op, $value) {
00177 $this->versConstraints[] = array($op, $field, $value);
00178 }
00179
00187 public function getDomain() { return $this->domain; }
00195 public function getTypes() { return $this->types; }
00203 public function getConjunction() { return $this->conj; }
00211 public function getOffset() { return $this->offset; }
00219 public function getLimit() { return $this->limit; }
00227 public function getOrdering() { return $this->ordering; }
00235 public function getDirConstraints() { return $this->dirConstraints; }
00243 public function getResConstraints() { return $this->resConstraints; }
00251 public function getFileConstraints() { return $this->fileConstraints; }
00259 public function getVersConstraints() { return $this->versConstraints; }
00268 public function getConstraints($type) {
00269 switch($type) {
00270 case self::TYPE_DIRECTORY:
00271 return array_merge($this->fileConstraints, $this->dirConstraints);
00272 case self::TYPE_RESOURCE:
00273 return array_merge($this->fileConstraints, $this->resConstraints);
00274 case self::TYPE_VERSION:
00275 return $this->versConstraints;
00276 }
00277 }
00278 }
00279
00280 ?>