/**
  * Overwrite initial output value for editorial intros
  *
  * @since 0.1.0
  * @access protected
  **/
 protected function create_output()
 {
     $this->output_tag_open();
     $content = BasePattern::pattern_factory($this->input, 'paragraph', $this->element, true);
     $this->output .= $content->embed();
     $this->output_tag_close();
 }
 public function set_block_paragraph_text()
 {
     $acf_paragraph = get_post_meta($this->container->post_id, 'block_paragraph_text', true);
     if (!empty($acf_paragraph)) {
         $input = array('text' => '<p>' . $acf_paragraph . '</p>');
         $this->container->block_paragraph_text = BasePattern::pattern_factory($input, 'paragraph', '', 'emphasisblock', false);
     }
 }
 /**
  * @return MetaConfiguration
  **/
 public function buildContainers()
 {
     $force = $this->isForcedGeneration();
     $out = $this->getOutput();
     $out->infoLine('Building containers: ');
     foreach ($this->classes as $class) {
         foreach ($class->getProperties() as $property) {
             if ($property->getRelation() && $property->getRelationId() != MetaRelation::ONE_TO_ONE) {
                 $userFile = ONPHP_META_DAO_DIR . $class->getName() . ucfirst($property->getName()) . 'DAO' . EXT_CLASS;
                 if ($force || !file_exists($userFile)) {
                     BasePattern::dumpFile($userFile, Format::indentize(ContainerClassBuilder::buildContainer($class, $property)));
                 }
                 // check for old-style naming
                 $oldStlye = ONPHP_META_DAO_DIR . $class->getName() . 'To' . $property->getType()->getClassName() . 'DAO' . EXT_CLASS;
                 if (is_readable($oldStlye)) {
                     $out->newLine()->error('remove manually: ' . $oldStlye);
                 }
             }
         }
     }
     return $this;
 }
				<!-- SHARED STORIES -->
				<?php 
if ($exchange->has_stories) {
    ?>
					<section class="collaboration__section collaboration__stories section--yellow-1-web section--coloured">
						<?php 
    echo BasePattern::build_edge_svg('top', exchange_slug_to_hex('yellow-1-web'));
    ?>
						<div class="section-inner">
							<?php 
    $exchange->publish_related_stories();
    ?>
						</div><!--section-inner-->
						<?php 
    echo BasePattern::build_edge_svg('bottom', exchange_slug_to_hex('yellow-1-web'));
    ?>
					</section>
				<?php 
}
?>

			</div> <!-- end articleBpdy -->

			<?php 
