예제 #1
0
 /**
  * Uploads attachment file
  *
  * @access  public
  * @return  string  javascript script segment
  */
 function UploadFile()
 {
     $file_num = jaws()->request->fetch('attachment_number', 'post');
     $file = Jaws_Utils::UploadFiles($_FILES, Jaws_Utils::upload_tmp_dir(), '', null);
     if (Jaws_Error::IsError($file)) {
         $response = array('type' => 'error', 'message' => $file->getMessage());
     } else {
         $response = array('type' => 'notice', 'file_info' => array('title' => $file['attachment' . $file_num][0]['user_filename'], 'filename' => $file['attachment' . $file_num][0]['host_filename'], 'filesize_format' => Jaws_Utils::FormatSize($file['attachment' . $file_num][0]['host_filesize']), 'filesize' => $file['attachment' . $file_num][0]['host_filesize'], 'filetype' => $file['attachment' . $file_num][0]['host_filetype']));
     }
     $response = Jaws_UTF8::json_encode($response);
     return "<script type='text/javascript'>parent.onUpload({$response});</script>";
 }
예제 #2
0
파일: Compose.php 프로젝트: juniortux/jaws
 /**
  * Get Message Attachment UI
  *
  * @access  public
  * @param   integer $message_id         Message Id
  * @param   bool    $loadAttachments    Load and show message attachments (parent message attachments)
  * @return  string XHTML template content
  */
 function GetMessageAttachmentUI($message_id = null, $loadAttachments = true)
 {
     $this->gadget->CheckPermission('SendMessage');
     if (empty($message_id)) {
         $message_id = jaws()->request->fetch('id', 'post');
     }
     $user = $GLOBALS['app']->Session->GetAttribute('user');
     $model = $this->gadget->model->load('Message');
     $tpl = $this->gadget->template->load('Compose.html');
     $tpl->SetBlock('attachments');
     if ($loadAttachments && !empty($message_id)) {
         $message = $model->GetMessage($message_id, true, false);
         if (isset($message['attachments'])) {
             foreach ($message['attachments'] as $file) {
                 $tpl->SetBlock('attachments/file');
                 $tpl->SetVariable('lbl_file_size', _t('PRIVATEMESSAGE_MESSAGE_FILE_SIZE'));
                 $tpl->SetVariable('file_name', $file['title']);
                 $tpl->SetVariable('file_size', Jaws_Utils::FormatSize($file['filesize']));
                 $tpl->SetVariable('file_id', $file['id']);
                 $tpl->SetVariable('file_download_link', $file['title']);
                 $file_url = $this->gadget->urlMap('Attachment', array('uid' => $user, 'mid' => $message_id, 'aid' => $file['id']));
                 $tpl->SetVariable('file_download_link', $file_url);
                 $tpl->ParseBlock('attachments/file');
             }
         }
     }
     $tpl->ParseBlock('attachments');
     return $tpl->Get();
 }
예제 #3
0
파일: Mailer.php 프로젝트: Dulciane/jaws
 /**
  * Uploads attachment file
  *
  * @access  public
  * @return  string  javascript script segment
  */
 function UploadFile()
 {
     $res = Jaws_Utils::UploadFiles($_FILES, Jaws_Utils::upload_tmp_dir());
     if (Jaws_Error::IsError($res)) {
         $response = array('type' => 'error', 'message' => $res->getMessage());
     } elseif (empty($res)) {
         $response = array('type' => 'error', 'message' => _t('GLOBAL_ERROR_UPLOAD_4'));
     } else {
         $response = array('type' => 'notice', 'filename' => $res['attachment'][0]['host_filename'], 'filesize' => Jaws_Utils::FormatSize($_FILES['attachment']['size']));
     }
     $response = Jaws_UTF8::json_encode($response);
     return "<script type='text/javascript'>parent.onUpload({$response});</script>";
 }
