helper = $this->loadHelper('fontello'); } /** * return sort order for position in admin menu * * @return int */ public function getMenuSort() { return 300; } /** * Handle ZIP uploads. * * @return void */ public function handle() { global $ID; if (($_POST['fontello_action'] ?? '') === 'save_enabled') { if (!checkSecurityToken()) { msg($this->getLang('err_bad_token'), -1); return; } $enabledIcons = $_POST['enabled_icons'] ?? []; if (!is_array($enabledIcons)) $enabledIcons = []; try { $this->helper->saveEnabledIconNames($enabledIcons); msg($this->getLang('activation_ok'), 1); send_redirect(wl($ID, ['do' => 'admin', 'page' => 'fontello'], true, '&')); } catch (RuntimeException $exception) { msg(hsc($exception->getMessage()), -1); } return; } if ( !isset($_FILES['fontellozip']) || ($_FILES['fontellozip']['error'] ?? UPLOAD_ERR_NO_FILE) === UPLOAD_ERR_NO_FILE ) { return; } if (!checkSecurityToken()) { msg($this->getLang('err_bad_token'), -1); return; } try { $this->helper->importPackage($_FILES['fontellozip']); msg($this->getLang('upload_ok'), 1); send_redirect(wl($ID, ['do' => 'admin', 'page' => 'fontello'], true, '&')); } catch (RuntimeException $exception) { msg(hsc($exception->getMessage()), -1); } } /** * Output the admin page. * * @return void */ public function html() { global $lang; $package = $this->helper->getPackageInfo(); echo '

' . hsc($this->getLang('menu')) . '

'; echo $this->locale_xhtml('intro'); echo '
'; formSecurityToken(); echo '

'; echo '
'; echo ' '; echo ''; echo '

'; echo '
'; if ($package === null) { echo '

' . hsc($this->getLang('no_package')) . '

'; return; } echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
' . hsc($this->getLang('current_zip')) . '' . hsc($package['zip_name']) . '
' . hsc($this->getLang('current_prefix')) . '' . hsc($package['prefix']) . '
' . hsc($this->getLang('current_count')) . '' . (int) $package['icon_count'] . '
' . hsc($this->getLang('current_enabled')) . '' . (int) $package['enabled_count'] . '
' . hsc($this->getLang('current_imported')) . '' . hsc($package['imported_at'] ? $package['imported_at'] : $this->getLang('unknown')) . '
'; echo '

' . hsc($this->getLang('icons_heading')) . '

'; echo '
'; formSecurityToken(); echo ''; echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; foreach ($package['icons'] as $icon) { $fieldId = 'fontello-enabled-' . preg_replace('/[^A-Za-z0-9_-]/', '-', $icon['name']); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
' . hsc($this->getLang('icon_enabled')) . '' . hsc($this->getLang('icon_name')) . '' . hsc($this->getLang('icon_class')) . '' . hsc($this->getLang('icon_preview')) . '
' . hsc($icon['class']) . '
'; echo '

'; echo '
'; } }