本文整理汇总了PHP中MetaModel::GetAttributeDef方法的典型用法代码示例。如果您正苦于以下问题:PHP MetaModel::GetAttributeDef方法的具体用法?PHP MetaModel::GetAttributeDef怎么用?PHP MetaModel::GetAttributeDef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetaModel
的用法示例。
在下文中一共展示了MetaModel::GetAttributeDef方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AddNodeDetails
/**
* Fills the given XML node with te details of the specified object
*/
function AddNodeDetails(&$oNode, $oObj)
{
$aZlist = MetaModel::GetZListItems(get_class($oObj), 'list');
$aLabels = array();
$index = 0;
foreach ($aZlist as $sAttCode) {
$oAttDef = MetaModel::GetAttributeDef(get_class($oObj), $sAttCode);
$aLabels[] = $oAttDef->GetLabel();
if (!$oAttDef->IsLinkSet()) {
$oNode->SetAttribute('att_' . $index, $oObj->GetAsHTML($sAttCode));
}
$index++;
}
$oNode->SetAttribute('zlist', implode(',', $aLabels));
}
示例2: SuggestField
protected function SuggestField($sClass, $sAttCode)
{
switch ($sAttCode) {
case 'id':
// replace 'id' by 'friendlyname'
$sAttCode = 'friendlyname';
break;
default:
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if ($oAttDef instanceof AttributeExternalKey) {
$sAttCode .= '_friendlyname';
}
}
return parent::SuggestField($sClass, $sAttCode);
}
示例3: FilterByContext
/**
* Adds the context parameters to the audit query
*/
function FilterByContext(DBSearch &$oFilter, ApplicationContext $oAppContext)
{
$sObjClass = $oFilter->GetClass();
$aContextParams = $oAppContext->GetNames();
$aCallSpec = array($sObjClass, 'MapContextParam');
if (is_callable($aCallSpec)) {
foreach ($aContextParams as $sParamName) {
$sValue = $oAppContext->GetCurrentValue($sParamName, null);
if ($sValue != null) {
$sAttCode = call_user_func($aCallSpec, $sParamName);
// Returns null when there is no mapping for this parameter
if ($sAttCode != null && MetaModel::IsValidAttCode($sObjClass, $sAttCode)) {
// Check if the condition points to a hierarchical key
if ($sAttCode == 'id') {
// Filtering on the objects themselves
$sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($sObjClass);
if ($sHierarchicalKeyCode !== false) {
$oRootFilter = new DBObjectSearch($sObjClass);
$oRootFilter->AddCondition($sAttCode, $sValue);
$oFilter->AddCondition_PointingTo($oRootFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW);
// Use the 'below' operator by default
$bConditionAdded = true;
}
} else {
$oAttDef = MetaModel::GetAttributeDef($sObjClass, $sAttCode);
$bConditionAdded = false;
if ($oAttDef->IsExternalKey()) {
$sHierarchicalKeyCode = MetaModel::IsHierarchicalClass($oAttDef->GetTargetClass());
if ($sHierarchicalKeyCode !== false) {
$oRootFilter = new DBObjectSearch($oAttDef->GetTargetClass());
$oRootFilter->AddCondition('id', $sValue);
$oHKFilter = new DBObjectSearch($oAttDef->GetTargetClass());
$oHKFilter->AddCondition_PointingTo($oRootFilter, $sHierarchicalKeyCode, TREE_OPERATOR_BELOW);
// Use the 'below' operator by default
$oFilter->AddCondition_PointingTo($oHKFilter, $sAttCode);
$bConditionAdded = true;
}
}
}
if (!$bConditionAdded) {
$oFilter->AddCondition($sAttCode, $sValue);
}
}
}
}
}
}
示例4: MakeResultValue
/**
* Helper to make an output value for a given attribute
*
* @param DBObject $oObject The object being reported
* @param string $sAttCode The attribute code (must be valid)
* @param boolean $bExtendedOutput Output all of the link set attributes ?
* @return string A scalar representation of the value
*/
protected function MakeResultValue(DBObject $oObject, $sAttCode, $bExtendedOutput = false)
{
if ($sAttCode == 'id') {
$value = $oObject->GetKey();
} else {
$sClass = get_class($oObject);
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if ($oAttDef instanceof AttributeLinkedSet) {
// Iterate on the set and build an array of array of attcode=>value
$oSet = $oObject->Get($sAttCode);
$value = array();
while ($oLnk = $oSet->Fetch()) {
$sLnkRefClass = $bExtendedOutput ? get_class($oLnk) : $oAttDef->GetLinkedClass();
$aLnkValues = array();
foreach (MetaModel::ListAttributeDefs($sLnkRefClass) as $sLnkAttCode => $oLnkAttDef) {
// Skip attributes pointing to the current object (redundant data)
if ($sLnkAttCode == $oAttDef->GetExtKeyToMe()) {
continue;
}
// Skip any attribute of the link that points to the current object
$oLnkAttDef = MetaModel::GetAttributeDef($sLnkRefClass, $sLnkAttCode);
if (method_exists($oLnkAttDef, 'GetKeyAttCode')) {
if ($oLnkAttDef->GetKeyAttCode() == $oAttDef->GetExtKeyToMe()) {
continue;
}
}
$aLnkValues[$sLnkAttCode] = $this->MakeResultValue($oLnk, $sLnkAttCode, $bExtendedOutput);
}
$value[] = $aLnkValues;
}
} else {
$value = $oAttDef->GetForJSON($oObject->Get($sAttCode));
}
}
return $value;
}
示例5: DisplayBareProperties
function DisplayBareProperties(WebPage $oPage, $bEditMode = false, $sPrefix = '', $aExtraParams = array())
{
$aFieldsMap = parent::DisplayBareProperties($oPage, $bEditMode, $sPrefix, $aExtraParams);
if (!$bEditMode) {
$sFields = trim($this->Get('fields'));
$bExportV1Recommended = $sFields == '';
if ($bExportV1Recommended) {
$oFieldAttDef = MetaModel::GetAttributeDef('QueryOQL', 'fields');
$oPage->add('<div class="message message_error" style="padding-left: 30px;"><div style="padding: 10px;">' . Dict::Format('UI:Query:UrlV1', $oFieldAttDef->GetLabel()) . '</div></div>');
$sUrl = utils::GetAbsoluteUrlAppRoot() . 'webservices/export.php?format=spreadsheet&login_mode=basic&query=' . $this->GetKey();
} else {
$sUrl = utils::GetAbsoluteUrlAppRoot() . 'webservices/export-v2.php?format=spreadsheet&login_mode=basic&query=' . $this->GetKey();
}
$sOql = $this->Get('oql');
$sMessage = null;
try {
$oSearch = DBObjectSearch::FromOQL($sOql);
$aParameters = $oSearch->GetQueryParams();
foreach ($aParameters as $sParam => $val) {
$sUrl .= '&arg_' . $sParam . '=["' . $sParam . '"]';
}
$oPage->p(Dict::S('UI:Query:UrlForExcel') . ':<br/><textarea cols="80" rows="3" READONLY>' . $sUrl . '</textarea>');
if (count($aParameters) == 0) {
$oBlock = new DisplayBlock($oSearch, 'list');
$aExtraParams = array('table_id' => 'query_preview_' . $this->getKey());
$sBlockId = 'block_query_preview_' . $this->GetKey();
// make a unique id (edition occuring in the same DOM)
$oBlock->Display($oPage, $sBlockId, $aExtraParams);
}
} catch (OQLException $e) {
$sMessage = '<div class="message message_error" style="padding-left: 30px;"><div style="padding: 10px;">' . Dict::Format('UI:RunQuery:Error', $e->getHtmlDesc()) . '</div></div>';
$oPage->p($sMessage);
}
}
return $aFieldsMap;
}
示例6: GetTooltip
public function GetTooltip($aContextDefs)
{
$sHtml = '';
$oCurrObj = $this->GetProperty('object');
$sSubClass = get_class($oCurrObj);
$sHtml .= $oCurrObj->GetHyperlink() . "<hr/>";
$aContextRootCauses = $this->GetProperty('context_root_causes');
if (!is_null($aContextRootCauses)) {
foreach ($aContextRootCauses as $key => $aObjects) {
$aContext = $aContextDefs[$key];
$aRootCauses = array();
foreach ($aObjects as $oRootCause) {
$aRootCauses[] = $oRootCause->GetHyperlink();
}
$sHtml .= '<p><img style="max-height: 24px; vertical-align:bottom;" src="' . utils::GetAbsoluteUrlModulesRoot() . $aContext['icon'] . '" title="' . htmlentities(Dict::S($aContext['dict'])) . '"> ' . implode(', ', $aRootCauses) . '</p>';
}
$sHtml .= '<hr/>';
}
$sHtml .= '<table><tbody>';
foreach (MetaModel::GetZListItems($sSubClass, 'list') as $sAttCode) {
$oAttDef = MetaModel::GetAttributeDef($sSubClass, $sAttCode);
$sHtml .= '<tr><td>' . $oAttDef->GetLabel() . ': </td><td>' . $oCurrObj->GetAsHtml($sAttCode) . '</td></tr>';
}
$sHtml .= '</tbody></table>';
return $sHtml;
}
示例7: unserialize
public function unserialize($sData)
{
$aData = unserialize($sData);
$this->iDefaultPageSize = $aData['iDefaultPageSize'];
$this->aColumns = $aData['aColumns'];
foreach ($this->aClassAliases as $sAlias => $sClass) {
foreach ($this->aColumns[$sAlias] as $sAttCode => $aData) {
$aFieldData = false;
if ($sAttCode == '_key_') {
$aFieldData = $this->GetFieldData($sAlias, $sAttCode, null, true, $aData['sort']);
} else {
if (MetaModel::isValidAttCode($sClass, $sAttCode)) {
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
$aFieldData = $this->GetFieldData($sAlias, $sAttCode, $oAttDef, true, $aData['sort']);
}
}
if ($aFieldData) {
$this->aColumns[$sAlias][$sAttCode] = $aFieldData;
} else {
unset($this->aColumns[$sAlias][$sAttCode]);
}
}
}
$this->FixVisibleColumns();
}
示例8: PrepareChangeOpLinkSet
/**
* Common to the recording of link set changes (add/remove/modify)
*/
private function PrepareChangeOpLinkSet($iLinkSetOwnerId, $oLinkSet, $sChangeOpClass, $aOriginalValues = null)
{
if ($iLinkSetOwnerId <= 0) {
return null;
}
if (!is_subclass_of($oLinkSet->GetHostClass(), 'CMDBObject')) {
// The link set owner class does not keep track of its history
return null;
}
// Determine the linked item class and id
//
if ($oLinkSet->IsIndirect()) {
// The "item" is on the other end (N-N links)
$sExtKeyToRemote = $oLinkSet->GetExtKeyToRemote();
$oExtKeyToRemote = MetaModel::GetAttributeDef(get_class($this), $sExtKeyToRemote);
$sItemClass = $oExtKeyToRemote->GetTargetClass();
if ($aOriginalValues) {
// Get the value from the original values
$iItemId = $aOriginalValues[$sExtKeyToRemote];
} else {
$iItemId = $this->Get($sExtKeyToRemote);
}
} else {
// I am the "item" (1-N links)
$sItemClass = get_class($this);
$iItemId = $this->GetKey();
}
// Get the remote object, to determine its exact class
// Possible optimization: implement a tool in MetaModel, to get the final class of an object (not always querying + query reduced to a select on the root table!
$oOwner = MetaModel::GetObject($oLinkSet->GetHostClass(), $iLinkSetOwnerId, false);
if ($oOwner) {
$sLinkSetOwnerClass = get_class($oOwner);
$oMyChangeOp = MetaModel::NewObject($sChangeOpClass);
$oMyChangeOp->Set("objclass", $sLinkSetOwnerClass);
$oMyChangeOp->Set("objkey", $iLinkSetOwnerId);
$oMyChangeOp->Set("attcode", $oLinkSet->GetCode());
$oMyChangeOp->Set("item_class", $sItemClass);
$oMyChangeOp->Set("item_id", $iItemId);
return $oMyChangeOp;
} else {
// Depending on the deletion order, it may happen that the id is already invalid... ignore
return null;
}
}
示例9: ParseJsonSet
static function ParseJsonSet($oMe, $sLinkClass, $sExtKeyToMe, $sJsonSet)
{
$aSet = json_decode($sJsonSet, true);
// true means hash array instead of object
$oSet = CMDBObjectSet::FromScratch($sLinkClass);
foreach ($aSet as $aLinkObj) {
$oLink = MetaModel::NewObject($sLinkClass);
foreach ($aLinkObj as $sAttCode => $value) {
$oAttDef = MetaModel::GetAttributeDef($sLinkClass, $sAttCode);
if ($oAttDef->IsExternalKey() && $value != '' && $value > 0) {
// For external keys: load the target object so that external fields
// get filled too
$oTargetObj = MetaModel::GetObject($oAttDef->GetTargetClass(), $value);
$oLink->Set($sAttCode, $oTargetObj);
}
$oLink->Set($sAttCode, $value);
}
$oLink->Set($sExtKeyToMe, $oMe->GetKey());
$oSet->AddObject($oLink);
}
return $oSet;
}
示例10: DisplaySearchField
protected function DisplaySearchField($sClass, $sAttSpec, $aExtraParams, $sPrefix, $sFieldName = null, $aFilterParams = array())
{
if (is_null($sFieldName)) {
$sFieldName = str_replace('->', PARAM_ARROW_SEP, $sAttSpec);
}
$iPos = strpos($sAttSpec, '->');
if ($iPos !== false) {
$sAttCode = substr($sAttSpec, 0, $iPos);
$sSubSpec = substr($sAttSpec, $iPos + 2);
if (!MetaModel::IsValidAttCode($sClass, $sAttCode)) {
throw new Exception("Invalid attribute code '{$sClass}/{$sAttCode}' in search specification '{$sAttSpec}'");
}
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if ($oAttDef->IsLinkSet()) {
$sTargetClass = $oAttDef->GetLinkedClass();
} elseif ($oAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) {
$sTargetClass = $oAttDef->GetTargetClass(EXTKEY_ABSOLUTE);
} else {
throw new Exception("Attribute specification '{$sAttSpec}', '{$sAttCode}' should be either a link set or an external key");
}
$this->DisplaySearchField($sTargetClass, $sSubSpec, $aExtraParams, $sPrefix, $sFieldName, $aFilterParams);
} else {
// $sAttSpec is an attribute code
//
$this->add('<span style="white-space: nowrap;padding:5px;display:inline-block;">');
$sFilterValue = '';
$sFilterValue = utils::ReadParam($sPrefix . $sFieldName, '', false, 'raw_data');
$sFilterOpCode = null;
// Use the default 'loose' OpCode
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttSpec);
if ($oAttDef->IsExternalKey()) {
$sTargetClass = $oAttDef->GetTargetClass();
$sFilterDefName = 'PORTAL_TICKETS_SEARCH_FILTER_' . $sAttSpec;
if (defined($sFilterDefName)) {
try {
$oFitlerWithParams = DBObjectSearch::FromOQL(constant($sFilterDefName));
$sFilterOQL = $oFitlerWithParams->ToOQL(true, $aFilterParams);
$oAllowedValues = new DBObjectSet(DBObjectSearch::FromOQL($sFilterOQL), array(), $aFilterParams);
} catch (OQLException $e) {
throw new Exception("Incorrect filter '{$sFilterDefName}' for attribute '{$sAttcode}': " . $e->getMessage());
}
} else {
$oAllowedValues = new DBObjectSet(new DBObjectSearch($sTargetClass));
}
$iFieldSize = $oAttDef->GetMaxSize();
$iMaxComboLength = $oAttDef->GetMaximumComboLength();
$this->add("<label>" . MetaModel::GetFilterLabel($sClass, $sAttSpec) . ":</label> ");
//$oWidget = UIExtKeyWidget::DIsplayFromAttCode($sAttSpec, $sClass, $oAttDef->GetLabel(), $oAllowedValues, $sFilterValue, $sPrefix.$sFieldName, false, '', $sPrefix, '');
//$this->add($oWidget->Display($this, $aExtraParams, true /* bSearchMode */));
$aExtKeyParams = $aExtraParams;
$aExtKeyParams['iFieldSize'] = $oAttDef->GetMaxSize();
$aExtKeyParams['iMinChars'] = $oAttDef->GetMinAutoCompleteChars();
// DisplayFromAttCode($this, $sAttCode, $sClass, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName = '', $sFormPrefix = '', $aArgs, $bSearchMode = false)
$sHtml = UIExtKeyWidget::DisplayFromAttCode($this, $sAttSpec, $sClass, $oAttDef->GetLabel(), $oAllowedValues, $sFilterValue, $sPrefix . $sFieldName, false, $sPrefix . $sFieldName, $sPrefix, $aExtKeyParams, true);
$this->add($sHtml);
} else {
$aAllowedValues = MetaModel::GetAllowedValues_flt($sClass, $sAttSpec, $aExtraParams);
if (is_null($aAllowedValues)) {
// Any value is possible, display an input box
$sSanitizedValue = htmlentities($sFilterValue, ENT_QUOTES, 'UTF-8');
$this->add("<label>" . MetaModel::GetFilterLabel($sClass, $sAttSpec) . ":</label> <input class=\"textSearch\" name=\"{$sPrefix}{$sFieldName}\" value=\"{$sSanitizedValue}\"/>\n");
} else {
//Enum field or external key, display a combo
$sValue = "<select name=\"{$sPrefix}{$sFieldName}\">\n";
$sValue .= "<option value=\"\">" . Dict::S('UI:SearchValue:Any') . "</option>\n";
foreach ($aAllowedValues as $key => $value) {
if ($sFilterValue == $key) {
$sSelected = ' selected';
} else {
$sSelected = '';
}
$sValue .= "<option value=\"{$key}\"{$sSelected}>{$value}</option>\n";
}
$sValue .= "</select>\n";
$this->add("<label>" . MetaModel::GetFilterLabel($sClass, $sAttSpec) . ":</label> {$sValue}\n");
}
}
unset($aExtraParams[$sFieldName]);
$this->add('</span> ');
$sTip = $oAttDef->GetHelpOnSmartSearch();
if (strlen($sTip) > 0) {
$sTip = addslashes($sTip);
$sTip = str_replace(array("\n", "\r"), " ", $sTip);
// :input does represent in form visible input (INPUT, SELECT, TEXTAREA)
$this->add_ready_script("\$(':input[name={$sPrefix}{$sFieldName}]').qtip( { content: '{$sTip}', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );");
}
}
}
示例11: AddLinkedObjects
/**
* Helper to link objects
*
* @param string sLinkAttCode
* @param string sLinkedClass
* @param array $aLinkList
* @param DBObject oTargetObj
* @param WebServiceResult oRes
*
* @return array List of objects that could not be found
*/
protected function AddLinkedObjects($sLinkAttCode, $sParamName, $sLinkedClass, $aLinkList, &$oTargetObj, &$oRes)
{
$oLinkAtt = MetaModel::GetAttributeDef(get_class($oTargetObj), $sLinkAttCode);
$sLinkClass = $oLinkAtt->GetLinkedClass();
$sExtKeyToItem = $oLinkAtt->GetExtKeyToRemote();
$aItemsFound = array();
$aItemsNotFound = array();
if (is_null($aLinkList)) {
return $aItemsNotFound;
}
foreach ($aLinkList as $aItemData) {
if (!array_key_exists('class', $aItemData)) {
$oRes->LogWarning("Parameter {$sParamName}: missing 'class' specification");
continue;
// skip
}
$sTargetClass = $aItemData['class'];
if (!MetaModel::IsValidClass($sTargetClass)) {
$oRes->LogError("Parameter {$sParamName}: invalid class '{$sTargetClass}'");
continue;
// skip
}
if (!MetaModel::IsParentClass($sLinkedClass, $sTargetClass)) {
$oRes->LogError("Parameter {$sParamName}: '{$sTargetClass}' is not a child class of '{$sLinkedClass}'");
continue;
// skip
}
$oReconFilter = new CMDBSearchFilter($sTargetClass);
$aCIStringDesc = array();
foreach ($aItemData['search'] as $sAttCode => $value) {
if (!MetaModel::IsValidFilterCode($sTargetClass, $sAttCode)) {
$aCodes = array_keys(MetaModel::GetClassFilterDefs($sTargetClass));
$oRes->LogError("Parameter {$sParamName}: '{$sAttCode}' is not a valid filter code for class '{$sTargetClass}', expecting a value in {" . implode(', ', $aCodes) . "}");
continue 2;
// skip the entire item
}
$aCIStringDesc[] = "{$sAttCode}: {$value}";
// The attribute is one of our reconciliation key
$oReconFilter->AddCondition($sAttCode, $value, '=');
}
if (count($aCIStringDesc) == 1) {
// take the last and unique value to describe the object
$sItemDesc = $value;
} else {
// describe the object by the given keys
$sItemDesc = $sTargetClass . '(' . implode('/', $aCIStringDesc) . ')';
}
$oExtObjects = new CMDBObjectSet($oReconFilter);
switch ($oExtObjects->Count()) {
case 0:
$oRes->LogWarning("Parameter {$sParamName}: object to link {$sLinkedClass} / {$sItemDesc} could not be found (searched: '" . $oReconFilter->ToOQL(true) . "')");
$aItemsNotFound[] = $sItemDesc;
break;
case 1:
$aItemsFound[] = array('object' => $oExtObjects->Fetch(), 'link_values' => @$aItemData['link_values'], 'desc' => $sItemDesc);
break;
default:
$oRes->LogWarning("Parameter {$sParamName}: Found " . $oExtObjects->Count() . " matches for item '{$sItemDesc}' (searched: '" . $oReconFilter->ToOQL(true) . "')");
$aItemsNotFound[] = $sItemDesc;
}
}
if (count($aItemsFound) > 0) {
$aLinks = array();
foreach ($aItemsFound as $aItemData) {
$oLink = MetaModel::NewObject($sLinkClass);
$oLink->Set($sExtKeyToItem, $aItemData['object']->GetKey());
foreach ($aItemData['link_values'] as $sKey => $value) {
if (!MetaModel::IsValidAttCode($sLinkClass, $sKey)) {
$oRes->LogWarning("Parameter {$sParamName}: Attaching item '" . $aItemData['desc'] . "', the attribute code '{$sKey}' is not valid ; check the class '{$sLinkClass}'");
} else {
$oLink->Set($sKey, $value);
}
}
$aLinks[] = $oLink;
}
$oImpactedInfraSet = DBObjectSet::FromArray($sLinkClass, $aLinks);
$oTargetObj->Set($sLinkAttCode, $oImpactedInfraSet);
}
return $aItemsNotFound;
}
示例12: htmlentities
if ($oObj->IsNew()) {
$iFlags = $oObj->GetInitialStateAttributeFlags($sAttCode);
} else {
$iFlags = $oObj->GetAttributeFlags($sAttCode);
}
if ($iFlags & OPT_ATT_READONLY) {
$sHTMLValue = "<span id=\"field_{$sId}\">" . $oObj->GetAsHTML($sAttCode);
$sHTMLValue .= '<input type="hidden" id="' . $sId . '" name="attr_' . $sFormPrefix . $sAttCode . '" value="' . htmlentities($oObj->Get($sAttCode), ENT_QUOTES, 'UTF-8') . '"/></span>';
$oWizardHelper->SetAllowedValuesHtml($sAttCode, $sHTMLValue);
} else {
// It may happen that the field we'd like to update does not
// exist in the form. For example, if the field should be hidden/read-only
// in the current state of the object
$value = $oObj->Get($sAttCode);
$displayValue = $oObj->GetEditValue($sAttCode);
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if (!$oAttDef->IsWritable()) {
// Even non-writable fields (like AttributeExternal) can be refreshed
$sHTMLValue = $oObj->GetAsHTML($sAttCode);
} else {
$iFlags = MetaModel::GetAttributeFlags($sClass, $oObj->GetState(), $sAttCode);
$sHTMLValue = cmdbAbstractObject::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value, $displayValue, $sId, '', $iFlags, array('this' => $oObj, 'formPrefix' => $sFormPrefix));
// Make sure that we immediately validate the field when we reload it
$oPage->add_ready_script("\$('#{$sId}').trigger('validate');");
}
$oWizardHelper->SetAllowedValuesHtml($sAttCode, $sHTMLValue);
}
}
}
$oPage->add_script("oWizardHelper{$sFormPrefix}.m_oData=" . $oWizardHelper->ToJSON() . ";\noWizardHelper{$sFormPrefix}.UpdateFields();\n");
break;
示例13: DisplayBareRelations
function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
{
parent::DisplayBareRelations($oPage, $bEditMode);
$sTicketListAttCode = 'tickets_list';
if (MetaModel::IsValidAttCode(get_class($this), $sTicketListAttCode)) {
// Display one list per leaf class (the only way to display the status as of now)
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sTicketListAttCode);
$sLnkClass = $oAttDef->GetLinkedClass();
$sExtKeyToMe = $oAttDef->GetExtKeyToMe();
$sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
$iTotal = 0;
$aSearches = array();
foreach (MetaModel::EnumChildClasses('Ticket') as $sSubClass) {
if (!MetaModel::HasChildrenClasses($sSubClass)) {
$sStateAttCode = MetaModel::GetStateAttributeCode($sSubClass);
if ($sStateAttCode != '') {
$oSearch = DBSearch::FromOQL("SELECT {$sSubClass} AS t JOIN {$sLnkClass} AS lnk ON lnk.{$sExtKeyToRemote} = t.id WHERE {$sExtKeyToMe} = :myself AND {$sStateAttCode} NOT IN ('rejected', 'resolved', 'closed')", array('myself' => $this->GetKey()));
$aSearches[$sSubClass] = $oSearch;
$oSet = new DBObjectSet($oSearch);
$iTotal += $oSet->Count();
}
}
}
$sCount = $iTotal > 0 ? ' (' . $iTotal . ')' : '';
$oPage->SetCurrentTab(Dict::S('Class:FunctionalCI/Tab:OpenedTickets') . $sCount);
foreach ($aSearches as $sSubClass => $oSearch) {
$sBlockId = __CLASS__ . '_opened_' . $sSubClass;
$oPage->add('<fieldset>');
$oPage->add('<legend>' . MetaModel::GetName($sSubClass) . '</legend>');
$oBlock = new DisplayBlock($oSearch, 'list', false);
$oBlock->Display($oPage, $sBlockId, array('menu' => false));
$oPage->add('</fieldset>');
}
}
}
示例14: GetDescription
public function GetDescription($sDefault = null)
{
$sLabel = parent::GetDescription('');
if (strlen($sLabel) == 0) {
$sKeyAttCode = $this->Get("extkey_attcode");
if ($sKeyAttCode == 'id') {
return Dict::S('Core:FriendlyName-Description');
} else {
$oExtKeyAttDef = MetaModel::GetAttributeDef($this->GetHostClass(), $sKeyAttCode);
$sLabel = $oExtKeyAttDef->GetDescription('');
}
}
return $sLabel;
}
示例15: CheckProjectionSpec
public function CheckProjectionSpec($oProjectionSpec, $sProjectedClass)
{
$sExpression = $oProjectionSpec->Get('value');
$sAttribute = $oProjectionSpec->Get('attribute');
// Shortcut: "any value" or "no value" means no projection
if (empty($sExpression)) {
return;
}
if ($sExpression == '<any>') {
return;
}
// 1st - compute the data type for the dimension
//
$sType = $this->Get('type');
if (MetaModel::IsValidClass($sType)) {
$sExpectedType = $sType;
} else {
$sExpectedType = '_scalar_';
}
// 2nd - compute the data type for the projection
//
$sTargetClass = '';
if ($sExpression == '<this>' || $sExpression == '<user>') {
$sTargetClass = $sProjectedClass;
} elseif ($sExpression == '<any>') {
$sTargetClass = '';
} else {
// Evaluate wether it is a constant or not
try {
$oObjectSearch = DBObjectSearch::FromOQL_AllData($sExpression);
$sTargetClass = $oObjectSearch->GetClass();
} catch (OqlException $e) {
}
}
if (empty($sTargetClass)) {
$sFoundType = '_void_';
} else {
if (empty($sAttribute)) {
$sFoundType = $sTargetClass;
} else {
if (!MetaModel::IsValidAttCode($sTargetClass, $sAttribute)) {
throw new CoreException('Unkown attribute code in projection specification', array('found' => $sAttribute, 'expecting' => MetaModel::GetAttributesList($sTargetClass), 'class' => $sTargetClass, 'projection' => $oProjectionSpec));
}
$oAttDef = MetaModel::GetAttributeDef($sTargetClass, $sAttribute);
if ($oAttDef->IsExternalKey()) {
$sFoundType = $oAttDef->GetTargetClass();
} else {
$sFoundType = '_scalar_';
}
}
}
// Compare the dimension type and projection type
if ($sFoundType != '_void_' && $sFoundType != $sExpectedType) {
throw new CoreException('Wrong type in projection specification', array('found' => $sFoundType, 'expecting' => $sExpectedType, 'expression' => $sExpression, 'attribute' => $sAttribute, 'projection' => $oProjectionSpec));
}
}