Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Form  /  Buttons   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 tls.gif     Form  trs.gif tl.gif Language tr.gif tl.gif Layout tr.gif tl.gif Menu tr.gif tl.gif Mvc tr.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  

DEFINE_CRUD_VIEW_CREATE_BUTTON_SHOW






Tilbage

Skjul: Navn

Buttons.php


Vis: Sample code, tutorial

Buttons, Sample code, tutorial

Sådan benyttes komponenten Buttons klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

Buttons, Sådan vises komponenten

Sådan vises komponenten Buttons klassen


Vis: PHP source code

Buttons, PHP source code

Den fulde PHP kildekode for Buttons klassen

<?php
/**
 * @package form
 * @filesource
 * @see HTML_FORM_COMPONENT_PATH.'/Buttons.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_COMMON_PATH.'/Html.php');
require_once(
HTML_BASE_UTIL_PATH.'/Raw.php');
require_once(
HTML_UTIL_COMPONENT_PATH.'/Request.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/ResetButton.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/CancelButton.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/SubmitButton.php');
if (
defined('HTML_BASE_UTIL_PATH')) {
    require_once(
HTML_BASE_UTIL_PATH.'/Div.php');
}

/**
 * Generates a line of predefined buttons, with i.e. cancel, reset and submit
 * <code>
 * Usage:
 *   $buttons = new Buttons($view, $buttons, $layout, $id);
 *   print $buttons->getHtml();
 * Or
 *   Buttons::display($view, $buttons, $layout, $id);
 * </code>
 * @package form
 */

