コード例 #1
0
 public static function get($layout = false, $option = null, $group_name = false, $default = null)
 {
     //If there's no option to retrieve, then we have nothing to retrieve.
     if ($option === null) {
         return null;
     }
     //If there's no group defined, define it using the default
     if (!$group_name) {
         $group_name = self::$default_group;
     }
     //Make sure there is a layout to use
     if (!$layout) {
         $layout = HeadwayLayout::get_current();
     }
     //Format layout ID
     $layout = self::format_layout_id($layout);
     $options = get_option('headway_layout_options_' . str_replace('-', '_', $layout) . HeadwayOption::$group_suffix);
     if (HeadwayOption::$group_suffix && !$options) {
         $options = get_option('headway_layout_options_' . str_replace('-', '_', $layout));
     }
     //Option does not exist
     if (!$options || !isset($options[$group_name][$option]) || !is_array($options)) {
         return $default;
     }
     //Option exists, let's format it
     $data = headway_fix_data_type($options[$group_name][$option]);
     return $data;
 }
コード例 #2
0
ファイル: slider.php プロジェクト: danaiser/hollandLawns
 function content($block)
 {
     $images = parent::get_setting($block, 'images', array());
     $block_width = HeadwayBlocksData::get_block_width($block);
     $block_height = HeadwayBlocksData::get_block_height($block);
     $has_images = false;
     foreach ($images as $image) {
         if ($image['image']) {
             $has_images = true;
             break;
         }
     }
     if (!$has_images) {
         echo '<div class="alert alert-yellow"><p>There are no images to display.</p></div>';
         return;
     }
     $no_slide_class = count($images) === 1 ? ' flexslider-no-slide' : '';
     echo '<div class="flexslider' . $no_slide_class . '">';
     /* Put in viewport div for sliders that only have 1 image and don't slide */
     if (count($images) === 1) {
         echo '<div class="flex-viewport">';
     }
     echo '<ul class="slides">';
     foreach ($images as $image) {
         if (!$image['image']) {
             continue;
         }
         $output = array('image' => array('src' => parent::get_setting($block, 'crop-resize-images', true) ? headway_resize_image($image['image'], $block_width, $block_height) : $image['image'], 'alt' => headway_fix_data_type(headway_get('image-alt', $image)), 'title' => headway_fix_data_type(headway_get('image-title', $image)), 'caption' => headway_fix_data_type(headway_get('image-description', $image))), 'hyperlink' => array('href' => headway_fix_data_type(headway_get('image-hyperlink', $image)), 'target' => headway_fix_data_type(headway_get('image-open-link-in-new-window', $image, false)) ? ' target="_blank"' : null));
         echo '<li>';
         /* Open hyperlink if user added one for image */
         if ($output['hyperlink']['href']) {
             echo '<a href="' . $output['hyperlink']['href'] . '"' . $output['hyperlink']['target'] . '>';
         }
         /* Don't forget to display the ACTUAL IMAGE */
         echo '<img src="' . $output['image']['src'] . '" alt="' . $output['image']['alt'] . '" title="' . $output['image']['title'] . '" />';
         /* Closing tag for hyperlink */
         if ($output['hyperlink']['href']) {
             echo '</a>';
         }
         /* Caption */
         if (!empty($output['image']['caption'])) {
             echo '<p class="flex-caption">' . $output['image']['caption'] . '</p>';
         }
         echo '</li>';
     }
     echo '</ul>';
     /* Put in viewport div for sliders that only have 1 image and don't slide */
     if (count($images) === 1) {
         echo '</div><!-- .flex-viewport -->';
     }
     echo '</div><!-- .flexslider -->';
 }
コード例 #3
0
 /**
  * Retrieve a value from the database.
  * 
  * @param string Option to retrieve
  * @param string Option group to fetch from
  * @param mixed Default value to be returned.  This will be returned if the requested option does not exist.
  * 
  * @return mixed
  **/
 public static function get($option = null, $group_name = false, $default = null, $main_site = false)
 {
     if ($option === null) {
         return false;
     }
     if (!$group_name) {
         $group_name = self::$default_group;
     }
     $group_data = self::get_group($group_name, $main_site);
     /* If option doesn't exist, return default. */
     if (!isset($group_data[$option])) {
         return $default;
     }
     /* Start formatting if it exists */
     $data = headway_fix_data_type($group_data[$option]);
     return $data;
 }
