defaultAction(); return; } $methodName = "{$task}Action"; if (method_exists($this, $methodName)) { $this->{$methodName}(); } else { die("Task '{$task}' not exists"); } } public function defaultAction() { die("default task not implemented"); } public function getLink($task = '', $args = null) { $clsName = get_class($this); if ('Route_' != substr($clsName, 0, strlen('Route_'))) throw new Exception("Wrong route class name '{$clsName}'"); $routeName = substr($clsName, strlen('Route_')); if (empty($args)) return Request::getPathUri() . "index.php?_route={$routeName}" . (!empty($task) ? "&_task={$task}" : ""); if (is_string($args)) { return Request::getPathUri() . "index.php?_route={$routeName}" . (!empty($task) ? "&_task={$task}" : "") . ltrim($args, '&'); } if (is_array($args)) { $urlArgs = []; $uniqArgs = []; if (!empty($task)) $uniqArgs['_task'] = $task; foreach ($args as $name => $val) $uniqArgs[$name] = $val; foreach ($uniqArgs as $name => $val) $urlArgs[] = "{$name}={$val}"; return Request::getPathUri() . "index.php?_route={$routeName}" . (!empty($urlArgs) ? '&' . implode('&', $urlArgs) : ''); } throw new Exception("Not Implemented args type", 501); } public function runTask($task) { if (empty($task)) throw new Exception("Empty method name"); $methodName = "{$task}Action"; if (!method_exists($this, $methodName)) { throw new Exception("Task '{$task}' not exists"); } $this->{$methodName}(); } public function runMethod($methodName) { if (empty($methodName)) throw new Exception("Empty method name"); if (!method_exists($this, $methodName)) { throw new Exception("Task '{$methodName}' not exists"); } $this->{$methodName}(); } public function parseMessageFromStorageTestAction() { $msgs = V::get('msgs', '', $_GET); //echo $this->parseMessageFromStorage($msg); Lib::loadClass('StorageException'); if (is_array($msgs)) { foreach ($msgs as $vMsg) { try { throw new StorageException($vMsg); } catch (Exception $e) { $vParsedMsg = $e->getMessage(); echo " MSG: {$vMsg}\n"; echo "PARSED: {$vParsedMsg}\n"; echo "isMsgParsed(" . ($vMsg != $vParsedMsg) . ")\n\n"; } } } else { throw new StorageException($msgs); } echo "\n\n"; die("parseMessageFromStorage end"); } public function parseMessageFromStorage($msg) { return $msg; } public function parseMessageFromMsgsSystem($msg) { return $msg; } public function runByMessageFromMsgsSystem($msg, & $execNotes) { } public function handleAuth() { User::authByRequest(); } public function reinstall() { $clsName = get_class($this); if ('Route_UrlAction' == substr($clsName, 0, strlen('Route_UrlAction'))) { $actionName = substr($clsName, strlen('Route_UrlAction_')); DBG::log(['msg'=>"\$actionName", '$actionName'=>$actionName]); $idTypespecial = DB::getPDO()->fetchValue(" select z.ID from CRM_LISTA_ZASOBOW z where z.`TYPE` = 'TYPESPECIALS' "); if (!$idTypespecial) { $idTypespecial = DB::getPDO()->insert('CRM_LISTA_ZASOBOW', [ 'TYPE' => 'TYPESPECIALS', 'DESC' => 'TYPESPECIALS', 'DESC_PL' => 'Powiązania tabel', 'OPIS' => 'Powiązania i relacje tabel do wyświetlania w funkcjach systemowych', ]); } DBG::log(['msg'=>"\$idTypespecial", '$idTypespecial'=>$idTypespecial]); if (!$idTypespecial) throw new Exception("Wystąpił błąd podczas tworzenia zasobu 'Powiązania tabel' (TYPESPECIALS)"); $idAction = DB::getPDO()->fetchValue(" select z.ID from CRM_LISTA_ZASOBOW z where z.`PARENT_ID` = {$idTypespecial} and z.`DESC` = '{$actionName}' "); if (!$idAction) { $idAction = DB::getPDO()->insert('CRM_LISTA_ZASOBOW', [ 'PARENT_ID' => $idTypespecial, 'TYPE' => 'URL_ACTION', 'DESC' => $actionName, 'DESC_PL' => $this->getActionLabel(), 'OPIS' => $this->getActionDescription(), ]); } DBG::log(['msg'=>"\$idAction", '$idAction'=>$idAction]); if (!$idAction) throw new Exception("Wystąpił błąd podczas tworzenia zasobu funkcji '{$actionName}' (URL_ACTION)"); $args = $this->getActionArgs(); foreach ($args as $argName => $argDesc) { $idArg = DB::getPDO()->fetchValue(" select z.ID from CRM_LISTA_ZASOBOW z where z.`PARENT_ID` = {$idAction} and z.`TYPE` = 'PARAM_IN' and z.`DESC` = '{$argName}' "); if (!$idArg) { $idArg = DB::getPDO()->insert('CRM_LISTA_ZASOBOW', [ 'PARENT_ID' => $idAction, 'TYPE' => 'PARAM_IN', 'DESC' => $argName, 'OPIS' => $argDesc, ]); } DBG::log(['msg'=>"\$idArg ('{$argName}')", '$idArg'=>$idArg]); if (!$idArg) throw new Exception("Wystąpił błąd podczas tworzenia zasobu dla argumentu funkcji '{$actionName}' '{$argName}' (PARAM_IN)"); } } } public function getActionLabel() { return ""; } public function getActionDescription() { return ""; } public function getActionArgs() { return []; } }