Esempio n. 1
0
/** Seems nutty, but take two associative arrays of attribute arrays, and
 * merge them with the above method, only for the given keys
 * @param type $keys
 * @param type $arr1
 * @param type $arr2
 */
function merge_att_arrs($keys, $arr1=[], $arr2 = []) {
  if (!$keys) return [];
  if (ne_string($keys)) {
    return merge_attributes(keyVal($keys,$arr1), keyVal($keys,$arr2));
  }
  $out = [];
  foreach ($keys as $key) {
    $out[$key] = merge_attributes(keyVal($key,$arr1), keyVal($key,$arr2));
  }
  return $out;
}
Esempio n. 2
0
 public function float($float, $callback, $attributes = array())
 {
     $content = Module::render($callback);
     return HTML::div($content, merge_attributes(array('class' => 'pull-' . $float), $attributes));
 }
 public function merge_attributes($tag = 'body', $attributes)
 {
     $this->set_attributes($tag, merge_attributes($this->get_attributes($tag), $attributes));
 }
Esempio n. 4
0
 /**
  * Merges the existing attributes with the new ones
  *
  * @param array|string $attributes Array of attribute 'name' => 'value' pairs
  *                                 or HTML attribute string
  * @param array|string $attributes Array of attribute 'name' => 'value' pairs
  *                                 or HTML attribute string
  *
  * @return string A string containing merged attributes
  */
 function merge_attributes_and_classes($attributes, $extra_attributes)
 {
     $attributes = prepare_attributes($attributes);
     $extra_attributes = prepare_attributes($extra_attributes);
     $class_extra = get_attribute($extra_attributes, 'class');
     $attributes = add_class($attributes, get_attribute($extra_attributes, 'class'));
     $extra_attributes = remove_attribute($extra_attributes, 'class');
     return merge_attributes($attributes, $extra_attributes);
 }
Esempio n. 5
0
 public function form($content, $options = [])
 {
     $options = merge_attributes($options);
     //return $this->rawcontent(PkForm::open($options) . $content . PkForm::close());
     $this->rawcontent(PkForm::open($options));
     $this->rawcontent($content);
     $this->rawcontent(PkForm::close());
     return $this;
 }
Esempio n. 6
0
 /** The BS Column Class (if any) should is a separate param, 'wrapperColClass'
  * Default is 'col-xs-2', but any 'wrapperColClass' will replace it, including
  * if the key exists but is empty.
  * 
  * @param type $inp
  * @param type $lbl
  * @param array|string $args - if string, the BS Col Class
  * @return type
  */
 public function pair($inp, $lbl = null, $args = [])
 {
     $defaults = ['labelAttributes' => $this->labelAttributes, 'valueAttributes' => $this->valueAttributes, 'wrapperAttributes' => $this->wrapperAttributes];
     if (is_array($args) && array_key_exists('wrapperColClass', $args)) {
         $wrapperColClass = $args['wrapperColClass'];
     } else {
         if (!is_array($args)) {
             #Default is [], so explicitly set, also to null.
             $wrapperColClass = $args;
         } else {
             $wrapperColClass = $this->defaultColClass;
         }
     }
     return PkRenderer::rawwrap(['value' => $inp, 'label' => $lbl, 'labelAttributes' => merge_att_arrs('labelAttributes', $defaults, $args), 'valueAttributes' => merge_att_arrs('valueAttributes', $defaults, $args), 'wrapperAttributes' => merge_attributes(merge_att_arrs('wrapperAttributes', $defaults, $args), $wrapperColClass)]);
 }
Esempio n. 7
0
 /**
  * Get the evaluated string content of the view.
  * 
  * @param  MenuItems 	$menuitems         	The menu items to render
  * @param  array  		$attributes 		Attributes for the element
  * @param  string  		$element 			The type of the element (ul or ol)
  * @return string
  */
 public function render_items($menuitems, $attributes = array(), $element = 'ul')
 {
     if (is_null($menuitems)) {
         return '';
     }
     $items = array();
     foreach ($menuitems as $menuitem) {
         if (!array_key_exists('html', $menuitem)) {
             $menuitem['url'] = (gettype($this->prefix) == 'string' ? $this->prefix : $this->container) . $menuitem['url'];
             if ($this->is_active($menuitem)) {
                 $menuitem['list_attributes'] = merge_attributes($menuitem['list_attributes'], array('class' => 'active'));
             }
             if ($this->has_active_children($menuitem)) {
                 $menuitem['list_attributes'] = merge_attributes($menuitem['list_attributes'], array('class' => 'active-children'));
             }
         }
         $menuitem['children'] = isset($menuitem['children']->items) ? $this->render_items($menuitem['children']->items, $attributes, $element) : '';
         $items[] = $this->render_item($menuitem);
     }
     return MenuHTML::$element($items, $attributes);
 }