public function loadFromFieldset($definition)
	{
		if(!is_array($definition))
		{
			$definition = deserialize($definition, true);
		}

		$buttons  = array();
		$group    = false;
		$dropdown = false;

		foreach($definition as $button)
		{
			if($button['label'] == '' && $button['type'] != 'group')
			{
				continue;
			}

			// encode value
			if(isset($button['button']) && $button['button'] == 'link')
			{
				if (substr($button['value'], 0, 7) == 'mailto:')
				{
					$button['value'] = \String::encodeEmail($button['value']);
				}
				else
				{
					$button['value'] = ampersand($button['value']);
				}
			}

			if($dropdown !== false && ($button['type'] != 'child' && $button['type'] != 'header'))
			{
				if($group !== false)
				{
					$this->addItemToTarget($group['items'], $dropdown);
				}
				else
				{
					$this->addItem($dropdown);
				}

				$dropdown = false;
			}

			// create new group
			if($button['type'] == 'group')
			{
				$this->toolbar = true;

				if($dropdown !== false)
				{
					if($group)
					{
						$this->addItemToTarget($group['items'], $dropdown);
					}
					else
					{
						$this->addItem($dropdown);
					}

					$dropdown = false;
				}

				if($group !== false)
				{
					$this->addItem($group);
				}

				$group = $button;
				$group['items'] = array();
			}

			// create dropdown
			elseif($button['type'] == 'dropdown')
			{
				$dropdown = $button;
				$dropdown['items'] = array();
			}

			// add dropdown child
			elseif($button['type'] == 'child' || $button['type'] == 'header')
			{
				$dropdown['items'][] = $button;
			}

			// add button
			elseif($group !== false)
			{
				$this->addItemToTarget($group['items'], $button);
			}
			else
			{
				$this->addItem($button);
			}
		}

		if($group !== false)
		{
			if($dropdown !== false)
			{
				$this->addItemToTarget($group['items'], $dropdown);
			}

			$this->addItem($group);
		}
		elseif($dropdown !== false)
		{
			$this->addItem($dropdown);
		}
	}
public function loadFromFieldset($definition)
	{
		if(!is_array($definition))
		{
			$definition = deserialize($definition, true);
		}

		$buttons  = array();
		$group    = false;
		$dropdown = false;

		foreach($definition as $button)
		{
			if($button['label'] == '' && $button['type'] != 'group')
			{
				continue;
			}

			// encode value
			if(isset($button['button']) && $button['button'] == 'link')
			{
				if (substr($button['value'], 0, 7) == 'mailto:')
				{
					$button['value'] = \String::encodeEmail($button['value']);
				}
				else
				{
					$button['value'] = ampersand($button['value']);
				}
			}

			if($dropdown !== false && ($button['type'] != 'child' && $button['type'] != 'header'))
			{
				if($group !== false)
				{
					$this->addItemToTarget($group['items'], $dropdown);
				}
				else
				{
					$this->addItem($dropdown);
				}

				$dropdown = false;
			}

			// create new group
			if($button['type'] == 'group')
			{
				$this->toolbar = true;

				if($dropdown !== false)
				{
					if($group)
					{
						$this->addItemToTarget($group['items'], $dropdown);
					}
					else
					{
						$this->addItem($dropdown);
					}

					$dropdown = false;
				}

				if($group !== false)
				{
					$this->addItem($group);
				}

				$group = $button;
				$group['items'] = array();
			}

			// create dropdown
			elseif($button['type'] == 'dropdown')
			{
				$dropdown = $button;
				$dropdown['items'] = array();
			}

			// add dropdown child
			elseif($button['type'] == 'child' || $button['type'] == 'header')
			{
				$dropdown['items'][] = $button;
			}

			// add button
			elseif($group !== false)
			{
				$this->addItemToTarget($group['items'], $button);
			}
			else
			{
				$this->addItem($button);
			}
		}

		if($group !== false)
		{
			if($dropdown !== false)
			{
				$this->addItemToTarget($group['items'], $dropdown);
			}

			$this->addItem($group);
		}
		elseif($dropdown !== false)
		{
			$this->addItem($dropdown);
		}
	}
public function loadFromFieldset ( $ definition ) { if ( ! is_array ( $ definition ) ) { $ definition = deserialize ( $ definition , true ) ; } $ buttons = array ( ) ; $ group = false ; $ dropdown = false ; foreach ( $ definition as $ button ) { if ( $ button [ 'label' ] == '' && $ button [ 'type' ] != 'group' ) { continue ; } // encode value if ( isset ( $ button [ 'button' ] ) && $ button [ 'button' ] == 'link' ) { if ( substr ( $ button [ 'value' ] , 0 , 7 ) == 'mailto:' ) { $ button [ 'value' ] = \ String :: encodeEmail ( $ button [ 'value' ] ) ; } else { $ button [ 'value' ] = ampersand ( $ button [ 'value' ] ) ; } } if ( $ dropdown !== false && ( $ button [ 'type' ] != 'child' && $ button [ 'type' ] != 'header' ) ) { if ( $ group !== false ) { $ this -> addItemToTarget ( $ group [ 'items' ] , $ dropdown ) ; } else { $ this -> addItem ( $ dropdown ) ; } $ dropdown = false ; } // create new group if ( $ button [ 'type' ] == 'group' ) { $ this -> toolbar = true ; if ( $ dropdown !== false ) { if ( $ group ) { $ this -> addItemToTarget ( $ group [ 'items' ] , $ dropdown ) ; } else { $ this -> addItem ( $ dropdown ) ; } $ dropdown = false ; } if ( $ group !== false ) { $ this -> addItem ( $ group ) ; } $ group = $ button ; $ group [ 'items' ] = array ( ) ; } // create dropdown elseif ( $ button [ 'type' ] == 'dropdown' ) { $ dropdown = $ button ; $ dropdown [ 'items' ] = array ( ) ; } // add dropdown child elseif ( $ button [ 'type' ] == 'child' || $ button [ 'type' ] == 'header' ) { $ dropdown [ 'items' ] [ ] = $ button ; } // add button elseif ( $ group !== false ) { $ this -> addItemToTarget ( $ group [ 'items' ] , $ button ) ; } else { $ this -> addItem ( $ button ) ; } } if ( $ group !== false ) { if ( $ dropdown !== false ) { $ this -> addItemToTarget ( $ group [ 'items' ] , $ dropdown ) ; } $ this -> addItem ( $ group ) ; } elseif ( $ dropdown !== false ) { $ this -> addItem ( $ dropdown ) ; } }
load buttons defined in a field set definition, created by the MultiColumnWizard
@param $definition
load buttons defined in a field set definition created by the MultiColumnWizard