| Current Path : /home/pteabiscqq/www/plugins/system/lab5_cookie_commander/_admin/elements/ext/ |
| Current File : /home/pteabiscqq/www/plugins/system/lab5_cookie_commander/_admin/elements/ext/documentation.php |
<?php
/**
* Cookie Commander
*
* @author : Lab5 - Dennis Riegelsberger
* @authorUrl : https://lab5.ch
* @copyright : Copyright (C) 2018+ Lab5 - Dennis Riegelsberger. All rights reserved.
* @license : GNU/GPL General Public License version 2 or later
* @project : https://lab5.ch/cookie-commander
* @on JED : https://extensions.joomla.org/extensions/extension/site-management/cookie-control/lab5-cookie-commander/
*
* Built with <3
* Lab5
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* * CHANGELOG :
* * 2020.08.27 : moved generation code into getInput, because renderField will not be called, if field is in component config.xml
* * 2020.08.27 : Added compatibility for use in component config.xml
*/
defined('JPATH_BASE') or die;
if(!defined('DS')) define('DS',DIRECTORY_SEPARATOR);
jimport('joomla.form.formfield');
// \libraries\src\Form\FormField.php$
// \layouts\joomla\form\renderfield.php
class JFormFieldDocumentation extends JFormField {
protected $type = "Documentation";
/////////////////////////////////////////////////////
public function renderField($options = array()) {
/////////////////////////////////////////////////////
// renderField will NOT be called if field is in Component Config
return $this->getInput();
} ///////////////////////////////////////////////////
protected function getLabel() {
/////////////////////////////////////////////////////
return "";
} ///////////////////////////////////////////////////
protected function getInput() {
/////////////////////////////////////////////////////
$description = trim($this->element["description"]);
/////////////////////////
$label = trim($this->element["label"]);
if( !$label ) $label = "Documentation / Manual";
/////////////////////////
$filepath = trim($this->element["filepath"]);
if( !$filepath ) return;
/////////////////////////
$extension = $this->form->getData();
$ismod = $extension->get('module', null);
if( !empty($extension->get('module', null)) ){ // MODULE :
$extension = $extension->get('module');
$extensionpath = "modules/".$extension ;
$configfile = JPATH_ROOT.'/'.$extensionpath.'/'.$extension.'.xml';
}elseif($extension->get('template', null)){ // TEMPLATE :
$extension = $extension->get('template');
$extensionpath = "templates/".$extension ;
$configfile = JPATH_ROOT.'/'.$extensionpath.'/templateDetails.xml';
}elseif($extension->get('folder') && $extension->get('element')){ // PLUGIN :
$folder = $extension->get('folder');
$extension = $extension->get('element');
$extensionpath = 'plugins/'.$folder.'/'.$extension ;
$configfile = JPATH_ROOT.'/'.$extensionpath.'/'.$extension.'.xml';
}else{ // COMPONENT :
$CUR_PATH = explode( DS, str_replace( JPATH_BASE, '', __DIR__ ) );
$extension = ( $CUR_PATH[0] ) ? $CUR_PATH[1] : $CUR_PATH[2] ; // wg. DS as first
$extensionpath = ( $CUR_PATH[0] ) ? $CUR_PATH[0] : $CUR_PATH[1] ; // wg. DS as first
$extensionpath = $extensionpath.'/'.$extension ;
if( str_replace( JPATH_ROOT, '', JPATH_BASE ) ){ // if Admin
$extensionpath = basename( str_replace( JPATH_ROOT, '', JPATH_BASE )).'/'.$extensionpath ;
}
$configfile = JPATH_ROOT.'/'.$extensionpath.'/config.xml';
}
// print_r($extension); exit;
/////////////////////////
$filepath = $extensionpath.'/'.$filepath ;
if( !file_exists( JPATH_SITE.'/'.$filepath )) return; // File not exists
/////////////////////////
$icon_url = "_admin/elements/ext/m/icon-pdf.png";
$html = '';
$html .= '
<div class="lab5-documentation" >
<br>
<hr>
<a target="_parent" href="'.JUri::root( false ).$filepath.'" />
<img class="" style="width:5em;" src="'.JUri::root( false ).$extensionpath.'/'.$icon_url.'" />
<h3> '.$label.' </h3>
'.$description.'
</a>
<hr>
</div>
';
return $html;
} ///////////////////////////////////////////////////
}