Esempio n. 1
0
 function main()
 {
     // ------------------------------------------------
     // Branch out to ajax handling functions
     if (gpExists('fwajax')) {
         return $this->FWAjax();
     }
     //   ...early return
     // ------------------------------------------------
     // Public sites can turn off table maintenance pages
     if (vgfGet('suppress_maintenance', false)) {
         return;
     }
     vgfset('maintenance', true);
     # KFD 2/17/09 Sourceforge 2546056
     #             If we are in default main code branch, and
     #             there is no data dictionary, the user has
     #             called a bad page.
     if (!isset($this->table['projections'])) {
         ?>
       <h1>Bad Page Request</h1>
       <p>There is no page <?php 
         echo hx(gp('gp_page'));
         ?>
       <?php 
         return;
     }
     // If a "fk jump", retrieve skey and make it look
     // like an edit call.
     if (gp('gp_pk') != '') {
         $pkval = gp("gp_pk");
         $pkcol = $this->table["pks"];
         $pktyp = $this->table['flat'][$pkcol]["type_id"];
         $table_id = $this->table["table_id"];
         // KFD 10/26/06, used to be $table_id
         $sq = "SELECT skey FROM " . $this->view_id . " WHERE " . $pkcol . " = " . SQL_Format($pktyp, $pkval);
         gpSet('gp_skey', SQL_OneValue('skey', $sq));
         gpSet('gp_mode', 'upd');
     }
     // If we were invoked by a child table, don't do this
     if (is_null($this->table_obj_child)) {
         // KFD 10/26/06, keep as $table_id
         Hidden('gp_page', $this->table_id);
         // always return to same page
         Hidden('gp_mode', '');
         Hidden('gp_skey', '');
         Hidden('gp_action', '');
         Hidden('gp_save', '');
         hidden('gp_copy', '');
     }
     // Work out what to do if mode is blank.  Might mean
     // upd, might mean browse.
     $mode = gp('gp_mode');
     $skey = gp('gp_skey');
     if ($mode == '') {
         $mode = $this->MainCheckForMover();
         if ($mode == '') {
             $mode = $skey == '' ? 'browse' : 'upd';
             gpSet('gp_mode', $mode);
         }
     }
     $this->mode = $mode;
     // KFD 8/13/07, Experimental COPY ability
     if (gp('gp_action') == 'copy') {
         $mode = 'ins';
         gpSet('gp_mode', 'ins');
     }
     switch ($mode) {
         case 'search':
             $this->PageSubtitle .= " (Lookup Mode)";
             break;
         case 'ins':
             $this->PageSubtitle .= " (New Entry)";
             break;
     }
     // ----------------------------------------------
     // Generate the main HTML elements
     if ($mode == 'browse') {
         $this->hBrowse();
     } elseif ($mode == 'mover') {
         $this->hMover();
     } else {
         $this->hBoxes($mode);
     }
     if ($mode != "mover") {
         $this->hButtonBar($mode);
     }
     $this->hLinks($mode);
     $this->hExtra($mode);
     // Now if this is a child table in a 1:M, it will not actually
     // output its own stuff, it will invoke its parent, so let's
     // buffer the output
     if ($this->table_id_parent != '') {
         ob_start();
     }
     // Echo out the HTML
     $this->ehMain();
     // Put this out at end, after all HTML has been output
     if ($mode == "search") {
         //$controls=vgfGet('gpControls');
         $controls = ContextGet('OldRow');
         $hScript = '';
         foreach ($controls as $key => $info) {
             $hScript .= "\nob('x2t_{$key}').value='';";
         }
         jqDocReady("function clearBoxes() { \n" . $hScript . "}\n\n");
     }
     // Again, if this is a child table in a 1:M, capture the output and
     // make it the responsibility of the parent
     if ($this->table_id_parent != '') {
         $this->h['Complete'] = ob_get_clean();
         // Wipe out and replace all gp variables, fool the parent object
         $OldRow = ContextGet('OldRow', array());
         $gpsave = aFromGP('gp_');
         gpUnsetPrefix('gp_');
         $dd = ContextGet('drilldown', array());
         $dd1 = array_pop($dd);
         gpSet('gp_skey', $dd1['skey']);
         // Now invoke the parent object, tell it about us
         $object = objPage($this->table_id_parent);
         $object->table_obj_child = $this;
         $object->main();
         // Replace the wiped out gp variables
         gpUnsetPrefix('gp_');
         gpSetFromArray('gp_', $gpsave);
         ContextSet('OldRow', $OldRow);
         // Force the menu to come from the parent
         vgaSet('menu_selected', $this->table_id_parent);
     }
 }
