libreccm-legacy/ccm-cms/pdl/com/arsdigita/content-section/query-itemsInSection.pg.pdl

62 lines
2.1 KiB
Plaintext
Executable File

//
// Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// $Id: query-itemsInSection.pg.pdl 287 2005-02-22 00:29:02Z sskracic $
// $DateTime: 2004/08/17 23:15:09 $
model com.arsdigita.cms;
query ItemsInSection {
ContentItem item;
ContentType type;
Boolean isFolder;
Boolean hasLiveVersion;
do {
select a.object_type, a.display_name, a.default_domain_class,
i.item_id, i.parent_id, i.version, i.name,
CASE WHEN (f.folder_id is null) THEN
0
ELSE
1
END as is_folder,
CASE WHEN (v.item_id is null) THEN
0
ELSE
1
END as has_live_version,
t.type_id, t.label
from cms_items i
left join content_types t on (i.type_id = t.type_id)
left join cms_folders f on (i.item_id = f.folder_id)
left join cms_items v on (i.item_id = v.master_id),
acs_objects a
where i.item_id = a.object_id
and i.section_id = :sectionId
} map {
item.id = i.item_id;
item.objectType = a.object_type;
item.displayName = a.display_name;
item.defaultDomainClass = a.default_domain_class;
item.version = i.version;
item.name = i.name;
type.id = t.type_id;
type.label = t.label;
isFolder = is_folder;
hasLiveVersion = has_live_version;
}
}