|
@@ -2460,20 +2460,12 @@ abstract class DBObject implements iDisplay
|
|
$ret = $this->GetKey();
|
|
$ret = $this->GetKey();
|
|
break;
|
|
break;
|
|
|
|
|
|
- case 'hyperlink()':
|
|
|
|
- $ret = $this->GetHyperlink('iTopStandardURLMaker', false);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case 'hyperlink(portal)':
|
|
|
|
- $ret = $this->GetHyperlink('PortalURLMaker', false);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
case 'name()':
|
|
case 'name()':
|
|
$ret = $this->GetName();
|
|
$ret = $this->GetName();
|
|
break;
|
|
break;
|
|
|
|
|
|
default:
|
|
default:
|
|
- if (preg_match('/^([^(]+)\\((.+)\\)$/', $sPlaceholderAttCode, $aMatches))
|
|
|
|
|
|
+ if (preg_match('/^([^(]+)\\((.*)\\)$/', $sPlaceholderAttCode, $aMatches))
|
|
{
|
|
{
|
|
$sVerb = $aMatches[1];
|
|
$sVerb = $aMatches[1];
|
|
$sAttCode = $aMatches[2];
|
|
$sAttCode = $aMatches[2];
|
|
@@ -2483,9 +2475,21 @@ abstract class DBObject implements iDisplay
|
|
$sVerb = '';
|
|
$sVerb = '';
|
|
$sAttCode = $sPlaceholderAttCode;
|
|
$sAttCode = $sPlaceholderAttCode;
|
|
}
|
|
}
|
|
-
|
|
|
|
- $oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
|
|
|
|
- $ret = $oAttDef->GetForTemplate($this->Get($sAttCode), $sVerb, $this);
|
|
|
|
|
|
+
|
|
|
|
+ if ($sVerb == 'hyperlink')
|
|
|
|
+ {
|
|
|
|
+ $sPortalId = ($sAttCode === '') ? 'console' : $sAttCode;
|
|
|
|
+ if (!array_key_exists($sPortalId, self::$aPortalToURLMaker))
|
|
|
|
+ {
|
|
|
|
+ throw new Exception("Unknown portal id '$sPortalId' in placeholder '$sPlaceholderAttCode''");
|
|
|
|
+ }
|
|
|
|
+ $ret = $this->GetHyperlink(self::$aPortalToURLMaker[$sPortalId], false);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ $oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
|
|
|
|
+ $ret = $oAttDef->GetForTemplate($this->Get($sAttCode), $sVerb, $this);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if ($ret === null)
|
|
if ($ret === null)
|
|
{
|
|
{
|
|
@@ -2495,6 +2499,20 @@ abstract class DBObject implements iDisplay
|
|
return $ret;
|
|
return $ret;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ static protected $aPortalToURLMaker = array('console' => 'iTopStandardURLMaker', 'portal' => 'PortalURLMaker');
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Associate a portal to a class that implements iDBObjectURLMaker,
|
|
|
|
+ * and which will be invoked with placeholders like $this->org_id->hyperlink(portal)$
|
|
|
|
+ *
|
|
|
|
+ * @param $sPortalId Identifies the portal. Conventions: the main portal is 'console', The user requests portal is 'portal'.
|
|
|
|
+ * @param $sUrlMakerClass
|
|
|
|
+ */
|
|
|
|
+ static public function RegisterURLMakerClass($sPortalId, $sUrlMakerClass)
|
|
|
|
+ {
|
|
|
|
+ self::$aPortalToURLMaker[$sPortalId] = $sUrlMakerClass;
|
|
|
|
+ }
|
|
|
|
+
|
|
// To be optionaly overloaded
|
|
// To be optionaly overloaded
|
|
protected function OnInsert()
|
|
protected function OnInsert()
|
|
{
|
|
{
|