Example #1
0
    public function content()
    {
        $current_layout = headway_post('layout');
        $pages_to_clone_select_options = self::clone_pages_select_walker(HeadwayLayout::get_pages());
        $templates_to_assign_select_options = self::templates_to_assign_select_options();
        ?>
		<ul id="grid-wizard-tabs" class="tabs">
			<?php 
        if ($pages_to_clone_select_options !== '' || $templates_to_assign_select_options !== '') {
            echo '<li><a href="#grid-wizard-tab-clone-page">Clone Existing Layout</a></li>';
            echo '<li><a href="#grid-wizard-tab-presets">Presets</a></li>';
        } else {
            echo '<li><a href="#grid-wizard-tab-presets">Presets</a></li>';
        }
        if ($templates_to_assign_select_options !== '' && strpos($current_layout, 'template-') === false) {
            echo '<li><a href="#grid-wizard-tab-assign-template">Assign Template</a></li>';
        }
        echo '<li><a href="#grid-wizard-tab-import-export">Import/Export</a></li>';
        ?>
		</ul>
		
		<div id="grid-wizard-tab-presets" class="tab-content">
					
			<div id="grid-wizard-presets-step-1">	
				<div class="grid-wizard-presets-row">
					<span class="layout-preset layout-preset-selected" id="layout-right-sidebar" title="Content | Sidebar">
						<img src="<?php 
        echo headway_url() . '/library/visual-editor/images/layouts/layout-right-sidebar.png';
        ?>
" alt="" />
					</span>
				
					<span class="layout-preset" id="layout-left-sidebar" title="Sidebar | Content">
						<img src="<?php 
        echo headway_url() . '/library/visual-editor/images/layouts/layout-left-sidebar.png';
        ?>
" alt="" />
					</span>
				
					<span class="layout-preset" id="layout-two-right" title="Content | Sidebar 1 | Sidebar 2">
						<img src="<?php 
        echo headway_url() . '/library/visual-editor/images/layouts/layout-two-right.png';
        ?>
" alt="" />
					</span>
				</div>

				<div class="grid-wizard-presets-row">
					<span class="layout-preset" id="layout-two-both" title="Sidebar 1 | Content | Sidebar 2">
						<img src="<?php 
        echo headway_url() . '/library/visual-editor/images/layouts/layout-two-both.png';
        ?>
" alt="" />
					</span>
				
					<span class="layout-preset" id="layout-all-content" title="Content">
						<img src="<?php 
        echo headway_url() . '/library/visual-editor/images/layouts/layout-all-content.png';
        ?>
" alt="" />
					</span>
				</div>
			</div><!-- #grid-wizard-presets-step-1 -->
			
			<div id="grid-wizard-presets-step-2">
				
				<h4>Select Which Blocks to Mirror</h4>
				
				<p class="grid-wizard-info">To save time, Headway allows you to "mirror" your blocks.  If you already have a widget area or sidebar that's configured, you may choose to use it by using the select boxes below.</p>
				
				<div id="grid-wizard-presets-mirroring-column-1" class="grid-wizard-presets-mirroring-column">
					<div id="grid-wizard-presets-mirroring-select-header">
						<h5>Header</h5>
				
						<div class="select-container">
							<select>
								<option value="">&mdash; Do Not Mirror &mdash;</option>
								<?php 
        echo self::get_blocks_select_options_for_mirroring('header');
        ?>
							</select>
						</div><!-- .select-container -->
					</div>
				
					<div id="grid-wizard-presets-mirroring-select-navigation">
						<h5>Navigation</h5>
				
						<div class="select-container">
							<select>
								<option value="">&mdash; Do Not Mirror &mdash;</option>
								<?php 
        echo self::get_blocks_select_options_for_mirroring('navigation');
        ?>
							</select>
						</div><!-- .select-container -->
					</div>
				
					<div id="grid-wizard-presets-mirroring-select-content">
						<h5>Content</h5>
				
						<div class="select-container">
							<select>
								<option value="">&mdash; Do Not Mirror &mdash;</option>
								<?php 
        echo self::get_blocks_select_options_for_mirroring('content');
        ?>
							</select>
						</div><!-- .select-container -->
					</div>
				</div>
				
				<div id="grid-wizard-presets-mirroring-column-2" class="grid-wizard-presets-mirroring-column">
					<div id="grid-wizard-presets-mirroring-select-sidebar-1">
						<h5>Sidebar 1</h5>
				
						<div class="select-container">
							<select>
								<option value="">&mdash; Do Not Mirror &mdash;</option>
								<?php 
        echo self::get_blocks_select_options_for_mirroring('widget-area');
        ?>
							</select>
						</div><!-- .select-container -->
					</div>
				
					<div id="grid-wizard-presets-mirroring-select-sidebar-2">
						<h5>Sidebar 2</h5>
				
						<div class="select-container">
							<select>
								<option value="">&mdash; Do Not Mirror &mdash;</option>
								<?php 
        echo self::get_blocks_select_options_for_mirroring('widget-area');
        ?>
							</select>
						</div><!-- .select-container -->
					</div>
				
					<div id="grid-wizard-presets-mirroring-select-footer">
						<h5>Footer</h5>
				
						<div class="select-container">
							<select>
								<option value="">&mdash; Do Not Mirror &mdash;</option>
								<?php 
        echo self::get_blocks_select_options_for_mirroring('footer');
        ?>
							</select>
						</div><!-- .select-container -->
					</div>
				</div>
				
			</div><!-- #grid-wizard-presets-step-2 -->
			
			<div class="grid-wizard-buttons">
				<span class="grid-wizard-use-empty-grid">Use Empty Grid</span>
				
				<?php 
        if ($pages_to_clone_select_options !== '') {
            $next_button_style = null;
            $use_button_style = ' style="display: none;"';
        } else {
            $next_button_style = ' style="display: none;"';
            $use_button_style = null;
        }
        echo '<span id="grid-wizard-button-preset-next" class="button grid-wizard-button-next"' . $next_button_style . '>Next &rarr;</span>';
        echo '<span id="grid-wizard-button-preset-use-preset" class="button grid-wizard-button-next"' . $use_button_style . '>Finish &rarr;</span>';
        echo '<span id="grid-wizard-button-preset-previous" class="button grid-wizard-button-previous" style="display: none;">&larr; Previous</span>';
        ?>
			</div>
			
		</div><!-- #grid-wizard-tab-presets -->
		
		<?php 
        if ($pages_to_clone_select_options !== '' || $templates_to_assign_select_options !== '') {
            ?>
		<div id="grid-wizard-tab-clone-page" class="tab-content">
		
			<h4>Choose a Layout to Clone</h4>
		
			<?php 
            echo '<div class="select-container"><select id="grid-wizard-pages-to-clone">';
            echo '<option value="" disabled="disabled">&mdash; Pages &mdash;</option>';
            echo $pages_to_clone_select_options;
            echo '<option value="" disabled="disabled">&mdash; Templates &mdash;</option>';
            echo $templates_to_assign_select_options;
            echo '</select></div><!-- .select-container -->';
            ?>
			
			<div class="grid-wizard-buttons">
				<span class="grid-wizard-use-empty-grid">Use Empty Grid</span>
				
				<span id="grid-wizard-button-clone-page" class="button grid-wizard-button-next">Clone Layout &rarr;</span>
			</div>
			
		</div><!-- #grid-wizard-tab-clone-page -->
		<?php 
        }
        if ($templates_to_assign_select_options !== '' && strpos($current_layout, 'template-') === false) {
            ?>
		<div id="grid-wizard-tab-assign-template" class="tab-content">
			
			<h4>Choose a Template</h4>
			
			<?php 
            echo '<div class="select-container"><select id="grid-wizard-assign-template">';
            echo '<option value="" disabled="disabled">&mdash; Select a Template &mdash;</option>';
            echo $templates_to_assign_select_options;
            echo '</select></div><!-- .select-container -->';
            ?>
			
			<div class="grid-wizard-buttons">
				<span class="grid-wizard-use-empty-grid">Use Empty Grid</span>
				
				<span id="grid-wizard-button-assign-template" class="button grid-wizard-button-next">Assign Template &rarr;</span>
			</div>
			
		</div><!-- #grid-wizard-tab-assign-template -->
		<?php 
        }
        ?>

		<div id="grid-wizard-tab-import-export" class="tab-content">
		
			<div id="grid-wizard-import" class="grid-wizard-buttons grid-wizard-import-export-group">
				<h4>Import Layout</h4>
				<p>Select the Headway Layout file you would like to import.<br /><br /><strong>Note:</strong> When you browse to and select a file below the imported layout's blocks will automatically be added to the current layout.</p>
				<input type="file" />
				<span class="button" id="grid-wizard-import-select-file">Select File &amp; Import</span>
			</div><!-- #grid-wizard-import -->
				
			<div id="grid-wizard-export" class="grid-wizard-buttons grid-wizard-import-export-group">
				<h4>Export Current Layout</h4>
				<p>Clicking on the button below will package up the current layout and its blocks into a file to be saved and imported later.</p>
				<span class="button" id="grid-wizard-export-download-file">Download Export File</span>
			</div><!-- #grid-wizard-export -->
			
		</div><!-- #grid-wizard-tab-import-export -->

	<?php 
    }
