Esempio n. 1
0
 /**
  * Over time, there may be issues to be corrected between updates or naming conventions to be changed between updates.
  * All of that will be processed here.
  **/
 public static function db_upgrade($db_version)
 {
     /* Pre-3.0.3 */
     if (version_compare($db_version, '3.0.3', '<')) {
         self::fix_serialization_in_db();
         self::repair_blocks();
     }
     /**
      * Pre-3.2.3
      * 
      * Change the old wrapper-horizontal-padding and wrapper-vertical-padding to design editor values
      **/
     if (version_compare($db_version, '3.2.3', '<')) {
         $horizontal_padding = HeadwayOption::get('wrapper-horizontal-padding', 'general', 15);
         $vertical_padding = HeadwayOption::get('wrapper-vertical-padding', 'general', 15);
         HeadwayElementsData::set_property('structure', 'wrapper', 'padding-top', $vertical_padding);
         HeadwayElementsData::set_property('structure', 'wrapper', 'padding-bottom', $vertical_padding);
         HeadwayElementsData::set_property('structure', 'wrapper', 'padding-left', $horizontal_padding);
         HeadwayElementsData::set_property('structure', 'wrapper', 'padding-right', $horizontal_padding);
     }
     /**
      * Pre-3.4
      * 
      * - Change block and wrapper margins to Design Editor values
      * - Convert Media blocks to Slider or Embed blocks
      **/
     if (version_compare($db_version, '3.4', '<')) {
         /* Change block and wrapper margins to Design Editor values */
         HeadwayElementsData::set_property('structure', 'wrapper', 'margin-top', HeadwayOption::get('wrapper-top-margin', 'general', 30));
         HeadwayElementsData::set_property('structure', 'wrapper', 'margin-bottom', HeadwayOption::get('wrapper-bottom-margin', 'general', 30));
         HeadwayElementsData::set_property('default-elements', 'default-block', 'margin-bottom', HeadwayOption::get('block-bottom-margin', 'general', 10));
         /* Convert Media blocks to Slider or Embed blocks */
         $media_blocks = HeadwayBlocksData::get_blocks_by_type('media');
         if (is_array($media_blocks) && count($media_blocks)) {
             foreach ($media_blocks as $media_block_id => $media_block_layout_id) {
                 $media_block = HeadwayBlocksData::get_block($media_block_id);
                 $media_block_mode = headway_get('mode', $media_block['settings'], 'embed');
                 switch ($media_block_mode) {
                     case 'embed':
                         HeadwayBlocksData::update_block($media_block['layout'], $media_block['id'], array('type' => 'embed'));
                         break;
                     case 'image-rotator':
                         $slider_images = array();
                         foreach (headway_get('images', $media_block['settings'], array()) as $media_block_image) {
                             $slider_images[] = array('image' => $media_block_image, 'image-description' => null, 'image-hyperlink' => null);
                         }
                         HeadwayBlocksData::update_block($media_block['layout'], $media_block['id'], array('type' => 'slider', 'settings' => array('images' => $slider_images)));
                         break;
                 }
             }
         }
     }
     /* Add action to flush caches */
     do_action('headway_db_upgrade');
     /* Update the version here. */
     $headway_settings = get_option('headway', array('version' => 0));
     $headway_settings['version'] = HEADWAY_VERSION;
     update_option('headway', $headway_settings);
     return true;
 }
Esempio n. 2
0
 public static function cache()
 {
     $raw_webfonts = self::pluck_webfonts(HeadwayElementsData::get_all_elements());
     $sorted_webfonts = array();
     foreach ($raw_webfonts as $webfont) {
         $fragments = explode('|', $webfont);
         $sorted_webfonts[$fragments[0]][] = !empty($fragments[2]) ? $fragments[1] . ':' . $fragments[2] : $fragments[1];
         /* $fragments[2] are the variants */
         $sorted_webfonts[$fragments[0]] = array_unique($sorted_webfonts[$fragments[0]]);
     }
     return HeadwayOption::set('webfont-cache', $sorted_webfonts);
 }
Esempio n. 3
0
 function modify_arguments($args = false)
 {
     /* Grid Settings Defaults */
     $this->inputs['setup']['column-width']['default'] = HeadwayWrappers::$default_column_width;
     $this->inputs['setup']['gutter-width']['default'] = HeadwayWrappers::$default_gutter_width;
     /* End Grid Settings Defaults */
     /* Margins */
     $wrapper_instance_id = $args['wrapper']['id'] . '-layout-' . $args['wrapper']['layout'];
     $this->inputs['setup']['wrapper-margin-top']['value'] = HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'margin-top', HeadwayWrappers::$default_wrapper_margin_top, 'structure');
     $this->inputs['setup']['wrapper-margin-bottom']['value'] = HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'margin-bottom', HeadwayWrappers::$default_wrapper_margin_bottom, 'structure');
     /* End Margins */
 }
