Revisit and clean up the existing "skinsets" code, which apparently is the desired functionality, merely obscured in an optional feature. The table in #68 proves that the existing functionality is almost identical to the desired functionality. However, lots of renaming and rethinking will have to happen here (although renaming and cleaning up stuff can also come later).

Comments

moonray’s picture

Status: Active » Needs work
StatusFileSize
new6.04 KB

First stab at a patch. Needs a lot of work still.

moonray’s picture

StatusFileSize
new25.86 KB

Here's an updated patch.
Uses new skinr plugin file format. Still needs some clean-up work to remove old and outdated code. Skinr UI has barely been touched and still needs a lot of work.

sun’s picture

This patch should entirely ignore #956932: Determine optimal skin include file format and all other issues for now.

The goal is very focused: Turn current 'skinsets' into 'skins'.

Keeping their current syntax and structure, loading, and all other behavior. Potentially cleaning up related functionality, but not necessarily.

moonray’s picture

We got rid of the loading of skinsets functionality, so really there's nothing much to do here if we're not going to approach this patch with our new file format in mind.

moonray’s picture

Status: Needs work » Needs review
StatusFileSize
new38.71 KB

Hopefully this patch will pass muster. There are a few minor assumptions made in this patch without which it a lot of improvement makes no sense, namely the fact that we're going to be looping through a set of hooks to retrieve our data. There is a @todo attached to that part of code.

Status: Needs review » Needs work

The last submitted patch, skinr_956990_5.patch, failed testing.

moonray’s picture

Status: Needs work » Needs review
StatusFileSize
new37.93 KB

Too many changes in skinr too fast. Re-roll.

vrajak@gmail.com’s picture

For review should this just be tested that skinr works normally? or is there any particular test/review of functionality that should be done?

jacine’s picture

Status: Needs review » Needs work

Isn't part of the point of this to remove all references to skinsets? I still see lots of references to skinsets all over the place.

moonray’s picture

