Ejemplo n.º 1
0
 function parse($data)
 {
     $this->clear();
     $struct = $this->struct;
     $this->data = $data;
     if (isset($data["settings"])) {
         $settings = $data["settings"];
         $this->important = isset($settings["important"]) ? $settings["important"] : false;
         unset($this->data["settings"]);
     }
     $elements = array_shift($struct);
     // first element is a 'stub' root.
     foreach ($elements as $el => $el_data) {
         $this->parse_part($el, $el_data);
     }
     $this->parse_responsive();
     maxUtils::startTime('compile CSS');
     $css = $this->compile($this->output_css);
     maxUtils::endTime('compile CSS');
     return $css;
 }
Ejemplo n.º 2
0
 public function display($args = array())
 {
     maxUtils::startTime('button-display-' . $this->id);
     $defaults = array("mode" => 'normal', "preview_part" => "full", "echo" => true, "load_css" => "footer", "compile" => false);
     $output = '';
     // init output;
     $args = wp_parse_args($args, $defaults);
     $cssParser = $this->getCSSParser();
     // init parser
     $this->load_css = $args["load_css"];
     if ($this->id == 0) {
         if (!$args["mode"] == 'editor') {
             return;
         }
         $data = apply_filters("mb-save-fields", array(), array());
         // load defaults
         $data["id"] = 0;
         do_action('mb-data-load', $data);
     }
     $mode = isset($args["mode"]) ? $args["mode"] : "normal";
     switch ($mode) {
         case "preview":
             $preview = true;
             $compile = false;
             break;
         case "editor":
             $preview = true;
             $compile = true;
             // editor is both compile and preview.
             break;
             break;
         case "normal":
             $preview = false;
             $compile = false;
             break;
     }
     if ($this->load_css == "element" || $args["preview_part"] != "full" || $args["compile"] == true) {
         // if css output is on element, for to compile - otherwise inline styles will not be loaded.
         $compile = true;
     } else {
         $compile = false;
     }
     // create button
     //maxUtils::startTime('button-parse-button-'. $this->id);
     $domObj = $this->parse_button($mode);
     //maxUtils::endTime('button-parse-button-' . $this->id);
     maxUtils::startTime('button-parse-css-' . $this->id);
     $this->parse_css($mode, $compile);
     maxUtils::endTime('button-parse-css-' . $this->id);
     if (!$preview) {
         // no js on previews
         $this->parse_js($mode);
     }
     if ($preview) {
         $domObj->find('a', 0)->class .= ' maxbutton-preview';
     }
     if ($preview && $args["preview_part"] != 'full') {
         if ($args["preview_part"] != 'normal') {
             $domObj->find('a', 0)->class .= ' hover';
             $domObj = $cssParser->outputInline($domObj, 'hover');
         } else {
             $domObj->find('a', 0)->class .= ' normal';
             $domObj = $cssParser->outputInline($domObj);
         }
     } elseif ($this->load_css == 'footer') {
         $css = $this->display_css(false, false);
         do_action('mb-footer', $this->id, $css);
         if (!$preview) {
             $js = $this->display_js(false, true);
             do_action('mb-footer', $this->document_id, $js, 'js');
         }
     } elseif ($this->load_css == 'inline') {
         if ($args["echo"]) {
             $this->display_css();
         } else {
             $output .= $this->display_css(false);
         }
     } elseif ($this->load_css == 'element') {
         $domObj->find('a', 0)->class .= ' normal';
         $domObj = $this->cssParser->outputInline($domObj);
         //$this->get_element_css($domObj, 'normal');
     }
     $output .= $domObj->save();
     $output = apply_filters('mb-before-button-output', $output);
     maxButtons::buttonDone(array("button_id" => $this->id, "document_id" => $this->document_id));
     maxUtils::endTime('button-display-' . $this->id);
     if ($args["echo"]) {
         echo $output;
     } else {
         return $output;
     }
 }
Ejemplo n.º 3
0
 function parse($args)
 {
     $preview = isset($args["preview"]) ? $args["preview"] : false;
     $domObj = new simple_html_dom();
     $collection_id = $this->collection_id;
     $node = "<div class='maxcollection maxcollection-" . $collection_id . "' data-collection='" . $collection_id . "'>\n\t\t\t\t\t   </div>";
     $node = apply_filters("mb-col-basic-container", $node);
     $domObj->load($node);
     // use picker to get button classes in array
     $picker = $this->getBlock("picker");
     $this->buttons = $picker->getButtons();
     // changes to buttons in this function
     maxUtils::startTime('collection-parse-parsebuttons');
     foreach ($this->blocks as $block) {
         $block->setPreview($preview);
         $this->buttons = $block->parseButtons($this->buttons);
     }
     maxUtils::endTime('collection-parse-parsebuttons');
     maxUtils::startTime('collection-parse-blockparse');
     // general parsing
     foreach ($this->blocks as $block) {
         $domObj = $block->parse($domObj, $args);
     }
     maxUtils::endTime('collection-parse-blockparse');
     $this->buttons = array();
     $cssParser = $this->getCSSParser();
     $domObj->load($domObj->save());
     $cssParser->loadDom($domObj);
     return $domObj;
 }