本文整理汇总了PHP中SS_HTTPRequest::getHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPRequest::getHeaders方法的具体用法?PHP SS_HTTPRequest::getHeaders怎么用?PHP SS_HTTPRequest::getHeaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_HTTPRequest
的用法示例。
在下文中一共展示了SS_HTTPRequest::getHeaders方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFakeRequest
/**
* Generates a fake request for the field
* @param {SS_HTTPRequest} $request Source Request to base the fake request off of
* @param {Widget} $sourceWidget Source widget
* @param {string} $baseLink Base URL to be truncated off of the form
* @return {SS_HTTPRequest} Fake HTTP Request used to fool the form field into thinking the request was made to it directly
*/
protected function getFakeRequest(SS_HTTPRequest $request, Widget $sourceWidget, $baseLink)
{
$fieldName = rawurldecode($request->param('FieldName'));
$objID = preg_replace('/Widget\\[(.*?)\\]\\[(.*?)\\]\\[(.*?)\\]$/', '$2', $fieldName);
$finalPostVars = array();
if ($request->isPOST()) {
$postVars = $request->postVars();
//Pull the post data for the widget
if (isset($postVars['Widget'][$this->getName()][$objID])) {
$finalPostVars = $postVars['Widget'][$this->getName()][$objID];
} else {
$finalPostVars = array();
}
$finalPostVars = array_merge($finalPostVars, $postVars);
unset($finalPostVars['Widget']);
//Workaround for UploadField's and GridFields confusing the request
$fields = $sourceWidget->getCMSFields();
$uploadFields = array();
$gridFields = array();
foreach ($fields as $field) {
if ($field instanceof UploadField) {
$uploadFields[] = $field->getName();
} else {
if ($field instanceof GridField) {
$gridFields[] = $field->getName();
}
}
}
//Re-orgazine the upload field data
if (count($uploadFields)) {
foreach ($uploadFields as $field) {
$formFieldName = 'Widget[' . $this->getName() . '][' . $objID . '][' . $field . ']';
$fieldData = array($formFieldName => array('name' => array('Uploads' => array()), 'type' => array('Uploads' => array()), 'tmp_name' => array('Uploads' => array()), 'error' => array('Uploads' => array()), 'size' => array('Uploads' => array())));
if (isset($postVars['Widget']['name'][$this->getName()][$objID][$field]['Uploads'])) {
for ($i = 0; $i < count($postVars['Widget']['name'][$this->getName()][$objID][$field]['Uploads']); $i++) {
$fieldData[$formFieldName]['name']['Uploads'][] = $postVars['Widget']['name'][$this->getName()][$objID][$field]['Uploads'][$i];
$fieldData[$formFieldName]['type']['Uploads'][] = $postVars['Widget']['type'][$this->getName()][$objID][$field]['Uploads'][$i];
$fieldData[$formFieldName]['tmp_name']['Uploads'][] = $postVars['Widget']['tmp_name'][$this->getName()][$objID][$field]['Uploads'][$i];
$fieldData[$formFieldName]['error']['Uploads'][] = $postVars['Widget']['error'][$this->getName()][$objID][$field]['Uploads'][$i];
$fieldData[$formFieldName]['size']['Uploads'][] = $postVars['Widget']['size'][$this->getName()][$objID][$field]['Uploads'][$i];
}
}
$finalPostVars = array_merge_recursive($finalPostVars, $fieldData);
}
}
//Reorganize the gridfield data
if (count($gridFields) && isset($postVars['Widget'][$this->getName()][$objID])) {
foreach ($gridFields as $field) {
$formFieldName = 'Widget[' . $this->getName() . '][' . $objID . '][' . $field . ']';
$fieldData = array($formFieldName => $postVars['Widget'][$this->getName()][$objID][$field]);
}
$finalPostVars = array_merge_recursive($finalPostVars, $fieldData);
}
}
$headers = $request->getHeaders();
$request = new SS_HTTPRequest($_SERVER['REQUEST_METHOD'], str_replace(rtrim($baseLink, '/'), '', rtrim($request->getURL(), '/')) . '/', $request->getVars(), $finalPostVars, $request->getBody());
$request->match('$Action/$ID/$OtherID');
//Merge in the headers
foreach ($headers as $header => $value) {
$request->addHeader($header, $value);
}
return $request;
}
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-advancedwidgeteditor,代码行数:70,代码来源:AdvancedWidgetAreaEditor.php