<?php

/**
 * @package         Smile Pack
 * @version         1.2.3 Pro
 * 
 * @author          Tassos Marinos <info@tassos.gr>
 * @link            http://www.tassos.gr
 * @copyright       Copyright © 2019 Tassos Marinos All Rights Reserved
 * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/

defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
use NRFramework\Extension;

$download_key = \NRFramework\Functions::getDownloadKey();



function tabSetStart($active, $selector)
{
    echo defined('nrJ4') ? HTMLHelper::_('uitab.startTabSet', $selector, ['active' => $active, 'recall' => true, 'orientation' => 'horizontal']) : HTMLHelper::_('bootstrap.startTabSet', $selector, ['active' => $active]);;
}

function tabSetEnd()
{
    echo defined('nrJ4') ? HTMLHelper::_('uitab.endTabSet') : HTMLHelper::_('bootstrap.endTabSet');;
}

function tabStart($name, $title, $selector)
{
    echo defined('nrJ4') ? HTMLHelper::_('uitab.addTab', $selector, $name, Text::_($title)) : HTMLHelper::_('bootstrap.addTab', $selector, $name, Text::_($title));
}

function tabEnd()
{
    echo defined('nrJ4') ? HTMLHelper::_('uitab.endTab') : HTMLHelper::_('bootstrap.endTab');
}

HTMLHelper::stylesheet('com_smilepack/smilepack.sys.css', ['relative' => true, 'version' => 'auto']);
if (!defined('nrJ4'))
{
	HTMLHelper::stylesheet('com_smilepack/smilepack-j3.sys.css', ['relative' => true, 'version' => 'auto']);
}
?>
<div class="smilepack-dashboard <?php echo defined('nrJ4') ? 'row' : 'row-fluid' ?>">
	<?php
	// Display extension notices
	\NRFramework\Notices\Notices::getInstance([
		'ext_element' => 'com_smilepack',
		'ext_xml' => 'com_smilepack',
		'exclude' => [
			'Geolocation'
		]
	])->show();
	?>

	<div class="smilepack-dashboard--content span9 col-md-9">
		<div class="smilepack-dashboard--content--header">
			<h2 class="title"><?php echo Text::_('COM_SMILEPACK_WELCOME_TITLE'); ?></h2>
			<div class="description"><?php echo Text::_('COM_SMILEPACK_WELCOME_DESC'); ?></div>
		</div>
		<div class="smilepack-dashboard--content--body">
			<?php
			tabSetStart('modules', 'sections');

			tabStart('modules', Text::_('COM_SMILEPACK_MODULES'), 'sections');
				require __DIR__ . '/pages/modules.php';
			tabEnd();

			tabStart('smart_tags', Text::_('COM_SMILEPACK_SMART_TAGS'), 'sections');
				require __DIR__ . '/pages/smarttags.php';
			tabEnd();

			tabStart('display_conditions', Text::_('NR_PUBLISHING_ASSIGNMENTS'), 'sections');
				require __DIR__ . '/pages/display_conditions.php';
			tabEnd();
			
			tabStart('widgets', Text::_('COM_SMILEPACK_WIDGETS'), 'sections');
				require __DIR__ . '/pages/widgets.php';
			tabEnd();

			tabSetEnd();
			?>
		</div>
	</div>
	<div class="smilepack-dashboard--sidebar span3 col-md-3">
		<div class="smilepack-dashboard--sidebar--item">
			<h4 class="smilepack-dashboard--sidebar--item--title"><?php echo Text::_('COM_SMILEPACK_STATUS'); ?></h4>
			<div class="smilepack-dashboard--sidebar--item--content">
				<div><?php echo Text::_('COM_SMILEPACK'); ?> <?php echo NRFramework\Functions::getExtensionVersion('com_smilepack', true); ?></div>
				<?php
				if (!$download_key)
				{
					$tassosFrameworkExtensionID = NRFramework\Functions::getExtensionID('nrframework', 'system');
					$tassosFrameworkPluginURL  = 'index.php?option=com_plugins&task=plugin.edit&extension_id=' . $tassosFrameworkExtensionID . '#jform_params_key';
					?>
					<div class="red-text"><?php echo Text::_('NR_DOWNLOAD_KEY_MISSING'); ?></div>
					<div><a href="<?php echo Uri::base() . $tassosFrameworkPluginURL; ?>" target="_blank" class="setup_key">Setup Download Key</a></div>
					<?php
				}
				?>
			</div>
			<div class="actions">
				<a href="https://www.tassos.gr/joomla-extensions/smile-pack/changelog" target="_blank"><?php echo Text::_('NR_CHANGELOG'); ?></a>
				<a href="https://www.tassos.gr/joomla-extensions/smile-pack/roadmap" target="_blank"><?php echo Text::_('COM_SMILEPACK_ROADMAP'); ?></a>
			</div>
		</div>
		
		<div class="smilepack-dashboard--sidebar--item">
			<h4 class="smilepack-dashboard--sidebar--item--title"><?php echo Text::_('COM_SMILEPACK_KNOWLEDGE_BASE'); ?></h4>
			<div class="smilepack-dashboard--sidebar--item--content">
				<ul>
					<li>
						<a href="https://www.tassos.gr/joomla-extensions/smile-pack/docs/getting-started-smile-pack" target="_blank"><?php echo Text::_('COM_SMILEPACK_KB_GETTING_STARTED'); ?></a>
					</li>
					<li>
						<a href="https://www.tassos.gr/joomla-extensions/smile-pack/docs/display-conditions" target="_blank"><?php echo Text::_('COM_SMILEPACK_KB_USING_DISPLAY_CONDITIONS'); ?></a>
					</li>
					<li>
						<a href="https://www.tassos.gr/joomla-extensions/smile-pack/docs/video-module" target="_blank"><?php echo Text::_('COM_SMILEPACK_KB_USING_VIDEO_MODULE'); ?></a>
					</li>
					<li>
						<a href="https://www.tassos.gr/joomla-extensions/smile-pack/docs/map-module" target="_blank"><?php echo Text::_('COM_SMILEPACK_KB_USING_MAP_MODULE'); ?></a>
					</li>
					<li>
						<a href="https://www.tassos.gr/joomla-extensions/smile-pack/docs/accordion-module" target="_blank"><?php echo Text::_('COM_SMILEPACK_KB_USING_ACCORDION_MODULE'); ?></a>
					</li>
					<li>
						<a href="https://www.tassos.gr/joomla-extensions/smile-pack/docs/gallery-module" target="_blank"><?php echo Text::_('COM_SMILEPACK_KB_USING_GALLERY_MODULE'); ?></a>
					</li>
					<li>
						<a href="https://www.tassos.gr/joomla-extensions/smile-pack/docs/paypal-module" target="_blank"><?php echo Text::_('COM_SMILEPACK_KB_USING_PAYPAL_MODULE'); ?></a>
					</li>
					<li>
						<a href="https://www.tassos.gr/joomla-extensions/smile-pack/docs/smart-tags-sp" target="_blank"><?php echo Text::_('COM_SMILEPACK_KB_USING_SMART_TAGS'); ?></a>
					</li>
				</ul>
			</div>
		</div>
		<div class="smilepack-dashboard--sidebar--item">
			<h4 class="smilepack-dashboard--sidebar--item--title"><?php echo Text::_('COM_SMILEPACK_SPREAD_THE_LOVE'); ?></h4>
			<div class="smilepack-dashboard--sidebar--item--content">
				<?php echo Text::sprintf('COM_SMILEPACK_WRITE_REVIEW', Extension::getExtensionJEDURL('com_smilepack')); ?>
			</div>
		</div>
		<div class="smilepack-dashboard--sidebar--item">
			<h4 class="smilepack-dashboard--sidebar--item--title"><?php echo Text::_('NR_HELP_WITH_TRANSLATIONS'); ?></h4>
			<div class="smilepack-dashboard--sidebar--item--content">
				<?php echo Text::sprintf('NR_TRANSLATE_INTEREST', Text::_('COM_SMILEPACK')); ?> <a href="https://www.transifex.com/tassosgr/smile-pack/" target="_blank" class="underline-link"><?php echo Text::_('COM_SMILEPACK_GET_STARTED'); ?></a>.
			</div>
		</div>
	</div>
	<?php include_once(JPATH_COMPONENT_ADMINISTRATOR."/layouts/footer.php"); ?>
</div>