当前位置: 首页>>代码示例>>PHP>>正文


PHP rcube_utils::file2class方法代码示例

本文整理汇总了PHP中rcube_utils::file2class方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_utils::file2class方法的具体用法?PHP rcube_utils::file2class怎么用?PHP rcube_utils::file2class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rcube_utils的用法示例。


在下文中一共展示了rcube_utils::file2class方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: attachment_upload

 /**
  * Handler for attachment uploads
  */
 public function attachment_upload($session_key, $id_prefix = '')
 {
     // Upload progress update
     if (!empty($_GET['_progress'])) {
         $this->rc->upload_progress();
     }
     $recid = $id_prefix . rcube_utils::get_input_value('_id', rcube_utils::INPUT_GPC);
     $uploadid = rcube_utils::get_input_value('_uploadid', rcube_utils::INPUT_GPC);
     if (!is_array($_SESSION[$session_key]) || $_SESSION[$session_key]['id'] != $recid) {
         $_SESSION[$session_key] = array();
         $_SESSION[$session_key]['id'] = $recid;
         $_SESSION[$session_key]['attachments'] = array();
     }
     // clear all stored output properties (like scripts and env vars)
     $this->rc->output->reset();
     if (is_array($_FILES['_attachments']['tmp_name'])) {
         foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) {
             // Process uploaded attachment if there is no error
             $err = $_FILES['_attachments']['error'][$i];
             if (!$err) {
                 $attachment = array('path' => $filepath, 'size' => $_FILES['_attachments']['size'][$i], 'name' => $_FILES['_attachments']['name'][$i], 'mimetype' => rcube_mime::file_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i]), 'group' => $recid);
                 $attachment = $this->rc->plugins->exec_hook('attachment_upload', $attachment);
             }
             if (!$err && $attachment['status'] && !$attachment['abort']) {
                 $id = $attachment['id'];
                 // store new attachment in session
                 unset($attachment['status'], $attachment['abort']);
                 $_SESSION[$session_key]['attachments'][$id] = $attachment;
                 if (($icon = $_SESSION[$session_key . '_deleteicon']) && is_file($icon)) {
                     $button = html::img(array('src' => $icon, 'alt' => $this->rc->gettext('delete')));
                 } else {
                     $button = rcube::Q($this->rc->gettext('delete'));
                 }
                 $content = html::a(array('href' => "#delete", 'class' => 'delete', 'onclick' => sprintf("return %s.remove_from_attachment_list('rcmfile%s')", rcmail_output::JS_OBJECT_NAME, $id), 'title' => $this->rc->gettext('delete'), 'aria-label' => $this->rc->gettext('delete') . ' ' . $attachment['name']), $button);
                 $content .= rcube::Q($attachment['name']);
                 $this->rc->output->command('add2attachment_list', "rcmfile{$id}", array('html' => $content, 'name' => $attachment['name'], 'mimetype' => $attachment['mimetype'], 'classname' => rcube_utils::file2class($attachment['mimetype'], $attachment['name']), 'complete' => true), $uploadid);
             } else {
                 // upload failed
                 if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
                     $msg = $this->rc->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $this->rc->show_bytes(parse_bytes(ini_get('upload_max_filesize'))))));
                 } else {
                     if ($attachment['error']) {
                         $msg = $attachment['error'];
                     } else {
                         $msg = $this->rc->gettext('fileuploaderror');
                     }
                 }
                 $this->rc->output->command('display_message', $msg, 'error');
                 $this->rc->output->command('remove_from_attachment_list', $uploadid);
             }
         }
     } else {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             // if filesize exceeds post_max_size then $_FILES array is empty,
             // show filesizeerror instead of fileuploaderror
             if ($maxsize = ini_get('post_max_size')) {
                 $msg = $this->rc->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $this->rc->show_bytes(parse_bytes($maxsize)))));
             } else {
                 $msg = $this->rc->gettext('fileuploaderror');
             }
             $this->rc->output->command('display_message', $msg, 'error');
             $this->rc->output->command('remove_from_attachment_list', $uploadid);
         }
     }
     $this->rc->output->send('iframe');
 }
开发者ID:Fneufneu,项目名称:libcalendaring,代码行数:69,代码来源:libcalendaring.php

