<?php

/**
 * @copyright	Copyright (C) 2011 Cedric KEIFLIN alias ced1870
 * https://www.joomlack.fr
 * @license		GNU/GPL
 * */
// no direct access
defined('_JEXEC') or die('Restricted access');

require_once JPATH_ADMINISTRATOR . '/components/com_carouselck/helpers/ckframework.php';
require_once JPATH_ADMINISTRATOR . '/components/com_carouselck/helpers/helper.php';

Carouselck\CKFramework::load();
CarouselckHelper::loadCkbox();

\Joomla\CMS\Language\Text::script('CAROUSELCK_ADDSLIDE');
\Joomla\CMS\Language\Text::script('CAROUSELCK_SELECTIMAGE');
\Joomla\CMS\Language\Text::script('CAROUSELCK_SELECT_LINK');
\Joomla\CMS\Language\Text::script('CAROUSELCK_REMOVE2');
\Joomla\CMS\Language\Text::script('CAROUSELCK_SELECT');
\Joomla\CMS\Language\Text::script('CAROUSELCK_CAPTION');
\Joomla\CMS\Language\Text::script('CAROUSELCK_USETOSHOW');
\Joomla\CMS\Language\Text::script('CAROUSELCK_IMAGE');
\Joomla\CMS\Language\Text::script('CAROUSELCK_VIDEO');
\Joomla\CMS\Language\Text::script('CAROUSELCK_TEXTOPTIONS');
\Joomla\CMS\Language\Text::script('CAROUSELCK_IMAGEOPTIONS');
\Joomla\CMS\Language\Text::script('CAROUSELCK_LINKOPTIONS');
\Joomla\CMS\Language\Text::script('CAROUSELCK_VIDEOOPTIONS');
\Joomla\CMS\Language\Text::script('CAROUSELCK_ALIGNEMENT_LABEL');
\Joomla\CMS\Language\Text::script('CAROUSELCK_TOPLEFT');
\Joomla\CMS\Language\Text::script('CAROUSELCK_TOPCENTER');
\Joomla\CMS\Language\Text::script('CAROUSELCK_TOPRIGHT');
\Joomla\CMS\Language\Text::script('CAROUSELCK_MIDDLELEFT');
\Joomla\CMS\Language\Text::script('CAROUSELCK_CENTER');
\Joomla\CMS\Language\Text::script('CAROUSELCK_MIDDLERIGHT');
\Joomla\CMS\Language\Text::script('CAROUSELCK_BOTTOMLEFT');
\Joomla\CMS\Language\Text::script('CAROUSELCK_BOTTOMCENTER');
\Joomla\CMS\Language\Text::script('CAROUSELCK_BOTTOMRIGHT');
\Joomla\CMS\Language\Text::script('CAROUSELCK_LINK');
\Joomla\CMS\Language\Text::script('CAROUSELCK_TARGET');
\Joomla\CMS\Language\Text::script('CAROUSELCK_SAMEWINDOW');
\Joomla\CMS\Language\Text::script('CAROUSELCK_NEWWINDOW');
\Joomla\CMS\Language\Text::script('CAROUSELCK_VIDEOURL');
\Joomla\CMS\Language\Text::script('CAROUSELCK_REMOVE');
\Joomla\CMS\Language\Text::script('CAROUSELCK_IMPORTFROMFOLDER');
\Joomla\CMS\Language\Text::script('CAROUSELCK_ARTICLEOPTIONS');
\Joomla\CMS\Language\Text::script('CAROUSELCK_SLIDETIME');
\Joomla\CMS\Language\Text::script('CAROUSELCK_CLEAR');
\Joomla\CMS\Language\Text::script('CAROUSELCK_SELECT');
\Joomla\CMS\Language\Text::script('CAROUSELCK_TITLE');
\Joomla\CMS\Language\Text::script('CAROUSELCK_STARTDATE');
\Joomla\CMS\Language\Text::script('CAROUSELCK_ENDDATE');
\Joomla\CMS\Language\Text::script('CAROUSELCK_SAVE');
\Joomla\CMS\Language\Text::script('CAROUSELCK_TEXT_CUSTOM');
\Joomla\CMS\Language\Text::script('CAROUSELCK_ARTICLE');
\Joomla\CMS\Language\Text::script('CAROUSELCK_TEXT');




class JFormFieldCkslidesmanager extends \Joomla\CMS\Form\FormField {

	protected $type = 'ckslidesmanager';

	protected function getInput() {

		// loads the language files from the frontend
		$lang	= \Joomla\CMS\Factory::getLanguage();
		$lang->load('com_carouselck', JPATH_SITE . '/components/com_carouselck', $lang->getTag(), false);
		$lang->load('com_carouselck', JPATH_SITE, $lang->getTag(), false);

		require_once(JPATH_ROOT . '/administrator/components/com_carouselck/helpers/defines.js.php');
		$path = 'media/com_carouselck/assets/elements/ckslidesmanager/';
		\Joomla\CMS\HTML\HTMLHelper::_('jquery.framework');
		// \Joomla\CMS\HTML\HTMLHelper::_('jquery.ui', array('core', 'sortable'));
		\Joomla\CMS\HTML\HTMLHelper::_('script', 'media/com_carouselck/assets/jquery-uick-custom.js');
		\Joomla\CMS\HTML\HTMLHelper::_('script', 'media/com_carouselck/assets/admin.js');
		\Joomla\CMS\HTML\HTMLHelper::_('script', $path . 'ckslidesmanager.js');
		if (\Carouselck\CKFof::isSite()) {
			\Joomla\CMS\HTML\HTMLHelper::_('stylesheet', 'media/com_carouselck/assets/front-edition.css');
		}
		
		\Joomla\CMS\HTML\HTMLHelper::_('stylesheet', 'media/com_carouselck/assets/jquery-ui.min.css');
		\Joomla\CMS\HTML\HTMLHelper::_('stylesheet', $path . 'ckslidesmanager.css');

		$html = '<input name="' . $this->name . '" id="ckslides" type="hidden" value="' . $this->value . '" />'
				. '<div class="ckaddslide ckbutton ckbutton-success" onclick="javascript:ckAddSlide();"><i class="far fa-plus-square"></i> ' . \Joomla\CMS\Language\Text::_('CAROUSELCK_ADDSLIDE') . '</div>'
				. '<ul id="ckslideslist" class="ckinterface" style="clear:both;"></ul>'
				. '<div class="ckaddslide ckbutton ckbutton-success" onclick="javascript:ckAddSlide();"><i class="far fa-plus-square"></i> ' . \Joomla\CMS\Language\Text::_('CAROUSELCK_ADDSLIDE') . '</div>';

		return $html;
	}

	protected function getLabel() {

		return '';
	}

//	protected function getArticlesList() {
//		$db = & \Joomla\CMS\Factory::getDBO();
//
//		$query = "SELECT id, title FROM #__content WHERE state = 1 LIMIT 2;";
//		$db->setQuery($query);
//		$row = $db->loadObjectList('id');
//		var_dump($row);
//		return json_encode($row);
//	}

}

