Permalink
Browse files

feature(widgets): widget title and description can be autodetected

fixes #3136
  • Loading branch information...
jdalsem committed Mar 22, 2016
1 parent bc56faf commit 3c61e2f0b2b21cac8ab538e5ede76f647f4217ed
Showing with 19 additions and 1 deletion.
  1. +19 −1 engine/classes/ElggWidgetDefinition.php
@@ -42,9 +42,27 @@ public function __construct($handler) {
*/
public static function factory(array $options) {
- $definition = new \ElggWidgetDefinition($options['handler']);
+ $handler = elgg_extract('handler', $options);
+ $definition = new \ElggWidgetDefinition($handler);
unset($options['handler']);
+ if (!isset($options['name']) || empty($options['name'])) {
+ $name = $handler;
+ if (elgg_language_key_exists("widgets:{$handler}:name")) {
+ $name = elgg_echo("widgets:{$handler}:name");
+ } elseif (elgg_language_key_exists($handler)) {
+ $name = elgg_echo($handler);
+ }
+
+ $options['name'] = $name;
+ }
+
+ if (!isset($options['description']) || empty($options['description'])) {
+ if (elgg_language_key_exists("widgets:{$handler}:description")) {
+ $options['description'] = elgg_echo("widgets:{$handler}:description");
+ }
+ }
+
foreach ($options as $key => $value) {
$definition->$key = $value;
}

0 comments on commit 3c61e2f

Please sign in to comment.