given any user defined wrapper instructions
build the wrapper data

@param   array   Array of any passed wrapper info
@param   array   Array of the inputs attributes
@return  array   two element array of tag / attr
548127
public function getWrapper($wrapper, $attr)
    {
        $type = '';
        if (! empty($attr['type'])) {
            $type = ' ' . $attr['type'];

            if ((isset($attr['type']) && $attr['type'] == 'select') && in_array('multiple', $attr)) {
                $type .= ' multiselect';
            }
        }

        $defaults = array(
            'tag' => 'div',
            'class' => 'input' . $type
        );

        $wrapperAttr = array_merge(
            $defaults,
            $wrapper
        );

        // double check for the presence of a tag element
        $tag = $wrapperAttr['tag'];
        unset($wrapperAttr['tag']);

        return array(
            'tag' => $tag,
            'attr' => $wrapperAttr
        );
    }
362782
private static Object generateArrayExample(ArrayProperty property, MarkupDocBuilder markupDocBuilder) {
        Property itemProperty = property.getItems();
        List<Object> exampleArray = new ArrayList<>();

        exampleArray.add(generateExample(itemProperty, markupDocBuilder));
        return exampleArray;
    }
895746
public function buildInput($attrs)
    {
        $html = parent::buildInput($attrs);

        if (count($this->options)) {
            $html .= new Datalist($attrs['list'], $this->options);
        }

        return $html;
    }
1173778
def build_attrs(self, *args, **kwargs):
        """"""
        self.attrs.setdefault('data-minimum-input-length', 1)
        self.attrs.setdefault('data-tags', 'true')
        self.attrs.setdefault('data-token-separators', '[",", " "]')
        return super(Select2TagMixin, self).build_attrs(*args, **kwargs)
423794
public function addElementArray(array $elements) {

		if(count($elements)) {
			
			$firstElement = array_shift($elements);
			$name = $firstElement->getName();

			// remove any array indexes from name

			$name = preg_replace('~\[\w*\]$~i', '', $name);

			if(!empty($this->elements[$name])) {

				throw new HtmlFormException(sprintf("Element '%s' already assigned.", $name));

			}

			$arrayName = $name . '[]';
			$firstElement
				->setName($arrayName)
				->setForm($this)
			;

			$this->elements[$name] = [$firstElement];

			foreach($elements as $e) {
				
				if(get_class($e) !== get_class($firstElement)) {

					throw new HtmlFormException(sprintf("Class mismatch of form elements array. Expected '%s', found '%s'.", get_class($firstElement), get_class($e)));

				}
				
				// check whether names of element arrays match

				$nameToCheck = preg_replace('~\[\w*\]$~i', '', $e->getName());

				if($nameToCheck && $nameToCheck !== $name) {
					
					throw new HtmlFormException(sprintf("Name mismatch of form elements array. Expected '%s' or empty name, found '%s'.", $name, $e->getName()));

				}

				$e
					->setName($arrayName)
					->setForm($this)
				;

				$this->elements[$name][] = $e;
			}

		}

		return $this;

	}
1185132
function attrs(/* args... */) {

		$attrs = func_get_args();

		if (count($attrs) == 1 && is_array($attrs[0])) {
			$this->attributes = $attrs[0];
		}
		else { # count != 1 || ! is_array(entities[0])
			$this->attributes = $attrs;
		}

		return $this;
	}
1016036
public function buildAttrs(array $attrs = array())
    {
        $result = ' ';
        foreach ($attrs as $key => $param) {
            $param = (array) $param;
            if ($key === 'data') {
                $result .= $this->_buildDataAttrs($param);
                continue;
            }

            $value = implode(' ', $param);
            $value = $this->_cleanValue($value);

            if ($key !== 'data' && $attr = $this->_buildAttr($key, $value)) {
                $result .= $attr;
            }
        }

        return trim($result);
    }
601875
static ElementAttributes createElementAttributes(String tag) {
        // Parsing strings
        // <!--$includetemplate$aggregated2$templatewithparams.jsp$-->
        // or
        // <!--$includeblock$aggregated2$$(block)$myblock$-->
        // in order to retrieve driver, page and name attributes
        Pattern pattern = Pattern.compile("(?<=\\$)(?:[^\\$]|\\$\\()*(?=\\$)");
        Matcher matcher = pattern.matcher(tag);
        List<String> listparameters = new ArrayList<>();
        while (matcher.find()) {
            listparameters.add(matcher.group());
        }

        String[] parameters = listparameters.toArray(new String[listparameters.size()]);

        Driver driver;
        String page = "";
        String name = null;

        if (parameters.length > 1) {
            driver = DriverFactory.getInstance(parameters[1]);
        } else {
            driver = DriverFactory.getInstance();
        }

        if (parameters.length > 2) {
            page = parameters[2];
        }

        if (parameters.length > 3) {
            name = parameters[3];
        }
        return new ElementAttributes(driver, page, name);

    }
