Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Mvc  /  Viewinfo   Login nu   Login
blank.gif
««« Se kilde koden
blank.gif
tl.gif Base tr.gif tl.gif Basic tr.gif tl.gif Dto tr.gif tl.gif Form tr.gif tl.gif Language tr.gif tl.gif Layout tr.gif tl.gif Menu tr.gif tls.gif     Mvc  trs.gif tl.gif Netbank.eksperter.dk tr.gif tl.gif Tab tr.gif tl.gif Table tr.gif tl.gif Util tr.gif
blank.gif
blank.gif
arrow-headline.gif Index
MenuLink  MenuLeft  
Tilbage

Skjul: Navn

ViewInfo.php


Vis: Sample code, tutorial

ViewInfo, Sample code, tutorial

Sådan benyttes komponenten ViewInfo klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

ViewInfo, Sådan vises komponenten

Sådan vises komponenten ViewInfo klassen

Privat telefon: 48246030
Finn Rasmussen
HvepseEksperten.dk ApS
Kongens Vænge 79
3400 Hillerød
Denmark

Vis: PHP source code

ViewInfo, PHP source code

Den fulde PHP kildekode for ViewInfo klassen

<?php
/**
 * @package mvc
 * @see HTML_MVC_VIEW_PATH.'/ViewInfo.php'
 * @copyright (c) http://Finn-Rasmussen.com
 * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
 * @author http://Finn-Rasmussen.com
 * @version 1.11
 * @since 27-nov-2009
 */

/**
 * The required files
 */
require_once(HTML_BASE_UTIL_PATH.'/Htmlspecialchars.php');
require_once(
HTML_MVC_VIEW_PATH.'/ViewCommon.php');
require_once(
HTML_BASE_UTIL_PATH.'/Link.php');
require_once(
HTML_BASE_UTIL_PATH.'/EmailLink.php');
if (
defined('HTML_LANGUAGE_UTIL_PATH')) {
    require_once(
HTML_LANGUAGE_UTIL_PATH.'/Translate.php');
}

/**
 * Generates the html for a View Info like a business card look-a-like
 * <code>
 * Usage:
 *   $view = new ViewInfo($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout);
 *   print $view->getHtml();
 * Or
 *   ViewInfo::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout);
 *
 * Generates a complete View Simple interface
 * +--------+
 * | Header |
 * +--------+
 * | data1  | 
 * | data2  |
 * +--------+
 * </code>
 * @package mvc
 */

