Source for file MultiRelationSelect.class.php
Documentation is available at MultiRelationSelect.class.php
* For including this file you have to define the constant "CLASSPATH".
* Because every include in the framework depends on the CLASSPATH definition.
* The CLASSPATH means the relative path to the folder that contains the
echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
* Including the basic class for form items.
require_once( CLASSPATH. "forms/items/ABSTHTMLFormItem.class.php" );
require_once( CLASSPATH. "forms/items/HTMLSelect.class.php" );
require_once( CLASSPATH. "forms/items/HTMLButton.class.php" );
require_once( CLASSPATH. "forms/items/HTMLHiddenInput.class.php" );
require_once( CLASSPATH. "html/JavaScript.class.php" );
require_once( CLASSPATH. "html/HTMLTable.class.php" );
* A class to generate selects mainly to handle multiple relation between two
* +-------+-+ | +-------+-+
* +-------+-+ | +-------+-+
* p - $primaryEntitySelect
* mtlb - $moveToLeftButton
* mtrb - $moveToRightButton
* @author Daniel Plücken <daniel@debakel.net>
* @license http://www.gnu.org/copyleft/lesser.html
* GNU Lesser General Public License
* @copyright Copyright (C) 2005 Daniel Plücken <daniel@debakel.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
* @var object $primaryEntityDBTObject
* @var object $secondaryEntityDBTObject
* @var object $targetDBTObject
* @var string $primaryEntityPrimaryKey
* @var array $primaryEntityLabelFieldArr
* @var string $primaryEntitySelectedValue
* @var string $secondaryEntityPrimaryKey
* @var array $secondaryEntityLabelFieldArr
* @var string $targetPrimaryEntityKey
* @var string $targetSecondaryEntityKey
* @var string $primaryEntityWhereClause
* @var string $secondaryEntityWhereClause
* @var string $targetDBTWhereClause
* @var integer $leftSelectSize
* @var integer $rightSelectSize
* @var string $moveToRightButtonLabel
* @var string $moveToLeftButtonLabel
* @var string $serializedStandardValue
* @var string $moveToRightButtonStyle
* @var string $moveToLeftButtonStyle
* @var string $primaryEntitySelectStyle
* @var string $leftSelectStyle
* @var string $rightSelectStyle
* @var HTMLHiddenInput $hiddenValueInput
* @var string $layout_table_head
* @author Daniel Plücken <daniel@debakel.net>
* @param object $primaryEntityDBTObject The databasetable object of
* the entity which should
* multiple connected to another
* For example one Person is a
* member of different Groups.
* The group is the primary
* entity if you want to assign
* persons to an afore selected
* @param string $primaryEntityPrimaryKey The field of the primary
* entity which should used for
* the relationship to the
* @param array $primaryEntityLabelFieldArr The fieldnames of the primary
* entity for the use of labels
* in the select of the primary
* entity, so that the primary
* entity could be identified by
* the user of the select.
* @param string $primaryEntitySelectedValue The selected value on primary
* @param object $secondaryEntityDBTObject The databasetable object of
* the entity which should
* For example some different
* Groups each have the same
* The person is the seconary
* entity if you want to assign
* persons to an afore selected
* @param string $secondaryEntityPrimaryKey The field of the secondary
* entity which should used for
* the relationship to the
* @param array $secondaryEntityLabelFieldArr The fieldnames which should
* secondary entity, so the user
* of the select is able to
* understand the meaning of
* @param object $targetDBTObject The databasetable object of
* the table that should keep
* the relation of the connected
* @param string $targetPrimaryEntityKey The fieldname where the
* value of the primary key of
* the primaray entity should
* @param string $targetSecondaryEntityKey The fieldname where the
* value of the primary key of
* the secondary entity should
* @param string $primaryEntityWhereClause This is to filter the primary
* entities. If their count is
* only one, the primary entity
* select will not be shown.
* @param integer $leftSelectSize
* @param integer $rightSelectSize
* @param string $moveToRightButtonLabel The label of the button by
* combined with the secondary
* @param string $moveToLeftButtonLabel The label of the button by
* lose their connection to the
* @param string $serializedStandardValue The content of the select on
* parameter overules the real
* value in the databasetable
&$primaryEntityDBTObject,
$primaryEntityPrimaryKey,
$primaryEntityLabelFieldArr,
$primaryEntitySelectedValue,
&$secondaryEntityDBTObject,
$secondaryEntityPrimaryKey,
$secondaryEntityLabelFieldArr,
$targetSecondaryEntityKey,
$primaryEntityWhereClause = "",
$moveToRightButtonLabel = "»",
$moveToLeftButtonLabel = "«",
$serializedStandardValue = ""
* Sets the size of the select appering on the left side.
* @author Daniel Plücken <daniel@debakel.net>
* Sets the size of the select appering on the right side.
* @author Daniel Plücken <daniel@debakel.net>
* Sets the styleclass of the select appering on the left side.
* @author Daniel Plücken <daniel@debakel.net>
* Sets the styleclass of the select appering on the right side.
* @author Daniel Plücken <daniel@debakel.net>
* Sets the styleclass of the button thats function is to move the items from
* the select on the left side to the select on the right side.
* @author Daniel Plücken <daniel@debakel.net>
* Sets the styleclass of the button thats function is to move the items from
* the select on the right side to the select on the left side.
* @author Daniel Plücken <daniel@debakel.net>
* Sets the styleclass of the select appering on the top of the select on the
* @author Daniel Plücken <daniel@debakel.net>
* Somtimes it can be usefule to filter the achievement from the Target
* @author Daniel Plücken <daniel@debakel.net>
* Somtimes it can be usefule to filter the achievement from the secondary
* @author Daniel Plücken <daniel@debakel.net>
* Somtimes it can be usefule to filter the achievement from the Target
* @author Daniel Plücken <daniel@debakel.net>
* This is for example to add a filter select for the target database table to
* the top of this select. Then you will be able to align it flush with the
* right side of this select.
* @author Daniel Plücken <daniel@debakel.net>
* Returns a generated string based on the attributes of this object.
* @author Daniel Plücken <daniel@debakel.net>
$GLOBALS["javascript_content"][] = HTMLSelect::getJS2moveItem( false );
$GLOBALS["javascript_content"][] = HTMLSelect::getJS2getAllValuesFrom( false );
$GLOBALS["javascript_content"][] = JavaScript::getSerialize( false );
$movedArr = Arrays::getIndexAsArray(
if ( is_array( $movedArr ) )
$where_list = implode( "', '", $movedArr );
$this->name. "leftMultiSelect", "",
$tmpLeftSelect->do_not_disable = true;
$tmpLeftSelect->showStandardLabel( false );
$tmpLeftSelect->setMultiple();
$tmpLeftSelect->setStyle( "leftSelectStyle" );
$tmpLeftSelect->showAltoughOnZeroLabelCount();
$this->name. "rightMultiSelect", "",
$tmpRightSelect->do_not_disable = true;
$tmpRightSelect->showStandardLabel( false );
$tmpRightSelect->setMultiple();
$tmpRightSelect->setStyle( "rightSelectStyle" );
$tmpRightSelect->showAltoughOnZeroLabelCount();
if( empty( $primaryEntitySelectedValue ) )
$primaryEntitySelectedValue = $_REQUEST["PrimarySelect"];
$this->name. "PrimarySelect",
$this->primarySelectChangeOrder /* todo */
$tmpPrimaryEntitySelect->setStyle( "primaryEntitySelectStyle" );
$this->name. "_serialized_arr",
serialize( $tmpRightSelect->getValueArr() )
$tmpMoveToLeftButton->setStyle( "moveToRightButtonStyle" );
$tmpMoveToRightButton->setStyle( "moveToLeftButtonStyle" );
$tmp_add_hidden_item = false;
!function_exists( "is_a" )
|| get_parent_class( $this->parentform ) == "htmlform"
$this->parentform->addHiddenFormItem( $tmpHiddenValueInput );
$this->parentform->addHiddenFormItem( $tmpHiddenValueInput );
$tmp_add_hidden_item = true;
. $tmp_parent_form_name. "."
. $this->name. "rightMultiSelect, "
. $tmp_parent_form_name. "."
. $this->name. "leftMultiSelect "
. "document.". $tmp_parent_form_name. "."
. $this->name. "_serialized_arr.value "
. "getAllValuesFrom( document."
. $tmp_parent_form_name. "."
. $tmpRightSelect->name. " "
. $tmp_parent_form_name. "."
. $this->name. "leftMultiSelect, "
. $tmp_parent_form_name. "."
. $this->name. "rightMultiSelect "
. "document.". $tmp_parent_form_name. "."
. $this->name. "_serialized_arr.value "
. "getAllValuesFrom( document."
. $tmp_parent_form_name. "."
. $tmpRightSelect->name. " "
3, $rows, $width, $height,
$cellWidthArr, $cellHeightArr,
$cellpadding = 0, $cellspacing = 0,
$border = 0, $style = "MultiRelationSelect",
"MultiRelationSelectHead", 3
if( count( $tmpPrimaryEntitySelect->ValueArr ) > 1 )
$tbl->addCol( "", "", 2 );
$tmpPrimaryEntitySelect->get(),
$tmpMoveToRightButton->get(). "\r\n"
. $tmpMoveToLeftButton->get(). "\r\n"
? $tmpHiddenValueInput->get()
} // End of class MultiRelationSelect
|