major updates to mocha-php with HttpOmsClient
This commit is contained in:
parent
bd367d7ba8
commit
0a3e0090e7
@ -101,12 +101,15 @@ function mocha_get_current_user() : ?InstanceReference
|
|||||||
|
|
||||||
if ($currentTenant !== null)
|
if ($currentTenant !== null)
|
||||||
{
|
{
|
||||||
if (isset($_SESSION["user_token_" . $currentTenant->ID]))
|
if (isset($_SESSION["user_token_" . System::GetTenantName()]))
|
||||||
{
|
{
|
||||||
// SELECT FROM `Users` WHERE `Token` = $_SESSION["user_token"]
|
// SELECT FROM `Users` WHERE `Token` = $_SESSION["user_token"]
|
||||||
|
|
||||||
|
//! FIXME: this still results in loads of (tiny) HTTP calls to the OMS
|
||||||
|
// replace with: /tenants/super/instances?4$223=...&4$215=...
|
||||||
$insts = $oms->getInstancesOfByAttributes(KnownClassGuids::UserLogin, array
|
$insts = $oms->getInstancesOfByAttributes(KnownClassGuids::UserLogin, array
|
||||||
(
|
(
|
||||||
KnownAttributeGuids::Token => $_SESSION["user_token_" . $currentTenant->ID]
|
KnownAttributeGuids::Token => $_SESSION["user_token_" . System::GetTenantName()]
|
||||||
));
|
));
|
||||||
|
|
||||||
$currentUser = null;
|
$currentUser = null;
|
||||||
|
|||||||
@ -5,23 +5,39 @@
|
|||||||
{
|
{
|
||||||
public $ClassIndex;
|
public $ClassIndex;
|
||||||
public $InstanceIndex;
|
public $InstanceIndex;
|
||||||
|
public $IsDerived;
|
||||||
|
|
||||||
public function __construct(int $class_id, int $inst_id)
|
public function __construct(int $class_id, int $inst_id, bool $isDerived = false)
|
||||||
{
|
{
|
||||||
$this->ClassIndex = $class_id;
|
$this->ClassIndex = $class_id;
|
||||||
$this->InstanceIndex = $inst_id;
|
$this->InstanceIndex = $inst_id;
|
||||||
|
$this->IsDerived = $isDerived;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function Parse(?string $instanceKeyStr) : ?InstanceKey
|
public static function Parse(?string $instanceKeyStr) : ?InstanceKey
|
||||||
{
|
{
|
||||||
if ($instanceKeyStr !== null)
|
if ($instanceKeyStr !== null)
|
||||||
{
|
{
|
||||||
$split = explode("$", $instanceKeyStr);
|
$sep = null;
|
||||||
if (count($split) == 2)
|
$isDerived = false;
|
||||||
|
if (str_contains($instanceKeyStr, '$'))
|
||||||
{
|
{
|
||||||
if (is_numeric($split[0]) && is_numeric($split[1]))
|
$sep = '$';
|
||||||
|
}
|
||||||
|
else if (str_contains($instanceKeyStr, '!'))
|
||||||
|
{
|
||||||
|
$sep = '!';
|
||||||
|
$isDerived = true;
|
||||||
|
}
|
||||||
|
if ($sep != null)
|
||||||
|
{
|
||||||
|
$split = explode($sep, $instanceKeyStr);
|
||||||
|
if (count($split) == 2)
|
||||||
{
|
{
|
||||||
return new InstanceKey(intval($split[0]), intval($split[1]));
|
if (is_numeric($split[0]) && is_numeric($split[1]))
|
||||||
|
{
|
||||||
|
return new InstanceKey(intval($split[0]), intval($split[1]), $isDerived);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,18 @@
|
|||||||
public ?int $DatabaseId;
|
public ?int $DatabaseId;
|
||||||
public InstanceKey|null $InstanceKey;
|
public InstanceKey|null $InstanceKey;
|
||||||
public UUID|null $GlobalIdentifier;
|
public UUID|null $GlobalIdentifier;
|
||||||
|
public string|null $Text;
|
||||||
|
public InstanceReference|null $DefaultTask;
|
||||||
|
public string|null $DefaultTaskUrl;
|
||||||
|
public InstanceReference|null $ParentClass;
|
||||||
|
|
||||||
|
public static function parse(array|null $obj) : InstanceReference|null
|
||||||
|
{
|
||||||
|
if ($obj == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new InstanceReference(null, InstanceKey::parse($obj["iid"]), UUID::parse($obj["globalIdentifier"]), $obj["text"], InstanceReference::parse($obj["parentClass"]["defaultTask"]), InstanceReference::parse($obj["parentClass"]));
|
||||||
|
}
|
||||||
|
|
||||||
public static function toInstanceKeys(array $instanceReferences) : array
|
public static function toInstanceKeys(array $instanceReferences) : array
|
||||||
{
|
{
|
||||||
@ -25,7 +37,7 @@
|
|||||||
return $keys;
|
return $keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct(?int $databaseId, InstanceKey|null $instanceKey, UUID|string|null $globalIdentifier)
|
public function __construct(?int $databaseId, InstanceKey|null $instanceKey, UUID|string|null $globalIdentifier, string|null $text = null, InstanceReference|string|null $defaultTaskOrUrl = null, InstanceReference|null $parentClass = null)
|
||||||
{
|
{
|
||||||
//$this->OMS = $oms;
|
//$this->OMS = $oms;
|
||||||
$this->DatabaseId = $databaseId;
|
$this->DatabaseId = $databaseId;
|
||||||
@ -36,6 +48,19 @@
|
|||||||
$globalIdentifier = UUID::parse($globalIdentifier);
|
$globalIdentifier = UUID::parse($globalIdentifier);
|
||||||
}
|
}
|
||||||
$this->GlobalIdentifier = $globalIdentifier;
|
$this->GlobalIdentifier = $globalIdentifier;
|
||||||
|
$this->Text = $text;
|
||||||
|
|
||||||
|
if (is_string($defaultTaskOrUrl))
|
||||||
|
{
|
||||||
|
$this->DefaultTaskUrl = $defaultTaskOrUrl;
|
||||||
|
$this->DefaultTask = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->DefaultTask = $defaultTaskOrUrl;
|
||||||
|
$this->DefaultTaskUrl = null;
|
||||||
|
}
|
||||||
|
$this->ParentClass = $parentClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -255,6 +255,7 @@ class KnownRelationshipGuids
|
|||||||
const Instance__for__Element_Content = "c3959f84248d4edea3f2f262917c7b56";
|
const Instance__for__Element_Content = "c3959f84248d4edea3f2f262917c7b56";
|
||||||
|
|
||||||
const Element_Content__has__Layout = "1ab7412005ea4acab6d3c7e0133e0c4f";
|
const Element_Content__has__Layout = "1ab7412005ea4acab6d3c7e0133e0c4f";
|
||||||
|
|
||||||
const Element_Content__has__EC_Dynamic_Display_Option = "{4a41391a-c325-4182-920a-a94ad28c15fa}";
|
const Element_Content__has__EC_Dynamic_Display_Option = "{4a41391a-c325-4182-920a-a94ad28c15fa}";
|
||||||
|
|
||||||
const EC_Dynamic_Display_Option__modifies__Element_Content = "{4d091643-2bfc-4b83-b3e4-8a3b22c665a9}";
|
const EC_Dynamic_Display_Option__modifies__Element_Content = "{4d091643-2bfc-4b83-b3e4-8a3b22c665a9}";
|
||||||
|
|||||||
@ -192,7 +192,6 @@
|
|||||||
*/
|
*/
|
||||||
public function getParentClass(InstanceReference $inst) : ?InstanceReference
|
public function getParentClass(InstanceReference $inst) : ?InstanceReference
|
||||||
{
|
{
|
||||||
$gid = $inst->GlobalIdentifier->__toString();
|
|
||||||
$forClass = $this->getRelatedInstance($inst, $this->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Instance__for__Class));
|
$forClass = $this->getRelatedInstance($inst, $this->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Instance__for__Class));
|
||||||
return $forClass;
|
return $forClass;
|
||||||
}
|
}
|
||||||
@ -964,9 +963,14 @@
|
|||||||
return new OmsContext();
|
return new OmsContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isConnected()
|
public function isConnected() : bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function processElement(InstanceReference $element, array $values) : array | bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -56,9 +56,10 @@
|
|||||||
{
|
{
|
||||||
//trigger_error("curl_request for url " . $relativeUrl);
|
//trigger_error("curl_request for url " . $relativeUrl);
|
||||||
$curl = $this->curl_new($relativeUrl);
|
$curl = $this->curl_new($relativeUrl);
|
||||||
|
\curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-Forwarded-For:" . $_SERVER["REMOTE_ADDR"]));
|
||||||
if ($method == HttpRequestMethod::POST)
|
if ($method == HttpRequestMethod::POST)
|
||||||
{
|
{
|
||||||
trigger_error("POST " . $relativeUrl);
|
//trigger_error("POST " . $relativeUrl);
|
||||||
\curl_setopt($curl, CURLOPT_POST, true);
|
\curl_setopt($curl, CURLOPT_POST, true);
|
||||||
if ($data !== null)
|
if ($data !== null)
|
||||||
{
|
{
|
||||||
@ -70,7 +71,7 @@
|
|||||||
{
|
{
|
||||||
if ($dataFormat == HttpPostDataFormat::URLENCODED)
|
if ($dataFormat == HttpPostDataFormat::URLENCODED)
|
||||||
{
|
{
|
||||||
trigger_error("POST(" . count($data) . ") " . http_build_query2($data));
|
//trigger_error("POST(" . count($data) . ") " . http_build_query2($data));
|
||||||
\curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query2($data));
|
\curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query2($data));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -196,9 +197,54 @@
|
|||||||
|
|
||||||
return $insts2;
|
return $insts2;
|
||||||
}
|
}
|
||||||
|
public function search(string $query, array | InstanceReference | null $parentClasses = null, string | null $m = null) : array | bool
|
||||||
|
{
|
||||||
|
$uri = "/tenants/super/instances?";
|
||||||
|
|
||||||
|
if ($m != null)
|
||||||
|
{
|
||||||
|
$uri .= "m=" . urlencode($m) . "&";
|
||||||
|
}
|
||||||
|
$uri .= "q=" . urlencode($query);
|
||||||
|
if (is_array($parentClasses))
|
||||||
|
{
|
||||||
|
for ($i = 0; $i < count($parentClasses); $i++)
|
||||||
|
{
|
||||||
|
$uri .= "&parentClassIid=" . $parentClasses[$i]->InstanceKey->__toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($parentClasses instanceof InstanceReference)
|
||||||
|
{
|
||||||
|
$uri .= "&parentClassIid=" . $parentClasses->InstanceKey->__toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $this->curl_request_json($uri, HttpRequestMethod::GET);
|
||||||
|
return $json;
|
||||||
|
}
|
||||||
public function getInstancesOfByAttributes(array|InstanceKey|InstanceReference|string|null $parentClass, array $parms)
|
public function getInstancesOfByAttributes(array|InstanceKey|InstanceReference|string|null $parentClass, array $parms)
|
||||||
{
|
{
|
||||||
$parentClass = $this->normalizeInstanceReference($parentClass);
|
$parentClass = $this->normalizeInstanceReference($parentClass);
|
||||||
|
$data = array();
|
||||||
|
foreach ($parms as $k => $v)
|
||||||
|
{
|
||||||
|
$data[$this->normalizeInstanceReference($k)->GlobalIdentifier->__toString()] = $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
$insts2 = array();
|
||||||
|
$url = "/tenants/" . $this->getTenantName() . "/instances";
|
||||||
|
if ($parentClass !== null)
|
||||||
|
{
|
||||||
|
$url .= "?parentClassIid=" . $parentClass->GlobalIdentifier;
|
||||||
|
}
|
||||||
|
$json = $this->curl_request_json($url, HttpRequestMethod::POST, $data);
|
||||||
|
foreach ($json["instances"] as $inst)
|
||||||
|
{
|
||||||
|
$insts2[] = new InstanceReference(null, InstanceKey::parse($inst["iid"]), UUID::parse($inst["globalIdentifier"]));
|
||||||
|
}
|
||||||
|
return $insts2;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
// FIXME: NOT IMPLEMENTED
|
// FIXME: NOT IMPLEMENTED
|
||||||
//usage:
|
//usage:
|
||||||
// getInstanceByAttributes (array ( getInstanceByGlobalIdentifier(NAME_ATTRIBUTE) => "zq-developer" ))
|
// getInstanceByAttributes (array ( getInstanceByGlobalIdentifier(NAME_ATTRIBUTE) => "zq-developer" ))
|
||||||
@ -227,6 +273,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $insts2;
|
return $insts2;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInstanceData(array|InstanceKey|InstanceReference|string|null $inst)
|
public function getInstanceData(array|InstanceKey|InstanceReference|string|null $inst)
|
||||||
@ -312,7 +359,7 @@
|
|||||||
public function getInstanceByKey(InstanceKey|string $key) : ?InstanceReference
|
public function getInstanceByKey(InstanceKey|string $key) : ?InstanceReference
|
||||||
{
|
{
|
||||||
$result = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $key);
|
$result = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $key);
|
||||||
return new InstanceReference(null, InstanceKey::parse($result["instanceKey"]), UUID::parse($result["globalIdentifier"]));
|
return new InstanceReference(null, InstanceKey::parse($result["iid"]), UUID::parse($result["globalIdentifier"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -321,7 +368,7 @@
|
|||||||
public function getInstanceByGlobalIdentifier(UUID|string $inst) : ?InstanceReference
|
public function getInstanceByGlobalIdentifier(UUID|string $inst) : ?InstanceReference
|
||||||
{
|
{
|
||||||
$result = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $inst);
|
$result = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $inst);
|
||||||
return new InstanceReference(null, InstanceKey::parse($result["instanceKey"]), UUID::parse($result["globalIdentifier"]));
|
return new InstanceReference(null, InstanceKey::parse($result["iid"]), UUID::parse($result["globalIdentifier"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createInstanceOf(InstanceReference $classInstance) : ?InstanceReference
|
public function createInstanceOf(InstanceReference $classInstance) : ?InstanceReference
|
||||||
@ -337,6 +384,26 @@
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function processElement(InstanceReference $element, array $values) : array | bool
|
||||||
|
{
|
||||||
|
$result = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $element->GlobalIdentifier . "/element", HttpRequestMethod::POST, $values);
|
||||||
|
if ($result["result"] == "success")
|
||||||
|
{
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRelatedTasks(InstanceReference $inst)
|
||||||
|
{
|
||||||
|
$result = $this->curl_request_json("/tenants/" . $this->getTenantName() . "/instances/" . $inst->GlobalIdentifier . "/relatedTasks", HttpRequestMethod::GET);
|
||||||
|
if ($result["result"] == "success")
|
||||||
|
{
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
return [ ];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -1,11 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Mocha\Search;
|
namespace Mocha\Search;
|
||||||
|
use Mocha\Core\InstanceKey;
|
||||||
|
use Mocha\Core\InstanceReference;
|
||||||
use Mocha\Core\KnownClassGuids;
|
use Mocha\Core\KnownClassGuids;
|
||||||
|
use Phast\UUID;
|
||||||
|
|
||||||
class SearchHelper
|
class SearchHelper
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Mocha\Oms\MySQLDatabaseOms
|
* @var \Mocha\Core\Oms
|
||||||
*/
|
*/
|
||||||
private $_OMS;
|
private $_OMS;
|
||||||
public function __construct($oms)
|
public function __construct($oms)
|
||||||
@ -19,12 +22,24 @@
|
|||||||
public $LastQuery;
|
public $LastQuery;
|
||||||
|
|
||||||
|
|
||||||
public function search(string $q)
|
public function search(string $q, string | null $m = null)
|
||||||
{
|
{
|
||||||
|
// this is ALL MySQL-specific
|
||||||
|
/*
|
||||||
if ($q == "")
|
if ($q == "")
|
||||||
return $this->searchSlow($q);
|
return $this->searchSlow($q);
|
||||||
|
|
||||||
return $this->searchIndexed($q);
|
return $this->searchIndexed($q);
|
||||||
|
*/
|
||||||
|
|
||||||
|
$json = $this->_OMS->search($q, $this->ValidClasses, $m);
|
||||||
|
$results = array();
|
||||||
|
|
||||||
|
foreach ($json["instances"] as $obj)
|
||||||
|
{
|
||||||
|
$results[] = InstanceReference::parse($obj);
|
||||||
|
}
|
||||||
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchIndexed(string $q)
|
public function searchIndexed(string $q)
|
||||||
|
|||||||
@ -194,8 +194,8 @@
|
|||||||
$li = new WebControl();
|
$li = new WebControl();
|
||||||
$li->TagName = "li";
|
$li->TagName = "li";
|
||||||
|
|
||||||
$instParent = $oms->getParentClass($inst);
|
//$instParent = $oms->getParentClass($inst);
|
||||||
$parentClassName = $oms->getInstanceText($instParent);
|
//$parentClassName = $oms->getInstanceText($instParent);
|
||||||
|
|
||||||
$adw = new AdditionalDetailWidget("");
|
$adw = new AdditionalDetailWidget("");
|
||||||
$adw->RelatedActionButtonUrl = "~/d/inst/" . $inst->InstanceKey . "/rel-tasks.htmld";
|
$adw->RelatedActionButtonUrl = "~/d/inst/" . $inst->InstanceKey . "/rel-tasks.htmld";
|
||||||
@ -207,9 +207,9 @@
|
|||||||
}
|
}
|
||||||
$adw->Attributes[] = new WebControlAttribute("data-instance-id", $inst->InstanceKey);
|
$adw->Attributes[] = new WebControlAttribute("data-instance-id", $inst->InstanceKey);
|
||||||
$adw->ClassList[] = "mcx-moniker";
|
$adw->ClassList[] = "mcx-moniker";
|
||||||
$adw->ClassTitle = $parentClassName;
|
//$adw->ClassTitle = $parentClassName;
|
||||||
|
|
||||||
$defaultTaskUrl = $oms->getDefaultTaskUrl($inst);
|
$defaultTaskUrl = $inst->DefaultTaskUrl; // $oms->getDefaultTaskUrl($inst);
|
||||||
if ($defaultTaskUrl !== null)
|
if ($defaultTaskUrl !== null)
|
||||||
{
|
{
|
||||||
$adw->TargetURL = $defaultTaskUrl;
|
$adw->TargetURL = $defaultTaskUrl;
|
||||||
@ -226,8 +226,13 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$adw->Text = $oms->getInstanceText($inst);
|
if ($inst->Text !== null)
|
||||||
|
{
|
||||||
|
$adw->Text = $inst->Text;
|
||||||
|
}
|
||||||
|
//$adw->Text = $oms->getInstanceText($inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$this->MenuItems = array(
|
$this->MenuItems = array(
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,13 @@
|
|||||||
|
|
||||||
namespace Mocha\UI\Renderers\HTML;
|
namespace Mocha\UI\Renderers\HTML;
|
||||||
|
|
||||||
|
use Mocha\Core\InstanceKey;
|
||||||
|
use Mocha\Core\InstanceReference;
|
||||||
use Mocha\Core\OmsContext;
|
use Mocha\Core\OmsContext;
|
||||||
|
use Mocha\UI\Controls\InstanceBrowser;
|
||||||
use Phast\System;
|
use Phast\System;
|
||||||
|
use Phast\WebControlAttribute;
|
||||||
|
use Phast\WebControls\AdditionalDetailWidget;
|
||||||
|
|
||||||
class HTMLRenderer2 extends HTMLRenderer
|
class HTMLRenderer2 extends HTMLRenderer
|
||||||
{
|
{
|
||||||
@ -12,6 +17,60 @@
|
|||||||
parent::__construct($context, $withoutOms);
|
parent::__construct($context, $withoutOms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function processPostback(InstanceReference $element) : array | bool
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Mocha\Core\Oms
|
||||||
|
*/
|
||||||
|
$oms = mocha_get_oms();
|
||||||
|
|
||||||
|
$values = array();
|
||||||
|
foreach ($_POST as $key => $value)
|
||||||
|
{
|
||||||
|
if (str_starts_with($key, "ec_"))
|
||||||
|
{
|
||||||
|
$fqecid = substr($key, 3);
|
||||||
|
$values[$fqecid] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$array = $this->OMS->processElement($element, $values);
|
||||||
|
if ($array === false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_callable($this->ProcessPostbackFunction))
|
||||||
|
{
|
||||||
|
// call user-defined ProcessPostbackFunction
|
||||||
|
return call_user_func($this->ProcessPostbackFunction, $this, $element, $array);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$dummy = [ ];
|
||||||
|
if (!$this->processRelatedPostback($dummy, $element))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($this->FailedValidations) > 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ($this->DebugMode)
|
||||||
|
{
|
||||||
|
echo ("debug mode done");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST["ReturnToURL"]))
|
||||||
|
{
|
||||||
|
System::Redirect($_POST["ReturnToURL"]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
|
|
||||||
public function renderInitialElement($element)
|
public function renderInitialElement($element)
|
||||||
{
|
{
|
||||||
$json = $this->OMS->getResponse($element);
|
$json = $this->OMS->getResponse($element);
|
||||||
@ -32,7 +91,11 @@
|
|||||||
|
|
||||||
public function renderFragment(array $json, $fqecidPrefix = "")
|
public function renderFragment(array $json, $fqecidPrefix = "")
|
||||||
{
|
{
|
||||||
|
// echo ("renderFragment:<br/>"); print_r($json);
|
||||||
|
//print_r($json); die();
|
||||||
$fqecid = $fqecidPrefix . $json["ecid"];
|
$fqecid = $fqecidPrefix . $json["ecid"];
|
||||||
|
// we do not yet know how to deal with fully-qualified ECIDs
|
||||||
|
$fqecid = $json["ecid"];
|
||||||
if ($json["visible"] === false)
|
if ($json["visible"] === false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -42,6 +105,45 @@
|
|||||||
{
|
{
|
||||||
$this->renderFragment($json["body"]);
|
$this->renderFragment($json["body"]);
|
||||||
}
|
}
|
||||||
|
else if ($json["widget"] == "grid")
|
||||||
|
{
|
||||||
|
echo ("<table class=\"uwt-listview mcx-element\" data-ecid=\"" . $json["ecid"] . "\" data-instance-id=\"" . $json["iid"] . "\">");
|
||||||
|
echo ("<thead>");
|
||||||
|
echo ("<tr>");
|
||||||
|
foreach ($json["columns"] as $col)
|
||||||
|
{
|
||||||
|
if (isset($col["visible"]) && !$col["visible"])
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo ("<th data-ecid=\"" . $col["ecid"] . "\" data-instance-id=\"" . $col["iid"] . "\">");
|
||||||
|
echo ("<label>" . $col["label"] . "</label>");
|
||||||
|
echo ("</th>");
|
||||||
|
}
|
||||||
|
echo ("</tr>");
|
||||||
|
echo ("</thead>");
|
||||||
|
echo ("<tbody>");
|
||||||
|
foreach ($json["rows"] as $row)
|
||||||
|
{
|
||||||
|
echo ("<tr>");
|
||||||
|
foreach ($row["cellsMap"] as $key => $col)
|
||||||
|
{
|
||||||
|
if (isset($col["visible"]) && !$col["visible"])
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo ("<td data-ecid=\"" . $col["ecid"] . "\" data-instance-id=\"" . $col["iid"] . "\">");
|
||||||
|
//print_r($col);
|
||||||
|
$this->renderFragment($col);
|
||||||
|
echo ("</td>");
|
||||||
|
}
|
||||||
|
echo ("</tr>");
|
||||||
|
}
|
||||||
|
echo ("</tbody>");
|
||||||
|
echo ("</table>");
|
||||||
|
}
|
||||||
else if ($json["widget"] == "vbox")
|
else if ($json["widget"] == "vbox")
|
||||||
{
|
{
|
||||||
echo ("<div class=\"uwt-layout-box uwt-orientation-vertical\">");
|
echo ("<div class=\"uwt-layout-box uwt-orientation-vertical\">");
|
||||||
@ -73,7 +175,9 @@
|
|||||||
echo ("<div class=\"uwt-formview mcx-element\" data-instance-id=\"" . $json["iid"] . "\" data-ecid=\"" . $fqecid . "\">");
|
echo ("<div class=\"uwt-formview mcx-element\" data-instance-id=\"" . $json["iid"] . "\" data-ecid=\"" . $fqecid . "\">");
|
||||||
foreach ($json["children"] as $child)
|
foreach ($json["children"] as $child)
|
||||||
{
|
{
|
||||||
$fqecidChild = $fqecidPrefix . $child["ecid"];
|
// $fqecidChild = $fqecidPrefix . $child["ecid"];
|
||||||
|
$fqecidChild = $child["ecid"];
|
||||||
|
|
||||||
echo ("<div class=\"uwt-formview-item mcx-elementcontent");
|
echo ("<div class=\"uwt-formview-item mcx-elementcontent");
|
||||||
if (!isset($child["label"]))
|
if (!isset($child["label"]))
|
||||||
{
|
{
|
||||||
@ -87,6 +191,10 @@
|
|||||||
{
|
{
|
||||||
echo(" mcx-required");
|
echo(" mcx-required");
|
||||||
}
|
}
|
||||||
|
if ($child["widget"] == "grid")
|
||||||
|
{
|
||||||
|
echo (" mcx-element");
|
||||||
|
}
|
||||||
echo ("\" data-instance-id=\"" . $child["iid"] . "\" data-ecid=\"" . $child["ecid"] . "\">");
|
echo ("\" data-instance-id=\"" . $child["iid"] . "\" data-ecid=\"" . $child["ecid"] . "\">");
|
||||||
|
|
||||||
echo ("<div class=\"uwt-formview-item-label\">");
|
echo ("<div class=\"uwt-formview-item-label\">");
|
||||||
@ -129,6 +237,62 @@
|
|||||||
{
|
{
|
||||||
echo ("<input id=\"ec_" . $fqecid . "\" name=\"ec_" . $fqecid . "\" type=\"password\" value=\"" . $json["value"] . "\" />");
|
echo ("<input id=\"ec_" . $fqecid . "\" name=\"ec_" . $fqecid . "\" type=\"password\" value=\"" . $json["value"] . "\" />");
|
||||||
}
|
}
|
||||||
|
else if ($json["widget"] == "monikerList")
|
||||||
|
{
|
||||||
|
$adw = new InstanceBrowser();
|
||||||
|
$adw->Attributes[] = new WebControlAttribute("data-ecid", $json["ecid"]);
|
||||||
|
if (isset($json["enabled"]) && $json["enabled"] == false)
|
||||||
|
{
|
||||||
|
$adw->Editable = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$adw->Editable = true;
|
||||||
|
}
|
||||||
|
if (isset($json["instances"]) && count($json["instances"]) > 0)
|
||||||
|
{
|
||||||
|
foreach ($json["instances"] as $json_inst)
|
||||||
|
{
|
||||||
|
if ($json_inst["widget"] == "moniker")
|
||||||
|
{
|
||||||
|
// $adw->SelectedInstances[] = $this->OMS->getInstanceByKey(InstanceKey::Parse($json_inst["instanceId"]));
|
||||||
|
$uri = $json_inst["target"];
|
||||||
|
if ($uri == "")
|
||||||
|
{
|
||||||
|
$uri = $this->makeSelfUri($json["selfUriTemplate"]);
|
||||||
|
}
|
||||||
|
$adw->SelectedInstances[] = new InstanceReference(null, InstanceKey::Parse($json_inst["instanceId"]), null, $json_inst["text"], $uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$adw->Text = $json["text"];
|
||||||
|
}
|
||||||
|
echo ("<!-- ");
|
||||||
|
print_r($json);
|
||||||
|
echo ("-->");
|
||||||
|
$adw->Render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeSelfUri(string $uriTemplate)
|
||||||
|
{
|
||||||
|
$uri_parts = explode("/", $uriTemplate);
|
||||||
|
$uri_parts2 = array();
|
||||||
|
$i = 0;
|
||||||
|
foreach ($uri_parts as $part)
|
||||||
|
{
|
||||||
|
$uri_parts2[] = $part;
|
||||||
|
if ($i == 1)
|
||||||
|
{
|
||||||
|
$uri_parts2[] = "d";
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$uri_parts2[count($uri_parts2) - 1] .= ".htmld";
|
||||||
|
|
||||||
|
return implode("/", $uri_parts2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -182,32 +182,34 @@ function McxInstanceBrowser(parentElement)
|
|||||||
this.NativeObject.clearSearchResults();
|
this.NativeObject.clearSearchResults();
|
||||||
System.ClassList.Remove(this.NativeObject.SearchResultsElement, "mcx-placeholder-visible");
|
System.ClassList.Remove(this.NativeObject.SearchResultsElement, "mcx-placeholder-visible");
|
||||||
|
|
||||||
for (var i = 0; i < json.items.length; i++)
|
if (typeof(json.items) !== 'undefined')
|
||||||
{
|
{
|
||||||
var li = document.createElement("li");
|
for (var i = 0; i < json.items.length; i++)
|
||||||
li.className = "uwt-menu-item uwt-menu-item-command uwt-visible";
|
|
||||||
li.searchResult = json.items[i];
|
|
||||||
li.NativeObject = this.NativeObject;
|
|
||||||
li.addEventListener("click", function()
|
|
||||||
{
|
{
|
||||||
if (this.NativeObject.activateSearchResult(this.searchResult))
|
var li = document.createElement("li");
|
||||||
|
li.className = "uwt-menu-item uwt-menu-item-command uwt-visible";
|
||||||
|
li.searchResult = json.items[i];
|
||||||
|
li.NativeObject = this.NativeObject;
|
||||||
|
li.addEventListener("click", function()
|
||||||
{
|
{
|
||||||
this.NativeObject.setEditing(false);
|
if (this.NativeObject.activateSearchResult(this.searchResult))
|
||||||
}
|
{
|
||||||
});
|
this.NativeObject.setEditing(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var moniker = McxMoniker.create(json.items[i].instanceId, json.items[i].text);
|
var moniker = McxMoniker.create(json.items[i].instanceId, json.items[i].text);
|
||||||
/*
|
/*
|
||||||
var span = document.createElement("span");
|
var span = document.createElement("span");
|
||||||
span.className = "uwt-title uwt-description-empty";
|
span.className = "uwt-title uwt-description-empty";
|
||||||
span.innerText = json.items[i].title;
|
span.innerText = json.items[i].title;
|
||||||
li.appendChild(span);
|
li.appendChild(span);
|
||||||
*/
|
*/
|
||||||
li.appendChild(moniker);
|
li.appendChild(moniker);
|
||||||
|
|
||||||
this.NativeObject.SearchResultsMenuElement.appendChild(li);
|
this.NativeObject.SearchResultsMenuElement.appendChild(li);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.ClassList.Remove(this.NativeObject.SearchResultsElement, "uwt-loading");
|
System.ClassList.Remove(this.NativeObject.SearchResultsElement, "uwt-loading");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -180,12 +180,11 @@ function McxMoniker(parentElement)
|
|||||||
xhr.thiss = this;
|
xhr.thiss = this;
|
||||||
xhr.onreadystatechange = function(e)
|
xhr.onreadystatechange = function(e)
|
||||||
{
|
{
|
||||||
var xhr = e.target;
|
if (this.readyState == 4)
|
||||||
if (xhr.readyState == 4)
|
|
||||||
{
|
{
|
||||||
if (xhr.status == 200)
|
if (this.status == 200)
|
||||||
{
|
{
|
||||||
var json = JSON.parse(xhr.responseText);
|
var json = JSON.parse(this.responseText);
|
||||||
console.log(json);
|
console.log(json);
|
||||||
|
|
||||||
if (json.result == "failure" && json.responseCode == 403)
|
if (json.result == "failure" && json.responseCode == 403)
|
||||||
@ -198,20 +197,20 @@ function McxMoniker(parentElement)
|
|||||||
{
|
{
|
||||||
if (json.instance.label)
|
if (json.instance.label)
|
||||||
{
|
{
|
||||||
// xhr.thiss.setClassTitle("Return Attribute Method Binding");
|
// this.thiss.setClassTitle("Return Attribute Method Binding");
|
||||||
xhr.thiss.setClassTitle(json.instance.label);
|
this.thiss.setClassTitle(json.instance.label);
|
||||||
}
|
}
|
||||||
if (json.instance.title)
|
if (json.instance.title)
|
||||||
{
|
{
|
||||||
// xhr.thiss.setInstanceTitle("Common Text@get Concatenated Date and Time Format (BA)*P*S(public)[ramb]");
|
// this.thiss.setInstanceTitle("Common Text@get Concatenated Date and Time Format (BA)*P*S(public)[ramb]");
|
||||||
xhr.thiss.setInstanceTitle(json.instance.title);
|
this.thiss.setInstanceTitle(json.instance.title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (json.taskGroups)
|
if (json.taskGroups)
|
||||||
{
|
{
|
||||||
System.ClassList.Remove(xhr.thiss.ActionsMenuElement.parentElement, "uwt-empty");
|
System.ClassList.Remove(this.thiss.ActionsMenuElement.parentElement, "uwt-empty");
|
||||||
|
|
||||||
xhr.thiss.ActionsMenuElement.innerHTML = "";
|
this.thiss.ActionsMenuElement.innerHTML = "";
|
||||||
for (var i = 0; i < json.taskGroups.length; i++)
|
for (var i = 0; i < json.taskGroups.length; i++)
|
||||||
{
|
{
|
||||||
var tgprimary = json.taskGroups[i].taskGroups[0];
|
var tgprimary = json.taskGroups[i].taskGroups[0];
|
||||||
@ -256,7 +255,7 @@ function McxMoniker(parentElement)
|
|||||||
|
|
||||||
li.appendChild(ulMenuChild);
|
li.appendChild(ulMenuChild);
|
||||||
|
|
||||||
xhr.thiss.ActionsMenuElement.appendChild(li);
|
this.thiss.ActionsMenuElement.appendChild(li);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,17 +269,17 @@ function McxMoniker(parentElement)
|
|||||||
|
|
||||||
if (json.preview)
|
if (json.preview)
|
||||||
{
|
{
|
||||||
xhr.thiss.PreviewContentElement.innerHTML = json.preview;
|
this.thiss.PreviewContentElement.innerHTML = json.preview;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.ClassList.Remove(xhr.thiss.PopupElement, "uwt-loading");
|
System.ClassList.Remove(this.thiss.PopupElement, "uwt-loading");
|
||||||
xhr.thiss.ParentElement.NativeObject.UpdatePopupLocation();
|
this.thiss.ParentElement.NativeObject.UpdatePopupLocation();
|
||||||
}
|
}
|
||||||
else if (xhr.status == 403)
|
else if (this.status == 403)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (xhr.status == 0)
|
else if (this.status == 0)
|
||||||
{
|
{
|
||||||
Alert.show("Please check your connection and try again", "Connection lost", "uwt-color-danger", 5000);
|
Alert.show("Please check your connection and try again", "Connection lost", "uwt-color-danger", 5000);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,11 +20,14 @@ function McxTypeaheadSearch(parentElement)
|
|||||||
|
|
||||||
this.search = function(query)
|
this.search = function(query)
|
||||||
{
|
{
|
||||||
|
if (query.length < 3)
|
||||||
|
return;
|
||||||
|
|
||||||
System.ClassList.Add(this.PopupElement, "uwt-visible");
|
System.ClassList.Add(this.PopupElement, "uwt-visible");
|
||||||
System.ClassList.Add(this.PopupElement, "uwt-loading");
|
System.ClassList.Add(this.PopupElement, "uwt-loading");
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
var searchUrl = System.ExpandRelativePath("~/" + System.TenantName + "/search.htmld?q=" + encodeURIComponent(query));
|
var searchUrl = System.ExpandRelativePath("~/" + System.TenantName + "/search.htmld?m=typeahead&q=" + encodeURIComponent(query));
|
||||||
// var searchUrl = System.ExpandRelativePath("~/madi/pex/fs/" + System.TenantName + "typeahead?q=" + encodeURIComponent(query) + "&contextualsearch=true&autocomplete=true&clientRequestId=");
|
// var searchUrl = System.ExpandRelativePath("~/madi/pex/fs/" + System.TenantName + "typeahead?q=" + encodeURIComponent(query) + "&contextualsearch=true&autocomplete=true&clientRequestId=");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -67,7 +70,7 @@ function McxTypeaheadSearch(parentElement)
|
|||||||
|
|
||||||
span = document.createElement("span");
|
span = document.createElement("span");
|
||||||
span.className = "uwt-description";
|
span.className = "uwt-description";
|
||||||
span.innerText = json.items[i].summaryDescription;
|
span.innerText = json.items[i].subtitle1; // json.items[i].summaryDescription;
|
||||||
li.appendChild(span);
|
li.appendChild(span);
|
||||||
|
|
||||||
this.NativeObject.MenuElement.appendChild(li);
|
this.NativeObject.MenuElement.appendChild(li);
|
||||||
|
|||||||
@ -148,7 +148,7 @@ div.uwt-actionpreviewbutton
|
|||||||
position: relative;
|
position: relative;
|
||||||
&> ul.uwt-menu
|
&> ul.uwt-menu
|
||||||
{
|
{
|
||||||
display: none;
|
// display: none; // this should already be handled by uwt-popup
|
||||||
position: absolute;
|
position: absolute;
|
||||||
//margin-left: 20px;
|
//margin-left: 20px;
|
||||||
left: @ActionPreviewButton_ActionMenu_Width;
|
left: @ActionPreviewButton_ActionMenu_Width;
|
||||||
@ -156,9 +156,10 @@ div.uwt-actionpreviewbutton
|
|||||||
width: max-content;
|
width: max-content;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
&:hover > ul.uwt-menu
|
&:hover > ul.uwt-menu, &:focus-within > ul.uwt-menu
|
||||||
{
|
{
|
||||||
display: block;
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -131,3 +131,12 @@ div.mcx-elementcontent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.uwt-formview-item.mcx-element
|
||||||
|
{
|
||||||
|
display: block !important;
|
||||||
|
&> div.uwt-formview-item-label, &> div.uwt-formview-item-content
|
||||||
|
{
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
use Mocha\UI\Controls\InstanceBrowser;
|
use Mocha\UI\Controls\InstanceBrowser;
|
||||||
use Mocha\UI\Renderers\HTML\HTMLRenderer;
|
use Mocha\UI\Renderers\HTML\HTMLRenderer;
|
||||||
|
use Mocha\UI\Renderers\HTML\HTMLRenderer2;
|
||||||
use Phast\RenderingEventArgs;
|
use Phast\RenderingEventArgs;
|
||||||
use Phast\WebPage;
|
use Phast\WebPage;
|
||||||
|
|
||||||
@ -21,10 +22,24 @@
|
|||||||
{
|
{
|
||||||
parent::OnRendering($re);
|
parent::OnRendering($re);
|
||||||
|
|
||||||
/**
|
$useLegacyRendering = false;
|
||||||
* @var MySQLDatabaseOms
|
if (isset($_GET["useLegacyRendering"]) && $_GET["useLegacyRendering"] == true)
|
||||||
*/
|
{
|
||||||
|
$useLegacyRendering = true;
|
||||||
|
}
|
||||||
|
|
||||||
$oms = mocha_get_oms();
|
$oms = mocha_get_oms();
|
||||||
|
$useRendererV2 = true;
|
||||||
|
|
||||||
|
$ctx = new OmsContext();
|
||||||
|
if ($useRendererV2)
|
||||||
|
{
|
||||||
|
$htmlRenderer = new HTMLRenderer2($ctx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$htmlRenderer = new HTMLRenderer($ctx);
|
||||||
|
}
|
||||||
|
|
||||||
$instkey = InstanceKey::parse($this->Page->GetPathVariableValue("instid"));
|
$instkey = InstanceKey::parse($this->Page->GetPathVariableValue("instid"));
|
||||||
|
|
||||||
@ -33,9 +48,6 @@
|
|||||||
$inst = $oms->getInstanceByKey($instkey);
|
$inst = $oms->getInstanceByKey($instkey);
|
||||||
if ($inst === null)
|
if ($inst === null)
|
||||||
{
|
{
|
||||||
$ctx = new OmsContext();
|
|
||||||
$htmlRenderer = new HTMLRenderer($ctx);
|
|
||||||
|
|
||||||
$htmlRenderer->renderBeginPage("Error");
|
$htmlRenderer->renderBeginPage("Error");
|
||||||
?>
|
?>
|
||||||
<div class="uwt-panel" style="width: 600px; margin-left: auto; margin-right: auto; margin-top: 128px;">
|
<div class="uwt-panel" style="width: 600px; margin-left: auto; margin-right: auto; margin-top: 128px;">
|
||||||
@ -72,15 +84,18 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$ctx = new OmsContext();
|
|
||||||
$htmlRenderer = new HTMLRenderer($ctx);
|
|
||||||
|
|
||||||
$parentClass = $oms->getParentClass($inst);
|
$parentClass = $oms->getParentClass($inst);
|
||||||
if ($castkey !== null)
|
if ($castkey !== null)
|
||||||
{
|
{
|
||||||
$parentClass = $oms->getInstanceByKey($castkey);
|
$parentClass = $oms->getInstanceByKey($castkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$useLegacyRendering)
|
||||||
|
{
|
||||||
|
$htmlRenderer->renderInitialElement($inst);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
$rel_Class__has_default__Task = $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Class__has_default__Task);
|
$rel_Class__has_default__Task = $oms->getInstanceByGlobalIdentifier(KnownRelationshipGuids::Class__has_default__Task);
|
||||||
if ($rel_Class__has_default__Task !== null)
|
if ($rel_Class__has_default__Task !== null)
|
||||||
{
|
{
|
||||||
@ -94,15 +109,13 @@
|
|||||||
$context->setWorkData($parentClass, $inst);
|
$context->setWorkData($parentClass, $inst);
|
||||||
|
|
||||||
// echo ("instance for " . $parentClass->InstanceKey . " = " . $inst->InstanceKey);
|
// echo ("instance for " . $parentClass->InstanceKey . " = " . $inst->InstanceKey);
|
||||||
|
$htmlRenderer->TargetInstance = $inst;
|
||||||
$taskRenderer = new HTMLRenderer($context);
|
$htmlRenderer->IsPostback = $this->Page->IsPostback;
|
||||||
$taskRenderer->TargetInstance = $inst;
|
|
||||||
$taskRenderer->IsPostback = $this->Page->IsPostback;
|
|
||||||
if ($this->Page->IsPostback)
|
if ($this->Page->IsPostback)
|
||||||
{
|
{
|
||||||
$taskRenderer->processPostback(element: $initiatingElement);
|
$htmlRenderer->processPostback(element: $initiatingElement);
|
||||||
}
|
}
|
||||||
$taskRenderer->renderTask($defaultTask, $inst);
|
$htmlRenderer->renderTask($defaultTask, $inst);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
$oms->setTenant($tenant);
|
$oms->setTenant($tenant);
|
||||||
$oms->initializeInstanceCache();
|
$oms->initializeInstanceCache();
|
||||||
|
|
||||||
// echo (" login token: " . $_SESSION["user_token_" . $oms->getTenant()->ID]);
|
// echo (" login token: " . $_SESSION["user_token_" . System::GetTenantName()]);
|
||||||
/*
|
/*
|
||||||
if (mocha_get_current_user() !== null)
|
if (mocha_get_current_user() !== null)
|
||||||
{
|
{
|
||||||
@ -103,6 +103,25 @@
|
|||||||
$json = $oms->getResponse($pageElement);
|
$json = $oms->getResponse($pageElement);
|
||||||
$json = $json["value"];
|
$json = $json["value"];
|
||||||
|
|
||||||
|
$renderer->ProcessPostbackFunction = function($sender, $element, $array)
|
||||||
|
{
|
||||||
|
$oms = mocha_get_oms();
|
||||||
|
|
||||||
|
if ($array["result"] == "success")
|
||||||
|
{
|
||||||
|
if (array_key_exists("sessionSecureToken", $array))
|
||||||
|
{
|
||||||
|
$token = $array["sessionSecureToken"];
|
||||||
|
$_SESSION["user_token_" . System::GetTenantName()] = $token;
|
||||||
|
if ($array["type"] == "redirect")
|
||||||
|
{
|
||||||
|
System::Redirect($array["destinationUrl"]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$renderer->ProcessUpdatesFunction = function($sender, $element)
|
$renderer->ProcessUpdatesFunction = function($sender, $element)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -160,7 +179,7 @@
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION["user_token_" . $oms->getTenant()->ID] = $token;
|
$_SESSION["user_token_" . System::GetTenantName()] = $token;
|
||||||
$oms->setCurrentUser($instUser);
|
$oms->setCurrentUser($instUser);
|
||||||
|
|
||||||
System::RedirectFromLoginPage();
|
System::RedirectFromLoginPage();
|
||||||
@ -287,7 +306,7 @@
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION["user_token_" . $oms->getTenant()->ID] = $token;
|
$_SESSION["user_token_" . System::GetTenantName()] = $token;
|
||||||
$oms->setCurrentUser($instUser);
|
$oms->setCurrentUser($instUser);
|
||||||
System::RedirectFromLoginPage();
|
System::RedirectFromLoginPage();
|
||||||
exit();
|
exit();
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
$oms = mocha_get_oms();
|
$oms = mocha_get_oms();
|
||||||
|
|
||||||
unset($_SESSION["user_token_" . $oms->getTenant()->ID]);
|
unset($_SESSION["user_token_" . System::GetTenantName()]);
|
||||||
|
|
||||||
System::Redirect("~/" . $_SESSION["CurrentTenantName"], true);
|
System::Redirect("~/" . $_SESSION["CurrentTenantName"], true);
|
||||||
exit();
|
exit();
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace Mocha\UI\Pages;
|
namespace Mocha\UI\Pages;
|
||||||
|
|
||||||
use Mocha\Core\InstanceKey;
|
use Mocha\Core\InstanceKey;
|
||||||
|
use Mocha\Core\InstanceReference;
|
||||||
use Mocha\Core\KnownClassGuids;
|
use Mocha\Core\KnownClassGuids;
|
||||||
use Mocha\Core\KnownInstanceGuids;
|
use Mocha\Core\KnownInstanceGuids;
|
||||||
use Mocha\Core\KnownRelationshipGuids;
|
use Mocha\Core\KnownRelationshipGuids;
|
||||||
@ -43,22 +44,34 @@
|
|||||||
|
|
||||||
$search = new SearchHelper($oms);
|
$search = new SearchHelper($oms);
|
||||||
|
|
||||||
$ec = $oms->getInstanceByKey(InstanceKey::parse($id));
|
$ik = new InstanceKey(0, 0);
|
||||||
if ($ec !== null)
|
if (InstanceKey::TryParse($id, $ik))
|
||||||
{
|
{
|
||||||
$ecinst = $oms->getRelatedInstance($ec, KnownRelationshipGuids::Element_Content__has__Instance);
|
$search->ValidClasses[] = new InstanceReference(null, $ik, null);
|
||||||
if ($ecinst !== null)
|
/*
|
||||||
|
$ec = $oms->getInstanceByKey($ik);
|
||||||
|
if ($ec !== null)
|
||||||
{
|
{
|
||||||
if ($oms->is_a($ecinst, KnownClassGuids::Clasz))
|
$ecinst = $oms->getRelatedInstance($ec, KnownRelationshipGuids::Element_Content__has__Instance);
|
||||||
|
if ($ecinst !== null)
|
||||||
{
|
{
|
||||||
$search->ValidClasses[] = $ecinst;
|
if ($oms->is_a($ecinst, KnownClassGuids::Clasz))
|
||||||
}
|
{
|
||||||
else if ($oms->is_a($ecinst, KnownClassGuids::Relationship))
|
$search->ValidClasses[] = $ecinst;
|
||||||
{
|
}
|
||||||
$relDestination = $oms->getRelatedInstance($ecinst, KnownRelationshipGuids::Relationship__has_destination__Class);
|
else if ($oms->is_a($ecinst, KnownClassGuids::Relationship))
|
||||||
$search->ValidClasses[] = $relDestination;
|
{
|
||||||
|
$relDestination = $oms->getRelatedInstance($ecinst, KnownRelationshipGuids::Relationship__has_destination__Class);
|
||||||
|
$search->ValidClasses[] = $relDestination;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo (json_encode(array("result" => "failure", "message" => "could not parse instance key: " . $id)));
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$postdata = file_get_contents("php://input");
|
$postdata = file_get_contents("php://input");
|
||||||
@ -77,15 +90,21 @@
|
|||||||
foreach ($results as $result)
|
foreach ($results as $result)
|
||||||
{
|
{
|
||||||
$viewTaskIid = null;
|
$viewTaskIid = null;
|
||||||
$viewTask =$oms->getRelatedInstance($oms->getParentClass($result->Instance), KnownRelationshipGuids::Class__has_default__Task);
|
if ($result->DefaultTask != null)
|
||||||
|
{
|
||||||
|
$viewTaskIid = $result->DefaultTask->InstanceKey->__toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
$viewTask =$oms->getRelatedInstance($oms->getParentClass($result), KnownRelationshipGuids::Class__has_default__Task);
|
||||||
if ($viewTask !== null)
|
if ($viewTask !== null)
|
||||||
{
|
{
|
||||||
$viewTaskIid = $viewTask->InstanceKey->__toString();
|
$viewTaskIid = $viewTask->InstanceKey->__toString();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
$json["items"][] = [
|
$json["items"][] = [
|
||||||
"instanceId" => $result->Instance->InstanceKey->__toString(),
|
"instanceId" => $result->InstanceKey->__toString(),
|
||||||
"text" => $result->Title,
|
"text" => $result->Text,
|
||||||
"action" => "view",
|
"action" => "view",
|
||||||
"viewTask" => $viewTaskIid
|
"viewTask" => $viewTaskIid
|
||||||
];
|
];
|
||||||
|
|||||||
@ -154,51 +154,54 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$query = $_GET["q"];
|
$query = $_GET["q"];
|
||||||
$results = $searchHelper->search($query);
|
if (strlen($query) < 3)
|
||||||
|
{
|
||||||
|
$json = array
|
||||||
|
(
|
||||||
|
"result" => "failure",
|
||||||
|
"responseCode" => 400,
|
||||||
|
"responseText" => "Bad Request",
|
||||||
|
|
||||||
|
"mochaResponseCode" => "MCX0019",
|
||||||
|
"mochaResponseText" => "Search Query Required",
|
||||||
|
"title" => "Search Query Required",
|
||||||
|
"message" => "Please enter a search query longer than 3 characters"
|
||||||
|
);
|
||||||
|
echo (json_encode($json));
|
||||||
|
$re->Handled = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$results = $searchHelper->search($query, isset($_GET["m"]) ? $_GET["m"] : null);
|
||||||
|
|
||||||
$count = count($results);
|
$count = count($results);
|
||||||
if ($count > 50)
|
if ($count > 50)
|
||||||
{
|
{
|
||||||
if (strlen($query) < 3)
|
|
||||||
{
|
|
||||||
$json = array
|
|
||||||
(
|
|
||||||
"result" => "failure",
|
|
||||||
"responseCode" => 400,
|
|
||||||
"responseText" => "Bad Request",
|
|
||||||
|
|
||||||
"mochaResponseCode" => "MCX0019",
|
|
||||||
"mochaResponseText" => "Search Query Required",
|
|
||||||
"title" => "Search Query Required",
|
|
||||||
"message" => "Please enter a search query longer than 3 characters"
|
|
||||||
);
|
|
||||||
echo (json_encode($json));
|
|
||||||
$re->Handled = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo ("{ \"result\": \"success\", \"items\": [ ");
|
echo ("{ \"result\": \"success\", \"items\": [ ");
|
||||||
for ($i = 0; $i < $count; $i++)
|
for ($i = 0; $i < $count; $i++)
|
||||||
{
|
{
|
||||||
$inst = $results[$i]->Instance;
|
$inst = $results[$i];
|
||||||
$instClass = $oms->getParentClass($inst);
|
$viewTask = $results[$i]->DefaultTask; // $oms->getRelatedInstance($instClass, KnownRelationshipGuids::Class__has_default__Task);
|
||||||
$viewTask = $oms->getRelatedInstance($instClass, KnownRelationshipGuids::Class__has_default__Task);
|
|
||||||
$uri = "/" . $oms->getTenantName() . "/d/inst/" . $inst->InstanceKey->__toString() . ".htmld";
|
$uri = "/" . $oms->getTenantName() . "/d/inst/" . $inst->InstanceKey->__toString() . ".htmld";
|
||||||
|
/*
|
||||||
if ($oms->is_a($inst, KnownClassGuids::Task))
|
if ($oms->is_a($inst, KnownClassGuids::Task))
|
||||||
{
|
{
|
||||||
$uri = "/" . $oms->getTenantName() . "/d/task/" . $inst->InstanceKey->__toString() . ".htmld";
|
$uri = "/" . $oms->getTenantName() . "/d/task/" . $inst->InstanceKey->__toString() . ".htmld";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
$instJson = array
|
$instJson = array
|
||||||
(
|
(
|
||||||
"iconId" => null,
|
"iconId" => null,
|
||||||
"iid" => $inst->InstanceKey->__toString(),
|
"iid" => $inst->InstanceKey->__toString(),
|
||||||
"imageUrl" => null,
|
"imageUrl" => null,
|
||||||
"label" => $results[$i]->Title,
|
"label" => $results[$i]->Text,
|
||||||
"title" => $results[$i]->Title,
|
"title" => $results[$i]->Text,
|
||||||
"subtitle1" => null,
|
"subtitle1" => $results[$i]->ParentClass->Text,
|
||||||
"subtitle2" => null,
|
"subtitle2" => null,
|
||||||
"subtitle3" => null,
|
"subtitle3" => null,
|
||||||
"summaryDescription" => $oms->getInstanceText($instClass),
|
// "summaryDescription" => $oms->getInstanceText($instClass),
|
||||||
"returnedByQueryIntent" => false,
|
"returnedByQueryIntent" => false,
|
||||||
"viewTask" => $viewTask === null ? null : $viewTask->InstanceKey->__toString(),
|
"viewTask" => $viewTask === null ? null : $viewTask->InstanceKey->__toString(),
|
||||||
"uri" => $uri
|
"uri" => $uri
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
use Mocha\Core\KnownRelationshipGuids;
|
use Mocha\Core\KnownRelationshipGuids;
|
||||||
use Mocha\Core\OmsContext;
|
use Mocha\Core\OmsContext;
|
||||||
use Mocha\UI\Renderers\HTML\HTMLRenderer;
|
use Mocha\UI\Renderers\HTML\HTMLRenderer;
|
||||||
|
use Mocha\UI\Renderers\HTML\HTMLRenderer2;
|
||||||
use Phast\RenderingEventArgs;
|
use Phast\RenderingEventArgs;
|
||||||
use Phast\WebPage;
|
use Phast\WebPage;
|
||||||
|
|
||||||
@ -26,7 +27,14 @@
|
|||||||
$initiatingElement = $oms->getRelatedInstance($taskInstance, KnownRelationshipGuids::Task__has_initiating__Element);
|
$initiatingElement = $oms->getRelatedInstance($taskInstance, KnownRelationshipGuids::Task__has_initiating__Element);
|
||||||
|
|
||||||
$context = new OmsContext();
|
$context = new OmsContext();
|
||||||
$taskRenderer = new HTMLRenderer($context);
|
if ($_GET["legacy"] == "1")
|
||||||
|
{
|
||||||
|
$taskRenderer = new HTMLRenderer($context);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$taskRenderer = new HTMLRenderer2($context);
|
||||||
|
}
|
||||||
//$taskRenderer->TargetInstance = $instance;
|
//$taskRenderer->TargetInstance = $instance;
|
||||||
$taskRenderer->IsPostback = $this->Page->IsPostback;
|
$taskRenderer->IsPostback = $this->Page->IsPostback;
|
||||||
if ($this->Page->IsPostback)
|
if ($this->Page->IsPostback)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user