00001 <?php
00002
00020 class TSDRequest extends SObject {
00021 const TYPE_TEXTBOOKS = 'textbooks';
00022 const TYPE_STANDARDS = 'standards';
00023 const TYPE_DICTIONARY = 'dictionary';
00024 const TYPE_RELATIONS = 'relations';
00025
00026 const OP_FILTER_ALIGNED = 'aligned';
00027 const OP_FILTER_RELATED = 'related';
00028 const OP_FILTER_MODE = 'mode';
00029 const OP_COUNT = 'count';
00030
00031 private $mode = TSD::MODE_LIVE;
00032 private $types = array('textbooks' => true, 'standards' => true, 'dictionary' => true, 'relations' => false);
00033
00034 private $resourceIds = null;
00035 private $objectId = null;
00036 private $objectType = null;
00037
00038 private $operation = null;
00039
00040 private $limit = false;
00041 private $offset = false;
00042
00048 public function setMode($newMode) {
00049 if(!ctype_digit((string) $newMode) || $newMode < 0 || $newMode > 8) {
00050 $this->setError('Invalid mode specified: ' . $newMode);
00051 return false;
00052 }
00053 $this->mode = $newMode;
00054 return true;
00055 }
00056
00068 public function enableType($type, $enable) {
00069 if(!isset($this->types[$type])) {
00070 $this->setError('Invalid type specified: ' . $type);
00071 return false;
00072 }
00073 $this->types[$type] = $enable;
00074 return true;
00075 }
00076
00086 public function setResourceId($rId) {
00087 if(!ctype_digit((string) $rId) && !is_array($rId)) {
00088 $this->setError('Invalid type for resource ID: ' . gettype($rId));
00089 return false;
00090 }
00091 if(is_array($rId)) {
00092 foreach($rId as $idx => $val)
00093 if(!ctype_digit((string) $idx) || !ctype_digit((string) $val)) {
00094 $this->setError("Invalid resource ID in array [$idx]: $val");
00095 return false;
00096 }
00097 $this->resourceIds = $rId;
00098 }
00099 else
00100 $this->resourceIds = array($rId);
00101
00102 return true;
00103 }
00104
00110 public function addResourceId($rId) {
00111 if(!ctype_digit((string) $rId)) {
00112 $this->setError('Resource ID must be numeric: ' . $rId);
00113 return false;
00114 }
00115
00116 if(is_array($this->resourceIds))
00117 $this->resourceIds[] = $rId;
00118 else if(ctype_digit((string) $this->resourceIds))
00119 $this->resourceIds = array($this->resourceIds, $rId);
00120 else
00121 $this->resourceIds = array($rId);
00122
00123 return true;
00124 }
00125
00131 public function setObjectId($id) {
00132 if(!ctype_digit((string) $id) && !is_string($id)) {
00133 $this->setError('Object ID must be numeric or string: ' . gettype($id));
00134 return false;
00135 }
00136 $this->objectId = $id;
00137 return true;
00138 }
00139
00148 public function setObjectType($type) {
00149 $this->objectType = $type;
00150 }
00151
00160 public function setOperation($op) {
00161 $this->operation = $op;
00162 }
00163
00172 public function setLimit($limit) {
00173 $this->limit = $limit;
00174 }
00175
00184 public function setOffset($offset) {
00185 $this->offset = $offset;
00186 }
00187
00192 public function getMode() {
00193 return $this->mode;
00194 }
00195
00201 public function getTypes() {
00202 return $this->types;
00203 }
00204
00209 public function getResourceIds() {
00210 return $this->resourceIds;
00211 }
00212
00217 public function getObjectId() {
00218 return $this->objectId;
00219 }
00220
00228 public function getObjectType() {
00229 return $this->objectType;
00230 }
00231
00239 public function getOperation() {
00240 return $this->operation;
00241 }
00242
00250 public function getLimit() {
00251 return $this->limit;
00252 }
00253
00261 public function getOffset() {
00262 return $this->offset;
00263 }
00264 }
00265
00266 ?>