예제 #4
0
파일: Message.php 프로젝트: Dulciane/jaws
 /**
  * Display a message Info
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function Message()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(401);
     }
     $id = jaws()->request->fetch('id', 'get');
     $date = Jaws_Date::getInstance();
     $model = $this->gadget->model->load('Message');
     $user = $GLOBALS['app']->Session->GetAttribute('user');
     $usrModel = new Jaws_User();
     $message = $model->GetMessage($id, true);
     if (empty($message)) {
         return Jaws_HTTPError::Get(404);
     }
     // Check permissions
     if (!($message['from'] == $user && $message['to'] == 0) && $message['to'] != $user) {
         return Jaws_HTTPError::Get(403);
     }
     // Detect message folder
     if ($message['from'] == $user && $message['to'] != $user) {
         $folder = PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_OUTBOX;
     } else {
         $folder = PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX;
     }
     if ($folder == PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX && $message['read'] == false) {
         $user = $GLOBALS['app']->Session->GetAttribute('user');
         $model->MarkMessages($id, true, $user);
     }
     $date_format = $this->gadget->registry->fetch('date_format');
     $tpl = $this->gadget->template->load('Message.html');
     $tpl->SetBlock('message');
     $tpl->SetVariable('id', $id);
     $tpl->SetBlock('message');
     $tpl->SetVariable('confirmTrash', _t('PRIVATEMESSAGE_MESSAGE_CONFIRM_TRASH'));
     $tpl->SetVariable('confirmDelete', _t('PRIVATEMESSAGE_MESSAGE_CONFIRM_DELETE'));
     $tpl->SetVariable('lbl_from', _t('PRIVATEMESSAGE_MESSAGE_FROM'));
     $tpl->SetVariable('lbl_send_time', _t('PRIVATEMESSAGE_MESSAGE_SEND_TIME'));
     $tpl->SetVariable('lbl_subject', _t('PRIVATEMESSAGE_MESSAGE_SUBJECT'));
     $tpl->SetVariable('lbl_body', _t('PRIVATEMESSAGE_MESSAGE_BODY'));
     $tpl->SetVariable('from', $message['from_nickname']);
     $tpl->SetVariable('username', $message['from_username']);
     $tpl->SetVariable('nickname', $message['from_nickname']);
     $tpl->SetVariable('send_time', $date->Format($message['insert_time'], $date_format));
     $tpl->SetVariable('subject', $message['subject']);
     $tpl->SetVariable('body', $this->gadget->ParseText($message['body'], 'PrivateMessage', 'index'));
     $tpl->SetVariable('trash_url', $this->gadget->urlMap('TrashMessage', array('id' => $id)));
     $tpl->SetVariable('delete_url', $this->gadget->urlMap('DeleteMessage', array('id' => $id)));
     // user's avatar
     $tpl->SetVariable('avatar', $usrModel->GetAvatar($message['avatar'], $message['email'], 80));
     // user's profile
     $tpl->SetVariable('user_url', $GLOBALS['app']->Map->GetURLFor('Users', 'Profile', array('user' => $message['from_username'])));
     if (!empty($message['attachments'])) {
         $tpl->SetBlock('message/attachment');
         $tpl->SetVariable('lbl_attachments', _t('PRIVATEMESSAGE_MESSAGE_ATTACHMENTS'));
         foreach ($message['attachments'] as $file) {
             $tpl->SetBlock('message/attachment/file');
             $tpl->SetVariable('lbl_file_size', _t('PRIVATEMESSAGE_MESSAGE_FILE_SIZE'));
             $tpl->SetVariable('file_name', $file['title']);
             $tpl->SetVariable('file_size', Jaws_Utils::FormatSize($file['filesize']));
             $tpl->SetVariable('file_download_link', $file['title']);
             $file_url = $this->gadget->urlMap('Attachment', array('uid' => $user, 'mid' => $message['id'], 'aid' => $file['id']));
             $tpl->SetVariable('file_download_link', $file_url);
             $tpl->ParseBlock('message/attachment/file');
         }
         $tpl->ParseBlock('message/attachment');
     }
     if ($message['folder'] != PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_TRASH) {
         $tpl->SetBlock('message/archive');
         if ($message['folder'] == PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_ARCHIVED) {
             $tpl->SetVariable('icon_archive', 'gadgets/PrivateMessage/Resources/images/unarchive-mini.png');
             $tpl->SetVariable('archive', _t('PRIVATEMESSAGE_UNARCHIVE'));
             $tpl->SetVariable('archive_url', $this->gadget->urlMap('UnArchiveMessage', array('id' => $id)));
         } else {
             $tpl->SetVariable('icon_archive', 'gadgets/PrivateMessage/Resources/images/archive-mini.png');
             $tpl->SetVariable('archive', _t('PRIVATEMESSAGE_ARCHIVE'));
             $tpl->SetVariable('archive_url', $this->gadget->urlMap('ArchiveMessage', array('id' => $id)));
         }
         $tpl->ParseBlock('message/archive');
     }
     if ($message['folder'] != PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_DRAFT && $message['folder'] != PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_TRASH) {
         if ($folder == PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX) {
             $tpl->SetBlock('message/reply');
             $tpl->SetVariable('reply_url', $this->gadget->urlMap('Compose', array('id' => $message['id'], 'reply' => 'true')));
             $tpl->SetVariable('icon_reply', 'gadgets/PrivateMessage/Resources/images/reply-mini.png');
             $tpl->SetVariable('reply', _t('PRIVATEMESSAGE_REPLY'));
             $tpl->ParseBlock('message/reply');
         }
         $tpl->SetBlock('message/forward');
         $tpl->SetVariable('forward_url', $this->gadget->urlMap('Compose', array('id' => $message['id'], 'reply' => 'false')));
         $tpl->SetVariable('icon_forward', 'gadgets/PrivateMessage/Resources/images/forward-mini.png');
         $tpl->SetVariable('forward', _t('PRIVATEMESSAGE_FORWARD'));
         $tpl->ParseBlock('message/forward');
     }
     if ($message['folder'] != PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_TRASH) {
         $tpl->SetBlock('message/trash');
         $tpl->SetVariable('icon_trash', 'gadgets/PrivateMessage/Resources/images/trash-mini.png');
         $tpl->SetVariable('trash', _t('PRIVATEMESSAGE_TRASH'));
         $tpl->ParseBlock('message/trash');
     }
     if ($message['folder'] == PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_TRASH) {
         $tpl->SetBlock('message/restore_trash');
         $tpl->SetVariable('restore_trash_url', $this->gadget->urlMap('RestoreTrashMessage', array('id' => $id)));
         $tpl->SetVariable('icon_restore_trash', '');
         $tpl->SetVariable('restore_trash', _t('PRIVATEMESSAGE_RESTORE_TRASH'));
         $tpl->ParseBlock('message/restore_trash');
         $tpl->SetBlock('message/delete');
         $tpl->SetVariable('icon_delete', STOCK_DELETE);
         $tpl->SetVariable('delete', _t('GLOBAL_DELETE'));
         $tpl->ParseBlock('message/delete');
     }
     $tpl->SetBlock('message/back');
     $tpl->SetVariable('back_url', $this->gadget->urlMap('Messages'));
     $tpl->SetVariable('icon_back', 'gadgets/PrivateMessage/Resources/images/back-mini.png');
     $tpl->SetVariable('back', _t('PRIVATEMESSAGE_BACK'));
     $tpl->ParseBlock('message/back');
     $tpl->ParseBlock('message');
     return $tpl->Get();
 }
예제 #5
0
파일: Directory.php 프로젝트: Dulciane/jaws
 /**
  * Displays file properties
  *
  * @access  public
  * @return  string  HTML content
  */
 function ViewFile($file)
 {
     $tpl = $this->gadget->template->load('Directory.html');
     $tpl->SetBlock('file');
     $tpl->SetVariable('lbl_title', _t('DIRECTORY_FILE_TITLE'));
     $tpl->SetVariable('lbl_desc', _t('DIRECTORY_FILE_DESC'));
     $tpl->SetVariable('lbl_filename', _t('DIRECTORY_FILE_FILENAME'));
     $tpl->SetVariable('lbl_type', _t('DIRECTORY_FILE_TYPE'));
     $tpl->SetVariable('lbl_size', _t('DIRECTORY_FILE_SIZE'));
     $tpl->SetVariable('lbl_bytes', _t('DIRECTORY_BYTES'));
     $tpl->SetVariable('lbl_created', _t('DIRECTORY_FILE_CREATED'));
     $tpl->SetVariable('lbl_modified', _t('DIRECTORY_FILE_MODIFIED'));
     $tpl->SetVariable('lbl_download', _t('DIRECTORY_DOWNLOAD'));
     $objDate = Jaws_Date::getInstance();
     $file['created'] = $objDate->Format($file['createtime'], 'n/j/Y g:i a');
     $file['modified'] = $objDate->Format($file['updatetime'], 'n/j/Y g:i a');
     $file['type'] = empty($file['filetype']) ? '-' : $file['filetype'];
     $file['size'] = Jaws_Utils::FormatSize($file['filesize']);
     $file['download'] = $this->gadget->urlMap('Download', array('id' => $file['id']));
     foreach ($file as $key => $value) {
         $tpl->SetVariable($key, $value);
     }
     // display tags
     if (Jaws_Gadget::IsGadgetInstalled('Tags')) {
         $tagsHTML = Jaws_Gadget::getInstance('Tags')->action->load('Tags');
         $tagsHTML->loadReferenceTags('Directory', 'file', $file['id'], $tpl, 'file');
     }
     // display file
     $fileInfo = pathinfo($file['host_filename']);
     if (isset($fileInfo['extension'])) {
         $ext = $fileInfo['extension'];
         $type = '';
         if ($ext === 'txt') {
             $type = 'text';
         } else {
             if (in_array($ext, array('jpg', 'jpeg', 'png', 'gif', 'svg'))) {
                 $type = 'image';
             } else {
                 if (in_array($ext, array('wav', 'mp3'))) {
                     $type = 'audio';
                 } else {
                     if (in_array($ext, array('webm', 'mp4', 'ogg'))) {
                         $type = 'video';
                     }
                 }
             }
         }
         if ($type != '') {
             $tpl->SetVariable('preview', $this->PlayMedia($file, $type));
         }
     }
     // display comments/comment-form
     if (Jaws_Gadget::IsGadgetInstalled('Comments')) {
         $allow_comments = $this->gadget->registry->fetch('allow_comments', 'Comments');
         $cHTML = Jaws_Gadget::getInstance('Comments')->action->load('Comments');
         $tpl->SetVariable('comments', $cHTML->ShowComments('Directory', 'File', $file['id'], array('action' => 'Directory', 'params' => array('id' => $file['id']))));
         if ($allow_comments == 'true') {
             $redirect_to = $this->gadget->urlMap('Directory', array('id' => $file['id']));
             $tpl->SetVariable('comment-form', $cHTML->ShowCommentsForm('Directory', 'File', $file['id'], $redirect_to));
         } elseif ($allow_comments == 'restricted') {
             $login_url = $GLOBALS['app']->Map->GetURLFor('Users', 'LoginBox');
             $register_url = $GLOBALS['app']->Map->GetURLFor('Users', 'Registration');
             $tpl->SetVariable('comment-form', _t('COMMENTS_COMMENTS_RESTRICTED', $login_url, $register_url));
         }
     }
     // Show like rating
     if (Jaws_Gadget::IsGadgetInstalled('Rating')) {
         $ratingHTML = Jaws_Gadget::getInstance('Rating')->action->load('RatingTypes');
         $ratingHTML->loadReferenceLike('Directory', 'File', $file['id'], 0, $tpl, 'file');
     }
     $tpl->ParseBlock('file');
     return $tpl->Get();
 }
