From 1fd022c0c69693ee05bfea66b62e73ba2e76012e Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 28 May 2024 16:22:42 -0400 Subject: [PATCH] major update --- mocha-php/src/mocha-php/images/logo-error.svg | 23 ++ .../include/BeforeLaunchEvent.inc.php | 27 +- .../src/mocha-php/include/mochacommon.inc.php | 19 +- .../mocha/core/KnownAttributeGuids.inc.php | 4 +- .../lib/mocha/core/KnownInstanceGuids.inc.php | 4 + .../mocha/core/KnownRelationshipGuids.inc.php | 4 +- .../lib/mocha/core/OmsContext.inc.php | 85 +++-- .../src/mocha-php/lib/mocha/oms/Oms.inc.php | 74 ++++- ...ectInstanceSetMethodImplementation.inc.php | 55 ++++ ...leanExpressionMethodImplementation.inc.php | 62 +++- ...ySystemRoutineMethodImplementation.inc.php | 41 ++- ...RelatedUpdatesMethodImplementation.inc.php | 1 + .../ui/renderers/html/HTMLRenderer.inc.php | 203 +++++++----- .../ui/renderers/html/HTMLRenderer.js.php | 23 +- .../mocha-php/themes/avondale/uwt-menu.less | 15 +- .../themes/common/styles/uwt-combobox.less | 34 ++ .../themes/common/styles/uwt-menu.less | 34 +- .../mocha-php/themes/common/styles/uwt.less | 1 + .../ui/pages/AttachmentPage.phpx.php | 2 + .../src/mocha-php/ui/pages/InstancePage.phpx | 2 - .../mocha-php/ui/pages/InstancePage.phpx.php | 58 +++- .../src/mocha-php/ui/pages/LoginPage.phpx.php | 10 +- .../ui/pages/RelatedTaskListPage.phpx.php | 4 +- mocha-php/src/mocha-php/ui/pages/SUVPage.phpx | 2 +- .../src/mocha-php/ui/pages/SUVPage.phpx.php | 310 ++++++++++++++++-- 25 files changed, 888 insertions(+), 209 deletions(-) create mode 100644 mocha-php/src/mocha-php/images/logo-error.svg create mode 100644 mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/ConditionalSelectInstanceSetMethodImplementation.inc.php create mode 100644 mocha-php/src/mocha-php/themes/common/styles/uwt-combobox.less diff --git a/mocha-php/src/mocha-php/images/logo-error.svg b/mocha-php/src/mocha-php/images/logo-error.svg new file mode 100644 index 0000000..b7e7111 --- /dev/null +++ b/mocha-php/src/mocha-php/images/logo-error.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mocha-php/src/mocha-php/include/BeforeLaunchEvent.inc.php b/mocha-php/src/mocha-php/include/BeforeLaunchEvent.inc.php index bae09f0..3217ada 100644 --- a/mocha-php/src/mocha-php/include/BeforeLaunchEvent.inc.php +++ b/mocha-php/src/mocha-php/include/BeforeLaunchEvent.inc.php @@ -1,5 +1,7 @@ IncludeTopNavigationBar = false; + $html->renderBeginErrorPage("Tenant not found", "Tenant not found"); + echo ("

The specified tenant does not exist or is not available.

"); + echo ("

We apologize for the inconvenience. If you are a MochaPowered customer and require additional assistance please contact the Designated Support Contact within your organization. Otherwise, please check back later.

"); + $html->renderEndErrorPage(); return false; } else { $oms->setTenant($currentTenant); + if (count($path) == 1) + { + System::Redirect("~/" . $path[0] . "/d/home.htmld", true); + return false; + } } return true; }; diff --git a/mocha-php/src/mocha-php/include/mochacommon.inc.php b/mocha-php/src/mocha-php/include/mochacommon.inc.php index f223d6b..12656ef 100644 --- a/mocha-php/src/mocha-php/include/mochacommon.inc.php +++ b/mocha-php/src/mocha-php/include/mochacommon.inc.php @@ -4,7 +4,9 @@ use Mocha\Core\InstanceReference; use Mocha\Core\KnownAttributeGuids; use Mocha\Core\KnownInstanceGuids; use Mocha\Core\KnownRelationshipGuids; +use Mocha\Core\OmsContext; use Mocha\Oms\MySQLDatabaseOms; +use Mocha\UI\Renderers\HTML\HTMLRenderer; use Phast\System; function mocha_asset_get_physical_path($package, $version, $path) @@ -28,9 +30,24 @@ function mocha_get_oms() return $_SESSION["OMS"]; */ global $oms; + if ($oms === null) { - $oms = new MySQLDatabaseOms(System::GetConfigurationValue("Database.ServerName"), System::GetConfigurationValue("Database.PortNumber"), System::GetConfigurationValue("Database.DatabaseName"), System::GetConfigurationValue("Database.UserName"), System::GetConfigurationValue("Database.Password")); + try + { + $oms = new MySQLDatabaseOms(System::GetConfigurationValue("Database.ServerName"), System::GetConfigurationValue("Database.PortNumber"), System::GetConfigurationValue("Database.DatabaseName"), System::GetConfigurationValue("Database.UserName"), System::GetConfigurationValue("Database.Password")); + } + catch (\PDOException $ex) + { + $ctx = new OmsContext(); + $html = new HTMLRenderer($ctx, true); + $html->IncludeTopNavigationBar = false; + $html->renderBeginErrorPage("Mocha is currrently unavailable", "We are experiencing a service interruption"); + echo ("

Your service will be restored as quickly as possible.

"); + echo ("

We apologize for the inconvenience. If you are a MochaPowered customer and require additional assistance please contact the Designated Support Contact within your organization. Otherwise, please check back later.

"); + $html->renderEndErrorPage(); + die(); + } } $oms->setCurrentUser(mocha_get_current_user()); return $oms; diff --git a/mocha-php/src/mocha-php/lib/mocha/core/KnownAttributeGuids.inc.php b/mocha-php/src/mocha-php/lib/mocha/core/KnownAttributeGuids.inc.php index 457613c..4a750a3 100644 --- a/mocha-php/src/mocha-php/lib/mocha/core/KnownAttributeGuids.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/core/KnownAttributeGuids.inc.php @@ -15,6 +15,8 @@ class KnownAttributeGuids const Order = "{49423f66-8837-430d-8cac-7892ebdcb1fe}"; const MethodType = "{47ae57a9-7723-48a8-80f2-dd410d929e14}"; + const EvaluateWorkSet = "{62c28f9e-5ce8-4ce5-8a56-1e80f1af7f6a}"; + const ClassName = "c7e8d78ecfac4dacae242ac67a0ba9d3"; const ThemeName = "{8cfc012c-52fd-4a66-8b2f-1b9b5e4af474}"; @@ -25,7 +27,7 @@ class KnownAttributeGuids const TargetURL = "970F79A09EFE4E7D92869908C6F06A67"; - const UserName = "960FAF025C5940F791A720012A99D9ED"; + const UserName = "{960faf02-5c59-40f7-91a7-20012a99d9ed}"; const PasswordHash = "F377FC294DF14AFB96434191F37A00A9"; const PasswordSalt = "8C5A99BC40ED4FA2B23FF373C1F3F4BE"; diff --git a/mocha-php/src/mocha-php/lib/mocha/core/KnownInstanceGuids.inc.php b/mocha-php/src/mocha-php/lib/mocha/core/KnownInstanceGuids.inc.php index d503a9a..f34aced 100644 --- a/mocha-php/src/mocha-php/lib/mocha/core/KnownInstanceGuids.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/core/KnownInstanceGuids.inc.php @@ -71,8 +71,12 @@ class KnownInstanceGuids const WorkSet__RelatedInstance = "{d9634929-0bb4-482a-85cc-9c8f1251556f}"; const WorkSet_ClassForMethod = "{d8eeff45-acbc-4031-8b09-bf9b8085c185}"; const WorkSet__TaskRelatedInstance = "{d3860252-491e-469e-939e-702d56d88063}"; + const WorkSet__ClassOfInstanceToCreate = "{1f1170ac-ee7e-405c-99bb-b922f3d598fa}"; const SystemAttributeRoutine_GetGlobalIdentifier = "{1a7ebec3-dc02-4c9b-a5df-0c72646453c9}"; const SystemAttributeRoutine_GetInstanceText = "{b024abd6-1f2b-495a-9da3-c9ce29fb0c2f}"; + + const SystemInstanceSetRoutine_CreateInstance = "{f46135f6-e812-49e6-9755-d63eb6ef1305}"; + const SystemInstanceSetRoutine_GetUserForUserNameParm = "{430f572d-d116-4b04-97b2-65a9e9230ce5}"; } ?> \ No newline at end of file diff --git a/mocha-php/src/mocha-php/lib/mocha/core/KnownRelationshipGuids.inc.php b/mocha-php/src/mocha-php/lib/mocha/core/KnownRelationshipGuids.inc.php index 574efee..4dc1136 100644 --- a/mocha-php/src/mocha-php/lib/mocha/core/KnownRelationshipGuids.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/core/KnownRelationshipGuids.inc.php @@ -227,7 +227,9 @@ class KnownRelationshipGuids const Integration_ID_Usage__for__Integration_ID = "d8d981ec768640dab89f006c85042444"; const Conditional_Select_from_Instance_Set_Method__has__Conditional_Select_from_Instance_Set_Case = "b6715132b4384073b81d3ecf19584b7d"; - const Conditional_Select_from_Instance_Set_Case__for__Conditional_Select_from_Instance_Set_Method = "1c868a068fb7432d839b7a5a02a50eb6"; + const Conditional_Select_from_Instance_Set_Case__invokes__Executable_returning_Instance_Set = "{8fde1baa-ce2e-4245-a775-bc4c66eac7b5}"; + + const Conditional_Select_from_Instance_Set_Method__returns__Work_Set = "{49396bd0-b5a9-4384-99f4-2126d80b3b66}"; const Condition_Group__has_true_condition__Executable_returning_Attribute = "d955da3f7ef443748b86167c73434f75"; const Executable_returning_Attribute__true_condition_for__Condition_Group = "1acdefd1e1b445bb99e1bf73dea71da5"; diff --git a/mocha-php/src/mocha-php/lib/mocha/core/OmsContext.inc.php b/mocha-php/src/mocha-php/lib/mocha/core/OmsContext.inc.php index 0b73757..deb8739 100644 --- a/mocha-php/src/mocha-php/lib/mocha/core/OmsContext.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/core/OmsContext.inc.php @@ -38,49 +38,88 @@ } return $defaultValue; } - public function setWorkData(string|InstanceReference $parmId, $value) + public function setWorkData(InstanceReference|string|InstanceKey|array $parm, $value) { /** * @var \Mocha\Oms\MySQLDatabaseOms */ $oms = mocha_get_oms(); - $key = $parmId; - if ($key instanceof InstanceReference) + // "Work Data" are .. "smart" variables + // They can be restricted to a set of "valid classes" (via `Work Data.has valid Class`) + // They could potentially also do a whole bunch of other validations if we want them to + + $parm = $oms->normalizeInstanceReference($parm); + $key = $parm->GlobalIdentifier->__toString(); + + // When setting a Work Data, first check to make sure the passed-in value is appropriate + // for the given Work Data. If the Work Data is a Work Set, check to make sure the value + // is indeed an InstanceReference, and that its parent class is in the selection list of + // `Work Set.has valid Class` for the given Work Set. + + $expectedDataType = ""; + $actualDataType = ""; + if (!$oms->validateWorkDataType($parm, $value, $expectedDataType, $actualDataType)) { - $key = $key->GlobalIdentifier->__toString(); - if ($value === null) + $printBacktrace = false; + trigger_error("invalid work data (expected: " . $expectedDataType . ", got: " . $actualDataType . " [ " . $value . " ] " . ") for attribute " . $parm->InstanceKey . " @ " . $parm->GlobalIdentifier); + if ($printBacktrace) { - //echo ("[ set wd " . $parmId->InstanceKey->__toString() . " = null ]"); + debug_print_backtrace(); } - else + } + + // Now here's where we start fudging things... If the Work Data is a Work Set, and the + // value is a Class, AND the Work Set valid classes DOES NOT include `Class`, THEN we + // should *evaluate* the Class value *as a work set* and see if THAT value is of a class + // valid for the Work Set. This should only happen once. If we are satisfied, assign THAT + // value to the given Work Set and we're all good. + if ($oms->is_a($parm, KnownClassGuids::WorkSet)) + { + $Valid_Classes_for_Work_Set = $oms->getRelatedInstances($parm, KnownRelationshipGuids::Work_Set__has_valid__Class); + if ($oms->is_a($value, KnownClassGuids::Clasz)) { - if (is_string($value)) + if (!$oms->instanceSetContains($Valid_Classes_for_Work_Set, KnownClassGuids::Clasz)) { - //echo ("[ set wd " . $parmId->InstanceKey . " = STR'" . $value . "' ]"); + $Evaluated_Value_for_Class = $this->getWorkData($value); + if ($Evaluated_Value_for_Class !== null) + { + $pclass = $oms->getParentClass($Evaluated_Value_for_Class); + + if ($oms->instanceSetContains($Valid_Classes_for_Work_Set, $pclass)) + { + $value = $Evaluated_Value_for_Class; + echo ("Work Set evaluated for class OK"); + } + else + { + echo ("Evaluated value for Class not valid for Work Set "); + } + } + else + { + // echo ("Evaluated value for Class was null! "); + } } else { - //echo ("[ set wd " . $parmId->InstanceKey . " = IK'" . $value->InstanceKey . "' ]"); + echo ("Valid Classes for Work Set contains Class"); } } - - $expectedDataType = ""; - $actualDataType = ""; - if (!$oms->validateWorkDataType($parmId, $value, $expectedDataType, $actualDataType)) - { - //echo("invalid work data (expected: " . $expectedDataType . ", got: " . $actualDataType . ") for attribute " . $parmId->InstanceKey . " @ " . $parmId->GlobalIdentifier); - } } + $this->workData[$key] = $value; } - public function getWorkData(string|InstanceReference $parmId, $defaultValue = null) + public function getWorkData(InstanceReference|string|InstanceKey|array $parmId, $defaultValue = null) { - $key = $parmId; - if ($key instanceof InstanceReference) - { - $key = $key->GlobalIdentifier->__toString(); - } + /** + * @var \Mocha\Oms\MySQLDatabaseOms + */ + $oms = mocha_get_oms(); + + $parmId = $oms->normalizeInstanceReference($parmId); + $key = $parmId->GlobalIdentifier->__toString(); + if (array_key_exists($key, $this->workData)) { return $this->workData[$key]; diff --git a/mocha-php/src/mocha-php/lib/mocha/oms/Oms.inc.php b/mocha-php/src/mocha-php/lib/mocha/oms/Oms.inc.php index a76d72b..4606f08 100644 --- a/mocha-php/src/mocha-php/lib/mocha/oms/Oms.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/oms/Oms.inc.php @@ -29,6 +29,8 @@ $this->MethodImplementations = null; } + public abstract function getUserByUserName(string $username) : ?InstanceReference; + private function registerMethodImplementation(InstanceReference|string|InstanceKey $methodImplementationClass, MethodImplementation $implementation) { $methodImplementationClass = $this->normalizeInstanceReference($methodImplementationClass); @@ -39,6 +41,7 @@ { $this->registerMethodImplementation(KnownClassGuids::BuildAttributeMethod, new \Mocha\Oop\MethodImplementations\BuildAttributeMethodImplementation()); $this->registerMethodImplementation(KnownClassGuids::ConditionalSelectAttributeMethod, new \Mocha\Oop\MethodImplementations\ConditionalSelectAttributeMethodImplementation()); + $this->registerMethodImplementation(KnownClassGuids::ConditionalSelectFromInstanceSetMethod, new \Mocha\Oop\MethodImplementations\ConditionalSelectInstanceSetMethodImplementation()); $this->registerMethodImplementation(KnownClassGuids::EvaluateBooleanExpressionMethod, new \Mocha\Oop\MethodImplementations\EvaluateBooleanExpressionMethodImplementation()); $this->registerMethodImplementation(KnownClassGuids::GetAttributeBySystemRoutineMethod, new \Mocha\Oop\MethodImplementations\GetAttributeBySystemRoutineMethodImplementation()); $this->registerMethodImplementation(KnownClassGuids::GetAttributeMethod, new \Mocha\Oop\MethodImplementations\GetAttributeMethodImplementation()); @@ -373,8 +376,9 @@ echo ($this->getInstanceKeysString($instanceReferences, $separator)); } - public function instanceSetContains(array /**/ $haystack, InstanceReference $needle) + public function instanceSetContains(array /**/ $haystack, InstanceReference|string|InstanceKey|UUID $needle) { + $needle = $this->normalizeInstanceReference($needle); foreach ($haystack as $v) { if ($v->DatabaseId == $needle->DatabaseId) @@ -528,7 +532,7 @@ // loop through all valid classes and check them foreach ($workDataHasValidClasses as $validClass) { - if ($this->is_a($instWorkData, $validClass)) + if ($this->is_a($value, $validClass)) { $expectedTypeName = $this->getAttributeValue($validClass, KnownAttributeGuids::Name); // our work set declares a valid class, and it passes @@ -536,7 +540,7 @@ } } // none of the valid classes pass validation for $instWorkData - $actualTypeName = $this->getAttributeValue($this->getParentClass($instWorkData), KnownAttributeGuids::Name); + $actualTypeName = $this->getAttributeValue($this->getParentClass($value), KnownAttributeGuids::Name); $expectedTypeName = $this->getAttributeValue($validClass, KnownAttributeGuids::Name); return false; } @@ -544,6 +548,17 @@ // this work set doesn't care whether or not $instWorkData passes validation return true; } + else if ($this->is_a($instWorkData, KnownClassGuids::Clasz)) + { + // Work Data is a Class, so make sure the value is of that class + if (!$this->is_a($value, $instWorkData)) + { + $actualTypeName = $this->getAttributeValue($this->getParentClass($value), KnownAttributeGuids::Name); + $expectedTypeName = $this->getAttributeValue($instWorkData, KnownAttributeGuids::Name); + return false; + } + return true; + } // we are not a work set, so we can't validate anything return true; @@ -602,7 +617,11 @@ private function createHtmlLinkToInstanceReference($val) { - return "InstanceKey . ".htmld") . "\">" . $val->InstanceKey->__toString() . ""; + if ($val === null) + { + return ""; + } + return "InstanceKey . ".htmld") . "\">" . $val->InstanceKey . ""; } public function getStackTraceWithLinks(array $arr) { @@ -634,7 +653,8 @@ $value = $this->execute($context, $inst); if ($value !== null) { - return $context->getWorkData($value); + $val = $context->getWorkData($value); + return $val; } return null; } @@ -672,7 +692,7 @@ { $this->applyParameterAssignment($context, $parameterAssignment); } - + /* if (is_array(value: $parms)) { foreach ($parms as $gid => $value) @@ -680,7 +700,7 @@ $context->setWorkData($gid, $value); } } - + */ // echo ("MB stack: " . $methodInstance->InstanceKey . ":" . $methodBindingExecutesMethod->InstanceKey); $retval = $this->execute($context, $methodBindingExecutesMethod, $parms); } @@ -706,9 +726,10 @@ public function applyParameterAssignment(OmsContext $context, InstanceReference $parameterAssignment) { + $evaluateWorkData = $this->getAttributeValue($parameterAssignment, KnownAttributeGuids::EvaluateWorkSet, false); $assignsFromWorkData = $this->getRelatedInstance($parameterAssignment, KnownRelationshipGuids::Parameter_Assignment__assigns_from__Executable_returning_Work_Data); $assignsToParm = $this->getRelatedInstance($parameterAssignment, KnownRelationshipGuids::Parameter_Assignment__assigns_to__Work_Data); - + if ($assignsFromWorkData !== null && $assignsToParm !== null) { $workData = $this->execute($context, $assignsFromWorkData); @@ -724,12 +745,14 @@ // !! HACK !! $workData = $workDataValue; } + //echo ("update with " . $assignsToParm->InstanceKey . " = " . $workDataValue); $context->setWorkData($assignsToParm, $workData); } else { - //echo ("setting null on " . $assignsToParm->InstanceKey); + // echo ("setting null on " . $assignsToParm->InstanceKey); + $context->setWorkData($assignsToParm, $assignsFromWorkData); } } } @@ -770,6 +793,23 @@ { echo ("[" . $this->createHtmlLinkToInstanceReference($value) . "]"); } + else if (is_array($value)) + { + echo("[ "); + foreach ($value as $val) + { + if ($val instanceof InstanceReference) + { + echo ("[" . $this->createHtmlLinkToInstanceReference($value) . "]"); + } + else + { + echo ("'" . $val . "'"); + } + echo (", "); + } + echo (" ]"); + } else { echo ("'" . $value . "'"); @@ -812,9 +852,8 @@ return false; } - private function __is_a_impl(InstanceReference $inst, InstanceReference|string|InstanceKey $what, int $reentrant_counter) + private function __is_a_impl(InstanceReference $inst, InstanceReference $what, int $reentrant_counter) { - $what = $this->normalizeInstanceReference($what); if ($reentrant_counter > 10) { if ($reentrant_counter == 11) @@ -851,8 +890,19 @@ return false; } - public function is_a(InstanceReference $inst, InstanceReference|string|InstanceKey $what) + public function is_a(InstanceReference|string|InstanceKey|array|null $inst, InstanceReference|string|InstanceKey $what) { + if ($inst === null) + { + return false; + } + if (is_array($inst)) + { + return false; + } + $inst = $this->normalizeInstanceReference($inst); + $what = $this->normalizeInstanceReference($what); + return $this->__is_a_impl($inst, $what, 0); } diff --git a/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/ConditionalSelectInstanceSetMethodImplementation.inc.php b/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/ConditionalSelectInstanceSetMethodImplementation.inc.php new file mode 100644 index 0000000..893a3c5 --- /dev/null +++ b/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/ConditionalSelectInstanceSetMethodImplementation.inc.php @@ -0,0 +1,55 @@ + Conditional Select Instance Set
"); + echo ("
The work data is:
"); + $oms->printWorkData($context->workData); + echo ("

