Why the change to findPairsForSelectForm?

16 views
Skip to first unread message

Steve

unread,
Nov 11, 2011, 10:23:57 PM11/11/11
to Omeka Dev
Can anyone explain why the function below was changed from 1.3.2 to
1.4.*? My clients used the dublin core items in the item type
dropdowns for csvimport, etc and this change does NOT pull dublin core
into the dropdown lists. Thanks for any insight!

From:

/**
* Override parent class method to retrieve a multidimensional array
of
* elements, organized by element set, to be used in Zend's FormSelect
view
* helper.
*
* @param array $options Set of parameters for searching/filtering
results.
* @see Omeka_Db_Table::findPairsForSelectForm()
* @return array
*/
public function findPairsForSelectForm(array $options = array())
{
$db = $this->getDb();
$sql = "
SELECT e.id AS element_id, e.name AS element_name, es.name AS
element_set_name
FROM {$db->Element} AS e
JOIN {$db->ElementSet} AS es
ON e.element_set_id = es.id
JOIN {$db->RecordType} AS rt
ON es.record_type_id = rt.id
WHERE rt.name = 'Item'
OR rt.name = 'All'
ORDER BY element_set_name ASC, element_name ASC";
$elements = $this->fetchAll($sql);
$options = array();
foreach ($elements as $element) {
$options[$element['element_set_name']][$element['element_id']] =
$element['element_name'];
}
return $options;
}

To:

/**
* Override parent class method to retrieve a multidimensional array
of
* elements, organized by element set, to be used in Zend's FormSelect
view
* helper.
*
* @param array $options Set of parameters for searching/filtering
results.
* @see Omeka_Db_Table::findPairsForSelectForm()
* @return array
*/
public function findPairsForSelectForm(array $options = array())
{
$db = $this->getDb();
// For backwards-compatibility.
if (!array_key_exists('record_types', $options)) {
$options['record_types'] = array('Item', 'All');
}
$select = $this->getSelectForFindBy($options);
$select->reset(Zend_Db_Select::COLUMNS);
$select->from(array(), array(
'id' => 'e.id',
'name' => 'e.name',
'set_name' => 'es.name',
));

$elements = $this->fetchAll($select);
$options = array();
foreach ($elements as $element) {
$options[$element['set_name']][$element['id']] = $element['name'];
}
return $options;
}

John Flatness

unread,
Nov 11, 2011, 11:30:33 PM11/11/11
to omek...@googlegroups.com
What problem are you having?

I'm looking at the CSV Import 1.3 plugin in a Omeka 1.4 installation right now, and it certainly does include the Dublin Core elements in the "Map to Element" dropdown.

As for why the function was changed, the aim was both to reduce duplication with the existing filtering code for the Element table, and to allow users of findPairsForSelectForm to actually use the $options parameter, which was basically a parameter in name only in the old version of this function.

-John Flatness

> --
> You received this message because you are subscribed to the Google Groups "Omeka Dev" group.
> To post to this group, send email to omek...@googlegroups.com.
> To unsubscribe from this group, send email to omeka-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/omeka-dev?hl=en.
>

Steve Stalder

unread,
Nov 11, 2011, 11:58:17 PM11/11/11
to omek...@googlegroups.com
I've attached an example. The bad example is a clean 1.4.2 example with the latest csvimport. The good is the same install with the findPairsForSelectForm function from 1.3.2 patched in.

Thanks,
Steve Stalder
ssta...@gmail.com
http://www.stevestalder.com
bad.png
good.png

Steve Stalder

unread,
Nov 12, 2011, 12:04:00 AM11/12/11
to omek...@googlegroups.com
Here is the item type screen as well, with missing dublin core from clean 1.4.2 install.

Thanks,
Steve Stalder
bad2.png
good2.png

John Flatness

unread,
Nov 12, 2011, 12:37:46 AM11/12/11
to omek...@googlegroups.com
I can't reproduce your first screenshots: With CsvImport 1.3.2 and Omeka 1.4.2, I see all 15 Dublin Core elements when mapping columns to types.

As for the second set of screenshots, it's expected behavior that the dropdown on the Item Type form only shows Item Type Elements. The Dublin Core elements apply to all Items, they can't be part of (and really don't make sense as part of) an Item Type.

I'm at a bit of a loss as to how you're only seeing some of the Dublin Core elements on the dropdown for CsvImport.  Have you made manual modifications to your database, or do you perhaps have another plugin that could be filtering the findBy results for Elements? 

Do you see all the elements in the dropdown on the Advanced Search page? That dropdown, if working properly, should include all the Dublin Core and all the Item Type elements.

-John Flatness

<bad2.png><good2.png>

Steve Stalder

unread,
Nov 12, 2011, 1:05:59 AM11/12/11
to omek...@googlegroups.com
Ok now it makes sense. Advanced search does show everything. CsvImport used to when selecting "Still Image" but now it doesn't. We do have a custom type however that shows more dublin core items in the selection when importing so we can use that. Thanks!
Reply all
Reply to author
Forward
0 new messages