Example #1
0
/**
 *  Displays the next and previous buttons
 *
 * $r is the result of a $db->Execute query used to display the table with records
 * When $paging is true, the records per page field will also be displayed
 * $num_p_r holds the (global) records per page variable
 */
function next_previous_buttons($r, $paging = false, $num_p_r = false, $numrows = false, $pagenr = false, $db = false, $tableinfo = false, $viewid = false)
{
    echo "<table border=0 width='100%'>\n<tr>\n<td align='left'>";
    if (function_exists($r->AtFirstPage)) {
        $r->AtFirstPage = $r->AtFirstPage();
    }
    if ($r && !$r->AtFirstPage) {
        echo "<input type=\"submit\" name=\"previous\" value=\"Previous\"></td>\n";
    } else {
        if ($paging) {
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>\n";
        } else {
            echo "&nbsp;</td>\n";
        }
    }
    if ($db && $tableinfo) {
        show_reports($db, $tableinfo, false, $viewid);
    }
    if ($paging) {
        if ($numrows > 0) {
            echo "<td align='center'>{$numrows} Records found. ";
            if ($pagenr) {
                $start = ($pagenr - 1) * $num_p_r + 1;
                $end = $pagenr * $num_p_r;
                if ($end > $numrows) {
                    $end = $numrows;
                }
                echo "Showing {$start} through {$end}. ";
            }
            echo "</td>\n";
        } else {
            echo "<td align='center'>No records found. </td>\n";
        }
        echo "<td align='center'>\n";
        echo "<input type='text' name='num_p_r'value='{$num_p_r}' size=3>&nbsp;";
        echo "Records per page</td>\n";
    }
    echo "<td align='right'>";
    // add direct links to pages
    if ($pagenr) {
        $startp = $pagenr - 5;
        if ($startp < 1) {
            $startp = 1;
        }
        $endp = $startp + 9;
        if ($numrows) {
            if ($numrows < $endp * $num_p_r) {
                $endp = ceil($numrows / $num_p_r);
            }
        }
        if ($endp > 1) {
            echo "Goto page: ";
            echo "<input type='hidden' name='{$tableinfo->pagename}' value='0'>\n";
            for ($i = $startp; $i <= $endp; $i++) {
                if ($pagenr == $i) {
                    echo "<b>{$i} </b>";
                } else {
                    // try using links with javascript converting it into post variables
                    echo "<a href='javascript:document.g_form.{$tableinfo->pagename}.value=\"{$i}\"; document.g_form.searchj.value=\"Search\"; document.g_form.submit()'>{$i} </a>";
                }
            }
        }
    }
    if (function_exists($r->AtLastPage)) {
        $r->AtLastPage = $r->AtLastPage();
    }
    if ($r && !$r->AtLastPage) {
        echo "<input type=\"submit\" name=\"next\" value=\"Next\">\n";
    } else {
        if ($paging) {
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        } else {
            echo "&nbsp;";
        }
    }
    echo "</td>\n</tr>\n";
    echo "</table>\n";
}
Example #2
0
function plugin_show($db, $tableinfo, $id, $USER, $system_settings, $backbutton = true)
{
    global $PHP_SELF;
    $journaltable = get_cell($db, $tableinfo->desname, "associated_table", "columnname", "journal");
    $categorytable = get_cell($db, $tableinfo->desname, "associated_table", "columnname", "category");
    if (!may_read($db, $tableinfo, $id, $USER)) {
        return false;
    }
    // get values
    $r = $db->Execute("SELECT {$tableinfo->fields} FROM {$tableinfo->realname} WHERE id={$id}");
    if ($r->EOF) {
        echo "<h3>Could not find this record in the database</h3>";
        return false;
    }
    $column = strtok($tableinfo->fields, ",");
    while ($column) {
        ${$column} = $r->fields[$column];
        $column = strtok(",");
    }
    echo "&nbsp;<br>\n";
    echo "<table border=0 align='center'>\n";
    echo "<tr>\n";
    echo "<th>Article: </th>\n";
    echo "<td>{$title}<br>\n{$author}<br>\n";
    $text = get_cell($db, $journaltable, "type", "id", $journal);
    echo "{$text} ({$pubyear}), <b>{$volume}</b>:{$fpage}-{$lpage}\n";
    echo "</td></tr>\n";
    if ($abstract) {
        echo "<tr>\n<th>Abstract</th>\n";
        echo "<td>{$abstract}</td>\n</tr>\n";
    }
    // Category
    if ($category) {
        $type2 = get_cell($db, $categorytable, "type", "id", $category);
        echo "<tr>\n<th>Category</th>\n";
        echo "<td>{$type2}</td>\n</tr>\n";
    }
    echo "<tr>";
    $query = "SELECT firstname,lastname,email FROM users WHERE id={$ownerid}";
    $r = $db->Execute($query);
    if ($r->fields["email"]) {
        echo "<th>Submitted by: </th><td><a href='mailto:" . $r->fields["email"] . "'>";
        echo $r->fields["firstname"] . " " . $r->fields["lastname"] . "</a> ";
    } else {
        echo "<th>Submitted by: </th><td>" . $r->fields["firstname"] . " ";
        echo $r->fields["lastname"] . " ";
    }
    $dateformat = get_cell($db, "dateformats", "dateformat", "id", $system_settings["dateformat"]);
    $date = date($dateformat, $date);
    echo "({$date})</td>\n";
    echo "</tr>\n";
    if ($lastmodby && $lastmoddate) {
        echo "<tr>";
        $query = "SELECT firstname,lastname,email FROM users WHERE id={$lastmodby}";
        $r = $db->Execute($query);
        if ($r->fields["email"]) {
            echo "<th>Last modified by: </th><td><a href='mailto:" . $r->fields["email"] . "'>";
            echo $r->fields["firstname"] . " " . $r->fields["lastname"] . "</a>";
        } else {
            echo "<th>Last modified by: </th><td>" . $r->fields["firstname"] . " ";
            echo $r->fields["lastname"];
        }
        $dateformat = get_cell($db, "dateformats", "dateformat", "id", $system_settings["dateformat"]);
        $lastmoddate = date($dateformat, $lastmoddate);
        echo " ({$lastmoddate})</td>\n";
        echo "</tr>\n";
    }
    echo "<tr>";
    $notes = nl2br(htmlentities($notes));
    echo "<th>Notes: </th><td>{$notes}</td>\n";
    echo "</tr>\n";
    $columnid = get_cell($db, $tableinfo->desname, "id", "columnname", "file");
    $files = get_files($db, $tableinfo->name, $id, $columnid, 1);
    if ($files) {
        echo "<tr><th>Files:</th>\n<td>";
        for ($i = 0; $i < sizeof($files); $i++) {
            echo $files[$i]["link"] . " (" . $files[$i]["type"] . " file, " . $files[$i]["size"] . ")<br>\n";
        }
        echo "</tr>\n";
    }
    echo "<tr><th>Links:</th><td colspan=7><a href='{$PHP_SELF}?tablename=" . $tableinfo->name . "&showid={$id}&";
    echo SID;
    echo "'>" . $system_settings["baseURL"] . getenv("SCRIPT_NAME") . "?tablename=" . $tableinfo->name . "&showid={$id}</a> (This page)<br>\n";
    echo "<a href='http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?";
    if ($system_settings["pdfget"]) {
        $addget = "&" . $system_settings["pdfget"];
    }
    echo "cmd=Retrieve&db=PubMed&list_uids={$pmid}&dopt=Abstract{$addget}'>This article at Pubmed</a><br>\n";
    echo "<a href='http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?";
    echo "cmd=Link&db=PubMed&dbFrom=PubMed&from_uid={$pmid}{$addget}'>Related articles at Pubmed</a><br>\n";
    if ($supmat) {
        echo "<a href='{$supmat}'>Supplemental material</a><br>\n";
    }
    echo "</td></tr>\n";
    show_reports($db, $tableinfo, $id);
    ?>
   
<form method='post' id='pdfview' action='<?php 
    echo "{$PHP_SELF}?tablename=" . $tableinfo->name;
    ?>
&<?php 
    echo SID;
    ?>
'> 
<?php 
    if ($backbutton) {
        echo "<tr>";
        echo "<td colspan=7 align='center'><input type='submit' name='submit' value='Back'></td>\n";
        echo "</tr>\n";
    } else {
        echo "<tr><td colspan=8 align='center'>&nbsp;<br><button onclick='self.close();window.opener.focus();' name='Close' value='close'>Close</button></td></tr>\n";
    }
    echo "</table></form>\n";
}
Example #3
0
/**
 * *
 *  Display a record in a nice format
 *
 */