include_once get_stylesheet_directory() . '/parts/content-story-footer.php';
?>

		</article> <!-- end article -->

		<?php 
 public function create_output()
 {
     if (!is_array($this->input['contents'])) {
         return;
     }
     $length = count($this->input['contents']);
     if (0 === $length) {
         return;
     }
     for ($i = 0; $i < $length; $i++) {
         if (!empty($this->input['contents'][$i]['acf_fc_layout'])) {
             $this->set_modifier_class('contents_' . $i, $this->input['contents'][$i]['acf_fc_layout']);
         }
     }
     // Check for background colour modifier and add to classes.
     if (!empty($this->input['background_colour'])) {
         $colour = $this->input['background_colour'];
         $this->set_modifier_class('colour', $colour);
         $this->set_modifier_class('style', 'coloured');
         $this->set_attribute('data', 'background-colour', $colour);
     }
     // Open section with edge.
     $this->output_tag_open('section');
     if (isset($colour)) {
         $this->output .= BasePattern::build_edge_svg('top', $colour);
     }
     $this->output .= '<div class="section-inner">';
     $this->build_section_header();
     foreach ($this->input['contents'] as $section_contents) {
         switch ($section_contents['acf_fc_layout']) {
             case 'has_map':
                 $this->set_map_data($section_contents)->build_map();
                 break;
             case 'has_form':
                 $this->build_form($section_contents);
                 break;
             case 'has_grid':
                 $this->build_simple_grid($section_contents);
                 break;
             case 'has_story_elements':
                 $this->build_story_elements($section_contents);
                 break;
             case 'has_contact_details':
                 $this->build_contact_block($section_contents);
                 break;
             case 'has_social_icons':
                 $this->build_social_icons($section_contents);
                 break;
         }
     }
     $this->output .= '</div>';
     // Close section with edge.
     if (isset($colour)) {
         $this->output .= BasePattern::build_edge_svg('bottom', $colour);
     }
     $this->output_tag_close('section');
 }
 /**
  * Create grid item from ACF Layout
  *
  * Creates grid item with post_item data, add modifiers when necessary.
  *
  * @param integer $item Post object to be represented by grid item.
  */
 protected function create_grid_item_from_layout($item)
 {
     if (!isset($item['acf_fc_layout'])) {
         return;
     }
     $item_mods = array();
     $layout = $item['acf_fc_layout'];
     switch ($layout) {
         case 'grid_exchange_story':
         case 'grid_exchange_collaboration':
         case 'grid_exchange_programme_round':
             if (!is_numeric($item['grid_exchange_object'])) {
                 if (is_array($item['grid_exchange_object']) && is_int($item['grid_exchange_object'][0])) {
                     $object_id = $item['grid_exchange_object'][0];
                 } else {
                     return;
                 }
             } else {
                 $object_id = intval($item['grid_exchange_object']);
             }
             if (empty($object_id)) {
                 return;
             }
             $object = BaseController::exchange_factory($object_id, 'griditem');
             $item_mods = self::add_grid_modifiers($object);
             break;
         case 'grid_paragraph':
             if ('grid_paragraph' === $layout && empty($item['text'])) {
                 return;
             }
         case 'grid_pull_quote':
             if ('grid_pull_quote' === $layout && empty($item['pquote_text'])) {
                 return;
             }
         case 'grid_image':
             if ('grid_image' === $layout && empty($item['image'])) {
                 return;
             }
             $pattern_type = str_replace('grid_', '', $layout);
             $object = BasePattern::pattern_factory($item, $pattern_type, 'griditem', true);
             $item_mods['type'] = 'pattern';
             $item_mods['pattern_type'] = $pattern_type;
             break;
         default:
             return;
     }
     if (!empty($item['grid_width'])) {
         $item_mods['grid_width'] = $item['grid_width'];
         $num = $this->get_grid_width_num($item['grid_width']);
         if (isset($num) & is_int($num)) {
             $item_mods['grid_width_num'] = $num;
         }
     }
     $grid_item = new GridItem($object, $this->element, $item_mods);
     return $grid_item;
 }
 public function publish_grid_cta($modifier = '')
 {
     $properties = array();
     if (function_exists('get_field')) {
         $properties = array('block_type' => 'cta', 'block_alignment' => false, 'cta_block_elements' => get_field('cta_block_elements', $this->post_id), 'cta_colour' => get_post_meta($this->post_id, 'cta_colour', true));
     }
     if ($modifier === 'grid_full') {
         $properties['block_alignment'] = 'full';
     }
     if (empty($properties['cta_block_elements'])) {
         return;
     } else {
         $length = count($properties['cta_block_elements']);
         for ($i = 0; $i < $length; $i++) {
             if ('block_button' === $properties['cta_block_elements'][$i]['acf_fc_layout']) {
                 // Add permalink to button if link left empty.
                 if (empty($properties['cta_block_elements'][$i]['button_link'])) {
                     $properties['cta_block_elements'][$i]['button_link'] = $this->link;
                 }
                 if (empty($properties['cta_block_elements'][$i]['button_size'])) {
                     $properties['cta_block_elements'][$i]['button_size'] = 'small';
                 }
             }
         }
     }
     $block = BasePattern::pattern_factory($properties, 'emphasis_block', 'griditem');
     echo $block;
 }
 public function create_token_form_cta($obj, $pr_token = '', $c_obj = null)
 {
     if (empty($obj->type) && empty($obj->post_type)) {
         return;
     }
     switch ($obj->type) {
         case 'participant':
             $form_paragraph = __('Update information about you and your organisation(s)', EXCHANGE_PLUGIN);
             $cta_colour = exchange_slug_to_hex('rose-1-web');
             $form_title = !empty($obj->name) ? $obj->name : 'participant';
             // Set update link.
             $acf_update_link = $obj->get_update_form_link();
             $update_link = !empty($acf_update_link) ? $acf_update_link : '#';
             break;
         case 'collaboration':
             $form_paragraph = __('Update information on your project', EXCHANGE_PLUGIN);
             $cta_colour = exchange_slug_to_hex('blue-2-web');
             $form_title = !empty($obj->title) ? wp_trim_words($obj->title, 6, __('...', EXCHANGE_PLUGIN)) : 'collaboration';
             // Set update link.
             $acf_update_link = $obj->get_update_form_link();
             $update_link = !empty($acf_update_link) ? $acf_update_link : '#';
             break;
         default:
             if ($obj->post_type == 'page') {
                 $form_paragraph = __('Share your Tandem experience on your collaboration page', EXCHANGE_PLUGIN);
                 $cta_colour = exchange_slug_to_hex('yellow-tandem');
                 $form_title = !empty($obj->post_title) ? $obj->post_title : 'story';
                 $permalink = get_post_permalink($obj->ID);
                 if ($c_obj instanceof Collaboration && is_numeric($c_obj->post_id)) {
                     $permalink = add_query_arg('update_id', $c_obj->post_id, $permalink);
                 }
                 if (!empty($pr_token)) {
                     $permalink = add_query_arg('pr_ref', $pr_token, $permalink);
                 }
                 $update_link = !empty($permalink) ? $permalink : '#';
                 break;
             } else {
                 return;
             }
     }
     // Set paragraph.
     $paragraph = '<p>' . $form_paragraph . '</p>';
     // Set programme name for logo.
     $prog_name = explode(' ', $this->title)[1];
     if (in_array($prog_name, array('C&P', 'Community', 'C'), true)) {
         $prog_name = 'C_P';
     }
     $properties = array('block_type' => 'cta', 'cta_colour' => $cta_colour, 'block_alignment' => false, 'cta_block_elements' => array(0 => array('acf_fc_layout' => 'block_header', 'block_header_text' => $form_title), 1 => array('acf_fc_layout' => 'block_logo', 'block_programme' => $prog_name), 2 => array('acf_fc_layout' => 'block_paragraph', 'block_paragraph_text' => $form_paragraph)));
     if ('collaboration' === $obj->type) {
         if (isset($obj->link)) {
             $properties['cta_block_elements'][3] = array('acf_fc_layout' => 'block_button', 'button_size' => 'small', 'button_text' => __('View my collaboration', EXCHANGE_PLUGIN), 'button_help_text' => __('Navigate to your collaboration page', EXCHANGE_PLUGIN), 'button_link' => $obj->link, 'button_target' => '_self');
         }
         if (isset($form_title) && isset($update_link)) {
             $properties['cta_block_elements'][4] = array('acf_fc_layout' => 'block_button', 'button_size' => 'small', 'button_text' => __('Update my collaboration page', EXCHANGE_PLUGIN), 'button_help_text' => sprintf(__('Add or edit information for %s', EXCHANGE_PLUGIN), $form_title), 'button_link' => $update_link, 'button_target' => '_self');
         }
     } elseif ('participant' === $obj->type) {
         if (isset($form_title) && isset($update_link)) {
             $properties['cta_block_elements'][3] = array('acf_fc_layout' => 'block_button', 'button_size' => 'small', 'button_text' => __('Update my info', EXCHANGE_PLUGIN), 'button_help_text' => sprintf(__('Edit the information about %s', EXCHANGE_PLUGIN), $form_title), 'button_link' => $update_link, 'button_target' => '_self');
         }
     } elseif ('page' === $obj->post_type) {
         $properties['cta_block_elements'][3] = array('acf_fc_layout' => 'block_button', 'button_size' => 'small', 'button_text' => __('Submit a story', EXCHANGE_PLUGIN), 'button_help_text' => __('Navigate to the page for submitting stories', EXCHANGE_PLUGIN), 'button_link' => $update_link, 'button_target' => '_self');
     }
     // $results = '<pre>' . print_r( $properties, true ) . '</pre>';
     // return $results;
     $block = BasePattern::pattern_factory($properties, 'emphasis_block', 'griditem', true);
     $griditem_mods = array('grid_width' => 'grid_fourth', 'type' => 'cta', 'grid_width_num' => 3);
     $griditem = new Griditem($block, 'simplegrid', $griditem_mods);
     return $griditem;
 }
 public function publish_collab_files($context = '')
 {
     if (!$this->has_files) {
         return;
     }
     $doc_block_input = array('add_file' => array());
     foreach ($this->files as $file) {
         $doc_block_input['add_file'][] = array('file' => $file);
     }
     $doc_block = BasePattern::pattern_factory($doc_block_input, 'uploaded_files', 'collaboration', true);
     if ($doc_block instanceof Documentblock) {
         $grid_mods = array('type' => 'documentblock');
         $griditem = new GridItem($doc_block, 'collaboration', $grid_mods);
         $griditem->publish();
     }
 }