Skip to content

Commit

Permalink
Merge pull request #10 from chkilel/next
Browse files Browse the repository at this point in the history
upgrade to OCMS 3
  • Loading branch information
chkilel authored Jun 26, 2022
2 parents 338d2a0 + c37c6e5 commit 5f84cff
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 177 deletions.
9 changes: 4 additions & 5 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,20 @@ public function registerListColumnTypes()


/**
* @param $value the JSON value on which the filter is applied
* @param $value the Array value on which the filter is applied
* @param $props associative array with the folowing possible keys (see REEDME.md):
* 'class','width', 'height', 'inline', 'hFlip', 'vFlip', 'flip', 'rotate', 'align', 'color', 'box'
* @return string SVG icon
* @throws ApplicationException
*/
public function iconify($jsonIcon, $props = [])
public function iconify($iconArray, $props = [])
{
$icon = new JsonIcon($jsonIcon);
$icon = new JsonIcon($iconArray);
return $icon->iconify($props);
}


/**
* @param $value the JSON representation of the icon
* @param $value the Array representation of the icon
* @param $column column definition object
* @param $record model record object.
* @return string SVG icon
Expand Down
125 changes: 79 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Icônes Form Widget 🪄 🎉 🎊

[📖 **Release Notes**]

>ℹ️ **Plugin version 3 is compatible only with Octobercms 3 (New Ajax framwork and the backend upgrade to bootstrap 5), please use version 2 of the plugin for OCMS 1 and 2.**
> **You cannot upgrade from version `1.*/2.*` to `3.*`**
---
<br />
Access thousands of SVG icons as a backend form widget.

One library, over **100,000** vector icons, Modern replacement for icon fonts. Fast, easy to use.
One library, over **133,000** vector icons, Modern replacement for icon fonts. Fast, easy to use.

- **128+** icon sets powered by [Iconify](https://iconify.design/)
- Browse the icons on [Iconify](https://icon-sets.iconify.design/) or on [Icônes](https://icones.netlify.app/)
Expand All @@ -22,11 +30,13 @@ You don't need to load any dependency at all.

You can use Font Awesome, Material Design Icons, Unicons, Dashicons, Emoji, ... and many other icon sets on same page or application using one form widget.

# TOC
<br />

**TOC**

- [Icônes Form Widget 🪄 🎉 🎊](#icônes-form-widget----)
- [Advantages of this form widget](#advantages-of-this-form-widget)
- [TOC](#toc)
- [Upgrading from version 1.* 🚨](#upgrading-from-version-1-)
- [Upgrading from version `1.*` to `2.*` 🚨](#upgrading-from-version-1-to-2-)
- [Installation](#installation)
- [Composer](#composer)
- [How to use](#how-to-use)
Expand All @@ -44,7 +54,7 @@ You can use Font Awesome, Material Design Icons, Unicons, Dashicons, Emoji, ...
- [Usage in Backend List](#usage-in-backend-list)


## Upgrading from version 1.* 🚨
## Upgrading from version `1.*` to `2.*` 🚨

Icônes Form Widget 2.0 depend on version 2 of [Iconify Icon Sets](https://github.com/iconify/icon-sets).
If you are upgrading from version 1.* , you need to upgrade your Iconify Icon Sets to version 2.* also.
Expand All @@ -66,7 +76,10 @@ Simply install the plugin from the marketplace, if you run into problems because
### Composer
If you prefer Composer or you run into problems when installing from the marketplace, run the following commands in the project’s root directory:
```bash
composer require chkilel/icones-plugin
composer require chkilel/icones-plugin:^2.0.0 # For Octobercms 1 and 2
# ℹ️ OR
composer require chkilel/icones-plugin:^3.0.0 # For Octobercms 3
# Then
php artisan october:up
```

Expand Down Expand Up @@ -161,100 +174,120 @@ large | ![large field size](https://res.cloudinary.com/chkilel/image/upload/v162
For `iconSets` option, you can choose one or more from the possible values below, if not set, the user can choose from all enabled icon sets in the backend settings:

Possible values |Icon set real name |Total icons
------------- | ------------- | --------------
akar-icons|Akar Icons|363
ant-design|Ant Design Icons|788
bi|Bootstrap Icons|1386
------------- | ------------- | --------------:
academicons|Academicons|149
akar-icons|Akar Icons|398
ant-design|Ant Design Icons|789
arcticons|Arcticons|4304
bi|Bootstrap Icons|1668
bpmn|BPMN|112
brandico|Brandico Font|45
bx|BoxIcons|1525
brandico|Brandico|45
bx|BoxIcons|797
bxl|BoxIcons Logo|153
bxs|BoxIcons Solid|650
bytesize|Bytesize Icons|101
carbon|Carbon|1840
carbon|Carbon|1798
charm|Charm Icons|255
ci|coolicons|412
cib|CoreUI Brands|830
cif|CoreUI Flags|199
cil|CoreUI Free|554
clarity|Clarity|1096
codicon|Codicons|374
circle-flags|Circle Flags|349
clarity|Clarity|1103
codicon|Codicons|413
cryptocurrency|Cryptocurrency Icons|471
dashicons|Dashicons|343
dashicons|Dashicons|342
ei|Evil Icons|70
el|Elusive Icons|304
emojione|Emoji One (Colored)|1834
emojione-monotone|Emoji One (Monotone)|1403
emojione-v1|Emoji One (v1)|1262
entypo|Entypo+|321
entypo-social|Entypo+ Social|76
eos-icons|EOS Icons|239
eos-icons|EOS Icons|253
ep|Element Plus|283
et|Elegant|100
eva|Eva Icons|490
fa|Font Awesome 4|678
fa-brands|Font Awesome 5 Brands|457
fa-regular|Font Awesome 5 Regular|151
fa-solid|Font Awesome 5 Solid|1001
fa6-brands|Font Awesome Brands|462
fa6-regular|Font Awesome Regular|162
fa6-solid|Font Awesome Solid|1387
fad|FontAudio|155
fe|Feather Icon|255
feather|Feather Icons|286
file-icons|File Icons|929
file-icons|File Icons|930
flag|Flag Icons|530
flagpack|Flagpack|255
flat-color-icons|Flat Color Icons|329
flat-ui|Flat UI Icons|100
fluent|Fluent UI System Icons|8566
fluent|Fluent UI System Icons|11468
fontelico|Fontelico|34
fontisto|Fontisto|615
foundation|Foundation|283
fxemoji|Firefox OS Emoji|1034
gala|Gala Icons|51
geo|GeoGlyphs|30
gg|css.gg|704
gis|Font-GIS|336
gis|Font-GIS|344
gridicons|Gridicons|201
grommet-icons|Grommet Icons|614
healthicons|Health Icons|1485
healthicons|Health Icons|1731
heroicons-outline|HeroIcons Outline|230
heroicons-solid|HeroIcons Solid|230
ic|Google Material Icons|9520
ic|Google Material Icons|10945
icomoon-free|IcoMoon Free|491
icon-park|IconPark|2422
icon-park-outline|IconPark Outline|2422
iconoir|Iconoir|941
icon-park|IconPark|2657
icon-park-outline|IconPark Outline|2657
icon-park-solid|IconPark Solid|1937
icon-park-twotone|IconPark TwoTone|1915
iconoir|Iconoir|1151
icons8|Icons8 Windows 10 Icons|234
il|Icalicons|84
ion|IonIcons|1332
iwwa|Innowatio Font|105
jam|Jam Icons|940
la|Line Awesome|1544
line-md|Material Line Icons|250
logos|SVG Logos|1236
line-md|Material Line Icons|298
logos|SVG Logos|1438
ls|Ligature Symbols|348
lucide|Lucide|491
majesticons|Majesticons|420
maki|Maki|204
lucide|Lucide|625
majesticons|Majesticons|760
maki|Maki|208
map|Map Icons|167
mdi|Material Design Icons|6031
material-symbols|Material Symbols|8001
mdi|Material Design Icons|7001
mdi-light|Material Design Light|267
medical-icon|Medical Icons|144
mi|Mono Icons|180
mono-icons|Mono Icons|180
noto|Noto Emoji|3310
nimbus|Nimbus|135
noto|Noto Emoji|3418
noto-v1|Noto Emoji (v1)|2157
octicon|Octicons|454
octicon|Octicons|506
oi|Open Iconic|223
openmoji|OpenMoji|3914
pepicons|Pepicons|316
ph|Phosphor|5206
pixelarticons|Pixelarticons|460
ooui|OOUI|322
openmoji|OpenMoji|4053
pepicons|Pepicons|410
ph|Phosphor|6282
pixelarticons|Pixelarticons|474
prime|Prime Icons|238
ps|PrestaShop Icons|479
radix-icons|Radix Icons|297
quill|Quill Icons|140
radix-icons|Radix Icons|318
raphael|Raphael|266
ri|Remix Icon|2271
si-glyph|SmartIcons Glyph|800
simple-icons|Simple Icons|1992
si-glyph|SmartIcons Glyph|799
simple-icons|Simple Icons|2263
simple-line-icons|Simple line icons|189
subway|Subway Icon Set|306
system-uicons|System UIcons|420
tabler|Tabler Icons|1298
system-uicons|System UIcons|430
tabler|Tabler Icons|2016
teenyicons|Teenyicons|1200
topcoat|TopCoat Icons|89
twemoji|Twitter Emoji|3556
twemoji|Twitter Emoji|3668
typcn|Typicons|336
uil|Unicons|1206
uim|Unicons Monochrome|296
Expand All @@ -263,14 +296,14 @@ uit|Unicons Thin Line|214
uiw|uiw icons|214
vaadin|Vaadin Icons|636
vs|Vesper Icons|159
vscode-icons|VSCode Icons|1084
vscode-icons|VSCode Icons|1139
websymbol|Web Symbols Liga|85
whh|WebHostingHub Glyphs|2125
wi|Weather Icons|228
wi|Weather Icons|219
wpf|Icons8 Windows 8 Icons|200
zmdi|Material Design Iconic Font|777
zondicons|Zondicons|297
<span>| **Total icons for all icon sets**|**102 443**
<span>| **Total icons for all icon sets**|**133 348**


# Settings
Expand Down
20 changes: 9 additions & 11 deletions classes/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static function installIconSet($prefix)


// For optimal seeding, because number of icons can be huge
$chunks = array_chunk($iconsToSave, 500);
$chunks = array_chunk($iconsToSave, 200);

foreach ($chunks as $chunk) {
Icon::insert($chunk);
Expand All @@ -131,35 +131,33 @@ public static function installIconSet($prefix)
}

/**
* Mape a JSON representation of icon's attributes to an Icon model
* @param $jsonIcon
* Mape the arry representation of icon's attributes to an Icon model
* @param $iconArray
* @return Icon
*/
public static function mapIcon($jsonIcon)
public static function mapIcon($iconArray)
{
$keys = [
"id", "icon_set_id", "name", "parent", "icon_set_name", "body", "hidden",
"id", "icon_set_id", "name", "parent", "icon_set_name", "readable_name", "body", "hidden",
"left", "top", "width", "height", "rotate", "hFlip", "vFlip",
"inlineTop", "inlineHeight", "verticalAlign"
];

// We check if the given value is a Json representation of an icon.
$iconArray = json_decode($jsonIcon, true) ?? [];
// dd($iconArray,$jsonIcon, gettype($jsonIcon) );
// We check if the given value is an Array representation of an icon.
$iconArrayKeys = array_keys($iconArray);
$isIcon = count(array_diff($keys, $iconArrayKeys)) == 0;

if ($isIcon) {
//Although we could grab the model by its Id, We construct the object from the Json,
//Although we could grab the model by its Id, We construct the object from the array,
// in case the icon is no more in DB if the icon set is deleted for example
$icon = new Icon();
foreach ($iconArray as $key => $attribute) {
$icon->{$key} = $attribute;
}
} else {
throw new ApplicationException(trans("chkilel.icones::lang.formwidgets.error_wrong_variable_type", [
'variable' => $jsonIcon,
'type' =>gettype($jsonIcon),
'variable' => $iconArray,
'type' =>gettype($iconArray),
]));
}

Expand Down
4 changes: 1 addition & 3 deletions controllers/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ public function __construct()

public function index()
{

$this->bodyClass = 'compact-container';
$this->vars['iconSetsPaginator'] = $this->iconSetsPaginator(1);
}

/**
* Handler for installing icon set
* Handler for installing iconset
* @return array|void
* @throws \SystemException
*/
Expand Down Expand Up @@ -171,7 +170,6 @@ public function iconSetsPaginator($page)
$query->where('is_installed', true);
}

// TODO paginate
// Active ones first ordred by name
$iconSetsPaginator = $query
->orderBy('is_enabled', 'desc')
Expand Down
Loading

0 comments on commit 5f84cff

Please sign in to comment.