public function test_table_row_with_string_of_td_tags() { $cells = '<td class=first>one</td><td class=second>two</td>'; $actual = table::tr($cells); $expected = '<tr><td class=first>one</td><td class=second>two</td></tr>'; $this->assertSame($expected, $actual); }
function show_preprint($rowId, $action, $showcancelButton = True) { global $dbClass; $res = $dbClass->query("SELECT * FROM publications WHERE RowId='" . $rowId . "'"); $row = $dbClass->next_record($res); $c = "class='align_right'"; $t = new table("cellpadding='2'", "<form action='loader.php?rowId=" . $rowId . "&action=" . $action . "' method='POST'>"); if ($showcancelButton) { $missing = x("", "?"); } else { $missing = False; } $field = nl2html($GLOBALS["NOR_fields"][$row["Field"]]); $authors = nl2html($row["Authors"], $missing); $title = nl2html($row["Title"], $missing); $location = nl2html($row["Location"], $missing); $journal = nl2html($row["PublIn"], $missing); $t->tro(); $t->th($c, "Preprint :"); $t->td("", pp_preprintID($row["Year"], $row["Report"])); $t->trc(); $t->tro(); $t->th($c, "Field :"); $t->td("", $field); $t->trc(); $t->tro(); $t->th($c, "Authors :"); $t->td("", $authors); $t->trc(); if ($location) { $t->tro(); $t->th($c, "Location :"); $t->td("", $location); $t->trc(); } if ($journal) { $t->tro(); $t->th($c, "Published in :"); $t->td("", $journal); $t->trc(); } $t->tro(); $t->th($c, "Entered by :"); $t->td("", uid2gecos($row["Id"])); $t->trc(); $buttons[] = "<input type='submit' value='continue' name='button'>"; if ($showcancelButton) { $buttons[] = "<input type='submit' value='cancel' name='button'>" . "<input type='hidden' name='load' value='show_preprints.php'>"; } else { $buttons[] = "<input type='submit' value='update information for this preprint' name='button'>" . "<input type='hidden' name='load' value='edit_preprints.php'>" . "<input type='hidden' name='nor_pp_mode' value='" . NOR_PP_MODE_EDIT . "'>"; } $t->tro(); $t->td(); $t->td("", join(" ", $buttons)); $t->trc(); if (!$showcancelButton) { $t->tr("", "colspan='3'", x("i", "<br>When you have published this preprint in a Public Archive<br>" . "(i.e. you know the URL to the abstract)<br>please return and complete the form.<br><br>" . "If you want to publish _only_ at Nordita you can upload your paper now.<br>" . "Note, you can correct eventual typos at any time, and you may also cancel the preprint reservation.")); } $t->close("</form>"); }
function core_importantMessagePrinter($txt, $h1, $body) { $w = core_getConfig('errorWidth', 'width=70%'); # $c = 'class=log2'; $t = new table("{$w} cellpaddindg=50 cellspacing=0 {$c}", " <br>"); $t->tr($c, $c, x("{$h1} class=darkgray", $txt, True) . x('i', x('font class=darkgray', ' ' . eregi_replace('<br>', '<br> ', $body)))); $t->close("<br>"); }
function loginPrompt($modeForced = "") { // mode = "login" // "tellpwd" $this->dbg("loginPrompt", "start execution"); $mode = "login"; if ($_POST["remindpassword"]) { unset($_GET["forgotpassword"]); if ($message = $this->remindPassword($_POST["auth_username"])) { $message = $this->errMsg($message); $mode = "tellpwd"; } else { $message = "<font color=green size=-1>The password reminder is sent to you</font>"; } } if ($_GET["forgotpassword"] && !$_SESSION["auth_pwdsent"]) { $mode = "tellpwd"; } if ($_POST["auth_pwd1"] || $_POST["auth_pwd2"]) { if ($message = $this->changePwd($_POST["auth_username"], $_POST["auth_password"], $_POST["auth_pwd1"], $_POST["auth_pwd2"])) { $mode = "cpw"; $message = $this->errMsg($message); } else { return array("cpw", False, False); } } if ($this->titleMessage) { print $this->titleMessage; } $this->dbg("loginPrompt", "mode={$mode} modeForced={$modeForced}"); if ($modeForced) { $this->dbg("loginPrompt", "mode {$mode} -> {$modeForced}"); $mode = $modeForced; } $post = "login"; if ($mode == "login") { if (list($g, $l, $u) = $this->login($_POST["auth_username"], $_POST["auth_password"])) { return $this->whoAmI(); } if ($_POST["auth_username"] && $_POST["auth_password"]) { $message = $this->errMsg("Wrong username or password"); } $pwPrompt = "password"; $suPrompt = "login"; $lnPrompt = "user name"; } elseif ($mode == "tellpwd") { $pwPrompt = ""; $suPrompt = "remind password"; $lnPrompt = "e-mail address"; $post = "remindpassword"; } elseif ($mode == "cpw") { $pwPrompt = "current password"; $suPrompt = "change password"; $lnPrompt = "user name"; } core_importantMessage($this->loginMessage, "font"); echo "<center>\n", "<form name=login action=", core_rebuildURL(array(), array("forgotpassword" => "drop", "quit" => "drop")), "&", htmlspecialchars(SID), " method=post>\n"; $t = new table("class='login'"); $t->tr("", "colspan='3' align='center'", eregi_replace("\n|\r", "<br>", $message)); $this->tr($t, "auth_username", "text", $lnPrompt, "auth_man.png", $value = $_POST["auth_username"]); if ($pwPrompt) { $this->tr($t, "auth_password", "password", $pwPrompt); } if ($mode == "cpw") { $this->tr($t, "auth_pwd1", "password", "new password"); $this->tr($t, "auth_pwd2", "password", "retype new password"); } $t->tro(); $t->td("", "<input name='{$post}' value='{$suPrompt}' type='submit'>"); $t->td(); $t->td("align='right'", $this->showPasswordReminder && $mode == "login" && !$_SESSION["auth_pwdsent"] ? x("a href=" . core_rebuildURL(array("forgotpassword" => "yes")), "forgot your password?") : ""); $t->trc(); $t->close(); echo "</form></center>"; }
$links[PP_PENDING] = $_SERVER["PHP_SELF"] . "?show=" . urlencode(PP_PENDING); } if ($allHash = getAllPreprints()) { if ($dbClass->num_rows($pendingHash) != $dbClass->num_rows($allHash)) { $links[PP_ALL] = $_SERVER["PHP_SELF"] . "?show=" . urlencode(PP_ALL); } } $tabs = new tabs(); $tabs->show($links); $t = new table("cellpadding='5'", "</center>"); if ($authClass->isAdmin() && $tabs->active == PP_ALL) { // provide the "year selection" option for ($i = $nor_pp_year0; $i <= $year; $i++) { $sel[] = x("option" . ($i == $nor_pp_period ? " selected='selected'" : ""), $i); } $t->tr("", "colspan='9'", x("form action='" . $links[$tabs->active] . "' method='post'", x("b", "Managing preprints for the year ") . x("select name='nor_pp_period' onchange='submit()'", join("\n", $sel)))); } $l = nbsp("Action legend:"); $t->tro(); foreach (array(NOR_PP_MODE_ACCEPT, NOR_PP_MODE_EDIT, NOR_PP_MODE_DELETE) as $a) { if ($a == NOR_PP_MODE_ACCEPT && !$authClass->isAdmin()) { continue; } $t->th("", $l); $l = ""; $t->td("", " <img src='img/" . $NOR_modes[$a]["i"] . "' border='0' alt='' valign='botton'>"); $t->td("", nbsp($NOR_modes[$a]["d"])); } $t->trc(); $t->close("<center>"); $t = new table("class='filled' width='100%' cellspacing='0' cellpadding='2'", "<br><div id='preprints' class='pp_list'>");
function add_SQLuser() { global $t, $links, $tabs, $dbClass, $authClass; if (!$_REQUEST["t"]) { $_REQUEST["t"] = "event"; } $accE = $_REQUEST["t"] == "event"; $error = array(); if ($_REQUEST["button"]) { $users = getSQLusers(); if ($v = $_REQUEST["full_name"]) { foreach ($users as $k => $u) { if (strToLower($u["gecos"]) == strToLower($v)) { $error[] = x("li", "'{$v}' is already known as '{$u['email']}'"); } } if ($accE && !eregi("20[0-9][0-9]\$", $v)) { $error[] = x("li", "'event title' must have the year at the end"); } } if ($v = strToLower($_REQUEST["username"])) { foreach ($users as $k => $u) { if (strToLower($u["email"]) == strToLower($v)) { $error[] = x("li", "'{$v}' is already known as '{$u['gecos']}'"); } } if ($accE && !eregi("^[a-z0-9]*\$", $v)) { $error[] = x("li", "'{$v}' is not a valid login name"); } if (!$accE && !eregi("@", $v)) { $error[] = x("li", "'{$v}' is not a valid e-mail address"); } } } if ($error || !$_REQUEST["username"] || !$_REQUEST["full_name"]) { /* * (re)send the form */ $tt = new table("cellpadding='10'", "<center>" . x("h3", "Adding new external user")); $tt->tr("", "valign='top' colspan='3'", x("i", "The external user account is associated either with a <ul>" . "<li> a person (identified by his e-mail and password) or</li>" . "<li> a Nordita event (program, conference, etc.)</li></ul>")); $tt->tro(); $tt->td($accE ? "Both the <b>event title</b> and <b>login name</b><br>must end by the 4-digits Year." . "<br><br><b>contact e-mail</b> is a comma-separated list<br>of the organizer e-mails" : ""); $tt->tdo("valign='top'"); $t = new table("", "<form action='" . $links[$tabs->active] . "' method='post'>"); if ($error) { str(False, "errors detected:" . x("ul", join("\n", $error)), "colspan='3' class='registered'"); } $r = "input type ='radio' name='t' onchange='submit()'"; str("account type", "<{$r} value='human' " . ($accE ? "" : "checked") . ">personal account <{$r} value='event' " . ($accE ? "checked" : "") . ">event account"); str($accE ? "event title" : "full name", "<input type='text' name='full_name' value='{$_REQUEST['full_name']}' size='35'>"); str($accE ? "login name" : "e-mail", "<input type='text' name='username' value='{$_REQUEST['username']}' size='35'>"); if ($accE) { str("proposed password", "<input type='password' name='pwd' value='{$_REQUEST['pwd']}' size='35'>"); } if ($accE) { str("confirm password", "<input type='password' name='pwd2' value='{$_REQUEST['pwd2']}' size='35'>"); } if ($accE) { str("contact e-mail(s)", "<input type='text' name='contact' value='{$_REQUEST['contact']}' size='35'>"); } str(" ", "<input type='submit' name='button' value='submit'> <input type='submit' name='button' value='cancel'>"); $t->close("</form>"); $tt->tdc(); $tt->trc(); $tt->close("</center>"); } else { /* * the form is ok. Create the account, send info mail */ $users = getSQLusers(); $uid = -1000; while ($users[$uid]) { --$uid; } if (!$_REQUEST["pwd"]) { $_REQUEST["pwd"] = $authClass->random_password(8); } $dbClass->query("INSERT INTO accounts (id,username,password,new_password,full_name,status,superviser) " . "VALUES ('{$uid}','{$_REQUEST['username']}','{$_REQUEST['pwd']}','{$_REQUEST['pwd']}','{$_REQUEST['full_name']}',1,'{$_REQUEST['contact']}')"); logIt("newuser", $_REQUEST["username"], $_REQUEST["full_name"]); print x("h3", "New user for the Preprints Database"); $t = new table(); # $t->tr("","",$uid,"uid:"); $t->tr("", "", $_REQUEST["full_name"], "name:"); $t->tr("", "", $_REQUEST["username"], x("b", "login name:")); if ($_REQUEST["contact"]) { $t->tr("", "", $_REQUEST["contact"], x("b", "contact e-mail:")); } else { $t->tr("", "colspan='2'", x("i", "The password is sent to " . $_REQUEST["username"])); } $t->close(); mail2newUser($_REQUEST["username"]); } }
public static function showMailsSent() { if (!empty(self::$sentMails)) { $t = new table("cellpadding='5' cellspacing='0' bgcolor='yellow' " . core_getConfig("errorWidth", "width=70%")); $t->tro(); $t->th("colspan=3", "Important message"); $t->trc(); $many = count(self::$sentMails) > 1; $t->tr("", "colspan=3", "We have sent the following e-mail" . ($many ? "s" : "") . " (see below) with an important information.<br>" . "Please make sure that " . ($many ? "these e-mails are" : "this e-mail is") . " not considered as spam by the mail filter and that<br>" . ($many ? "they reach" : "it reaches") . " the address you indicated.<br>"); $t->tro(); $t->th("", " "); $t->th("", $t->x("i", "To:")); $t->th("", $t->x("i", "Subject:")); $t->trc(); foreach (self::$sentMails as $to => $v) { if (!$v || (int) $to) { continue; } foreach ($v as $k => $subject) { $t->tro(); $t->td(); $t->td("", $to); $t->td("", $subject); $t->trc(); $to = ""; } } $t->close(); } }
} } break; case NOR_PP_MODE_EDIT: nor_pp_require_row_owner($rowId, $AUTH_login); startPage("Edit Preprints" . ($authClass->isAdmin() ? " (Admin)" : "")); $res = $dbClass->query("SELECT * FROM publications WHERE RowId={$rowId}"); $row = mysql_fetch_array($res); $default_field = nl2html($row["Field"]); $t = new table("class='framed'", "<center>" . "<form action='update_preprint.php' enctype='multipart/form-data' method='post'>\n" . "<input type='hidden' name='pp_id' value='" . pp_preprintID($row["Year"], $row["Report"]) . "'>\n" . "<input type='hidden' name='nor_pp_period' value='{$nor_pp_period}'>\n" . "<input type='hidden' name='nor_pp_mode' value='{$nor_pp_mode}'>\n"); getEditDialog(); $t->tro("align='left'"); $t->th("", "entry owner"); $t->td("", make_user_selection($row["Id"])); $t->trc(); $t->tr("", "", "<input name='button' type='submit' value='continue'> " . "<input name='button' type='submit' value='cancel'>", " "); $t->close("</form></center>"); break; case NOR_PP_MODE_REGISTER: nor_pp_require_row_owner($rowId, $AUTH_login); startPage("Preprint registered in database"); $dbClass->query("UPDATE publications SET Status='registered',Tm='" . time() . "' WHERE RowId='{$rowId}'"); $res = $dbClass->query("SELECT * FROM publications WHERE RowId={$rowId}"); $row = mysql_fetch_array($res); mail2secretary("Registered"); echo "<p>Your preprint has been registered, and is waiting for acceptance</p>\n"; echo "<p><a href='show_preprints.php'>Return to preprints</a>.</p>"; show_preprint($rowId, "show_preprints.php"); break; case NOR_PP_MODE_DELETE: nor_pp_require_row_owner($rowId, $AUTH_login);
function showMailsSent() { global $apps_listOfEmails; if ($apps_listOfEmails) { $t = new table("cellpadding='5' cellspacing='0' bgcolor='yellow' " . core_getConfig('errorWidth', 'width=70%')); $t->tro(); $t->th('colspan=3', 'Important message'); $t->trc(); $many = count($apps_listOfEmails) > 1; $t->tr('', 'colspan=3', 'We have sent the following e-mail' . ($many ? 's' : '') . ' (see below) with an important information.<br>' . 'Please make sure that ' . ($many ? 'these e-mails are' : 'this e-mail is') . ' not considered as spam by the mail filter and that<br>' . ($many ? 'they reach' : 'it reaches') . ' the address you indicated.<br>'); $t->tro(); $t->th('', ' '); $t->th('', $t->x('i', "To:")); $t->th('', $t->x('i', "Subject:")); $t->trc(); foreach ($apps_listOfEmails as $to => $v) { if (!$v || (int) $to) { continue; } foreach ($v as $k => $subject) { $t->tro(); $t->td(); $t->td('', $to); $t->td('', $subject); $t->trc(); $to = ''; } } $t->close(); } }
function loginPrompt($modeForced = '') { // mode = 'login' // 'tellpwd' $this->dbg("loginPrompt", "start execution"); $mode = 'login'; if ($_POST["remindpassword"]) { unset($_GET["forgotpassword"]); if ($message = $this->remindPassword($_POST["auth_username"])) { $message = $this->errMsg($message); $mode = 'tellpwd'; } else { $message = "<font color=green size=-1>The password reminder is sent to you</font>"; } } if ($_GET["forgotpassword"] && !$_SESSION["auth_pwdsent"]) { $mode = 'tellpwd'; } if ($_POST["auth_pwd1"] || $_POST["auth_pwd2"]) { if ($message = $this->changePwd($_POST["auth_username"], $_POST["auth_password"], $_POST["auth_pwd1"], $_POST["auth_pwd2"])) { $mode = 'cpw'; $message = $this->errMsg($message); } else { return array('cpw', False, False); } } if ($this->titleMessage) { print $this->titleMessage; } $this->dbg("loginPrompt", "mode={$mode} modeForced={$modeForced}"); if ($modeForced) { $this->dbg("loginPrompt", "mode {$mode} -> {$modeForced}"); $mode = $modeForced; } $post = 'login'; if ($mode == 'login') { if (list($g, $l, $u) = $this->login($_POST["auth_username"], $_POST["auth_password"])) { return $this->whoAmI(); } if ($_POST["auth_username"] && $_POST["auth_password"]) { $message = $this->errMsg("Wrong username or password"); } $pwPrompt = 'password'; $suPrompt = 'login'; $lnPrompt = 'user name'; } elseif ($mode == 'tellpwd') { $pwPrompt = ''; $suPrompt = 'remind password'; $lnPrompt = 'e-mail address'; $post = 'remindpassword'; } elseif ($mode == 'cpw') { $pwPrompt = 'current password'; $suPrompt = 'change password'; $lnPrompt = 'user name'; } core_importantMessage($this->loginMessage, 'font'); echo "<center>\n", "<form name=login action=", core_rebuildURL(array(), array('forgotpassword' => 'drop', 'quit' => 'drop')), '&', htmlspecialchars(SID), " method=post>\n"; $t = new table('class=login'); $t->tr('', 'colspan=3 align=center', eregi_replace("\n|\r", "<br>", $message)); $this->tr($t, 'auth_username', 'text', $lnPrompt, 'auth_man.png', $value = $_POST["auth_username"]); if ($pwPrompt) { $this->tr($t, 'auth_password', 'password', $pwPrompt); } if ($mode == 'cpw') { $this->tr($t, 'auth_pwd1', 'password', 'new password'); $this->tr($t, 'auth_pwd2', 'password', 'retype new password'); } $t->tro(); $t->td('', "<input name='{$post}' value='{$suPrompt}' type='submit'>"); $t->td(); $t->td('align=right', $this->showPasswordReminder && $mode == 'login' && !$_SESSION["auth_pwdsent"] ? x("a href=" . core_rebuildURL(array('forgotpassword' => 'yes')), "forgot your password?") : ""); $t->trc(); $t->close(); echo "</form></center>"; }