diff --git a/application/ajaxwebpage.class.inc.php b/application/ajaxwebpage.class.inc.php index 1ccb602dd..ac732ae86 100644 --- a/application/ajaxwebpage.class.inc.php +++ b/application/ajaxwebpage.class.inc.php @@ -88,6 +88,11 @@ class ajax_page extends WebPage return $sPreviousTab; } + public function GetCurrentTab() + { + return $this->m_sCurrentTab; + } + /** * Echoes the content of the whole page * @return void @@ -230,6 +235,44 @@ EOF } } + /** + * Records the current state of the 'html' part of the page output + * @return mixed The current state of the 'html' output + */ + public function start_capture() + { + if (!empty($this->m_sCurrentTabContainer) && !empty($this->m_sCurrentTab)) + { + $iOffset = isset($this->m_aTabs[$this->m_sCurrentTabContainer][$this->m_sCurrentTab]) ? strlen($this->m_aTabs[$this->m_sCurrentTabContainer][$this->m_sCurrentTab]): 0; + return array('tc' => $this->m_sCurrentTabContainer, 'tab' => $this->m_sCurrentTab, 'offset' => $iOffset); + } + else + { + return parent::start_capture(); + } + } + + /** + * Returns the part of the html output that occurred since the call to start_capture + * and removes this part from the current html output + * @param $offset mixed The value returned by start_capture + * @return string The part of the html output that was added since the call to start_capture + */ + public function end_capture($offset) + { + if (is_array($offset)) + { + if ($this->m_sCurrentTab != $offset['tab']) echo "

le TAB a changé !!! currentTab: ".$this->m_sCurrentTab."

"; + $sCaptured = substr($this->m_aTabs[$offset['tc']]['content'][$offset['tab']], $offset['offset']); + $this->m_aTabs[$offset['tc']]['content'][$offset['tab']] = substr($this->m_aTabs[$offset['tc']]['content'][$offset['tab']], 0, $offset['offset']); + } + else + { + $sCaptured = parent::end_capture($offset); + } + return $sCaptured; + } + /** * Add any text or HTML fragment (identified by an ID) at the end of the body of the page * This is useful to add hidden content, DIVs or FORMs that should not diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php index b62515249..29987825d 100644 --- a/application/itopwebpage.class.inc.php +++ b/application/itopwebpage.class.inc.php @@ -834,6 +834,11 @@ EOF return $sPreviousTab; } + public function GetCurrentTab() + { + return $this->m_sCurrentTab; + } + /** * Make the given tab the active one, as if it were clicked * DOES NOT WORK: apparently in the *old* version of jquery diff --git a/application/template.class.inc.php b/application/template.class.inc.php index b4a32af35..00c9ec51d 100644 --- a/application/template.class.inc.php +++ b/application/template.class.inc.php @@ -35,7 +35,15 @@ class DisplayTemplate public function __construct($sTemplate) { - $this->m_aTags = array('itopblock', 'itopcheck', 'itoptabs', 'itoptab', 'itoptoggle', 'itopstring', 'sqlblock'); + $this->m_aTags = array ( + 'itopblock', + 'itopcheck', + 'itoptabs', + 'itoptab', + 'itoptoggle', + 'itopstring', + 'sqlblock' + ); $this->m_sTemplate = $sTemplate; } @@ -208,7 +216,6 @@ class DisplayTemplate $oBlock->RenderContent($oPage); break; - case 'itopblock': // No longer used, handled by DisplayBlock::FromTemplate see above $oPage->add(""); break; @@ -272,6 +279,7 @@ class ObjectDetailsTemplate extends DisplayTemplate public function Render(WebPage $oPage, $aParams = array(), $bEditMode = false) { + $sStateAttCode = MetaModel :: GetStateAttributeCode(get_class($this->m_oObj)); $aTemplateFields = array(); preg_match_all('/\\$this->([a-z0-9_]+)\\$/', $this->m_sTemplate, $aMatches); $aTemplateFields = $aMatches[1]; @@ -302,6 +310,11 @@ class ObjectDetailsTemplate extends DisplayTemplate $iFlags = $iFlags & ~OPT_ATT_READONLY; // Mandatory fields cannot be read-only when creating an object } + if ((!$oAttDef->IsWritable()) || ($sStateAttCode == $sAttCode)) + { + $iFlags = $iFlags | OPT_ATT_READONLY; + } + if ($iFlags & OPT_ATT_HIDDEN) { $aParams['this->label('.$sAttCode.')'] = ''; @@ -313,7 +326,6 @@ class ObjectDetailsTemplate extends DisplayTemplate { if ($bEditMode && ($iFlags & (OPT_ATT_READONLY|OPT_ATT_SLAVE))) { - // Check if the attribute is not read-only because of a synchro... $aReasons = array(); $sSynchroIcon = ''; @@ -336,7 +348,6 @@ class ObjectDetailsTemplate extends DisplayTemplate $aParams['this->comments('.$sAttCode.')'] = $sSynchroIcon; } - if ($bEditMode && !($iFlags & OPT_ATT_READONLY)) //TODO: check the data synchro status... { $aParams['this->field('.$sAttCode.')'] = "".$this->m_oObj->GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, @@ -388,5 +399,4 @@ class ObjectDetailsTemplate extends DisplayTemplate } //DisplayTemplate::UnitTest(); - ?>