当前位置: 首页>>代码示例>>PHP>>正文


PHP DBObjectSearch::SetModifierProperty方法代码示例

本文整理汇总了PHP中DBObjectSearch::SetModifierProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObjectSearch::SetModifierProperty方法的具体用法?PHP DBObjectSearch::SetModifierProperty怎么用?PHP DBObjectSearch::SetModifierProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBObjectSearch的用法示例。


在下文中一共展示了DBObjectSearch::SetModifierProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetSearchForm

 public static function GetSearchForm(WebPage $oPage, CMDBObjectSet $oSet, $aExtraParams = array())
 {
     static $iSearchFormId = 0;
     $bMultiSelect = false;
     $oAppContext = new ApplicationContext();
     $sHtml = '';
     $numCols = 4;
     $sClassName = $oSet->GetFilter()->GetClass();
     // Romain: temporarily removed the tab "OQL query" because it was not finalized
     // (especially when used to add a link)
     /*
     $sHtml .= "<div class=\"mini_tabs\" id=\"mini_tabs{$iSearchFormId}\"><ul>
     			<li><a href=\"#\" onClick=\"$('div.mini_tab{$iSearchFormId}').toggle();$('#mini_tabs{$iSearchFormId} ul li a').toggleClass('selected');\">".Dict::S('UI:OQLQueryTab')."</a></li>
     			<li><a class=\"selected\" href=\"#\" onClick=\"$('div.mini_tab{$iSearchFormId}').toggle();$('#mini_tabs{$iSearchFormId} ul li a').toggleClass('selected');\">".Dict::S('UI:SimpleSearchTab')."</a></li>
     			</ul></div>\n";
     */
     // Simple search form
     if (isset($aExtraParams['currentId'])) {
         $sSearchFormId = $aExtraParams['currentId'];
     } else {
         $iSearchFormId = $oPage->GetUniqueId();
         $sSearchFormId = 'SimpleSearchForm' . $iSearchFormId;
         $sHtml .= "<div id=\"ds_{$sSearchFormId}\" class=\"mini_tab{$iSearchFormId}\">\n";
     }
     // Check if the current class has some sub-classes
     if (isset($aExtraParams['baseClass'])) {
         $sRootClass = $aExtraParams['baseClass'];
     } else {
         $sRootClass = $sClassName;
     }
     $aSubClasses = MetaModel::GetSubclasses($sRootClass);
     if (count($aSubClasses) > 0) {
         $aOptions = array();
         $aOptions[MetaModel::GetName($sRootClass)] = "<option value=\"{$sRootClass}\">" . MetaModel::GetName($sRootClass) . "</options>\n";
         foreach ($aSubClasses as $sSubclassName) {
             $aOptions[MetaModel::GetName($sSubclassName)] = "<option value=\"{$sSubclassName}\">" . MetaModel::GetName($sSubclassName) . "</options>\n";
         }
         $aOptions[MetaModel::GetName($sClassName)] = "<option selected value=\"{$sClassName}\">" . MetaModel::GetName($sClassName) . "</options>\n";
         ksort($aOptions);
         $sContext = $oAppContext->GetForLink();
         $sClassesCombo = "<select name=\"class\" onChange=\"ReloadSearchForm('{$sSearchFormId}', this.value, '{$sRootClass}', '{$sContext}')\">\n" . implode('', $aOptions) . "</select>\n";
     } else {
         $sClassesCombo = MetaModel::GetName($sClassName);
     }
     $oUnlimitedFilter = new DBObjectSearch($sClassName);
     $sAction = isset($aExtraParams['action']) ? $aExtraParams['action'] : utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php';
     $sHtml .= "<form id=\"fs_{$sSearchFormId}\" action=\"{$sAction}\">\n";
     // Don't use $_SERVER['SCRIPT_NAME'] since the form may be called asynchronously (from ajax.php)
     $sHtml .= "<h2>" . Dict::Format('UI:SearchFor_Class_Objects', $sClassesCombo) . "</h2>\n";
     $index = 0;
     $sHtml .= "<p>\n";
     $aMapCriteria = array();
     $aList = MetaModel::GetZListItems($sClassName, 'standard_search');
     $aConsts = $oSet->ListConstantFields();
     // Some fields are constants based on the query/context
     $sClassAlias = $oSet->GetFilter()->GetClassAlias();
     foreach ($aList as $sFilterCode) {
         //$oAppContext->Reset($sFilterCode); // Make sure the same parameter will not be passed twice
         $sHtml .= '<span style="white-space: nowrap;padding:5px;display:inline-block;">';
         $sFilterValue = isset($aConsts[$sClassAlias][$sFilterCode]) ? $aConsts[$sClassAlias][$sFilterCode] : '';
         $sFilterValue = utils::ReadParam($sFilterCode, $sFilterValue, false, 'raw_data');
         $sFilterOpCode = null;
         // Use the default 'loose' OpCode
         if (empty($sFilterValue)) {
             if (isset($aMapCriteria[$sFilterCode])) {
                 if (count($aMapCriteria[$sFilterCode]) > 1) {
                     $sFilterValue = Dict::S('UI:SearchValue:Mixed');
                 } else {
                     $sFilterValue = $aMapCriteria[$sFilterCode][0]['value'];
                     $sFilterOpCode = $aMapCriteria[$sFilterCode][0]['opcode'];
                 }
                 // Todo: Investigate...
                 if ($sFilterCode != 'company') {
                     $oUnlimitedFilter->AddCondition($sFilterCode, $sFilterValue, $sFilterOpCode);
                 }
             }
         }
         $oAttDef = MetaModel::GetAttributeDef($sClassName, $sFilterCode);
         if ($oAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) {
             $oKeyAttDef = $oAttDef->GetFinalAttDef();
             $sKeyAttClass = $oKeyAttDef->GetHostClass();
             $sKeyAttCode = $oKeyAttDef->GetCode();
             $sTargetClass = $oKeyAttDef->GetTargetClass();
             $oSearch = new DBObjectSearch($sTargetClass);
             $oSearch->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true);
             $oAllowedValues = new DBObjectSet($oSearch);
             $iFieldSize = $oKeyAttDef->GetMaxSize();
             $iMaxComboLength = $oKeyAttDef->GetMaximumComboLength();
             $sHtml .= "<label>" . MetaModel::GetFilterLabel($sKeyAttClass, $sKeyAttCode) . ":</label>&nbsp;";
             $aExtKeyParams = $aExtraParams;
             $aExtKeyParams['iFieldSize'] = $oKeyAttDef->GetMaxSize();
             $aExtKeyParams['iMinChars'] = $oKeyAttDef->GetMinAutoCompleteChars();
             $sHtml .= UIExtKeyWidget::DisplayFromAttCode($oPage, $sKeyAttCode, $sKeyAttClass, $oAttDef->GetLabel(), $oAllowedValues, $sFilterValue, $sSearchFormId . 'search_' . $sFilterCode, false, $sFilterCode, '', $aExtKeyParams, true);
         } else {
             $aAllowedValues = MetaModel::GetAllowedValues_flt($sClassName, $sFilterCode, $aExtraParams);
             if (is_null($aAllowedValues)) {
                 // Any value is possible, display an input box
                 $sHtml .= "<label>" . MetaModel::GetFilterLabel($sClassName, $sFilterCode) . ":</label>&nbsp;<input class=\"textSearch\" name=\"{$sFilterCode}\" value=\"" . htmlentities($sFilterValue, ENT_QUOTES, 'utf-8') . "\"/>\n";
             } else {
                 //Enum field, display a multi-select combo
//.........这里部分代码省略.........
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:101,代码来源:cmdbabstract.class.inc.php

示例2: GetSiloSelectionForm

 public function GetSiloSelectionForm()
 {
     // List of visible Organizations
     $iCount = 0;
     $oSet = null;
     if (MetaModel::IsValidClass('Organization')) {
         // Display the list of *favorite* organizations... but keeping in mind what is the real number of organizations
         $aFavoriteOrgs = appUserPreferences::GetPref('favorite_orgs', null);
         $oSearchFilter = new DBObjectSearch('Organization');
         $oSearchFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true);
         $oSet = new CMDBObjectSet($oSearchFilter);
         $iCount = $oSet->Count();
         // total number of existing Orgs
         // Now get the list of Orgs to be displayed in the menu
         $oSearchFilter = DBObjectSearch::FromOQL(ApplicationMenu::GetFavoriteSiloQuery());
         $oSearchFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true);
         if (!empty($aFavoriteOrgs)) {
             $oSearchFilter->AddCondition('id', $aFavoriteOrgs, 'IN');
         }
         $oSet = new CMDBObjectSet($oSearchFilter);
         // List of favorite orgs
     }
     switch ($iCount) {
         case 0:
             // No such dimension/silo => nothing to select
             $sHtml = '<div id="SiloSelection"><!-- nothing to select --></div>';
             break;
         case 1:
             // Only one possible choice... no selection, but display the value
             $oOrg = $oSet->Fetch();
             $sHtml = '<div id="SiloSelection">' . $oOrg->GetName() . '</div>';
             $sHtml .= '';
             break;
         default:
             $sHtml = '';
             $oAppContext = new ApplicationContext();
             $iCurrentOrganization = $oAppContext->GetCurrentValue('org_id');
             $sHtml = '<div id="SiloSelection">';
             $sHtml .= '<form style="display:inline" action="' . utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php">';
             //<select class="org_combo" name="c[org_id]" title="Pick an organization" onChange="this.form.submit();">';
             $sFavoriteOrgs = '';
             $oWidget = new UIExtKeyWidget('Organization', 'org_id', '', true);
             $sHtml .= $oWidget->Display($this, 50, false, '', $oSet, $iCurrentOrganization, 'org_id', false, 'c[org_id]', '', array('iFieldSize' => 20, 'iMinChars' => MetaModel::GetConfig()->Get('min_autocomplete_chars'), 'sDefaultValue' => Dict::S('UI:AllOrganizations')), null, 'select', false);
             $this->add_ready_script('$("#org_id").bind("extkeychange", function() { $("#SiloSelection form").submit(); } )');
             $this->add_ready_script("\$('#label_org_id').click( function() { \$(this).val(''); \$('#org_id').val(''); return true; } );\n");
             // Add other dimensions/context information to this form
             $oAppContext->Reset('org_id');
             // org_id is handled above and we want to be able to change it here !
             $oAppContext->Reset('menu');
             // don't pass the menu, since a menu may expect more parameters
             $sHtml .= $oAppContext->GetForForm();
             // Pass what remains, if anything...
             $sHtml .= '</form>';
             $sHtml .= '</div>';
     }
     return $sHtml;
 }
开发者ID:henryavila,项目名称:itop,代码行数:57,代码来源:itopwebpage.class.inc.php

示例3: MakeSingleRow

 public static function MakeSingleRow($sClass, $iKey, $bMustBeFound = true, $bAllowAllData = false, $aModifierProperties = null)
 {
     // Build the query cache signature
     //
     $sQuerySign = $sClass;
     if ($bAllowAllData) {
         $sQuerySign .= '_all_';
     }
     if (count($aModifierProperties)) {
         array_multisort($aModifierProperties);
         $sModifierProperties = json_encode($aModifierProperties);
         $sQuerySign .= '_all_' . md5($sModifierProperties);
     }
     if (!array_key_exists($sQuerySign, self::$aQueryCacheGetObject)) {
         // NOTE: Quick and VERY dirty caching mechanism which relies on
         //       the fact that the string '987654321' will never appear in the
         //       standard query
         //       This could be simplified a little, relying solely on the query cache,
         //       but this would slow down -by how much time?- the application
         $oFilter = new DBObjectSearch($sClass);
         $oFilter->AddCondition('id', 987654321, '=');
         if ($aModifierProperties) {
             foreach ($aModifierProperties as $sPluginClass => $aProperties) {
                 foreach ($aProperties as $sProperty => $value) {
                     $oFilter->SetModifierProperty($sPluginClass, $sProperty, $value);
                 }
             }
         }
         if ($bAllowAllData) {
             $oFilter->AllowAllData();
         }
         $sSQL = $oFilter->MakeSelectQuery();
         self::$aQueryCacheGetObject[$sQuerySign] = $sSQL;
         self::$aQueryCacheGetObjectHits[$sQuerySign] = 0;
     } else {
         $sSQL = self::$aQueryCacheGetObject[$sQuerySign];
         self::$aQueryCacheGetObjectHits[$sQuerySign] += 1;
         //			echo " -load $sClass/$iKey- ".self::$aQueryCacheGetObjectHits[$sQuerySign]."<br/>\n";
     }
     $sSQL = str_replace(CMDBSource::Quote(987654321), CMDBSource::Quote($iKey), $sSQL);
     $res = CMDBSource::Query($sSQL);
     $aRow = CMDBSource::FetchArray($res);
     CMDBSource::FreeResult($res);
     if ($bMustBeFound && empty($aRow)) {
         throw new CoreException("No result for the single row query: '{$sSQL}'");
     }
     return $aRow;
 }
开发者ID:henryavila,项目名称:itop,代码行数:48,代码来源:metamodel.class.php

示例4: GetSearchDialog

    public function GetSearchDialog(WebPage $oPage, $sTitle, $oCurrObject = null)
    {
        $sHTML = '<div class="wizContainer" style="vertical-align:top;"><div id="dc_' . $this->iId . '">';
        if ($oCurrObject != null && $this->sAttCode != '') {
            $oAttDef = MetaModel::GetAttributeDef(get_class($oCurrObject), $this->sAttCode);
            $aArgs = array('this' => $oCurrObject);
            $aParams = array('query_params' => $aArgs);
            $oSet = $oAttDef->GetAllowedValuesAsObjectSet($aArgs);
            $oFilter = $oSet->GetFilter();
        } else {
            $aParams = array();
            $oFilter = new DBObjectSearch($this->sTargetClass);
        }
        $oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
        $oBlock = new DisplayBlock($oFilter, 'search', false, $aParams);
        $sHTML .= $oBlock->GetDisplay($oPage, $this->iId, array('open' => true, 'currentId' => $this->iId));
        $sHTML .= "<form id=\"fr_{$this->iId}\" OnSubmit=\"return oACWidget_{$this->iId}.DoOk();\">\n";
        $sHTML .= "<div id=\"dr_{$this->iId}\" style=\"vertical-align:top;background: #fff;height:100%;overflow:auto;padding:0;border:0;\">\n";
        $sHTML .= "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>" . Dict::S('UI:Message:EmptyList:UseSearchForm') . "</p></div>\n";
        $sHTML .= "</div>\n";
        $sHTML .= "<input type=\"button\" id=\"btn_cancel_{$this->iId}\" value=\"" . Dict::S('UI:Button:Cancel') . "\" onClick=\"\$('#ac_dlg_{$this->iId}').dialog('close');\">&nbsp;&nbsp;";
        $sHTML .= "<input type=\"button\" id=\"btn_ok_{$this->iId}\" value=\"" . Dict::S('UI:Button:Ok') . "\"  onClick=\"oACWidget_{$this->iId}.DoOk();\">";
        $sHTML .= "<input type=\"hidden\" id=\"count_{$this->iId}\" value=\"0\">";
        $sHTML .= "</form>\n";
        $sHTML .= '</div></div>';
        $sDialogTitle = addslashes($sTitle);
        $oPage->add_ready_script(<<<EOF
\t\t\$('#ac_dlg_{$this->iId}').dialog({ width: \$(window).width()*0.8, height: \$(window).height()*0.8, autoOpen: false, modal: true, title: '{$sDialogTitle}', resizeStop: oACWidget_{$this->iId}.UpdateSizes, close: oACWidget_{$this->iId}.OnClose });
\t\t\$('#fs_{$this->iId}').bind('submit.uiAutocomplete', oACWidget_{$this->iId}.DoSearchObjects);
\t\t\$('#dc_{$this->iId}').resize(oACWidget_{$this->iId}.UpdateSizes);
EOF
);
        $oPage->add($sHTML);
    }
开发者ID:henryavila,项目名称:itop,代码行数:34,代码来源:ui.extkeywidget.class.inc.php

示例5: ReadContext

 /**
  * Read the context directly in the PHP parameters (either POST or GET)
  * return nothing
  */
 protected function ReadContext()
 {
     if (!isset(self::$aDefaultValues)) {
         self::$aDefaultValues = array();
         $aContext = utils::ReadParam('c', array(), false, 'context_param');
         foreach ($this->aNames as $sName) {
             $sValue = isset($aContext[$sName]) ? $aContext[$sName] : '';
             // TO DO: check if some of the context parameters are mandatory (or have default values)
             if (!empty($sValue)) {
                 self::$aDefaultValues[$sName] = $sValue;
             }
             // Hmm, there must be a better (more generic) way to handle the case below:
             // When there is only one possible (allowed) organization, the context must be
             // fixed to this org
             if ($sName == 'org_id') {
                 if (MetaModel::IsValidClass('Organization')) {
                     $oSearchFilter = new DBObjectSearch('Organization');
                     $oSearchFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true);
                     $oSet = new CMDBObjectSet($oSearchFilter);
                     $iCount = $oSet->Count();
                     if ($iCount == 1) {
                         // Only one possible value for org_id, set it in the context
                         $oOrg = $oSet->Fetch();
                         self::$aDefaultValues[$sName] = $oOrg->GetKey();
                     }
                 }
             }
         }
     }
     $this->aValues = self::$aDefaultValues;
 }
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:35,代码来源:applicationcontext.class.inc.php


注:本文中的DBObjectSearch::SetModifierProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。