Horde_Mime_Part::buildMimeIds PHP Method

buildMimeIds() public method

Build the MIME IDs for this part and all subparts.
public buildMimeIds ( string $id = null, boolean $rfc822 = false )
$id string The ID of this part.
$rfc822 boolean Is this a message/rfc822 part?
    public function buildMimeIds($id = null, $rfc822 = false)
    {
        $this->_status &= ~self::STATUS_REINDEX;
        if (is_null($id)) {
            $rfc822 = true;
            $id = '';
        }
        if ($rfc822) {
            if (empty($this->_parts) && $this->getPrimaryType() != 'multipart') {
                $this->setMimeId($id . '1');
            } else {
                if (empty($id) && $this->getType() == 'message/rfc822') {
                    $this->setMimeId('1.0');
                } else {
                    $this->setMimeId($id . '0');
                }
                $i = 1;
                foreach ($this as $val) {
                    $val->buildMimeIds($id . $i++);
                }
            }
        } else {
            $this->setMimeId($id);
            $id = $id ? substr($id, -2) === '.0' ? substr($id, 0, -1) : $id . '.' : '';
            if (count($this)) {
                if ($this->getType() == 'message/rfc822') {
                    $this->rewind();
                    $this->current()->buildMimeIds($id, true);
                } else {
                    $i = 1;
                    foreach ($this as $val) {
                        $val->buildMimeIds($id . $i++);
                    }
                }
            }
        }
    }

Usage Example

Example #1
0
$command = trim($vars->php);
$title = _("PHP Shell");
$view = new Horde_View(array('templatePath' => HORDE_TEMPLATES . '/admin'));
$view->addHelper('Horde_Core_View_Helper_Help');
$view->addHelper('Text');
$view->action = Horde::url('admin/phpshell.php');
$view->application = $application;
$view->apps = $apps;
$view->command = $command;
$view->title = $title;
if ($command) {
    $pushed = $registry->pushApp($application);
    $part = new Horde_Mime_Part();
    $part->setContents($command);
    $part->setType('application/x-httpd-phps');
    $part->buildMimeIds();
    $pretty = $injector->getInstance('Horde_Core_Factory_MimeViewer')->create($part)->render('inline');
    $view->pretty = $pretty[1]['data'];
    Horde::startBuffer();
    try {
        eval($command);
    } catch (Exception $e) {
        echo $e;
    }
    $view->command_exec = Horde::endBuffer();
    if ($pushed) {
        $registry->popApp();
    }
}
$page_output->addScriptFile('stripe.js', 'horde');
$page_output->header(array('title' => $title));
All Usage Examples Of Horde_Mime_Part::buildMimeIds