<?php

/**
	* @name			Social Pin Board
	* @version 1     pincategory.php$
	* @package		Apptha
	* @subpackage	com_socialpinboard
	* @author		Contus Support
	* @copyright	Copyright (C) 2011 powered by Apptha
	* @license		GNU/GPL http://www.gnu.org/copyleft/gpl.html
	* @since		Joomla 1.5&1.6&1.7
 */
// No direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.controller');
jimport('joomla.filesystem.file');
class wishlogueControllersubcatalogues extends WishlogueController
{
	/**
	 * Function to display the Category list
	 * 
	 * @param   string  $cachable  will display something
	 * @param   string  $urlparams  will display
	 * 
	 * @return test will display something
	 */
	function display($cachable = false, $urlparams = false)
	{
		$viewName = JRequest::getVar('view', 'subcatalogues');
		$viewLayout = JRequest::getVar('layout', 'subcatalogues');
		$view = $this->getView($viewName);

		if ($model = $this->getModel('subcatalogues'))
		{
			$view->setModel($model, true);
		}

		$view->setLayout($viewLayout);
		$view->display();
	}

	/**
	 * Function to edit a particular category
	 * 
	 * @param   string  $cachable  will display something
	 * @param   string  $urlparams  will display something
	 * 
	 * @return test will display something
	 */
	function edit($cachable = false, $urlparams = false)
	{
		$view = $this->getView('subcatalogues');

		if ($model = $this->getModel('subcatalogues'))
		{
			$view->setModel($model, true);
		}

		$view->setLayout('subcataloguesform');
		$view->display();
	}

	/**
	 * Function to save a new category
	 * 
	 * @param   string  $cachable  will display something
	 * @param   string  $urlparams  will display something
	 * 
	 * @return test will display something
	 */
	function save($cachable = false, $urlparams = false)
	{
		$detail = JRequest::get('POST');
		$model = $this->getModel('subcatalogues');
		$model->savesubcatalogue($detail);
		//$this->setRedirect('index.php?layout=subcatalogues&option=' . JRequest::getVar('option'), 'Subcatalogue Saved!');
	}

	/**
	 * Function to add a new category
	 * 
	 * @param   string  $cachable  will display something
	 * @param   string  $urlparams  will display something
	 * 
	 * @return test will display something
	 */
	function add($cachable = false, $urlparams = false)
	{
		$view = $this->getView('subcatalogues');

		if ($model = $this->getModel('subcatalogues'))
		{
			$view->setModel($model, true);
		}

		$view->setLayout('subcataloguesform');
		$view->display();
	}

	/**
	 * Function to delete a category
	 * 
	 * @param   string  $cachable  will display something
	 * @param   string  $urlparams  will display something
	 * 
	 * @return test will display something
	 */
	function remove($cachable = false, $urlparams = false)
	{
		$arrayIDs = JRequest::getVar('cid', null, 'default', 'array');

		if ($arrayIDs === null)
		{
			JError::raiseError(500, 'cid parameter missing from the request');
		}

		$model = $this->getModel('subcatalogues');
		$model->deletesubcatalogues($arrayIDs);
		$this->setRedirect('index.php?layout=subcatalogues&option=' . JRequest::getVar('option'), 'Deleted');
	}

	/**
	 * Function to store and stay on the same page till we click on save button[Apply]
	 * 
	 * @param   string  $cachable  will display something
	 * @param   string  $urlparams  will display something
	 * 
	 * @return test will display something
	 */
	function apply($cachable = false, $urlparams = false)
	{
		$detail = JRequest::get('POST');
		$model = $this->getModel('subcatalogues');
		$categoryId = $model->savepincategory($detail);
		$link = 'index.php?option=com_wishlogue&layout=subcatalogues&task=edit&cid[]=' . $categoryId;
		$this->setRedirect($link, 'All Catalogue Saved!');
	}

	/**
	 * Function to cancel some operation
	 * 
	 * @param   string  $cachable  will display something
	 * @param   string  $urlparams  will display something
	 * 
	 * @return test will display something
	 */
	function cancel($cachable = false, $urlparams = false)
	{
		$this->setRedirect('index.php?layout=subcatalogues&option=' . JRequest::getVar('option'), 'Cancelled...');
	}

	/**
	 * Function to publish a category
	 * 
	 * @param   string  $cachable  will display something
	 * @param   string  $urlparams  will display something
	 * 
	 * @return test will display something
	 */
	function publish($cachable = false, $urlparams = false)
	{
		$detail = JRequest::get('POST');
		$model = $this->getModel('subcatalogues');
		$model->pubsubcatalogue($detail);
		$this->setRedirect('index.php?option=' . JRequest::getVar('option') . '&layout=subcatalogues');
	}

	/**
	 * Function to unpublish a category
	 * 
	 * @param   string  $cachable  will display something
	 * @param   string  $urlparams  will display something
	 * 
	 * @return test will display something
	 */
	function unpublish($cachable = false, $urlparams = false)
	{
		$detail = JRequest::get('POST');
		$model = $this->getModel('subcatalogues');
		$model->pubsubcatalogue($detail);
		$this->setRedirect('index.php?option=' . JRequest::getVar('option') . '&layout=subcatalogues');
	}
}

?>
