part II of rewriting

git-svn-id: svn://ttmath.org/publicrep/winix/trunk@635 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-08-12 19:10:12 +00:00
parent c3fac2e83f
commit 9a199cd834
38 changed files with 1159 additions and 1167 deletions

View File

@@ -58,6 +58,56 @@ return i->second;
}
void Functions::PrepareUrl(Item & item)
{
TrimWhite(item.url);
if( item.url.empty() )
item.url = item.subject; // if the subject is empty then the url will be corrected by CorrectUrlOnlyAllowedChar()
CorrectUrlOnlyAllowedChar(item.url);
if( Find(item.url) )
{
// the name provided by an user is the same as a name of a function
// we add one underscore character at the beginning
// names of functions should not begin with an underscore '_'
// and we can simply add one '_' at the beginning
// and the name will be unique
item.url.insert(item.url.begin(), '_');
}
}
Error Functions::CheckSpecialFile(const Item & item)
{
static std::string fstab = "fstab";
Item * etc = system->dirs.GetEtcDir();
if( !etc )
return WINIX_NOTHING_TO_DO;
if( item.parent_id != etc->id )
return WINIX_NOTHING_TO_DO;
if( item.url == fstab )
{
log << log3 << "Functions: reloading mount points" << logend;
Error status = system->mounts.ReadMounts(item.content);
templates->ReadNewIndexTemplates();
return status;
}
return WINIX_NOTHING_TO_DO;
}
void Functions::SetObjects(FunctionBase * fun)
{
fun->SetConfig(config);
@@ -299,25 +349,26 @@ bool Functions::ReadItemUrlSubject(Item & item, Item::Type item_type)
{
bool with_url = false;
std::string * new_url = request->PostVar("url");
std::string * new_subject = request->PostVar("subject");
const std::string & new_url = request->PostVar("url");
const std::string & new_subject = request->PostVar("subject");
if( item_type == Item::file )
{
if( !request->is_item || (new_url && *new_url != item.url) )
if( !request->is_item || new_url != item.url )
with_url = true;
}
else
{
// !! dla katalogow zawsze ma modyfikowac url?
with_url = true;
}
if( new_url )
item.url = *new_url;
if( !new_url.empty() )
item.url = new_url;
if( new_subject )
item.subject = *new_subject;
if( !new_subject.empty() )
item.subject = new_subject;
if( item.subject.empty() )
@@ -328,7 +379,7 @@ bool Functions::ReadItemUrlSubject(Item & item, Item::Type item_type)
}
// if item.url is empty then it will be set from item.subject
system->PrepareUrl(item);
PrepareUrl(item);
return with_url;
}