Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Component  /  Google   Login nu   Login
blank.gif
««« Se kilde koden
blank.gif
tl.gif Cms tr.gif tls.gif     Component  trs.gif tl.gif Db tr.gif tl.gif Db-basket tr.gif tl.gif Db-login tr.gif tl.gif Db-customer tr.gif tl.gif Db-select tr.gif tl.gif Jquery tr.gif tl.gif Form-elements tr.gif tl.gif Menu-fisheye tr.gif tl.gif Template tr.gif tl.gif Tree-node tr.gif tl.gif Validator tr.gif
blank.gif
blank.gif
arrow-headline.gif Index
MenuLink  MenuLeft  
Tilbage

Skjul: Navn

Google.php


Vis: Sample code, tutorial

Google, Sample code, tutorial

Sådan benyttes komponenten Google klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

Google, Sådan vises komponenten

Sådan vises komponenten Google klassen

Søgning i http://google.com

Fra denne side kan du søge efter mere information.

blank.gif triangle.gif Google

Vis: PHP source code

Google, PHP source code

Den fulde PHP kildekode for Google klassen

<?php
/**
 * @package component
 * @see HTML_COMPONENT_PAGE_PATH.'/Google.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.'/TableHeader.php');
require_once(
HTML_TABLE_COMPONENT_PATH.'/Table.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/Form.php');
require_once(
HTML_BASE_UTIL_PATH.'/Link.php');
require_once(
HTML_COMPONENT_PAGE_PATH.'/Googlebox.php');
if (
defined('HTML_LANGUAGE_UTIL_PATH')) {
    require_once(
HTML_LANGUAGE_UTIL_PATH.'/Translate.php');
}

/**
 * Generates a Google search box
 * <code>
 * Usage:
 *   $datareader  = null;
 *   $text        = "Text header";
 *   $width       = "100%";
 *   $class       = "theTable";
 *   $border      = "1";
 *   $cellpadding = "5"
 *   $cellspacing = "0";
 *   $summary     = "";
 *   $caption     = "";
 *   $id          = "";
 *   
 *   $google = new Google($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id);
 *   print $google->getStart();
 *   print $google->getHtml();
 *   print $google->getEnd();
 * Or
 *   Google::start($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id);
 *   // Do something
 *   Google::end();
 * Or
 *   Google::display();
 * </code>
 * @package menu
 */

class Google extends Table {
    
/**
     * 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 CSS Class name to use
     * @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 $id      The element ID
     */
    
function __construct($datareader=null$text=''$width=''$class=''$border=''$cellpadding=''$cellspacing=''$summary=''$caption=''$id='') {
        
$theText   $text   != '' $text   GOOGLE_TEXT_HEADER;
        
$theWidth  $width  != '' $width  GOOGLE_VIEW_WIDTH;
        
$theClass  $class  != '' $class  GOOGLE_VIEW_CLASS;
        
$theBorder $border != '' $border GOOGLE_VIEW_BORDER;
        
$theCellpadding $cellpadding != '' $cellpadding GOOGLE_VIEW_CELLPADDING;
        
$theCellspacing $cellspacing != '' $cellspacing GOOGLE_VIEW_CELLSPACING;
        
$theId $id !== '' $id $this->getClassName()."Id";
        
parent::__construct($datareader$text$theWidth$theClass$theBorder$theCellpadding$theCellspacing$summary$caption$theId);
    }

    
/**
     * Builds the start html for a Google search box, and return it 
     * @return String The start of the form as html
     */
    
function getFormStart() {
        
$html '';
        if (
defined('COMPONENT_SHOW') && COMPONENT_SHOW COMPONENT_SHOW_GOOGLE || defined('LINK_SHOW') && LINK_SHOW LINK_SHOW_GOOGLE_TOP) {
            
$form = new Form();
            
$html .= $form->getStart(@GOOGLE_COM_CUSTOM_URL);
        }
        return 
$html;
    }

    
/**
     * Builds the end html for a Google search box, and return it 
     * @return String The end if the form as html
     */
    
function getFormEnd() {
        
$html '';
        if (
defined('COMPONENT_SHOW') && COMPONENT_SHOW COMPONENT_SHOW_GOOGLE || defined('LINK_SHOW') && LINK_SHOW LINK_SHOW_GOOGLE_TOP) {
            
$form = new Form();
            
$html .= $form->getEnd();
        }
        return 
$html;
    }

    
/**
     * Return the header text for the Google search box as html
     * @return String The header text as an html
     */
    
function getHeader() {
        
$object = new Raw();
        
$link = new Link("http:/"."/google.com","http:/"."/google.com");
        
$object->add(new Raw("<h1>".@GOOGLE_TEXT_HEADER.$link->getHtml()."</h1>\r\n")); 
        
$object->add(new Raw("<p>".@GOOGLE_TEXT_PARAGRAPH."</p>\r\n"));
        return 
$object->getHtml();
    }

    
/**
     * Builds the html for a Google search box, and return it 
     * This function assumes that you already have a table like:
     * <code>
     * <table ...><tr><td>...</td> ... <google> ... <td>...</td></tr></table>
     * </code>
     * @return String The google seach box as html
     */
    
function getHtml() {
        
$html  $this->html;
        if (
defined('COMPONENT_SHOW') && COMPONENT_SHOW COMPONENT_SHOW_GOOGLE || defined('LINK_SHOW') && LINK_SHOW LINK_SHOW_GOOGLE_TOP) {
            if (
CACHE_MENU && $this->getCacheFileName(CACHE_MENU_PATH) != '' && file_exists($this->getCacheFileName(CACHE_MENU_PATH))) {
                
$html .= $this->content($this->getCacheFileName(CACHE_MENU_PATH));
            } else {
                
$tr = new Tr();
                
$tr->add($this->newData());
                
$this->add($tr);
                
// Render it
                
$html .= $this->getHeader();
                
$html .= $this->getFormStart();
                if (
$this->text != '') {
                    
$html .= $this->getTableHeader();
                }
                
$html .= $this->getStart();
                
$html .= $this->getEnd();
                
$html .= $this->getFormEnd();
                if (
CACHE_MENU) {
                    
$this->save($htmlCACHE_COMPONENT_PATH);
                }
            }
        } else {
            
$html .= "<!-- ".$this->getClassName()." disabled -->\r\n";
        }
        return 
$html;
    }

    
/**
     * Builds the html for a Google search box, and return it 
     * This function assumes that you already have a table like:
     * <code>
     * <table><tr>
     *    <td>...</td> ... <google> ... <td>...</td> // The googlebox
     * </tr></table>
     * </code>
     * @return Googlebox The googlebox as an object
     */
    
function newData() {
        return new 
Googlebox($this->textCSS_BODY);
    }

    
/**
     * Display start html
     * <code>
     * Usage:
     *    Google::formstart($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 for the table
     * @param String $class   The CSS Class name to use
     * @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 
     */
    
public static function start($datareader=null$text=''$width=''$class=''$border=''$cellpadding=''$cellspacing=''$summary=''$caption=''$id='') {
        
$html = new Google($datareader$text$width$class$border$cellpadding$cellspacing$summary$caption$id);
        
$html->addHtml($html->getStart());
    }

    
/**
     * Display end html
     * <code>
     * Usage:
     *    Google::end();
     * </code>
     * @static
     */
    
public static function end() {
        
$html = new Google();
        
$html->addHtml($html->getEnd());
    }

    
/**
     * Display html
     * <code>
     * Usage:
     *    Google::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 for the table
     * @param String $class   The CSS Class name to use
     * @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 $id      The element ID
     */
    
public static function display($datareader=null$text=''$width=''$class=''$border=''$cellpadding=''$cellspacing=''$summary=''$caption=''$id='') {
        
$html = new Google($datareader$text$width$class$border$cellpadding$cellspacing$summary$caption$id);
        
$html->addHtml();
    }
}
?>

