40, 'class' => "layoutBlock" ); class layoutBlock extends block { protected $blockname = "layout"; protected $fields = array( "margin_left" => array("default" => "0px", "css" => "margin-left", "csspart" => "maxcollection"), "margin_right" => array("default" => "0px", "css" => "margin-right", "csspart" => "maxcollection"), "margin_top" => array("default" => "0px", "css" => "margin-top", "csspart" => "maxcollection"), "margin_bottom" => array("default" => "0px", "css" => "margin-bottom", "csspart" => "maxcollection"), "orientation" => array("default" => "auto"), /*"item_margin_right" => array("default" => "0px", "css" => "margin-right", "csspart" => "mb-collection-item", ), "item_margin_bottom" => array("default" => "0px", "css" => "margin-bottom", "csspart" => "mb-collection-item", ), */ 'size' => array('default' => 100), 'use_background' => array('default' => 1, ), 'background_color' => array('default' => '#000', 'css' => 'background-color', 'csspart' => 'maxbutton-social', ), 'background_color_hover' => array('default' => '#000', 'css' => 'background-color', 'csspart' => 'maxbutton-social', 'csspseudo' => 'hover', ), 'color' => array('default' => '#fff', 'css' => 'color', 'csspart' => 'mb-icon,mb-share-count,mb-label'), 'color_hover' => array('default' => '#fff', 'css' => 'color', 'csspart' => 'mb-icon,mb-share-count,mb-label', 'csspseudo' => 'hover'), "button_spacing" => array('default' => '5', ), "ignore_container" => array("default" => 1), /* "static_position_ver" => array("default" => "Auto", ), "static_position_hor" => array("default" => "Auto", ), */ ); /*public function map_fields($map) { $map = parent::map_fields($map); $map["orientation"]["func"] = "updatePlacement"; return $map; } */ /* function parseButtons($buttons) { // searches the cache for the container statement ending with -container or -center and tries to remove then // not very optimal code, but this is a way to maintain cache loading while altering css. if ($this->data["ignore_container"] == 0) return $buttons; // ignore container off . foreach($buttons as $button) { $cache = $button->getCache(); // chops all css statements in a different line preg_match_all('/([^{]+)\s*\{\s*([^}]+)\s*}/i',$cache, $matches); foreach($matches[0] as $cssline) { // tries to find the last part of the statement from - to { preg_match_all('/.([^-])*{/i', $cssline, $item); $item = trim(str_replace("{","",$item[0][0])); if ($item == '-center' || $item == '-container') { $cache = str_replace($cssline,'',$cache); } } //([^{]+)\s*\{\s*([^}]+)\s*} { split } // match last thing .([^-])*{ $button->setCache($cache); $data = $button->get(); $container = isset($data["container"]) ? $data["container"] : array(); foreach($container as $key => $value) { if ($key != 'container_enabled' && $key != 'container_center_div_wrap') // causes container to be removed otherwise $container[$key] = ''; } $button->setdata("container", $container); } return $buttons; } */ function parseCSS($css, $args) { $css = parent::parseCSS($css, $args); $hook = $this->collection->getHook(); $blockdata = $this->data[$this->blockname]; // if true, use network colors $use_background = isset($blockdata['use_background']) ? $blockdata['use_background'] : false; if ($use_background) { unset ($css['maxbutton-social']['normal']['background-color']); unset ($css['maxbutton-social']['hover']['background-color']); } $css['mb-icon.svg path']['normal']['color'] = '#fff'; $css['mb-icon.svg path']['hover']['color'] = '#ff0000'; $css["collection-item"]["normal"]["float"] = "left"; $css["collection-item"]["normal"]["display"] = "inline-block"; $css["collection-item a"]["normal"]["cursor"] = "pointer"; // by default social share = call to action. if ($blockdata['button_spacing'] > 0) { $orientation = $this->collection->orientation; $button_spacing = $blockdata['button_spacing']; if ($orientation == 'horizontal') { $css['collection-item']['normal']['margin-right'] = $button_spacing . 'px'; } if ($orientation == 'vertical') { $css['collection-item']['normal']['margin-bottom'] = $button_spacing . 'px'; } } return $css; } public function parse($itemObj, $args = array() ) { $blockdata = $this->data[$this->blockname]; $use_background = isset($blockdata['use_background']) ? $blockdata['use_background'] : false; if ($use_background) { $item = $itemObj->find('.collection-item',0); $item->class .= ' social-colors'; } return $itemObj; } function save_fields($data, $post) { $data = parent::save_fields($data, $post); if (! isset($post["ignore_container"]) && ! is_null($post)) $data[$this->blockname]["ignore_container"] = 0; if (! isset($post['use_background']) && ! is_null($post)) $data[$this->blockname]['use_background'] = 0; return $data; } function admin() { $admin = mbSocial()->admin(); ?>