TableDataReader
TableDataReader Du er her: /  Forsiden  /  Kildekoden  /  Table  /  Tabledatareader   Login nu   Login
TableDataReader
 ««« Se kilde koden
TableDataReader
TableDataReader Basic TableDataReader TableDataReader Base TableDataReader TableDataReader Component TableDataReader TableDataReader Db TableDataReader TableDataReader Dto TableDataReader TableDataReader Form TableDataReader TableDataReader Form-elements TableDataReader TableDataReader Jquery TableDataReader TableDataReader Layout TableDataReader TableDataReader Menu TableDataReader TableDataReader Menu-fisheye TableDataReader TableDataReader Mvc TableDataReader TableDataReader Tab TableDataReader TableDataReader Table  TableDataReader TableDataReader Template TableDataReader TableDataReader Util TableDataReader
TableDataReader
TableDataReader
TableDataReader Index
 
Tilbage

Navn : TableDataReader.php


Sample code, tutorial

Sådan benyttes komponenten TableDataReader klassen

Først skal du inkludere den fil der beskriver komponenten, som en klasse fil

  • <?
    require_once(HTML_PACKAGE_PATH.'/TableDataReader.php');
    ?>

Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):

  • <?
    TableDataReader
    ::display($param1, $param2, $param3, ...);
    ?>

eller du kan lave en instance af komponenten og benytte metoderne direkte:

  • <?
    $object
    = new TableDataReader($param1, $param2, $param3, ...);
    print
    $object->getHtml();
    ?>

Parent html

Sådan vises komponenten TableDataReader klassen

Der er ikke fundet noget

PHP source code

Den fulde PHP kildekode for TableDataReader klassen

<?
/**
* @package table
* @filesource
* @see HTML_TABLE_COMPONENT_PATH.'/TableDataReader.php'
* @copyright (c) http://Finn-Rasmussen.com
* @license http://Finn-Rasmussen.com/license/ myPHP License conditions
* @author http://Finn-Rasmussen.com
* @version 1.10
* @since 22-feb-2007
*/

/**
* The required files
*/
require_once(HTML_TABLE_COMPONENT_PATH.'/TableHeader.php');
require_once(
HTML_TABLE_COMPONENT_PATH.'/Table.php');
if (
defined('HTML_DTO_UTIL_PATH')) {
    require_once(
HTML_DTO_UTIL_PATH.'/DataReaderFactory.php');
}
require_once(
HTML_BASIC_UTIL_PATH.'/Message.php');
require_once(
HTML_BASE_UTIL_PATH.'/Raw.php');
require_once(
HTML_BASE_UTIL_PATH.'/Ul.php');
require_once(
HTML_BASE_UTIL_PATH.'/Li.php');
require_once(
HTML_BASE_UTIL_PATH.'/Links.php');
require_once(
HTML_BASE_UTIL_PATH.'/Link.php');
require_once(
HTML_BASE_UTIL_PATH.'/Images.php');
require_once(
HTML_BASE_UTIL_PATH.'/Image.php');
require_once(
HTML_UTIL_COMPONENT_PATH.'/Request.php');
if (
defined('HTML_COMPONENT_PAGE_PATH')) {
    require_once(
HTML_COMPONENT_PAGE_PATH.'/Googlebox.php');
}
if (
defined('HTML_LANGUAGE_UTIL_PATH')) {
    require_once(
HTML_LANGUAGE_UTIL_PATH.'/Translate.php');
}
if (
defined('HTML_LOG_UTIL_PATH')) {
    require_once(
HTML_LOG_UTIL_PATH.'/Log.php');
}

/**
* Generates the html for a table
* <code>
* Usage:
*   $rows = array(
*     array('head_1'=>'dat_0_1', 'head_2'=>'dat_0_2', 'head_3'=>'dat_0_3',),
*     array('head_1'=>'dat_1_1', 'head_2'=>'dat_1_2', 'head_3'=>'dat_1_3',),
*   );
*   $datareader = DataReaderFactory::newDataReader($rows);
*   $table = new TableDataReader($datareader,$text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
*   print $table->getHtml();
* Or
*   Table::display($datareader,$text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
*
* Generates a complete table interface with data supplied by the DataReader object
* ------------------------------+
* | Text header                 |
* ------------------------------+
* | head_1  | head_2  | head_3  |
* ------------------------------+
* | dat_0_1 | dat_0_2 | dat_0_3 |
* | dat_1_1 | dat_1_2 | dat_1_3 |
* ------------------------------+
* </code>
* @package table
*/

