public static function display_grid_blocks($blocks, $wrapper)
    {
        echo '<div class="grid-container">';
        if (is_array($blocks)) {
            foreach ($blocks as $block_id => $block) {
                HeadwayBlocks::display_block($block, 'grid');
            }
        }
        /* Mirrored wrapper notice */
        $mirror_wrapper_id = HeadwayWrappers::format_wrapper_id(headway_get('mirror-wrapper', $wrapper));
        $mirror_wrapper = $mirror_wrapper_id ? HeadwayWrappers::get_wrapper($mirror_wrapper_id) : null;
        $mirror_wrapper_layout = $mirror_wrapper ? HeadwayLayout::get_name(headway_get('layout', $mirror_wrapper)) : null;
        $mirror_wrapper_alias = headway_get('alias', $mirror_wrapper) ? '(' . headway_get('alias', $mirror_wrapper) . ')' : null;
        echo '<div class="wrapper-mirror-notice">
						<div>
						<h2>Wrapper Mirrored</h2>
						<p>This wrapper is mirroring the blocks from Wrapper #<span class="wrapper-mirror-notice-id">' . $mirror_wrapper_id . '</span> <span class="wrapper-mirror-notice-alias">' . $mirror_wrapper_alias . '</span> <span class="wrapper-mirror-notice-layout">from "' . $mirror_wrapper_layout . '" layout</span></p>
						<small>Mirroring can be disabled via Wrapper Options in the right-click menu</small>
						</div>
					</div><!-- .wrapper-mirror-notice -->';
        /* End mirrored wrapper notice */
        echo '</div><!-- .grid-container -->';
    }
Exemple #2
0
 public function get_blocks_select_options_for_mirroring()
 {
     $block_type = $this->block['type'];
     $blocks = HeadwayBlocksData::get_blocks_by_type($block_type);
     $options = array('' => '&ndash; Do Not Mirror &ndash;');
     //If there are no blocks, then just return the Do Not Mirror option.
     if (!isset($blocks) || !is_array($blocks)) {
         return $options;
     }
     foreach ($blocks as $block_id => $layout_id) {
         //Get the block instance
         $block = HeadwayBlocksData::get_block($block_id);
         //If the block is mirrored, skip it
         if (HeadwayBlocksData::is_block_mirrored($block)) {
             continue;
         }
         /* Do not show block that's in a mirrored wrapper */
         if (HeadwayWrappers::get_wrapper_mirror(HeadwayWrappers::get_wrapper(headway_get('wrapper', $block)))) {
             continue;
         }
         //Create the default name by using the block type and ID
         $default_name = HeadwayBlocks::block_type_nice($block['type']) . ' #' . $block['id'];
         //If we can't get a name for the layout, then things probably aren't looking good.  Just skip this block.
         if (!($layout_name = HeadwayLayout::get_name($layout_id))) {
             continue;
         }
         //Make sure the block exists
         if (!HeadwayBlocksData::block_exists($block['id'])) {
             continue;
         }
         $current_layout_suffix = $this->block['layout'] == $layout_id ? ' (Warning: Same Layout)' : null;
         //Get alias if it exists, otherwise use the default name
         $options[$block['id']] = headway_get('alias', $block['settings'], $default_name) . ' &ndash; ' . $layout_name . $current_layout_suffix;
     }
     //Remove the current block from the list
     unset($options[$this->block['id']]);
     return $options;
 }