Esempio n. 2
0
function index_hidden_command()
{
    // Get command, strip out multiple spaces, split up and
    // grab the command separate from the arguments
    # KFD 9/10/08.  Unset pretty much everything we know about
    #               so we can create a new get/post setup out
    #               of the command.
    gpUnsetPrefix('gpx');
    gpUnsetPrefix('gp_');
    gpUnsetPrefix('x2t_');
    gpUnset('gpContext');
    $commands = gp('gp_command');
    $commands = preg_replace('/\\s{2,}/', ' ', $commands);
    gpSet('gp_command', $commands);
    $args = explode(' ', $commands);
    $table_frag = array_shift($args);
    $table_frag = strtolower($table_frag);
    // If a special command was added, pull it out
    $dotcmd = '';
    if (strpos($table_frag, '.') !== false) {
        list($table_frag, $dotcmd) = explode('.', $table_frag, 2);
    }
    // Now run through the list of pages looking for the first match, but
    // look at the aliases first if they exist
    $aliases = ArraySafe($GLOBALS, 'COMMAND_ALIASES', array());
    foreach ($aliases as $alias => $page) {
        if (substr(strtolower($alias), 0, strlen($table_frag)) == $table_frag) {
            $table_id = $page;
            break;
        }
    }
    $PAGES = array();
    include 'ddpages.php';
    $pages = array_keys($PAGES);
    foreach ($pages as $page) {
        if (substr(strtolower($page), 0, strlen($table_frag)) == $table_frag) {
            $table_id = $page;
            break;
        }
    }
    $x4 = configGet('x4welcome', 'N') == 'Y' ? true : false;
    // Can't figure it, have to leave
    if (!isset($table_id)) {
        vgfSet('command_error', 'Unknown: ' . $table_frag);
        return;
    }
    // Now decide what to do.
    if ($dotcmd == 'new') {
        if ($x4) {
            gpSet('x4Page', $table_id);
            gpSet('x4Mode', 'new');
        } else {
            gpSet('gp_mode', 'ins');
            gpSet('gp_page', $table_id);
        }
    } else {
        if ($dotcmd != '') {
            vgfSet('command_error', 'Unknown Command: ' . $table_frag . '.' . $dotcmd);
            return;
        } else {
            // for now we assume everything else is a lookup
            if (count($args) == 0) {
                // No arguments means go to lookup mode
                gpSet('gp_mode', 'search');
                gpSet('gp_page', $table_id);
                if ($x4) {
                    gpSet('x4Page', $table_id);
                }
            } else {
                // Clear prior search results
                processPost_TableSearchResultsClear($table_id);
                // Re-write the query into a search
                // by setting our values as the search values
                gpSet('gp_page', $table_id);
                gpSet('gpx_page', $table_id);
                gpSet('gp_mode', 'browse');
                gpSet('gpx_mode', 'search');
                # KFD 8/18/08 MAJOR CHANGE.  Loading this up w/old code caused
                #             things like viewname not to exist
                #$dd=dd_tableRef($table_id);
                $dd = ddTable($table_id);
                # KFD 8/18/08
                $cols = explode(',', $dd['projections']['_uisearch']);
                array_shift($cols);
                // pop off the first one, assume it is the pk/code
                gpUnsetPrefix('x2t_');
                // clear troublesome values
                foreach ($cols as $i => $colname) {
                    if (isset($args[$i])) {
                        gpSet('x2t_' . $colname, $args[$i]);
                    }
                }
                if ($x4) {
                    gpSet('x4Page', $table_id);
                    foreach ($cols as $i => $colname) {
                        if (isset($args[$i])) {
                            gpSet('pre_' . $colname, $args[$i]);
                        }
                    }
                }
            }
        }
    }
}