Esempio n. 1
0
function pm_export_html($message_array, ZipArchive $zip, $options_array = array())
{
    if (!is_array($message_array)) {
        return false;
    }
    if (!is_array($options_array)) {
        $options_array = array();
    }
    if (!isset($options_array['PM_EXPORT_FILE'])) {
        if (isset($_SESSION['PM_EXPORT_FILE']) && in_array($_SESSION['PM_EXPORT_FILE'], array(PM_EXPORT_SINGLE, PM_EXPORT_MANY))) {
            $options_array['PM_EXPORT_FILE'] = $_SESSION['PM_EXPORT_FILE'];
        } else {
            $options_array['PM_EXPORT_FILE'] = PM_EXPORT_HTML;
        }
    }
    if (!isset($options_array['PM_EXPORT_WORDFILTER'])) {
        if (isset($_SESSION['PM_EXPORT_WORDFILTER']) && in_array($_SESSION['PM_EXPORT_WORDFILTER'], array('Y', 'N'))) {
            $options_array['PM_EXPORT_WORDFILTER'] = $_SESSION['PM_EXPORT_WORDFILTER'];
        } else {
            $options_array['PM_EXPORT_WORDFILTER'] = 'Y';
        }
    }
    $pm_display = '';
    if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_SINGLE) {
        $pm_display = pm_export_html_top();
    }
    if (sizeof($message_array) == 0) {
        return false;
    }
    foreach ($message_array as $message) {
        $message['CONTENT'] = pm_get_content($message['MID']);
        if ($options_array['PM_EXPORT_WORDFILTER'] == 'Y') {
            $message = array_map('pm_export_word_filter_apply', $message);
        }
        if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_MANY) {
            $pm_display = pm_export_html_top($message);
        }
        $pm_display .= pm_display_html_export($message);
        if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_SINGLE) {
            $pm_display .= "<br />\n";
        }
        if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_MANY) {
            $pm_display .= pm_export_html_bottom();
            $zip->addFromString(sprintf("message_%s.html", $message['MID']), $pm_display);
        }
    }
    if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_SINGLE) {
        $pm_display .= pm_export_html_bottom();
        $zip->addFromString("messages.html", $pm_display);
    }
    return true;
}
Esempio n. 2
0
function pm_export_html($messages_array, &$zip_file, $options_array = array())
{
    if (!is_array($messages_array)) {
        return false;
    }
    if (!is_object($zip_file)) {
        return false;
    }
    if (!is_array($options_array)) {
        $options_array = array();
    }
    if (!isset($options_array['PM_EXPORT_FILE'])) {
        $options_array['PM_EXPORT_FILE'] = session::get_value('PM_EXPORT_FILE');
    }
    if (!isset($options_array['PM_EXPORT_ATTACHMENTS'])) {
        $options_array['PM_EXPORT_ATTACHMENTS'] = session::get_value('PM_EXPORT_ATTACHMENTS');
    }
    if (!isset($options_array['PM_EXPORT_WORDFILTER'])) {
        $options_array['PM_EXPORT_WORDFILTER'] = session::get_value('PM_EXPORT_WORDFILTER');
    }
    if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_SINGLE) {
        $pm_display = pm_export_html_top();
    }
    if (sizeof($messages_array) == 0) {
        return false;
    }
    foreach ($messages_array as $mid) {
        if (!($message = pm_message_get($mid))) {
            return false;
        }
        if (isset($message['AID']) && $options_array['PM_EXPORT_ATTACHMENTS'] == 'Y') {
            pm_export_attachments($message['AID'], $message['FROM_UID'], $zip_file);
        }
        $message['FOLDER'] = pm_message_get_folder($message['MID']);
        $message['CONTENT'] = pm_get_content($message['MID']);
        if ($options_array['PM_EXPORT_WORDFILTER'] == 'Y') {
            $message = array_map('pm_export_word_filter_apply', $message);
        }
        if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_MANY) {
            $pm_display = pm_export_html_top($message);
        }
        $pm_display .= pm_display_html_export($message, $message['FOLDER']);
        if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_SINGLE) {
            $pm_display .= "<br />\n";
        }
        if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_MANY) {
            $pm_display .= pm_export_html_bottom();
            $zip_file->add_file($pm_display, sprintf("message_%s.html", $message['MID']));
        }
    }
    if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_SINGLE) {
        $pm_display .= pm_export_html_bottom();
        $zip_file->add_file($pm_display, "messages.html");
    }
    return true;
}