Sådan benyttes komponenten Skeleton klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/Skeleton.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? Skeleton::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new Skeleton($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten Skeleton klassen
Den fulde PHP kildekode for Skeleton klassen
<?php/** * @package table * @filesource * @see HTML_TABLE_PAGE_PATH.'/Skeleton.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_TABLE_COMPONENT_PATH.'/TableTag.php');/** * The skeleton. * Generates the Skeleton html for a Page built on a Table object * <code> * Usage: * $datareader = null; * $text = "skeleton text"; * $width = "100%"; * $class = "skeletonClass"; * $border = "1"; * $cellpadding = "2"; * $cellspacing = "0"; * $summary = ""; * $caption = ""; * $id = "skeletonID"; * * $skeleton = new Skeleton($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); * print $skeleton->getHtml(); // See this, for usage * Or * Skeleton::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); * Or * Skeleton::start($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); * </code> * @package table */class Skeleton extends TableTag { protected $contentLeft = ''; protected $contentCenter = ''; protected $contentRight = ''; protected $teaserLeft = ''; protected $teaserCenter = ''; protected $teaserRight = ''; /** * 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 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 $id The element ID */ function __construct($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $id='') { $theBorder = $border; $theId = $id != '' ? $id : $this->getClassName()."Id"; parent::__construct($text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $theId); if (defined('DEBUG_LEVEL_SHOW_INFO') && DEBUG_LEVEL & DEBUG_LEVEL_SHOW_INFO) { $this->contentLeft = "<!-- Skeleton Content Left -->\r\n"; $this->contentCenter = "<!-- Skeleton Content Center -->\r\n"; $this->contentRight = "<!-- Skeleton Content Right -->\r\n"; $this->teaserLeft = "<!-- Skeleton Teaser Left -->\r\n"; $this->teaserCenter = "<!-- Skeleton Teaser Center -->\r\n"; $this->teaserRight = "<!-- Skeleton Teaser Right -->\r\n"; } } /** * Returns the html for the skeleton * @return String the complete html */ function getHtml() { $html = ''; if (SKELETON_SHOW & SKELETON_SHOW_LEFT || SKELETON_SHOW & SKELETON_SHOW_CENTER || SKELETON_SHOW & SKELETON_SHOW_RIGHT || SKELETON_SHOW & SKELETON_SHOW_TEASER_LEFT || SKELETON_SHOW & SKELETON_SHOW_TEASER_CENTER || SKELETON_SHOW & SKELETON_SHOW_TEASER_RIGHT) { $html .= $this->getStart(SKELETON_TEXT,SKELETON_WIDTH,SKELETON_CLASS,SKELETON_BORDER,SKELETON_CELL_PADDING,SKELETON_CELL_SPACING); } // Content row if (SKELETON_SHOW & SKELETON_SHOW_LEFT || SKELETON_SHOW & SKELETON_SHOW_CENTER || SKELETON_SHOW & SKELETON_SHOW_RIGHT) { $html .= $this->getRowStart(); } // Left if (SKELETON_SHOW & SKELETON_SHOW_LEFT) { $html .= $this->getColumnStart(CSS_SKELETON_LEFT.' '.CSS_BORDER_RIGHT); $html .= $this->contentLeft; $html .= $this->getColumnEnd(); } // Center if (SKELETON_SHOW & SKELETON_SHOW_CENTER) { $html .= $this->getColumnStart(CSS_SKELETON_CENTER); $html .= $this->contentCenter; $html .= $this->getColumnEnd(); } // Right if (SKELETON_SHOW & SKELETON_SHOW_RIGHT) { $html .= $this->getColumnStart(CSS_SKELETON_RIGHT.' '.CSS_BORDER_LEFT); $html .= $this->contentRight; $html .= $this->getColumnEnd(); } if (SKELETON_SHOW & SKELETON_SHOW_LEFT || SKELETON_SHOW & SKELETON_SHOW_CENTER || SKELETON_SHOW & SKELETON_SHOW_RIGHT) { $html .= $this->getRowEnd(); } // Teaser Row if (SKELETON_SHOW & SKELETON_SHOW_TEASER_LEFT || SKELETON_SHOW & SKELETON_SHOW_TEASER_CENTER || SKELETON_SHOW & SKELETON_SHOW_TEASER_RIGHT) { $html .= $this->getRowStart(); } // Left Teaser if (SKELETON_SHOW & SKELETON_SHOW_TEASER_LEFT) { $html .= $this->getColumnStart(CSS_SKELETON_LEFT.' '.CSS_BORDER_RIGHT); $html .= $this->teaserLeft; $html .= $this->getColumnEnd(); } // Center Teaser if (SKELETON_SHOW & SKELETON_SHOW_TEASER_CENTER) { $html .= $this->getColumnStart(CSS_SKELETON_CENTER); $html .= $this->teaserCenter; $html .= $this->getColumnEnd(); } // Right Teaser if (SKELETON_SHOW & SKELETON_SHOW_TEASER_RIGHT) { $html .= $this->getColumnStart(CSS_SKELETON_RIGHT.' '.CSS_BORDER_LEFT); $html .= $this->teaserRight; $html .= $this->getColumnEnd(); } if (SKELETON_SHOW & SKELETON_SHOW_TEASER_LEFT || SKELETON_SHOW & SKELETON_SHOW_TEASER_CENTER || SKELETON_SHOW & SKELETON_SHOW_TEASER_RIGHT) { $html .= $this->getRowEnd(); } if (SKELETON_SHOW & SKELETON_SHOW_LEFT || SKELETON_SHOW & SKELETON_SHOW_CENTER || SKELETON_SHOW & SKELETON_SHOW_RIGHT || SKELETON_SHOW & SKELETON_SHOW_TEASER_LEFT || SKELETON_SHOW & SKELETON_SHOW_TEASER_CENTER || SKELETON_SHOW & SKELETON_SHOW_TEASER_RIGHT) { $html .= $this->getEnd(); } return $html; } /** * Display html * <code> * Usage: * Skeleton::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); * </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 $id The element ID */ public static function display($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $id='') { $html = new Skeleton($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); $html->addHtml(); }}?>
Den fulde HTML kildekode for Skeleton klassen
<? <table width="100%" class="theTable" border="0" cellpadding="2" cellspacing="0"> <caption>SkeletonId</caption> <tr> <td class="tableSkeletonLeft tableBorderRight" valign="top"><!-- Skeleton Content Left --> </td> <td class="tableSkeletonCenter" valign="top"><!-- Skeleton Content Center --> </td> <td class="tableSkeletonRight tableBorderLeft" valign="top"><!-- Skeleton Content Right --> </td> </tr> <tr> <td class="tableSkeletonLeft tableBorderRight" valign="top"><!-- Skeleton Teaser Left --> </td> <td class="tableSkeletonCenter" valign="top"><!-- Skeleton Teaser Center --> </td> <td class="tableSkeletonRight tableBorderLeft" valign="top"><!-- Skeleton Teaser Right --> </td> </tr> </table> ?>
Her er 'klasse metoderne' for Skeleton klassen:
Her er 'objekt variable' for Skeleton klassen: