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>'); }
function GetBareProperties(WebPage $oPage, $bEditMode = false, $sPrefix, $aExtraParams = array()) { $sHtml = ''; $oAppContext = new ApplicationContext(); $sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this)); $aDetails = array(); $sClass = get_class($this); $aDetailsList = MetaModel::GetZListItems($sClass, 'details'); $aDetailsStruct = self::ProcessZlist($aDetailsList, array('UI:PropertiesTab' => array()), 'UI:PropertiesTab', 'col1', ''); // Compute the list of properties to display, first the attributes in the 'details' list, then // all the remaining attributes that are not external fields $sHtml = ''; $aDetails = array(); $iInputId = 0; $aFieldsMap = array(); $aFieldsComments = isset($aExtraParams['fieldsComments']) ? $aExtraParams['fieldsComments'] : array(); $aExtraFlags = isset($aExtraParams['fieldsFlags']) ? $aExtraParams['fieldsFlags'] : array(); $bFieldComments = count($aFieldsComments) > 0; foreach ($aDetailsStruct as $sTab => $aCols) { $aDetails[$sTab] = array(); ksort($aCols); $oPage->SetCurrentTab(Dict::S($sTab)); $oPage->add('<table style="vertical-align:top"><tr>'); foreach ($aCols as $sColIndex => $aFieldsets) { $oPage->add('<td style="vertical-align:top">'); //$aDetails[$sTab][$sColIndex] = array(); $sLabel = ''; $sPreviousLabel = ''; $aDetails[$sTab][$sColIndex] = array(); foreach ($aFieldsets as $sFieldsetName => $aFields) { if (!empty($sFieldsetName) && $sFieldsetName[0] != '_') { $sLabel = $sFieldsetName; } else { $sLabel = ''; } if ($sLabel != $sPreviousLabel) { if (!empty($sPreviousLabel)) { $oPage->add('<fieldset>'); $oPage->add('<legend>' . Dict::S($sPreviousLabel) . '</legend>'); } $oPage->Details($aDetails[$sTab][$sColIndex]); if (!empty($sPreviousLabel)) { $oPage->add('</fieldset>'); } $aDetails[$sTab][$sColIndex] = array(); $sPreviousLabel = $sLabel; } foreach ($aFields as $sAttCode) { if ($bEditMode) { $sComments = isset($aFieldsComments[$sAttCode]) ? $aFieldsComments[$sAttCode] : ' '; $sInfos = ' '; $iFlags = $this->GetFormAttributeFlags($sAttCode); if (array_key_exists($sAttCode, $aExtraFlags)) { // the caller may override some flags if needed $iFlags = $iFlags | $aExtraFlags[$sAttCode]; } $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); if (!$oAttDef->IsLinkSet() && ($iFlags & OPT_ATT_HIDDEN) == 0) { $sInputId = $this->m_iFormId . '_' . $sAttCode; if ($oAttDef->IsWritable()) { if ($sStateAttCode == $sAttCode) { // State attribute is always read-only from the UI $sHTMLValue = $this->GetStateLabel(); $val = array('label' => '<span>' . $oAttDef->GetLabel() . '</span>', 'value' => $sHTMLValue, 'comments' => $sComments, 'infos' => $sInfos); } else { if ($iFlags & OPT_ATT_HIDDEN) { // Attribute is hidden, add a hidden input $oPage->add('<input type="hidden" id="' . $sInputId . '" name="attr_' . $sPrefix . $sAttCode . '" value="' . htmlentities($this->Get($sAttCode), ENT_QUOTES, 'UTF-8') . '"/>'); $aFieldsMap[$sAttCode] = $sInputId; } else { if ($iFlags & (OPT_ATT_READONLY | OPT_ATT_SLAVE)) { // Check if the attribute is not read-only because of a synchro... $aReasons = array(); $sSynchroIcon = ''; if ($iFlags & OPT_ATT_SLAVE) { $iSynchroFlags = $this->GetSynchroReplicaFlags($sAttCode, $aReasons); $sSynchroIcon = " <img id=\"synchro_{$sInputId}\" src=\"../images/transp-lock.png\" style=\"vertical-align:middle\"/>"; $sTip = ''; foreach ($aReasons as $aRow) { $sTip .= "<p>Synchronized with {$aRow['name']} - {$aRow['description']}</p>"; } $sTip = addslashes($sTip); $oPage->add_ready_script("\$('#synchro_{$sInputId}').qtip( { content: '{$sTip}', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );"); } // Attribute is read-only $sHTMLValue = "<span id=\"field_{$sInputId}\">" . $this->GetAsHTML($sAttCode); $sHTMLValue .= '<input type="hidden" id="' . $sInputId . '" name="attr_' . $sPrefix . $sAttCode . '" value="' . htmlentities($this->Get($sAttCode), ENT_QUOTES, 'UTF-8') . '"/></span>'; $aFieldsMap[$sAttCode] = $sInputId; $sComments = $sSynchroIcon; } else { $sValue = $this->Get($sAttCode); $sDisplayValue = $this->GetEditValue($sAttCode); $aArgs = array('this' => $this, 'formPrefix' => $sPrefix); $sHTMLValue = "<span id=\"field_{$sInputId}\">" . self::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $sValue, $sDisplayValue, $sInputId, '', $iFlags, $aArgs) . '</span>'; $aFieldsMap[$sAttCode] = $sInputId; } $val = array('label' => '<span title="' . $oAttDef->GetDescription() . '">' . $oAttDef->GetLabel() . '</span>', 'value' => $sHTMLValue, 'comments' => $sComments, 'infos' => $sInfos); } } } else { $val = array('label' => '<span title="' . $oAttDef->GetDescription() . '">' . $oAttDef->GetLabel() . '</span>', 'value' => "<span id=\"field_{$sInputId}\">" . $this->GetAsHTML($sAttCode) . "</span>", 'comments' => $sComments, 'infos' => $sInfos); $aFieldsMap[$sAttCode] = $sInputId; } } else { $val = null; // Skip this field } } else { // !bEditMode $val = $this->GetFieldAsHtml($sClass, $sAttCode, $sStateAttCode); } if ($val != null) { // The field is visible, add it to the current column $aDetails[$sTab][$sColIndex][] = $val; $iInputId++; } } } if (!empty($sPreviousLabel)) { $oPage->add('<fieldset>'); $oPage->add('<legend>' . Dict::S($sFieldsetName) . '</legend>'); } $oPage->Details($aDetails[$sTab][$sColIndex]); if (!empty($sPreviousLabel)) { $oPage->add('</fieldset>'); } $oPage->add('</td>'); } $oPage->add('</tr></table>'); } return $aFieldsMap; }
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(); }