PHP jQuery Tabs Class

php class I coded to easily implement jQuery UI tabs dynamically

/*
Requires;
jQuery UI Core
jQuery UI Tabs <a href="http://stilbuero.de/jquery/tabs_3/<br />
*/
<br />
/**<br />
" title="http://stilbuero.de/jquery/tabs_3/<br />
*/
<br />
/**<br />
">http://stilbuero.de/jquery/tabs_3/<br />
*/
<br />
/**<br />
</a> * jtabs
 *
 * @package jTabs  
 * @version 1.0.0
 * @access public
 */

 
class tabs
{
    var $name;
    var $tabs;
    var $active;
    var $current;
   
    function __construct( $name )
    {
        $this->name = $name;
    }
   
    function start( $name )
    {
        if ( empty($this->active) ) {
            $this->active = $name;
        }
        $this->current = $name;
        ob_start();
    }
   
    function end()
    {
        $this->tabs[$this->current] = ob_get_contents();
        ob_end_clean();
    }
   
    function run()
    {
        if ( count($this->tabs) > 0 ) {
            $jsClear = "";
         //$tabname = preg_replace('/[^a-zA-Z0-9]/', '', $tabname);
            echo "<script type="text/javascript">n";
            echo "$(function() {n";
            echo "$('#" . $this->name . " ul').tabs();n";
            echo "});n";
            echo "</script>n";
            echo '<div id="' . $this->name . '">' . "n";
            echo '<ul class="ui-tabs-nav">' . "n";
            foreach ( $this->tabs as $tabname => $tabcontent ) {
                $tabid = preg_replace('/[^a-zA-Z0-9]/', '', $this->name);
            $tabname1 = preg_replace('/[^a-zA-Z0-9]/', '', $tabname);
                $contentid = 'content-' . $tabid . '-' . $tabname1 . '';
                echo '<li><a href="#' . $contentid . '"><span>' . $tabname .
'</span></a></li>' . "n";
            }
            echo '</ul>' . "n";
            foreach ( $this->tabs as $tabname => $tabcontent ) {
                $tabid = preg_replace('/[^a-zA-Z0-9]/', '', $this->name);
            $tabname = preg_replace('/[^a-zA-Z0-9]/', '', $tabname);
                $contentid = 'content-' . $tabid . '-' . $tabname . '';
                echo '<div id="' . $contentid . '">' . $tabcontent . '</div>' .
"n";
            }
            echo '</div>' . "n"; // End Main Container
            echo '<div style="clear: both;"></div>' . "n";
        }
    }
}

// Example Implementation
/*
$tabs->start( 'Tab1' );
echo 'Some Content';
$tabs->end();
$tabs->run();
   
   */

Back To Homepage

Hi there, I would like to thank Dean for the outstanding service I recently received. Dean was very thorough, explained to us in detail what was wrong with our computer,

Hello, Just a quick note to say thank you to Dean for his excellent customer service he provided during a recent computer problem we had.He was more than happy to answer any questions we had, and took the time to give us a full explanation in our...

Dean was on time and his computer diagnosis was spot on.The computer problem was fixed in a matter of minutes.Dean also noticed we had 4 computers in the house and set up our wireless router in the time he had left so we could share files.I can...