|
@@ -32,6 +32,10 @@ use \Combodo\iTop\Portal\Brick\AbstractBrick;
|
|
|
*/
|
|
|
abstract class PortalBrick extends AbstractBrick
|
|
|
{
|
|
|
+ const ENUM_OPENING_TARGET_MODAL = 'modal';
|
|
|
+ const ENUM_OPENING_TARGET_SELF = 'self';
|
|
|
+ const ENUM_OPENING_TARGET_NEW = 'new';
|
|
|
+
|
|
|
const DEFAULT_WIDTH = 1;
|
|
|
const DEFAULT_HEIGHT = 1;
|
|
|
const DEFAULT_MODAL = false;
|
|
@@ -41,8 +45,11 @@ abstract class PortalBrick extends AbstractBrick
|
|
|
const DEFAULT_DECORATION_CLASS_NAVIGATION_MENU = '';
|
|
|
const DEFAULT_TILE_TEMPLATE_PATH = 'itop-portal-base/portal/src/views/bricks/tile.html.twig';
|
|
|
const DEFAULT_TILE_CONTROLLER_ACTION = null;
|
|
|
+ const DEFAULT_OPENING_TARGET = self::ENUM_OPENING_TARGET_MODAL;
|
|
|
|
|
|
static $sRouteName = null;
|
|
|
+ static $aOpeningTargets = array(self::ENUM_OPENING_TARGET_MODAL, self::ENUM_OPENING_TARGET_SELF, self::ENUM_OPENING_TARGET_NEW);
|
|
|
+
|
|
|
protected $iWidth;
|
|
|
protected $iHeight;
|
|
|
protected $bModal;
|
|
@@ -52,6 +59,7 @@ abstract class PortalBrick extends AbstractBrick
|
|
|
protected $sDecorationClassNavigationMenu;
|
|
|
protected $sTileTemplatePath;
|
|
|
protected $sTileControllerAction;
|
|
|
+ protected $sOpeningTarget;
|
|
|
// Vars below are itemization from parent class
|
|
|
protected $fRankHome;
|
|
|
protected $fRankNavigationMenu;
|
|
@@ -79,6 +87,7 @@ abstract class PortalBrick extends AbstractBrick
|
|
|
$this->sDecorationClassNavigationMenu = static::DEFAULT_DECORATION_CLASS_NAVIGATION_MENU;
|
|
|
$this->sTileTemplatePath = static::DEFAULT_TILE_TEMPLATE_PATH;
|
|
|
$this->sTileControllerAction = static::DEFAULT_TILE_CONTROLLER_ACTION;
|
|
|
+ $this->sOpeningTarget = static::DEFAULT_OPENING_TARGET;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -211,6 +220,16 @@ abstract class PortalBrick extends AbstractBrick
|
|
|
return $this->sTileTemplatePath;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns the brick's objects opening target (modal, new tab, current window)
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function GetOpeningTarget()
|
|
|
+ {
|
|
|
+ return $this->sOpeningTarget;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Sets the width of the brick
|
|
|
*
|
|
@@ -354,6 +373,18 @@ abstract class PortalBrick extends AbstractBrick
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Sets the brick's objects opening target
|
|
|
+ *
|
|
|
+ * @param string $sOpeningTarget
|
|
|
+ * @return \Combodo\iTop\Portal\Brick\PortalBrick
|
|
|
+ */
|
|
|
+ public function SetOpeningTarget($sOpeningTarget)
|
|
|
+ {
|
|
|
+ $this->sOpeningTarget = $sOpeningTarget;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Load the brick's data from the xml passed as a ModuleDesignElement.
|
|
|
* This is used to set all the brick attributes at once.
|
|
@@ -373,13 +404,16 @@ abstract class PortalBrick extends AbstractBrick
|
|
|
case 'width':
|
|
|
$this->SetWidth((int) $oBrickSubNode->GetText(static::DEFAULT_WIDTH));
|
|
|
break;
|
|
|
+
|
|
|
case 'height':
|
|
|
$this->SetHeight((int) $oBrickSubNode->GetText(static::DEFAULT_HEIGHT));
|
|
|
break;
|
|
|
+
|
|
|
case 'modal':
|
|
|
$bModal = ($oBrickSubNode->GetText(static::DEFAULT_MODAL) === 'true');
|
|
|
$this->SetModal($bModal);
|
|
|
break;
|
|
|
+
|
|
|
case 'visible':
|
|
|
// Default value
|
|
|
$oOptionalNode = $oBrickSubNode->GetOptionalElement('default');
|
|
@@ -404,6 +438,7 @@ abstract class PortalBrick extends AbstractBrick
|
|
|
$this->SetVisibleNavigationMenu($optionalNodeValue);
|
|
|
}
|
|
|
break;
|
|
|
+
|
|
|
case 'templates':
|
|
|
$oTemplateNodeList = $oBrickSubNode->GetNodes('template[@id=' . ModuleDesign::XPathQuote('tile') . ']');
|
|
|
if ($oTemplateNodeList->length > 0)
|
|
@@ -411,6 +446,7 @@ abstract class PortalBrick extends AbstractBrick
|
|
|
$this->SetTileTemplatePath($oTemplateNodeList->item(0)->GetText(static::DEFAULT_TILE_TEMPLATE_PATH));
|
|
|
}
|
|
|
break;
|
|
|
+
|
|
|
case 'rank':
|
|
|
// Setting value from parent attribute
|
|
|
$this->SetRankHome($this->fRank);
|
|
@@ -438,6 +474,7 @@ abstract class PortalBrick extends AbstractBrick
|
|
|
$this->SetRankNavigationMenu($optionalNodeValue);
|
|
|
}
|
|
|
break;
|
|
|
+
|
|
|
case 'title':
|
|
|
// Setting value from parent attribute
|
|
|
$this->SetTitleHome($this->sTitle);
|
|
@@ -466,6 +503,7 @@ abstract class PortalBrick extends AbstractBrick
|
|
|
$this->SetTitle($optionalNodeValue);
|
|
|
}
|
|
|
break;
|
|
|
+
|
|
|
case 'decoration_class':
|
|
|
// Setting value from parent attribute
|
|
|
$this->SetDecorationClassHome(static::DEFAULT_DECORATION_CLASS_HOME);
|
|
@@ -493,9 +531,20 @@ abstract class PortalBrick extends AbstractBrick
|
|
|
$this->SetDecorationClassNavigationMenu($optionalNodeValue);
|
|
|
}
|
|
|
break;
|
|
|
+
|
|
|
case 'tile_controller_action':
|
|
|
$this->SetTileControllerAction($oBrickSubNode->GetText(static::DEFAULT_TILE_CONTROLLER_ACTION));
|
|
|
break;
|
|
|
+
|
|
|
+ case 'opening_target':
|
|
|
+ $sOpeningTarget = $oBrickSubNode->GetText(static::DEFAULT_OPENING_TARGET);
|
|
|
+ if (!in_array($sOpeningTarget, array(static::ENUM_OPENING_TARGET_MODAL, static::ENUM_OPENING_TARGET_NEW, static::ENUM_OPENING_TARGET_SELF)))
|
|
|
+ {
|
|
|
+ throw new DOMFormatException('PortalBrick : opening_target tag value must be modal|new|self ("' . $sOpeningTarget . '" given)', null, null, $oBrickSubNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->SetOpeningTarget($sOpeningTarget);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|