-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(developers): explorer entity information in developer tools #10318
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In hypeDBExplorer (https://github.com/hypejunction/hypedbexplorer) I also have subgrids for metadata owned by the entities, entity annotations and annotations owned, entities owned and contained by the entity, access collections owned by the entity, access collections the entity is member of, river items that the entity is subject/object/target of
if (empty($entity) || empty($type) || $key === null) { | ||
register_error(elgg_echo('error:missing_data')); | ||
access_show_hidden_entities($show_hidden); | ||
forward(REFERER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should start using response objects for new actions.
return elgg_error_response()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
|
||
// Entity Information | ||
$entity_rows = ['type', 'subtype', 'owner_guid', 'site_guid', 'container_guid', 'access_id', 'time_created', 'time_updated', 'last_action', 'enabled']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a static method to ElggEntity
to get those from there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meh... maybe later... schema is being overhauled... could add it later on...
|
||
$entity_info .= '</table>'; | ||
|
||
echo elgg_view_module('inline', elgg_echo('developers:entity_explorer:info:attributes'), $entity_info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One module - one view. Makes it easier to read and modify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
$metadata_info .= '<td>' . elgg_view('output/url', [ | ||
'text' => elgg_view_icon('remove'), | ||
'href' => 'action/developers/entity_explorer_delete?guid=' . $entity->guid . '&type=metadata&key=' . $md->name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use elgg_http_add_url_query_elements()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (empty($entity_relationships)) { | ||
$relationship_info = elgg_echo('notfound'); | ||
} else { | ||
$relationship_columns = ['id', 'time_created', 'guid_one', 'relationship', 'guid_two']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make guid_one
and guid_two
links that open a new tab/ligthbox with Entity explorer for that entity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool but can wait
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will wait...
echo elgg_view_module('inline', elgg_echo('developers:entity_explorer:info:attributes'), $entity_info); | ||
|
||
// Metadata Information | ||
$entity_metadata = elgg_get_metadata(['guid' => $guid, 'limit' => false]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use elgg_list_*
where possible with proper offset keys, in case these get too much on a large site.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metadata is manageable... offsets makes it more complex... you will just have to wait a few secs longer
I think non-tech admins could really wreck things with this. I wouldn't mind requiring a setting be checked to enable editing, with a big red warning. And a hook to override so sites could decide who can edit. But I'm paranoid. |
69a515f
to
570e5b0
Compare
i was trying to add a basic feature for debugging... dbexplorer brings way more features... like it, but may be a bit too much for core...
it is developer tools... i do not expect non-tech to use it a lot.
can always make a view_var hook to quick return if you want to limit it.... |
hoping this can go in in current state... if you see need for improvements you can always add a PR for it |
<?php | ||
$entity = elgg_extract('entity', $vars); | ||
|
||
$entity_rows = ['type', 'subtype', 'owner_guid', 'site_guid', 'container_guid', 'access_id', 'time_created', 'time_updated', 'last_action', 'enabled']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entities are iterators:
foreach ($entity as $attr => $value) {
// just need to strip password_hash, password, and salt.
}
|
||
foreach ($entity_rows as $entity_row) { | ||
$entity_info .= '<tr>'; | ||
$entity_info .= '<td>' . $entity_row . '</td><td>' . $entity->$entity_row . '</td>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs htmlspecialchars(..., ENT_QUOTES)
if (empty($entity_metadata)) { | ||
$metadata_info = elgg_echo('notfound'); | ||
} else { | ||
$md_columns = ['id', 'name_id', 'name', 'value_id', 'value', 'value_type', 'access_id', 'time_created', 'enabled']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ElggMetadata iterate their attributes, too.
foreach ($entity_metadata as $md) { | ||
$metadata_info .= '<tr>'; | ||
foreach ($md_columns as $md_col) { | ||
$metadata_info .= '<td>' . $md->$md_col . '</td>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here...
|
||
foreach ($private_settings as $key => $value) { | ||
$private_settings_info .= '<tr>'; | ||
$private_settings_info .= "<td>$key</td><td>$value</td>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTML escape both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTML escaping is a must. Reworking to use iterators (for everything) to get attributes/values can wait.
I suppose filter_tags() would be OK instead of escaping. |
i think going for output/text is more the elgg way |
With the developer tools you can now lookup attributes, metadata, relationships and private settings of entities. You can also remove individual metadata, relationships or private settings for an entity or remove an entity completely. fixes Elgg#9384
570e5b0
to
251f406
Compare
now using output/text, so html is escaped where needed |
With the developer tools you can now lookup attributes, metadata,
relationships and private settings of entities. You can also remove
individual metadata, relationships or private settings for an entity or
remove an entity completely.
fixes #9384