コード例 #1
0
ファイル: androLib.php プロジェクト: KlabsTechnology/andro
 function addColumn($options)
 {
     $column_id = arr($options, 'column_id');
     if ($column_id == '') {
         $column_id = rand(100000, 999999);
     }
     $dispsize = arr($options, 'dispsize', 10);
     # KFD 3/6/09 Sourceforge 2668452, respect descshort if present
     $description = arr($options, 'descshort', '');
     if ($description == '') {
         $description = arr($options, 'description', 'No Desc');
     }
     $type_id = arr($options, 'type_id', 'char');
     $forcelong = arr($options, 'forcelong', false);
     $table_id_fko = arr($options, 'table_id_fko', '');
     # Permanently store the column information,
     # and increment the running total
     $width1 = max($dispsize, strlen(trim($description)));
     $width1++;
     # KFD 1/8/09, expand width (maybe) if this column
     #             gets an x6select
     if ($table_id_fko != '') {
         if ($type_id == 'cbool' || $type_id == 'gender') {
             if ($width1 < 5) {
                 $width1 = 5;
             }
         } else {
             $width1 += 3;
         }
     }
     # Now that we have what we need from description,
     # turn spaces into &nbsp;
     $description = str_replace(' ', '&nbsp;', $description);
     # KFD Calculated width of 14 12px chars is 110px
     #     This means avg width is 7.85 pixels
     #     This means the ratio of width to height is .654
     #     However, if you add sortable, it gets a LEETLE TOO TINY,
     #     so we kicked it up to....
     $width1 *= x6CssDefine('bodyfs', '12px') * 0.67;
     $width = $forcelong ? $width1 : intval(min($width1, 200));
     $pad0 = x6CSSDefine('pad0');
     $bord = 1;
     // HARDCODE!
     $this->colWidths += $width + $pad0 * 2 + $bord * 2;
     # Save the information about the column permanently,
     # we will need all of this when adding cells.
     $colinfo = array('description' => $description, 'dispsize' => $dispsize, 'type_id' => $type_id, 'column_id' => $column_id, 'width' => $width, 'colprec' => arr($options, 'colprec', $dispsize), 'colscale' => arr($options, 'colscale', $dispsize), 'uiro' => arr($options, 'uiro', 'N'));
     $this->columns[] = $colinfo;
     $this->columnsById[$column_id] = $colinfo;
     $cssExtra = '';
     if (in_array($type_id, array('int', 'numb', 'money'))) {
         $cssExtra = 'text-align: right';
     }
     $styleId = 'div.' . $this->hp['id'] . '_' . $column_id;
     $this->colStyles[$styleId] = "width: {$width}px; {$cssExtra}";
     $iWidth = $width;
     if ($table_id_fko != '') {
         $iWidth -= x6cssdefine('bodyfs', '12px') * 0.67 * 5;
         $this->colStyles[$styleId . ' input'] = "width: {$iWidth}px; {$cssExtra}";
     } else {
         if ($type_id == 'mime-f') {
             $iWidth -= x6cssdefine('bodyfs', '12px') * 0.67 * 20;
             $this->colStyles[$styleId . ' input'] = "width: {$iWidth}px; {$cssExtra}";
         } else {
             if (!in_array($type_id, array('cbool', 'gender'))) {
                 $this->colStyles[$styleId . ' input'] = "width: {$iWidth}px; {$cssExtra}";
             }
         }
     }
     # Finally, generate the HTML.
     $div = $this->dhead->h('div', $description);
     $div->hp['xColumn'] = $column_id;
     $div->addclass($this->hp['id'] . '_' . $column_id);
     $this->headers[] = $div;
 }
