當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DBObjectSet::GetFilter方法代碼示例

本文整理匯總了PHP中DBObjectSet::GetFilter方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBObjectSet::GetFilter方法的具體用法?PHP DBObjectSet::GetFilter怎麽用?PHP DBObjectSet::GetFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DBObjectSet的用法示例。


在下文中一共展示了DBObjectSet::GetFilter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: GetSetAsHTMLSpreadsheet

 /**
  * Spreadsheet output: designed for end users doing some reporting
  * Then the ids are excluded and replaced by the corresponding friendlyname
  */
 static function GetSetAsHTMLSpreadsheet(DBObjectSet $oSet, $aParams = array())
 {
     $aFields = null;
     if (isset($aParams['fields']) && strlen($aParams['fields']) > 0) {
         $aFields = explode(',', $aParams['fields']);
     }
     $bFieldsAdvanced = false;
     if (isset($aParams['fields_advanced'])) {
         $bFieldsAdvanced = (bool) $aParams['fields_advanced'];
     }
     $bLocalize = true;
     if (isset($aParams['localize_values'])) {
         $bLocalize = (bool) $aParams['localize_values'];
     }
     $aList = array();
     $oAppContext = new ApplicationContext();
     $aClasses = $oSet->GetFilter()->GetSelectedClasses();
     $aAuthorizedClasses = array();
     foreach ($aClasses as $sAlias => $sClassName) {
         if (UserRights::IsActionAllowed($sClassName, UR_ACTION_READ, $oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) {
             $aAuthorizedClasses[$sAlias] = $sClassName;
         }
     }
     $aAttribs = array();
     $aHeader = array();
     foreach ($aAuthorizedClasses as $sAlias => $sClassName) {
         $aList[$sAlias] = array();
         foreach (MetaModel::ListAttributeDefs($sClassName) as $sAttCode => $oAttDef) {
             if (is_null($aFields) || count($aFields) == 0) {
                 // Standard list of attributes (no link sets)
                 if ($oAttDef->IsScalar() && ($oAttDef->IsWritable() || $oAttDef->IsExternalField())) {
                     $sAttCodeEx = $oAttDef->IsExternalField() ? $oAttDef->GetKeyAttCode() . '->' . $oAttDef->GetExtAttCode() : $sAttCode;
                     $aList[$sAlias][$sAttCodeEx] = $oAttDef;
                     if ($bFieldsAdvanced && $oAttDef->IsExternalKey(EXTKEY_RELATIVE)) {
                         $sRemoteClass = $oAttDef->GetTargetClass();
                         foreach (MetaModel::GetReconcKeys($sRemoteClass) as $sRemoteAttCode) {
                             $aList[$sAlias][$sAttCode . '->' . $sRemoteAttCode] = MetaModel::GetAttributeDef($sRemoteClass, $sRemoteAttCode);
                         }
                     }
                 }
             } else {
                 // User defined list of attributes
                 if (in_array($sAttCode, $aFields) || in_array($sAlias . '.' . $sAttCode, $aFields)) {
                     $aList[$sAlias][$sAttCode] = $oAttDef;
                 }
             }
         }
         // Replace external key by the corresponding friendly name (if not already in the list)
         foreach ($aList[$sAlias] as $sAttCode => $oAttDef) {
             if ($oAttDef->IsExternalKey()) {
                 unset($aList[$sAlias][$sAttCode]);
                 $sFriendlyNameAttCode = $sAttCode . '_friendlyname';
                 if (!array_key_exists($sFriendlyNameAttCode, $aList[$sAlias]) && MetaModel::IsValidAttCode($sClassName, $sFriendlyNameAttCode)) {
                     $oFriendlyNameAtt = MetaModel::GetAttributeDef($sClassName, $sFriendlyNameAttCode);
                     $aList[$sAlias][$sFriendlyNameAttCode] = $oFriendlyNameAtt;
                 }
             }
         }
         foreach ($aList[$sAlias] as $sAttCodeEx => $oAttDef) {
             $sColLabel = $bLocalize ? MetaModel::GetLabel($sClassName, $sAttCodeEx) : $sAttCodeEx;
             $oFinalAttDef = $oAttDef->GetFinalAttDef();
             if (get_class($oFinalAttDef) == 'AttributeDateTime') {
                 $aHeader[] = $sColLabel . ' (' . Dict::S('UI:SplitDateTime-Date') . ')';
                 $aHeader[] = $sColLabel . ' (' . Dict::S('UI:SplitDateTime-Time') . ')';
             } else {
                 $aHeader[] = $sColLabel;
             }
         }
     }
     $sHtml = "<table border=\"1\">\n";
     $sHtml .= "<tr>\n";
     $sHtml .= "<td>" . implode("</td><td>", $aHeader) . "</td>\n";
     $sHtml .= "</tr>\n";
     $oSet->Seek(0);
     while ($aObjects = $oSet->FetchAssoc()) {
         $aRow = array();
         foreach ($aAuthorizedClasses as $sAlias => $sClassName) {
             $oObj = $aObjects[$sAlias];
             foreach ($aList[$sAlias] as $sAttCodeEx => $oAttDef) {
                 if (is_null($oObj)) {
                     $aRow[] = '<td></td>';
                 } else {
                     $oFinalAttDef = $oAttDef->GetFinalAttDef();
                     if (get_class($oFinalAttDef) == 'AttributeDateTime') {
                         $sDate = $oObj->Get($sAttCodeEx);
                         if ($sDate === null) {
                             $aRow[] = '<td></td>';
                             $aRow[] = '<td></td>';
                         } else {
                             $iDate = AttributeDateTime::GetAsUnixSeconds($sDate);
                             $aRow[] = '<td>' . date('Y-m-d', $iDate) . '</td>';
                             $aRow[] = '<td>' . date('H:i:s', $iDate) . '</td>';
                         }
                     } else {
                         if ($oAttDef instanceof AttributeCaseLog) {
                             $rawValue = $oObj->Get($sAttCodeEx);
//.........這裏部分代碼省略.........
開發者ID:besmirzanaj,項目名稱:itop-code,代碼行數:101,代碼來源:cmdbabstract.class.inc.php


注:本文中的DBObjectSet::GetFilter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。