Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
194 lines (130 sloc) 4.77 KB
<?php
/**
* @copyright Roy Rosenzweig Center for History and New Media, 2007-2012
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @package Mapfig
*/
//define('STUDIO_MAP_TABLE', $wpdb->prefix . 'studio_map');
define('STUDIO_DOCROOT', dirname(__FILE__));
//define('STUDIO_WEBROOT', str_replace(getcwd(), home_url(), dirname(__FILE__)));
define('STUDIO_SERVER', get_option('mapfig_studio_url'));
class MapfigStudioPlugin extends Omeka_Plugin_AbstractPlugin {
protected $_hooks = array(
'install',
'uninstall',
'define_routes',
'define_acl',
'public_items_show',
'admin_items_show_sidebar',
'admin_items_browse_detailed_each',
'initialize',
'after_save_item' ,
'public_head',
'admin_head',
'config_form',
'config'
);
protected $_filters = array(
'admin_navigation_main',
'exhibit_layouts', // Added by David
'admin_items_form_tabs' // Added by David
);
public function hookInstall(){
include("includes/studioInstaller.class.php");
$installObj = new studioInstaller;
$installObj->install();
}
public function hookUninstall(){
include("includes/studioInstaller.class.php");
$installObj = new studioInstaller;
$installObj->uninstall();
}
public function hookInitialize(){
add_shortcode ('StudioMap', array($this,'studioMapfigShortcode'));
}
public function studioMapfigShortcode($args){
$atts = $args;
include("includes/shortcodes/StudioMap.php");
}
public function hookConfigForm(){
include 'includes/configForm.php';
}
public function hookConfig($args){
// Use the form to set a bunch of default options in the db
set_option('mapfig_studio_api_key', $_POST['studio_apikey']);
set_option('mapfig_studio_url', $_POST['studio_url']);
}
public function hookPublicHead($args){
}
public function hookAdminHead($args){
queue_css_file('mapfig-studio');
}
public function hookPublicItemsShow($args){
$item = $args['item'];
$id = $item->id;
$mapfigItem = get_db()->getTable('MapfigStudioItem')->getByItemId($item->id);
if(count($mapfigItem) > 0){
$tobj = new Omeka_View_Helper_Shortcodes;
echo $tobj->shortcodes($mapfigItem->content);
}
}
public function hookDefineAcl($args){
}
public function hookAdminItemsBrowseDetailedEach($args){
}
public function hookAdminItemsShowSidebar($args){
}
public function hookDefineRoutes($array){
}
public function filterAdminNavigationMain($navArray){
$navArray['MapfigStudio'] = array('label'=>__("MapFig Studio"), 'uri'=>url('mapfig-studio'));
return $navArray;
}
// Added by David - Add MapFig Layout
public function filterExhibitLayouts($layouts){
$layouts['mapfig-studio'] = array(
'name' => __('Mapfig Studio Map'),
'description' => __('Display a MapFig Studio Map')
);
return $layouts;
}
// Added by David - add MapFig to 'Add an Item' Tab
public function filterAdminItemsFormTabs($tabs, $args){
// insert the mapfig tab before the Miscellaneous tab
$item = $args['item'];
$tabs['MapFig Studio'] = $this->_studioMapfigForm($item);
return $tabs;
}
public function hookAfterSaveItem($args){
if (!($post = $args['post'])) {
return;
}
$item = $args['record'];
// If we don't have the geolocation form on the page, don't do anything!
if (!isset($post['studiomapfig_content'])) {
return;
}
$studiomapfig_item_id = $post['studiomapfig_item_id'];
$mapfigItem = get_db()->getTable('MapfigStudioItem');
$itemsJson = array(
"item_id"=>$item->id,
"content"=>$post['studiomapfig_content']
);
if(empty($studiomapfig_item_id)){
$mapfigItem->insert($itemsJson);
} else {
$mapfigItem->update($itemsJson, $studiomapfig_item_id);
}
}
// Start of Added by David: this is to add MapFig Map as an Item
protected function _studioMapfigForm($item, $post = null)
{
$mapfig_item_id = $item->id;
ob_start();
include("includes/studioMapfigItemForm.php");
$string = ob_get_contents();
ob_end_clean();
return $string;
}
// End of Added by David
}