/** * * @param RP_Persona $persona * @param array $options * @param integer $page_id * @return string */ public function build($persona, $options, $page_id) { $block = ''; if ($options['hide_header'] == 0) { $block .= RP_Header_Panel_Creator::create($persona, $options); } if ($options['hide_bio'] == 0 && isset($persona->notes) && count($persona->notes) > 0) { $block .= RP_Bio_Panel_Creator::create($persona->notes, $options); } if ($options['hide_facts'] == 0 && isset($persona->facts) && count($persona->facts) > 0) { $block .= RP_Facts_Panel_Creator::create($persona->facts, $options); } if ($options['hide_ancestors'] == 0 && isset($persona->ancestors)) { $creator = new RP_Ancestors_Panel_Creator(); $block .= $creator->create($persona->ancestors, $options); } if ($options['hide_descendancy'] == 0 && isset($persona->marriages)) { $creator = new RP_Descendancy_Panel_Creator(); $block .= $creator->create($persona, $options); } if ($options['hide_family_c'] == 0 && isset($persona->ancestors)) { $block .= RP_Group_Sheet_Panel_Creator::create_group_child('c0', $persona->ancestors, $persona->siblings, $options); } if ($options['hide_family_s'] == 0 && isset($persona->marriages) && count($persona->marriages) > 0) { $cnt = count($persona->marriages); for ($idx = 0; $idx < $cnt; $idx++) { $marriage = $persona->marriages[$idx]; $block .= RP_Group_Sheet_Panel_Creator::create_group_spouse('p' . $idx, $marriage, $options); } } if ($options['hide_pictures'] == 0 && isset($persona->picfiles) && count($persona->picfiles) > 0) { $block .= RP_Picture_Panel_Creator::create($persona, $options); } if ($options['hide_evidence'] == 0 && isset($persona->sources) && count($persona->sources) > 0) { $block .= RP_Evidence_Panel_Creator::create($persona, $options); } $block .= RP_Persona_Helper::get_banner($options, ''); $block .= RP_Persona_Page_Builder::create_end_of_page($persona->id, $persona->batch_id, $page_id, $options); return $block; }
/** * * @param array $atts * @param string $content * @param string $callback * @return string */ function persona_handler($atts, $content = null, $callback = null) { //$time_start = microtime( true ); global $post; try { $block = ''; $persona_id = $atts['personid']; if ($persona_id == '0') { unset($persona_id); } if (isset($persona_id)) { $batch_id = isset($atts['batchid']) ? $atts['batchid'] : '1'; $options = get_option('persona_plugin'); if ((empty($callback) || strtolower($callback) == 'rootspersona') && isset($options['custom_page']) && !empty($options['custom_page'])) { $picfile1 = isset($atts['picfile1']) ? $atts['picfile1'] : plugins_url('images/boy-silhouette.gif', __FILE__); $pageContent = html_entity_decode($options['custom_page'], ENT_QUOTES); $pageContent = str_replace("{%personid%}", $persona_id, $pageContent); $pageContent = str_replace("{%batchid%}", $batch_id, $pageContent); $pageContent = str_replace("{%picfile1%}", $picfile1, $pageContent); $block = do_shortcode($pageContent); } else { $builder = new RP_Persona_Page_Builder(); $options = $builder->get_persona_options($atts, $callback, $options); $factory = new RP_Persona_Factory($this->credentials); $persona = $factory->get_with_options($persona_id, $batch_id, $options); //if($persona->full_name == 'Private') // $post->post_title = 'Private'; $block = $builder->build($persona, $options, RP_Persona_Helper::get_page_id()); } } else { $msg = __('Invalid person id.', 'rootspersona'); $block = RP_Persona_Helper::return_default_empty($msg, WP_PLUGIN_URL); } //$time = microtime( true ) - $time_start; //echo "\nDone in $time seconds using " // . memory_get_peak_usage( true ) / 1024 / 1024 . 'MB.'; return $block; } catch (Exception $e) { error_log($e->getMessage() . "::" . RP_Persona_Helper::trace_caller(), 0); return '<span style="color:red;margin-top:20px;display:inline-block;">' . $e->getMessage() . "::" . RP_Persona_Helper::trace_caller() . '</span>'; } }