示例2: save_data

 function save_data()
 {
     $COMPOSE_ID = rcube_utils::get_input_value('_id', rcube_utils::INPUT_GPC);
     $COMPOSE = null;
     if ($COMPOSE_ID && $_SESSION['compose_data_' . $COMPOSE_ID]) {
         $SESSION_KEY = 'compose_data_' . $COMPOSE_ID;
         $COMPOSE =& $_SESSION[$SESSION_KEY];
     }
     if (!$COMPOSE) {
         die("Invalid session var!");
     }
     $uploadid = rcube_utils::get_input_value('_uploadid', rcube_utils::INPUT_POST);
     $files = rcube_utils::get_input_value('files', rcube_utils::INPUT_POST);
     $RCMAIL = rcmail::get_instance();
     $RCMAIL->output->reset();
     //rcube::write_log('dropbox_attachments', $files);
     if (is_array($files)) {
         $multiple = count($files) > 1;
         foreach ($files as $i => $file) {
             /*File checks*/
             $err = false;
             if ($file['is_dir'] == 'true') {
                 $err = "UPLOAD_ERR_DIRECTORY";
             }
             // Fetch file
             $filepath = $this->download_fopen($file['link']);
             //rcube::write_log('dropbox_attachments', link);
             //rcube::write_log('dropbox_attachments', $filepath);
             rcube::write_log('dropbox_attachments', $file['link']);
             if (!$filepath) {
                 $err = "UPLOAD_ERR_FETCH";
             }
             if (!$err) {
                 $attachment = $this->move_file(array('path' => $filepath, 'size' => $file['bytes'], 'name' => $file['name'], 'mimetype' => rcube_mime::file_content_type($filepath, $file['name']), 'group' => $COMPOSE_ID));
             }
             //rcube::write_log('dropbox_attachments', $attachment);
             if (!$err && $attachment['status'] && !$attachment['abort']) {
                 $id = $attachment['id'];
                 // store new attachment in session
                 unset($attachment['status'], $attachment['abort']);
                 $RCMAIL->session->append($SESSION_KEY . '.attachments', $id, $attachment);
                 if (($icon = $COMPOSE['deleteicon']) && is_file($icon)) {
                     $button = html::img(array('src' => $icon, 'alt' => $RCMAIL->gettext('delete')));
                 } else {
                     if ($COMPOSE['textbuttons']) {
                         $button = rcube::Q($RCMAIL->gettext('delete'));
                     } else {
                         $button = '';
                     }
                 }
                 $content = html::a(array('href' => "#delete", 'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%s', this)", rcmail_output::JS_OBJECT_NAME, $id), 'title' => $RCMAIL->gettext('delete'), 'class' => 'delete'), $button);
                 $content .= rcube::Q($attachment['name']);
                 $RCMAIL->output->command('add2attachment_list', "rcmfile{$id}", array('html' => $content, 'name' => $attachment['name'], 'mimetype' => $attachment['mimetype'], 'classname' => rcube_utils::file2class($attachment['mimetype'], $attachment['name']), 'complete' => true), $uploadid);
             } else {
                 // upload failed
                 if ($err == "UPLOAD_ERR_DIRECTORY") {
                     $msg = "Directory upload not allowed.";
                 } else {
                     if ($err == "UPLOAD_ERR_FETCH") {
                         $msg = "Failed to download file from Dropbox";
                     } else {
                         if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
                             $size = $RCMAIL->show_bytes(parse_bytes(ini_get('upload_max_filesize')));
                             $msg = $RCMAIL->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $size)));
                         } else {
                             if ($attachment['error']) {
                                 $msg = $attachment['error'];
                             } else {
                                 $msg = $RCMAIL->gettext('fileuploaderror');
                             }
                         }
                     }
                 }
                 if ($attachment['error'] || $err != UPLOAD_ERR_NO_FILE) {
                     $RCMAIL->output->command('display_message', $msg, 'error');
                     $RCMAIL->output->command('remove_from_attachment_list', $uploadid);
                 }
             }
         }
     }
     $RCMAIL->output->command('auto_save_start', 'false');
     $RCMAIL->output->send();
 }
开发者ID:rigent1164,项目名称:dropbox_attachments,代码行数:83,代码来源:dropbox_attachments.php

示例3: mail_message2event

 /**
  * Read email message and return contents for a new event based on that message
  */
 public function mail_message2event()
 {
     $uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
     $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
     $event = array();
     // establish imap connection
     $imap = $this->rc->get_storage();
     $imap->set_mailbox($mbox);
     $message = new rcube_message($uid);
     if ($message->headers) {
         $event['title'] = trim($message->subject);
         $event['description'] = trim($message->first_text_part());
         $this->load_driver();
         // add a reference to the email message
         if ($msgref = $this->driver->get_message_reference($message->headers, $mbox)) {
             $event['links'] = array($msgref);
         } else {
             if ($message->attachments) {
                 $eventid = 'cal-';
                 if (!is_array($_SESSION[self::SESSION_KEY]) || $_SESSION[self::SESSION_KEY]['id'] != $eventid) {
                     $_SESSION[self::SESSION_KEY] = array();
                     $_SESSION[self::SESSION_KEY]['id'] = $eventid;
                     $_SESSION[self::SESSION_KEY]['attachments'] = array();
                 }
                 foreach ((array) $message->attachments as $part) {
                     $attachment = array('data' => $imap->get_message_part($uid, $part->mime_id, $part), 'size' => $part->size, 'name' => $part->filename, 'mimetype' => $part->mimetype, 'group' => $eventid);
                     $attachment = $this->rc->plugins->exec_hook('attachment_save', $attachment);
                     if ($attachment['status'] && !$attachment['abort']) {
                         $id = $attachment['id'];
                         $attachment['classname'] = rcube_utils::file2class($attachment['mimetype'], $attachment['name']);
                         // store new attachment in session
                         unset($attachment['status'], $attachment['abort'], $attachment['data']);
                         $_SESSION[self::SESSION_KEY]['attachments'][$id] = $attachment;
                         $attachment['id'] = 'rcmfile' . $attachment['id'];
                         // add prefix to consider it 'new'
                         $event['attachments'][] = $attachment;
                     }
                 }
             }
         }
         $this->rc->output->command('plugin.mail2event_dialog', $event);
     } else {
         $this->rc->output->command('display_message', $this->gettext('messageopenerror'), 'error');
     }
     $this->rc->output->send();
 }
