Ejemplo n.º 1
0
 public function prsp_get_cf_vals()
 {
     $att_id = $_POST['att_id'];
     $d_char = $_POST['delim'];
     $result = array();
     // Get matching Records
     $args = array('post_type' => 'prsp-record', 'posts_per_page' => -1);
     $query = new WP_Query($args);
     if ($query->have_posts()) {
         foreach ($query->posts as $rec) {
             $data = get_post_meta($rec->ID, $att_id, true);
             if ($data && $data != '') {
                 if ($d_char && $d_char != '' && $d_char != ' ') {
                     $vals = explode($d_char, $data);
                     foreach ($vals as $one_value) {
                         $trimmed = trim($one_value);
                         ProspectAttribute::sorted_insert($trimmed, $result);
                     }
                 } else {
                     $trimmed = trim($data);
                     ProspectAttribute::sorted_insert($trimmed, $result);
                 }
             }
             // if data
         }
     }
     die(json_encode($result));
 }
Ejemplo n.º 2
0
 public function convert_undefined()
 {
     if (($this->def->t == 'N' || $this->def->t == 'D') && isset($this->range->u)) {
         $color = $this->range->u;
         $b = ProspectAttribute::black_contrast($color);
         // Create pseudo-obect to contain Legend entry
         $this->range->u = new stdClass();
         $this->range->u->v = $color;
         $this->range->u->b = $b;
         $this->range->u->l = '?';
     }
 }
Ejemplo n.º 3
0
    // Get Joined form of Template Attributes
    $att_defs = array_merge($att_defs, $the_template->get_all_attributes(false));
    array_push($all_ts, $the_template);
    // Replace Template's Unjoined Attribute list with Joined
    $the_template->def->a = $the_template->all_att_ids;
    // Remove any Record hints
    unset($the_template->def->h);
    echo '{ id: "' . $the_template->id . '", ';
    echo ' def: ' . json_encode($the_template->def, JSON_UNESCAPED_UNICODE) . ', ';
    echo ' n: ' . $the_template->get_num_records() . ' }';
}
?>
 ],
		a: [ <?php 
// Sort definitions of all current Attributes
$att_defs = ProspectAttribute::unique_sorted_att_array($att_defs);
// Output each entry
$first = true;
foreach ($att_defs as $the_attribute) {
    // Ignore Attributes whose Privacy setting protects them
    if ($the_attribute->privacy == 'o') {
        if (!$first) {
            echo ', ';
        }
        $first = false;
        echo '{ id: "' . $the_attribute->id . '", ';
        echo ' def: ' . json_encode($the_attribute->def, JSON_UNESCAPED_UNICODE) . ', ';
        $the_attribute->convert_undefined();
        echo ' r: ' . json_encode($the_attribute->range, JSON_UNESCAPED_UNICODE) . ', ';
        echo ' l: ' . json_encode($the_attribute->legend, JSON_UNESCAPED_UNICODE) . ', ';
        // In which Templates does this Attribute appear?
Ejemplo n.º 4
0
 public function prsp_page_template($page_template)
 {
     global $post;
     $post_type = get_query_var('post_type');
     // What kind of page viewed?
     switch ($post_type) {
         case 'prsp-attribute':
         case 'prsp-template':
             break;
         case 'prsp-record':
             $blog_id = get_current_blog_id();
             $ajax_url = get_admin_url($blog_id, 'admin-ajax.php');
             $tmplt_id = get_post_meta($post->ID, 'tmplt-id', true);
             if ($tmplt_id != '') {
                 // Load Template definition
                 $the_template = new ProspectTemplate(false, $tmplt_id, true, true, true);
                 // Get dependent Templates needed for Joins
                 $d_templates = $the_template->get_dependent_templates(true);
                 // Get associative array for all Attribute definitions
                 $assoc_atts = ProspectAttribute::get_assoc_defs();
                 $record = new ProspectRecord(true, $post->ID, false, $the_template, $d_templates, $assoc_atts);
                 wp_enqueue_script('jquery');
                 wp_enqueue_script('underscore');
                 wp_enqueue_style('view-record-css', plugins_url('/css/view-record.css', dirname(__FILE__)));
                 if ($the_template->view->sc != null && $the_template->view->sc != 'disable') {
                     wp_enqueue_script('soundcloud-api', 'http://w.soundcloud.com/player/api.js');
                 }
                 wp_enqueue_script('view-record', plugins_url('/js/view-record.js', dirname(__FILE__)), array('jquery', 'underscore'));
                 // Convert attributes to serial array
                 $att_array = array();
                 foreach ($assoc_atts as $key => $value) {
                     $att_entry = array();
                     $att_entry['id'] = $key;
                     $att_entry['def'] = $value;
                     array_push($att_array, $att_entry);
                 }
                 // Sort by ID
                 usort($att_array, array('Prospect', 'cmp_ids'));
                 // Compile Dependent Template view data
                 $d_t_array = array();
                 foreach ($d_templates as $this_temp) {
                     $d_t_entry = array();
                     $d_t_entry['id'] = $this_temp->id;
                     $d_t_entry['v'] = $this_temp->view;
                     array_push($d_t_array, $d_t_entry);
                 }
                 wp_localize_script('view-record', 'prspdata', array('ajax_url' => $ajax_url, 'd' => $record->att_data, 'a' => $att_array, 'v' => $the_template->view, 'j' => $the_template->joins, 't' => $d_t_array));
                 $dltext = ProspectAdmin::get_script_text('view-record.txt');
                 echo $dltext;
             }
             break;
         case 'prsp-exhibit':
             $page_template = dirname(__FILE__) . '/view-exhibit.php';
             break;
             // Don't currently support any special views as they are meant for backend
         // Don't currently support any special views as they are meant for backend
         case 'prsp-map':
         case 'prsp-prspctv':
             break;
     }
     // switch
     return $page_template;
 }