wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
class.NodeListController.php
Go to the documentation of this file.
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2014 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of any of the following licenses
7  * at your choice:
8  *
9  * - GNU Lesser General Public License (LGPL)
10  * http://www.gnu.org/licenses/lgpl.html
11  * - Eclipse Public License (EPL)
12  * http://www.eclipse.org/org/documents/epl-v10.php
13  *
14  * See the license.txt file distributed with this work for
15  * additional information.
16  *
17  * $Id: class.NodeListController.php 1462 2014-02-04 23:52:27Z iherwig $
18  */
19 require_once(BASE."wcmf/application/controller/class.PagingController.php");
20 require_once(BASE."wcmf/lib/persistence/class.PersistenceFacade.php");
21 require_once(BASE."wcmf/lib/model/class.NodeUtil.php");
22 
23 /**
24  * @class NodeListController
25  * @ingroup Controller
26  * @brief NodeListController is a controller that loads nodes of a given type
27  * and displays the result in a list.
28  *
29  * <b>Input actions:</b>
30  * - unspecified: List Nodes
31  *
32  * <b>Output actions:</b>
33  * - see PagingController
34  *
35  * @param[in,out] type The type of node to list
36  * @param[in,out] pageSize The number of nodes to display on one tab page (optional, default: 5)
37  *
38  * @author ingo herwig <ingo@wemove.com>
39  */
41 {
42  /**
43  * @see Controller::initialize()
44  */
45  function initialize(&$request, &$response)
46  {
47  parent::initialize($request, $response);
48 
49  // store the paging size in the session
50  $pageSize = $this->getLength();
51  if (intval($request->getValue('pageSize')) > 0 && $request->getValue('pageSize') != $pageSize)
52  {
53  $pageSize = $request->getValue('pageSize');
54  $session = &SessionData::getInstance();
55  $session->set($this->getSessionPrefix().'pagesize', $pageSize);
56  $this->reset();
57  }
58  }
59  /**
60  * @see Controller::validate()
61  */
62  function validate()
63  {
64  if(!PersistenceFacade::isKnownType($this->_request->getValue('type')))
65  {
66  $this->setErrorMsg("No valid 'type' given in data.");
67  return false;
68  }
69  return parent::validate();
70  }
71  /**
72  * @see PagingController::getOIDs()
73  */
74  function getOIDs()
75  {
76  $oids = array();
77 
78  $persistenceFacade = &PersistenceFacade::getInstance();
79  $oids = &$persistenceFacade->getOIDs($this->_request->getValue('type'));
80 
81  return $oids;
82  }
83  /**
84  * @see PagingController::getDisplayText()
85  */
86  function getDisplayText(&$node)
87  {
88  return strip_tags(preg_replace("/[\r\n']/", " ", NodeUtil::getDisplayValue($node)));
89  }
90  /**
91  * @see PagingController::modifyModel()
92  */
93  function modifyModel(&$nodes)
94  {
96  }
97  /**
98  * @see PagingController::getLength()
99  */
100  function getLength()
101  {
102  // 1. return a value that is already stored in the session
103  $sessionVarName = $this->getSessionPrefix().'pagesize';
104  $session = &SessionData::getInstance();
105  if ($session->exist($sessionVarName))
106  return $session->get($sessionVarName);
107 
108  // 2. return the currently requested value
109  if (intval($this->_request->getValue('pageSize')) > 0)
110  $pageSize = $this->_request->getValue('pageSize');
111 
112  // 3. return the default value
113  return 5;
114  }
115  /**
116  * @see Controller::executeKernel()
117  */
118  function executeKernel()
119  {
120  $this->_response->setValue('type', $this->_request->getValue('type'));
121  $this->_response->setValue('pageSize', $this->_request->getValue('pageSize'));
122 
123  return parent::executeKernel();
124  }
125  /**
126  * Get the sesson varname prefix depending on parent and child type.
127  * @return The prefix
128  */
129  function getSessionPrefix()
130  {
131  return 'NodeListController.'.$this->_request->getValue('type').'.';
132  }
133 }
134 ?>
setSortProperties(&$nodeList)
PagingController is a controller that allows to navigate lists.
NodeListController is a controller that loads nodes of a given type and displays the result in a list...
initialize(&$request, &$response)
getDisplayValue(&$node, $useDisplayType=false, $language=null, $values=null)