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

Skjul: Navn

ViewTransferType.php


Vis: Sample code, tutorial

ViewTransferType, Sample code, tutorial

Sådan benyttes komponenten ViewTransferType klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

ViewTransferType, Sådan vises komponenten

Sådan vises komponenten ViewTransferType klassen






Vis: PHP source code

ViewTransferType, PHP source code

Den fulde PHP kildekode for ViewTransferType klassen

<?php
/**
 * @package netbank.eksperter.dk
 * @see MYPHP_NETBANK_EKSPERTER_DK_PATH.'/ViewTransferType.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_FORM_COMPONENT_PATH.'/Label.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/Select.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/Options.php');
if (
defined('HTML_JQUERY_PAGE_PATH')) {
    require_once(
HTML_JQUERY_PAGE_PATH.'/Jquery.php');
    require_once(
HTML_JQUERY_PAGE_PATH.'/JQueryFunctions.php');
}

/**
 * Generates the html for a Netbank Transfer Type select view
 * The generated HTML looks like the following
 * 
 *    <label for="id1">$label1</label>
 *    <select name="$name1" id="id1" onchange="HideShow('hiddenTextarea')">
 *       <optgroup label="$labelgroup">
 *          <option value="$value1">$text1</option>
 *          <option value="$value2">$text2</option>
 *          <option value="$value3">$text3</option>
 *       </optgroup>
 *    </select>
 *    
 *    <div id="id3">
 *       <label for="id1">$label2</label>
 *       <textarea name="$name2" id="id2"></textarea>
 *    </div>
 *    
 *    // and some JQuery script will also be generated
 *    
 * <code>
 * Usage:
 *   $name    = "transferType";
 *   $label   = "Transfer type";
 *   $options = array(
 *      array('name'=>$name,'label'=>'Choose ...','value'=>'s','text'=>'Short Msg',),
 *      array('name'=>$name,'label'=>'Choose ...','value'=>'l','text'=>'Long  Msg',),
 *      array('name'=>$name,'label'=>'Choose ...','value'=>'w','text'=>'Wait  Msg',),
 *   );
 *   
 *   $view = new ViewTransferType($name, $label, $options);
 *   print $view->getHtml();
 * Or
 *   ViewTransferType::display($name, $label, $options);
 *
 * Generates a complete View for a Transfer Type select view
 * +--------------------------------
 * | Curently selected option  | V |
 * +--------------------------------
 * |  Choose the group
 * +--------------------------------
 * |     The value1 for the text1
 * |     The value2 for the text2
 * |     The value3 for the text3
 * +--------------------------------
 * 
 * and this will hide or show a textarea, where the user may type a long message text.
 * 
 * </code>
 * @package netbank.eksperter.dk
 */

class ViewTransferType extends Html {
    
/**
     * @var String $name The name of the select element
     */
    
private $name "";
    
/**
     * @var String $label The label text for the associated select element
     */
    
private $label "";
    
/**
     * @var array $options The array of options elements
     * @see Options.php
     */
    
private $options = array();
    
    
/**
     * Constructor
     * @param String $name    The name of the select box
     * @param String $label   The label text for the select box
     * @param array  $options The array of options elements
     * @param String $value   The value for the short message
     */
    
function __construct($name=''$label=''$options=''$value='k') {
        
parent::__construct();
        
/**
         * Initialize the internal object members
         */
        
$this->name     $name    !== "" $name    : @SELECT_NETBANK_PAYMENT_TYPE;
        
$this->label    $label   !== "" $label   Translate::sql(NETBANK_EKSPERTER_DK_TRANSFER_TYPE);
        
$this->options  $options !== "" $options $this->getOptionsArray($value);
        
/**
         * Add the components to the final HTML
         */
        
$this->addComponents($value);
    }
    
    
/**
     * Return an array of the different option elements available
     * <code>
     * If you want just a single optgroup/option return, like the following HTML
     * 
     *    <optgroup label="Choose ...">
     *       <option value="X">Transfer</option>
     *    </optgroup>
     *    
     * Then the array should look like the following:
     * where the 'name' is the selected option in a request
     *    
     * $options = array(
     *    array('name'=>'theName','label'=>'Choose ...','value'=>'X','text'=>'Transfer',),
     * );
     * </code>
     * @param  String $value The value for the short message
     * @return array of the different option key/value pairs
     */
    
private function getOptionsArray($value) {
        
$choose Translate::sql(NETBANK_EKSPERTER_DK_CHOOSE);
        
$options = array(
            
// TODO, translate to the different languages, however this is a pure danish speciality, so skip for now ...
            
array('name'=>$this->name,'label'=>$choose,'value'=>$value,'text'=>Translate::sql(NETBANK_EKSPERTER_DK_TYPE_SHORT),),
            array(
'name'=>$this->name,'label'=>$choose,'value'=>'l'   ,'text'=>Translate::sql(NETBANK_EKSPERTER_DK_TYPE_LONG),),
            array(
'name'=>$this->name,'label'=>$choose,'value'=>'v'   ,'text'=>Translate::sql(NETBANK_EKSPERTER_DK_TYPE_ADVIS),),
        );
        return 
$options;
    }
    
    
/**
     * 
     * @param unknown_type $value
     * @return Ambigous <string, unknown>
     */
    
public function getText($value) {
        
$text "";
        foreach(
$this->options as $no=>$option) {
            foreach(
$option as $aKey=>$aValue) {
//                print "$value-$no $aKey=>$aValue<br />";
                
if ($aKey == 'value' && $value == $aValue) {
                    
$text .= $option['text'];
                }
            }
        }
        return 
$text;
    }
    
    
/**
     * Build the components which will generate the final HTML
     * and add these to the final html.
     * 
     * This is actually here the HTML is build, and in this scenario you have the following:
     * 
     * <label>Label text</label>
     * <select name="">
     *     // one or more of these
     *    [<optgroup>
     *        <option value="">The option text</option>
     *     </optgroup>]
     * </select>
     * <div id=""> // hidden or visisble
     *    <label>Text areae label</label>
     *    <textarea name="">The long text</textarea>
     * </div>
     * 
     * @param  String $value The value which decides if the div tag will show og hide
     */
    
private function addComponents($value) {
        
$this->add(new Label($this->label));
        
$class "";
        
$select = new Select($this->name$class);
        
$select->setId($this->name.'Id');
        
$select->add(new Options($this->options));
        
$this->add($select);
        
/**
         * The hidden textarea field for long text messages.
         * The textarea is hidden as default behavior
         */
        
$id  "longMessageId";
        
$div = new Div(""""""$id);
        
$text Translate::sql(NETBANK_EKSPERTER_DK_LONG_MESSAGE);
        
$div->add(new Label($text));
        
$div->add(new Textarea(@SELECT_NETBANK_LONG_MESSAGE));
        
$div->add($this->newScript($this->name$id$value));
        
$this->add($div);
    }
    
    
/**
     * Return a new Script object, with the required JQuery software for plug-n-play
     * @param  String $name  The name for the select element, which controls the hide/show behaviour
     * @param  String $id    The ID for the div tag to show/hide
     * @param  String $value The value which decides if the div tag will show og hide
     * @return Script the fully populated Script object
     */
    
private function newScript($name$id$value) {
        
$script = new Script();
        if (
defined('JQUERY_SHOW_JQUERY') && JQUERY_SHOW JQUERY_SHOW_JQUERY) {
            
$script->add(JQueryFunctions::newFunctionToogle($name$id$value));
        } else {
            
$script->add(new Raw("/* JQuery is disabled */\r\n"));
        }
        return 
$script;
    }
    
    
/**
     * Display html
     * <code>
     * Usage:
     *    ViewTransferType::display($name, $label, $options); 
     * </code>
     * @static
     * @param String $name    The name of the select box
     * @param String $label   The label text for the select box
     * @param array  $options The array of options elements
     * @param String $value   The value for the short message
     */
    
public static function display($name=''$label=''$options=''$value='k') {
        
$html = new ViewTransferType($name$label$options$value);
        
$html->addHtml();
    }
}
?>

