40, 'class' => "layoutBlock" ); class layoutBlock extends block { protected $blockname = "layout"; protected $fields = array( "margin_left" => array("default" => "0px", "css" => "margin-left", "csspart" => "maxsocial"), "margin_right" => array("default" => "0px", "css" => "margin-right", "csspart" => "maxsocial"), "margin_top" => array("default" => "0px", "css" => "margin-top", "csspart" => "maxsocial"), "margin_bottom" => array("default" => "0px", "css" => "margin-bottom", "csspart" => "maxsocial"), "orientation" => array("default" => "auto"), "font" => array("default" => "", "css" => "font-family", "csspart" => 'mb-label,mb-share-count' ), "font_label_size" => array("default" => "15px", "css" => "font-size", "csspart" => 'mb-label' ), "font_label_style" => array("default" => "normal", "css" => "font-style", "csspart" => 'mb-label'), "font_label_weight" => array("default" => "normal", "css" => "font-weight", "csspart" => 'mb-label'), "font_label_upper" => array('default' => 'none', 'css' => 'text-transform', 'csspart' => 'mb-label', ), "font_icon_size" => array("default" => "15px", "css" => "font-size", "csspart" => 'mb-icon' ), "font_icon_style" => array("default" => "normal", "css" => "font-style", "csspart" => 'mb-icon'), "font_icon_weight" => array("default" => "normal", "css" => "font-weight", "csspart" => 'mb-icon'), // 'width' => array(), // 'height' => array(), 'use_background' => array('default' => 1, ), 'background_color' => array('default' => '#000', 'css' => 'background-color', 'csspart' => 'mb-social', ), 'background_color_hover' => array('default' => '#000', 'css' => 'background-color', 'csspart' => 'mb-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); $w = MBSocial()->whistle(); $hook = $this->collection->getHook(); $blockdata = $this->data[$this->blockname]; $network = $this->network; // if true, use network colors $use_background = isset($blockdata['use_background']) ? $blockdata['use_background'] : false; if ($use_background) { unset ($css['mb-social']['normal']['background-color']); unset ($css['mb-social']['hover']['background-color']); $color = $network->get('color'); $css['mb-social']['normal']['background-color'] = $color; $css['mb-social']['hover']['background-color'] = "darken($color, 10%)"; } $css['mb-icon.svg path']['normal']['color'] = '#fff'; $css['mb-icon.svg path']['hover']['color'] = '#ff0000'; $css["mb-item"]["normal"]["float"] = "left"; $css["mb-item"]["normal"]["display"] = "inline-block"; $css["mb-item a"]["normal"]["cursor"] = "pointer"; // by default social share = call to action. if (isset($blockdata['button_spacing']) && $blockdata['button_spacing'] > 0) { $orientation = $this->collection->orientation; $is_static = $w->ask('display/env/is_static'); $button_spacing = $blockdata['button_spacing']; if ($orientation == 'horizontal') { $css['mb-item']['normal']['margin'] = $button_spacing . 'px'; } if ($orientation == 'vertical') { $css['mb-item']['normal']['margin'] = $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('.mb-item',0); // $item->class .= ' social-colors'; // $network = $this->network->get('network'); } 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(); ?>