mail : getHeaders function added

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5827 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2019-12-09 20:42:39 +00:00
parent abd8b70ad1
commit 5f52085461
2 changed files with 108 additions and 18 deletions

View File

@@ -1292,6 +1292,22 @@ class mail
}
// }}}
/** Get all the headers, in the order in EML. The format is
* [] => array ("header" => "value")
* @param array|null $headers The headers to examine
* @return array
*/
public function getHeaders ($headers=null)
{
$sectionMainID = $this->sectionMainID ();
if ($sectionMainID === false ||
! key_exists ("_headersArray", $this->sections[$sectionMainID]))
$headers = array ();
else
$headers = $this->sections[$sectionMainID]["_headersArray"];
return $headers;
}
/** Get a generic header
* If there is multiple headers with the same name, return the first
* @param string $header The header to get
@@ -1301,15 +1317,7 @@ class mail
public function getHeader ($header, $headers=null)
// {{{
{
if ($headers === null)
{
$sectionMainID = $this->sectionMainID ();
if ($sectionMainID === false ||
! key_exists ("_headersArray", $this->sections[$sectionMainID]))
$headers = array ();
else
$headers = $this->sections[$sectionMainID]["_headersArray"];
}
$headers = $this->getHeaders ($headers);
foreach ($headers as $key=>$val)
{
$head = key ($val);
@@ -1330,15 +1338,7 @@ class mail
public function getHeaderValue ($header, $headers=null)
// {{{
{
if ($headers === null)
{
$sectionMainID = $this->sectionMainID ();
if ($sectionMainID === false ||
! key_exists ("_headersArray", $this->sections[$sectionMainID]))
$headers = array ();
else
$headers = $this->sections[$sectionMainID]["_headersArray"];
}
$headers = $this->getHeaders ($headers);
foreach ($headers as $key=>$val)
{
$head = key ($val);