| 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/about.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.03.05 : Added extension differentiation "template"
* * 2020.08.17 : Made 'Thanks' dynamik, loadable via the extension XML
* * 2020.08.27 : Added compatibility for use in component config.xml
*/
defined('_JEXEC') or die;
if(!defined('DS')) define('DS',DIRECTORY_SEPARATOR);
jimport('joomla.form.formfield');
JHtml::_('behavior.framework', true); // für CSS etc (?)
class JFormFieldAbout extends JFormField {
/////////////////////////////////////////////////////
protected $type = 'About';
/////////////////////////////////////////////////////
protected function getInput() {
/////////////////////////////////////////////////////
//return '<script src="'.JURI::root().$this->element['path'].'script.js"></script>';
//JFactory::getDocument()->addStyleSheet(JURI::root().$this->element['path'].'style.css');
$csspath = str_replace( JPATH_ROOT.DIRECTORY_SEPARATOR, '', __DIR__ ).'/m/style.css';
$csspath = JURI::root(false).str_replace( DIRECTORY_SEPARATOR, '/', $csspath );
JFactory::getDocument()->addStyleSheet( $csspath );
//////////////////////////////////////////////////
// EXTENSION INFO
//////////////////////////////////////////////////
$extension = $this->form->getData();
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.'/'.(str_replace("com_", "", $extension)).'.xml';
}
// print_r($extension); exit;
/////////////////////////
$xml = simplexml_load_file($configfile);
$ver = $xml->version;
$id = strtoupper($extension);
$lastupdated = '';
// $lastupdated = ($xml->updateDate) ? ' <small>(last updated '.$xml->updateDate.')</small>' : '';
//////////////////////////////////////////////////
/////////////////////////
// CREDITS
/////////////////////////
$credits = "";
//////////////////////////
// via Language String ( old )
//////////////////////////
if( JText::_($id.'_CREDITS') != $id.'_CREDITS' ){ // Language String actually exists because it's translated.
$credits .= JText::_($id.'_CREDITS');
}
//////////////////////////
// via XML
//////////////////////////
if( count($xml->thanks) && count($xml->thanks->thank)){
$credits .= "\n"."<p><span>special thanks go to :</span></p>"."\n";
$credits .= "<ul>"."\n";
// foreach( $thanks as $thank ){
foreach( $xml->thanks->thank as $thank ){
$credits .= "\n"."<li>".$thank."</li>";
}
$credits .= "</ul>"."\n";
}
//////////////////////////
/////////////////////////
$TITLE = $xml->name;
/////////////////////////
if(empty($TITLE)) $TITLE = 'PLG_'.$id;
if( strtoupper($TITLE) == JText::_($TITLE) ) $TITLE = $id; // not translated or not LNG CONST =>
$TITLE = trim( JText::_($TITLE) );
/////////////////////////
$shortname = $xml->shortname;
/////////////////////////
if(empty($shortname)) $shortname = $id.'_SHORTNAME';
if( strtoupper($shortname) == JText::_($shortname) ) $shortname = 'PLG_'.$id; // not translated or not LNG CONST =>
if( strtoupper($shortname) == JText::_($shortname) ) $shortname = $id; // not translated or not LNG CONST =>
if( strtoupper($shortname) == JText::_($shortname) ) $shortname = $TITLE; // not translated or not LNG CONST =>
$shortname = JText::_($shortname);
// if( strpos( $shortname, '-' ) !== false ) $shortname = substr( $shortname, strpos( $shortname, '-' )+1);
$shortname = trim($shortname);
/////////////////////////
$DESC = $xml->description;
/////////////////////////
if(empty($DESC)) $DESC = 'PLG_'.$id.'_DESCRIPTION';
if( strtoupper($DESC) == JText::_($DESC) ) $DESC = $id.'_DESCRIPTION'; // not translated or not LNG CONST =>
$DESC = trim( JText::_($DESC) );
/////////////////////////
// HTML
/////////////////////////
$return = "<div class='lab5-descarea'><h1>".$TITLE."<small> ver. ".$xml->version."</small></h1>";
// $lastupdated.
if($xml->project && !empty($xml->project)){
$return .=
"<p class='projectwebsite'><a href='".$xml->project."' target='_blank'>Learn more on the ".$shortname." project website.</a></p>";
}
$return .= "
<p class='smaller license'>".$shortname." is released under the <a target='_blank' href='".$xml->licenseUrl."'>".$xml->license.".</a></p>".
"<div class='descriptionbox'> ";
/////////////////////////
if( stripos( __DIR__, '_admin' ) !== false ){
$logourl = '_admin';
}else{
$logourl = 'admin';
}
$logourl = JUri::root(true).'/'.$extensionpath.'/'.$logourl.'/elements/ext/m/lab5.jpg';
/////////////////////////
$return .=
//<p>Description :</p>
$DESC.'
</div>'.
'<img height="30" width="auto" src="'.$logourl.'" border="0" style="clear:both; float:none; margin:20px 0px;">
' . $credits . '
</div>'.
// '<img src="https://piwik.lab5.ch/matomo.php?idsite=11&rec=1&_rcn='.$extension.'&_rck='.$extension.'_jadmin_tab_about&action_name='.$_SERVER['HTTP_HOST'].'" style="border:0"/>'.
'';
return $return;
}
/////////////////////////////////////////////////////
//protected function getLabel() { }
}