changed: in plugin 'menu'

menu_dir_tab ezc functions can be nested now
         (not finished yet)
added:   'meta' winix function
         additional meta information for files and directories
         (not finished yet)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@775 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2011-11-25 04:51:55 +00:00
parent 1e9ab2f805
commit 7902389ef1
41 changed files with 2461 additions and 1863 deletions

View File

@@ -1,23 +1,27 @@
# 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/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 ../core/mount.h
db.o: ../templates/locale.h ../core/confparser.h ../core/log.h ../core/misc.h
db.o: ../core/misc.h ../core/item.h ../core/confparser.h
db.o: ../core/requesttypes.h ../core/error.h dbitemquery.h ../core/item.h
db.o: dbitemcolumns.h ../core/confparser.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/error.h ../core/config.h
db.o: ../core/htmlfilter.h ../templates/htmltextstream.h ../core/session.h
db.o: ../core/user.h ../core/plugindata.h ../core/rebus.h ../core/mount.h
db.o: ../templates/locale.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/requesttypes.h
dbbase.o: ../core/error.h ../core/log.h ../core/misc.h ../../ezc/src/utf8.h
dbbase.o: ../core/misc.h ../core/item.h ../core/confparser.h
dbbase.o: ../core/requesttypes.h ../core/error.h ../core/log.h ../core/misc.h
dbbase.o: ../../ezc/src/utf8.h
dbconn.o: dbconn.h dbtextstream.h ../core/textstream.h ../core/misc.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/requesttypes.h ../core/error.h
dbconn.o: ../core/item.h ../core/confparser.h ../core/requesttypes.h
dbconn.o: ../core/log.h ../core/error.h
dbitemcolumns.o: dbitemcolumns.h ../core/item.h ../core/confparser.h dbbase.h
dbitemcolumns.o: dbconn.h dbtextstream.h ../core/textstream.h ../core/misc.h
dbitemcolumns.o: ../core/item.h ../core/confparser.h ../core/requesttypes.h
dbitemcolumns.o: ../core/error.h ../core/log.h
dbitemquery.o: dbitemquery.h ../core/item.h
dbtextstream.o: dbtextstream.h ../core/textstream.h ../core/misc.h
dbtextstream.o: ../core/item.h ../core/requesttypes.h ../../ezc/src/utf8.h
dbtextstream.o: ../core/item.h ../core/confparser.h ../core/requesttypes.h
dbtextstream.o: ../../ezc/src/utf8.h

View File

@@ -678,6 +678,7 @@ void Db::GetItemsQuerySelect(const DbItemQuery & iq, DbTextStream & query, bool
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");
if( iq.sel_meta ) query << R(", meta");
}
query << R(" from core.item");
@@ -811,16 +812,18 @@ void Db::GetItems(std::vector<Item> & item_tab, const DbItemQuery & item_query)
r = GetItemsQuery(item_query);
AssertResult(r, PGRES_TUPLES_OK);
Item item;
get_item_temp.Clear();
int rows = Rows(r);
DbItemColumns col;
col.SetColumns(r);
if( rows > 0 && size_t(rows) > item_tab.capacity() )
item_tab.reserve(rows);
item_cols.SetColumns(r);
for(int i = 0 ; i<rows ; ++i)
for(int i=0 ; i<rows ; ++i)
{
col.SetItem(r, i, item);
item_tab.push_back(item);
item_tab.push_back(get_item_temp);
item_cols.SetItem(r, i, item_tab.back());
}
}
catch(const Error &)
@@ -874,9 +877,8 @@ Error Db::GetItem(Item & item, const DbItemQuery & item_query)
if( rows == 1 )
{
DbItemColumns col;
col.SetColumns(r);
col.SetItem(r, 0, item);
item_cols.SetColumns(r);
item_cols.SetItem(r, 0, item);
}
else
if( rows == 0 )
@@ -957,9 +959,8 @@ Error Db::GetItem(long parent_id, const std::wstring & url, Item & item)
if( Rows(r) == 0 )
throw Error(WINIX_ERR_NO_ITEM);
DbItemColumns col;
col.SetColumns(r);
col.SetItem(r, 0, item);
item_cols.SetColumns(r);
item_cols.SetItem(r, 0, item);
}
catch(const Error & e)
{
@@ -991,9 +992,8 @@ Error Db::GetItemById(long item_id, Item & item)
if( Rows(r) == 0 )
throw Error(WINIX_ERR_NO_ITEM);
DbItemColumns col;
col.SetColumns(r);
col.SetItem(r, 0, item);
item_cols.SetColumns(r);
item_cols.SetItem(r, 0, item);
}
catch(const Error & e)
{
@@ -1076,9 +1076,8 @@ bool result = false;
if( Rows(r) != 1 )
throw Error();
DbItemColumns col;
col.SetColumns(r);
col.SetItem(r, 0, item);
item_cols.SetColumns(r);
item_cols.SetItem(r, 0, item);
result = true;
}
@@ -1238,6 +1237,23 @@ return EndTrans(result);
Error Db::EditMetaById(const Space & meta, long id)
{
meta_stream.Clear();
meta.Serialize(meta_stream);
query.Clear();
query << R("update core.item set (meta) = (")
<< meta_stream.Str()
<< R(") where id=")
<< id
<< R(";");
meta_stream.Clear();
return DoCommand(query);
}
@@ -1466,13 +1482,11 @@ void Db::GetDirs(DirContainer & dir_tab)
dir_temp.Clear();
int rows = Rows(r);
item_cols.SetColumns(r);
DbItemColumns col;
col.SetColumns(r);
for(int i = 0 ; i<rows ; ++i)
for(int i=0 ; i<rows ; ++i)
{
col.SetItem(r, i, dir_temp);
item_cols.SetItem(r, i, dir_temp);
dir_tab.PushBack(dir_temp);
}
}

