22 require_once(BASE.
"wcmf/lib/presentation/class.Controller.php");
23 require_once(BASE.
"wcmf/lib/presentation/class.ActionMapper.php");
90 $data = &$this->_request->getValue(
'data');
91 foreach($data as $key => $value)
93 if (!is_array($value))
95 $this->
setErrorMsg(
"Data should be an associative array of action definition arrays.");
118 $data = &$this->_request->getValue(
'data');
119 $actions = array_keys($data);
120 $numActions =
sizeof($actions);
121 $exceptions = array();
122 for($i=0; $i<$numActions; $i++)
124 $action = $actions[$i];
138 'TerminateController',
139 $data[$action][
'context'],
140 $data[$action][
'usr_action'],
143 $request->setFormat(
'Null');
144 $request->setResponseFormat($this->_request->getResponseFormat());
154 if ($response == null) {
155 $response =
new Response(
'',
'', $action, array());
156 $response->setFormat($request->getResponseFormat());
157 $requestData = $request->getData();
158 foreach ($requestData as $key => $value) {
159 $response->setValue($key, $value);
162 $response->setValue(
'success',
false);
164 $response->setValue(
'errorMessage', $ex->getMessage());
167 catch (Exception $ex)
174 $results[$action] = &$response->getData();
181 if (
sizeof($exceptions) > 0) {
182 $ex = $exceptions[0];
183 $this->_response->setValue(
'success',
false);
184 $this->_response->setValue(
'errorCode', $ex->getCodeString());
185 $this->_response->setValue(
'errorMessage', $ex->getMessage());
187 $this->_response->setValue(
'data', $results);
188 $this->_response->setAction(
'ok');
199 $keys = array_keys($data);
200 for($i=0; $i<
sizeof($keys); $i++)
203 $value = $data[$key];
210 if ($key != $newKey || $value != $newValue)
215 Log::debug(
"Replace $key by $newKey", __CLASS__);
216 if ($value != $newValue)
217 Log::debug(
"Replace $value by $newValue", __CLASS__);
220 $data[$newKey] = $newValue;
233 preg_match_all(
'/\{([^\{]+)\}/', $value, $variableMatches);
234 $variables = $variableMatches[1];
235 foreach($variables as $variable)
237 preg_match(
'/^([^:]+)[:]*(.*)$/', $variable, $matches);
238 if (
sizeof($matches > 0))
240 $variableName = $matches[1];
241 $parameters = $matches[2];
244 if ($variableName ==
'last_created_oid')
250 $oid = $persistenceFacade->getLastCreatedOID($type);
251 $value = preg_replace(
"/{".$variable.
"}/", $oid, $value);
258 $type = $variableName;
260 $oid = $persistenceFacade->getLastCreatedOID($type);
error($message, $category)
debug($message, $category)
& processAction(&$request)
MultipleActionController is a controller that executes multiple actions by passing them do the approp...
Request holds the request values that are used as input to Controller instances. It is typically inst...
Controller is the base class of all controllers. If a Controller has a view it is expected to reside ...
isDebugEnabled($category)
replaceVariablesString($value)
Response holds the response values that are used as output from Controller instances. It is typically instantiated by the ActionMapper instance and filled during Controller execution.