Шаблон собственного типа поля
<?php
/**
* @version 1.0.0
* @package com_products
* @copyright Copyright (C) 2011 Amy Stephen. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.html.html');
jimport('joomla.access.access');
jimport('joomla.form.formfield');
/**
* Form Field class for the Joomla Framework.
*
* @package Joomla.Administrator
* @subpackage com_content
* @since 1.6
*/
class JFormField### extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = '###';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput() {
$this->addRessurs();
if(is_array($this->value)) {
$this->val=$this->value;
} else {
$this->val=$this->value ? json_decode($this->value) : array();
}
$html=$this->getView();
return $html;
}
protected function addRessurs() {
$this->baseURI=str_replace($_SERVER['DOCUMENT_ROOT'],'',__DIR__);
$this->baseDIR=__DIR__;
$doc=JFactory::getDocument();
//$doc->addScript('//code.jquery.com/jquery-latest.min.js');
//$doc->addScript('//cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js');
//$doc->addScript('//cdn.jsdelivr.net/npm/sortablejs@1.7.0/Sortable.min.js');
//$doc->addScript('//cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/2.17.0/vuedraggable.min.js');
$doc->addScript($this->baseURI.'/'.strtolower($this->type).'/'.strtolower($this->type).'.js');
$doc->addStyleSheet($this->baseURI.'/'.strtolower($this->type).'/'.strtolower($this->type).'.css');
return true;
}
protected function getView($view = false){
if(!$view) {
$view=strtolower($this->type).'.view.php';
}
ob_start();
include($this->baseDIR .'/'. strtolower($this->type) . '/'. $view);
$html = ob_get_contents();
ob_end_clean();
return $html;
}
public function getLabel() {
return '';
}
}