sabahtan beri uğraşıyorum bir türlü kuramadım şu scripti.
hata = Parse error: syntax error, unexpected 'return' (T_RETURN), expecting while (T_WHILE) in /home/ndctgrxt/public_html/includes/thegrid.php.lc on line 445
bu thegrid.php.lc nin 445. satırı
return $out
thegrid.php.lc tamamı
<?php
 
 
 
 
 
 
 
 
class thegrid
{
    var $data = array( );
    var $columns = array( );
    var $options = array( );
    var $page_output = "html";
    function thegrid( &$DB, $options = array( ) )
    {
        $this->DB = $DB;
        $this->options = $options;
        $this->table_name = $options['table_name'];
        $this->group_by = $options['group_by'];
        $this->having = $options['having'];
        $this->id = $options['id'];
        $this->edit_id = $options['edit_id'];
        $this->edit_columns = $options['edit_columns'];
        $this->view_columns = $options['view_columns'];
        $this->isAjaxEditForm = true;
        if ( isset( $options['isAjaxEditForm'] ) )
        {
            $this->isAjaxEditForm = $options['isAjaxEditForm'];
        }
        if ( $options['show_edit_controls'] == "" )
        {
            $this->is_admin = false;
        }
        else
        {
            $this->is_admin = $options['show_edit_controls'];
        }
        if ( $options['page_output'] != "" )
        {
            $this->page_output = $options['page_output'];
        }
        if ( $options['id_column'] == "" )
        {
            $this->id_column = "id";
        }
        else
        {
            $this->id_column = $options['id_column'];
        }
        $this->str_search = $options['str_search'];
        $this->order_by = $options['order_by'];
        $this->join = $options['join'];
        $this->url = $options['url'];
        $this->ajax_url = $options['ajax_url'];
        $this->show_pagination = $options['show_pagination'];
        $this->show_add = $options['show_add'];
        $this->is_sortable = $options['is_sortable'];
        $this->page = $options['page'] != "" ? $options['page'] : 1;
        $this->items_per_page = $options['items_per_page'] != "" ? $options['items_per_page'] : ITEMS_PER_PAGE;
        $this->additional_links = $options['additional_links'];
        $this->extra_query = $this->get_extra_query( );
        $this->buildjoin( );
    }
    function get_extra_query( )
    {
        global $_REQUEST;
        $str_arr = array( );
        if ( is_array( $_REQUEST['filter'] ) )
        {
            foreach ( $GLOBALS['_REQUEST']['filter'] as $k => $v )
            {
                $str_arr[] = "filter[".$k."]={$v}";
            }
        }
        if ( is_array( $_REQUEST['sort'] ) )
        {
            foreach ( $GLOBALS['_REQUEST']['sort'][$this->id] as $k => $v )
            {
                $str_arr[] = "sort[".$this->id.( "][".$k."]={$v}" );
                $str_arr[] = "column=".$k;
            }
        }
        return implode( "&", $str_arr );
    }
    function buildjoin( )
    {
        $this->joinTables = "";
        $this->joinSelectColumns = "";
        if ( is_array( $this->join ) )
        {
            foreach ( $this->join as $k )
            {
                $this->joinTables .= " LEFT JOIN `".$k['table']."` ".$k['alias']." ON (".$k['alias'].".".$k['key']."=".$k['foreign_key']." ".$k['on']." )";
                if ( isset( $k['select_columns'] ) )
                {
                    foreach ( $k['select_columns'] as $c => $a )
                    {
                        $this->joinSelectColumns .= ", ".$c." as ".$a." ";
                    }
                }
            }
        }
    }
    function get_data( )
    {
        global $_REQUEST;
        $str_search = "";
        $str_order = " ORDER BY ".$this->id_column." DESC ";
        if ( is_array( $_REQUEST['filter'] ) )
        {
            $search_arr = array( );
            foreach ( $GLOBALS['_REQUEST']['filter'] as $k => $v )
            {
                if ( $v != "" )
                {
                    $search_arr[] = " ".$k." LIKE '%".$v."%' ";
                }
            }
            if ( count( $search_arr ) )
            {
                $str_search = " AND ".implode( " AND ", $search_arr );
            }
        }
        $this->str_search .= $str_search;
        if ( is_array( $_REQUEST['sort'][$this->id] ) )
        {
            $order_arr = array( );
            foreach ( $GLOBALS['_REQUEST']['sort'][$this->id] as $k => $v )
            {
                if ( $v != "" )
                {
                    $order_arr[] = " ".$k." {$v} ";
                }
            }
            if ( count( $order_arr ) )
            {
                $str_order = " ORDER BY ".implode( " , ", $order_arr );
            }
        }
        if ( !isset( $this->order_by ) )
        {
            $this->order_by = $str_order;
        }
        $total = $this->DB->get( "SELECT COUNT(`".$this->id_column."`) as `total` FROM `".$this->table_name."` a WHERE 1 ".$this->str_search."  " );
        $this->total = $total['total'];
        $sql = "SELECT a.* ".$this->joinSelectColumns." FROM `".$this->table_name."` a ".$this->joinTables." WHERE 1 ".$this->str_search." ".$this->group_by." ".$this->order_by."";
        if ( $this->show_pagination !== false )
        {
            $sql .= "LIMIT ".( $this->page - 1 ) * $this->items_per_page.", ".$this->items_per_page;
        }
        $this->data = $this->DB->getall( $sql );
    }
    function get( $id )
    {
        if ( $id != "" )
        {
            $sql = "SELECT a.* ".$this->joinSelectColumns." FROM `".$this->table_name."` a ".$this->joinTables." WHERE a.`".$this->id_column."`='".$id."' ".$this->group_by." ";
            $this->item_data = $this->DB->get( $sql );
            return $this->item_data;
        }
        return false;
    }
    function reorder( )
    {
        global $_REQUEST;
        $order_arr = explode( ",", $_REQUEST['order_arr'] );
        $i = 0;
        for ( ; $i < count( $order_arr ); ++$i )
        {
            $sql = "UPDATE `".$this->table_name."` SET `sort_order`='".$i."' WHERE `id`='".$order_arr[$i]."'";
            $this->DB->query( $sql );
        }
    }
    function _before_save( )
    {
        global $siteError;
        global $LANG;
        global $_SESSION;
        global $_POST;
        $sql = "SHOW COLUMNS FROM `".$this->table_name."` ";
        $columns = $this->DB->getall( $sql );
        $this->has_created = false;
        $this->has_modified = false;
        $i = 0;
        for ( ; $i < count( $columns ); ++$i )
        {
            if ( $columns[$i]['Field'] == "created" )
            {
                $this->has_created = true;
            }
            if ( $columns[$i]['Field'] == "modified" )
            {
                $this->has_modified = true;
            }
        }
        $this->captcha = false;
        foreach ( $this->edit_columns as $k => $v )
        {
            if ( $v['type'] == "captcha" )
            {
                $this->captcha = true;
                $this->captchaKey = $k;
            }
            if ( !( $v['required'] == true ) && !( trim( $_POST[$k] ) == "" ) )
            {
                $siteError->add( $LANG->l( "The field `".$v['title']."` cannot be empty." ) );
            }
        }
        if ( $this->captcha === true && ( tools::issubmit( "save" ) || tools::issubmit( "send" ) ) && $this->captcha === true )
        {
            if ( isset( $_SESSION[$this->captchaKey], $_SESSION[$this->captchaKey] ) )
            {
                unset( $_SESSION->$this->captchaKey );
            }
            else
            {
                $siteError->add( $LANG->l( "Sorry, you have provided an invalid security code" ) );
            }
        }
    }
    function save( $id = "" )
    {
        global $_REQUEST;
        global $_FILES;
        global $siteError;
        global $LANG;
        $this->_before_save( );
        $arr = array( );
        $test_update = false;
        $return = true;
        foreach ( $this->edit_columns as $k => $v )
        {
            if ( $v['type'] == "static" || $v['type'] == "captcha" || $id == "" && $k == "created" )
            {
                if ( $v['type'] == "password" )
                {
                    $value = md5( $_REQUEST[$k] );
                }
                else
                {
                    $value = $_REQUEST[$k];
                }
                if ( !( $v['update'] !== false ) && !( $v['type'] != "file" ) )
                {
                    $arr[] = " `".$k."`='".$value."' ";
                }
            }
        }
        if ( $siteError->haserrors( ) === false )
        {
            if ( 0 < count( $arr ) )
            {
                if ( $id != "" )
                {
                    $sql = "UPDATE `".$this->table_name."` SET ".implode( ", ", $arr )." \r\n\t\t\t\t\t\t".( $this->has_modified ? ", `modified`=NOW()" : "" )." WHERE `".$this->id_column."`='".$id."' ";
                }
                else
                {
                    $sql = "INSERT INTO `".$this->table_name."` SET ".implode( ", ", $arr )." \r\n\t\t\t\t\t\t".( $this->has_created ? ", `created`=NOW()" : "" )." ".( $this->has_modified ? ", `modified`=NOW()" : "" )."  ";
                }
                $test_run = $this->DB->query( $sql );
                if ( $test_run == false )
                {
                    $return = false;
                }
                if ( $id == "" )
                {
                    $id = $this->DB->last_id( );
                }
                $test_update = true;
            }
            foreach ( $this->edit_columns as $k => $v )
            {
                if ( $v['update'] !== false && $v['type'] != "file" || !( $v['table'] != "" ) )
                {
                    if ( $v['type'] != "editable_table" )
                    {
                        $sql = "DELETE FROM `".$v['table']."` WHERE `".$v['values_control_column']."`='".$id."'  ";
                        $this->DB->query( $sql );
                        $key = str_replace( "[]", "", $k );
                        if ( is_array( $_REQUEST[$key] ) )
                        {
                            foreach ( $GLOBALS['_REQUEST'][$key] as $a => $b )
                            {
                                $sql = "INSERT INTO `".$v['table']."` SET  `".$key."`='".$b."', `".$v['values_control_column']."`='".$id."'  ";
                                $test_run = $this->DB->query( $sql );
                                if ( $test_run == false )
                                {
                                    $return = false;
                                }
                            }
                        }
                    }
                    if ( $v['type'] == "editable_table" )
                    {
                        $sql = "DELETE FROM `".$v['table']."` WHERE `".$v['control_column']."`='".$id."'  ";
                        $test_run = $this->DB->query( $sql );
                        if ( $test_run == false )
                        {
                            $return = false;
                        }
                        $sql = "SHOW COLUMNS FROM `".$v['table']."` ";
                        $columns = $this->DB->getall( $sql );
                        $arr_table = array( );
                        if ( 0 < count( $columns ) )
                        {
                            $i = 0;
                            for ( ; $i < count( $columns ); ++$i )
                            {
                                if ( !in_array( $columns[$i][0], $v['exclude_columns'] ) )
                                {
                                    $arr_table[] = " `".$columns[$i][0]."`='".$this->DB->s( $_REQUEST[$columns[$i][0]] )."' ";
                                }
                            }
                        }
                        if ( 0 < count( $arr_table ) )
                        {
                            $arr_table[] = " `".$v['control_column']."`='".$id."' ";
                            $sql = "INSERT INTO `".$v['table']."` SET ".implode( ", ", $arr_table )."  ";
                            $test_run = $this->DB->query( $sql );
                            if ( $test_run == false )
                            {
                                $return = false;
                            }
                        }
                    }
                }
            }
            foreach ( $this->edit_columns as $k => $v )
            {
                if ( !( $v['type'] == "file" ) && !( $_FILES[$k]['tmp_name'] != "" ) )
                {
                    $sourceFile = $_FILES[$k]['tmp_name'];
                    $fullsizePath = $v['localfilepath'].$id."_".$_FILES[$k]['name'];
                    if ( !is_uploaded_file( $sourceFile ) )
                    {
                        $siteError->add( "error_image_upload", "error" );
                        return false;
                    }
                    if ( !move_uploaded_file( $sourceFile, $fullsizePath ) )
                    {
                        $siteError->add( "error_upload_failed", "error" );
                        return false;
                    }
                    if ( !chmod( $fullsizePath, 493 ) )
                    {
                        $siteError->add( "error_upload_rights", "error" );
                        return false;
                    }
                    @unlink( $v['localfilepath'].$_REQUEST["old_".$k] );
                    $sql = "UPDATE `".$this->table_name.( "` SET `".$k."`='" ).$id."_".$_FILES[$k]['name']."' WHERE `".$this->id_column."`='".$id."' ";
                    $this->DB->query( $sql );
                }
            }
            if ( $test_update )
            {
                $siteError->add( "Item saved correctly", "success" );
                if ( $_REQUEST['from'] != "js" )
                {
                    redirect( $this->url."?".$this->extra_query );
                    return $return;
                }
            }
        }
        else
        {
            $return = false;
        }
        return $return;
    }
    function delete( $id )
    {
        if ( $id != "" )
        {
            $this->DB->query( "DELETE FROM `".$this->table_name."` WHERE `".$this->id_column."`='".$id."' " );
            redirect( $this->url."?".$this->extra_query );
        }
    }
    function enable( $id )
    {
        if ( $id != "" )
        {
            $this->DB->query( "UPDATE `".$this->table_name."` SET `enabled`=1 WHERE `".$this->id_column."`='".$id."' " );
            redirect( $this->url."?".$this->extra_query );
        }
    }
    function disable( $id )
    {
        if ( $id != "" )
        {
            $this->DB->query( "UPDATE `".$this->table_name."` SET `enabled`=0 WHERE `".$this->id_column."`='".$id."' " );
            redirect( $this->url."?".$this->extra_query );
        }
    }
    function shorten( $str, $field_name, $v = array( ) )
    {
        switch ( $field_name )
        {
        case "url" :
            $arr = parse_url( $str );
            $out = "<a ".$v['attributes']." href=\"".$str."\" target=\"_blank\">".str_replace( "www.", "", $arr['host'] )."</a>";
            return $out;
        case "enabled" :
            $out = $WS->show_input( array(
                "type" => "checkbox",
                "disabled" => true,
                "name" => $k,
                "class" => "input-text",
                "value" => "1",
                "checked" => $str == 1 ? true : ""
            ) );
            return $out;
        case "created" :
        case "logged" :
        case "modified" :
            $out = $str;
            return $out;
        default :
            do
            {
                if ( 50 < strlen( $str ) )
                {
                    $out = substr( $str, 0, 50 );
                }
                else
                {
                    $out = $str;
                }
            }
            return $out;
        }
    function show_json( )
    {
        global $_SESSION;
        global $_REQUEST;
        global $WS;
        global $page;
        global $DB;
    }
    function show( )
    {
        global $_SESSION;
        global $_REQUEST;
        global $WS;
        global $page;
        global $DB;
        global $template_dir;
        ob_start( );
        if ( $this->page_output != "ajax" )
        {
            echo "\t\r\n<script type=\"text/javascript\">\r\n<!--\r\nvar agt = navigator.userAgent.toLowerCase();\r\nvar ie  = ((agt.indexOf(\"msie\") != -1) && (agt.indexOf(\"opera\") == -1));\r\n\r\nfunction ieTableInnerHTML(target, rowHTML) {\r\n\t/* Vars */\r\n\ttarget = \$(target);\r\n\t\r\n\t/* Remove all existing rows */\r\n\twhile (target.rows.length > 0) {\r\n\t\ttarget.deleteRow(0);\r\n\t}\r\n\t/* Create temporary table */\r\n\tvar tempDiv = document.createElement(\"div\");\r\n\tdocument.body.appendChild(tempDiv);\r\n\ttempDiv.innerHTML = '<table id=\"tempTable\" style=\"display: none\">' + rowHTML + '</table>';\r\n\tvar tt = \$(\"tempTable\");\r\n\t\r\n\t/* Copy temporary table's rows to target */\r\n\tfor (var i = 0; i < tt.rows.length; i++) {\r\n\t\ttarget.appendChild(tt.rows[i].cloneNode(true));\r\n\t}\r\n\t\r\n\t/* Remove temporary table */\r\n\tElement.remove(tt);\r\n};\r\n//var theGrid = new Array();\r\nvar fx_grid = new Array();\r\nvar grid_sort = new Array();\r\nfx_grid['body_";
            echo $this->id;
            echo "'] = new Fx.Elements('body_";
            echo $this->id;
            echo "', {duration: 1000, transition: Fx.Transitions.Quart.easeOut});\r\n\r\n\r\nwindow.addEvent('domready', function(){\r\n\t";
            if ( $this->is_sortable )
            {
                echo "makeSortable();";
            }
            echo "\t\r\n\t\$\$('.triggered').setStyle('display', 'none');\r\n\tvar list = \$\$('.trigger');\r\n\tfor (i=0;i<list.length;i++)\r\n\t{\r\n\t\tif (list[i].get('checked')==true)\r\n\t\t{\r\n\t\t\tvar rel = list[i].get('rel');\r\n\t\t\t\$\$('.'+rel).setStyle('display', 'block');\t\r\n\t\t}\r\n\t}\r\n\t\r\n});\r\n";
            if ( $this->is_sortable )
            {
                echo "function makeSortable()\r\n{\r\n\tnew Sortables(\$('body_";
                echo $this->id;
                echo "'), {\r\n\t\thandle: '.sort-handle',\r\n\t\tonDragStart: function(element, ghost){\r\n\t\t\tghost.addClass('myGhostClass').setOpacity(.5);\r\n\t\t\telement.setStyle('opacity', 0.7);\r\n\t\t\tghost.setStyle('background-color', '#dddddd');\r\n\t\t\t\r\n\t\t\tvar items = \$\$('#body_";
                echo $this->id;
                echo " tr');\r\n\t\t\tvar row = items[0];\r\n\t\t\titems = row.getElements('td');\r\n\t\t\tvar elems = ghost.getElements('td');\r\n\t\t\tfor (i=0;i<items.length;i++)\r\n\t\t\t{\r\n\t\t\t\tif (elems[i])\r\n\t\t\t\t\telems[i].setStyle('width', items[i].getStyle('width'));\r\n\t\t\t}\r\n\t\t},\r\n\t\tinitialize: function(){\r\n\t\t\tvar step = 0;\r\n\t\t\tthis.elements.each(function(element, i){\r\n\t\t\t\tvar color = [step, 82, 87].hsbToRgb();\r\n\t\t\t\t\r\n\t\t\t\tif (element.getElement('.sort-handle')) element.getElement('.sort-handle').setStyle('cursor', 'move');\r\n\t\t\t\tstep = step + 35;\r\n\t\t\t\t\r\n\t\t\t});\r\n\t\t},\r\n\t\tonComplete: function(){\r\n\t\t\t\r\n\t\t\tvar items = \$\$('.sortme');\r\n\t\t\tvar arr_str = Array();\r\n\t\t\tfor (i=0;i<items.length;i++)\r\n\t\t\t{\r\n\t\t\t\tif (items[i].id!='')\r\n\t\t\t\t{\r\n\t\t\t\t\tarr_str.push(items[i].id.replace('item-row-', ''));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar str = 'taction=reorder&order_arr='+arr_str.join(',');\r\n\t\t\t\r\n\t\t\tvar myRequest = new Request({url: \"";
                echo $this->ajax_url;
                echo "\", data:  str, method: 'get', onRequest: function(){\r\n\t\t\t\t\t\r\n\t\t\t\t},\r\n\t\t\t\tonComplete: \t\t\tfunction(resp)\r\n\t\t\t\t{ \r\n\t\t\t\t\t//reapply rules\r\n\t\t\t\t\tBehaviour.apply(myrules);\r\n\t\t\t\t\t";
                if ( $this->is_sortable )
                {
                    echo "if (makeSortable) makeSortable();";
                }
                echo "\t\t\t\t} } ).send();\r\n\t\t\t\r\n\t\t}\r\n\t \r\n\t});\r\n}\r\n";
            }
            echo "\r\n\$extend(myrules, {\r\n\t\t\r\n\t\t'.thegrid .pagination a': function(element){\r\n\t\t\telement.onclick = function(evt){\r\n\t\t\t\tvar evt = new Event(evt).stop();\r\n\t\t\t\tvar strd = rtrim(element.href, '/');\r\n\t\t\t\tvar page = strd.split('/');\r\n\t\t\t\tpage = page[page.length-1];\r\n\t\t\t\r\n\t\t\t\tvar str_arr = Array();\r\n\t\t\t\tvar elems = \$\$('.col-search input');\r\n\t\t\t\tfor (i=0;i<elems.length;i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar bs = elems[i].id.split(\"-\");\r\n\t\t\t\t\tstr_arr.push(\"filter[\" + bs[2] + \"]=\" + elems[i].value) ;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif (grid_sort['body_";
            echo $this->id;
            echo "'])\r\n\t\t\t\t{\r\n\t\t\t\t\tstr_arr.push('column='+grid_sort['body_";
            echo $this->id;
            echo "'][2]);\r\n\t\t\t\t\tstr_arr.push('sort[";
            echo $this->id;
            echo "]'+'['+grid_sort['body_";
            echo $this->id;
            echo "'][2]+']='+grid_sort['body_";
            echo $this->id;
            echo "'][3]);\r\n\t\t\t\t}\r\n\t\t\t\tstr_arr.push('page='+page);\r\n\t\t\t\tvar str = str_arr.join(\"&\");\r\n\t\t\t\tvar myRequest = new Request({url: \"";
            echo $this->ajax_url;
            echo "\", data:  str, method: 'get', onRequest: function(){\r\n\t\t\t\t\tvar resp = \"<tr><td colspan='";
            echo count( $this->view_columns ) + 1;
            echo "'><img src='";
            echo $template_dir;
            echo "images/ajax-loader.gif' alt='Loading' /></td></tr>\";\r\n\t\t\t\t\tif (!ie) \$('body_";
            echo $this->id;
            echo "').set('html', resp);\r\n\t\t\t\t\telse ieTableInnerHTML('body_";
            echo $this->id;
            echo "', resp);\r\n\t\t\t\t},\r\n\t\t\t\tonComplete: function(resp)\r\n\t\t\t\t{ \t\r\n\t\t\t\t\tif (!ie) { \$('body_";
            echo $this->id;
            echo "').set('html', resp); }\r\n\t\t\t\t\telse { ieTableInnerHTML('body_";
            echo $this->id;
            echo "', resp); }\r\n\t\t\t\t\t\r\n\t\t\t\t\t//reapply rules\r\n\t\t\t\t\tBehaviour.apply(myrules);\r\n\t\t\t\t\t";
            if ( $this->is_sortable )
            {
                echo "if (makeSortable) makeSortable();";
            }
            echo "\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t} \r\n\t\t\t\t\r\n\t\t\t\t} ).send();\r\n\t\t\t}\r\n\t\t},\r\n\t\t'.thegrid th a': function(element){\r\n\t\t\telement.onclick = function(evt){\r\n\t\t\t\tvar evt = new Event(evt).stop();\r\n\t\t\t\tvar brokenstring=element.id.split(\"-\");\r\n\t\t\t\tgrid_sort['body_";
            echo $this->id;
            echo "'] = brokenstring;\r\n\t\t\t\t\r\n\t\t\t\tvar str_arr = Array();\r\n\t\t\t\tvar elems = \$\$('.col-search input');\r\n\t\t\t\tfor (i=0;i<elems.length;i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar bs = elems[i].id.split(\"-\");\r\n\t\t\t\t\tstr_arr.push(\"filter[\" + bs[2] + \"]=\" + elems[i].value) ;\r\n\t\t\t\t}\r\n\t\t\t\tvar str = str_arr.join(\"&\");\r\n\t\t\t\tvar sort_order = brokenstring[3];\r\n\t\t\t\tif (brokenstring[3]==\"asc\")\r\n\t\t\t\t\tsort_order = \"desc\";\r\n\t\t\t\telse\r\n\t\t\t\t\tsort_order = \"asc\";\r\n\t\t\t\telement.id = brokenstring[0]+'-'+brokenstring[1]+'-'+brokenstring[2]+'-'+sort_order;\r\n\t\t\t\t\t\t\t\r\n\t\t\t\tvar myRequest = new Request({url: \"";
            echo $this->ajax_url;
            echo "\", data: 'column='+brokenstring[2]+'&sort[";
            echo $this->id;
            echo "]'+'['+brokenstring[2]+']='+brokenstring[3]+'&'+str, method: 'get', onRequest: function(){\r\n\t\t\t\t\tvar resp = \"<tr><td colspan='";
            echo count( $this->view_columns ) + 1;
            echo "'><img src='";
            echo $template_dir;
            echo "images/ajax-loader.gif' alt='Loading' /></td></tr>\";\r\n\t\t\t\t\tif (!ie) \$('body_";
            echo $this->id;
            echo "').set('html', resp);\r\n\t\t\t\t\telse ieTableInnerHTML('body_";
            echo $this->id;
            echo "', resp);\r\n\t\t\t\t}, onComplete: \t\t\tfunction(resp)\r\n\t\t\t\t{ fx.start({\t\r\n\t\t\t\t\t}).chain(function() {\r\n\t\t\t\t\t\tif (!ie) \$('body_";
            echo $this->id;
            echo "').set('html', resp);\r\n\t\t\t\t\t\telse ieTableInnerHTML('body_";
            echo $this->id;
            echo "', resp);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tBehaviour.apply(myrules);\r\n\t\t\t\t\t\t";
            if ( $this->is_sortable )
            {
                echo "if (makeSortable) makeSortable();";
            }
            echo "\t\t\t\t\t\t\r\n\t\t\t\t\t});\r\n\t\t\t\t} } ).send();\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t},\r\n\t\t'.thegrid th.col-search input': function(element){\r\n\t\t\telement.onkeyup = function(evt){\r\n\t\t\t\tvar evt = new Event(evt);\r\n\t\t\t\tif (evt.key != 'enter') return;\r\n\t\t\t\tevt.stop();\r\n\t\t\t\tvar brokenstring=element.id.split(\"-\");\r\n\t\t\t\t\r\n\t\t\t\tvar str_arr = Array();\r\n\t\t\t\tvar elems = \$\$('.col-search input');\r\n\t\t\t\tfor (i=0;i<elems.length;i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar bs = elems[i].id.split(\"-\");\r\n\t\t\t\t\tstr_arr.push(\"filter[\" + bs[2] + \"]=\" + elems[i].value) ;\r\n\t\t\t\t}\r\n\t\t\t\tvar str = str_arr.join(\"&\");\r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t\tvar myRequest = new Request({url: \"";
            echo $this->ajax_url;
            echo "\", data:  str, method: 'get', onRequest: function(){\r\n\t\t\t\t\tvar resp = \"<tr><td colspan='";
            echo count( $this->view_columns ) + 1;
            echo "'><img src='";
            echo $template_dir;
            echo "images/ajax-loader.gif' alt='Loading' /></td></tr>\";\r\n\t\t\t\t\tif (!ie) \$('body_";
            echo $this->id;
            echo "').set('html', resp);\r\n\t\t\t\t\telse ieTableInnerHTML('body_";
            echo $this->id;
            echo "', resp);\r\n\t\t\t\t}, \r\n\t\t\t\tonComplete: function(resp)\r\n\t\t\t\t{ fx.start({\t\r\n\t\t\t\t\t}).chain(function() {\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif (!ie) \$('body_";
            echo $this->id;
            echo "').set('html', resp);\r\n\t\t\t\t\t\telse ieTableInnerHTML('body_";
            echo $this->id;
            echo "', resp);\r\n\t\t\t\t\t\tBehaviour.apply(myrules);\r\n\t\t\t\t\t\t";
            if ( $this->is_sortable )
            {
                echo "if (makeSortable) makeSortable();";
            }
            echo "\t\t\t\t\t\t\r\n\t\t\t\t\t});\r\n\t\t\t\t} } ).send();\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t},\r\n\t\t'.trigger': function(element){\r\n\t\t\telement.onchange = function(evt){\r\n\t\t\t\tvar evt = new Event(evt);\r\n\t\t\t\tif (element.get('checked')==true)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar rel = element.get('rel');\r\n\t\t\t\t\t\$\$('.triggered[class!='+rel+']').setStyle('display', 'none');\r\n\t\t\t\t\t/*\$\$('.'+rel).each(function(item, index){\r\n\t\t\t\t\t\tvar myFx = new Fx.Slide(item);\r\n\t\t\t\t\t\tmyFx.toggle();\r\n\t\t\t\t\t}\r\n\t\t\t\t\t);*/\r\n\t\t\t\t\t\$\$('.'+rel).setStyle('display', 'block');\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n});\r\n\r\nfunction rtrim ( str, charlist ) {\r\n    // http://kevin.vanzonneveld.net\r\n    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)\r\n    // +      input by: Erkekjetter\r\n    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)\r\n    // *     example 1: rtrim('    Kevin van Zonneveld    ');\r\n    // *     returns 1: '    Kevin van Zonneveld'\r\n \r\n    charlist = !charlist ? ' \\s\\xA0' : charlist.replace(/([\\[\\]\\(\\)\\.\\?\\/\\*\\{\\}\\+\\\$\\^\\:])/g, '\\\$1');\r\n    var re = new RegExp('[' + charlist + ']+\$', 'g');\r\n    return str.replace(re, '');\r\n}\r\n\r\n//-->\r\n</script>\r\n\r\n";
            if ( $this->show_add !== false && is_array( $this->edit_columns ) && 0 < count( $this->edit_columns ) )
            {
                echo "<div class=\"add-box\">\r\n<a href=\"";
                echo $this->url;
                echo "?taction=add\" title=\"Add\" class=\"button\"><img src=\"";
                echo $template_dir;
                echo "images/button_add.png\" alt=\"Add\" />Add</a>\r\n</div>\r\n";
            }
            echo "\r\n";
            if ( is_array( $this->edit_columns ) && 0 < count( $this->edit_columns ) )
            {
                echo "<div class=\"reset\"></div>\r\n<div class=\"edit-box\" id=\"edit-";
                echo $this->id;
                echo "\">\r\n\t<!-- start of edit/add form -->\r\n    ";
                if ( $_REQUEST['taction'] == "edit" || $_REQUEST['taction'] == "add" )
                {
                    echo "\r\n        <form name=\"formSave";
                    $this->id;
                    echo "\" ";
                    if ( $this->isAjaxEditForm )
                    {
                        echo "class=\"editForm\"";
                    }
                    echo " id=\"formSave";
                    $this->id;
                    echo "\" action=\"";
                    if ( $this->isAjaxEditForm )
                    {
                        echo $this->ajax_url."?".$this->extra_query;
                    }
                    else
                    {
                        echo $this->url."?".$this->extra_query;
                    }
                    echo "\" method=\"post\" enctype=\"multipart/form-data\">\r\n        <input type=\"hidden\" id=\"return_url\" name=\"return_url\" value=\"";
                    echo $this->url."?".$this->extra_query;
                    echo "\" />\r\n        <div id=\"box\"></div>\r\n        <fieldset>\r\n            <ul class=\"editFormUL\">\r\n                ";
                    foreach ( $this->edit_columns as $k => $v )
                    {
                        if ( $v['visible'] !== false )
                        {
                            $array_options = array(
                                "type" => $v['type'],
                                "name" => $k,
                                "class" => "input-text"
                            );
                            if ( is_array( $v ) )
                            {
                                $array_options = array_merge( $array_options, $v );
                            }
                            echo "\t\t\t\t\t\t<li class=\"editFormLI ";
                            echo $v['classLI'];
                            echo "\"><label for=\"";
                            echo $k;
                            echo "\">";
                            echo $v['required'] == true ? "<strong>" : "";
                            echo $v['title'];
                            echo ":";
                            echo $v['required'] == true ? "</strong>" : "";
                            echo "</label><span>";
                            echo $this->show_input( $array_options );
                            echo "</span></li>\r\n\t\t\t\t   ";
                        }
                    }
                    echo "                <li><input type=\"hidden\" id=\"id_column\" name=\"id_column\" value=\"";
                    echo $_REQUEST['id_column'];
                    echo "\" />\t\r\n                <input type=\"hidden\" name=\"taction\" value=\"";
                    echo $_REQUEST['taction'];
                    echo "\" />\t\r\n                <input type=\"submit\" class=\"button\" name=\"save\" id=\"save";
                    $this->id;
                    echo "Data\" style=\"margin-top:5px\" value=\"Save\" /> \r\n                <a href=\"";
                    echo $this->url;
                    echo "?page=";
                    $this->page;
                    echo "\" title=\"Cancel\"><input type=\"button\" class=\"button cancelBtn\" name=\"cancel\" id=\"cancel";
                    $this->id;
                    echo "Data\" style=\"margin-top:5px\" value=\"Cancel\" /></a></li>\r\n            </ul>\r\n        </fieldset>\r\n        </form>\r\n       \r\n        <div class=\"reset\"></div>\r\n        ";
                }
                echo "    <!-- end of edit/add form -->\r\n</div>\r\n";
            }
            echo "<table class=\"data thegrid ";
            if ( $this->is_sortable )
            {
                echo "sortable";
            }
            echo "\" id=\"";
            echo $this->id;
            echo "\" cellpadding=\"3\" cellspacing=\"0\">\r\n\t<thead>\r\n    \t<tr>\r\n        \t";
            foreach ( $this->view_columns as $k => $v )
            {
                echo "                <th class=\"col-search\" style=\"";
                echo $v['width'] ? "width:".$v['width'].";" : "";
                echo "\">\r\n                ";
                if ( $k != "enabled" && $k != "created" && $k != "logged" && $k != "modified" && $v['show_search'] !== false )
                {
                    echo "                <input type=\"text\" name=\"search-";
                    echo $this->id;
                    echo "-";
                    echo $v['sort'];
                    echo "\" class=\"input-text\" style=\"width:70px\" id=\"search-";
                    echo $this->id;
                    echo "-";
                    echo $v['sort'];
                    echo "\" value=\"";
                    echo $_REQUEST['filter'][$v['sort']];
                    echo "\" />\r\n                ";
                }
                echo "                </th>\r\n\t\t\t";
            }
            echo "            \r\n            ";
            if ( $this->is_admin )
            {
                echo "\t\t\t\t<th></th>\r\n\t\t\t\t";
            }
            echo "        </tr>\r\n\t\t<tr >\r\n\t\t\t\r\n\r\n\t\t\t";
            foreach ( $this->view_columns as $k => $v )
            {
                echo "\t\t\t\t";
                $order = "asc";
                if ( $_REQUEST['sort'][$this->id][$v['sort']] == "asc" )
                {
                    $order = "desc";
                }
                echo "                <th ><a href=\"#\" id=\"sort-";
                echo $this->id;
                echo "-";
                echo $v['sort'];
                echo "-";
                echo $order;
                echo "\" class=\"col-sort\" title=\"Sort by ";
                echo $v['title'];
                echo "\">";
                echo $v['title'];
                echo "</a></th>\r\n\t\t\t";
            }
            echo "            \r\n            ";
            if ( $this->is_admin )
            {
                echo "\t\t\t\t<th></th>\r\n\t\t\t\t";
            }
            echo "            \r\n\t\t</tr>\r\n\t</thead>\r\n\t<tbody id=\"body_";
            echo $this->id;
            echo "\">\r\n";
        }
        echo "\t\t";
        if ( 0 < count( $this->data ) )
        {
            echo "\t\t\t";
            $i = 0;
            for ( ; $i < count( $this->data ); ++$i )
            {
                echo "\t\t\t<tr class=\"sortme item-row ";
                echo $i % 2 == 0 ? "" : "row_odd";
                echo "\" id=\"item-row-";
                echo $this->data[$i][$this->id_column];
                echo "\">\r\n\t\t\t\t\r\n                \r\n\t\t\t\t";
                $count = 0;
                foreach ( $this->view_columns as $k => $v )
                {
                    $width = "16%";
                    if ( $this->options['widths'][$count] != "" )
                    {
                        $width = $this->options['widths'][$count];
                    }
                    echo "\t\t\t\t\t\t<td>";
                    if ( $this->options['is_sortable'] && $count == 0 )
                    {
                        echo "<div ";
                        echo $count == 0 ? "class=\"sort-handle\"" : "";
                        echo " ";
                        echo $this->options['is_sortable'] ? "title=\"Drag and drop to reorder\"" : "";
                        echo "><img src=\"";
                        echo $template_dir;
                        echo "images/button_move.png\" alt=\"Move\" title=\"Drag and drop to reorder\" /></div>\r\n\t\t\t\t\t\t";
                    }
                    echo "                        \r\n\t\t\t\t\t\t\t";
                    $data = $this->data[$i];
                    $extra_info = "";
                    if ( $v['extra_info'] != "" )
                    {
                        eval( "\$tmp=".$v['extra_info'].";" );
                        $extra_info = $tmp;
                    }
                    $out = $this->data[$i][$k];
                    if ( $v['link'] != "" )
                    {
                        eval( "\$tmp=".vsprintf( $v['link'], array(
                            $out
                        ) ) );
                        echo "<a ".$v['attributes']." href=\"".$tmp."\" target=\"_blank\">";
                    }
                    echo $this->shorten( $out, $k, $v );
                    if ( $v['link'] != "" )
                    {
                        echo "</a>".$extra_info;
                    }
                    echo "\t\t\t\t\t\t</td>\r\n\t\t\t\t";
                    ++$count;
                }
                echo "            \r\n\t\t\t\t";
                if ( $this->is_admin )
                {
                    echo "\t\t\t\t\t<td><a href=\"";
                    echo $this->options['url'];
                    echo "?taction=edit&amp;id_column=";
                    echo $this->data[$i][$this->id_column];
                    echo "&amp;page=";
                    echo $page;
                    echo "&amp;";
                    echo $this->extra_query;
                    echo "\" title=\"Edit\" class=\"icon-space\"><img src=\"";
                    echo $template_dir;
                    echo "images/button_edit.png\" alt=\"Edit\" /></a>";
?>