コード例 #1
0
ファイル: general_inc.php プロジェクト: nicost/phplabware
/**
 * * 
 *  Displays all information within the table
 *
 */
function display_table_info($db, $tableinfo, $Fieldscomma, $pr_query, $num_p_r, $pr_curr_page, $page_array, $r = false, $viewid = false)
{
    global $nr_records, $USER, $LAYOUT, $_SESSION;
    $first_record = ($pr_curr_page - 1) * $num_p_r;
    $current_record = $first_record;
    $last_record = $pr_curr_page * $num_p_r;
    if (!$r) {
        $r = $db->Execute($pr_query);
    }
    $r->Move($first_record);
    // we keep a list with fileids in the user settings
    // these files can be seen without checking the database
    // to be sure that only the current files can be seen, unset the entry first
    unset($USER['settings']['fileids']);
    // Insert some javascript functions to be used for viewing, modifying and
    // deleting entries
    if ($_SESSION['javascript_enabled']) {
        echo "\n<script>\n";
        echo "function deleteEntry(shortTitle, element) {\n        if( confirm(\n            \"Remove record \" +  shortTitle + \"?\")) \n        {\n            element.value='Remove';\n            document.g_form.submit();\n        }\n      }";
        echo "\n</script>\n";
    }
    // print all entries
    while (!$r->EOF && $r && $current_record < $last_record) {
        // Get required ID and title
        $id = $r->fields['id'];
        $title = get_cell($db, $tableinfo->realname, 'title', 'id', $r->fields['id']);
        $Allfields = getvalues($db, $tableinfo, $Fieldscomma, 'id', $id);
        // print start of row of selected group
        if ($current_record % 2) {
            echo "<tr class='row_odd' align='center'>\n";
        } else {
            echo "<tr class='row_even' align='center'>\n";
        }
        foreach ($Allfields as $nowfield) {
            // nested table links to the current world:
            if (isset($nowfield['nested'])) {
                $nowfield['text'] = $nowfield['nested']['text'];
                $nowfield['values'] = $nowfield['nested']['values'];
                $nowfield['datatype'] = $nowfield['nested']['datatype'];
                $nowfield['fileids'] = $nowfield['nested']['fileids'];
            }
            // display the contents
            if (array_key_exists('link', $nowfield) && $nowfield['link']) {
                echo "<td>{$nowfield['link']}</td>\n";
            } elseif ($nowfield['datatype'] == 'mpulldown') {
                echo "<td align='left' cellpadding='5%'>{$nowfield['text']}</td>\n";
            } elseif ($nowfield['datatype'] == 'textlong' && strlen($nowfield['text']) > 59 && $_SESSION['javascript_enabled'] && substr($nowfield['text'], 0, 7) != '<a href') {
                // provide long text by mouseover -- by MM
                $startofText = substr($nowfield['text'], 0, 60);
                echo "<td><a class='Tooltip' href=\"javascript:void(0);\" ";
                // single quotes causes javascript problems even when 'htmled'
                $escapedText = str_replace("'", '"', $escapedText);
                echo "onmouseover=\"this.T_WIDTH=400;return escape";
                $escapedText = htmlspecialchars($nowfield['text'], ENT_QUOTES);
                // returns spoil the party
                $escapedText = preg_replace("/\r\n|\n|\r/", "<br>", $escapedText);
                // Even when converted to HTML characters, the following kill tooltips.  Remove
                $escapedText = str_replace('&quot;', ' ', $escapedText);
                $escapedText = str_replace('&#039;', ' ', $escapedText);
                echo '(\'' . $escapedText . '\')">' . $startofText . "...</a></td>\n";
            } else {
                echo "<td>{$nowfield['text']}</td>\n";
            }
            // write file ids to user settings so that we do not need to check them again when downloading thumbnails
            if (isset($nowfield['fileids'])) {
                foreach ($nowfield['fileids'] as $fileid) {
                    $USER['settings']['fileids'][] = $fileid;
                }
            }
        }
        // Action column - icons and javascript to enable these by Michael Muller
        echo "<td align='center'>&nbsp;\n";
        // View action
        if ($_SESSION['javascript_enabled']) {
            $jscript = " onclick='MyWindow=window.open (\"general.php?tablename=" . $tableinfo->name . "&amp;showid={$id}&amp;jsnewwindow=true&amp;viewid={$viewid}\",\"view\",\"status,menubar,toolbar,scrollbars,resizable,titlebar,width=700,height=500\");MyWindow.focus()'";
            echo "<A href=\"javascript:void(0)\" {$jscript}> <img src=\"icons/detail.png\" alt=\"detail\" title=\"detail\" border=\"0\"/></A>\n";
        } else {
            echo "<input type=\"submit\" name=\"view_" . $id . "\" value=\"View\">\n";
        }
        if (may_write($db, $tableinfo->id, $id, $USER)) {
            // Modify action
            // this works, but how do you go back from the modify window to this one???
            if ($_SESSION['javascript_enabled']) {
                $jscript = "onclick='MyWindow=window.open (\"general.php?tablename=" . $tableinfo->name . "&amp;jsnewwindow=true&amp;modify=true&amp;mod_" . $id . "=Modify\",\"modify\",\"scrollbars,resizable,status,menubar,toolbar,width=700,height=500\");MyWindow.focus()'";
                echo "<A href=\"javascript:void(0)\" {$jscript}> <img src=\"icons/edit_modify.png\" alt=\"modify\" title=\"modify\" border=\"0\"/></A>\n";
            } else {
                echo "<input type=\"submit\" name=\"mod_" . $id . "\" value=\"Modify\">\n";
            }
            // Delete action
            if (!$_SESSION['javascript_enabled']) {
                $delstring = "<input type=\"submit\" name=\"del_" . $id . "\" value=\"Remove\">\n";
            } else {
                $jstitle = str_replace("'", " ", $title);
                $jstitleShort = substr($jstitle, 0, 30);
                $delstring = "<input type='hidden' name='del_{$id}'>\n";
                $delstring .= "<a href='javascript:deleteEntry(\"{$jstitleShort}\", document.g_form.del_{$id})'>\n";
                $delstring .= "   <img src=\"icons/delete.png\" alt=\"delete\" title=\"delete\" border=\"0\"/>\n</a>\n";
            }
            echo "{$delstring}\n";
        }
        echo "</td>\n";
        echo "</tr>\n";
        $r->MoveNext();
        $current_record++;
    }
    // Add Record button
    if (may_write($db, $tableinfo->id, false, $USER)) {
        echo "<tr><td colspan=20 align='center'>";
        if ($_SESSION['javascript_enabled']) {
            $jscript = " onclick='MyWindow=window.open (\"general.php?tablename=" . $tableinfo->name . "&amp;add=Add&amp;jsnewwindow=true\",\"view\",\"scrollbars,resizable,toolbar,status,menubar,width=700,height=500\");MyWindow.focus()'";
            echo "<input type=\"button\" name=\"add\" value=\"Add Record\" {$jscript}>";
        } else {
            echo "<input type=\"submit\" name=\"add\" value=\"Add Record\">";
        }
        echo "</td></tr>";
    }
    echo "</table>\n";
    next_previous_buttons($page_array);
    echo "</form>\n";
    echo "<script language='JavaScript' type='text/javascript' src='includes/js/wz_tooltip.js'></script>";
}
コード例 #2
0
ファイル: general.php プロジェクト: nicost/phplabware
     if ($md == 'edit') {
         echo "<td align='center'><a href='{$PHP_SELF}?add=Add&amp;tablename={$tableinfo->name}&amp;md=edit&amp;" . SID . "'>Add Record</a></td>\n";
     } else {
         //echo "<td align='center'><a href='$PHP_SELF?add=Add&amp;tablename=$tableinfo->name&amp;".SID."' target='_blank'>Add Record</a></td>\n";
         echo "<td align='center'><a href='{$PHP_SELF}?add=Add&amp;tablename={$tableinfo->name}&amp;" . SID . "'>Add Record</a></td>\n";
     }
 } else {
     echo "<td>&nbsp;</td>\n";
 }
 echo "<td align='center'>{$tabletext} <B>{$tableinfo->label}</B> {$modetext}</td>";
 echo "<td align='center'>" . viewmenu($db, $tableinfo, $viewid, false) . "</td>\n";
 if ($may_write) {
     echo "<td align='center'><a href='import.php?tableid={$tableinfo->id}'>Import Data</a></td>\n";
 }
 echo "</tr>\n</table>\n";
 next_previous_buttons($rp, true, $num_p_r, $numrows, ${$pagename}, $db, $tableinfo, $viewid);
 // get a list with ids we may see, $listb has all the ids we may see
 if ($db_type == 'mysql') {
     $lista = make_SQL_csf($r, false, 'id', $nr_records);
     if (!$lista) {
         $lista = "-1";
     }
     $lista = " id IN ({$lista}) ";
 } else {
     make_temp_table($db, 'tempa', $r);
     $lista = " ({$tableinfo->realname}.id=tempa.uniqueid) ";
 }
 //  get a list of all fields that are displayed in the table
 $Allfields = getvalues($db, $tableinfo, $Fieldscomma, false, false);
 // javascript to automatically execute search when pulling down
 $jscript = "onChange='document.g_form.searchj.value=\"Search\"; document.g_form.submit()'";