class TableDataReader extends Table {
    
/**
     * @var DataReader The Data Reader object
     */
    
var $datareader = '';

    
/**
     * @var $layout The different layouts to use
     * image link | image link | etc. on the same line
     * image link | image link | etc. on the same line and google search
     * image and link on each line
     * <li> image and link on each line
     * image <br> link etc. on the same line
     */
    
var $layout = '';

    
/**
     * Constructor
     * @param DataReader $datareader The Data Reader object
     * @param String $text    The text header for the table
     * @param String $width   The Width for the table
     * @param String $class   The Class
     * @param String $border  The Border
     * @param String $cellpadding The CellSpacing
     * @param String $cellspacing The CellPadding
     * @param String $summary The Summary
     * @param String $caption The Caption
     */
    
function TableDataReader($datareader='',$text='',$width='',$class='',$border='',$cellpadding='',$cellspacing='',$summary='',$caption='') {
        
$this->Table($text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
        
$this->datareader = $this->getDatareader($datareader);
        
$this->adjustColumns();
    }

    
/**
     * Get the DataReader to use for this class
     * @param  DataReader $datareader The DataReader object, if defined
     * @return DataReader or array The DataReader object or an array of default data
     */
    
function getDatareader($datareader) {
        
$theDatareader = $datareader;
        if (
$theDatareader == '') {
            
$print = new Links(LINK_PRINT);
        
            
$columns = array(
             
LINK_TEXT_HOME=>array('text'=>LINK_TEXT_HOME,'href'=>WWW_ROOT.'/?'.REQUEST_TAB.'='.TAB_INDEX_B,'title'=>LINK_TITLE_HOME),
             
LINK_TEXT_CONTACT_US=>array('text'=>LINK_TEXT_CONTACT_US,'href'=>LINK_HREF_EMAIL.'?'.REQUEST_EMNE.'=','title'=>LINK_TITLE_CONTACT_US,), // ,'class'=>'email'
             //LINK_TEXT_COMPANY_PROFILE=>array('text'=>LINK_TEXT_COMPANY_PROFILE,'href'=>LINK_HREF_URL.'/hvepseboguide/About/','title'=>LINK_TITLE_COMPANY_PROFILE,),
             
LINK_TEXT_PRINT=>array('text'=>$print->get('text'),'href'=>$print->get('href'),'title'=>$print->get('title'),),
            );
            
$theDatareader = $columns;
        }
        return
$theDatareader;
    }

   
/**
     * Return the column data for the view
     * @param  String $value  The value to use
     * @param  String $css    The CSS to use
     * @param  String $valign The valign to use
     * @return Object The html as an object
     */
    
function newData($value='', $css='', $valign='') {
        
$text = $value!=''?$value:'';
        
$object = new Td($css,$valign,'',$text);
        if (
$this->layout & LINK_LAYOUT_LI) {
            
$object = new Raw($text);
        }
        return
$object;
    }

    
/**
     * Get the CSS class Name for this component
     * You may override this function if you need another CSS class name
     * @abstract
     * @return String The CSS class name
     */
    
function getCssClass() {
        return
CSS_BODY;
    }

    
/**
     * Return the column data as html
     * The column data may be
     * - LINK_NAME
     * - IMAGE_NAME
     * - link
     * - image
     * - link + image
     * <code>
     * </code>
     * @param  String  $page          The page key
     * @param  array   $column        The column to loop for key/value pairs
     * @param  boolean $isActivetab   The Tab is active
     * @param  boolean $isActiveindex The Index is active
     * @return Object The html as an object
     */
    
function newColumn($page, $column, $isActiveTab=false, $isActiveIndex=false) {
        
$object = new Raw();
        if (
count($column)>0) {
            
$text   = '';
            
$href   = '';
            
$title  = '';
            
$src    = '';
            
$width  = '';
            
$height = '';
            
$alt    = '';
            
$class  = $this->getCssClass();
               
$theValue = '';
            
$valign = 'middle';
            foreach(
$column as $key=>$value) {
                switch (
$key) {
                    case
KEY_TRIANGLE:
                        
$aux = '';
                        if (
$this->layout & LINK_LAYOUT_LI) {
                            
$aux = LINK_LAYOUT_LI;
                        }
                        
$theValue = $this->newTriangle($value, $class, $aux);
                        
$class .= ' '.CSS_ONEPC;
                        break;
                    case
KEY_LINK:
                        
$class .= ' '.CSS_ALIGN_LEFT; // Intentionally fall through
                    
case KEY_POWERED:
                        if (
$class == $this->getCssClass()) {
                            
$class .= ' '.CSS_ALIGN_RIGHT;
                        }
                        
$theValue = new Links($value,'',$class);
                        break;
                    case
KEY_VERSION:
                        
$theValue = TEXT_VERSION.'&nbsp;'; // Intentionally fall through
                    
case KEY_PLAIN:
                    case
KEY_GOOGLE:
                        
$theValue .= $value;
                        break;
                    default:
                        $
$key = $value;
                        break;
                }
            }
            if (
$theValue == '') {
                
$theValue = new Raw();
                if (
$href != '' || $text != '') {
                    if (
defined('HTML_LANGUAGE_UTIL_PATH')) {
                        
$text = ucfirst(Translate::get($text));
                    }
                    
$aux = '';
                    if (
$this->layout & LINK_LAYOUT_LI) {
                        
$aux = LINK_LAYOUT_LI;
                    } else if (
$this->layout & LINK_LAYOUT_BR) {
                        
$aux = LINK_LAYOUT_BR;
                    }
                    if (
$isActiveTab || $isActiveIndex ) {
                        
// The selected Tab
                        
if ($this->layout & LINK_LAYOUT_TAB) {
                            
$class = CSS_ATAB_ACTIVE;
                        }
                        
$theValue = new Raw('<b class="'.$class.'">'.$text."</b>&nbsp;");
                        if (
$src != '') {
                            
$theValue->add(new Image($src,$width,$height,$alt,$class));
                        }
                        if (
$this->layout & LINK_LAYOUT_TAB) {
                            
$class = CSS_TAB_ACTIVE;
                        }
                    } else {
                        
$theValue = new Link($text,$href,$class,$title,$aux);
                        if (
$src != '') {
                            
$theValue->add(new Image($src,$width,$height,$alt,$class));
                        }
                        if (
$this->layout & LINK_LAYOUT_TAB) {
                            
$class = CSS_TAB;
                        }
                    }
                }
            }
            if (
$key == KEY_GOOGLE) {
                
$object->add(new Raw($theValue));
            } else {
                if (
$theValue != '') {
                    
$object->add($this->newData($theValue, $class, $valign));
                } else {
                    
// TODO what
                
}
            }
        } else {
            
// Ignore
        
}
        return
$object;
    }

    
/**
     * Return true if this is an active item
     * @param  String $page    The current item to test
     * @param  String $request The name of the key request
     * @param  String $default The default request parameter to use, of no request parameter
     * @return boolean True if this is an active Tab, else return false
     */
    
function isActive($page, $request='', $default='') {
        
$isActive = false;
        
$item = '';
        if (
defined('REQUEST_TAB')) {
            if (
TAB_SHOW & TAB_SHOW_URL) {
                
$item = Request::get($request, $default);
            } else {
                
$item = $default;
            }
        }
        if (
$item != '' && strtolower($page)==strtolower($item) ) {
            
$isActive = true;
        }
        return
$isActive;
    }

    
/**
     * Return true if this is an active Tab
     * @param  String $page    The current item to test
     * @param  String $request The name of the key request
     * @param  String $default The default request parameter to use, of no request parameter
     * @return boolean True if this is an active Tab, else return false
     */
    
function isActiveTab($page) {
        return
$this->isActive($page, REQUEST_TAB, TAB_INDEX);
    }

    
/**
     * Return true if this is an active Index
     * @param  String $page    The current item to test
     * @param  String $request The name of the key request
     * @param  String $default The default request parameter to use, of no request parameter
     * @return boolean True if this is an active Index, else return false
     */
    
function isActiveIndex($page) {
        return
$this->isActive($page, REQUEST_INDEX, "");
    }

    
/**
     * Return the content as a row object
     * @return Object The content as an object
     */
    
function newColumns() {
        
$object = new Tr();
        
// Menu Corner Left
        
if ($this->layout & LINK_LAYOUT_CORNER) {
            if (!(
$this->layout & LINK_LAYOUT_TAB)) {
                
$object->add($this->newCorner()); // L Border
            
}
        }
        
$numrows = 0;
        if (
is_a($this->datareader,DATA_READER_CLASS_NAME)) {
            
$numrows = $this->datareader->getNumRows();
        }
        if (
$numrows > 0) {
            if (
$this->layout & LINK_LAYOUT_LI) {
                
$object = new Ul($this->getCssClass());
            }
            foreach(
$this->datareader->getRows() as $page=>$column) {
                
$isActiveTab   = $this->isActiveTab($page);
                
$isActiveIndex = $this->isActiveIndex($page);
                if (
$this->layout & LINK_LAYOUT_CORNER && $this->layout & LINK_LAYOUT_TAB) {
                    
$object->add($this->newCorner($isActiveTab?IMAGE_TAB_LEFT_WHITE:IMAGE_TAB_LEFT)); // L Tab
                
}
                
$object->add($this->newColumn($page, $column, $isActiveTab, $isActiveIndex));
                if (
$this->layout & LINK_LAYOUT_CORNER && $this->layout & LINK_LAYOUT_TAB) {
                    
$object->add($this->newCorner($isActiveTab?IMAGE_TAB_RIGHT_WHITE:IMAGE_TAB_RIGHT)); // R Tab
                
}
            }
            
// Menu Corner No Data
            
if ($this->layout & LINK_LAYOUT_LI) {
                
$tr = new Tr();
                if (
$this->layout & LINK_LAYOUT_CORNER) {
                    if (!(
$this->layout & LINK_LAYOUT_TAB)) {
                        
$tr->add($this->newCorner()); // L Border
                    
}
                }
                
$td = new Td($this->getCssClass(),'','','<!-- LINK_LAYOUT_XX='.$this->layout.' -->');
                
$td->add($object);
                
$tr->add($td);
                
$object = $tr; // Return the final object
            
}
        } else {
            
$object->add($this->newTextRow(TEXT_NO_DATA,'',$this->getCssClass()));
        }
        
// Menu Corner Right
        
if ($this->layout & LINK_LAYOUT_CORNER) {
            if (!(
$this->layout & LINK_LAYOUT_TAB)) {
                
$object->add($this->newCorner()); // R Border
            
}
        }
        return
$object;
    }
    
    
/**
     * Adjust the columns for the horizontal view, and add the triangle gif
     */
    
function adjustColumns() {
        if (
$this->datareader != '' && is_array($this->datareader)) {
            
$columns   = array();
            if (
$this->layout & LINK_LAYOUT_TRIANGLE) {
                if (
$this->layout & LINK_LAYOUT_TAB) {
                    
$columns[-2] = array(KEY_TRIANGLE=>IMAGE_TRIANGLE);
                } else {
                    
$columns[] = array(KEY_TRIANGLE=>IMAGE_TRIANGLE);
                }
            }
            
$index = false;
            foreach(
$this->datareader as $key=>$column) {
                if (
$this->layout & LINK_LAYOUT_TAB) {
                    
$columns[$key] = $column; // Speciel case for TAB
                
} else {
                    
$columns[] = $column;
                }
                if (
$this->layout & LINK_LAYOUT_HORIZONTAL) {
                    
$columns[] = array(KEY_PLAIN=>'&nbsp;&#166;&nbsp;',);
                }
            }
            if (
$this->layout & LINK_LAYOUT_FILL_OUT) {
                if (
$this->layout & LINK_LAYOUT_TAB) {
                    
$columns[-1] = array(KEY_PLAIN=>'&nbsp;','class'=>$this->getCssClass().' '.CSS_FILL_OUT,);
                } else {
                    
$columns[] = array(KEY_PLAIN=>'&nbsp;','class'=>$this->getCssClass().' '.CSS_FILL_OUT,);
                }
            }
            if (
$this->layout & LINK_LAYOUT_GOOGLE && defined('HTML_COMPONENT_PAGE_PATH')) {
                if (
LINK_SHOW & LINK_SHOW_GOOGLE_TOP) {
                    
$googlebox = new Raw("<!-- Googlebox is disabled -->");
                    if (
defined('HTML_COMPONENT_PAGE_PATH')) {
                        
$googlebox = new Googlebox('',$this->getCssClass());
                    }
                    
// Form start/end are defined in pagestart.php
                    
$columns[] = array(KEY_PLAIN=>'&nbsp;','class'=>$this->getCssClass().' '.CSS_FILL_OUT,);
                    
$columns[] = array(KEY_GOOGLE=>$googlebox->getHtml(),);
                    
$columns[] = array(KEY_PLAIN=>'&nbsp;',);
                }
            }
            if (
defined('HTML_DTO_UTIL_PATH')) {
                
$this->datareader = DataReaderFactory::newDataReader($columns);
            }
        }
        if (!
is_a($this->datareader,DATA_READER_CLASS_NAME)) {
            
$msg = $this->getClassName().'(), '.DATA_READER_CLASS_NAME." object expected, unknown datareader type=".gettype($this->datareader);
            if (
defined('HTML_LOG_UTIL_PATH')) {
                
Log::error(__FILE__,__LINE__,$msg);
            } else {
            }
            
Message::add($msg,__FILE__,__LINE__);
        }
    }
    
    
/**
     * Return a new Corner or Border object
     * Corner: only the gif file should be added with no class name
     * Border: only the class name should be added
     * @param  String  $imageName  The name of the image to get
     * @return Td The new Td object
     */
    
function newCorner($imageName='') {
        
$class   = $imageName!=''?"":$this->getCssClass();
        
$valign  = "";
        
$colspan = "";
        
$text    = "";
        
$width   = "1px"; // NOT XHTML 1.0 strict compliant
        
$object = new Td($class, $valign, $colspan, $text, $width);
        if (
$imageName != '') {
            
/**
             * CSS_FLOAT_LEFT is a Bugfix for Firefox strict compliant
             * @see http://www.webmasterworld.com/css/3458552.htm
             */
            
$object->add(new Images($imageName,'','','',CSS_FLOAT_LEFT,'0'));
        } else {
            
$object->add(new Raw('&nbsp;'));
        }
        return
$object;
    }
    
    
/**
     * Get the content for the columns
     * Each row is definition of a column
     * @return String The html
     */
    
function getColumns() {
        
$html = '';
        
// Menu Corner Top
        
if ($this->layout & LINK_LAYOUT_CORNER) {
            if (!(
$this->layout & LINK_LAYOUT_TAB)) {
                
$tr = new Tr();
                
$tr->add($this->newCorner(IMAGE_CORNER_TOP_LEFT));
                
$tr->add($this->newCorner()); // MT border
                
$tr->add($this->newCorner(IMAGE_CORNER_TOP_RIGHT));
                
$this->add($tr);
            }
        }
        
$this->add($this->newColumns());
        
// Menu Corner Bottom
        
if ($this->layout & LINK_LAYOUT_CORNER) {
            if (!(
$this->layout & LINK_LAYOUT_TAB)) {
                
$tr = new Tr();
                
$tr->add($this->newCorner(IMAGE_CORNER_BOTTOM_LEFT));
                
$tr->add($this->newCorner()); // MB border
                
$tr->add($this->newCorner(IMAGE_CORNER_BOTTOM_RIGHT));
                
$this->add($tr);
            }
        }
        
// Render it
        
if ($this->text != '') {
            
$html .= $this->getTableHeader();
        }
        
$html .= $this->getStart();
        
$html .= $this->getEnd();
        return
$html;
    }
}
?>

HTML source code

Den fulde HTML kildekode for TableDataReader klassen

<?
<!-- No text in TableHeader -->

<
table width="100%" class="theTable" border="0" cellpadding="2" cellspacing="0">
<
tr>
    <
td valign="top">Der er ikke fundet noget</td>
</
tr>
</
table>

?>

Class methods

Her er 'klasse metoderne' for TableDataReader klassen:

