Example #1
0
 static function getForPost($postid)
 {
     global $wpdb;
     $table = WpExhibitConfig::table_name(WpExhibitConfig::$DATASCRAPS_ASSOC_TABLE_KEY);
     $scrapid = $wpdb->get_var("SELECT datascrapid FROM {$table} WHERE postid={$postid} ;");
     if (!($scrapid == 0)) {
         $scrap = new DataScrap();
         if (DbMethods::loadFromDatabase($scrap, $scrapid)) {
             return $scrap;
         }
     }
     return NULL;
 }
Example #2
0
 static function getForPost($postid)
 {
     global $wpdb;
     $table = WpExhibitConfig::table_name(WpExhibitConfig::$EXHIBITS_ASSOC_TABLE_KEY);
     $exhibitid = $wpdb->get_var("SELECT exhibitid FROM {$table} WHERE postid={$postid} ;");
     if (!($exhibitid == 0)) {
         $post_exhibit = new WpPostExhibit();
         if (DbMethods::loadFromDatabase($post_exhibit, $exhibitid)) {
             return $post_exhibit;
         }
     }
     return NULL;
 }
 static function save()
 {
     /* This file saves, or updates, an exhibit to the database (depending on whether an ID is present).
      * it returns (JSONP-style) a callback with the Exhibit ID in the database. 
      *
      *
      * TODO:
      *  - Protect so that only admins can load this page
      */
     $ex_id = $_POST['exhibitid'];
     $ex_exhibit = new WpPostExhibit();
     if ($ex_id != NULL) {
         $ex_success = DbMethods::loadFromDatabase($ex_exhibit, $ex_id);
     }
     // Loop through data sources contained, add them if necessary, then
     // add the association
     $ex_next_datasource = new WpExhibitDatasource();
     $formIds = WpExhibitModel::findFormObjectsByPrefix($ex_next_datasource->getFormPrefix());
     $datasources = array();
     foreach ($formIds as $formId) {
         $ex_next_datasource = new WpExhibitDatasource(array('formid' => $formId));
         array_push($datasources, $ex_next_datasource);
     }
     $ex_exhibit->set('datasources', $datasources);
     // Load all the facets
     $ex_next_facet = new WpExhibitFacet();
     $formIds = WpExhibitModel::findFormObjectsByPrefix($ex_next_facet->getFormPrefix());
     $facets = array();
     foreach ($formIds as $formId) {
         $ex_next_facet = new WpExhibitFacet(array('formid' => $formId));
         array_push($facets, $ex_next_facet);
     }
     $ex_exhibit->set('facets', $facets);
     // Load all the lenses
     $ex_next_lens = new WpExhibitLens();
     $formIds = WpExhibitModel::findFormObjectsByPrefix($ex_next_lens->getFormPrefix());
     $lenses = array();
     foreach ($formIds as $formId) {
         $ex_next_lens = new WpExhibitLens(array('formid' => $formId));
         array_push($lenses, $ex_next_lens);
     }
     $ex_exhibit->set('lenses', $lenses);
     // Load all the views
     $ex_next_view = new WpExhibitView();
     $formIds = WpExhibitModel::findFormObjectsByPrefix($ex_next_view->getFormPrefix());
     $views = array();
     foreach ($formIds as $formId) {
         $ex_next_view = new WpExhibitView(array('formid' => $formId));
         array_push($views, $ex_next_view);
     }
     /*
     	Add tile view if no other views are present.
     	if(count($views) == 0) {
     		$list_view = new WpExhibitView();
     		$list_view->set('kind', 'view-tile');
     		$list_view->set('label', 'List');
     		if(count($datasources) > 0) {
     			$title = $datasources[0]->get('sourcename');	
     			$list_view->set('label', $title);
     		}
     
     	}*/
     $ex_exhibit->set('views', $views);
     // Save exhibit-level configuration options
     $lightbox = WpExhibitModel::findFormObjectValue('display-configuration-lightbox') == 'show-lightbox';
     $height = WpExhibitModel::findFormObjectValue('display-configuration-height');
     $css = WpExhibitModel::findFormObjectValue('display-configuration-css');
     $custom_html = WpExhibitModel::findFormObjectValue('display-configuration-custom-html');
     $ex_exhibit->set('lightbox', $lightbox);
     if (!$height) {
         $height = 700;
     }
     $ex_exhibit->set('height', $height);
     if ($css) {
         $ex_exhibit->set('css', $css);
     }
     if ($custom_html) {
         $ex_exhibit->set('custom_html', $custom_html);
     } else {
         $ex_exhibit->set('custom_html', NULL);
     }
     $ex_exhibit->save();
     echo $ex_exhibit->get('id');
 }
} else {
    // Before 2.6
    require_once $root . '/wp-config.php';
}
ob_end_clean();
//Ensure we don't have output from other plugins.
header('Content-Type: text/html; charset=' . get_option('blog_charset'));
/*
 * Load up the lightboxed exhibit
 */
