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:
@@ -1,37 +1,37 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
init.o: ../../core/log.h ../../core/textstream.h ../../core/misc.h
|
||||
init.o: ../../core/item.h ../../core/requesttypes.h
|
||||
init.o: ../../core/item.h ../../core/confparser.h ../../core/requesttypes.h
|
||||
init.o: ../../core/logmanipulators.h ../../core/slog.h ../../core/cur.h
|
||||
init.o: ../../core/request.h ../../core/error.h ../../core/config.h
|
||||
init.o: ../../core/confparser.h ../../core/htmlfilter.h
|
||||
init.o: ../../templates/htmltextstream.h ../../core/textstream.h
|
||||
init.o: ../../core/session.h ../../core/user.h ../../core/plugindata.h
|
||||
init.o: ../../core/rebus.h ../../core/mount.h ../../templates/locale.h
|
||||
init.o: ../../core/confparser.h ../../core/plugin.h ../../core/pluginmsg.h
|
||||
init.o: ../../core/log.h ../../core/system.h ../../core/dirs.h
|
||||
init.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
|
||||
init.o: ../../db/dbconn.h ../../db/dbtextstream.h ../../core/error.h
|
||||
init.o: ../../db/dbitemquery.h ../../core/item.h ../../db/dbitemcolumns.h
|
||||
init.o: ../../core/user.h ../../core/group.h ../../core/dircontainer.h
|
||||
init.o: ../../core/ugcontainer.h ../../notify/notify.h
|
||||
init.o: ../../notify/notifypool.h ../../templates/patterns.h
|
||||
init.o: ../../templates/locale.h ../../templates/localefilter.h
|
||||
init.o: ../../../ezc/src/ezc.h ../../../ezc/src/utf8.h
|
||||
init.o: ../../../ezc/src/generator.h ../../../ezc/src/pattern.h
|
||||
init.o: ../../../ezc/src/functions.h ../../../ezc/src/funinfo.h
|
||||
init.o: ../../../ezc/src/stringconv.h ../../notify/notifythread.h
|
||||
init.o: ../../core/basethread.h ../../core/synchro.h
|
||||
init.o: ../../notify/templatesnotify.h ../../core/config.h ../../core/users.h
|
||||
init.o: ../../core/ugcontainer.h ../../core/lastcontainer.h
|
||||
init.o: ../../templates/misc.h ../../templates/htmltextstream.h
|
||||
init.o: ../../core/mounts.h ../../core/mountparser.h ../../core/crypt.h
|
||||
init.o: ../../core/run.h ../../core/users.h ../../core/groups.h
|
||||
init.o: ../../core/group.h ../../core/loadavg.h ../../core/image.h
|
||||
init.o: ../../core/basethread.h ../../core/threadmanager.h
|
||||
init.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h
|
||||
init.o: ../../functions/functions.h ../../functions/functionbase.h
|
||||
init.o: ../../core/request.h ../../core/system.h ../../core/synchro.h
|
||||
init.o: ../../core/htmlfilter.h ../../templates/htmltextstream.h
|
||||
init.o: ../../core/textstream.h ../../core/session.h ../../core/user.h
|
||||
init.o: ../../core/plugindata.h ../../core/rebus.h ../../core/mount.h
|
||||
init.o: ../../templates/locale.h ../../core/confparser.h ../../core/plugin.h
|
||||
init.o: ../../core/pluginmsg.h ../../core/log.h ../../core/system.h
|
||||
init.o: ../../core/dirs.h ../../core/dircontainer.h ../../db/db.h
|
||||
init.o: ../../db/dbbase.h ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
init.o: ../../core/error.h ../../db/dbitemquery.h ../../core/item.h
|
||||
init.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
init.o: ../../core/dircontainer.h ../../core/ugcontainer.h
|
||||
init.o: ../../notify/notify.h ../../notify/notifypool.h
|
||||
init.o: ../../templates/patterns.h ../../templates/locale.h
|
||||
init.o: ../../templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
init.o: ../../../ezc/src/utf8.h ../../../ezc/src/generator.h
|
||||
init.o: ../../../ezc/src/pattern.h ../../../ezc/src/functions.h
|
||||
init.o: ../../../ezc/src/funinfo.h ../../../ezc/src/stringconv.h
|
||||
init.o: ../../notify/notifythread.h ../../core/basethread.h
|
||||
init.o: ../../core/synchro.h ../../notify/templatesnotify.h
|
||||
init.o: ../../core/config.h ../../core/users.h ../../core/ugcontainer.h
|
||||
init.o: ../../core/lastcontainer.h ../../templates/misc.h
|
||||
init.o: ../../templates/htmltextstream.h ../../core/mounts.h
|
||||
init.o: ../../core/mountparser.h ../../core/crypt.h ../../core/run.h
|
||||
init.o: ../../core/users.h ../../core/groups.h ../../core/group.h
|
||||
init.o: ../../core/loadavg.h ../../core/image.h ../../core/basethread.h
|
||||
init.o: ../../core/threadmanager.h ../../core/sessionmanager.h
|
||||
init.o: ../../core/sessioncontainer.h ../../functions/functions.h
|
||||
init.o: ../../functions/functionbase.h ../../core/request.h
|
||||
init.o: ../../core/system.h ../../core/synchro.h
|
||||
init.o: ../../functions/functionparser.h ../../core/cur.h
|
||||
init.o: ../../functions/adduser.h ../../functions/cat.h
|
||||
init.o: ../../functions/chmod.h ../../functions/privchanger.h
|
||||
@@ -40,7 +40,7 @@ init.o: ../../functions/cp.h ../../functions/default.h
|
||||
init.o: ../../functions/download.h ../../functions/emacs.h
|
||||
init.o: ../../functions/last.h ../../functions/login.h
|
||||
init.o: ../../functions/logout.h ../../functions/ln.h ../../functions/ls.h
|
||||
init.o: ../../functions/mkdir.h ../../functions/mv.h
|
||||
init.o: ../../functions/meta.h ../../functions/mkdir.h ../../functions/mv.h
|
||||
init.o: ../../functions/nicedit.h ../../functions/node.h
|
||||
init.o: ../../functions/passwd.h ../../functions/priv.h
|
||||
init.o: ../../functions/reload.h ../../functions/rm.h ../../functions/sort.h
|
||||
@@ -55,32 +55,31 @@ init.o: ../../templates/changepatterns.h ../../core/sessionmanager.h
|
||||
templates.o: ../../templates/templates.h ../../../ezc/src/ezc.h
|
||||
templates.o: ../../../ezc/src/utf8.h ../../../ezc/src/generator.h
|
||||
templates.o: ../../../ezc/src/pattern.h ../../core/item.h
|
||||
templates.o: ../../../ezc/src/functions.h ../../../ezc/src/funinfo.h
|
||||
templates.o: ../../../ezc/src/stringconv.h ../../core/misc.h
|
||||
templates.o: ../../core/requesttypes.h ../../templates/patterncacher.h
|
||||
templates.o: ../../core/item.h ../../templates/indexpatterns.h
|
||||
templates.o: ../../templates/patterns.h ../../templates/locale.h
|
||||
templates.o: ../../templates/changepatterns.h
|
||||
templates.o: ../../core/confparser.h ../../../ezc/src/functions.h
|
||||
templates.o: ../../../ezc/src/funinfo.h ../../../ezc/src/stringconv.h
|
||||
templates.o: ../../core/misc.h ../../core/requesttypes.h
|
||||
templates.o: ../../templates/patterncacher.h ../../core/item.h
|
||||
templates.o: ../../templates/indexpatterns.h ../../templates/patterns.h
|
||||
templates.o: ../../templates/locale.h ../../templates/changepatterns.h
|
||||
templates.o: ../../templates/htmltextstream.h ../../templates/localefilter.h
|
||||
templates.o: ../../core/config.h ../../core/cur.h ../../core/system.h
|
||||
templates.o: ../../core/sessionmanager.h ../../core/htmlfilter.h
|
||||
templates.o: ../../db/db.h ../../db/dbbase.h ../../db/dbconn.h
|
||||
templates.o: ../../db/dbtextstream.h ../../core/textstream.h
|
||||
templates.o: ../../core/error.h ../../db/dbitemquery.h
|
||||
templates.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
templates.o: ../../core/dircontainer.h ../../core/ugcontainer.h
|
||||
templates.o: ../../core/log.h ../../core/plugin.h ../../core/pluginmsg.h
|
||||
templates.o: ../../core/plugindata.h ../../core/config.h
|
||||
templates.o: ../../core/confparser.h ../../core/htmlfilter.h
|
||||
templates.o: ../../core/request.h ../../core/error.h ../../core/textstream.h
|
||||
templates.o: ../../db/dbitemcolumns.h ../../core/confparser.h
|
||||
templates.o: ../../core/user.h ../../core/group.h ../../core/dircontainer.h
|
||||
templates.o: ../../core/ugcontainer.h ../../core/log.h ../../core/plugin.h
|
||||
templates.o: ../../core/pluginmsg.h ../../core/plugindata.h
|
||||
templates.o: ../../core/config.h ../../core/htmlfilter.h ../../core/request.h
|
||||
templates.o: ../../core/error.h ../../core/textstream.h
|
||||
templates.o: ../../templates/htmltextstream.h ../../core/system.h
|
||||
templates.o: ../../core/dirs.h ../../core/dircontainer.h
|
||||
templates.o: ../../notify/notify.h ../../notify/notifypool.h
|
||||
templates.o: ../../templates/locale.h ../../core/confparser.h
|
||||
templates.o: ../../templates/patterns.h ../../notify/notifythread.h
|
||||
templates.o: ../../core/basethread.h ../../core/synchro.h
|
||||
templates.o: ../../notify/templatesnotify.h ../../core/users.h
|
||||
templates.o: ../../core/user.h ../../core/ugcontainer.h
|
||||
templates.o: ../../templates/locale.h ../../templates/patterns.h
|
||||
templates.o: ../../notify/notifythread.h ../../core/basethread.h
|
||||
templates.o: ../../core/synchro.h ../../notify/templatesnotify.h
|
||||
templates.o: ../../core/users.h ../../core/user.h ../../core/ugcontainer.h
|
||||
templates.o: ../../core/lastcontainer.h ../../core/cur.h ../../core/session.h
|
||||
templates.o: ../../core/rebus.h ../../core/mount.h ../../templates/misc.h
|
||||
templates.o: ../../core/mounts.h ../../core/mountparser.h ../../core/crypt.h
|
||||
@@ -97,7 +96,7 @@ templates.o: ../../functions/ckeditor.h ../../functions/cp.h
|
||||
templates.o: ../../functions/default.h ../../functions/download.h
|
||||
templates.o: ../../functions/emacs.h ../../functions/last.h
|
||||
templates.o: ../../functions/login.h ../../functions/logout.h
|
||||
templates.o: ../../functions/ln.h ../../functions/ls.h
|
||||
templates.o: ../../functions/ln.h ../../functions/ls.h ../../functions/meta.h
|
||||
templates.o: ../../functions/mkdir.h ../../functions/mv.h
|
||||
templates.o: ../../functions/nicedit.h ../../functions/node.h
|
||||
templates.o: ../../functions/passwd.h ../../functions/priv.h
|
||||
|
||||
@@ -14,6 +14,74 @@
|
||||
#include "core/misc.h"
|
||||
|
||||
|
||||
// !! temporarily
|
||||
template<class Key, class Value>
|
||||
class Stack
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Key StackKey;
|
||||
typedef Value StackValue;
|
||||
|
||||
struct Item
|
||||
{
|
||||
StackKey key;
|
||||
StackValue value;
|
||||
};
|
||||
|
||||
|
||||
Stack()
|
||||
{
|
||||
added_new = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
StackValue * Get(const StackKey & key)
|
||||
{
|
||||
for(size_t i=0 ; i<tab.size() ; ++i)
|
||||
{
|
||||
if( tab[i].key == key )
|
||||
{
|
||||
added_new = false;
|
||||
return &tab[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
// there is no such an element in our table
|
||||
// so we add a new item
|
||||
tab.push_back(Item());
|
||||
|
||||
tab.back().key = key;
|
||||
added_new = true;
|
||||
|
||||
return &tab.back().value;
|
||||
}
|
||||
|
||||
/*
|
||||
returning true if Get() method has inserted a new Item
|
||||
*/
|
||||
bool AddedNew()
|
||||
{
|
||||
return added_new;
|
||||
}
|
||||
|
||||
|
||||
void Clear()
|
||||
{
|
||||
tab.clear();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::vector<Item> tab;
|
||||
bool added_new;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Menu
|
||||
{
|
||||
@@ -23,11 +91,25 @@ using TemplatesFunctions::system;
|
||||
extern int mount_par_menu_skip;
|
||||
|
||||
|
||||
static std::vector<Item> menu_dir_items;
|
||||
static size_t menu_dir_index;
|
||||
static size_t menu_dir_reqid = 0;
|
||||
static std::wstring menu_dir_last_dir;
|
||||
static DbItemQuery menu_dir_iq;
|
||||
|
||||
struct MenuDir
|
||||
{
|
||||
std::vector<Item> items;
|
||||
size_t index;
|
||||
std::wstring dir;
|
||||
|
||||
MenuDir()
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static MenuDir * menu_dir = 0;
|
||||
static DbItemQuery iq;
|
||||
static Stack<std::wstring, MenuDir> menu_dir_stack;
|
||||
static size_t req_id = 0;
|
||||
|
||||
|
||||
|
||||
// O(n^2) complexity
|
||||
@@ -42,10 +124,10 @@ void menu_dir_skip_items(long parent_id)
|
||||
|
||||
for(size_t i=0 ; i<arg.size() ; ++i)
|
||||
{
|
||||
for(size_t x=0 ; x<menu_dir_items.size() ; )
|
||||
for(size_t x=0 ; x<menu_dir->items.size() ; )
|
||||
{
|
||||
if( menu_dir_items[x].url == arg[i] )
|
||||
menu_dir_items.erase(menu_dir_items.begin() + x);
|
||||
if( menu_dir->items[x].url == arg[i] )
|
||||
menu_dir->items.erase(menu_dir->items.begin() + x);
|
||||
else
|
||||
x += 1;
|
||||
}
|
||||
@@ -55,10 +137,10 @@ void menu_dir_skip_items(long parent_id)
|
||||
|
||||
void menu_dir_skip_static_files()
|
||||
{
|
||||
for(size_t x=0 ; x<menu_dir_items.size() ; )
|
||||
for(size_t x=0 ; x<menu_dir->items.size() ; )
|
||||
{
|
||||
if( menu_dir_items[x].type == Item::file && menu_dir_items[x].file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
menu_dir_items.erase(menu_dir_items.begin() + x);
|
||||
if( menu_dir->items[x].type == Item::file && menu_dir->items[x].file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
menu_dir->items.erase(menu_dir->items.begin() + x);
|
||||
else
|
||||
x += 1;
|
||||
}
|
||||
@@ -68,17 +150,20 @@ void menu_dir_skip_static_files()
|
||||
|
||||
void menu_dir_load_menu(long parent_id)
|
||||
{
|
||||
menu_dir_iq.SetAll(false, false);
|
||||
menu_dir_iq.sel_subject = true;
|
||||
menu_dir_iq.sel_url = true;
|
||||
menu_dir_iq.sel_sort_index = true;
|
||||
menu_dir_iq.sel_type = true;
|
||||
menu_dir_iq.sel_file = true;
|
||||
menu_dir_iq.WhereParentId(parent_id);
|
||||
iq.SetAll(false, false);
|
||||
iq.sel_subject = true;
|
||||
iq.sel_url = true;
|
||||
iq.sel_sort_index = true;
|
||||
iq.sel_type = true;
|
||||
iq.sel_file = true;
|
||||
iq.WhereParentId(parent_id);
|
||||
|
||||
db->GetItems(menu_dir->items, iq);
|
||||
|
||||
db->GetItems(menu_dir_items, menu_dir_iq);
|
||||
menu_dir_skip_items(parent_id);
|
||||
menu_dir_skip_static_files();
|
||||
|
||||
// !! temporarily for debug purposes
|
||||
log << log1 << "Menu: db used" << logend;
|
||||
}
|
||||
|
||||
@@ -86,25 +171,31 @@ void menu_dir_load_menu(long parent_id)
|
||||
|
||||
void menu_dir_init(const std::wstring & path)
|
||||
{
|
||||
if( cur->request->id != menu_dir_reqid || menu_dir_last_dir != path )
|
||||
if( cur->request->id != req_id )
|
||||
{
|
||||
menu_dir_reqid = cur->request->id;
|
||||
menu_dir_items.clear();
|
||||
menu_dir_stack.Clear();
|
||||
req_id = cur->request->id;
|
||||
}
|
||||
|
||||
menu_dir = menu_dir_stack.Get(path);
|
||||
|
||||
if( !path.empty() && path[0] != '/' )
|
||||
{
|
||||
log << log1 << "Menu: path for menu should not be relative" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
if( menu_dir_stack.AddedNew() )
|
||||
{
|
||||
if( path.empty() )
|
||||
{
|
||||
// current directory
|
||||
menu_dir_load_menu(cur->request->dir_tab.back()->id);
|
||||
system->dirs.MakePath(cur->request->dir_tab, menu_dir_last_dir);
|
||||
}
|
||||
else
|
||||
if( path[0] != '/' )
|
||||
{
|
||||
log << log1 << "Menu: path for menu should not be relative" << logend;
|
||||
system->dirs.MakePath(cur->request->dir_tab, menu_dir->dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu_dir_last_dir = path;
|
||||
menu_dir->dir = path;
|
||||
Item * pdir = system->dirs.GetDir(path);
|
||||
|
||||
if( pdir )
|
||||
@@ -119,25 +210,24 @@ void menu_dir_init(const std::wstring & path)
|
||||
|
||||
void menu_dir_tab(Info & i)
|
||||
{
|
||||
if( i.iter == 0 )
|
||||
menu_dir_init(i.par);
|
||||
menu_dir_init(i.par);
|
||||
|
||||
menu_dir_index = i.iter;
|
||||
i.res = menu_dir_index < menu_dir_items.size();
|
||||
menu_dir->index = i.iter;
|
||||
i.res = menu_dir->index < menu_dir->items.size();
|
||||
}
|
||||
|
||||
|
||||
void menu_dir_tab_subject(Info & i)
|
||||
{
|
||||
if( menu_dir_index < menu_dir_items.size() )
|
||||
i.out << menu_dir_items[menu_dir_index].subject;
|
||||
if( menu_dir->index < menu_dir->items.size() )
|
||||
i.out << menu_dir->items[menu_dir->index].subject;
|
||||
}
|
||||
|
||||
|
||||
void menu_dir_tab_url(Info & i)
|
||||
{
|
||||
if( menu_dir_index < menu_dir_items.size() )
|
||||
i.out << menu_dir_items[menu_dir_index].url;
|
||||
if( menu_dir->index < menu_dir->items.size() )
|
||||
i.out << menu_dir->items[menu_dir->index].url;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,14 +236,14 @@ void menu_dir_tab_url(Info & i)
|
||||
|
||||
void menu_dir_tab_link(Info & i)
|
||||
{
|
||||
if( menu_dir_index < menu_dir_items.size() )
|
||||
if( menu_dir->index < menu_dir->items.size() )
|
||||
{
|
||||
i.out << menu_dir_last_dir;
|
||||
i.out << menu_dir->dir;
|
||||
|
||||
if( !IsLastSlash(menu_dir_last_dir) )
|
||||
if( !IsLastSlash(menu_dir->dir) )
|
||||
i.out << '/';
|
||||
|
||||
i.out << menu_dir_items[menu_dir_index].url;
|
||||
i.out << menu_dir->items[menu_dir->index].url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,13 +251,51 @@ void menu_dir_tab_link(Info & i)
|
||||
|
||||
void menu_dir_tab_is_current(Info & i)
|
||||
{
|
||||
if( menu_dir_index < menu_dir_items.size() )
|
||||
if( menu_dir->index < menu_dir->items.size() )
|
||||
{
|
||||
i.res = (menu_dir_items[menu_dir_index].id == cur->request->last_item->id);
|
||||
i.res = (menu_dir->items[menu_dir->index].id == cur->request->last_item->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// returning true if the dir tab element is a first parent for current item
|
||||
void menu_dir_tab_is_first_parent_for_current_item(Info & i)
|
||||
{
|
||||
if( menu_dir->index < menu_dir->items.size() )
|
||||
i.res = (menu_dir->items[menu_dir->index].id == cur->request->last_item->parent_id);
|
||||
}
|
||||
|
||||
|
||||
// returning true if the dir tab element is a parent for current item
|
||||
// (it don't have to be the first parent - it can be a descendant)
|
||||
void menu_dir_tab_is_parent_for_current_item(Info & i)
|
||||
{
|
||||
if( menu_dir->index < menu_dir->items.size() )
|
||||
{
|
||||
size_t len = cur->request->dir_tab.size(); // at least one
|
||||
|
||||
if( !cur->request->is_item )
|
||||
{
|
||||
// the last item is a directory so we don't get it into account
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
for(size_t a=0 ; a<len ; ++a)
|
||||
{
|
||||
if( menu_dir->items[menu_dir->index].id == cur->request->dir_tab[a]->id )
|
||||
{
|
||||
i.res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AddEzcFunctions(PluginInfo & info)
|
||||
{
|
||||
using TemplatesFunctions::EzcFun;
|
||||
@@ -178,6 +306,8 @@ void AddEzcFunctions(PluginInfo & info)
|
||||
fun->Insert("menu_dir_tab_url", menu_dir_tab_url);
|
||||
fun->Insert("menu_dir_tab_link", menu_dir_tab_link);
|
||||
fun->Insert("menu_dir_tab_is_current", menu_dir_tab_is_current);
|
||||
fun->Insert("menu_dir_tab_is_first_parent_for_current_item", menu_dir_tab_is_first_parent_for_current_item);
|
||||
fun->Insert("menu_dir_tab_is_parent_for_current_item", menu_dir_tab_is_parent_for_current_item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user