"); + $retval = null; + $returnsWorkSet = $oms->getRelatedInstance($method, KnownRelationshipGuids::Conditional_Select_from_Instance_Set_Method__returns__Work_Set); + $cases = $oms->getRelatedInstances($method, KnownRelationshipGuids::Conditional_Select_from_Instance_Set_Method__has__Conditional_Select_from_Instance_Set_Case); + foreach ($cases as $case) + { + $trueConditions = $oms->getRelatedInstances($case, KnownRelationshipGuids::Condition_Group__has_true_condition__Executable_returning_Attribute); + $falseConditions = $oms->getRelatedInstances($case, KnownRelationshipGuids::Condition_Group__has_false_condition__Executable_returning_Attribute); + if (!$oms->evaluateConditions($context, $trueConditions, $falseConditions)) + { + continue; + } + + $invokesExecutableReturningInstanceSet = $oms->getRelatedInstance($case, KnownRelationshipGuids::Conditional_Select_from_Instance_Set_Case__invokes__Executable_returning_Instance_Set); + if ($invokesExecutableReturningInstanceSet !== null) + { + $ws = $oms->execute($context, $invokesExecutableReturningInstanceSet); + echo ("

setting work data " . $returnsWorkSet . " = " . $ws . " [ from " . $invokesExecutableReturningInstanceSet . " ]

