Exemple #1
0
 function checkboxSave()
 {
     $row = aFromGP('cbval_');
     x6Data('row', $row);
     $table_id = gp('x6page');
     if (gp('checked') == 'true') {
         SQLX_Insert($table_id, $row);
     } else {
         SQLX_Delete($table_id, $row);
     }
 }
Exemple #2
0
function x4Data($name, $data)
{
    if (vgfGet('x6', false)) {
        return x6Data($name, $data);
    }
    $script = "\n\$a.data.{$name} = " . json_encode_safe($data) . ";";
    x4Script($script);
}
function index_hidden_x6Dispatch($x6page, $x6file, $x6yaml, $x6profile, $x6plugin, $x6action)
{
    # This is everything that *might* go back, make a place
    # for all of it
    $GLOBALS['AG']['x4'] = array('error' => array(), 'debug' => array(), 'notice' => array(), 'html' => array(), 'script' => array());
    vgfSet('x6', true);
    # KFD 12/10/08, allow dynamic lookups.
    #
    if (gp('x6select', false)) {
        $table_id = gp('x6page');
        $gpletters = gp('gpletters');
        # KFD 4/11/09 Sourceforge 2753358 do real matches
        $matches = aFromGp('mtch_');
        $rows = RowsForSelect($table_id, $gpletters, $matches, '', true);
        foreach ($rows as $idx => $row) {
            unset($rows[$idx]['skey']);
            foreach ($row as $col => $val) {
                if ($col != 'skey') {
                    $rows[$idx][$col] = trim($val);
                }
            }
        }
        x6Data('x6select', $rows);
        echo json_encode_safe($GLOBALS['AG']['x4']);
        return;
    }
    # Make hidden variables for x6page and module
    hidden('x6page', $x6page);
    hidden('x6module', gp('x6module', 'X'));
    # This little bit of magic loads up the CSS information
    # for the current template and skin, allowing downstream
    # code to determine how much space they have to work with
    #
    $x6skin = arr($_COOKIE, 'x6skin', 'Default.Gray.1024');
    setCookie('x6skin', $x6skin);
    if ($x6skin != '') {
        $filename = fsDirTop() . "templates/x6/skinsphp/x6skin.{$x6skin}.ser.txt";
        if (file_exists($filename)) {
            $serialized = file_get_contents($filename);
            $GLOBALS['AG']['x6skin'] = unserialize($serialized);
        }
    }
    # If they have already defined MPPages in applib, we will
    # pick it up here with this global declaration.
    #
    # MPPages lists pages that may be accessed w/o login
    global $MPPages;
    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';
    # Session timeouts.  Need to code for basic page access
    # and code for ajax timeouts.
    if (!LoggedIn() && !in_array($x6page, array_keys($MPPages))) {
        if (gpExists('json')) {
            x4Script("window.location='index.php?gp_page=x_login'");
            echo json_encode($GLOBALS['AG']['x4']);
        } else {
            echo "<script>window.location='index.php?gp_page=x_login&x2=1'</script>";
        }
        return;
    }
    # Include the basic x6 class, and set a default for
    # the class and the method call
    include 'androX6.php';
    $x6class = 'androX6';
    $x6method = 'x6main';
    # This is the core resolution where we figure out what class
    # to use and what method to call.  It is a little complicated
    # because we support 3 different kinds of pages (yaml, profile
    # and custom) plus calls from plugins to refresh, plus JSON
    # calls to do database stuff.
    if ($x6plugin != '') {
        # DEFUNCT.  We don't use plugins, they were an early
        #           idea, but profiles and androHTML classes
        #           made them unecessary.
        # A plugin always wins.  A call to a plugin assumes that
        # x6action is also specified.  We are going to instantiate
        # the plugin and call the method named by x6action.
        #$x6file  = '';
        #$x6class = 'x6plugin'.$x6plugin;
        #$x6method= $x6action;
        #include($x6class.'.php');
    } else {
        # No plugin means we are either using the base andromeda
        # class androX6, or using a custom class.  We only use
        # a custom class if the programmer has supplied a file.
        # So if that file exists we load that and use it.
        if ($x6file != '') {
            $x6class = 'x6' . $x6page;
            include $x6class . '.php';
        }
        # The next major decision is whether we are calling some
        # specific action, or loading a page.  If an action was
        # specified that wins.
        if ($x6action != '') {
            $x6method = $x6action;
        } else {
            # KFD 12/22/08.  Support for androPage! Extremely important!
            if (file_exists("application/{$x6page}.page.yaml")) {
                $x6class = 'androPage';
                $x6method = 'x6main';
                include 'androPage.php';
            } else {
                # Now we must be loading a page, because no plugin was
                # specified and no action.  At this point all that is
                # left to figure out is whether we load a profile or
                # go for the default "x6main" routine.
                if ($x6profile != '') {
                    $x6method = 'profile_' . $x6profile;
                } else {
                    $x6method = 'x6main';
                }
            }
            # If we are loading a page, we need the x6 javascript
            # and the first command in jqDocReady should be to
            # initialize the objects so downstrem code can make
            # them visible.
            # KFD 12/23/08, see if they set a cookie for an
            #               alternate location.
            # KFD 1/22/09 , Yikes! Don't do this if JSON was passed
            if (gp('json', '') != '1') {
                $xpath = arr($_COOKIE, 'altjs', 'clib/');
                jsInclude($xpath . 'x6.js');
                #jsInclude('clib/jquery.maskedinput-1.1.4.js');
                jqDocReady('x6.init()');
            }
        }
    }
    # Final trap.  If the class is androX6 and the method
    # is x6main, this means an unprogrammed page: there is
    # no custom program file and no profile in the yaml.
    # So we default to the conventional profile.
    #
    # KFD 2/17/09 Sourceforge 2546056
    #             This means that bad page requests go to
    #             profile_conventional(), so that is where
    #             we trap for them.  See androX6::profile_conventional()
    if ($x6method == 'x6main' && $x6class == 'androX6') {
        $x6method = 'profile_conventional';
        # KFD 2/2/09.  Allow fallback to x2 processing.  If the
        #              app is set for it, and a file exists, call
        #              that instead
        if (configGet('x6_x2', 'N') == 'Y') {
            if (file_exists(fsDirTop() . 'application/' . $x6page . '.php')) {
                include_once 'x_table2.php';
                include_once $x6page . '.php';
                $x6class = $x6page;
                $x6method = "main";
            }
        }
    }
    # Now everything is resolved.  We know what class to instantiate
    # and what method to call, so go for it.
    ob_start();
    $obj = new $x6class();
    # KFD 3/30/09 Sourceforge 2697962 Do this here, so it
    #             does not matter if androX6 or androPage
    $obj->hld = aFromGp('hld_');
    $obj->dd = ddTable($x6page);
    $obj->x6page = $x6page;
    $obj->view = arr($obj->dd, 'viewname', '');
    $obj->{$x6method}();
    $HTML = ob_get_clean();
    # KFD 3/20/09 Sourceforge 2697962
    #             Make sure programmer never has to send out
    #             hold variables, they should go automatically
    if (gp('json') != 1) {
        if (isset($obj->hld)) {
            foreach ($obj->hld as $name => $value) {
                # KFD 3/20/09 Sourceforge 2697962
                #             Put out as hidden instead
                hidden('hld_' . $name, $value);
                #$inp = $top->h('input');
                #$inp->hp['type'] = 'hidden';
                #$inp->hp['name'] = $inp->hp['id'] = 'hld_'.$name;
                #$inp->hp['value'] = $value;
            }
        }
    }
    # Now if they made a "main" call, see if they want us to
    # send back some script as well
    if ($x6method == 'x6main') {
        if (method_exists($obj, 'x6script')) {
            ob_start();
            $obj->x6script();
            x6script(ob_get_clean());
        }
    }
    # And again see if they are sending out any popups
    if ($x6method == 'x6main') {
        if (method_exists($obj, 'x6modals')) {
            ob_start();
            $obj->x6modals();
            $HTML .= ob_get_clean();
        }
    }
    x6HTML('*MAIN*', $HTML);
    # Put errors in that were reported by database operations
    if (Errors()) {
        $errs = errorsGet();
        foreach ($errs as $err) {
            x4Error($err);
        }
    }
    # CODE BELOW HERE WAS TAKEN FROM X4 UNCHANGED.
    # if the "json" flag is set, we return all output as JSON,
    # otherwise we package it up with the normal template and
    # return it as main content
    if (gp('json') == 1) {
        echo json_encode_safe($GLOBALS['AG']['x4']);
    } else {
        # Don't need a form in x6 mode
        vgaSet('NOFORM', true);
        #  Put things where the template expects to find them
        vgfSet('HTML', $GLOBALS['AG']['x4']['html']['*MAIN*']);
        #  If there was some script, add that in
        foreach ($GLOBALS['AG']['x4']['script'] as $script) {
            jqDocReady($script);
        }
        # Just before the absolute very last command is the
        # firing of our (currently) one and only queue
        jqDocReady('x6events.fireQueue("afterInit")');
        # The absolute very last command is the fade in
        $fadeIn = "\$('.fadein').fadeIn('slow',function() { x6.initFocus(); });";
        jqDocReady($fadeIn);
        # DUPLICATE ALERT: This code copied from
        #                  index_hidden_page() below
        index_hidden_template('x4');
        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;
    }
    return;
}