'Help', 'BANNER2' => 'Explanations and notes about the website', 'TITLE' => 'Help', 'MODULENAME' => 'help.phpx', 'NAV1' => 'HELP' ); $HELPCFG = array( 'ADMINLEVEL' => '4' ); //-------------------------------------------------------------------------- // BEGIN Field Definitions, Arrays, Variables, etc //-------------------------------------------------------------------------- $ALLFIELD = array( 'help_id', 'meta_id', 'contact_id', 'language', 'topic', 'subtopic', 'application', 'context', 'module', 'keywords', 'sequence', 'level', 'table_name', 'field_name', 'help_type', 'short_help', 'long_help', 'summary', 'last_modified' ); $SHOW = array( 'topic', 'subtopic', 'application', 'context', 'module', 'table_name', 'field_name', 'help_type', 'summary' ); // Fields that can have query drill down links on display $LINK = array( 'contact_id', 'language', 'topic', 'subtopic', 'application', 'module', 'table_name', 'field_name', 'help_type' ); // Fields that are from a Menu Picklist that can have new members $EXTEND = array( 'help_type', 'subtopic' ); // Required for New Entry $RequiredField = array( 'contact_id' => 'enter contact id', 'language' => 'enter language, default is US_English', 'topic' => 'enter topic', 'application' => 'enter application', 'context' => 'enter context', 'module' => 'enter php module name', 'summary' => 'enter help summary', 'help_type' => 'enter help type', 'short_help' => 'enter short version or quick help', 'long_help' => 'enter long version or detailed help' ); // Global query choices $InValidChoice = array( 'All', 'None', '', ' ', 'Choose' ); // Edit record fields with edit disabled $NoEdit = array( 'help_id', 'last_modified' ); $FieldType = array( 'help_type' => 'Menu', 'language' => 'Menu', 'contact_id' => 'People', 'keywords' => 'LongText', 'summary' => 'LongText', 'short_help' => 'TextArea', 'long_help' => 'TextArea' ); $MenuBase = "SELECT choice from menu where table_name = 'help' "; $Menu = array( "help_type" => "$MenuBase AND field_name = 'help_type'", "language" => "$MenuBase AND field_name = 'language'" ); // Display exceptions from default tdcs centered display table cell $JustifyCss = array( 'summary', 'tds' // small left justified ); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ spew_header($FMT); if (array_key_exists('Action', $_REQUEST)) { echo "
\n"; // DEVONLY print_r($_REQUEST); // DEVONLY echo "\n"; // DEVONLY //---------------------------------------------------------------------- // Insert New Entry //---------------------------------------------------------------------- if ($_REQUEST['Action'] == "Insert New Entry" ) { // Get list of fields for this table $fieldlabels = get_field_labels('help','help',$JJNCFG['DBNAME']); $fields = array_keys($fieldlabels); // Eliminate all keys that have invalid answers foreach ($fields as $f) { $altkey = "NEW_" . $f; if (in_array($_REQUEST[$f], $InValidChoice)) { unset ($_REQUEST[$f]); } if (in_array($_REQUEST[$altkey], $InValidChoice)) { unset ($_REQUEST[$altkey]); }else{ if ( isset($_REQUEST[$altkey])){ $_REQUEST[$key] = $_REQUEST[$altkey]; unset ($_REQUEST[$altkey]); } } } // Delete auto_increment primary keys unset ($goodfields['help_id']); // Requred fields gauntlet foreach ($RequiredField as $key => $val) { if (! array_key_exists($key, $goodfields)) { $err .= '
|
$finalsql
\n"; //DEBUG $result = $dbh->query($finalsql); echo "'; // DEBUG DEVONLY print htmlspecialchars(print_r($fieldlabels), ENT_QUOTES); // DEBUG DEVONLY print ''; // DEBUG DEVONLY // // Query Original for comparision, only update deltas // $sql = "SELECT * from help WHERE help_id = " . $dbh->quote($help_id); $result = $dbh->query($sql); echo "
$sql
\n"; // DEVONLY $Original = array(); $Original = $result->fetch(PDO::FETCH_ASSOC); // // Eliminate all keys that have invalid answers // foreach ($fields as $f) { $altkey = "NEW_" . $f; if ( isset($_REQUEST[$altkey])){ if (!in_array($_REQUEST[$altkey], $InValidChoice)) { $_REQUEST[$key] = $_REQUEST[$altkey]; unset($_REQUEST[$altkey]); } } if ( in_array($_REQUEST[$f], $InValidChoice) ) { unset ($_REQUEST[$f]); } } $sql = 'UPDATE help SET '; $sqlentry = array (); $modcnt = count($sqlentry); echo "Initial modcount: $modcnt
\n"; //DEBUG foreach ($fields as $f) { if ( isset($_REQUEST[$f]) ){ if ( $Original[$f] != $_REQUEST[$f] ){ echo "Final modcount: $modcnt
\n"; //DEBUG if ( $modcnt != 0) { $sql .= implode (', ', $sqlentry); $sql .= " WHERE help_id = " . $dbh->quote($help_id); echo "$sql
\n"; //DEBUG $result = $dbh->query($sql); echo "Help: $sql
\n"; // DEVONLY $result = $dbh->query($sql); $count = $result->rowCount(); echo "Count is $count
\n"; // DEVONLY if ( $count == 1 ) { $row = $result->fetch(PDO::FETCH_ASSOC); echo "\n"; // DEVONLY
print_r($row); // DEVONLY
echo "\n"; // DEVONLY
echo "| Quick Help | \n"; echo "|
|---|---|
| "; echo " | ";
echo "$row[short_help] "; echo " | \n";
echo "
| Detailed Help | \n"; echo "|
| ";
echo "$row[long_help] "; echo " | \n";
echo "
$sql
\n"; //DEBUG DEVONLY $result = $dbh->query($sql); $count = $result->rowCount(); echo "Record count is $count
\n"; // DEVONLY $COLCOUNT = count($SHOW); echo "Default Col count is $COLCOUNT
\n"; // DEVONLY $COLCOUNT += 2; echo "Col count is $COLCOUNT
\n"; // DEVONLY echo "| Edit | \n"; echo "View | \n"; foreach ($ALLFIELD as $f) { if (in_array($f, $SHOW)) { echo "$fieldlabels[$f] | \n"; } } while ($row = $result->fetch(PDO::FETCH_ASSOC)){ echo "
|---|---|---|
";
echo "";
echo "![]() | \n";
// Show
echo "";
echo "";
echo "![]() | \n";
// Record entry row
foreach ($ALLFIELD as $f) {
$display = $row[$f];
// Re-Map foreign key table lookups
//if ($f == 'contact_id'){
//$contact_id = $row[$f];
//$display = $People[$contact_id];
//}
if (in_array($f, $SHOW)) {
$css = "tdcs";
if (array_key_exists($f, $JustifyCss)) {
$css = $JustifyCss[$f];
}
echo "";
if (in_array($f, $LINK)) {
echo "";
echo "$display\n";
}else{
echo "$display\n";
}
echo " | \n";
}
}
}
echo "
$peoplesql
\n"; // DEVONLY $People = get_menu_array($peoplesql); echo "$peoplesql
\n"; // DEVONLY $People = get_menu_array($peoplesql); $dbh = jjn_pdo_connect(); echo "$sql
\n"; // DEVONLY $result = $dbh->query($sql); $count = $result->rowCount(); echo "RowCount: $count
\n"; // DEVONLY $row = $result->fetch(PDO::FETCH_ASSOC); echo "View: $sql
\n"; // DEVONLY $result = $dbh->query($sql); $row = $result->fetch(PDO::FETCH_ASSOC); echo "