public static function validateThemeInformation($information)
{
// set default thumbnail if not sets
if (!$information['thumbnail']) {
$information['thumbnail'] = 'thumbnail.png';
}
// check if there are templates
if (isset($information['templates']) && $information['templates']) {
foreach ($information['templates'] as $i => $template) {
if (!isset($template['label']) || !$template['label'] || !isset($template['path']) || !$template['path'] || !isset($template['format']) || !$template['format']) {
unset($information['templates'][$i]);
continue;
}
// if there are no positions we should continue with the next item
if (!isset($template['positions']) && $template['positions']) {
continue;
}
// loop positions
foreach ($template['positions'] as $j => $position) {
if (!isset($position['name']) || !$position['name']) {
unset($information['templates'][$i]['positions'][$j]);
continue;
}
// ensure widgets are well-formed
if (!isset($position['widgets']) || !$position['widgets']) {
$information['templates'][$i]['positions'][$j]['widgets'] = array();
}
// ensure editors are well-formed
if (!isset($position['editors']) || !$position['editors']) {
$information['templates'][$i]['positions'][$j]['editors'] = array();
}
// loop widgets
foreach ($position['widgets'] as $k => $widget) {
// check if widget is valid
if (!isset($widget['module']) || !$widget['module'] || !isset($widget['action']) || !$widget['action']) {
unset($information['templates'][$i]['positions'][$j]['widgets'][$k]);
continue;
}
}
}
// check if there still are valid positions
if (!isset($information['templates'][$i]['positions']) || !$information['templates'][$i]['positions']) {
return;
}
}
// check if there still are valid templates
if (!isset($information['templates']) || !$information['templates']) {
return;
}
}
return $information;
}