View File

@@ -57,10 +57,11 @@ public:
Error GetItem(Item & item, const DbItemQuery & item_query);
bool GetPriv(Item & item, long id);
Error EditPrivById(Item & item, long id);
Error EditPrivById(Item & item, long id); // !! dlaczego tu nie ma const?
Error EditParentUrlById(Item & item, long id);
Error EditFileById(const Item & item, long id); // file_path, file_fs, file_type
Error EditHasThumbById(bool has_thumb, long id);
Error EditMetaById(const Space & meta, long id);
Error DelDirById(long id);
Error DelFileById(long file_id);
@@ -96,7 +97,11 @@ protected:
DbTextStream query, query_create_url;
std::wstring temp_url;
Item dir_temp;
Item get_item_temp;
std::wstring iq_id_list;
DbItemColumns item_cols;
TextStream<std::wstring> meta_stream;
bool AddItemCreateUrlSubject(Item & item);

View File

@@ -9,6 +9,7 @@
#include "dbitemcolumns.h"
#include "dbbase.h"
#include "core/log.h"
@@ -43,6 +44,28 @@ void DbItemColumns::SetColumns(PGresult * r)
ref = PQfnumber(r, "ref");
modify_index = PQfnumber(r, "modify_index");
sort_index = PQfnumber(r, "sort_index");
meta = PQfnumber(r, "meta");
}
void DbItemColumns::SetMeta(PGresult * r, long row, Item & item)
{
DbBase::AssertValueWide(r, row, meta, meta_str);
item.meta.Clear();
conf_parser.SetSpace(item.meta);
conf_parser.UTF8(true); // from the db we always have UTF-8 string
conf_parser.SplitSingle(true);
if( conf_parser.ParseString(meta_str) != ConfParser::ok )
{
log << log1 << "Db: syntax error when parsing meta information for"
<< " item id: " << item.id
<< ", url: " << item.url
<< ", line: " << conf_parser.line << logend;
}
meta_str.clear();
}
@@ -79,6 +102,8 @@ void DbItemColumns::SetItem(PGresult * r, long row, Item & item)
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);
if( meta != -1 ) SetMeta(r, row, item);
}

View File

@@ -13,6 +13,7 @@
#include <libpq-fe.h>
#include "core/item.h"
#include "core/confparser.h"
@@ -47,9 +48,22 @@ struct DbItemColumns
int ref;
int modify_index;
int sort_index;
int meta;
void SetColumns(PGresult * r);
void SetItem(PGresult * r, long row, Item & item);
private:
// for parsing meta information
ConfParser conf_parser;
// meta string
std::wstring meta_str;
void SetMeta(PGresult * r, long row, Item & item);
};

View File

@@ -57,6 +57,7 @@ void DbItemQuery::SetAllSel(bool sel)
sel_file = sel;
sel_html_template = sel;
sel_sort_index = sel;
sel_meta = sel;
}

View File

@@ -33,6 +33,7 @@ struct DbItemQuery
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 sel_meta; // meta Space
bool where_id; //
bool where_parent_id; //