/**
  * Sets the type of the field item currently being edited.
  *
  * @param   string $urlVar The name of the URL variable if different from the primary key
  *
  * @return  void
  * @since       1.1.0
  */
 function setType($urlVar = 'id')
 {
     // Get the posted values from the request.
     $data = $this->input->post->get('jform', array(), 'array');
     $recordId = $this->input->get($urlVar, 0, 'int');
     // Get the type.
     $options = new JRegistry(base64_decode($data['temp_type']));
     $name = $options->get('name');
     $typeMode = $options->get('type_mode');
     $modes = FieldsandfiltersModes::getMode()->get($typeMode);
     $type = FieldsandfiltersFactory::getTypes()->getTypesByName($name)->get($name);
     if ($name && $modes && $type && $recordId == $options->get('id', 0)) {
         $data['type'] = $name;
         $data['type_mode'] = $typeMode;
         //Save the data in the session.
         JFactory::getApplication()->setUserState('com_fieldsandfilters.edit.field.data', $data);
         $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $urlVar), false));
         return true;
     }
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
     return false;
 }
 public static function setUserStateFieldID($context, $name = 'field_id')
 {
     $app = JFactory::getApplication();
     $userState = (array) $app->getUserState($context);
     if ($fieldID = $app->input->getInt($name)) {
         if ($fieldID != JArrayHelper::getValue($userState, $name)) {
             $userState[$name] = $fieldID;
             $app->setUserState($context, $userState);
             return true;
         }
     } else {
         if (!JArrayHelper::getValue($userState, $name)) {
             $filterMode = FieldsandfiltersModes::getMode(FieldsandfiltersModes::MODE_FILTER);
             $extensionsID = FieldsandfiltersFactory::getExtensions()->getExtensionsColumn('content_type_id');
             $fieldsID = FieldsandfiltersFactory::getFields()->getFieldsByModeIDColumn('id', $extensionsID, $filterMode, array(1, -1));
             $fieldID = current($fieldsID);
             $userState[$name] = $fieldID;
             $app->setUserState($context, $userState);
             return true;
         }
     }
     return false;
 }
 /**
  * Method to delete one or more records.
  *
  * @param   array &$pks An array of record primary keys.
  *
  * @return  boolean  True if successful, false if an error occurs.
  * @since       1.1.0
  */
 public function delete(&$pks)
 {
     $app = JFactory::getApplication();
     $pks = (array) $pks;
     $table = $this->getTable();
     $valueTable = $this->getTable('Fieldvalue', 'FieldsandfiltersTable');
     $elementTable = $this->getTable('Element', 'FieldsandfiltersTable');
     $filterMode = (array) FieldsandfiltersModes::getMode(FieldsandfiltersModes::MODE_FILTER);
     $otherMode = (array) FieldsandfiltersModes::getModes(null, array(), true, $filterMode);
     // Include the content plugins for the on delete events.
     JPluginHelper::importPlugin('content');
     // Include the fieldsandfilters Types plugins for the on save events.
     JPluginHelper::importPlugin(FieldsandfiltersTypes::PLUGIN_FOLDER);
     try {
         // Iterate the items to delete each one.
         foreach ($pks as $i => $pk) {
             if (!$table->load($pk) || !$this->canDelete($table)) {
                 throw new Exception($table->getError());
             }
             $context = $this->option . '.' . $this->name;
             // Trigger the onContentBeforeDelete event.
             $result = $app->triggerEvent($this->event_before_delete, array($context, $table));
             if (in_array(false, $result, true)) {
                 throw new Exception($table->getError());
             }
             // Get old item
             $item = $this->getItem($pk);
             // Trigger the onFieldsandfiltersBeforeSaveData event.
             $result = $app->triggerEvent('onFieldsandfiltersBeforeDeleteData', array($context, $item));
             if (in_array(false, $result, true)) {
                 throw new Exception($table->getError());
             }
             $objectTable = new stdClass();
             $objectTable->field_id = $table->id;
             $objectTable->element_id = null;
             //delete fields values and connections
             if (in_array($table->mode, $filterMode)) {
                 if (!$valueTable->deleteByFieldID($table->id)) {
                     throw new Exception($valueTable->getError());
                 }
                 if (!$elementTable->deleteConnections($objectTable)) {
                     throw new Exception($elementTable->getError());
                 }
             } else {
                 if (in_array($table->mode, $otherMode) && !$elementTable->deleteData($objectTable)) {
                     throw new Exception($elementTable->getError());
                 }
             }
             if (!$table->delete($pk)) {
                 throw new Exception($table->getError());
             }
             // Trigger the onContentAfterDelete event.
             $app->triggerEvent($this->event_after_delete, array($context, $table));
         }
         // Clear the component's cache
         $this->cleanCache();
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     return true;
 }
 /**
  * @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 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);
 }
 /**
  * Method to save the form data.
  *
  * @param   array $data The form data.
  *
  * @return  boolean  True on success, False on error.
  *
  * @since       1.1.0
  */
 public function save($data)
 {
     $app = JFactory::getApplication();
     $table = $this->getTable();
     $key = $table->getKeyName();
     $pk = !empty($data[$key]) ? $data[$key] : (int) $this->getState($this->getName() . '.id');
     $isNew = true;
     // Include the content plugins for the on save events.
     JPluginHelper::importPlugin('content');
     JPluginHelper::importPlugin('fieldsandfilterstypes');
     // Allow an exception to be thrown.
     try {
         // Load the row if saving an existing record.
         if ($pk > 0) {
             $table->load($pk);
             $isNew = false;
         }
         // Bind the data.
         if (!$table->bind($data)) {
             throw new Exception($table->getError());
         }
         // Prepare the row for saving
         $this->prepareTable($table);
         // Check the data.
         if (!$table->check()) {
             throw new Exception($table->getError());
         }
         // Load PluginExtensions Helper
         $extensionName = ($extension = FieldsandfiltersFactory::getExtensions()->getExtensionsByTypeIDPivot('content_type_id', $table->content_type_id)->get($table->content_type_id)) ? $extension->name : '';
         $context = $this->option . '.' . $this->name . '.' . $extensionName;
         // Trigger the onContentBeforeSave event.
         $result = $app->triggerEvent($this->event_before_save, array($context, $table, $isNew));
         if (in_array(false, $result, true)) {
             throw new Exception($table->getError());
         }
         $tableFields = (array) $table->get('fields');
         // Get old item
         $item = $this->getItem($table->{$key});
         // Store the data.
         if (!$table->store()) {
             throw new Exception($table->getError());
         }
         $table->set('fields', JArrayHelper::toObject($tableFields, 'JObject'));
         // Store fields data and connections
         // Trigger the onFieldsandfiltersBeforeSaveData event.
         $result = $app->triggerEvent('onFieldsandfiltersBeforeSaveData', array($this->option . '.' . $this->name, $table, $item, $isNew));
         // array($newItem, $oldItem)
         if (in_array(false, $result, true)) {
             throw new Exception($table->getError());
         }
         $item = $item->get('fields', new JObject());
         $dataItem = $item->get('data', new JObject());
         $connectionsItem = $item->get('connections', new JObject());
         $tableFields = $table->get('fields', new JObject());
         $data = $tableFields->get('data', new JObject());
         $connections = $tableFields->get('connections', new JObject());
         $filterMode = (array) FieldsandfiltersModes::getMode(FieldsandfiltersModes::MODE_FILTER, array());
         $otherMode = (array) FieldsandfiltersModes::getModes(null, array(), true, $filterMode);
         $fields = FieldsandfiltersFieldsHelper::getFieldsByTypeIDColumnFieldType($table->content_type_id);
         $fields = KextensionsArray::flatten(get_object_vars($fields));
         while ($field = array_shift($fields)) {
             $_data = (string) $data->get($field->id, '');
             $_dataItem = (string) $dataItem->get($field->id, '');
             $_connections = (array) $connections->get($field->id, new JObject())->getProperties(true);
             $_connectionsItem = (array) $connectionsItem->get($field->id, new JObject())->getProperties(true);
             // other (field/static)
             if (in_array($field->mode, $otherMode) && (!empty($_data) || !empty($_dataItem))) {
                 $tableObject = new stdClass();
                 $tableObject->field_id = (int) $field->id;
                 // delete text
                 if (!empty($_dataItem) && empty($_data)) {
                     $table->deleteData($tableObject);
                 } elseif (empty($_dataItem) && !empty($_data)) {
                     $tableObject->data = $_data;
                     $table->insertData($tableObject);
                 } elseif ($_dataItem != $_data) {
                     $tableObject->data = $_data;
                     $table->updateData($tableObject);
                 }
             } elseif (in_array($field->mode, $filterMode) && (!empty($_connections) || !empty($_connectionsItem))) {
                 $tableObject = new stdClass();
                 $tableObject->field_id = (int) $field->id;
                 $field_valuesID = array_keys($field->values->getProperties(true));
                 $_connections = array_intersect($field_valuesID, $_connections);
                 $__connections = array_unique(array_diff($_connections, $_connectionsItem));
                 JArrayHelper::toInteger($__connections);
                 if (!empty($__connections)) {
                     $tableObject->field_value_id = $__connections;
                     $table->insertConnections($tableObject);
                 }
                 $__connections = array_unique(array_diff($_connectionsItem, $_connections));
                 JArrayHelper::toInteger($__connections);
                 if (!empty($__connections)) {
                     $tableObject = new stdClass();
                     $tableObject->field_value_id = $__connections;
                     $table->deleteConnections($tableObject);
                 }
             }
         }
         // Trigger the onContentAfterSave event.
         $app->triggerEvent($this->event_after_save, array($context, $table, $isNew));
         // Clean the cache.
         $this->cleanCache();
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     $pkName = $table->getKeyName();
     if (isset($table->{$pkName})) {
         $this->setState($this->getName() . '.id', $table->{$pkName});
     }
     $this->setState($this->getName() . '.new', $isNew);
     return true;
 }
 /**
  * @since       1.2.0
  **/
 public static function getFieldsByTypeIDColumnFieldType($contentTypeID, $withStatic = null, $states = array(1, -1), $getAllextensions = true)
 {
     $withStatic = !is_null($withStatic) ? $withStatic : JComponentHelper::getParams('com_fieldsandfilters')->get('show_static_fields', true);
     $contentTypeID = (array) $contentTypeID;
     if ($getAllextensions && ($extension = FieldsandfiltersFactory::getExtensions()->getExtensionsByName(FieldsandfiltersExtensions::EXTENSION_DEFAULT)->get(FieldsandfiltersExtensions::EXTENSION_DEFAULT))) {
         $contentTypeID[] = (int) $extension->content_type_id;
     }
     $fieldsHelper = FieldsandfiltersFactory::getFields();
     if ($withStatic) {
         $fields = $fieldsHelper->getFieldsPivot('type', $contentTypeID, $states, FieldsandfiltersFields::VALUES_BOTH);
     } else {
         $staticMode = (array) FieldsandfiltersModes::getMode(FieldsandfiltersModes::MODE_STATIC, array());
         $otherMode = (array) FieldsandfiltersModes::getModes(null, array(), true, $staticMode);
         $fields = $fieldsHelper->getFieldsByModeIDPivot('type', $contentTypeID, $otherMode, $states, FieldsandfiltersFields::VALUES_BOTH);
     }
     return $fields;
 }
									</ul>
								</div>
							</div>
						<?php 
        }
        ?>
					</div>
				</td>

				<td class="center">
					<?php 
        if ($type = $typesHelper->getTypes(true)->get($item->type)) {
            ?>
						<?php 
            KextensionsLanguage::load('plg_' . $type->type . '_' . $type->name, JPATH_ADMINISTRATOR);
            $typeName = FieldsandfiltersModes::getModeName($item->mode, FieldsandfiltersModes::MODE_NAME_TYPE);
            $typeForm = $type->forms->get($typeName, new JObject());
            if (isset($typeForm->group->title)) {
                $titleType = JText::_($typeForm->title) . ' [' . JText::_($typeForm->group->title) . ']';
            } else {
                $titleType = JText::_($typeForm->title);
            }
            ?>
						<?php 
            echo $titleType;
            ?>
					<?php 
        } else {
            ?>
						<?php 
            echo JText::_('JUNDEFINED');
 /**
  * @since       1.1.0
  */
 public function onFieldsandfiltersPrepareFiltersHTML($context, Jobject $filters, $fieldsID = null, $getAllextensions = true, JRegistry $params = null, $ordering = 'ordering')
 {
     if (!in_array($context, $this->_contexts)) {
         return;
     }
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $id = $jinput->get('id', 0, 'int');
     // Load PluginExtensions Helper
     $extensionsHelper = FieldsandfiltersFactory::getExtensions();
     $extensionContent = $extensionsHelper->getExtensionsByName($this->_name)->get($this->_name);
     if ($context == $this->_contexts['category'] && !$id || !$extensionContent) {
         return;
     }
     // add model path
     $prefix = get_class($this);
     list($option, $class) = explode('.', $context);
     JModelLegacy::addIncludePath(sprintf('%s/%s/%s/overrides/models', JPATH_PLUGINS, $this->_type, $this->_name), $prefix . 'Model');
     if (!($model = JModelLegacy::getInstance($class, $prefix . 'Model', array('ignore_request' => false, 'table_path' => JPATH_ADMINISTRATOR . '/components/' . $option . '/tables')))) {
         return;
     }
     $itemsID = $model->getContentItemsID();
     if (empty($itemsID)) {
         return;
     }
     // Load Filters Helper
     $counts = FieldsandfiltersFiltersHelper::getFiltersValuesCount($extensionContent->content_type_id, $fieldsID, $itemsID, $model->getState('filter.published'));
     if (empty($counts)) {
         return;
     }
     $extensionsID = $getAllextensions ? $extensionsHelper->getExtensionsByNameColumn('content_type_id', array(FieldsandfiltersExtensions::EXTENSION_DEFAULT, $this->_name)) : $extensionContent->content_type_id;
     // Load Fields Helper
     $fieldsHelper = FieldsandfiltersFactory::getFields();
     if (is_null($fieldsID)) {
         // Load PluginTypes Helper
         if ($modes = FieldsandfiltersModes::getMode(FieldsandfiltersModes::MODE_FILTER)) {
         }
         // multi extensions array( $this->_name, 'allextensions' )
         // $fields = $fieldsHelper->getFieldsByModeIDPivot( 'type', $extensionsID, $modes, 1, true );
         // single extension $this->_name
         $fields = $fieldsHelper->getFieldsByModeIDPivot('type', $extensionsID, $modes, 1, FieldsandfiltersFields::VALUES_VALUES, true);
     } else {
         if (is_numeric($fieldsID) || is_array($fieldsID)) {
             // multi extensions array( $this->_name, 'allextensions' )
             // $fields = $fieldsHelper->getFieldsByIDPivot( 'type', $extensionContent->content_type_id, $fieldsID, 1, true );
             // single extension $this->_name
             $fields = $fieldsHelper->getFieldsByIDPivot('type', $extensionsID, $fieldsID, 1, FieldsandfiltersFields::VALUES_VALUES, true);
         } else {
             return;
         }
     }
     $templateFields = new JObject();
     JPluginHelper::importPlugin('fieldsandfilterstypes');
     // Trigger the onFieldsandfiltersPrepareFormField event.
     $app->triggerEvent('getFieldsandfiltersFiltersHTML', array($templateFields, $fields, $context, $params, $ordering));
     $templateFields = $templateFields->getProperties(true);
     if (empty($templateFields)) {
         return;
     }
     ksort($templateFields);
     $filters->set('layouts', $templateFields);
     $filters->set('request', array('extensionID' => (int) $extensionContent->content_type_id, 'id' => $app->input->get('id', 0, 'int')));
     $filters->set('counts', (array) $counts);
     $router = JFactory::getApplication()->getRouter();
     if ($router->getMode() == JROUTER_MODE_SEF) {
         $filters->set('pagination', array('start' => 0));
     } else {
         $filters->set('pagination', array('limitstart' => 0));
     }
     $selectors = $filters->get('selectors');
     if ($context == $this->_contexts['category'] && ($selector = trim($this->params->get('selector_other_category', '#adminForm')))) {
         $selectors['other'] = $selector;
     } elseif ($context == $this->_contexts['archive'] && ($selector = trim($this->params->get('selector_other_archive', '#adminForm')))) {
         $selectors['other'] = $selector;
     } elseif ($context == $this->_contexts['featured'] && ($selector = trim($this->params->get('selector_other_featured', '')))) {
         $selectors['other'] = $selector;
     }
     $filters->set('selectors', $selectors);
     return implode("\n", $templateFields);
 }
 /**
  * Method to get the available options fields item. value & text
  *
  * @return    array    array associate value and text
  * @since       1.1.0
  */
 public static function fields($modes = FieldsandfiltersModes::MODE_FILTER, $state = 1)
 {
     $options = array();
     // Load Extensions Helper
     $extenionsID = FieldsandfiltersFactory::getExtensions()->getExtensionsColumn('content_type_id');
     $modes = FieldsandfiltersModes::getModes($modes, array(), true);
     // Load Fields Helper
     $fieldsHelper = FieldsandfiltersFactory::getFields();
     if (!empty($modes)) {
         $fields = $fieldsHelper->getFieldsByModeID($extenionsID, $modes, $state);
     } else {
         $fields = $fieldsHelper->getFields($extenionsID, $state);
     }
     if ($fields = get_object_vars($fields)) {
         while ($field = array_shift($fields)) {
             $options[] = JHtml::_('select.option', $field->id, $field->name);
         }
     }
     return $options;
 }
 /**
  *
  * @since       1.1.0
  */
 public function __construct($debug = false)
 {
     parent::__construct($debug);
     $this->_valuesModes = (array) FieldsandfiltersModes::getMode(FieldsandfiltersModes::MODE_FILTER);
     $this->_staticModes = (array) FieldsandfiltersModes::getMode(FieldsandfiltersModes::MODE_STATIC);
 }
 /**
  * Method to get the field input markup.
  *
  * @return    string    The field input markup.
  * @since       1.2.0
  */
 protected function getInput()
 {
     // Initialise variables
     $value = '';
     $html = array();
     $size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
     $class = !empty($this->class) ? ' class="' . $this->class . '"' : 'class="inputbox"';
     $recordId = (int) $this->form->getValue('id', 0);
     $mode = (int) $this->form->getValue('mode', 0);
     $typesHelper = FieldsandfiltersFactory::getTypes();
     if ($mode && ($pluginType = $typesHelper->getTypes(true)->get($this->value))) {
         // Load Extensions Helper
         KextensionsLanguage::load('plg_' . $pluginType->type . '_' . $pluginType->name, JPATH_ADMINISTRATOR);
         $modeName = FieldsandfiltersModes::getModeName($mode, FieldsandfiltersModes::MODE_NAME_TYPE);
         $typeForm = $pluginType->forms->get($modeName, new JObject());
         if (isset($typeForm->group->title)) {
             $value = JText::_($typeForm->title) . ' [' . JText::_($typeForm->group->title) . ']';
         } else {
             if (isset($typeForm->title)) {
                 $value = JText::_($typeForm->title);
             }
         }
     }
     // Load the javascript and css
     JHtml::_('behavior.framework');
     JHtml::_('behavior.modal');
     $query = array('option' => 'com_fieldsandfilters', 'view' => 'plugins', 'tmpl' => 'component', 'layout' => 'types', 'recordId' => $recordId);
     $link = JRoute::_('index.php?' . JURI::buildQuery($query));
     if (FieldsandfiltersFactory::isVersion()) {
         $html[] = '<span class="input-append">';
         $html[] = '	<input type="text" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' />';
         $html[] = '	<a class="btn btn-primary" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\'' . $link . '\'})">';
         $html[] = '		<i class="icon-list icon-white"></i>';
         $html[] = JText::_('JSELECT');
         $html[] = '	</a>';
         $html[] = '</span>';
         $html[] = '<input class="input-small" type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
     } else {
         $html[] = '<input type="text" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' />';
         $html[] = '<input type="button" value="' . JText::_('JSELECT') . '" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\'' . $link . '\'})" />';
         $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
     }
     return implode("\n", $html);
 }
 /**
  * Overrides JTable::store to set modified data and user id.
  *
  * @param   boolean $updateNulls True to update fields even if they are null.
  *
  * @return  boolean  True on success.
  * @since    1.1.0
  */
 public function store($updateNulls = false)
 {
     // Check mode field
     if (in_array($this->mode, (array) FieldsandfiltersModes::getMode(FieldsandfiltersModes::MODE_FILTER))) {
         // Verify that the alias is unique
         $table = JTable::getInstance('Field', 'FieldsandfiltersTable');
         if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) {
             $this->setError(JText::sprintf('COM_FIELDSANDFILTERS_DATABASE_ERROR_FIELD_ALIAS_EXISTS', $this->alias));
             return false;
         }
     }
     return parent::store($updateNulls);
 }