Sådan benyttes komponenten Info klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/Info.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? Info::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new Info($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten Info klassen
Den fulde PHP kildekode for Info klassen
<?php/** * @package base * @see HTML_BASE_PAGE_PATH.'/Info.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(PORTAL_PATH.CURRENT_MYPHP_VERSION.'/Filename.php');/** * Generates the hidden Info as html * <code> * Usage: * $package = basename(HTML_BASE_PAGE_PATH); * $info = ""; * $extension = "php"; * * $html = new Info($package, $info, $extension); * print $html->getHtml(); * Or: * Info::display($package, $info, $extension); * </code> * @package base */class Info { /** * @var String $package The package information to show */ protected $package = ''; /** * @var String $info The information to show */ protected $info = ''; /** * @var String $extension The extension to show */ protected $extension = ''; /** * @var String $classname The name of the classname to show */ protected $classname = ''; /** * @var String $cachefile The name of the cachefile to show */ protected $cachefile = ''; /** * Constructor * @param String $package The package information to show * @param String $info The information to show * @param String $extension The extension to show * @param String $classname The classname to show * @param String $cachefile The cachefile to show */ function __construct($package='', $info='', $extension='', $classname='', $cachefile='') { $this->package = $package; $this->info = $info; $this->extension = $extension; $this->classname = $classname; $this->cachefile = $cachefile; } /** * Get the start tag for the comment defined by the extension * @return String The start of the comment */ function getStartTag() { $html = ""; switch($this->extension) { case 'php': $html .= "<"."?php\r\n"."\t/"."**"; break; case 'js': $html .= "\t/"."**"; break; case 'css': $html .= "\t/"."*"; break; default: $html .= "<!--\r\n"; break; } return $html; } /** * Get the end tag for the comment defined by the extension * @return String The end of the comment */ function getEndTag() { $html = ""; switch($this->extension) { case 'js': case 'css': $html .= "*"."/\r\n"; break; case 'php': $html .= "*"."/\r\n"."?".">\r\n"; break; default: $html .= "-->\r\n"; break; } return $html; } /** * Returns the html for the Banner info * @param boolean $preTags The html pre tags is inserted if true, which is default * @return String the complete html */ function getBanner($preTags=true) { $html = ""; switch($this->extension) { case 'js' : case 'css': case 'php': // Intentionally fall through break; default: if ($preTags) { $html .= "<pre>\r\n"; } break; } $html .= " _____________________________________________________\r\n"; $html .= " ________| |________\r\n"; $html .= " \ | http:/"."/Finn-Rasmussen.com Phone (+45) 40 50 60 69 | /\r\n"; $html .= " \ | Kongens Vænge 79, 3400 Hillerød, Denmark | /\r\n"; $html .= " / |_____________________________________________________| \\\r\n"; $html .= " /___________) (__________\\\r\n"; $html .= "\r\n"; switch($this->extension) { case 'js': break; case 'php': break; default: if ($preTags) { $html .= "</pre>\r\n"; } break; } return $html; } /** * Returns the html for the Info * @return String the complete html */ function getHtml() { $html = ''; // TODO move info code from Writer.php to this class if (defined('INFO_TEXT_COPYRIGHT')) { $html .= $this->getStartTag(); $html .= "**********************************************************\r\n"; $html .= "\t *\r\n"; $html .= "\t * AUTOGENERATED file, DO NOT CHANGE OR EDIT, the full source code is here\r\n"; $html .= $this->getBanner(false); // Skip pre tags $html .= "\t *\r\n"; if ($this->package != '') { $html .= "\t * @package \t: $this->package\r\n"; } if ($this->info != '') { $html .= "\t * @see \t: $this->info\r\n"; } $html .= "\t * @version \t: ".CURRENT_VERSION.MYPHP_RUNTIME."\r\n"; $html .= "\t * @since \t: ".date('d-M-Y H:i:s')."\r\n"; $html .= "\t * @copyright \t: ".INFO_TEXT_COPYRIGHT."\r\n";// $html .= "\t * @author \t: ".MY_SELF."\r\n"; $html .= "\t *\r\n";// $html .= "\t * Address \t: ".INFO_TEXT_CONTACT_ADDRESS."\r\n"; $html .= "\t * Email \t: ".INFO_TEXT_LINK_HREF_EMAIL."\r\n";// $html .= "\t * Contact \t: ".INFO_TEXT_CONTACT_PERSON."\r\n";// $html .= "\t * Phone \t: ".INFO_TEXT_MOBILE_PHONE."\r\n"; $html .= "\t * Web \t: ".INFO_TEXT_AUTHOR."\r\n"; $html .= "\t * \t: This website was created by the myPHP taglib and CMS\r\n"; $html .= "\t * \t: Download a free demo of the myPHP taglib here ...\r\n"; $html .= "\t * \t: ".INFO_TEXT_AUTHOR."/myPHP/\r\n"; if (defined('MYPHP_SITE_PACKAGE_PATH')) { $html .= "\t * @package \t: ".basename(MYPHP_SITE_PACKAGE_PATH)."\r\n";; } if (defined('DOMAIN_NAME') && DOMAIN_NAME != '') { $html .= "\t * @domain \t: ".DOMAIN_NAME."\r\n"; } if (defined('LANGUAGE') && LANGUAGE != '') { $html .= "\t * @language \t: ".LANGUAGE."\r\n"; } if (defined('CMS_LOGIN_USERNAME')) { $html .= "\t * @webmaster \t: ".CMS_LOGIN_USERNAME."\r\n"; } if ($this->cachefile !== '') { $domainname = ""; $languge = ""; $filename = basename($this->cachefile); $filepath = ""; // Must be empty $pos = strlen(PROJECT_PATH); // CACHE_FILES_PATH = PROJECT_PATH.'/cache/files'; $subpath = substr(CACHE_FILES_PATH, $pos); $fileurl = PROJECT_URL.$subpath; $file = Filename::get($domainname, $languge, $filename, $filepath, $fileurl); $html .= "\t * @file \t: ".$file; $html .= " (Autocreated cache file)\r\n"; } if ($this->classname != '') { $html .= "\t * @classname \t: ".$this->classname."\r\n"; } $html .= "\t **********************************************************"; $html .= $this->getEndTag(); } else { if (defined('DEBUG_LEVEL_SHOW_INFO') && DEBUG_LEVEL & DEBUG_LEVEL_SHOW_INFO) { $html .= $this->getStartTag(); $html .= "\t *".$this->getClassName()." disabled\r\n"; $html .= $this->getEndTag(); } } return $html; }// /**// * Display html// * <code>// * Usage:// * Info::display($package, $info, $extension);// * </code> // * @static// * @param String $package The package information to show// * @param String $info The information to show// * @param String $extension The extension to show// */// public static function display($package='', $info='', $extension='') {// $html = new Info($package, $info, $extension);// $html->addHtml();// }}?>
Den fulde HTML kildekode for Info klassen
<? <!-- ********************************************************** * * AUTOGENERATED file, DO NOT CHANGE OR EDIT, the full source code is here _____________________________________________________ ________| |________ \ | http://Finn-Rasmussen.com Phone (+45) 40 50 60 69 | / \ | Kongens Vænge 79, 3400 Hillerød, Denmark | / / |_____________________________________________________| \ /___________) (__________\ * * @version : 1.11 * @since : 07-Feb-2012 02:48:59 * @copyright : Copyright © 1999-2010 http://Finn-Rasmussen.com * * Email : Please, phone me for my email address * Web : http://Finn-Rasmussen.com * : This website was created by the myPHP taglib and CMS * : Download a free demo of the myPHP taglib here ... * : http://Finn-Rasmussen.com/myPHP/ * @domain : kakerlakker.info * @language : da * @webmaster : DEFAULT_CMS_LOGIN_USERNAME(+)kakerlakker.info **********************************************************--> ?>
Her er 'klasse metoderne' for Info klassen:
Her er 'objekt variable' for Info klassen: