<?php
	
	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );

	/**
	 * implements the main view of the feed reader plugin
	 */
	class PluginStickyPostsConfigView extends AdminPluginTemplatedView
	{

		function PluginStickyPostsConfigView( $blogInfo )
		{
			$this->AdminPluginTemplatedView( $blogInfo, "stickyposts", "stickyposts" );
		}
		
		function render()
		{
			// load some configuration settings
			$blogSettings = $this->_blogInfo->getSettings();
			$pluginEnabled = $blogSettings->getValue( "plugin_stickyposts_enabled" );
			$stickyCategoryId = $blogSettings->getValue( "plugin_stickyposts_stickycategoryid");
			$announceCategoryId = $blogSettings->getValue( "plugin_stickyposts_announcecategoryid");
			$maxStickys = $blogSettings->getValue( "plugin_stickyposts_maxstickys" );
			$maxAnnounces = $blogSettings->getValue( "plugin_stickyposts_maxAnnounces" );
			if ($maxStickys == "") $maxStickys = 5;
			if ($maxAnnounce == "") $maxAnnounces = 5;
			
			//get all categories's id and name as an assoication array
			$categories = new articleCategories();
			$blogId = $this->_blogInfo->getId();
			$allCategories = $categories->getBlogCategories( $blogId );
			$catNameId = array();
			foreach( $allCategories as $aCategory ){
				$catNameId[$aCategory->getId()] = $aCategory->getName();
			}
			
			// create a view and export the settings to the template
			$this->setValue( "pluginEnabled", $pluginEnabled );
			$this->setValue( "stickyCategoryId", $stickyCategoryId );
			$this->setValue( "announceCategoryId", $announceCategoryId );
			$this->setValue( "catNameId", $catNameId );
			$this->setValue( "maxStickys", $maxStickys );
			$this->setValue( "maxAnnounces", $maxAnnounces );
			
			parent::render();
		}
	}
?>