function display_record($db, $Allfields, $id, $tableinfo, $backbutton = true, $previousid = false, $nextid = false, $viewid = false)
{
    global $PHP_SELF, $md, $USER;
    if (!$Allfields[1]['recordid']) {
        echo "<table border=0 align='center'>\n";
        echo "<tr>\n<td align='center'><h3>Record not found</h3>\n</td>\n</tr>";
        echo "<tr>\n<td align='center'>\n<button onclick='self.close();window.opener.focus();' name='Close' value='close'>Close</button></td></tr>\n";
        echo "</table>\n";
        exit;
    }
    echo "&nbsp;<br>\n";
    echo "<table border=0 align='center'>\n";
    $count = 0;
    echo "<tr>\n";
    // if viewid is defined we will over-ride display record with values from the view settings
    if ($viewid) {
        $r = $db->Execute("SELECT columnid FROM tableviews WHERE viewnameid={$viewid} AND viewmode=2");
        while ($r && !$r->EOF) {
            $viewlist[] = $r->fields[0];
            $r->MoveNext();
        }
    }
    //print_r($Allfields);
    foreach ($Allfields as $nowfield) {
        // decide whether this field will be shown
        unset($thisfield);
        // if we have a viewid, check the list
        if ($viewlist) {
            $thisfield = in_array($nowfield['columnid'], $viewlist);
        } else {
            //Only show the entry when display_record is set
            $thisfield = $nowfield['display_record'] === 'Y';
        }
        if ($thisfield && is_array($nowfield)) {
            // explode 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 fields in two columns
            if ($count && !($count % 2)) {
                echo "</tr>\n<tr>\n";
            }
            if ($nowfield['datatype'] == 'textlong') {
                $textlarge = nl2br(htmlentities($nowfield['values']));
                echo "<th>{$nowfield['label']}</th><td colspan=2>{$textlarge}</td>\n";
            } elseif ($nowfield['datatype'] == 'file' || $nowfield['datatype'] == 'image') {
                // if this came through a associated table:
                if ($nowfield['nested']['nested_tbname'] && $nowfield['nested']['nested_columnid']) {
                    $files = get_files($db, $nowfield['nested']['nested_tbname'], $nowfield['nested']['nested_id'], $nowfield['nested']['nested_columnid'], 0, 'big');
                } else {
                    $files = get_files($db, $tableinfo->name, $id, $nowfield['columnid'], 0, 'big');
                }
                if ($files) {
                    echo "<th>{$nowfield['label']}:</th>\n<td colspan=5>";
                    for ($i = 0; $i < sizeof($files); $i++) {
                        echo $files[$i]['link'] . "&nbsp;&nbsp;(<i>" . $files[$i]['name'] . "</i>, " . $files[$i]['type'];
                        echo " file, " . $files[$i]['size'] . ")<br>\n";
                    }
                    echo "<td>\n";
                } else {
                    $count--;
                }
            } else {
                echo "<th>{$nowfield['label']}</th>\n";
                if ($nowfield['link']) {
                    echo "<td colspan=2>{$nowfield['link']}</td>\n";
                } else {
                    echo "<td colspan=2>{$nowfield['text']}</td>\n";
                }
            }
            $count++;
        }
    }
    echo "</tr>\n";
    make_link($id, $tableinfo->name);
    show_reports($db, $tableinfo, $id, $viewid);
    if (function_exists("plugin_display_show")) {
        plugin_display_show($db, $Allfields, $id);
        return $Allfields;
    }
    echo "</table>\n";
    echo "<form method='post' name='g_form' action='{$PHP_SELF}?tablename=" . $tableinfo->name . "&" . SID . "'>\n";
    echo "<input type='hidden' name='md' value='{$md}'>\n";
    echo "<input type='hidden' name='showid' value='{$id}'>\n";
    //echo "<input type='hidden' name='jsnewwindow' value='false'>\n";
    // for organizational purpose, define buttons here:
    // next and previous buttons
    if ($previousid) {
        $previousbutton = "<input type=\"button\" name=\"view_" . $previousid . "\" value=\"Previous\" onClick='MyWindow=window.open(\"general.php?tablename={$tableinfo->name}&amp;showid={$previousid}&amp;jsnewwindow=true&amp;viewid={$viewid}\",\"view\",\"scrollbars,resizable,toolbar,width=600,height=400\")'>\n";
    }
    if ($nextid) {
        $nextbutton = "<input type=\"button\" name=\"view_" . $nextid . "\" value=\"Next\" onClick='MyWindow=window.open(\"general.php?tablename={$tableinfo->name}&amp;showid={$nextid}&amp;jsnewwindow=true&amp;viewid={$viewid}\",\"view\",\"scrollbars,resizable,toolbar,width=600,height=400\")'>\n";
    }
    // closebutton
    $closebutton = "<input type=\"button\" onclick='self.close();window.opener.focus();' name='Close' value='Close'>\n";
    if ($backbutton) {
        $backbutton = "<input type='submit' name='submit' value='Back'>\n";
    }
    // modify button
    if (may_write($db, $tableinfo->id, $id, $USER)) {
        $modifybutton = "<input type=\"submit\" name=\"mod_" . $id . "\" value=\"Modify\">\n";
    }
    // viewmenu:
    $viewmenu = viewmenu($db, $tableinfo, $viewid, false);
    // and now display the buttons
    echo "<table border=0 align='center' width='100%'>\n";
    if ($backbutton) {
        echo "<tr>\n<td align='left'>";
        echo " {$previousbutton}</td><td align='center'>{$modifybutton} {$backbutton} {$viewmenu}</td><td align='right'>{$nextbutton} </td>\n</tr>\n";
    } else {
        echo "<tr><td align='left'>{$previousbutton} &nbsp;</td><td align='center'> {$modifybutton} {$closebutton} </td><td>{$viewmenu}</td><td align='right'>{$nextbutton} &nbsp;</td></tr>\n";
    }
    echo "</table>\n\n";
    echo "</form>\n";
}
Example #4
0
if (is_file($MODULE_FOLDER . "stats/" . MAIN_LANG . ".lang.php")) {
    require_once $MODULE_FOLDER . "stats/" . MAIN_LANG . ".lang.php";
} else {
    require_once $MODULE_FOLDER . "stats/en.lang.php";
}
$Delimeter = " &gt ";
$Title1 = NETCAT_MODULE_STATS;
$Title2 = "<a href=" . $ADMIN_PATH . "modules/>" . NETCAT_MODULES . "</a>";
// check permission
$perm->ExitIfNotAccess(NC_PERM_MODULE, 0, 0, 0, 1);
//LoadModuleEnv();
$MODULE_VARS = $nc_core->modules->get_module_vars();
$phase += 0;
BeginHtml($Title1, $Title2 . $Delimeter . $Title1, "http://" . $DOC_DOMAIN . "/settings/modules/stats/openstat");
// check permission
$perm->ExitIfNotAccess(NC_PERM_MODULE, 0, 0, 0, 1);
$db->get_results("SELECT * FROM `Stats_Openstat_Counters` order by `Counter_Id`");
$counters = @array_combine($db->get_col(NULL, 0), $db->get_results(NULL));
switch ($sub_view) {
    case 'templates':
        show_templates($phase);
        break;
    case 'counters':
        show_counters($phase);
        break;
    case 'reports':
    default:
        show_reports($phase);
        break;
}
EndHtml();