| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
This program is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of the GNU General Public License |
| 6 |
as published by the Free Software Foundation; either version 2 |
| 7 |
of the License, or (at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program; if not, write to the Free Software |
| 16 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 |
|
| 18 |
Copyright 2017 Buttonizer |
| 19 |
*/ |
| 20 |
namespace Buttonizer\Admin; |
| 21 |
|
| 22 |
# No script kiddies |
| 23 |
defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
| 24 |
class IconManager |
| 25 |
{ |
| 26 |
private $aFontAwesome = array() ; |
| 27 |
public function __construct( $aFontAwesome ) |
| 28 |
{ |
| 29 |
$this->aFontAwesome = $aFontAwesome; |
| 30 |
} |
| 31 |
|
| 32 |
public function generator( $aData ) |
| 33 |
{ |
| 34 |
if ( !isset( $aData['image'] ) || !isset( $aData['icon'] ) || !isset( $aData['image_fieldname'] ) || !isset( $aData['icon_fieldname'] ) ) { |
| 35 |
return 'Invalid.'; |
| 36 |
} |
| 37 |
$p = $this->generator_start( $aData ); |
| 38 |
return $p; |
| 39 |
} |
| 40 |
|
| 41 |
private function generator_start( $aData ) |
| 42 |
{ |
| 43 |
$p = '<div class="icon-or-image" data-type="' . (( $aData['image'] != '' ? 'image' : 'icon' )) . '"> |
| 44 |
<div class="icon-placeholder" ' . (( $aData['image'] != '' ? 'style="display: none;"' : '' )) . '> |
| 45 |
<div class="placeholder-choose"> |
| 46 |
or <span class="buttonizer-click-to-pro" style="color: #0073aa; text-decoration: underline; cursor: pointer;">upload image (PRO ONLY)</span> |
| 47 |
</div>'; |
| 48 |
$p .= '<select name="' . $aData['icon_fieldname'] . '" id="' . $fieldName . '" style="font-family: \'FontAwesome\', \'Helvetica\';" class="fa-chooser">'; |
| 49 |
$p .= '<option value="+">+</option>'; |
| 50 |
foreach ( $this->aFontAwesome as $key => $row ) { |
| 51 |
$p .= '<option value="' . $key . '" ' . (( $aData['icon'] == $key ? 'selected="selected"' : '' )) . '>' . $row . ' ' . $key . '</option>'; |
| 52 |
} |
| 53 |
$p .= '</select>'; |
| 54 |
$p .= '</div>'; |
| 55 |
return $p; |
| 56 |
} |
| 57 |
|
| 58 |
} |