コード例 #2
0
    function x6main()
    {
        $top = html('div');
        $top->addClass('fadein');
        $top->h('h1', 'User Options');
        $height = x6cssdefine('insideheight') - x6cssHeight('h1') * 2;
        $pad1 = x6cssDefine('pad1');
        $tabs = $top->addTabs('useroptions', $height);
        # --------------------------------------------------------------
        # This is skin stuff
        # --------------------------------------------------------------
        $tab1 = $tabs->addTab('Appearance');
        $tab1->hp['style'] = "padding: {$pad1}px";
        $file = fsDirTop() . 'templates/x6/skinsphp/x6skins.ser.txt';
        $skins = unserialize(file_get_contents($file));
        $select = html('select');
        $cookie = arr($_COOKIE, 'x6skin', 'Default.Gray.1024');
        foreach ($skins as $name => $stats) {
            $option = $select->h('option', $name);
            $option->hp['value'] = $stats;
            # Note that $cookie was defined above
            if ($cookie == $stats) {
                $option->hp['selected'] = 'selected';
            }
        }
        $select->hp['onchange'] = 'x6ChangeSkin(this)';
        ob_start();
        ?>
        
        <script>
        window.x6ChangeSkin = function(select) {
            // Sourceforge 2753325 use quirksmode-supplied set cookie
            createCookie('x6skin',select.value,3650);
            //document.cookie 
            //    = "x6skin="+select.value+"; expires=12/31/2049 00:00:00;";
            window.location.reload(true);
        }
        </script>
        <h2>Skin Selection</h2>
        Skin: <?php 
        echo $select->render();
        ?>
        <?php 
        $tab1->setHtml(ob_get_clean());
        # <------- EARLY RETURN
        #
        if (!inGroup('debugging')) {
            $top->render();
            return;
        }
        # --------------------------------------------------------------
        # Now for javascript and logging
        # --------------------------------------------------------------
        $tab2 = $tabs->addTab('Javascript Development');
        $tab2->hp['style'] = "padding: {$pad1}px";
        $tab2->h('h2', 'Alternate Javascript Files');
        $tab2->h('p', 'You can use this feature to debug and enhance the
            Andromeda Javascript files without having a complete installation.
            Here is how it works:');
        $ul = $tab2->h('ul');
        $ul->h('li', 'Use Firebug to make local copies of x6.js and androLib.js');
        $ul->h('li', 'Put these files somewhere you can edit them which is also
              on a <i>publicly visible website</i>.');
        $ul->h('li', 'Put the address of the public website here, including a
              trailing slash.');
        $ul->h('li', '<span style="color:red">If you make a mistake and the files
              are not visible, this demo will stop working.  Close your
              browser and try again.</span>');
        $tab2->h('span', 'Alternate Location:&nbsp;&nbsp;');
        $input = html('input');
        $input->hp['size'] = 70;
        $input->hp['id'] = 'altjs';
        $input->hp['value'] = arr($_COOKIE, 'altjs', '');
        $input->code['change'] = <<<JS
        function(input) {
            createCookie('altjs',input.value);
        }
JS;
        $tab2->addChild($input);
        $tab2->h('h2', 'Logging');
        $tab2->h('p', 'Logging is by default turned off.  Use the checkboxes
            below to turn on the various logging features.');
        $a = $tab2->h('a-void', 'Detect console devices');
        $a->code['click'] = <<<JS
        function(input) {
            var msg = x6consoleActivate();
            if(msg==false) {
                alert("No console devices found, logging is disabled");
            }
            else {
                alert(msg);
            }
        }
JS;
        $tab2->br(2);
        $loptions = array('Server' => 'Server-Side Query Log', 'FBLite' => 'I am on IE, load Firebug Lite for me', 'Group' => 'Javascript Log Outline', 'Log' => 'Javascript Log Detail', 'Warn' => 'Warnings', 'Info' => 'Informational', 'Error' => 'Errors', 'Time' => 'Time start/end (requires firebug)');
        foreach ($loptions as $loption => $description) {
            $input = html('input');
            $input->hp['type'] = 'checkbox';
            $input->hp['command'] = $loption;
            $input->code['click'] = <<<JS
            function(input) {
                var command = x6.p(input,'command');
                var checked = input.checked;
                if(checked) {
                    x6.console['enable'+command] = true;
                    createCookie('log_'+command,1);
                }
                else {
                    x6.console['enable'+command] = false;
                    eraseCookie('log_'+command);
                }
            }
JS;
            if (arr($_COOKIE, 'log_' . $loption, 0) == 1) {
                $input->hp['checked'] = 'checked';
            }
            $tab2->addChild($input);
            $tab2->h('span', $description);
            $tab2->br();
            if ($loption == 'Server') {
                $tab2->br();
            }
        }
        # --------------------------------------------------------------
        # End of the line
        # --------------------------------------------------------------
        $top->render();
    }