020 555 1111
  • Old fashion, modular, procedural PHP plus some scaffolding techniques to allow it to mimic MVC simplicity.
  • A quick reference to help you find in PHP maze what needs to be done and how to do it.
  • Learn a PHP Object Oriented Programming by building a live discussion forum application.
  • MVC - Model View Controller - real life, easy reference and application.
This product has options, take a look at them and select ones you like the most.
Options are displayed under image section.

jQuery UI button insert via wrapper class
[PHP example]

 

This class may help you with creating button on the flight.

Handy for dynamic buttons.

Note: this actually a function in a class wrapper. This could be done better and some day will be (or not).

 

sample use:

//"IE7pad" class adds eaxtra top/bottom pixel - see: "Horizontal misalignment of buttons in IE" article
$button = new UIButton();
$params = array('type' => 'button', 'attrib' => 'class="shadow IE7pad" style="margin:10px 25px 0 0;"');
 echo $button->ui_button('back to login', array('iconpos' => 'left', 'name' => 'seek-prev'),  'http://doamin.com/', 'bold', 'a', $params, 'bID');

 

For "what does what", see class code below. It has detailed description.

 

Also see this link about some IE problems with UI buttons.

 

 

/** 
* Description of UIButton
 *
 * @author Jeff Z. Parzych jp@lokalny.net
 */
class UIButton {

    /**
     *  Outputs a jQuery UI Button and makes it a bit more manageable on per case basis
     *  question of preference
     * 
     * @staticvar int $button_counter  
     * 	used when generating auto_id for button;<br>
     * 	an arbitrary id can be created,<br>
     * 	if id is created, $button_counter is bypassed<br>
     * 
     * @param mixed $title 
     * 	button label ('null' for none - if you want image butoon only)<br>
     * 
     * @param array $icon 
     * 	button icon params given as an array - example: array('name'=>'pencil', 'iconpos'=>'right'), <br>
     *  icon position (iconpos): left of label, or right<br>
     *  DEFAULT location (e.g. if "iconpos" is not set): right<br>
     *  find icon names here: http://jqueryui.com/themeroller/<br>
     * 
     * @param string $link 
     * 	full link (incl. https) to external page ('null' for none - usually null is used with <button> tag)
     * 
     * @param string $lbl_weight 
     * 	'bold' for bold label text and ui-css priority::primary <br>
     *  'normal' (or anything else incl. empty string, null etc.) for standard text, ui-css priority::secondary<br>
     *  DEFAULT: 'normal'
     * 
     * @param string $tagtype
     *  "button", "input", or "a" <br>
     *  NOTE! IE tends to (mis)place <button> tag all over the place, more - link below<br>
     *  http://reference.xarray.org.uk/product_info.php/jquery/jquery-ui-problems/jquery-ui/misalignment-of-buttons-in-ie-p-372
     * 
     * @param array $params 
     *  passed as a 2 element array - array('type'=>'', 'attrib'=>'')<br>
     *  --<br>
     *  first element 'type' - is a string - types available: submit, button, reset<br>
     *  --<br>
     *  second element is a strng of attributes, e.g.: <br>
     *  'target="_blank" onclick="history.back();return false;" onclick="return false;" style="color:red" class=="IE7pad"' <br>
     *  (IE7pad in example is a class fix for IE7 problem - see: Horizontal misalignment of buttons in IE)<<br>
     * 
     * @param mixed $id
     * 	arbitrary button id, if not selected all button will bet autoincreament button with prefix "bID", e.g. bID1<br>
     * 
     * @return string 
     * 	button code is returned as a string an echoed out<br>
     * 
     */
    public function ui_button( $title = null, $icon = null, $link = null, $lbl_weight = null, $tagtype = null, $params = null, $id = null ) {

	static $button_counter = 1;

	$types = array('submit', 'button', 'reset');
	
	if (!isset($params['type'])) {
	    $params['type'] = 'submit';
	}

	if (!in_array($params['type'], $types)) {
	    $params['type'] = 'submit';
	}

	if (($params['type'] == 'submit') && isset($link)) {
	    $params['type'] = 'button';
	}

	$priority = 'secondary';
	if (isset($lbl_weight) && $lbl_weight == 'bold') {
	    $priority = 'primary';
	} else {
	    $priority = 'secondary';
	}
	
	$id_select = ' id="bID'.$button_counter.'" ';
	if (isset($id)) {
	    $id_select = ' id="'.$id.'" ';
	} 
	
	$button = '<span class="btCls">';
	
	
	if ($tagtype == 'button') {
	    
	    $button .= '<button ';
	    
	} elseif ($tagtype == 'input') {
	    
	    $button .= '<input ';
	    
	} else {    
	    
	    $button .= '<a href="' . $link . '" ';
	}
	
	$button .= $id_select . ' type="' . htmlspecialchars($params['type']) . '"';
	
	
	//define additional aparams
	if (isset($params['attrib'])) $button .= " ".$params['attrib']." ";
	

	if ($tagtype == 'button') {
	    
	    $button .= '>' . $title . '</button>';
	    
	} elseif ($tagtype == 'input') {
	    
	    $button .= ' value="' . $title . '" />';
	    
	} else {
	    
	    $button .= '>' . $title . '</a>';
	    
	}
	
	
	if (isset($id)) {
	    $button .= '</span><script type="text/javascript">$("#' . $id . '").button(';
	} else {
	    $button .= '</span><script type="text/javascript">$("#bID' . $button_counter . '").button(';
	}

	
	$args = array();

	if (isset($icon['name'])) {
	    if (isset($icon['iconpos']) && $icon['iconpos'] == 'left') {
		$icon['iconpos'] = 'left';
	    } else {
		$icon['iconpos'] = 'right';
	    }

	    if ($icon['iconpos'] == 'left') {
		$args[] = 'icons:{primary:"ui-icon-' . $icon['name'] . '"}';
	    } else {
		$args[] = 'icons:{secondary:"ui-icon-' . $icon['name'] . '"}';
	    }
	}

	if (empty($title) || !isset($title)) {
	    $args[] = 'text:false';
	}

	if (!empty($args)) {
	    $button .= '{' . implode(',', $args) . '}';
	}

	$button .= ').addClass("ui-priority-' . $priority . '").parent().removeClass("btCls");</script>';

	if (!isset($id))
	    $button_counter++;

	return $button;
    }

}