Exemple #3
0
 public static function register_block_element_instances()
 {
     if ((headway_get('layout-in-use') || headway_post('layout')) && !headway_get('compiler-cache')) {
         $layout_id = headway_get('layout-in-use') ? headway_get('layout-in-use') : headway_post('layout');
         $register_block_mirrors = true;
         if (!($blocks = HeadwayBlocksData::get_blocks_by_layout($layout_id))) {
             return false;
         }
     } else {
         $register_block_mirrors = false;
         if (!($blocks = HeadwayBlocksData::get_all_blocks())) {
             return false;
         }
     }
     foreach ($blocks as $block) {
         /* Do not register instance for block that's in a mirrored wrapper */
         if (HeadwayWrappers::get_wrapper_mirror(HeadwayWrappers::get_wrapper(headway_get('wrapper', $block)))) {
             continue;
         }
         /* If it's a mirrored block then we'll register it as long as $register_block_mirrors is true */
         if ($block_mirror = HeadwayBlocksData::is_block_mirrored($block)) {
             if (!$register_block_mirrors) {
                 continue;
             }
             $block = $block_mirror;
         }
         $default_name = self::block_type_nice($block['type']) . ' #' . $block['id'];
         $name = headway_get('alias', $block['settings'], $default_name);
         HeadwayElementAPI::register_element_instance(array('group' => 'blocks', 'element' => 'block-' . $block['type'], 'id' => $block['type'] . '-block-' . $block['id'], 'name' => $name, 'selector' => '#block-' . $block['id'], 'layout' => $block['layout']));
         /* Register sub elements */
         $block_element = HeadwayElementAPI::get_element('block-' . $block['type']);
         foreach (headway_get('children', $block_element, array()) as $block_element_sub_element) {
             /* Make sure that the element supports instances */
             if (!headway_get('supports-instances', $block_element_sub_element)) {
                 continue;
             }
             /* Register instance */
             $instance_selector = str_replace('.block-type-' . $block['type'], '#block-' . $block['id'], $block_element_sub_element['selector']);
             HeadwayElementAPI::register_element_instance(array('group' => 'blocks', 'grandparent' => 'block-' . $block['type'], 'element' => $block_element_sub_element['id'], 'id' => $block_element_sub_element['id'] . '-block-' . $block['id'], 'name' => $name . ' - ' . $block_element_sub_element['name'], 'selector' => $instance_selector, 'layout' => $block['layout']));
             /* Register instance states as instances */
             if (!empty($block_element_sub_element['states']) && is_array($block_element_sub_element['states'])) {
                 foreach ($block_element_sub_element['states'] as $instance_state_id => $instance_state_info) {
                     HeadwayElementAPI::register_element_instance(array('group' => 'blocks', 'grandparent' => 'block-' . $block['type'], 'element' => $block_element_sub_element['id'], 'id' => $block_element_sub_element['id'] . '-block-' . $block['id'] . '-state-' . $instance_state_id, 'name' => $name . ' - ' . $block_element_sub_element['name'] . ' (State: ' . $instance_state_info['name'] . ')', 'selector' => str_replace('.block-type-' . $block['type'], '#block-' . $block['id'], $instance_state_info['selector']), 'layout' => $block['layout'], 'state-of' => $block_element_sub_element['id'] . '-block-' . $block['id'], 'state-name' => $instance_state_info['name']));
                 }
             }
         }
         /* /foreach */
     }
 }
Exemple #4
0
 public static function get_wrapper_mirror($wrapper_settings)
 {
     if (empty($wrapper_settings['mirror-wrapper'])) {
         return false;
     }
     /* If wrapper mirror is same ID as wrapper then we have a problem and it's not a mirror */
     if ($wrapper_settings['mirror-wrapper'] == $wrapper_settings['id']) {
         return false;
     }
     /* It's only a potential mirror because we must first check that the wrapper wanting to be mirrored isn't mirroring a wrapper itself */
     $potential_wrapper_mirror = HeadwayWrappers::get_wrapper($wrapper_settings['mirror-wrapper']);
     if (!empty($potential_wrapper_mirror['mirror-wrapper']) && HeadwayWrappers::get_wrapper($potential_wrapper_mirror['mirror-wrapper'])) {
         return false;
     }
     return $potential_wrapper_mirror;
 }
 public static function method_load_wrapper_options()
 {
     $layout_id = headway_post('layout');
     $wrapper_id = headway_post('wrapper_id');
     $unsaved_options = headway_post('unsaved_wrapper_options', array());
     $wrapper = HeadwayWrappers::get_wrapper($wrapper_id, $layout_id);
     /* Merge unsaved options in */
     if (is_array($unsaved_options)) {
         $wrapper = array_merge($wrapper, $unsaved_options);
     }
     do_action('headway_wrapper_options', $wrapper, $layout_id);
 }