225577
public static function textarea( array $attributes = array(), $value = null, $wrapper = null )
    {
        $_html = static::tag( 'textarea', $attributes, $value );

        if ( null !== $wrapper )
        {
            $_html = static::div( array('class' => $wrapper), $_html );
        }

        return $_html;
    }
314154
function parseArray(tag, attrs, content, indentStr, indentLevel) {
    let html = '';
    for (let item of content) {
        if (getType(item)==='object') {
            let innerAttrs = getAttributes(item);
            let innerContent = TEXT in item ? item[TEXT] : '';
            html += renderElement(tag, innerAttrs, innerContent, indentStr, indentLevel);
        } else {
            html += renderElement(tag, attrs, item, indentStr, indentLevel);
        }
    }
    return html;
}
910710
protected void initWithWrapperTypArray() {
     // =========== wrapper array type ==============
        transformers.put(Boolean[].class, new Transformer() {
            @Override
            public SFSDataWrapper transform(Object value) {
                return new SFSDataWrapper(SFSDataType.BOOL_ARRAY, wrapperArrayToCollection((Boolean[])value));
            }
        });
        transformers.put(Byte[].class, new Transformer() {
            @Override
            public SFSDataWrapper transform(Object value) {
                return new SFSDataWrapper(SFSDataType.BYTE_ARRAY, toPrimitiveByteArray((Byte[])value));
            }
        });
        transformers.put(Character[].class, new Transformer() {
            @Override
            public SFSDataWrapper transform(Object value) {
                return new SFSDataWrapper(SFSDataType.BYTE_ARRAY, charWrapperArrayToPrimitiveByteArray((Character[])value));
            }
        });
        transformers.put(Double[].class, new Transformer() {
            @Override
            public SFSDataWrapper transform(Object value) {
                return new SFSDataWrapper(SFSDataType.DOUBLE_ARRAY, wrapperArrayToCollection((Double[])value));
            }
        });
        transformers.put(Float[].class, new Transformer() {
            @Override
            public SFSDataWrapper transform(Object value) {
                return new SFSDataWrapper(SFSDataType.FLOAT_ARRAY, wrapperArrayToCollection((Float[])value));
            }
        });
        transformers.put(Integer[].class, new Transformer() {
            @Override
            public SFSDataWrapper transform(Object value) {
                return new SFSDataWrapper(SFSDataType.INT_ARRAY, wrapperArrayToCollection((Integer[])value));
            }
        });
        transformers.put(Long[].class, new Transformer() {
            @Override
            public SFSDataWrapper transform(Object value) {
                return new SFSDataWrapper(SFSDataType.LONG_ARRAY, wrapperArrayToCollection((Long[])value));
            }
        });
        transformers.put(Short[].class, new Transformer() {
            @Override
            public SFSDataWrapper transform(Object value) {
                return new SFSDataWrapper(SFSDataType.SHORT_ARRAY, wrapperArrayToCollection((Short[])value));
            }
        });
    }
