public function rest_get_template(WP_REST_Request $request) { $id = $request['id']; $format = $request['t']; $template = new ProspectTemplate(false, $id, true, true, false); if ($template == null || $template->post_id == null) { return ''; } if ($format == 'j') { // Replace Template's Unjoined Attribute list with Joined $template->get_all_attributes(false); $template->def->a = $template->all_att_ids; } $result = array('id' => $id, 'def' => $template->def, 'n' => $template->get_num_records()); return $result; }
echo ' g: ' . json_encode($the_xhbt->gen, JSON_UNESCAPED_UNICODE) . ', '; echo ' vf: ' . $the_xhbt->meta_views . ', '; echo ' i: ' . $the_xhbt->meta_inspect . ' }, '; // Also need to output Template data based on Exhibit data echo ' t: [ '; $first = true; $all_ts = array(); $att_defs = array(); foreach ($the_xhbt->gen->ts as $template_id) { if (!$first) { echo ', '; } $first = false; $the_template = new ProspectTemplate(false, $template_id, true, true, false); // 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