Vis: HTML source code

ViewTransferType, HTML source code

Den fulde HTML kildekode for ViewTransferType klassen

<?
<!-- DEBUGViewTransferType -->
<!-- 
DEBUGLabel -->
<
label for="Label1" accesskey="O" title="Accelerator key, use (Alt + O)">
    <
b><span class="baseColorDark">O</span>verførselstype</b>&nbsp; (Alt O) </label><br />

<!-- 
DEBUGSelect -->
<
select name="SELECT_NETBANK_PAYMENT_TYPE" id="SELECT_NETBANK_PAYMENT_TYPEId" class="formXLARGE formSelect" tabindex="1">
<!-- 
DEBUGOptions -->
<!-- 
DEBUGOptgroup -->
 <
optgroup label="Vælg ...">
<!-- 
DEBUGOption -->
    <
option value="k">Overførsel med kort besked</option>

<!-- 
DEBUGOption -->
    <
option value="l">Overførsel med lang besked</option>

<!-- 
DEBUGOption -->
    <
option value="v">Overførsel med lang beskedventeadvisering</option>

</
optgroup>



</
select><br />

<
div id="longMessageId"><!-- DEBUGLabel -->
<
label for="Label2" accesskey="L" title="Accelerator key, use (Alt + L)">
    <
b><span class="baseColorDark">L</span>ang&nbsp;besked&nbsp;til&nbsp;modtager</b>&nbsp; (Alt L) </label><br />

<!-- 
DEBUGTextarea -->
<
textarea name="SELECT_NETBANK_LONG_MESSAGE" id="Label2" rows="5" cols="35" class="formXLARGE baseBorder baseBody" tabindex="2"></textarea><br />

<!-- 
DEBUGScript -->
<
script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
        if ($(
"#SELECT_NETBANK_PAYMENT_TYPEId").val() !== "k" ) {
            $(
"#longMessageId").show();
        } else {
            $(
"#longMessageId").hide();
        }
    $(
":reset").click(function() {
        $(
"#longMessageId").hide();
    });
    $(
"#SELECT_NETBANK_PAYMENT_TYPEId").change(function() {
        if ($(
this).val() !== "k" ) {
            $(
"#longMessageId").show();
        } else {
            $(
"#longMessageId").hide();
        };
    });
});


//]]>
</script>

</div>


?>

Vis: Class methods

ViewTransferType, Class methods

Her er 'klasse metoderne' for ViewTransferType klassen:

  • __construct
  • getText
  • display
  • setObject
  • set
  • get
  • getAttribute
  • getTag
  • add
  • getSizeof
  • getElement
  • getElements
  • getToogle
  • getMaximize
  • getMinimize
  • newTriangle
  • getStartHtml
  • getEndHtml
  • getHtml
  • showsource
  • getClassName
  • getMsg
  • addHtml
  • __toString
  • getCacheFileName
  • save
  • content

Vis: Object vars

ViewTransferType, Object vars

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