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:
File diff suppressed because it is too large
Load Diff
@@ -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.
|
||||
*
|
||||
*/
|
||||
@@ -20,6 +20,11 @@ Ckeditor::Ckeditor()
|
||||
fun.url = L"ckeditor";
|
||||
}
|
||||
|
||||
void Ckeditor::Init()
|
||||
{
|
||||
system->AddCommonFileToVar(L"winix/ckeditor_full.js", L"ckeditor_full.js");
|
||||
system->AddCommonFileToVar(L"winix/ckeditor_winix.js", L"ckeditor_winix.js");
|
||||
}
|
||||
|
||||
bool Ckeditor::HasAccess()
|
||||
{
|
||||
@@ -27,6 +32,16 @@ bool Ckeditor::HasAccess()
|
||||
}
|
||||
|
||||
|
||||
void Ckeditor::MakeGet()
|
||||
{
|
||||
cur->session->last_css.clear();
|
||||
int parcss = system->mounts.MountParCss();
|
||||
|
||||
if( cur->mount->param[parcss].defined )
|
||||
cur->session->last_css = cur->mount->param[parcss].arg;
|
||||
}
|
||||
|
||||
|
||||
void Ckeditor::MakePost()
|
||||
{
|
||||
functions->fun_emacs.MakePost();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -23,7 +23,9 @@ class Ckeditor : public FunctionBase
|
||||
public:
|
||||
|
||||
Ckeditor();
|
||||
void Init();
|
||||
bool HasAccess();
|
||||
void MakeGet();
|
||||
void MakePost();
|
||||
|
||||
};
|
||||
|
||||
@@ -64,12 +64,17 @@ return true;
|
||||
|
||||
bool Rm::HasAccess()
|
||||
{
|
||||
if( !cur->request->is_item )
|
||||
return HasAccess(*cur->request->dir_tab.back());
|
||||
else
|
||||
return HasAccess(cur->request->item);
|
||||
bool res;
|
||||
|
||||
return true;
|
||||
if( !cur->request->is_item )
|
||||
res = HasAccess(*cur->request->dir_tab.back());
|
||||
else
|
||||
res = HasAccess(cur->request->item);
|
||||
|
||||
if( !res && cur->request->IsParam(L"jquery_upload") )
|
||||
CreateJSON(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -219,9 +224,6 @@ void Rm::RemoveDir(const Item & dir)
|
||||
void Rm::RemoveFile()
|
||||
{
|
||||
RemoveFileOrSymlink(cur->request->item);
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
system->RedirectToLastDir();
|
||||
}
|
||||
|
||||
|
||||
@@ -250,9 +252,6 @@ void Rm::RemoveDirContent()
|
||||
}
|
||||
|
||||
RemoveDirContent(*cur->request->dir_tab.back());
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
system->RedirectToLastDir();
|
||||
}
|
||||
|
||||
|
||||
@@ -268,9 +267,6 @@ void Rm::RemoveDir()
|
||||
|
||||
RemoveDir(*cur->request->dir_tab.back());
|
||||
cur->request->dir_tab.erase(--cur->request->dir_tab.end());
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
system->RedirectToLastDir();
|
||||
}
|
||||
|
||||
|
||||
@@ -284,6 +280,18 @@ void Rm::Clear()
|
||||
|
||||
|
||||
|
||||
void Rm::CreateJSON(bool status)
|
||||
{
|
||||
if( status )
|
||||
cur->request->page << "true\n";
|
||||
else
|
||||
cur->request->page << "false\n";
|
||||
|
||||
cur->request->page_generated = true;
|
||||
cur->request->use_html_filter = false;
|
||||
}
|
||||
|
||||
|
||||
void Rm::MakePost()
|
||||
{
|
||||
Prepare();
|
||||
@@ -301,6 +309,13 @@ void Rm::MakePost()
|
||||
}
|
||||
|
||||
Clear();
|
||||
|
||||
if( cur->request->IsParam(L"jquery_upload") )
|
||||
CreateJSON(true);
|
||||
else
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
system->RedirectToLastDir();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ private:
|
||||
void RemoveDirContent();
|
||||
void RemoveDir();
|
||||
void RemoveFile();
|
||||
void CreateJSON(bool status);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
*/
|
||||
@@ -21,12 +21,28 @@ Tinymce::Tinymce()
|
||||
}
|
||||
|
||||
|
||||
void Tinymce::Init()
|
||||
{
|
||||
system->AddCommonFileToVar(L"winix/tinymce.js", L"tinymce.js");
|
||||
}
|
||||
|
||||
|
||||
bool Tinymce::HasAccess()
|
||||
{
|
||||
return functions->fun_emacs.HasAccess();
|
||||
}
|
||||
|
||||
|
||||
void Tinymce::MakeGet()
|
||||
{
|
||||
cur->session->last_css.clear();
|
||||
int parcss = system->mounts.MountParCss();
|
||||
|
||||
if( cur->mount->param[parcss].defined )
|
||||
cur->session->last_css = cur->mount->param[parcss].arg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Tinymce::MakePost()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -22,7 +22,9 @@ class Tinymce : public FunctionBase
|
||||
public:
|
||||
|
||||
Tinymce();
|
||||
void Init();
|
||||
bool HasAccess();
|
||||
void MakeGet();
|
||||
void MakePost();
|
||||
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -25,12 +25,15 @@ public:
|
||||
Upload();
|
||||
bool HasAccess();
|
||||
void MakePost();
|
||||
void MakeGet();
|
||||
void UploadFile(Item & item, const std::wstring & tmp_filename);
|
||||
|
||||
private:
|
||||
|
||||
std::wstring path;
|
||||
std::string patha, path_thumba;
|
||||
DbItemQuery query;
|
||||
bool is_jquery_upload;
|
||||
|
||||
bool HasAccess(const Item & item);
|
||||
bool UploadSaveStaticFile(const Item & item, const std::wstring & tmp_filename);
|
||||
@@ -38,6 +41,7 @@ private:
|
||||
void UploadMulti();
|
||||
void UploadSingle();
|
||||
void CreateThumb(Item & item);
|
||||
void CreateJSON();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -15,41 +15,6 @@
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
// WYMeditor doesn't work on different domains by default,
|
||||
// solution: http://forum.wymeditor.org/forum/viewtopic.php?f=2&t=731&p=2507#p2504
|
||||
// we add one file to winix: /var/wymiframe.html
|
||||
// in the future this will be removed
|
||||
|
||||
|
||||
static const char vim_wymiframe[] =
|
||||
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
|
||||
"<!--\n"
|
||||
" * WYMeditor : what you see is What You Mean web-based editor\n"
|
||||
" * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/\n"
|
||||
" * Dual licensed under the MIT (MIT-license.txt)\n"
|
||||
" * and GPL (GPL-license.txt) licenses.\n"
|
||||
" *\n"
|
||||
" * For further information visit:\n"
|
||||
" * http://www.wymeditor.org/\n"
|
||||
" *\n"
|
||||
" * File Name:\n"
|
||||
" * wymiframe.html\n"
|
||||
" * Iframe used by designMode.\n"
|
||||
" * See the documentation for more info.\n"
|
||||
" *\n"
|
||||
" * File Authors:\n"
|
||||
" * Jean-Francois Hovinne (jf.hovinne a-t wymeditor dotorg)\n"
|
||||
"-->\n"
|
||||
"<html>\n"
|
||||
"<head>\n"
|
||||
"<title>WYMeditor iframe</title>\n"
|
||||
"<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7\" />\n"
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"[doc_base_url_common]/wymeditor/iframe/default/wymiframe.css\" />\n"
|
||||
"</head>\n"
|
||||
"<body class=\"wym_iframe\"></body>\n"
|
||||
"</html>\n";
|
||||
|
||||
|
||||
Vim::Vim()
|
||||
{
|
||||
fun.url = L"vim";
|
||||
@@ -58,29 +23,11 @@ Vim::Vim()
|
||||
|
||||
void Vim::Init()
|
||||
{
|
||||
Item * var = system->dirs.CreateVarDir();
|
||||
// WYMeditor doesn't work on different domains by default,
|
||||
// solution: http://forum.wymeditor.org/forum/viewtopic.php?f=2&t=731&p=2507#p2504
|
||||
// we add one file to winix: /var/wymiframe.html
|
||||
|
||||
if( var )
|
||||
{
|
||||
Item temp;
|
||||
|
||||
if( db->GetItem(var->id, L"wymiframe.html", temp) == WINIX_ERR_NO_ITEM )
|
||||
{
|
||||
Item v;
|
||||
|
||||
v.parent_id = var->id;
|
||||
v.user_id = -1;
|
||||
v.group_id = -1;
|
||||
v.privileges = 0755;
|
||||
v.subject = L"wymiframe.html";
|
||||
v.url = L"wymiframe.html";
|
||||
v.type = Item::file;
|
||||
v.content_type = Item::ct_raw;
|
||||
AssignString(vim_wymiframe, v.content);
|
||||
|
||||
system->AddFile(v, false);
|
||||
}
|
||||
}
|
||||
system->AddCommonFileToVar(L"winix/wymiframe.html", L"wymiframe.html");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user