mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°2847 - Refactor some early choices
- TWIG: Change calls to object methods from simple notation (eg. oObject.Id) to complete notation (eg. oObject.GetId()) to avoid confusion with use of arrays and variables (eg. aObject.sId) - UIBlock: $sId should not be first parameter as most of the time it can be ignored and generated by the system - NewsroomMenu: Rename method for something more less ambiguous - Html: Embed content in <div /> so we can easily find all such HTML fragments in the UI
This commit is contained in:
@@ -32,23 +32,35 @@ use Combodo\iTop\Application\UI\Component\PopoverMenu\PopoverMenu;
|
||||
*/
|
||||
class NewsroomMenu extends PopoverMenu
|
||||
{
|
||||
// Overloaded constants
|
||||
const HTML_TEMPLATE_REL_PATH = 'components/popover-menu/newsroom-menu/layout';
|
||||
const JS_TEMPLATE_REL_PATH = 'components/popover-menu/newsroom-menu/layout';
|
||||
|
||||
const JS_FILES_REL_PATH = [
|
||||
'js/components/newsroom-menu.js',
|
||||
];
|
||||
|
||||
/** @var array $aParams */
|
||||
protected $aParams;
|
||||
|
||||
|
||||
/**
|
||||
* Set all parameters at once
|
||||
*
|
||||
* @param array $aParams
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetParams($aParams)
|
||||
{
|
||||
$this->aParams = $aParams;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function GetParams()
|
||||
/**
|
||||
* Return all parameters as a JSON string
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
public function GetParamsAsJson()
|
||||
{
|
||||
return json_encode($this->aParams);
|
||||
}
|
||||
|
||||
@@ -46,20 +46,26 @@ class NewsroomMenuFactory
|
||||
public static function MakeNewsroomMenuForNavigationMenu()
|
||||
{
|
||||
$oMenu = new NewsroomMenu('ibo-navigation-menu--notifications-menu');
|
||||
$oMenu->SetParams(static::PrepareNewsForNewsroomMenu());
|
||||
$oMenu->SetParams(static::PrepareParametersForNewsroomMenu());
|
||||
|
||||
return $oMenu;
|
||||
}
|
||||
|
||||
|
||||
protected static function PrepareNewsForNewsroomMenu()
|
||||
/**
|
||||
* Prepare parameters for the newsroom JS widget
|
||||
*
|
||||
* @return array
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \MySQLException
|
||||
* @throws \OQLException
|
||||
*/
|
||||
protected static function PrepareParametersForNewsroomMenu()
|
||||
{
|
||||
$aItems = [];
|
||||
|
||||
$aProviderParams=[];
|
||||
$oUser = UserRights::GetUserObject();
|
||||
/**
|
||||
* @var iNewsroomProvider[] $aProviders
|
||||
* @var \iNewsroomProvider[] $aProviders
|
||||
*/
|
||||
$aProviders = MetaModel::EnumPlugins('iNewsroomProvider');
|
||||
foreach($aProviders as $oProvider)
|
||||
|
||||
@@ -37,7 +37,6 @@ class PopoverMenu extends UIBlock
|
||||
// Overloaded constants
|
||||
const BLOCK_CODE = 'ibo-popover-menu';
|
||||
const HTML_TEMPLATE_REL_PATH = 'components/popover-menu/layout';
|
||||
//const JS_TEMPLATE_REl_PATH = 'components/popover-menu/layout';
|
||||
const JS_FILES_REL_PATH = [
|
||||
'js/components/popover-menu.js',
|
||||
];
|
||||
|
||||
@@ -35,12 +35,19 @@ class JsPopoverMenuItem extends PopoverMenuItem
|
||||
// Overloaded constants
|
||||
const HTML_TEMPLATE_REL_PATH = 'components/popover-menu/item/mode_js';
|
||||
|
||||
/**
|
||||
* @see \JSPopupMenuItem::GetJsCode()
|
||||
* @return string
|
||||
*/
|
||||
public function GetJsCode()
|
||||
{
|
||||
return $this->oPopupMenuItem->GetJSCode();
|
||||
}
|
||||
|
||||
/** @ignore */
|
||||
/**
|
||||
* @see \JSPopupMenuItem::GetUrl()
|
||||
* @return string
|
||||
*/
|
||||
public function GetUrl()
|
||||
{
|
||||
return $this->oPopupMenuItem->GetUrl();
|
||||
|
||||
@@ -33,13 +33,19 @@ class UrlPopoverMenuItem extends PopoverMenuItem
|
||||
// Overloaded constants
|
||||
const HTML_TEMPLATE_REL_PATH = 'components/popover-menu/item/mode_url';
|
||||
|
||||
/** @ignore */
|
||||
/**
|
||||
* @see \URLPopupMenuItem::GetUrl()
|
||||
* @return string
|
||||
*/
|
||||
public function GetUrl()
|
||||
{
|
||||
return $this->oPopupMenuItem->GetUrl();
|
||||
}
|
||||
|
||||
/** @ignore */
|
||||
/**
|
||||
* @see \URLPopupMenuItem::GetTarget()
|
||||
* @return string
|
||||
*/
|
||||
public function GetTarget()
|
||||
{
|
||||
return $this->oPopupMenuItem->GetTarget();
|
||||
|
||||
Reference in New Issue
Block a user