class Buttons extends Html {
    
/**
     * @var String $view The View to use
     */
    
protected $view ''

    
/**
     * @var String $buttons The buttons to use
     */
    
protected $buttons ''

    
/**
     * @var String $layout The Layout to use [left | right]
     */
    
protected $layout '';   

    
/**
     * @var String $id The ID of the submit button, if any
     */
    
protected $id '';   

    
/**
     * Constructor
     * @param String $view    The View to use for the buttons
     * @param String $buttons The buttons to use
     * @param String $layout  The Layout to use for the buttons [left | right]
     * @param String $id      The ID of the submit button, if any
     */
    
function __construct($view=''$buttons=''$layout=''$id='') {
        
parent::__construct();
        
$this->view    $view    != '' $view    '';
        
$this->buttons $buttons != '' $buttons FORM_BUTTON_SHOW;
        
$this->layout  $layout  != '' $layout  CSS_ALIGN_RIGHT;
        
$this->id      $id      != '' $id      "";
    }

    
/**
     * Return the Reset Button as html
     * @return Object The html as an Object
     */
    
function newResetButton() {
        
$object = new Raw();
        if (
$this->buttons FORM_BUTTON_SHOW_RESET) {
            
$object = new ResetButton();
        }
        return 
$object;
    }

    
/**
     * Return the Cancel Button as html
     * @return Object The html as an Object
     */
    
function newCancelButton() {
        
$object = new Raw();
        if (
$this->buttons FORM_BUTTON_SHOW_CANCEL) {
            
$object = new CancelButton();
        }
        return 
$object;
    }
    
    
/**
     * Get the debug tekst for the button
     * @param  String $command The command
     * @param  String $show The flag to show the button or not 
     * @return String The debug tekst
     */
    
function getDebug($command$show) {
         
$debug '';
         switch (
$command) {
            case @
CRUD_VIEW_BASKET_CREATE:
                
$debug 'CRUD_VIEW_BASKET_CREATE';
                break;
            case @
CRUD_VIEW_BASKET_UPDATE:
                
$debug 'CRUD_VIEW_BASKET_UPDATE';
                break;
                
            case 
CRUD_VIEW_FORM_UPDATE:
                
$debug 'CRUD_VIEW_FORM_UPDATE';
                break;
            case 
CRUD_VIEW_FORM_DELETE:
                
$debug 'CRUD_VIEW_FORM_DELETE';
                break;
            case 
CRUD_VIEW_FORM_CREATE:
                
$debug 'CRUD_VIEW_FORM_CREATE';
                break;
            case @
VIEW_LOGIN_FORM:
                
$debug 'VIEW_LOGIN_FORM';
                break;
            case @
CRUD_VIEW_EMAIL_FORM:
                
$debug 'CRUD_VIEW_EMAIL_FORM';
                break;
            case @
CRUD_VIEW_SEARCH_FORM:
                
$debug 'CRUD_VIEW_SEARCH_FORM';
                break;
            default:
                break;
        }
        if (
$debug == '') {
             switch (
$show) {
                case 
FORM_BUTTON_SHOW_SUBMIT:
                    
$debug  'BUTTON_SUBMIT_TEXT';
                    break;
                case 
FORM_BUTTON_SHOW_LOGIN:
                    
$debug  'BUTTON_LOGIN_TEXT';
                    break;
                case 
FORM_BUTTON_SHOW_EMAIL:
                    
$debug  'BUTTON_EMAIL_TEXT';
                    break;
                case 
FORM_BUTTON_SHOW_SEARCH:
                    
$debug  'BUTTON_SEARCH_TEXT';
                    break;
                default:
                    
$debug  "Unknown button OR command $command";
                    break;
            }
        }
        return 
$debug;
    }

    
/**
     * Get the tekst for the button
     * @param  String $command The command
     * @param  String $show The flag to show the button or not 
     * @return String The tekst
     */
    
function getText($command$show) {
         
$text  '';
         switch (
$command) {
            case @
CRUD_VIEW_BASKET_CREATE:
                
$text  BUTTON_INSERT_TEXT;
                break;
            case @
CRUD_VIEW_BASKET_UPDATE:
                
$text  BUTTON_UPDATE_TEXT;
                break;
            case 
CRUD_VIEW_FORM_UPDATE:
                
$text  BUTTON_UPDATE_TEXT;
                break;
            case 
CRUD_VIEW_FORM_DELETE:
                
$text  BUTTON_DELETE_TEXT;
                break;
            case 
CRUD_VIEW_FORM_CREATE:
                
$text  BUTTON_INSERT_TEXT;
                break;
            case @
VIEW_LOGIN_FORM:
                
$text  BUTTON_LOGIN_TEXT;
                break;
            case @
CRUD_VIEW_EMAIL_FORM:
                
$text  BUTTON_EMAIL_TEXT;
                break;
            case @
CRUD_VIEW_SEARCH_FORM:
                
$text  BUTTON_SEARCH_TEXT;
                break;
            default:
                break;
        }
        if (
$text == '') {
             switch (
$show) {
                case 
FORM_BUTTON_SHOW_SUBMIT:
                    
$text  BUTTON_SUBMIT_TEXT;
                    break;
                case 
FORM_BUTTON_SHOW_LOGIN:
                    
$text  BUTTON_LOGIN_TEXT;
                    break;
                case 
FORM_BUTTON_SHOW_EMAIL:
                    
$text  BUTTON_EMAIL_TEXT;
                    break;
                case 
FORM_BUTTON_SHOW_SEARCH:
                    
$text  BUTTON_SEARCH_TEXT;
                    break;
                default:
                    break;
            }
        }
        return 
$text;
    }
    
    
/**
     * Return the Submit Button as html
     * @param String $show The flag to show the button or not 
     * @return Object The html as an Object
     */
    
function newSubmitButton($show) {
        
$object = new Raw();
        if (
$this->buttons $show) {
            
$command Request::get(REQUEST_COMMAND$this->view);
            
$text   '???? WHAT ????';
            
$debug  'UNKNOWN BUTTOMS='.$this->buttons;
            
$text   $this->getText ($command$show);;
            
$debug  $this->getDebug($command$show);;
            
$object->add(new Raw("<!-- $debug -->\r\n"));
            
$name   "";
            
$button = new SubmitButton($name$text);
            
$button->setId($this->id);
            
$object->add($button);
        }
        return 
$object;
    }

    
/**
     * Return the Buttons as html
     * @return Object The html as an Object 
     */
    
function newButtons() {
        
$object = new Raw();
        if (
defined('HTML_PAGE_UTIL_PATH')) {
            
$text  "";
            
$class $this->layout;
            
$align "";
            
$object = new Div($text$class$align); // Override
        
} else {
            
//
        
}
        
/**
         * Create the buttons
         */
        
$object->add($this->newCancelButton());
        
$object->add($this->newResetButton());
        
$object->add($this->newSubmitButton(FORM_BUTTON_SHOW_SUBMIT));
        
$object->add($this->newSubmitButton(FORM_BUTTON_SHOW_LOGIN));
        
$object->add($this->newSubmitButton(FORM_BUTTON_SHOW_EMAIL));
        
$object->add($this->newSubmitButton(FORM_BUTTON_SHOW_SEARCH));
        return 
$object;
    }

    
/**
     * Returns the html for the line of buttons
     * @return String the complete html
     */
    
function getHtml() {
        
$html $this->html;
        
$this->add($this->newButtons());
        
$html .= "<p>".$this->getElements()."</p>\r\n";
        return 
$html;
    }
    
    
/**
     * Display html
     * <code>
     * Usage:
     *    Buttons::display($view, $submit, $layout, $id); 
     * </code> 
     * @static
     * @param String $view   The View to use for the buttons
     * @param String $submit The submit button to use
     * @param String $layout The Layout to use for the buttons [left | right]
     * @param String $id     The ID of the submit button, if any
     */
    
public static function display($view=''$submit=''$layout=''$id='') {
        
$html = new Buttons($view$submit$layout$id);
        
$html->addHtml();
    }
}
?>

Vis: HTML source code

Buttons, HTML source code

Den fulde HTML kildekode for Buttons klassen

<?
<!-- DEBUGButtons -->
<
p><div class="baseAlignRight"><!-- DEBUGCancelButton -->
<
input type="button" class="formButton baseBorder baseBody formXXSmall"
     
onclick="history.back();" value="Fortryd" title="Fortryd" tabindex="12" />

<!-- 
DEBUGResetButton -->
<
input type="reset" class="formButton baseBorder baseBody formXXSmall"
     
value="Nulstil" title="Nulstil (Alt + A)" tabindex="13" accesskey="A" />

<!-- 
BUTTON_SUBMIT_TEXT -->

<!-- 
DEBUGSubmitButton -->
<
input type="submit" class="formButton baseBorder baseBody formXXSmall"
     
value="Go" title="Go (Alt + C)" tabindex="14" accesskey="C" />





</
div>

</
p>

?>

Vis: Class methods

Buttons, Class methods

Her er 'klasse metoderne' for Buttons klassen:

  • __construct
  • newResetButton
  • newCancelButton
  • getDebug
  • getText
  • newSubmitButton
  • newButtons
  • getHtml
  • display
  • 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

Buttons, Object vars

Her er 'objekt variable' for Buttons 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+squeeze9) 1.11
blank.gif