| @@ -20,10 +20,25 @@ | ||
| 20 | 20 | * |
| 21 | 21 | */ |
| 22 | 22 | function __construct($priority = 10) |
| 23 | 23 | { |
| 24 | + | |
| 25 | + // filters for save_post, display etc. Buttons class will the filters. | |
| 26 | + //add_filter('mb-save-fields', array($this, 'save_fields'),10,2); | |
| 27 | + //add_action('mb-admin-fields', array($this,'admin_fields' ) ); | |
| 28 | + //add_action('mb-data-load', array($this,'set') ); | |
| 29 | + | |
| 30 | + //add_filter('mb-parse-button', array($this, 'parse_button'),10,2 ); | |
| 31 | + //add_filter('mb-js-blocks', array($this, 'parse_js'), 10, 2); | |
| 32 | + //add_filter('mb-parse-element-preview', array($this,'parse_element'), 10,2); | |
| 33 | + | |
| 34 | + //add_filter('mb-css-blocks', array($this, 'parse_css'),10,2 ); | |
| 35 | + //add_filter('mb-field-map', array($this, 'map_fields') ); | |
| 36 | + | |
| 37 | + | |
| 24 | 38 | $this->fields = apply_filters($this->blockname. "-block-fields",$this->fields); |
| 25 | 39 | $this->data[$this->blockname] = array(); //empty init |
| 40 | + | |
| 26 | 41 | } |
| 27 | 42 | |
| 28 | 43 | /** Save fields runs the POST variable through all blocks |
| 29 | 44 | * |
| @@ -80,31 +95,15 @@ | ||
| 80 | 95 | return false; |
| 81 | 96 | } |
| 82 | 97 | |
| 83 | 98 | |
| 84 | - /* Build the Block admin interface | |
| 99 | + /* Display Block admin interface | |
| 85 | 100 | * |
| 86 | - * Builds admin interface via Admin class ( addfield ). After building, display fields should be called. | |
| 101 | + * Writes admin interface to output. | |
| 87 | 102 | * @abstract |
| 88 | 103 | */ |
| 89 | 104 | abstract public function admin_fields(); |
| 90 | - public function display_fields() | |
| 91 | - { | |
| 92 | - $admin = MB()->getClass('admin'); | |
| 93 | - $admin->display_fields(); | |
| 94 | 105 | |
| 95 | - } | |
| 96 | - | |
| 97 | - /** Adding a sidebar ** | |
| 98 | - * | |
| 99 | - * This function can be used to add a sidebar to the block. The sidebar should be called before display_fields is put out but after the last field | |
| 100 | - * | |
| 101 | - * */ | |
| 102 | - public function sidebar() | |
| 103 | - { | |
| 104 | - return; | |
| 105 | - } | |
| 106 | - | |
| 107 | 106 | /** Parse HTML portion of button |
| 108 | 107 | * |
| 109 | 108 | * This filter is passed through to modify the HTML parts of the button. |
| 110 | 109 | * |
| @@ -115,9 +114,8 @@ | ||
| 115 | 114 | * |
| 116 | 115 | * @return DomObj |
| 117 | 116 | */ |
| 118 | 117 | public function parse_button($button, $mode) { return $button; } |
| 119 | - public function post_parse_button($domObj, $mode) { return $domObj; } | |
| 120 | 118 | |
| 121 | 119 | /* Parse CSS of the button |
| 122 | 120 | * |
| 123 | 121 | * This function will go through the blocks, matching the $css definitions of a fields and putting them in the |
| @@ -150,13 +148,8 @@ | ||
| 150 | 148 | { |
| 151 | 149 | if ($value == '') $value = 0; // pixel values, no empty but 0 |
| 152 | 150 | $value .= "px"; |
| 153 | 151 | } |
| 154 | - elseif (isset($field_data["default"]) && strpos($field_data["default"],"%") && ! strpos($value,"%")) | |
| 155 | - { | |
| 156 | - if ($value == '') $value = 0; // pixel values, no empty but 0 | |
| 157 | - $value .= "%"; | |
| 158 | - } | |
| 159 | 152 | if (isset($data[$field])) |
| 160 | 153 | { |
| 161 | 154 | foreach($csspart as $part) |
| 162 | 155 | { |
| @@ -214,17 +207,12 @@ | ||
| 214 | 207 | } |
| 215 | 208 | $map[$field]["css"] = $cssdef; |
| 216 | 209 | if ( isset($field_data["default"]) && strpos($field_data["default"],"px") != false ) |
| 217 | 210 | $map[$field]["css_unit"] = 'px'; |
| 218 | - else if ( isset($field_data["default"]) && strpos($field_data["default"],"%") != false ) | |
| 219 | - $map[$field]["css_unit"] = '%'; | |
| 220 | 211 | |
| 221 | 212 | } |
| 222 | 213 | if (isset($field_data["csspart"])) |
| 223 | 214 | $map[$field]["csspart"] = $field_data["csspart"]; |
| 224 | - if (isset($field_data['csspseudo'])) | |
| 225 | - $map[$field]['pseudo'] = $field_data['csspseudo']; | |
| 226 | - | |
| 227 | 215 | } |
| 228 | 216 | return $map; |
| 229 | 217 | |
| 230 | 218 | } |
| @@ -239,5 +227,27 @@ | ||
| 239 | 227 | |
| 240 | 228 | $this->data = $dataArray; |
| 241 | 229 | } |
| 242 | 230 | |
| 231 | + public function getValue($field) | |
| 232 | + { | |
| 233 | + $data = $this->data; | |
| 234 | + /*foreach($data as $blockname => $fieldname) | |
| 235 | + { | |
| 236 | + if ($fieldname == $field) | |
| 237 | + return $data[$blockname][$fieldname]; | |
| 238 | + }*/ | |
| 239 | + | |
| 240 | + if (isset($data[$this->blockname][$field])) | |
| 241 | + { | |
| 242 | + return $data[$this->blockname][$field]; | |
| 243 | + } | |
| 244 | + | |
| 245 | + if (isset($this->fields[$field]['default'])) | |
| 246 | + return $this->fields[$field]['default']; | |
| 247 | + | |
| 248 | + // if not found return default | |
| 249 | + return false; | |
| 250 | + } | |
| 251 | + | |
| 243 | 252 | } |
| 253 | +?> | |