| Current Path : /home/digilove/public_html/plugins/content/aimyindexnow/fields/ |
| Current File : /home/digilove/public_html/plugins/content/aimyindexnow/fields/indexnowkey.php |
<?php
/*
* Copyright (c) 2020-2024 Aimy Extensions, Netzum Sorglos Software GmbH
*
* https://www.aimy-extensions.com/
*
* License: GNU GPLv2, see LICENSE.txt within distribution and/or
* https://www.aimy-extensions.com/software-license.html
*/
defined( '_JEXEC' ) or die(); require_once( __DIR__ . '/../helpers/PluginHelper.php' ); use Joomla\CMS\Form\FormField; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Uri\Uri; use Joomla\CMS\Language\Text; use Aimy\IndexNow\Helpers\PluginHelper; class JFormFieldIndexNowKey extends FormField { protected $type = 'indexnowkey'; protected $layout = 'joomla.form.field.text'; public function getInput() { HTMLHelper::_( 'jquery.framework' ); Factory::getDocument() ->addScript( Uri::root() . '/media/plg_aimyindexnow/keygen.js' ) ->addScriptDeclaration( 'jQuery(document).ready(function($)' . '{' . '$("<button></button>").text("' . Text::_( 'AIMY_IN_GENERATE_KEY' ) . '")' . '.addClass("btn btn-secondary btn-sm indexnowkeygen")' . '.click(' . 'function(e){' . '$("#' . $this->id . '").val(' . 'AimyIndexNowKeyGen(24)' . ');' . 'return e.preventDefault();' . '}).insertAfter($("#' . $this->id . '"));' . '});' ) ->addStyleDeclaration( PluginHelper::isJoomla3() ? '.indexnowkeygen{margin-left:12px}' : '.indexnowkeygen{margin-top:12px;}' ); return $this->getRenderer( $this->layout ) ->render( $this->getLayoutData() ); } public function getLabel() { if ( empty( $this->element[ 'label' ] ) ) { return ''; } $label = Text::_( $this->element[ 'label' ] ); $dsc = ''; $classes = array(); if ( ! empty( $this->class ) ) { $classes[] = $this->class; } if ( $this->required ) { $classes[] = 'required'; } if ( PluginHelper::isJoomla3() && isset( $this->element[ 'description' ] ) ) { $dsc = sprintf( ' data-content="%s" data-original-title="%s"', htmlspecialchars( Text::_( $this->element[ 'description' ] ) ), htmlspecialchars( $label ) ); $classes[] = 'hasPopover'; } return sprintf( '<label id="%s" class="%s"%s>%s</label>', $this->id . '-lbl', implode( ' ', $classes ), $dsc, $label ); } protected function getLayoutData() { return array_merge( array( 'options' => array(), 'addonBefore' => '', 'addonAfter' => '', 'dirname' => '' ), parent::getLayoutData(), ); } }