Component properties can now be translated
This commit is contained in:
parent
05017dc559
commit
fbe23091b6
|
|
@ -9066,7 +9066,6 @@ html.cssanimations .cursor-loading-indicator.hide {
|
|||
line-height: 150%;
|
||||
position: relative;
|
||||
list-style: none;
|
||||
/* Temporary checkbox style */
|
||||
}
|
||||
.control-filelist ul li a:hover {
|
||||
background: #dddddd;
|
||||
|
|
@ -9231,7 +9230,7 @@ html.cssanimations .cursor-loading-indicator.hide {
|
|||
}
|
||||
.control-filelist ul li .checkbox {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
top: 13px;
|
||||
right: 17px;
|
||||
}
|
||||
.control-filelist ul li .checkbox label {
|
||||
|
|
|
|||
|
|
@ -150,10 +150,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
/* Temporary checkbox style */
|
||||
.checkbox {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
top: 13px;
|
||||
right: 17px;
|
||||
|
||||
label {
|
||||
|
|
|
|||
|
|
@ -20,26 +20,35 @@ class ComponentHelpers
|
|||
$result = [];
|
||||
|
||||
$property = [
|
||||
'property'=>'oc.alias',
|
||||
'title'=>Lang::get('cms::lang.component.alias'),
|
||||
'description'=>Lang::get('cms::lang.component.alias_description'),
|
||||
'type'=>'string',
|
||||
'validationPattern'=>'^[a-zA-Z]+[0-9a-z\_]*$',
|
||||
'validationMessage'=>Lang::get('cms::lang.component.validation_message')
|
||||
'property' => 'oc.alias',
|
||||
'title' => Lang::get('cms::lang.component.alias'),
|
||||
'description' => Lang::get('cms::lang.component.alias_description'),
|
||||
'type' => 'string',
|
||||
'validationPattern' => '^[a-zA-Z]+[0-9a-z\_]*$',
|
||||
'validationMessage' => Lang::get('cms::lang.component.validation_message')
|
||||
];
|
||||
$result[] = $property;
|
||||
|
||||
$properties = $component->defineProperties();
|
||||
foreach ($properties as $name=>$params) {
|
||||
foreach ($properties as $name => $params) {
|
||||
$property = [
|
||||
'property'=>$name,
|
||||
'title'=>isset($params['title']) ? $params['title'] : $name,
|
||||
'type'=>isset($params['type']) ? $params['type'] : 'string'
|
||||
'property' => $name,
|
||||
'title' => isset($params['title']) ? $params['title'] : $name,
|
||||
'type' => isset($params['type']) ? $params['type'] : 'string'
|
||||
];
|
||||
|
||||
foreach ($params as $name=>$value) {
|
||||
if (!array_key_exists($name, $property))
|
||||
$property[$name] = $value;
|
||||
foreach ($params as $name => $value) {
|
||||
if (isset($property[$name])) continue;
|
||||
$property[$name] = $value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Translate human values
|
||||
*/
|
||||
$translate = ['title', 'description'];
|
||||
foreach ($property as $name => $value) {
|
||||
if (!in_array($name, $translate)) continue;
|
||||
$property[$name] = Lang::get($value);
|
||||
}
|
||||
|
||||
$result[] = $property;
|
||||
|
|
@ -60,7 +69,7 @@ class ComponentHelpers
|
|||
$result['oc.alias'] = $component->alias;
|
||||
|
||||
$properties = $component->defineProperties();
|
||||
foreach ($properties as $name=>$params)
|
||||
foreach ($properties as $name => $params)
|
||||
$result[$name] = $component->property($name);
|
||||
|
||||
return json_encode($result);
|
||||
|
|
@ -74,10 +83,11 @@ class ComponentHelpers
|
|||
public static function getComponentName($component)
|
||||
{
|
||||
$details = $component->componentDetails();
|
||||
if (isset($details['name']))
|
||||
return $details['name'];
|
||||
$name = (isset($details['name']))
|
||||
? $details['name']
|
||||
: 'cms::lang.component.unnamed';
|
||||
|
||||
return Lang::get('cms::lang.component.unnamed');
|
||||
return Lang::get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -88,9 +98,10 @@ class ComponentHelpers
|
|||
public static function getComponentDescription($component)
|
||||
{
|
||||
$details = $component->componentDetails();
|
||||
if (isset($details['description']))
|
||||
return $details['description'];
|
||||
$name = (isset($details['description']))
|
||||
? $details['description']
|
||||
: 'cms::lang.component.no_description';
|
||||
|
||||
return Lang::get('cms::lang.component.no_description');
|
||||
return Lang::get($name);
|
||||
}
|
||||
}
|
||||
|
|
@ -102,15 +102,15 @@ class ComponentList extends WidgetBase
|
|||
$component->alias = '--alias--';
|
||||
|
||||
$item = (object)[
|
||||
'title' => ComponentHelpers::getComponentName($component),
|
||||
'description' => ComponentHelpers::getComponentDescription($component),
|
||||
'plugin' => $pluginName,
|
||||
'title' => ComponentHelpers::getComponentName($component),
|
||||
'description' => ComponentHelpers::getComponentDescription($component),
|
||||
'plugin' => $pluginName,
|
||||
'propertyConfig' => ComponentHelpers::getComponentsPropertyConfig($component),
|
||||
'propertyValues' => ComponentHelpers::getComponentPropertyValues($component, $alias),
|
||||
'className' => get_class($component),
|
||||
'pluginIcon' => $pluginIcon,
|
||||
'alias' => $alias,
|
||||
'name' => $componentInfo->duplicateAlias ? $componentInfo->className : $componentInfo->alias
|
||||
'className' => get_class($component),
|
||||
'pluginIcon' => $pluginIcon,
|
||||
'alias' => $alias,
|
||||
'name' => $componentInfo->duplicateAlias ? $componentInfo->className : $componentInfo->alias
|
||||
];
|
||||
|
||||
if ($searchWords && !$this->itemMatchesSearch($searchWords, $item))
|
||||
|
|
@ -118,11 +118,11 @@ class ComponentList extends WidgetBase
|
|||
|
||||
if (!array_key_exists($pluginClass, $items)) {
|
||||
$group = (object)[
|
||||
'title' => $pluginName,
|
||||
'title' => $pluginName,
|
||||
'description' => $pluginDescription,
|
||||
'pluginClass' => $pluginClass,
|
||||
'icon' => $pluginIcon,
|
||||
'items' => []
|
||||
'icon' => $pluginIcon,
|
||||
'items' => []
|
||||
];
|
||||
|
||||
$items[$pluginClass] = $group;
|
||||
|
|
@ -167,10 +167,10 @@ class ComponentList extends WidgetBase
|
|||
}
|
||||
|
||||
$componentList[] = (object)[
|
||||
'className' => $className,
|
||||
'alias' => $alias,
|
||||
'className' => $className,
|
||||
'alias' => $alias,
|
||||
'duplicateAlias' => $duplicateAlias,
|
||||
'pluginClass' => get_class($plugin)
|
||||
'pluginClass' => get_class($plugin)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue