2009-04-20 00:13:21 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of CMSLU -- Content Management System like Unix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2009-04-21 22:50:55 +02:00
|
|
|
* Copyright (c) 2008-2009, Tomasz Sowa
|
2009-04-20 00:13:21 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "content.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
#include "../core/request.h"
|
|
|
|
#include "../core/db.h"
|
|
|
|
#include "../core/data.h"
|
|
|
|
#include "../core/mount.h"
|
2009-04-20 00:13:21 +02:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
#include <algorithm>
|
2009-04-20 00:13:21 +02:00
|
|
|
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
bool Content::FunThreadSort(const Thread & t1, const Thread & t2)
|
2009-04-20 00:13:21 +02:00
|
|
|
{
|
2009-06-05 22:29:06 +02:00
|
|
|
Item * pdir1 = data.dirs.GetDir(t1.dir_id);
|
|
|
|
Item * pdir2 = data.dirs.GetDir(t2.dir_id);
|
|
|
|
|
|
|
|
if( !pdir1 || !pdir2 )
|
|
|
|
return false;
|
2009-04-20 00:13:21 +02:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
time_t time1 = mktime(&pdir1->date_creation);
|
|
|
|
time_t time2 = mktime(&pdir2->date_creation);
|
2009-04-20 00:13:21 +02:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
return time1 > time2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Content::FunThread()
|
|
|
|
{
|
2009-04-21 01:49:28 +02:00
|
|
|
bool asc = true;
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
if( data.mounts.CurrentMountIsParam(Mount::desc) )
|
2009-04-21 01:49:28 +02:00
|
|
|
asc = false;
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
db.GetItems(request.item_table, request.dir_table.back()->id, Item::file, true, true, asc);
|
|
|
|
db.GetThreads(request.dir_table.back()->id, request.thread_tab);
|
|
|
|
|
|
|
|
std::sort(request.thread_tab.begin(), request.thread_tab.end(), FunThreadSort);
|
2009-04-20 00:13:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|