/**
  *
  * @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;
 }
 public static function build_level($persona, $options, $lvl)
 {
     $spacer1 = '';
     $indent1 = ($lvl - 1) * 2;
     $indent2 = $indent1 + 1;
     $block = '<div style="padding-left:' . $indent1 . 'em;"' . ' itemscope itemtype="http://historical-data.org/HistoricalPerson.html">' . '<meta itemprop="gender" content="' . $persona->gender . '"/>' . $lvl . '&nbsp;<a href="' . $options['home_url'] . '?page_id=' . $persona->page . '">' . '<span class="nospace" itemprop="name">' . $persona->full_name . '</span>' . '</a>';
     if ($options['hide_dates'] == 0) {
         $block .= '<span style="font-size:smaller;padding-left:1em;">';
         $d = @preg_replace('/@.*@(.*)/US', '$1', $persona->birth_date);
         if (isset($d) & !empty($d)) {
             $year = preg_replace("/.*([0-9][0-9][0-9][0-9]).*/i", '$1', $d);
             $tmpDate = '<span itemprop="birth" itemscope itemtype="http://historical-data.org/HistoricalEvent.html">' . (strlen($year) == 4 ? '<span itemprop="startDate" content="' . $year . '">' : '') . @preg_replace('/@.*@(.*)/US', '$1', $persona->birth_date) . (strlen($year) == 4 ? '</span>' : '') . '</span>';
             $block .= ' b: ' . $tmpDate;
         }
         $d = @preg_replace('/@.*@(.*)/US', '$1', $persona->death_date);
         if (isset($d) & !empty($d)) {
             $year = preg_replace("/.*([0-9][0-9][0-9][0-9]).*/i", '$1', $d);
             $tmpDate = '<span itemprop="death" itemscope itemtype="http://historical-data.org/HistoricalEvent.html">' . (strlen($year) == 4 ? '<span itemprop="startDate" content="' . $year . '">' : '') . @preg_replace('/@.*@(.*)/US', '$1', $persona->death_date) . (strlen($year) == 4 ? '</span>' : '') . '</span>';
             $block .= ' d: ' . $tmpDate;
         }
         $block .= '</span>';
     }
     $block .= '</div>';
     $cnt = count($persona->marriages);
     for ($idx = 0; $idx < $cnt; $idx++) {
         $marriage = $persona->marriages[$idx];
         if ($marriage['spouse1']->id == $persona->id) {
             $associated = $marriage['spouse2'];
         } else {
             $associated = $marriage['spouse1'];
         }
         if (isset($associated) && !empty($associated)) {
             $block .= '<div style="padding-left:' . $indent2 . 'em;"' . ' itemscope itemtype="http://historical-data.org/HistoricalPerson.html">' . '<meta itemprop="gender" content="' . $associated->gender . '"/>' . '+&nbsp;<a href="' . $options['home_url'] . '?page_id=' . $associated->page . '">' . '<span class="nospace" itemprop="name">' . $associated->full_name . '</span>' . '</a>';
         }
         if ($options['hide_dates'] == 0) {
             $block .= '<span style="font-size:smaller;padding-left:1em;">';
             $d = @preg_replace('/@.*@(.*)/US', '$1', $associated->birth_date);
             if (isset($d) & !empty($d)) {
                 $year = preg_replace("/.*([0-9][0-9][0-9][0-9]).*/i", '$1', $d);
                 $tmpDate = '<span itemprop="birth" itemscope itemtype="http://historical-data.org/HistoricalEvent.html">' . (strlen($year) == 4 ? '<span itemprop="startDate" content="' . $year . '">' : '') . @preg_replace('/@.*@(.*)/US', '$1', $associated->birth_date) . (strlen($year) == 4 ? '</span>' : '') . '</span>';
                 $block .= ' b: ' . $tmpDate;
             }
             $d = @preg_replace('/@.*@(.*)/US', '$1', $associated->death_date);
             if (isset($d) & !empty($d)) {
                 $year = preg_replace("/.*([0-9][0-9][0-9][0-9]).*/i", '$1', $d);
                 $tmpDate = '<span itemprop="death" itemscope itemtype="http://historical-data.org/HistoricalEvent.html">' . (strlen($year) == 4 ? '<span itemprop="startDate" content="' . $year . '">' : '') . @preg_replace('/@.*@(.*)/US', '$1', $associated->death_date) . (strlen($year) == 4 ? '</span>' : '') . '</span>';
                 $block .= ' d: ' . $tmpDate;
             }
             $block .= '</span>';
         }
         $block .= '</div>';
         if ($lvl < 10) {
             $cnt2 = count($marriage['children']);
             // recurse children
             for ($idx2 = 0; $idx2 < $cnt2; $idx2++) {
                 $child = $marriage['children'][$idx2];
                 if ($child->full_name != 'Private') {
                     $block .= RP_Descendancy_Panel_Creator::build_level($child, $options, $lvl + 1);
                 }
             }
         }
     }
     return $block;
 }