本文整理汇总了PHP中Horde_Mime_Part::setMimeId方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Part::setMimeId方法的具体用法?PHP Horde_Mime_Part::setMimeId怎么用?PHP Horde_Mime_Part::setMimeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime_Part
的用法示例。
在下文中一共展示了Horde_Mime_Part::setMimeId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _partAction
/**
* Function used to find a specific MIME part by ID and perform an action
* on it.
*
* @param string $id The MIME ID.
* @param string $action The action to perform ('get',
* 'remove', or 'alter').
* @param Horde_Mime_Part $mime_part The object to use for 'alter'.
*
* @return mixed See calling functions.
*/
protected function _partAction($id, $action, $mime_part = null)
{
$this_id = $this->getMimeId();
/* Need strcmp() because, e.g., '2.0' == '2'. */
if ($action === 'get' && strcmp($id, $this_id) === 0) {
return $this;
}
if ($this->_reindex) {
$this->buildMimeIds(is_null($this_id) ? '1' : $this_id);
}
foreach ($this->_parts as $key => $val) {
$partid = $val->getMimeId();
if (($match = strcmp($id, $partid) === 0) || strpos($id, $partid . '.') === 0 || strrchr($partid, '.') === '.0') {
switch ($action) {
case 'alter':
if ($match) {
$mime_part->setMimeId($partid);
$this->_parts[$key] = $mime_part;
return true;
}
return $val->alterPart($id, $mime_part);
case 'get':
return $match ? $val : $val->getPart($id);
case 'remove':
if ($match) {
unset($this->_parts[$key]);
$this->_reindex = true;
return true;
}
return $val->removePart($id);
}
}
}
return $action === 'get' ? null : false;
}
示例2: _partAction
/**
* Function used to find a specific MIME part by ID and perform an action
* on it.
*
* @param string $id The MIME ID.
* @param string $action The action to perform ('get',
* 'remove', or 'alter').
* @param Horde_Mime_Part $mime_part The object to use for 'alter'.
*
* @return mixed See calling functions.
*/
protected function _partAction($id, $action, $mime_part = null)
{
$this_id = $this->getMimeId();
/* Need strcmp() because, e.g., '2.0' == '2'. */
if ($action == 'get' && strcmp($id, $this_id) === 0) {
return $this;
}
if ($this->_reindex) {
$this->buildMimeIds(is_null($this_id) ? '1' : $this_id);
}
foreach (array_keys($this->_parts) as $val) {
$partid = $this->_parts[$val]->getMimeId();
if (strcmp($id, $partid) === 0) {
switch ($action) {
case 'alter':
$mime_part->setMimeId($this->_parts[$val]->getMimeId());
$this->_parts[$val] = $mime_part;
return true;
case 'get':
return $this->_parts[$val];
case 'remove':
unset($this->_parts[$val]);
$this->_reindex = true;
return true;
}
}
if (strpos($id, $partid . '.') === 0 || strrchr($partid, '.') === '.0') {
return $this->_parts[$val]->_partAction($id, $action, $mime_part);
}
}
return $action == 'get' ? null : false;
}