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:
@@ -1,23 +1,23 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
db.o: db.h dbbase.h dbconn.h dbtextstream.h ../core/textstream.h
|
||||
db.o: ../core/misc.h ../core/item.h ../core/error.h dbitemquery.h
|
||||
db.o: ../core/item.h dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
db.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/log.h
|
||||
db.o: ../core/textstream.h ../core/logmanipulators.h ../core/slog.h
|
||||
db.o: ../core/cur.h ../core/request.h ../core/requesttypes.h ../core/error.h
|
||||
db.o: ../core/misc.h ../core/item.h ../core/requesttypes.h ../core/error.h
|
||||
db.o: dbitemquery.h ../core/item.h dbitemcolumns.h ../core/user.h
|
||||
db.o: ../core/group.h ../core/dircontainer.h ../core/ugcontainer.h
|
||||
db.o: ../core/log.h ../core/textstream.h ../core/logmanipulators.h
|
||||
db.o: ../core/slog.h ../core/cur.h ../core/request.h ../core/error.h
|
||||
db.o: ../core/config.h ../core/confparser.h ../core/htmlfilter.h
|
||||
db.o: ../templates/htmltextstream.h ../core/session.h ../core/user.h
|
||||
db.o: ../core/plugindata.h ../core/rebus.h ../templates/locale.h
|
||||
db.o: ../core/confparser.h ../core/log.h ../core/misc.h
|
||||
db.o: ../core/plugindata.h ../core/rebus.h ../core/mount.h
|
||||
db.o: ../templates/locale.h ../core/confparser.h ../core/log.h ../core/misc.h
|
||||
dbbase.o: dbbase.h dbconn.h dbtextstream.h ../core/textstream.h
|
||||
dbbase.o: ../core/misc.h ../core/item.h ../core/error.h ../core/log.h
|
||||
dbbase.o: ../core/misc.h ../../ezc/src/utf8.h
|
||||
dbbase.o: ../core/misc.h ../core/item.h ../core/requesttypes.h
|
||||
dbbase.o: ../core/error.h ../core/log.h ../core/misc.h ../../ezc/src/utf8.h
|
||||
dbconn.o: dbconn.h dbtextstream.h ../core/textstream.h ../core/misc.h
|
||||
dbconn.o: ../core/item.h ../core/log.h ../core/error.h
|
||||
dbconn.o: ../core/item.h ../core/requesttypes.h ../core/log.h ../core/error.h
|
||||
dbitemcolumns.o: dbitemcolumns.h ../core/item.h dbbase.h dbconn.h
|
||||
dbitemcolumns.o: dbtextstream.h ../core/textstream.h ../core/misc.h
|
||||
dbitemcolumns.o: ../core/item.h ../core/error.h
|
||||
dbitemcolumns.o: ../core/item.h ../core/requesttypes.h ../core/error.h
|
||||
dbitemquery.o: dbitemquery.h ../core/item.h
|
||||
dbtextstream.o: dbtextstream.h ../core/textstream.h ../core/misc.h
|
||||
dbtextstream.o: ../core/item.h ../../ezc/src/utf8.h
|
||||
dbtextstream.o: ../core/item.h ../core/requesttypes.h ../../ezc/src/utf8.h
|
||||
|
||||
107
db/db.cpp
107
db/db.cpp
@@ -195,7 +195,7 @@ Error Db::AddItemIntoItem(Item & item)
|
||||
query.Clear();
|
||||
query << R("insert into core.item (user_id, modification_user_id, group_id, privileges, "
|
||||
"date_creation, date_modification, type, parent_id, content_id, "
|
||||
"link_to, link_redirect, subject, guest_name, template, url) values (")
|
||||
"link_to, link_redirect, subject, guest_name, template, sort_index, url) values (")
|
||||
<< item.user_id
|
||||
<< item.modification_user_id
|
||||
<< item.group_id
|
||||
@@ -209,7 +209,8 @@ Error Db::AddItemIntoItem(Item & item)
|
||||
<< item.link_redirect
|
||||
<< item.subject
|
||||
<< item.guest_name
|
||||
<< item.html_template;
|
||||
<< item.html_template
|
||||
<< item.sort_index;
|
||||
|
||||
url_without_id = AddItemCreateUrlSubject(item);
|
||||
|
||||
@@ -250,13 +251,16 @@ Error Db::AddItemIntoContent(Item & item)
|
||||
{
|
||||
query.Clear();
|
||||
query << R("insert into core.content (content, content_type, file_path, file_fs, "
|
||||
"file_type, has_thumb, ref, modify_index) values (")
|
||||
"file_type, has_thumb, hash, hash_type, file_size, ref, modify_index) values (")
|
||||
<< item.content
|
||||
<< static_cast<int>(item.content_type)
|
||||
<< item.file_path
|
||||
<< item.file_fs
|
||||
<< item.file_type
|
||||
<< static_cast<int>(item.has_thumb)
|
||||
<< item.hash
|
||||
<< item.hash_type
|
||||
<< item.file_size
|
||||
<< first_ref
|
||||
<< item.modify_index
|
||||
<< R(");");
|
||||
@@ -348,7 +352,7 @@ Error Db::EditItemInItem(Item & item, bool with_url)
|
||||
query.Clear();
|
||||
query << R("update core.item set (user_id, modification_user_id, group_id, privileges, "
|
||||
"date_creation, date_modification, type, link_to, link_redirect, parent_id, subject, "
|
||||
"guest_name, template");
|
||||
"guest_name, template, sort_index");
|
||||
|
||||
if( with_url )
|
||||
query << R(", url");
|
||||
@@ -366,7 +370,8 @@ Error Db::EditItemInItem(Item & item, bool with_url)
|
||||
<< item.parent_id
|
||||
<< item.subject
|
||||
<< item.guest_name
|
||||
<< item.html_template;
|
||||
<< item.html_template
|
||||
<< item.sort_index;
|
||||
|
||||
if( with_url )
|
||||
{
|
||||
@@ -408,13 +413,16 @@ Error Db::EditItemInContent(Item & item)
|
||||
// we don't change 'ref' here
|
||||
query.Clear();
|
||||
query << R("update core.content set (content, content_type, file_path, file_fs, "
|
||||
"file_type, has_thumb, modify_index) = (")
|
||||
"file_type, has_thumb, hash, hash_type, file_size, modify_index) = (")
|
||||
<< item.content
|
||||
<< static_cast<int>(item.content_type)
|
||||
<< item.file_path
|
||||
<< item.file_fs
|
||||
<< item.file_type
|
||||
<< static_cast<int>(item.has_thumb)
|
||||
<< item.hash
|
||||
<< item.hash_type
|
||||
<< item.file_size
|
||||
<< item.modify_index
|
||||
<< R(") where id=")
|
||||
<< item.content_id
|
||||
@@ -611,9 +619,22 @@ return result;
|
||||
|
||||
|
||||
|
||||
PGresult * Db::GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel)
|
||||
Error Db::EditSortIndexItemById(long id, int sort_index)
|
||||
{
|
||||
query.Clear();
|
||||
query << R("update core.item set (sort_index) = (")
|
||||
<< sort_index
|
||||
<< R(") where id=")
|
||||
<< id
|
||||
<< R(";");
|
||||
|
||||
return DoCommand(query);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PGresult * Db::GetItemsQuerySelect(const DbItemQuery & iq, DbTextStream & query, bool skip_other_sel)
|
||||
{
|
||||
query << R("select item.id, content_id");
|
||||
|
||||
if( !skip_other_sel )
|
||||
@@ -629,15 +650,25 @@ PGresult * Db::GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel)
|
||||
if( iq.sel_url ) query << R(", url");
|
||||
if( iq.sel_type ) query << R(", type");
|
||||
if( iq.sel_link ) query << R(", link_to, link_redirect");
|
||||
if( iq.sel_file ) query << R(", file_path, file_fs, file_type, has_thumb");
|
||||
if( iq.sel_file ) query << R(", file_path, file_fs, file_type, has_thumb, hash, hash_type, file_size");
|
||||
if( iq.sel_html_template ) query << R(", template");
|
||||
if( iq.sel_sort_index ) query << R(", sort_index");
|
||||
}
|
||||
|
||||
query << R(" from core.item");
|
||||
|
||||
}
|
||||
|
||||
|
||||
PGresult * Db::GetItemsQueryJoin(const DbItemQuery & iq, DbTextStream & query)
|
||||
{
|
||||
if( iq.sel_content || iq.sel_file || iq.where_file_type )
|
||||
query << R(" left join core.content on item.content_id = content.id");
|
||||
}
|
||||
|
||||
|
||||
|
||||
PGresult * Db::GetItemsQueryWhere(const DbItemQuery & iq, DbTextStream & query)
|
||||
{
|
||||
if( iq.where_id || iq.where_parent_id || iq.where_type || iq.where_file_type )
|
||||
{
|
||||
query << R(" where ");
|
||||
@@ -682,19 +713,53 @@ PGresult * Db::GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel)
|
||||
if_and = add_and;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query << R(" order by item.date_creation");
|
||||
|
||||
if( iq.sort_asc )
|
||||
query << R(" asc");
|
||||
else
|
||||
query << R(" desc");
|
||||
|
||||
PGresult * Db::GetItemsQueryOrder(const DbItemQuery & iq, DbTextStream & query)
|
||||
{
|
||||
if( iq.sel_sort_index || iq.sel_date )
|
||||
{
|
||||
query << R(" order by");
|
||||
|
||||
if( iq.sel_sort_index )
|
||||
query << R(" sort_index");
|
||||
|
||||
if( iq.sel_date )
|
||||
{
|
||||
if( iq.sel_sort_index )
|
||||
query << R(",");
|
||||
|
||||
query << R(" item.date_creation");
|
||||
}
|
||||
|
||||
if( iq.sort_asc )
|
||||
query << R(" asc");
|
||||
else
|
||||
query << R(" desc");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PGresult * Db::GetItemsQueryLimit(const DbItemQuery & iq, DbTextStream & query)
|
||||
{
|
||||
if( iq.limit != 0 )
|
||||
query << R(" limit ") << iq.limit;
|
||||
|
||||
if( iq.offset != 0 )
|
||||
query << R(" offset ") << iq.offset;
|
||||
}
|
||||
|
||||
|
||||
PGresult * Db::GetItemsQuery(const DbItemQuery & iq, DbTextStream & query, bool skip_other_sel)
|
||||
{
|
||||
query.Clear();
|
||||
|
||||
GetItemsQuerySelect(iq, query, skip_other_sel);
|
||||
GetItemsQueryJoin(iq, query);
|
||||
GetItemsQueryWhere(iq, query);
|
||||
GetItemsQueryOrder(iq, query);
|
||||
GetItemsQueryLimit(iq, query);
|
||||
|
||||
query << R(";");
|
||||
|
||||
@@ -703,6 +768,13 @@ return AssertQuery(query);
|
||||
|
||||
|
||||
|
||||
PGresult * Db::GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel)
|
||||
{
|
||||
return GetItemsQuery(iq, query, skip_other_sel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Db::GetItems(std::vector<Item> & item_tab, const DbItemQuery & item_query)
|
||||
{
|
||||
@@ -1082,11 +1154,14 @@ Error Db::EditFileById(const Item & item, long id)
|
||||
throw Error(WINIX_ERR_NO_ITEM);
|
||||
|
||||
query.Clear();
|
||||
query << R("update core.content set (file_path, file_fs, file_type, has_thumb) = (")
|
||||
query << R("update core.content set (file_path, file_fs, file_type, has_thumb, hash, hash_type, file_size) = (")
|
||||
<< item.file_path
|
||||
<< item.file_fs
|
||||
<< item.file_type
|
||||
<< static_cast<int>(item.has_thumb)
|
||||
<< item.hash
|
||||
<< item.hash_type
|
||||
<< item.file_size
|
||||
<< R(") where id=") << content_id << R(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
|
||||
12
db/db.h
12
db/db.h
@@ -86,7 +86,7 @@ public:
|
||||
long GetDirId(long parent_id, const std::wstring & url);
|
||||
|
||||
Error AddHardLink(Item & item);
|
||||
|
||||
Error EditSortIndexItemById(long id, int sort_index);
|
||||
|
||||
|
||||
|
||||
@@ -107,13 +107,21 @@ protected:
|
||||
Error EditItemGetIdsByUrl(Item & item);
|
||||
long GetContentId(long item_id);
|
||||
|
||||
PGresult * GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel = false);
|
||||
|
||||
Error DelItemDelItem(long item_id, int type);
|
||||
Error DelItemDelContent(long content_id);
|
||||
|
||||
Error IncrementContentRef(long content_id);
|
||||
Error DecrementContentRef(long content_id);
|
||||
|
||||
PGresult * GetItemsQuerySelect(const DbItemQuery & iq, DbTextStream & query, bool skip_other_sel);
|
||||
PGresult * GetItemsQueryJoin(const DbItemQuery & iq, DbTextStream & query);
|
||||
PGresult * GetItemsQueryWhere(const DbItemQuery & iq, DbTextStream & query);
|
||||
PGresult * GetItemsQueryOrder(const DbItemQuery & iq, DbTextStream & query);
|
||||
PGresult * GetItemsQueryLimit(const DbItemQuery & iq, DbTextStream & query);
|
||||
PGresult * GetItemsQuery(const DbItemQuery & iq, DbTextStream & query, bool skip_other_sel = false);
|
||||
PGresult * GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel = false);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
*/
|
||||
@@ -37,8 +37,12 @@ void DbItemColumns::SetColumns(PGresult * r)
|
||||
file_fs = PQfnumber(r, "file_fs");
|
||||
file_type = PQfnumber(r, "file_type");
|
||||
has_thumb = PQfnumber(r, "has_thumb");
|
||||
hash = PQfnumber(r, "hash");
|
||||
hash_type = PQfnumber(r, "hash_type");
|
||||
file_size = PQfnumber(r, "file_size");
|
||||
ref = PQfnumber(r, "ref");
|
||||
modify_index = PQfnumber(r, "modify_index");
|
||||
sort_index = PQfnumber(r, "sort_index");
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +64,10 @@ void DbItemColumns::SetItem(PGresult * r, long row, Item & item)
|
||||
if( file_fs != -1 ) item.file_fs = DbBase::AssertValueInt(r, row, file_fs);
|
||||
if( file_type != -1 ) item.file_type = DbBase::AssertValueInt(r, row, file_type);
|
||||
if( has_thumb != -1 ) item.has_thumb = DbBase::AssertValueBool(r, row, has_thumb);
|
||||
if( hash != -1 ) DbBase::AssertValueWide(r, row, hash, item.hash);
|
||||
if( hash_type != -1 ) item.hash_type = DbBase::AssertValueInt(r, row, hash_type);
|
||||
if( file_size != -1 ) item.file_size = DbBase::AssertValueLong(r, row, file_size);
|
||||
|
||||
if( ref != -1 ) item.ref = DbBase::AssertValueInt(r, row, ref);
|
||||
if( modify_index != -1 ) item.modify_index = DbBase::AssertValueInt(r, row, modify_index);
|
||||
|
||||
@@ -70,6 +78,7 @@ void DbItemColumns::SetItem(PGresult * r, long row, Item & item)
|
||||
if( link_to != -1 ) DbBase::AssertValueWide(r, row, link_to, item.link_to);
|
||||
if( guest_name != -1 ) DbBase::AssertValueWide(r, row, guest_name, item.guest_name);
|
||||
if( html_template != -1 ) DbBase::AssertValueWide(r, row, html_template, item.html_template);
|
||||
if( sort_index != -1 ) item.sort_index = DbBase::AssertValueInt(r, row, sort_index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
*/
|
||||
@@ -41,8 +41,12 @@ struct DbItemColumns
|
||||
int file_fs;
|
||||
int file_type;
|
||||
int has_thumb;
|
||||
int hash;
|
||||
int hash_type;
|
||||
int file_size;
|
||||
int ref;
|
||||
int modify_index;
|
||||
int sort_index;
|
||||
|
||||
void SetColumns(PGresult * r);
|
||||
void SetItem(PGresult * r, long row, Item & item);
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
*/
|
||||
@@ -56,6 +56,7 @@ void DbItemQuery::SetAllSel(bool sel)
|
||||
sel_link = sel;
|
||||
sel_file = sel;
|
||||
sel_html_template = sel;
|
||||
sel_sort_index = sel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
*/
|
||||
@@ -30,8 +30,9 @@ struct DbItemQuery
|
||||
bool sel_url; // url
|
||||
bool sel_type; // type (dir, file, none)
|
||||
bool sel_link; // link_to, link_redirect
|
||||
bool sel_file; // file_path, file_fs, file_type, has_thumb
|
||||
bool sel_file; // file_path, file_fs, file_type, has_thumb, hash, hash_type, file_size
|
||||
bool sel_html_template; // template
|
||||
bool sel_sort_index; // sort_index
|
||||
|
||||
bool where_id; //
|
||||
bool where_parent_id; //
|
||||
|
||||
Reference in New Issue
Block a user