Skip to content

Commit

Permalink
Update to v 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
denysdesign committed Jul 3, 2023
1 parent 5a48903 commit b5003dd
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 0 deletions.
225 changes: 225 additions & 0 deletions plg_cck_field_juicon/juicon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
<?php
/**
* JUIcon for SEBLOD
*
* @package Joomla.Site
* @subpackage plg_cck_field_juicon
*
* @author Denys Nosov, denys@joomla-ua.org
* @copyright 2023 (C) Joomla! Ukraine, https://joomla-ua.org. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

use Joomla\CMS\Layout\FileLayout;

defined('_JEXEC') or die;

/**
* plgCCK_FieldJUIcon
*
* @since 1.0
* @subpackage plg_cck_field_juicon
* @package Joomla.Site
*/
class plgCCK_FieldJUIcon extends JCckPluginField
{
/**
* @since 1.0
* @var string
*/
protected static string $type = 'juicon';

/**
* @since 1.0
* @var string
*/
protected static string $path;

/**
* @param $type
* @param array $data
*
* @return void
* @since 1.0
*/
public function onCCK_FieldConstruct($type, array &$data = []): void
{
if(self::$type !== $type)
{
return;
}

$this->g_onCCK_FieldConstruct($data);
}

/**
* @param $field
* @param $style
* @param array $data
* @param array $config
*
* @return void
* @since 1.0
*/
public static function onCCK_FieldConstruct_SearchSearch(&$field, $style, $data = [], &$config = [])
{
$data[ 'live' ] = null;
$data[ 'match_mode' ] = null;
$data[ 'validation' ] = null;
$data[ 'variation' ] = null;

parent::onCCK_FieldConstruct_SearchSearch($field, $style, $data, $config);
}

/**
* @param $field
* @param $style
* @param array $data
* @param array $config
*
* @return void
* @since 1.0
*/
public static function onCCK_FieldConstruct_TypeForm(&$field, $style, $data = [], &$config = [])
{
$data[ 'live' ] = null;
$data[ 'validation' ] = null;
$data[ 'variation' ] = null;

parent::onCCK_FieldConstruct_TypeForm($field, $style, $data, $config);
}

/**
* @param $field
* @param string $value
* @param array $config
*
* @return void
* @since 1.0
*/
public function onCCK_FieldPrepareContent(&$field, $value = '', &$config = []): void
{
if(self::$type !== $field->type)
{
return;
}

self::g_onCCK_FieldPrepareContent($field, $config);

$options2 = JCckDev::fromJSON($field->options2);
$html = (new FileLayout('icon', JPATH_SITE . '/plugins/cck_field/juicon/tmpl'))->render([
'sprite' => $options2[ 'sprite' ],
'icon' => $field->location,
'size' => $options2[ 'size' ],
'class' => ($options2[ 'class' ] ? : '')
]);

$field->text = $html;
$field->typo_target = 'text';
$field->value = $field->location;
}

/**
* @param $field
* @param string $value
* @param array $config
* @param array $inherit
* @param bool $return
*
* @return void
* @since 1.0
*/
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = [], $inherit = [], $return = false)
{
if(self::$type !== $field->type)
{
return;
}

self::$path = self::g_getPath(self::$type . '/');
self::g_onCCK_FieldPrepareForm($field, $config);

$options2 = JCckDev::fromJSON($field->options2);
$form = (new FileLayout('icon', JPATH_SITE . '/plugins/cck_field/juicon/tmpl'))->render([
'sprite' => $options2[ 'sprite' ],
'icon' => $field->location,
'size' => $options2[ 'size' ],
'class' => ($options2[ 'class' ] ? : '')
]);

$field->form = $form;
$field->value = $field->location;

if($return === true)
{
return $field;
}
}