"); + $context->setWorkData($returnsWorkSet, $ws); + $retval = $returnsWorkSet; + } + else + { + $context->setWorkData($returnsWorkSet, "SSC case with NULL instance set"); + $retval = $returnsWorkSet; + } + } + if ($retval === null) + { + $context->setWorkData($returnsWorkSet, "SSC returned no case"); + $retval = $returnsWorkSet; + } + return $retval; + } + } + +?> \ No newline at end of file diff --git a/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/EvaluateBooleanExpressionMethodImplementation.inc.php b/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/EvaluateBooleanExpressionMethodImplementation.inc.php index 38db807..bc71675 100644 --- a/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/EvaluateBooleanExpressionMethodImplementation.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/EvaluateBooleanExpressionMethodImplementation.inc.php @@ -22,23 +22,65 @@ $booleanOperator = $oms->getRelatedInstance($method, KnownRelationshipGuids::IDR_Evaluate_Boolean_Expression_Method__uses__Boolean_Operator); $targetInstanceRef = $oms->getRelatedInstance($method, KnownRelationshipGuids::Evaluate_Boolean_Expression_Method__has_target__Executable_returning_Work_Data); - $sourceInstanceWD = $oms->execute($context, $sourceInstanceRef); - $sourceInstance = $sourceInstanceWD; - if ($oms->is_a($sourceInstanceWD, KnownClassGuids::WorkSet)) + $sourceInstance = null; + if ($oms->is_a($sourceInstanceRef, KnownClassGuids::WorkSet)) { - $sourceInstance = $context->getWorkData($sourceInstanceWD); + $sourceInstance = $context->getWorkData($sourceInstanceRef); + } + else + { + $sourceInstanceWD = $oms->execute($context, $sourceInstanceRef); + $sourceInstance = $sourceInstanceWD; + if ($oms->is_a($sourceInstanceWD, KnownClassGuids::WorkSet)) + { + $sourceInstance = $context->getWorkData($sourceInstanceWD); + } } - if ($sourceInstanceWD === null) + if ($sourceInstance === null) { $oms->MetadataExceptions[] = new OmsMetadataException("Evaluate Boolean Expression `source instance` is null", array ( "Source Instance Method Binding" => $sourceInstanceRef )); - // echo ("ERR: `source inst` [ from " . $sourceInstanceRef->InstanceKey . " ] null"); + echo ("ERR: `source inst` [ from " . $sourceInstanceRef . " ] null"); return false; } - if ($targetInstanceRef !== null) + + if ($booleanOperator->GlobalIdentifier == UUID::parse(KnownInstanceGuids::RelationalOperator__Empty)) + { + echo ("source instance : " . $sourceInstanceRef); + if ($oms->is_a($sourceInstanceRef, KnownClassGuids::WorkSet)) + { + $si = $sourceInstance; + $sourceInstance = $context->getWorkData($sourceInstance); + echo ("WARN: work set hack used ( " . $si . " := " . $sourceInstance . " )"); + } + echo (" compare : " . $sourceInstance); + echo (" is empty ? "); + if ($sourceInstance == null) + { + echo (" ! yes !"); + $value = true; + } + else + { + echo (" ! no !"); + $value = false; + } + } + else if ($booleanOperator->GlobalIdentifier == UUID::parse(KnownInstanceGuids::RelationalOperator__NotEmpty)) + { + if ($sourceInstance !== null) + { + $value = true; + } + else + { + $value = false; + } + } + else if ($targetInstanceRef !== null) { $targetInstanceWD = $oms->execute($context, $targetInstanceRef, false); $targetInstance = $targetInstanceWD; @@ -76,6 +118,10 @@ // echo ("EBE check: " . $source->Instance . " ?? " . $target); $value = $source === $target; } + else + { + echo("err: not implement bool operator " . $booleanOperator); + } } else { @@ -83,10 +129,12 @@ } if ($returnsAttribute !== null) { + echo ("setting attribute " . $returnsAttribute . " = " . ($value ? "true" : "false")); $context->setWorkData($returnsAttribute, $value); } else { + echo ("EBE returned null attribute"); $oms->MetadataExceptions[] = new OmsMetadataException("EBE : returned null attribute", array ( "Method Instance" => $method diff --git a/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/GetInstanceSetBySystemRoutineMethodImplementation.inc.php b/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/GetInstanceSetBySystemRoutineMethodImplementation.inc.php index e0d8148..14605cb 100644 --- a/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/GetInstanceSetBySystemRoutineMethodImplementation.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/GetInstanceSetBySystemRoutineMethodImplementation.inc.php @@ -4,6 +4,7 @@ use Mocha\Core\InstanceReference; use Mocha\Core\KnownAttributeGuids; use Mocha\Core\KnownClassGuids; + use Mocha\Core\KnownInstanceGuids; use Mocha\Core\KnownRelationshipGuids; use Mocha\Core\OmsContext; use Mocha\Oms\Oms; @@ -16,26 +17,40 @@ protected function executeInternal(Oms $oms, OmsContext $context, InstanceReference $method, ?array $parms) { $instSystemRoutine = $oms->getRelatedInstance($method, $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Get_Instance_Set_by_System_Routine_Method__uses__System_Instance_Set_Routine)); + echo ("exec sys routine " . $instSystemRoutine->GlobalIdentifier); $returnsWorkData = $oms->getRelatedInstance($method, KnownRelationshipGuids::Get_Instance_Set_by_System_Routine_Method__returns__Instance_Set); - $singular = false; $oms->getAttributeValue($instSystemRoutine, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::Singular)); + $singular = $oms->getAttributeValue($instSystemRoutine, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::Singular)); + $value = null; - if ($instSystemRoutine->GlobalIdentifier->__is_equal(UUID::parse("430f572dd1164b0497b265a9e9230ce5"))) + if ($instSystemRoutine->GlobalIdentifier->__is_equal(UUID::parse(KnownInstanceGuids::SystemInstanceSetRoutine_CreateInstance))) + { + $clasz = $context->getWorkData(KnownInstanceGuids::WorkSet__ClassOfInstanceToCreate); + if (is_array($clasz)) + { + $clasz = $clasz[0]; + } + + $inst = $oms->createInstanceOf($clasz); + $value = $inst; + echo ("create instance of " . $clasz . " = " . $inst . " , returned in " . $returnsWorkData); + } + else if ($instSystemRoutine->GlobalIdentifier->__is_equal(UUID::parse(KnownInstanceGuids::SystemInstanceSetRoutine_GetUserForUserNameParm))) { // get User for User Name parm // this System Attribute Routine has a required parm: `User Name [TX]` [4$11] - $userName = $context->getWorkData(KnownAttributeGuids::UserName); // $parms[KnownAttributeGuids::UserName]; - $singular = true; - if ($singular) - { - $value = $oms->getUserByUserName($userName); - } - else - { - $value = [ $oms->getUserByUserName($userName) ]; - } - $context->setWorkData($returnsWorkData, $value); + $value = $oms->getUserByUserName($userName); } + + if (is_array($value) && $singular) + { + $value = $value[0]; + } + else if (!is_array($value) && !$singular) + { + $value = [ $value ]; + } + $context->setWorkData($returnsWorkData, $value); return $returnsWorkData; } diff --git a/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/ProcessRelatedUpdatesMethodImplementation.inc.php b/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/ProcessRelatedUpdatesMethodImplementation.inc.php index 334385a..5f7a980 100644 --- a/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/ProcessRelatedUpdatesMethodImplementation.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/oop/methodImplementations/ProcessRelatedUpdatesMethodImplementation.inc.php @@ -53,6 +53,7 @@ $usesExecutableReturningAttribute = $oms->getRelatedInstance($instExecutableForPUMB, KnownRelationshipGuids::Assign_Attribute_Method__uses__Executable_returning_Attribute); //$context->setWorkData($assignsAttribute->GlobalIdentifier->__toString(), $usesExecutableReturningAttribute); + echo ("for PRU inst: " . $instForPRU->InstanceKey); echo ("assigning attribute '" . $assignsAttribute->GlobalIdentifier . "' the value from executable '" . $usesExecutableReturningAttribute->GlobalIdentifier . "'"); $value = $context->getWorkData($usesExecutableReturningAttribute); diff --git a/mocha-php/src/mocha-php/lib/mocha/ui/renderers/html/HTMLRenderer.inc.php b/mocha-php/src/mocha-php/lib/mocha/ui/renderers/html/HTMLRenderer.inc.php index 1add386..7674a98 100644 --- a/mocha-php/src/mocha-php/lib/mocha/ui/renderers/html/HTMLRenderer.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/ui/renderers/html/HTMLRenderer.inc.php @@ -10,6 +10,7 @@ use Mocha\Core\KnownRelationshipGuids; use Mocha\Core\OmsContext; + use Mocha\Oms\Oms; use Mocha\Oms\MySQLDatabaseOms; use Mocha\Oms\OmsMetadataException; @@ -67,13 +68,16 @@ public $FailedValidationElements; + public $Scripts; public $StyleClasses; public bool $IsPostback; public string $SubmitButtonText; public bool $IncludeTopNavigationBar; - public function __construct(OmsContext $context) + public ?Oms $OMS; + + public function __construct(OmsContext $context, bool $withoutOms = false) { $this->DebugMode = false; $this->Context = $context; @@ -81,12 +85,18 @@ $this->FailedValidations = []; $this->FailedValidationElements = []; $this->IsPostback = false; + $this->Scripts = []; $this->StyleClasses = []; $this->SubmitButtonText = "OK"; // "Save Changes"; $this->IncludeTopNavigationBar = true; $this->__renderingElement = null; $this->__processingElement = null; + $this->OMS = null; + if (!$withoutOms) + { + $this->OMS = mocha_get_oms(); + } $this->registerEditors(); } @@ -95,7 +105,8 @@ /** * @var MySQLDatabaseOms */ - $oms = mocha_get_oms(); + $oms = $this->OMS; + if ($oms == null) return; $genericViewFunc = function($oms, $parentElementContents, $elementContent, $ecInst, $value) { @@ -208,6 +219,35 @@ } return $fullyQualifiedECID; } + + public function renderBeginContent() + { + echo ("
"); + } + public function renderEndContent() + { + echo ("
"); + } + + public function renderBeginErrorPage(string $title, string $heading) + { + $this->renderBeginPage($title); + $this->renderBeginContent(); + echo ("
"); + echo ("\"Error\""); + echo ("

" . $heading . "

"); + } + public function renderEndErrorPage() + { + echo ("
"); + $this->renderSystemFooter(); + $this->renderEndContent(); + $this->renderEndPage(); + } + public function renderSystemFooter() + { + echo ("
Powered by Mocha
© 2024 MBS Business Solutions
"); + } public function renderPageHeader(InstanceReference|string $title, InstanceReference|string|null $subtitle) { @@ -297,9 +337,6 @@ echo ("TargetInstance->InstanceKey . "\" />"); $this->renderPageHeader($title, $this->TargetInstance); - echo ("work data!"); - print_r($this->Context->workData); - $this->renderBeginTag("div", [ ], [ "uwt-page-content" ]); $this->renderElement($parentElementContents, $usesElement, [ $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__Singular), $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::DisplayOption__ShowSubelementsVertically) ]); $this->renderEndTag("div"); @@ -677,7 +714,8 @@ EOF } $subelementInstances = $this->getSubelementInstances($parentElementContent); $count = $_POST[$ecid_count]; - + + echo ("check count : " . $count . " vs existing : " . count($subelementInstances)); if ($count != count($subelementInstances)) { echo ("WARN: count mismatch (got " . $count . "; expected " . count($subelementInstances) . ") - add / remove sub elements not implemented"); //die(); @@ -685,16 +723,12 @@ EOF for ($i = 0; $i < $count; $i++) { - $targetRelatedInstance = $subelementInstances[$i]; - if ($i >= count($subelementInstances)) - { - // we are creating a new instance of the class of the subelement (element content #0) - echo ("creating instance of " . $classParent->InstanceKey); - $targetRelatedInstance = $oms->createInstanceOf($classParent); - } - else + $targetRelatedInstance = null; + if ($i < count($subelementInstances)) { + $targetRelatedInstance = $subelementInstances[$i]; } + echo ("target rel inst: " . $targetRelatedInstance->InstanceKey); $this->updateWorkDataWithElementContents($parentElementContents, $element, false, $i); @@ -812,11 +846,6 @@ EOF foreach ($relatedECs as $relatedEC) { $fullyQualifiedECID = $this->getElementContentId($parentElementContents, $relatedEC); - if ($this->DebugMode) - { - echo ("FQECID : " . $fullyQualifiedECID . "
"); - } - $value = null; if (isset($_POST["ec_" . $fullyQualifiedECID])) { @@ -836,11 +865,6 @@ EOF $relatedECInst = $oms->getRelatedInstance($relatedEC, KnownRelationshipGuids::Element_Content__has__Instance); - - if ($this->DebugMode) - { - echo ("updating singular EC : target = " . $targetInstance->InstanceKey . "; ec = " . $fullyQualifiedECID . " = '" . $value . "'"); - } array_push($parentElementContents, $relatedEC); $this->updateElementContentInstance($parentElementContents, $targetInstance, $relatedECInst, $value); array_pop($parentElementContents); @@ -2005,8 +2029,11 @@ EOF /** * @var MySQLDatabaseOms */ - $oms = mocha_get_oms(); - $oms->MetadataExceptions = array(); + $oms = $this->OMS; + if ($oms !== null) + { + $oms->MetadataExceptions = array(); + } $this->_stopwatch = new Stopwatch(); $this->_stopwatch->start(); @@ -2048,8 +2075,29 @@ EOF $this->renderBeginTag("script", array("type" => "text/javascript")); echo("System.BasePath = '" . System::GetConfigurationValue("Application.BasePath") . "';"); echo("System.IsTenantedHostingEnabled = function() { return false; };"); - echo("System.TenantName = '" . $oms->getTenantName() . "';"); + + $tenantName = null; + if ($oms !== null) + { + $tenantName = $oms->getTenantName(); + } + echo("System.TenantName = '" . $tenantName . "';"); + $this->renderEndTag("script"); + foreach ($this->Scripts as $script) + { + if ($script->FileName !== null) + { + $this->renderBeginTag("script", array("type" => $script->ContentType, "src" => $script->FileName)); + $this->renderEndTag("script"); + } + else if ($script->Content !== null) + { + $this->renderBeginTag("script", array("type" => $script->ContentType)); + echo($script->Content); + $this->renderEndTag("script"); + } + } $this->renderEndTag("head"); $bodyClasses = [ "uwt-header-visible", "uwt-header-inverse", "uwt-javascript-disabled" ]; foreach ($this->StyleClasses as $className) @@ -2151,72 +2199,73 @@ EOF /** * @var MySQLDatabaseOms */ - $oms = mocha_get_oms(); + $oms = $this->OMS; echo("
"); - if ($this->IsPostback) + if ($oms !== null) { - if (count($this->FailedValidations) > 0) + if ($this->IsPostback) { - foreach ($this->FailedValidations as $validation) + if (count($this->FailedValidations) > 0) { - $oms->MetadataExceptions[] = new OmsMetadataException - ( - $validation->Title . " : " . $validation->Message - ); - /* - $ik = ""; - echo("
"); - echo("
" . $validation->Title . "
"); - echo("
" . str_replace("\n", "
", $validation->Message) . "
"); + foreach ($this->FailedValidations as $validation) + { + $oms->MetadataExceptions[] = new OmsMetadataException + ( + $validation->Title . " : " . $validation->Message + ); + /* + $ik = ""; + echo("
"); + echo("
" . $validation->Title . "
"); + echo("
" . str_replace("\n", "
", $validation->Message) . "
"); + echo("
"); + */ + } + } + /* + else + { + echo("
"); + echo("
Saved
"); echo("
"); - */ + } + */ + } + + $errors = [ ]; + $warnings = [ ]; + $infos = [ ]; + foreach ($oms->MetadataExceptions as $exc) + { + if ($exc->Severity == OmsMetadataExceptionSeverity::Error) + { + $errors[] = $exc; + } + else if ($exc->Severity == OmsMetadataExceptionSeverity::Warning) + { + $warnings[] = $exc; + } + else //if ($exc->Severity == OmsMetadataExceptionSeverity::Information) + { + $infos[] = $exc; } } - /* - else + if (count($errors) > 0) { - echo("
"); - echo("
Saved
"); - echo("
"); + $this->renderOmsMetadataExceptions($errors, "Errors", "error", "errors", "uwt-color-danger"); } - */ - } - - - - $errors = [ ]; - $warnings = [ ]; - $infos = [ ]; - foreach ($oms->MetadataExceptions as $exc) - { - if ($exc->Severity == OmsMetadataExceptionSeverity::Error) + if (count($warnings) > 0) { - $errors[] = $exc; + $this->renderOmsMetadataExceptions($warnings, "Warnings", "warning", "warnings", "uwt-color-warning"); } - else if ($exc->Severity == OmsMetadataExceptionSeverity::Warning) + if (count($infos) > 0) { - $warnings[] = $exc; - } - else //if ($exc->Severity == OmsMetadataExceptionSeverity::Information) - { - $infos[] = $exc; + $this->renderOmsMetadataExceptions($infos, "Messages", "message", "messages", "uwt-color-info"); } } - if (count($errors) > 0) - { - $this->renderOmsMetadataExceptions($errors, "Errors", "error", "errors", "uwt-color-danger"); - } - if (count($warnings) > 0) - { - $this->renderOmsMetadataExceptions($warnings, "Warnings", "warning", "warnings", "uwt-color-warning"); - } - if (count($infos) > 0) - { - $this->renderOmsMetadataExceptions($infos, "Messages", "message", "messages", "uwt-color-info"); - } - + echo("
"); $this->renderEndTag("body"); diff --git a/mocha-php/src/mocha-php/lib/mocha/ui/renderers/html/HTMLRenderer.js.php b/mocha-php/src/mocha-php/lib/mocha/ui/renderers/html/HTMLRenderer.js.php index 918441d..d17f891 100644 --- a/mocha-php/src/mocha-php/lib/mocha/ui/renderers/html/HTMLRenderer.js.php +++ b/mocha-php/src/mocha-php/lib/mocha/ui/renderers/html/HTMLRenderer.js.php @@ -1,6 +1,23 @@ getTenantName(); + //$oms = mocha_get_oms(); + + $path = $_SERVER["REQUEST_URI"]; + $parts = explode("/", $path); + $tenantName = null; + + if (count($parts) > 3 && $parts[1] == "madi" && $parts[2] == "authgwy") + { + $tenantName = $parts[3]; + } + else if (count($parts) > 1) + { + $tenantName = $parts[1]; + } + + //if ($oms !== null) + { + //$tenantName = $oms->getTenantName(); + } $cdn_url = "static.alcehosting.net"; $tenant_environment_text = "Implementation - " . $tenantName; @@ -9,7 +26,7 @@ $ret = $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["SERVER_NAME"]; if ($path != "") { - $ret .= "/" . $path;; + $ret .= "/" . $path; } return $ret; } diff --git a/mocha-php/src/mocha-php/themes/avondale/uwt-menu.less b/mocha-php/src/mocha-php/themes/avondale/uwt-menu.less index f927328..e81a23b 100644 --- a/mocha-php/src/mocha-php/themes/avondale/uwt-menu.less +++ b/mocha-php/src/mocha-php/themes/avondale/uwt-menu.less @@ -13,6 +13,14 @@ ul.uwt-menu &> li:not(.uwt-section) { + &:not(.uwt-selected) > a:not(:hover) + { + &> span.uwt-description + { + color: #666666; + } + } + &> a { /* @@ -20,14 +28,9 @@ ul.uwt-menu font-weight: 600; */ font-size: 12pt; - font-weight: 300; + // font-weight: 300; padding: 0.309375rem 0.9375rem; - - &:not(:hover) > span.uwt-description - { - color: #aaaaaa; - } } &:not(.uwt-disabled) > a { diff --git a/mocha-php/src/mocha-php/themes/common/styles/uwt-combobox.less b/mocha-php/src/mocha-php/themes/common/styles/uwt-combobox.less new file mode 100644 index 0000000..ff2e569 --- /dev/null +++ b/mocha-php/src/mocha-php/themes/common/styles/uwt-combobox.less @@ -0,0 +1,34 @@ +div.uwt-combobox +{ + display: inline-block; + box-sizing: border-box; + position: relative; + + &::after + { + content: "\f0d7"; + font-weight: bold; + display: inline-block; + height: 24px; + width: 18px; + font-family: "Font Awesome 6 Pro"; + position: absolute; + right: 0px; + top: 8px; + font-size: 9pt; + color: var(--uwt-color-gray); + pointer-events: none; + } + &> input + { + display: block; + width: 100%; + box-sizing: border-box; + padding-right: 24px; + + &:not(:focus) + { + cursor: default; + } + } +} diff --git a/mocha-php/src/mocha-php/themes/common/styles/uwt-menu.less b/mocha-php/src/mocha-php/themes/common/styles/uwt-menu.less index 7198faf..c53120a 100644 --- a/mocha-php/src/mocha-php/themes/common/styles/uwt-menu.less +++ b/mocha-php/src/mocha-php/themes/common/styles/uwt-menu.less @@ -4,6 +4,12 @@ ul.uwt-menu padding-left: 0px; margin: 0px; user-select: none; + &.uwt-popup + { + max-height: 200px; + overflow: scroll; + overflow-x: hidden; + } &> li { padding: .438rem 1.25rem; @@ -30,6 +36,10 @@ ul.uwt-menu { //font-weight: bold; } + &.uwt-description + { + font-size: 0.8em; + } } } &.uwt-menu-item-command @@ -90,17 +100,25 @@ ul.uwt-menu padding: 4px; } } - &.uwt-selected + } + } + &> li:not(.uwt-section) + { + &.uwt-selected + { + &> a { - &> a + /* + &::before { - &::before - { - background-color: var(--uwt-color-accent); - border-color: var(--uwt-color-accent); - content: "\f00c"; - } + background-color: var(--uwt-color-accent); + border-color: var(--uwt-color-accent); + content: "\f00c"; } + */ + background-color: var(--uwt-color-accent); + border-color: var(--uwt-color-accent); + color: #fff; } } } diff --git a/mocha-php/src/mocha-php/themes/common/styles/uwt.less b/mocha-php/src/mocha-php/themes/common/styles/uwt.less index fda1ba0..27be091 100644 --- a/mocha-php/src/mocha-php/themes/common/styles/uwt.less +++ b/mocha-php/src/mocha-php/themes/common/styles/uwt.less @@ -8,6 +8,7 @@ @import "uwt-calendar.less"; @import "uwt-checkbox.less"; @import "uwt-column.less"; +@import "uwt-combobox.less"; @import "uwt-dialog.less"; @import "uwt-disclosure.less"; @import "uwt-expand.less"; diff --git a/mocha-php/src/mocha-php/ui/pages/AttachmentPage.phpx.php b/mocha-php/src/mocha-php/ui/pages/AttachmentPage.phpx.php index 6312b08..88993a4 100644 --- a/mocha-php/src/mocha-php/ui/pages/AttachmentPage.phpx.php +++ b/mocha-php/src/mocha-php/ui/pages/AttachmentPage.phpx.php @@ -50,6 +50,8 @@ $ext = "svg"; } $path = "/var/mocha/uploads/" . $inst->GlobalIdentifier->__toStringFormat(false, null, null) . "." . $ext; + //echo ("iid: " . $inst->GlobalIdentifier); + if (file_exists($path)) { $fsz = filesize($path); diff --git a/mocha-php/src/mocha-php/ui/pages/InstancePage.phpx b/mocha-php/src/mocha-php/ui/pages/InstancePage.phpx index 34f6c48..70c6d83 100644 --- a/mocha-php/src/mocha-php/ui/pages/InstancePage.phpx +++ b/mocha-php/src/mocha-php/ui/pages/InstancePage.phpx @@ -8,8 +8,6 @@
-

Test Instance

-

Instance ID:

diff --git a/mocha-php/src/mocha-php/ui/pages/InstancePage.phpx.php b/mocha-php/src/mocha-php/ui/pages/InstancePage.phpx.php index 09c70ca..d20eb29 100644 --- a/mocha-php/src/mocha-php/ui/pages/InstancePage.phpx.php +++ b/mocha-php/src/mocha-php/ui/pages/InstancePage.phpx.php @@ -9,6 +9,7 @@ use Mocha\Core\OmsContext; use Mocha\Oms\MySQLDatabaseOms; + use Mocha\UI\Controls\InstanceBrowser; use Mocha\UI\Renderers\HTML\HTMLRenderer; use Phast\RenderingEventArgs; use Phast\WebPage; @@ -71,12 +72,15 @@ } else { + $ctx = new OmsContext(); + $htmlRenderer = new HTMLRenderer($ctx); + $parentClass = $oms->getParentClass($inst); if ($castkey !== null) { $parentClass = $oms->getInstanceByKey($castkey); } - + $rel_Class__has_default__Task = $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Class__has_default__Task); if ($rel_Class__has_default__Task !== null) { @@ -101,7 +105,59 @@ $taskRenderer->renderTask($defaultTask, $inst); exit(); } + else + { + $htmlRenderer->renderBeginPage("View Instance [Hardcoded]"); + + $htmlRenderer->renderPageHeader("View Instance [Hardcoded]", $inst); + $htmlRenderer->renderBeginContent(); + + $htmlRenderer->renderBeginTag("div", [ ], [ "uwt-formview", "mcx-element" ]); + + $htmlRenderer->renderBeginTag("div", [ ], [ "mcx-elementcontent", "uwt-formview-item" ]); + + $htmlRenderer->renderBeginTag("div", [ ], [ "uwt-formview-item-label" ]); + $htmlRenderer->renderBeginTag("label",[ ], [ ]); + echo("Instance"); + $htmlRenderer->renderEndTag("label"); + $htmlRenderer->renderEndTag("div"); + + $htmlRenderer->renderBeginTag("div", [ ], [ "uwt-formview-item-content" ]); + $htmlRenderer->renderEndTag("div"); + + $adw = new InstanceBrowser(); + $adw->SelectedInstances[] = $inst; + $adw->Render(); + + $htmlRenderer->renderEndTag("div"); + + $htmlRenderer->renderBeginTag("div", [ ], [ "mcx-elementcontent", "uwt-formview-item" ]); + + $htmlRenderer->renderBeginTag("div", [ ], [ "uwt-formview-item-label" ]); + $htmlRenderer->renderBeginTag("label",[ ], [ ]); + echo("Parent Class"); + $htmlRenderer->renderEndTag("label"); + $htmlRenderer->renderEndTag("div"); + + $htmlRenderer->renderBeginTag("div", [ ], [ "uwt-formview-item-content" ]); + $htmlRenderer->renderEndTag("div"); + + + $adw = new InstanceBrowser(); + $adw->SelectedInstances[] = $parentClass; + $adw->Render(); + + + $htmlRenderer->renderEndTag("div"); + + $htmlRenderer->renderEndTag("div"); + + $htmlRenderer->renderEndContent(); + } } + + $htmlRenderer->renderEndPage(); + } } diff --git a/mocha-php/src/mocha-php/ui/pages/LoginPage.phpx.php b/mocha-php/src/mocha-php/ui/pages/LoginPage.phpx.php index 118f3d4..2b56d69 100644 --- a/mocha-php/src/mocha-php/ui/pages/LoginPage.phpx.php +++ b/mocha-php/src/mocha-php/ui/pages/LoginPage.phpx.php @@ -131,12 +131,9 @@ echo("`User@get User for User Name parm`: method not found ('" . KnownMethodBindingGuids::User__get__User_for_User_Name_parm . "')");die(); } - $context = new OmsContext(); - $instUser = $oms->execute($context, $mbUser__get__User_for_User_Name_parm, true, array( KnownAttributeGuids::UserName => $userName )); - $instUser = $context->getWorkData($instUser); - - echo ("user: " . $instUser->InstanceKey); - + $instUser = $oms->execute($sender->Context, $mbUser__get__User_for_User_Name_parm); + $instUser = $sender->Context->getWorkData($instUser); + if ($instUser !== null) { $passwordSalt = $oms->getAttributeValue($instUser, $oms->getInstanceByGlobalIdentifier(KnownAttributeGuids::PasswordSalt)); @@ -189,6 +186,7 @@ } $renderer->SubmitButtonText = "Log In"; $renderer->renderInitialElement($pageElement); + exit(); } diff --git a/mocha-php/src/mocha-php/ui/pages/RelatedTaskListPage.phpx.php b/mocha-php/src/mocha-php/ui/pages/RelatedTaskListPage.phpx.php index 36aaacb..8db87e1 100644 --- a/mocha-php/src/mocha-php/ui/pages/RelatedTaskListPage.phpx.php +++ b/mocha-php/src/mocha-php/ui/pages/RelatedTaskListPage.phpx.php @@ -213,9 +213,9 @@ $json["result"] = "success"; $messages = array(); - foreach ($oms->Messages as $message) + foreach ($oms->MetadataExceptions as $message) { - $messages[] = array("title" => $message->Title, "content" => $message->Message, "severity" => $message->Severity); + $messages[] = array("title" => $message->Message, "content" => $message->Message, "severity" => $message->Severity); } $json["messages"] = $messages; diff --git a/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx b/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx index bbfc5f6..ec31b21 100644 --- a/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx +++ b/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx.php b/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx.php index 1088d9d..9197019 100644 --- a/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx.php +++ b/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx.php @@ -2,52 +2,298 @@ namespace Mocha\UI\Pages; + use Mocha\Core\OmsContext; + use Mocha\UI\Renderers\HTML\HTMLRenderer; + use Phast\CancelEventArgs; use Phast\RenderingEventArgs; use Phast\System; + use Phast\WebControls\TabContainer; + use Phast\WebControls\TabPage; + use Phast\WebControls\Window; use Phast\WebPage; + use Phast\WebScript; class SUVPage extends WebPage { - protected function RenderContents() + protected function OnPreRender(CancelEventArgs $e) { + $e->Cancel = true; + $path = System::GetVirtualPath(); - $tenantName = null; - if ($path[1] == "phpinfo.html") { phpinfo(); + return; } - else if ($path[1] == "suvinfo.html") + + $ctx = new OmsContext(); + + $htmlRenderer = new HTMLRenderer($ctx, true); + $htmlRenderer->Scripts[] = WebScript::FromContent(<< -

SUV Self Service

-

General

-
-
- - - - - - - - - - - - - - - - - -
PropertyValue
Namesuv
Instance Id
-

Actions

- -
-
-renderBeginPage("SUV Self Service"); + + if ($path[1] == "suvinfo.html") + { + $htmlRenderer->renderPageHeader("SUV Self Service", ""); + $htmlRenderer->renderBeginContent(); + + $windowCreateTenant = new Window(); + $windowCreateTenant->ID = "windowCreateTenant"; + $windowCreateTenant->Title = "Create Tenant"; + $windowCreateTenant->Content = function() + { + ?> +
+ Create Tenant +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ + Render(); + + $tabContainer = new TabContainer(); + $page = new TabPage(); + $page->Title = "General"; + $page->Content = function() + { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyValue
Namesuv
Instance Id
Host Name
Environment Version58132
Confidence Levelprod
Statuscompleted
+

Actions

+ + TabPages[] = $page; + + $page = new TabPage(); + $page->Title = "Tenants"; + $page->Content = function() + { + ?> +
+ Add Tenant + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Tenant NameStatusTenant TypeData CenterChargeInitial TermRenewal TermTenant Start DateTenant Expiration DatePurpose
superActiveDevelopmentLocalNo ChargeDefault Tenant
+ TabPages[] = $page; + + $page = new TabPage(); + $page->Title = "Database"; + $page->Content = function() + { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyValue
Backendmysql
User
Host
Port
Statusrunning
+ TabPages[] = $page; + + + $tabContainer->Render(); } + + $htmlRenderer->renderEndContent(); + + $htmlRenderer->renderEndPage(); } }