本文整理汇总了PHP中utils::GetSafeId方法的典型用法代码示例。如果您正苦于以下问题:PHP utils::GetSafeId方法的具体用法?PHP utils::GetSafeId怎么用?PHP utils::GetSafeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils::GetSafeId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param $iListId mixed Unique ID for this div/table in the page
* @param $oSet DBObjectSet The set of data to display
* @param $aClassAliases Hash The list of classes/aliases to be displayed in this set $sAlias => $sClassName
* @param $sTableId mixed A string (or null) identifying this table in order to persist its settings
*/
public function __construct($iListId, $oSet, $aClassAliases, $sTableId = null)
{
$this->iListId = utils::GetSafeId($iListId);
// Make a "safe" ID for jQuery
$this->oSet = $oSet;
$this->aClassAliases = $aClassAliases;
$this->sTableId = $sTableId;
$this->iNbObjects = $oSet->Count();
$this->bUseCustomSettings = false;
$this->oDefaultSettings = null;
}
示例2: RenderContent
public function RenderContent(WebPage $oPage, $aExtraParams = array())
{
$oSearch = new DBObjectSearch($this->sClass);
$aParams = array_merge(array('open' => true, 'table_id' => 'Menu_' . utils::GetSafeId($this->GetMenuId())), $aExtraParams);
$oBlock = new DisplayBlock($oSearch, 'search', false, $aParams);
$oBlock->Display($oPage, 0);
}
示例3: GetFormRow
/**
* A one-row form for editing a link record
* @param WebPage $oP Web page used for the ouput
* @param DBObject $oLinkedObj The object to which all the elements of the linked set refer to
* @param mixed $linkObjOrId Either the object linked or a unique number for new link records to add
* @param Hash $aArgs Extra context arguments
* @return string The HTML fragment of the one-row form
*/
protected function GetFormRow(WebPage $oP, DBObject $oLinkedObj, $linkObjOrId = null, $aArgs = array(), $oCurrentObj)
{
$sPrefix = "{$this->m_sAttCode}{$this->m_sNameSuffix}";
$aRow = array();
$aFieldsMap = array();
if (is_object($linkObjOrId) && !$linkObjOrId->IsNew()) {
$key = $linkObjOrId->GetKey();
$iRemoteObjKey = $linkObjOrId->Get($this->m_sExtKeyToRemote);
$sPrefix .= "[{$key}][";
$sNameSuffix = "]";
// To make a tabular form
$aArgs['prefix'] = $sPrefix;
$aArgs['wizHelper'] = "oWizardHelper{$this->m_iInputId}{$key}";
$aArgs['this'] = $linkObjOrId;
$aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onClick=\"oWidget" . $this->m_iInputId . ".OnSelectChange();\" value=\"{$key}\">";
$aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"attr_{$sPrefix}id{$sNameSuffix}\" value=\"{$key}\">";
foreach ($this->m_aEditableFields as $sFieldCode) {
$sFieldId = $this->m_iInputId . '_' . $sFieldCode . '[' . $linkObjOrId->GetKey() . ']';
$sSafeId = utils::GetSafeId($sFieldId);
$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
$aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $linkObjOrId->Get($sFieldCode), '', $sSafeId, $sNameSuffix, 0, $aArgs);
$aFieldsMap[$sFieldCode] = $sSafeId;
}
$sState = $linkObjOrId->GetState();
} else {
// form for creating a new record
if (is_object($linkObjOrId)) {
// New link existing only in memory
$oNewLinkObj = $linkObjOrId;
$iRemoteObjKey = $oNewLinkObj->Get($this->m_sExtKeyToRemote);
$oRemoteObj = MetaModel::GetObject($this->m_sRemoteClass, $iRemoteObjKey);
$oNewLinkObj->Set($this->m_sExtKeyToMe, $oCurrentObj);
// Setting the extkey with the object also fills the related external fields
$linkObjOrId = -$iRemoteObjKey;
} else {
$iRemoteObjKey = -$linkObjOrId;
$oNewLinkObj = MetaModel::NewObject($this->m_sLinkedClass);
$oRemoteObj = MetaModel::GetObject($this->m_sRemoteClass, -$linkObjOrId);
$oNewLinkObj->Set($this->m_sExtKeyToRemote, $oRemoteObj);
// Setting the extkey with the object alsoo fills the related external fields
$oNewLinkObj->Set($this->m_sExtKeyToMe, $oCurrentObj);
// Setting the extkey with the object also fills the related external fields
}
$sPrefix .= "[{$linkObjOrId}][";
$sNameSuffix = "]";
// To make a tabular form
$aArgs['prefix'] = $sPrefix;
$aArgs['wizHelper'] = "oWizardHelper{$this->m_iInputId}_" . -$linkObjOrId;
$aArgs['this'] = $oNewLinkObj;
$aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onClick=\"oWidget" . $this->m_iInputId . ".OnSelectChange();\" value=\"{$linkObjOrId}\">";
$aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"attr_{$sPrefix}id{$sNameSuffix}\" value=\"\">";
foreach ($this->m_aEditableFields as $sFieldCode) {
$sFieldId = $this->m_iInputId . '_' . $sFieldCode . '[' . $linkObjOrId . ']';
$sSafeId = utils::GetSafeId($sFieldId);
$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
$aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $oNewLinkObj->Get($sFieldCode), '', $sSafeId, $sNameSuffix, 0, $aArgs);
$aFieldsMap[$sFieldCode] = $sSafeId;
}
$sState = '';
$oP->add_script(<<<EOF
\$(".date-pick").datepicker({
\t\tshowOn: 'button',
\t\tbuttonImage: '../images/calendar.png',
\t\tbuttonImageOnly: true,
\t\tdateFormat: 'yy-mm-dd',
\t\tconstrainInput: false,
\t\tchangeMonth: true,
\t\tchangeYear: true
\t});
\$(".datetime-pick").datepicker({
\t\tshowOn: 'button',
\t\tbuttonImage: '../images/calendar.png',
\t\tbuttonImageOnly: true,
\t\tdateFormat: 'yy-mm-dd 00:00:00',
\t\tconstrainInput: false,
\t\tchangeMonth: true,
\t\tchangeYear: true
});
EOF
);
}
$sExtKeyToMeId = utils::GetSafeId($sPrefix . $this->m_sExtKeyToMe);
$aFieldsMap[$this->m_sExtKeyToMe] = $sExtKeyToMeId;
$aRow['form::checkbox'] .= "<input type=\"hidden\" id=\"{$sExtKeyToMeId}\" value=\"" . $oCurrentObj->GetKey() . "\">";
$sExtKeyToRemoteId = utils::GetSafeId($sPrefix . $this->m_sExtKeyToRemote);
$aFieldsMap[$this->m_sExtKeyToRemote] = $sExtKeyToRemoteId;
$aRow['form::checkbox'] .= "<input type=\"hidden\" id=\"{$sExtKeyToRemoteId}\" value=\"{$iRemoteObjKey}\">";
$iFieldsCount = count($aFieldsMap);
$sJsonFieldsMap = json_encode($aFieldsMap);
$oP->add_script(<<<EOF
var {$aArgs['wizHelper']} = new WizardHelper('{$this->m_sLinkedClass}', '', '{$sState}');
{$aArgs['wizHelper']}.SetFieldsMap({$sJsonFieldsMap});
//.........这里部分代码省略.........