- Implementation of the localization... on going...

SVN:trunk[362]
This commit is contained in:
Denis Flaven
2010-04-27 13:10:27 +00:00
parent 42ae42d5ee
commit ef5877779d
6 changed files with 61 additions and 41 deletions

View File

@@ -951,7 +951,7 @@ abstract class cmdbAbstractObject extends CMDBObject
$sOperation = ($oObjectToClone == null) ? 'apply_new' : 'apply_clone';
$sClass = ($oObjectToClone == null) ? $sClass : get_class($oObjectToClone);
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
$oPage->add("<form id=\"creation_form_{$iCreationFormId}\" method=\"post\" onSubmit=\"return CheckMandatoryFields('creation_form_{$iCreationFormId}')\">\n");
$oPage->add("<form id=\"creation_form_{$iCreationFormId}\" method=\"post\" enctype=\"multipart/form-data\" onSubmit=\"return CheckMandatoryFields('creation_form_{$iCreationFormId}')\">\n");
$aStates = MetaModel::EnumStates($sClass);
if ($oObjectToClone == null)
{

View File

@@ -123,12 +123,12 @@ class DisplayBlock
if(empty($aParams['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.");
throw new ApplicationException(Dict::S('UI:Error:MandatoryTemplateParameter_object_id'));
}
if(empty($aParams['target_attr']))
{
// 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.");
throw new ApplicationException(Dict::S('UI:Error:MandatoryTemplateParameter_link_attr'));
}
}
@@ -234,7 +234,7 @@ class DisplayBlock
{
// render it as an Ajax (asynchronous) call
$sHtml .= "<div id=\"$sId\" class=\"display_block loading\">\n";
$sHtml .= $oPage->GetP("<img src=\"../images/indicator_arrows.gif\"> Loading...");
$sHtml .= $oPage->GetP("<img src=\"../images/indicator_arrows.gif\"> ".Dict::S('UI:Loading'));
$sHtml .= "</div>\n";
$sHtml .= '
<script language="javascript">
@@ -312,13 +312,13 @@ class DisplayBlock
$aData[] = array ( 'group' => $sLabels[$sValue],
'value' => "<a href=\"./UI.php?operation=search&dosearch=1&$sParams&filter=$sFilter&$sGroupByField=".urlencode($sValue)."\">$iCount</a>"); // TO DO: add the context information
}
$sHtml .= $oPage->GetTable(array('group' => array('label' => MetaModel::GetLabel($this->m_oFilter->GetClass(), $sGroupByField), 'description' => ''), 'value' => array('label'=>'Count', 'description' => 'Number of elements')), $aData);
$sHtml .= $oPage->GetTable(array('group' => array('label' => MetaModel::GetLabel($this->m_oFilter->GetClass(), $sGroupByField), 'description' => ''), 'value' => array('label'=> Dict::S('UI:GroupBy:Count'), 'description' => Dict::S('UI:GroupBy:Count+'))), $aData);
}
else
{
// Simply count the number of elements in the set
$iCount = $oSet->Count();
$sHtml .= $oPage->GetP("$iCount objects matching the criteria.");
$sHtml .= $oPage->GetP(Dict::Format('UI:CountOfObjects', $iCount));
}
break;
@@ -327,7 +327,7 @@ class DisplayBlock
$aDisplayAliases = isset($aExtraParams['display_aliases']) ? explode(',', $aExtraParams['display_aliases']): array();
if (!isset($aExtraParams['group_by']))
{
$sHtml .= $oPage->GetP("parameter group_by is mandatory.");
$sHtml .= $oPage->GetP(Dict::S('UI:Error:MandatoryTemplateParameter_group_by'));
}
else
{
@@ -343,7 +343,7 @@ class DisplayBlock
}
if (count($aGroupByFields) == 0)
{
$sHtml .= $oPage->GetP("Invalid list of fields to group by: '".$aExtraParams['group_by']."'.");
$sHtml .= $oPage->GetP(Dict::Format('UI:Error:InvalidGroupByFields', $aExtraParams['group_by']));
}
else
{
@@ -427,13 +427,13 @@ class DisplayBlock
else
{
// Empty set
$sHtml .= $oPage->GetP("No object to display.");
$sHtml .= $oPage->GetP(Dict::S('UI:NoObjectToDisplay'));
}
}
else
{
// Not authorized
$sHtml .= $oPage->GetP("No object to display.");
$sHtml .= $oPage->GetP(Dict::S('UI:NoObjectToDisplay'));
}
}
else
@@ -445,7 +445,7 @@ class DisplayBlock
}
else
{
$sHtml .= $oPage->GetP("No object to display.");
$sHtml .= $oPage->GetP(Dict::S('UI:NoObjectToDisplay'));
$sClass = $this->m_oFilter->GetClass();
$bDisplayMenu = isset($aExtraParams['menu']) ? $aExtraParams['menu'] == true : true;
if ($bDisplayMenu)
@@ -468,7 +468,7 @@ class DisplayBlock
}
}
$sHtml .= $oPage->GetP("<a href=\"./UI.php?operation=new&class=$sClass&$sParams{$sDefault}\">Click here to create a new ".Metamodel::GetName($sClass)."</a>\n");
$sHtml .= $oPage->GetP("<a href=\"./UI.php?operation=new&class=$sClass&$sParams{$sDefault}\">".Dict::Format('UI:ClickToCreateNew', Metamodel::GetName($sClass))."</a>\n");
}
}
}
@@ -488,7 +488,7 @@ class DisplayBlock
$sClass = $this->m_oFilter->GetClass();
$oAttDef = MetaModel::GetAttributeDef($sClass, $this->m_aParams['target_attr']);
$sTargetClass = $oAttDef->GetTargetClass();
$sHtml .= $oPage->GetP("No ".MetaModel::GetName($sTargetClass)." to display.");
$sHtml .= $oPage->GetP(Dict::Format('UI:NoObject_Class_ToDisplay', MetaModel::GetName($sTargetClass)));
$bDisplayMenu = isset($this->m_aParams['menu']) ? $this->m_aParams['menu'] == true : true;
if ($bDisplayMenu)
{
@@ -496,7 +496,7 @@ class DisplayBlock
{
$oAppContext = new ApplicationContext();
$sParams = $oAppContext->GetForLink();
$sHtml .= $oPage->GetP("<a href=\"../pages/UI.php?operation=modify_links&class=$sClass&sParams&link_attr=".$aExtraParams['link_attr']."&id=".$aExtraParams['object_id']."&target_class=$sTargetClass&addObjects=true\">Click here to add new ".Metamodel::GetName($sTargetClass)."s</a>\n");
$sHtml .= $oPage->GetP("<a href=\"../pages/UI.php?operation=modify_links&class=$sClass&sParams&link_attr=".$aExtraParams['link_attr']."&id=".$aExtraParams['object_id']."&target_class=$sTargetClass&addObjects=true\">".Dict::Format('UI:ClickToCreateNew', Metamodel::GetName($sClass))."</a>\n");
}
}
}
@@ -753,7 +753,7 @@ class DisplayBlock
default:
// Unsupported style, do nothing.
$sHtml .= "Error: unsupported style of block: ".$this->m_sStyle;
$sHtml .= Dict::format('UI:Error:UnsupportedStyleOfBlock', $this->m_sStyle);
}
return $sHtml;
}
@@ -804,7 +804,7 @@ class HistoryBlock extends DisplayBlock
$oChange = $oContext->GetObject('CMDBChange', $oLatestChangeOp->Get('change'));
$sUserInfo = $oChange->GetAsHTML('userinfo');
$oSet->Rewind(); // Reset the pointer to the beginning of the set
$sHtml .= $oPage->GetStartCollapsibleSection("Last modified on $sDate by $sUserInfo.");
$sHtml .= $oPage->GetStartCollapsibleSection(Dict::Format('UI:History:LastModified_On_By', $sDate, $sUserInfo));
//$sHtml .= cmdbAbstractObject::GetDisplaySet($oPage, $oSet);
$aChanges = array();
while($oChangeOp = $oSet->Fetch())
@@ -823,9 +823,9 @@ class HistoryBlock extends DisplayBlock
$aChanges[$changeId]['log'][] = $sChangeDescription;
}
}
$aAttribs = array('date' => array('label' => 'Date', 'description' => 'Date of the change'),
'userinfo' => array('label' => 'User', 'description' => 'User who made the change'),
'log' => array('label' => 'Changes', 'description' => 'Changes made to the object'),
$aAttribs = array('date' => array('label' => Dict::S('UI:History:Date'), 'description' => Dict::S('UI:History:Date+')),
'userinfo' => array('label' => Dict::S('UI:History:User'), 'description' => Dict::S('UI:History:User+')),
'log' => array('label' => Dict::S('UI:History:Changes'), 'description' => Dict::S('UI:History:Changes+')),
);
$aValues = array();
foreach($aChanges as $aChange)
@@ -874,7 +874,7 @@ class MenuBlock extends DisplayBlock
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{$sDefault}"); }
if ($bIsModifyAllowed) { $aActions[] = array ('label' => Dict::S('UI:Menu:New'), 'url' => "../page/$sUIPage?operation=new&class=$sClass&$sContext{$sDefault}"); }
break;
case 1:
@@ -891,20 +891,20 @@ class MenuBlock extends DisplayBlock
$sTargetAttr = $aExtraParams['target_attr'];
$oAttDef = MetaModel::GetAttributeDef($sClass, $sTargetAttr);
$sTargetClass = $oAttDef->GetTargetClass();
if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'Add...', 'url' => "../pages/$sUIPage?operation=modify_links&class=$sClass&link_attr=".$aExtraParams['link_attr']."&target_class=$sTargetClass&id=$id&addObjects=true&$sContext"); }
if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'Manage...', 'url' => "../pages/$sUIPage?operation=modify_links&class=$sClass&link_attr=".$aExtraParams['link_attr']."&target_class=$sTargetClass&id=$id&sContext"); }
if ($bIsModifyAllowed) { $aActions[] = array ('label' => Dict::S('UI:Menu:Add'), 'url' => "../pages/$sUIPage?operation=modify_links&class=$sClass&link_attr=".$aExtraParams['link_attr']."&target_class=$sTargetClass&id=$id&addObjects=true&$sContext"); }
if ($bIsModifyAllowed) { $aActions[] = array ('label' => Dict::S('UI:Menu:Manage'), 'url' => "../pages/$sUIPage?operation=modify_links&class=$sClass&link_attr=".$aExtraParams['link_attr']."&target_class=$sTargetClass&id=$id&sContext"); }
//if ($bIsDeleteAllowed) { $aActions[] = array ('label' => 'Remove All', 'url' => "#"); }
}
else
{
$sUrl = utils::GetAbsoluteUrl();
$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' => Dict::S('UI:Menu:EMail'), 'url' => "mailto:?subject=".$oSet->GetFilter()->__DescribeHTML()."&body=".urlencode("$sUrl?operation=search&filter=$sFilter&$sContext"));
$aActions[] = array ('label' => Dict::S('UI:Menu:CSVExport'), '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{$sDefault}"); }
if ($bIsModifyAllowed) { $aActions[] = array ('label' => Dict::S('UI:Menu: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"); }
if ($bIsModifyAllowed) { $aActions[] = array ('label' => Dict::S('UI:Menu:Modify'), 'url' => "../pages/$sUIPage?operation=modify&class=$sClass&id=$id&$sContext"); }
if ($bIsDeleteAllowed) { $aActions[] = array ('label' => Dict::S('UI:Menu:Delete'), 'url' => "../pages/$sUIPage?operation=delete&class=$sClass&id=$id&$sContext"); }
}
$aTransitions = $oObj->EnumTransitions();
$aStimuli = Metamodel::EnumStimuli($sClass);
@@ -941,19 +941,19 @@ class MenuBlock extends DisplayBlock
$oAttDef = MetaModel::GetAttributeDef($sClass, $sTargetAttr);
$sTargetClass = $oAttDef->GetTargetClass();
$bIsDeleteAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_DELETE, $oSet);
if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'Add...', 'url' => "../pages/$sUIPage?operation=modify_links&class=$sClass&link_attr=".$aExtraParams['link_attr']."&target_class=$sTargetClass&id=$id&addObjects=true&$sContext"); }
if ($bIsModifyAllowed) { $aActions[] = array ('label' => Dict::S('UI:Menu:Add'), 'url' => "../pages/$sUIPage?operation=modify_links&class=$sClass&link_attr=".$aExtraParams['link_attr']."&target_class=$sTargetClass&id=$id&addObjects=true&$sContext"); }
//if ($bIsBulkModifyAllowed) { $aActions[] = array ('label' => 'Add...', 'url' => "../pages/$sUIPage?operation=modify_links&class=$sClass&linkage=".$aExtraParams['linkage']."&id=$id&addObjects=true&$sContext"); }
if ($bIsBulkModifyAllowed) { $aActions[] = array ('label' => 'Manage...', 'url' => "../pages/$sUIPage?operation=modify_links&class=$sClass&link_attr=".$aExtraParams['link_attr']."&target_class=$sTargetClass&id=$id&sContext"); }
if ($bIsBulkModifyAllowed) { $aActions[] = array ('label' => Dict::S('UI:Menu:Manage'), 'url' => "../pages/$sUIPage?operation=modify_links&class=$sClass&link_attr=".$aExtraParams['link_attr']."&target_class=$sTargetClass&id=$id&sContext"); }
//if ($bIsBulkDeleteAllowed) { $aActions[] = array ('label' => 'Remove All...', 'url' => "#"); }
}
else
{
// many objects in the set, possible actions are: new / modify all / delete all
$sUrl = utils::GetAbsoluteUrl();
$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' => Dict::S('UI:Menu:EMail'), 'url' => "mailto:?subject=".$oSet->GetFilter()->__DescribeHTML()."&body=".urlencode("$sUrl?operation=search&filter=$sFilter&$sContext"));
$aActions[] = array ('label' => Dict::S('UI:Menu:CSVExport'), '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{$sDefault}"); }
if ($bIsModifyAllowed) { $aActions[] = array ('label' => Dict::S('UI:Menu: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"); }
}

View File

@@ -142,7 +142,7 @@ EOF
$oSearchFilter = $oContext->NewFilter("bizOrganization");
$oSet = new CMDBObjectSet($oSearchFilter);
$sSelected = ($this->m_currentOrganization == '') ? ' selected' : '';
$this->AddToMenu("<option value=\"\"$sSelected> All Organizations </option>");
$this->AddToMenu("<option value=\"\"$sSelected>".Dict::S('UI:AllOrganizations')."</option>");
if ($oSet->Count() > 0)
while($oOrg = $oSet->Fetch())
{
@@ -289,17 +289,27 @@ EOF
// if no search text is supplied then
// 1) the search text is filled with "your search"
// 2) clicking on it will erase it
$sText = "Your search";
$sText = Dict::S("UI:YourSearch");
$sOnClick = " onclick=\"this.value='';this.onclick=null;\"";
}
$sUserName = UserRights::GetUser();
$sIsAdmin = UserRights::IsAdministrator() ? '(Administrator)' : '';
echo "<div id=\"Login\" style=\"position:absolute; top:18px; right:16px; width:500px;\">Logged in as '$sUserName'&nbsp;$sIsAdmin&nbsp;&nbsp;";
if (UserRights::IsAdministrator())
{
$sLogonMessage = Dict::Format('UI:LoggedAsMessage+Admin', $sUserName);
}
else
{
$sLogonMessage = Dict::Format('UI:LoggedAsMessage', $sUserName);
}
$sLogOffBtn = Dict::S('UI:Button:Logoff');
$sSearchBtn = Dict::S('UI:Button:Search');
echo "<div id=\"Login\" style=\"position:absolute; top:18px; right:16px; width:600px;\">{$sLogonMessage}&nbsp;&nbsp;";
echo "<form action=\"../pages/UI.php\" method=\"post\" style=\"display:inline\">\n";
echo "<input type=\"submit\" value=\"Log off\" />\n";
echo "<input type=\"submit\" value=\"$sLogOffBtn\" />\n";
echo "<input type=\"hidden\" name=\"loginop\" value=\"logoff\" />\n";
echo "</form>\n";
echo "<form action=\"../pages/UI.php\" style=\"display:inline\"><div style=\"padding:1px; background-color:#fff;display:inline;\"><img src=\"../images/magnifier.gif\"/><input style=\"border:0\" type=\"text\" size=\"15\" title=\"Global Search\" name=\"text\" value=\"$sText\"$sOnClick></input></div><input type=\"submit\" value=\"Search\" />
echo "<form action=\"../pages/UI.php\" style=\"display:inline\"><div style=\"padding:1px; background-color:#fff;display:inline;\"><img src=\"../images/magnifier.gif\"/><input style=\"border:0\" type=\"text\" size=\"15\" title=\"Global Search\" name=\"text\" value=\"$sText\"$sOnClick></input></div><input type=\"submit\" value=\"$sSearchBtn\" />
<input type=\"hidden\" name=\"operation\" value=\"full_text\" /></form>\n";
echo "</div>\n";

View File

@@ -63,7 +63,7 @@ class menuNode extends DBObject
public function GetMenuName()
{
return $this->Get('name');
return Dict::S($this->Get('name'));
}
public function GetMenuIcon()
@@ -73,7 +73,7 @@ class menuNode extends DBObject
public function GetMenuLabel()
{
return $this->Get('label');
return Dict::S($this->Get('label'));
}
public function GetMenuLink($aExtraParams)

View File

@@ -35,14 +35,20 @@ class NiceWebPage extends WebPage
// $aTopLevelClasses = array('bizService', 'bizContact', 'logInfra', 'bizDocument');
// These are classes wich root class is cmdbAbstractObject !
$this->add("<select id=\"select_$sName\" name=\"$sName\">");
$aValidClasses = array();
foreach(MetaModel::GetClasses('bizmodel') as $sClassName)
{
if (is_null($iActionCode) || UserRights::IsActionAllowed($sClassName, $iActionCode))
{
$sSelected = ($sClassName == $sDefaultValue) ? " SELECTED" : "";
$this->add("<option style=\"width: ".$iWidthPx." px;\" value=\"$sClassName\"$sSelected>$sClassName - ".MetaModel::GetClassDescription($sClassName)."</option>");
$sDescription = MetaModel::GetClassDescription($sClassName);
$sDisplayName = MetaModel::GetName($sClassName);
$aValidClasses[$sDisplayName] = "<option style=\"width: ".$iWidthPx." px;\" title=\"$sDescription\" value=\"$sClassName\"$sSelected>$sDisplayName</option>";
}
}
ksort($aValidClasses);
$this->add(implode("\n", $aValidClasses));
$this->add("</select>");
}

View File

@@ -11,7 +11,7 @@ class DisplayTemplate
public function __construct($sTemplate)
{
$this->m_aTags = array('itopblock', 'itoptabs', 'itoptab', 'itoptoggle');
$this->m_aTags = array('itopblock', 'itoptabs', 'itoptab', 'itoptoggle', 'itopstring');
$this->m_sTemplate = $sTemplate;
}
@@ -150,6 +150,10 @@ class DisplayTemplate
$oPage->EndCollapsibleSection();
break;
case 'itopstring':
$oPage->add(Dict::S($sContent));
break;
case 'itopblock': // No longer used, handled by DisplayBlock::FromTemplate see above
$oPage->add("<!-- Application Error: should be handled by DisplayBlock::FromTemplate -->");
break;