예제 #1
0
 public function get_wrappers_select_options_for_mirroring()
 {
     $wrappers = HeadwayWrappers::get_all_wrappers();
     $options = array('' => '– Do Not Mirror –');
     //If there are no blocks, then just return the Do Not Mirror option.
     if (empty($wrappers) || !is_array($wrappers)) {
         return $options;
     }
     foreach ($wrappers as $wrapper_id => $wrapper_settings) {
         /* If we can't get a name for the layout, then things probably aren't looking good.  Just skip this wrapper. */
         if (!($layout_name = HeadwayLayout::get_name($wrapper_settings['layout']))) {
             continue;
         }
         /* Check for mirroring here */
         if (HeadwayWrappers::get_wrapper_mirror($wrapper_settings)) {
             continue;
         }
         $current_layout_suffix = $this->wrapper['layout'] == $wrapper_settings['layout'] ? ' (Warning: Same Layout)' : null;
         $wrapper_alias = headway_get('alias', $wrapper_settings) ? ' – ' . headway_get('alias', $wrapper_settings) : null;
         //Get alias if it exists, otherwise use the default name
         $options[$wrapper_id] = 'Wrapper #' . HeadwayWrappers::format_wrapper_id($wrapper_id) . $wrapper_alias . ' – ' . $layout_name . $current_layout_suffix;
     }
     //Remove the current wrapper from the list
     unset($options[$this->wrapper['id']]);
     return $options;
 }
예제 #2
0
    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 -->';
    }
예제 #3
0
 public function display()
 {
     if (!$this->blocks) {
         return $this->display_no_blocks_message();
     }
     foreach ($this->wrappers as $wrapper_id => $wrapper_settings) {
         $wrapper_id_for_blocks = $wrapper_id;
         /* Check if mirroring.  If mirroring, change wrapper ID to the wrapper being mirrored and preserve original ID for a later class */
         if ($wrapper_being_mirrored = HeadwayWrappers::get_wrapper_mirror($wrapper_settings)) {
             $mirrored_wrapper_id = $wrapper_being_mirrored['id'];
             $wrapper_id_for_blocks = $mirrored_wrapper_id;
             foreach (HeadwayBlocksData::get_blocks_by_wrapper($wrapper_being_mirrored['layout'], $mirrored_wrapper_id) as $block_from_mirrored_wrapper) {
                 $this->blocks[$block_from_mirrored_wrapper['id']] = $block_from_mirrored_wrapper;
             }
         }
         /* Grab blocks belonging to this wrapper */
         $wrapper_blocks = array();
         foreach ($this->blocks as $block_id => $block) {
             if (headway_get('wrapper', $block, HeadwayWrappers::$default_wrapper_id) === $wrapper_id_for_blocks) {
                 $wrapper_blocks[$block_id] = $block;
             }
             /* If there's only one wrapper and the block does not have a proper ID or is default, move it to that wrapper */
             if (count($this->wrappers) === 1 && (headway_get('wrapper', $block) === null || headway_get('wrapper', $block) == 'wrapper-default' || !isset($this->wrappers[headway_get('wrapper', $block)]))) {
                 $wrapper_blocks[$block_id] = $block;
             }
         }
         /* Setup wrapper classes */
         $wrapper_column_width = headway_get('use-independent-grid', $wrapper_settings) ? headway_get('column-width', $wrapper_settings) : HeadwayOption::get('column-width', false, HeadwayWrappers::$default_column_width);
         $wrapper_gutter_width = headway_get('use-independent-grid', $wrapper_settings) ? headway_get('gutter-width', $wrapper_settings) : HeadwayOption::get('gutter-width', false, HeadwayWrappers::$default_gutter_width);
         $wrapper_classes = array('wrapper');
         $wrapper_classes[] = $wrapper_settings['fluid'] ? 'wrapper-fluid' : 'wrapper-fixed';
         $wrapper_classes[] = HeadwayResponsiveGrid::is_active() ? 'responsive-grid' : null;
         $wrapper_classes[] = headway_get('use-independent-grid', $wrapper_settings) ? 'independent-grid' : null;
         $wrapper_classes[] = 'grid-' . ($wrapper_settings['fluid-grid'] || HeadwayResponsiveGrid::is_enabled() ? 'fluid' : 'fixed') . '-' . $wrapper_settings['columns'] . '-' . $wrapper_column_width . '-' . $wrapper_gutter_width;
         $wrapper_classes[] = $wrapper_being_mirrored ? 'wrapper-mirroring-' . HeadwayWrappers::format_wrapper_id($mirrored_wrapper_id) : null;
         $last_wrapper_id = array_slice(array_keys($this->wrappers), -1, 1);
         $last_wrapper_id = $last_wrapper_id[0];
         $first_wrapper_id = array_keys($this->wrappers);
         $first_wrapper_id = $first_wrapper_id[0];
         if ($last_wrapper_id == $wrapper_id) {
             $wrapper_classes[] = 'wrapper-last';
         } else {
             if ($first_wrapper_id == $wrapper_id) {
                 $wrapper_classes[] = 'wrapper-first';
             }
         }
         /* Custom wrapper classes */
         $custom_css_classes = explode(' ', str_replace('  ', ' ', str_replace(',', ' ', htmlspecialchars(strip_tags(headway_get('css-classes', $wrapper_settings, ''))))));
         $wrapper_classes = array_merge($wrapper_classes, $custom_css_classes);
         /* Display the wrapper */
         do_action('headway_before_wrapper');
         echo '<div id="' . $wrapper_id . '" class="' . implode(' ', array_unique(array_filter($wrapper_classes))) . '">' . "\n\n";
         do_action('headway_wrapper_open');
         $wrapper = new HeadwayGridRenderer($wrapper_blocks, $wrapper_settings);
         $wrapper->render_grid();
         do_action('headway_wrapper_close');
         echo '</div><!-- .wrapper -->' . "\n\n";
         do_action('headway_after_wrapper');
         /* End displaying wrapper */
     }
 }
예제 #4
0
 public static function register_wrapper_instances()
 {
     $all_wrappers = HeadwayOption::get_group('wrappers');
     if (!$all_wrappers) {
         return false;
     }
     foreach ($all_wrappers as $layout_id => $layout_wrappers) {
         /* Skip over the last-id option */
         if ($layout_id == 'last-id') {
             continue;
         }
         foreach ($layout_wrappers as $layout_wrapper_id => $layout_wrapper_settings) {
             /* Do NOT register the default wrapper instance */
             if ($layout_wrapper_id == 'wrapper-default') {
                 continue;
             }
             /* Format the wrapper settings array */
             $layout_wrapper_settings['id'] = $layout_wrapper_id;
             /* Do not register instance for mirrored wrapper */
             if (HeadwayWrappers::get_wrapper_mirror($layout_wrapper_settings)) {
                 continue;
             }
             $wrapper_alias = headway_get('alias', $layout_wrapper_settings) ? ' &ndash; ' . headway_get('alias', $layout_wrapper_settings) : null;
             HeadwayElementAPI::register_element_instance(array('group' => 'structure', 'element' => 'wrapper', 'id' => $layout_wrapper_id . '-layout-' . $layout_id, 'name' => 'Wrapper #' . HeadwayWrappers::format_wrapper_id($layout_wrapper_id) . $wrapper_alias, 'selector' => '#' . $layout_wrapper_id . ', div.wrapper-mirroring-' . HeadwayWrappers::format_wrapper_id($layout_wrapper_id), 'layout' => $layout_id));
         }
     }
 }