Example #2
0
 public static function list_pages($pages = null)
 {
     //Since this function is recursive, we must designate the default like this
     if ($pages === null) {
         $pages = HeadwayLayout::get_pages();
         $root_pages = true;
     }
     $return = '';
     $return .= '<ul>' . "\n";
     /**
      * Only show the message the function is being called for the first time (not showing children) and that the 
      * mode is NOT the grid and the grid is supported still.
      **/
     if (isset($root_pages) && HeadwayVisualEditor::get_current_mode() !== 'grid' && current_theme_supports('headway-grid')) {
         $return .= '<li class="layout-item info-layout-item"><span class="layout"><strong>To add blocks to a new layout, please switch to the Grid mode.</strong></span></li>';
     }
     foreach ($pages as $id => $children) {
         $layout_id_fragments = explode('-', $id);
         $status = HeadwayLayout::get_status($id, true);
         $class = array('layout-item');
         if (is_array($children) && count($children) !== 0 && headway_post('mode') === 'grid') {
             $class[] = 'has-children';
         }
         if ($status['customized'] === true && !$status['template'] && count(HeadwayBlocksData::get_blocks_by_layout($id)) > 0) {
             $class[] = 'layout-item-customized';
         }
         if ($status['template']) {
             $class[] = 'layout-item-template-used';
         }
         if ($id === headway_post('currentLayout')) {
             $class[] = 'layout-selected';
         }
         $template_id = $status['template'] ? 'template-' . $status['template'] : 'none';
         $template_name = $status['template'] ? HeadwayLayout::get_name('template-' . $status['template']) : null;
         /* Take care of layouts that are the front page or blog index */
         if (get_option('show_on_front') === 'page' && (isset($layout_id_fragments[1]) && $layout_id_fragments[1] == 'page') || apply_filters('headway_layout_selector_no_edit_item_' . $id, false)) {
             /* If the page is set as the static homepage or blog page, hide it if they don't have children.  The Blog Index and Front Page layouts will override them. */
             if (end($layout_id_fragments) == get_option('page_on_front') || end($layout_id_fragments) == get_option('page_for_posts') || apply_filters('headway_layout_selector_no_edit_item_' . $id, false)) {
                 /* Layout has children--add the no edit class and has children class. */
                 if (is_array($children) && count($children) !== 0) {
                     $class[] = 'layout-item-no-edit';
                     /* If the layout doesn't have children, then just hide it. */
                 } else {
                     continue;
                 }
             }
         }
         /* Set layouts that aren't customized in the DE to no edit */
         if (headway_post('mode') === 'design') {
             /* Handle layouts that aren't customized or have a template */
             if (headway_get('customized', $status, false) === false || headway_get('template', $status, false) !== false) {
                 /* If there ARE customized children, add the no-edit class */
                 if (is_array($children) && count($children) !== 0) {
                     $show_node = false;
                     //Get the variable ready
                     /* Check if the children are customized. */
                     if (self::is_any_layout_child_customized($children)) {
                         $class[] = 'layout-item-no-edit';
                         $class[] = 'has-children';
                         $class[] = 'has-customized-children';
                         $show_node = true;
                     }
                     /* If the children aren't customized, then don't display it at all */
                     if (!isset($show_node) || !$show_node) {
                         continue;
                     }
                     /* If there aren't any children, do not display the node at all */
                 } else {
                     continue;
                 }
                 /* Handle layouts that are customized */
             }
         }
         /* Add other classes */
         if (is_array($children) && count($children) && self::is_any_layout_child_customized($children)) {
             $class[] = 'has-children';
             $class[] = 'has-customized-children';
         }
         /* Get post status */
         $post_status = headway_get('post_status', $status);
         $formatted_post_status = $post_status && $post_status != 'Published' ? '<span class="status status-post-status">(' . $post_status . ')</span>' : null;
         /* Output Stuff */
         $return .= '<li class="' . implode(' ', array_filter($class)) . '">';
         $return .= '<span class="layout-has-customized-children tooltip" title="This layout has customized children.">&deg;</span>';
         $return .= '<span data-layout-id="' . $id . '" data-layout-url="' . HeadwayLayout::get_url($id) . '" class="layout layout-page">';
         $return .= '<strong>' . htmlspecialchars(HeadwayLayout::get_name($id)) . '</strong>';
         $return .= $formatted_post_status;
         $return .= '<span class="status status-template" data-template-id="' . $template_id . '">' . $template_name . '</span>';
         $return .= '<span class="status status-customized">Customized</span>';
         $return .= '<span class="status status-currently-editing">Currently Editing</span>';
         $return .= '<span class="remove-template layout-selector-button">Remove Template</span>';
         if (HeadwayVisualEditor::get_current_mode() !== 'design') {
             $return .= '<span class="edit layout-selector-button">Edit</span>';
         } else {
             $return .= '<span class="edit layout-selector-button">View</span>';
         }
         $return .= '<span class="revert layout-selector-button tooltip" title="Resetting a layout will remove all of its blocks&lt;br /&gt;so it inherits the blocks of a parent layout.">Reset</span>';
         $return .= '</span>' . "\n";
         if (is_array($children) && count($children) !== 0) {
             $return .= self::list_pages($children);
         }
         $return .= '</li>' . "\n";
     }
     $return .= '</ul>' . "\n";
     return $return;
 }