diff --git a/mocha-php/src/mocha-php/lib/mocha/oms/HttpOmsClient.inc.php b/mocha-php/src/mocha-php/lib/mocha/oms/HttpOmsClient.inc.php index 6b20322..e71d7e0 100644 --- a/mocha-php/src/mocha-php/lib/mocha/oms/HttpOmsClient.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/oms/HttpOmsClient.inc.php @@ -146,7 +146,7 @@ $retval = array(); foreach ($ary as $inst) { - $retval[] = new InstanceReference(null, InstanceKey::parse($inst["iid"]), UUID::parse($inst["globalIdentifier"])); + $retval[] = new InstanceReference(null, InstanceKey::parse($inst["iid"]), UUID::parse($inst["globalIdentifier"]), $inst["text"]); } return $retval; } @@ -360,8 +360,18 @@ public function getResponse($element, InstanceReference|null $relatedInstance = null) // , array|null $workData = null) { + $url = "/tenants/" . $this->getTenantName() . "/instances/" . $element->InstanceKey . "/element"; + echo ("getResponse (' " . $url . " ');
"); + if ($relatedInstance !== null) { + // related instance is passed in by: + // UI Task.has Related Menu Item + // -> Related Menu Item.uses object of Class + // + // the parm for that class type is then set to the value of the relatedInstance URL parm + // or as WD calls, an Instance Set + $workDataPost = array("relatedInstance" => $relatedInstance->InstanceKey); /* $workDataPost = array(); @@ -370,10 +380,10 @@ $workDataPost[UUID::parse($key)->__toString()] = strval($value); } */ - $json = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $element->InstanceKey . "/element", HttpRequestMethod::POST, $workDataPost); + $json = $this->curl_request_json($url, HttpRequestMethod::POST, $workDataPost); return $json; } - $json = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $element->InstanceKey . "/element"); + $json = $this->curl_request_json($url); return $json; } @@ -410,7 +420,12 @@ public function processElement(InstanceReference $element, array $values) : array { - $result = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $element->GlobalIdentifier . "/element", HttpRequestMethod::POST, $values); + $url = "/tenants/" . $this->getTenantName() . "/instances/" . $element->GlobalIdentifier . "/element"; + echo ("

POST " . $url . "
Values:
"); + echo ("

"); + print_r($values); + echo ("

