Source for file DBMS_FIELD_DBSELECTLIST.phpclass
Documentation is available at DBMS_FIELD_DBSELECTLIST.phpclass
* Class file DBMS_FIELD_DBSELECTLIST.phpclass
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: DBMS_FIELD_DBSELECTLIST.phpclass,v 1.11 2008/08/08 02:00:42 pitlinz Exp $
// ---------------------------------------------------------
// ---------------------------------------------------------
* Class DBMS_FIELD_DBSELECTLIST
* handels select fields (<SELECT>) with DB Values
* extends DBMS_FIELD_SELECTLIST to get the values from the database
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version pk-06-07-24 getPopupLinkJs() added
* @version $Id: DBMS_FIELD_DBSELECTLIST.phpclass,v 1.11 2008/08/08 02:00:42 pitlinz Exp $
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* @constant string CLASS_SRC_FILE
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** class vars ------------------------------------------------------ */
* multidimensonal array of already loaded values
* array[$this->getClassCacheKey()][$value] = {query result}
* if self::$classValPopulateTs[$this->getClassCacheKey()] > (time() - ini_get('max_execution_time'))
* the array should be up to date and there is no need to query the db
* for list modes simply check if the value is set
protected static $classCache =
array();
* array of class value populate time stemps
* @var array $classValPopulateTs
protected static $classValPopulateTs =
array();
/*** class methods --------------------------------------------------- */
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** compostion --------------------------------------------------- */
/*** attributes -------------------------------------------------- */
* a sql query to get data array
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// OBJECT SETTINGS METHODS
// ---------------------------------------------------------------------------
* 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['SELECT']['FLD_LSTVALS']=
NULL; // unset parent field
$a_ret['SELECT']['FLD_VALQUERY']=
array(
'FLDLAB'=>
"Query (SELECT KEY,VALUE ..)",
'FLDVAL'=>
"<textarea name=\"SELECTQUERY\" cols=\"40\" rows=\"5\" wrap=\"off\">".
htmlspecialchars($this->query).
"</textarea>"
* save the filed definition form
* @version pk-08-06-13 use OCSP_OBJ::defaultReadDBObj()
if (isset
($_POST['SELECTQUERY'])) // <pk-07-05-17> E_ALL
// -----------------------------------------------------------
// -----------------------------------------------------------
* sets populates $this->myValues array from the database
* @global string ${$arrName}
* @version pk-08-06-13 use OCSP_OBJ::defaultReadDBObj()
* @version pk-08-08-01 use self::$classCache
(DBMS_FIELD_DBSELECTLIST::$classValPopulateTs[$this->getClassCacheKey()] >
(time() -
ini_get('max_execution_time')))
$dbVals=
array("NULL"=>
"keine Datensätzegefunden");
// ###########################################################
// OBJECT HTML FORM METHODS
// ###########################################################
* return the link to the new or edit form
* the link is a template which is parsed with global ${$this->myDataArrName}
* also ##VALUE## is replaced with the current value
global $
{$this->myDataArrName};
if ($debug) echo
"<pre>\$valArr:\n".
print_r($valArr,TRUE).
"</pre>";
if (empty($url)) return ""; // empty url stop
unset
($valArr[$this->myName]); // do not add own values to new link
if ($this->enableEdit) { // user can change value -> get the current value from the select
if (!strstr($url,"?")) $url.=
"?"; // ensure we are adding get values from now
if (!empty($this->myURIQueryArrgs)) { // add aditional args
if ($debug) echo
"<blockquote><p>Args: ".
$this->myURIQueryArrgs.
"</p>";
if ($addArgs=
explode(";",$this->myURIQueryArrgs)) {
unset
($addArgs[$this->myName]); // do not add field value as it is added later
foreach($addArgs as $key) {
if (!empty($valArr[$key])) { // only not empty values
$url.=
"&$key=".
$valArr[$key];
} else if (!empty($valArr[$this->myURIQueryArrgs])) {
$url.=
"&".
$this->myURIQueryArrgs.
"=".
$valArr[$this->myURIQueryArrgs];
if ($debug) echo
"</blockquote>";
if ($mode !=
FRM_MODE_NEW) { // ensure the field value is in the param list
// generate the fields to set update the field from the popup
$oArgs['FORMID'] =
$myForm->getId(); // id of the form
$oArgs['FORMNAME'] =
$this->getMyFormName(); // html name of the form (document.forms[...])
$oArgs['ARRNAME'] =
$this->myDataArrName; // name of the data array
$oArgs['FIELD'] =
$this->myName; // name of the field
if (!intval($this->popupWndWidth)) {
$this->popupWndWidth=
$this->newWndWidth;
$this->popupWndWidth=
$this->editWndWidth;
$this->popupWndWidth=
400;
if (!intval($this->popupWndpopupWndHeight)) {
$this->popupWndpopupWndHeight=
$this->editWndHeight;
$this->popupWndpopupWndHeight=
$this->editWndpopupWndHeight;
$this->popupWndpopupWndHeight=
300;
$jCmd.=
"var url_".
$this->myName.
"='".
$url.
"';\n";
$jCmd.=
"var opt_".
$this->myName.
"='width=".
$this->popupWndWidth.
",height=".
$this->popupWndHeight.
",toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes';\n";
$jCmd.=
"hWnd_".
$this->myName.
".focus();\n";
if ($debug) echo
"<blockquote><pre>".
htmlspecialchars($jCmd).
"</pre></blockquote>";
// -------------------------------------------------
// -------------------------------------------------
if (isset
($options['FRMARRAYNAME']) &&
(!empty($options['FRMARRAYNAME'])))
global $
{$this->myDataArrName};
if (isset
($options['fldValue']))
if (isset
($options['fldValue']) &&
!empty($options['fldValue']))
$arr_values[] =
$options['fldValue'];
if (obj_fld = document.getElementById('" .
$options['domId'] .
"'))
if (obj_fld.options[i].value != '')
if (obj_fld.options[i].defaultSelected)
defaultValues[obj_fld.options[i].value] = obj_fld.options[i].value;
obj_fld.options[i] = new Option('" .
$this->nullLabel .
"','',false," .
(sizeof($arr_values) ?
"false" :
"true") .
");
foreach($this->myValues as $str_val =>
$str_text)
if (obj_fld.options[i].value != '" .
pcf_js_escape($str_val) .
"')
if (obj_fld.options[i].defaultSelected)
defaultValues[obj_fld.options[i].value] = obj_fld.options[i].value;
int_len = obj_fld.options.length;
obj_fld.options[i] = null;
// restore default values
if (defaultValues.length)
int_len = obj_fld.options.length;
for (i = 0;i < int_len;i++)
if (defaultValues[obj_fld.options[i].value] == obj_fld.options[i].value)
obj_fld.options[i].defaultSelected = true;
} // end class DBMS_FIELD_DBSELECTLIST
Documentation generated on Thu, 08 Jan 2009 17:41:18 +0100 by phpDocumentor 1.4.0a2