19 require_once(BASE.
"wcmf/lib/presentation/class.Controller.php");
20 require_once(BASE.
"wcmf/lib/persistence/class.PersistenceFacade.php");
21 require_once(BASE.
"wcmf/lib/model/class.Node.php");
22 require_once(BASE.
"wcmf/lib/model/class.NodeUtil.php");
23 require_once(BASE.
"wcmf/lib/model/class.NullNode.php");
54 $this->
setErrorMsg(
"No valid 'oid' given in data.");
77 $parentOID = $this->_request->getValue(
'oid');
78 $lockManager->releaseLock($parentOID);
82 $associateoids = $this->_request->getValue(
'associateoids');
83 $associateoidArray = split(
',', $associateoids);
84 foreach ($associateoidArray as $associateoid)
86 $associateoid = trim($associateoid);
90 $this->_response->setAction(
'ok');
95 $lockManager->releaseLock($associateoid);
98 if ($parentNode != null && $childNode != null)
102 $parentTemplate = &$persistenceFacade->create($parentType, 1);
104 $childTemplate = &$persistenceFacade->create($childType, 1);
107 if ($this->_request->getAction() ==
'associate')
110 if ($this->_request->getValue(
'associateAs') ==
'child' && $this->
isDirectAssociation($parentTemplate, $childTemplate))
112 $parentNode->addChild($childNode);
113 $parentNode->setType($parentNode->getBaseType());
117 else if ($this->_request->getValue(
'associateAs') ==
'parent' && $this->
isDirectAssociation($childTemplate, $parentTemplate))
119 $childNode->addChild($parentNode);
126 if ($linkType != null)
128 $link = &$persistenceFacade->create($linkType, BUILDTYPE_SINGLE);
129 $parentNode->addChild($link);
131 $link = &$persistenceFacade->load($link->getOID(), BUILDTYPE_SINGLE);
132 $childNode->addChild($link);
134 $this->_response->setValue(
"manyToMany", $link);
139 array($associateoid, $parentOID)));
143 elseif ($this->_request->getAction() ==
'disassociate')
149 $parentNode =
new NullNode($parentTemplate->getBaseType());
157 $childNode =
new NullNode($childTemplate->getType());
165 if ($linkType != null)
170 $parentNode->loadChildren();
171 $childNode->loadChildren();
172 $parentChildren = $parentNode->getChildren();
173 $childChildren = $childNode->getChildren();
174 for($i=0, $countI=
sizeof($parentChildren); $i<$countI; $i++)
176 for($j=0, $countJ=
sizeof($childChildren); $j<$countJ; $j++)
178 $objA = &$parentChildren[$i];
179 $objB = &$childChildren[$j];
180 if (($objA->getType() == $linkType || $objB->getType() == $linkType) && ($objA->getBaseOID() == $objB->getBaseOID()))
190 array($associateoid, $parentOID)));
197 if ($parentNode == null)
198 $this->
appendErrorMsg(
Message::get(
"Cannot %1% %2% and %3%. Parent does not exist.", array($this->_request->getAction(), $associateoid, $parentOID)));
199 if ($childNode == null)
200 $this->
appendErrorMsg(
Message::get(
"Cannot %1% %2% and %3%. Child does not exist.", array($this->_request->getAction(), $associateoid, $parentOID)));
203 $this->_response->setAction(
'ok');
215 $childTypeChildren = $parent->getChildrenEx(null, $child->getType(), null, null);
216 if (
sizeof($childTypeChildren) > 0) {
223 foreach ($parents as $tmpParent) {
224 if ($parent->getType() == $tmpParent->getType()) {
241 foreach ($parent->getChildren() as $possibleChild)
243 if (in_array(
'manyToMany', $possibleChild->getPropertyNames()))
245 $associationEnds = $possibleChild->getProperty(
'manyToMany');
246 if (in_array($child->getType(), $associationEnds))
247 return $possibleChild->getType();
250 foreach ($child->getChildren() as $possibleChild)
252 if (in_array(
'manyToMany', $possibleChild->getPropertyNames()))
254 $associationEnds = $possibleChild->getProperty(
'manyToMany');
255 if (in_array($parent->getType(), $associationEnds))
256 return $possibleChild->getType();
get($message, $parameters=null, $domain='', $lang='')
addChild(&$child, $addtype=ADDCHILD_BACK)
Controller is the base class of all controllers. If a Controller has a view it is expected to reside ...
NullNode is an implementation of the NullObject pattern, It inherits all functionality from Node (act...
getOIDParameter($oid, $param, $validate=true)
getPossibleParents(&$realNode, &$tplNode)
isDirectAssociation(&$parent, &$child)
AssociateController is a controller that (dis-)associates Nodes (by setting the parent/child relation...
findAssociationType(&$parent, &$child)