本文整理汇总了PHP中MetaModel::FlattenZlist方法的典型用法代码示例。如果您正苦于以下问题:PHP MetaModel::FlattenZlist方法的具体用法?PHP MetaModel::FlattenZlist怎么用?PHP MetaModel::FlattenZlist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetaModel
的用法示例。
在下文中一共展示了MetaModel::FlattenZlist方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ComputeWizardStructure
/**
* Compute the order of the fields & pages in the wizard
* @param $oPage iTopWebPage The current page (used to display error messages)
* @param $sClass string Name of the class
* @param $sStateCode string Code of the target state of the object
* @return hash Two dimensional array: each element represents the list of fields for a given page
*/
protected function ComputeWizardStructure()
{
$aWizardSteps = array('mandatory' => array(), 'optional' => array());
$aFieldsDone = array();
// Store all the fields that are already covered by a previous step of the wizard
$aStates = MetaModel::EnumStates($this->m_sClass);
$sStateAttCode = MetaModel::GetStateAttributeCode($this->m_sClass);
$aMandatoryAttributes = array();
// Some attributes are always mandatory independently of the state machine (if any)
foreach (MetaModel::GetAttributesList($this->m_sClass) as $sAttCode) {
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
if (!$oAttDef->IsExternalField() && !$oAttDef->IsNullAllowed() && $oAttDef->IsWritable() && $sAttCode != $sStateAttCode) {
$aMandatoryAttributes[$sAttCode] = OPT_ATT_MANDATORY;
}
}
// Now check the attributes that are mandatory in the specified state
if (!empty($this->m_sTargetState) && count($aStates[$this->m_sTargetState]['attribute_list']) > 0) {
// Check all the fields that *must* be included in the wizard for this
// particular target state
$aFields = array();
foreach ($aStates[$this->m_sTargetState]['attribute_list'] as $sAttCode => $iOptions) {
if (isset($aMandatoryAttributes[$sAttCode]) && $aMandatoryAttributes[$sAttCode] & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT)) {
$aMandatoryAttributes[$sAttCode] |= $iOptions;
} else {
$aMandatoryAttributes[$sAttCode] = $iOptions;
}
}
}
// Check all the fields that *must* be included in the wizard
// i.e. all mandatory, must-change or must-prompt fields that are
// not also read-only or hidden.
// Some fields may be required (null not allowed) from the database
// perspective, but hidden or read-only from the user interface perspective
$aFields = array();
foreach ($aMandatoryAttributes as $sAttCode => $iOptions) {
if ($iOptions & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT) && !($iOptions & (OPT_ATT_READONLY | OPT_ATT_HIDDEN))) {
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
$aPrerequisites = $oAttDef->GetPrerequisiteAttributes();
$aFields[$sAttCode] = array();
foreach ($aPrerequisites as $sCode) {
$aFields[$sAttCode][$sCode] = '';
}
}
}
// Now use the dependencies between the fields to order them
// Start from the order of the 'details'
$aList = MetaModel::FlattenZlist(MetaModel::GetZListItems($this->m_sClass, 'details'));
$index = 0;
$aOrder = array();
foreach ($aFields as $sAttCode => $void) {
$aOrder[$sAttCode] = 999;
// At the end of the list...
}
foreach ($aList as $sAttCode) {
if (array_key_exists($sAttCode, $aFields)) {
$aOrder[$sAttCode] = $index;
}
$index++;
}
foreach ($aFields as $sAttCode => $aDependencies) {
// All fields with no remaining dependencies can be entered at this
// step of the wizard
if (count($aDependencies) > 0) {
$iMaxPos = 0;
// Remove this field from the dependencies of the other fields
foreach ($aDependencies as $sDependentAttCode => $void) {
// position the current field after the ones it depends on
$iMaxPos = max($iMaxPos, 1 + $aOrder[$sDependentAttCode]);
}
}
}
asort($aOrder);
$aCurrentStep = array();
foreach ($aOrder as $sAttCode => $rank) {
$aCurrentStep[] = $sAttCode;
$aFieldsDone[$sAttCode] = '';
}
$aWizardSteps['mandatory'][] = $aCurrentStep;
// Now computes the steps to fill the optional fields
$aFields = array();
// reset
foreach (MetaModel::ListAttributeDefs($this->m_sClass) as $sAttCode => $oAttDef) {
$iOptions = isset($aStates[$this->m_sTargetState]['attribute_list'][$sAttCode]) ? $aStates[$this->m_sTargetState]['attribute_list'][$sAttCode] : 0;
if ($sStateAttCode != $sAttCode && !$oAttDef->IsExternalField() && ($iOptions & (OPT_ATT_HIDDEN | OPT_ATT_READONLY)) == 0 && !isset($aFieldsDone[$sAttCode])) {
// 'State', external fields, read-only and hidden fields
// and fields that are already listed in the wizard
// are removed from the 'optional' part of the wizard
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
$aPrerequisites = $oAttDef->GetPrerequisiteAttributes();
$aFields[$sAttCode] = array();
foreach ($aPrerequisites as $sCode) {
if (!isset($aFieldsDone[$sCode])) {
// retain only the dependencies that were not covered
//.........这里部分代码省略.........
示例2: DisplayBareProperties
function DisplayBareProperties(WebPage $oPage, $bEditMode = false, $sPrefix = '', $aExtraParams = array())
{
if ($bEditMode) {
return array();
}
// Not editable
$aDetails = array();
$sClass = get_class($this);
$aZList = MetaModel::FlattenZlist(MetaModel::GetZListItems($sClass, 'details'));
foreach ($aZList as $sAttCode) {
$sDisplayValue = $this->GetAsHTML($sAttCode);
$aDetails[] = array('label' => '<span title="' . MetaModel::GetDescription($sClass, $sAttCode) . '">' . MetaModel::GetLabel($sClass, $sAttCode) . '</span>', 'value' => $sDisplayValue);
}
$oPage->Details($aDetails);
return array();
}
示例3: DisplayBareProperties
function DisplayBareProperties(WebPage $oPage, $bEditMode = false, $sPrefix = '', $aExtraParams = array())
{
if ($bEditMode) {
return;
}
// Not editable
$oPage->add('<table style="vertical-align:top"><tr style="vertical-align:top"><td>');
$aDetails = array();
$sClass = get_class($this);
$oPage->add('<fieldset>');
$oPage->add('<legend>' . Dict::S('Core:SynchroReplica:PrivateDetails') . '</legend>');
$aZList = MetaModel::FlattenZlist(MetaModel::GetZListItems($sClass, 'details'));
foreach ($aZList as $sAttCode) {
$sDisplayValue = $this->GetAsHTML($sAttCode);
$aDetails[] = array('label' => '<span title="' . MetaModel::GetDescription($sClass, $sAttCode) . '">' . MetaModel::GetLabel($sClass, $sAttCode) . '</span>', 'value' => $sDisplayValue);
}
$oPage->Details($aDetails);
$oPage->add('</fieldset>');
if (strlen($this->Get('dest_class')) > 0) {
$oDestObj = MetaModel::GetObject($this->Get('dest_class'), $this->Get('dest_id'), false);
if (is_object($oDestObj)) {
$oPage->add('<fieldset>');
$oPage->add('<legend>' . Dict::Format('Core:SynchroReplica:TargetObject', $oDestObj->GetHyperlink()) . '</legend>');
$oDestObj->DisplayBareProperties($oPage, false, $sPrefix, $aExtraParams);
$oPage->add('<fieldset>');
}
}
$oPage->add('</td><td>');
$oPage->add('<fieldset>');
$oPage->add('<legend>' . Dict::S('Core:SynchroReplica:PublicData') . '</legend>');
$oSource = MetaModel::GetObject('SynchroDataSource', $this->Get('sync_source_id'));
$sSQLTable = $oSource->GetDataTable();
$aData = $this->LoadExtendedDataFromTable($sSQLTable);
$aHeaders = array('attcode' => array('label' => 'Attribute Code', 'description' => ''), 'data' => array('label' => 'Value', 'description' => ''));
$aRows = array();
foreach ($aData as $sKey => $value) {
$aRows[] = array('attcode' => $sKey, 'data' => $value);
}
$oPage->Table($aHeaders, $aRows);
$oPage->add('</fieldset>');
$oPage->add('</td></tr></table>');
}
示例4: test_zlist
function test_zlist()
{
echo "<h4>Test ZLists</h4>";
$aZLists = MetaModel::EnumZLists();
foreach ($aZLists as $sListCode) {
$aListInfos = MetaModel::GetZListInfo($sListCode);
echo "<h4>List '" . $sListCode . "' (" . $aListInfos["description"] . ") of type '" . $aListInfos["type"] . "'</h5>\n";
foreach (MetaModel::GetSubclasses("cmdbObjectHomeMade") as $sKlass) {
$aItems = MetaModel::FlattenZlist(MetaModel::GetZListItems($sKlass, $sListCode));
if (count($aItems) == 0) {
continue;
}
echo "{$sKlass} - {$sListCode} : {" . implode(", ", $aItems) . "}</br>\n";
}
}
echo "<h4>IsAttributeInZList()... </h4>";
echo "Liens_entre_contacts_et_workshop::ws_info in list1 ? " . (MetaModel::IsAttributeInZList("Liens_entre_contacts_et_workshop", "list1", "ws_info") ? "yes" : "no") . "</br>\n";
echo "Liens_entre_contacts_et_workshop::toworkshop in list1 ? " . (MetaModel::IsAttributeInZList("Liens_entre_contacts_et_workshop", "list1", "toworkshop") ? "yes" : "no") . "</br>\n";
}