global $lightboxed_exhibit;
$exhibitid = $_GET['exhibitid'];
if (isset($exhibitid) && $exhibitid != NULL) {
    // We are goiing to try to load just this one
    $lightboxed_exhibit = new WpPostExhibit();
    DbMethods::loadFromDatabase($lightboxed_exhibit, $exhibitid);
}
$currentview = $_GET['currentview'];
$postid = $_GET['postid'];
$exhibit_html = $exhibit_html = WpExhibitHtmlBuilder::get_exhibit_html($lightboxed_exhibit, $currentview, $postid);
?>
<html>
<head>
<?php 
require 'head.php';
?>
</head>
<body>
<?php 
echo $exhibit_html;
?>
function show_datapress_html()
{
    if (!($guessurl = site_url())) {
        $guessurl = wp_guess_url();
    }
    $baseuri = $guessurl;
    $exhibituri = $baseuri . '/wp-content/plugins/datapress';
    /* -------------------------------------------------
     * Load up the exhibit if it exists
     * ------------------------------------------------- */
    $exhibitID = $_GET['exhibitid'];
    $exhibitConfig = NULL;
    if ($exhibitID != NULL) {
        // See if we know about any data sources associated with this item.
        $exhibitConfig = new WpPostExhibit();
        $ex_success = DbMethods::loadFromDatabase($exhibitConfig, $exhibitID);
        if (!$ex_success) {
            $exhibitConfig = NULL;
        }
    }
    ?>
	<form id="exhibit-config-form" action="javascript:return false;">
	<div id="exhibit-input">
		<div class="inside">

		  <div id="exhibit-input-container">
			<ul id="ex-tabs" class="outer-tabs">
				<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#exhibit-data"><span>Add Data</span></a></li>
				<li class="spacer">&gt;</li>
				<li class="ui-state-default ui-corner-top wp-no-js-hidden"><a href="#exhibit-views"><span>Add Visualizations</span></a></li>
				<li class="spacer">&gt;</li>
				<li class="ui-state-default ui-corner-top wp-no-js-hidden"><a href="#exhibit-facets" ><span>Add Facets</span></a></li>
				<li class="spacer">&gt;</li>
	    		<li class="ui-state-default ui-corner-top wp-no-js-hidden"><a href="#exhibit-display" ><span>Configure Display</span></a></li>
				<li class="spacer">&gt;</li>
				<li class="ui-state-default ui-corner-top wp-no-js-hidden" ><a href="#exhibit-lenses"><span>Lenses (Advanced)</span></a></li>
			</ul>

			<div id="exhibit-data" class="outer-tabs-panel ui-tabs-hide">
				<?php 
    include "exhibit-inputbox-data.php";
    ?>
			</div>
			<div id="exhibit-views" class="outer-tabs-panel ui-tabs-hide">
                 <?php 
    include "exhibit-inputbox-views.php";
    ?>
			</div>
			<div id="exhibit-lenses" class="outer-tabs-panel ui-tabs-hide">
				<?php 
    include "exhibit-inputbox-lenses.php";
    ?>
			</div>
			<div id="exhibit-facets" class="outer-tabs-panel ui-tabs-hide">
				<?php 
    include "exhibit-inputbox-facets.php";
    ?>
			</div>
			<div id="exhibit-display" class="outer-tabs-panel ui-tabs-hide">
				<?php 
    include "exhibit-inputbox-display.php";
    ?>
			</div>
		  </div>

		</div>

		  <p align="right">
			<input type="hidden" value="<?php 
    echo $exhibitID;
    ?>
" name="exhibitid" />
			<input type="hidden" value="save_exhibit_configuration" name="action" />
			<input id="save_btn" type="button" class="button savebutton" name="save" value="<?php 
    echo attribute_escape(__('Save'));
    ?>
" />
		  </p>
     </div>
	</form>
	<script>	    
	    jQuery(function() {
    	    jQuery("#exhibit-input-container").tabs();
    	});
		jQuery(document).ready(function(){		    
			function postExhibit(e) {
				var paste_exhibit = false;
				var paste_footnotes = false;
				
				if (e.target.name == "save_insert") {
					paste_exhibit = true;
				}
				if (e.target.name == "save_insert_footnotes") {
					paste_exhibit = true;
					paste_footnotes = true;
				}

				jQuery.post("<?php 
    bloginfo('wpurl');
    ?>
/wp-admin/admin-ajax.php",
				            jQuery("#exhibit-config-form").serialize(),
					        function(data) {
								if(geocodeFields.length != 0) {
									for(key in geocodeFields) {
										var itemProps = getItemProps(geocodeFields[key]);
										//these are the arrays to post to wp-exhibit-geocode.php
										var addresses = Array();
										var datumIds = Array();
										var i = 0;
										for(key2 in itemProps) {
											addresses[i] = itemProps[key2];
											datumIds[i] = key2;
											i++;
										}
										try {
										jQuery.post(<?php 
    echo "'{$exhibituri}/wp-exhibit-geocode.php'";
    ?>
,
										{'exhibitid': data, 'datumids[]': datumIds, 'addresses[]': addresses, 'addressField': geocodeFields[key]});
										} catch(e) {
											console.log(e);
										}
									}
								}
								var win = window.dialogArguments || opener || parent || top;
								win.set_post_exhibit(data);
								win.add_exhibit_token_and_exit();

							});

			}
			
			jQuery('#save_btn').bind("click", postExhibit);
			jQuery('#save_insert_btn').bind("click", postExhibit);
			jQuery('#save_insert_footnotes_btn').bind("click", postExhibit);
			
			jQuery('#ex-tabs').tabs({
                select: function(event, ui) {
                    alert('selected');
                    return true;
                }    
			});
			remove_callbacks = new Array();
			db = Exhibit.Database.create();
				
			ex_load_links();
		});

		//print item properties (for debugging)
		function printItemProps(propertyName) {
			var props = getItemProps(propertyName);
			for(key in props) {
				alert(key + "->" + props[key]);
			}
		}

		function getItemProps(propertyName) {
			var ret = new Array();
			var items = db.getAllItems();
			items.visit(function(item) {
				var obj = db.getObject(item, propertyName);
				if(obj != null) {
					ret[item] = obj;
				}
			});
			return ret;
		}
	</script>
<?php 
}