wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
class.HTMLFormat.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.HTMLFormat.php 1462 2014-02-04 23:52:27Z iherwig $
18  */
19 require_once(BASE."wcmf/lib/presentation/format/class.AbstractFormat.php");
20 
21 /**
22  * @class HTMLFormat
23  * @ingroup Format
24  * @brief HTMLFormat realizes the HTML request/response format. Since all data
25  * from the external representation arrives in form fields, grouping of values
26  * has to be done via the field names. So Nodes are represented by their values
27  * whose field names are of the form value-<datatype>-<name>-<oid>. All of these
28  * values will be removed from the request and replaced by Node instances
29  * representing the data. The each node is stored under its oid in the data array.
30  *
31  * @author ingo herwig <ingo@wemove.com>
32  */
34 {
35  /**
36  * @see IFormat::deserialize()
37  */
38  function deserialize(&$request)
39  {
40  // construct nodes from values serialized as form fields
41  // nodes are encoded in separated fields with names value-<datatype>-<name>-<oid>
42  $data = &$request->getData();
43  $nodeValues = array();
44  foreach ($data as $key => $value)
45  {
47  if ($valueDef != null && strlen($valueDef['oid']) > 0)
48  {
49  $node = &$this->getNode($valueDef['oid']);
50  $node->setValue($valueDef['name'], $value, $valueDef['dataType']);
51  array_push($nodeValues, $key);
52  }
53  }
54 
55  // replace node values by nodes
56  foreach ($nodeValues as $key)
57  $request->clearValue($key);
58  $deserializedNodes = $this->getNodes();
59  foreach (array_keys($deserializedNodes) as $oid)
60  $request->setValue($oid, $deserializedNodes[$oid]);
61  }
62  /**
63  * @see IFormat::serialize()
64  */
65  function serialize(&$response)
66  {
67  // assign the data to the view if one exists
68  if (($view = &$response->getView()) != null)
69  {
70  $data = &$response->getData();
71  foreach (array_keys($data) as $variable)
72  {
73  if (is_scalar($data[$variable]))
74  $view->assign($variable, $data[$variable]);
75  else
76  $view->assign_by_ref($variable, $data[$variable]);
77  }
78  }
79  }
80 }
81 ?>
AbstractFormat maybe used as base class for specialized formats.
HTMLFormat realizes the HTML request/response format. Since all data from the external representation...
deserialize(&$request)
serialize(&$response)
getValueDefFromInputControlName($name)