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:
71
functions/meta.cpp
Executable file
71
functions/meta.cpp
Executable file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "meta.h"
|
||||
#include "core/log.h"
|
||||
|
||||
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
Meta::Meta()
|
||||
{
|
||||
fun.url = L"meta";
|
||||
}
|
||||
|
||||
|
||||
bool Meta::HasAccess()
|
||||
{
|
||||
return system->HasReadAccess(*cur->request->last_item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Meta::AddMetaInfo(Item & item, const std::wstring & meta_str)
|
||||
{
|
||||
space.Clear();
|
||||
conf_parser.SetSpace(space);
|
||||
conf_parser.UTF8(config->utf8);
|
||||
conf_parser.SplitSingle(true);
|
||||
|
||||
if( conf_parser.ParseString(meta_str) == ConfParser::ok )
|
||||
{
|
||||
if( db->EditMetaById(space, item.id) == WINIX_ERR_OK )
|
||||
{
|
||||
item.meta = space;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Meta::MakePost()
|
||||
{
|
||||
if( system->HasWriteAccess(*cur->request->last_item) )
|
||||
{
|
||||
const std::wstring & meta_str = cur->request->PostVar(L"itemmeta");
|
||||
|
||||
if( AddMetaInfo(*cur->request->last_item, meta_str) )
|
||||
system->RedirectToLastItem();
|
||||
else
|
||||
slog << logerror << "Syntax error in line: " << conf_parser.line << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user