19 require_once(BASE.
"wcmf/lib/presentation/class.Controller.php");
20 require_once(BASE.
"wcmf/lib/util/class.SessionData.php");
21 require_once(BASE.
"wcmf/lib/output/class.ArrayOutputStrategy.php");
22 require_once(BASE.
"wcmf/lib/visitor/class.OutputVisitor.php");
23 require_once(BASE.
"wcmf/lib/util/class.Obfuscator.php");
73 $filter = $this->_request->getValue(
'filter');
75 if (strlen($filter) > 0 && strlen($unveiled) > 0) {
81 $pagingInfo =
new PagingInfo($this->_request->getValue(
'limit'));
82 $pagingInfo->
setIndex($this->_request->getValue(
'start'));
83 $type = $this->_request->getValue(
'type');
88 $sortType = $sortProperties[
'type'];
89 $sortAttribute = $sortProperties[
'attribute'];
90 $sortDir = $sortProperties[
'direction'];
91 if ($sortAttribute != null) {
92 $sortStr = $sortAttribute;
93 if ($sortType != null) {
94 $sortStr = $sortType.
'.'.$sortStr;
96 if ($sortDir != null) {
97 $sortStr .=
' '.$sortDir;
99 $sortArray = array($sortStr);
102 $objects = $this->
getObjects($type, stripslashes($filter), $sortArray, $pagingInfo);
106 for($i=0; $i<
sizeof($objects); $i++)
108 $curObject = &$objects[$i];
111 if ($rightsManager->authorize($curObject->getOID(),
'',
ACTION_READ)) {
112 $nodes[
sizeof($nodes)] = &$curObject;
120 for ($i=0; $i<
sizeof($nodes); $i++) {
121 $localization->loadTranslation($nodes[$i], $this->_request->getValue(
'language'),
true,
true);
129 $this->_response->setValue(
'totalCount', $pagingInfo->getTotalCount());
130 $this->_response->setValue(
'objects', $nodes);
133 $this->_response->setAction(
'ok');
146 function getObjects($type, $filter, $sortArray, &$pagingInfo)
154 if ($sortProperties[
'type'] == null) {
158 if (strlen($filter) == 0) {
167 function getOIDs($type, $filter, $sortArray, &$pagingInfo)
179 if ($this->_sortProperties == null) {
182 $dir = $this->_request->hasValue(
'dir') ? $this->_request->getValue(
'dir') : null;
184 $sort = $this->_request->getValue(
'sort');
185 if (strlen($sort) > 0) {
186 $orderParts = preg_split(
'/\./', $sort, 2);
187 if (
sizeof($orderParts) > 1) {
188 $type = $orderParts[0];
189 $attribute = $orderParts[1];
192 $attribute = $orderParts[0];
195 $mapper = $persistenceFacade->getMapper($this->_request->getValue(
'type'));
196 if ($mapper->isAttribute($attribute)) {
197 $type = $this->_request->getValue(
'type');
201 $this->_sortProperties = array(
'type' => $type,
'attribute' => $attribute,
'direction' => $dir);
215 if ($this->_request->getBooleanValue(
'completeObjects',
false) ==
false) {
216 for($i=0; $i<
sizeof($nodes); $i++) {
221 if ($this->_request->getBooleanValue(
'renderValues',
false) ==
true) {
225 if (strlen($this->_request->getValue(
'sort')) == 0) {
235 $parentTemplate = &$persistenceFacade->create($parentType, 1);
236 for ($i=0; $i<
sizeof($nodes); $i++)
238 $curNode = &$nodes[$i];
241 $childTemplate = &$parentTemplate->getFirstChild($curNode->getType());
242 foreach ($childTemplate->getPropertyNames() as $property)
244 if ($property !=
'childoids' && $property !=
'parentoids') {
245 $curNode->setProperty($property, $childTemplate->getProperty($property));
252 if (in_array(
'manyToMany', $curNode->getPropertyNames()))
258 foreach($curNode->getProperty(
'parentoids') as $curParentOID)
263 $clientOID = $curParentOID;
265 $curNode->setProperty(
'realSubject', $realSubject);
266 $curNode->setProperty(
'realSubjectType', $realSubjectType);
267 $curNode->setProperty(
'clientOID', $clientOID);
268 $curNode->setProperty(
'composition',
false);
273 $curNode->setProperty(
'clientOID', $this->_request->getValue(
'poid'));
280 if (
sizeof($nodes) > 0) {
281 $testNode = $nodes[0];
282 if (in_array(
'manyToMany', $testNode->getPropertyNames())) {
284 if ($sortProperties[
'type'] != $testNode->getType()) {
286 $realSubject = $testNode->getProperty(
'realSubject');
288 $mapper = $persistenceFacade->getMapper($realSubject->getType());
289 if ($mapper->isAttribute($sortProperties[
'attribute'])) {
291 Node::sort($nodes, null,
false,
false, array($this,
'sortByRealSubject'));
296 if ($this->_request->getValue(
'renderValues'))
298 foreach ($nodes as $node) {
299 $realSubject = $node->getProperty(
'realSubject');
301 $subjectList = array(&$realSubject);
305 $realSubject = $persistenceFacade->create($node->getProperty(
'realSubjectType'),
BUILDDEPTH_SINGLE);
307 $node->setProperty(
'realSubject', $realSubject);
318 $realSubjectA = $a->getProperty(
'realSubject');
319 $realSubjectB = $b->getProperty(
'realSubject');
320 $valueA = strtoupper($realSubjectA->getUnconvertedValue($sortProperties[
'attribute'],
DATATYPE_ATTRIBUTE));
321 $valueB = strtoupper($realSubjectB->getUnconvertedValue($sortProperties[
'attribute'],
DATATYPE_ATTRIBUTE));
322 if ($valueA == $valueB)
return 0;
323 if ($sortProperties[
'direction'] ==
'ASC') {
324 return ($valueA > $valueB) ? 1 : -1;
327 return ($valueA < $valueB) ? 1 : -1;
executeString($type, $query, $buildDepth, $orderby=null, &$pagingInfo)
getOIDs($type, $filter, $sortArray, &$pagingInfo)
setSortProperties(&$nodeList)
sort(&$nodeList, $criteria, $recursive=false, $changeSortkey=false, $sortFunction='')
renderValues(&$nodes, $language=null)
AsyncPagingController is a controller that allows to navigate lists.
throwEx($message, $file='', $line='')
sortByRealSubject($a, $b)
Controller is the base class of all controllers. If a Controller has a view it is expected to reside ...
removeNonDisplayValues(&$node)
getOIDParameter($oid, $param, $validate=true)
PagingInfo contains information about a paged list.
getObjects($type, $filter, $sortArray, &$pagingInfo)
getRealSubjectType(&$proxy, $parentType)