class ViewInfo extends ViewCommon {
    
/**
     * Constructor
     * @param DataReader / array $datareader The Data Reader object OR an array
     * @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 
     * @param String $layout  The layout to use 
     */
    
function __construct($datareader=null$text=''$width=''$class=''$border=''$cellpadding=''$cellspacing=''$summary=''$caption=''$layout='') {
        
$theText        $text != '' $text '';

        
// Global table characteristics
        
$theWidth       $width  != '' $width  BUSINESS_CARD_VIEW_WIDTH;
        
$theClass       $class  != '' $class  BUSINESS_CARD_VIEW_CLASS;
        
$theBorder      $border != '' $border BUSINESS_CARD_VIEW_BORDER;
        
$theCellPadding $cellpadding != '' $cellpadding BUSINESS_CARD_VIEW_CELLPADDING;
        
$theCellSpacing $cellspacing != '' $cellspacing BUSINESS_CARD_VIEW_CELLSPACING;
        
parent::__construct($datareader$theText$theWidth$theClass$theBorder$theCellPadding$theCellSpacing$summary$caption$layout);
    }

    
/**
     * Return the column header data as an object
     * @param  String $key The key to use
     * @return Object The html as an object
     */
    
function newHeader($key) {
        
$text $key;
        if (
defined('HTML_LANGUAGE_UTIL_PATH')) {
            
$text Translate::sql($key,TRANSLATE_QUERY);
        }
        return new 
Raw($text."&nbsp;");
    }
    
    
/**
     * Return the column data as an object
     * @param  String $key     The key to use
     * @param  String $value   The value to use
     * @return Object The html as an object
     */
    
function newColumnInfo($key$value) {
        
$object = new Raw();
        
$text '';
        switch (
$key) {
//            case @SELECT_MAIL: // deprecated
            
case SELECT_CUSTOMER_EMAIL:
                
$text $key;
                if (
defined('HTML_LANGUAGE_UTIL_PATH')) {
                    
$text Translate::sql($key,TRANSLATE_QUERY);
                }
                
$object->add(new EmailLink($value$value));
                break;
            case 
SELECT_CUSTOMER_WWW:
                
$text $key;
                if (
defined('HTML_LANGUAGE_UTIL_PATH')) {
                    
$text Translate::sql($key,TRANSLATE_QUERY);
                }
                
$object->add(new Link($value$value));
                break;
            case 
SELECT_CUSTOMER_PRIVATE_PHONE:
            case 
SELECT_CUSTOMER_BUSINESS_PHONE:
            case 
SELECT_CUSTOMER_MOBILE_PHONE:
            case 
SELECT_CUSTOMER_CVR:
            case 
SELECT_CUSTOMER_EAN:
                
$text $key;
                if (
defined('HTML_LANGUAGE_UTIL_PATH')) {
                    
$text Translate::sql($keyTRANSLATE_QUERY);
                }
                
$object = new Raw($text.': '.$value);
                
//$object->add(new Lookup($value));
                
break;
            default: 
// Use as is
                
$object = new Raw($value != '' $value "&nbsp;");
                break;
        }
        
$object->add(new Raw("<br />\r\n"));
        return 
$object;
    }
    
    
/**
     * Return the row data as html
     * <tr><td>header 1</td><td>data 1< br />data 2<br /> ...</td></tr>
     * @param  array  $row The rows to loop 
     * @return Object The html as an object
     */
    
function newRow($row) {
        
$object = new Raw();
        if (
count($row) > 0) {
            
$zip '';
            foreach(
$row as $key=>$rawvalue) {
                
$value $this->strip($rawvalue__FILE____LINE__);
                switch (
$key) {
                    case 
SELECT_CUSTOMER_ZIP:
                        
$zip $value;
                        break;
                    case 
SELECT_CUSTOMER_CITY:
                        
$value $zip.'&nbsp;'.$value;
                        
// Intentionally fall through
                    
default:
                        if (
$value != '') {
                            
$object->add($this->newColumnInfo($key$value));
                        }
                        break;
                } 
            }
        } else {
            
// TODO
        
}
        return 
$object;
    }

    
/**
     * Return the content as an object
     * @return Object The content as an object
     */
    
function newContent() {
        
$object = new Tr();
        
$numrows $this->datareader->getNumRows();
        if (
$numrows 0) {
            if (
$numrows 1) {
                
$this->text .= $this->text != '' " ($numrows)" '';
                
$td = new Td();
                
$td->add(new Raw("TODO More than one ($numrows) ..."));
                
$object->add($td);
            }
            
$td = new Td();
            foreach(
$this->datareader->getRows() as $no=>$row) {
                
$td->add($this->newRow($row));
            }
            
$object->add($td);
        } else {
            
$object->add($this->newTextRow(TEXT_NO_DATALINK_BACK));
        }
        return 
$object;
    }

    
/**
     * Return the html
     * @return String The html
     */
    
function getHtml() {
        
$html $this->html;
        
$this->add($this->newContent());
        
// Render it
        
if ($this->text != '') {
            
$html .= $this->getTableHeader();
        }
        
$html .= $this->getStart();
        
$html .= $this->getEnd();
        return 
$html;
    }

    
/**
     * Display html
     * <code>
     * Usage:
     *    ViewInfo::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); 
     * </code>
     * @static
     * @param DataReader / array $datareader The Data Reader object OR an array
     * @param String $text    The text header for the table
     * @param String $width   The width of the table
     * @param String $class   The class of the table
     * @param String $border  The border of the table
     * @param String $cellpadding The CellSpacing
     * @param String $cellspacing The CellPadding
     * @param String $summary The Summary
     * @param String $caption The Caption 
     * @param String $layout  The layout to use 
     */
    
public static function display($datareader=null$text=''$width=''$class=''$border=''$cellpadding=''$cellspacing=''$summary=''$caption=''$layout='') {
        
$html = new ViewInfo($datareader$text$width$class$border$cellpadding$cellspacing$summary$caption$layout);
        
$html->addHtml();
    }
}
?>

Vis: HTML source code

ViewInfo, HTML source code

Den fulde HTML kildekode for ViewInfo klassen

<?
<!-- DEBUGViewInfo -->

<
table id="ViewInfoId" width="400" class="tableBusinessCardView baseBorder" border="0" cellpadding="2" cellspacing="0">
 <
tr>
    <
td valign="top">Privat telefon48246030<br />


Finn Rasmussen<br />


HvepseEksperten.dk ApS<br />


Kongens Vænge 79<br />


3400&nbsp;Hillerød<br />


Denmark<br />



</
td>
 </
tr>

</
table>

?>

Vis: Class methods

ViewInfo, Class methods

Her er 'klasse metoderne' for ViewInfo klassen:

  • __construct
  • newHeader
  • newColumnInfo
  • newRow
  • newContent
  • getHtml
  • display
  • setStriphttp
  • setStriptags
  • setEncode
  • setMultipleEditColumns
  • setTable
  • newHiddens
  • newButtons
  • newData
  • getCssClass
  • newColumn
  • isActive
  • isActiveTab
  • isActiveIndex
  • newColumns
  • adjustColumns
  • newCorner
  • getColumns
  • newTextRow
  • getTableHeader
  • getStart
  • getEnd
  • start
  • end
  • setObject
  • set
  • get
  • getAttribute
  • getTag
  • add
  • getSizeof
  • getElement
  • getElements
  • getToogle
  • getMaximize
  • getMinimize
  • newTriangle
  • getStartHtml
  • getEndHtml
  • showsource
  • getClassName
  • getMsg
  • addHtml
  • __toString
  • getCacheFileName
  • save
  • content

Vis: Object vars

ViewInfo, Object vars

Her er 'objekt variable' for ViewInfo klassen:

  • html =>
  • sql =>

MenuRight 
triangle.gif

Dansk

Deutch

English (UK)

France

Italy

Norsk

Svensk

English (USA)


 
blank.gif
MenuBottom 
triangle.gif Copyright @ 1999-2010 www.Finn-Rasmussen.com Powered by myPHP Version (5.3.3-7+squeeze3) 1.11
blank.gif