Yes it is. However, skinr_ui.admin.inc contains too much outdated code that will have to be completely re-written (and therefore I didn't touch it except for changes to existing function names); that is where most of the remaining references to skinsets remain.

  • Cleaned up variable names wherever I could to be consistent with the things we discussed in #956932: Determine optimal skin include file format
  • I fixed the update hooks in skinr.install to not change the update number between version 6.x and 7.x versions for the exact same functionality.
  • skinr_skinsets and skinr_skins tables are dropped because the code that used these tables no longer exists.
  • There is a small tweak to skinr_ui.admin.inc for admin/appearance/skinr/skins to at least make it useable to see which skins exist. (should I leave this part out of the patch?)

(for some reason d.o. won't let me upload patches at the moment, so it's forthcoming)

moonray’s picture

StatusFileSize
new95.29 KB
moonray’s picture

Status: Needs work » Needs review
moonray’s picture

StatusFileSize
new96.89 KB

Here's an update that fixes several issues found in above patch by jacine.

  • Old skins stored in db are updated to the new format now.
  • If a group isn't found, fields are dropped in the same way as if no group was specified.
  • A check was added to make sure we don't try to process an empty JS or CSS attachment when adjusting paths.
moonray’s picture

StatusFileSize
new96.16 KB

Hrm. let's try that without some of my testing code in it.

moonray’s picture

StatusFileSize
new97.01 KB

OK, found some more bugs and errors (css and js in skin options wouldn't load).

jacine’s picture

Status: Needs review » Needs work

Ok, first off it's really great that Skinr is working again. Yay :)

At almost 100k, this patch is really hard to review, because there is no general summary of what was done. Please summarize the main points, or changes from the previous patch next time, so we can get through these reviews easier.

Here's my attempt at a summary (mostly for my own sanity – I want to make sure I understand), and my review of the patch.

Summary

  • Changed:

    # Before After
    1 _skinr_fetch_config_defaults() skinr_config_info_default()
    2 hook_skinr_config() hook_skinr_config_info()
    3 skinr_fetch_config() skinr_fetch_config_info()
    4 skinr_get() skinr_skin_load()
    5 skinr_group_default() skinr_group_info_default()
    6 skinr_skin_default() skinr_skin_info_default()
    7 skinr_set() skinr_skin_save()
    8 skinr_skin_data() skinr_get_group_info()
    9 skinr_skinset_statuses() skinr_get_skin_info()
    10 skinr_skinsets() skinr_skin_info_process()
    11 _skinr_ui_admin_skinsets_build_row() _skinr_ui_admin_skin_infos_build_row() *
    12 skinr_ui_admin_skinsets() skinr_ui_admin_skin_infos() *
    13 skinr_ui_admin_skinsets_settings() skinr_ui_admin_skin_infos_settings() *
    14 skinr_ui_admin_skinsets_submit() skinr_ui_admin_skin_infos_submit() *
    15 skinr_ui_admin_skinsets_settings_submit() skinr_ui_admin_skin_infos_settings_submit() *
    16 skinr_ui_sort_by_info_name() skinr_ui_sort_by_title() *
    17 theme_skinr_ui_admin_skinsets_fieldset() theme_skinr_ui_admin_skin_infos_fieldset() *
    18 theme_skinr_ui_admin_skinsets_info() theme_skinr_ui_admin_skin_infos_summary() *
    19 theme_skinr_ui_admin_skinsets_incompatible() theme_skinr_ui_admin_skin_infos_incompatible() *
    20 theme_skinr_ui_admin_skinsets_settings_fieldset() theme_skinr_ui_admin_skin_infos_settings_fieldset() *
    21 theme_skinr_ui_admin_skinsets_settings_info() theme_skinr_ui_admin_skin_infos_summary() *
    22 theme_skinr_ui_admin_skinsets_settings_info() theme_skinr_ui_admin_skin_infos_settings_summary() *

    * See "Infos" below.

  • Added:

    1. skinr_plugin_hooks() – not functional.
    2. skinr_skin_delete().
    3. skinr_skin_delete_multiple().
    4. skinr_skin_info_status_default().
    5. skinr_skin_load_multiple() – not functional.
  • Removed

    1. _skinr_add_file()
    2. _skinr_skinset()
    3. skinr_skins_default()
    4. skinr_ui_overlay_enabled()

Apologies if any of the above is wrong. That's what I was able to grok.

$skin->skins

I realize that this is a @todo, but reading through the code it's really, really confusing:

@todo Rename $skin->skins to $skin->options throughout the module.

Is there a reason why we aren't doing this now?

infos?

All references to "infos" in function names and variables is literally making me cry. It doesn't make any sense at all to me. "plugins" seems more appropriate in most of these places, and there are way too many theme functions here, no? I realize this is a work in progress and this will not be the final version by any means, but I think they all (#12-22 in changed summary) have to change. Also, the comment blocks for all these functions still refer to "skinsets."

Table on admin/appearance/skinr/skins

This table is way too verbose, and there are too many theme functions used to generate it. I realize we'll have to figure out how to better display this information, but in the meantime, the following tweaks should be made:

  1. Run "theme hooks" through theme_item_list(). Give it #theme => item_list__skinr.
  2. Run "operations" though theme_links(). Give it a #theme => links__skinr and give it an .links & .inline class. Also, make sure you check if $skin_info['links'][$key] is set before doing anything with it.
  3. Nix the <h2> for the skin name.
  4. Remove the description. It's totally wrong in this context.
  5. Change "source name" to Source and just leave the module or theme name there. A module and theme cannot be named the same so this should be enough.
  6. Obviously, remove the "source type" column, per 5.
  7. Get rid of the "source" prefix for version.
  8. Also, if you are going to add classes to the table cells, make sure to do it for all of them so it's consistent.

One last thing regarding that page... The default fieldset has no legend. It should be labeled "General."

Other comments

+++ skinr.install
@@ -286,9 +157,29 @@ function skinr_update_7001() {
+/**
+ * No longer used: Install {skinr_skinsets} tables.
+ */
+
+/**
+ * No longer used: Install {skinr_skins} table.
+ */
+
+/**
+ * Create new {skinr_rules}.rule_type field to allow region rules.
+ */
+function skinr_update_7002() {

I don't get this. I thought they might be placeholders for functions you need to write, but skinr_update_7200() drops both tables. Maybe you forgot to delete this?

+++ skinr.module
@@ -44,6 +44,8 @@ function skinr_init() {
+  * @todo Account for drupal's caching being enabled and make it work.

Drupal should be capitalized.

+++ skinr.module
@@ -264,52 +236,64 @@ function skinr_skin_get_files($skins, $type, $theme = NULL) {
+function in_multiarray($needle, $haystack) {
+ ...
 }

Do we really need this? I see you are using it twice in this patch. If so, shouldn't it be named more appropriately named as a helper function with a skinr prefix?

+++ skinr.module
@@ -713,311 +729,265 @@ function skinr_group_default() {
+      if (strpos($file[0], 'http://') === 0) {

What about https?

+++ skinr_ui.module
-function skinr_ui_overlay_enabled() {
- ...
-}

We also need to:

  1. Delete the skinr_overlay_width and skinr_overlay_height variables in an update function.
  2. Remove admin/appearance/skinr/settings from hook_menu().
  3. Remove skinr_ui_settings().
  4. Remove dialog_js_load() in skinr_ui.module.
  5. And whatever else I'm missing
sun’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new88.51 KB

Reviewed this *giant* patch. Didn't have the guts to go into all details, but overall, this patch looks like a huge improvement, code-wise. I'd recommend to commit it under the following premise:

*Lots of* follow-up patches that are going to revamp the API "anyway".

- Removed most of the .install file changes. Let's care for the upgrade/update path later on.

- $skin['_options'] and similar properties having starting with an underscore will have to be completely revised in a next step.

- Most of the added @todos are in line with the idea of major API rewrites "anyway".

- Some CSS classes that actually belong to Skinr module have been changed from "skinr" prefix to "skin" prefix. That'll have to be fixed in a follow-up patch. ("skin" is outside of the module's namespace.)

I understand that Jacine is probably not able to make much sense of the code just yet. However, I'd still recommend to commit this patch as-is anyway, but as said, only under the premise that we're going to heavily refactor the code afterwards.

Reasoning:

This patch doesn't really change the existing code. It merely renames a couple of functions and variable names throughout the module to comply with the terminology and ideas we came up with in the other "determine..." issue. So, in turn, trying to understand this code is the same WTF of understanding the current code, with the sole exception that with this patch, function and variable names are a bit more human-readable.

jacine’s picture

Status: Reviewed & tested by the community » Needs work

Ok, patch in #17 is committed in the interest of moving things along, but I still stand by all my comments in #17. :)

http://drupal.org/cvs?commit=456360

Marking needs work, so we can get to the next step. Please change the title to whatever that is accordingly. :)

moonray’s picture

StatusFileSize
new7.65 KB
  1. I've created a separate issue for the admin UI (skinr_ui.admin.inc) since that'll require a lot of UI work before code can be written for it: #984402: Add "details" link that shows preview of rendered skin widget and additional info. I only updated some of the function and variable names for this include file in the above patch. Any actual optimization work (and subsequent comment adjustments) still needs to happen.
  2. See #956994: Write load and parse code for Skinr include files in PHP format for the reason I haven't done @todo Rename $skin->skins to $skin->options throughout the module.; we need to re-think the whole skin object.

I've addressed all Jacine's other issues in the below patch.

  • Capitalized Drupal in PHPdocs
  • Renamed in_multiarray() function to _skinr_ in_multiarray()
  • Added filtering for https in _skinr_add_path_to_files()
  • Removed Dialog module related code and renamed dialog_js_load() to skinr_js_load() (which we'll need for the UI later on).
  • I also removed some old @todos

Here's a list of all the @todos found in code (I've left out the ones from skinr_ui.admin.inc and skinr_ui.install since they need to be done later or elsewhere):

skinr.module:48:         * @todo Account for Drupal's caching being enabled and make it work. [function skinr_preprocess()]
skinr.module:71:        // @todo How can this be done better with drupal_process_attached()? [function skinr_preprocess()]
skinr.module:113:        * @todo Rename this function to something more indicative of its function. [function skinr_skin_extract()]
skinr.module:114:        * @todo Rename $sids to something more descriptive; these are skin ids. [function skinr_skin_extract()]
skinr.module:275:        * @todo Rename function to reflect new functionality. [function skinr_flatten_skins_array()]
skinr.module:385:        * @todo Rename this function to skinr_rule_is_visible(). [function skinr_rule_visible()]
skinr.module:559:        * @todo Make this function functional. [function skinr_skin_delete_multiple()]
skinr.module:580:        * @todo Rename $skin->skins to $skin->options throughout the module. [function skinr_skin_load()]
skinr.module:655:        * @todo Make this function functional. [function skinr_skin_load_multiple()]
skinr.module:656:        * @todo Look at using hook_entity_info() and entity_load(). [function skinr_skin_load_multiple()]
skinr.module:780:       // @todo Load the include files and get an array of hooks; we need to know which module and which plugin comprises the hook.[function skinr_plugin_hooks()]
skinr.module:794:        * @todo Adjust docs to account for arrays instead of filenames. [function _skinr_add_path_to_files()]
skinr.module:844:       // @todo Apply overridden statuses. This will need to be loaded from database. [function skinr_skin_info_process()]
skinr_ui.module:477:    // @todo Allow for custom form callbacks. [function skinr_ui_form_alter()]
skinr_ui.module:734:     * @todo Rename function to be more descriptive. [function _skinr_is_featured()]
skinr_ui.module:751:     * @todo Evaluate the usefulness of this function. Should it go into a UI front-end specific file? [function _skinr_ui_ajax_id()]
skinr_ui.module:769:     * @todo Rename function to be more descriptive. [function skinr_ui_info_options_to_form_options()]
moonray’s picture

Status: Needs work » Needs review
jacine’s picture

Status: Needs review » Needs work

I'm fine with this patch except for the _skinr_in_multiarray() function. It's better that it has been renamed but I find it odd to include in the first place. Seems to me that it would be better to just do the looping in place, but I'll leave that to others to comment on further. Marking "needs work" based on that for now.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new14.74 KB

We need to defer removal of that _skinr_in_multiarray() function until further clean-ups. As mentioned before, we're far from done with this issue yet.

moonray’s picture

Status: Needs review » Reviewed & tested by the community

Looks good. All the additions are good ones (but of course!). :)

jacine’s picture

Status: Reviewed & tested by the community » Needs work

Committed: http://drupal.org/cvs?commit=461516 :)

Setting to needs work, as the focus of this issue will now be on the handlers.

jacine’s picture

The patch in #22 broke Skinr. @moonray has a feeling that the modules/*skinr.inc files are not loading and therefore it's completely not functional right now.

jacine’s picture

Status: Needs work » Needs review
StatusFileSize
new770 bytes

Proposed fix from @moonray attached.

jacine’s picture

StatusFileSize
new725 bytes

Here's an updated patch.

jacine’s picture

Status: Needs review » Reviewed & tested by the community

Committed patch in #27: http://drupal.org/cvs?commit=462660

jacine’s picture

Status: Reviewed & tested by the community » Needs work

Needs work for API docs.

sun’s picture

+++ skinr.module	10 Dec 2010 21:31:24 -0000
@@ -425,7 +425,12 @@ function skinr_rule_visible($rid) {
+    if (function_exists('drupal_get_path')) {

I do not understand this condition. skinr_module_load_all_includes() is invoked from skinr_init() only, and hook_init() itself is only invoked when Drupal reached full bootstrap, so all subsystems and modules have been loaded. Can we clarify what's happening here?

Powered by Dreditor.

jacine’s picture

Can anyone clarify #30 for @sun, please?

coltrane’s picture

If skinr_module_load_all_includes() is only called from skinr_init() I also don't see why the function_exists() is necessary.

moonray’s picture

We can get rid of the line in #30.
Code was copied from http://api.drupal.org/api/drupal/includes--module.inc/function/module_lo..., but I forgot to take that out (wasn't 100% sure about it in any case).

coltrane’s picture

Status: Needs work » Needs review
StatusFileSize
new783 bytes
moonray’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

jacine’s picture

Status: Reviewed & tested by the community » Needs work

Committed! Thanks :) http://drupal.org/cvs?commit=466110

Setting to needs work for API docs.

jacine’s picture

Priority: Critical » Normal
Status: Needs work » Needs review
StatusFileSize
new8.25 KB

Here's a patch for the docs.

jacine’s picture

StatusFileSize
new8.25 KB

Err, Here's one without trailing white-space problems.

jacine’s picture

StatusFileSize
new8.92 KB

Forgot alter hooks.

moonray’s picture

Status: Needs review » Needs work

The plugin will inherit information such as what version of core it applies to from the module or theme implementing it.

I don't think this information is relevant. It's implied if it's part of a module or theme. The module or theme would never be enabled if it wasn't compatible with core, so the hook_skinr_api() hook would never be loaded anyway.

+ * the name of the group. Note that you cannot define 2 groups with the same
+ * the same name, even if they are in different plugins.

'the same' is repeated. It appears at the end of the line and again at the beginning of the next. This is the case with the description for both groups and skins.

+ * Required. Define the skin(s) for this Skinr plugin. Each skin definition

Should hook_plugin_skinr_skin_info() be required? It's not in our default groups plugin in skinr core.

+ * - weight (discouraged): Sets the weight of the skin inside the group; NULL
+ * by default. weight should not be set on each individual skin. Instead
+ * - attached (optional): A array containing information about CSS and

The sentence abruptly stops with the word "Instead".

+ * - class (required): An array containing one or more classes the skin
+ * should apply. All classes should be entered as an array: For example:
+ * 'class' => array('class-b', 'class-b')

Should 'class' be indented that far?

+ * - default_status (optional): Skins are disabled by default to keep UI
+ * clutter to a minimum. In some cases, like contrib themes, it makes sense to
+ * enable skins which are required to make the theme work properly by default.
+ * Setting this property to 1, will cause it to be enabled it by default for
+ * all installed themes.

"will cause it to be enabled it by default"... there's an "it" too many.

Looks good otherwise. :)

jacine’s picture

Status: Needs work » Needs review
StatusFileSize
new8.87 KB

Thanks! This patch should address all those concerns.

moonray’s picture

Status: Needs review » Needs work

This patch will need to be adjusted again, depending on what happens in #956994: Write load and parse code for Skinr include files in PHP format with the hook_skinr_api() function.

  • In hook_plugin_skinr_skin_info() you use 'skinr_navigation' as the group, but in hook_plugin_skinr_group_info() you have 'skinr_menus'. You might want to make those consistent with each other.
  • Perhaps there should be mention of the default groups in the docs there?
  • hook_plugin_skinr_skin_info_alter() has an empty line at the end of the function, which should probably be removed.
phyadmin’s picture

StatusFileSize
new8.17 KB

Patch given on 12/20 broken after patch

While the code in CVS isn't "working" right now, this is the only issue that is actually holding up the basic functionality: #956994: Write load and parse code for Skinr include files in PHP format, and it has working patches. I've got the one in #29 running locally to use for my themes: http://drupal.org/files/issues/patch_commit_4790e14e3753.patch

@ http://drupal.org/node/959686

applied. Fixed by taking added lines from that patch and applying them after the above patch. Here's the patch.

jacine’s picture

Status: Needs work » Needs review
StatusFileSize
new10.21 KB

Hopefully this addresses all of @moonray's points in #42.

moonray’s picture

Status: Needs review » Reviewed & tested by the community

Let's commit this. The patch in #956994: Write load and parse code for Skinr include files in PHP format should then be responsible for making any alterations it requires in the api docs.

sun’s picture

Assigned: Unassigned » sun
Status: Reviewed & tested by the community » Needs review
+++ skinr.api.php	7 Jan 2011 04:33:02 -0000
@@ -93,18 +93,220 @@ function hook_skinr_config() {
+function hook_plugin_skinr_group_info() {

s/plugin/PLUGINNAME/

+++ skinr.api.php	7 Jan 2011 04:33:02 -0000
@@ -93,18 +93,220 @@ function hook_skinr_config() {
+ * - default_status (optional): Skins are disabled by default to keep UI

All of the skin info properties specify more or less "defaults", so 'status' should be sufficient.

+++ skinr.api.php	7 Jan 2011 04:33:02 -0000
@@ -93,18 +93,220 @@ function hook_skinr_config() {
+function hook_plugin_skinr_skin_info() {

Actually, we should (or need to) move the "dynamic" (arbitrary) PLUGINNAME to a later position.

That is, because several namespace conflicts exist with having the plugin name directly after hook. The "plugin" of one module may clash with the module name of another module.

Simple example for a nameclash: Someone thinks that Skinr's default settings or whatnot are bad and thus creates the skinr_default module. The hook namespace for this module therefore is skinr_default, but Skinr module already contains a skin "plugin" that is named default, so we potentially have the identical function defined twice.

To prevent this, the pattern should be:

hook_skinr_skin_PLUGIN_info()

Powered by Dreditor.

sun’s picture

StatusFileSize
new12.58 KB

Here we go.

jacine’s picture

Status: Needs review » Fixed

Ok, committed. Thanks :)

sun’s picture

+++ skinr.api.php	9 Jan 2011 11:56:10 -0000
@@ -93,18 +93,281 @@ function hook_skinr_config() {
+ * - default_status (optional): Skins are disabled by default to keep UI

I forgot to rename default_status into status, but we can also do this in #956994: Write load and parse code for Skinr include files in PHP format or separate issue.

Powered by Dreditor.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.