/**
* @param $field
* @param string $value
* @param array $config
* @param array $inherit
* @param bool $return
*
* @return void
* @since 1.0
*/
public function onCCK_FieldPrepareSearch(&$field, $value = '', &$config = [], $inherit = [], $return = false)
{
if(self::$type !== $field->type)
{
return;
}

$this->onCCK_FieldPrepareForm($field, $value, $config, $inherit, $return);

if($return === true)
{
return $field;
}
}

/**
* @param $field
* @param string $value
* @param array $config
* @param array $inherit
* @param bool $return
*
* @return void|bool
* @since 1.0
*/
public function onCCK_FieldPrepareStore($field, $value = '', &$config = [], $inherit = [], $return = false)
{
if(self::$type !== $field->type)
{
return true;
}
}

/**
* @param $field
* @param array $config
*
* @return mixed
* @since 1.0
*/
public static function onCCK_FieldRenderContent($field, &$config = [])
{
return parent::g_onCCK_FieldRenderContent($field, 'text');
}

/**
* @param $field
* @param array $config
*
* @return mixed
* @since 1.0
*/
public static function onCCK_FieldRenderForm($field, &$config = [])
{
return parent::g_onCCK_FieldRenderForm($field);
}
}
45 changes: 45 additions & 0 deletions plg_cck_field_juicon/juicon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="cck_field" version="3.9" method="upgrade">
<name>plg_cck_field_juicon</name>
<author>Denys Nosov (Joomla! Ukraine)</author>
<authorEmail>denys@joomla-ua.org</authorEmail>
<authorUrl>https://joomla-ua.org</authorUrl>
<copyright>Copyright (C) 2017-2022 Joomla! Ukraine. All Rights Reserved.</copyright>
<license>GNU General Public License version 2 or later.</license>
<creationDate>@date@</creationDate>
<description>JUIcon Field Plug-in for SEBLOD // SEBLOD 4.x - Joomla! Ukraine</description>
<version>@version@</version>

<scriptfile>install/script.php</scriptfile>

<files>
<folder>assets</folder>
<folder>classes</folder>
<folder>install</folder>
<folder>tmpl</folder>
<filename plugin="juicon">juicon.php</filename>
</files>

<languages folder="languages">
<language tag="en-GB">en-GB/plg_cck_field_juicon.ini</language>
<language tag="en-GB">en-GB/plg_cck_field_juicon.sys.ini</language>
</languages>

<config>
<fields name="params" addfieldpath="/libraries/cck/construction/field">
<fieldset name="basic">
<field name="" type="spacer" hr="false" />
</fieldset>

<fieldset name="advanced">
<field name="group" type="text" default="PLG_CCK_FIELD_GROUP_HTML" label="LIB_CCK_GROUP_LABEL" size="60" description="LIB_CCK_FIELD_GROUP_DESC" />
<field name="export" type="cckexport" default="" label="LIB_CCK_EXPORT_LABEL" description="LIB_CCK_FIELD_EXPORT_DESC" />
</fieldset>
</fields>
</config>

<updateservers>
<server type="extension" priority="1" name="JUIcon">https://joomla-ua.org/update/plg/plg_cck_field_juicon.xml</server>
</updateservers>

</extension>
7 changes: 7 additions & 0 deletions plg_cck_field_juicon/languages/en-GB/plg_cck_field_juicon.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PLG_CCK_FIELD_JUICON="JUIcon Field Plug-in for SEBLOD"
PLG_CCK_FIELD_JUICON_LABEL="JUIcon"
PLG_CCK_FIELD_JUICON_LABEL2="JUIcon"
PLG_CCK_FIELD_JUICON_DESC="JUIcon.."
PLG_CCK_FIELD_GROUP_HTML="HTML"
COM_CCK_SPRITE_PATH="Path to SVG sprite"
COM_CCK_ADD_SPRITE_PATH="First, add the path to the svg-sprite relative to the site root. For example: <code>/app/icons/sprite.svg</code>. After saving, you will be able to choose your icon"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PLG_CCK_FIELD_JUICON="JUIcon Field Plug-in for SEBLOD"

0 comments on commit b5003dd

Please sign in to comment.