  • object
  • getclassname
  • getmsg
  • addhtml
  • gethtml
  • tostring
  • getcachefilename
  • save
  • content
  • stop
  • html
  • setobject
  • set
  • get
  • getattribute
  • gettag
  • add
  • getsizeof
  • getelement
  • getelements
  • gettoogle
  • getmaximize
  • getminimize
  • newtriangle
  • display
  • showsource
  • table
  • newtextrow
  • gettableheader
  • getstart
  • getend
  • start
  • end
  • tabledatareader
  • getdatareader
  • newdata
  • getcssclass
  • newcolumn
  • isactive
  • isactivetab
  • isactiveindex
  • newcolumns
  • adjustcolumns
  • newcorner
  • getcolumns

Object vars

Her er 'objekt variable' for TableDataReader klassen:

  • html =>
  • sql =>
  • elements => Array
  • sizeof => 0
  • text =>
  • width => 100%
  • class => theTable
  • border => 0
  • cellpadding => 2
  • cellspacing => 0
  • summary =>
  • caption =>
  • datareader => Object
  • layout =>

DataReader.php

Her er felterne i DataReader for TableDataReader klassen:

  0   






  1   






  2   






TableDataReader

Vis denne side på danmark

Vis denne side på Germany

Vis denne side på England

Vis denne side på France

Vis denne side på Italy

Vis denne side på Norge

Vis denne side på Sverige

Vis denne side på USA


 
TableDataReader