function processCreate($nextStep = null) { try { $this->fillFromRequest(); $this->validateForDB(); } catch (\SimplOn\ElementValidationException $ev) { $data = array(); foreach ($ev->datasValidationMessages() as $key => $value) { $data[] = array('func' => 'showValidationMessages', 'args' => array($key, $value[0])); } $return = array('status' => true, 'type' => 'commands', 'data' => $data); echo json_encode($return); return; } try { if ($this->create()) { if (empty($nextStep)) { $data = array(array('func' => 'redirectNextStep', 'args' => array($this->encodeURL(array($this->getId())) . '!showAdmin'))); $return = array('status' => true, 'type' => 'commands', 'data' => $data); echo json_encode($return); return; } else { if (substr($nextStep, -1 * strlen('makeSelection')) == 'makeSelection') { header('Location: ' . $nextStep . '/' . $this->getId() . '/"' . Main::fixCode(strtr(urlencode($this->getClass()), '\\', '-')) . '"'); return; } else { $data = array(array('func' => 'redirectNextStep', 'args' => $nextStep)); $return = array('status' => true, 'type' => 'commands', 'data' => $data); echo json_encode($return); return; } } } else { // @todo: error handling user_error('Cannot update in DS!', E_USER_ERROR); } } catch (\PDOException $ev) { //user_error($ev->errorInfo[1]); //@todo handdle the exising ID (stirngID) in the DS user_error($ev); } }
static function decodeURL() { $string_delimiter = '"'; $server_request = urldecode(substr($_SERVER['REQUEST_URI'], strlen(self::$REMOTE_ROOT))); $qs = self::$URL_METHOD_SEPARATOR; $sd = $string_delimiter; $offset = 0; $parameterDecoder = function ($what, $encapsulated = false) use($sd, $qs, $server_request, &$offset) { $regexes = array('class' => '\\/ (?<raw>[^' . $sd . $qs . '\\/]+) ', 'construct_params' => '(?:\\/(?: (?<raw>[^' . $sd . $qs . '\\/]+) | ' . $sd . '(?<string>[^' . $sd . ']*)' . $sd . ' ))', 'dataName' => '\\/?' . $qs . ' (?<raw>[^' . $sd . $qs . '\\/]+) (?=' . $qs . ')', 'method' => '\\/?' . $qs . ' (?<raw>[^' . $sd . $qs . '\\/]+) ', 'method_params' => '(?:\\/(?: (?<raw>[^' . $sd . $qs . '\\/]+) | ' . $sd . '(?<string>[^' . $sd . ']*)' . $sd . ' ))'); if (preg_match('/^' . $regexes[$what] . '/x', substr($server_request, $offset), $matches, PREG_OFFSET_CAPTURE)) { $offset += $matches[0][1] + strlen($matches[0][0]); $raw = @$matches['raw'][0]; $string = @$matches['string'][0]; if (empty($raw) && empty($string)) { $return = ''; } else { if (!empty($raw) && empty($string)) { if ($raw == 'null') { $return = null; } else { if ($raw == 'false') { $return = array(false); } else { if (is_numeric($raw)) { $return = floatval($raw) == intval($raw) ? intval($raw) : floatval($raw); } else { $return = $raw; } } } } else { if (empty($raw) && !empty($string)) { $return = urldecode(\SimplOn\Main::fixCode($string, false)); } } } return $encapsulated ? array($return) : $return; } else { return false; } }; self::$class = strtr($parameterDecoder('class'), '-', '\\') ?: Main::$DEFAULT_ELEMENT; self::$construct_params = array(); while (($param = $parameterDecoder('construct_params', true)) !== false) { self::$construct_params[] = $param[0]; } self::$dataName = $parameterDecoder('dataName'); self::$method = $parameterDecoder('method') ?: Main::$DEFAULT_METHOD; self::$method_params = array(); while (($param = $parameterDecoder('method_params', true)) !== false) { self::$method_params[] = $param[0]; } }