wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
SortController Class Reference
+ Inheritance diagram for SortController:

Public Member Functions

 hasView ()
 
 validate ()
 
 executeKernel ()
 
 getSortColumn ()
 
 swapNodes (&$node1, &$node2, $doSave)
 
 sortAll ()
 
- Public Member Functions inherited from Controller
 Controller (&$delegate)
 
 initialize (&$request, &$response)
 
 validate ()
 
 hasView ()
 
 execute ()
 
 executeKernel ()
 
 getErrorMsg ()
 
 setErrorMsg ($msg)
 
 appendErrorMsg ($msg)
 
getRequest ()
 
getResponse ()
 
getView ()
 
getDelegate ()
 
 getViewTemplate ($controller, $context, $action)
 
 getCacheId ()
 
 assignViewDefaults (&$view)
 
 isLocalizedRequest ()
 

Additional Inherited Members

- Public Attributes inherited from Controller
 $_request = null
 
 $_response = null
 
 $_errorMsg = ''
 
 $_view = null
 
 $_delegate = null
 

Detailed Description

SortController is a controller that sorts Nodes of same type.

wCMF - wemove Content Management Framework Copyright (C) 2005-2014 wemove digital solutions GmbH

Licensed under the terms of any of the following licenses at your choice:

See the license.txt file distributed with this work for additional information.

Id:
class.SortController.php 1462 2014-02-04 23:52:27Z iherwig

This Controller sorts the Nodes by responding to the 'sortup', 'sortdown' action names. It requires a parameter 'sortoid' which tells to which Node the action should be applied. According to the given action the Nodes sortkey attribute will be changed the way that it either swaps with its predecessor ('prevoid') or with its successor ('nextoid') or move a given distance ('dist') in a list of nodes that is either defined by the 'filter' or the 'poid' parameter. If none of the both parameters is given, the list contains all entities that have the same type as the type defined by 'sortoid'.

After using the NodeUtil::setSortProperties method on a list of Nodes you could write the following Smarty template code to support sorting:

{foreach from=$nodeList item=curNode}
{if $curNode->getValue('hasSortUp')}
<a href="javascript:setVariable('sortoid', '{$curNode->getOID()}'); setVariable('prevoid', '{$curNode->getValue('prevoid')}'); submitAction('sortup');">{translate text="up"}</a>
{else}
<span>{translate text="up"}</span>
{/if}
{if $curNode->getValue('hasSortDown')}
<a href="javascript:setVariable('sortoid', '{$curNode->getOID()}'); setVariable('nextoid', '{$curNode->getValue('nextoid')}'); submitAction('sortdown');">{translate text="down"}</a>
{else}
<span>{translate text="down"}</span>
{/if}
{/foreach}

Input actions:

  • sortup Move the given Node up in the list
  • sortdown Move the given Node down in the list

Output actions:

  • ok In any case
Parameters
[in]sortoidThe oid of the Node to change its sortkey. The Controller assumes that the given Node has a sortkey attribute (DATATYPE_IGNORE).
[in]prevoidThe oid of the Node to swap with on sortup action. If not given, the Node with previous sortkey is taken.
[in]nextoidThe oid of the Node to swap with on sortdown action. If not given, the Node with next sortkey is taken.
[in]distThe distance to move the Node up or down. 'prevoid', 'nextoid' will be ignored.
[in]filterA filter string to be used to filter the entities in the list, when moving by dist (see StringQuery), if no filter is defined, all entities of the type defined in sortoid are contained in the list to sort.
[in]poidAs alternative to the filter parameter the entity list maybe defined by a parent oid, which means that all child nodes of that parent are contained in the list to sort.
[in]sortcolThe name of the column to use for sorting (DATATYPE_IGNORE). If not given it defaults to 'sortkey'.
[out]oidThe oid of the Node that changed its sortkey (= sortoid).
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 86 of file class.SortController.php.

Member Function Documentation

SortController::hasView ( )
See Also
Controller::hasView()

Definition at line 91 of file class.SortController.php.

SortController::validate ( )
See Also
Controller::validate()

Definition at line 98 of file class.SortController.php.

References Controller\setErrorMsg().

+ Here is the call graph for this function:

SortController::executeKernel ( )

Sort Nodes.

Returns
Array of given context and action 'ok' in every case.
See Also
Controller::executeKernel()

Definition at line 112 of file class.SortController.php.

References BUILDDEPTH_SINGLE, PersistenceFacade\getInstance(), PersistenceFacade\isValidOID(), sortAll(), and swapNodes().

+ Here is the call graph for this function:

SortController::getSortColumn ( )

Get the name of the column to use for sorting.

Returns
The name.

Definition at line 145 of file class.SortController.php.

Referenced by sortAll(), and swapNodes().

SortController::swapNodes ( $node1,
$node2,
  $doSave 
)

Swap sortkey of two given Nodes.

Parameters
node1first Node
node2second Node
doSaveTrue/False wether to save the Nodes or not

Definition at line 160 of file class.SortController.php.

References DATATYPE_IGNORE, getSortColumn(), and sortAll().

Referenced by executeKernel(), and sortAll().

+ Here is the call graph for this function:


The documentation for this class was generated from the following file: