added: new plugin: menu
fixed: System::FollowAllLinks didn't check permissions to a file (only to a simlink or a directory) added: new ezc function: insert_page now we are able to nest pages in pages git-svn-id: svn://ttmath.org/publicrep/winix/trunk@750 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
27
plugins/menu/Makefile
Executable file
27
plugins/menu/Makefile
Executable file
@@ -0,0 +1,27 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
name = menu.so
|
||||
|
||||
|
||||
all: $(name)
|
||||
|
||||
$(name): $(o)
|
||||
$(CXX) -shared -Wl,-soname,$(name).so -o $(name) $(CXXFLAGS) *.o
|
||||
|
||||
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $<
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
makedepend -Y. -I../.. -I../../../ezc/src -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f $(name)
|
||||
|
||||
include Makefile.dep
|
109
plugins/menu/Makefile.dep
Executable file
109
plugins/menu/Makefile.dep
Executable file
@@ -0,0 +1,109 @@
|
||||
# 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/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/misc.h
|
||||
init.o: ../../templates/localefilter.h ../../templates/locale.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 ../../templates/htmltextstream.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 ../../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/thumb.h ../../core/basethread.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: ../../functions/functionparser.h ../../core/cur.h
|
||||
init.o: ../../functions/adduser.h ../../functions/cat.h
|
||||
init.o: ../../functions/chmod.h ../../functions/privchanger.h
|
||||
init.o: ../../functions/chown.h ../../functions/ckeditor.h
|
||||
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/nicedit.h ../../functions/node.h
|
||||
init.o: ../../functions/passwd.h ../../functions/priv.h
|
||||
init.o: ../../functions/reload.h ../../functions/rm.h
|
||||
init.o: ../../functions/specialdefault.h ../../functions/stat.h
|
||||
init.o: ../../functions/subject.h ../../functions/template.h
|
||||
init.o: ../../functions/tinymce.h ../../functions/uname.h
|
||||
init.o: ../../functions/upload.h ../../functions/uptime.h
|
||||
init.o: ../../functions/who.h ../../functions/vim.h ../../core/htmlfilter.h
|
||||
init.o: ../../templates/templates.h ../../templates/patterncacher.h
|
||||
init.o: ../../templates/ckeditorgetparser.h ../../core/httpsimpleparser.h
|
||||
init.o: ../../core/log.h ../../templates/indexpatterns.h
|
||||
init.o: ../../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/ckeditorgetparser.h
|
||||
templates.o: ../../core/httpsimpleparser.h ../../core/log.h
|
||||
templates.o: ../../templates/indexpatterns.h ../../templates/localefilter.h
|
||||
templates.o: ../../templates/locale.h ../../core/config.h
|
||||
templates.o: ../../templates/htmltextstream.h ../../core/cur.h
|
||||
templates.o: ../../core/system.h ../../core/sessionmanager.h
|
||||
templates.o: ../../core/htmlfilter.h ../../db/db.h ../../db/dbbase.h
|
||||
templates.o: ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
templates.o: ../../core/textstream.h ../../core/error.h
|
||||
templates.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.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/confparser.h
|
||||
templates.o: ../../core/htmlfilter.h ../../core/request.h ../../core/error.h
|
||||
templates.o: ../../core/textstream.h ../../templates/htmltextstream.h
|
||||
templates.o: ../../core/system.h ../../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/misc.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: ../../core/lastcontainer.h ../../core/cur.h ../../core/session.h
|
||||
templates.o: ../../core/rebus.h ../../core/mount.h ../../core/mounts.h
|
||||
templates.o: ../../core/mountparser.h ../../core/crypt.h ../../core/run.h
|
||||
templates.o: ../../core/users.h ../../core/groups.h ../../core/group.h
|
||||
templates.o: ../../core/loadavg.h ../../core/thumb.h ../../core/basethread.h
|
||||
templates.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h
|
||||
templates.o: ../../functions/functions.h ../../functions/functionbase.h
|
||||
templates.o: ../../core/request.h ../../core/synchro.h
|
||||
templates.o: ../../functions/functionparser.h ../../functions/adduser.h
|
||||
templates.o: ../../functions/cat.h ../../functions/chmod.h
|
||||
templates.o: ../../functions/privchanger.h ../../functions/chown.h
|
||||
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/mkdir.h ../../functions/mv.h
|
||||
templates.o: ../../functions/nicedit.h ../../functions/node.h
|
||||
templates.o: ../../functions/passwd.h ../../functions/priv.h
|
||||
templates.o: ../../functions/reload.h ../../functions/rm.h
|
||||
templates.o: ../../functions/specialdefault.h ../../functions/stat.h
|
||||
templates.o: ../../functions/subject.h ../../functions/template.h
|
||||
templates.o: ../../functions/tinymce.h ../../functions/uname.h
|
||||
templates.o: ../../functions/upload.h ../../functions/uptime.h
|
||||
templates.o: ../../functions/who.h ../../functions/vim.h ../../core/log.h
|
||||
templates.o: ../../core/logmanipulators.h ../../core/slog.h ../../core/misc.h
|
1
plugins/menu/Makefile.o.dep
Executable file
1
plugins/menu/Makefile.o.dep
Executable file
@@ -0,0 +1 @@
|
||||
o = init.o templates.o
|
78
plugins/menu/init.cpp
Executable file
78
plugins/menu/init.cpp
Executable file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "core/log.h"
|
||||
#include "core/plugin.h"
|
||||
|
||||
|
||||
|
||||
extern "C" void Init(PluginInfo &);
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Menu
|
||||
{
|
||||
|
||||
|
||||
const wchar_t plugin_name[] = L"menu";
|
||||
int mount_par_menu_skip = -1;
|
||||
|
||||
|
||||
|
||||
void AddMountParams(PluginInfo & info)
|
||||
{
|
||||
using TemplatesFunctions::system;
|
||||
|
||||
mount_par_menu_skip = system->mounts.AddMountPar(L"menu_skip");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FstabChanged(PluginInfo & info)
|
||||
{
|
||||
if( mount_par_menu_skip == -1 )
|
||||
return;
|
||||
|
||||
/*
|
||||
// GetMountTab() returns a const pointer so we cannot sort menu_skip parameters
|
||||
// may change it to non-const in the future?
|
||||
|
||||
const Mounts::MountTab * mt = system->mounts.GetMountTab();
|
||||
Mounts::MountTab::const_iterator i;
|
||||
|
||||
for(i = mt->begin() ; i != mt->end() ; ++i)
|
||||
SortMenuSkip(i->second);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AddEzcFunctions(PluginInfo & info);
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Init(PluginInfo & info)
|
||||
{
|
||||
using namespace Menu;
|
||||
|
||||
plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
|
||||
plugin.Assign(WINIX_ADD_MOUNTS, AddMountParams);
|
||||
plugin.Assign(WINIX_FSTAB_CHANGED, FstabChanged);
|
||||
|
||||
|
||||
info.p1 = (void*)(plugin_name);
|
||||
}
|
||||
|
||||
|
165
plugins/menu/templates.cpp
Executable file
165
plugins/menu/templates.cpp
Executable file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "templates/templates.h"
|
||||
#include "core/plugin.h"
|
||||
#include "core/item.h"
|
||||
#include "core/log.h"
|
||||
#include "core/misc.h"
|
||||
|
||||
|
||||
|
||||
namespace Menu
|
||||
{
|
||||
using namespace TemplatesFunctions;
|
||||
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;
|
||||
|
||||
|
||||
// O(n^2) complexity
|
||||
void menu_dir_skip_items(long parent_id)
|
||||
{
|
||||
Mount * m = system->mounts.CalcMount(parent_id);
|
||||
|
||||
if( !m || mount_par_menu_skip==-1 || !m->param[mount_par_menu_skip].defined )
|
||||
return;
|
||||
|
||||
const Mount::ParamRow::ParamArg & arg = m->param[mount_par_menu_skip].arg;
|
||||
|
||||
for(size_t i=0 ; i<arg.size() ; ++i)
|
||||
{
|
||||
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);
|
||||
else
|
||||
x += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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.WhereParentId(parent_id);
|
||||
|
||||
// !! directories will not be read with WINIX_ITEM_FILETYPE_NONE
|
||||
//menu_dir_iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
|
||||
|
||||
db->GetItems(menu_dir_items, menu_dir_iq);
|
||||
menu_dir_skip_items(parent_id);
|
||||
log << log1 << "Menu: db used" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void menu_dir_init(const std::wstring & path)
|
||||
{
|
||||
if( cur->request->id != menu_dir_reqid || menu_dir_last_dir != path )
|
||||
{
|
||||
menu_dir_reqid = cur->request->id;
|
||||
menu_dir_last_dir = path;
|
||||
menu_dir_items.clear();
|
||||
|
||||
if( path.empty() )
|
||||
{
|
||||
log << log1 << "Menu: you should provide a path for menu" << logend;
|
||||
}
|
||||
else
|
||||
if( path[0] != '/' )
|
||||
{
|
||||
log << log1 << "Menu: path for menu should not be relative" << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
Item * pdir = system->dirs.GetDir(path);
|
||||
|
||||
if( pdir )
|
||||
menu_dir_load_menu(pdir->id);
|
||||
else
|
||||
log << log1 << "Menu: I cannot find a directory: " << path << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void menu_dir_tab(Info & i)
|
||||
{
|
||||
if( i.iter == 0 )
|
||||
menu_dir_init(i.par);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
void menu_dir_tab_url(Info & i)
|
||||
{
|
||||
if( menu_dir_index < menu_dir_items.size() )
|
||||
i.out << menu_dir_items[menu_dir_index].url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void menu_dir_tab_link(Info & i)
|
||||
{
|
||||
if( menu_dir_index < menu_dir_items.size() )
|
||||
{
|
||||
i.out << menu_dir_last_dir;
|
||||
|
||||
if( !IsLastSlash(menu_dir_last_dir) )
|
||||
i.out << '/';
|
||||
|
||||
i.out << menu_dir_items[menu_dir_index].url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AddEzcFunctions(PluginInfo & info)
|
||||
{
|
||||
using TemplatesFunctions::EzcFun;
|
||||
EzcFun * fun = reinterpret_cast<EzcFun*>(info.p1);
|
||||
|
||||
fun->Insert("menu_dir_tab", menu_dir_tab);
|
||||
fun->Insert("menu_dir_tab_subject", menu_dir_tab_subject);
|
||||
fun->Insert("menu_dir_tab_url", menu_dir_tab_url);
|
||||
fun->Insert("menu_dir_tab_link", menu_dir_tab_link);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user