Posts: 305
Threads: 15
Joined: Mar 2014
2016-06-14, 05:22:09
(This post was last modified: 2019-04-08, 08:46:45 by Tyblitz.)
Introduction
Extended functionality for GS Components: better UI with sort & search, CodeMirror support, doubleclick code snippet copy, individual component save without page reload. Components Extended saves your components as <slug>.xml files in data/components with AJAX, one component at a time (no page reload!). It replaces the components tab with a custom tab, and will automatically import existing components from components.xml on activation. Available in EN, FR, NL. Download it from Extend.
Components Extension adds one PHP function for components, get_ext_component($slug, $params = array()); where $params is an array of named keys (or an object).
Eg if you had the following:
PHP Code: <?php get_ext_component($slug, array( 'greet' => 'Hello', 'name' => 'world' )); ?>
In your extended component you could do:
PHP Code: <?php echo $params->greet . ' ' . $params->name . '!'; ?>
And it would output: 'Hello world!'.
Features
- Single-file components saved in data/components, modify 1 component at a time, smaller request payload.
- Cleaner UI
- Rename the component title independently from its slug.
- Keeps track of the created date, modified date, and last editor.
- Replaces the component tag cloud with an autofill search + sort (by [reverse] alphabetical)
- One extra PHP function:
<?php get_ext_component($slug, $params = array()); ?>
- Bonus: doubleclick the get_component snippet for automatic copy to clipboard
Notes
Be sure to set the GSTIMEZONE constant to your timezone if you wish to have meaningful timestamps for created & modified dates.
NB: to other plugin developers; the standard GS hooks component-save and component-extras also work with this plugin.
Screenshot
Posts: 6,266
Threads: 181
Joined: Sep 2011
Since you are doing 1 at a time maybe see if you can base64 or other encoding to bypass security fiteres
Posts: 1,247
Threads: 82
Joined: Feb 2011
2016-06-14, 20:30:25
(This post was last modified: 2016-06-18, 10:10:34 by datiswous.)
Nice.
Just some some small things I encountered:
When I try to delete a component I get an alert dialog saying:
Quote:undefined: component-name
I was expecting something like:
Quote:Are you sure you want to delete component-name ?
Maybe the (yellow) status messages could just hover on the top instead of bumping the page (it also moves the page-view down to where the status message is), I think it's suboptimal if such status messages move the page when editing code. Also, the edit-cursur should stay active at it's location.
Posts: 305
Threads: 15
Joined: Mar 2014
V0.7 release 2016-06-18
- CSRF (cookie, header & nonce check) vulnerability patch
- Allow changing the directory where components are saved
- Make component title available in component as $params->title
- Bugfix slug<->title when creating new component, labels
- Added languages FR/NL
- CodeMirror support
Posts: 1,928
Threads: 88
Joined: Apr 2010
Posts: 305
Threads: 15
Joined: Mar 2014
2016-06-18, 07:54:33
(This post was last modified: 2016-06-18, 07:57:55 by Tyblitz.)
v0.7.1 release - 2016-06-18
- Bugfix
Posts: 305
Threads: 15
Joined: Mar 2014
2016-06-18, 08:09:31
(This post was last modified: 2016-06-18, 08:22:30 by Tyblitz.)
@oleg, you have a very unusual GSDATAPATH . Your GSROOTPATH is set to demo.getsimplethemes.ru/uikit .
I don't know how to fix it (@shawn_a any idea?), but you can do in gsconfig.php : define('GSDATACOMPONENTSPATH', str_replace('uikit/', '', GSDATAPATH . 'components/'));
Posts: 1,928
Threads: 88
Joined: Apr 2010
Posts: 1,928
Threads: 88
Joined: Apr 2010
if the site is at the root http://prntscr.com/bhq1p0
Posts: 305
Threads: 15
Joined: Mar 2014
2016-06-18, 08:42:20
(This post was last modified: 2016-06-18, 08:45:33 by Tyblitz.)
I'll have a look into this when I get some time, but your display is very, very strange.
I get none of these issues on my local install. Could you have a conflict with another plugin?
The file formats at bottom right, what is that? Also, the search icon is not visible.. You're not using UTF-8?
Posts: 1,928
Threads: 88
Joined: Apr 2010
the removal of all plugins
http://prntscr.com/bhufqc
Posts: 305
Threads: 15
Joined: Mar 2014
(2016-06-18, 18:17:45)Oleg06 Wrote: the removal of all plugins
http://prntscr.com/bhufqc
Can you give me temporary access (with GSDEBUG on)? I have no idea how this is possible.
Posts: 1,928
Threads: 88
Joined: Apr 2010
I'm working on a local server.
After removing all of my components.
http://prntscr.com/bhvp2d
I could not disable any plugin.
Posts: 1,928
Threads: 88
Joined: Apr 2010
Posts: 1,247
Threads: 82
Joined: Feb 2011
Maybe it's easier to see what's going on if you (also) test this on an English version of the admin.
Posts: 1,928
Threads: 88
Joined: Apr 2010
Posts: 305
Threads: 15
Joined: Mar 2014
2016-06-21, 03:32:14
(This post was last modified: 2016-06-21, 03:34:35 by Tyblitz.)
(2016-06-20, 21:06:52)Oleg06 Wrote: http://prntscr.com/bims6w
http://prntscr.com/bimsdp
http://prntscr.com/bimsne
I know what it is (the security check failed), but not sure how to solve it.
It's the same nonce check as GS uses..
In components_ext.php , line 53 - 62 you can see this:
PHP Code: <?php // protect against CSRF, basic check if (!isset($USR) || $USR != get_cookie('GS_ADMIN_USERNAME') || !isset($_COOKIE['PHPSESSID'])) die(); // only continue if the request comes from the same domain & nonces match if (empty($_SERVER['HTTP_ORIGIN']) || strpos($_SERVER['HTTP_ORIGIN'], $_SERVER['SERVER_NAME']) < 5 || empty($_GET['nonce']) || !check_nonce($_GET['nonce'], 'components_ext_action', 'components_ext.php')) die();
So either: - the
$USR global is not set or the $USR global does not match GS_ADMIN_USERNAME .
- the
PHPSESSID is not set
- the
$_SERVER['HTTP_ORIGIN'] is not set or $_SERVER['SERVER_NAME'] doesn't appear in [c]$_SERVER['HTTP_ORIGIN'] .
- the
$_GET['nonce'] is not set or isn't correct according to check_nonce .
To debug, can you please replace the above lines with the following:
PHP Code: if (!isset($USR) || $USR != get_cookie('GS_ADMIN_USERNAME')) $components_ext->response(200, '$USR global missing or GS_ADMIN_USERNAME cookie missing'); if (!isset($_COOKIE['PHPSESSID'])) $components_ext->response(200, '$_COOKIE[\'PHPSESSID\'] is not set'); if (empty($_SERVER['HTTP_ORIGIN']) || strpos($_SERVER['HTTP_ORIGIN'], $_SERVER['SERVER_NAME']) < 5) $components_ext->response(400, 'Server name mismatch'); if (empty($_GET['nonce'])) $components_ext->response(400, 'No nonce given'); if (!check_nonce($_GET['nonce'], 'components_ext_action', 'components_ext.php')) $components_ext->response(400, 'Nonce mismatch');
Try to save again, and see what error message is displayed, thanks
Posts: 1,928
Threads: 88
Joined: Apr 2010
I do not know where I have to replace these lines?
Posts: 6,266
Threads: 181
Joined: Sep 2011
Gs doesnt use that...
We dont even use sessions.
Check_nonce()
Is_logged_in()
If i had to guess your origin check doesnt work on all enviroments or phpsessions were not started
Posts: 305
Threads: 15
Joined: Mar 2014
(2016-06-21, 06:15:55)shawn_a Wrote: Gs doesnt use that...
We dont even use sessions.
Check_nonce()
Is_logged_in()
If i had to guess your origin check doesnt work on all enviroments or phpsessions were not started
Hey thanks for coming in shawn, I'm not a pro at PHP security and I assumed these were de facto requirements for the session to be valid. I'll check the Is_logged_in function, didn't know about that one yet.
Oleg, it's in the main plugin file components_ext.php (in your plugin folder), line 53-62.
Posts: 6,266
Threads: 181
Joined: Sep 2011
Theres also login_cookie_check to auto handle includes w login redirect
Posts: 1,928
Threads: 88
Joined: Apr 2010
Posts: 6,266
Threads: 181
Joined: Sep 2011
tested with stable works for me
Posts: 6,266
Threads: 181
Joined: Sep 2011
I would clean up that code, put the native gs checking stuff first, then your secondary local stuff second, too many or strings
Messages do not contain component id or title, no undo on delete
Add a setting or gsconfig to auto save to components.xml, so you can use native gs getters ?
Add sidebar tags back and jump to open component ?
Posts: 305
Threads: 15
Joined: Mar 2014
(2016-06-22, 03:23:09)shawn_a Wrote: I would clean up that code, put the native gs checking stuff first, then your secondary local stuff second, too many or strings
Messages do not contain component id or title, no undo on delete
Add a setting or gsconfig to auto save to components.xml, so you can use native gs getters ?
Add sidebar tags back and jump to open component ?
Glad to hear it works on your install, concerning the suggestions:
- Yes, should/will do.
- Might consider, but I believe users who didn't intend to delete the component would'nt hit OK when prompted to confirm deletion. I don't see much added value in an undo feature as you can cancel everything client-side. Automatic backups will be part of a future release though.
- One of the major reasons for creating this plugin is that it saves components in individual files instead of lumping them together in one. So native GS getters won't help here.
- IMO Sort & search together are way more flexible/ powerful than a tag cloud (that's why I replaced it).
|