"); + $result = $this->curl_request_json($url, HttpRequestMethod::POST, $values); return $result; } 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 7a2cd3e..9c0a2eb 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 @@ -41,6 +41,8 @@ */ public $Context; + public $CodeBehindFileName; + /** * Run in debug mode (prints log to screen and then dies at end). */ @@ -2277,6 +2279,7 @@ EOF $this->_stopwatch->stop(); $this->logRequestSuccess($this->_stopwatch->getElapsedTime()); + echo (""); } public function renderInitialElement(InstanceReference $element) diff --git a/mocha-php/src/mocha-php/lib/mocha/ui/renderers/html/HTMLRenderer2.inc.php b/mocha-php/src/mocha-php/lib/mocha/ui/renderers/html/HTMLRenderer2.inc.php index 1b7e63b..2960a7a 100644 --- a/mocha-php/src/mocha-php/lib/mocha/ui/renderers/html/HTMLRenderer2.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/ui/renderers/html/HTMLRenderer2.inc.php @@ -25,8 +25,6 @@ */ $oms = mocha_get_oms(); - echo ("postbakc!"); - $values = array(); foreach ($_POST as $key => $value) { @@ -36,15 +34,19 @@ $values[$fqecid] = $value; } } - + $array = $this->OMS->processElement($element, $values); if ($array["result"] === "failure") { + echo ("failed at processElement"); + print_r($array); return false; } + //*** DO NOT DELETE, WE STILL USE THIS FOR LOGIN ***// if (is_callable($this->ProcessPostbackFunction)) { + echo ("calling user function"); // call user-defined ProcessPostbackFunction return call_user_func($this->ProcessPostbackFunction, $this, $element, $array); } @@ -53,6 +55,8 @@ $dummy = [ ]; if (!$this->processRelatedPostback($dummy, $element)) { + echo ("failed at processRelatedPostback"); + print_r($array); return false; } } @@ -65,6 +69,14 @@ echo ("debug mode done"); die(); } + + if ($array["result"] == "success" && $array["type"] == "redirect") + { + System::Redirect($array["destinationUrl"]); + return true; + } + + print_r($array); die(); if (isset($_POST["ReturnToURL"])) { @@ -80,7 +92,7 @@ $this->renderResponse($json["value"]); } - public function renderResponse(array $json) + public function renderResponse(array $json, $subtitle = null) { $title = ""; if (array_key_exists("title", $json)) @@ -99,7 +111,7 @@ if (!array_key_exists("visible", $json["title"]) || $json["title"]["visible"] === true) { - $this->renderPageHeader($title, null); + $this->renderPageHeader($title, $subtitle); } $this->renderBeginContent(); @@ -120,8 +132,8 @@ { // FIXME: pass in work data parms as array e.g. //? getResponse($task, array( RELATED_INSTANCE => $relatedInstance )) - $workData = null; /* + $workData = null; if ($relatedInstance !== null) { $workData = array @@ -131,10 +143,11 @@ } */ $json = $this->OMS->getResponse($task, $relatedInstance); + // print_r($json); if ($json["result"] == "success") { $title = $json["value"]["title"]["label"]; - $this->renderResponse($json["value"]); + $this->renderResponse($json["value"], $relatedInstance); } else @@ -359,6 +372,18 @@ echo (" />"); } } + else if ($json["widget"] == "checkbox") + { + if ($json["enabled"] === false) + { + echo ("" . $json["value"] . ""); + } + else + { + echo (""); + } + } else if ($json["widget"] == "obscuredText") { echo (""); @@ -366,6 +391,7 @@ else if ($json["widget"] == "monikerList") { $adw = new InstanceBrowser(); + $adw->Name = "ec_" . $fqecid; $adw->Attributes[] = new WebControlAttribute("data-ecid", $json["ecid"]); if (isset($json["enabled"]) && $json["enabled"] == false) { diff --git a/mocha-php/src/mocha-php/ui/pages/HomePage.phpx.php b/mocha-php/src/mocha-php/ui/pages/HomePage.phpx.php index 2830ec9..c09b51b 100644 --- a/mocha-php/src/mocha-php/ui/pages/HomePage.phpx.php +++ b/mocha-php/src/mocha-php/ui/pages/HomePage.phpx.php @@ -43,6 +43,7 @@ // $renderer = new HTMLRenderer($context); $renderer = new HTMLRenderer2($context); + $renderer->CodeBehindFileName = "HomePage"; $renderer->IsPostback = $this->Page->IsPostback; if ($this->Page->IsPostback) { 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 52a904d..b09e3c9 100644 --- a/mocha-php/src/mocha-php/ui/pages/InstancePage.phpx.php +++ b/mocha-php/src/mocha-php/ui/pages/InstancePage.phpx.php @@ -40,14 +40,19 @@ { $htmlRenderer = new HTMLRenderer($ctx); } + $htmlRenderer->CodeBehindFileName = "InstancePage"; $instkey = InstanceKey::parse($this->Page->GetPathVariableValue("instid")); $castkey = InstanceKey::parse($this->Page->GetPathVariableValue("castinstid")); - + + echo ("@ getInstanceByKey
"); $inst = $oms->getInstanceByKey($instkey); + + echo ("@ getResponse
"); $json = $oms->getResponse($inst, $inst); - // print_r($json); + echo ("@ renderResponse
"); + print_r($json); $htmlRenderer->renderResponse($json["value"]); return; diff --git a/mocha-php/src/mocha-php/ui/pages/OTSPage.phpx.php b/mocha-php/src/mocha-php/ui/pages/OTSPage.phpx.php index 2b2fd2c..960a6d0 100644 --- a/mocha-php/src/mocha-php/ui/pages/OTSPage.phpx.php +++ b/mocha-php/src/mocha-php/ui/pages/OTSPage.phpx.php @@ -130,23 +130,24 @@ { echo (" - instance: '" . $this->zqGetClassName($ir) . "'\n"); } + echo (" name: '" . $ir->Text . "'"); //$attrs = $oms->getRelatedInstances($ir, KnownRelationshipGuids::Class__has__Attribute); $attrs = $oms->getAttributes($ir); if (count($attrs) > 0) { - echo (" - attributes:\n"); + echo (" attributes:\n"); foreach ($attrs as $attr) { echo (" - instance: '" . $attr->GlobalIdentifier . "'\n"); - echo (" - value: '" . $oms->getAttributeValue($ir, $attr) . "'\n"); + echo (" value: '" . $oms->getAttributeValue($ir, $attr) . "'\n"); } } $rels = $oms->getRelationships($ir); if (count($rels) > 0) { - echo (" - relationships:\n"); + echo (" relationships:\n"); foreach ($rels as $rel) { $gid = $rel->GlobalIdentifier->__toString(); @@ -168,7 +169,7 @@ $iid = "&" . $this->EntityDefinitions2[$targ->GlobalIdentifier->__toStringFormat(false, "", "")] . ";"; } - echo (" = instance: '" . $iid . "'\n"); + echo (" - instance: '" . $iid . "'\n"); } } } @@ -177,13 +178,13 @@ $defaultTask = $oms->getRelatedInstance($ir, KnownRelationshipGuids::Class__has_default__Task); if ($defaultTask !== null) { - echo (" - defaultTask: '" . $defaultTask->GlobalIdentifier . "'\n"); + echo (" defaultTask: '" . $defaultTask->GlobalIdentifier . "'\n"); } $relTasks = $oms->getRelatedINstances($ir, KnownRelationshipGuids::Class__has_related__Task); if (count($relTasks) > 0) { - echo (" - relatedTasks:\n"); + echo (" relatedTasks:\n"); foreach ($relTasks as $relTask) { echo (" - instance: '" . $relTask->GlobalIdentifier . "'\n"); @@ -203,7 +204,7 @@ $ct = count($instances); for ($i = 0; $i < $ct; $i++) { - print("{ \"name\": \"mocha:inst" . $i . "\", \"title\": \"" . $oms->getInstanceText($instances[$i]) . "\", \"type\": \"class\", \"instanceId\": \"" . $instances[$i]->InstanceKey . "\" }"); + print("{ \"name\": \"mocha:inst" . $i . "\", \"title\": \"" . $instances[$i]->Text . "\", \"type\": \"class\", \"instanceId\": \"" . $instances[$i]->InstanceKey . "\" }"); if ($i < $ct - 1) { print(", "); @@ -212,7 +213,7 @@ print("] }"); print("] }"); - return; + exit(); } } } diff --git a/mocha-php/src/mocha-php/ui/pages/RelatedTaskPage.phpx.php b/mocha-php/src/mocha-php/ui/pages/RelatedTaskPage.phpx.php index 55475bf..b9096ce 100644 --- a/mocha-php/src/mocha-php/ui/pages/RelatedTaskPage.phpx.php +++ b/mocha-php/src/mocha-php/ui/pages/RelatedTaskPage.phpx.php @@ -39,16 +39,21 @@ $taskRenderer = new HTMLRenderer($context); $taskRenderer->TargetInstance = $instance; - $taskRenderer->IsPostback = $this->Page->IsPostback; - if ($this->Page->IsPostback) - { - $taskRenderer->processPostback(element: $initiatingElement); - } */ $context = new OmsContext(); $taskRenderer = new HTMLRenderer2($context); - $taskRenderer->renderTask($relatedTaskInstance, $instance); + $taskRenderer->CodeBehindFileName = "RelatedTaskPage"; + $taskRenderer->IsPostback = $this->Page->IsPostback; + if ($this->Page->IsPostback) + { + $initiatingElement = $oms->getRelatedInstance($relatedTaskInstance, KnownRelationshipGuids::Task__has_initiating__Element); + $taskRenderer->processPostback(element: $initiatingElement); + } + else + { + $taskRenderer->renderTask($relatedTaskInstance, $instance); + } exit(); } diff --git a/mocha-php/src/mocha-php/ui/pages/TaskPage.phpx.php b/mocha-php/src/mocha-php/ui/pages/TaskPage.phpx.php index 74556bc..33a6edd 100644 --- a/mocha-php/src/mocha-php/ui/pages/TaskPage.phpx.php +++ b/mocha-php/src/mocha-php/ui/pages/TaskPage.phpx.php @@ -27,7 +27,7 @@ $initiatingElement = $oms->getRelatedInstance($taskInstance, KnownRelationshipGuids::Task__has_initiating__Element); $context = new OmsContext(); - if ($_GET["legacy"] == "1") + if (isset($_GET["legacy"]) && $_GET["legacy"] == "1") { $taskRenderer = new HTMLRenderer($context); } @@ -37,11 +37,15 @@ } //$taskRenderer->TargetInstance = $instance; $taskRenderer->IsPostback = $this->Page->IsPostback; + $taskRenderer->CodeBehindFileName = "TaskPage"; if ($this->Page->IsPostback) { $taskRenderer->processPostback(element: $initiatingElement); } - $taskRenderer->renderTask($taskInstance); + else + { + $taskRenderer->renderTask($taskInstance); + } exit(); } diff --git a/phast b/phast index 2374310..ac75616 160000 --- a/phast +++ b/phast @@ -1 +1 @@ -Subproject commit 2374310056c7ea727839cfea04f7bdf2df34760b +Subproject commit ac7561660f08060b4685e10f08e7dd6ab84f96f2