# HG changeset patch # User Matti Hamalainen # Date 1416821810 -7200 # Node ID 59528ba5813aae0378409960a1a74e8f833e9473 # Parent 546058da8f07f2bed7f1059dbaa425dd6668dcd3 Move stuff around. diff -r 546058da8f07 -r 59528ba5813a msite.inc.php --- 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 + "". + ($edit ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)). + ""; +} + + +function stGetEditFormTextInput($mode, $title, $size, $len, $name, $id, $prefix, $value, $extra = "") +{ + return + "
".chentities($title)."". + ($mode ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)). + "
"; +} + + +function stGetEditFormTextArea($mode, $title, $rows, $cols, $name, $id, $prefix, $value, $extra = "") +{ + return + "
".chentities($title)."". + stGetFormTextArea($rows, $cols, $name, $id, $prefix, $value, ($mode ? "" : " disabled=\"disabled\" ").$extra). + "
"; +} + + +function stConvSwitchMode(&$str, &$mode, $newMode) +{ + if ($newMode != $mode) + { + if ($mode != "") + $str .= "\n\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 .= "
  • ".($chent ? chentities($m[1]) : $m[1])."
  • \n"; + } + else + if (preg_match("/^\s*-\s*(.+)$/", $line, $m)) + { + stConvSwitchMode($str, $mode, "ul"); + $str .= "
  • ".($chent ? chentities($m[1]) : $m[1])."
  • \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 - "". - ($edit ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)). - ""; -} - - -function stGetEditFormTextInput($mode, $title, $size, $len, $name, $id, $prefix, $value, $extra = "") -{ - return - "
    ".chentities($title)."". - ($mode ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)). - "
    "; -} - - -function stGetEditFormTextArea($mode, $title, $rows, $cols, $name, $id, $prefix, $value, $extra = "") -{ - return - "
    ".chentities($title)."". - stGetFormTextArea($rows, $cols, $name, $id, $prefix, $value, ($mode ? "" : " disabled=\"disabled\" ").$extra). - "
    "; -} - - -function stConvSwitchMode(&$str, &$mode, $newMode) -{ - if ($newMode != $mode) - { - if ($mode != "") - $str .= "\n\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 .= "
  • ".($chent ? chentities($m[1]) : $m[1])."
  • \n"; - } - else - if (preg_match("/^\s*-\s*(.+)$/", $line, $m)) - { - stConvSwitchMode($str, $mode, "ul"); - $str .= "
  • ".($chent ? chentities($m[1]) : $m[1])."
  • \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) { //