Skip to content

Instantly share code, notes, and snippets.

@jeremyboggs
Created February 11, 2011 00:09
Show Gist options
  • Save jeremyboggs/821666 to your computer and use it in GitHub Desktop.
Save jeremyboggs/821666 to your computer and use it in GitHub Desktop.
Use WikiCite for Omeka plugin instead! http://github.com/clioweb/WikiCiteOmeka Generates Wikipedia citation code for an Omeka Item, and appends to the items/show page.
<?php
/*
I created an Omeka plugin, WikiCite for Omeka, based on this code:
http://github.com/clioweb/WikiCiteOmeka
*/
/**
* Generates Wikipedia citation code for an Omeka Item, and appends to the items/show page.
* Based on Cite_web template at http://en.wikipedia.org/wiki/Template:Cite_web, and
* inspired by Seb Chan implementation for Powerhouse Museum at
* http://www.powerhousemuseum.com/dmsblog/index.php/2011/01/20/quick-wikipedia-citation-code-added-to-collection/
*
* @todo Add more citation parameters if available in item.
*
* @param Item|null $item Check for this specific item record (current item if null).
* @param boolean $textarea Whether to wrap the cite_web code in a textarea (true by default).
*/
function wikicite_for_item($item = null, $textarea = true)
{
$html = '';
if (!$item) {
$item = get_current_item();
}
$html .= '{{cite web';
$html .= ' |url = '.item('permalink');
$html .= ' |title = '.item('Dublin Core', 'Title', array(), $item);
$html .= '}}';
if ($textarea) {
$html = '<textarea rows="3" style="width:100%;" id="wikipedia-cite-code">'.$html.'</textarea>';
}
echo $html;
}
add_plugin_hook('public_append_to_items_show', 'wikipedia_web_cite_for_item');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment