Ejemplo n.º 1
0
 public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId)
 {
     $sHtml = '';
     $bTruncated = false;
     $oSet = new CMDBObjectSet($this->m_oFilter, array('date' => false));
     if ($this->iLimitStart > 0 || $this->iLimitCount > 0) {
         $oSet->SetLimit($this->iLimitCount, $this->iLimitStart);
         if ($this->iLimitCount - $this->iLimitStart < $oSet->Count()) {
             $bTruncated = true;
         }
     }
     $sHtml .= "<!-- filter: " . $this->m_oFilter->ToOQL() . "-->\n";
     switch ($this->m_sStyle) {
         case 'toggle':
             // First the latest change that the user is allowed to see
             do {
                 $oLatestChangeOp = $oSet->Fetch();
             } while (is_object($oLatestChangeOp) && $oLatestChangeOp->GetDescription() == '');
             if (is_object($oLatestChangeOp)) {
                 // There is one change in the list... only when the object has been created !
                 $sDate = $oLatestChangeOp->GetAsHTML('date');
                 $oChange = MetaModel::GetObject('CMDBChange', $oLatestChangeOp->Get('change'));
                 $sUserInfo = $oChange->GetAsHTML('userinfo');
                 $sHtml .= $oPage->GetStartCollapsibleSection(Dict::Format('UI:History:LastModified_On_By', $sDate, $sUserInfo));
                 $sHtml .= $this->GetHistoryTable($oPage, $oSet);
                 $sHtml .= $oPage->GetEndCollapsibleSection();
             }
             break;
         case 'table':
         default:
             if ($bTruncated) {
                 $sFilter = $this->m_oFilter->serialize();
                 $sHtml .= '<div id="history_container"><p>';
                 $sHtml .= Dict::Format('UI:TruncatedResults', $this->iLimitCount, $oSet->Count());
                 $sHtml .= ' ';
                 $sHtml .= '<a href="#" onclick="DisplayHistory(\'#history_container\', \'' . $sFilter . '\', 0, 0); return false;">' . Dict::S('UI:DisplayAll') . '</a>';
                 $sHtml .= $this->GetHistoryTable($oPage, $oSet);
                 $sHtml .= '</p></div>';
                 $oPage->add_ready_script("\$('#{$sId} table.listResults tr:last td').addClass('truncated');");
             } else {
                 $sHtml .= $this->GetHistoryTable($oPage, $oSet);
             }
     }
     return $sHtml;
 }