changed: winix 'upload' function is a file manager now

we're using an jquery upload plugin
added:   Item struct has new rows: hash, hash_type, file_size, sort_index
added:   css mount parameter
         you can specify css files there, and javascript wysiwyg editors
         (ckeditor, tinymce) can make use of it
changed: post parsers can parse post variables with the same name
         (a postfix is added in such a case)
added:   common_dir parameter to the config
         this is a path to common directory (directory with common static files)
         it is needed to the 'css' mount parameter
         


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@746 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2011-06-24 20:53:21 +00:00
parent 1d6ff73aad
commit 06f42dd9cb
58 changed files with 2462 additions and 1685 deletions

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
@@ -14,6 +14,7 @@
#include "upload.h"
#include "core/misc.h"
#include "functions/functions.h"
#include "templates/templates.h"
#include "utf8.h"
@@ -28,7 +29,6 @@ Upload::Upload()
bool Upload::HasAccess(const Item & item)
{
// you can use 'upload' only in a directory
@@ -97,7 +97,7 @@ void Upload::CreateThumb(Item & item)
int mode = config->thumb_mode;
int index;
// reading width and height from then mount point (if exists)
// reading width and height from the mount point (if exists)
index = system->mounts.MountParThumbSize();
if( m.param[index].defined && m.param[index].arg.size() == 2 )
@@ -112,7 +112,7 @@ void Upload::CreateThumb(Item & item)
if( cy > 2000 )
cy = 2000;
// reading thumb mode from then mount point (if exists)
// reading thumb mode from the mount point (if exists)
index = system->mounts.MountParThumbMode();
if( m.param[index].defined && m.param[index].arg.size() == 1 )
@@ -138,6 +138,9 @@ void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
if( item.file_type == WINIX_ITEM_FILETYPE_IMAGE && config->create_thumb )
CreateThumb(item);
if( is_jquery_upload )
cur->request->item_tab.push_back(item);
}
else
{
@@ -189,12 +192,17 @@ void Upload::UploadMulti()
cur->request->item.subject = file_name;
cur->request->item.url = file_name;
cur->request->item.file_type = SelectFileType(file_name);
cur->request->item.file_size = i->second.file_size;
functions->PrepareUrl(cur->request->item);
UploadFile(cur->request->item, i->second.tmp_filename);
i->second.tmp_filename.clear();
}
system->RedirectToLastDir();
if( is_jquery_upload )
CreateJSON();
else
system->RedirectToLastDir();
}
@@ -209,8 +217,11 @@ void Upload::UploadSingle()
functions->SetUser(cur->request->item);
cur->request->item.privileges = 0644; // !! tymczasowo
const wchar_t * file_name = cur->request->post_file_tab.begin()->second.filename.c_str();
PostFile & post_file = cur->request->post_file_tab.begin()->second;
const wchar_t * file_name = post_file.filename.c_str();
cur->request->item.file_type = SelectFileType(file_name);
cur->request->item.file_size = post_file.file_size;
if( !has_subject )
cur->request->item.subject = file_name;
@@ -221,17 +232,24 @@ void Upload::UploadSingle()
functions->PrepareUrl(cur->request->item);
}
UploadFile(cur->request->item, cur->request->post_file_tab.begin()->second.tmp_filename);
UploadFile(cur->request->item, post_file.tmp_filename);
post_file.tmp_filename.clear();
if( is_jquery_upload )
CreateJSON();
else
if( cur->request->status == WINIX_ERR_OK )
system->RedirectTo(cur->request->item, L"/cat");
}
// !! dodac usuwanie plikow statycznych przez rm
void Upload::MakePost()
{
cur->request->item_tab.clear();
is_jquery_upload = cur->request->IsParam(L"jquery_upload");
if( cur->request->post_file_tab.empty() )
{
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
@@ -249,6 +267,39 @@ void Upload::MakePost()
void Upload::CreateJSON()
{
// !! locale beda w zaleznosci od uzytkownika
size_t loc = TemplatesFunctions::locale.GetLang();
size_t idu = static_cast<size_t>(id);
TemplatesFunctions::Patterns & patfun = TemplatesFunctions::patterns_fun;
if( loc < patfun.size() && idu < patfun[loc].size() )
{
templates->Generate(patfun[loc][idu]);
cur->request->page_generated = true;
cur->request->use_html_filter = false;
}
// !! usunac
//log << log1 << cur->request->page.Str() << logend;
}
void Upload::MakeGet()
{
if( cur->request->IsParam(L"jquery_upload") )
{
query.Clear();
query.WhereParentId(cur->request->dir_tab.back()->id);
query.WhereType(Item::file);
query.WhereFileType(WINIX_ITEM_FILETYPE_NONE, false);
db->GetItems(cur->request->item_tab, query);
CreateJSON();
}
}
} // namespace