Vis: HTML source code

Google, HTML source code

Den fulde HTML kildekode for Google klassen

<?
<!-- DEBUGGoogle -->
<
h1>Søgning i <!-- DEBUGLink -->
<!-- 
http://google.com --><a class="baseLinkColor" href="http://google.com" title="http://google.com">http://google.com</a></h1>

<p>Fra denne side kan du søge efter mere information.</p>

<
form action="/source-code/component/Google/index.php" method="get" name="Form1" id="Form1">

<
table id="GoogleId" width="300" class="baseBorder baseBody" border="0" cellpadding="0" cellspacing="0">
 <
tr>
<!-- 
DEBUGGooglebox -->
  <
td valign="top" class="baseBody"><!-- DEBUGImages -->
<
img src="http://kakerlakker.info/images/blank.gif" width="1" height="10" alt="blank.gif" /></td>
  <
td valign="top" class="baseBody"><!-- DEBUGImages -->
<
img src="http://kakerlakker.info/images/triangle.gif" width="10" height="10" alt="triangle.gif" class="baseBody" /></td>
  <
td valign="middle" class="baseBody"><!-- DEBUGLink -->
<
class="baseBody" href="http://www.google.com/search" title="Powered by Google"><span class="menuBlue">G</span><span class="menuRed">o</span><span class="menuYellow">o</span><span class="menuBlue">g</span><span class="menuGreen">l</span><span class="menuRed">e</span></a></td>
    <
td class="baseBody" valign="middle"><!-- DEBUGLabel -->
<!-- 
Label->getHtml() Text for the label is empty -->

<!-- 
DEBUGText -->
<
input type="text" name="q" id="Label2" class="formXSmall baseBorder" maxlength="255" value="Google" title="Skriv dine søgeord" tabindex="1" /><br />


<!-- 
DEBUGHidden -->
<
input type="hidden" name="client" value="pub-3894654089466394" />

<!-- 
DEBUGHidden -->
<
input type="hidden" name="forid" value="1" />

<!-- 
DEBUGHidden -->
<
input type="hidden" name="ie" value="ISO-8859-1" />

<!-- 
DEBUGHidden -->
<
input type="hidden" name="oe" value="ISO-8859-1" />

<!-- 
DEBUGHidden -->
<
input type="hidden" name="cof" value="GALT:#000000;GL:1;DIV:#ff0000;VLC:ff0000;AH:left;BGC:ffffff;LBGC:ffffff;ALC:ff0000;LC:0000ff;T:000000;GFNT:000066;GIMP:ff0000;FORID:11;" />

<!-- 
DEBUGHidden -->
<
input type="hidden" name="hl" value="da" />

<!-- 
DEBUGHiddens -->


</
td>
    <
td class="baseBody" valign="middle"><!-- DEBUGSubmitButton -->
<
input type="submit" class="formSearchSubmit baseBorder"
     
value="    - Go" title="Powered by Google Search" tabindex="2" accesskey="G" />

</
td>

 </
tr>

</
table>
</
form>

?>

Vis: Class methods

Google, Class methods

Her er 'klasse metoderne' for Google klassen:

  • __construct
  • getFormStart
  • getFormEnd
  • getHeader
  • getHtml
  • newData
  • start
  • end
  • display
  • newTextRow
  • getTableHeader
  • getStart
  • getEnd
  • 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

Google, Object vars

Her er 'objekt variable' for Google 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