function hBoxesDefault($mode) { # KFD 10/8/08, correction to setting of context, make dtimes # use the same format that we display, so they # don't come back looking changed when they have not $oldRow = array(); #hprint_r($this->row); foreach ($this->table['flat'] as $colname => $colinfo) { if (!isset($this->row[$colname])) { $oldRow[$colname] = ''; } else { if ($colinfo['type_id'] != 'dtime') { $oldRow[$colname] = $this->row[$colname]; } else { $oldRow[$colname] = date('m/d/Y h:i A', dEnsureTs($this->row[$colname])); } } } ContextSet('OldRow', $oldRow); // KFD 5/27/07, This line replaces the commented line // below that used ahInputsComprehensive(). We now // want to allow more complex arrangements, and // eventually do ui.yaml and stuff. // // In any event, this remains a two-line routine return $this->hBoxesX3($mode); //return $this->hBoxesFromProjection($mode); }
/** * @deprecated */ function ahInputsComprehensive(&$table, $mode, $row = array(), $projection = '', $opts = array()) { $table_id = $table['table_id']; $ahcols = array(); $stuff = aColInfoFromDD($table); // Grab these for later $colerrs = vgfget('errorsCOL', array()); $acols = DDProjectionResolve($table, $projection); if (isset($opts['drilldownmatches'])) { $ddmatches = $opts['drilldownmatches']; } else { $ddmatches = DrillDownMatches(); } $name_prefix = isset($opts['name_prefix']) ? $opts['name_prefix'] : 'x2t_'; /* KFD 5/10/06, will be used to store original values */ $context_row = ContextGet('OldRow', array()); // KFD 5/23/07, VERY IMPORTANT STRUCTURAL CHANGE TO CODE // From now on, all generated javascript for widgets will // be produced in this routine we are calling out to. // This returns ahInputsComprehensive to the role of just // generating HTML. // // NOPE. CANCEL THAT as of 5/24/07, we figured out that // ahinputscomprehensive is not salvagable, it was split up // into about 6 other routines. See comments up at top // of routine. $ajscols = ajsFromDD($table, $name_prefix); // KFD 1/12/07, parse out possible ajax options. $ajax_page = ''; if (is_array(ArraySafe($opts, 'ajaxcallback', ''))) { $ajax_page = $opts['ajaxcallback']['page']; $ajax_columns = explode(',', $opts['ajaxcallback']['columns']); } $hpsize = ArraySafe($opts, 'hpsize', 25); $colparms = ArraySafe($opts, 'colparms', array()); // KFD 1/16/07, pull out the list of columns that we should save to // session as we go $savetosession = ArraySafe($opts, 'savetosession', ''); $savetosession = explode(',', $savetosession); // KFD 1/16/07, begin to allow hard-coded overrides. This is required // to get it to recognize multi-column foreign keys $columnoverrides = ArraySafe($opts, 'columnoverrides', array()); $columndynparms = ArraySafe($opts, 'columndynparms', array()); // KFD 5/21/07, When in search mode, force the primary key // to be a dynamic lookup to itself. Trust me, it makes sense. // Best way to understand is to go into search mode on something // like a customers table. Well no, it doesn't make sense after // all, eliminates ability to use >, < - and lists //if($mode=='search') { // $columnoverrides[$table['pks']]['table_id_fko']=$table_id; //} // ***** STEP 1 OF 3: Derivations // Loop through each control and put everything we know and // can figure out about it into the array, such as name, // value, class, enabled/disabled, size and so forth. //$tabindex=1; foreach ($acols as $colname) { # HACK KFD 6/2/08. if ($colname == '') { continue; } $colinfo =& $table['flat'][$colname]; $value = ColumnValue($table, $row, $mode, $colname); /* KFD 5/10/06 */ //$name=AddControl($table_id,$skey,$colname,$value); $name = $name_prefix . $colname; $context_row[$colname] = $value; // Establish if user can write, then set tabindex accordingly $writable = isset($ddmatches[$colname]) ? false : DDColumnWritable($colinfo, $mode, $value); $propti = $writable ? hpTabIndexNext() : 999; $ahcols[$colname] = array('writeable' => $writable, 'hparms' => '', 'hinner' => '', 'hright' => '', 'html' => '', 'errors' => '', 'parms' => array('value' => $value, 'type' => 'textbox', 'class' => 'inp-' . $mode, 'name' => $name, 'size' => min($hpsize, $colinfo['dispsize']) + 1, 'maxlength' => $colinfo['dispsize'], 'tabindex' => $propti)); if (isset($opts['dispsize'])) { $ahcols[$colname]['parms']['size'] = min($ahcols[$colname]['parms']['size'], $opts['dispsize']); } // decimals get an extra digit for maxlength if ($colinfo['colscale'] != 0) { $ahcols[$colname]['parms']['maxlength'] = $colinfo['dispsize'] + 1; } // Trap keys for two of our modes if ($mode == 'search') { $ahcols[$colname]['parms']['onkeypress'] = "doButton(event,13,'but_lookup')"; } //if($mode=='ins') { // $ahcols[$colname]['parms']['onkeypress']="doButton(event,13,'but_save')"; //} // Lose maxlength if in search mode if ($mode == 'search') { unset($ahcols[$colname]['parms']['maxlength']); } // These are passed in on the $opts array if (isset($colparms[$colname])) { foreach ($colparms[$colname] as $name => $value) { $ahcols[$colname]['parms'][$name] = $value; } } // Slip in the errors if they are there. $colerrsx = ArraySafe($colerrs, $colname, array()); if (count($colerrsx) > 0) { $ahcols[$colname]['errors'] = "<span class=\"x2columnerr\">" . implode("<br/>", $colerrsx) . "</span>"; } // refinement: PK caps if ($table["capspk"] == "Y" && $colinfo["primary_key"] == "Y") { $ahcols[$colname]['parms']['onBlur'] = "javascript:this.value=this.value.toUpperCase();\" "; } // KFD 1/12/07 If an ajax callback column, put that in. if ($ajax_page != '') { if (in_array($colname, $ajax_columns)) { $ahcols[$colname]['parms']['onChange'] = "javascript:AjaxCol('{$colname}',this.value);"; } } // KFD 1/16/07, see if we need to save to session //if(in_array($colname,$savetosession)) { // $x=$ahcols[$colname]['parms']['name']; // $ahcols[$colname]['parms']['onchange'] // ="andrax('?gp_ajax2ssn=$colname&gp_val='+ob('$x').value)"; //} } /* KFD 5/10/06, will be used to store original values */ #hprint_r($context_row); ContextSet("OldRow", $context_row); // ***** STEP 2 OF 3: HTML Decisions and derivations // Decide which kind of control to use for each one, and // do any overrides and extra stuff that may be necessary foreach ($acols as $colname) { # HACK KFD 6/2/08. if ($colname == '') { continue; } $col =& $ahcols[$colname]; $colinfo =& $table['flat'][$colname]; $col['input'] = 'input'; $coltype = $table['flat'][$colname]['type_id']; //echo "$colname is $coltype<br>"; switch ($coltype) { case 'date': $col['parms']['data-date-format'] = 'yyyy-mm-dd'; case 'time': $col['input'] = 'select'; $v = $col['parms']['value']; if ($v === '') { $hinner = '\\n<option SELECTED value="">--:-- --</option>'; } else { $hinner = '\\n<option value="">--:-- --</option>'; } for ($x = 0; $x <= 1425; $x += 15) { $s = $v === strval($x) ? ' SELECTED ' : ''; $hinner .= "\n<option {$s} value=\"{$x}\">" . hTime($x) . "</option>"; } $col['hinner'] = $hinner; //unset($col['parms']['class']); unset($col['parms']['type']); unset($col['parms']['size']); unset($col['parms']['maxlength']); break; case 'cbool': $col['parms']['type'] = 'checkbox'; if ($col['parms']['value'] == 'Y') { $col['hparms'] .= ' CHECKED '; } $col['parms']['value'] = 'Y'; // checkboxes must always be 'Y' break; case 'mime-x': $col['html'] = hImageFromBytes($table_id, $colname, $row[$table['pks']], $row[$colname]); //unset($col['parms']['value']); break; case 'text': case 'mime-h-f': case 'mime-h': //$x=SQL_UNESCAPE_BINARY($col['parms']['value']); //ob_start(); //ehFCKEditor($col['parms']['name'],$x); //$col['html']=ob_get_clean(); //$col['html']= $col['input'] = 'textarea'; $col['parms']['rows'] = isset($colparms[$colname]['rows']) ? $colparms[$colname]['rows'] : '10'; $col['parms']['cols'] = isset($colparms[$colname]['cols']) ? $colparms[$colname]['cols'] : '50'; //if($coltype=='mime-h') { // $col['hinner']=base64_decode($col['parms']['value']); //} //else { $col['hinner'] = $col['parms']['value']; //} // 10/20/06, thanks to csnyder@gmail.com via nyphp-talk $col['hinner'] = htmlentities($col['hinner']); unset($col['parms']['value']); break; case 'numb': case 'int': case 'money': if (vgaGet('AJAX_X3', false) == true) { $col['parms']['size'] = 12; $col['parms']['style'] = 'text-align: right'; break; } //default: // $col['parms']['type']='textbox'; // break; } // KFD 1/16/07, allow Dynamic list or Dropdown, and override // if present $table_id_fko = isset($columnoverrides[$colname]['table_id_fko']) ? $columnoverrides[$colname]['table_id_fko'] : $colinfo['table_id_fko']; if ($table_id_fko != '' && $colinfo['type_id'] != 'date') { // Add in the html off to the right $col['hright'] = "<a tabindex=999 href=\"javascript:Info2('" . $table_id_fko . "','" . $col['parms']['name'] . "')\">Info</a>"; // This nifty undocumented option causes an ajax request to // fetch a row after the value changes if (isset($columnoverrides[$colname]['fetchrow'])) { $col['parms']['onblur'] = "FetchRow('{$table_id_fko}','" . $col['parms']['name'] . "')"; } if ($col['writeable']) { $x_table = DD_TableRef($table_id_fko); $fkdisplay = ArraySafe($x_table, 'fkdisplay', ''); // This is unnecessary in either case unset($col['parms']['maxlength']); // This branch is the HTML SELECT, for small lists //if($fkdisplay<>'dynamic') { if ($fkdisplay != 'dynamic') { // KFD 2/16/07. Figure out if there is a filter column $fkk = $colinfo['table_id_fko'] . $colinfo['suffix']; $uifc = trim(ArraySafe($table['fk_parents'][$fkk], 'uifiltercolumn')); $matches = array(); if ($uifc != '') { $matches[$uifc] = ArraySafe($row, $uifc, ''); } $col['input'] = 'select'; $col['hinner'] = hOptionsFromTable($table_id_fko, ArraySafe($row, $colname), '', $matches); // For search mode, or for allow-empty $allow_empty = $table['fk_parents'][$fkk]['allow_empty']; if ($mode == 'search' || $allow_empty) { $col['hinner'] = '<OPTION></OPTION>' . $col['hinner']; } // These parms not used for html select //unset($col['parms']['class']); unset($col['parms']['type']); unset($col['parms']['size']); } else { // Turn on this branch with fk_coldisplay=dynamic, // gives us an ajax display //$fkparms='gp_dropdown='.$table_id.'&gp_col='.$colname; $fkparms = 'gp_dropdown=' . $table_id_fko; $xcdps = ArraySafe($columndynparms, $colname, array()); foreach ($xcdps as $xcdp) { $xcdpn = $name_prefix . $xcdp; $fkparms .= "&adl_{$xcdp}='+ob('{$xcdpn}').value+'"; } if ($col['writeable']) { //$col['input']='select'; $col['parms']['onkeyup'] = "androSelect_onKeyUp(this,'{$fkparms}',event)"; $col['parms']['onkeydown'] = "androSelect_onKeyDown(event)"; //$col['parms']['onkeyup'] // ="ajax_showOptions(this,'$fkparms',event)"; } // The dynamic list assigns value of key here: hidden($col['parms']['name'], $col['parms']['value']); $col['parms']['autocomplete'] = 'off'; $col['parms']['name'] .= '_select'; $col['parms']['size'] = 10; $col['parms']['value'] = hValueForSelect($table_id_fko, $col['parms']['value']); } } } } // ***** STEP 3 OF 3: Generate actual HTML // Finally, generate the html for each one, with special // cases for checkboxes, readonly, and so forth foreach ($acols as $colname) { # HACK KFD 6/2/08. if ($colname == '') { continue; } // Some things, like Images, are completely setup earlier, // so just skip them completely if ($ahcols[$colname]['html'] != '') { // echo "Did it for $colname"; continue; } $col =& $ahcols[$colname]; $colinfo =& $table['flat'][$colname]; $hparms = $col['hparms']; if (!$col['writeable']) { $hparms .= " READONLY "; $col['parms']['class'] = 'ro'; } //if(isset($col['parms']['size'])) $col['parms']['size']=12; // now just run out the parms foreach ($col['parms'] as $pname => $pvalue) { if ($pname == 'value') { if ($colinfo['type_id'] == 'date' && $pvalue != '') { $pvalue = hDate(strtotime($pvalue)); } $pvalue = htmlentities($pvalue); } $hparms .= ' ' . $pname . ' ="' . trim($pvalue) . '"'; } $hparms .= ' id="' . $col['parms']['name'] . '"'; // If there is any generated stuff, do that also KFD 5/23/07 if (isset($ajscols[$colname])) { foreach ($ajscols[$colname] as $parm => $code) { $hparms .= ' ' . $parm . ' = "' . $code . '"'; } } $inp = $col['input']; // 10/20/06, thanks to chsnyder@gmail.com via nyphp-talk // for mentioning we left out html_entities $ahcols[$colname]['html'] = "<" . $inp . $hparms . ">" . $col['hinner'] . "</" . $inp . ">"; // Now stick a date next to every last one of them if ($table['flat'][$colname]['type_id'] == 'date') { if ($col['writeable']) { $cname = $col['parms']['name']; $ahcols[$colname]['html'] .= " " . "<img src='clib/dhtmlgoodies_calendar_images/calendar1.gif' value='Cal'\n onclick=\"displayCalendar(ob('{$cname}'),'mm/dd/yyyy',this,true)\">"; } } // If there is an error, put that now $ahcols[$colname]['html'] .= $ahcols[$colname]['errors']; } // return the entire comprehensive array return $ahcols; }
function index_hidden_page() { global $AG; $sessok = !LoggedIn() ? false : true; // KFD 3/6/08, moved here from the main stream of index_hidden // because these are relevant only to page processing if (gpExists('x_module')) { SessionSet('AGMENU_MODULE', gp('x_module')); } elseif (vgaGet('nomodule') != '' && SessionGet('AGMENU_MODULE') == '') { SessionSet('AGMENU_MODULE', vgaGet('nomodule')); } // If the search flag is set, we need to know what class for this // application handles searchs if (gpExists('gp_search')) { gpSet('gp_page', vgaGet('SEARCH_CLASS')); } // Load up a list of pages that public users are allowed to see, // with home and password always there. global $MPPages; // allows it to be in applib $MP = array(); //$MPPages= array(); // This is the old method, load $MPPages from its own file if (file_exists_incpath('appPublicMenu.php')) { include_once 'appPublicMenu.php'; } if (!is_array($MPPages)) { $MPPages = array(); } $MPPages['x_home'] = 'Home Page'; $MPPages['x_login'] = '******'; $MPPages['x_noauth'] = 'Authorization Required'; $MPPages['x_password'] = "******"; $MPPages['x_mpassword'] = "******"; $MPPages['x_paypalipn'] = 'Paypal IPN'; // If the install page exists, it will be used, no getting // around it. $install = $GLOBALS['AG']['dirs']['application'] . 'install.php'; $instal2 = $GLOBALS['AG']['dirs']['application'] . 'install.done.php'; if (file_exists($install)) { if (gp('gp_install') == 'finish') { rename($install, $instal2); } else { $MPPages['install'] = 'install'; gpSet('gp_page', 'install'); } } // First pass is to look for the "flaglogin" flag. This says save all // current page settings and go to login screen. They will be restored // on a successful login. Very useful for links that say "Login to // see nifty stuff..." if (gp('gp_flaglogin') == '1') { gpSet('gp_flaglogin', ''); gpToSession(); gpSet('gp_page', 'x_login'); } // Second pass redirection, pick default page if there // is none, and verify public pages. // $gp_page = gp('gp_page'); if ($gp_page == '') { if (vgfGet('LoginAttemptOK') === true && vgfGet('x4') === true) { $gp_page = 'x4init'; gpSet('gp_page', 'x4init'); SessionSet('TEMPLATE', 'x4'); } else { if (function_exists('appNoPage')) { $gp_page = appNoPage(); } else { if (!LoggedIn()) { $gp_page = FILE_EXISTS_INCPATH('x_home.php') ? 'x_home' : 'x_login'; } else { // KFD 3/2/07, pull vga stuff to figure defaults if (vgaGet('nopage') != '') { $gp_page = vgaGet('nopage'); } else { $gp_page = 'x_welcome'; } } } } } // If they are trying to access a restricted page and are not // logged in, cache their request and redirect to login page if (!$sessok && !isset($MPPages[$gp_page])) { if (vgfGet('loglogins', false)) { fwLogEntry('1014', 'Page access w/o login', $gp_page); } gpToSession(); $gp_page = 'x_login'; } // If pos is activated and the current requested page does not // match what they are cleared for, redirect to login if (vgaGet('POS_SECURITY', false) == true && SessionGet('ADMIN') == false) { if (SessionGet('POS_PAGE', '', 'FW') != $gp_page) { gpToSession(); $gp_page = 'x_login'; } } gpSet('gp_page', $gp_page); // Make any database saves. Do this universally, even if save // was not selected. If errors, reset to previous request. //if(gp('gp_save')=='1') processPost(); processPost(); if (Errors()) { gpSetFromArray('gp_', aFromGp('gpx_')); } // Put Userid where HTML forms can find it //vgfSet("UID",SessionGet("UID")); //if (vgfSet("UID")=="") { vgfSet("UID","Not Logged In"); } // THIS IS NEWER X_TABLE2 version of drilldown commands, // considerably simpler than the older ones. It makes use of // three gp_dd variables. // // Notice how we process drillbacks FIRST, allowing a link // to contain both drillback and drilldown, for the super-nifty // effect of a "drill-across" hidden('gp_dd_page'); hidden('gp_dd_skey'); hidden('gp_dd_back'); if (intval(gp('gp_dd_back')) > 0 && $sessok) { // this is drillback $dd = ContextGet('drilldown', array()); $back = intval(gp('gp_dd_back')); if (count($dd) >= $back) { $spot = count($dd) - $back; $aback = $dd[$spot]; gpSet('gp_skey', $aback['skey']); gpSet('gp_page', $aback['page']); $gp_page = $aback['page']; gpSet('gpx_skey', $aback['skey']); gpSet('gpx_page', $aback['page']); gpSetFromArray('parent_', $aback['parent']); if (!gpExists('gp_mode')) { gpSet('gp_mode', 'upd'); } $dd = $spot == 0 ? array() : array_slice($dd, 0, $spot); ContextSet('drilldown', $dd); ContextSet('drilldown_top', $aback['page']); //ContextSet('drilldown_level',count($dd)); } } if (gp('gp_dd_page') != '' && $sessok) { // this is drilldown... $matches = DrillDownMatches(); $matches = array_merge($matches, aFromGP('parent_')); $dd = ContextGet('drilldown', array()); $newdd = array('matches' => $matches, 'parent' => aFromGP('parent_'), 'skey' => gp('gpx_skey'), 'page' => gp('gpx_page')); $dd[] = $newdd; ContextSet('drilldown', $dd); ContextSet('drilldown_top', gp('gp_dd_page')); //ContextSet('drilldown_level',count($dd)); // having saved the stack, redirect to new page. $tnew = gp('gp_dd_page'); $gp_page = $tnew; gpSet('gp_page', $tnew); if (gp('gp_dd_skey') != '') { gpSet('gp_skey', gp('gp_dd_skey')); gpSet('gp_mode', 'upd'); } // Clear search of new page, set filters to blank processPost_TableSearchResultsClear($tnew); ConSet('table', $tnew, 'search', array()); } // If no drilldown commands were received, and we are not on // the page that is the top, user must have picked a new page // altogether, wipe out the drilldown stack if (gp('gp_page') != ContextGet('drilldown_top', '')) { ContextSet('drilldown', array()); ContextSet('drilldown_top', ''); } // Must always have these on the user's form. These can // be retired with x_Table, they are for old drilldown // hidden("dd_page", ""); hidden("dd_ddc", ""); hidden("dd_ddv", ""); hidden("dd_ddback", ""); hidden("dd_action", "searchexecute"); hidden("dd_skey", ""); // Load user preferences just before display UserPrefsLoad(); $dir = $GLOBALS['AG']['dirs']['root'] . 'application/'; if (file_exists($dir . $gp_page . ".page.yaml")) { include 'androPage.php'; $obj_page = new androPage(); if ($obj_page->flag_buffer) { ob_start(); } $obj_page->main($gp_page); if ($obj_page->flag_buffer) { vgfSet("HTML", ob_get_clean()); //ob_end_clean(); } vgfSet("PageSubtitle", $obj_page->PageSubtitle); } else { $obj_page = DispatchObject($gp_page); if ($obj_page->flag_buffer) { ob_start(); } $obj_page->main(); if ($obj_page->flag_buffer && vgfGet('HTML') == '') { vgfSet("HTML", ob_get_contents()); ob_end_clean(); } vgfSet("PageSubtitle", $obj_page->PageSubtitle); } // Save context onto the page. Note that it is not really // protected by these methods, just compressed and obscured. // $t2 = serialize($GLOBALS['AG']['clean']['gpContext']); $t2 = gzcompress($t2); $t2 = base64_encode($t2); Hidden('gpContext', $t2); // KFD 3/7/07, give the app the final opportunity to process // things before the display, while logged in. if (function_exists('appdisplaypre')) { appDisplayPre(); } // ...and write output and we are done. Assume if there was // no buffering that the output is already done. if ($obj_page->flag_buffer != false) { // Work out what template we are using index_hidden_template('x2'); // KFD 5/30/07, send back only main content if asked if (gp('ajxBUFFER') == 1) { echo "andromeda_main_content|"; ehStandardContent(); echo "|-|_focus|" . vgfGet('HTML_focus'); $ajax = ElementReturn('ajax', array()); echo '|-|' . implode('|-|', $ajax); echo '|-|_title|' . vgfGet('PageTitle'); } elseif (defined('_VALID_MOS')) { // This is the default branch, using a Joomla template // DUPLICATE ALERT: This code copied into // index_hidden_x4Dispatch() above global $J; $mainframe = $J['mainframe']; $my = $J['my']; $mosConfig_absolute_path = $J['mC_absolute_path']; $mosConfig_live_site = $J['mC_live_site']; $template_color = $J['template_color']; $template_color = 'red'; $file = $GLOBALS['AG']['dirs']['root'] . '/templates/' . $mainframe->GetTemplate() . "/index.php"; include $file; } elseif ($obj_page->html_template !== '') { // This is newer style, let the class specify the template. include $obj_page->html_template . '.php'; } else { // This is old style, defaults to "html_main.php", can be // set also by vgaSet() or by gp(gp_out) $html_main = vgaGet('html_main') == '' ? 'html_main' : vgaGet('html_main'); switch (CleanGet("gp_out", "", false)) { case "print": include "html_print.php"; break; case "info": include "html_info.php"; break; case "": include $html_main . ".php"; break; default: } } } }