Commit 730162f7 authored by Carsten  Rose's avatar Carsten Rose
Browse files

HelperFormElement: new created

parent 3eb33091
<?php
/**
* Created by PhpStorm.
* User: crose
* Date: 1/26/16
* Time: 11:25 AM
*/
namespace qfq;
use qfq;
use qfq\Store;
use qfq\exceptions\UserException;
require_once(__DIR__ . '/../../qfq/store/Store.php');
require_once(__DIR__ . '/../../qfq/Constants.php');
require_once(__DIR__ . '/../../qfq/helper/KeyValueStringParser.php');
require_once(__DIR__ . '/../../qfq/exceptions/UserException.php');
class HelperFormElement {
/**
* Iterates over all FormElements in $elements.
* If $element['parameter'] exist and is filled: explode the content and apend them to the current FormElement Array.
*
* @param array $elements
* @throws UserException
*/
public static function explodeParameter(array &$elements) {
// Iterate all FormElements
foreach ($elements AS $key => $element) {
// Something to explode?
if (isset($element['parameter']) && $element['parameter'] !== '') {
// Explode
$arr = KeyValueStringParser::parse($element['parameter'], "=", "\n");
// Check if some of the exploded keys conflict with existing keys
$checkKeys = array_keys($arr);
foreach ($checkKeys AS $checkKey) {
if (isset($element[$checkKey])) {
$store = Store::getInstance();
$store->setVar(SYSTEM_FORM_ELEMENT, $element['name'] . ' / ' . $element['id'], STORE_SYSTEM);
$store->setVar(SYSTEM_FORM_ELEMENT_COLUMN, 'parameter', STORE_SYSTEM);
throw new UserException("Found reserved keyname '$checkKey'");
}
}
$elements[$key] = array_merge($element, $arr);
}
}
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment