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.NodeIterator.php");
24 require_once(BASE.
"wcmf/lib/visitor/class.CommitVisitor.php");
51 if(!$this->_request->hasValue(
'newtype'))
76 $persistenceFacade->startTransaction();
80 $possibleChildren = null;
81 $poid = $this->_request->getValue(
'poid');
86 $parentTemplate = &$persistenceFacade->create($poidParts[
'type'], 1);
87 $possibleChildren = $nodeUtil->getPossibleChildren($parentNode, $parentTemplate);
91 $newType = $this->_request->getValue(
'newtype');
92 if ($parentNode != null)
95 if (!in_array($newType, array_keys($possibleChildren)))
97 $this->
appendErrorMsg(
Message::get(
"%1% does not accept children of type %2%. The parent type is not compatible.", array($poid, $newType)));
102 $template = &$possibleChildren[$newType];
103 if (!$template->getProperty(
'canCreate'))
105 $this->
appendErrorMsg(
Message::get(
"%1% does not accept children of type %2%. The maximum number of children of that type is reached.", array($poid, $newType)));
113 $localizationTpl = null;
114 foreach($this->_request->getData() as $key => $value)
123 $localizationTpl = &$persistenceFacade->create($newType, BUIDLDEPTH_SINGLE);
136 $parentNode->addChild($newNode);
148 $cv->startIterator($nIter);
154 $localizationTpl->setOID($newNode->getOID());
156 $localization->saveTranslation($localizationTpl, $this->_request->getValue(
'language'));
163 $persistenceFacade->commitTransaction();
166 $this->_response->setValue(
'oid', $newNode->getOID());
168 $this->_response->setAction(
'ok');
The CommitVisitor is used to commit the object's changes to the object storage. The objects must impl...
get($message, $parameters=null, $domain='', $lang='')
NodeIterator is used to iterate over a tree/list build of objects using a Depth-First-Algorithm. Classes used with the NodeIterator must implement the getChildren() and getOID() methods. NodeIterator implements the 'Iterator Pattern'. The base class NodeIterator defines the interface for all specialized Iterator classes.
NodeUtil provides services for the Node class. All methods are static.
InsertController is a controller that inserts Nodes.
Controller is the base class of all controllers. If a Controller has a view it is expected to reside ...
decomposeOID($oid, $validate=true)
const BUILDDEPTH_REQUIRED
getOIDParameter($oid, $param, $validate=true)