/**
  * 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();
     $dispatcher = FieldsandfiltersFactory::getDispatcher();
     // Include the content plugins for the on delete events.
     JPluginHelper::importPlugin('content');
     JPluginHelper::importPlugin('fieldsandfilterstypes');
     // Load PluginExtensions Helper
     $extensionsHelper = FieldsandfiltersFactory::getExtensions();
     // Iterate the items to delete each one.
     foreach ($pks as $i => $pk) {
         if (!$table->load($pk) || !$this->canDelete($table)) {
             throw new Exception($table->getError());
         }
         $extensionName = ($extension = $extensionsHelper->getExtensionsByTypeID($table->content_type_id)->get($table->content_type_id)) ? $extension->name : '';
         $context = $this->option . '.' . $this->name . '.' . $extensionName;
         // 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());
         }
         // Trigger the onFieldsandfiltersBeforeDeleteData event.
         $result = $app->triggerEvent('onFieldsandfiltersBeforeDeleteData', array($this->option . '.' . $this->name, $this->getItem($pk)));
         if (in_array(false, $result, true)) {
             throw new Exception($table->getError());
         }
         // delete fields data element
         if (!$table->deleteData($pk)) {
             throw new Exception($table->getError());
         }
         // delete fields connections element
         if (!$table->deleteConnections($pk)) {
             throw new Exception($table->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();
     return true;
 }
 /**
  * @since         1.1.0
  * @deprecated    1.2.0
  * @use           FieldsandfiltersFieldsSite::getFieldsLayoutsByItemID()
  **/
 public static function getFieldsByItemIDWithTemplate($option = null, $itemID = null, $fieldsID = null, $getAllextensions = true, $params = false, $ordering = 'ordering')
 {
     $object = self::getFieldsByItemID($option, $itemID, $fieldsID, $getAllextensions);
     $templateFields = new JObject();
     $fields = $object->fields->getProperties();
     if (empty($fields)) {
         return $templateFields;
     }
     $fields = new JObject(JArrayHelper::pivot($fields, 'field_type'));
     JPluginHelper::importPlugin('fieldsandfilterstypes');
     FieldsandfiltersFactory::getDispatcher()->trigger('getFieldsandfiltersFieldsHTML', array($templateFields, $fields, $object->element, $params, $ordering));
     return $templateFields;
 }