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");
25 require_once(BASE.
"wcmf/lib/util/class.Obfuscator.php");
100 if(!$this->_request->hasValue(
'sortoid'))
120 $node1 = &$persistenceFacade->load($this->_request->getValue(
'sortoid'),
BUILDDEPTH_SINGLE);
121 $node2 = &$persistenceFacade->load($this->_request->getValue(
'nextoid'),
BUILDDEPTH_SINGLE);
127 $node1 = &$persistenceFacade->load($this->_request->getValue(
'sortoid'),
BUILDDEPTH_SINGLE);
128 $node2 = &$persistenceFacade->load($this->_request->getValue(
'prevoid'),
BUILDDEPTH_SINGLE);
137 $this->_response->setValue(
'oid', $this->_request->getValue(
'sortoid'));
138 $this->_response->setAction(
'ok');
148 $sortCol =
'sortkey';
149 if (strlen($this->_request->getValue(
'sortcol')) > 0) {
150 $sortCol = $this->_request->getValue(
'sortcol');
168 if (!$sortkey1 || !$sortkey2)
175 if ($sortkey1 == $sortkey2) {
196 $mapper = &$persistenceFacade->getMapper($type);
200 if ($this->_request->hasValue(
'poid'))
202 $poid = $this->_request->getValue(
'poid');
206 $parent = &$persistenceFacade->load($poid, 1);
208 $parent->sortChildren(
'sortkey');
209 $nodes = $parent->getChildren();
213 $this->
setErrorMsg(
"The 'poid' parameter is invalid.");
217 else if ($this->_request->hasValue(
'filter'))
220 $filter = $this->_request->getValue(
'filter');
222 if (strlen($filter) > 0 && strlen($unveiled) > 0) {
227 $this->
setErrorMsg(
"The 'poid' parameter is invalid.");
238 $dir = $this->_request->getAction() ==
'sortdown' ? 1 : -1;
240 $orderBy = $mapper->getOrderBy();
241 if (
sizeof($orderBy) > 0) {
242 $firstAttribute = $orderBy[0];
243 if (preg_match(
'/'.$sortCol.
' DESC/', $firstAttribute)) {
249 $rootNode =
new Node(
'');
251 for ($i=0; $i<
sizeof($nodes); $i++)
254 $rootNode->addChild($nodes[$i]);
259 if (strlen($this->_request->getValue(
'dist')) > 0) {
260 $dist = $this->_request->getValue(
'dist');
263 $nodes = $rootNode->getChildren();
264 $numNodes =
sizeof($nodes);
265 for ($j=0; $j<$dist; $j++)
267 for ($i=0; $i<$numNodes; $i++)
269 if ($nodes[$i]->getOID() == $this->_request->getValue(
'sortoid'))
271 if ($dir == 1 && $i<$numNodes-1) {
272 $this->
swapNodes($nodes[$i], $nodes[$i+1],
false);
274 elseif ($dir == -1 && $i>0) {
275 $this->
swapNodes($nodes[$i], $nodes[$i-1],
false);
288 $cv->startIterator($nIter);
executeString($type, $query, $buildDepth, $orderby=null, &$pagingInfo)
The CommitVisitor is used to commit the object's changes to the object storage. The objects must impl...
Node is the basic component for building trees (although a Node can have one than more parents)...
sort(&$nodeList, $criteria, $recursive=false, $changeSortkey=false, $sortFunction='')
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.
Controller is the base class of all controllers. If a Controller has a view it is expected to reside ...
SortController is a controller that sorts Nodes of same type.
getOIDParameter($oid, $param, $validate=true)
swapNodes(&$node1, &$node2, $doSave)