/**
  * @since       1.1.0
  */
 public function getFieldsandfiltersFieldsHTML(JObject $layoutFields, Jobject $fields, stdClass $element = null, $context = 'fields', JRegistry $params = null, $ordering = 'ordering')
 {
     if (!($fields = $fields->get($this->_name))) {
         return;
     }
     $fields = is_array($fields) ? $fields : array($fields);
     $variables = new JObject();
     $variables->type = $this->_type;
     $variables->name = $this->_name;
     $variables->params = $this->params;
     $variables->element = $element;
     jimport('joomla.filesystem.file');
     while ($field = array_shift($fields)) {
         $modeName = FieldsandfiltersModes::getModeName($field->mode);
         $isStaticMode = $modeName == FieldsandfiltersModes::MODE_STATIC;
         if ($isStaticMode && empty($field->data) || $modeName == 'field' && (!isset($element->data) || !property_exists($element->data, $field->id))) {
             continue;
         }
         $dataElement = $isStaticMode ? $field->data : $element->data->get($field->id);
         if (is_string($dataElement)) {
             if ($isStaticMode) {
                 $field->data = new JRegistry($dataElement);
             } else {
                 $element->data->set($field->id, new JRegistry($dataElement));
             }
         }
         if ($params) {
             $paramsTemp = $field->params;
             $paramsField = clone $field->params;
             $paramsField->merge($params);
             $field->params = $paramsField;
         }
         if ($field->params->get('base.show_name')) {
             FieldsandfiltersFieldsField::preparationContent('base.prepare_name', $field, 'name', $context, $field->id, $params);
         }
         if ($field->params->get('base.site_enabled_description')) {
             FieldsandfiltersFieldsField::preparationContent('base.prepare_description', $field, 'description', $context, $field->id, $params);
         }
         // create new image if not exists
         $scaleImage = (int) $field->params->def('type.scale', $this->params->get('scale', 0));
         $createThumb = (bool) $field->params->get('type.create_thumb');
         $scaleThumb = (int) $field->params->def('type.scale_thumb', $this->params->get('scale_thumb', 0));
         if ($scaleImage || $createThumb && $scaleThumb) {
             $data = $isStaticMode ? $field->data : $element->data->get($field->id, new JRegistry());
             if (($image = $data->get('image')) && file_exists(JPath::clean(JPATH_ROOT . '/' . $image))) {
                 if ($scaleImage && ($src = $data->get('src')) && !file_exists(JPath::clean(JPATH_ROOT . '/' . $src))) {
                     $imageInfo = self::prepareImageInfo($field, $element, $image, basename($src), $scaleImage);
                     try {
                         if (!FieldsandfiltersImage::createImage($field->name, $imageInfo)) {
                             throw new RuntimeException(JText::sprintf('COM_FIELDSANDFILTERS_ERROR_NOT_CREATE_IMAGE', $field->name));
                         }
                     } catch (Exception $e) {
                         JLog::add($e->getMessage(), JLog::ERROR, 'plgFieldsandfiltersTypesImage');
                     }
                 }
                 if ($createThumb && $scaleThumb && ($src = $data->get('src_thumb')) && !file_exists(JPath::clean(JPATH_ROOT . '/' . $src))) {
                     $imageInfo = $this->prepareImageInfo($field, $element, $image, basename($src), $scaleThumb, 'thumb');
                     try {
                         if (!FieldsandfiltersImage::createImage($field->name . ' Thumbs', $imageInfo)) {
                             throw new RuntimeException(JText::sprintf('COM_FIELDSANDFILTERS_ERROR_NOT_CREATE_IMAGE', $field->name . ' Thumb'));
                         }
                     } catch (Exception $e) {
                         JLog::add($e->getMessage(), JLog::ERROR, 'plgFieldsandfiltersTypesImage');
                     }
                 }
             }
             unset($data, $imageInfo);
         }
         unset($fieldTypeParams);
         $layoutField = FieldsandfiltersFieldsField::getLayout('field', $modeName, $field->params);
         $variables->field = $field;
         $layout = KextensionsPlugin::renderLayout($variables, $layoutField);
         $layoutFields->set(KextensionsArray::getEmptySlotObject($layoutFields, $field->{$ordering}, false), $layout);
         if ($params) {
             $field->params = $paramsTemp;
             unset($paramsField);
         }
     }
     unset($variables, $imageInfo);
 }
 /**
  * @since       1.1.0
  */
 public function getFieldsandfiltersFieldsHTML(JObject $layoutFields, Jobject $fields, stdClass $element = null, $context = 'fields', JRegistry $params = null, $ordering = 'ordering')
 {
     if (!($fields = $fields->get($this->_name))) {
         return;
     }
     $fields = is_array($fields) ? $fields : array($fields);
     $variables = new JObject();
     $variables->type = $this->_type;
     $variables->name = $this->_name;
     $variables->params = $this->params;
     $variables->element = $element;
     while ($field = array_shift($fields)) {
         $modeName = FieldsandfiltersModes::getModeName($field->mode);
         $isStaticMode = $modeName == FieldsandfiltersModes::MODE_STATIC;
         if ($isStaticMode && empty($field->data) || $modeName == 'field' && (!isset($element->data) || !property_exists($element->data, $field->id))) {
             continue;
         }
         if ($params) {
             $paramsTemp = $field->params;
             $paramsField = clone $field->params;
             $paramsField->merge($params);
             $field->params = $paramsField;
         }
         if ($field->params->get('base.show_name')) {
             FieldsandfiltersFieldsField::preparationContent('base.prepare_name', $field, 'name', $context, $field->id, $params);
         }
         if ($field->params->get('base.site_enabled_description')) {
             FieldsandfiltersFieldsField::preparationContent('base.prepare_description', $field, 'description', $context, $field->id, $params);
         }
         if ($isStaticMode) {
             FieldsandfiltersFieldsField::preparationContent('type.prepare_data', $field, 'data', $context, $field->id, $params);
         } else {
             FieldsandfiltersFieldsField::preparationContentData('type.prepare_data', $field, $element, $context, $field->id, $params);
         }
         $layoutField = FieldsandfiltersFieldsField::getLayout('field', $modeName, $field->params);
         $variables->field = $field;
         $layout = KextensionsPlugin::renderLayout($variables, $layoutField);
         $layoutFields->set(KextensionsArray::getEmptySlotObject($layoutFields, $field->{$ordering}, false), $layout);
         if ($params) {
             $field->params = $paramsTemp;
             unset($paramsField);
         }
     }
     unset($variables);
 }
 /**
  * @since    1.1.0
  */
 public function getFieldsandfiltersFiltersHTML(JObject $layoutFilters, JObject $fields, $context = 'filters', JRegistry $params = null, $ordering = 'ordering')
 {
     if (!($fields = $fields->get($this->_name))) {
         return;
     }
     $fields = is_array($fields) ? $fields : array($fields);
     $variables = new JObject();
     $variables->type = $this->_type;
     $variables->name = $this->_name;
     $variables->params = $this->params;
     while ($field = array_shift($fields)) {
         if ($params) {
             $paramsTemp = $field->params;
             $paramsField = clone $field->params;
             $paramsField->merge($params);
             $field->params = $paramsField;
         }
         if ($field->params->get('base.show_name')) {
             FieldsandfiltersFieldsField::preparationContent('base.prepare_name', $field, 'name', $context, $field->id, $params);
         }
         if ($field->params->get('base.site_enabled_description')) {
             FieldsandfiltersFieldsField::preparationContent('base.prepare_description', $field, 'description', $context, $field->id, $params);
         }
         FieldsandfiltersFieldsField::preparationContentValues('type.prepare_values', $field, $context, $field->id, $params);
         $layoutFilter = FieldsandfiltersFieldsField::getLayout('filter', 'filter', $field->params);
         $variables->field = $field;
         $layout = KextensionsPlugin::renderLayout($variables, $layoutFilter);
         $layoutFilters->set(KextensionsArray::getEmptySlotObject($layoutFilters, $field->{$ordering}, false), $layout);
         if ($params) {
             $field->params = $paramsTemp;
             unset($paramsFilter);
         }
     }
     unset($variables);
 }