361662
public function build_array() {

		global $post;

		$breadcrumbs = array();

		// Not for 404 Not Found
		if ( ! is_404() ) {

			// Get post type data
			$post_type = get_post_type();
			$post_type_obj = get_post_type_object( $post_type );

			// Page Number
			$page_num = ctc_page_num();
			if ( $page_num > 1 ) {
				$this->add_breadcrumb( $breadcrumbs, array(
					sprintf( _x( 'Page %s', 'breadcrumb', 'church-theme-framework' ), $page_num ),
					$_SERVER['REQUEST_URI']
				) );
			}

			// Not on front page
			if ( ! is_front_page() ) {

				// Search Results
				if ( is_search() ) {
					$this->add_breadcrumb( $breadcrumbs, array(
						_x( 'Search Results', 'breadcrumb', 'church-theme-framework' ),
						get_search_link()
					) );
				}

				// Posts/Pages & Archives
				else {

					// Get post type data
					$post_type = get_post_type();

					// No post type found
					// Get post type via content type (section)
					$post_types = ctc_current_content_type_data( 'post_types' );
					if ( is_array( $post_types ) && 1 == count( $post_types ) && isset( $post_types[0] ) ) { // use section's post type if only one
						$post_type = $post_types[0];
					}

					// Get post type object
					$post_type_obj = get_post_type_object( $post_type );

					// Attachment
					if ( is_attachment() ) {

						/* translators: %s is mime type */
						$this->add_breadcrumb( $breadcrumbs, array(
							ctc_mime_type_name( $post->post_mime_type ),
							get_permalink()
						) );

						// Make parent(s) show, if any
						if ( ! empty( $post->post_parent ) ) {
							$parent_post_id = $post->post_parent;
						}

					}

					// Post or Page
					if ( ( is_singular() && ! is_attachment() ) || ! empty( $parent_post_id ) ) { // $parent_post_id can be attachment parent

						// Get post/page ID
						// Parent post (from attachment?) or current post
						$post_id = $post->ID;
						if ( ! empty( $parent_post_id ) ) {
							$post_id = $parent_post_id;
							$post_type = get_post_type( $post_id );
							$post_type_obj = get_post_type_object( $post_type );
						}

						// Show taxonomy before if has one
						// Use primary taxonomy's first term
						$taxonomies = get_object_taxonomies( $post_type );
						$taxonomy = isset( $taxonomies[0] ) ? $taxonomies[0] : false;
						if ( $taxonomy ) {
							$taxonomy_terms = get_the_terms( $post_id, $taxonomy );
							$taxonomy_term = is_array( $taxonomy_terms ) ? current( $taxonomy_terms ) : $taxonomy_terms; // use first term in list
						}

						// Post breadcrumb options
						$options = array();

							// Show parents only if not showing taxonomy
							if ( ! empty( $taxonomy ) ) {
								$options['show_parents'] = false; // default true
							}

						// Show post and parent(s)
						$this->add_breadcrumbs_array( $breadcrumbs, $this->post_breadcrumbs( $post_id, $options ) );

					}

					// Archives
					if ( is_archive() || ! empty( $taxonomy_term ) ) {

						// Blog Category
						if ( is_category() ) {
							$this->add_breadcrumbs_array( $breadcrumbs, $this->taxonomy_term_breadcrumbs( get_query_var( 'cat' ), 'category' ) );
						}

						// Blog Tag
						if ( is_tag() ) {

							// Get tag name
							$tag_data = get_term( get_query_var( 'tag_id' ), 'post_tag' );
							$tag_name = ! empty( $tag_data->name ) ? $tag_data->name : get_query_var( 'tag' );

							// Add tag to breadcrumb
							$this->add_breadcrumb( $breadcrumbs, array(
								$tag_name,
								get_tag_link( get_query_var( 'tag_id' ) )
							) );

						}

						// Custom Taxonomy and Parents
						if ( is_tax() || ! empty( $taxonomy_term ) ) { //  $taxonomy_term can come from post

							// Taxonomy passed in from post or are we on actual taxonomy?
							if ( is_tax() ) { // actual taxonomy
								$taxonomy = get_query_var( 'taxonomy' );
								$taxonomy_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
							}

							// Add taxonomies
							$this->add_breadcrumbs_array( $breadcrumbs, $this->taxonomy_term_breadcrumbs( $taxonomy_term, $taxonomy ) );

						}

						// Date Archive
						elseif ( is_year() || is_month() || is_day() ) {

							// Append date breadcrumbs
							$base_url = get_post_type_archive_link( $post_type );
							$this->add_breadcrumbs_array( $breadcrumbs, $this->date_breadcrumbs( $base_url ) );

						}

						// Author Archive
						elseif ( is_author() ) {
							$this->add_breadcrumb( $breadcrumbs, array(
								get_the_author(),
								get_author_posts_url( get_query_var( 'author' ) )
							) );
						}

					}

					// Post Type Archive
					// Single posts, taxonomies, etc.
					if ( $post_type_obj && ! is_page() ) { // not for pages

						// If static front page used and "Posts page" set, use that
						if ( 'post' == $post_type && $posts_page_id = get_option( 'page_for_posts' ) ) {
							$posts_page = get_page( $posts_page_id );
							$archive_name = $posts_page->post_title;
							$archive_url = get_permalink( $posts_page_id );
						}

						// Otherwise use current post type
						else {
							$archive_name = $post_type_obj->labels->name;
							$archive_url = get_post_type_archive_link( $post_type );
						}

						// Show only if have URL
						// When static front used and no "Posts page" set, there is no archive URL
						if ( $archive_url ) {
							$this->add_breadcrumb( $breadcrumbs, array(
								$archive_name,
								$archive_url
							) );
						}

					}

				}

			}

			// Add "Home" to front if have other breadcrumb(s)
			if ( ! empty( $breadcrumbs ) ) {
				$this->add_breadcrumb( $breadcrumbs, array(
					_x( 'Home', 'breadcrumbs', 'church-theme-framework' ),
					home_url( '/' )
				) );
			}

		}

		return apply_filters( 'ctc_breadcrumbs_array', $breadcrumbs );

	}