Esempio n. 4
0
 public static function format_wrappers_array($wrappers, $layout_id, $include_design_editor_instance = false)
 {
     /* Loop through and run headway_fix_data_type() for each layout */
     foreach ($wrappers as $wrapper_id => $wrapper_settings) {
         /* Use wrapper defaults, then merge in the actual wrapper settings and run fix_data_type on the wrapper settings that way booleans, etc are set correctly */
         $wrappers[$wrapper_id] = array_merge(self::$default_wrappers['wrapper-default'], array_map('headway_fix_data_type', $wrapper_settings));
         /* Add wrapper ID and layout ID to the wrapper settings */
         $wrappers[$wrapper_id]['id'] = $wrapper_id;
         $wrappers[$wrapper_id]['layout'] = $layout_id;
         /* Include Design Editor instance if set to do so */
         if ($include_design_editor_instance) {
             $wrappers[$wrapper_id]['styling'] = HeadwayElementsData::get_special_element_properties(array('element' => 'wrapper', 'se_type' => 'instance', 'se_meta' => $wrapper_id . '-layout-' . $layout_id, 'element_group' => 'structure'));
         }
     }
     return $wrappers;
 }
Esempio n. 5
0
    static function wrapper()
    {
        $layout_id = headway_get('layout-in-use');
        $wrappers = HeadwayWrappers::get_layout_wrappers($layout_id);
        $return = '';
        /* Default Wrapper Margins */
        if (headway_get('file') == 've-iframe-grid-dynamic' && headway_get('visual-editor-open')) {
            $return .= HeadwayElementProperties::output_css('div.wrapper', array('margin-top' => HeadwayElementsData::get_property('wrapper', 'margin-top', HeadwayWrappers::$default_wrapper_margin_top, 'structure'), 'margin-bottom' => HeadwayElementsData::get_property('wrapper', 'margin-bottom', HeadwayWrappers::$default_wrapper_margin_bottom, 'structure'), 'padding-top' => HeadwayElementsData::get_property('wrapper', 'padding-top', null, 'structure'), 'padding-right' => HeadwayElementsData::get_property('wrapper', 'padding-right', null, 'structure'), 'padding-bottom' => HeadwayElementsData::get_property('wrapper', 'padding-bottom', null, 'structure'), 'padding-left' => HeadwayElementsData::get_property('wrapper', 'padding-left', null, 'structure')));
        }
        /* Wrappers for Layout */
        foreach ($wrappers as $wrapper_id => $wrapper_settings) {
            $wrapper_grid_width = HeadwayWrappers::get_grid_width($wrapper_settings);
            /* Set up variables for wrapper */
            $wrapper_selector = 'div#' . $wrapper_id;
            /* Fixed Wrapper */
            if (!$wrapper_settings['fluid']) {
                /* Wrapper */
                $return .= $wrapper_selector . ' {
							width: ' . $wrapper_grid_width . 'px;
						}';
                if (HeadwayResponsiveGrid::is_enabled()) {
                    $return .= $wrapper_selector . '.responsive-grid {
								width: auto !important;
								max-width: ' . $wrapper_grid_width . 'px;
							}';
                }
                /* Grid */
                if (headway_get('file') != 've-iframe-grid-dynamic' || !headway_get('visual-editor-open')) {
                    $return .= HeadwayResponsiveGrid::is_enabled() ? self::responsive_grid($wrapper_settings) : self::fixed_grid($wrapper_settings);
                }
                /* Fluid Wrapper */
            } else {
                /* Grid Container */
                /* Fixed Grid */
                if (!$wrapper_settings['fluid-grid']) {
                    $return .= $wrapper_selector . ' div.grid-container {
									width: ' . $wrapper_grid_width . 'px;
								}';
                    if (HeadwayResponsiveGrid::is_enabled()) {
                        $return .= $wrapper_selector . '.responsive-grid div.grid-container {
										width: auto !important;
										max-width: ' . $wrapper_grid_width . 'px;
									}';
                    }
                }
                /* Grid */
                if (headway_get('file') != 've-iframe-grid-dynamic' || !headway_get('visual-editor-open')) {
                    $return .= HeadwayResponsiveGrid::is_enabled() || $wrapper_settings['fluid-grid'] ? self::responsive_grid($wrapper_settings) : self::fixed_grid($wrapper_settings);
                }
            }
            /* Both Fixed and Fluid: Margin in Grid Mode */
            if (headway_get('file') == 've-iframe-grid-dynamic' && headway_get('visual-editor-open')) {
                $wrapper_instance_id = $wrapper_settings['id'] . '-layout-' . $wrapper_settings['layout'];
                $return .= HeadwayElementProperties::output_css($wrapper_selector, array('margin-top' => HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'margin-top', null, 'structure'), 'margin-bottom' => HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'margin-bottom', null, 'structure'), 'padding-top' => HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'padding-top', null, 'structure'), 'padding-right' => HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'padding-right', null, 'structure'), 'padding-bottom' => HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'padding-bottom', null, 'structure'), 'padding-left' => HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'padding-left', null, 'structure')));
            }
        }
        return $return;
    }
