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

107
db/db.cpp
View File

@@ -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);