开发者ID:nciftci,项目名称:plugins,代码行数:49,代码来源:calendar.php

示例4: test_file2class

 /**
  * rcube:utils::file2class()
  */
 function test_file2class()
 {
     $test = array(array('', '', 'unknown'), array('text', 'text', 'text'), array('image/png', 'image.png', 'image png'));
     foreach ($test as $v) {
         $result = rcube_utils::file2class($v[0], $v[1]);
         $this->assertSame($v[2], $result);
     }
 }
开发者ID:NathanAUS,项目名称:roundcubemail,代码行数:11,代码来源:Utils.php

示例5: rcmail_filetype2classname

function rcmail_filetype2classname($mimetype, $filename)
{
    return rcube_utils::file2class($mimetype, $filename);
}
开发者ID:noikiy,项目名称:roundcubemail,代码行数:4,代码来源:bc.php

示例6: addFilesToMail

    public function addFilesToMail()
    {
        $COMPOSE_ID = rcube_utils::get_input_value('_id', rcube_utils::INPUT_GPC);
        $uploadid = rcube_utils::get_input_value('_uploadid', rcube_utils::INPUT_GPC);
        $COMPOSE = null;
        if ($COMPOSE_ID && $_SESSION['compose_data_' . $COMPOSE_ID]) {
            $SESSION_KEY = 'compose_data_' . $COMPOSE_ID;
            $COMPOSE =& $_SESSION[$SESSION_KEY];
        }
        if (!$COMPOSE) {
            die("Invalid session var!");
        }
        $rcmail = rcmail::get_instance();
        $index = 0;
        $attachments = self::getFiles();
        foreach ($attachments as $attachment) {
            $index++;
            $attachment['group'] = $COMPOSE_ID;
            $userid = rcmail::get_instance()->user->ID;
            list($usec, $sec) = explode(' ', microtime());
            $id = preg_replace('/[^0-9]/', '', $userid . $sec . $usec) . $index;
            $attachment['id'] = $id;
            $_SESSION['plugins']['filesystem_attachments'][$COMPOSE_ID][$id] = $attachment['path'];
            $rcmail->session->append($SESSION_KEY . '.attachments', $id, $attachment);
            if (($icon = $COMPOSE['deleteicon']) && is_file($icon)) {
                $button = html::img(array('src' => $icon, 'alt' => $rcmail->gettext('delete')));
            } else {
                if ($COMPOSE['textbuttons']) {
                    $button = rcube::Q($rcmail->gettext('delete'));
                } else {
                    $button = '';
                }
            }
            $content = html::a(array('href' => "#delete", 'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%s', this)", rcmail_output::JS_OBJECT_NAME, $id), 'title' => $rcmail->gettext('delete'), 'class' => 'delete', 'aria-label' => $rcmail->gettext('delete') . ' ' . $attachment['name']), $button);
            $content .= rcube::Q($attachment['name']);
            $htmlAttachments .= 'window.rcmail.add2attachment_list("rcmfile' . $id . '",{html:"<a href=\\"#delete\\" onclick=\\"return rcmail.command(\'remove-attachment\',\'rcmfile' . $id . '\', this)\\" title=\\"' . $rcmail->gettext('delete') . '\\" class=\\"delete\\" aria-label=\\"' . $rcmail->gettext('delete') . ' ' . $attachment['name'] . '\\"><\\/a>' . $attachment['name'] . '",name:"' . $attachment['name'] . '",mimetype:"' . $attachment['mimetype'] . '",classname:"' . rcube_utils::file2class($attachment['mimetype'], $attachment['name']) . '",complete:true},"' . $uploadid . '");' . PHP_EOL;
        }
        $response = '<!DOCTYPE html>
<html lang="en">
<head><title></title><meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
if (window && window.rcmail) {
	window.rcmail.iframe_loaded("");
	' . $htmlAttachments . '
	window.rcmail.auto_save_start(false);
}
</script>
</head>
<body>
</body>
</html>';
        echo $response;
        exit;
    }
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:54,代码来源:yetiforce.php

示例7: rcmail_filetype2classname

function rcmail_filetype2classname($mimetype, $filename)
{
    _deprecation_warning(__FUNCTION__);
    return rcube_utils::file2class($mimetype, $filename);
}
开发者ID:JotapePinheiro,项目名称:roundcubemail,代码行数:5,代码来源:bc.php


注:本文中的rcube_utils::file2class方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。