<?php
/**
 * @author      Lefteris Kavadas
 * @copyright   Copyright (c) 2016 - 2018 Lefteris Kavadas / firecoders.com
 * @license     GNU General Public License version 3 or later
 */
defined('_JEXEC') or die;

use Joomla\Registry\Registry;

class Route66ViewPreview extends JViewLegacy
{
	public function display($tpl = null)
	{
  /*  $application = JFactory::getApplication();
    $application->input->set('view', 'article');
    $application->input->set('id', '3');

    require_once JPATH_SITE.'/components/com_content/controller.php';
    $controller = new ContentController(array('base_path' => JPATH_SITE.'/components/com_content'));
    $controller->execute('');
    die;*/

    require_once JPATH_SITE.'/components/com_content/views/article/view.html.php';
    $view = new ContentViewArticle();
    var_dump($view->display());
    die;
    $application = JFactory::getApplication();
    $application->input->set('view', 'article');
    $controller = new JControllerLegacy(array('base_path' => JPATH_SITE.'/components/com_content'));
    $controller->execute('');
    die;





		$application = JFactory::getApplication();
		$url = $application->input->getString('url');
		$options = new Registry();
		$options->set('timeout', 15);
		$http = JHttpFactory::getHttp($options);

    //$user = JFactory::getUser();
    //$site = JApplication::getInstance('site');
    //$result = $site->login(array('username' => $user->username, 'password' => $user->password));
    //var_dump($result);
    //die;
		try
		{
			$response = $http->get($url);

			if ($response && $response->code == 200)
			{
				$buffer = $response->body;
        var_dump($response->body);
        die;
			}
			else
			{
				$this->out('Failed downloading image ' . $src);
			}
		}
		catch (\Exception $e)
		{
			die('error');
		}
	}
}
