protected function build_block_elements()
 {
     // Subheader.
     $section_header_text = !empty($this->input['uploaded_files_header']) ? $this->input['uploaded_files_header'] : __('Available downloads', EXCHANGE_PLUGIN);
     $section_header_mods = array('type' => 'taped_header', 'colour' => exchange_slug_to_hex('blue-3'));
     $section_header = new SectionHeader($section_header_text, $this->element, $section_header_mods);
     $this->output .= $section_header->embed();
     // Paragraph.
     $paragraph_text = '<ul class="documentblock__file-list dont-break-out">';
     foreach ($this->input['add_file'] as $doc) {
         if (!is_numeric($doc['file'])) {
             continue;
         }
         if (function_exists('acf_get_attachment')) {
             $meta = acf_get_attachment($doc['file']);
         }
         if (empty($meta)) {
             continue;
         }
         $description = !empty($meta['description']) ? $meta['description'] : $meta['filename'];
         $paragraph_text .= '<li class="documentblock__file-list__item">';
         $paragraph_text .= '<a href="' . $meta['url'] . '" target="_blank">' . $description . '</a>';
         $paragraph_text .= '</li>';
     }
     $paragraph_text .= '</ul>';
     $paragraph = new Paragraph($paragraph_text, $this->element);
     $this->output .= $paragraph->embed();
 }
 /**
  * For each CTA element in array, embed the right pattern class instantiation.
  *
  * @since 0.1.0
  *
  * @param string $type String describing the kind of block we're building.
  *
  * @TODO proper Error notifications.
  **/
 protected function build_block_elements()
 {
     // Check for CTA elements.
     foreach ($this->input as $e) {
         switch ($e['acf_fc_layout']) {
             case 'block_graphic':
                 $image_arr = $e['block_graphic_select'];
                 if (empty($image_arr) || empty($image_arr['mime_type'])) {
                     break;
                 }
                 $image_mods = array();
                 if ('image/svg+xml' === $image_arr['mime_type']) {
                     $image = new ImageSVG($image_arr, $this->element, $image_mods);
                 } else {
                     $image = new Image($image_arr, $this->element, $image_mods);
                 }
                 $this->output .= $image->embed();
                 break;
             case 'block_logo':
                 if (!empty($e['block_programme'])) {
                     $colour = isset($this->modifiers['colour']) ? $this->modifiers['colour'] : 'default';
                     $image_mods = array('background-colour' => $colour);
                     $image = new ImageSVG($e['block_programme'], $this->element, $image_mods);
                     $this->output .= $image->embed();
                 }
                 break;
             case 'block_paragraph':
                 if (!empty($e['block_paragraph_text'])) {
                     $paragraph = new Paragraph($e['block_paragraph_text'], $this->element);
                     $this->output .= $paragraph->embed();
                 }
                 break;
             case 'block_header':
                 if (!empty($e['block_header_text'])) {
                     $subheader = new SubHeader($e['block_header_text'], $this->element);
                     $this->output .= $subheader->embed();
                 }
                 break;
             case 'block_button':
                 $button_mods = array('link' => array(), 'data' => array());
                 if (!empty($e['button_link'])) {
                     $button_mods['link']['href'] = $e['button_link'];
                 }
                 if (!empty($e['button_target'])) {
                     $button_mods['link']['target'] = $e['button_target'];
                 }
                 if (!empty($e['button_help_text'])) {
                     $button_mods['link']['title'] = $e['button_help_text'];
                 }
                 if (!empty($e['button_size'])) {
                     $button_mods['size'] = $e['button_size'];
                 }
                 $button = new Button($e, $this->element, $button_mods);
                 $this->output .= $button->embed();
                 break;
             default:
                 break;
         }
     }
 }
 /**
  * Build interview, QA-style.
  *
  * @return HTML string with questions and answers
  **/
 public function build_interview()
 {
     if (is_array($this->input) && count($this->input) > 0) {
         $output = '';
         foreach ($this->input as $qa) {
             if (!empty($qa['question']) && !empty($qa['answer'])) {
                 $modifiers_q = array('style' => 'question');
                 $modifiers_a = array('style' => 'answer');
                 $question = new Paragraph($qa['question'], $this->element, $modifiers_q);
                 $answer = new Paragraph($qa['answer'], $this->element, $modifiers_a);
                 $output .= $question->embed();
                 $output .= $answer->embed();
             }
         }
         return $output;
     }
     return __('There are no questions or answers to show here!', EXCHANGE_PLUGIN);
 }
 /**
  * Build interview, Conversation-style.
  *
  * @return HTML string with names and statements.
  **/
 public function build_interview()
 {
     if (is_array($this->input) && !empty($this->input)) {
         $output = '';
         foreach ($this->input as $vs) {
             if (!empty($vs['voice']) && !empty($vs['statement'])) {
                 $voice = '<td class="' . $this->element . '__voice">' . $vs['voice'] . '</td>';
                 $statement = '<td class="' . $this->element . '__statement">' . $vs['statement'] . '</td>';
                 $row = '<tr>' . $voice . $statement . '</tr>';
                 $output .= $row;
             }
         }
         $paragraph = new Paragraph('<table>' . $output . '</table>', $this->element);
         return $paragraph->embed();
     } else {
         return __('There are no questions or answers to show here!', EXCHANGE_PLUGIN);
     }
 }
 protected function build_translation($translation)
 {
     $lang_term = $this->get_translation_language($translation);
     if (empty($lang_term)) {
         return;
     }
     $p_mods = array('lang' => $lang_term->slug, 'misc' => array('id' => $lang_term->slug));
     if ($lang_term->description === 'rtl') {
         $p_mods['misc']['dir'] = 'rtl';
     }
     $p = new Paragraph($translation['translation_text'], $this->element, $p_mods);
     $this->output .= $p->embed();
 }