Skip to content

Instantly share code, notes, and snippets.

View jeremyboggs's full-sized avatar

Jeremy Boggs jeremyboggs

View GitHub Profile
@jeremyboggs
jeremyboggs / filter_collections_alphabetically.php
Created September 20, 2011 02:12
Filter the collections browse SQL to sort records alphabetically by name.
<?php
/**
* Filter the collections browse SQL to sort records alphabetically by name.
*/
function filter_collections_alphabetically($select, $params)
{
if (!array_key_exists('sort_field', $params)) {
$select->order('c.name ASC');
}
@jeremyboggs
jeremyboggs / get_users_ordered_by_usermeta.php
Created October 18, 2011 15:09
Returns WP users ordered by a usermeta key
<?php
/**
* Returns users ordered by a given key.
*
* @param string The meta_key to order by. Default is 'last_name'.
* @param string The sort direction. Default is ASC.
* @todo Add parameter to skip users with specific IDs
* @todo Add parameter to skip users with an empty last name.
*/
@jeremyboggs
jeremyboggs / exhibitbuilderhomelink.php
Created October 22, 2011 16:05
Link back to exhibit home page for Omeka
@jeremyboggs
jeremyboggs / dibny_display_filters.php
Created December 20, 2011 04:52
Filters function for Dibny theme
<?php
/**
* Returns a string detailing the parameters of a given query array.
*
* @param array A search array
* @return string HTML
*/
function dibny_display_filters($query = null)
{
$html = '';
@jeremyboggs
jeremyboggs / simple_insert_files_for_item_loop.php
Created December 22, 2011 20:08
Inserting multiple files for an item.
<?php
$files = array(
'http://example.com/file1.txt' => array(
'Dublin Core' => array(
'Title' => array('text' => 'Title of my first item'),
'Description' => array('text' => 'Description of my first item.')
)
),
'http://example.com/file2.txt' => array(
@jeremyboggs
jeremyboggs / omeka_use_internal_js.php
Created January 4, 2012 15:55
Code to check whether an instance of Omeka is using internal JavaScript libraries, instead of using libraries from a CDN. Useful if you'd like your plugin to do the same thing.
<?php
/**
* Function to return whether to use local or external JavaScript libraries in
* Omeka. Useful if you'd like your plugin or theme to honor this setting.
*
* Checks presence of, and value for, useInternalJavascripts in
* application/config/config.ini. If it is not set, returns false. Otherwise,
* returns boolean value for the setting.
*
* @return boolean
@jeremyboggs
jeremyboggs / NeatlineTimeTimelineTest.php
Created January 14, 2012 14:41
Unit tests for the NeatlineTimeTimeline model.
<?php
/**
* Test the NeatlineTimeTimeline model.
*/
class NeatlineTimeTimelineTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->dbAdapter = new Zend_Test_DbAdapter;
$this->db = new Omeka_Db($this->dbAdapter);
@jeremyboggs
jeremyboggs / file_filter_name.php
Created January 26, 2012 00:53
Creating a filter name based on text from a file's call back.
<?php
$filterName = Inflector::underscore($callback);
// Avoid creating a 'file_default_display_display' filter name.
if ($filterName == 'default_display') {
$filterName = 'file_'.$filterName;
} else {
$filterName = 'file_'.$filterName.'_display';
}
@jeremyboggs
jeremyboggs / beveled-border.css
Created February 15, 2012 14:25
CSS to create a beveled or inset border before a selected element.
#whatever:before {
display:block;
height:0;
content: "";
border-top: 1px solid rgba(0,0,0,0.5);
border-bottom: 1px solid rgba(255,255,255,0.5);
}
@jeremyboggs
jeremyboggs / link_categories_to_related_page.php
Created February 24, 2012 15:14
Filter links to WP categories to a page with the same name.