<?php
/*
 *
 * @package		ARI Smart Content
 * @author		ARI Soft
 * @copyright	Copyright (c) 2011 www.ari-soft.com. All rights reserved
 * @license		GNU/GPL (http://www.gnu.org/copyleft/gpl.html)
 *
 */

(defined('_JEXEC') && defined('ARI_FRAMEWORK_LOADED')) or die;

AriKernel::import('Joomla.Controllers.Controller');
AriKernel::import('Data.DataFilter');
AriKernel::import('Web.Controls.Data.MultiPageDataTable');
AriKernel::import('Application.ARISmartContent.Providers.ProvidersHelper');

class AriSmartContentControllerSource extends AriController
{
    function edit()
    {
        $jInput = JFactory::getApplication()->input;
        $sourceId = $jInput->request->get('Id', null, 'int');

        $model = $this->getModel('Providersource');
        $source = $model->getSource($sourceId);

        if (empty($source))
        {
            echo JText::_('COM_ARISMARTCONTENT_LABEL_SELECTEDSOURCENOTEXIST');
            exit();
        }

        @list($sourceGroup, $sourceType) = explode('_', $source->SourceType->SystemName);
        $sourceType = 'provider_' . $sourceGroup . '_source_' . $sourceType;

        $direct = $jInput->request->get('direct', null, 'bool');
        $callback = $jInput->request->get('callback', null, 'raw');

        $this->redirect('index.php?option=com_arismartcontent&view=' . $sourceType . '&task=edit&Id=' . $sourceId . ($direct ? '&direct=1' : '') . ($callback ? '&callback=' . $callback : ''));
    }
}