<?php
/**
 * @name        Social Pin Board
 * @version	1.0: admin.socialpinboard.php$
 * @since       Joomla 1.5&1.6&1.7
 * @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
 */
defined( '_JEXEC' ) or die( 'Restricted access' );
if(!defined('DS')){
    define('DS',DIRECTORY_SEPARATOR);
}
JLoader::register('WishlogueController', JPATH_COMPONENT.'/helpers/controller.php');
JLoader::register('WishlogueView', JPATH_COMPONENT.'/helpers/view.php');
JLoader::register('WishlogueModel', JPATH_COMPONENT.'/helpers/model.php');

if (!JFactory::getUser()->authorise('core.manage', 'com_wishlogue'))
{
	return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}

$controllerName = JRequest::getCmd( 'layout','controlpanel');
$document = JFactory::getDocument();
$document->addStyleSheet('components'.DS.'com_wishlogue'.DS.'assets'.DS.'socialpinboard.css');
if($controllerName == 'wishsection') // to enable the user tab when the controller is set as user
{
    JSubMenuHelper::addEntry(JText::_('Catalogues'), 'index.php?option=com_wishlogue&layout=wishsection', true );
    JSubMenuHelper::addEntry(JText::_('Member Details'), 'index.php?option=com_wishlogue&layout=memberdetails');
    JSubMenuHelper::addEntry(JText::_('Subcatalogues'), 'index.php?option=com_wishlogue&layout=subcatalogues');
    JSubMenuHelper::addEntry(JText::_('Member Subcatalogues'), 'index.php?option=com_wishlogue&layout=managecatalogue');
    JSubMenuHelper::addEntry(JText::_('Manage Wishes'), 'index.php?option=com_wishlogue&layout=managewishes');
    JSubMenuHelper::addEntry(JText::_('Site Settings'), 'index.php?option=com_wishlogue&layout=sitesettings');
    JSubMenuHelper::addEntry(JText::_('Request Approval'), 'index.php?option=com_wishlogue&layout=requestapproval');
    JSubMenuHelper::addEntry(JText::_('Google Adsense'), 'index.php?option=com_wishlogue&layout=googlead');
    JSubMenuHelper::addEntry(JText::_('Wishlogue Ad Space'), 'index.php?option=com_wishlogue&layout=wishlogueadspace');
}
else if ($controllerName == 'memberdetails')
{
    JSubMenuHelper::addEntry(JText::_('Catalogues'), 'index.php?option=com_wishlogue&layout=wishsection');
    JSubMenuHelper::addEntry(JText::_('Member Details'), 'index.php?option=com_wishlogue&layout=memberdetails',true);
    JSubMenuHelper::addEntry(JText::_('Subcatalogues'), 'index.php?option=com_wishlogue&layout=subcatalogues');
    JSubMenuHelper::addEntry(JText::_('Member Subcatalogues'), 'index.php?option=com_wishlogue&layout=managecatalogue');
    JSubMenuHelper::addEntry(JText::_('Manage Wishes'), 'index.php?option=com_wishlogue&layout=managewishes');
    JSubMenuHelper::addEntry(JText::_('Site Settings'), 'index.php?option=com_wishlogue&layout=sitesettings');
    JSubMenuHelper::addEntry(JText::_('Request Approval'), 'index.php?option=com_wishlogue&layout=requestapproval');
    JSubMenuHelper::addEntry(JText::_('Google Adsense'), 'index.php?option=com_wishlogue&layout=googlead');
    JSubMenuHelper::addEntry(JText::_('Wishlogue Ad Space'), 'index.php?option=com_wishlogue&layout=wishlogueadspace');
}
else if ($controllerName == 'managecatalogue')
{
    JSubMenuHelper::addEntry(JText::_('Catalogues'), 'index.php?option=com_wishlogue&layout=wishsection');
    JSubMenuHelper::addEntry(JText::_('Member Details'), 'index.php?option=com_wishlogue&layout=memberdetails');
    JSubMenuHelper::addEntry(JText::_('Subcatalogues'), 'index.php?option=com_wishlogue&layout=subcatalogues');
    JSubMenuHelper::addEntry(JText::_('Member Subcatalogues'), 'index.php?option=com_wishlogue&layout=managecatalogue',true);
    JSubMenuHelper::addEntry(JText::_('Manage Wishes'), 'index.php?option=com_wishlogue&layout=managewishes');
    JSubMenuHelper::addEntry(JText::_('Site Settings'), 'index.php?option=com_wishlogue&layout=sitesettings');
    JSubMenuHelper::addEntry(JText::_('Request Approval'), 'index.php?option=com_wishlogue&layout=requestapproval');
    JSubMenuHelper::addEntry(JText::_('Google Adsense'), 'index.php?option=com_wishlogue&layout=googlead');
    JSubMenuHelper::addEntry(JText::_('Wishlogue Ad Space'), 'index.php?option=com_wishlogue&layout=wishlogueadspace');
}
else if ($controllerName == 'managewishes')
{
    JSubMenuHelper::addEntry(JText::_('Catalogues'), 'index.php?option=com_wishlogue&layout=wishsection');
    JSubMenuHelper::addEntry(JText::_('Member Details'), 'index.php?option=com_wishlogue&layout=memberdetails');
    JSubMenuHelper::addEntry(JText::_('Subcatalogues'), 'index.php?option=com_wishlogue&layout=subcatalogues');
    JSubMenuHelper::addEntry(JText::_('Member Subcatalogues'), 'index.php?option=com_wishlogue&layout=managecatalogue');
    JSubMenuHelper::addEntry(JText::_('Manage Wishes'), 'index.php?option=com_wishlogue&layout=managewishes',true);
    JSubMenuHelper::addEntry(JText::_('Site Settings'), 'index.php?option=com_wishlogue&layout=sitesettings');
    JSubMenuHelper::addEntry(JText::_('Request Approval'), 'index.php?option=com_wishlogue&layout=requestapproval');
    JSubMenuHelper::addEntry(JText::_('Google Adsense'), 'index.php?option=com_wishlogue&layout=googlead');
    JSubMenuHelper::addEntry(JText::_('Wishlogue Ad Space'), 'index.php?option=com_wishlogue&layout=wishlogueadspace');
}
else if ($controllerName == 'sitesettings')
{
    JSubMenuHelper::addEntry(JText::_('Catalogues'), 'index.php?option=com_wishlogue&layout=wishsection');
    JSubMenuHelper::addEntry(JText::_('Member Details'), 'index.php?option=com_wishlogue&layout=memberdetails');
    JSubMenuHelper::addEntry(JText::_('Subcatalogues'), 'index.php?option=com_wishlogue&layout=subcatalogues');
    JSubMenuHelper::addEntry(JText::_('Member Subcatalogues'), 'index.php?option=com_wishlogue&layout=managecatalogue');
    JSubMenuHelper::addEntry(JText::_('Manage Wishes'), 'index.php?option=com_wishlogue&layout=managewishes');
    JSubMenuHelper::addEntry(JText::_('Site Settings'), 'index.php?option=com_wishlogue&layout=sitesettings',true);
    JSubMenuHelper::addEntry(JText::_('Request Approval'), 'index.php?option=com_wishlogue&layout=requestapproval');
    JSubMenuHelper::addEntry(JText::_('Google Adsense'), 'index.php?option=com_wishlogue&layout=googlead');
    JSubMenuHelper::addEntry(JText::_('Wishlogue Ad Space'), 'index.php?option=com_wishlogue&layout=wishlogueadspace');
}
else if ($controllerName == 'requestapproval')
{
    JSubMenuHelper::addEntry(JText::_('Catalogues'), 'index.php?option=com_wishlogue&layout=wishsection');
    JSubMenuHelper::addEntry(JText::_('Member Details'), 'index.php?option=com_wishlogue&layout=memberdetails');
    JSubMenuHelper::addEntry(JText::_('Subcatalogues'), 'index.php?option=com_wishlogue&layout=subcatalogues');
    JSubMenuHelper::addEntry(JText::_('Member Subcatalogues'), 'index.php?option=com_wishlogue&layout=managecatalogue');
    JSubMenuHelper::addEntry(JText::_('Manage Wishes'), 'index.php?option=com_wishlogue&layout=managewishes');
    JSubMenuHelper::addEntry(JText::_('Site Settings'), 'index.php?option=com_wishlogue&layout=sitesettings');
    JSubMenuHelper::addEntry(JText::_('Request Approval'), 'index.php?option=com_wishlogue&layout=requestapproval',true);
    JSubMenuHelper::addEntry(JText::_('Google Adsense'), 'index.php?option=com_wishlogue&layout=googlead');
    JSubMenuHelper::addEntry(JText::_('Wishlogue Ad Space'), 'index.php?option=com_wishlogue&layout=wishlogueadspace');
}else if ($controllerName == 'googlead')
{
    JSubMenuHelper::addEntry(JText::_('Catalogues'), 'index.php?option=com_wishlogue&layout=wishsection');
    JSubMenuHelper::addEntry(JText::_('Member Details'), 'index.php?option=com_wishlogue&layout=memberdetails');
    JSubMenuHelper::addEntry(JText::_('Subcatalogues'), 'index.php?option=com_wishlogue&layout=subcatalogues');
    JSubMenuHelper::addEntry(JText::_('Member Subcatalogues'), 'index.php?option=com_wishlogue&layout=managecatalogue');
    JSubMenuHelper::addEntry(JText::_('Manage Wishes'), 'index.php?option=com_wishlogue&layout=managewishes');
    JSubMenuHelper::addEntry(JText::_('Site Settings'), 'index.php?option=com_wishlogue&layout=sitesettings');
    JSubMenuHelper::addEntry(JText::_('Request Approval'), 'index.php?option=com_wishlogue&layout=requestapproval');
    JSubMenuHelper::addEntry(JText::_('Google AdSense'), 'index.php?option=com_wishlogue&layout=googlead',true);
    JSubMenuHelper::addEntry(JText::_('Wishlogue Ad Space'), 'index.php?option=com_wishlogue&layout=wishlogueadspace');
}else if ($controllerName == 'wishlogueadspace')
{
    JSubMenuHelper::addEntry(JText::_('Catalogues'), 'index.php?option=com_wishlogue&layout=wishsection');
    JSubMenuHelper::addEntry(JText::_('Member Details'), 'index.php?option=com_wishlogue&layout=memberdetails');
    JSubMenuHelper::addEntry(JText::_('Subcatalogues'), 'index.php?option=com_wishlogue&layout=subcatalogues');
    JSubMenuHelper::addEntry(JText::_('Member Subcatalogues'), 'index.php?option=com_wishlogue&layout=managecatalogue');
    JSubMenuHelper::addEntry(JText::_('Manage Wishes'), 'index.php?option=com_wishlogue&layout=managewishes');
    JSubMenuHelper::addEntry(JText::_('Site Settings'), 'index.php?option=com_wishlogue&layout=sitesettings');
    JSubMenuHelper::addEntry(JText::_('Request Approval'), 'index.php?option=com_wishlogue&layout=requestapproval');
    JSubMenuHelper::addEntry(JText::_('Google AdSense'), 'index.php?option=com_wishlogue&layout=googlead');
    JSubMenuHelper::addEntry(JText::_('Wishlogue Ad Space'), 'index.php?option=com_wishlogue&layout=wishlogueadspace',true);
}else if ($controllerName == 'subcatalogues')
{
    JSubMenuHelper::addEntry(JText::_('Catalogues'), 'index.php?option=com_wishlogue&layout=wishsection');
    JSubMenuHelper::addEntry(JText::_('Member Details'), 'index.php?option=com_wishlogue&layout=memberdetails');
    JSubMenuHelper::addEntry(JText::_('Subcatalogues'), 'index.php?option=com_wishlogue&layout=subcatalogues',true);
    JSubMenuHelper::addEntry(JText::_('Member Subcatalogues'), 'index.php?option=com_wishlogue&layout=managecatalogue');
    JSubMenuHelper::addEntry(JText::_('Manage Wishes'), 'index.php?option=com_wishlogue&layout=managewishes');
    JSubMenuHelper::addEntry(JText::_('Site Settings'), 'index.php?option=com_wishlogue&layout=sitesettings');
    JSubMenuHelper::addEntry(JText::_('Request Approval'), 'index.php?option=com_wishlogue&layout=requestapproval');
    JSubMenuHelper::addEntry(JText::_('Google AdSense'), 'index.php?option=com_wishlogue&layout=googlead');
    JSubMenuHelper::addEntry(JText::_('Wishlogue Ad Space'), 'index.php?option=com_wishlogue&layout=wishlogueadspace');
}

switch ($controllerName)
{
    default:
        $controllerName = 'controlpanel';
              case 'wishsection':
                  case 'memberdetails':
                      case 'managecatalogue':
                          case 'managewishes':
                              case 'sitesettings':
                                  case 'requestapproval':
                                      case 'googlead':
										  case 'wishlogueadspace':
											  case 'subcatalogues':
                        // Temporary interceptor
                        $task = JRequest::getCmd('task');
                        require_once( JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php' );
                        $controllerName = 'wishlogueController'.$controllerName;
                        // Create the controller
                        $controller = new $controllerName();
                        // Perform the Request task
                        $controller->execute( JRequest::getCmd('task') );
                        // Redirect if set by the controller
                        $controller->redirect();
                        break;
}
?>