diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php
index dd4782afc..454cbd8e8 100644
--- a/application/cmdbabstract.class.inc.php
+++ b/application/cmdbabstract.class.inc.php
@@ -386,7 +386,7 @@ abstract class cmdbAbstractObject extends CMDBObject
if ($bDisplayMenu)
{
$sColspan = 'colspan="2"';
- $aMenuExtraParams = array();
+ $aMenuExtraParams = $aExtraParams;
if (!empty($sLinkageAttribute))
{
//$aMenuExtraParams['linkage'] = $sLinkageAttribute;
@@ -725,6 +725,11 @@ abstract class cmdbAbstractObject extends CMDBObject
$sHTMLValue .= "\n";
$oPage->add_ready_script("\$('#label_$iInputId').autocomplete('./ajax.render.php', { minChars:3, onItemSelect:selectItem, onFindValue:findValue, formatItem:formatItem, autoFill:true, keyHolder:'#$iInputId', extraParams:{operation:'autocomplete', sclass:'$sClass',attCode:'".$sAttCode."'}});");
$oPage->add_ready_script("\$('#label_$iInputId').result( function(event, data, formatted) { if (data) { $('#{$iInputId}').val(data[1]); } } );");
+ // Prepopulate with a default value -- but no display value...
+ //if (!empty($value))
+ //{
+ // $oPage->add_ready_script("\$('#label_$iInputId').search( 'domino.combodo.com' );");
+ //}
}
else
{
diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php
index f744cf6c4..9dd0ebeb2 100644
--- a/application/displayblock.class.inc.php
+++ b/application/displayblock.class.inc.php
@@ -55,11 +55,14 @@ class DisplayBlock
{
$iStartPos = stripos($sTemplate, '<'.self::TAG_BLOCK.' ',0);
$iEndPos = stripos($sTemplate, ''.self::TAG_BLOCK.'>', $iStartPos);
+ $iEndTag = stripos($sTemplate, '>', $iStartPos);
+ $aParams = array();
if (($iStartPos === false) || ($iEndPos === false)) return null; // invalid template
- $sITopBlock = substr($sTemplate,$iStartPos, $iEndPos-$iStartPos);
- $sITopData = substr($sITopBlock, 1+stripos($sITopBlock, ">"));
- $sITopTag = substr($sITopBlock, 0, stripos($sITopBlock, ">"));
+ $sITopBlock = substr($sTemplate,$iStartPos, $iEndPos-$iStartPos+strlen(''.self::TAG_BLOCK.'>'));
+ $sITopData = substr($sTemplate, 1+$iEndTag, $iEndPos - $iEndTag - 1);
+ $sITopTag = substr($sTemplate, $iStartPos + strlen('<'.self::TAG_BLOCK), $iEndTag - $iStartPos - strlen('<'.self::TAG_BLOCK));
+
$aMatches = array();
$sBlockClass = "DisplayBlock";
$bAsynchronous = false;
@@ -88,7 +91,12 @@ class DisplayBlock
if (preg_match('/ link_attr="(.*)"/U',$sITopTag, $aMatches))
{
// The list to display is a list of links to the specified object
- $aParams['link_attr'] = $aMatches[1]; // Name of the Ext. Key that make this linkage
+ $aParams['link_attr'] = $aMatches[1]; // Name of the Ext. Key that makes this linkage
+ }
+ if (preg_match('/ target_attr="(.*)"/U',$sITopTag, $aMatches))
+ {
+ // The list to display is a list of links to the specified object
+ $aParams['target_attr'] = $aMatches[1]; // Name of the Ext. Key that make this linkage
}
if (preg_match('/ object_id="(.*)"/U',$sITopTag, $aMatches))
{
@@ -97,7 +105,6 @@ class DisplayBlock
}
// Parameters contains a list of extra parameters for the block
// the syntax is param_name1:value1;param_name2:value2;...
- $aParams = array();
if (preg_match('/ parameters="(.*)"/U',$sITopTag, $aMatches))
{
$sParameters = $aMatches[1];
@@ -120,7 +127,7 @@ class DisplayBlock
}
if(empty($aParams['target_attr']))
{
- // if 'links' mode is requested the d of the object to link to must be specified
+ // if 'links' mode is requested the id of the object to link to must be specified
throw new ApplicationException("Parameter target_attr is mandatory when link_attr is specified. Check the definition of the display template.");
}
@@ -291,7 +298,21 @@ class DisplayBlock
{
$oAppContext = new ApplicationContext();
$sParams = $oAppContext->GetForLink();
- $sHtml .= $oPage->GetP("Click here to create a new ".Metamodel::GetName($sClass)."\n");
+ // 1:n links, populate the target object as a default value when creating a new linked object
+ if (isset($aExtraParams['target_attr']))
+ {
+ $aExtraParams['default'][$aExtraParams['target_attr']] = $aExtraParams['object_id'];
+ }
+ $sDefault = '';
+ if (!empty($aExtraParams['default']))
+ {
+ foreach($aExtraParams['default'] as $sKey => $sValue)
+ {
+ $sDefault.= "&default[$sKey]=$sValue";
+ }
+ }
+
+ $sHtml .= $oPage->GetP("Click here to create a new ".Metamodel::GetName($sClass)."\n");
}
}
}
@@ -678,12 +699,25 @@ class MenuBlock extends DisplayBlock
$sFilter = $this->m_oFilter->serialize();
$aActions = array();
$sUIPage = cmdbAbstractObject::ComputeUIPage($sClass);
+ // 1:n links, populate the target object as a default value when creating a new linked object
+ if (isset($aExtraParams['target_attr']))
+ {
+ $aExtraParams['default'][$aExtraParams['target_attr']] = $aExtraParams['object_id'];
+ }
+ $sDefault = '';
+ if (!empty($aExtraParams['default']))
+ {
+ foreach($aExtraParams['default'] as $sKey => $sValue)
+ {
+ $sDefault.= "&default[$sKey]=$sValue";
+ }
+ }
switch($oSet->Count())
{
case 0:
// No object in the set, the only possible action is "new"
$bIsModifyAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY);
- if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'New', 'url' => "../page/$sUIPage?operation=new&class=$sClass&$sContext"); }
+ if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'New', 'url' => "../page/$sUIPage?operation=new&class=$sClass&$sContext{$sDefault}"); }
break;
case 1:
@@ -710,7 +744,7 @@ class MenuBlock extends DisplayBlock
$aActions[] = array ('label' => 'eMail', 'url' => "mailto:?subject=".$oSet->GetFilter()->__DescribeHTML()."&body=".urlencode("$sUrl?operation=search&filter=$sFilter&$sContext"));
$aActions[] = array ('label' => 'CSV Export', 'url' => "../pages/$sUIPage?operation=search&filter=$sFilter&format=csv&$sContext");
//$aActions[] = array ('label' => 'Bookmark...', 'url' => "../pages/ajax.render.php?operation=create&class=$sClass&filter=$sFilter", 'class' => 'jqmTrigger');
- if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'New...', 'url' => "../pages/$sUIPage?operation=new&class=$sClass&$sContext"); }
+ if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'New...', 'url' => "../pages/$sUIPage?operation=new&class=$sClass&$sContext{$sDefault}"); }
//if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'Clone...', 'url' => "../pages/$sUIPage?operation=clone&class=$sClass&id=$id&$sContext"); }
if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'Modify...', 'url' => "../pages/$sUIPage?operation=modify&class=$sClass&id=$id&$sContext"); }
if ($bIsDeleteAllowed) { $aActions[] = array ('label' => 'Delete...', 'url' => "../pages/$sUIPage?operation=delete&class=$sClass&id=$id&$sContext"); }
@@ -762,7 +796,7 @@ class MenuBlock extends DisplayBlock
$aActions[] = array ('label' => 'eMail', 'url' => "mailto:?subject=".$oSet->GetFilter()->__DescribeHTML()."&body=".urlencode("$sUrl?operation=search&filter=$sFilter&$sContext"));
$aActions[] = array ('label' => 'CSV Export', 'url' => "../pages/$sUIPage?operation=search&filter=$sFilter&format=csv&$sContext");
//$aActions[] = array ('label' => 'Bookmark...', 'url' => "../pages/ajax.render.php?operation=create&class=$sClass&filter=$sFilter", 'class' => 'jqmTrigger');
- if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'New...', 'url' => "../pages/$sUIPage?operation=new&class=$sClass&$sContext"); }
+ if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'New...', 'url' => "../pages/$sUIPage?operation=new&class=$sClass&$sContext{$sDefault}"); }
//if ($bIsBulkModifyAllowed) { $aActions[] = array ('label' => 'Modify All...', 'url' => "../pages/$sUIPage?operation=modify_all&filter=$sFilter&$sContext"); }
//if ($bIsBulkDeleteAllowed) { $aActions[] = array ('label' => 'Delete All...', 'url' => "../pages/$sUIPage?operation=delete_all&filter=$sFilter&$sContext"); }
}
diff --git a/application/template.class.inc.php b/application/template.class.inc.php
index 20d57620c..e7b30dcae 100644
--- a/application/template.class.inc.php
+++ b/application/template.class.inc.php
@@ -7,6 +7,7 @@ class DisplayTemplate
{
protected $m_sTemplate;
protected $m_aTags;
+ static protected $iBlockCount = 0;
public function __construct($sTemplate)
{
@@ -25,17 +26,31 @@ class DisplayTemplate
while($sTag = $this->GetNextTag($iStart, $iEnd))
{
$sContent = $this->GetTagContent($sTag, $iStart, $iEnd);
- $aAttributes = $this->GetTagAttributes($sTag, $iStart, $iEnd);
- //$oPage->p("Tag: $sTag - ($iStart, $iEnd)");
+ $iAfterTagPos = $iEnd + strlen(''.$sTag.'>');
+ $sOuterTag = substr($this->m_sTemplate, $iStart, $iAfterTagPos - $iStart);
$oPage->add(substr($this->m_sTemplate, $iBeforeTagPos, $iStart - $iBeforeTagPos));
- $this->RenderTag($oPage, $sTag, $aAttributes, $sContent);
-
+ if ($sTag == DisplayBlock::TAG_BLOCK)
+ {
+ $oBlock = DisplayBlock::FromTemplate($sOuterTag);
+ if (is_object($oBlock))
+ {
+ $oBlock->Display($oPage, 'block_'.self::$iBlockCount);
+ }
+ self::$iBlockCount++;
+ }
+ else
+ {
+ $aAttributes = $this->GetTagAttributes($sTag, $iStart, $iEnd);
+ //$oPage->p("Tag: $sTag - ($iStart, $iEnd)");
+ $this->RenderTag($oPage, $sTag, $aAttributes, $sContent);
+
+ }
$iAfterTagPos = $iEnd + strlen(''.$sTag.'>');
$iBeforeTagPos = $iAfterTagPos;
$iStart = $iEnd;
$iEnd = strlen($this->m_sTemplate);
$iCount++;
- if ($iCount > 10) break;
+ if ($iCount > 10) break; //@@@ Why ?? Debug ??
}
$oPage->add(substr($this->m_sTemplate, $iAfterTagPos));
}
@@ -105,7 +120,6 @@ class DisplayTemplate
protected function RenderTag($oPage, $sTag, $aAttributes, $sContent)
{
static $iTabContainerCount = 0;
- static $iBlockCount = 0;
switch($sTag)
{
case 'itoptabs':
@@ -134,46 +148,8 @@ class DisplayTemplate
$oPage->EndCollapsibleSection();
break;
- case 'itopblock': // TO DO: Use DisplayBlock::FromTemplate here
- $sBlockClass = $aAttributes['blockclass'];
- $sBlockType = $aAttributes['type'];
- $aExtraParams = array();
- if (isset($aAttributes['link_attr']))
- {
- $aExtraParams['link_attr'] = $aAttributes['link_attr'];
- // Check that all mandatory parameters are present:
- if(empty($aAttributes['object_id']))
- {
- // if 'links' mode is requested the d of the object to link to must be specified
- throw new ApplicationException("Parameter object_id is mandatory when link_attr is specified. Check the definition of the display template.");
- }
- if(empty($aAttributes['target_attr']))
- {
- // if 'links' mode is requested the d of the object to link to must be specified
- throw new ApplicationException("Parameter target_attr is mandatory when link_attr is specified. Check the definition of the display template.");
- }
- $aExtraParams['object_id'] = $aAttributes['object_id'];
- $aExtraParams['target_attr'] = $aAttributes['target_attr'];
- }
-
- switch($aAttributes['encoding'])
- {
- case 'text/sibusql':
- $oFilter = CMDBSearchFilter::FromSibusQL($sContent);
- break;
-
- case 'text/oql':
- $oFilter = CMDBSearchFilter::FromOQL($sContent);
- break;
-
- case 'text/serialize':
- default:
- $oFilter = CMDBSearchFilter::unserialize($sContent);
- break;
- }
- $oBlock = new $sBlockClass($oFilter, $sBlockType, false, $aExtraParams);
- $oBlock->Display($oPage, 'block_'.$iBlockCount);
- $iBlockCount++;
+ case 'itopblock': // No longer used, handled by DisplayBlock::FromTemplate see above
+ $oPage->add("");
break;
default:
@@ -196,7 +172,7 @@ class DisplayTemplate
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = \'$class$\'
- bizNetworkDevice: pkey = $pkey$
+ bizNetworkDevice: pkey = $pkey$
bizInterface: device_id = $pkey$
diff --git a/application/templates/audit_category.html b/application/templates/audit_category.html
index a5e1c89c5..0ac638131 100644
--- a/application/templates/audit_category.html
+++ b/application/templates/audit_category.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-$class$: pkey = $pkey$
+$class$: pkey = $pkey$
AuditRule: category_id = $pkey$
diff --git a/business/templates/Circuits.html b/business/templates/Circuits.html
index a903e792b..e01fc9fec 100644
--- a/business/templates/Circuits.html
+++ b/business/templates/Circuits.html
@@ -4,6 +4,6 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-$class$: pkey = $pkey$
+$class$: pkey = $pkey$
diff --git a/business/templates/application.html b/business/templates/application.html
index a4a1fd0d2..a48915c12 100644
--- a/business/templates/application.html
+++ b/business/templates/application.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT bizApplication WHERE id = $pkey$
+SELECT bizApplication WHERE id = $pkey$
SELECT lnkClientServer WHERE server_id = $pkey$
diff --git a/business/templates/change.html b/business/templates/change.html
index 01c67ff61..714cd71e0 100644
--- a/business/templates/change.html
+++ b/business/templates/change.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT $class$ WHERE id = $pkey$
+SELECT $class$ WHERE id = $pkey$
SELECT lnkInfraChangeTicket WHERE ticket_id = $pkey$
diff --git a/business/templates/contract.html b/business/templates/contract.html
index 03eaecd53..594a4c9d4 100644
--- a/business/templates/contract.html
+++ b/business/templates/contract.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT bizContract WHERE id = $pkey$
+SELECT bizContract WHERE id = $pkey$
SELECT lnkInfraContract WHERE contract_id = $pkey$
diff --git a/business/templates/default.html b/business/templates/default.html
index 2464cd216..541b31cdb 100644
--- a/business/templates/default.html
+++ b/business/templates/default.html
@@ -4,5 +4,5 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-$class$: pkey = $pkey$
+$class$: pkey = $pkey$
diff --git a/business/templates/document.html b/business/templates/document.html
index a0c5a8322..72c723746 100644
--- a/business/templates/document.html
+++ b/business/templates/document.html
@@ -4,4 +4,4 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT $class$ WHERE id = $pkey$
+SELECT $class$ WHERE id = $pkey$
diff --git a/business/templates/group.html b/business/templates/group.html
index c7d450eb3..a45401ced 100644
--- a/business/templates/group.html
+++ b/business/templates/group.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT bizInfraGroup WHERE id = $pkey$
+SELECT bizInfraGroup WHERE id = $pkey$
SELECT lnkInfraGrouping WHERE infra_group_id = $pkey$
diff --git a/business/templates/interface.html b/business/templates/interface.html
index 26e5a58d3..7b2a95fc3 100644
--- a/business/templates/interface.html
+++ b/business/templates/interface.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT bizInterface WHERE id = $pkey$
+SELECT bizInterface WHERE id = $pkey$
SELECT lnkInfraGrouping WHERE infra_id = $pkey$
diff --git a/business/templates/knownError.html b/business/templates/knownError.html
index 99e0ce0de..4b2ab68ce 100644
--- a/business/templates/knownError.html
+++ b/business/templates/knownError.html
@@ -3,7 +3,7 @@
$class_name$: $name$
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT bizKnownError WHERE id = $pkey$
+SELECT bizKnownError WHERE id = $pkey$
SELECT lnkInfraError WHERE error_id = $pkey$
diff --git a/business/templates/location.html b/business/templates/location.html
index 14d3f9562..04d0609cf 100644
--- a/business/templates/location.html
+++ b/business/templates/location.html
@@ -4,10 +4,10 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT bizLocation WHERE id = $pkey$
+SELECT bizLocation WHERE id = $pkey$
- SELECT bizContact WHERE location_id = $pkey$
+ SELECT bizContact WHERE location_id = $pkey$
SELECT bizServer WHERE location_id = $pkey$
diff --git a/business/templates/network.device.html b/business/templates/network.device.html
index f4c5bf4f1..c56238467 100644
--- a/business/templates/network.device.html
+++ b/business/templates/network.device.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT bizNetworkDevice WHERE id = $pkey$
+SELECT bizNetworkDevice WHERE id = $pkey$
SELECT bizInterface WHERE device_id = $pkey$
diff --git a/business/templates/pc.html b/business/templates/pc.html
index 7c722e454..6e58ca797 100644
--- a/business/templates/pc.html
+++ b/business/templates/pc.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT bizPC WHERE id = $pkey$
+SELECT bizPC WHERE id = $pkey$
SELECT bizApplication WHERE device_id = $pkey$
diff --git a/business/templates/person.html b/business/templates/person.html
index cb853e88c..c59073aef 100644
--- a/business/templates/person.html
+++ b/business/templates/person.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT bizPerson WHERE id = $pkey$
+SELECT bizPerson WHERE id = $pkey$
SELECT lnkContactTeam WHERE contact_id = $pkey$
diff --git a/business/templates/server.html b/business/templates/server.html
index 7244c88b4..ab0f8810a 100644
--- a/business/templates/server.html
+++ b/business/templates/server.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT bizServer WHERE id = $pkey$
+SELECT bizServer WHERE id = $pkey$
SELECT bizApplication WHERE device_id = $pkey$
@@ -13,13 +13,13 @@
SELECT bizPatch WHERE device_id = $pkey$
- SELECT bizInterface WHERE device_id = $pkey$
+ SELECT bizInterface WHERE device_id = $pkey$
SELECT lnkContactRealObject WHERE object_id = $pkey$
- lnkInfraTicket: infra_id = $pkey$
+ SELECT lnkInfraTicket WHERE infra_id = $pkey$
bizChangeTicket: PKEY IS ticket_id IN (lnkInfraChangeTicket: infra_id = $pkey$)
diff --git a/business/templates/service.html b/business/templates/service.html
index a99953b4a..1491110a5 100644
--- a/business/templates/service.html
+++ b/business/templates/service.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-$class$: pkey = $pkey$
+$class$: pkey = $pkey$
bizContract: service_id = $pkey$
diff --git a/business/templates/serviceCall.html b/business/templates/serviceCall.html
index f1ede4982..38ed4e2c1 100644
--- a/business/templates/serviceCall.html
+++ b/business/templates/serviceCall.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT $class$ WHERE id = $pkey$
+SELECT $class$ WHERE id = $pkey$
SELECT lnkInfraCall WHERE call_id = $pkey$
diff --git a/business/templates/serviceRequest.html b/business/templates/serviceRequest.html
index d938f8653..4e95b7b51 100644
--- a/business/templates/serviceRequest.html
+++ b/business/templates/serviceRequest.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT $class$ WHERE id = $pkey$
+SELECT $class$ WHERE id = $pkey$
SELECT bizServiceItem WHERE request_id = $pkey$
diff --git a/business/templates/software.html b/business/templates/software.html
index fb50db6a6..12663e9e2 100644
--- a/business/templates/software.html
+++ b/business/templates/software.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-bizSoftware: pkey = $pkey$
+bizSoftware: pkey = $pkey$
bizApplication: soft_id = $pkey$
diff --git a/business/templates/team.html b/business/templates/team.html
index d48b8aefe..d38eea2f6 100644
--- a/business/templates/team.html
+++ b/business/templates/team.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-SELECT $class$ WHERE id = $pkey$
+SELECT $class$ WHERE id = $pkey$
SELECT lnkContactTeam WHERE team_id=$pkey$
diff --git a/business/templates/ticket.html b/business/templates/ticket.html
index 1fcf7709e..fe8f2d5c7 100644
--- a/business/templates/ticket.html
+++ b/business/templates/ticket.html
@@ -4,7 +4,7 @@
SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'
-$class$: pkey = $pkey$
+$class$: pkey = $pkey$
SELECT lnkInfraTicket WHERE ticket_id = $pkey$