예제 #6
0
파일: Files.php 프로젝트: Dulciane/jaws
 /**
  * Get file properties
  *
  * @access  public
  * @param   string  $path   Where to read
  * @param   string  $fname
  * @return  array   A list of properties of file
  */
 function GetFileProperties($path, $fname)
 {
     static $root_dir;
     if (!isset($root_dir)) {
         $root_dir = trim($this->gadget->registry->fetch('root_dir'));
     }
     $file = array();
     $file['filename'] = $fname;
     $file['is_dir'] = false;
     //Get url
     if ($path == '/') {
         $path = '';
     }
     $url = $GLOBALS['app']->getDataURL(str_replace('//', '/', $root_dir . '/' . $path . '/' . $fname), false);
     $file['url'] = $url;
     $file['relative'] = str_replace('//', '/', $path . '/' . $fname);
     //Get the extension
     //require 'MIME/Type.php';
     //var_dump(MIME_Type::autoDetect($filepath));
     $ext = strtolower(strrev(substr(strrev($fname), 0, strpos(strrev($fname), '.'))));
     //Get the icon
     $theme = $GLOBALS['app']->GetTheme();
     $iconName = $this->getExtImage($ext);
     $image_path = $theme['path'] . 'FileBrowser/';
     $image_url = $theme['url'] . 'FileBrowser/';
     if (is_file($image_path . $iconName)) {
         $file['icon'] = $image_url . $iconName;
     } else {
         //Is icon does not exists..
         if (!is_file(JAWS_PATH . 'images/' . $iconName)) {
             $icon = 'images/mimetypes/text-generic.png';
         } else {
             $icon = 'images/' . $iconName;
         }
         $file['icon'] = $icon;
     }
     //Set the extension
     $file['ext'] = $ext;
     //Fullpath
     $filepath = $this->GetFileBrowserRootDir() . $path . '/' . $fname;
     $file['fullpath'] = $filepath;
     //Set the icon
     $file['mini_icon'] = 'gadgets/FileBrowser/Resources/images/mini_file.png';
     //Get $date
     $file['date'] = @filemtime($filepath);
     //Set the file size
     $file['size'] = Jaws_Utils::FormatSize(@filesize($filepath));
     //Set the curr dir name
     $file['dirname'] = $path;
     $dbFile = $this->DBFileInfo($path, $fname);
     if (Jaws_Error::IsError($dbFile) || empty($dbFile)) {
         $file['id'] = 0;
         $file['title'] = $fname;
         $file['description'] = '';
         $file['fast_url'] = '';
         $file['hits'] = '';
     } else {
         $file['id'] = $dbFile['id'];
         $file['title'] = $dbFile['title'];
         $file['description'] = $dbFile['description'];
         $file['fast_url'] = $dbFile['fast_url'];
         $file['hits'] = $dbFile['hits'];
     }
     return $file;
 }