<?xml version="1.0"?>

<queryset>
   <rdbms><type>postgresql</type><version>7.2</version></rdbms>

	<fullquery name="bcms::template::create_template.create_template">
		<querytext>
			select content_template__new(:template_name, :parent_id,
				null, now(), :creation_user_id, :creation_ip)
		</querytext>
	</fullquery>

	<fullquery name="bcms::template::add_template.add_template">
		<querytext>
			select content_revision__new(:title, :description, now(), 'text/html', null, :content, :template_id, null, now(), :creation_user_id, :creation_ip)
		</querytext>
	</fullquery>

	<fullquery name="bcms::template::delete_template.delete_template">
		<querytext>
			select content_template__delete(:template_id)
		</querytext>
	</fullquery>

	<fullquery name="bcms::template::get_cr_root_template_folder.get_template_root">
		<querytext>
			select content_template__get_root_folder()
		</querytext>
	</fullquery>

	<fullquery name="bcms::template::apply_template.apply_template">
		<querytext>
			select content_item__register_template(:item_id, :template_id, :context)
		</querytext>
	</fullquery>

	<fullquery name="bcms::template::register_template.register_template">
		<querytext>
			select content_type__register_template(
				:content_type, 
				:template_id, 
				:context,
				:is_default_p)
		</querytext>
	</fullquery>
	
	<fullquery name="bcms::template::unregister_template.unregister_template">
		<querytext>
			select content_item__unregister_template(:item_id, :template_id, :context)
		</querytext>
	</fullquery>

	<fullquery name="bcms::template::get_template.get_template">
		<querytext>
			select name, item_id from cr_items where item_id = content_item__get_template(:item_id, :context)
		</querytext>
	</fullquery>

    <fullquery name="bcms::template::list_templates.list_templates">
        <querytext>
            select  i.item_id as template_id, i.name, i.live_revision, i.latest_revision, i.publish_status, i.content_type, i.storage_type, i.tree_sortkey,
                    r.title, r.description
            from cr_items i, cr_revisions r
            where
                    i.parent_id = :parent_id
                    and i.item_id = r.item_id
                    and r.revision_id = $revision
        </querytext>
    </fullquery>

</queryset>