Esempio n. 6
0
    function box($args)
    {
        $defaults = array('group' => null, 'element' => null, 'special_element_type' => false, 'special_element_meta' => false, 'selective_properties' => false, 'property_values' => false, 'property_values_excluding_defaults' => false, 'unsaved_values' => false);
        extract(array_merge($defaults, $args));
        //Format the group name into capitalized and spaced
        $group = ucwords(str_replace('-', ' ', $group));
        //If the group doesn't exist, don't attempt to display it
        if (!($properties = HeadwayElementProperties::get_properties_by_group($group))) {
            return false;
        }
        /* Set up variables */
        $uncustomize_button = '<span class="uncustomize-property tooltip" title="Set the property to inherit."></span>';
        $customize_button = '<div class="customize-property"><span class="tooltip" title="Click to change the value for this property.  If left uncustomized, the property will automatically inherit to the default set for this element type in the defaults tab or the parent element if editing a state, instance, or layout-specific element.">Customize</span></div>';
        $element_selector_attr = isset($element['selector']) ? ' element_selector="' . htmlspecialchars($element['selector']) . '"' : null;
        /* Determine if it's a special element */
        $special_element = !$special_element_type || $special_element_type == 'default' ? false : true;
        /* Custom behaviors for special element types */
        switch ($special_element_type) {
            case 'default':
                $uncustomize_button = null;
                $customize_button = null;
                break;
            case 'instance':
                $instances = headway_get('instances', $element);
                $instance = $instances[$special_element_meta];
                $element_selector_attr = ' element_selector="' . htmlspecialchars($instance['selector']) . '"';
                break;
            case 'state':
                $states = headway_get('states', $element);
                $state = $states[$special_element_meta];
                $element_selector_attr = ' element_selector="' . htmlspecialchars($state['selector']) . '"';
                break;
            case 'layout':
                if (isset($element['selector']) && isset($special_element_meta)) {
                    $element_selector_attr = ' element_selector="' . htmlspecialchars('body.layout-using-' . $special_element_meta . ' ' . $element['selector']) . '"';
                    if ($element['selector'] == 'body') {
                        $element_selector_attr = str_replace(' body', '', $element_selector_attr);
                    }
                }
                break;
        }
        /* Set customized box class flag */
        $customized_box_class = '';
        $property_box_title = '';
        foreach ($property_values_excluding_defaults as $property_id => $property_value) {
            if (!isset($properties[$property_id])) {
                continue;
            }
            $customized_box_class = ' design-editor-box-customized';
            $property_box_title = ' title="' . __('You have customized a property in this property group.', 'headway') . '"';
            break;
        }
        /* Create the box */
        echo '<div class="design-editor-box design-editor-box-' . str_replace(' ', '-', strtolower($group)) . ' design-editor-box-minimized' . $customized_box_class . '">';
        echo '<span class="design-editor-box-title"' . $property_box_title . '>' . $group . '</span>';
        echo '<span class="design-editor-box-toggle"></span>';
        if ($group == 'Rounded Corners' || $group == 'Borders' || $group == 'Padding' || $group == 'Margins') {
            echo '<span class="design-editor-lock-sides" data-locked="false"></span>';
        }
        echo '<ul class="design-editor-box-content">';
        foreach ($properties as $property_id => $options) {
            //If the $selective_properties variable is set, then make sure we're only showing those properties.
            if (is_array($selective_properties)) {
                if (!in_array($property_id, $selective_properties)) {
                    continue;
                }
            }
            //Make sure the input type for the property really exists
            if (!is_callable(array(__CLASS__, 'input_' . str_replace('-', '_', $options['type'])))) {
                continue;
            }
            if (headway_fix_data_type(headway_get($property_id, $property_values)) || headway_fix_data_type(headway_get($property_id, $property_values)) === 0) {
                $options['value'] = $property_values[$property_id];
                $customized = true;
                //If the value isn't set try to get the inherit location value, if not, revert clear back to the default property type value
            } else {
                $property_default = isset($options['default']) ? $options['default'] : null;
                $options['value'] = HeadwayElementsData::get_inherited_property($element['id'], $property_id, $property_default);
                $customized = false;
            }
            $js_callback = htmlspecialchars('
									(function(params){
										' . $options['js-callback'] . '
									})');
            /* Set up attributes */
            $property_title = '';
            $property_classes = array('design-editor-property-' . $property_id);
            if (headway_fix_data_type(headway_get($property_id, $property_values_excluding_defaults)) || headway_fix_data_type(headway_get($property_id, $property_values_excluding_defaults)) === 0) {
                $property_classes[] = 'customized-property-by-user';
                $property_title = ' title="' . __('You have customized this property.', 'headway') . '"';
            } else {
                if (!$customized && $special_element_type !== 'default') {
                    $property_classes[] = 'uncustomized-property';
                }
                if (!$customized && headway_get($property_id, $property_values) === '') {
                    $property_classes[] = 'uncustomized-property-by-user';
                    $property_title = ' title="' . __('You have set this property to inherit.', 'headway') . '"';
                }
            }
            /* add a locked class if it's a lockable element only */
            if ($group == 'Rounded Corners' || $group == 'Padding' || $group == 'Margins' || $property_id == 'border-top-width' || $property_id == 'border-right-width' || $property_id == 'border-bottom-width' || $property_id == 'border-left-width') {
                $property_classes[] = 'lockable';
            }
            if ($property_id == 'border-top-width') {
                echo '<li class="design-property-border-heading"><strong>Border Width</strong></li>';
            }
            echo '<li class="' . implode(' ', array_filter($property_classes)) . '"' . $property_title . '>';
            echo '<strong><span class="property-label">' . $options['name'] . '</span>' . $uncustomize_button . '</strong>';
            echo '<div class="property-' . $options['type'] . ' property">';
            call_user_func(array(__CLASS__, 'input_' . str_replace('-', '_', $options['type'])), $options, $property_id);
            echo '<input ' . $element_selector_attr . ' element="' . $element['id'] . '" property="' . $property_id . '" data-element-group="' . $element['group'] . '" special_element_type="' . $special_element_type . '" special_element_meta="' . $special_element_meta . '" type="hidden" callback="' . $js_callback . '" class="property-hidden-input" value="' . $options['value'] . '" />';
            echo '</div>';
            echo $customize_button;
            echo '</li>';
        }
        echo '</ul><!-- .design-editor-box-content -->';
        echo '</div><!-- .design-editor-box -->';
    }
Esempio n. 7
0
 public static function export_skin($skin_name = 'Unnamed', $include_live_css = false, $included_templates = false)
 {
     do_action('headway_before_export_skin');
     /* Set up variables */
     $element_data = HeadwayElementsData::get_all_elements();
     $skin = array('name' => $skin_name, 'element-data' => $element_data);
     if ($include_live_css) {
         $skin['live-css'] = HeadwayOption::get('live-css');
     }
     /* If templates are to be included then query for them and convert all mirrored blocks into original blocks by pulling their mirror target's settings */
     if (is_array($included_templates)) {
         $skin['templates'] = array();
         $white_listed_block_instances = array();
         $white_listed_wrapper_instances = array();
         foreach ($included_templates as $template_id) {
             $template_name = HeadwayLayout::get_name('template-' . $template_id);
             $template_blocks = HeadwayBlocksData::get_blocks_by_layout('template-' . $template_id);
             $template_wrappers = HeadwayWrappers::get_layout_wrappers('template-' . $template_id);
             /* Loop through each block in the template and check if it's mirrored.  If it is, replace it with the block that it's mirroring */
             foreach ($template_blocks as $template_block_index => $template_block) {
                 if (!($mirrored_block = HeadwayBlocksData::is_block_mirrored($template_block))) {
                     /* Allow this block's instances to be in the skin */
                     $white_listed_block_instances[] = $template_block['id'];
                     /* Delete mirror option in case it's present */
                     if (isset($template_blocks[$template_block_index]['settings']['mirror-block'])) {
                         unset($template_blocks[$template_block_index]['settings']['mirror-block']);
                     }
                     continue;
                 }
                 $template_blocks[$template_block_index]['id'] = $mirrored_block['id'];
                 $template_blocks[$template_block_index]['settings'] = $mirrored_block['settings'];
                 /* Allow this block's instances to be in the skin */
                 $white_listed_block_instances[] = $mirrored_block['id'];
             }
             /* Whitelist wrapper instances */
             foreach ($template_wrappers as $template_wrapper_id => $template_wrapper_settings) {
                 $white_listed_wrapper_instances[] = $template_wrapper_id;
             }
             $skin['templates'][$template_name] = $template_blocks;
             $skin['templates'][$template_name]['wrappers'] = $template_wrappers;
         }
     }
     /* Need to remove instances that aren't in the included templates and layout specific customizations from $element_data here */
     foreach ($skin['element-data'] as $element_id => $element) {
         /* Add in the element group that way it can be saved @since 3.4.8 */
         $element_registration = HeadwayElementAPI::get_element($element_id);
         $skin['element-data'][$element_id]['group'] = $element_registration['group'];
         /* Remove instances that aren't in this skin's templates */
         if (isset($element['special-element-instance'])) {
             /* White list doesn't exist, just remove all instances */
             if (!isset($white_listed_block_instances)) {
                 unset($skin['element-data'][$element_id]['special-element-instance']);
                 /* White List Exists, loop through each instance and check its ID */
             } else {
                 foreach ($skin['element-data'][$element_id]['special-element-instance'] as $instance_id => $properties) {
                     $instance_id_fragments = explode('-', $instance_id);
                     $instance_potential_block_id_search = preg_match('/\\bblock\\b\\-[0-9]+/', $instance_id, $instance_potential_block_id_search_results);
                     $instance_potential_block_id = str_replace('block-', '', end($instance_potential_block_id_search_results));
                     $instance_potential_wrapper_id = $instance_id_fragments[0] . '-' . $instance_id_fragments[1];
                     /* Wrapper instance conditional.  If a positive match, CONTINUE that way the unset doesn't happen */
                     if (strpos($instance_id, 'wrapper-') === 0 && in_array($instance_potential_wrapper_id, $white_listed_wrapper_instances)) {
                         continue;
                     } else {
                         if (strpos($instance_id, 'block-') !== false && is_numeric($instance_potential_block_id) && in_array($instance_potential_block_id, $white_listed_block_instances)) {
                             continue;
                         }
                     }
                     /* Delete the instance if it doesn't match the block OR wrapper whitelist */
                     unset($skin['element-data'][$element_id]['special-element-instance'][$instance_id]);
                 }
             }
         }
         /* Remove layout-specific customizations from the skin */
         if (isset($element['special-element-layout'])) {
             unset($skin['element-data'][$element_id]['special-element-layout']);
         }
     }
     /* Spit the file out */
     return self::to_json('Headway Skin - ' . $skin_name, 'skin', $skin);
 }
Esempio n. 8
0
 public static function save($options, $current_layout = false, $mode = false)
 {
     if (!$current_layout) {
         $current_layout = headway_post('layout');
     }
     if (!$mode) {
         $mode = headway_post('mode');
     }
     //Handle triple slash bullshit
     if (get_magic_quotes_gpc() === 1) {
         $options = array_map('stripslashes_deep', $options);
     }
     $blocks = isset($options['blocks']) ? $options['blocks'] : null;
     $wrappers = isset($options['wrappers']) ? $options['wrappers'] : null;
     $layout_options = isset($options['layout-options']) ? $options['layout-options'] : null;
     $options_inputs = isset($options['options']) ? $options['options'] : null;
     $design_editor_inputs = isset($options['design-editor']) ? $options['design-editor'] : null;
     //Set the current layout to customized if it's the grid mode
     if ($mode == 'grid') {
         HeadwayLayoutOption::set($current_layout, 'customized', true);
     }
     /* Blocks */
     if ($blocks) {
         foreach ($blocks as $id => $methods) {
             foreach ($methods as $method => $value) {
                 switch ($method) {
                     case 'new':
                         if (HeadwayBlocksData::get_block($id)) {
                             continue;
                         }
                         $dimensions = explode(',', $blocks[$id]['dimensions']);
                         $position = explode(',', $blocks[$id]['position']);
                         $settings = isset($blocks[$id]['settings']) ? $blocks[$id]['settings'] : array();
                         $args = array('id' => $id, 'type' => $value, 'position' => array('left' => $position[0], 'top' => $position[1]), 'dimensions' => array('width' => $dimensions[0], 'height' => $dimensions[1]), 'settings' => $settings);
                         HeadwayBlocksData::add_block($current_layout, $args);
                         break;
                     case 'delete':
                         HeadwayBlocksData::delete_block($current_layout, $id);
                         break;
                     case 'dimensions':
                         $dimensions = explode(',', $value);
                         $args = array('dimensions' => array('width' => $dimensions[0], 'height' => $dimensions[1]));
                         HeadwayBlocksData::update_block($current_layout, $id, $args);
                         break;
                     case 'position':
                         $position = explode(',', $value);
                         $args = array('position' => array('left' => $position[0], 'top' => $position[1]));
                         HeadwayBlocksData::update_block($current_layout, $id, $args);
                         break;
                     case 'wrapper':
                         $args = array('wrapper' => $value);
                         HeadwayBlocksData::update_block($current_layout, $id, $args);
                         break;
                     case 'settings':
                         //Retrieve all blocks from layout
                         $layout_blocks = HeadwayBlocksData::get_blocks_by_layout($current_layout);
                         //Get the block from the layout
                         $block = headway_get($id, $layout_blocks);
                         //If block doesn't exist, we can't do anything.
                         if (!$block) {
                             continue;
                         }
                         //If there aren't any options, then don't do anything either
                         if (!is_array($value) || count($value) === 0) {
                             continue;
                         }
                         $block['settings'] = array_merge($block['settings'], $value);
                         HeadwayBlocksData::update_block($current_layout, $id, $block);
                         break;
                 }
             }
         }
     }
     /* End Blocks */
     /* Wrappers */
     if ($wrappers) {
         /* Pluck last-id out of wrappers and send it to DB */
         if (headway_get('last-id', $wrappers)) {
             $last_id = $wrappers['last-id'];
             unset($wrappers['last-id']);
             HeadwayOption::set('last-id', $last_id, 'wrappers');
         }
         /* Save layout wrappers to dB */
         HeadwayOption::set($current_layout, $wrappers, 'wrappers');
     }
     /* End Wrappers */
     /* Layout Options */
     if ($layout_options) {
         foreach ($layout_options as $group => $options) {
             foreach ($options as $option => $value) {
                 HeadwayLayoutOption::set($current_layout, $option, $value, $group);
             }
         }
     }
     /* End Layout Options */
     /* Options */
     if ($options_inputs) {
         foreach ($options_inputs as $group => $options) {
             foreach ($options as $option => $value) {
                 HeadwayOption::set($option, $value, $group);
             }
         }
     }
     /* End Options */
     /* Design Editor Inputs */
     if ($design_editor_inputs) {
         /* If skin import is set to true then nuke all design settings to prevent overlapping settings */
         if (headway_get('skin-import', $design_editor_inputs)) {
             HeadwayElementsData::delete_all();
         }
         /* End skin import nuke */
         /* Handle skin templates */
         $skin_templates = headway_get('skin-import-templates', $design_editor_inputs);
         if (is_array($skin_templates) && count($skin_templates)) {
             $skin_template_block_id_translations = array();
             $skin_template_wrapper_id_translations = array();
             foreach ($skin_templates as $skin_template_name => $skin_template_blocks) {
                 /* Pluck wrappers array out of blocks array */
                 $skin_template_wrappers = $skin_template_blocks['wrappers'];
                 unset($skin_template_blocks['wrappers']);
                 $template = HeadwayLayout::add_template($skin_template_name, $skin_template_blocks, $skin_template_wrappers);
                 /* Use + rather than array_merge because + preserves numeric keys */
                 $skin_template_block_id_translations = $skin_template_block_id_translations + $template['block-id-translations'];
                 $skin_template_wrapper_id_translations = $skin_template_wrapper_id_translations + $template['wrapper-id-translations'];
             }
             /* Re-map block IDs in instances according to block ID translations */
             foreach ($design_editor_inputs as $element_id => $element_data) {
                 if (!is_array($element_data) || !isset($element_data['special-element-instance'])) {
                     continue;
                 }
                 foreach ($element_data['special-element-instance'] as $instance_id => $instance_properties) {
                     $instance_id_fragments = explode('-', $instance_id);
                     $instance_potential_block_id_search = preg_match('/\\bblock\\b\\-[0-9]+/', $instance_id, $instance_potential_block_id_search_results);
                     $instance_potential_block_id = str_replace('block-', '', end($instance_potential_block_id_search_results));
                     $instance_potential_wrapper_id = $instance_id_fragments[1];
                     /* Wrapper instance conditional. Modify new instance ID accordingly */
                     if (strpos($instance_id, 'wrapper-') === 0 && isset($skin_template_wrapper_id_translations[intval($instance_potential_wrapper_id)])) {
                         $new_wrapper_id = $skin_template_wrapper_id_translations[intval($instance_potential_wrapper_id)]['id'];
                         $new_wrapper_layout = $skin_template_wrapper_id_translations[intval($instance_potential_wrapper_id)]['layout'];
                         $new_instance_id = 'wrapper-' . $new_wrapper_id . '-layout-' . $new_wrapper_layout;
                         /* Block instance conditional.  Modify new instance ID accordingly */
                     } else {
                         if (strpos($instance_id, 'block-') !== false && is_numeric($instance_potential_block_id) && isset($skin_template_block_id_translations[intval($instance_potential_block_id)])) {
                             $new_block_id = $skin_template_block_id_translations[intval($instance_potential_block_id)];
                             $new_instance_id = str_replace('block-' . $instance_potential_block_id, 'block-' . $new_block_id, $instance_id);
                             /* Not a proper block or wrapper instance, just skip it */
                         } else {
                             continue;
                         }
                     }
                     /* Remove existing instance key/value pair */
                     unset($design_editor_inputs[$element_id]['special-element-instance'][$instance_id]);
                     /* Add new instance key/value pair with new instance ID */
                     $design_editor_inputs[$element_id]['special-element-instance'][$new_instance_id] = $instance_properties;
                 }
             }
         }
         /* End skin template handling */
         /* Loop through to get every element and its properties */
         foreach ($design_editor_inputs as $element_id => $element_data) {
             if (!is_array($element_data) || !isset($element_data['group'])) {
                 continue;
             }
             $element_group = $element_data['group'];
             //Dispatch depending on type of element data
             foreach ($element_data as $element_data_node => $element_data_node_data) {
                 //Handle different nodes depending on what they are
                 if ($element_data_node == 'properties') {
                     //Set each property for the regular element
                     foreach ($element_data_node_data as $property_id => $property_value) {
                         HeadwayElementsData::set_property($element_group, $element_id, $property_id, $property_value);
                     }
                     //Handle instances, states, etc.
                 } else {
                     if (strpos($element_data_node, 'special-element-') === 0) {
                         $special_element_type = str_replace('special-element-', '', $element_data_node);
                         //Loop through the special elements
                         foreach ($element_data_node_data as $special_element => $special_element_properties) {
                             //Set the special element properties now
                             foreach ($special_element_properties as $special_element_property => $special_element_property_value) {
                                 HeadwayElementsData::set_special_element_property($element_group, $element_id, $special_element_type, $special_element, $special_element_property, $special_element_property_value);
                             }
                         }
                     }
                 }
             }
         }
         /* End loop */
     }
     /* End Design Editor Inputs */
     //This hook is used by cache flushing, plugins, etc.  Do not fire on preview save because it'll flush preview options
     if (!headway_get('ve-preview')) {
         do_action('headway_visual_editor_save');
     }
     return true;
 }
Esempio n. 9
0
function headway_content_block_editor_style()
{
    $body_bg = HeadwayElementsData::get_property('block-content-entry-container', 'background-color', 'ffffff');
    $body_color = HeadwayElementsData::get_property('block-content-entry-content', 'color', '333333');
    $body_font_family = HeadwayElementsData::get_property('block-content-entry-content', 'font-family', 'helvetica, sans-serif');
    $body_font_size = HeadwayElementsData::get_property('block-content-entry-content', 'font-size', '13');
    $body_line_height = HeadwayElementsData::get_property('block-content-entry-content', 'line-height', '180');
    if (!($body_hyperlink_color = HeadwayElementsData::get_property('block-content-entry-content-hyperlinks', 'color', null))) {
        $body_hyperlink_color = $body_color;
    }
    return '
		* {
			font-size: ' . $body_font_size . 'px;
			font-family: ' . $body_font_family . ';
			font-style: inherit;
			font-weight: inherit;
			line-height: ' . $body_line_height . '%;
			color: inherit;
		}
		body {
			background: #' . $body_bg . ';
			color: #' . $body_color . ';
			font-size: ' . $body_font_size . 'px;
			font-family: ' . $body_font_family . ';
			line-height: ' . $body_line_height . '%;
		}

		/* Headings */
		h1,h2,h3,h4,h5,h6 {
			clear: both;
		}
		h1,
		h2 {
			color: #000;
			font-size: 15px;
			font-weight: bold;
			margin: 0 0 20px;
		}
		h3, h4, h5, h6 {
			font-size: 10px;
			letter-spacing: 0.1em;
			line-height: 2.6em;
			text-transform: uppercase;
			margin: 0 0 15px;
		}
		hr {
			background-color: #ccc;
			border: 0;
			height: 1px;
			margin: 0 0 15px;
		}

		/* Text elements */
		p {
			margin: 0 0 15px;
		}
		
		/* Lists */
		ul, ol {
			padding: 0 0 0 40px;
			margin: 15px 0;
		}
		
		ul ul, ol ol { margin: 0; } /* Lists inside lists should not have the margin on them. */	

	    ul li { list-style: disc; }
	    ul ul li { list-style: circle; }
	    ul ul ul li { list-style: square; }
	    
	    ol li { list-style: decimal; }
	    ol ol li { list-style: lower-alpha; }
	    ol ol ol li { list-style: lower-roman; }
		
		strong {
			font-weight: bold;
		}
		cite, em, i {
			font-style: italic;
		}
		cite {
			border: none;
		}
		pre {
			background: #f4f4f4;
			font: 13px "Courier 10 Pitch", Courier, monospace;
			line-height: 1.5;
			margin-bottom: 1.625em;
			padding: 0.75em 1.625em;
		}
		code {
			font: 13px Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
		}
		abbr, acronym {
			border-bottom: 1px dotted #666;
			cursor: help;
		}

		/* Links */
		a,
		a em,
		a strong {
			color: #' . $body_hyperlink_color . ';
			text-decoration: underline;
			cursor: pointer;
		}
		a:focus,
		a:active,
		a:hover {
			text-decoration: none;
		}

		/* Alignment */
		.alignleft {
			display: inline;
			float: left;
			margin-right: 1.625em;
		}
		.alignright {
			display: inline;
			float: right;
			margin-left: 1.625em;
		}
		.aligncenter {
			clear: both;
			display: block;
			margin-left: auto;
			margin-right: auto;
		}';
}
Esempio n. 10
0
 public static function method_get_design_editor_elements()
 {
     $current_layout = headway_post('layout');
     $all_elements = HeadwayElementAPI::get_all_elements();
     $groups = HeadwayElementAPI::get_groups();
     $customized_element_data = HeadwayElementsData::get_all_elements(true);
     $elements = array();
     /* Assemble the arrays */
     foreach ($all_elements as $group_id => $main_elements) {
         $elements[$group_id] = array();
         /* Loop through main elements */
         foreach ($main_elements as $main_element_id => $main_element_settings) {
             /* Handle main element */
             $inherit_location = HeadwayElementAPI::get_element(HeadwayElementAPI::get_inherit_location($main_element_id));
             $elements[$group_id][$main_element_id] = array('selector' => $main_element_settings['selector'], 'id' => $main_element_settings['id'], 'name' => $main_element_settings['name'], 'description' => headway_get('description', $main_element_settings), 'properties' => $main_element_settings['properties'], 'group' => $group_id, 'groupName' => headway_get($group_id, $groups), 'states' => headway_get('states', $main_element_settings, array()), 'instances' => headway_get('instances', $main_element_settings, array()), 'inherit-location' => headway_get('id', $inherit_location), 'inherit-location-name' => headway_get('name', $inherit_location), 'disallow-nudging' => headway_get('disallow-nudging', $main_element_settings, false), 'indent-in-selector' => headway_get('indent-in-selector', $main_element_settings, false), 'customized' => isset($customized_element_data[$main_element_settings['id']]) ? true : false, 'children' => array());
             /* Loop through main element instances and add customized flag if necessary */
             foreach ($elements[$group_id][$main_element_id]['instances'] as $main_element_instance_id => $main_element_instance_settings) {
                 if (isset($customized_element_data[$main_element_settings['id']]['special-element-instance'][$main_element_instance_id])) {
                     $elements[$group_id][$main_element_id]['instances'][$main_element_instance_id]['customized'] = true;
                 }
             }
             /* Loop through element children */
             foreach (headway_get('children', $main_element_settings, array()) as $child_element_id => $child_element_settings) {
                 /* Handle child element */
                 $inherit_location = HeadwayElementAPI::get_element(HeadwayElementAPI::get_inherit_location($child_element_id));
                 $elements[$group_id][$main_element_id]['children'][$child_element_id] = array('selector' => $child_element_settings['selector'], 'id' => $child_element_settings['id'], 'name' => $child_element_settings['name'], 'description' => headway_get('description', $child_element_settings), 'properties' => $child_element_settings['properties'], 'group' => $group_id, 'groupName' => headway_get($group_id, $groups), 'parent' => $main_element_id, 'parentName' => headway_get('name', $main_element_settings), 'states' => headway_get('states', $child_element_settings, array()), 'instances' => headway_get('instances', $child_element_settings, array()), 'indent-in-selector' => headway_get('indent-in-selector', $child_element_settings, false), 'inherit-location' => headway_get('id', $inherit_location), 'inherit-location-name' => headway_get('name', $inherit_location), 'disallow-nudging' => headway_get('disallow-nudging', $child_element_settings, false), 'customized' => isset($customized_element_data[$child_element_settings['id']]) ? true : false);
                 /* Loop through sub element instances and add customized flag if necessary */
                 foreach ($elements[$group_id][$main_element_id]['children'][$child_element_id]['instances'] as $sub_element_instance_id => $sub_element_instance_settings) {
                     if (isset($customized_element_data[$child_element_settings['id']]['special-element-instance'][$sub_element_instance_id])) {
                         $elements[$group_id][$main_element_id]['children'][$child_element_id]['instances'][$sub_element_instance_id]['customized'] = true;
                     }
                 }
             }
         }
     }
     /* Spit it all out */
     self::json_encode($elements);
 }