From cd0446e080df20609b24d27a4c5b4ebd52a51dd1 Mon Sep 17 00:00:00 2001 From: dignajar Date: Sun, 7 Feb 2021 17:19:24 +0100 Subject: [PATCH] Settings trough API, change user password via API, refactor code --- ...figure-plugin.php => plugins-settings.php} | 0 bl-kernel/admin/themes/booty/css/bludit.css | 10 + bl-kernel/admin/views/content.php | 75 +- bl-kernel/admin/views/edit-user.php | 660 +++++++-------- ...figure-plugin.php => plugins-settings.php} | 0 bl-kernel/admin/views/plugins.php | 133 +-- bl-kernel/admin/views/settings.php | 762 +++++++++--------- bl-kernel/boot/rules/60.plugins.php | 3 + bl-kernel/functions.php | 57 +- bl-kernel/helpers/bootstrap.class.php | 112 +-- bl-kernel/js/api.js | 25 + bl-kernel/user.class.php | 10 +- bl-kernel/users.class.php | 3 +- bl-plugins/api/plugin.php | 24 + 14 files changed, 961 insertions(+), 913 deletions(-) rename bl-kernel/admin/controllers/{configure-plugin.php => plugins-settings.php} (100%) rename bl-kernel/admin/views/{configure-plugin.php => plugins-settings.php} (100%) diff --git a/bl-kernel/admin/controllers/configure-plugin.php b/bl-kernel/admin/controllers/plugins-settings.php similarity index 100% rename from bl-kernel/admin/controllers/configure-plugin.php rename to bl-kernel/admin/controllers/plugins-settings.php diff --git a/bl-kernel/admin/themes/booty/css/bludit.css b/bl-kernel/admin/themes/booty/css/bludit.css index 328f922e..a56bd26f 100644 --- a/bl-kernel/admin/themes/booty/css/bludit.css +++ b/bl-kernel/admin/themes/booty/css/bludit.css @@ -27,6 +27,16 @@ div.sidebar .nav-item h4 { cursor: pointer; } +.link { + cursor: pointer; + text-decoration: underline; + color: #555; +} + +.link:hover { + color: #0a58ca; +} + /* OLD >>>>>>>>> */ diff --git a/bl-kernel/admin/views/content.php b/bl-kernel/admin/views/content.php index 9e296086..136b9a02 100644 --- a/bl-kernel/admin/views/content.php +++ b/bl-kernel/admin/views/content.php @@ -72,31 +72,24 @@ function table($type) echo '
- ' . ($page->title() ? $page->title() : '' . $L->g('Empty title') . ' ') . ' + ' . ($page->title() ? $page->title() : '' . $L->g('Empty title') . ' ') . '
-
- ' . (((ORDER_BY == 'position') || ($type != 'published')) ? $L->g('Position') . ': ' . $page->position() : $page->date(MANAGE_CONTENT_DATE_FORMAT)) . ' +
+ ' . $L->g('View') . ' + ' . $L->g('Edit') . ' + '; + + if (count($page->children()) == 0) { + echo 'Delete'; + } + + echo '
'; echo '' . $L->get('Category') . ': ' . ($page->category() ? $page->category() : $L->get('uncategorized')) . ''; - echo ' - - '; + echo '' . (((ORDER_BY == 'position') || ($type != 'published')) ? $L->g('Position') . ': ' . $page->position() : $page->date(MANAGE_CONTENT_DATE_FORMAT)) . ''; echo ''; @@ -105,28 +98,18 @@ function table($type) echo '
- ' . ($child->title() ? $child->title() : '' . $L->g('Empty title') . ' ') . ' + ' . ($child->title() ? $child->title() : '' . $L->g('Empty title') . ' ') . '
-
- ' . (((ORDER_BY == 'position') || ($type != 'published')) ? $L->g('Position') . ': ' . $child->position() : $child->date(MANAGE_CONTENT_DATE_FORMAT)) . ' + '; echo '' . $L->get('Category') . ': ' . ($child->category() ? $child->category() : $L->get('uncategorized')) . ''; - echo ' - - '; + echo '' . (((ORDER_BY == 'position') || ($type != 'published')) ? $L->g('Position') . ': ' . $child->position() : $child->date(MANAGE_CONTENT_DATE_FORMAT)) . ''; echo ''; } @@ -143,28 +126,18 @@ function table($type) echo '
- ' . ($page->title() ? $page->title() : '' . $L->g('Empty title') . ' ') . ' + ' . ($page->title() ? $page->title() : '' . $L->g('Empty title') . ' ') . '
-
- ' . (($type == 'scheduled') ? $L->g('Scheduled') . ': ' . $page->date(SCHEDULED_DATE_FORMAT) : $page->date(MANAGE_CONTENT_DATE_FORMAT)) . ' + '; echo '' . $L->get('Category') . ': ' . ($page->category() ? $page->category() : $L->get('uncategorized')) . ''; - echo ' - - '; + echo ' ' . (((ORDER_BY == 'position') || ($type != 'published')) ? $L->g('Position') . ': ' . $page->position() : $page->date(MANAGE_CONTENT_DATE_FORMAT)) . ''; echo ''; } catch (Exception $e) { diff --git a/bl-kernel/admin/views/edit-user.php b/bl-kernel/admin/views/edit-user.php index fb9d89c8..1da26128 100644 --- a/bl-kernel/admin/views/edit-user.php +++ b/bl-kernel/admin/views/edit-user.php @@ -1,329 +1,101 @@ -
-

p('Edit user') ?>

-
- - p('Cancel') ?> -
-
- - - - - - -
- - -
- 'username', - 'label' => $L->g('Username'), - 'value' => $user->username(), - 'disabled' => true - )); - - if ($login->role() === 'admin') { - echo Bootstrap::formSelect(array( - 'name' => 'role', - 'label' => $L->g('Role'), - 'options' => array('author' => $L->g('Author'), 'editor' => $L->g('Editor'), 'admin' => $L->g('Administrator')), - 'selected' => $user->role(), - 'tip' => $L->g('author-can-write-and-edit-their-own-content') - )); - } - - echo Bootstrap::formInputText(array( - 'name' => 'email', - 'label' => $L->g('Email'), - 'value' => $user->email() - )); - - echo Bootstrap::formInputText(array( - 'name' => 'nickname', - 'label' => $L->g('Nickname'), - 'value' => $user->nickname(), - 'tip' => $L->g('The nickname is almost used in the themes to display the author of the content') - )); - - echo Bootstrap::formInputText(array( - 'name' => 'firstName', - 'label' => $L->g('First Name'), - 'value' => $user->firstName() - )); - - echo Bootstrap::formInputText(array( - 'name' => 'lastName', - 'label' => $L->g('Last Name'), - 'value' => $user->lastName() - )); - ?> -
- - - -
-
-
-
- Profile picture preview -
-
- - -
-
-
-
- - - -
- $L->g('Status'))); - - echo Bootstrap::formInputText(array( - 'name' => 'status', - 'label' => $L->g('Current status'), - 'value' => $user->enabled() ? $L->g('Enabled') : $L->g('Disabled'), - 'disabled' => true, - 'tip' => $user->enabled() ? '' : $L->g('To enable the user you must set a new password') - )); - - echo Bootstrap::formInputText(array( - 'name' => 'registered', - 'label' => $L->g('Registered'), - 'value' => Date::format($user->registered(), DB_DATE_FORMAT, ADMIN_PANEL_DATE_FORMAT), - 'disabled' => true - )); - - if ($user->enabled()) { - echo ' -
-
-
- - - -
-
- '; - } - } - - echo Bootstrap::formTitle(array('title' => $L->g('Authentication Token'))); - - echo Bootstrap::formInputText(array( - 'name' => 'tokenAuth', - 'label' => $L->g('Token'), - 'value' => $user->tokenAuth(), - 'class' => '', - 'tip' => $L->g('this-token-is-similar-to-a-password-it-should-not-be-shared') - )); - - echo Bootstrap::formTitle(array('title' => $L->g('Change password'))); - - echo Bootstrap::formInputText(array( - 'name' => 'newPassword', - 'label' => $L->g('New password'), - 'type' => 'password', - 'value' => '', - )); - - echo Bootstrap::formInputText(array( - 'name' => 'confirmPassword', - 'label' => $L->g('Confirm password'), - 'type' => 'password', - 'value' => '', - )); - ?> -
- - - -
- 'twitter', - 'label' => 'Twitter', - 'value' => $user->twitter(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'facebook', - 'label' => 'Facebook', - 'value' => $user->facebook(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'codepen', - 'label' => 'CodePen', - 'value' => $user->codepen(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'instagram', - 'label' => 'Instagram', - 'value' => $user->instagram(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'gitlab', - 'label' => 'GitLab', - 'value' => $user->gitlab(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'github', - 'label' => 'GitHub', - 'value' => $user->github(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'linkedin', - 'label' => 'LinkedIn', - 'value' => $user->linkedin(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'xing', - 'label' => 'Xing', - 'value' => $user->xing(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'mastodon', - 'label' => 'Mastodon', - 'value' => $user->mastodon(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'vk', - 'label' => 'VK', - 'value' => $user->vk(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - ?> -
-
- \ No newline at end of file + + // ============================================================================ + // Initlization for the view + // ============================================================================ + $(document).ready(function() { + // nothing here yet + // how do you hang your toilet paper ? over or under ? + }); + + +
+

p('Edit user') ?>

+
+ + p('Cancel') ?> +
+
+ + + + + + +
+ + +
+ 'username', + 'label' => $L->g('Username'), + 'value' => $user->username(), + 'disabled' => true + )); + + if ($login->role() === 'admin') { + echo Bootstrap::formSelect(array( + 'name' => 'role', + 'label' => $L->g('Role'), + 'options' => array('author' => $L->g('Author'), 'editor' => $L->g('Editor'), 'admin' => $L->g('Administrator')), + 'selected' => $user->role(), + 'tip' => $L->g('author-can-write-and-edit-their-own-content') + )); + } + + echo Bootstrap::formInputText(array( + 'name' => 'email', + 'label' => $L->g('Email'), + 'value' => $user->email(), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'nickname', + 'label' => $L->g('Nickname'), + 'value' => $user->nickname(), + 'tip' => $L->g('The nickname is almost used in the themes to display the author of the content'), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'firstName', + 'label' => $L->g('First Name'), + 'value' => $user->firstName(), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'lastName', + 'label' => $L->g('Last Name'), + 'value' => $user->lastName(), + 'data' => array('save' => 'true') + )); + ?> +
+ + + +
+
+
+
+ Profile picture preview +
+
+ + +
+
+
+
+ + + +
+ $L->g('Status'))); + + echo Bootstrap::formInputText(array( + 'name' => 'status', + 'label' => $L->g('Current status'), + 'value' => $user->enabled() ? $L->g('Enabled') : $L->g('Disabled'), + 'disabled' => true, + 'tip' => $user->enabled() ? '' : $L->g('To enable the user you must set a new password') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'registered', + 'label' => $L->g('Registered'), + 'value' => Date::format($user->registered(), DB_DATE_FORMAT, ADMIN_PANEL_DATE_FORMAT), + 'disabled' => true + )); + + if ($user->enabled()) { + echo ' +
+
+
+ + + +
+
+ '; + } + } + + echo Bootstrap::formTitle(array('title' => $L->g('Authentication Token'))); + + echo Bootstrap::formInputText(array( + 'name' => 'tokenAuth', + 'label' => $L->g('Token'), + 'value' => $user->tokenAuth(), + 'tip' => $L->g('this-token-is-similar-to-a-password-it-should-not-be-shared') + )); + + echo Bootstrap::formTitle(array('title' => $L->g('Change password'))); + + echo Bootstrap::formInputText(array( + 'name' => 'newPassword', + 'label' => $L->g('New password'), + 'type' => 'password', + 'value' => '' + )); + + echo Bootstrap::formInputText(array( + 'name' => 'confirmPassword', + 'label' => $L->g('Confirm password'), + 'type' => 'password', + 'value' => '' + )); + ?> +
+ + + +
+ 'youtube', + 'label' => 'Youtube', + 'value' => $user->youtube(), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'twitter', + 'label' => 'Twitter', + 'value' => $user->twitter(), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'facebook', + 'label' => 'Facebook', + 'value' => $user->facebook(), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'codepen', + 'label' => 'CodePen', + 'value' => $user->codepen(), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'instagram', + 'label' => 'Instagram', + 'value' => $user->instagram(), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'gitlab', + 'label' => 'GitLab', + 'value' => $user->gitlab(), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'github', + 'label' => 'GitHub', + 'value' => $user->github(), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'linkedin', + 'label' => 'LinkedIn', + 'value' => $user->linkedin(), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'xing', + 'label' => 'Xing', + 'value' => $user->xing(), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'mastodon', + 'label' => 'Mastodon', + 'value' => $user->mastodon(), + 'data' => array('save' => 'true') + )); + + echo Bootstrap::formInputText(array( + 'name' => 'vk', + 'label' => 'VK', + 'value' => $user->vk(), + 'data' => array('save' => 'true') + )); + ?> +
+
diff --git a/bl-kernel/admin/views/configure-plugin.php b/bl-kernel/admin/views/plugins-settings.php similarity index 100% rename from bl-kernel/admin/views/configure-plugin.php rename to bl-kernel/admin/views/plugins-settings.php diff --git a/bl-kernel/admin/views/plugins.php b/bl-kernel/admin/views/plugins.php index 7e3fe6c9..fb3b5111 100644 --- a/bl-kernel/admin/views/plugins.php +++ b/bl-kernel/admin/views/plugins.php @@ -1,69 +1,108 @@ - -echo Bootstrap::pageTitle(array('title'=>$L->g('Plugins'), 'icon'=>'puzzle-piece')); - -// echo Bootstrap::link(array( -// 'title'=>$L->g('Change the position of the plugins'), -// 'href'=>HTML_PATH_ADMIN_ROOT.'plugins-position', -// 'icon'=>'arrows' -// )); - -echo Bootstrap::formTitle(array('title'=>$L->g('Search plugins'))); - -?> - - +
+

p('Plugins') ?>

+ +
+ + 'search', 'title' => $L->g('Search plugins'))); ?> + + + $L->g('Enabled plugins'))); +echo Bootstrap::formTitle(array('icon' => 'check-square', 'title' => $L->g('Enabled plugins'))); echo ' - +
'; // Show installed plugins foreach ($pluginsInstalled as $plugin) { - echo ''; + echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; @@ -74,35 +113,35 @@ echo '
-
'.$plugin->name().'
+
' . $plugin->name() . '
'; - if (method_exists($plugin, 'form')) { - echo ''.$L->g('Settings').''; - } - echo ''.$L->g('Deactivate').''; - echo '
'; + if (method_exists($plugin, 'form')) { + echo '' . $L->g('Settings') . ''; + } + echo '' . $L->g('Deactivate') . ''; + echo ''; echo '
'; - echo $plugin->description(); + echo $plugin->description(); echo ''; - echo ''.$plugin->version().''; + echo '' . $plugin->version() . ''; echo ' - '.$plugin->author().' + ' . $plugin->author() . '
'; -echo Bootstrap::formTitle(array('title'=>$L->g('Disabled plugins'))); +echo Bootstrap::formTitle(array('icon' => 'dash-square', 'title' => $L->g('Disabled plugins'))); echo ' - +
'; // Plugins not installed $pluginsNotInstalled = array_diff_key($plugins['all'], $pluginsInstalled); foreach ($pluginsNotInstalled as $plugin) { - echo ''; + echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; @@ -111,4 +150,4 @@ foreach ($pluginsNotInstalled as $plugin) { echo '
-
'.$plugin->name().'
+
' . $plugin->name() . '
- '.$L->g('Activate').' + ' . $L->g('Activate') . '
'; - echo $plugin->description(); + echo $plugin->description(); echo ''; - echo ''.$plugin->version().''; + echo '' . $plugin->version() . ''; echo ' - '.$plugin->author().' + ' . $plugin->author() . '
-'; \ No newline at end of file +'; diff --git a/bl-kernel/admin/views/settings.php b/bl-kernel/admin/views/settings.php index db1d7af6..60ba69d3 100644 --- a/bl-kernel/admin/views/settings.php +++ b/bl-kernel/admin/views/settings.php @@ -1,577 +1,559 @@ -
-
- - p('Cancel') ?> +
+

p('Settings') ?>

+
+ + p('Cancel') ?>
- $L->g('Settings'), 'icon'=>'cog')); ?>
- + -
+ +
-
- $L->g('Site'))); +
+ $L->g('Site'))); echo Bootstrap::formInputText(array( - 'name'=>'title', - 'label'=>$L->g('Site title'), - 'value'=>$site->title(), - 'tip'=>$L->g('use-this-field-to-name-your-site') + 'name' => 'title', + 'label' => $L->g('Site title'), + 'value' => $site->title(), + 'tip' => $L->g('use-this-field-to-name-your-site'), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'slogan', - 'label'=>$L->g('Site slogan'), - 'value'=>$site->slogan(), - 'tip'=>$L->g('use-this-field-to-add-a-catchy-phrase') + 'name' => 'slogan', + 'label' => $L->g('Site slogan'), + 'value' => $site->slogan(), + 'tip' => $L->g('use-this-field-to-add-a-catchy-phrase'), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'description', - 'label'=>$L->g('Site description'), - 'value'=>$site->description(), - 'tip'=>$L->g('you-can-add-a-site-description-to-provide') + 'name' => 'description', + 'label' => $L->g('Site description'), + 'value' => $site->description(), + 'tip' => $L->g('you-can-add-a-site-description-to-provide'), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'footer', - 'label'=>$L->g('Footer text'), - 'value'=>$site->footer(), - 'tip'=>$L->g('you-can-add-a-small-text-on-the-bottom') + 'name' => 'footer', + 'label' => $L->g('Footer text'), + 'value' => $site->footer(), + 'tip' => $L->g('you-can-add-a-small-text-on-the-bottom'), + 'data' => array('save' => 'true') )); - echo Bootstrap::formTitle(array('title'=>$L->g('Content'))); + echo Bootstrap::formTitle(array('title' => $L->g('Autosave'))); + + echo Bootstrap::formInputText(array( + 'name' => 'autosaveInterval', + 'label' => $L->g('Interval'), + 'value' => $site->autosaveInterval(), + 'tip' => $L->g('Number in minutes for every execution of autosave'), + 'data' => array('save' => 'true') + )); + + + echo Bootstrap::formTitle(array('title' => $L->g('Content'))); echo Bootstrap::formSelect(array( - 'name'=>'itemsPerPage', - 'label'=>$L->g('Items per page'), - 'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8', '-1'=>$L->g('All content')), - 'selected'=>$site->itemsPerPage(), - 'tip'=>$L->g('Number of items to show per page') + 'name' => 'itemsPerPage', + 'label' => $L->g('Items per page'), + 'options' => array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '-1' => $L->g('All content')), + 'selected' => $site->itemsPerPage(), + 'tip' => $L->g('Number of items to show per page'), + 'data' => array('save' => 'true') )); echo Bootstrap::formSelect(array( - 'name'=>'orderBy', - 'label'=>$L->g('Order content by'), - 'options'=>array('date'=>$L->g('Date'),'position'=>$L->g('Position')), - 'selected'=>$site->orderBy(), - 'tip'=>$L->g('order-the-content-by-date-to-build-a-blog') + 'name' => 'orderBy', + 'label' => $L->g('Order content by'), + 'options' => array('date' => $L->g('Date'), 'position' => $L->g('Position')), + 'selected' => $site->orderBy(), + 'tip' => $L->g('order-the-content-by-date-to-build-a-blog'), + 'data' => array('save' => 'true') )); - ?> + ?>
-
- $L->g('Page content'))); +
+ $L->g('Page content'))); echo Bootstrap::formSelect(array( - 'name'=>'markdownParser', - 'label'=>$L->g('Markdown parser'), - 'options'=>array('true'=>$L->g('Enabled'), 'false'=>$L->g('Disabled')), - 'selected'=>($site->markdownParser()?'true':'false'), - 'tip'=>$L->g('Enable the markdown parser for the content of the page.') + 'name' => 'markdownParser', + 'label' => $L->g('Markdown parser'), + 'options' => array('true' => $L->g('Enabled'), 'false' => $L->g('Disabled')), + 'selected' => ($site->markdownParser() ? 'true' : 'false'), + 'tip' => $L->g('Enable the markdown parser for the content of the page.'), + 'data' => array('save' => 'true') )); - echo Bootstrap::formTitle(array('title'=>$L->g('Predefined pages'))); + echo Bootstrap::formTitle(array('title' => $L->g('Predefined pages'))); echo Bootstrap::formSelect(array( - 'name'=>'homepage', - 'label'=>$L->g('Homepage'), - 'options'=>$options, - 'selected'=>false, - 'class'=>'', - 'tip'=>$L->g('Returning page for the main page') + 'name' => 'homepage', + 'label' => $L->g('Homepage'), + 'options' => array(), // Complete via Ajax + 'selected' => false, + 'tip' => $L->g('Returning page for the main page'), + 'data' => array('save' => 'true') )); echo Bootstrap::formSelect(array( - 'name'=>'pageNotFound', - 'label'=>$L->g('Page not found'), - 'options'=>$options, - 'selected'=>false, - 'class'=>'', - 'tip'=>$L->g('Returning page when the page doesnt exist') + 'name' => 'pageNotFound', + 'label' => $L->g('Page not found'), + 'options' => array(), // Complete via Ajax + 'selected' => false, + 'tip' => $L->g('Returning page when the page doesnt exist'), + 'data' => array('save' => 'true') )); - echo Bootstrap::formTitle(array('title'=>$L->g('Email account settings'))); + echo Bootstrap::formTitle(array('title' => $L->g('Email account settings'))); echo Bootstrap::formInputText(array( - 'name'=>'emailFrom', - 'label'=>$L->g('Sender email'), - 'value'=>$site->emailFrom(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('Emails will be sent from this address') + 'name' => 'emailFrom', + 'label' => $L->g('Sender email'), + 'value' => $site->emailFrom(), + 'tip' => $L->g('Emails will be sent from this address'), + 'data' => array('save' => 'true') )); - echo Bootstrap::formTitle(array('title'=>$L->g('Autosave'))); + echo Bootstrap::formTitle(array('title' => $L->g('Site URL'))); echo Bootstrap::formInputText(array( - 'name'=>'autosaveInterval', - 'label'=>$L->g('Interval'), - 'value'=>$site->autosaveInterval(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('Number in minutes for every execution of autosave') + 'name' => 'url', + 'label' => 'URL', + 'value' => $site->url(), + 'tip' => $L->g('full-url-of-your-site'), + 'placeholder' => 'https://', + 'data' => array('save' => 'true') )); - echo Bootstrap::formTitle(array('title'=>$L->g('Site URL'))); + echo Bootstrap::formTitle(array('title' => $L->g('URL Filters'))); echo Bootstrap::formInputText(array( - 'name'=>'url', - 'label'=>'URL', - 'value'=>$site->url(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('full-url-of-your-site'), - 'placeholder'=>'https://' - )); - - echo Bootstrap::formTitle(array('title'=>$L->g('URL Filters'))); - - echo Bootstrap::formInputText(array( - 'name'=>'uriPage', - 'label'=>$L->g('Pages'), - 'value'=>$site->uriFilters('page'), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>DOMAIN_PAGES + 'name' => 'uriPage', + 'label' => $L->g('Pages'), + 'value' => $site->uriFilters('page'), + 'tip' => DOMAIN_PAGES, + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'uriTag', - 'label'=>$L->g('Tags'), - 'value'=>$site->uriFilters('tag'), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>DOMAIN_TAGS + 'name' => 'uriTag', + 'label' => $L->g('Tags'), + 'value' => $site->uriFilters('tag'), + 'tip' => DOMAIN_TAGS, + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'uriCategory', - 'label'=>$L->g('Category'), - 'value'=>$site->uriFilters('category'), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>DOMAIN_CATEGORIES + 'name' => 'uriCategory', + 'label' => $L->g('Category'), + 'value' => $site->uriFilters('category'), + 'tip' => DOMAIN_CATEGORIES, + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'uriBlog', - 'label'=>$L->g('Blog'), - 'value'=>$site->uriFilters('blog'), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>DOMAIN.$site->uriFilters('blog'), - 'disabled'=>Text::isEmpty($site->uriFilters('blog')) + 'name' => 'uriBlog', + 'label' => $L->g('Blog'), + 'value' => $site->uriFilters('blog'), + 'tip' => DOMAIN . $site->uriFilters('blog'), + 'disabled' => Text::isEmpty($site->uriFilters('blog')), + 'data' => array('save' => 'true') )); - ?> + ?>
-
- $L->g('Extreme friendly URL'))); +
+ $L->g('Extreme friendly URL'))); echo Bootstrap::formSelect(array( - 'name'=>'extremeFriendly', - 'label'=>$L->g('Allow Unicode'), - 'options'=>array('true'=>$L->g('Enabled'), 'false'=>$L->g('Disabled')), - 'selected'=>($site->extremeFriendly()?'true':'false'), - 'class'=>'', - 'tip'=>$L->g('Allow unicode characters in the URL and some part of the system.') + 'name' => 'extremeFriendly', + 'label' => $L->g('Allow Unicode'), + 'options' => array('true' => $L->g('Enabled'), 'false' => $L->g('Disabled')), + 'selected' => ($site->extremeFriendly() ? 'true' : 'false'), + 'tip' => $L->g('Allow unicode characters in the URL and some part of the system.'), + 'data' => array('save' => 'true') )); - echo Bootstrap::formTitle(array('title'=>$L->g('Title formats'))); + echo Bootstrap::formTitle(array('title' => $L->g('Title formats'))); echo Bootstrap::formInputText(array( - 'name'=>'titleFormatHomepage', - 'label'=>$L->g('Homepage'), - 'value'=>$site->titleFormatHomepage(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('Variables allowed').' {{site-title}} {{site-slogan}} {{site-description}}', - 'placeholder'=>'' + 'name' => 'titleFormatHomepage', + 'label' => $L->g('Homepage'), + 'value' => $site->titleFormatHomepage(), + 'tip' => $L->g('Variables allowed') . ' {{site-title}} {{site-slogan}} {{site-description}}', + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'titleFormatPages', - 'label'=>$L->g('Pages'), - 'value'=>$site->titleFormatPages(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('Variables allowed').' {{page-title}} {{page-description}} {{site-title}} {{site-slogan}} {{site-description}}', - 'placeholder'=>'' + 'name' => 'titleFormatPages', + 'label' => $L->g('Pages'), + 'value' => $site->titleFormatPages(), + 'tip' => $L->g('Variables allowed') . ' {{page-title}} {{page-description}} {{site-title}} {{site-slogan}} {{site-description}}', + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'titleFormatCategory', - 'label'=>$L->g('Category'), - 'value'=>$site->titleFormatCategory(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('Variables allowed').' {{category-name}} {{site-title}} {{site-slogan}} {{site-description}}', - 'placeholder'=>'' + 'name' => 'titleFormatCategory', + 'label' => $L->g('Category'), + 'value' => $site->titleFormatCategory(), + 'class' => '', + 'tip' => $L->g('Variables allowed') . ' {{category-name}} {{site-title}} {{site-slogan}} {{site-description}}', + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'titleFormatTag', - 'label'=>$L->g('Tag'), - 'value'=>$site->titleFormatTag(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('Variables allowed').' {{tag-name}} {{site-title}} {{site-slogan}} {{site-description}}', - 'placeholder'=>'' + 'name' => 'titleFormatTag', + 'label' => $L->g('Tag'), + 'value' => $site->titleFormatTag(), + 'tip' => $L->g('Variables allowed') . ' {{tag-name}} {{site-title}} {{site-slogan}} {{site-description}}', + 'data' => array('save' => 'true') )); - ?> + ?>
-
- $L->g('Social Networks'))); +
+ $L->g('Social Networks'))); echo Bootstrap::formInputText(array( - 'name'=>'twitter', - 'label'=>'Twitter', - 'value'=>$site->twitter(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>'' + 'name' => 'twitter', + 'label' => 'Twitter', + 'value' => $site->twitter(), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'facebook', - 'label'=>'Facebook', - 'value'=>$site->facebook(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>'' + 'name' => 'facebook', + 'label' => 'Facebook', + 'value' => $site->facebook(), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'codepen', - 'label'=>'CodePen', - 'value'=>$site->codepen(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>'' + 'name' => 'codepen', + 'label' => 'CodePen', + 'value' => $site->codepen(), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'instagram', - 'label'=>'Instagram', - 'value'=>$site->instagram(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>'' + 'name' => 'instagram', + 'label' => 'Instagram', + 'value' => $site->instagram(), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'gitlab', - 'label'=>'GitLab', - 'value'=>$site->gitlab(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>'' + 'name' => 'gitlab', + 'label' => 'GitLab', + 'value' => $site->gitlab(), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'github', - 'label'=>'GitHub', - 'value'=>$site->github(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>'' + 'name' => 'github', + 'label' => 'GitHub', + 'value' => $site->github(), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'linkedin', - 'label'=>'LinkedIn', - 'value'=>$site->linkedin(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>'' + 'name' => 'linkedin', + 'label' => 'LinkedIn', + 'value' => $site->linkedin(), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'xing', - 'label'=>'Xing', - 'value'=>$site->xing(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>'' + 'name' => 'xing', + 'label' => 'Xing', + 'value' => $site->xing(), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'mastodon', - 'label'=>'Mastodon', - 'value'=>$site->mastodon(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>'' + 'name' => 'mastodon', + 'label' => 'Mastodon', + 'value' => $site->mastodon(), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'dribbble', - 'label'=>'Dribbble', - 'value'=>$site->dribbble(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>'' + 'name' => 'dribbble', + 'label' => 'Dribbble', + 'value' => $site->dribbble(), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'vk', - 'label'=>'VK', - 'value'=>$site->vk(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>'' + 'name' => 'vk', + 'label' => 'VK', + 'value' => $site->vk(), + 'data' => array('save' => 'true') )); - ?> + ?>
-
- $L->g('Thumbnails'))); +
+ $L->g('Thumbnails'))); echo Bootstrap::formInputText(array( - 'name'=>'thumbnailWidth', - 'label'=>$L->g('Width'), - 'value'=>$site->thumbnailWidth(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('Thumbnail width in pixels') + 'name' => 'thumbnailWidth', + 'label' => $L->g('Width'), + 'value' => $site->thumbnailWidth(), + 'tip' => $L->g('Thumbnail width in pixels'), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'thumbnailHeight', - 'label'=>$L->g('Height'), - 'value'=>$site->thumbnailHeight(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('Thumbnail height in pixels') + 'name' => 'thumbnailHeight', + 'label' => $L->g('Height'), + 'value' => $site->thumbnailHeight(), + 'tip' => $L->g('Thumbnail height in pixels'), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'thumbnailQuality', - 'label'=>$L->g('Quality'), - 'value'=>$site->thumbnailQuality(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('Thumbnail quality in percentage') + 'name' => 'thumbnailQuality', + 'label' => $L->g('Quality'), + 'value' => $site->thumbnailQuality(), + 'tip' => $L->g('Thumbnail quality in percentage'), + 'data' => array('save' => 'true') )); - ?> + ?>
-
- $L->g('Language and timezone'))); +
+ $L->g('Language and timezone'))); echo Bootstrap::formSelect(array( - 'name'=>'language', - 'label'=>$L->g('Language'), - 'options'=>$L->getLanguageList(), - 'selected'=>$site->language(), - 'class'=>'', - 'tip'=>$L->g('select-your-sites-language') + 'name' => 'language', + 'label' => $L->g('Language'), + 'options' => $L->getLanguageList(), + 'selected' => $site->language(), + 'tip' => $L->g('select-your-sites-language'), + 'data' => array('save' => 'true') )); echo Bootstrap::formSelect(array( - 'name'=>'timezone', - 'label'=>$L->g('Timezone'), - 'options'=>Date::timezoneList(), - 'selected'=>$site->timezone(), - 'class'=>'', - 'tip'=>$L->g('select-a-timezone-for-a-correct') + 'name' => 'timezone', + 'label' => $L->g('Timezone'), + 'options' => Date::timezoneList(), + 'selected' => $site->timezone(), + 'tip' => $L->g('select-a-timezone-for-a-correct'), + 'data' => array('save' => 'true') )); echo Bootstrap::formInputText(array( - 'name'=>'locale', - 'label'=>$L->g('Locale'), - 'value'=>$site->locale(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('with-the-locales-you-can-set-the-regional-user-interface') + 'name' => 'locale', + 'label' => $L->g('Locale'), + 'value' => $site->locale(), + 'tip' => $L->g('with-the-locales-you-can-set-the-regional-user-interface'), + 'data' => array('save' => 'true') )); - echo Bootstrap::formTitle(array('title'=>$L->g('Date and time formats'))); + echo Bootstrap::formTitle(array('title' => $L->g('Date and time formats'))); echo Bootstrap::formInputText(array( - 'name'=>'dateFormat', - 'label'=>$L->g('Date format'), - 'value'=>$site->dateFormat(), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('Current format').': '.Date::current($site->dateFormat()) + 'name' => 'dateFormat', + 'label' => $L->g('Date format'), + 'value' => $site->dateFormat(), + 'tip' => $L->g('Current format') . ': ' . Date::current($site->dateFormat()), + 'data' => array('save' => 'true') )); - ?> + ?>
-
- $L->g('Custom fields'))); +
+ $L->g('Custom fields'))); echo Bootstrap::formTextarea(array( - 'name'=>'customFields', - 'label'=>'JSON Format', - 'value'=>json_encode($site->customFields(), JSON_PRETTY_PRINT), - 'class'=>'', - 'placeholder'=>'', - 'tip'=>$L->g('define-custom-fields-for-the-content'), - 'rows'=>15 + 'name' => 'customFields', + 'label' => 'JSON Format', + 'value' => json_encode($site->customFields(), JSON_PRETTY_PRINT), + 'tip' => $L->g('define-custom-fields-for-the-content'), + 'rows' => 15, + 'data' => array('save' => 'true') )); - ?> + ?>
- + \ No newline at end of file diff --git a/bl-kernel/boot/rules/60.plugins.php b/bl-kernel/boot/rules/60.plugins.php index 947564ea..11d67fba 100644 --- a/bl-kernel/boot/rules/60.plugins.php +++ b/bl-kernel/boot/rules/60.plugins.php @@ -29,6 +29,9 @@ $plugins = array( 'paginator'=>array(), + 'beforePageModify'=>array(), + 'beforePageDelete'=>array(), + 'afterPageCreate'=>array(), 'afterPageModify'=>array(), 'afterPageDelete'=>array(), diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 3355e43b..2a8af969 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -73,6 +73,9 @@ function editPage($args) { return false; } + // Call the plugins before the page is edited + execPluginsByHook('beforePageModify', array($args['key'])); + $key = $pages->edit($args); if ($key) { // Call the plugins after page modified @@ -105,6 +108,9 @@ function deletePage($args) { global $pages; global $syslog; + // Call the plugins before the page is deleted + execPluginsByHook('beforePageDelete', array($args['key'])); + if ($pages->delete($args['key'])) { // Call the plugins after page deleted execPluginsByHook('afterPageDelete', array($args['key'])); @@ -497,6 +503,34 @@ function uploadPageFile($pageKey) { return false; } +/* Install and activate a plugin === Bludit v4 + + @pluginClassName string The plugin PHP class name + @return string/bool Returns TRUE on successful install, FALSE otherwise +*/ +function activatePlugin($pluginClassName) { + global $plugins; + global $syslog; + + if (!isset($plugins['all'][$pluginClassName])) { + Log::set(__FUNCTION__.LOG_SEP.'The plugin doesn\'t exist: '.$pluginClassName, LOG_TYPE_ERROR); + return false; + } + + $plugin = $plugins['all'][$pluginClassName]; + if ($plugin->install()) { + $syslog->add(array( + 'dictionaryKey'=>'plugin-activated', + 'notes'=>$plugin->name() + )); + Log::set(__FUNCTION__.LOG_SEP.'Plugin installed.', LOG_TYPE_INFO); + return true; + } + + Log::set(__FUNCTION__.LOG_SEP.'Not was possible install the plugin.', LOG_TYPE_ERROR); + return false; +} + // Re-index database of categories // If you create/edit/remove a page is necessary regenerate the database of categories function reindexCategories() { @@ -702,30 +736,7 @@ function pluginActivated($pluginClassName) { return false; } -// Activate / install the plugin -// Returns TRUE if the plugin is successfully activated, FALSE otherwise -function activatePlugin($pluginClassName) { - global $plugins; - global $syslog; - global $L; - // Check if the plugin exists - if (isset($plugins['all'][$pluginClassName])) { - $plugin = $plugins['all'][$pluginClassName]; - if ($plugin->install()) { - // Add to syslog - $syslog->add(array( - 'dictionaryKey'=>'plugin-activated', - 'notes'=>$plugin->name() - )); - - // Create an alert - Alert::set($L->g('plugin-activated')); - return true; - } - } - return false; -} // Deactivate / uninstall the plugin // Returns TRUE if the plugin is successfully deactivated, FALSE otherwise diff --git a/bl-kernel/helpers/bootstrap.class.php b/bl-kernel/helpers/bootstrap.class.php index f4639b33..85c0b732 100644 --- a/bl-kernel/helpers/bootstrap.class.php +++ b/bl-kernel/helpers/bootstrap.class.php @@ -46,12 +46,21 @@ EOF; $class = $class.' '.$args['class']; } + $data = 'data-current-value="'.$args['selected'].'"'; + if (isset($args['data'])) { + if (is_array($args['data'])) { + foreach ($args['data'] as $x => $y) { + $data .= 'data-'.$x.' = "'.$y.'"'; + } + } + } + $html = '
'; if (!empty($args['label'])) { $html .= ''; } $html .= '
'; - $html .= ''; foreach ($args['options'] as $key=>$value) { $html .= ''; } @@ -148,103 +157,46 @@ EOF; $class = $class.' '.$args['class']; } + $data = 'data-current-value="'.$value.'"'; + if (isset($args['data'])) { + if (is_array($args['data'])) { + foreach ($args['data'] as $x => $y) { + $data .= ' data-'.$x.' = "'.$y.'"'; + } + } + } + return << $label
- + $tip
EOF; } - public static function formSelectOld($args) - { - $name = $args['name']; - $id = isset($args['id'])?$args['id']:$name; - $value = isset($args['value'])?$args['value']:''; - - $class = 'custom-select'; - if (isset($args['class'])) { - $class = $class.' '.$args['class']; - } - - $html = '
'; - if (!empty($args['label'])) { - $html .= ''; - } - $html .= '
'; - $html .= ''; - if (!empty($args['tip'])) { - $html .= '
'.$args['tip'].'
'; - } - $html .= '
'; - $html .= '
'; - - return $html; - } - public static function pageTitle($args) { - $icon = $args['icon']; - $title = $args['title']; -return << - $title - -EOF; + $title = ''; + if (isset($args['icon'])) { + $title = ''; + } + $title .= ''.$args['title'].''; + return '

'.$title.'

'; } public static function formTitle($args) { - $title = $args['title']; -return <<$title -EOF; + $title = ''; + if (isset($args['icon'])) { + $title = ''; + } + $title .= ''.$args['title'].''; + return '
'.$title.'
'; } - - // -- OLD -------- - public static function modal($args) { - - $buttonSecondary = $args['buttonSecondary']; - $buttonSecondaryClass = $args['buttonSecondaryClass']; - - $buttonPrimary = $args['buttonPrimary']; - $buttonPrimaryClass = $args['buttonPrimaryClass']; - - $modalText = $args['modalText']; - $modalTitle = $args['modalTitle']; - $modalId = $args['modalId']; - - -return << - -
-EOF; - } - - - - - public static function formOpen($args) { $class = empty($args['class'])?'':'class="'.$args['class'].'"'; diff --git a/bl-kernel/js/api.js b/bl-kernel/js/api.js index adf0b700..90bb4ae6 100644 --- a/bl-kernel/js/api.js +++ b/bl-kernel/js/api.js @@ -293,4 +293,29 @@ class API { } } + /* Install and activate a plugin === Bludit v4 + + @args array Arguments can be any of the fields from a category + @return string New category key + */ + async activatePlugin(args) { + var url = this.apiURL + "plugins/" + args['pluginClassName']; + var body = Object.assign({}, this.body, args); + try { + var response = await fetch(url, { + credentials: "same-origin", + method: "POST", + body: JSON.stringify(body), + headers: new Headers({ + "Content-Type": "application/json" + }) + }); + var json = await response.json(); + return json; + } catch (err) { + console.log(err); + return true; + } + } + } \ No newline at end of file diff --git a/bl-kernel/user.class.php b/bl-kernel/user.class.php index e737c5da..f1716de0 100644 --- a/bl-kernel/user.class.php +++ b/bl-kernel/user.class.php @@ -105,6 +105,11 @@ class User { return $this->getValue('registered'); } + public function youtube() + { + return $this->getValue('youtube'); + } + public function twitter() { return $this->getValue('twitter'); @@ -170,7 +175,8 @@ class User { $tmp['firstName'] = $this->firstName(); $tmp['lastName'] = $this->lastName(); $tmp['nickname'] = $this->nickname(); - $tmp['description'] = $this->description(); + $tmp['description'] = $this->description(); + $tmp['youtube'] = $this->youtube(); $tmp['twitter'] = $this->twitter(); $tmp['facebook'] = $this->facebook(); $tmp['codepen'] = $this->codepen(); @@ -180,7 +186,7 @@ class User { $tmp['linkedin'] = $this->linkedin(); $tmp['xing'] = $this->xing(); $tmp['mastodon'] = $this->mastodon(); - $tmp['vk'] = $this->vk(); + $tmp['vk'] = $this->vk(); $tmp['profilePicture'] = $this->profilePicture(); if ($returnsArray) { diff --git a/bl-kernel/users.class.php b/bl-kernel/users.class.php index 39d4eb4b..915a9395 100644 --- a/bl-kernel/users.class.php +++ b/bl-kernel/users.class.php @@ -23,7 +23,8 @@ class Users extends dbJSON { 'gitlab'=>'', 'linkedin'=>'', 'mastodon'=>'', - 'vk'=>'' + 'vk'=>'', + 'youtube'=>'' ); function __construct() diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php index 2e5ee60e..3fd07ae0 100644 --- a/bl-plugins/api/plugin.php +++ b/bl-plugins/api/plugin.php @@ -265,6 +265,11 @@ class pluginAPI extends Plugin { $inputs['username'] = $parmB; $data = $this->editUser($inputs); } + // (POST) /api/plugins/:key + elseif ( ($method==='POST') && ($parmA==='plugins') && !empty($parmB) ) { + $pluginClassName = $parmB; + $data = $this->activatePlugin($pluginClassName); + } // (GET) /api/helper/:name elseif ( ($method==='GET') && ($parmA==='helper') && !empty($parmB) ) { $name = $parmB; @@ -915,4 +920,23 @@ class pluginAPI extends Plugin { 'data'=>$files ); } + + /* Install and activate a plugin === Bludit v4 + Referer to the function activatePlugin() from functions.php + */ + private function activatePlugin($pluginClassName) + { + if (activatePlugin($pluginClassName)) { + return array( + 'status'=>'0', + 'message'=>'Plugin installed and activated.', + 'data'=>array('key'=>$pluginClassName) + ); + } + + return array( + 'status'=>'1', + 'message'=>'An error occurred while trying to install the plugin.' + ); + } } \ No newline at end of file