changed: now Request class is a model class - we have fields() method there to map fields for ezc templates (currently only dir_tab)
removed: [dir_tab] ezc statement
changed: Ls winix function loads its own dir_tab container (beforehand it was loaded by [dir_tab] ezc statement)
it's available by [child_dirs] name
This commit is contained in:
@@ -50,6 +50,41 @@ Ls::Ls()
|
||||
}
|
||||
|
||||
|
||||
void Ls::prepare_files()
|
||||
{
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", cur->request->dir_tab.back()->id).
|
||||
neq(L"type", static_cast<int>(Item::dir));
|
||||
|
||||
if( cur->request->IsParam(L"ckeditor_browse") )
|
||||
{
|
||||
finder.eq(L"content", L"file_type", WINIX_ITEM_FILETYPE_IMAGE);
|
||||
}
|
||||
|
||||
finder.get_vector(item_tab);
|
||||
}
|
||||
|
||||
|
||||
void Ls::prepare_dirs()
|
||||
{
|
||||
dir_tab.clear();
|
||||
|
||||
// with parent directory (if exists)
|
||||
// if dir_tab.size() is equal to 1 then we at the root directory
|
||||
if( cur->request->dir_tab.size() >= 2 )
|
||||
{
|
||||
Item * dir_up = cur->request->dir_tab[cur->request->dir_tab.size()-2];
|
||||
dir_tab.push_back(dir_up);
|
||||
}
|
||||
|
||||
system->dirs.GetDirChilds(cur->request->dir_tab.back()->id, dir_tab);
|
||||
}
|
||||
|
||||
|
||||
void Ls::MakeGet()
|
||||
{
|
||||
// !! IMPROVE ME
|
||||
@@ -61,33 +96,15 @@ void Ls::MakeGet()
|
||||
|
||||
if( !cur->request->is_item )
|
||||
{
|
||||
// DbItemQuery iq;
|
||||
//
|
||||
// iq.sel_content = false;
|
||||
//
|
||||
// iq.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
// iq.WhereType(Item::dir, false);
|
||||
prepare_files();
|
||||
prepare_dirs();
|
||||
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
cur->request->models.Add(L"items", item_tab);
|
||||
cur->request->models.Add(L"child_dirs", dir_tab);
|
||||
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", cur->request->dir_tab.back()->id).
|
||||
neq(L"type", static_cast<int>(Item::dir));
|
||||
|
||||
if( cur->request->IsParam(L"ckeditor_browse") )
|
||||
{
|
||||
//iq.WhereFileType(WINIX_ITEM_FILETYPE_IMAGE);
|
||||
//db->GetItems(cur->request->item_tab, iq);
|
||||
finder.eq(L"content", L"file_type", WINIX_ITEM_FILETYPE_IMAGE);
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// //db->GetItems(cur->request->item_tab, iq);
|
||||
// }
|
||||
|
||||
finder.get_vector(cur->request->item_tab);
|
||||
// IMPROVEME this will be put by a generic method from winix
|
||||
// if output is html
|
||||
cur->request->models.Add(L"request", cur->request);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -55,7 +55,11 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
std::vector<Item> item_tab;
|
||||
std::vector<Item*> dir_tab;
|
||||
|
||||
void prepare_files();
|
||||
void prepare_dirs();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user