Mercurial > hg > fapweb
changeset 806:59528ba5813a
Move stuff around.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 24 Nov 2014 11:36:50 +0200 |
parents | 546058da8f07 |
children | 0bb4b1973e08 |
files | msite.inc.php |
diffstat | 1 files changed, 90 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- a/msite.inc.php Mon Nov 24 09:33:45 2014 +0200 +++ b/msite.inc.php Mon Nov 24 11:36:50 2014 +0200 @@ -198,6 +198,9 @@ } +// +// Like stExecSQL(), but throws error messages to "userspace". +// function stExecSQLCond($sql, $msg = FALSE) { global $db; @@ -268,6 +271,93 @@ } +function stGetTDFormTextInput($edit, $size, $len, $name, $id, $prefix, $value, $extra = "") +{ + return + "<td class=\"".$name."\">". + ($edit ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)). + "</td>"; +} + + +function stGetEditFormTextInput($mode, $title, $size, $len, $name, $id, $prefix, $value, $extra = "") +{ + return + "<div class=\"editControl\"><span class=\"editControlTitle\">".chentities($title)."</span>". + ($mode ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)). + "</div>"; +} + + +function stGetEditFormTextArea($mode, $title, $rows, $cols, $name, $id, $prefix, $value, $extra = "") +{ + return + "<div class=\"editControl\"><span class=\"editControlTitle\">".chentities($title)."</span>". + stGetFormTextArea($rows, $cols, $name, $id, $prefix, $value, ($mode ? "" : " disabled=\"disabled\" ").$extra). + "</div>"; +} + + +function stConvSwitchMode(&$str, &$mode, $newMode) +{ + if ($newMode != $mode) + { + if ($mode != "") + $str .= "\n</".$mode.">\n"; + + $mode = $newMode; + + if ($mode != "") + $str .= "<".$mode.">\n"; + } +} + + +function stConvertCommonDesc($desc, $chent) +{ + $str = ""; + $mode = ""; + + foreach (explode("\n", $desc) as $line) + { + if (preg_match("/^\s*\s*\*(.+)$/", $line, $m)) + { + stConvSwitchMode($str, $mode, "ol"); + $str .= "<li>".($chent ? chentities($m[1]) : $m[1])."</li>\n"; + } + else + if (preg_match("/^\s*-\s*(.+)$/", $line, $m)) + { + stConvSwitchMode($str, $mode, "ul"); + $str .= "<li>".($chent ? chentities($m[1]) : $m[1])."</li>\n"; + } + else + { + stConvSwitchMode($str, $mode, "p"); + $str .= ($chent ? chentities($line) : $line); + } + } + + stConvSwitchMode($str, $mode, ""); + + return $str; +} + + +function stGetNumberSuffix($val) +{ + switch ($val) + { + case 1: return "st"; + case 2: return "nd"; + case 3: return "rd"; + case 4: case 5: case 6: + case 7: case 8: case 9: return "th"; + default: return "th"; + } +} + + function stGenerateUserKey() { global $db; @@ -377,93 +467,6 @@ } -function stGetTDFormTextInput($edit, $size, $len, $name, $id, $prefix, $value, $extra = "") -{ - return - "<td class=\"".$name."\">". - ($edit ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)). - "</td>"; -} - - -function stGetEditFormTextInput($mode, $title, $size, $len, $name, $id, $prefix, $value, $extra = "") -{ - return - "<div class=\"editControl\"><span class=\"editControlTitle\">".chentities($title)."</span>". - ($mode ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)). - "</div>"; -} - - -function stGetEditFormTextArea($mode, $title, $rows, $cols, $name, $id, $prefix, $value, $extra = "") -{ - return - "<div class=\"editControl\"><span class=\"editControlTitle\">".chentities($title)."</span>". - stGetFormTextArea($rows, $cols, $name, $id, $prefix, $value, ($mode ? "" : " disabled=\"disabled\" ").$extra). - "</div>"; -} - - -function stConvSwitchMode(&$str, &$mode, $newMode) -{ - if ($newMode != $mode) - { - if ($mode != "") - $str .= "\n</".$mode.">\n"; - - $mode = $newMode; - - if ($mode != "") - $str .= "<".$mode.">\n"; - } -} - - -function stConvertCommonDesc($desc, $chent) -{ - $str = ""; - $mode = ""; - - foreach (explode("\n", $desc) as $line) - { - if (preg_match("/^\s*\s*\*(.+)$/", $line, $m)) - { - stConvSwitchMode($str, $mode, "ol"); - $str .= "<li>".($chent ? chentities($m[1]) : $m[1])."</li>\n"; - } - else - if (preg_match("/^\s*-\s*(.+)$/", $line, $m)) - { - stConvSwitchMode($str, $mode, "ul"); - $str .= "<li>".($chent ? chentities($m[1]) : $m[1])."</li>\n"; - } - else - { - stConvSwitchMode($str, $mode, "p"); - $str .= ($chent ? chentities($line) : $line); - } - } - - stConvSwitchMode($str, $mode, ""); - - return $str; -} - - -function stGetNumberSuffix($val) -{ - switch ($val) - { - case 1: return "st"; - case 2: return "nd"; - case 3: return "rd"; - case 4: case 5: case 6: - case 7: case 8: case 9: return "th"; - default: return "th"; - } -} - - function stGetCompoResultsSQL($mode, $compo, $flags) { //