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

Navn : Google.php


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();
    ?>

Parent html

Sådan vises komponenten Google klassen

Søgning i http://google.com

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

Google Google Google

PHP source code

Den fulde PHP kildekode for Google klassen

<?
/**
* @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.10
* @since 22-feb-2007
*/

/**
* 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:
*    $google = new Google($text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
*    print $google->getStart();
*    print $google->getHtml();
*    print $google->getEnd();
* Or
*    Google::start($text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
*    // Do something
*    Google::end();
* Or
*    Google::display();
* </code>
* @package menu
*/

class Google extends Table {
    
/**
     * Constructor
     * @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
     */
    
function Google($text='',$width='',$class='',$border='',$cellpadding='',$cellspacing='',$summary='',$caption='') {
        
$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;
        
$this->Table($text,$theWidth,$theClass,$theBorder,$theCellpadding,$theCellspacing,$summary,$caption);
    }

    
/**
     * 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) {
            
$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($html, CACHE_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->text, CSS_BODY);
    }

    
/**
     * Display start html
     * <code>
     * Usage:
     *    Google::formstart($text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
     * </code>
     * @static
     * @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
     */
    
function start($text='',$width='',$class='',$border='',$cellpadding='',$cellspacing='',$summary='',$caption='') {
        
$html = new Google($text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
        
$html->addHtml($html->getStart());
    }

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

    
/**
     * Display html
     * <code>
     * Usage:
     *    Google::display($text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
     * </code>
     * @static
     * @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
     */
    
function display($text='',$width='',$class='',$border='',$cellpadding='',$cellspacing='',$summary='',$caption='') {
        
$html = new Google($text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
        
$html->addHtml();
    }
}
?>

HTML source code

Den fulde HTML kildekode for Google klassen

<?
<h1>Søgning i <!-- 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="Form10" id="Form10">

<
table width="300" class="baseBorder baseBody" border="0" cellpadding="0" cellspacing="0">
<
tr>
  <
td valign="top" class="baseBody"><img src="/images/blank.gif" width="1" height="10" alt="Google" /></td>
  <
td valign="top" class="baseBody"><img src="/images/triangle.gif" width="10" height="10" alt="Google" class="baseBody" /></td>
  <
td valign="middle" class="baseBody"><a 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">
<
input type="text" name="q" id="Label11" class="formXSmall baseBorder" maxlength="255" value="Google" title="Skriv dine søgeord" tabindex="3" /><br />

<
input type="hidden" name="client" id="Hidden12" value="pub-3894654089466394" />

<
input type="hidden" name="forid" id="Hidden13" value="1" />

<
input type="hidden" name="ie" id="Hidden14" value="ISO-8859-1" />

<
input type="hidden" name="oe" id="Hidden15" value="ISO-8859-1" />

<
input type="hidden" name="cof" id="Hidden16" 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;" />

<
input type="hidden" name="hl" id="Hidden17" value="da" />


</
td>
    <
td class="baseBody" valign="middle"><input type="submit" id="Submitbutton18" class="formSearchSubmit baseBorder"
    
value="    - Go" title="Powered by Google Search" tabindex="4" accesskey="O" />

</
td>

</
tr>

<
tr>
  <
td valign="top" class="baseBody"><img src="/images/blank.gif" width="1" height="10" alt="Google" /></td>
  <
td valign="top" class="baseBody"><img src="/images/triangle.gif" width="10" height="10" alt="Google" class="baseBody" /></td>
  <
td valign="middle" class="baseBody"><a 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">
<
input type="text" name="q" id="Label19" class="formXSmall baseBorder" maxlength="255" value="Google" title="Skriv dine søgeord" tabindex="5" /><br />

<
input type="hidden" name="client" id="Hidden20" value="pub-3894654089466394" />

<
input type="hidden" name="forid" id="Hidden21" value="1" />

<
input type="hidden" name="ie" id="Hidden22" value="ISO-8859-1" />

<
input type="hidden" name="oe" id="Hidden23" value="ISO-8859-1" />

<
input type="hidden" name="cof" id="Hidden24" 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;" />

<
input type="hidden" name="hl" id="Hidden25" value="da" />


</
td>
    <
td class="baseBody" valign="middle"><input type="submit" id="Submitbutton26" class="formSearchSubmit baseBorder"
    
value="    - Go" title="Powered by Google Search" tabindex="6" accesskey="E" />

</
td>

</
tr>

</
table>
</
form>

?>

Class methods

Her er 'klasse metoderne' for Google 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
  • google
  • getformstart
  • getformend
  • getheader
  • newdata

Object vars

Her er 'objekt variable' for Google klassen:

  • html =>
  • sql =>
  • elements => Array
  • sizeof => 2
  • text =>
  • width => 300
  • class => baseBorder baseBody
  • border => 0
  • cellpadding => 0
  • cellspacing => 0
  • summary =>
  • caption =>

Google

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


 
Google
Google Copyright @ 1999-2009 www.Finn-Rasmussen.com Powered by myPHP Version 1.10
Google