コード例 #4
0
ファイル: api-block.php プロジェクト: danaiser/hollandLawns
 public function title_and_subtitle($block)
 {
     if (!$this->allow_titles) {
         return;
     }
     /* Output Block Titles */
     if (headway_get('original', $block)) {
         $block = headway_get('original', $block);
     }
     $block_title = headway_get('block-title', headway_get('settings', $block, array()));
     $block_subtitle = headway_get('block-subtitle', headway_get('settings', $block, array()));
     if ($block_title || $block_subtitle) {
         /* Open hgroup if necessary */
         if ($block_title && $block_subtitle) {
             echo '<hgroup>';
         }
         /* Title */
         if ($block_title) {
             echo '<h1 class="block-title">' . headway_fix_data_type($block_title) . '</h1>';
         }
         /* Subtitle */
         if ($block_subtitle) {
             echo '<h2 class="block-subtitle">' . headway_fix_data_type($block_subtitle) . '</h2>';
         }
         /* Close hgroup */
         if ($block_title && $block_subtitle) {
             echo '</hgroup>';
         }
     }
 }
コード例 #5
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 -->';
    }
コード例 #6
0
ファイル: api-panel.php プロジェクト: danaiser/hollandLawns
    public function input_checkbox($input)
    {
        $checked_class = (bool) headway_fix_data_type($input['value']) === true ? ' class="checkbox-checked"' : null;
        echo '
			<div class="input-left">
				<label' . $checked_class . '>' . $input['label'] . '</label>
			</div>
			
			<div class="input-right">
				<span' . $checked_class . '></span>
				<input ' . $input['attributes'] . ' type="hidden" value="' . ((bool) headway_fix_data_type($input['value']) ? 'true' : 'false') . '" />
			</div>
		';
    }
コード例 #7
0
 public static function get_special_element_property($element_id, $se_type, $se_meta, $property_id, $default = null, $element_group = 'blocks')
 {
     $properties = self::get_special_element_properties(array('element' => $element_id, 'se_type' => $se_type, 'se_meta' => $se_meta, 'element_group' => $element_group));
     if ($properties !== null && !is_wp_error($properties) && isset($properties[$property_id]) && (headway_fix_data_type($properties[$property_id]) || headway_fix_data_type($properties[$property_id]) === 0)) {
         return headway_fix_data_type($properties[$property_id]);
     } else {
         return $default;
     }
 }
コード例 #8
0
ファイル: functions.php プロジェクト: danaiser/hollandLawns
/**
 * A simple function to retrieve a key/value pair from the $_GET array or any other user-specified array.  This will automatically return false if the key is not set.
 * 
 * @param string Key to retrieve
 * @param array Optional array to retrieve from.  Default is $_GET
 * 
 * @return mixed
 **/
function headway_get($name, $array = false, $default = null, $fix_data_type = false)
{
    if ($array === false) {
        $array = $_GET;
    }
    if ((is_string($name) || is_numeric($name)) && !is_float($name)) {
        if (is_array($array) && isset($array[$name])) {
            $result = $array[$name];
        } elseif (is_object($array) && isset($array->{$name})) {
            $result = $array->{$name};
        }
    }
    if (!isset($result)) {
        $result = $default;
    }
    return !$fix_data_type ? $result : headway_fix_data_type($result);
}
コード例 #9
0
 public static function method_export_skin()
 {
     Headway::load('data/data-portability');
     $skin_name = headway_get('skin-name', false, 'Unnamed');
     $include_live_css = headway_fix_data_type(headway_get('include-live-css', false, true));
     $included_templates = headway_get('included-templates', false);
     return HeadwayDataPortability::export_skin($skin_name, $include_live_css, $included_templates);
 }