Category and page

Category

Creating a category

The categories may be created either in the site root either in a parent category.

public void site_createTopic( ISiteModule siteModule, IContext context, ISite site ) throws SiteModuleException {
	// 1st case: creation of a category in the site root
	ITopic topic = siteModule.createTopic( context, site, "test-topic", "test topic label" );

	// 2nd case: creation of a category in a parent category
	ITopic parentTopic = null;
	topic = siteModule.createTopic( context, parentTopic, "test-topic", "test topic label" );
}

Recovering a category

A root category or a sub-category is recovered using the category system name.

public void site_getTopic( ISiteModule siteModule, IContext context, ISite site ) throws SiteModuleException {
	// recovering a category from a site
	ITopic topic = siteModule.getTopic( context, site, "test-topic" );

	// recovering a category from a parent category
	ITopic parentTopic = null;
	topic = siteModule.getTopic( context, parentTopic, "test-topic" );

	System.out.println( topic.getName() );
}

Recovering categories of a site or a topic

The site module planned to recover the root categories or the sub-categories of a specific topic.

public void site_getTopics( ISiteModule siteModule, IContext context, ISite site ) throws SiteModuleException {
	// recovering root categories from a site
	Collection topics = siteModule.getTopics( context, site );
	for ( Iterator iterator = topics.iterator() ; iterator.hasNext() ; ) {
		ITopic topic = (ITopic)iterator.next();
		System.out.println( topic.getName() );
	}

	// recovering root categories from a parent category
	ITopic parentTopic = null;
	topics = siteModule.getTopics( context, parentTopic );
	for ( Iterator iterator = topics.iterator() ; iterator.hasNext() ; ) {
		ITopic topic = (ITopic)iterator.next();
		System.out.println( topic.getName() );
	}
}

Page

Creating a page

The categories may be directly created in the site root or in a parent category.

public void site_createPage( ISiteModule siteModule, IContext context, ISite site ) throws SiteModuleException {
	// 1st case: creation of a page on the site root
	IPageContainer sitePage = siteModule.createPageContainer( context, site, "site-page", "My page" );

	ITopic topic = null;
	// 2nd case: creation of a page under a category
	IPageContainer topicPage = siteModule.createPageContainer( context, topic, "topic-page", "page" );
}

Recovering a page

The site management module planned to recover a page from the website root as well as a category.

public void site_getPage( ISiteModule siteModule, IContext context, ISite site ) throws SiteModuleException {
	// 1st case: recover a page from the site root
	IPageContainer pageContainer = siteModule.getPageContainer( context, site, "site-page" );

	ITopic topic = null;
	// 2nd case: recover a page from a category
	IPageContainer childPageContainer = siteModule.getPageContainer( context, topic, "topic-page" );
}

Recovering pages of a site or a topic

The site management module enables to recover every pages present at the site root as well as the one presents in a sub-category.

public void site_getPages( ISiteModule siteModule, IContext context, ISite site ) throws SiteModuleException {
	// recovering the pages in the website root
	Collection pageContainers = siteModule.getPageContainers( context, site );
	for ( Iterator iterator = pageContainers.iterator() ; iterator.hasNext() ; ) {
		IPageContainer pageContainer = (IPageContainer)iterator.next();
		System.out.println( pageContainer.getLabel() );
	}

	// recovering a category
	ITopic topic = siteModule.getTopic( context, site, "my-lovely-topic" );

	// recovering the pages in the website category
	pageContainers = siteModule.getPageContainers( context, topic );
	for ( Iterator iterator = pageContainers.iterator() ; iterator.hasNext() ; ) {
		IPageContainer pageContainer = (IPageContainer)iterator.next();
		System.out.println( pageContainer.getLabel() );
	}
}

Approving a Page

Each page is linked to a validation cycle. After modifying the “draft” version of a page, it is required to approve the page so that it can be consulted by the site users. If nevertheless, the user approving the page does not have enough rights, he must do an approval request. The manager may then approve or refuse the request.

The following example shows the page validation cycle.

public void page_approuvePage( ISiteModule siteModule, IContext context, ISite site ) throws SiteModuleException {
	// recover a page to approve
	IPageContainer pageContainer = siteModule.getPageContainer( context, site, "my-lovely-page" );

	// Requesting Approval of a Page
	siteModule.requestApproval( context, pageContainer, "Please..." );

	// Approving a Page
	siteModule.approve( context, pageContainer );

	// Request approval
	siteModule.reject( context, pageContainer, "No way." );
}