static function layout_selector(&$params, $formname = 'adminForm', $autosubmit = 1, $layout_type = 'clayout')
 {
     if (!$params->get($layout_type . '_switcher')) {
         return '';
     }
     $_default_layout = $params->get($layout_type, $layout_type == 'clayout' ? 'blog' : 'default');
     if ($layout_type == 'clayout') {
         $displayed_tmpls = $params->get('displayed_' . $layout_type . 's');
         if (empty($displayed_tmpls)) {
             $displayed_tmpls = array();
         } else {
             if (!is_array($displayed_tmpls)) {
                 $displayed_tmpls = explode("|", $displayed_tmpls);
             }
         }
         $current_layout = $params->get('clayout');
         if (count($displayed_tmpls) && $current_layout && !in_array($current_layout, $displayed_tmpls)) {
             $displayed_tmpls[] = $current_layout;
         }
     }
     $allowed_tmpls = $params->get('allowed_' . $layout_type . 's');
     if (empty($allowed_tmpls)) {
         $allowed_tmpls = array();
     } else {
         if (!is_array($allowed_tmpls)) {
             $allowed_tmpls = explode("|", $allowed_tmpls);
         }
     }
     // Return if none allowed layout(s) were configured / allowed
     $layout_names = $layout_type == 'clayout' ? $displayed_tmpls : $allowed_tmpls;
     if (!count($layout_names)) {
         return false;
     }
     $app = JFactory::getApplication();
     $option = JRequest::getCmd('option');
     $layout = JRequest::getCmd('layout');
     $svar = $layout ? '.' . $layout : '.category';
     $layout_typename = $layout_type == 'clayout' ? 'category' : 'items';
     /*if (!$layout) $svar .= JRequest::getInt('cid');
     		else if ($layout=='tags') $svar .= JRequest::getInt('tagid');
     		else if ($layout=='author') $svar .= JRequest::getInt('authorid');
     		if ($layout) $svar .= '.category'.JRequest::getInt('cid');*/
     $layout = $app->getUserStateFromRequest($option . $svar . '.' . $layout_type, $layout_type, $_default_layout, 'string');
     $_switcher_label = $params->get($layout_type . '_switcher_label', 0);
     $inside_label = $_switcher_label == 2 ? ' ' . JText::_('FLEXI_LAYOUT') : '';
     $outside_label = $_switcher_label == 1 ? '<span class="flexi label limit_override_label">' . JText::_('FLEXI_LAYOUT') . '</span>' : '';
     $tmpls = flexicontent_tmpl::getTemplates();
     // Get layout parameters and find the layout title
     foreach ($layout_names as $layout_name) {
         $tmpl = @$tmpls->{$layout_typename}->{$layout_name};
         if ($tmpl && empty($tmpl->parameters)) {
             $tmpl->parameters = new JRegistry(flexicontent_tmpl::getLayoutparams($layout_typename, $layout_name));
         }
         $tmpl->customtitle = $tmpl ? JText::_($tmpl->parameters->get('custom_layout_title', @$tmpl->defaulttitle)) : '';
     }
     if ($params->get('clayout_switcher_display_mode', 1) == 0) {
         flexicontent_html::loadFramework('select2');
         $classes = "fc_field_filter use_select2_lib";
         $onchange = !$autosubmit ? '' : ' onchange="adminFormPrepare(this.form, 2);" ';
         $attribs = ' class="' . $classes . '" ' . $onchange;
         $options = array();
         foreach ($layout_names as $layout_name) {
             $tmpl = @$tmpls->{$layout_typename}->{$layout_name};
             $tmpl_title = $tmpl ? $tmpl->customtitle : $layout_name;
             $options[] = JHTML::_('select.option', $layout_name, $tmpl_title . $inside_label);
         }
         $html = JHTML::_('select.genericlist', $options, $layout_type, $attribs, 'value', 'text', $layout);
     } else {
         $tmplurl = 'components/com_flexicontent/templates/';
         $tooltip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip';
         $n = 0;
         $options = array();
         foreach ($layout_names as $layout_name) {
             $tmpl = @$tmpls->{$layout_typename}->{$layout_name};
             $tmpl_title = $tmpl ? $tmpl->customtitle : '';
             $checked_attr = $layout == $layout_name ? ' checked=checked ' : '';
             $options[] = '<input type="radio" name="' . $layout_type . '" value="' . $layout_name . '" id="' . $layout_type . $n . '" onchange="adminFormPrepare(this.form, 2);" ' . $checked_attr . '>' . '<label for="' . $layout_type . $n . '" class="btn ' . $tooltip_class . '" title="' . $tmpl_title . '"><img alt="' . $layout_name . '" src="' . $tmplurl . $layout_name . '/clayout.png"></label>';
             $n++;
         }
         $html = '<fieldset class="radio btn-group group-fcinfo">' . implode('', $options) . '</fieldset>' . '<script> jQuery(\'input[name="' . $layout_type . '"]\').click( function() { adminFormPrepare(this.form, 2); }); </script>';
     }
     return $outside_label . $html;
 }
 /**
  * Method to get the layout parameters of an item
  * 
  * @return string
  * @since 1.5
  */
 function getLayoutparams($force = false)
 {
     return $this->_clayout ? flexicontent_tmpl::getLayoutparams('category', $this->_clayout, $force) : '';
 }
 /**
  * Method to get the layout parameters of an item
  * 
  * @return string
  * @since 3.0
  */
 function getLayoutparams($force = false)
 {
     return $this->_ilayout ? flexicontent_tmpl::getLayoutparams('items', $this->_ilayout, $force) : '';
 }