145853
public static DbAttribute[] toDbAttributeArray(final String[] array, final int mode) throws DevFailed {
        if (mode < 1 && mode > 2) {
            Except.throw_non_supported_exception("API_NotSupportedMode", "Mode " + mode
                    + " to decode attribute properties is not supported",
                    "ApiUtil.toDbAttributeArray()");
        }

        int idx = 1;
        final int nb_attr = Integer.parseInt(array[idx++]);
        final DbAttribute[] attr = new DbAttribute[nb_attr];
        for (int i = 0; i < nb_attr; i++) {
            // Create DbAttribute with name and nb properties
            // ------------------------------------------------------
            attr[i] = new DbAttribute(array[idx++]);

            // Get nb properties
            // ------------------------------------------------------
            final int nb_prop = Integer.parseInt(array[idx++]);

            for (int j = 0; j < nb_prop; j++) {
                // And copy property name and value in
                // DbAttribute's DbDatum array
                // ------------------------------------------
                final String p_name = array[idx++];
                switch (mode) {
                    case 1:
                        // Value is just one element
                        attr[i].add(p_name, array[idx++]);
                        break;
                    case 2:
                        // value is an array
                        final int p_length = Integer.parseInt(array[idx++]);
                        final String[] val = new String[p_length];
                        for (int p = 0; p < p_length; p++) {
                            val[p] = array[idx++];
                        }
                        attr[i].add(p_name, val);
                        break;
                }
            }
        }
        return attr;
    }
265329
public static function tag($tag, $attr = [], $html = '')
    {
        // Build attributes
        $attributes = [];
        foreach ($attr as $name => $value) {
            $attributes[] = $name.'="'.$value.'"';
        }

        if (in_array($tag, self::$voidElements)) {
            return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>';
        } else {
            return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>'.$html.'</'.$tag.'>';
        }
    }
1327625
public static <T> T[] append(final T[] array, final T element) {

    Class<?> compType = getClassType(array, element);
    if (compType == null) {
      return null;
    }
    int newArrLength = array != null ? array.length + 1 : 1;
    @SuppressWarnings("unchecked")
    T[] newArray = (T[]) Array.newInstance(compType, newArrLength);
    if (array != null) {
      System.arraycopy(array, 0, newArray, 0, array.length);
    }
    newArray[newArray.length - 1] = element;
    return newArray;
  }
666298
protected function generateHtmlClassTag()
    {
        $classArray = [];
        foreach (func_get_args() as $arg) {
            switch (gettype($arg)) {
                case 'string':
                case 'integer':
                    $classArray[] = $arg;
                    break;
                case 'array':
                    $classArray = !empty($arg) ? array_merge($classArray, $arg) : $classArray;
                    break;
                case 'NULL':
                    break;
                default:
                    throw new Exception('The given class arguments should be strings, integers or arrays : '
                                        . gettype($arg) . ' type given for « ' . $arg . ' » argument.');
            }
        }
        $classArray = array_map('trim', array_filter(array_flatten($classArray)));

        return new HtmlString(!empty($classArray) ? 'class="' . implode(' ', $classArray) . '"' : '');
    }
171440
public static function buildFromArray(&$html, $array, $tab = 0)
    {
        $pad = '';
        if ($tab > 0) {
            $pad = str_pad($pad, $tab * 2, ' ', STR_PAD_LEFT);
        }

        if (!isset($array[1])) {
            $html .= $array[0]."\n";

            return;
        }

        if (!empty($array[0])) {
            $html .= $pad;
            $html .= '<'.$array[0].$array[1].'>';
            $html .= "\n";
        }

        if (!empty($array[2])) {
            $html .= $pad.'  ';
            $html .= $array[2];
            $html .= "\n";
        }

        if (isset($array[3]) && is_array($array[3])) {
            foreach ($array[3] as $child_array) {
                self::buildFromArray($html, $child_array, $tab + 1);
            }
        }

        if (!empty($array[0])) {
            $html .= $pad;
            $html .= '</'.$array[0].'>';
            $html .= "\n";
        }
    }