Source for file DBMS_FIELD_SELECTLIST.phpclass
Documentation is available at DBMS_FIELD_SELECTLIST.phpclass
* Class file DBMS_FIELD_SELECTLIST.phpclass
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: DBMS_FIELD_SELECTLIST.phpclass,v 1.33 2008/11/24 23:30:31 pitlinz Exp $
require_once dirname(__FILE__
) .
_OCSP_DIRSEP_ .
"DBMS_FIELD.phpclass";
require_once dirname(__FILE__
) .
_OCSP_DIRSEP_ .
"INFA_DBMS_FIELD_SELECTLIST.phpclass";
* Class DBMS_FIELD_SELECTLIST
* handels select fields (<SELECT>)
* the class holds all values available in $this->myValues
* serialization is done with expolde and implode functions
* the default seperator is "\n" make sure the database column
* is big enough to hold all the values.
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: DBMS_FIELD_SELECTLIST.phpclass,v 1.33 2008/11/24 23:30:31 pitlinz Exp $
* source file of the class
* @var string $classSrcFile
// ###########################################################
// OBJECT (CONST) VAR DECLARATION
// ###########################################################
* @var boolean $multiselect
* @var boolean $showListNullEntry
* @var boolean $nullToZero set the NullOptionValue to 0
* @var int $selectsize (added into <select ... size="e;$this->selectsize"e; ... >)
* @var string $selectAddTag (additional html tag attributes for <select ...>)
* @var int $reloadFormOnChange (if >0 a onChange event forces to reload the form)
* @staticvar boolean $static_fixedSelSize
* use a table of checkboxes or radio boxes instead of
* @var boolean $showAsCheckRadio
* show not in list values
* if true all values of $valArr are added to the list
* even if the are not in myValues
* @var boolean $notInLstValues
* seperator used in multiselect mode
* NOTE: this::save() sets this too
* do not htmlspecialchars list values
* @var boolean $lstValueIsHtml
* wether to lookup in the select list for the representation of a value
* or just output the value in list view
* @var boolean $showValuesInList
* @var boolean $ajax_onChange_FuncName
* xtype to use in the extJS framework for the field
* @var string $extJSxType
// ###########################################################
// OBJECT SETTINGS METHODS
// ###########################################################
// ###########################################################
// ###########################################################
* extracts the array out of the input string
while(list
($line,$keyVal)=
each($arr)) {
if ((!empty($tmp[0])) ||
($tmp[0] ===
"0")) {
if (isset
($tmp[1]) &&
!empty($tmp[1]))
$str_ret[$tmp[0]]=
$tmp[1];
$str_ret[$tmp[0]]=
$tmp[0];
foreach($str_ret as $key =>
$val) {
* does nothing in this class becaus $this->myValues
* is stored internal. Is redefined in descendants
* make sure this is called once before accessing
//overwrite in subclasses if needed
// -----------------------------------------------------------
// -----------------------------------------------------------
* returns the html select tag onChange statement to reload the form
return " onChange=\"ocsp_from_fieldChanged('".
$this->myForm->getHTMLName().
"','".
$this->getJsName().
"',this.value);\"";
// ###########################################################
// OBJECT HTML FORM METHODS
// ###########################################################
* @version pk-04-08-31 $debug added
function getInputTag($aValue,$arrName=
"DBVAL",$debug=
False)
$debug=
($debug ||
$this->fldDebug); // <pk-04-08-31>
* returns the html code for the select
* @deprecated since pk-08-02-06
protected function getSelectTag($aValue,$arrName=
"DBVAL",$debug=
False) {
$debug=
($debug ||
$this->fldDebug); // <pk-04-08-31>
if ($debug) echoDebugMethod(__FILE__
,get_class($this),"DBMS_FIELD_SELECTLIST::getSelectTag()","\$aValue=".
print_r($aValue,TRUE).
"<br />\n\$arrName: $arrName");
//$s_tag = $this->js_getFieldScript($debug);
* returns the html code for the checkbox or radiobox table
* @var string $s_onChange
* @version pk-06-10-30 bugfix 1 entry uses 2 columsn
$debug=
($debug ||
$this->fldDebug); // <pk-04-08-31>
$s_input=
"<input type=\"checkbox\" name=\"".
$arrName.
"[".
$this->myName.
"][]".
"\" ";
$s_input=
"<input type=\"radio\" name=\"".
$arrName.
"[".
$this->myName.
"]".
"\" ";
if ($debug) echoDebug(__FILE__
,"<pre>Values: \n".
print_r($a_ValArr,TRUE).
"</pre>");
$s_tag =
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border:none;margin:0px;padding:0px\" align=\"center\">";
if ($this->nullToZero) $s_nullValue=
"0"; else $s_nullValue=
"";
$s_tag.=
"\t<td align=\"right\" valign=\"top\">".
$s_input.
" value=\"".
$s_nullValue.
"\" ".
(empty($aValue) ?
"checked" :
"").
"></td><td>".
$this->nullLabel.
"</td>\n";
if ($debug) echo
"<pre>getCheckRadio::myValues\n".
print_r($this->myValues,TRUE).
"</pre>";
foreach($this->myValues as $key =>
$s_val) {
$s_tag.=
"\t<td align=\"right\" valign=\"top\">".
$s_input .
"value=\"".
htmlspecialchars($key).
"\" ";
// if ((!empty($key) || ($key==="0")) && in_array($key,$a_ValArr)) $s_tag.="checked"; // <pk-06-07-28 />
if (in_array($key,$a_ValArr)) $s_tag.=
"checked"; // <pk-06-08-19 /> a array key can't be NULL
$s_tag.=
" ></td><td>".
$s_val.
"</td>";
while ($i_colNr++ <
$this->selectsize) $s_tag.=
"\t<td colspan=\"2\"> </td>\n"; // <pk-06-10-30 />
* returns the html code for the readonly field
if ($debug) echo
"<hr /><p><b>DBMS_FIELD_SELECTLIST::getScreenValue($aValue,$arrName,...)</b></p>";
while(list
($key,$val)=
each($valArr)) {
if (!empty($val) || isset
($this->myValues[intval($val)])) { // <pk-06-05-15> // <pk-07-02-28 />
} else if (!empty($aValue)) {
* returns the html code to show the value(s) in a list (table column)
function getListValue($aValue,$arrName=
"DBVAL",$debug=
False) {
if ($debug) echo
"<hr /><p><b>DBMS_FIELD_SELECTLIST::getListValue($aValue,$arrName,...)</b></p>";
if (empty($aValue) &&
($this->nullToZero)) { // <pk-06-10-09>
while(list
($key,$val)=
each($valArr)) {
if (!empty($val)) { // <pk-06-05-15>
} else if (!empty($aValue)) {
// ################################################
// ################################################
* returns the html code for the search comp types
return "<input type=\"hidden\" name=\"".
$arrName.
"[".
$this->myName.
"][COMPTYPE]\" value=\"=\"> = ";
* returns the html code for a searchformular element
* @param mixed $aValue the value to set
* @param string $nameAdd @see DBMS_FIELD::getInputTag()
$s_tag =
"<select name='".
$arrName.
"[".
$this->myName.
"][VALUE]' size=\"1\" ";
} else $valArr=
array(NULL);
// ###########################################################
// OBJECT VALUE CHECK/RETURN METHODS
// ###########################################################
* add slashes to the value from getValue to add it to a sql command
* @param string $aValue the value
* @param array $err error array
* @param string $arrName name of the global array to access field gloabl ${$arrName}
* @deprecated since pk-08-08-11
function slashedValue($aValue,&$err,$arrName=
"DBVAL",$debug=
False)
if ($debug) echo
"<hr><p><b>DBMS_FIELD_SELECTLIST::slashedValue($aValue,$err,$arrName,$debug)</b> (".
get_class($this).
"/".
$this->myName.
")</p>";
$val =
$this->getValue($aValue,$err,$arrName,$debug);
if ($debug) echo
"<p>slashedValue: returned ".
$GLOBALS[$this->getGlobalDBObjIdx()]->qs_getSlashedValue($val).
" for $aValue</p>";
return $GLOBALS[$this->getGlobalDBObjIdx()]->qs_getSlashedValue($val);
} else if ($val ===
False) {
if ($debug) echo
"<p>slashedValue: NULL returned for $aValue</p>";
return $GLOBALS[$this->getGlobalDBObjIdx()]->qs_getNullStmt();
// ###########################################################
// ###########################################################
// ###########################################################
// implementation of INFA_DBMS_FIELD
// ###########################################################
// ###########################################################
// ###########################################################
// --------------------------------------------------------
// --------------------------------------------------------
// --------------------------------------------------------
// --------------------------------------------------------
* returns an array of field to bie shown in the edit form
* by using editTbl_echoForm
* the array is in the form:
* [FLDLAB] (complete html code with <td></td>)
* [FLDVAL] (complete html code with <td></td>)
$a_ret=
parent::editTbl_getFieldEditArr($debug);
* save the filed definition form
$bol_ret =
parent::editTabl_save();
$this->nullLabel =
(isset
($_POST['nullLabel']) ?
$_POST['nullLabel'] :
"");
$this->showNullOption =
((isset
($_POST['showNullOption']) &&
intval($_POST['showNullOption'])) ?
TRUE :
False );
$this->nullToZero =
((isset
($_POST['nullToZero']) &&
intval($_POST['nullToZero'])) ?
TRUE :
False );
if (!$this->allowNull &&
(isset
($_POST['allowNull']) &&
intval($_POST['allowNull'])))
// we have not null db column check if we should use 0 for the null value
$this->multiselect =
((isset
($_POST['MULTISELECT']) &&
intval($_POST['MULTISELECT'])) ?
TRUE :
False );
$this->showAsCheckRadio =
((isset
($_POST['showAsCheckRadio']) &&
intval($_POST['showAsCheckRadio'])) ?
TRUE :
False); // <pk-05-09-16 />
$this->notInLstValues =
((isset
($_POST['notInLstValues']) &&
intval($_POST['notInLstValues'])) ?
TRUE :
False); // <pk-05-12-01 />
if (isset
($_POST['SELECTSIZE']) &&
intval($_POST['SELECTSIZE'])) {
if (isset
($_POST['VALUES']) &&
!empty($_POST['VALUES'])) {
$this->selectAddTag =
(isset
($_POST['selectAddTag']) ?
$_POST['selectAddTag'] :
"");
$this->mySeperator=
"\n"; // <pk-06-02-10 /> set to the default seperator
// if a derived class uses a different one you have to overwrite this
$this->lstValueIsHtml=
((isset
($_POST['lstValueIsHtml']) &&
intval($_POST['lstValueIsHtml'])) ?
TRUE :
False); // <pk-06-05-29 /> <pk-07-5-17 /> E_ALL
$this->showValuesInList=
((isset
($_POST['showValuesInList']) &&
intval($_POST['showValuesInList'])) ?
TRUE :
False); // <pk-06-07-22 /> <pk-07-5-17 /> E_ALL
// --------------------------------------------------------
// --------------------------------------------------------
* returns an array of jOCSP/jQuery Modules which are required
* $arr_ret[]="script url";
if ($debug) echoDebugMethod(__FILE__
,get_classe($this),"DBMS_FIELD::jOCSP_getRequiredModules()");
$arr_ret =
parent::jOCSP_getRequiredModules($debug);
'CLASS' =>
'jOCSP.FLDOBJ_SelectList',
'SRC' =>
OCSP_OBJ::getConf('SYSTEMURL').
"jOCSP/formFields/jOCSP_FLDOBJ_SelectList.js"
'CLASS' =>
'jQuery.fn.ajaxSubmit',
* returns additional object elements of the field object
* array definition: [elemName] = value
* NOTE: do not js_escapte value this is done when building the json object
$arr_ret =
parent::jOCSP_getAdditonalFieldObjElems($debug);
$arr_ret['reloadOnChange'] =
"false";
$arr_ret['reloadUrl'] =
"'" .
pcf_js_escape($_SERVER['REQUEST_URI']) .
"'";
$arr_ret['reloadOnChange'] =
"true";
if (!($str_reloadUrl =
$this->getControl()->getReloadUrl()) ||
empty($str_reloadUrl))
$arr_ret['reloadUrl'] =
"'" .
pcf_js_escape($str_reloadUrl) .
"'";
$arr_ret['reloadOnChange'] =
"true";
$arr_ret['reloadOnChange'] =
"false";
$arr_ret['doReload'] =
"function(aValue) {alert('reload type not defined');}";
$arr_ret['fldClass'] =
"'FLDOBJ_SelectList'";
$arr_ret['debug'] =
True;
* returns a javascript to be called for reloading the form
* @todo could sometimes not get the controll
alert('Reload: " .
$this->myName .
"');";
if (obj_form = jOCSP.getFormByHash('" .
$this->getControl()->jOCSP_getfrmHash() .
"'))
obj_form.fieldChanged('" .
$this->getDOMId() .
"',this.value);
$str_ret .=
" else { alert('Form: " .
$this->getControl()->jOCSP_getfrmHash() .
" not found\\nField: " .
$this->myName .
"\\n" .
basename(__FILE__
) .
" L: " . __LINE__ .
"');}";
$str_ret .=
"} catch(e) {alert('Field: " .
$this->myName .
": ' + e);}";
* returns options of an ext js field config object
* NOTE the return string is NOT enclosed by {}
$arr_ret =
parent::getExtJSConfigOptions($debug);
$arr_ret['name'] =
"'" .
$this->myName .
"_showField'";
$arr_ret['id'] =
"'" .
$this->getJsName() .
"_showField'";
$arr_ret['hiddenId'] =
"'" .
$this->getJsName() .
"'";
$arr_ret['store'] =
"new Ext.data.SimpleStore({
fields: [{name: 'optVal'}, {name: 'optLabel'}],
foreach($this->myValues as $m_key =>
$m_val)
$arr_ret['store'] .=
"]})";
$arr_ret['displayField'] =
"'optLabel'";
$arr_ret['valueField'] =
"'optVal'";
$arr_ret['forceSelection'] =
"true";
$arr_ret['mode'] =
"'local'";
$arr_ret['typeAhead']=
"true";
$arr_ret['triggerAction'] =
"'all'";
$arr_ret['selectOnFocus'] =
"true";
//$arr_ret['editable'] = "false";
//$arr_ret['disableKeyFilter'] = "true";
// --------------------------------------------------------
// --------------------------------------------------------
* returns an array of <select> attributes
* @see http://www.w3schools.com/tags/tag_select.asp
* array('Attribute' => "\"Value\"");
* NOTE: the output of value is done as is.
* Ensure values are in " if needed
* echo $attribute . "=" . $value;
$arr_ret['multiple']=
"\"multiple\"";
* returns the html code for the <select> field
foreach($arr_attributes as $str_att =>
$str_val)
$str_tag .=
" " .
$str_att .
"=" .
$str_val;
// options ------------------------------
* returns a string with the options
* calls setMyValues to be sure $this->myValues is set correkt
protected function getOptionList($aValArr,$addNull=
False,$debug=
False) {
$debug=
($debug ||
$this->fldDebug); // <pk-04-08-31>
// if (($this->allowNull) || ($addNull)) {
if ($addNull) { /* <pk-05-02-08 addNull -> addNULL /> */
$str_ret.=
"\t<option value=\"\">".
$this->nullLabel.
"</option>\n";
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"flippedValues=<pre style=\"font-size:80%;padding-left: 100px;\">".
print_r($a_flipVal,TRUE).
"</pre>");
foreach($this->myValues as $m_key =>
$m_val)
$str_ret.=
"<option value=\"".
$m_key.
"\"";
if (isset
($a_flipVal[$m_key]))
$str_ret.=
" selected=\"selected\"";
unset
($a_flipVal[$m_key]);
$str_ret.=
">".
strip_tags($m_val['SHOWFIELD']).
"</option>\n";
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"flippedValues=<pre style=\"font-size:80%;padding-left: 100px;\">".
print_r($a_flipVal,TRUE).
"</pre>");
foreach($aValArr as $s_value) {
if (!empty($s_value)) $str_ret.=
"<option value=\"$s_value\" selected=\"selected\">$s_value</option>\n";
* returns the html code for a button to reload the form
* @version pk-06-10-10 link name added
$str_ret =
$this->myView->getButton('RELOAD',$debug);
$str_ret.="<img src=\"{$OCSP_CONF['SYSIMGURL']}icons-16x16/reload.gif\" border=\"0\" alt=\"refresh form\" class=\"button\"
onClick=\"ocsp_from_fieldChanged('".$this->myForm->getHTMLName()."','".$this->getJsName()."');\" title=\"Formular aktualisieren\"
// --------------------------------------------------------
// --------------------------------------------------------
* returns the field value if its an array,
* it is imploded with $this->mySeperator as seperator
* @param string $aValue the value
* @param array $err error array
* @param string $arrName name of the array to access fieldsarray gloabl ${$arrName}
function getValue($aValue,&$err,$arrName=
"DBVAL",$debug=
False) {
if (empty($aValue) &&
($this->nullToZero)) $aValue=
"0"; //<pk-05-12-10 />
return parent::getValue($aValue,$err,$arrName,$debug);
} // end class DBMS_FIELD_SELECTLIST
Documentation generated on Thu, 08 Jan 2009 17:42:47 +0100 by phpDocumentor 1.4.0a2