protected function storeMore($searchId, $client, $fields, $params) { $db = JFactory::getDbo(); jimport('cck.construction.field.generic_more'); $table = 'search_field'; $method = 'gm_getConstruction_Values_Search'; JCckDatabase::execute('DELETE FROM #__cck_core_' . $table . ' WHERE searchid = ' . (int) $searchId . ' AND client = "' . $client . '"'); if (count($fields)) { $assigned = ''; $ordering = 1; $position = 'mainbody'; $positions = ''; foreach ($fields as $k => $v) { $next = next($fields); if ($v == 'position') { $legend = @$params[$k]['legend'] != '' ? $db->escape($params[$k]['legend']) : ''; $variation = @$params[$k]['variation'] != '' ? $params[$k]['variation'] : ''; $variation_options = @$params[$k]['variation_options'] != '' ? $db->escape($params[$k]['variation_options']) : ''; $width = @$params[$k]['width'] != '' ? $params[$k]['width'] : ''; $height = @$params[$k]['height'] != '' ? $params[$k]['height'] : ''; $css = @$params[$k]['css'] != '' ? $params[$k]['css'] : ''; $position = substr($k, 4); if ($next != 'position') { $positions .= ', ( ' . (int) $searchId . ', "' . (string) $position . '", "' . $client . '", "' . $legend . '", "' . $variation . '", "' . $variation_options . '", "' . $width . '", "' . $height . '", "' . $css . '" )'; } } else { $assigned .= ', ( ' . (int) $searchId . ', ' . (int) $v . ', "' . $client . '", ' . $ordering . ', ' . plgCCK_FieldGeneric_More::$method($k, $params, $position, $client) . ' )'; $ordering++; } } if ($assigned) { $assigned = substr($assigned, 1); JCckDatabase::execute('INSERT INTO #__cck_core_' . $table . ' ( searchid, fieldid, client, ordering, ' . plgCCK_FieldGeneric_More::gm_getConstruction_Columns($table) . ' ) VALUES ' . $assigned); } if ($positions) { $positions = substr($positions, 1); JCckDatabase::execute('DELETE FROM #__cck_core_search_position WHERE searchid = ' . (int) $searchId . ' AND client = "' . $client . '"'); JCckDatabase::execute('INSERT INTO #__cck_core_search_position ( searchid, position, client, legend, variation, variation_options, width, height, css ) VALUES ' . $positions); } } }
public static function getFields($element, $item, $featured = '', $exclusion = false, $force = false, $pos = '') { jimport('cck.construction.field.generic_more'); $table = $element . '_field'; if (!isset($item->id)) { $fields = array(); if ($featured != '') { $where = 'WHERE ' . $featured . ' AND a.storage != "dev" AND ( a.storage_table NOT LIKE "#__cck_store_form_%" )'; $fields = JCckDatabase::loadObjectList('SELECT DISTINCT a.id, a.title, a.name, a.folder, a.type, a.label FROM #__cck_core_fields AS a ' . $where . ' ORDER BY a.ordering ASC'); if (count($fields)) { $list = array(); foreach ($fields as $f) { $f->position = $pos; $list[$pos][] = $f; } $fields = $list; } } return $fields; } if ($exclusion !== false) { $query = 'SELECT a.fieldid FROM #__cck_core_' . $table . ' AS a WHERE a.' . $element . 'id = ' . (int) $item->id . ' AND a.client = "' . $item->client . '"'; $fields = JCckDatabase::loadColumn($query); if (!is_array($fields)) { return ''; } $fields = implode(',', $fields); } else { $and = $force === true ? ' ' . $featured : ''; $query = ' SELECT DISTINCT a.id, a.title, a.name, a.folder, a.type, a.label, c.client, ' . plgCCK_FieldGeneric_More::gm_getConstruction_Columns($table, '_get') . ' FROM #__cck_core_fields AS a ' . ' LEFT JOIN #__cck_core_' . $table . ' AS c ON c.fieldid = a.id' . ' WHERE c.' . $element . 'id = ' . (int) $item->id . ' AND c.client = "' . $item->client . '"' . $and . ' ORDER BY c.ordering ASC'; $fields = JCckDatabase::loadObjectListArray($query, 'position'); if (!$fields) { return array(); } } return $fields; }