Ejemplo n.º 1
0
    public static function create_holder($args)
    {
        $c = 0;
        $out = "";
        $section = "";
        $html = "";
        if (count($args) < 10) {
            $merge_all_fields = true;
            $no_sections = "wpi_no_sections";
        } else {
            $merge_all_fields = false;
            $no_sections = "";
        }
        foreach ($args as $arg) {
            if ($merge_all_fields == true) {
                $section_name = 'settings';
                $arg['group'] = 'no_group';
            } else {
                if (isset($arg['section']) && $arg['section'] != "" && isset($arg['name']) && $arg['name'] != "") {
                    $section_name = $arg['section'];
                } else {
                    $section_name = 'settings';
                }
            }
            $sections[$section_name]['backup'][] = $arg;
        }
        foreach ($sections as $key => $section) {
            foreach ($section['backup'] as $data) {
                if (isset($data['group']) && $data['group'] != "") {
                    $group_name = $data['group'];
                } else {
                    $group_name = 'no_group';
                }
                $sections[$key][$group_name][] = $data;
            }
            unset($sections[$key]['backup']);
        }
        $header = '
		<div class="wpi_header">
			<span class="wpi_menu genericon genericon-menu">
			  <div class="wpi_back genericon genericon-previous"></div>      
			</span>
			<span class="wpi_heading">Settings</span>
		  </div><!-- header--> ';
        if ($merge_all_fields == false) {
            $sec = '<div class="wpi_sections">';
            foreach ($sections as $key => $section) {
                $sec .= '<div class="wpi_section" data-target_id="' . sanitize_title($key) . '" data-target="' . $key . '">' . $key . '<div class="wpi_open genericon genericon-next"></div></div>';
            }
            $sec .= '</div><!-- sections-->';
        } else {
            $sec = "";
        }
        $c = 0;
        $sections_content = '<div class="wpi_sections_content">';
        foreach ($sections as $key => $section) {
            if ($c == 0) {
                $visible = "";
            } else {
                $visible = "wpi_none";
            }
            $c++;
            if (count($section) <= 1) {
                $disable_accordion = "wpi_disable_accordion";
            } else {
                $disable_accordion = "";
            }
            $sections_content .= '<div class="wpi_section_content ' . $visible . ' " id="' . sanitize_title($key) . '">';
            $sections_content .= '<div class="wpiAccordion ' . $disable_accordion . '">';
            foreach ($section as $group_key => $group) {
                $sections_content .= '<li>';
                if ($group_key == "no_group") {
                    $sections_content .= '<h3>All<i class="genericon genericon-next"></i></h3>';
                } else {
                    $sections_content .= '<h3>' . $group_key . ' <i class="genericon genericon-next"></i></h3>';
                }
                $sections_content .= '<div class="wpi_accordion_content">';
                foreach ($group as $data) {
                    $defaults = array("name" => "", "label" => "", "type" => "text", "value" => "", "list" => array(0), "default" => "", "global_enabled" => "");
                    extract(wp_parse_args($data, $defaults));
                    if ($global_enabled != "") {
                        $is_enabled = get_option("wpi_admin_" . "global_settings_" . $global_enabled);
                        if (!$is_enabled) {
                            $type = "hidden";
                        }
                    }
                    if ($type == "text") {
                        $input = WPiControls::text(array("name" => $name, "value" => $value, "default" => $default));
                    } else {
                        if ($type == "textarea") {
                            $input = WPiControls::textarea(array("name" => $name, "value" => $value, "default" => $default));
                        } else {
                            if ($type == "link") {
                                $input = WPiControls::link(array("name" => $name, "value" => $value));
                            } else {
                                if ($type == "hidden") {
                                    $input = WPiControls::hidden(array("name" => $name, "value" => $value));
                                } else {
                                    if ($type == "button") {
                                        $input = WPiControls::button(array("name" => $name, "value" => $value));
                                    } else {
                                        if ($type == "wp_image") {
                                            $input = WPiControls::wp_image(array("name" => $name, "value" => $value));
                                        } else {
                                            if ($type == "select") {
                                                $input = WPiControls::select(array("name" => $name, "value" => $value, "list" => $list, "default" => $default));
                                            } else {
                                                if ($type == "boolean") {
                                                    $input = WPiControls::boolean(array("name" => $name, "value" => $value, "list" => $list));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($type != "hidden") {
                        $sections_content .= '<div class="label">' . $label . '</div>';
                    }
                    $sections_content .= '<div class="input">' . $input . '</div>';
                }
                $sections_content .= '</div><!-- accordion_content-->';
                $sections_content .= '</li>';
            }
            $sections_content .= '</div><!-- wpiAccordion-->';
            $sections_content .= '</div><!-- section content-->';
        }
        $sections_content .= '</div><!-- sections content-->';
        $html .= '<div  class="wpiHolder ' . $no_sections . '">';
        $html .= $header;
        $html .= '<div class="wpi_content"><div class="wpi_content_holder">';
        $html .= $sec;
        $html .= $sections_content;
        $html .= "</div><!-- content holder--></div><!-- content-->";
        $html .= "</div><!-- wpiHolder-->";
        $sample = '<div class="wpiHolder">
		  <div class="wpi_header">
			<span class="wpi_menu genericon genericon-menu">
			  <div class="wpi_back genericon genericon-previous"></div>      
			</span>
			<span class="wpi_heading">Settings</span>
		  </div><!-- header-->  
		  <div class="wpi_content">
			<div class="wpi_content_holder">
			  <div class="wpi_sections">
				<div class="wpi_section" data-target_id="heading_settings" data-target="Heading settings">Slide Heading </div>
				<div class="wpi_section" data-target_id="text_settings" data-target="Text settings">Slide Text</div>
			  </div><!-- sections-->
			  <div class="wpi_sections_content">
				<div class="wpi_section_content" id="heading_settings">
				  <div class="label">Heading</div>
				  <div class="input"><input type="text" value="heading"/></div>
				</div><!-- section content-->
				<div class="wpi_section_content" id="text_settings">
				  <div class="label">Text</div>
				  <div class="input"><input type="text" value="text"/></div>
				</div><!-- section content-->
			  </div><!-- sections content-->
			</div><!-- content holder-->
		  </div><!-- content-->
		</div><!-- wpiHolder-->';
        return $html;
    }
Ejemplo n.º 2
0
    public static function html($post_id, $args = array())
    {
        $sec_alt = 0;
        $c = 0;
        $out = "";
        $section = "";
        $html = "";
        $ss = array();
        foreach ($args as $arg) {
            if (isset($arg['section']) && $arg['section'] != "" && isset($arg['name']) && $arg['name'] != "") {
                $section_name = $arg['section'];
            } else {
                $section_name = 'settings';
            }
            $sections[$section_name]['backup'][] = $arg;
        }
        foreach ($sections as $key => $section) {
            foreach ($section['backup'] as $data) {
                if (isset($data['group']) && $data['group'] != "") {
                    $group_name = $data['group'];
                } else {
                    $group_name = 'no_group';
                }
                $sections[$key][$group_name][] = $data;
            }
            unset($sections[$key]['backup']);
        }
        $header = '
		<div class="wpi_header">
			<span class="wpi_menu genericon genericon-menu">
			  <div class="wpi_back genericon genericon-previous"></div>      
			</span>
			<span class="wpi_heading">Settings</span>
		  </div><!-- header--> ';
        $sec = '<div class="wpi_sections">';
        foreach ($sections as $key => $section) {
            $sec .= '<div class="wpi_section" data-target_id="' . sanitize_title($key) . '" data-target="' . $key . '">' . $key . '<div class="wpi_open genericon genericon-next"></div></div>';
        }
        $sec .= '</div><!-- sections-->';
        $c = 0;
        $sections_content = '<div class="wpi_sections_content">';
        foreach ($sections as $key => $section) {
            if ($c == 0) {
                $visible = "";
            } else {
                $visible = "wpi_none";
            }
            $c++;
            $sections_content .= '<div class="wpi_section_content ' . $visible . '" id="' . sanitize_title($key) . '">';
            $sections_content .= '<div class="wpiAccordion">';
            foreach ($section as $group_key => $group) {
                $sections_content .= '<li>';
                if ($group_key == "no_group") {
                    $sections_content .= '<h3>All<i class="genericon genericon-next"></i></h3>';
                } else {
                    $sections_content .= '<h3>' . $group_key . ' <i class="genericon genericon-next"></i></h3>';
                }
                $sections_content .= '<div class="wpi_accordion_content">';
                foreach ($group as $data) {
                    $data['value'] = WPiData::get_post_meta($post_id, $data['name']);
                    if ($data['type'] == "text") {
                        $input = WPiControls::text(array("name" => $data['name'], "value" => $data['value']));
                    } else {
                        if ($data['type'] == "textarea") {
                            $input = WPiControls::textarea(array("name" => $data['name'], "value" => $data['value']));
                        } else {
                            if ($data['type'] == "hidden") {
                                $input = WPiControls::hidden(array("name" => $data['name'], "value" => $data['value']));
                            } else {
                                if ($data['type'] == "button") {
                                    $input = WPiControls::button(array("name" => $data['name'], "value" => $data['value']));
                                } else {
                                    if ($data['type'] == "wp_image") {
                                        $input = WPiControls::wp_image(array("name" => $data['name'], "value" => $data['value']));
                                    } else {
                                        if ($data['type'] == "select") {
                                            $input = WPiControls::select(array("name" => $data['name'], "value" => $data['value'], "list" => $data['list']));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($data['type'] != "hidden") {
                        $sections_content .= '<div class="label">' . $data['label'] . '</div>';
                    }
                    $sections_content .= '<div class="input">' . $input . '</div>';
                }
                $sections_content .= '</div><!-- accordion_content-->';
                $sections_content .= '</li>';
            }
            $sections_content .= '</div><!-- wpiAccordion-->';
            $sections_content .= '</div><!-- section content-->';
        }
        $sections_content .= '</div><!-- sections content-->';
        $html .= '<div  class="wpiHolder">';
        $html .= $header;
        $html .= '<div class="wpi_content"><div class="wpi_content_holder">';
        $html .= $sec;
        $html .= $sections_content;
        $html .= "</div><!-- content holder--></div><!-- content-->";
        $html .= "</div><!-- wpiHolder-->";
        $sample = '<div class="wpiHolder">
		  <div class="wpi_header">
			<span class="wpi_menu genericon genericon-menu">
			  <div class="wpi_back genericon genericon-previous"></div>      
			</span>
			<span class="wpi_heading">Settings</span>
		  </div><!-- header-->  
		  <div class="wpi_content">
			<div class="wpi_content_holder">
			  <div class="wpi_sections">
				<div class="wpi_section" data-target_id="heading_settings" data-target="Heading settings">Slide Heading </div>
				<div class="wpi_section" data-target_id="text_settings" data-target="Text settings">Slide Text</div>
			  </div><!-- sections-->
			  <div class="wpi_sections_content">
				<div class="wpi_section_content" id="heading_settings">
				  <div class="label">Heading</div>
				  <div class="input"><input type="text" value="heading"/></div>
				</div><!-- section content-->
				<div class="wpi_section_content" id="text_settings">
				  <div class="label">Text</div>
				  <div class="input"><input type="text" value="text"/></div>
				</div><!-- section content-->
			  </div><!-- sections content-->
			</div><!-- content holder-->
		  </div><!-- content-->
		</div><!-- wpiHolder-->';
        return $html;
        //$out=print_r($sections,true);
        //return $out;
    }