浏览代码

Re-added the "toggle" style for history blocks. The style by default remains the plain "table" (inside a dedicated tab).

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@615 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 年之前
父节点
当前提交
047de98abc
共有 2 个文件被更改,包括 45 次插入36 次删除
  1. 1 1
      application/cmdbabstract.class.inc.php
  2. 44 35
      application/displayblock.class.inc.php

+ 1 - 1
application/cmdbabstract.class.inc.php

@@ -126,7 +126,7 @@ abstract class cmdbAbstractObject extends CMDBObject
 		$oHistoryFilter = new DBObjectSearch('CMDBChangeOp');
 		$oHistoryFilter->AddCondition('objkey', $this->GetKey());
 		$oHistoryFilter->AddCondition('objclass', get_class($this));
-		$oBlock = new HistoryBlock($oHistoryFilter, 'tab', false);
+		$oBlock = new HistoryBlock($oHistoryFilter, 'table', false);
 		$oBlock->Display($oPage, -1);
 	}
 

+ 44 - 35
application/displayblock.class.inc.php

@@ -718,7 +718,7 @@ class HistoryBlock extends DisplayBlock
 		$sHtml .= "<!-- filter: ".($this->m_oFilter->ToOQL())."-->\n";
 		switch($this->m_sStyle)
 		{
-			default:
+			case 'toggle':
 			// First the latest change that the user is allowed to see
 			do
 			{
@@ -728,48 +728,57 @@ class HistoryBlock extends DisplayBlock
 			
 			if (is_object($oLatestChangeOp))
 			{
-				global $oContext; // User Context.. should be statis instead of global...
+				$oContext = new UserContext();
 				// There is one change in the list... only when the object has been created !
 				$sDate = $oLatestChangeOp->GetAsHTML('date');
 				$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(Dict::Format('UI:History:LastModified_On_By', $sDate, $sUserInfo));
-				//$sHtml .= cmdbAbstractObject::GetDisplaySet($oPage, $oSet);
-				$aChanges = array();
-				while($oChangeOp = $oSet->Fetch())
-				{
-					$sChangeDescription = $oChangeOp->GetDescription();
-					if ($sChangeDescription != '')
-					{
-						// The change is visible for the current user
-						$changeId = $oChangeOp->Get('change');
-						$aChanges[$changeId]['date'] = $oChangeOp->Get('date');
-						$aChanges[$changeId]['userinfo'] = $oChangeOp->Get('userinfo');
-						if (!isset($aChanges[$changeId]['log']))
-						{
-							$aChanges[$changeId]['log'] = array();
-						}
-						$aChanges[$changeId]['log'][] = $sChangeDescription;
-					}
-				}
-				$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)
+				$sHtml .= $oPage->GetStartCollapsibleSection(Dict::Format('UI:History:LastModified_On_By', $sDate, $sUserInfo));
+				$sHtml .= $this->GetHistoryTable($oPage, $oSet);		
+				$sHtml .= $oPage->GetEndCollapsibleSection();
+			}
+			break;
+
+			case 'table':
+			default:
+			$sHtml .= $this->GetHistoryTable($oPage, $oSet);		
+
+		}
+		return $sHtml;
+	}
+	
+	protected function GetHistoryTable(WebPage $oPage, DBObjectSet $oSet)
+	{
+		$sHtml = '';
+		// First the latest change that the user is allowed to see
+		$oSet->Rewind(); // Reset the pointer to the beginning of the set
+		$aChanges = array();
+		while($oChangeOp = $oSet->Fetch())
+		{
+			$sChangeDescription = $oChangeOp->GetDescription();
+			if ($sChangeDescription != '')
+			{
+				// The change is visible for the current user
+				$changeId = $oChangeOp->Get('change');
+				$aChanges[$changeId]['date'] = $oChangeOp->Get('date');
+				$aChanges[$changeId]['userinfo'] = $oChangeOp->Get('userinfo');
+				if (!isset($aChanges[$changeId]['log']))
 				{
-					$aValues[] = array('date' => $aChange['date'], 'userinfo' => $aChange['userinfo'], 'log' => "<ul><li>".implode('</li><li>', $aChange['log'])."</li></ul>");
+					$aChanges[$changeId]['log'] = array();
 				}
-				$sHtml .= $oPage->GetTable($aAttribs, $aValues);		
-				//$sHtml .= $oPage->GetEndCollapsibleSection();
+				$aChanges[$changeId]['log'][] = $sChangeDescription;
 			}
-			break;
-						
-			///default:
-			//$sHtml .= parent::GetRenderContent($oPage, $aExtraParams);
 		}
+		$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)
+		{
+			$aValues[] = array('date' => $aChange['date'], 'userinfo' => $aChange['userinfo'], 'log' => "<ul><li>".implode('</li><li>', $aChange['log'])."</li></ul>");
+		}
+		$sHtml .= $oPage->GetTable($aAttribs, $aValues);
 		return $sHtml;
 	}
 }