function WDG_JsRecordset($RecordsetName) { $rs = $GLOBALS[$RecordsetName]; if (is_resource($rs)) { $recordset = new KT_Recordset($rs); } else { $recordset =& $rs; } $nl = "\r\n"; $this->outputString .= <<<EOD <script> top.jsRawData_{$RecordsetName} = [ EOD; $fieldCount = $recordset->FieldCount(); $fieldNames = array(); for ($i = 0; $i < $fieldCount; $i++) { $meta = $recordset->FetchField($i); if ($meta) { $fieldNames[] = $meta->name; $this->outputString .= ($i == 0 ? '[' : ', ') . '"' . $meta->name . '"'; } } $this->outputString .= <<<EOD ], //data EOD; while (!$recordset->EOF) { $arr = array(); foreach ($fieldNames as $field) { $arr[] = $recordset->Fields($field); } $this->outputString .= WDG_phparray2jsarray($arr) . ', '; $recordset->MoveNext(); } $this->outputString .= <<<EOD [] ]; top.{$RecordsetName} = new JSRecordset('{$RecordsetName}'); </script> EOD; //restore old rs position $recordset->MoveFirst(); }
/** * Setter. Sets the attachmetns * Only for PRO version * @param string rename rule * @access public */ function setAttachmentRenameRule($renameRule) { if ($this->type == 'recordset' && $this->error == '') { if (!isset($GLOBALS[$this->rsName])) { $this->error = new tNG_error('EMAIL_ERROR_RECORDSET', array(), array($this->rsName)); return; } $recordset =& $GLOBALS[$this->rsName]; if (is_resource($recordset)) { $rs = new KT_Recordset($recordset); } else { $rs =& $recordset; } $rs->MoveFirst(); while (!$rs->EOF) { $GLOBALS["row_" . $this->rsName] = $rs->fields; $renameRule2 = KT_DynamicData($renameRule, null, null, false, array()); // security if (substr(KT_realpath($this->folder . $renameRule2, false), 0, strlen($this->folder)) != $this->folder) { $this->error = new tNG_error("EMAIL_ERROR_FOLDER", array(), array(KT_realpath($this->folder . $renameRule2, false), $this->folder)); break; } else { if (is_file($this->folder . $renameRule2)) { $this->attachments[] = $this->folder . $renameRule2; } } $rs->MoveNext(); } $rs->MoveFirst(); } else { if ($this->type == 'custom' && $this->error == '') { $renameRule = KT_DynamicData($renameRule, $this->getTng(), $this->escapeMethod, $this->getUseSavedData(), array()); // security if (substr(KT_realpath($this->folder . $renameRule, false), 0, strlen($this->folder)) != $this->folder) { $this->error = new tNG_error("EMAIL_ERROR_FOLDER", array(), array(KT_realpath($this->folder . $renameRule, false), $this->folder)); } else { if (is_file($this->folder . $renameRule)) { $this->attachments[] = $this->folder . $renameRule; } } } } $this->type = ''; $this->folder = ''; $this->rsName = ''; }